@lacneu/atrium 0.104.4 → 0.105.2

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 (143) hide show
  1. package/dist/assets/AccessTab-BEJ_Jyn5.js +1 -0
  2. package/dist/assets/{AdminSettings-C2bsOn0u.js → AdminSettings-5meEb9W8.js} +1 -1
  3. package/dist/assets/{AdvancedFilter-DYTsdqhC.js → AdvancedFilter-xN0--ljK.js} +1 -1
  4. package/dist/assets/AgentFilesTab-Can04JU-.js +3 -0
  5. package/dist/assets/AnomaliesTab-4RaS1dK-.js +1 -0
  6. package/dist/assets/AuditTab-Sl2mKF7H.js +1 -0
  7. package/dist/assets/BridgeTab-CuyyGEDU.js +1 -0
  8. package/dist/assets/ChatDefaultsTab-BUW8zL7h.js +1 -0
  9. package/dist/assets/{ConfirmDialog-Bfi4_Ti8.js → ConfirmDialog-2GlWReLp.js} +1 -1
  10. package/dist/assets/{DataTableShell-1ZsZ0a2J.js → DataTableShell-DbR2ZB8f.js} +1 -1
  11. package/dist/assets/DeletedChatsTab-CJeOOn67.js +1 -0
  12. package/dist/assets/{DetailChips-DkRU5HQ5.js → DetailChips-3dcLcTwx.js} +1 -1
  13. package/dist/assets/{EntitySheet-D8Vdib4B.js → EntitySheet-C6w3z1QT.js} +1 -1
  14. package/dist/assets/FeedbacksTab-Xzcf0-m6.js +1 -0
  15. package/dist/assets/{FieldLabel-Ce8urE01.js → FieldLabel-C4REF2c9.js} +1 -1
  16. package/dist/assets/FilesTab-CAQXH5ub.js +1 -0
  17. package/dist/assets/{FilterBar-DtNuk6dI.js → FilterBar-DB4FJ8Dg.js} +1 -1
  18. package/dist/assets/GroupsTab-Bza-axVm.js +1 -0
  19. package/dist/assets/InstancesTab-ylJayyDG.js +1 -0
  20. package/dist/assets/IntegrationsTab-SlsD4tnS.js +1 -0
  21. package/dist/assets/KnobRow-C5AnEUHi.js +1 -0
  22. package/dist/assets/KpiTab-66ywB2qQ.js +1 -0
  23. package/dist/assets/PreferencesTab-DVGrydjd.js +1 -0
  24. package/dist/assets/ProjectPage-m5wYC2Rt.js +1 -0
  25. package/dist/assets/PromptInjectionsTab-Dj53oYJM.js +4 -0
  26. package/dist/assets/RolesTab-DWAYA0bo.js +1 -0
  27. package/dist/assets/ScheduledTab-CgXOwbXe.js +1 -0
  28. package/dist/assets/ServiceAccountsTab-DDHjiTam.js +1 -0
  29. package/dist/assets/SubAgentReportsTab-CkY5rTJw.js +1 -0
  30. package/dist/assets/ThemeShowroom-CP-Ano4O.js +1 -0
  31. package/dist/assets/{TimeRangePicker-jsNw51TL.js → TimeRangePicker-BWc2zMyq.js} +1 -1
  32. package/dist/assets/{TimezoneCombobox-zOqV7dxe.js → TimezoneCombobox-BFCCUJtt.js} +1 -1
  33. package/dist/assets/TracesTab--6clA1rh.js +1 -0
  34. package/dist/assets/TrashTab-DLVzwkoC.js +1 -0
  35. package/dist/assets/UsersTab-CZ7JvSwK.js +1 -0
  36. package/dist/assets/VoiceTab-jKwAy1TX.js +1 -0
  37. package/dist/assets/{alert-dialog-C6NSAwQv.js → alert-dialog-DC8Z8Wmm.js} +1 -1
  38. package/dist/assets/api-V6x-16tY.js +44 -0
  39. package/dist/assets/{badge-DwWXPxwl.js → badge-X282ki8x.js} +1 -1
  40. package/dist/assets/{button-DeHzYOzP.js → button-Dk2mXV1u.js} +1 -1
  41. package/dist/assets/{card-WAOfM0PL.js → card-BOTLCW-9.js} +1 -1
  42. package/dist/assets/check-BgudyeCZ.js +1 -0
  43. package/dist/assets/{checkbox-BuTZzFvU.js → checkbox-D6bftQAn.js} +1 -1
  44. package/dist/assets/chevron-left-C0Y3isEh.js +1 -0
  45. package/dist/assets/chevron-right-Bh8XLdLx.js +1 -0
  46. package/dist/assets/chevron-up-DvUmXiwf.js +1 -0
  47. package/dist/assets/chevrons-up-down-PaGXQ-HZ.js +1 -0
  48. package/dist/assets/compatView-B790jH8G.js +1 -0
  49. package/dist/assets/convexApi-BPs2Hfq9.js +1 -0
  50. package/dist/assets/{copy-4wREwP-V.js → copy-rAnqIOxQ.js} +1 -1
  51. package/dist/assets/{cronDescribe-B-ifUeLg.js → cronDescribe-_S84hFUo.js} +1 -1
  52. package/dist/assets/{deliveryRecorder-owdOglrQ.js → deliveryRecorder-C4wafMM5.js} +1 -1
  53. package/dist/assets/{dialog-awuZdW9M.js → dialog-BNsKJRIY.js} +1 -1
  54. package/dist/assets/dispatchErrorInfo-3a3ZRCxk.js +1 -0
  55. package/dist/assets/{dist-BtzRSR0_.js → dist-BH0QTybL.js} +1 -1
  56. package/dist/assets/{dist-D4a9D7kU.js → dist-BIRd8lcZ.js} +1 -1
  57. package/dist/assets/{dist-B4zBnzNF.js → dist-BR-NmSzA.js} +1 -1
  58. package/dist/assets/{dist-mViq22LZ.js → dist-BcFkCuIu.js} +1 -1
  59. package/dist/assets/{dist-C0V3m4aH.js → dist-Dn0V4znq.js} +1 -1
  60. package/dist/assets/{download-BUlwPQI8.js → download-D9QjuqE8.js} +1 -1
  61. package/dist/assets/{dropdown-menu-C5VrCGFe.js → dropdown-menu-CvM7DyUW.js} +1 -1
  62. package/dist/assets/{eye-BU60QIdS.js → eye-uNqwwZRR.js} +1 -1
  63. package/dist/assets/{format-g5Z3Txjl.js → format-BrALULQ2.js} +1 -1
  64. package/dist/assets/{groupManageView-CKEYC6zY.js → groupManageView-CDgw3aW6.js} +1 -1
  65. package/dist/assets/index-CIz3ifJj.css +1 -0
  66. package/dist/assets/index-DtQP3Nqp.js +158 -0
  67. package/dist/assets/{input-CZ0jp9Rx.js → input-BxgrPOQB.js} +1 -1
  68. package/dist/assets/{list-Bb0MIh_I.js → list-Dh8ZiyiT.js} +1 -1
  69. package/dist/assets/loader-circle-BotUEUd9.js +1 -0
  70. package/dist/assets/{lock-xfEfLa2G.js → lock-EGsKhQj8.js} +1 -1
  71. package/dist/assets/{pencil-CHRZ3__S.js → pencil-DNZlqJcO.js} +1 -1
  72. package/dist/assets/plus-D_fN9BU6.js +1 -0
  73. package/dist/assets/{popover-UJtu3EZ6.js → popover-BwLP1xvY.js} +1 -1
  74. package/dist/assets/roleDescriptions-3xKxmmOg.js +1 -0
  75. package/dist/assets/rotate-ccw-Cyt4JAE8.js +1 -0
  76. package/dist/assets/{search-NOJ0tWl2.js → search-Bwyf2eDv.js} +1 -1
  77. package/dist/assets/{select-wXM6h61N.js → select-BTp5btAs.js} +1 -1
  78. package/dist/assets/{server-C5TTb6-A.js → server-DLcIoj6y.js} +1 -1
  79. package/dist/assets/{speech-BPCrvnrE.js → speech-CsTQ-A5Z.js} +1 -1
  80. package/dist/assets/{star-N2N0cbAA.js → star-C8s9YR-B.js} +1 -1
  81. package/dist/assets/{switch-Beq0wUQ_.js → switch-CGlTuNUT.js} +1 -1
  82. package/dist/assets/{table-CegX53gV.js → table-CbcTxWSv.js} +1 -1
  83. package/dist/assets/{tabs-CfQK0-wk.js → tabs-CgaqwjVr.js} +1 -1
  84. package/dist/assets/toast-n2l0FW-G.js +1 -0
  85. package/dist/assets/{tooltip-Dpar43UD.js → tooltip-CRMDA8JT.js} +1 -1
  86. package/dist/assets/{trash-2-CqKGt3lC.js → trash-2-DMkzussw.js} +1 -1
  87. package/dist/assets/trashPage-CaQsoE3L.js +1 -0
  88. package/dist/assets/trashView-nGIDBl8U.js +1 -0
  89. package/dist/assets/{triangle-alert-nUld87-H.js → triangle-alert-CcKY6Wsw.js} +1 -1
  90. package/dist/assets/{usageView-DIPUGYx9.js → usageView-ht_gv_iV.js} +1 -1
  91. package/dist/assets/{useChart-BTVKxdLu.js → useChart-6Fi69FKB.js} +1 -1
  92. package/dist/assets/{useFontScale-P_rNok04.js → useFontScale-CPt1xprW.js} +1 -1
  93. package/dist/assets/{useStartNewChat-GAbwTTkG.js → useStartNewChat-rxpg0noT.js} +2 -2
  94. package/dist/assets/{use_paginated_query-C-Aw4n8b.js → use_paginated_query-SUExS5Ri.js} +1 -1
  95. package/dist/assets/{users-BUu1wJNm.js → users-BYrKGPt9.js} +1 -1
  96. package/dist/assets/x-C7RkX_i_.js +1 -0
  97. package/dist/index.html +54 -54
  98. package/package.json +1 -1
  99. package/dist/assets/AccessTab-B2bpNynj.js +0 -1
  100. package/dist/assets/AgentFilesTab-BM2NUWub.js +0 -3
  101. package/dist/assets/AnomaliesTab-BWiKxnXQ.js +0 -1
  102. package/dist/assets/AuditTab-CqpDXgVz.js +0 -1
  103. package/dist/assets/BridgeTab-Cv2Co6h7.js +0 -1
  104. package/dist/assets/ChatDefaultsTab-Dr-czhQm.js +0 -1
  105. package/dist/assets/DeletedChatsTab-By_xLvEC.js +0 -1
  106. package/dist/assets/FeedbacksTab-YFBk45oU.js +0 -1
  107. package/dist/assets/FilesTab-DL27Krkt.js +0 -1
  108. package/dist/assets/GroupsTab-CQrEUZSF.js +0 -1
  109. package/dist/assets/InstancesTab-DiW-4KlM.js +0 -1
  110. package/dist/assets/IntegrationsTab-DqWlrC3M.js +0 -1
  111. package/dist/assets/KnobRow-4WODwFrS.js +0 -1
  112. package/dist/assets/KpiTab-BXC9YG9_.js +0 -1
  113. package/dist/assets/PreferencesTab-DarNzYdF.js +0 -1
  114. package/dist/assets/ProjectPage-BbYuFPDW.js +0 -1
  115. package/dist/assets/PromptInjectionsTab-KMsWE-dW.js +0 -4
  116. package/dist/assets/RolesTab-DpN3MOih.js +0 -1
  117. package/dist/assets/ScheduledTab-BBofaJj5.js +0 -1
  118. package/dist/assets/ServiceAccountsTab-CSIwvppo.js +0 -1
  119. package/dist/assets/SubAgentReportsTab-BoNbdt38.js +0 -1
  120. package/dist/assets/ThemeShowroom-DdUZV2nA.js +0 -1
  121. package/dist/assets/TracesTab-Dg_eyLYF.js +0 -1
  122. package/dist/assets/TrashTab-Dwjjxu8X.js +0 -1
  123. package/dist/assets/UsersTab-eQY9UCh5.js +0 -1
  124. package/dist/assets/VoiceTab-BFVfbSld.js +0 -1
  125. package/dist/assets/api-D64JTta1.js +0 -44
  126. package/dist/assets/check-pVsND9oZ.js +0 -1
  127. package/dist/assets/chevron-left-CjQ1kn0w.js +0 -1
  128. package/dist/assets/chevron-right-DkaFdk2G.js +0 -1
  129. package/dist/assets/chevron-up-s_deZUWR.js +0 -1
  130. package/dist/assets/chevrons-up-down-uk0IvxY8.js +0 -1
  131. package/dist/assets/compatView-Db657dNx.js +0 -1
  132. package/dist/assets/convexApi-DxRiI80M.js +0 -1
  133. package/dist/assets/dispatchErrorInfo-C4Qh_2oR.js +0 -1
  134. package/dist/assets/index-DLjKxzJ_.css +0 -1
  135. package/dist/assets/index-MNxzNMLb.js +0 -158
  136. package/dist/assets/loader-circle-1XN8tjq6.js +0 -1
  137. package/dist/assets/plus-DrzxZ4iS.js +0 -1
  138. package/dist/assets/roleDescriptions-BW3e0J2_.js +0 -1
  139. package/dist/assets/rotate-ccw-CiOuaG2h.js +0 -1
  140. package/dist/assets/toast-DtA87VYn.js +0 -1
  141. package/dist/assets/trashPage-D9B1uAuS.js +0 -1
  142. package/dist/assets/trashView-TIQT30u4.js +0 -1
  143. package/dist/assets/x-BNU-sWkh.js +0 -1
@@ -0,0 +1,158 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pdf-EQHMWEbX.js","assets/preload-helper-Czpn1I53.js","assets/RolesTab-DWAYA0bo.js","assets/bundle-mjs-C73ZY4La.js","assets/api-V6x-16tY.js","assets/lock-EGsKhQj8.js","assets/checkbox-D6bftQAn.js","assets/check-BgudyeCZ.js","assets/dist-DDCmobc1.js","assets/dist-BcFkCuIu.js","assets/button-Dk2mXV1u.js","assets/input-BxgrPOQB.js","assets/convexApi-BPs2Hfq9.js","assets/toast-n2l0FW-G.js","assets/x-C7RkX_i_.js","assets/badge-X282ki8x.js","assets/ConfirmDialog-2GlWReLp.js","assets/alert-dialog-DC8Z8Wmm.js","assets/dist-BIRd8lcZ.js","assets/dialog-BNsKJRIY.js","assets/EntitySheet-C6w3z1QT.js","assets/loader-circle-BotUEUd9.js","assets/roleDescriptions-3xKxmmOg.js","assets/InstancesTab-ylJayyDG.js","assets/FieldLabel-C4REF2c9.js","assets/tooltip-CRMDA8JT.js","assets/select-BTp5btAs.js","assets/dist-Dn0V4znq.js","assets/chevron-up-DvUmXiwf.js","assets/dist-BH0QTybL.js","assets/popover-BwLP1xvY.js","assets/locales-CPjguROj.js","assets/curation-CQksaIbm.js","assets/groupManageView-CDgw3aW6.js","assets/DataTableShell-DbR2ZB8f.js","assets/chevrons-up-down-PaGXQ-HZ.js","assets/dropdown-menu-CvM7DyUW.js","assets/dist-BR-NmSzA.js","assets/plus-D_fN9BU6.js","assets/trash-2-DMkzussw.js","assets/table-CbcTxWSv.js","assets/useTableLayout-Cmwnuzxb.js","assets/measureClone-CHN0WNEY.js","assets/BridgeTab-CuyyGEDU.js","assets/useNavigate-D3GIoxyW.js","assets/chevron-right-Bh8XLdLx.js","assets/usageView-ht_gv_iV.js","assets/server-DLcIoj6y.js","assets/triangle-alert-CcKY6Wsw.js","assets/tabs-CgaqwjVr.js","assets/format-BrALULQ2.js","assets/appHost-CH3EGcJw.js","assets/FilterBar-DB4FJ8Dg.js","assets/search-Bwyf2eDv.js","assets/rotate-ccw-Cyt4JAE8.js","assets/TimeRangePicker-BWc2zMyq.js","assets/compatView-B790jH8G.js","assets/dispatchErrorInfo-3a3ZRCxk.js","assets/PromptInjectionsTab-Dj53oYJM.js","assets/localePickerView-C2RmOS86.js","assets/confTabs-BpNy5aSd.css","assets/GroupsTab-Bza-axVm.js","assets/chevron-left-C0Y3isEh.js","assets/users-BYrKGPt9.js","assets/star-C8s9YR-B.js","assets/DetailChips-3dcLcTwx.js","assets/IntegrationsTab-SlsD4tnS.js","assets/FeedbacksTab-Xzcf0-m6.js","assets/SubAgentReportsTab-CkY5rTJw.js","assets/TrashTab-DLVzwkoC.js","assets/use_paginated_query-SUExS5Ri.js","assets/fileMetaView-Ci5C4w9Q.js","assets/trashView-nGIDBl8U.js","assets/trashPage-CaQsoE3L.js","assets/trashPage-B7NvDkP2.css","assets/DeletedChatsTab-CJeOOn67.js","assets/FilesTab-CAQXH5ub.js","assets/download-D9QjuqE8.js","assets/ScheduledTab-CgXOwbXe.js","assets/list-Dh8ZiyiT.js","assets/cronDescribe-_S84hFUo.js","assets/pencil-DNZlqJcO.js","assets/TimezoneCombobox-BFCCUJtt.js","assets/AgentFilesTab-Can04JU-.js","assets/capabilities-CASxhKEd.js","assets/PreferencesTab-DVGrydjd.js","assets/useFontScale-CPt1xprW.js","assets/switch-CGlTuNUT.js","assets/ChatDefaultsTab-BUW8zL7h.js","assets/KnobRow-C5AnEUHi.js","assets/AccessTab-BEJ_Jyn5.js","assets/ThemeShowroom-CP-Ano4O.js","assets/useChart-6Fi69FKB.js","assets/card-BOTLCW-9.js","assets/AdvancedFilter-xN0--ljK.js","assets/ProjectPage-m5wYC2Rt.js","assets/useStartNewChat-rxpg0noT.js","assets/useStartNewChat-DgQf_3y0.css","assets/eye-uNqwwZRR.js","assets/ProjectPage-D3DrzSxV.css","assets/TracesTab--6clA1rh.js","assets/copy-rAnqIOxQ.js","assets/deliveryRecorder-C4wafMM5.js","assets/searchSchemas-Dm-Qg010.js","assets/VoiceTab-jKwAy1TX.js","assets/speech-CsTQ-A5Z.js","assets/AuditTab-Sl2mKF7H.js","assets/AnomaliesTab-4RaS1dK-.js","assets/KpiTab-66ywB2qQ.js","assets/ServiceAccountsTab-DDHjiTam.js","assets/UsersTab-CZ7JvSwK.js","assets/AdminSettings-5meEb9W8.js"])))=>i.map(i=>d[i]);
2
+ import{a as e,c as t,i as n,l as r,o as i,r as a,s as o}from"./bundle-mjs-C73ZY4La.js";import{$C as s,$E as c,$H as l,$J as u,$M as d,$N as f,$T as p,$U as m,$V as h,$W as g,$_ as _,$a as v,$c as y,$i as b,$k as x,$m as S,$n as C,$o as w,$r as T,$s as E,$t as D,$y as O,AB as k,AD as A,AE as j,AH as M,AM as N,AQ as P,AT as F,AU as I,AW as L,AX as R,AY as z,A_ as B,Aa as V,Ab as ee,Af as te,Ah as ne,Ai as re,Ak as ie,Am as ae,Ao as oe,Ap as se,At as ce,Au as le,Av as ue,BB as de,BC as fe,BD as pe,BE as me,BH as he,BM as ge,BO as _e,BQ as ve,BU as ye,BV as be,BW as xe,BX as Se,B_ as Ce,Ba as we,Bb as Te,Bc as Ee,Bd as De,Bf as Oe,Bg as ke,Bi as Ae,Bk as je,Bm as Me,Bo as Ne,Br as Pe,Bs as Fe,Bu as Ie,CB as Le,CD as Re,CE as ze,CH as Be,CQ as Ve,CT as He,CU as Ue,CW as We,CX as Ge,C_ as Ke,Ca as qe,Cc as Je,Cf as Ye,Ch as Xe,Ci as Ze,Cm as Qe,Co as $e,Cp as et,Cr as tt,Ct as nt,Cu as rt,Cv as it,DB as at,DD as ot,DE as st,DH as ct,DM as lt,DQ as ut,DT as dt,DU as ft,DW as pt,DX as mt,D_ as ht,Da as gt,Dc as _t,Df as vt,Dh as yt,Di as bt,Dk as xt,Dl as St,Dm as Ct,Do as wt,Dp as Tt,Dt as Et,Du as Dt,Dv as Ot,EB as kt,ED as At,EE as jt,EH as Mt,EM as Nt,EQ as Pt,ET as Ft,EU as It,EW as Lt,EX as Rt,E_ as zt,Ea as Bt,Ec as Vt,Ef as Ht,Eh as Ut,Ei as Wt,Ek as Gt,Em as Kt,Eo as qt,Ep as Jt,Et as Yt,Eu as Xt,Ev as Zt,FB as Qt,FC as $t,FE as en,FH as tn,FM as nn,FO as rn,FQ as H,FT as an,FU as on,FV as sn,FW as cn,FX as ln,F_ as un,Fa as dn,Fb as fn,Fc as pn,Fd as mn,Ff as hn,Fg as gn,Fi as _n,Fk as vn,Fm as yn,Fo as bn,Fp as xn,Fr as Sn,Ft as Cn,Fu as wn,Fv as Tn,GC as En,GD as Dn,GE as On,GH as kn,GM as An,GN as jn,GQ as Mn,GU as Nn,GV as Pn,GW as Fn,GX as In,G_ as Ln,Ga as Rn,Gc as zn,Gd as Bn,Gg as Vn,Gi as Hn,Gk as Un,Gm as Wn,Gn,Go as Kn,Gr as qn,Gs as Jn,Gt as Yn,Gu as Xn,HC as Zn,HD as Qn,HE as $n,HH as er,HM as tr,HN as nr,HQ as rr,HU as ir,HV as ar,HW as or,HX as sr,H_ as cr,Ha as lr,Hc as ur,Hd as dr,Hf as fr,Hg as pr,Hi as mr,Hk as hr,Hm as gr,Ho as _r,Hr as vr,Hs as yr,Hu as br,IB as xr,IC as Sr,ID as Cr,IE as wr,IH as Tr,IM as Er,IO as Dr,IQ as Or,IT as kr,IU as Ar,IV as jr,IW as Mr,IX as Nr,I_ as Pr,Ia as Fr,Ib as Ir,Ic as Lr,Id as Rr,If as zr,Ig as Br,Ii as Vr,Ik as Hr,Im as Ur,Io as Wr,Ip as Gr,Ir as Kr,Is as qr,Iu as Jr,Iv as Yr,JC as Xr,JD as Zr,JE as Qr,JH as $r,JM as ei,JN as ti,JO as ni,JT as ri,JU as ii,JV as ai,JW as oi,JX as si,J_ as ci,Ja as li,Jc as ui,Jd as di,Jg as fi,Ji as pi,Jk as mi,Jl as hi,Jm as gi,Jn as _i,Jo as vi,Jr as yi,Js as bi,Jt as xi,Jy as Si,KC as Ci,KD as wi,KE as Ti,KH as Ei,KI as Di,KM as Oi,KN as ki,KO as Ai,KU as ji,KV as Mi,KW as Ni,KX as Pi,K_ as Fi,Ka as Ii,Kc as Li,Kd as Ri,Kg as zi,Ki as Bi,Kk as Vi,Kl as Hi,Km as Ui,Kn as Wi,Ko as Gi,Kr as Ki,Kt as qi,Ky as Ji,LB as Yi,LC as Xi,LD as Zi,LE as Qi,LH as $i,LM as ea,LO as ta,LQ as na,LT as ra,LU as ia,LV as aa,LW as oa,LX as sa,L_ as ca,La as la,Lb as ua,Lc as da,Ld as fa,Lf as pa,Lg as ma,Li as ha,Lk as ga,Lm as _a,Lo as va,Lp as ya,Lr as ba,Ls as xa,Lu as Sa,Lv as Ca,MB as wa,MD as Ta,ME as Ea,MH as Da,MM as Oa,MO as ka,MQ as Aa,MT as ja,MU as Ma,MV as Na,MW as Pa,MX as Fa,M_ as Ia,Ma as La,Mf as Ra,Mh as za,Mi as Ba,Mk as Va,Mm as Ha,Mo as Ua,Mp as Wa,Mt as Ga,Mu as Ka,Mv as qa,NB as Ja,NC as Ya,NE as Xa,NH as Za,NM as Qa,NO as $a,NQ as eo,NT as to,NU as no,NV as ro,NW as io,NX as ao,N_ as oo,Na as so,Nb as co,Nc as lo,Nf as uo,Ng as fo,Nh as po,Ni as mo,Nk as ho,Nm as go,No as _o,Np as vo,Nt as yo,Nu as bo,Nv as xo,O as So,OB as Co,OD as wo,OE as To,OH as Eo,OM as Do,OQ as Oo,OT as ko,OU as Ao,OW as jo,OX as Mo,O_ as No,Oa as Po,Ob as Fo,Oc as Io,Of as Lo,Oh as Ro,Oi as zo,Ok as Bo,Ol as Vo,Om as Ho,Oo as Uo,Op as Wo,Ot as Go,Ou as Ko,Ov as qo,PB as Jo,PC as Yo,PE as Xo,PH as Zo,PM as Qo,PO as $o,PQ as U,PT as es,PU as ts,PV as ns,PW as rs,PX as is,P_ as as,Pa as os,Pb as ss,Pc as cs,Pf as ls,Pg as us,Ph as ds,Pi as fs,Pk as ps,Pm as ms,Po as hs,Pp as gs,Pr as _s,Pt as vs,Pu as ys,Pv as bs,QC as xs,QE as Ss,QH as Cs,QM as ws,QN as Ts,QT as Es,QU as Ds,QV as Os,QW as ks,Q_ as As,Qa as js,Qc as Ms,Qi as Ns,Qk as Ps,Ql as Fs,Qm as Is,Qn as Ls,Qr as Rs,Qs as zs,Qt as Bs,Qy as Vs,RB as Hs,RC as Us,RD as Ws,RE as Gs,RH as Ks,RM as qs,RO as Js,RQ as Ys,RT as Xs,RU as Zs,RV as Qs,RW as $s,RX as ec,R_ as tc,Ra as nc,Rb as rc,Rc as ic,Rd as ac,Rf as oc,Rg as sc,Ri as cc,Rk as lc,Rm as uc,Ro as dc,Rp as fc,Rr as pc,Rs as mc,Ru as hc,S as gc,SB as _c,SD as vc,SE as yc,SH as bc,SQ as xc,ST as Sc,SU as Cc,SW as wc,SX as Tc,S_ as Ec,Sa as Dc,Sb as Oc,Sc as kc,Sf as Ac,Sh as jc,Si as Mc,Sm as Nc,So as Pc,Sp as Fc,Sr as Ic,St as Lc,Su as Rc,Sv as zc,TB as Bc,TD as Vc,TE as Hc,TH as Uc,TM as Wc,TQ as Gc,TT as Kc,TU as qc,TW as Jc,TX as Yc,T_ as Xc,Ta as Zc,Tc as Qc,Td as $c,Tf as el,Th as tl,Ti as nl,Tk as rl,Tm as il,To as al,Tp as ol,Tt as sl,Tu as cl,Tv as ll,UC as ul,UD as dl,UE as fl,UH as pl,UM as ml,UN as hl,UQ as gl,UU as _l,UV as vl,UW as yl,UX as bl,U_ as xl,Ua as Sl,Uc as Cl,Ud as wl,Uf as Tl,Ug as El,Ui as Dl,Uk as Ol,Um as kl,Un as Al,Uo as jl,Ur as Ml,Uu as Nl,VB as Pl,VC as Fl,VD as Il,VE as Ll,VH as Rl,VM as zl,VQ as Bl,VU as Vl,VV as Hl,VW as Ul,VX as Wl,V_ as Gl,Va as Kl,Vb as ql,Vc as Jl,Vd as Yl,Vf as Xl,Vg as Zl,Vi as Ql,Vk as $l,Vm as eu,Vo as tu,Vr as nu,Vs as ru,Vu as iu,WC as au,WD as ou,WE as su,WH as cu,WM as lu,WN as uu,WQ as du,WV as fu,WW as pu,WX as mu,W_ as hu,Wa as gu,Wc as _u,Wd as vu,Wf as yu,Wg as bu,Wi as xu,Wk as Su,Wm as Cu,Wn as wu,Wo as Tu,Wr as Eu,Ws as Du,Wu as Ou,XC as ku,XD as Au,XE as ju,XH as Mu,XJ as Nu,XM as Pu,XN as Fu,XO as Iu,XT as Lu,XU as Ru,XV as zu,XW as Bu,X_ as Vu,Xa as Hu,Xb as Uu,Xc as Wu,Xi as Gu,Xk as Ku,Xl as qu,Xm as Ju,Xn as Yu,Xo as Xu,Xr as Zu,Xs as Qu,Xt as $u,Xy as ed,YC as td,YD as nd,YE as rd,YH as id,YM as ad,YN as od,YO as sd,YT as cd,YU as ld,YV as ud,YW as dd,YX as fd,Y_ as pd,Ya as md,Yc as hd,Yd as gd,Yg as _d,Yi as vd,Yk as yd,Yl as bd,Ym as xd,Yn as Sd,Yo as Cd,Yr as wd,Ys as Td,Yt as Ed,Yy as Dd,ZC as Od,ZD as kd,ZE as Ad,ZH as jd,ZJ as Md,ZM as Nd,ZN as Pd,ZO as Fd,ZT as Id,ZU as Ld,ZV as Rd,ZW as zd,Z_ as Bd,Za as Vd,Zc as Hd,Zi as Ud,Zk as Wd,Zl as Gd,Zm as Kd,Zn as qd,Zr as Jd,Zs as Yd,Zt as Xd,Zy as Zd,_B as Qd,_D as $d,_E as ef,_G as tf,_H as nf,_T as rf,_U as af,_W as of,_X as sf,__ as cf,_a as lf,_b as uf,_c as df,_f as ff,_i as pf,_l as mf,_m as hf,_o as gf,_r as _f,_s as vf,_t as yf,_u as bf,_v as xf,a as Sf,aB as Cf,aD as wf,aE as Tf,aG as Ef,aH as Df,aP as Of,aU as kf,aW as Af,aa as jf,ac as Mf,af as Nf,ah as Pf,ai as Ff,al as If,an as Lf,ao as Rf,ar as zf,as as Bf,at as Vf,au as Hf,av as Uf,aw as Wf,b as Gf,bB as Kf,bD as qf,bE as Jf,bH as Yf,bQ as Xf,bT as Zf,bU as Qf,bW as $f,bX as ep,b_ as tp,ba as np,bb as rp,bc as ip,bf as ap,bi as op,bk as sp,bm as cp,bo as lp,bp as up,br as dp,bt as fp,bu as pp,bv as mp,cB as hp,cD as gp,cE as _p,cG as vp,cH as yp,cP as bp,cT as xp,cU as Sp,cW as Cp,c_ as wp,ca as Tp,cc as Ep,cf as Dp,ch as Op,ci as kp,cl as Ap,cn as jp,co as Mp,cr as Np,ct as Pp,cu as Fp,cv as Ip,cw as Lp,dB as Rp,dD as zp,dE as Bp,dG as Vp,dH as Hp,dP as Up,dU as Wp,dW as Gp,dX as Kp,d_ as qp,da as Jp,db as Yp,dc as Xp,df as Zp,di as Qp,dk as $p,dl as em,dm as tm,dn as nm,do as rm,dr as im,dt as am,du as om,dv as sm,eA as cm,eD as lm,eE as um,eG as dm,eH as fm,eN as pm,eP as mm,eU as hm,eW as gm,eY as _m,ea as vm,eb as ym,ec as bm,eh as xm,ei as Sm,ej as Cm,el as wm,en as Tm,eo as Em,er as Dm,eu as Om,ev as km,ew as Am,fB as jm,fD as Mm,fE as eee,fG as tee,fH as nee,fP as ree,fU as iee,fW as aee,fX as oee,f_ as see,fa as cee,fb as lee,fc as uee,ff as Nm,fi as Pm,fl as dee,fn as Fm,fo as Im,fr as Lm,ft as Rm,fu as zm,fv as Bm,gB as Vm,gD as Hm,gE as Um,gG as Wm,gH as Gm,gT as Km,gU as qm,gW as Jm,gX as Ym,g_ as Xm,ga as Zm,gb as Qm,gc as $m,gf as eh,gi as th,gl as nh,gm as rh,gn as ih,go as ah,gr as oh,gs as sh,gt as ch,gu as lh,gv as uh,hB as dh,hD as fh,hE as ph,hG as mh,hH as hh,hT as gh,hU as _h,hW as vh,hX as yh,h_ as bh,ha as xh,hb as Sh,hc as Ch,hf as wh,hi as Th,hl as Eh,hn as Dh,ho as Oh,hr as kh,hs as Ah,ht as jh,hu as Mh,hv as Nh,i as Ph,iB as Fh,iD as Ih,iE as Lh,iG as Rh,iH as zh,iP as Bh,iU as Vh,iW as Hh,ia as Uh,ic as Wh,ih as Gh,ii as Kh,il as qh,in as Jh,io as Yh,ir as Xh,iu as Zh,iv as Qh,iw as $h,jB as eg,jD as tg,jE as ng,jH as rg,jM as ig,jO as ag,jQ as og,jT as sg,jU as cg,jW as lg,jX as ug,j_ as dg,ja as fg,jf as pg,jh as mg,ji as hg,jk as gg,jm as _g,jo as vg,jp as yg,jt as bg,ju as xg,jv as Sg,k as W,kB as Cg,kD as wg,kE as Tg,kH as Eg,kM as Dg,kQ as Og,kT as fee,kU as kg,kW as Ag,kX as jg,k_ as Mg,ka as Ng,kf as Pg,kh as Fg,ki as Ig,kk as Lg,kl as Rg,km as zg,ko as Bg,kp as Vg,kt as Hg,ku as Ug,kv as Wg,lB as Gg,lD as Kg,lE as qg,lG as Jg,lH as Yg,lP as Xg,lT as Zg,lU as Qg,lW as $g,lX as pee,l_ as mee,la as e_,lb as hee,lc as gee,lf as _ee,lh as vee,li as yee,ll as t_,ln as bee,lo as n_,lr as xee,lt as See,lu as Cee,lv as wee,mB as Tee,mD as Eee,mE as Dee,mG as Oee,mH as kee,mP as Aee,mU as r_,mW as jee,mX as Mee,m_ as Nee,ma as Pee,mb as Fee,mc as Iee,mf as i_,mi as a_,mk as Lee,ml as o_,mm as Ree,mn as zee,mo as Bee,mr as Vee,mt as Hee,mu as Uee,mv as s_,nA as Wee,nD as Gee,nE as Kee,nG as qee,nH as c_,nN as Jee,nP as Yee,nU as l_,nW as Xee,nY as Zee,na as Qee,nb as $ee,nc as ete,nh as tte,ni as u_,nl as d_,nn as f_,no as p_,nr as m_,ns as h_,nu as g_,nv as __,nw as v_,o as y_,oB as b_,oD as x_,oE as S_,oG as C_,oH as w_,oP as T_,oU as E_,oW as D_,o_ as O_,oa as k_,ob as A_,oc as j_,of as M_,oh as N_,oi as P_,ol as F_,on as I_,oo as L_,or as R_,ot as z_,ou as B_,ov as V_,ow as H_,pB as U_,pD as W_,pE as G_,pG as K_,pH as q_,pP as J_,pU as Y_,pW as X_,pX as Z_,p_ as Q_,pa as $_,pb as ev,pc as tv,pf as nv,pi as rv,pl as iv,pn as av,po as ov,pr as sv,pt as cv,pu as lv,pv as uv,qC as dv,qD as fv,qE as pv,qH as mv,qM as hv,qN as gv,qO as _v,qT as vv,qU as yv,qV as bv,qW as xv,q_ as Sv,qa as Cv,qc as wv,qd as Tv,qg as Ev,qi as Dv,qk as Ov,ql as kv,qm as Av,qn as jv,qo as Mv,qr as Nv,qt as Pv,qy as Fv,r as Iv,rD as Lv,rE as Rv,rG as zv,rH as Bv,rN as Vv,rP as Hv,rU as Uv,rW as Wv,rY as Gv,ra as Kv,rc as qv,rh as Jv,ri as Yv,rl as Xv,rn as Zv,ro as Qv,rr as $v,ru as ey,rv as ty,rw as ny,sB as ry,sD as iy,sE as ay,sG as oy,sH as sy,sP as cy,sU as ly,sW as uy,s_ as dy,sa as fy,sb as py,sc as my,sf as hy,sh as gy,si as _y,sl as vy,sn as yy,so as by,sr as xy,st as Sy,su as Cy,sv as wy,sw as Ty,t as G,tA as Ey,tD as Dy,tE as Oy,tG as ky,tH as Ay,tN as jy,tP as My,tU as Ny,tW as Py,tY as Fy,ta as Iy,tb as Ly,tc as Ry,th as zy,ti as By,tl as Vy,tn as Hy,to as Uy,tr as Wy,tu as Gy,tv as Ky,tw as qy,uB as Jy,uD as Yy,uE as Xy,uG as Zy,uH as Qy,uP as $y,uT as eb,uU as tb,uW as nb,uX as rb,u_ as ib,ua as ab,uc as ob,uf as sb,uh as cb,ui as lb,uk as ub,ul as db,um as fb,un as pb,uo as mb,ur as hb,ut as gb,uu as _b,uv as vb,vB as yb,vD as bb,vE as xb,vG as Sb,vH as Cb,vQ as wb,vT as Tb,vU as Eb,vW as Db,vX as Ob,v_ as kb,va as Ab,vb as jb,vc as Mb,vd as Nb,vf as Pb,vi as Fb,vo as Ib,vr as Lb,vs as Rb,vt as zb,vu as Bb,vv as Vb,w as Hb,wB as Ub,wD as Wb,wE as Gb,wH as Kb,wQ as qb,wT as Jb,wU as Yb,wW as Xb,wX as Zb,w_ as nte,wa as Qb,wc as rte,wf as ite,wh as ate,wi as ote,wk as ste,wm as cte,wo as lte,wp as ute,wt as dte,wu as fte,wv as pte,x as $b,xB as mte,xD as hte,xE as gte,xH as _te,xQ as vte,xT as yte,xU as bte,xW as xte,xX as Ste,x_ as Cte,xa as wte,xb as Tte,xc as Ete,xf as Dte,xh as Ote,xi as kte,xk as Ate,xm as jte,xo as Mte,xp as Nte,xr as Pte,xt as Fte,xu as ex,xv as Ite,y as tx,yB as Lte,yD as Rte,yE as zte,yH as nx,yQ as Bte,yT as Vte,yU as Hte,yW as rx,yX as Ute,y_ as ix,ya as ax,yb as Wte,yc as Gte,yd as Kte,yf as qte,yi as Jte,yo as Yte,yr as ox,yt as Xte,yu as Zte,yv as sx,zB as cx,zC as Qte,zD as $te,zE as ene,zH as tne,zM as nne,zO as lx,zQ as ux,zT as dx,zU as fx,zV as px,zW as mx,zX as hx,z_ as gx,za as _x,zb as vx,zc as yx,zd as bx,zf as rne,zg as xx,zi as Sx,zk as Cx,zm as wx,zo as Tx,zr as Ex,zs as Dx,zu as Ox}from"./api-V6x-16tY.js";import{S as kx,_ as Ax,a as jx,b as Mx,c as Nx,d as Px,f as Fx,g as Ix,h as Lx,i as Rx,l as zx,m as Bx,n as Vx,o as Hx,p as Ux,r as Wx,s as Gx,t as Kx,u as qx,v as ine,x as Jx,y as Yx}from"./useNavigate-D3GIoxyW.js";import{B as Xx,C as Zx,D as Qx,E as $x,F as eS,G as tS,H as nS,I as rS,J as iS,K as aS,L as oS,M as sS,N as cS,O as lS,P as uS,R as dS,T as fS,U as pS,V as mS,_ as hS,a as gS,b as _S,c as vS,d as yS,f as bS,g as xS,h as ane,i as SS,k as CS,l as wS,m as TS,n as ES,o as DS,p as OS,q as kS,r as AS,s as jS,t as MS,v as NS,w as PS,x as FS,y as IS,z as LS}from"./useStartNewChat-rxpg0noT.js";import{a as RS,c as zS,d as BS,f as VS,i as HS,l as US,m as WS,n as GS,o as KS,p as qS,r as JS,s as YS,u as XS}from"./speech-CsTQ-A5Z.js";import{t as ZS}from"./check-BgudyeCZ.js";import{r as QS}from"./dist-Dn0V4znq.js";import{t as $S}from"./chevron-left-C0Y3isEh.js";import{t as eC}from"./chevron-right-Bh8XLdLx.js";import{t as tC}from"./chevron-up-DvUmXiwf.js";import{n as nC,t as rC}from"./usageView-ht_gv_iV.js";import{_ as iC,a as aC,c as oC,d as sC,f as cC,g as lC,h as one,i as uC,l as sne,m as cne,n as dC,o as fC,p as lne,r as pC,s as mC,t as hC,u as gC}from"./dropdown-menu-CvM7DyUW.js";import{n as _C,t as vC}from"./search-Bwyf2eDv.js";import{t as yC}from"./copy-rAnqIOxQ.js";import{t as bC}from"./download-D9QjuqE8.js";import{n as xC,t as SC}from"./eye-uNqwwZRR.js";import{a as CC,i as wC,n as TC,o as EC,t as DC}from"./deliveryRecorder-C4wafMM5.js";import{t as OC}from"./loader-circle-BotUEUd9.js";import{t as kC}from"./lock-EGsKhQj8.js";import{t as AC}from"./checkbox-D6bftQAn.js";import{a as jC,i as MC,n as NC,r as PC,t as FC}from"./cronDescribe-_S84hFUo.js";import{t as IC}from"./pencil-DNZlqJcO.js";import{t as LC}from"./plus-D_fN9BU6.js";import{t as RC}from"./rotate-ccw-Cyt4JAE8.js";import{t as zC}from"./server-DLcIoj6y.js";import{i as BC,n as VC,r as HC,t as UC}from"./users-BYrKGPt9.js";import{t as WC}from"./trash-2-DMkzussw.js";import{t as GC}from"./triangle-alert-CcKY6Wsw.js";import{i as KC,n as qC,t as JC}from"./useChart-6Fi69FKB.js";import{t as YC}from"./x-C7RkX_i_.js";import{a as XC,i as ZC,n as QC,o as $C,r as ew,s as tw,t as nw}from"./tooltip-CRMDA8JT.js";import{a as rw,i as iw,n as aw,r as ow,t as sw}from"./select-BTp5btAs.js";import{a as cw,c as lw,i as uw,n as dw,o as fw,r as pw,s as mw,t as hw}from"./alert-dialog-DC8Z8Wmm.js";import{n as gw,r as _w,t as vw}from"./popover-BwLP1xvY.js";import{a as yw,i as bw,n as xw,o as Sw,r as Cw,t as ww}from"./tabs-CgaqwjVr.js";import{t as K}from"./button-Dk2mXV1u.js";import{t as Tw}from"./input-BxgrPOQB.js";import"./convexApi-BPs2Hfq9.js";import{a as Ew,c as Dw,d as Ow,i as kw,l as Aw,n as jw,o as Mw,r as Nw,s as Pw}from"./useFontScale-CPt1xprW.js";import{n as Fw,r as Iw,t as Lw}from"./toast-n2l0FW-G.js";import{t as Rw}from"./badge-X282ki8x.js";import{c as zw,d as Bw,f as Vw,l as Hw,o as Uw,r as Ww,s as Gw,u as Kw}from"./chunk-7TTQLYRW-ByhoRIPY.js";import{t as qw}from"./preload-helper-Czpn1I53.js";import{a as Jw,i as Yw,n as Xw,r as Zw}from"./format-BrALULQ2.js";import{a as Qw,i as $w,n as eT,o as tT,r as nT,t as rT}from"./dialog-BNsKJRIY.js";import{a as iT,d as aT,f as oT,h as sT,i as cT,l as lT,m as uT,p as dT,r as fT}from"./searchSchemas-Dm-Qg010.js";import{n as pT,r as mT,t as hT}from"./appHost-CH3EGcJw.js";import{n as gT,r as _T,t as vT}from"./ConfirmDialog-2GlWReLp.js";import{a as yT,c as bT,i as xT,n as ST,o as une,r as dne,s as CT,t as wT}from"./EntitySheet-C6w3z1QT.js";import{a as fne,c as pne,d as mne,f as TT,g as hne,h as gne,i as _ne,l as vne,m as ET,n as DT,o as yne,p as OT,r as kT,s as bne,u as xne}from"./KnobRow-C5AnEUHi.js";import{s as AT}from"./groupManageView-CDgw3aW6.js";import{n as Sne,r as jT,t as MT}from"./fileMetaView-Ci5C4w9Q.js";import{n as Cne,r as NT,t as PT}from"./measureClone-CHN0WNEY.js";import{r as FT,t as wne}from"./trashView-nGIDBl8U.js";import{a as Tne,c as IT,i as LT,l as RT,n as zT,r as BT,s as VT}from"./AdminSettings-5meEb9W8.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var HT=i((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),UT=i(((e,t)=>{t.exports=HT()})),WT=i((t=>{var r=UT(),i=e(),a=n();function o(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function l(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(c(e)!==e)throw Error(o(188))}function f(e){var t=e.alternate;if(!t){if(t=c(e),t===null)throw Error(o(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return d(i),e;if(a===r)return d(i),t;a=a.sibling}throw Error(o(188))}if(n.return!==r.return)n=i,r=a;else{for(var s=!1,l=i.child;l;){if(l===n){s=!0,n=i,r=a;break}if(l===r){s=!0,r=i,n=a;break}l=l.sibling}if(!s){for(l=a.child;l;){if(l===n){s=!0,n=a,r=i;break}if(l===r){s=!0,r=a,n=i;break}l=l.sibling}if(!s)throw Error(o(189))}}if(n.alternate!==r)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,h=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),_=Symbol.for(`react.portal`),v=Symbol.for(`react.fragment`),y=Symbol.for(`react.strict_mode`),b=Symbol.for(`react.profiler`),x=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),w=Symbol.for(`react.suspense`),T=Symbol.for(`react.suspense_list`),E=Symbol.for(`react.memo`),D=Symbol.for(`react.lazy`),O=Symbol.for(`react.activity`),k=Symbol.for(`react.memo_cache_sentinel`),A=Symbol.iterator;function j(e){return typeof e!=`object`||!e?null:(e=A&&e[A]||e[`@@iterator`],typeof e==`function`?e:null)}var M=Symbol.for(`react.client.reference`);function N(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===M?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case v:return`Fragment`;case b:return`Profiler`;case y:return`StrictMode`;case w:return`Suspense`;case T:return`SuspenseList`;case O:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case _:return`Portal`;case S:return e.displayName||`Context`;case x:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case E:return t=e.displayName||null,t===null?N(e.type)||`Memo`:t;case D:t=e._payload,e=e._init;try{return N(e(t))}catch{}}return null}var P=Array.isArray,F=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L={pending:!1,data:null,method:null,action:null},R=[],z=-1;function B(e){return{current:e}}function V(e){0>z||(e.current=R[z],R[z]=null,z--)}function ee(e,t){z++,R[z]=e.current,e.current=t}var te=B(null),ne=B(null),re=B(null),ie=B(null);function ae(e,t){switch(ee(re,t),ee(ne,e),ee(te,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Xd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Xd(t),e=Zd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}V(te),ee(te,e)}function oe(){V(te),V(ne),V(re)}function se(e){e.memoizedState!==null&&ee(ie,e);var t=te.current,n=Zd(t,e.type);t!==n&&(ee(ne,e),ee(te,n))}function ce(e){ne.current===e&&(V(te),V(ne)),ie.current===e&&(V(ie),sp._currentValue=L)}var le,ue;function de(e){if(le===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);le=t&&t[1]||``,ue=-1<e.stack.indexOf(`
3
+ at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
+ `+le+e+ue}var fe=!1;function pe(e,t){if(!e||fe)return``;fe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
5
+ `),l=s.split(`
6
+ `);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
7
+ `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{fe=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?de(n):``}function me(e,t){switch(e.tag){case 26:case 27:case 5:return de(e.type);case 16:return de(`Lazy`);case 13:return e.child!==t&&t!==null?de(`Suspense Fallback`):de(`Suspense`);case 19:return de(`SuspenseList`);case 0:case 15:return pe(e.type,!1);case 11:return pe(e.type.render,!1);case 1:return pe(e.type,!0);case 31:return de(`Activity`);default:return``}}function he(e){try{var t=``,n=null;do t+=me(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
8
+ Error generating stack: `+e.message+`
9
+ `+e.stack}}var ge=Object.prototype.hasOwnProperty,_e=r.unstable_scheduleCallback,ve=r.unstable_cancelCallback,ye=r.unstable_shouldYield,be=r.unstable_requestPaint,xe=r.unstable_now,Se=r.unstable_getCurrentPriorityLevel,Ce=r.unstable_ImmediatePriority,we=r.unstable_UserBlockingPriority,Te=r.unstable_NormalPriority,Ee=r.unstable_LowPriority,De=r.unstable_IdlePriority,Oe=r.log,ke=r.unstable_setDisableYieldValue,Ae=null,je=null;function Me(e){if(typeof Oe==`function`&&ke(e),je&&typeof je.setStrictMode==`function`)try{je.setStrictMode(Ae,e)}catch{}}var Ne=Math.clz32?Math.clz32:Ie,Pe=Math.log,Fe=Math.LN2;function Ie(e){return e>>>=0,e===0?32:31-(Pe(e)/Fe|0)|0}var Le=256,Re=262144,ze=4194304;function Be(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Ve(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Be(n))):i=Be(o):i=Be(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Be(n))):i=Be(o)):i=Be(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function He(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ue(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function We(){var e=ze;return ze<<=1,!(ze&62914560)&&(ze=4194304),e}function Ge(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ke(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function qe(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-Ne(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&Je(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function Je(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Ne(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function Ye(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ne(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Xe(e,t){var n=t&-t;return n=n&42?1:Ze(n),(n&(e.suspendedLanes|t))===0?n:0}function Ze(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Qe(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function $e(){var e=I.p;return e===0?(e=window.event,e===void 0?32:Cp(e.type)):e}function et(e,t){var n=I.p;try{return I.p=e,t()}finally{I.p=n}}var tt=Math.random().toString(36).slice(2),nt=`__reactFiber$`+tt,rt=`__reactProps$`+tt,it=`__reactContainer$`+tt,at=`__reactEvents$`+tt,ot=`__reactListeners$`+tt,st=`__reactHandles$`+tt,ct=`__reactResources$`+tt,lt=`__reactMarker$`+tt;function ut(e){delete e[nt],delete e[rt],delete e[at],delete e[ot],delete e[st]}function dt(e){var t=e[nt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[it]||n[nt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=bf(e);e!==null;){if(n=e[nt])return n;e=bf(e)}return t}e=n,n=e.parentNode}return null}function ft(e){if(e=e[nt]||e[it]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function pt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function mt(e){var t=e[ct];return t||=e[ct]={hoistableStyles:new Map,hoistableScripts:new Map},t}function ht(e){e[lt]=!0}var gt=new Set,_t={};function vt(e,t){yt(e,t),yt(e+`Capture`,t)}function yt(e,t){for(_t[e]=t,e=0;e<t.length;e++)gt.add(t[e])}var bt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),xt={},St={};function Ct(e){return ge.call(St,e)?!0:ge.call(xt,e)?!1:bt.test(e)?St[e]=!0:(xt[e]=!0,!1)}function wt(e,t,n){if(Ct(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function Tt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function Et(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function Dt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Ot(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function kt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function At(e){if(!e._valueTracker){var t=Ot(e)?`checked`:`value`;e._valueTracker=kt(e,t,``+e[t])}}function jt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Ot(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function Mt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Nt=/[\n"\\]/g;function Pt(e){return e.replace(Nt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Ft(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Dt(t)):e.value!==``+Dt(t)&&(e.value=``+Dt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Lt(e,o,Dt(n)):Lt(e,o,Dt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Dt(s):e.removeAttribute(`name`)}function It(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){At(e);return}n=n==null?``:``+Dt(n),t=t==null?n:``+Dt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),At(e)}function Lt(e,t,n){t===`number`&&Mt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function Rt(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Dt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function zt(e,t,n){if(t!=null&&(t=``+Dt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Dt(n)}function Bt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(o(92));if(P(r)){if(1<r.length)throw Error(o(93));r=r[0]}n=r}n??=``,t=n}n=Dt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),At(e)}function Vt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ht=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Ut(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Ht.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Wt(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(o(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var i in t)r=t[i],t.hasOwnProperty(i)&&n[i]!==r&&Ut(e,i,r)}else for(var a in t)t.hasOwnProperty(a)&&Ut(e,a,t[a])}function Gt(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Kt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),qt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Jt(e){return qt.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Yt(){}var Xt=null;function Zt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Qt=null,$t=null;function en(e){var t=ft(e);if(t&&(e=t.stateNode)){var n=e[rt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Ft(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Pt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=r[rt]||null;if(!i)throw Error(o(90));Ft(r,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&jt(r)}break a;case`textarea`:zt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&Rt(e,!!n.multiple,t,!1)}}}var tn=!1;function nn(e,t,n){if(tn)return e(t,n);tn=!0;try{return e(t)}finally{if(tn=!1,(Qt!==null||$t!==null)&&(Eu(),Qt&&(t=Qt,e=$t,$t=Qt=null,en(t),e)))for(t=0;t<e.length;t++)en(e[t])}}function rn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[rt]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(o(231,t,typeof n));return n}var H=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),an=!1;if(H)try{var on={};Object.defineProperty(on,"passive",{get:function(){an=!0}}),window.addEventListener(`test`,on,on),window.removeEventListener(`test`,on,on)}catch{an=!1}var sn=null,cn=null,ln=null;function un(){if(ln)return ln;var e,t=cn,n=t.length,r,i=`value`in sn?sn.value:sn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return ln=i.slice(e,1<r?1-r:void 0)}function dn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function fn(){return!0}function pn(){return!1}function mn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?fn:pn,this.isPropagationStopped=pn,this}return m(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=fn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=fn)},persist:function(){},isPersistent:fn}),t}var hn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},gn=mn(hn),_n=m({},hn,{view:0,detail:0}),vn=mn(_n),yn,bn,xn,Sn=m({},_n,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Nn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==xn&&(xn&&e.type===`mousemove`?(yn=e.screenX-xn.screenX,bn=e.screenY-xn.screenY):bn=yn=0,xn=e),yn)},movementY:function(e){return`movementY`in e?e.movementY:bn}}),Cn=mn(Sn),wn=mn(m({},Sn,{dataTransfer:0})),Tn=mn(m({},_n,{relatedTarget:0})),En=mn(m({},hn,{animationName:0,elapsedTime:0,pseudoElement:0})),Dn=mn(m({},hn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),On=mn(m({},hn,{data:0})),kn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},An={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},jn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Mn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=jn[e])?!!t[e]:!1}function Nn(){return Mn}var Pn=mn(m({},_n,{key:function(e){if(e.key){var t=kn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=dn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?An[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Nn,charCode:function(e){return e.type===`keypress`?dn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?dn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Fn=mn(m({},Sn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),In=mn(m({},_n,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Nn})),Ln=mn(m({},hn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Rn=mn(m({},Sn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),zn=mn(m({},hn,{newState:0,oldState:0})),Bn=[9,13,27,32],Vn=H&&`CompositionEvent`in window,Hn=null;H&&`documentMode`in document&&(Hn=document.documentMode);var Un=H&&`TextEvent`in window&&!Hn,Wn=H&&(!Vn||Hn&&8<Hn&&11>=Hn),Gn=` `,Kn=!1;function qn(e,t){switch(e){case`keyup`:return Bn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Jn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Yn=!1;function Xn(e,t){switch(e){case`compositionend`:return Jn(t);case`keypress`:return t.which===32?(Kn=!0,Gn):null;case`textInput`:return e=t.data,e===Gn&&Kn?null:e;default:return null}}function Zn(e,t){if(Yn)return e===`compositionend`||!Vn&&qn(e,t)?(e=un(),ln=cn=sn=null,Yn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return Wn&&t.locale!==`ko`?null:t.data;default:return null}}var Qn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function $n(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Qn[e.type]:t===`textarea`}function er(e,t,n,r){Qt?$t?$t.push(r):$t=[r]:Qt=r,t=Pd(t,`onChange`),0<t.length&&(n=new gn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var tr=null,nr=null;function rr(e){Ed(e,0)}function ir(e){if(jt(pt(e)))return e}function ar(e,t){if(e===`change`)return t}var or=!1;if(H){var sr;if(H){var cr=`oninput`in document;if(!cr){var lr=document.createElement(`div`);lr.setAttribute(`oninput`,`return;`),cr=typeof lr.oninput==`function`}sr=cr}else sr=!1;or=sr&&(!document.documentMode||9<document.documentMode)}function ur(){tr&&(tr.detachEvent(`onpropertychange`,dr),nr=tr=null)}function dr(e){if(e.propertyName===`value`&&ir(nr)){var t=[];er(t,nr,e,Zt(e)),nn(rr,t)}}function fr(e,t,n){e===`focusin`?(ur(),tr=t,nr=n,tr.attachEvent(`onpropertychange`,dr)):e===`focusout`&&ur()}function pr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return ir(nr)}function mr(e,t){if(e===`click`)return ir(t)}function hr(e,t){if(e===`input`||e===`change`)return ir(t)}function gr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var _r=typeof Object.is==`function`?Object.is:gr;function vr(e,t){if(_r(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!ge.call(t,i)||!_r(e[i],t[i]))return!1}return!0}function yr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function br(e,t){var n=yr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=yr(n)}}function xr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?xr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Sr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Mt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Mt(e.document)}return t}function Cr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var wr=H&&`documentMode`in document&&11>=document.documentMode,Tr=null,Er=null,Dr=null,Or=!1;function kr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Or||Tr==null||Tr!==Mt(r)||(r=Tr,`selectionStart`in r&&Cr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Dr&&vr(Dr,r)||(Dr=r,r=Pd(Er,`onSelect`),0<r.length&&(t=new gn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Tr)))}function Ar(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var jr={animationend:Ar(`Animation`,`AnimationEnd`),animationiteration:Ar(`Animation`,`AnimationIteration`),animationstart:Ar(`Animation`,`AnimationStart`),transitionrun:Ar(`Transition`,`TransitionRun`),transitionstart:Ar(`Transition`,`TransitionStart`),transitioncancel:Ar(`Transition`,`TransitionCancel`),transitionend:Ar(`Transition`,`TransitionEnd`)},Mr={},Nr={};H&&(Nr=document.createElement(`div`).style,`AnimationEvent`in window||(delete jr.animationend.animation,delete jr.animationiteration.animation,delete jr.animationstart.animation),`TransitionEvent`in window||delete jr.transitionend.transition);function Pr(e){if(Mr[e])return Mr[e];if(!jr[e])return e;var t=jr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Nr)return Mr[e]=t[n];return e}var Fr=Pr(`animationend`),Ir=Pr(`animationiteration`),Lr=Pr(`animationstart`),Rr=Pr(`transitionrun`),zr=Pr(`transitionstart`),Br=Pr(`transitioncancel`),Vr=Pr(`transitionend`),Hr=new Map,Ur=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Ur.push(`scrollEnd`);function Wr(e,t){Hr.set(e,t),vt(t,[e])}var Gr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Kr=[],qr=0,Jr=0;function Yr(){for(var e=qr,t=Jr=qr=0;t<e;){var n=Kr[t];Kr[t++]=null;var r=Kr[t];Kr[t++]=null;var i=Kr[t];Kr[t++]=null;var a=Kr[t];if(Kr[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&$r(n,i,a)}}function Xr(e,t,n,r){Kr[qr++]=e,Kr[qr++]=t,Kr[qr++]=n,Kr[qr++]=r,Jr|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Zr(e,t,n,r){return Xr(e,t,n,r),ei(e)}function Qr(e,t){return Xr(e,null,null,t),ei(e)}function $r(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-Ne(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function ei(e){if(50<_u)throw _u=0,vu=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var ti={};function ni(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ri(e,t,n,r){return new ni(e,t,n,r)}function ii(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ai(e,t){var n=e.alternate;return n===null?(n=ri(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function oi(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function si(e,t,n,r,i,a){var s=0;if(r=e,typeof e==`function`)ii(e)&&(s=1);else if(typeof e==`string`)s=Qf(e,n,te.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case O:return e=ri(31,n,t,i),e.elementType=O,e.lanes=a,e;case v:return ci(n.children,i,a,t);case y:s=8,i|=24;break;case b:return e=ri(12,n,t,i|2),e.elementType=b,e.lanes=a,e;case w:return e=ri(13,n,t,i),e.elementType=w,e.lanes=a,e;case T:return e=ri(19,n,t,i),e.elementType=T,e.lanes=a,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case S:s=10;break a;case x:s=9;break a;case C:s=11;break a;case E:s=14;break a;case D:s=16,r=null;break a}s=29,n=Error(o(130,e===null?`null`:typeof e,``)),r=null}return t=ri(s,n,t,i),t.elementType=e,t.type=r,t.lanes=a,t}function ci(e,t,n,r){return e=ri(7,e,r,t),e.lanes=n,e}function li(e,t,n){return e=ri(6,e,null,t),e.lanes=n,e}function ui(e){var t=ri(18,null,null,0);return t.stateNode=e,t}function di(e,t,n){return t=ri(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var fi=new WeakMap;function pi(e,t){if(typeof e==`object`&&e){var n=fi.get(e);return n===void 0?(t={value:e,source:t,stack:he(t)},fi.set(e,t),t):n}return{value:e,source:t,stack:he(t)}}var mi=[],hi=0,gi=null,_i=0,vi=[],yi=0,bi=null,xi=1,Si=``;function Ci(e,t){mi[hi++]=_i,mi[hi++]=gi,gi=e,_i=t}function wi(e,t,n){vi[yi++]=xi,vi[yi++]=Si,vi[yi++]=bi,bi=e;var r=xi;e=Si;var i=32-Ne(r)-1;r&=~(1<<i),n+=1;var a=32-Ne(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,xi=1<<32-Ne(t)+i|n<<i|r,Si=a+e}else xi=1<<a|n<<i|r,Si=e}function Ti(e){e.return!==null&&(Ci(e,1),wi(e,1,0))}function Ei(e){for(;e===gi;)gi=mi[--hi],mi[hi]=null,_i=mi[--hi],mi[hi]=null;for(;e===bi;)bi=vi[--yi],vi[yi]=null,Si=vi[--yi],vi[yi]=null,xi=vi[--yi],vi[yi]=null}function Di(e,t){vi[yi++]=xi,vi[yi++]=Si,vi[yi++]=bi,xi=t.id,Si=t.overflow,bi=e}var Oi=null,ki=null,Ai=!1,ji=null,Mi=!1,Ni=Error(o(519));function Pi(e){throw Bi(pi(Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Ni}function Fi(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[nt]=e,t[rt]=r,n){case`dialog`:Dd(`cancel`,t),Dd(`close`,t);break;case`iframe`:case`object`:case`embed`:Dd(`load`,t);break;case`video`:case`audio`:for(n=0;n<wd.length;n++)Dd(wd[n],t);break;case`source`:Dd(`error`,t);break;case`img`:case`image`:case`link`:Dd(`error`,t),Dd(`load`,t);break;case`details`:Dd(`toggle`,t);break;case`input`:Dd(`invalid`,t),It(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Dd(`invalid`,t);break;case`textarea`:Dd(`invalid`,t),Bt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Bd(t.textContent,n)?(r.popover!=null&&(Dd(`beforetoggle`,t),Dd(`toggle`,t)),r.onScroll!=null&&Dd(`scroll`,t),r.onScrollEnd!=null&&Dd(`scrollend`,t),r.onClick!=null&&(t.onclick=Yt),t=!0):t=!1,t||Pi(e,!0)}function Ii(e){for(Oi=e.return;Oi;)switch(Oi.tag){case 5:case 31:case 13:Mi=!1;return;case 27:case 3:Mi=!0;return;default:Oi=Oi.return}}function Li(e){if(e!==Oi)return!1;if(!Ai)return Ii(e),Ai=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||Qd(e.type,e.memoizedProps)),n=!n),n&&ki&&Pi(e),Ii(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(317));ki=yf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(317));ki=yf(e)}else t===27?(t=ki,sf(e.type)?(e=vf,vf=null,ki=e):ki=t):ki=Oi?_f(e.stateNode.nextSibling):null;return!0}function Ri(){ki=Oi=null,Ai=!1}function zi(){var e=ji;return e!==null&&(ru===null?ru=e:ru.push.apply(ru,e),ji=null),e}function Bi(e){ji===null?ji=[e]:ji.push(e)}var Vi=B(null),Hi=null,Ui=null;function Wi(e,t,n){ee(Vi,t._currentValue),t._currentValue=n}function Gi(e){e._currentValue=Vi.current,V(Vi)}function Ki(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function qi(e,t,n,r){var i=e.child;for(i!==null&&(i.return=e);i!==null;){var a=i.dependencies;if(a!==null){var s=i.child;a=a.firstContext;a:for(;a!==null;){var c=a;a=i;for(var l=0;l<t.length;l++)if(c.context===t[l]){a.lanes|=n,c=a.alternate,c!==null&&(c.lanes|=n),Ki(a.return,n,e),r||(s=null);break a}a=c.next}}else if(i.tag===18){if(s=i.return,s===null)throw Error(o(341));s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),Ki(s,n,e),s=null}else s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===e){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}}function Ji(e,t,n,r){e=null;for(var i=t,a=!1;i!==null;){if(!a){if(i.flags&524288)a=!0;else if(i.flags&262144)break}if(i.tag===10){var s=i.alternate;if(s===null)throw Error(o(387));if(s=s.memoizedProps,s!==null){var c=i.type;_r(i.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(i===ie.current){if(s=i.alternate,s===null)throw Error(o(387));s.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(e===null?e=[sp]:e.push(sp))}i=i.return}e!==null&&qi(t,e,n,r),t.flags|=262144}function Yi(e){for(e=e.firstContext;e!==null;){if(!_r(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Xi(e){Hi=e,Ui=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Zi(e){return $i(Hi,e)}function Qi(e,t){return Hi===null&&Xi(e),$i(e,t)}function $i(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Ui===null){if(e===null)throw Error(o(308));Ui=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Ui=Ui.next=t;return n}var ea=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},ta=r.unstable_scheduleCallback,na=r.unstable_NormalPriority,ra={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ia(){return{controller:new ea,data:new Map,refCount:0}}function aa(e){e.refCount--,e.refCount===0&&ta(na,function(){e.controller.abort()})}var oa=null,sa=0,ca=0,la=null;function ua(e,t){if(oa===null){var n=oa=[];sa=0,ca=vd(),la={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return sa++,t.then(da,da),t}function da(){if(--sa===0&&oa!==null){la!==null&&(la.status=`fulfilled`);var e=oa;oa=null,ca=0,la=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function fa(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var pa=F.S;F.S=function(e,t){ou=xe(),typeof t==`object`&&t&&typeof t.then==`function`&&ua(e,t),pa!==null&&pa(e,t)};var ma=B(null);function ha(){var e=ma.current;return e===null?Vl.pooledCache:e}function ga(e,t){t===null?ee(ma,ma.current):ee(ma,t.pool)}function _a(){var e=ha();return e===null?null:{parent:ra._currentValue,pool:e}}var va=Error(o(460)),ya=Error(o(474)),ba=Error(o(542)),xa={then:function(){}};function Sa(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Ca(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Yt,Yt),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Da(e),e;default:if(typeof t.status==`string`)t.then(Yt,Yt);else{if(e=Vl,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Da(e),e}throw Ta=t,va}}function wa(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Ta=e,va):e}}var Ta=null;function Ea(){if(Ta===null)throw Error(o(459));var e=Ta;return Ta=null,e}function Da(e){if(e===va||e===ba)throw Error(o(483))}var Oa=null,ka=0;function Aa(e){var t=ka;return ka+=1,Oa===null&&(Oa=[]),Ca(Oa,e,t)}function ja(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Ma(e,t){throw t.$$typeof===h?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Na(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function i(e,t){return e=ai(e,t),e.index=0,e.sibling=null,e}function a(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=li(n,e.mode,r),t.return=e,t):(t=i(t,n),t.return=e,t)}function l(e,t,n,r){var a=n.type;return a===v?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===a||typeof a==`object`&&a&&a.$$typeof===D&&wa(a)===t.type)?(t=i(t,n.props),ja(t,n),t.return=e,t):(t=si(n.type,n.key,n.props,null,e.mode,r),ja(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=di(n,e.mode,r),t.return=e,t):(t=i(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,a){return t===null||t.tag!==7?(t=ci(n,e.mode,r,a),t.return=e,t):(t=i(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=li(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case g:return n=si(t.type,t.key,t.props,null,e.mode,n),ja(n,t),n.return=e,n;case _:return t=di(t,e.mode,n),t.return=e,t;case D:return t=wa(t),f(e,t,n)}if(P(t)||j(t))return t=ci(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Aa(t),n);if(t.$$typeof===S)return f(e,Qi(e,t),n);Ma(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case g:return n.key===i?l(e,t,n,r):null;case _:return n.key===i?u(e,t,n,r):null;case D:return n=wa(n),p(e,t,n,r)}if(P(n)||j(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Aa(n),r);if(n.$$typeof===S)return p(e,t,Qi(e,n),r);Ma(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case g:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case _:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case D:return r=wa(r),m(e,t,n,r,i)}if(P(r)||j(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,Aa(r),i);if(r.$$typeof===S)return m(e,t,n,Qi(t,r),i);Ma(t,r)}return null}function h(i,o,s,c){for(var l=null,u=null,d=o,h=o=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),o=a(_,o,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),Ai&&Ci(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(o=a(d,o,h),u===null?l=d:u.sibling=d,u=d);return Ai&&Ci(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),o=a(g,o,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),Ai&&Ci(i,h),l}function y(i,s,c,l){if(c==null)throw Error(o(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),s=a(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),Ai&&Ci(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return Ai&&Ci(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),Ai&&Ci(i,g),u}function b(e,r,a,c){if(typeof a==`object`&&a&&a.type===v&&a.key===null&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case g:a:{for(var l=a.key;r!==null;){if(r.key===l){if(l=a.type,l===v){if(r.tag===7){n(e,r.sibling),c=i(r,a.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===D&&wa(l)===r.type){n(e,r.sibling),c=i(r,a.props),ja(c,a),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}a.type===v?(c=ci(a.props.children,e.mode,c,a.key),c.return=e,e=c):(c=si(a.type,a.key,a.props,null,e.mode,c),ja(c,a),c.return=e,e=c)}return s(e);case _:a:{for(l=a.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){n(e,r.sibling),c=i(r,a.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=di(a,e.mode,c),c.return=e,e=c}return s(e);case D:return a=wa(a),b(e,r,a,c)}if(P(a))return h(e,r,a,c);if(j(a)){if(l=j(a),typeof l!=`function`)throw Error(o(150));return a=l.call(a),y(e,r,a,c)}if(typeof a.then==`function`)return b(e,r,Aa(a),c);if(a.$$typeof===S)return b(e,r,Qi(e,a),c);Ma(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,a),c.return=e,e=c):(n(e,r),c=li(a,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{ka=0;var i=b(e,t,n,r);return Oa=null,i}catch(t){if(t===va||t===ba)throw t;var a=ri(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Pa=Na(!0),Fa=Na(!1),Ia=!1;function La(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ra(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function za(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ba(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Bl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=ei(e),$r(e,null,n),t}return Xr(e,r,t,n),ei(e)}function Va(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ye(e,n)}}function Ha(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Ua=!1;function Wa(){if(Ua){var e=la;if(e!==null)throw e}}function Ga(e,t,n,r){Ua=!1;var i=e.updateQueue;Ia=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Ul&f)===f:(r&f)===f){f!==0&&f===ca&&(Ua=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,f);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,f=typeof h==`function`?h.call(_,d,f):h,f==null)break a;d=m({},d,f);break a;case 2:Ia=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Zl|=o,e.lanes=o,e.memoizedState=d}}function Ka(e,t){if(typeof e!=`function`)throw Error(o(191,e));e.call(t)}function qa(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ka(n[e],t)}var Ja=B(null),Ya=B(0);function Xa(e,t){e=Yl,ee(Ya,e),ee(Ja,t),Yl=e|t.baseLanes}function Za(){ee(Ya,Yl),ee(Ja,Ja.current)}function Qa(){Yl=Ya.current,V(Ja),V(Ya)}var $a=B(null),eo=null;function to(e){var t=e.alternate;ee(oo,oo.current&1),ee($a,e),eo===null&&(t===null||Ja.current!==null||t.memoizedState!==null)&&(eo=e)}function no(e){ee(oo,oo.current),ee($a,e),eo===null&&(eo=e)}function ro(e){e.tag===22?(ee(oo,oo.current),ee($a,e),eo===null&&(eo=e)):io(e)}function io(){ee(oo,oo.current),ee($a,$a.current)}function ao(e){V($a),eo===e&&(eo=null),V(oo)}var oo=B(0);function so(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||mf(n)||hf(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var co=0,lo=null,uo=null,fo=null,po=!1,mo=!1,ho=!1,go=0,_o=0,vo=null,yo=0;function bo(){throw Error(o(321))}function xo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!_r(e[n],t[n]))return!1;return!0}function So(e,t,n,r,i,a){return co=a,lo=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,F.H=e===null||e.memoizedState===null?Rs:zs,ho=!1,a=n(r,i),ho=!1,mo&&(a=wo(t,n,r,i)),Co(e),a}function Co(e){F.H=Ls;var t=uo!==null&&uo.next!==null;if(co=0,fo=uo=lo=null,po=!1,_o=0,vo=null,t)throw Error(o(300));e===null||nc||(e=e.dependencies,e!==null&&Yi(e)&&(nc=!0))}function wo(e,t,n,r){lo=e;var i=0;do{if(mo&&(vo=null),_o=0,mo=!1,25<=i)throw Error(o(301));if(i+=1,fo=uo=null,e.updateQueue!=null){var a=e.updateQueue;a.lastEffect=null,a.events=null,a.stores=null,a.memoCache!=null&&(a.memoCache.index=0)}F.H=Bs,a=t(n,r)}while(mo);return a}function To(){var e=F.H,t=e.useState()[0];return t=typeof t.then==`function`?Mo(t):t,e=e.useState()[0],(uo===null?null:uo.memoizedState)!==e&&(lo.flags|=1024),t}function Eo(){var e=go!==0;return go=0,e}function Do(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Oo(e){if(po){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}po=!1}co=0,fo=uo=lo=null,mo=!1,_o=go=0,vo=null}function ko(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return fo===null?lo.memoizedState=fo=e:fo=fo.next=e,fo}function Ao(){if(uo===null){var e=lo.alternate;e=e===null?null:e.memoizedState}else e=uo.next;var t=fo===null?lo.memoizedState:fo.next;if(t!==null)fo=t,uo=e;else{if(e===null)throw lo.alternate===null?Error(o(467)):Error(o(310));uo=e,e={memoizedState:uo.memoizedState,baseState:uo.baseState,baseQueue:uo.baseQueue,queue:uo.queue,next:null},fo===null?lo.memoizedState=fo=e:fo=fo.next=e}return fo}function jo(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Mo(e){var t=_o;return _o+=1,vo===null&&(vo=[]),e=Ca(vo,e,t),t=lo,(fo===null?t.memoizedState:fo.next)===null&&(t=t.alternate,F.H=t===null||t.memoizedState===null?Rs:zs),e}function No(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Mo(e);if(e.$$typeof===S)return Zi(e)}throw Error(o(438,String(e)))}function Po(e){var t=null,n=lo.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=lo.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=jo(),lo.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=k;return t.index++,n}function Fo(e,t){return typeof t==`function`?t(e):t}function Io(e){return Lo(Ao(),uo,e)}function Lo(e,t,n){var r=e.queue;if(r===null)throw Error(o(311));r.lastRenderedReducer=n;var i=e.baseQueue,a=r.pending;if(a!==null){if(i!==null){var s=i.next;i.next=a.next,a.next=s}t.baseQueue=i=a,r.pending=null}if(a=e.baseState,i===null)e.memoizedState=a;else{t=i.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(co&f)===f:(Ul&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===ca&&(d=!0);else if((co&p)===p){u=u.next,p===ca&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=a):l=l.next=f,lo.lanes|=p,Zl|=p;f=u.action,ho&&n(a,f),a=u.hasEagerState?u.eagerState:n(a,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=a):l=l.next=p,lo.lanes|=f,Zl|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=a:l.next=c,!_r(a,e.memoizedState)&&(nc=!0,d&&(n=la,n!==null)))throw n;e.memoizedState=a,e.baseState=s,e.baseQueue=l,r.lastRenderedState=a}return i===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Ro(e){var t=Ao(),n=t.queue;if(n===null)throw Error(o(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,a=t.memoizedState;if(i!==null){n.pending=null;var s=i=i.next;do a=e(a,s.action),s=s.next;while(s!==i);_r(a,t.memoizedState)||(nc=!0),t.memoizedState=a,t.baseQueue===null&&(t.baseState=a),n.lastRenderedState=a}return[a,r]}function zo(e,t,n){var r=lo,i=Ao(),a=Ai;if(a){if(n===void 0)throw Error(o(407));n=n()}else n=t();var s=!_r((uo||i).memoizedState,n);if(s&&(i.memoizedState=n,nc=!0),i=i.queue,ls(Ho.bind(null,r,i,e),[e]),i.getSnapshot!==t||s||fo!==null&&fo.memoizedState.tag&1){if(r.flags|=2048,is(9,{destroy:void 0},Vo.bind(null,r,i,n,t),null),Vl===null)throw Error(o(349));a||co&127||Bo(r,t,n)}return n}function Bo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=lo.updateQueue,t===null?(t=jo(),lo.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Vo(e,t,n,r){t.value=n,t.getSnapshot=r,Uo(t)&&Wo(e)}function Ho(e,t,n){return n(function(){Uo(t)&&Wo(e)})}function Uo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!_r(e,n)}catch{return!0}}function Wo(e){var t=Qr(e,2);t!==null&&xu(t,e,2)}function Go(e){var t=ko();if(typeof e==`function`){var n=e;if(e=n(),ho){Me(!0);try{n()}finally{Me(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fo,lastRenderedState:e},t}function Ko(e,t,n,r){return e.baseState=n,Lo(e,uo,typeof r==`function`?r:Fo)}function qo(e,t,n,r,i){if(Ps(e))throw Error(o(485));if(e=t.action,e!==null){var a={payload:i,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){a.listeners.push(e)}};F.T===null?a.isTransition=!1:n(!0),r(a),n=t.pending,n===null?(a.next=t.pending=a,Jo(t,a)):(a.next=n.next,t.pending=n.next=a)}}function Jo(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=F.T,o={};F.T=o;try{var s=n(i,r),c=F.S;c!==null&&c(o,s),Yo(e,t,s)}catch(n){Zo(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),F.T=a}}else try{a=n(i,r),Yo(e,t,a)}catch(n){Zo(e,t,n)}}function Yo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Xo(e,t,n)},function(n){return Zo(e,t,n)}):Xo(e,t,n)}function Xo(e,t,n){t.status=`fulfilled`,t.value=n,Qo(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Jo(e,n)))}function Zo(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Qo(t),t=t.next;while(t!==r)}e.action=null}function Qo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function $o(e,t){return t}function U(e,t){if(Ai){var n=Vl.formState;if(n!==null){a:{var r=lo;if(Ai){if(ki){b:{for(var i=ki,a=Mi;i.nodeType!==8;){if(!a){i=null;break b}if(i=_f(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){ki=_f(i.nextSibling),r=i.data===`F!`;break a}}Pi(r)}r=!1}r&&(t=n[0])}}return n=ko(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:$o,lastRenderedState:t},n.queue=r,n=js.bind(null,lo,r),r.dispatch=n,r=Go(!1),a=Ns.bind(null,lo,!1,r.queue),r=ko(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=qo.bind(null,lo,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function es(e){return ts(Ao(),uo,e)}function ts(e,t,n){if(t=Lo(e,t,$o)[0],e=Io(Fo)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Mo(t)}catch(e){throw e===va?ba:e}else r=t;t=Ao();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(lo.flags|=2048,is(9,{destroy:void 0},ns.bind(null,i,n),null)),[r,a,e]}function ns(e,t){e.action=t}function rs(e){var t=Ao(),n=uo;if(n!==null)return ts(t,n,e);Ao(),t=t.memoizedState,n=Ao();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function is(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=lo.updateQueue,t===null&&(t=jo(),lo.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function as(){return Ao().memoizedState}function os(e,t,n,r){var i=ko();lo.flags|=e,i.memoizedState=is(1|t,{destroy:void 0},n,r===void 0?null:r)}function ss(e,t,n,r){var i=Ao();r=r===void 0?null:r;var a=i.memoizedState.inst;uo!==null&&r!==null&&xo(r,uo.memoizedState.deps)?i.memoizedState=is(t,a,n,r):(lo.flags|=e,i.memoizedState=is(1|t,a,n,r))}function cs(e,t){os(8390656,8,e,t)}function ls(e,t){ss(2048,8,e,t)}function us(e){lo.flags|=4;var t=lo.updateQueue;if(t===null)t=jo(),lo.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function ds(e){var t=Ao().memoizedState;return us({ref:t,nextImpl:e}),function(){if(Bl&2)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function fs(e,t){return ss(4,2,e,t)}function ps(e,t){return ss(4,4,e,t)}function ms(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function hs(e,t,n){n=n==null?null:n.concat([e]),ss(4,4,ms.bind(null,t,e),n)}function gs(){}function _s(e,t){var n=Ao();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&xo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function vs(e,t){var n=Ao();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&xo(t,r[1]))return r[0];if(r=e(),ho){Me(!0);try{e()}finally{Me(!1)}}return n.memoizedState=[r,t],r}function ys(e,t,n){return n===void 0||co&1073741824&&!(Ul&261930)?e.memoizedState=t:(e.memoizedState=n,e=bu(),lo.lanes|=e,Zl|=e,n)}function bs(e,t,n,r){return _r(n,t)?n:Ja.current===null?!(co&42)||co&1073741824&&!(Ul&261930)?(nc=!0,e.memoizedState=n):(e=bu(),lo.lanes|=e,Zl|=e,t):(e=ys(e,n,r),_r(e,t)||(nc=!0),e)}function xs(e,t,n,r,i){var a=I.p;I.p=a!==0&&8>a?a:8;var o=F.T,s={};F.T=s,Ns(e,!1,t,n);try{var c=i(),l=F.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Ms(e,t,fa(c,r),yu(e)):Ms(e,t,r,yu(e))}catch(n){Ms(e,t,{then:function(){},status:`rejected`,reason:n},yu())}finally{I.p=a,o!==null&&s.types!==null&&(o.types=s.types),F.T=o}}function Ss(){}function Cs(e,t,n,r){if(e.tag!==5)throw Error(o(476));var i=ws(e).queue;xs(e,i,t,L,n===null?Ss:function(){return Ts(e),n(r)})}function ws(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:L,baseState:L,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fo,lastRenderedState:L},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ts(e){var t=ws(e);t.next===null&&(t=e.alternate.memoizedState),Ms(e,t.next.queue,{},yu())}function Es(){return Zi(sp)}function Ds(){return Ao().memoizedState}function Os(){return Ao().memoizedState}function ks(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=yu();e=za(n);var r=Ba(t,e,n);r!==null&&(xu(r,t,n),Va(r,t,n)),t={cache:ia()},e.payload=t;return}t=t.return}}function As(e,t,n){var r=yu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ps(e)?Fs(t,n):(n=Zr(e,t,n,r),n!==null&&(xu(n,e,r),Is(n,t,r)))}function js(e,t,n){Ms(e,t,n,yu())}function Ms(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ps(e))Fs(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,_r(s,o))return Xr(e,t,i,0),Vl===null&&Yr(),!1}catch{}if(n=Zr(e,t,i,r),n!==null)return xu(n,e,r),Is(n,t,r),!0}return!1}function Ns(e,t,n,r){if(r={lane:2,revertLane:vd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ps(e)){if(t)throw Error(o(479))}else t=Zr(e,n,r,2),t!==null&&xu(t,e,2)}function Ps(e){var t=e.alternate;return e===lo||t!==null&&t===lo}function Fs(e,t){mo=po=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Is(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ye(e,n)}}var Ls={readContext:Zi,use:No,useCallback:bo,useContext:bo,useEffect:bo,useImperativeHandle:bo,useLayoutEffect:bo,useInsertionEffect:bo,useMemo:bo,useReducer:bo,useRef:bo,useState:bo,useDebugValue:bo,useDeferredValue:bo,useTransition:bo,useSyncExternalStore:bo,useId:bo,useHostTransitionStatus:bo,useFormState:bo,useActionState:bo,useOptimistic:bo,useMemoCache:bo,useCacheRefresh:bo};Ls.useEffectEvent=bo;var Rs={readContext:Zi,use:No,useCallback:function(e,t){return ko().memoizedState=[e,t===void 0?null:t],e},useContext:Zi,useEffect:cs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),os(4194308,4,ms.bind(null,t,e),n)},useLayoutEffect:function(e,t){return os(4194308,4,e,t)},useInsertionEffect:function(e,t){os(4,2,e,t)},useMemo:function(e,t){var n=ko();t=t===void 0?null:t;var r=e();if(ho){Me(!0);try{e()}finally{Me(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=ko();if(n!==void 0){var i=n(t);if(ho){Me(!0);try{n(t)}finally{Me(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=As.bind(null,lo,e),[r.memoizedState,e]},useRef:function(e){var t=ko();return e={current:e},t.memoizedState=e},useState:function(e){e=Go(e);var t=e.queue,n=js.bind(null,lo,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:gs,useDeferredValue:function(e,t){return ys(ko(),e,t)},useTransition:function(){var e=Go(!1);return e=xs.bind(null,lo,e.queue,!0,!1),ko().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=lo,i=ko();if(Ai){if(n===void 0)throw Error(o(407));n=n()}else{if(n=t(),Vl===null)throw Error(o(349));Ul&127||Bo(r,t,n)}i.memoizedState=n;var a={value:n,getSnapshot:t};return i.queue=a,cs(Ho.bind(null,r,a,e),[e]),r.flags|=2048,is(9,{destroy:void 0},Vo.bind(null,r,a,n,t),null),n},useId:function(){var e=ko(),t=Vl.identifierPrefix;if(Ai){var n=Si,r=xi;n=(r&~(1<<32-Ne(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=go++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=yo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Es,useFormState:U,useActionState:U,useOptimistic:function(e){var t=ko();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Ns.bind(null,lo,!0,n),n.dispatch=t,[e,t]},useMemoCache:Po,useCacheRefresh:function(){return ko().memoizedState=ks.bind(null,lo)},useEffectEvent:function(e){var t=ko(),n={impl:e};return t.memoizedState=n,function(){if(Bl&2)throw Error(o(440));return n.impl.apply(void 0,arguments)}}},zs={readContext:Zi,use:No,useCallback:_s,useContext:Zi,useEffect:ls,useImperativeHandle:hs,useInsertionEffect:fs,useLayoutEffect:ps,useMemo:vs,useReducer:Io,useRef:as,useState:function(){return Io(Fo)},useDebugValue:gs,useDeferredValue:function(e,t){return bs(Ao(),uo.memoizedState,e,t)},useTransition:function(){var e=Io(Fo)[0],t=Ao().memoizedState;return[typeof e==`boolean`?e:Mo(e),t]},useSyncExternalStore:zo,useId:Ds,useHostTransitionStatus:Es,useFormState:es,useActionState:es,useOptimistic:function(e,t){return Ko(Ao(),uo,e,t)},useMemoCache:Po,useCacheRefresh:Os};zs.useEffectEvent=ds;var Bs={readContext:Zi,use:No,useCallback:_s,useContext:Zi,useEffect:ls,useImperativeHandle:hs,useInsertionEffect:fs,useLayoutEffect:ps,useMemo:vs,useReducer:Ro,useRef:as,useState:function(){return Ro(Fo)},useDebugValue:gs,useDeferredValue:function(e,t){var n=Ao();return uo===null?ys(n,e,t):bs(n,uo.memoizedState,e,t)},useTransition:function(){var e=Ro(Fo)[0],t=Ao().memoizedState;return[typeof e==`boolean`?e:Mo(e),t]},useSyncExternalStore:zo,useId:Ds,useHostTransitionStatus:Es,useFormState:rs,useActionState:rs,useOptimistic:function(e,t){var n=Ao();return uo===null?(n.baseState=e,[e,n.queue.dispatch]):Ko(n,uo,e,t)},useMemoCache:Po,useCacheRefresh:Os};Bs.useEffectEvent=ds;function Vs(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:m({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Hs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=yu(),i=za(r);i.payload=t,n!=null&&(i.callback=n),t=Ba(e,i,r),t!==null&&(xu(t,e,r),Va(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=yu(),i=za(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Ba(e,i,r),t!==null&&(xu(t,e,r),Va(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=yu(),r=za(n);r.tag=2,t!=null&&(r.callback=t),t=Ba(e,r,n),t!==null&&(xu(t,e,n),Va(t,e,n))}};function Us(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!vr(n,r)||!vr(i,a):!0}function Ws(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Hs.enqueueReplaceState(t,t.state,null)}function Gs(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=m({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Ks(e){Gr(e)}function qs(e){console.error(e)}function Js(e){Gr(e)}function Ys(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Xs(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Zs(e,t,n){return n=za(n),n.tag=3,n.payload={element:null},n.callback=function(){Ys(e,t)},n}function Qs(e){return e=za(e),e.tag=3,e}function $s(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Xs(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Xs(t,n,r),typeof i!=`function`&&(lu===null?lu=new Set([this]):lu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function ec(e,t,n,r,i){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Ji(t,n,i,!0),n=$a.current,n!==null){switch(n.tag){case 31:case 13:return eo===null?Nu():n.alternate===null&&Xl===0&&(Xl=3),n.flags&=-257,n.flags|=65536,n.lanes=i,r===xa?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Qu(e,r,i)),!1;case 22:return n.flags|=65536,r===xa?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Qu(e,r,i)),!1}throw Error(o(435,n.tag))}return Qu(e,r,i),Nu(),!1}if(Ai)return t=$a.current,t===null?(r!==Ni&&(t=Error(o(423),{cause:r}),Bi(pi(t,n))),e=e.current.alternate,e.flags|=65536,i&=-i,e.lanes|=i,r=pi(r,n),i=Zs(e.stateNode,r,i),Ha(e,i),Xl!==4&&(Xl=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=i,r!==Ni&&(e=Error(o(422),{cause:r}),Bi(pi(e,n)))),!1;var a=Error(o(520),{cause:r});if(a=pi(a,n),nu===null?nu=[a]:nu.push(a),Xl!==4&&(Xl=2),t===null)return!0;r=pi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,e=Zs(n.stateNode,r,e),Ha(n,e),!1;case 1:if(t=n.type,a=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||a!==null&&typeof a.componentDidCatch==`function`&&(lu===null||!lu.has(a))))return n.flags|=65536,i&=-i,n.lanes|=i,i=Qs(i),$s(i,e,n,r),Ha(n,i),!1}n=n.return}while(n!==null);return!1}var tc=Error(o(461)),nc=!1;function rc(e,t,n,r){t.child=e===null?Fa(t,null,n,r):Pa(t,e.child,n,r)}function ic(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Xi(t),r=So(e,t,n,o,a,i),s=Eo(),e!==null&&!nc?(Do(e,t,i),Oc(e,t,i)):(Ai&&s&&Ti(t),t.flags|=1,rc(e,t,r,i),t.child)}function ac(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ii(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,oc(e,t,a,r,i)):(e=si(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!kc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?vr:n,n(o,r)&&e.ref===t.ref)return Oc(e,t,i)}return t.flags|=1,e=ai(a,r),e.ref=t.ref,e.return=t,t.child=e}function oc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(vr(a,r)&&e.ref===t.ref)if(nc=!1,t.pendingProps=r=a,kc(e,i))e.flags&131072&&(nc=!0);else return t.lanes=e.lanes,Oc(e,t,i)}return mc(e,t,n,r,i)}function sc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return lc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&ga(t,a===null?null:a.cachePool),a===null?Za():Xa(t,a),ro(t);else return r=t.lanes=536870912,lc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&ga(t,null),Za(),io(t)):(ga(t,a.cachePool),Xa(t,a),io(t),t.memoizedState=null);return rc(e,t,i,n),t.child}function cc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function lc(e,t,n,r,i){var a=ha();return a=a===null?null:{parent:ra._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&ga(t,null),Za(),ro(t),e!==null&&Ji(e,t,r,!0),t.childLanes=i,null}function uc(e,t){return t=Cc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function dc(e,t,n){return Pa(t,e.child,null,n),e=uc(t,t.pendingProps),e.flags|=2,ao(t),t.memoizedState=null,e}function fc(e,t,n){var r=t.pendingProps,i=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(Ai){if(r.mode===`hidden`)return e=uc(t,r),t.lanes=536870912,cc(null,e);if(no(t),(e=ki)?(e=pf(e,Mi),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:bi===null?null:{id:xi,overflow:Si},retryLane:536870912,hydrationErrors:null},n=ui(e),n.return=t,t.child=n,Oi=t,ki=null)):e=null,e===null)throw Pi(t);return t.lanes=536870912,null}return uc(t,r)}var a=e.memoizedState;if(a!==null){var s=a.dehydrated;if(no(t),i)if(t.flags&256)t.flags&=-257,t=dc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if(nc||Ji(e,t,n,!1),i=(n&e.childLanes)!==0,nc||i){if(r=Vl,r!==null&&(s=Xe(r,n),s!==0&&s!==a.retryLane))throw a.retryLane=s,Qr(e,s),xu(r,e,s),tc;Nu(),t=dc(e,t,n)}else e=a.treeContext,ki=_f(s.nextSibling),Oi=t,Ai=!0,ji=null,Mi=!1,e!==null&&Di(t,e),t=uc(t,r),t.flags|=4096;return t}return e=ai(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function pc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(o(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function mc(e,t,n,r,i){return Xi(t),n=So(e,t,n,r,void 0,i),r=Eo(),e!==null&&!nc?(Do(e,t,i),Oc(e,t,i)):(Ai&&r&&Ti(t),t.flags|=1,rc(e,t,n,i),t.child)}function hc(e,t,n,r,i,a){return Xi(t),t.updateQueue=null,n=wo(t,r,n,i),Co(e),r=Eo(),e!==null&&!nc?(Do(e,t,a),Oc(e,t,a)):(Ai&&r&&Ti(t),t.flags|=1,rc(e,t,n,a),t.child)}function gc(e,t,n,r,i){if(Xi(t),t.stateNode===null){var a=ti,o=n.contextType;typeof o==`object`&&o&&(a=Zi(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Hs,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},La(t),o=n.contextType,a.context=typeof o==`object`&&o?Zi(o):ti,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Vs(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Hs.enqueueReplaceState(a,a.state,null),Ga(t,r,a,i),Wa(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Gs(n,s);a.props=c;var l=a.context,u=n.contextType;o=ti,typeof u==`object`&&u&&(o=Zi(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Ws(t,a,r,o),Ia=!1;var f=t.memoizedState;a.state=f,Ga(t,r,a,i),Wa(),l=t.memoizedState,s||f!==l||Ia?(typeof d==`function`&&(Vs(t,n,d,r),l=t.memoizedState),(c=Ia||Us(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Ra(e,t),o=t.memoizedProps,u=Gs(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=ti,typeof l==`object`&&l&&(c=Zi(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Ws(t,a,r,c),Ia=!1,f=t.memoizedState,a.state=f,Ga(t,r,a,i),Wa();var p=t.memoizedState;o!==d||f!==p||Ia||e!==null&&e.dependencies!==null&&Yi(e.dependencies)?(typeof s==`function`&&(Vs(t,n,s,r),p=t.memoizedState),(u=Ia||Us(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Yi(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,pc(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Pa(t,e.child,null,i),t.child=Pa(t,null,n,i)):rc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Oc(e,t,i),e}function _c(e,t,n,r){return Ri(),t.flags|=256,rc(e,t,n,r),t.child}var vc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function yc(e){return{baseLanes:e,cachePool:_a()}}function bc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=eu),e}function xc(e,t,n){var r=t.pendingProps,i=!1,a=(t.flags&128)!=0,s;if((s=a)||(s=e!==null&&e.memoizedState===null?!1:(oo.current&2)!=0),s&&(i=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(Ai){if(i?to(t):io(t),(e=ki)?(e=pf(e,Mi),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:bi===null?null:{id:xi,overflow:Si},retryLane:536870912,hydrationErrors:null},n=ui(e),n.return=t,t.child=n,Oi=t,ki=null)):e=null,e===null)throw Pi(t);return hf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,i?(io(t),i=t.mode,c=Cc({mode:`hidden`,children:c},i),r=ci(r,i,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=yc(n),r.childLanes=bc(e,s,n),t.memoizedState=vc,cc(null,r)):(to(t),Sc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(a)t.flags&256?(to(t),t.flags&=-257,t=wc(e,t,n)):t.memoizedState===null?(io(t),c=r.fallback,i=t.mode,r=Cc({mode:`visible`,children:r.children},i),c=ci(c,i,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Pa(t,e.child,null,n),r=t.child,r.memoizedState=yc(n),r.childLanes=bc(e,s,n),t.memoizedState=vc,t=cc(null,r)):(io(t),t.child=e.child,t.flags|=128,t=null);else if(to(t),hf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(o(419)),r.stack=``,r.digest=s,Bi({value:r,source:null,stack:null}),t=wc(e,t,n)}else if(nc||Ji(e,t,n,!1),s=(n&e.childLanes)!==0,nc||s){if(s=Vl,s!==null&&(r=Xe(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Qr(e,r),xu(s,e,r),tc;mf(c)||Nu(),t=wc(e,t,n)}else mf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,ki=_f(c.nextSibling),Oi=t,Ai=!0,ji=null,Mi=!1,e!==null&&Di(t,e),t=Sc(t,r.children),t.flags|=4096);return t}return i?(io(t),c=r.fallback,i=t.mode,l=e.child,u=l.sibling,r=ai(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=ci(c,i,n,null),c.flags|=2):c=ai(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,cc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=yc(n):(i=c.cachePool,i===null?i=_a():(l=ra._currentValue,i=i.parent===l?i:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:i}),r.memoizedState=c,r.childLanes=bc(e,s,n),t.memoizedState=vc,cc(e.child,r)):(to(t),n=e.child,e=n.sibling,n=ai(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function Sc(e,t){return t=Cc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Cc(e,t){return e=ri(22,e,null,t),e.lanes=0,e}function wc(e,t,n){return Pa(t,e.child,null,n),e=Sc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Tc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ki(e.return,t,n)}function Ec(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function Dc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=oo.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,ee(oo,o),rc(e,t,r,n),r=Ai?_i:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Tc(e,n,t);else if(e.tag===19)Tc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&so(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Ec(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&so(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Ec(t,!0,n,null,a,r);break;case`together`:Ec(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function Oc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Zl|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Ji(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(o(153));if(t.child!==null){for(e=t.child,n=ai(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ai(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function kc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&Yi(e))):!0}function Ac(e,t,n){switch(t.tag){case 3:ae(t,t.stateNode.containerInfo),Wi(t,ra,e.memoizedState.cache),Ri();break;case 27:case 5:se(t);break;case 4:ae(t,t.stateNode.containerInfo);break;case 10:Wi(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,no(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(to(t),e=Oc(e,t,n),e===null?null:e.sibling):xc(e,t,n):(to(t),t.flags|=128,null);to(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(Ji(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return Dc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),ee(oo,oo.current),r)break;return null;case 22:return t.lanes=0,sc(e,t,n,t.pendingProps);case 24:Wi(t,ra,e.memoizedState.cache)}return Oc(e,t,n)}function jc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)nc=!0;else{if(!kc(e,n)&&!(t.flags&128))return nc=!1,Ac(e,t,n);nc=!!(e.flags&131072)}else nc=!1,Ai&&t.flags&1048576&&wi(t,_i,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=wa(t.elementType),t.type=e,typeof e==`function`)ii(e)?(r=Gs(e,r),t.tag=1,t=gc(null,t,e,r,n)):(t.tag=0,t=mc(null,t,e,r,n));else{if(e!=null){var i=e.$$typeof;if(i===C){t.tag=11,t=ic(null,t,e,r,n);break a}else if(i===E){t.tag=14,t=ac(null,t,e,r,n);break a}}throw t=N(e)||e,Error(o(306,t,``))}}return t;case 0:return mc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,i=Gs(r,t.pendingProps),gc(e,t,r,i,n);case 3:a:{if(ae(t,t.stateNode.containerInfo),e===null)throw Error(o(387));r=t.pendingProps;var a=t.memoizedState;i=a.element,Ra(e,t),Ga(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Wi(t,ra,r),r!==a.cache&&qi(t,[ra],n,!0),Wa(),r=s.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){t=_c(e,t,r,n);break a}else if(r!==i){i=pi(Error(o(424)),t),Bi(i),t=_c(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(ki=_f(e.firstChild),Oi=t,Ai=!0,ji=null,Mi=!0,n=Fa(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ri(),r===i){t=Oc(e,t,n);break a}rc(e,t,r,n)}t=t.child}return t;case 26:return pc(e,t),e===null?(n=Rf(t.type,null,t.pendingProps,null))?t.memoizedState=n:Ai||(n=t.type,e=t.pendingProps,r=Yd(re.current).createElement(n),r[nt]=t,r[rt]=e,Ud(r,n,e),ht(r),t.stateNode=r):t.memoizedState=Rf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return se(t),e===null&&Ai&&(r=t.stateNode=xf(t.type,t.pendingProps,re.current),Oi=t,Mi=!0,i=ki,sf(t.type)?(vf=i,ki=_f(r.firstChild)):ki=i),rc(e,t,t.pendingProps.children,n),pc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Ai&&((i=r=ki)&&(r=df(r,t.type,t.pendingProps,Mi),r===null?i=!1:(t.stateNode=r,Oi=t,ki=_f(r.firstChild),Mi=!1,i=!0)),i||Pi(t)),se(t),i=t.type,a=t.pendingProps,s=e===null?null:e.memoizedProps,r=a.children,Qd(i,a)?r=null:s!==null&&Qd(i,s)&&(t.flags|=32),t.memoizedState!==null&&(i=So(e,t,To,null,null,n),sp._currentValue=i),pc(e,t),rc(e,t,r,n),t.child;case 6:return e===null&&Ai&&((e=n=ki)&&(n=ff(n,t.pendingProps,Mi),n===null?e=!1:(t.stateNode=n,Oi=t,ki=null,e=!0)),e||Pi(t)),null;case 13:return xc(e,t,n);case 4:return ae(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Pa(t,null,r,n):rc(e,t,r,n),t.child;case 11:return ic(e,t,t.type,t.pendingProps,n);case 7:return rc(e,t,t.pendingProps,n),t.child;case 8:return rc(e,t,t.pendingProps.children,n),t.child;case 12:return rc(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Wi(t,t.type,r.value),rc(e,t,r.children,n),t.child;case 9:return i=t.type._context,r=t.pendingProps.children,Xi(t),i=Zi(i),r=r(i),t.flags|=1,rc(e,t,r,n),t.child;case 14:return ac(e,t,t.type,t.pendingProps,n);case 15:return oc(e,t,t.type,t.pendingProps,n);case 19:return Dc(e,t,n);case 31:return fc(e,t,n);case 22:return sc(e,t,n,t.pendingProps);case 24:return Xi(t),r=Zi(ra),e===null?(i=ha(),i===null&&(i=Vl,a=ia(),i.pooledCache=a,a.refCount++,a!==null&&(i.pooledCacheLanes|=n),i=a),t.memoizedState={parent:r,cache:i},La(t),Wi(t,ra,i)):((e.lanes&n)!==0&&(Ra(e,t),Ga(t,null,null,n),Wa()),i=e.memoizedState,a=t.memoizedState,i.parent===r?(r=a.cache,Wi(t,ra,r),r!==i.cache&&qi(t,[ra],n,!0)):(i={parent:r,cache:r},t.memoizedState=i,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=i),Wi(t,ra,r))),rc(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function Mc(e){e.flags|=4}function Nc(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(Au())e.flags|=8192;else throw Ta=xa,ya}else e.flags&=-16777217}function Pc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!$f(t))if(Au())e.flags|=8192;else throw Ta=xa,ya}function Fc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:We(),e.lanes|=t,tu|=t)}function Ic(e,t){if(!Ai)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Lc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Rc(e,t,n){var r=t.pendingProps;switch(Ei(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Lc(t),null;case 1:return Lc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Gi(ra),oe(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Li(t)?Mc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,zi())),Lc(t),null;case 26:var i=t.type,a=t.memoizedState;return e===null?(Mc(t),a===null?(Lc(t),Nc(t,i,null,r,n)):(Lc(t),Pc(t,a))):a?a===e.memoizedState?(Lc(t),t.flags&=-16777217):(Mc(t),Lc(t),Pc(t,a)):(e=e.memoizedProps,e!==r&&Mc(t),Lc(t),Nc(t,i,e,r,n)),null;case 27:if(ce(t),n=re.current,i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Mc(t);else{if(!r){if(t.stateNode===null)throw Error(o(166));return Lc(t),null}e=te.current,Li(t)?Fi(t,e):(e=xf(i,r,n),t.stateNode=e,Mc(t))}return Lc(t),null;case 5:if(ce(t),i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Mc(t);else{if(!r){if(t.stateNode===null)throw Error(o(166));return Lc(t),null}if(a=te.current,Li(t))Fi(t,a);else{var s=Yd(re.current);switch(a){case 1:a=s.createElementNS(`http://www.w3.org/2000/svg`,i);break;case 2:a=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;default:switch(i){case`svg`:a=s.createElementNS(`http://www.w3.org/2000/svg`,i);break;case`math`:a=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;case`script`:a=s.createElement(`div`),a.innerHTML=`<script><\/script>`,a=a.removeChild(a.firstChild);break;case`select`:a=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?a.multiple=!0:r.size&&(a.size=r.size);break;default:a=typeof r.is==`string`?s.createElement(i,{is:r.is}):s.createElement(i)}}a[nt]=t,a[rt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)a.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=a;a:switch(Ud(a,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Mc(t)}}return Lc(t),Nc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Mc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(o(166));if(e=re.current,Li(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=Oi,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[nt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Bd(e.nodeValue,n)),e||Pi(t,!0)}else e=Yd(e).createTextNode(r),e[nt]=t,t.stateNode=e}return Lc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Li(t),n!==null){if(e===null){if(!r)throw Error(o(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(557));e[nt]=t}else Ri(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Lc(t),e=!1}else n=zi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(ao(t),t):(ao(t),null);if(t.flags&128)throw Error(o(558))}return Lc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=Li(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(o(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(o(317));i[nt]=t}else Ri(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Lc(t),i=!1}else i=zi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(ao(t),t):(ao(t),null)}return ao(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),a=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(a=r.memoizedState.cachePool.pool),a!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Fc(t,t.updateQueue),Lc(t),null);case 4:return oe(),e===null&&Ad(t.stateNode.containerInfo),Lc(t),null;case 10:return Gi(t.type),Lc(t),null;case 19:if(V(oo),r=t.memoizedState,r===null)return Lc(t),null;if(i=(t.flags&128)!=0,a=r.rendering,a===null)if(i)Ic(r,!1);else{if(Xl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=so(e),a!==null){for(t.flags|=128,Ic(r,!1),e=a.updateQueue,t.updateQueue=e,Fc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)oi(n,e),n=n.sibling;return ee(oo,oo.current&1|2),Ai&&Ci(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&xe()>su&&(t.flags|=128,i=!0,Ic(r,!1),t.lanes=4194304)}else{if(!i)if(e=so(a),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,Fc(t,e),Ic(r,!0),r.tail===null&&r.tailMode===`hidden`&&!a.alternate&&!Ai)return Lc(t),null}else 2*xe()-r.renderingStartTime>su&&n!==536870912&&(t.flags|=128,i=!0,Ic(r,!1),t.lanes=4194304);r.isBackwards?(a.sibling=t.child,t.child=a):(e=r.last,e===null?t.child=a:e.sibling=a,r.last=a)}return r.tail===null?(Lc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=xe(),e.sibling=null,n=oo.current,ee(oo,i?n&1|2:n&1),Ai&&Ci(t,r.treeForkCount),e);case 22:case 23:return ao(t),Qa(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Lc(t),t.subtreeFlags&6&&(t.flags|=8192)):Lc(t),n=t.updateQueue,n!==null&&Fc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&V(ma),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Gi(ra),Lc(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function zc(e,t){switch(Ei(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Gi(ra),oe(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ce(t),null;case 31:if(t.memoizedState!==null){if(ao(t),t.alternate===null)throw Error(o(340));Ri()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(ao(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Ri()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return V(oo),null;case 4:return oe(),null;case 10:return Gi(t.type),null;case 22:case 23:return ao(t),Qa(),e!==null&&V(ma),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Gi(ra),null;case 25:return null;default:return null}}function Bc(e,t){switch(Ei(t),t.tag){case 3:Gi(ra),oe();break;case 26:case 27:case 5:ce(t);break;case 4:oe();break;case 31:t.memoizedState!==null&&ao(t);break;case 13:ao(t);break;case 19:V(oo);break;case 10:Gi(t.type);break;case 22:case 23:ao(t),Qa(),e!==null&&V(ma);break;case 24:Gi(ra)}}function Vc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Zu(t,t.return,e)}}function Hc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Zu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Zu(t,t.return,e)}}function Uc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{qa(t,n)}catch(t){Zu(e,e.return,t)}}}function Wc(e,t,n){n.props=Gs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Zu(e,t,n)}}function Gc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Zu(e,t,n)}}function Kc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Zu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Zu(e,t,n)}else n.current=null}function qc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Zu(e,e.return,t)}}function Jc(e,t,n){try{var r=e.stateNode;Wd(r,e.type,n,t),r[rt]=t}catch(t){Zu(e,e.return,t)}}function Yc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&sf(e.type)||e.tag===4}function Xc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Yc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&sf(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Zc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Yt));else if(r!==4&&(r===27&&sf(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Zc(e,t,n),e=e.sibling;e!==null;)Zc(e,t,n),e=e.sibling}function Qc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&sf(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Qc(e,t,n),e=e.sibling;e!==null;)Qc(e,t,n),e=e.sibling}function $c(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Ud(t,r,n),t[nt]=e,t[rt]=n}catch(t){Zu(e,e.return,t)}}var el=!1,tl=!1,nl=!1,rl=typeof WeakSet==`function`?WeakSet:Set,il=null;function al(e,t){if(e=e.containerInfo,qd=gp,e=Sr(e),Cr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||i!==0&&f.nodeType!==3||(c=s+i),f!==a||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===i&&(c=s),p===a&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Jd={focusedElem:e,selectionRange:n},gp=!1,il=t;il!==null;)if(t=il,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,il=e;else for(;il!==null;){switch(t=il,a=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)i=e[n],i.ref.impl=i.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&a!==null){e=void 0,n=t,i=a.memoizedProps,a=a.memoizedState,r=n.stateNode;try{var h=Gs(n.type,i);e=r.getSnapshotBeforeUpdate(h,a),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Zu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)uf(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:uf(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(o(163))}if(e=t.sibling,e!==null){e.return=t.return,il=e;break}il=t.return}}function ol(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:xl(e,n),r&4&&Vc(5,n);break;case 1:if(xl(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Zu(n,n.return,e)}else{var i=Gs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Zu(n,n.return,e)}}r&64&&Uc(n),r&512&&Gc(n,n.return);break;case 3:if(xl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{qa(e,t)}catch(e){Zu(n,n.return,e)}}break;case 27:t===null&&r&4&&$c(n);case 26:case 5:xl(e,n),t===null&&r&4&&qc(n),r&512&&Gc(n,n.return);break;case 12:xl(e,n);break;case 31:xl(e,n),r&4&&fl(e,n);break;case 13:xl(e,n),r&4&&pl(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=td.bind(null,n),gf(e,n))));break;case 22:if(r=n.memoizedState!==null||el,!r){t=t!==null&&t.memoizedState!==null||tl,i=el;var a=tl;el=r,(tl=t)&&!a?Cl(e,n,(n.subtreeFlags&8772)!=0):xl(e,n),el=i,tl=a}break;case 30:break;default:xl(e,n)}}function sl(e){var t=e.alternate;t!==null&&(e.alternate=null,sl(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&ut(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var cl=null,ll=!1;function ul(e,t,n){for(n=n.child;n!==null;)dl(e,t,n),n=n.sibling}function dl(e,t,n){if(je&&typeof je.onCommitFiberUnmount==`function`)try{je.onCommitFiberUnmount(Ae,n)}catch{}switch(n.tag){case 26:tl||Kc(n,t),ul(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:tl||Kc(n,t);var r=cl,i=ll;sf(n.type)&&(cl=n.stateNode,ll=!1),ul(e,t,n),Sf(n.stateNode),cl=r,ll=i;break;case 5:tl||Kc(n,t);case 6:if(r=cl,i=ll,cl=null,ul(e,t,n),cl=r,ll=i,cl!==null)if(ll)try{(cl.nodeType===9?cl.body:cl.nodeName===`HTML`?cl.ownerDocument.body:cl).removeChild(n.stateNode)}catch(e){Zu(n,t,e)}else try{cl.removeChild(n.stateNode)}catch(e){Zu(n,t,e)}break;case 18:cl!==null&&(ll?(e=cl,cf(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Hp(e)):cf(cl,n.stateNode));break;case 4:r=cl,i=ll,cl=n.stateNode.containerInfo,ll=!0,ul(e,t,n),cl=r,ll=i;break;case 0:case 11:case 14:case 15:Hc(2,n,t),tl||Hc(4,n,t),ul(e,t,n);break;case 1:tl||(Kc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Wc(n,t,r)),ul(e,t,n);break;case 21:ul(e,t,n);break;case 22:tl=(r=tl)||n.memoizedState!==null,ul(e,t,n),tl=r;break;default:ul(e,t,n)}}function fl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Hp(e)}catch(e){Zu(t,t.return,e)}}}function pl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Hp(e)}catch(e){Zu(t,t.return,e)}}function ml(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new rl),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new rl),t;default:throw Error(o(435,e.tag))}}function hl(e,t){var n=ml(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=nd.bind(null,e,t);t.then(r,r)}})}function gl(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r],a=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(sf(c.type)){cl=c.stateNode,ll=!1;break a}break;case 5:cl=c.stateNode,ll=!1;break a;case 3:case 4:cl=c.stateNode.containerInfo,ll=!0;break a}c=c.return}if(cl===null)throw Error(o(160));dl(a,s,i),cl=null,ll=!1,a=i.alternate,a!==null&&(a.return=null),i.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)vl(t,e),t=t.sibling}var _l=null;function vl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:gl(t,e),yl(e),r&4&&(Hc(3,e,e.return),Vc(3,e),Hc(5,e,e.return));break;case 1:gl(t,e),yl(e),r&512&&(tl||n===null||Kc(n,n.return)),r&64&&el&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var i=_l;if(gl(t,e),yl(e),r&512&&(tl||n===null||Kc(n,n.return)),r&4){var a=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,i=i.ownerDocument||i;b:switch(r){case`title`:a=i.getElementsByTagName(`title`)[0],(!a||a[lt]||a[nt]||a.namespaceURI===`http://www.w3.org/2000/svg`||a.hasAttribute(`itemprop`))&&(a=i.createElement(r),i.head.insertBefore(a,i.querySelector(`head > title`))),Ud(a,r,n),a[nt]=e,ht(a),r=a;break a;case`link`:var s=Xf(`link`,`href`,i).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(a=s[c],a.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&a.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&a.getAttribute(`title`)===(n.title==null?null:n.title)&&a.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}a=i.createElement(r),Ud(a,r,n),i.head.appendChild(a);break;case`meta`:if(s=Xf(`meta`,`content`,i).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(a=s[c],a.getAttribute(`content`)===(n.content==null?null:``+n.content)&&a.getAttribute(`name`)===(n.name==null?null:n.name)&&a.getAttribute(`property`)===(n.property==null?null:n.property)&&a.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&a.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}a=i.createElement(r),Ud(a,r,n),i.head.appendChild(a);break;default:throw Error(o(468,r))}a[nt]=e,ht(a),r=a}e.stateNode=r}else Zf(i,e.type,e.stateNode);else e.stateNode=Gf(i,r,e.memoizedProps);else a===r?r===null&&e.stateNode!==null&&Jc(e,e.memoizedProps,n.memoizedProps):(a===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):a.count--,r===null?Zf(i,e.type,e.stateNode):Gf(i,r,e.memoizedProps))}break;case 27:gl(t,e),yl(e),r&512&&(tl||n===null||Kc(n,n.return)),n!==null&&r&4&&Jc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(gl(t,e),yl(e),r&512&&(tl||n===null||Kc(n,n.return)),e.flags&32){i=e.stateNode;try{Vt(i,``)}catch(t){Zu(e,e.return,t)}}r&4&&e.stateNode!=null&&(i=e.memoizedProps,Jc(e,i,n===null?i:n.memoizedProps)),r&1024&&(nl=!0);break;case 6:if(gl(t,e),yl(e),r&4){if(e.stateNode===null)throw Error(o(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Zu(e,e.return,t)}}break;case 3:if(Yf=null,i=_l,_l=Tf(t.containerInfo),gl(t,e),_l=i,yl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Hp(t.containerInfo)}catch(t){Zu(e,e.return,t)}nl&&(nl=!1,bl(e));break;case 4:r=_l,_l=Tf(e.stateNode.containerInfo),gl(t,e),yl(e),_l=r;break;case 12:gl(t,e),yl(e);break;case 31:gl(t,e),yl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,hl(e,r)));break;case 13:gl(t,e),yl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(au=xe()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,hl(e,r)));break;case 22:i=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=el,d=tl;if(el=u||i,tl=d||l,gl(t,e),tl=d,el=u,yl(e),r&8192)a:for(t=e.stateNode,t._visibility=i?t._visibility&-2:t._visibility|1,i&&(n===null||l||el||tl||Sl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(a=l.stateNode,i)s=a.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Zu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=i?``:l.memoizedProps}catch(e){Zu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;i?lf(m,!0):lf(l.stateNode,!1)}catch(e){Zu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,hl(e,n))));break;case 19:gl(t,e),yl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,hl(e,r)));break;case 30:break;case 21:break;default:gl(t,e),yl(e)}}function yl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Yc(r)){n=r;break}r=r.return}if(n==null)throw Error(o(160));switch(n.tag){case 27:var i=n.stateNode;Qc(e,Xc(e),i);break;case 5:var a=n.stateNode;n.flags&32&&(Vt(a,``),n.flags&=-33),Qc(e,Xc(e),a);break;case 3:case 4:var s=n.stateNode.containerInfo;Zc(e,Xc(e),s);break;default:throw Error(o(161))}}catch(t){Zu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function bl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;bl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function xl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)ol(e,t.alternate,t),t=t.sibling}function Sl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Hc(4,t,t.return),Sl(t);break;case 1:Kc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Wc(t,t.return,n),Sl(t);break;case 27:Sf(t.stateNode);case 26:case 5:Kc(t,t.return),Sl(t);break;case 22:t.memoizedState===null&&Sl(t);break;case 30:Sl(t);break;default:Sl(t)}e=e.sibling}}function Cl(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:Cl(i,a,n),Vc(4,a);break;case 1:if(Cl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Zu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Ka(c[i],s)}catch(e){Zu(r,r.return,e)}}n&&o&64&&Uc(a),Gc(a,a.return);break;case 27:$c(a);case 26:case 5:Cl(i,a,n),n&&r===null&&o&4&&qc(a),Gc(a,a.return);break;case 12:Cl(i,a,n);break;case 31:Cl(i,a,n),n&&o&4&&fl(i,a);break;case 13:Cl(i,a,n),n&&o&4&&pl(i,a);break;case 22:a.memoizedState===null&&Cl(i,a,n),Gc(a,a.return);break;case 30:break;default:Cl(i,a,n)}t=t.sibling}}function wl(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&aa(n))}function Tl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&aa(e))}function El(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Dl(e,t,n,r),t=t.sibling}function Dl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:El(e,t,n,r),i&2048&&Vc(9,t);break;case 1:El(e,t,n,r);break;case 3:El(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&aa(e)));break;case 12:if(i&2048){El(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Zu(t,t.return,e)}}else El(e,t,n,r);break;case 31:El(e,t,n,r);break;case 13:El(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?El(e,t,n,r):(a._visibility|=2,Ol(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?El(e,t,n,r):kl(e,t),i&2048&&wl(o,t);break;case 24:El(e,t,n,r),i&2048&&Tl(t.alternate,t);break;default:El(e,t,n,r)}}function Ol(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Ol(a,o,s,c,i),Vc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Ol(a,o,s,c,i)):u._visibility&2?Ol(a,o,s,c,i):kl(a,o),i&&l&2048&&wl(o.alternate,o);break;case 24:Ol(a,o,s,c,i),i&&l&2048&&Tl(o.alternate,o);break;default:Ol(a,o,s,c,i)}t=t.sibling}}function kl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:kl(n,r),i&2048&&wl(r.alternate,r);break;case 24:kl(n,r),i&2048&&Tl(r.alternate,r);break;default:kl(n,r)}t=t.sibling}}var Al=8192;function jl(e,t,n){if(e.subtreeFlags&Al)for(e=e.child;e!==null;)Ml(e,t,n),e=e.sibling}function Ml(e,t,n){switch(e.tag){case 26:jl(e,t,n),e.flags&Al&&e.memoizedState!==null&&ep(n,_l,e.memoizedState,e.memoizedProps);break;case 5:jl(e,t,n);break;case 3:case 4:var r=_l;_l=Tf(e.stateNode.containerInfo),jl(e,t,n),_l=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Al,Al=16777216,jl(e,t,n),Al=r):jl(e,t,n));break;default:jl(e,t,n)}}function Nl(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Pl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];il=r,Ll(r,e)}Nl(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Fl(e),e=e.sibling}function Fl(e){switch(e.tag){case 0:case 11:case 15:Pl(e),e.flags&2048&&Hc(9,e,e.return);break;case 3:Pl(e);break;case 12:Pl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Il(e)):Pl(e);break;default:Pl(e)}}function Il(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];il=r,Ll(r,e)}Nl(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Hc(8,t,t.return),Il(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Il(t));break;default:Il(t)}e=e.sibling}}function Ll(e,t){for(;il!==null;){var n=il;switch(n.tag){case 0:case 11:case 15:Hc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:aa(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,il=r;else a:for(n=e;il!==null;){r=il;var i=r.sibling,a=r.return;if(sl(r),r===n){il=null;break a}if(i!==null){i.return=a,il=i;break a}il=a}}}var Rl={getCacheForType:function(e){var t=Zi(ra),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Zi(ra).controller.signal}},zl=typeof WeakMap==`function`?WeakMap:Map,Bl=0,Vl=null,Hl=null,Ul=0,Wl=0,Gl=null,Kl=!1,ql=!1,Jl=!1,Yl=0,Xl=0,Zl=0,Ql=0,$l=0,eu=0,tu=0,nu=null,ru=null,iu=!1,au=0,ou=0,su=1/0,cu=null,lu=null,uu=0,du=null,fu=null,pu=0,mu=0,hu=null,gu=null,_u=0,vu=null;function yu(){return Bl&2&&Ul!==0?Ul&-Ul:F.T===null?$e():vd()}function bu(){if(eu===0)if(!(Ul&536870912)||Ai){var e=Re;Re<<=1,!(Re&3932160)&&(Re=262144),eu=e}else eu=536870912;return e=$a.current,e!==null&&(e.flags|=32),eu}function xu(e,t,n){(e===Vl&&(Wl===2||Wl===9)||e.cancelPendingCommit!==null)&&(Ou(e,0),Tu(e,Ul,eu,!1)),Ke(e,n),(!(Bl&2)||e!==Vl)&&(e===Vl&&(!(Bl&2)&&(Ql|=n),Xl===4&&Tu(e,Ul,eu,!1)),ud(e))}function Su(e,t,n){if(Bl&6)throw Error(o(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||He(e,t),i=r?Iu(e,t):Pu(e,t,!0),a=r;do{if(i===0){ql&&!r&&Tu(e,t,0,!1);break}else{if(n=e.current.alternate,a&&!wu(n)){i=Pu(e,t,!1),a=!1;continue}if(i===2){if(a=t,e.errorRecoveryDisabledLanes&a)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;i=nu;var l=c.current.memoizedState.isDehydrated;if(l&&(Ou(c,s).flags|=256),s=Pu(c,s,!1),s!==2){if(Jl&&!l){c.errorRecoveryDisabledLanes|=a,Ql|=a,i=4;break a}a=ru,ru=i,a!==null&&(ru===null?ru=a:ru.push.apply(ru,a))}i=s}if(a=!1,i!==2)continue}}if(i===1){Ou(e,0),Tu(e,t,0,!0);break}a:{switch(r=e,a=i,a){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t)break;case 6:Tu(r,t,eu,!Kl);break a;case 2:ru=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(i=au+300-xe(),10<i)){if(Tu(r,t,eu,!Kl),Ve(r,0,!0)!==0)break a;pu=t,r.timeoutHandle=tf(Cu.bind(null,r,n,ru,cu,iu,t,eu,Ql,tu,Kl,a,`Throttled`,-0,0),i);break a}Cu(r,n,ru,cu,iu,t,eu,Ql,tu,Kl,a,null,-0,0)}}break}while(1);ud(e)}function Cu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Yt},Ml(t,a,d);var m=(a&62914560)===a?au-xe():(a&4194048)===a?ou-xe():0;if(m=np(d,m),m!==null){pu=a,e.cancelPendingCommit=m(Uu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),Tu(e,a,o,!l);return}}Uu(e,t,a,n,r,i,o,s,c)}function wu(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!_r(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Tu(e,t,n,r){t&=~$l,t&=~Ql,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Ne(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&Je(e,n,t)}function Eu(){return Bl&6?!0:(dd(0,!1),!1)}function Du(){if(Hl!==null){if(Wl===0)var e=Hl.return;else e=Hl,Ui=Hi=null,Oo(e),Oa=null,ka=0,e=Hl;for(;e!==null;)Bc(e.alternate,e),e=e.return;Hl=null}}function Ou(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,nf(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),pu=0,Du(),Vl=e,Hl=n=ai(e.current,null),Ul=t,Wl=0,Gl=null,Kl=!1,ql=He(e,t),Jl=!1,tu=eu=$l=Ql=Zl=Xl=0,ru=nu=null,iu=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Ne(r),a=1<<i;t|=e[i],r&=~a}return Yl=t,Yr(),n}function ku(e,t){lo=null,F.H=Ls,t===va||t===ba?(t=Ea(),Wl=3):t===ya?(t=Ea(),Wl=4):Wl=t===tc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Gl=t,Hl===null&&(Xl=1,Ys(e,pi(t,e.current)))}function Au(){var e=$a.current;return e===null?!0:(Ul&4194048)===Ul?eo===null:(Ul&62914560)===Ul||Ul&536870912?e===eo:!1}function ju(){var e=F.H;return F.H=Ls,e===null?Ls:e}function Mu(){var e=F.A;return F.A=Rl,e}function Nu(){Xl=4,Kl||(Ul&4194048)!==Ul&&$a.current!==null||(ql=!0),!(Zl&134217727)&&!(Ql&134217727)||Vl===null||Tu(Vl,Ul,eu,!1)}function Pu(e,t,n){var r=Bl;Bl|=2;var i=ju(),a=Mu();(Vl!==e||Ul!==t)&&(cu=null,Ou(e,t)),t=!1;var o=Xl;a:do try{if(Wl!==0&&Hl!==null){var s=Hl,c=Gl;switch(Wl){case 8:Du(),o=6;break a;case 3:case 2:case 9:case 6:$a.current===null&&(t=!0);var l=Wl;if(Wl=0,Gl=null,Bu(e,s,c,l),n&&ql){o=0;break a}break;default:l=Wl,Wl=0,Gl=null,Bu(e,s,c,l)}}Fu(),o=Xl;break}catch(t){ku(e,t)}while(1);return t&&e.shellSuspendCounter++,Ui=Hi=null,Bl=r,F.H=i,F.A=a,Hl===null&&(Vl=null,Ul=0,Yr()),o}function Fu(){for(;Hl!==null;)Ru(Hl)}function Iu(e,t){var n=Bl;Bl|=2;var r=ju(),i=Mu();Vl!==e||Ul!==t?(cu=null,su=xe()+500,Ou(e,t)):ql=He(e,t);a:do try{if(Wl!==0&&Hl!==null){t=Hl;var a=Gl;b:switch(Wl){case 1:Wl=0,Gl=null,Bu(e,t,a,1);break;case 2:case 9:if(Sa(a)){Wl=0,Gl=null,zu(t);break}t=function(){Wl!==2&&Wl!==9||Vl!==e||(Wl=7),ud(e)},a.then(t,t);break a;case 3:Wl=7;break a;case 4:Wl=5;break a;case 7:Sa(a)?(Wl=0,Gl=null,zu(t)):(Wl=0,Gl=null,Bu(e,t,a,7));break;case 5:var s=null;switch(Hl.tag){case 26:s=Hl.memoizedState;case 5:case 27:var c=Hl;if(s?$f(s):c.stateNode.complete){Wl=0,Gl=null;var l=c.sibling;if(l!==null)Hl=l;else{var u=c.return;u===null?Hl=null:(Hl=u,Vu(u))}break b}}Wl=0,Gl=null,Bu(e,t,a,5);break;case 6:Wl=0,Gl=null,Bu(e,t,a,6);break;case 8:Du(),Xl=6;break a;default:throw Error(o(462))}}Lu();break}catch(t){ku(e,t)}while(1);return Ui=Hi=null,F.H=r,F.A=i,Bl=n,Hl===null?(Vl=null,Ul=0,Yr(),Xl):0}function Lu(){for(;Hl!==null&&!ye();)Ru(Hl)}function Ru(e){var t=jc(e.alternate,e,Yl);e.memoizedProps=e.pendingProps,t===null?Vu(e):Hl=t}function zu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=hc(n,t,t.pendingProps,t.type,void 0,Ul);break;case 11:t=hc(n,t,t.pendingProps,t.type.render,t.ref,Ul);break;case 5:Oo(t);default:Bc(n,t),t=Hl=oi(t,Yl),t=jc(n,t,Yl)}e.memoizedProps=e.pendingProps,t===null?Vu(e):Hl=t}function Bu(e,t,n,r){Ui=Hi=null,Oo(t),Oa=null,ka=0;var i=t.return;try{if(ec(e,i,t,n,Ul)){Xl=1,Ys(e,pi(n,e.current)),Hl=null;return}}catch(t){if(i!==null)throw Hl=i,t;Xl=1,Ys(e,pi(n,e.current)),Hl=null;return}t.flags&32768?(Ai||r===1?e=!0:ql||Ul&536870912?e=!1:(Kl=e=!0,(r===2||r===9||r===3||r===6)&&(r=$a.current,r!==null&&r.tag===13&&(r.flags|=16384))),Hu(t,e)):Vu(t)}function Vu(e){var t=e;do{if(t.flags&32768){Hu(t,Kl);return}e=t.return;var n=Rc(t.alternate,t,Yl);if(n!==null){Hl=n;return}if(t=t.sibling,t!==null){Hl=t;return}Hl=t=e}while(t!==null);Xl===0&&(Xl=5)}function Hu(e,t){do{var n=zc(e.alternate,e);if(n!==null){n.flags&=32767,Hl=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Hl=e;return}Hl=e=n}while(e!==null);Xl=6,Hl=null}function Uu(e,t,n,r,i,a,s,c,l){e.cancelPendingCommit=null;do Ju();while(uu!==0);if(Bl&6)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(a=t.lanes|t.childLanes,a|=Jr,qe(e,n,a,s,c,l),e===Vl&&(Hl=Vl=null,Ul=0),fu=t,du=e,pu=n,mu=a,hu=i,gu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,rd(Te,function(){return Yu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=F.T,F.T=null,i=I.p,I.p=2,s=Bl,Bl|=4;try{al(e,t,n)}finally{Bl=s,I.p=i,F.T=r}}uu=1,Wu(),Gu(),Ku()}}function Wu(){if(uu===1){uu=0;var e=du,t=fu,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=F.T,F.T=null;var r=I.p;I.p=2;var i=Bl;Bl|=4;try{vl(t,e);var a=Jd,o=Sr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&xr(s.ownerDocument.documentElement,s)){if(c!==null&&Cr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=br(s,h),v=br(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}gp=!!qd,Jd=qd=null}finally{Bl=i,I.p=r,F.T=n}}e.current=t,uu=2}}function Gu(){if(uu===2){uu=0;var e=du,t=fu,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=F.T,F.T=null;var r=I.p;I.p=2;var i=Bl;Bl|=4;try{ol(e,t.alternate,t)}finally{Bl=i,I.p=r,F.T=n}}uu=3}}function Ku(){if(uu===4||uu===3){uu=0,be();var e=du,t=fu,n=pu,r=gu;t.subtreeFlags&10256||t.flags&10256?uu=5:(uu=0,fu=du=null,qu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(lu=null),Qe(n),t=t.stateNode,je&&typeof je.onCommitFiberRoot==`function`)try{je.onCommitFiberRoot(Ae,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=F.T,i=I.p,I.p=2,F.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{F.T=t,I.p=i}}pu&3&&Ju(),ud(e),i=e.pendingLanes,n&261930&&i&42?e===vu?_u++:(_u=0,vu=e):_u=0,dd(0,!1)}}function qu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,aa(t)))}function Ju(){return Wu(),Gu(),Ku(),Yu()}function Yu(){if(uu!==5)return!1;var e=du,t=mu;mu=0;var n=Qe(pu),r=F.T,i=I.p;try{I.p=32>n?32:n,F.T=null,n=hu,hu=null;var a=du,s=pu;if(uu=0,fu=du=null,pu=0,Bl&6)throw Error(o(331));var c=Bl;if(Bl|=4,Fl(a.current),Dl(a,a.current,s,n),Bl=c,dd(0,!1),je&&typeof je.onPostCommitFiberRoot==`function`)try{je.onPostCommitFiberRoot(Ae,a)}catch{}return!0}finally{I.p=i,F.T=r,qu(e,t)}}function Xu(e,t,n){t=pi(n,t),t=Zs(e.stateNode,t,2),e=Ba(e,t,2),e!==null&&(Ke(e,2),ud(e))}function Zu(e,t,n){if(e.tag===3)Xu(e,e,n);else for(;t!==null;){if(t.tag===3){Xu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(lu===null||!lu.has(r))){e=pi(n,e),n=Qs(2),r=Ba(t,n,2),r!==null&&($s(n,r,t,e),Ke(r,2),ud(r));break}}t=t.return}}function Qu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new zl;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Jl=!0,i.add(n),e=$u.bind(null,e,t,n),t.then(e,e))}function $u(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Vl===e&&(Ul&n)===n&&(Xl===4||Xl===3&&(Ul&62914560)===Ul&&300>xe()-au?!(Bl&2)&&Ou(e,0):$l|=n,tu===Ul&&(tu=0)),ud(e)}function ed(e,t){t===0&&(t=We()),e=Qr(e,t),e!==null&&(Ke(e,t),ud(e))}function td(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),ed(e,n)}function nd(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(o(314))}r!==null&&r.delete(t),ed(e,n)}function rd(e,t){return _e(e,t)}var id=null,ad=null,od=!1,sd=!1,cd=!1,ld=0;function ud(e){e!==ad&&e.next===null&&(ad===null?id=ad=e:ad=ad.next=e),sd=!0,od||(od=!0,_d())}function dd(e,t){if(!cd&&sd){cd=!0;do for(var n=!1,r=id;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Ne(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,gd(r,a))}else a=Ul,a=Ve(r,r===Vl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||He(r,a)||(n=!0,gd(r,a));r=r.next}while(n);cd=!1}}function fd(){pd()}function pd(){sd=od=!1;var e=0;ld!==0&&ef()&&(e=ld);for(var t=xe(),n=null,r=id;r!==null;){var i=r.next,a=md(r,t);a===0?(r.next=null,n===null?id=i:n.next=i,i===null&&(ad=n)):(n=r,(e!==0||a&3)&&(sd=!0)),r=i}uu!==0&&uu!==5||dd(e,!1),ld!==0&&(ld=0)}function md(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Ne(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Ue(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Vl,n=Ul,n=Ve(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Wl===2||Wl===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&ve(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||He(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&ve(r),Qe(n)){case 2:case 8:n=we;break;case 32:n=Te;break;case 268435456:n=De;break;default:n=Te}return r=hd.bind(null,e),n=_e(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&ve(r),e.callbackPriority=2,e.callbackNode=null,2}function hd(e,t){if(uu!==0&&uu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Ju()&&e.callbackNode!==n)return null;var r=Ul;return r=Ve(e,e===Vl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Su(e,r,t),md(e,xe()),e.callbackNode!=null&&e.callbackNode===n?hd.bind(null,e):null)}function gd(e,t){if(Ju())return null;Su(e,t,!0)}function _d(){af(function(){Bl&6?_e(Ce,fd):pd()})}function vd(){if(ld===0){var e=ca;e===0&&(e=Le,Le<<=1,!(Le&261888)&&(Le=256)),ld=e}return ld}function yd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:Jt(``+e)}function bd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function xd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=yd((i[rt]||null).action),o=r.submitter;o&&(t=(t=o[rt]||null)?yd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new gn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(ld!==0){var e=o?bd(i,o):new FormData(i);Cs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?bd(i,o):new FormData(i),Cs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var Sd=0;Sd<Ur.length;Sd++){var Cd=Ur[Sd];Wr(Cd.toLowerCase(),`on`+(Cd[0].toUpperCase()+Cd.slice(1)))}Wr(Fr,`onAnimationEnd`),Wr(Ir,`onAnimationIteration`),Wr(Lr,`onAnimationStart`),Wr(`dblclick`,`onDoubleClick`),Wr(`focusin`,`onFocus`),Wr(`focusout`,`onBlur`),Wr(Rr,`onTransitionRun`),Wr(zr,`onTransitionStart`),Wr(Br,`onTransitionCancel`),Wr(Vr,`onTransitionEnd`),yt(`onMouseEnter`,[`mouseout`,`mouseover`]),yt(`onMouseLeave`,[`mouseout`,`mouseover`]),yt(`onPointerEnter`,[`pointerout`,`pointerover`]),yt(`onPointerLeave`,[`pointerout`,`pointerover`]),vt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),vt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),vt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),vt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),vt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),vt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var wd=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),Td=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(wd));function Ed(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Gr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Gr(e)}i.currentTarget=null,a=c}}}}function Dd(e,t){var n=t[at];n===void 0&&(n=t[at]=new Set);var r=e+`__bubble`;n.has(r)||(jd(t,e,2,!1),n.add(r))}function Od(e,t,n){var r=0;t&&(r|=4),jd(n,e,r,t)}var kd=`_reactListening`+Math.random().toString(36).slice(2);function Ad(e){if(!e[kd]){e[kd]=!0,gt.forEach(function(t){t!==`selectionchange`&&(Td.has(t)||Od(t,!1,e),Od(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[kd]||(t[kd]=!0,Od(`selectionchange`,!1,t))}}function jd(e,t,n,r){switch(Cp(t)){case 2:var i=_p;break;case 8:i=vp;break;default:i=yp}n=i.bind(null,t,n,e),i=void 0,!an||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Md(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var s=r.stateNode.containerInfo;if(s===i)break;if(o===4)for(o=r.return;o!==null;){var l=o.tag;if((l===3||l===4)&&o.stateNode.containerInfo===i)return;o=o.return}for(;s!==null;){if(o=dt(s),o===null)return;if(l=o.tag,l===5||l===6||l===26||l===27){r=a=o;continue a}s=s.parentNode}}r=r.return}nn(function(){var r=a,i=Zt(n),o=[];a:{var s=Hr.get(e);if(s!==void 0){var l=gn,u=e;switch(e){case`keypress`:if(dn(n)===0)break a;case`keydown`:case`keyup`:l=Pn;break;case`focusin`:u=`focus`,l=Tn;break;case`focusout`:u=`blur`,l=Tn;break;case`beforeblur`:case`afterblur`:l=Tn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=Cn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=wn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=In;break;case Fr:case Ir:case Lr:l=En;break;case Vr:l=Ln;break;case`scroll`:case`scrollend`:l=vn;break;case`wheel`:l=Rn;break;case`copy`:case`cut`:case`paste`:l=Dn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Fn;break;case`toggle`:case`beforetoggle`:l=zn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?s===null?null:s+`Capture`:s;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=rn(m,p),g!=null&&d.push(Nd(m,g,h))),f)break;m=m.return}0<d.length&&(s=new l(s,u,null,n,i),o.push({event:s,listeners:d}))}}if(!(t&7)){a:{if(s=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,s&&n!==Xt&&(u=n.relatedTarget||n.fromElement)&&(dt(u)||u[it]))break a;if((l||s)&&(s=i.window===i?i:(s=i.ownerDocument)?s.defaultView||s.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?dt(u):null,u!==null&&(f=c(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=Cn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Fn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?s:pt(l),h=u==null?s:pt(u),s=new d(g,m+`leave`,l,n,i),s.target=f,s.relatedTarget=h,g=null,dt(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Fd,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Id(o,s,l,d,!1),u!==null&&f!==null&&Id(o,f,u,d,!0)}}a:{if(s=r?pt(r):window,l=s.nodeName&&s.nodeName.toLowerCase(),l===`select`||l===`input`&&s.type===`file`)var v=ar;else if($n(s))if(or)v=hr;else{v=pr;var y=fr}else l=s.nodeName,!l||l.toLowerCase()!==`input`||s.type!==`checkbox`&&s.type!==`radio`?r&&Gt(r.elementType)&&(v=ar):v=mr;if(v&&=v(e,r)){er(o,v,n,i);break a}y&&y(e,s,r),e===`focusout`&&r&&s.type===`number`&&r.memoizedProps.value!=null&&Lt(s,`number`,s.value)}switch(y=r?pt(r):window,e){case`focusin`:($n(y)||y.contentEditable===`true`)&&(Tr=y,Er=r,Dr=null);break;case`focusout`:Dr=Er=Tr=null;break;case`mousedown`:Or=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Or=!1,kr(o,n,i);break;case`selectionchange`:if(wr)break;case`keydown`:case`keyup`:kr(o,n,i)}var b;if(Vn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else Yn?qn(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Wn&&n.locale!==`ko`&&(Yn||x!==`onCompositionStart`?x===`onCompositionEnd`&&Yn&&(b=un()):(sn=i,cn=`value`in sn?sn.value:sn.textContent,Yn=!0)),y=Pd(r,x),0<y.length&&(x=new On(x,e,null,n,i),o.push({event:x,listeners:y}),b?x.data=b:(b=Jn(n),b!==null&&(x.data=b)))),(b=Un?Xn(e,n):Zn(e,n))&&(x=Pd(r,`onBeforeInput`),0<x.length&&(y=new On(`onBeforeInput`,`beforeinput`,null,n,i),o.push({event:y,listeners:x}),y.data=b)),xd(o,e,r,n,i)}Ed(o,t)})}function Nd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Pd(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=rn(e,n),i!=null&&r.unshift(Nd(e,i,a)),i=rn(e,t),i!=null&&r.push(Nd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Fd(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Id(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=rn(n,a),l!=null&&o.unshift(Nd(n,l,c))):i||(l=rn(n,a),l!=null&&o.push(Nd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Ld=/\r\n?/g,Rd=/\u0000|\uFFFD/g;function zd(e){return(typeof e==`string`?e:``+e).replace(Ld,`
10
+ `).replace(Rd,``)}function Bd(e,t){return t=zd(t),zd(e)===t}function Vd(e,t,n,r,i,a){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Vt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Vt(e,``+r);break;case`className`:Tt(e,`class`,r);break;case`tabIndex`:Tt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Tt(e,n,r);break;case`style`:Wt(e,r,a);break;case`data`:if(t!==`object`){Tt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Jt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof a==`function`&&(n===`formAction`?(t!==`input`&&Vd(e,t,`name`,i.name,i,null),Vd(e,t,`formEncType`,i.formEncType,i,null),Vd(e,t,`formMethod`,i.formMethod,i,null),Vd(e,t,`formTarget`,i.formTarget,i,null)):(Vd(e,t,`encType`,i.encType,i,null),Vd(e,t,`method`,i.method,i,null),Vd(e,t,`target`,i.target,i,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Jt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Yt);break;case`onScroll`:r!=null&&Dd(`scroll`,e);break;case`onScrollEnd`:r!=null&&Dd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(o(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(o(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Jt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Dd(`beforetoggle`,e),Dd(`toggle`,e),wt(e,`popover`,r);break;case`xlinkActuate`:Et(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Et(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Et(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Et(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Et(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Et(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Et(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Et(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Et(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:wt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Kt.get(n)||n,wt(e,n,r))}}function Hd(e,t,n,r,i,a){switch(n){case`style`:Wt(e,r,a);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(o(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(o(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Vt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Vt(e,``+r);break;case`onScroll`:r!=null&&Dd(`scroll`,e);break;case`onScrollEnd`:r!=null&&Dd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Yt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!_t.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(i=n.endsWith(`Capture`),t=n.slice(2,i?n.length-7:void 0),a=e[rt]||null,a=a==null?null:a[n],typeof a==`function`&&e.removeEventListener(t,a,i),typeof r==`function`)){typeof a!=`function`&&a!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,i);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):wt(e,n,r)}}}function Ud(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Dd(`error`,e),Dd(`load`,e);var r=!1,i=!1,a;for(a in n)if(n.hasOwnProperty(a)){var s=n[a];if(s!=null)switch(a){case`src`:r=!0;break;case`srcSet`:i=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(o(137,t));default:Vd(e,t,a,s,n,null)}}i&&Vd(e,t,`srcSet`,n.srcSet,n,null),r&&Vd(e,t,`src`,n.src,n,null);return;case`input`:Dd(`invalid`,e);var c=a=s=i=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:i=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:a=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(o(137,t));break;default:Vd(e,t,r,d,n,null)}}It(e,a,c,l,u,s,i,!1);return;case`select`:for(i in Dd(`invalid`,e),r=s=a=null,n)if(n.hasOwnProperty(i)&&(c=n[i],c!=null))switch(i){case`value`:a=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Vd(e,t,i,c,n,null)}t=a,n=s,e.multiple=!!r,t==null?n!=null&&Rt(e,!!r,n,!0):Rt(e,!!r,t,!1);return;case`textarea`:for(s in Dd(`invalid`,e),a=i=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:i=c;break;case`children`:a=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(o(91));break;default:Vd(e,t,s,c,n,null)}Bt(e,r,i,a);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Vd(e,t,l,r,n,null)}return;case`dialog`:Dd(`beforetoggle`,e),Dd(`toggle`,e),Dd(`cancel`,e),Dd(`close`,e);break;case`iframe`:case`object`:Dd(`load`,e);break;case`video`:case`audio`:for(r=0;r<wd.length;r++)Dd(wd[r],e);break;case`image`:Dd(`error`,e),Dd(`load`,e);break;case`details`:Dd(`toggle`,e);break;case`embed`:case`source`:case`link`:Dd(`error`,e),Dd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(o(137,t));default:Vd(e,t,u,r,n,null)}return;default:if(Gt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Hd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Vd(e,t,c,r,n,null))}function Wd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var i=null,a=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Vd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:a=m;break;case`name`:i=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(o(137,t));break;default:m!==f&&Vd(e,t,p,m,r,f)}}Ft(e,s,c,l,u,d,a,i);return;case`select`:for(a in m=s=c=p=null,n)if(l=n[a],n.hasOwnProperty(a)&&l!=null)switch(a){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(a)||Vd(e,t,a,null,r,l)}for(i in r)if(a=r[i],l=n[i],r.hasOwnProperty(i)&&(a!=null||l!=null))switch(i){case`value`:p=a;break;case`defaultValue`:c=a;break;case`multiple`:s=a;default:a!==l&&Vd(e,t,i,a,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Rt(e,!!n,n?[]:``,!1):Rt(e,!!n,t,!0)):Rt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(i=n[c],n.hasOwnProperty(c)&&i!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Vd(e,t,c,null,r,i)}for(s in r)if(i=r[s],a=n[s],r.hasOwnProperty(s)&&(i!=null||a!=null))switch(s){case`value`:p=i;break;case`defaultValue`:m=i;break;case`children`:break;case`dangerouslySetInnerHTML`:if(i!=null)throw Error(o(91));break;default:i!==a&&Vd(e,t,s,i,r,a)}zt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Vd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Vd(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Vd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(o(137,t));break;default:Vd(e,t,u,p,r,m)}return;default:if(Gt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Hd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Hd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Vd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Vd(e,t,f,p,r,m)}function Gd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Kd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Gd(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Gd(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var qd=null,Jd=null;function Yd(e){return e.nodeType===9?e:e.ownerDocument}function Xd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Zd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Qd(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var $d=null;function ef(){var e=window.event;return e&&e.type===`popstate`?e===$d?!1:($d=e,!0):($d=null,!1)}var tf=typeof setTimeout==`function`?setTimeout:void 0,nf=typeof clearTimeout==`function`?clearTimeout:void 0,rf=typeof Promise==`function`?Promise:void 0,af=typeof queueMicrotask==`function`?queueMicrotask:rf===void 0?tf:function(e){return rf.resolve(null).then(e).catch(of)};function of(e){setTimeout(function(){throw e})}function sf(e){return e===`head`}function cf(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Hp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)Sf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,Sf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[lt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&Sf(e.ownerDocument.body);n=i}while(n);Hp(t)}function lf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function uf(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:uf(n),ut(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function df(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[lt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=_f(e.nextSibling),e===null)break}return null}function ff(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=_f(e.nextSibling),e===null))return null;return e}function pf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=_f(e.nextSibling),e===null))return null;return e}function mf(e){return e.data===`$?`||e.data===`$~`}function hf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function gf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function _f(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var vf=null;function yf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return _f(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function bf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function xf(e,t,n){switch(t=Yd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(o(452));return e;case`head`:if(e=t.head,!e)throw Error(o(453));return e;case`body`:if(e=t.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function Sf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);ut(e)}var Cf=new Map,wf=new Set;function Tf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Ef=I.d;I.d={f:Df,r:Of,D:jf,C:Mf,L:Nf,m:Pf,X:If,S:Ff,M:Lf};function Df(){var e=Ef.f(),t=Eu();return e||t}function Of(e){var t=ft(e);t!==null&&t.tag===5&&t.type===`form`?Ts(t):Ef.r(e)}var kf=typeof document>`u`?null:document;function Af(e,t,n){var r=kf;if(r&&typeof t==`string`&&t){var i=Pt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),wf.has(i)||(wf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Ud(t,`link`,e),ht(t),r.head.appendChild(t)))}}function jf(e){Ef.D(e),Af(`dns-prefetch`,e,null)}function Mf(e,t){Ef.C(e,t),Af(`preconnect`,e,t)}function Nf(e,t,n){Ef.L(e,t,n);var r=kf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Pt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Pt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Pt(n.imageSizes)+`"]`)):i+=`[href="`+Pt(e)+`"]`;var a=i;switch(t){case`style`:a=zf(e);break;case`script`:a=Uf(e)}Cf.has(a)||(e=m({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),Cf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Bf(a))||t===`script`&&r.querySelector(Wf(a))||(t=r.createElement(`link`),Ud(t,`link`,e),ht(t),r.head.appendChild(t)))}}function Pf(e,t){Ef.m(e,t);var n=kf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Pt(r)+`"][href="`+Pt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Uf(e)}if(!Cf.has(a)&&(e=m({rel:`modulepreload`,href:e},t),Cf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Wf(a)))return}r=n.createElement(`link`),Ud(r,`link`,e),ht(r),n.head.appendChild(r)}}}function Ff(e,t,n){Ef.S(e,t,n);var r=kf;if(r&&e){var i=mt(r).hoistableStyles,a=zf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Bf(a)))s.loading=5;else{e=m({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=Cf.get(a))&&qf(e,n);var c=o=r.createElement(`link`);ht(c),Ud(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Kf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function If(e,t){Ef.X(e,t);var n=kf;if(n&&e){var r=mt(n).hoistableScripts,i=Uf(e),a=r.get(i);a||(a=n.querySelector(Wf(i)),a||(e=m({src:e,async:!0},t),(t=Cf.get(i))&&Jf(e,t),a=n.createElement(`script`),ht(a),Ud(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Lf(e,t){Ef.M(e,t);var n=kf;if(n&&e){var r=mt(n).hoistableScripts,i=Uf(e),a=r.get(i);a||(a=n.querySelector(Wf(i)),a||(e=m({src:e,async:!0,type:`module`},t),(t=Cf.get(i))&&Jf(e,t),a=n.createElement(`script`),ht(a),Ud(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Rf(e,t,n,r){var i=(i=re.current)?Tf(i):null;if(!i)throw Error(o(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=zf(n.href),n=mt(i).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=zf(n.href);var a=mt(i).hoistableStyles,s=a.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},a.set(e,s),(a=i.querySelector(Bf(e)))&&!a._p&&(s.instance=a,s.state.loading=5),Cf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Cf.set(e,n),a||Hf(i,e,n,s.state))),t&&r===null)throw Error(o(528,``));return s}if(t&&r!==null)throw Error(o(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Uf(n),n=mt(i).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(o(444,e))}}function zf(e){return`href="`+Pt(e)+`"`}function Bf(e){return`link[rel="stylesheet"][`+e+`]`}function Vf(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function Hf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Ud(t,`link`,n),ht(t),e.head.appendChild(t))}function Uf(e){return`[src="`+Pt(e)+`"]`}function Wf(e){return`script[async]`+e}function Gf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Pt(n.href)+`"]`);if(r)return t.instance=r,ht(r),r;var i=m({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),ht(r),Ud(r,`style`,i),Kf(r,n.precedence,e),t.instance=r;case`stylesheet`:i=zf(n.href);var a=e.querySelector(Bf(i));if(a)return t.state.loading|=4,t.instance=a,ht(a),a;r=Vf(n),(i=Cf.get(i))&&qf(r,i),a=(e.ownerDocument||e).createElement(`link`),ht(a);var s=a;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Ud(a,`link`,r),t.state.loading|=4,Kf(a,n.precedence,e),t.instance=a;case`script`:return a=Uf(n.src),(i=e.querySelector(Wf(a)))?(t.instance=i,ht(i),i):(r=n,(i=Cf.get(a))&&(r=m({},n),Jf(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),ht(i),Ud(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(o(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Kf(r,n.precedence,e));return t.instance}function Kf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function qf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Jf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Yf=null;function Xf(e,t,n){if(Yf===null){var r=new Map,i=Yf=new Map;i.set(n,r)}else i=Yf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[lt]||a[nt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Zf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Qf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function $f(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function ep(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=zf(r.href),a=t.querySelector(Bf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=rp.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,ht(a);return}a=t.ownerDocument||t,r=Vf(r),(i=Cf.get(i))&&qf(r,i),a=a.createElement(`link`),ht(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Ud(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=rp.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var tp=0;function np(e,t){return e.stylesheets&&e.count===0&&ap(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&ap(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&tp===0&&(tp=62500*Kd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&ap(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>tp?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function rp(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ap(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var ip=null;function ap(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ip=new Map,t.forEach(op,e),ip=null,rp.call(e))}function op(e,t){if(!(t.state.loading&4)){var n=ip.get(e);if(n)var r=n.get(null);else{n=new Map,ip.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=rp.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var sp={$$typeof:S,Provider:null,Consumer:null,_currentValue:L,_currentValue2:L,_threadCount:0};function cp(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ge(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ge(0),this.hiddenUpdates=Ge(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function lp(e,t,n,r,i,a,o,s,c,l,u,d){return e=new cp(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=ri(3,null,null,t),e.current=a,a.stateNode=e,t=ia(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},La(a),e}function up(e){return e?(e=ti,e):ti}function dp(e,t,n,r,i,a){i=up(i),r.context===null?r.context=i:r.pendingContext=i,r=za(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Ba(e,r,t),n!==null&&(xu(n,e,t),Va(n,e,t))}function fp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function pp(e,t){fp(e,t),(e=e.alternate)&&fp(e,t)}function mp(e){if(e.tag===13||e.tag===31){var t=Qr(e,67108864);t!==null&&xu(t,e,67108864),pp(e,67108864)}}function hp(e){if(e.tag===13||e.tag===31){var t=yu();t=Ze(t);var n=Qr(e,t);n!==null&&xu(n,e,t),pp(e,t)}}var gp=!0;function _p(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=2,yp(e,t,n,r)}finally{I.p=a,F.T=i}}function vp(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=8,yp(e,t,n,r)}finally{I.p=a,F.T=i}}function yp(e,t,n,r){if(gp){var i=bp(r);if(i===null)Md(e,t,r,xp,n),Mp(e,r);else if(Pp(i,e,t,n,r))r.stopPropagation();else if(Mp(e,r),t&4&&-1<jp.indexOf(e)){for(;i!==null;){var a=ft(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Be(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Ne(o);s.entanglements[1]|=c,o&=~c}ud(a),!(Bl&6)&&(su=xe()+500,dd(0,!1))}}break;case 31:case 13:s=Qr(a,2),s!==null&&xu(s,a,2),Eu(),pp(a,2)}if(a=bp(r),a===null&&Md(e,t,r,xp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Md(e,t,r,null,n)}}function bp(e){return e=Zt(e),Sp(e)}var xp=null;function Sp(e){if(xp=null,e=dt(e),e!==null){var t=c(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=l(t),e!==null)return e;e=null}else if(n===31){if(e=u(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return xp=e,null}function Cp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Se()){case Ce:return 2;case we:return 8;case Te:case Ee:return 32;case De:return 268435456;default:return 32}default:return 32}}var wp=!1,Tp=null,Ep=null,Dp=null,Op=new Map,kp=new Map,Ap=[],jp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Mp(e,t){switch(e){case`focusin`:case`focusout`:Tp=null;break;case`dragenter`:case`dragleave`:Ep=null;break;case`mouseover`:case`mouseout`:Dp=null;break;case`pointerover`:case`pointerout`:Op.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:kp.delete(t.pointerId)}}function Np(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=ft(t),t!==null&&mp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Pp(e,t,n,r,i){switch(t){case`focusin`:return Tp=Np(Tp,e,t,n,r,i),!0;case`dragenter`:return Ep=Np(Ep,e,t,n,r,i),!0;case`mouseover`:return Dp=Np(Dp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Op.set(a,Np(Op.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,kp.set(a,Np(kp.get(a)||null,e,t,n,r,i)),!0}return!1}function Fp(e){var t=dt(e.target);if(t!==null){var n=c(t);if(n!==null){if(t=n.tag,t===13){if(t=l(n),t!==null){e.blockedOn=t,et(e.priority,function(){hp(n)});return}}else if(t===31){if(t=u(n),t!==null){e.blockedOn=t,et(e.priority,function(){hp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ip(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=bp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Xt=r,n.target.dispatchEvent(r),Xt=null}else return t=ft(n),t!==null&&mp(t),e.blockedOn=n,!1;t.shift()}return!0}function Lp(e,t,n){Ip(e)&&n.delete(t)}function Rp(){wp=!1,Tp!==null&&Ip(Tp)&&(Tp=null),Ep!==null&&Ip(Ep)&&(Ep=null),Dp!==null&&Ip(Dp)&&(Dp=null),Op.forEach(Lp),kp.forEach(Lp)}function zp(e,t){e.blockedOn===t&&(e.blockedOn=null,wp||(wp=!0,r.unstable_scheduleCallback(r.unstable_NormalPriority,Rp)))}var Bp=null;function Vp(e){Bp!==e&&(Bp=e,r.unstable_scheduleCallback(r.unstable_NormalPriority,function(){Bp===e&&(Bp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Sp(r||n)===null)continue;break}var a=ft(n);a!==null&&(e.splice(t,3),t-=3,Cs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Hp(e){function t(t){return zp(t,e)}Tp!==null&&zp(Tp,e),Ep!==null&&zp(Ep,e),Dp!==null&&zp(Dp,e),Op.forEach(t),kp.forEach(t);for(var n=0;n<Ap.length;n++){var r=Ap[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Ap.length&&(n=Ap[0],n.blockedOn===null);)Fp(n),n.blockedOn===null&&Ap.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[rt]||null;if(typeof a==`function`)o||Vp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[rt]||null)s=o.formAction;else if(Sp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Vp(n)}}}function Up(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Wp(e){this._internalRoot=e}Gp.prototype.render=Wp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var n=t.current;dp(n,yu(),e,t,null,null)},Gp.prototype.unmount=Wp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;dp(e.current,2,null,e,null,null),Eu(),t[it]=null}};function Gp(e){this._internalRoot=e}Gp.prototype.unstable_scheduleHydration=function(e){if(e){var t=$e();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ap.length&&t!==0&&t<Ap[n].priority;n++);Ap.splice(n,0,e),n===0&&Fp(e)}};var Kp=i.version;if(Kp!==`19.2.7`)throw Error(o(527,Kp,`19.2.7`));I.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(o(188)):(e=Object.keys(e).join(`,`),Error(o(268,e)));return e=f(t),e=e===null?null:p(e),e=e===null?null:e.stateNode,e};var qp={bundleType:0,version:`19.2.7`,rendererPackageName:`react-dom`,currentDispatcherRef:F,reconcilerVersion:`19.2.7`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Jp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Jp.isDisabled&&Jp.supportsFiber)try{Ae=Jp.inject(qp),je=Jp}catch{}}t.createRoot=function(e,t){if(!s(e))throw Error(o(299));var n=!1,r=``,i=Ks,a=qs,c=Js;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(a=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=lp(e,1,!1,null,null,n,r,null,i,a,c,Up),e[it]=t.current,Ad(e),new Wp(t)}})),GT=i(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=WT()})),KT=Object.defineProperty,qT=(e,t,n)=>t in e?KT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,JT=(e,t,n)=>qT(e,typeof t==`symbol`?t:t+``,n),YT=void 0,XT=class{constructor(e,t){if(JT(this,`address`),JT(this,`auth`),JT(this,`adminAuth`),JT(this,`encodedTsPromise`),JT(this,`debug`),JT(this,`fetchOptions`),JT(this,`fetch`),JT(this,`logger`),JT(this,`mutationQueue`,[]),JT(this,`isProcessingQueue`,!1),typeof t==`boolean`)throw Error("skipConvexDeploymentUrlCheck as the second argument is no longer supported. Please pass an options object, `{ skipConvexDeploymentUrlCheck: true }`.");(t??{}).skipConvexDeploymentUrlCheck!==!0&&Mn(e),this.logger=t?.logger===!1?Ys({verbose:!1}):t?.logger!==!0&&t?.logger?t.logger:na({verbose:!1}),this.address=e,this.debug=!0,this.auth=void 0,this.adminAuth=void 0,this.fetch=t?.fetch,t?.auth&&this.setAuth(t.auth)}backendUrl(){return`${this.address}/api`}get url(){return this.address}setAuth(e){this.clearAuth(),this.auth=e}setAdminAuth(e,t){if(this.clearAuth(),t!==void 0){let n=new TextEncoder().encode(JSON.stringify(t)),r=btoa(String.fromCodePoint(...n));this.adminAuth=`${e}:${r}`}else this.adminAuth=e}clearAuth(){this.auth=void 0,this.adminAuth=void 0}setDebug(e){this.debug=e}setFetchOptions(e){this.fetchOptions=e}async consistentQuery(e,...t){let n=du(t[0]),r=this.getTimestamp();return await this.queryInner(e,n,{timestampPromise:r})}async getTimestamp(){return this.encodedTsPromise?this.encodedTsPromise:this.encodedTsPromise=this.getTimestampInner()}async getTimestampInner(){let e=this.fetch||YT||fetch,t={"Content-Type":`application/json`,"Convex-Client":`npm-${ve}`},n=await e(`${this.address}/api/query_ts`,{...this.fetchOptions,method:`POST`,headers:t});if(!n.ok)throw Error(await n.text());let{ts:r}=await n.json();return r}async query(e,...t){let n=du(t[0]);return await this.queryInner(e,n,{})}async queryInner(e,t,n){let r=Or(e),i=[rr(t)],a={"Content-Type":`application/json`,"Convex-Client":`npm-${ve}`};this.adminAuth?a.Authorization=`Convex ${this.adminAuth}`:this.auth&&(a.Authorization=`Bearer ${this.auth}`);let o=this.fetch||YT||fetch,s=n.timestampPromise?await n.timestampPromise:void 0,c=JSON.stringify({path:r,format:`convex_encoded_json`,args:i,...s?{ts:s}:{}}),l=await o(s?`${this.address}/api/query_at_ts`:`${this.address}/api/query`,{...this.fetchOptions,body:c,method:`POST`,headers:a});if(!l.ok&&l.status!==560)throw Error(await l.text());let u=await l.json();if(this.debug)for(let e of u.logLines??[])ux(this.logger,`info`,`query`,r,e);switch(u.status){case`success`:return gl(u.value);case`error`:throw u.errorData===void 0?Error(u.errorMessage):ZT(u.errorData,new Bl(u.errorMessage));default:throw Error(`Invalid response: ${JSON.stringify(u)}`)}}async mutationInner(e,t){let n=Or(e),r=JSON.stringify({path:n,format:`convex_encoded_json`,args:[rr(t)]}),i={"Content-Type":`application/json`,"Convex-Client":`npm-${ve}`};this.adminAuth?i.Authorization=`Convex ${this.adminAuth}`:this.auth&&(i.Authorization=`Bearer ${this.auth}`);let a=await(this.fetch||YT||fetch)(`${this.address}/api/mutation`,{...this.fetchOptions,body:r,method:`POST`,headers:i});if(!a.ok&&a.status!==560)throw Error(await a.text());let o=await a.json();if(this.debug)for(let e of o.logLines??[])ux(this.logger,`info`,`mutation`,n,e);switch(o.status){case`success`:return gl(o.value);case`error`:throw o.errorData===void 0?Error(o.errorMessage):ZT(o.errorData,new Bl(o.errorMessage));default:throw Error(`Invalid response: ${JSON.stringify(o)}`)}}async processMutationQueue(){if(!this.isProcessingQueue){for(this.isProcessingQueue=!0;this.mutationQueue.length>0;){let{mutation:e,args:t,resolve:n,reject:r}=this.mutationQueue.shift();try{n(await this.mutationInner(e,t))}catch(e){r(e)}}this.isProcessingQueue=!1}}enqueueMutation(e,t){return new Promise((n,r)=>{this.mutationQueue.push({mutation:e,args:t,resolve:n,reject:r}),this.processMutationQueue()})}async mutation(e,...t){let[n,r]=t,i=du(n);return r?.skipQueue?await this.mutationInner(e,i):await this.enqueueMutation(e,i)}async action(e,...t){let n=du(t[0]),r=Or(e),i=JSON.stringify({path:r,format:`convex_encoded_json`,args:[rr(n)]}),a={"Content-Type":`application/json`,"Convex-Client":`npm-${ve}`};this.adminAuth?a.Authorization=`Convex ${this.adminAuth}`:this.auth&&(a.Authorization=`Bearer ${this.auth}`);let o=await(this.fetch||YT||fetch)(`${this.address}/api/action`,{...this.fetchOptions,body:i,method:`POST`,headers:a});if(!o.ok&&o.status!==560)throw Error(await o.text());let s=await o.json();if(this.debug)for(let e of s.logLines??[])ux(this.logger,`info`,`action`,r,e);switch(s.status){case`success`:return gl(s.value);case`error`:throw s.errorData===void 0?Error(s.errorMessage):ZT(s.errorData,new Bl(s.errorMessage));default:throw Error(`Invalid response: ${JSON.stringify(s)}`)}}async function(e,t,...n){let r=du(n[0]),i=typeof e==`string`?e:Or(e),a=JSON.stringify({componentPath:t,path:i,format:`convex_encoded_json`,args:rr(r)}),o={"Content-Type":`application/json`,"Convex-Client":`npm-${ve}`};this.adminAuth?o.Authorization=`Convex ${this.adminAuth}`:this.auth&&(o.Authorization=`Bearer ${this.auth}`);let s=await(this.fetch||YT||fetch)(`${this.address}/api/function`,{...this.fetchOptions,body:a,method:`POST`,headers:o});if(!s.ok&&s.status!==560)throw Error(await s.text());let c=await s.json();if(this.debug)for(let e of c.logLines??[])ux(this.logger,`info`,`any`,i,e);switch(c.status){case`success`:return gl(c.value);case`error`:throw c.errorData===void 0?Error(c.errorMessage):ZT(c.errorData,new Bl(c.errorMessage));default:throw Error(`Invalid response: ${JSON.stringify(c)}`)}}};function ZT(e,t){return t.data=gl(e),t}var q=r(e(),1),QT=(0,q.createContext)(void 0);function $T(){let e=(0,q.useContext)(QT);if(e===void 0)throw Error("Could not find `ConvexProviderWithAuth` (or `ConvexProviderWithClerk` or `ConvexProviderWithAuth0`) as an ancestor component. This component may be missing, or you might have two instances of the `convex/react` module loaded in your project.");return e}function eE({children:e,client:t,useAuth:n}){let{isLoading:r,isAuthenticated:i,fetchAccessToken:a}=n(),[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(!1);r&&o!==null&&(s(null),l(!1)),!r&&!i&&o!==!1&&(s(!1),l(!1));let u=i&&(o??!1);return q.createElement(QT.Provider,{value:{isLoading:o===null,isAuthenticated:u,isRefreshing:c&&u}},q.createElement(tE,{authProviderAuthenticated:i,fetchAccessToken:a,authProviderLoading:r,client:t,setIsConvexAuthenticated:s,setIsRefreshing:l}),q.createElement(P,{client:t},e),q.createElement(nE,{authProviderAuthenticated:i,fetchAccessToken:a,authProviderLoading:r,client:t,setIsConvexAuthenticated:s,setIsRefreshing:l}))}function tE({authProviderAuthenticated:e,fetchAccessToken:t,authProviderLoading:n,client:r,setIsConvexAuthenticated:i,setIsRefreshing:a}){return(0,q.useEffect)(()=>{let n=!0;if(e)return r.setAuth(t,e=>{n&&i(()=>e)},e=>{n&&a(e)}),()=>{n=!1,i(e=>!e&&null),a(!1)}},[e,t,n,r,i,a]),null}function nE({authProviderAuthenticated:e,fetchAccessToken:t,authProviderLoading:n,client:r,setIsConvexAuthenticated:i,setIsRefreshing:a}){return(0,q.useEffect)(()=>{if(e)return()=>{r.clearAuth(),i(()=>null),a(!1)}},[e,t,n,r,i,a]),null}function rE({children:e}){let{isLoading:t,isAuthenticated:n}=$T();return t||!n?null:q.createElement(q.Fragment,null,e)}function iE({children:e}){let{isLoading:t,isAuthenticated:n}=$T();return t||n?null:q.createElement(q.Fragment,null,e)}function aE({children:e}){let{isLoading:t}=$T();return t?q.createElement(q.Fragment,null,e):null}var oE=r(GT(),1),J=a(),sE=Object.prototype.toString,cE=e=>sE.call(e)===`[object Error]`,lE=new Set([`network error`,`NetworkError when attempting to fetch resource.`,`The Internet connection appears to be offline.`,`Network request failed`,`fetch failed`,`terminated`,` A network error occurred.`,`Network connection lost`]);function uE(e){if(!(e&&cE(e)&&e.name===`TypeError`&&typeof e.message==`string`))return!1;let{message:t,stack:n}=e;return t===`Load failed`||t.startsWith(`Load failed (`)&&t.endsWith(`)`)?n===void 0||`__sentry_captured__`in e:t.startsWith(`error sending request for url`)||t===`Failed to fetch`||t.startsWith(`Failed to fetch (`)&&t.endsWith(`)`)?!0:lE.has(t)}var dE=[500,2e3],fE=100,pE=(0,q.createContext)(void 0),mE=(0,q.createContext)(void 0);function hE(){return(0,q.useContext)(mE)}var gE=(0,q.createContext)(null),_E=`__convexAuthOAuthVerifier`,vE=`__convexAuthJWT`,yE=`__convexAuthRefreshToken`,bE=`__convexAuthServerStateFetchTime`;function xE({client:e,serverState:t,onChange:n,shouldHandleCode:r,storage:i,storageNamespace:a,replaceURL:o,children:s}){let c=(0,q.useRef)(t?._state.token??null),[l,u]=(0,q.useState)(c.current===null),[d,f]=(0,q.useState)(c.current),p=e.verbose??!1,m=(0,q.useCallback)(t=>{p&&(console.debug(`${new Date().toISOString()} ${t}`),e.logger?.logVerbose(t))},[p]),{storageSet:h,storageGet:g,storageRemove:_,storageKey:v}=SE(i,a),[y,b]=(0,q.useState)(!1),x=(0,q.useCallback)(async e=>{let t=c.current!==null,r;if(e.tokens===null)c.current=null,e.shouldStore&&(await _(vE),await _(yE)),r=null;else{let{token:t}=e.tokens;if(c.current=t,e.shouldStore){let{refreshToken:n}=e.tokens;await h(vE,t),await h(yE,n)}r=t}t!==(r!==null)&&await n?.(),f(r),u(!1)},[h,_]);(0,q.useEffect)(()=>{let e=async e=>{if(y)return e.preventDefault(),e.returnValue=!0,`Are you sure you want to leave? Your changes may not be saved.`};return kE(`beforeunload`,e),()=>{AE(`beforeunload`,e)}}),(0,q.useEffect)(()=>{let e=e=>{(async()=>{if(e.storageArea===i&&e.key===v(vE)){let t=e.newValue;m(`synced access token, is null: ${t===null}`),await x({shouldStore:!1,tokens:t===null?null:{token:t}})}})()};return kE(`storage`,e),()=>AE(`storage`,e)},[x]);let S=(0,q.useCallback)(async t=>{let n,r=0;for(;r<dE.length;)try{return await e.unauthenticatedCall(`auth:signIn`,`code`in t?{params:{code:t.code},verifier:t.verifier}:t)}catch(e){if(n=e,!uE(e))break;let t=dE[r]+fE*Math.random();r++,m(`verifyCode failed with network error, retry ${r} of ${dE.length} in ${t}ms`),await new Promise(e=>setTimeout(e,t))}throw n},[e]),C=(0,q.useCallback)(async e=>{let{tokens:t}=await S(e);return m(`retrieved tokens, is null: ${t===null}`),await x({shouldStore:!0,tokens:t??null}),t!==null},[e,x]),w=(0,q.useCallback)(async(t,n)=>{let r=n instanceof FormData?Array.from(n.entries()).reduce((e,[t,n])=>(e[t]=n,e),{}):n??{},i=await g(_E)??void 0;await _(_E);let a=await e.authenticatedCall(`auth:signIn`,{provider:t,params:r,verifier:i});if(a.redirect!==void 0){let e=new URL(a.redirect);return await h(_E,a.verifier),navigator.product!==`ReactNative`&&(window.location.href=e.toString()),{signingIn:!1,redirect:e}}else if(a.tokens!==void 0){let{tokens:e}=a;return m(`signed in and got tokens, is null: ${e===null}`),await x({shouldStore:!0,tokens:e}),{signingIn:a.tokens!==null}}return{signingIn:!1}},[e,x,g]),T=(0,q.useCallback)(async()=>{try{await e.authenticatedCall(`auth:signOut`)}catch{}m(`signed out, erasing tokens`),await x({shouldStore:!0,tokens:null})},[x,e]),E=(0,q.useCallback)(async({forceRefreshToken:e})=>{if(e){let e=c.current;return await wE(yE,async()=>{let t=c.current;if(t!==e)return m(`returning synced token, is null: ${t===null}`),t;let n=await g(yE)??null;return n===null?(b(!1),m(`returning null, there is no refresh token`),null):(b(!0),await C({refreshToken:n}).finally(()=>{b(!1)}),m(`returning retrieved token, is null: ${t===null}`),c.current)})}return c.current},[C,T,g]),D=(0,q.useRef)(!1);(0,q.useEffect)(()=>{if(i===void 0)throw Error("`localStorage` is not available in this environment, set the `storage` prop on `ConvexAuthProvider`!");let e=async()=>{let e=await g(vE)??null;m(`retrieved token from storage, is null: ${e===null}`),await x({shouldStore:!1,tokens:e===null?null:{token:e}})};if(t!==void 0){let n=g(bE),r=n=>{if(!n||t._timeFetched>+n){let{token:e,refreshToken:n}=t._state,r=e===null||n===null?null:{token:e,refreshToken:n};h(bE,t._timeFetched.toString()),x({tokens:r,shouldStore:!0})}else e()};n instanceof Promise?n.then(r):r(n);return}let n=window?.location?.search===void 0?null:new URLSearchParams(window.location.search).get(`code`);if(!D.current)if(n&&(r===void 0||(typeof r==`function`?r():r))){D.current=!0;let e=new URL(window.location.href);e.searchParams.delete(`code`),(async()=>{await o(e.pathname+e.search+e.hash),await w(void 0,{code:n}),D.current=!1})()}else e()},[e,g]);let O=(0,q.useMemo)(()=>({signIn:w,signOut:T}),[w,T]),k=d!==null,A=(0,q.useMemo)(()=>({isLoading:l,isAuthenticated:k,fetchAccessToken:E}),[E,l,k]);return(0,J.jsx)(mE.Provider,{value:A,children:(0,J.jsx)(pE.Provider,{value:O,children:(0,J.jsx)(gE.Provider,{value:d,children:s})})})}function SE(e,t){let n=CE(),r=(0,q.useMemo)(()=>e??n(),[e]),i=t.replace(/[^a-zA-Z0-9]/g,``),a=(0,q.useCallback)(e=>`${e}_${i}`,[t]);return{storageSet:(0,q.useCallback)((e,t)=>r.setItem(a(e),t),[r,a]),storageGet:(0,q.useCallback)(e=>r.getItem(a(e)),[r,a]),storageRemove:(0,q.useCallback)(e=>r.removeItem(a(e)),[r,a]),storageKey:a}}function CE(){let[e,t]=(0,q.useState)({});return()=>({getItem:t=>e[t],setItem:(e,n)=>{t(t=>({...t,[e]:n}))},removeItem:e=>{t(t=>{let{[e]:n,...r}=t;return r})}})}async function wE(e,t){let n=window?.navigator?.locks;return n===void 0?await OE(e,t):await n.request(e,t)}function TE(e){globalThis.__convexAuthMutexes===void 0&&(globalThis.__convexAuthMutexes={});let t=globalThis.__convexAuthMutexes[e];return t===void 0&&(globalThis.__convexAuthMutexes[e]={currentlyRunning:null,waiting:[]}),t=globalThis.__convexAuthMutexes[e],t}function EE(e,t){globalThis.__convexAuthMutexes[e]=t}async function DE(e,t){let n=TE(e);n.currentlyRunning===null?EE(e,{currentlyRunning:t().finally(()=>{let t=TE(e).waiting.shift();TE(e).currentlyRunning=null,EE(e,{...TE(e),currentlyRunning:t===void 0?null:DE(e,t)})}),waiting:[]}):EE(e,{...n,waiting:[...n.waiting,t]})}async function OE(e,t){return new Promise((n,r)=>{DE(e,()=>t().then(e=>n(e)).catch(e=>r(e)))})}function kE(e,t,n){typeof window>`u`||window.addEventListener?.(e,t,n)}function AE(e,t,n){typeof window>`u`||window.removeEventListener?.(e,t,n)}function jE(){return(0,q.useContext)(pE)}function ME(e){let{client:t,storage:n,storageNamespace:r,replaceURL:i,shouldHandleCode:a,children:o}=e;return(0,J.jsx)(xE,{client:(0,q.useMemo)(()=>({authenticatedCall(e,n){return t.action(e,n)},unauthenticatedCall(e,n){return new XT(t.address,{logger:t.logger}).action(e,n)},verbose:t.options?.verbose,logger:t.logger}),[t]),storage:n??(typeof window>`u`?void 0:window?.localStorage),storageNamespace:r??t.address,replaceURL:i??(e=>{window.history.replaceState({},``,e)}),shouldHandleCode:a,children:(0,J.jsx)(eE,{client:t,useAuth:hE,children:o})})}function NE(){return(0,q.useContext)(gE)}var PE=q.use,FE=typeof window<`u`?q.useLayoutEffect:q.useEffect;function IE(e){let t=q.useRef({value:e,prev:null}),n=t.current.value;return e!==n&&(t.current={value:e,prev:n}),t.current.prev}function LE(e,t,n={},r={}){q.useEffect(()=>{if(!e.current||r.disabled||typeof IntersectionObserver!=`function`)return;let i=new IntersectionObserver(([e])=>{t(e)},n);return i.observe(e.current),()=>{i.disconnect()}},[t,n,r.disabled,e])}function RE(e){let t=q.useRef(null);return q.useImperativeHandle(e,()=>t.current,[]),t}function zE(e){let t=new Map,n,r,i=e=>{e.next&&(e.prev?(e.prev.next=e.next,e.next.prev=e.prev,e.next=void 0,r&&(r.next=e,e.prev=r)):(e.next.prev=void 0,n=e.next,e.next=void 0,r&&(e.prev=r,r.next=e)),r=e)};return{get(e){let n=t.get(e);if(n)return i(n),n.value},set(a,o){if(t.size>=e&&n){let e=n;t.delete(e.key),e.next&&(n=e.next,e.next.prev=void 0),e===r&&(r=void 0)}let s=t.get(a);if(s)s.value=o,i(s);else{let e={key:a,value:o,prev:r};r&&(r.next=e),r=e,n||=e,t.set(a,e)}},clear(){t.clear(),n=void 0,r=void 0}}}var BE=4,VE=5;function HE(e){let t=e.indexOf(`{`);if(t===-1)return null;let n=e.indexOf(`}`,t);return n===-1||t+1>=e.length?null:[t,n]}function UE(e,t,n=new Uint16Array(6)){let r=e.indexOf(`/`,t),i=r===-1?e.length:r,a=e.substring(t,i);if(!a||!a.includes(`$`))return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n;if(a===`$`){let r=e.length;return n[0]=2,n[1]=t,n[2]=t,n[3]=r,n[4]=r,n[5]=r,n}if(a.charCodeAt(0)===36)return n[0]=1,n[1]=t,n[2]=t+1,n[3]=i,n[4]=i,n[5]=i,n;let o=HE(a);if(o){let[r,s]=o,c=a.charCodeAt(r+1);if(c===45){if(r+2<a.length&&a.charCodeAt(r+2)===36){let e=r+3,a=s;if(e<a)return n[0]=3,n[1]=t+r,n[2]=t+e,n[3]=t+a,n[4]=t+s+1,n[5]=i,n}}else if(c===36){let a=r+1,o=r+2;return o===s?(n[0]=2,n[1]=t+r,n[2]=t+a,n[3]=t+o,n[4]=t+s+1,n[5]=e.length,n):(n[0]=1,n[1]=t+r,n[2]=t+o,n[3]=t+s,n[4]=t+s+1,n[5]=i,n)}}return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n}function WE(e,t,n,r,i,a,o){o?.(n);let s=r;{let r=n.fullPath??n.from,o=r.length,c=n.options?.caseSensitive??e,l=n.options?.params?.parse??n.options?.parseParams;for(;s<o;){let e=UE(r,s,t),o,u=s,d=e[5];switch(s=d+1,a++,e[0]){case 0:{let t=r.substring(e[2],e[3]);if(c){let e=i.static?.get(t);if(e)o=e;else{i.static??=new Map;let e=qE(n.fullPath??n.from);e.parent=i,e.depth=a,o=e,i.static.set(t,e)}}else{let e=t.toLowerCase(),r=i.staticInsensitive?.get(e);if(r)o=r;else{i.staticInsensitive??=new Map;let t=qE(n.fullPath??n.from);t.parent=i,t.depth=a,o=t,i.staticInsensitive.set(e,t)}}break}case 1:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),f=c&&!!(t||s),p=t?f?t:t.toLowerCase():void 0,m=s?f?s:s.toLowerCase():void 0,h=!l&&i.dynamic?.find(e=>!e.parse&&e.caseSensitive===f&&e.prefix===p&&e.suffix===m);if(h)o=h;else{let e=JE(1,n.fullPath??n.from,f,p,m);o=e,e.depth=a,e.parent=i,i.dynamic??=[],i.dynamic.push(e)}break}case 3:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),f=c&&!!(t||s),p=t?f?t:t.toLowerCase():void 0,m=s?f?s:s.toLowerCase():void 0,h=!l&&i.optional?.find(e=>!e.parse&&e.caseSensitive===f&&e.prefix===p&&e.suffix===m);if(h)o=h;else{let e=JE(3,n.fullPath??n.from,f,p,m);o=e,e.parent=i,e.depth=a,i.optional??=[],i.optional.push(e)}break}case 2:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),l=c&&!!(t||s),f=t?l?t:t.toLowerCase():void 0,p=s?l?s:s.toLowerCase():void 0,m=JE(2,n.fullPath??n.from,l,f,p);o=m,m.parent=i,m.depth=a,i.wildcard??=[],i.wildcard.push(m)}}i=o}if(l&&n.children&&!n.isRoot&&n.id&&n.id.charCodeAt(n.id.lastIndexOf(`/`)+1)===95){let e=qE(n.fullPath??n.from);e.kind=VE,e.parent=i,a++,e.depth=a,i.pathless??=[],i.pathless.push(e),i=e}let u=(n.path||!n.children)&&!n.isRoot;if(u&&r.endsWith(`/`)){let e=qE(n.fullPath??n.from);e.kind=BE,e.parent=i,a++,e.depth=a,i.index=e,i=e}i.parse=l??null,i.priority=n.options?.params?.priority??0,u&&!i.route&&(i.route=n,i.fullPath=n.fullPath??n.from)}if(n.children)for(let r of n.children)WE(e,t,r,s,i,a,o)}function GE(e,t){if(e.parse&&!t.parse)return-1;if(!e.parse&&t.parse)return 1;if(e.parse&&t.parse&&(e.priority||t.priority))return t.priority-e.priority;if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function KE(e){if(e.pathless)for(let t of e.pathless)KE(t);if(e.static)for(let t of e.static.values())KE(t);if(e.staticInsensitive)for(let t of e.staticInsensitive.values())KE(t);if(e.dynamic?.length){e.dynamic.sort(GE);for(let t of e.dynamic)KE(t)}if(e.optional?.length){e.optional.sort(GE);for(let t of e.optional)KE(t)}if(e.wildcard?.length){e.wildcard.sort(GE);for(let t of e.wildcard)KE(t)}}function qE(e){return{kind:0,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:e,parent:null,parse:null,priority:0}}function JE(e,t,n,r,i){return{kind:e,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:t,parent:null,parse:null,priority:0,caseSensitive:n,prefix:r,suffix:i}}function YE(e,t){let n=qE(`/`),r=new Uint16Array(6);for(let t of e)WE(!1,r,t,1,n,0);KE(n),t.masksTree=n,t.flatCache=zE(1e3)}function XE(e,t){e||=`/`;let n=t.flatCache.get(e);if(n)return n;let r=tD(e,t.masksTree);return t.flatCache.set(e,r),r}function ZE(e,t,n,r,i){e||=`/`,r||=`/`;let a=t?`case\0${e}`:e,o=i.singleCache.get(a);return o||(o=qE(`/`),WE(t,new Uint16Array(6),{from:e},1,o,0),i.singleCache.set(a,o)),tD(r,o,n)}function QE(e,t,n=!1){let r=n?e:`nofuzz\0${e}`,i=t.matchCache.get(r);if(i!==void 0)return i;e||=`/`;let a;try{a=tD(e,t.segmentTree,n)}catch(e){if(e instanceof URIError)a=null;else throw e}return a&&(a.branch=rD(a.route)),t.matchCache.set(r,a),a}function $E(e){return e===`/`?e:e.replace(/\/{1,}$/,``)}function eD(e,t=!1,n){let r=qE(e.fullPath),i=new Uint16Array(6),a={},o={},s=0;return WE(t,i,e,1,r,0,e=>{if(n?.(e,s),e.id in a&&Nx(),a[e.id]=e,s!==0&&e.path){let t=$E(e.fullPath);(!o[t]||e.fullPath.endsWith(`/`))&&(o[t]=e)}s++}),KE(r),{processedTree:{segmentTree:r,singleCache:zE(1e3),matchCache:zE(1e3),flatCache:null,masksTree:null},routesById:a,routesByPath:o}}function tD(e,t,n=!1){let r=e.split(`/`),i=aD(e,r,t,n);if(!i)return null;let[a]=nD(e,r,i);return{route:i.node.route,rawParams:a}}function nD(e,t,n){let r=iD(n.node),i=null,a=Object.create(null),o=n.extract?.part??0,s=n.extract?.node??0,c=n.extract?.path??0,l=n.extract?.segment??0;for(;s<r.length;o++,s++,c++,l++){let u=r[s];if(u.kind===BE)break;if(u.kind===VE){l--,o--,c--;continue}let d=t[o],f=c;if(d&&(c+=d.length),u.kind===1){i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0;if(e.charCodeAt(t)===123){let n=u.suffix?.length??0,r=e.substring(t+2,e.length-n-1),i=d.substring(t,d.length-n);a[r]=decodeURIComponent(i)}else{let t=e.substring(1);a[t]=decodeURIComponent(d)}}else if(u.kind===3){if(n.skipped&1<<s){o--,c=f-1;continue}i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0,r=u.suffix?.length??0,p=e.substring(t+3,e.length-r-1),m=u.suffix||u.prefix?d.substring(t,d.length-r):d;m&&(a[p]=decodeURIComponent(m))}else if(u.kind===2){let t=u,n=e.substring(f+(t.prefix?.length??0),e.length-(t.suffix?.length??0)),r=decodeURIComponent(n);a[`*`]=r,a._splat=r;break}}return n.rawParams&&Object.assign(a,n.rawParams),[a,{part:o,node:s,path:c,segment:l}]}function rD(e){let t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function iD(e){let t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function aD(e,t,n,r){if(e===`/`&&n.index)return{node:n.index,skipped:0};let i=!Mx(t),a=i&&e!==`/`,o=t.length-+!!i,s=[{node:n,index:1,skipped:0,depth:1,statics:0,dynamics:0,optionals:0}],c=null,l=null;for(;s.length;){let n=s.pop(),{node:i,index:u,skipped:d,depth:f,statics:p,dynamics:m,optionals:h}=n,{extract:g,rawParams:_}=n;if(i.kind===2&&i.route&&!lD(l,n))continue;if(i.parse){if(!cD(e,t,n))continue;_=n.rawParams,g=n.extract}r&&i.route&&i.kind!==BE&&lD(c,n)&&(c=n);let v=u===o;if(v&&(i.route&&(!a||i.kind===BE||i.kind===2)&&lD(l,n)&&(l=n),!i.optional&&!i.wildcard&&!i.index&&!i.pathless))continue;let y=v?void 0:t[u],b;if(v&&i.index){let n={node:i.index,index:u,skipped:d,depth:f+1,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_},r=!0;if(i.index.parse&&(cD(e,t,n)||(r=!1)),r){if(!m&&!h&&!d&&sD(p,o))return n;lD(l,n)&&(l=n)}}if(i.wildcard)for(let e=i.wildcard.length-1;e>=0;e--){let n=i.wildcard[e],{prefix:r,suffix:a}=n;if(!(r&&(v||!(n.caseSensitive?y:b??=y.toLowerCase()).startsWith(r)))){if(a){if(v)continue;let e=t.slice(u).join(`/`).slice(-a.length);if((n.caseSensitive?e:e.toLowerCase())!==a)continue}s.push({node:n,index:o,skipped:d,depth:f+1,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_})}}if(i.optional){let e=d|1<<f,t=f+1;for(let n=i.optional.length-1;n>=0;n--){let r=i.optional[n];s.push({node:r,index:u,skipped:e,depth:t,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_})}if(!v)for(let e=i.optional.length-1;e>=0;e--){let n=i.optional[e],{prefix:r,suffix:a}=n;if(r||a){let e=n.caseSensitive?y:b??=y.toLowerCase();if(r&&!e.startsWith(r)||a&&!e.endsWith(a))continue}s.push({node:n,index:u+1,skipped:d,depth:t,statics:p,dynamics:m,optionals:h+oD(o,u),extract:g,rawParams:_})}}if(!v&&i.dynamic&&y)for(let e=i.dynamic.length-1;e>=0;e--){let t=i.dynamic[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?y:b??=y.toLowerCase();if(n&&!e.startsWith(n)||r&&!e.endsWith(r))continue}s.push({node:t,index:u+1,skipped:d,depth:f+1,statics:p,dynamics:m+oD(o,u),optionals:h,extract:g,rawParams:_})}if(!v&&i.staticInsensitive){let e=i.staticInsensitive.get(b??=y.toLowerCase());e&&s.push({node:e,index:u+1,skipped:d,depth:f+1,statics:p+oD(o,u),dynamics:m,optionals:h,extract:g,rawParams:_})}if(!v&&i.static){let e=i.static.get(y);e&&s.push({node:e,index:u+1,skipped:d,depth:f+1,statics:p+oD(o,u),dynamics:m,optionals:h,extract:g,rawParams:_})}if(i.pathless){let e=f+1;for(let t=i.pathless.length-1;t>=0;t--){let n=i.pathless[t];s.push({node:n,index:u,skipped:d,depth:e,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_})}}}if(l)return l;if(r&&c){let n=c.index;for(let e=0;e<c.index;e++)n+=t[e].length;let r=n===e.length?`/`:e.slice(n);return c.rawParams??=Object.create(null),c.rawParams[`**`]=decodeURIComponent(r),c}return null}function oD(e,t){return 2**(e-t-1)}function sD(e,t){return e===2**(t-1)-1}function cD(e,t,n){let r,i;try{[r,i]=nD(e,t,n)}catch{return null}if(n.rawParams=r,n.extract=i,!n.node.parse)return!0;try{if(n.node.parse(r)===!1)return null}catch{}return!0}function lD(e,t){return!e||t.statics>e.statics||t.statics===e.statics&&(t.dynamics>e.dynamics||t.dynamics===e.dynamics&&(t.optionals>e.optionals||t.optionals===e.optionals&&((t.node.kind===BE)>(e.node.kind===BE)||t.node.kind===BE==(e.node.kind===BE)&&t.depth>e.depth)))}function uD(e){return dD(e.filter(e=>e!==void 0).join(`/`))}function dD(e){return e.replace(/\/{2,}/g,`/`)}function fD(e){return e===`/`?e:e.replace(/^\/{1,}/,``)}function pD(e){let t=e.length;return t>1&&e[t-1]===`/`?e.replace(/\/{1,}$/,``):e}function mD(e){return pD(fD(e))}function hD(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function gD(e,t,n){return hD(e,n)===hD(t,n)}function _D({base:e,to:t,trailingSlash:n=`never`,cache:r}){let i=t.startsWith(`/`),a=!i&&t===`.`,o;if(r){o=i?t:a?e:e+`\0`+t;let n=r.get(o);if(n)return n}let s;if(a)s=e.split(`/`);else if(i)s=t.split(`/`);else{for(s=e.split(`/`);s.length>1&&Mx(s)===``;)s.pop();let n=t.split(`/`);for(let e=0,t=n.length;e<t;e++){let r=n[e];r===``?e?e===t-1&&s.push(r):s=[r]:r===`..`?s.pop():r===`.`||s.push(r)}}s.length>1&&(Mx(s)===``?n===`never`&&s.pop():n===`always`&&s.push(``));let c=dD(s.join(`/`))||`/`;return o&&r&&r.set(o,c),c}function vD(e){let t=new Map(e.map(e=>[encodeURIComponent(e),e])),n=Array.from(t.keys()).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),r=new RegExp(n,`g`);return e=>e.replace(r,e=>t.get(e)??e)}function yD(e,t,n){let r=t[e];return typeof r==`string`?e===`_splat`?/^[a-zA-Z0-9\-._~!/]*$/.test(r)?r:r.split(`/`).map(e=>xD(e,n)).join(`/`):xD(r,n):r}function bD({path:e,params:t,decoder:n,...r}){let i=!1,a=Object.create(null);if(!e||e===`/`)return{interpolatedPath:`/`,usedParams:a,isMissingParams:i};if(!e.includes(`$`))return{interpolatedPath:e,usedParams:a,isMissingParams:i};let o=e.length,s=0,c,l=``;for(;s<o;){let r=s;c=UE(e,r,c);let o=c[5];if(s=o+1,r===o)continue;let u=c[0];if(u===0){l+=`/`+e.substring(r,o);continue}if(u===2){let s=t._splat;a._splat=s,a[`*`]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o);if(!s){i=!0,(u||d)&&(l+=`/`+u+d);continue}let f=yD(`_splat`,t,n);l+=`/`+u+f+d;continue}if(u===1){let s=e.substring(c[2],c[3]);!i&&!(s in t)&&(i=!0),a[s]=t[s];let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=yD(s,t,n)??`undefined`;l+=`/`+u+f+d;continue}if(u===3){let i=e.substring(c[2],c[3]),s=t[i];if(s==null)continue;a[i]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=yD(i,t,n)??``;l+=`/`+u+f+d;continue}}return e.endsWith(`/`)&&(l+=`/`),{usedParams:a,interpolatedPath:l||`/`,isMissingParams:i}}function xD(e,t){let n=encodeURIComponent(e);return t?.(n)??n}function SD(e){return e?.isNotFound===!0}function CD(e,t=String){let n=new URLSearchParams;for(let r in e){let i=e[r];i!==void 0&&n.set(r,t(i))}return n.toString()}function wD(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function TD(e){let t=new URLSearchParams(e),n=Object.create(null);for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=wD(r):Array.isArray(t)?t.push(wD(r)):n[e]=[t,wD(r)]}return n}var ED=OD(JSON.parse),DD=kD(JSON.stringify,JSON.parse);function OD(e){return t=>{t[0]===`?`&&(t=t.substring(1));let n=TD(t);for(let t in n){let r=n[t];if(typeof r==`string`)try{n[t]=e(r)}catch{}}return n}}function kD(e,t){let n=typeof t==`function`;function r(r){if(typeof r==`object`&&r)try{return e(r)}catch{}else if(n&&typeof r==`string`)try{return t(r),e(r)}catch{}return r}return e=>{let t=CD(e,r);return t?`?${t}`:``}}var AD=`__root__`;function jD(e){if(e.statusCode=e.statusCode||e.code||307,!e._builtLocation&&!e.reloadDocument&&typeof e.href==`string`)try{new URL(e.href),e.reloadDocument=!0}catch{}let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function MD(e){return e instanceof Response&&!!e.options}var ND=e=>{if(!e.rendered)return e.rendered=!0,e.onReady?.()},PD=e=>e.stores.matchesId.get().some(t=>e.stores.matchStores.get(t)?.get()._forcePending),FD=(e,t)=>!!(e.preload&&!e.router.stores.matchStores.has(t)),ID=(e,t,n=!0)=>{let r={...e.router.options.context??{}},i=n?t:t-1;for(let t=0;t<=i;t++){let n=e.matches[t];if(!n)continue;let i=e.router.getMatch(n.id);i&&Object.assign(r,i.__routeContext,i.__beforeLoadContext)}return r},LD=(e,t)=>{if(!e.matches.length)return;let n=t.routeId,r=e.matches.findIndex(t=>t.routeId===e.router.routeTree.id),i=r>=0?r:0,a=n?e.matches.findIndex(e=>e.routeId===n):e.firstBadMatchIndex??e.matches.length-1;a<0&&(a=i);for(let t=a;t>=0;t--){let n=e.matches[t];if(e.router.looseRoutesById[n.routeId].options.notFoundComponent)return t}return n?a:i},RD=(e,t,n)=>{if(!(!MD(n)&&!SD(n)))throw MD(n)&&n.redirectHandled&&!n.options.reloadDocument?n:(t&&(t._nonReactive.beforeLoadPromise?.resolve(),t._nonReactive.loaderPromise?.resolve(),t._nonReactive.beforeLoadPromise=void 0,t._nonReactive.loaderPromise=void 0,t._nonReactive.error=n,e.updateMatch(t.id,r=>({...r,status:MD(n)?`redirected`:SD(n)?`notFound`:r.status===`pending`?`success`:r.status,context:ID(e,t.index),isFetching:!1,error:n})),SD(n)&&!n.routeId&&(n.routeId=t.routeId),t._nonReactive.loadPromise?.resolve()),MD(n)&&(e.rendered=!0,n.options._fromLocation=e.location,n.redirectHandled=!0,n=e.router.resolveRedirect(n)),n)},zD=(e,t)=>{let n=e.router.getMatch(t);return!!(!n||n._nonReactive.dehydrated)},BD=(e,t,n)=>{let r=ID(e,n);e.updateMatch(t,e=>({...e,context:r}))},VD=(e,t,n)=>{let{id:r,routeId:i}=e.matches[t],a=e.router.looseRoutesById[i];if(n instanceof Promise)throw n;e.firstBadMatchIndex??=t,RD(e,e.router.getMatch(r),n);try{a.options.onError?.(n)}catch(t){n=t,RD(e,e.router.getMatch(r),n)}e.updateMatch(r,e=>(e._nonReactive.beforeLoadPromise?.resolve(),e._nonReactive.beforeLoadPromise=void 0,e._nonReactive.loadPromise?.resolve(),{...e,error:n,status:`error`,isFetching:!1,updatedAt:Date.now(),abortController:new AbortController})),!e.preload&&!MD(n)&&!SD(n)&&(e.serialError??=n)},HD=(e,t,n,r)=>{if(r._nonReactive.pendingTimeout!==void 0)return;let i=n.options.pendingMs??e.router.options.defaultPendingMs;if(e.onReady&&!FD(e,t)&&(n.options.loader||n.options.beforeLoad||$D(n))&&typeof i==`number`&&i!==1/0&&(n.options.pendingComponent??e.router.options?.defaultPendingComponent)){let t=setTimeout(()=>{ND(e)},i);r._nonReactive.pendingTimeout=t}},UD=(e,t,n)=>{let r=e.router.getMatch(t);if(!r._nonReactive.beforeLoadPromise&&!r._nonReactive.loaderPromise)return;HD(e,t,n,r);let i=()=>{let n=e.router.getMatch(t);n.preload&&(n.status===`redirected`||n.status===`notFound`)&&RD(e,n,n.error)};return r._nonReactive.beforeLoadPromise?r._nonReactive.beforeLoadPromise.then(i):i()},WD=(e,t,n,r)=>{let i=e.router.getMatch(t),a=i._nonReactive.loadPromise;i._nonReactive.loadPromise=Px(()=>{a?.resolve(),a=void 0});let{paramsError:o,searchError:s}=i;o&&VD(e,n,o),s&&VD(e,n,s),HD(e,t,r,i);let c=new AbortController,l=!1,u=()=>{l||(l=!0,e.updateMatch(t,e=>({...e,isFetching:`beforeLoad`,fetchCount:e.fetchCount+1,abortController:c})))},d=()=>{i._nonReactive.beforeLoadPromise?.resolve(),i._nonReactive.beforeLoadPromise=void 0,e.updateMatch(t,e=>({...e,isFetching:!1}))};if(!r.options.beforeLoad){e.router.batch(()=>{u(),d()});return}i._nonReactive.beforeLoadPromise=Px();let f={...ID(e,n,!1),...i.__routeContext},{search:p,params:m,cause:h}=i,g=FD(e,t),_={search:p,abortController:c,params:m,preload:g,context:f,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),buildLocation:e.router.buildLocation,cause:g?`preload`:h,matches:e.matches,routeId:r.id,...e.router.options.additionalContext},v=r=>{if(r===void 0){e.router.batch(()=>{u(),d()});return}(MD(r)||SD(r))&&(u(),VD(e,n,r)),e.router.batch(()=>{u(),e.updateMatch(t,e=>({...e,__beforeLoadContext:r})),d()})},y;try{if(y=r.options.beforeLoad(_),Yx(y))return u(),y.catch(t=>{VD(e,n,t)}).then(v)}catch(t){u(),VD(e,n,t)}v(y)},GD=(e,t)=>{let{id:n,routeId:r}=e.matches[t],i=e.router.looseRoutesById[r],a=()=>s(),o=()=>WD(e,n,t,i),s=()=>{if(zD(e,n))return;let t=UD(e,n,i);return Yx(t)?t.then(o):o()};return a()},KD=(e,t,n)=>{let r=e.router.getMatch(t);if(!r||!n.options.head&&!n.options.scripts&&!n.options.headers)return;let i={ssr:e.router.options.ssr,matches:e.matches,match:r,params:r.params,loaderData:r.loaderData};return Promise.all([n.options.head?.(i),n.options.scripts?.(i),n.options.headers?.(i)]).then(([e,t,n])=>({meta:e?.meta,links:e?.links,headScripts:e?.scripts,headers:n,scripts:t,styles:e?.styles}))},qD=(e,t,n,r,i)=>{let a=t[r-1],{params:o,loaderDeps:s,abortController:c,cause:l}=e.router.getMatch(n),u=ID(e,r),d=FD(e,n);return{params:o,deps:s,preload:!!d,parentMatchPromise:a,abortController:c,context:u,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),cause:d?`preload`:l,route:i,...e.router.options.additionalContext}},JD=async(e,t,n,r,i)=>{try{let a=e.router.getMatch(n);try{QD(i);let o=i.options.loader,s=typeof o==`function`?o:o?.handler,c=s?.(qD(e,t,n,r,i)),l=!!s&&Yx(c);if((l||i._lazyPromise||i._componentsPromise||i.options.head||i.options.scripts||i.options.headers||a._nonReactive.minPendingPromise)&&e.updateMatch(n,e=>({...e,isFetching:`loader`})),s){let t=l?await c:c;RD(e,e.router.getMatch(n),t),t!==void 0&&e.updateMatch(n,e=>({...e,loaderData:t}))}i._lazyPromise&&await i._lazyPromise;let u=a._nonReactive.minPendingPromise;u&&await u,i._componentsPromise&&await i._componentsPromise,e.updateMatch(n,t=>({...t,error:void 0,context:ID(e,r),status:`success`,isFetching:!1,updatedAt:Date.now()}))}catch(t){let o=t;if(o?.name===`AbortError`){if(a.abortController.signal.aborted){a._nonReactive.loaderPromise?.resolve(),a._nonReactive.loaderPromise=void 0;return}e.updateMatch(n,t=>({...t,status:t.status===`pending`?`success`:t.status,isFetching:!1,context:ID(e,r)}));return}let s=a._nonReactive.minPendingPromise;s&&await s,SD(t)&&await i.options.notFoundComponent?.preload?.(),RD(e,e.router.getMatch(n),t);try{i.options.onError?.(t)}catch(t){o=t,RD(e,e.router.getMatch(n),t)}!MD(o)&&!SD(o)&&await QD(i,[`errorComponent`]),e.updateMatch(n,t=>({...t,error:o,context:ID(e,r),status:`error`,isFetching:!1}))}}catch(t){let r=e.router.getMatch(n);r&&(r._nonReactive.loaderPromise=void 0),RD(e,r,t)}},YD=async(e,t,n)=>{async function r(r,a,c,l,d){let f=Date.now()-a.updatedAt,p=r?d.options.preloadStaleTime??e.router.options.defaultPreloadStaleTime??3e4:d.options.staleTime??e.router.options.defaultStaleTime??0,m=d.options.shouldReload,h=typeof m==`function`?m(qD(e,t,i,n,d)):m,{status:g,invalid:_}=l,v=f>=p&&(!!e.forceStaleReload||l.cause===`enter`||c!==void 0&&c!==l.id);o=g===`success`&&(_||(h??v)),r&&d.options.preload===!1||(o&&!e.sync&&u?(s=!0,(async()=>{try{await JD(e,t,i,n,d);let r=e.router.getMatch(i);r._nonReactive.loaderPromise?.resolve(),r._nonReactive.loadPromise?.resolve(),r._nonReactive.loaderPromise=void 0,r._nonReactive.loadPromise=void 0}catch(t){MD(t)&&await e.router.navigate(t.options)}})()):g!==`success`||o?await JD(e,t,i,n,d):BD(e,i,n))}let{id:i,routeId:a}=e.matches[n],o=!1,s=!1,c=e.router.looseRoutesById[a],l=c.options.loader,u=((typeof l==`function`?void 0:l?.staleReloadMode)??e.router.options.defaultStaleReloadMode)!==`blocking`;if(zD(e,i)){if(!e.router.getMatch(i))return e.matches[n];BD(e,i,n)}else{let t=e.router.getMatch(i),o=e.router.stores.matchesId.get()[n],s=(o&&e.router.stores.matchStores.get(o)||null)?.routeId===a?o:e.router.stores.matches.get().find(e=>e.routeId===a)?.id,l=FD(e,i);if(t._nonReactive.loaderPromise){if(t.status===`success`&&!e.sync&&!t.preload&&u)return t;await t._nonReactive.loaderPromise;let n=e.router.getMatch(i),a=n._nonReactive.error||n.error;a&&RD(e,n,a),n.status===`pending`&&await r(l,t,s,n,c)}else{let n=l&&!e.router.stores.matchStores.has(i),a=e.router.getMatch(i);a._nonReactive.loaderPromise=Px(),n!==a.preload&&e.updateMatch(i,e=>({...e,preload:n})),await r(l,t,s,a,c)}}let d=e.router.getMatch(i);s||(d._nonReactive.loaderPromise?.resolve(),d._nonReactive.loadPromise?.resolve(),d._nonReactive.loadPromise=void 0),clearTimeout(d._nonReactive.pendingTimeout),d._nonReactive.pendingTimeout=void 0,s||(d._nonReactive.loaderPromise=void 0),d._nonReactive.dehydrated=void 0;let f=s?d.isFetching:!1;return f!==d.isFetching||d.invalid!==!1?(e.updateMatch(i,e=>({...e,isFetching:f,invalid:!1})),e.router.getMatch(i)):d};async function XD(e){let t=e,n=[];PD(t.router)&&ND(t);let r;for(let e=0;e<t.matches.length;e++){try{let n=GD(t,e);Yx(n)&&await n}catch(e){if(MD(e))throw e;if(SD(e))r=e;else if(!t.preload)throw e;break}if(t.serialError||t.firstBadMatchIndex!=null)break}let i=t.firstBadMatchIndex??t.matches.length,a=r&&!t.preload?LD(t,r):void 0,o=r&&t.preload?0:a===void 0?i:Math.min(a+1,i),s,c;for(let e=0;e<o;e++)n.push(YD(t,n,e));try{await Promise.all(n)}catch{let e=await Promise.allSettled(n);for(let t of e){if(t.status!==`rejected`)continue;let e=t.reason;if(MD(e))throw e;SD(e)?s??=e:c??=e}if(c!==void 0)throw c}let l=s??(r&&!t.preload?r:void 0),u=t.firstBadMatchIndex===void 0?t.matches.length-1:t.firstBadMatchIndex;if(!l&&r&&t.preload)return t.matches;if(l){let e=LD(t,l);e===void 0&&Nx();let n=t.matches[e],r=t.router.looseRoutesById[n.routeId],i=t.router.options?.defaultNotFoundComponent;!r.options.notFoundComponent&&i&&(r.options.notFoundComponent=i),l.routeId=n.routeId;let a=n.routeId===t.router.routeTree.id;t.updateMatch(n.id,e=>({...e,...a?{status:`success`,globalNotFound:!0,error:void 0}:{status:`notFound`,error:l},isFetching:!1})),u=e,await QD(r,[`notFoundComponent`])}else if(!t.preload){let e=t.matches[0];e.globalNotFound||t.router.getMatch(e.id)?.globalNotFound&&t.updateMatch(e.id,e=>({...e,globalNotFound:!1,error:void 0}))}if(t.serialError&&t.firstBadMatchIndex!==void 0){let e=t.router.looseRoutesById[t.matches[t.firstBadMatchIndex].routeId];await QD(e,[`errorComponent`])}for(let e=0;e<=u;e++){let{id:n,routeId:r}=t.matches[e],i=t.router.looseRoutesById[r];try{let e=KD(t,n,i);if(e){let r=await e;t.updateMatch(n,e=>({...e,...r}))}}catch(e){console.error(`Error executing head for route ${r}:`,e)}}let d=ND(t);if(Yx(d)&&await d,l)throw l;if(t.serialError&&!t.preload&&!t.onReady)throw t.serialError;return t.matches}function ZD(e,t){let n=t.map(t=>e.options[t]?.preload?.()).filter(Boolean);if(n.length!==0)return Promise.all(n)}function QD(e,t=eO){!e._lazyLoaded&&e._lazyPromise===void 0&&(e.lazyFn?e._lazyPromise=e.lazyFn().then(t=>{let{id:n,...r}=t.options;Object.assign(e.options,r),e._lazyLoaded=!0,e._lazyPromise=void 0}):e._lazyLoaded=!0);let n=()=>e._componentsLoaded?void 0:t===eO?(()=>{if(e._componentsPromise===void 0){let t=ZD(e,eO);t?e._componentsPromise=t.then(()=>{e._componentsLoaded=!0,e._componentsPromise=void 0}):e._componentsLoaded=!0}return e._componentsPromise})():ZD(e,t);return e._lazyPromise?e._lazyPromise.then(n):n()}function $D(e){for(let t of eO)if(e.options[t]?.preload)return!0;return!1}var eO=[`component`,`errorComponent`,`pendingComponent`,`notFoundComponent`];function tO(e){return{input:({url:t})=>{for(let n of e)t=rO(n,t);return t},output:({url:t})=>{for(let n=e.length-1;n>=0;n--)t=iO(e[n],t);return t}}}function nO(e){let t=mD(e.basepath),n=`/${t}`,r=e.caseSensitive?n:n.toLowerCase(),i=`${r}/`;return{input:({url:t})=>{let a=e.caseSensitive?t.pathname:t.pathname.toLowerCase();return a===r?t.pathname=`/`:a.startsWith(i)&&(t.pathname=t.pathname.slice(n.length)),t},output:({url:e})=>(e.pathname=uD([`/`,t,e.pathname]),e)}}function rO(e,t){let n=e?.input?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function iO(e,t){let n=e?.output?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function aO(e,t){let{createMutableStore:n,createReadonlyStore:r,batch:i,init:a}=t,o=new Map,s=new Map,c=new Map,l=n(e.status),u=n(e.loadedAt),d=n(e.isLoading),f=n(e.isTransitioning),p=n(e.location),m=n(e.resolvedLocation),h=n(e.statusCode),g=n(e.redirect),_=n([]),v=n([]),y=n([]),b=r(()=>oO(o,_.get())),x=r(()=>oO(s,v.get())),S=r(()=>oO(c,y.get())),C=r(()=>_.get()[0]),w=r(()=>_.get().some(e=>o.get(e)?.get().status===`pending`)),T=r(()=>({locationHref:p.get().href,resolvedLocationHref:m.get()?.href,status:l.get()})),E=r(()=>({status:l.get(),loadedAt:u.get(),isLoading:d.get(),isTransitioning:f.get(),matches:b.get(),location:p.get(),resolvedLocation:m.get(),statusCode:h.get(),redirect:g.get()})),D=zE(64);function O(e){let t=D.get(e);return t||(t=r(()=>{let t=_.get();for(let n of t){let t=o.get(n);if(t&&t.routeId===e)return t.get()}}),D.set(e,t)),t}let k={status:l,loadedAt:u,isLoading:d,isTransitioning:f,location:p,resolvedLocation:m,statusCode:h,redirect:g,matchesId:_,pendingIds:v,cachedIds:y,matches:b,pendingMatches:x,cachedMatches:S,firstId:C,hasPending:w,matchRouteDeps:T,matchStores:o,pendingMatchStores:s,cachedMatchStores:c,__store:E,getRouteMatchStore:O,setMatches:A,setPending:j,setCached:M};A(e.matches),a?.(k);function A(e){sO(e,o,_,n,i)}function j(e){sO(e,s,v,n,i)}function M(e){sO(e,c,y,n,i)}return k}function oO(e,t){let n=[];for(let r of t){let t=e.get(r);t&&n.push(t.get())}return n}function sO(e,t,n,r,i){let a=e.map(e=>e.id),o=new Set(a);i(()=>{for(let e of t.keys())o.has(e)||t.delete(e);for(let n of e){let e=t.get(n.id);if(!e){let e=r(n);e.routeId=n.routeId,t.set(n.id,e);continue}e.routeId=n.routeId,e.get()!==n&&e.set(n)}qx(n.get(),a)||n.set(a)})}var cO=`__TSR_index`,lO=`popstate`,uO=`beforeunload`;function dO(e){let t=e.getLocation(),n=new Set,r=r=>{t=e.getLocation(),n.forEach(e=>e({location:t,action:r}))},i=n=>{e.notifyOnIndexChange??!0?r(n):t=e.getLocation()},a=async({task:n,navigateOpts:r,...i})=>{if(r?.ignoreBlocker??!1){n();return}let a=e.getBlockers?.()??[],o=i.type===`PUSH`||i.type===`REPLACE`;if(typeof document<`u`&&a.length&&o)for(let n of a){let r=hO(i.path,i.state);if(await n.blockerFn({currentLocation:t,nextLocation:r,action:i.type})){e.onBlocked?.();return}}n()};return{get location(){return t},get length(){return e.getLength()},subscribers:n,subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(n,i,o)=>{let s=t.state[cO];i=fO(s+1,i),a({task:()=>{e.pushState(n,i),r({type:`PUSH`})},navigateOpts:o,type:`PUSH`,path:n,state:i})},replace:(n,i,o)=>{let s=t.state[cO];i=fO(s,i),a({task:()=>{e.replaceState(n,i),r({type:`REPLACE`})},navigateOpts:o,type:`REPLACE`,path:n,state:i})},go:(t,n)=>{a({task:()=>{e.go(t),i({type:`GO`,index:t})},navigateOpts:n,type:`GO`})},back:t=>{a({task:()=>{e.back(t?.ignoreBlocker??!1),i({type:`BACK`})},navigateOpts:t,type:`BACK`})},forward:t=>{a({task:()=>{e.forward(t?.ignoreBlocker??!1),i({type:`FORWARD`})},navigateOpts:t,type:`FORWARD`})},canGoBack:()=>t.state[cO]!==0,createHref:t=>e.createHref(t),block:t=>{if(!e.setBlockers)return()=>{};let n=e.getBlockers?.()??[];return e.setBlockers([...n,t]),()=>{let n=e.getBlockers?.()??[];e.setBlockers?.(n.filter(e=>e!==t))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:r}}function fO(e,t){t||={};let n=gO();return{...t,key:n,__TSR_key:n,[cO]:e}}function pO(e){let t=e?.window??(typeof document<`u`?window:void 0),n=t.history.pushState,r=t.history.replaceState,i=[],a=()=>i,o=e=>i=e,s=e?.createHref??(e=>e),c=e?.parseLocation??(()=>hO(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){let e=gO();t.history.replaceState({[cO]:0,key:e,__TSR_key:e},``)}let l=c(),u,d=!1,f=!1,p=!1,m=!1,h=()=>l,g,_,v=()=>{g&&(C._ignoreSubscribers=!0,(g.isPush?t.history.pushState:t.history.replaceState)(g.state,``,g.href),C._ignoreSubscribers=!1,g=void 0,_=void 0,u=void 0)},y=(e,t,n)=>{let r=s(t);_||(u=l),l=hO(t,n),g={href:r,state:n,isPush:g?.isPush||e===`push`},_||=Promise.resolve().then(()=>v())},b=e=>{l=c(),C.notify({type:e})},x=async()=>{if(f){f=!1;return}let e=c(),n=e.state[cO]-l.state[cO],r=n===1,i=n===-1,o=!r&&!i||d;d=!1;let s=o?`GO`:i?`BACK`:`FORWARD`,u=o?{type:`GO`,index:n}:{type:i?`BACK`:`FORWARD`};if(p)p=!1;else{let n=a();if(typeof document<`u`&&n.length){for(let r of n)if(await r.blockerFn({currentLocation:l,nextLocation:e,action:s})){f=!0,t.history.go(1),C.notify(u);return}}}l=c(),C.notify(u)},S=e=>{if(m){m=!1;return}let t=!1,n=a();if(typeof document<`u`&&n.length)for(let e of n){let n=e.enableBeforeUnload??!0;if(n===!0){t=!0;break}if(typeof n==`function`&&n()===!0){t=!0;break}}if(t)return e.preventDefault(),e.returnValue=``},C=dO({getLocation:h,getLength:()=>t.history.length,pushState:(e,t)=>y(`push`,e,t),replaceState:(e,t)=>y(`replace`,e,t),back:e=>(e&&(p=!0),m=!0,t.history.back()),forward:e=>{e&&(p=!0),m=!0,t.history.forward()},go:e=>{d=!0,t.history.go(e)},createHref:e=>s(e),flush:v,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener(uO,S,{capture:!0}),t.removeEventListener(lO,x)},onBlocked:()=>{u&&l!==u&&(l=u)},getBlockers:a,setBlockers:o,notifyOnIndexChange:!1});return t.addEventListener(uO,S,{capture:!0}),t.addEventListener(lO,x),t.history.pushState=function(...e){let r=n.apply(t.history,e);return C._ignoreSubscribers||b(`PUSH`),r},t.history.replaceState=function(...e){let n=r.apply(t.history,e);return C._ignoreSubscribers||b(`REPLACE`),n},C}function mO(e){let t=e.replace(/[\x00-\x1f\x7f]/g,``);return t.startsWith(`//`)&&(t=`/`+t.replace(/^\/+/,``)),t}function hO(e,t){let n=mO(e),r=n.indexOf(`#`),i=n.indexOf(`?`),a=gO();return{href:n,pathname:n.substring(0,r>0?i>0?Math.min(r,i):r:i>0?i:n.length),hash:r>-1?n.substring(r):``,search:i>-1?n.slice(i,r===-1?void 0:r):``,state:t||{[cO]:0,key:a,__TSR_key:a}}}function gO(){return(Math.random()+1).toString(36).substring(7)}function _O(e,t){let n=t,r=e;return{fromLocation:n,toLocation:r,pathChanged:n?.pathname!==r.pathname,hrefChanged:n?.href!==r.href,hashChanged:n?.hash!==r.hash}}var vO=new WeakMap,yO=class{constructor(e,t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this._scroll={next:!0},this.shouldViewTransition=void 0,this.isViewTransitionTypesSupported=void 0,this.subscribers=new Set,this.routeBranchCache=new WeakMap,this.startTransition=e=>e(),this.update=e=>{let t=this.options,n=this.basepath??t?.basepath??`/`,r=this.basepath===void 0,i=t?.rewrite;if(this.options={...t,...e},this.isServer=this.options.isServer??typeof document>`u`,this.protocolAllowlist=new Set(this.options.protocolAllowlist),this.options.pathParamsAllowedCharacters&&(this.pathParamsDecoder=vD(this.options.pathParamsAllowedCharacters)),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.options.history?this.history=this.options.history:this.history=pO()),this.origin=this.options.origin,this.origin||(window?.origin&&window.origin!==`null`?this.origin=window.origin:this.origin=`http://localhost`),this.history&&this.updateLatestLocation(),this.options.routeTree!==this.routeTree){this.routeTree=this.options.routeTree;let e;this.resolvePathCache=zE(1e3),e=this.buildRouteTree(),this.setRoutes(e)}if(!this.stores&&this.latestLocation){let e=this.getStoreConfig(this);this.batch=e.batch,this.stores=aO(SO(this.latestLocation),e),HO(this)}let a=!1,o=this.options.basepath??`/`,s=this.options.rewrite;if(r||n!==o||i!==s){this.basepath=o;let e=[],t=mD(o);t&&t!==`/`&&e.push(nO({basepath:o})),s&&e.push(s),this.rewrite=e.length===0?void 0:e.length===1?e[0]:tO(e),this.history&&this.updateLatestLocation(),a=!0}a&&this.stores&&this.stores.location.set(this.latestLocation),typeof window<`u`&&`CSS`in window&&typeof window.CSS?.supports==`function`&&(this.isViewTransitionTypesSupported=window.CSS.supports(`selector(:active-view-transition-type(a))`))},this.updateLatestLocation=()=>{this.latestLocation=this.parseLocation(this.history.location,this.latestLocation)},this.buildRouteTree=()=>{let e=eD(this.routeTree,this.options.caseSensitive,(e,t)=>{e.init({originalIndex:t})});return this.options.routeMasks&&YE(this.options.routeMasks,e.processedTree),e},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{this.subscribers.forEach(t=>{t.eventType===e.type&&t.fn(e)})},this.parseLocation=(e,t)=>{let n=({pathname:e,search:n,hash:r,href:i,state:a})=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(e)){let i=this.options.parseSearch(n),o=this.options.stringifySearch(i);return{href:e+o+r,publicHref:e+o+r,pathname:Fx(e).path,external:!1,searchStr:o,search:Jx(t?.search,i),hash:Fx(r.slice(1)).path,state:kx(t?.state,a)}}let o=new URL(i,this.origin),s=rO(this.rewrite,o),c=this.options.parseSearch(s.search),l=this.options.stringifySearch(c);return s.search=l,{href:s.href.replace(s.origin,``),publicHref:i,pathname:Fx(s.pathname).path,external:!!this.rewrite&&s.origin!==this.origin,searchStr:l,search:Jx(t?.search,c),hash:Fx(s.hash.slice(1)).path,state:kx(t?.state,a)}},r=n(e),{__tempLocation:i,__tempKey:a}=r.state;if(i&&(!a||a===this.tempLocationKey)){let e=n(i);return e.state.key=r.state.key,e.state.__TSR_key=r.state.__TSR_key,delete e.state.__tempLocation,{...e,maskedLocation:r}}return r},this.resolvePathWithBase=(e,t)=>_D({base:e,to:t.includes(`//`)?dD(t):t,trailingSlash:this.options.trailingSlash,cache:this.resolvePathCache}),this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=e=>wO({pathname:e,routesById:this.routesById,processedTree:this.processedTree}),this.cancelMatch=e=>{let t=this.getMatch(e);t&&(t.abortController.abort(),clearTimeout(t._nonReactive.pendingTimeout),t._nonReactive.pendingTimeout=void 0)},this.cancelMatches=()=>{this.stores.pendingIds.get().forEach(e=>{this.cancelMatch(e)}),this.stores.matchesId.get().forEach(e=>{if(this.stores.pendingMatchStores.has(e))return;let t=this.stores.matchStores.get(e)?.get();t&&(t.status===`pending`||t.isFetching===`loader`)&&this.cancelMatch(e)})},this.buildLocation=e=>{let t=(t={})=>{let n=t._fromLocation||this.pendingBuiltLocation||this.latestLocation,r=this.matchRoutesLightweight(n);t.from;let i=t.unsafeRelative===`path`?n.pathname:t.from??r.fullPath,a=t.to?`${t.to}`:void 0,o=r.search,s=Object.assign(Object.create(null),r.params),c=a?.charCodeAt(0)===47?`/`:this.resolvePathWithBase(i,`.`),l=a?this.resolvePathWithBase(c,a):c,u=t.params===!1||t.params===null?Object.create(null):(t.params??!0)===!0?s:Object.assign(s,Lx(t.params,s)),d=this.routesByPath[pD(l)],f;if(d)f=this.getRouteBranch(d);else if(l.includes(`$`))f=[];else{let e=this.getMatchedRoutes(l);f=e.matchedRoutes,this.options.notFoundRoute&&(!e.foundRoute||e.foundRoute.path!==`/`&&e.routeParams[`**`])&&(f=[...f,this.options.notFoundRoute])}if(f.length&&Ix(u))for(let e of f){let t=e.options.params?.stringify??e.options.stringifyParams;if(t)try{Object.assign(u,t(u))}catch{}}let p=e.leaveParams?l:Fx(bD({path:l,params:u,decoder:this.pathParamsDecoder,server:this.isServer}).interpolatedPath).path,m=o;if(e._includeValidateSearch&&this.options.search?.strict){let e={};f.forEach(t=>{if(t.options.validateSearch)try{Object.assign(e,CO(t.options.validateSearch,{...e,...m}))}catch{}}),m=e}m=TO({search:m,dest:t,destRoutes:f,_includeValidateSearch:e._includeValidateSearch}),m=Jx(o,m);let h=this.options.stringifySearch(m),g=t.hash===!0?n.hash:t.hash?Lx(t.hash,n.hash):void 0,_=g?`#${g}`:``,v=t.state===!0?n.state:t.state?Lx(t.state,n.state):{};v=kx(n.state,v);let y=`${p}${h}${_}`,b,x,S=!1;if(this.rewrite){let e=new URL(y,this.origin),t=iO(this.rewrite,e);b=e.href.replace(e.origin,``),t.origin===this.origin?x=t.pathname+t.search+t.hash:(x=t.href,S=!0)}else b=Bx(y),x=b;return{publicHref:x,href:b,pathname:p,search:m,searchStr:h,state:v,hash:g??``,external:S,unmaskOnReload:t.unmaskOnReload}},n=(n={},r)=>{let i=t(n),a=r?t(r):void 0;if(!a){let n=Object.create(null);if(this.options.routeMasks){let o=XE(i.pathname,this.processedTree);if(o){Object.assign(n,o.rawParams);let{from:i,params:s,...c}=o.route,l=s===!1||s===null?Object.create(null):(s??!0)===!0?n:Object.assign(n,Lx(s,n));r={from:e.from,...c,params:l},a=t(r)}}}return a&&(i.maskedLocation=a),i};return e.mask?n(e,{from:e.from,...e.mask}):n(e)},this.commitLocation=async({viewTransition:e,ignoreBlocker:t,...n})=>{let r,i=()=>{let e=[`key`,`__TSR_key`,`__TSR_index`,`__hashScrollIntoViewOptions`];e.forEach(e=>{n.state[e]=this.latestLocation.state[e]});let t=Ux(n.state,this.latestLocation.state);return e.forEach(e=>{delete n.state[e]}),t},a=pD(this.latestLocation.href)===pD(n.href),o=this.commitLocationPromise;if(this.commitLocationPromise=Px(()=>{o?.resolve(),o=void 0}),a&&i())this.load();else{let{maskedLocation:i,hashScrollIntoView:a,...o}=n;i&&(o={...i,state:{...i.state,__tempKey:void 0,__tempLocation:{...o,search:o.searchStr,state:{...o.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(o.unmaskOnReload??this.options.unmaskOnReload??!1)&&(o.state.__tempKey=this.tempLocationKey)),o.state.__hashScrollIntoViewOptions=a??this.options.defaultHashScrollIntoView??!0,this.shouldViewTransition=e,r=n.replace?`REPLACE`:`PUSH`,this.history[r===`REPLACE`?`replace`:`push`](o.publicHref,o.state,{ignoreBlocker:t})}return this._scroll.next=n.resetScroll??!0,this.history.subscribers.size||this.load(r?{action:{type:r}}:void 0),this.commitLocationPromise},this.buildAndCommitLocation=({replace:e,resetScroll:t,hashScrollIntoView:n,viewTransition:r,ignoreBlocker:i,href:a,...o}={})=>{if(a){let t=this.history.location.state.__TSR_index,n=hO(a,{__TSR_index:e?t:t+1}),r=new URL(n.pathname,this.origin);o.to=rO(this.rewrite,r).pathname,o.search=this.options.parseSearch(n.search),o.hash=n.hash.slice(1)}let s=this.buildLocation({...o,_includeValidateSearch:!0});this.pendingBuiltLocation=s;let c=this.commitLocation({...s,viewTransition:r,replace:e,resetScroll:t,hashScrollIntoView:n,ignoreBlocker:i});return Promise.resolve().then(()=>{this.pendingBuiltLocation===s&&(this.pendingBuiltLocation=void 0)}),c},this.navigate=async({to:e,reloadDocument:t,href:n,publicHref:r,...i})=>{let a=!1;if(n)try{new URL(`${n}`),a=!0}catch{}if(a&&!t&&(t=!0),t){if(e!==void 0||!n){let t=this.buildLocation({to:e,...i});n??=t.publicHref,r??=t.publicHref}let t=!a&&r?r:n;if(Ax(t,this.protocolAllowlist))return Promise.resolve();if(!i.ignoreBlocker){let e=this.history.getBlockers?.()??[];for(let t of e)if(t?.blockerFn&&await t.blockerFn({currentLocation:this.latestLocation,nextLocation:this.latestLocation,action:`PUSH`}))return Promise.resolve()}return i.replace?window.location.replace(t):window.location.href=t,Promise.resolve()}return this.buildAndCommitLocation({...i,href:n,to:e,_isNavigate:!0})},this.beforeLoad=()=>{this.cancelMatches(),this.updateLatestLocation();let e=this.matchRoutes(this.latestLocation),t=this.stores.cachedMatches.get().filter(t=>!e.some(e=>e.id===t.id));this.batch(()=>{this.stores.status.set(`pending`),this.stores.statusCode.set(200),this.stores.isLoading.set(!0),this.stores.location.set(this.latestLocation),this.stores.setPending(e),this.stores.setCached(t)})},this.load=async e=>{let t=e?.action?.type,n,r,i,a=this.stores.resolvedLocation.get()??this.stores.location.get();for(i=new Promise(o=>{this.startTransition(async()=>{try{this.beforeLoad(),t?vO.set(this.latestLocation,t):vO.delete(this.latestLocation);let n=this.latestLocation,r=_O(n,this.stores.resolvedLocation.get());this.stores.redirect.get()||this.emit({type:`onBeforeNavigate`,...r}),this.emit({type:`onBeforeLoad`,...r}),await XD({router:this,sync:e?.sync,forceStaleReload:a.href===n.href,matches:this.stores.pendingMatches.get(),location:n,updateMatch:this.updateMatch,onReady:async()=>{this.startTransition(()=>{this.startViewTransition(async()=>{let e=null,t=null,n=null,r=null;this.batch(()=>{let i=this.stores.pendingMatches.get(),a=i.length,o=this.stores.matches.get();e=a?o.filter(e=>!this.stores.pendingMatchStores.has(e.id)):null;let s=new Set;for(let e of this.stores.pendingMatchStores.values())e.routeId&&s.add(e.routeId);let c=new Set;for(let e of this.stores.matchStores.values())e.routeId&&c.add(e.routeId);t=a?o.filter(e=>!s.has(e.routeId)):null,n=a?i.filter(e=>!c.has(e.routeId)):null,r=a?i.filter(e=>c.has(e.routeId)):o,this.stores.isLoading.set(!1),this.stores.loadedAt.set(Date.now()),a&&(this.stores.setMatches(i),this.stores.setPending([]),this.stores.setCached([...this.stores.cachedMatches.get(),...e.filter(e=>e.status!==`error`&&e.status!==`notFound`&&e.status!==`redirected`)]),this.clearExpiredCache())});for(let[e,i]of[[t,`onLeave`],[n,`onEnter`],[r,`onStay`]])if(e)for(let t of e)this.looseRoutesById[t.routeId].options[i]?.(t)})})}})}catch(e){MD(e)?(n=e,this.navigate({...n.options,replace:!0,ignoreBlocker:!0})):SD(e)&&(r=e);let t=n?n.status:r?404:this.stores.matches.get().some(e=>e.status===`error`)?500:200;this.batch(()=>{this.stores.statusCode.set(t),this.stores.redirect.set(n)})}this.latestLoadPromise===i&&(this.commitLocationPromise?.resolve(),this.latestLoadPromise=void 0,this.commitLocationPromise=void 0),o()})}),this.latestLoadPromise=i,await i;this.latestLoadPromise&&i!==this.latestLoadPromise;)await this.latestLoadPromise;let o;this.hasNotFoundMatch()?o=404:this.stores.matches.get().some(e=>e.status===`error`)&&(o=500),o!==void 0&&this.stores.statusCode.set(o)},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,t&&typeof document<`u`&&`startViewTransition`in document&&typeof document.startViewTransition==`function`){let n;if(typeof t==`object`&&this.isViewTransitionTypesSupported){let r=this.latestLocation,i=this.stores.resolvedLocation.get(),a=typeof t.types==`function`?t.types(_O(r,i)):t.types;if(a===!1){e();return}n={update:e,types:a}}else n=e;document.startViewTransition(n)}else e()},this.updateMatch=(e,t)=>{this.startTransition(()=>{let n=this.stores.pendingMatchStores.get(e);if(n){n.set(t);return}let r=this.stores.matchStores.get(e);if(r){r.set(t);return}let i=this.stores.cachedMatchStores.get(e);if(i){let n=t(i.get());n.status===`redirected`?this.stores.cachedMatchStores.delete(e)&&this.stores.cachedIds.set(t=>t.filter(t=>t!==e)):i.set(n)}})},this.getMatch=e=>this.stores.cachedMatchStores.get(e)?.get()??this.stores.pendingMatchStores.get(e)?.get()??this.stores.matchStores.get(e)?.get(),this.invalidate=e=>{let t=t=>e?.filter?.(t)??!0?{...t,invalid:!0,...e?.forcePending||t.status===`error`||t.status===`notFound`?{status:`pending`,error:void 0}:void 0}:t;return this.batch(()=>{this.stores.setMatches(this.stores.matches.get().map(t)),this.stores.setCached(this.stores.cachedMatches.get().map(t)),this.stores.setPending(this.stores.pendingMatches.get().map(t))}),this.shouldViewTransition=!1,this.load({sync:e?.sync})},this.getParsedLocationHref=e=>e.publicHref||`/`,this.resolveRedirect=e=>{let t=e.headers.get(`Location`);if(!e.options.href||e.options._builtLocation){let t=e.options._builtLocation??this.buildLocation(e.options),n=this.getParsedLocationHref(t);e.options.href=n,e.headers.set(`Location`,n)}else if(t)try{let n=new URL(t);if(this.origin&&n.origin===this.origin){let t=n.pathname+n.search+n.hash;e.options.href=t,e.headers.set(`Location`,t)}}catch{}if(e.options.href&&!e.options._builtLocation&&Ax(e.options.href,this.protocolAllowlist))throw Error(`Redirect blocked: unsafe protocol`);return e.headers.get(`Location`)||e.headers.set(`Location`,e.options.href),e},this.clearCache=e=>{let t=e?.filter;t===void 0?this.stores.setCached([]):this.stores.setCached(this.stores.cachedMatches.get().filter(e=>!t(e)))},this.clearExpiredCache=()=>{let e=Date.now();this.clearCache({filter:t=>{let n=this.looseRoutesById[t.routeId];if(!n.options.loader)return!0;let r=(t.preload?n.options.preloadGcTime??this.options.defaultPreloadGcTime:n.options.gcTime??this.options.defaultGcTime)??300*1e3;return t.status===`error`||e-t.updatedAt>=r}})},this.loadRouteChunk=QD,this.preloadRoute=async e=>{let t=e._builtLocation??this.buildLocation(e),n=this.matchRoutes(t,{throwOnError:!0,preload:!0,dest:e}),r=new Set([...this.stores.matchesId.get(),...this.stores.pendingIds.get()]),i=new Set([...r,...this.stores.cachedIds.get()]),a=n.filter(e=>!i.has(e.id));if(a.length){let e=this.stores.cachedMatches.get();this.stores.setCached([...e,...a])}try{return n=await XD({router:this,matches:n,location:t,preload:!0,updateMatch:(e,t)=>{r.has(e)?n=n.map(n=>n.id===e?t(n):n):this.updateMatch(e,t)}}),n}catch(e){if(MD(e))return e.options.reloadDocument?void 0:await this.preloadRoute({...e.options,_fromLocation:t});SD(e)||console.error(e);return}},this.matchRoute=(e,t)=>{let n={...e,to:e.to?this.resolvePathWithBase(e.from||``,e.to):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n);if(t?.pending&&this.stores.status.get()!==`pending`)return!1;let i=(t?.pending===void 0?!this.stores.isLoading.get():t.pending)?this.latestLocation:this.stores.resolvedLocation.get()||this.stores.location.get(),a=ZE(r.pathname,t?.caseSensitive??!1,t?.fuzzy??!1,i.pathname,this.processedTree);return!a||e.params&&!Ux(a.rawParams,e.params,{partial:!0})?!1:t?.includeSearch??!0?Ux(i.search,r.search,{partial:!0})?a.rawParams:!1:a.rawParams},this.hasNotFoundMatch=()=>this.stores.matches.get().some(e=>e.status===`notFound`||e.globalNotFound),this.getStoreConfig=t,this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??`fuzzy`,stringifySearch:e.stringifySearch??DD,parseSearch:e.parseSearch??ED,protocolAllowlist:e.protocolAllowlist??zx}),typeof document<`u`&&(self.__TSR_ROUTER__=this)}isShell(){return!!this.options.isShell}isPrerendering(){return!!this.options.isPrerendering}get state(){return this.stores.__store.get()}setRoutes({routesById:e,routesByPath:t,processedTree:n}){this.routesById=e,this.routesByPath=t,this.processedTree=n;let r=this.options.notFoundRoute;r&&(r.init({originalIndex:99999999999}),this.routesById[r.id]=r)}getRouteBranch(e){let t=this.routeBranchCache.get(e);return t||(t=rD(e),this.routeBranchCache.set(e,t)),t}get looseRoutesById(){return this.routesById}getParentContext(e){return e?.id?e.context??this.options.context??void 0:this.options.context??void 0}matchRoutesInternal(e,t){let n=this.getMatchedRoutes(e.pathname),{foundRoute:r,routeParams:i}=n,{matchedRoutes:a}=n,o=!1;(r?r.path!==`/`&&i[`**`]:pD(e.pathname))&&(this.options.notFoundRoute?a=[...a,this.options.notFoundRoute]:o=!0);let s=o?DO(this.options.notFoundMode,a):void 0,c=Array(a.length),l=new Map;for(let e of this.stores.matchStores.values())e.routeId&&l.set(e.routeId,e.get());for(let n=0;n<a.length;n++){let r=a[n],o=c[n-1],u,d,f;{let n=o?.search??e.search,i=o?._strictSearch??void 0;try{let e=CO(r.options.validateSearch,{...n})??void 0;u={...n,...e},d={...i,...e},f=void 0}catch(e){let r=e;if(e instanceof bO||(r=new bO(e.message,{cause:e})),t?.throwOnError)throw r;u=n,d={},f=r}}let p=r.options.loaderDeps?.({search:u})??``,m=p?JSON.stringify(p):``,{interpolatedPath:h,usedParams:g}=bD({path:r.fullPath,params:i,decoder:this.pathParamsDecoder,server:this.isServer}),_=r.id+h+m,v=this.getMatch(_),y=l.get(r.id),b=v?._strictParams??g,x;if(!v)try{OO(r,b)}catch(e){if(x=SD(e)||MD(e)?e:new xO(e.message,{cause:e}),t?.throwOnError)throw x}Object.assign(i,b);let S=y?`stay`:`enter`,C;if(v)C={...v,cause:S,params:y?.params??i,_strictParams:b,search:Jx(y?y.search:v.search,u),_strictSearch:d};else{let e=r.options.loader||r.options.beforeLoad||r.lazyFn||$D(r)?`pending`:`success`;C={id:_,ssr:r.options.ssr,index:n,routeId:r.id,params:y?.params??i,_strictParams:b,pathname:h,updatedAt:Date.now(),search:y?Jx(y.search,u):u,_strictSearch:d,searchError:void 0,status:e,isFetching:!1,error:void 0,paramsError:x,__routeContext:void 0,_nonReactive:{loadPromise:Px()},__beforeLoadContext:void 0,context:{},abortController:new AbortController,fetchCount:0,cause:S,loaderDeps:y?kx(y.loaderDeps,p):p,invalid:!1,preload:!1,links:void 0,scripts:void 0,headScripts:void 0,meta:void 0,staticData:r.options.staticData||{},fullPath:r.fullPath}}t?.preload||(C.globalNotFound=s===r.id),C.searchError=f;let w=this.getParentContext(o);C.context={...w,...C.__routeContext,...C.__beforeLoadContext},c[n]=C}for(let t=0;t<c.length;t++){let n=c[t],r=this.looseRoutesById[n.routeId],a=this.getMatch(n.id),o=l.get(n.routeId);if(n.params=o?Jx(o.params,i):i,!a){let i=c[t-1],a=this.getParentContext(i);if(r.options.context){let t={deps:n.loaderDeps,params:n.params,context:a??{},location:e,navigate:t=>this.navigate({...t,_fromLocation:e}),buildLocation:this.buildLocation,cause:n.cause,abortController:n.abortController,preload:!!n.preload,matches:c,routeId:r.id};n.__routeContext=r.options.context(t)??void 0}n.context={...a,...n.__routeContext,...n.__beforeLoadContext}}}return c}matchRoutesLightweight(e){let{matchedRoutes:t,routeParams:n}=this.getMatchedRoutes(e.pathname),r=Mx(t),i={...e.search};for(let e of t)try{Object.assign(i,CO(e.options.validateSearch,i))}catch{}let a=Mx(this.stores.matchesId.get()),o=a&&this.stores.matchStores.get(a)?.get(),s=o&&o.routeId===r.id&&o.pathname===e.pathname,c;if(s)c=o.params;else{let e=Object.assign(Object.create(null),n);for(let n of t)try{OO(n,e)}catch{}c=e}return{matchedRoutes:t,fullPath:r.fullPath,search:i,params:c}}},bO=class extends Error{},xO=class extends Error{};function SO(e){return{loadedAt:0,isLoading:!1,isTransitioning:!1,status:`idle`,resolvedLocation:void 0,location:e,matches:[],statusCode:200}}function CO(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new bO(`Async validation not supported`);if(n.issues)throw new bO(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}function wO({pathname:e,routesById:t,processedTree:n}){let r=Object.create(null),i=pD(e),a,o=QE(i,n,!0);return o&&(a=o.route,Object.assign(r,o.rawParams)),{matchedRoutes:o?.branch||[t.__root__],routeParams:r,foundRoute:a}}function TO({search:e,dest:t,destRoutes:n,_includeValidateSearch:r}){return EO(n)(e,t,r??!1)}function EO(e){let t,n,r=[];for(let t of e){let e=t.options;`search`in e?e.search?.middlewares&&r.push(...e.search.middlewares):(e.preSearchFilters||e.postSearchFilters)&&r.push(({search:t,next:n})=>{let r=n(e.preSearchFilters?e.preSearchFilters.reduce((e,t)=>t(e),t):t);return e.postSearchFilters?e.postSearchFilters.reduce((e,t)=>t(e),r):r});let i=e.validateSearch;i&&r.push(({search:e,next:t,meta:r})=>{let a=t(e);if(n)try{let e=CO(i,a);if(r&&e)for(let t in e)t in a||(r.defaulted||=new Map).set(t,e[t]);return{...a,...e}}catch{}return a})}let i=(e,n,a)=>{if(e>=r.length){if(!t.search)return{};if(t.search===!0)return n;let e=Lx(t.search,n);return a&&(a.explicit=e),e}return r[e]({search:n,next:(t,n)=>{if(n){let n=a||{};return{search:i(e+1,t,n),meta:n}}return i(e+1,t,a)},meta:a})};return function(e,r,a){return t=r,n=a,i(0,e)}}function DO(e,t){if(e!==`root`)for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.children)return n.id}return AD}function OO(e,t){let n=e.options.params?.parse??e.options.parseParams;if(n){let e=n(t);if(e===!1)throw Error(`Route params.parse returned false for a matched route`);Object.assign(t,e)}}function kO(){try{return sessionStorage}catch{return}}var AO=`tsr-scroll-restoration-v1_3`,jO=kO();function MO(){try{return JSON.parse(jO?.getItem(`tsr-scroll-restoration-v1_3`)||`{}`)}catch{return{}}}function NO(){try{jO?.setItem(AO,JSON.stringify(PO))}catch{}}var PO=MO(),FO=`data-scroll-restoration-id`,IO=e=>e.state.__TSR_key||e.href;function LO(e){let t=e.getAttribute(FO);if(t)return`[${FO}="${t}"]`;let n=``,r=e,i;for(;i=r.parentNode;){let e=1,t=r;for(;t=t.previousElementSibling;)e++;let a=`${r.localName}:nth-child(${e})`;n=n?`${a} > ${n}`:a,r=i}return n}var RO=!1,zO=`window`;function BO(e){try{return typeof e==`function`?e():document.querySelector(e)}catch{}}function VO(e){let t=[];for(let n of e){if(n===zO)continue;let e=BO(n);e&&t.push(e)}return t}function HO(e,t){let n=t??e.options.scrollRestoration,r=e._scroll;n&&(r.restoring=!0);let i=e.options.getScrollRestorationKey||IO,a=new Map,o=(e,t,n)=>{let r=a.get(e)||{};r.scrollX=t,r.scrollY=n,a.set(e,r)},s=e=>{if(!(RO||!r.restoring))if(e.target===document)o(zO,scrollX,scrollY);else{let t=e.target;o(t,t.scrollLeft,t.scrollTop)}},c=e=>{if(!r.restoring)return;let t=PO[e]||={};for(let[e,n]of a)e===zO?t[zO]=n:e.isConnected&&(t[LO(e)]=n)};n&&!r.restoration&&(r.restoration=!0,RO=!1,history.scrollRestoration=`manual`,document.addEventListener(`scroll`,s,!0),e.subscribe(`onBeforeLoad`,e=>{e.fromLocation&&c(i(e.fromLocation)),a.clear()}),addEventListener(`pagehide`,()=>{c(i(e.stores.resolvedLocation.get()??e.stores.location.get())),NO()})),!r.reset&&(r.reset=!0,e.subscribe(`onRendered`,t=>{let n=e.options.scrollRestorationBehavior,o=e.options.scrollToTopSelectors,s=r.next,c;if(a.clear(),s||(r.next=!0),typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))return;let l=i(t.toLocation),u=t.fromLocation&&i(t.fromLocation);if(r.restoring&&u&&u!==l){let e=PO[u];if(e){let t=PO[l];for(let n in e){if(n===zO){if(s)continue}else{let e=BO(n);if(!e||s&&o&&(c??=VO(o),c.includes(e)))continue}t||=PO[l]={},t[n]??=e[n]}}}RO=!0;try{let e=t.toLocation.hash,i=t.toLocation.state.__hashScrollIntoViewOptions??!0,a=!1;if(s){let s=vO.get(t.toLocation),u=e&&i&&(s===`PUSH`||s===`REPLACE`),d=r.restoring?PO[l]:void 0;if(d)for(let e in d){let{scrollX:t,scrollY:r}=d[e];if(e===zO){if(u)continue;scrollTo({top:r,left:t,behavior:n}),a=!0}else{let n=BO(e);n&&(n.scrollLeft=t,n.scrollTop=r)}}if(!a&&!e){let e={top:0,left:0,behavior:n};if(scrollTo(e),o){c??=VO(o);for(let t of c)t.scrollTo(e)}}}!a&&e&&i&&document.getElementById(e)?.scrollIntoView(i)}finally{RO=!1}}))}var UO=`Error preloading route! ☝️`,WO=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=e=>{this.originalIndex=e.originalIndex;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=AD:this.parentRoute||Nx();let r=n?AD:t?.path;r&&r!==`/`&&(r=fD(r));let i=t?.id||r,a=n?AD:uD([this.parentRoute.id===`__root__`?``:this.parentRoute.id,i]);r===`__root__`&&(r=`/`),a!==`__root__`&&(a=uD([`/`,a]));let o=a===`__root__`?`/`:uD([this.parentRoute.fullPath,r]);this._path=r,this._id=a,this._fullPath=o,this._to=pD(o)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>jD({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},GO=class extends WO{constructor(e){super(e)}};function KO(e){let t=e.errorComponent??JO;return(0,J.jsx)(qO,{getResetKey:e.getResetKey,onCatch:e.onCatch,children:({error:n,reset:r})=>n?q.createElement(t,{error:n,reset:r}):e.children})}var qO=class extends q.Component{constructor(...e){super(...e),this.state={error:null}}static getDerivedStateFromProps(e,t){let n=e.getResetKey();return t.error&&t.resetKey!==n?{resetKey:n,error:null}:{resetKey:n}}static getDerivedStateFromError(e){return{error:e}}reset(){this.setState({error:null})}componentDidCatch(e,t){this.props.onCatch&&this.props.onCatch(e,t)}render(){return this.props.children({error:this.state.error,reset:()=>{this.reset()}})}};function JO({error:e}){let[t,n]=q.useState(!1);return(0,J.jsxs)(`div`,{style:{padding:`.5rem`,maxWidth:`100%`},children:[(0,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`.5rem`},children:[(0,J.jsx)(`strong`,{style:{fontSize:`1rem`},children:`Something went wrong!`}),(0,J.jsx)(`button`,{style:{appearance:`none`,fontSize:`.6em`,border:`1px solid currentColor`,padding:`.1rem .2rem`,fontWeight:`bold`,borderRadius:`.25rem`},onClick:()=>n(e=>!e),children:t?`Hide Error`:`Show Error`})]}),(0,J.jsx)(`div`,{style:{height:`.25rem`}}),t?(0,J.jsx)(`div`,{children:(0,J.jsx)(`pre`,{style:{fontSize:`.7em`,border:`1px solid red`,borderRadius:`.25rem`,padding:`.3rem`,color:`red`,overflow:`auto`},children:e.message?(0,J.jsx)(`code`,{children:e.message}):null})}):null]})}function YO({children:e,fallback:t=null}){return XO()?(0,J.jsx)(q.Fragment,{children:e}):(0,J.jsx)(q.Fragment,{children:t})}function XO(){return q.useSyncExternalStore(ZO,()=>!0,()=>!1)}function ZO(){return()=>{}}var QO=(e=>(e[e.None=0]=`None`,e[e.Mutable=1]=`Mutable`,e[e.Watching=2]=`Watching`,e[e.RecursedCheck=4]=`RecursedCheck`,e[e.Recursed=8]=`Recursed`,e[e.Dirty=16]=`Dirty`,e[e.Pending=32]=`Pending`,e))(QO||{});function $O({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function ek(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var tk=[],nk=0,{link:rk,unlink:ik,propagate:ak,checkDirty:ok,shallowPropagate:sk}=$O({update(e){return e._update()},notify(e){tk[lk++]=e,e.flags&=~QO.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=QO.Mutable|QO.Dirty,pk(e))}}),ck=0,lk=0,uk,dk=0;function fk(e){try{++dk,e()}finally{--dk||mk()}}function pk(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=ik(n,e)}function mk(){if(!(dk>0)){for(;ck<lk;){let e=tk[ck];tk[ck++]=void 0,e.notify()}ck=0,lk=0}}function hk(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?QO.None:QO.Mutable,get(){return uk!==void 0&&rk(i,uk,nk),i._snapshot},subscribe(e){let t=ek(e),n={current:!1},r=gk(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=uk,o=t?.compare??Object.is;if(n)uk=i,++nk,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=QO.Mutable|QO.RecursedCheck);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{uk=a,n&&(i.flags&=~QO.RecursedCheck),pk(i)}}};return n?(i.flags=QO.Mutable|QO.Dirty,i.get=function(){let e=i.flags;if(e&QO.Dirty||e&QO.Pending&&ok(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&sk(e)}}else e&QO.Pending&&(i.flags=e&~QO.Pending);return uk!==void 0&&rk(i,uk,nk),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(ak(e),sk(e),mk())}},i}function gk(e){let t=()=>{let t=uk;uk=n,++nk,n.depsTail=void 0,n.flags=QO.Watching|QO.RecursedCheck;try{return e()}finally{uk=t,n.flags&=~QO.RecursedCheck,pk(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:QO.Watching|QO.RecursedCheck,notify(){let e=this.flags;e&QO.Dirty||e&QO.Pending&&ok(this.deps,this)?t():this.flags=QO.Watching},stop(){this.flags=QO.None,this.depsTail=void 0,pk(this)}};return t(),n}function _k(e){return Wx({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function vk(e){let{select:t,...n}=e;return Wx({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function yk(e){return Wx({...e,select:t=>e.select?e.select(t.context):t.context})}var bk=r(n(),1);function xk(e,t){let n=Hx(),r=RE(t),{activeProps:i,inactiveProps:a,activeOptions:o,to:s,preload:c,preloadDelay:l,preloadIntentProximity:u,hashScrollIntoView:d,replace:f,startTransition:p,resetScroll:m,viewTransition:h,children:g,target:_,disabled:v,style:y,className:b,onClick:x,onBlur:S,onFocus:C,onMouseEnter:w,onMouseLeave:T,onTouchStart:E,ignoreBlocker:D,params:O,search:k,hash:A,state:j,mask:M,reloadDocument:N,unsafeRelative:P,from:F,_fromLocation:I,...L}=e,R=XO(),z=q.useMemo(()=>e,[n,e.from,e._fromLocation,e.hash,e.to,e.search,e.params,e.state,e.mask,e.unsafeRelative]),B=Rx(n.stores.location,e=>e,(e,t)=>e.href===t.href),V=q.useMemo(()=>{let e={_fromLocation:B,...z};return n.buildLocation(e)},[n,B,z]),ee=V.maskedLocation?V.maskedLocation.publicHref:V.publicHref,te=V.maskedLocation?V.maskedLocation.external:V.external,ne=q.useMemo(()=>Ak(ee,te,n.history,v),[v,te,ee,n.history]),re=q.useMemo(()=>{if(ne?.external)return Ax(ne.href,n.protocolAllowlist)?void 0:ne.href;if(!jk(s)&&!(typeof s!=`string`||s.indexOf(`:`)===-1))try{return new URL(s),Ax(s,n.protocolAllowlist)?void 0:s}catch{}},[s,ne,n.protocolAllowlist]),ie=q.useMemo(()=>{if(re)return!1;if(o?.exact){if(!gD(B.pathname,V.pathname,n.basepath))return!1}else{let e=hD(B.pathname,n.basepath),t=hD(V.pathname,n.basepath);if(!(e.startsWith(t)&&(e.length===t.length||e[t.length]===`/`)))return!1}return(o?.includeSearch??!0)&&!Ux(B.search,V.search,{partial:!o?.exact,ignoreUndefined:!o?.explicitUndefined})?!1:!o?.includeHash||R&&B.hash===V.hash},[o?.exact,o?.explicitUndefined,o?.includeHash,o?.includeSearch,B,re,R,V.hash,V.pathname,V.search,n.basepath]),ae=ie?Lx(i,{})??Ck:Sk,oe=ie?Sk:Lx(a,{})??Sk,se=[b,ae.className,oe.className].filter(Boolean).join(` `),ce=(y||ae.style||oe.style)&&{...y,...ae.style,...oe.style},[le,ue]=q.useState(!1),de=q.useRef(!1),fe=e.reloadDocument||re?!1:c??n.options.defaultPreload,pe=l??n.options.defaultPreloadDelay??0,me=q.useCallback(()=>{n.preloadRoute({...z,_builtLocation:V}).catch(e=>{console.warn(e),console.warn(UO)})},[n,z,V]);LE(r,q.useCallback(e=>{e?.isIntersecting&&me()},[me]),Ok,{disabled:!!v||fe!==`viewport`}),q.useEffect(()=>{de.current||!v&&fe===`render`&&(me(),de.current=!0)},[v,me,fe]);let he=e=>{let t=e.currentTarget.getAttribute(`target`),r=_===void 0?t:_;if(!v&&!Nk(e)&&!e.defaultPrevented&&(!r||r===`_self`)&&e.button===0){e.preventDefault(),(0,bk.flushSync)(()=>{ue(!0)});let t=n.subscribe(`onResolved`,()=>{t(),ue(!1)});n.navigate({...z,replace:f,resetScroll:m,hashScrollIntoView:d,startTransition:p,viewTransition:h,ignoreBlocker:D})}};if(re)return{...L,ref:r,href:re,...g&&{children:g},..._&&{target:_},...v&&{disabled:v},...y&&{style:y},...b&&{className:b},...x&&{onClick:x},...S&&{onBlur:S},...C&&{onFocus:C},...w&&{onMouseEnter:w},...T&&{onMouseLeave:T},...E&&{onTouchStart:E}};let ge=e=>{if(v||fe!==`intent`)return;if(!pe){me();return}let t=e.currentTarget;if(Dk.has(t))return;let n=setTimeout(()=>{Dk.delete(t),me()},pe);Dk.set(t,n)},_e=e=>{v||fe!==`intent`||me()},ve=e=>{if(v||!fe||!pe)return;let t=e.currentTarget,n=Dk.get(t);n&&(clearTimeout(n),Dk.delete(t))};return{...L,...ae,...oe,href:ne?.href,ref:r,onClick:kk([x,he]),onBlur:kk([S,ve]),onFocus:kk([C,ge]),onMouseEnter:kk([w,ge]),onMouseLeave:kk([T,ve]),onTouchStart:kk([E,_e]),disabled:!!v,target:_,...ce&&{style:ce},...se&&{className:se},...v&&wk,...ie&&Tk,...R&&le&&Ek}}var Sk={},Ck={className:`active`},wk={role:`link`,"aria-disabled":!0},Tk={"data-status":`active`,"aria-current":`page`},Ek={"data-transitioning":`transitioning`},Dk=new WeakMap,Ok={rootMargin:`100px`},kk=e=>t=>{for(let n of e)if(n){if(t.defaultPrevented)return;n(t)}};function Ak(e,t,n,r){if(!r)return t?{href:e,external:!0}:{href:n.createHref(e)||`/`,external:!1}}function jk(e){if(typeof e!=`string`)return!1;let t=e.charCodeAt(0);return t===47?e.charCodeAt(1)!==47:t===46}var Mk=q.forwardRef((e,t)=>{let{_asChild:n,...r}=e,{type:i,...a}=xk(r,t),o=typeof r.children==`function`?r.children({isActive:a[`data-status`]===`active`}):r.children;if(!n){let{disabled:e,...t}=a;return q.createElement(`a`,t,o)}return q.createElement(n,a,o)});function Nk(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var Pk=class extends WO{constructor(e){super(e),this.useMatch=e=>Wx({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>yk({...e,from:this.id}),this.useSearch=e=>Vx({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>iS({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>vk({...e,from:this.id}),this.useLoaderData=e=>_k({...e,from:this.id}),this.useNavigate=()=>Kx({from:this.fullPath}),this.Link=q.forwardRef((e,t)=>(0,J.jsx)(Mk,{ref:t,from:this.fullPath,...e}))}};function Fk(e){return new Pk(e)}var Ik=class extends GO{constructor(e){super(e),this.useMatch=e=>Wx({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>yk({...e,from:this.id}),this.useSearch=e=>Vx({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>iS({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>vk({...e,from:this.id}),this.useLoaderData=e=>_k({...e,from:this.id}),this.useNavigate=()=>Kx({from:this.fullPath}),this.Link=q.forwardRef((e,t)=>(0,J.jsx)(Mk,{ref:t,from:this.fullPath,...e}))}};function Lk(e){return new Ik(e)}function Rk(e,t){let n,r,i,a,o=()=>(n||=e().then(e=>{n=void 0,r=e[t??`default`]}).catch(e=>{if(i=e,ine(i)&&i instanceof Error&&typeof window<`u`&&typeof sessionStorage<`u`){let e=`tanstack_router_reload:${i.message}`;sessionStorage.getItem(e)||(sessionStorage.setItem(e,`1`),a=!0)}}),n),s=function(e){if(a)throw window.location.reload(),new Promise(()=>{});if(i)throw i;if(!r)if(PE)PE(o());else throw o();return q.createElement(r,e)};return s.preload=o,s}function zk(e){let t=Hx(),n=`not-found-${Rx(t.stores.location,e=>e.pathname)}-${Rx(t.stores.status,e=>e)}`;return(0,J.jsx)(KO,{getResetKey:()=>n,onCatch:(t,n)=>{if(SD(t))e.onCatch?.(t,n);else throw t},errorComponent:({error:t})=>{if(SD(t))return e.fallback?.(t);throw t},children:e.children})}function Bk(){return(0,J.jsx)(`p`,{children:`Not Found`})}function Vk(e){return(0,J.jsx)(J.Fragment,{children:e.children})}function Hk(e,t,n){return t.options.notFoundComponent?(0,J.jsx)(t.options.notFoundComponent,{...n}):e.options.defaultNotFoundComponent?(0,J.jsx)(e.options.defaultNotFoundComponent,{...n}):(0,J.jsx)(Bk,{})}var Uk=q.memo(function({matchId:e}){let t=Hx(),n=t.stores.matchStores.get(e);n||Nx();let r=Rx(t.stores.loadedAt,e=>e),i=Rx(n,e=>e);return(0,J.jsx)(Wk,{router:t,matchId:e,resetKey:r,matchState:q.useMemo(()=>{let e=i.routeId,n=t.routesById[e].parentRoute?.id;return{routeId:e,ssr:i.ssr,_displayPending:i._displayPending,parentRouteId:n}},[i._displayPending,i.routeId,i.ssr,t.routesById])})});function Wk({router:e,matchId:t,resetKey:n,matchState:r}){let i=e.routesById[r.routeId],a=i.options.pendingComponent??e.options.defaultPendingComponent,o=a?(0,J.jsx)(a,{}):null,s=i.options.errorComponent??e.options.defaultErrorComponent,c=i.options.onCatch??e.options.defaultOnCatch,l=i.isRoot?i.options.notFoundComponent??e.options.notFoundRoute?.options.component:i.options.notFoundComponent,u=r.ssr===!1||r.ssr===`data-only`,d=(!i.isRoot||i.options.wrapInSuspense||u)&&(i.options.wrapInSuspense??a??(i.options.errorComponent?.preload||u))?q.Suspense:Vk,f=s?KO:Vk,p=l?zk:Vk;return(0,J.jsxs)(i.isRoot?i.options.shellComponent??Vk:Vk,{children:[(0,J.jsx)(jx.Provider,{value:t,children:(0,J.jsx)(d,{fallback:o,children:(0,J.jsx)(f,{getResetKey:()=>n,errorComponent:s||JO,onCatch:(e,t)=>{if(SD(e))throw e.routeId??=r.routeId,e;c?.(e,t)},children:(0,J.jsx)(p,{fallback:e=>{if(e.routeId??=r.routeId,!l||e.routeId&&e.routeId!==r.routeId||!e.routeId&&!i.isRoot)throw e;return q.createElement(l,e)},children:u||r._displayPending?(0,J.jsx)(YO,{fallback:o,children:(0,J.jsx)(Kk,{matchId:t})}):(0,J.jsx)(Kk,{matchId:t})})})})}),r.parentRouteId===`__root__`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Gk,{resetKey:n}),(e.options.scrollRestoration,null)]}):null]})}function Gk({resetKey:e}){let t=Hx(),n=q.useRef(void 0);return FE(()=>{let e=t.latestLocation.href;(n.current===void 0||n.current!==e)&&(t.emit({type:`onRendered`,..._O(t.stores.location.get(),t.stores.resolvedLocation.get())}),n.current=e)},[t.latestLocation.state.__TSR_key,e,t]),null}var Kk=q.memo(function({matchId:e}){let t=Hx(),n=(e,n)=>t.getMatch(e.id)?._nonReactive[n]??e._nonReactive[n],r=t.stores.matchStores.get(e);r||Nx();let i=Rx(r,e=>e),a=i.routeId,o=t.routesById[a],s=q.useMemo(()=>{let e=(t.routesById[a].options.remountDeps??t.options.defaultRemountDeps)?.({routeId:a,loaderDeps:i.loaderDeps,params:i._strictParams,search:i._strictSearch});return e?JSON.stringify(e):void 0},[a,i.loaderDeps,i._strictParams,i._strictSearch,t.options.defaultRemountDeps,t.routesById]),c=q.useMemo(()=>{let e=o.options.component??t.options.defaultComponent;return e?(0,J.jsx)(e,{},s):(0,J.jsx)(qk,{})},[s,o.options.component,t.options.defaultComponent]);if(i._displayPending)throw n(i,`displayPendingPromise`);if(i._forcePending)throw n(i,`minPendingPromise`);if(i.status===`pending`){let e=o.options.pendingMinMs??t.options.defaultPendingMinMs;if(e){let n=t.getMatch(i.id);if(n&&!n._nonReactive.minPendingPromise){let t=Px();n._nonReactive.minPendingPromise=t,setTimeout(()=>{t.resolve(),n._nonReactive.minPendingPromise=void 0},e)}}throw n(i,`loadPromise`)}if(i.status===`notFound`)return SD(i.error)||Nx(),Hk(t,o,i.error);if(i.status===`redirected`)throw MD(i.error)||Nx(),n(i,`loadPromise`);if(i.status===`error`)throw i.error;return c}),qk=q.memo(function(){let e=Hx(),t=q.useContext(jx),n,r=!1,i;{let a=t?e.stores.matchStores.get(t):void 0;[n,r]=Rx(a,e=>[e?.routeId,e?.globalNotFound??!1]),i=Rx(e.stores.matchesId,e=>e[e.findIndex(e=>e===t)+1])}let a=n?e.routesById[n]:void 0,o=e.options.defaultPendingComponent?(0,J.jsx)(e.options.defaultPendingComponent,{}):null;if(r)return a||Nx(),Hk(e,a,void 0);if(!i)return null;let s=(0,J.jsx)(Uk,{matchId:i});return n===`__root__`?(0,J.jsx)(q.Suspense,{fallback:o,children:s}):s});function Jk(){let e=Hx(),t=q.useRef({router:e,mounted:!1}),[n,r]=q.useState(!1),i=Rx(e.stores.isLoading,e=>e),a=Rx(e.stores.hasPending,e=>e),o=IE(i),s=i||n||a,c=IE(s),l=i||a,u=IE(l);return e.startTransition=e=>{r(!0),q.startTransition(()=>{e(),r(!1)})},q.useEffect(()=>{let t=e.history.subscribe(e.load),n=e.buildLocation({to:e.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});return pD(e.latestLocation.publicHref)!==pD(n.publicHref)&&e.commitLocation({...n,replace:!0}),()=>{t()}},[e,e.history]),FE(()=>{typeof window<`u`&&e.ssr||t.current.router===e&&t.current.mounted||(t.current={router:e,mounted:!0},(async()=>{try{await e.load()}catch(e){console.error(e)}})())},[e]),FE(()=>{o&&!i&&e.emit({type:`onLoad`,..._O(e.stores.location.get(),e.stores.resolvedLocation.get())})},[o,e,i]),FE(()=>{u&&!l&&e.emit({type:`onBeforeRouteMount`,..._O(e.stores.location.get(),e.stores.resolvedLocation.get())})},[l,u,e]),FE(()=>{if(c&&!s){let t=_O(e.stores.location.get(),e.stores.resolvedLocation.get());e.emit({type:`onResolved`,...t}),fk(()=>{e.stores.status.set(`idle`),e.stores.resolvedLocation.set(e.stores.location.get())})}},[s,c,e]),null}function Yk(){let e=Hx(),t=e.routesById.__root__.options.pendingComponent??e.options.defaultPendingComponent,n=t?(0,J.jsx)(t,{}):null,r=(0,J.jsxs)(typeof document<`u`&&e.ssr?Vk:q.Suspense,{fallback:n,children:[(0,J.jsx)(Jk,{}),(0,J.jsx)(Xk,{})]});return e.options.InnerWrap?(0,J.jsx)(e.options.InnerWrap,{children:r}):r}function Xk(){let e=Hx(),t=Rx(e.stores.firstId,e=>e),n=Rx(e.stores.loadedAt,e=>e),r=t?(0,J.jsx)(Uk,{matchId:t}):null;return(0,J.jsx)(jx.Provider,{value:t,children:e.options.disableGlobalCatchBoundary?r:(0,J.jsx)(KO,{getResetKey:()=>n,errorComponent:JO,onCatch:void 0,children:r})})}function Zk(){let e=Hx();return Rx(e.stores.matchRouteDeps,e=>e),q.useCallback(t=>{let{pending:n,caseSensitive:r,fuzzy:i,includeSearch:a,...o}=t;return e.matchRoute(o,{pending:n,caseSensitive:r,fuzzy:i,includeSearch:a})},[e])}var Qk=e=>({createMutableStore:hk,createReadonlyStore:hk,batch:fk}),$k=e=>new eA(e),eA=class extends yO{constructor(e){super(e,Qk)}};function tA({router:e,children:t,...n}){Ix(n)&&e.update({...e.options,...n,context:{...e.options.context,...n.context}});let r=(0,J.jsx)(Gx.Provider,{value:e,children:t});return e.options.Wrap?(0,J.jsx)(e.options.Wrap,{children:r}):r}function nA({router:e,...t}){return(0,J.jsx)(tA,{router:e,...t,children:(0,J.jsx)(Yk,{})})}function rA(e){let t=Hx(),n=(0,q.useRef)(void 0);return Rx(t.stores.location,r=>{let i=e?.select?e.select(r):r;if(e?.structuralSharing??t.options.defaultStructuralSharing){let e=kx(n.current,i);return n.current=e,e}return i})}var iA=W(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),aA=W(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),oA=W(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),sA=W(`at-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]),cA=W(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),lA=W(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),uA=W(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),dA=W(`brain`,[[`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`}]]),fA=W(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),pA=W(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),mA=W(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),hA=W(`circle-slash`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]),gA=W(`circle-user-round`,[[`path`,{d:`M17.925 20.056a6 6 0 0 0-11.851.001`,key:`z69sun`}],[`circle`,{cx:`12`,cy:`11`,r:`4`,key:`1gt34v`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),_A=W(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),vA=W(`compass`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}]]),yA=W(`corner-down-right`,[[`path`,{d:`m15 10 5 5-5 5`,key:`qqa56n`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`,key:`z08zvw`}]]),bA=W(`cpu`,[[`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`}]]),xA=W(`crown`,[[`path`,{d:`M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z`,key:`1vdc57`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),SA=W(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),CA=W(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),wA=W(`feather`,[[`path`,{d:`M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z`,key:`18jl4k`}],[`path`,{d:`M16 8 2 22`,key:`vp34q`}],[`path`,{d:`M17.5 15H9`,key:`1oz8nu`}]]),TA=W(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),EA=W(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),DA=W(`flag`,[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]),OA=W(`fold-vertical`,[[`path`,{d:`M12 22v-6`,key:`6o8u61`}],[`path`,{d:`M12 8V2`,key:`1wkif3`}],[`path`,{d:`M4 12H2`,key:`rhcxmi`}],[`path`,{d:`M10 12H8`,key:`s88cx1`}],[`path`,{d:`M16 12h-2`,key:`10asgb`}],[`path`,{d:`M22 12h-2`,key:`14jgyd`}],[`path`,{d:`m15 19-3-3-3 3`,key:`e37ymu`}],[`path`,{d:`m15 5-3 3-3-3`,key:`19d6lf`}]]),kA=W(`folder-search`,[[`path`,{d:`M10.7 20H4a2 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.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]),AA=W(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),jA=W(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),MA=W(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),NA=W(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),PA=W(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),FA=W(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),IA=W(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),LA=W(`inbox`,[[`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`}]]),RA=W(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),zA=W(`key-round`,[[`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`}]]),BA=W(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),VA=W(`library-big`,[[`rect`,{width:`8`,height:`18`,x:`3`,y:`3`,rx:`1`,key:`oynpb5`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M20.4 18.9c.2.5-.1 1.1-.6 1.3l-1.9.7c-.5.2-1.1-.1-1.3-.6L11.1 5.1c-.2-.5.1-1.1.6-1.3l1.9-.7c.5-.2 1.1.1 1.3.6Z`,key:`1qboyk`}]]),HA=W(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),UA=W(`list-end`,[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M16 12H3`,key:`1a2rj7`}],[`path`,{d:`M9 19H3`,key:`s61nz1`}],[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M21 5v12a2 2 0 0 1-2 2h-6`,key:`hey24a`}]]),WA=W(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),GA=W(`locate-fixed`,[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),KA=W(`log-out`,[[`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`}]]),qA=W(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),JA=W(`megaphone`,[[`path`,{d:`M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z`,key:`q8bfy3`}],[`path`,{d:`M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14`,key:`1853fq`}],[`path`,{d:`M8 6v8`,key:`15ugcq`}]]),YA=W(`message-circle-question-mark`,[[`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:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),XA=W(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),ZA=W(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),QA=W(`monitor`,[[`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`}]]),$A=W(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),ej=W(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),tj=W(`octagon-x`,[[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z`,key:`2d38gg`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),nj=W(`panel-left-open`,[[`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`}]]),rj=W(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),ij=W(`phone-off`,[[`path`,{d:`M10.1 13.9a14 14 0 0 0 3.732 2.668 1 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 2 18 18 0 0 1-12.728-5.272`,key:`1wngk7`}],[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}],[`path`,{d:`M4.76 13.582A18 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 .244.473`,key:`10hv5p`}]]),aj=W(`reply`,[[`path`,{d:`M20 18v-2a4 4 0 0 0-4-4H4`,key:`5vmcpk`}],[`path`,{d:`m9 17-5-5 5-5`,key:`nvlc11`}]]),oj=W(`rotate-cw`,[[`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`}]]),sj=W(`send-horizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),cj=W(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),lj=W(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),uj=W(`settings`,[[`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`}]]),dj=W(`shield-alert`,[[`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`}]]),fj=W(`shield-ellipsis`,[[`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:`M8 12h.01`,key:`czm47f`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}]]),pj=W(`shield-cog`,[[`path`,{d:`m10.929 14.467-.383.924`,key:`hdyevy`}],[`path`,{d:`M10.929 8.923 10.546 8`,key:`1nr44d`}],[`path`,{d:`M13.225 8.923 13.608 8`,key:`aewley`}],[`path`,{d:`m13.607 15.391-.382-.924`,key:`m37gf1`}],[`path`,{d:`m14.849 10.547.923-.383`,key:`1d3c4q`}],[`path`,{d:`m14.849 12.843.923.383`,key:`lmvhy3`}],[`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.305 10.547-.923-.383`,key:`1d13ox`}],[`path`,{d:`m9.305 12.843-.923.383`,key:`7wxwh5`}],[`circle`,{cx:`12.077`,cy:`11.695`,r:`3`,key:`fse9k8`}]]),mj=W(`shuffle`,[[`path`,{d:`m18 14 4 4-4 4`,key:`10pe0f`}],[`path`,{d:`m18 2 4 4-4 4`,key:`pucp1d`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`,key:`1ailkh`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`,key:`km57vx`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`,key:`os18l9`}]]),hj=W(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),gj=W(`split`,[[`path`,{d:`M16 3h5v5`,key:`1806ms`}],[`path`,{d:`M8 3H3v5`,key:`15dfkv`}],[`path`,{d:`M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3`,key:`1qrqzj`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}]]),_j=W(`square-terminal`,[[`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`}]]),vj=W(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),yj=W(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),bj=W(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),xj=W(`timer`,[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]),Sj=W(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Cj=W(`wrench`,[[`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`}]]),wj=W(`zoom-in`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`,key:`1vmskp`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),Tj=W(`zoom-out`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]);function Ej(e,t,n,r){return r>1.01?0:Math.max(0,Math.round(e-t-n))}function Dj(e,t){return t>1.01?0:Math.max(0,Math.round(e))}function Oj(e,t){return t>1.01?0:Math.max(0,Math.round(e))}function kj(e,t,n,r){return r>1.01?0:Math.max(0,Math.ceil(e-t-n-.01))}var Aj={position:`fixed`,visibility:`hidden`,pointerEvents:`none`,zIndex:`-1`};function jj(e=window){let t=e.visualViewport;if(!t)return()=>void 0;let n=e.document,r=n.documentElement,i=(e,t)=>{if(n.body===null)return null;let r=n.createElement(`div`);return r.setAttribute(`aria-hidden`,`true`),r.setAttribute(e,``),Object.assign(r.style,Aj,t),n.body.appendChild(r),r},a=i(`data-viewport-sentinel`,{inset:`0`}),o=i(`data-dvh-sentinel`,{top:`0`,left:`0`,width:`0`,height:`100dvh`}),s=e=>{let t=e?.getBoundingClientRect?.().height;return t!==void 0&&t>0?t:null},c=()=>s(a)??e.innerHeight,l=()=>s(o)??e.innerHeight,u=``,d=!1,f=()=>{if(d)return;let e=Ej(l(),t.height,t.offsetTop,t.scale),n=Dj(t.offsetTop,t.scale),i=Oj(t.offsetLeft,t.scale),a=kj(c(),t.height,t.offsetTop,t.scale),o=`${n}/${e}/${i}/${a}`;o!==u&&(u=o,r.style.setProperty(`--oc-kb`,`${e}px`),r.style.setProperty(`--oc-vv-top`,`${n}px`),r.style.setProperty(`--oc-vv-left`,`${i}px`),r.style.setProperty(`--oc-vv-bottom`,`${a}px`))};f();let p=null,m=()=>{f(),p!==null&&e.clearTimeout(p),p=e.setTimeout(()=>{p=null,f()},0)};t.addEventListener(`resize`,f),t.addEventListener(`scroll`,f),e.addEventListener(`resize`,f),n.addEventListener(`focusin`,f),n.addEventListener(`focusout`,f);let h=e.getComputedStyle(r).fontSize,g=typeof e.MutationObserver==`function`?new e.MutationObserver(()=>{let t=e.getComputedStyle(r).fontSize;t!==h&&(h=t,m())}):null;g?.observe(r,{attributes:!0,attributeFilter:[`style`,`class`]});let _=null;return typeof e.ResizeObserver==`function`&&(_=new e.ResizeObserver(f),a!==null&&_.observe(a),o!==null&&_.observe(o)),()=>{d=!0,p!==null&&e.clearTimeout(p),t.removeEventListener(`resize`,f),t.removeEventListener(`scroll`,f),e.removeEventListener(`resize`,f),n.removeEventListener(`focusin`,f),n.removeEventListener(`focusout`,f),g?.disconnect(),_?.disconnect(),a?.remove(),o?.remove(),r.style.removeProperty(`--oc-kb`),r.style.removeProperty(`--oc-vv-top`),r.style.removeProperty(`--oc-vv-left`),r.style.removeProperty(`--oc-vv-bottom`)}}function Mj(e=window){let t=e.visualViewport,n=e.document?.documentElement;return!t||t.scale>1.01?{x:0,y:0,w:n?.clientWidth||e.innerWidth,h:n?.clientHeight||e.innerHeight}:{x:Math.max(0,Math.round(t.offsetLeft)),y:Math.max(0,Math.round(t.offsetTop)),w:Math.round(t.width),h:Math.round(t.height)}}var Nj=`oc.detachedComposer.geom`,Pj=300,Fj=200,Y=null,Ij=0,Lj=0,Rj=null,zj=0,Bj=new Set;function Vj(){for(let e of Bj)e()}function Hj(e){return Bj.add(e),()=>Bj.delete(e)}function Uj(){return Y}function Wj(e,t){let n=t.x??0,r=t.y??0,i=Math.min(Math.max(Pj,Math.min(e.w,t.w)),t.w),a=Math.min(Math.max(Fj,Math.min(e.h,t.h)),t.h);return{x:Math.max(n,Math.min(e.x,n+t.w-i)),y:Math.max(r,Math.min(e.y,r+t.h-a)),w:i,h:a}}function Gj(){let e=typeof window<`u`?Mj():{x:0,y:0,w:1200,h:800},t=Math.min(720,Math.round(e.w*.72)),n=Math.min(300,Math.round(e.h*.42));return{x:e.x+Math.round((e.w-t)/2),y:e.y+e.h-n-28,w:t,h:n}}function Kj(){let e=null;try{let t=typeof localStorage<`u`?localStorage.getItem(Nj):null;if(t!==null){let n=JSON.parse(t);typeof n.x==`number`&&typeof n.y==`number`&&typeof n.w==`number`&&typeof n.h==`number`&&(e={x:n.x,y:n.y,w:n.w,h:n.h})}}catch{}return e===null&&(e=Gj()),typeof window<`u`&&window.innerWidth&&window.innerHeight&&(e=Wj(e,Mj())),e}function qj(e){try{localStorage?.setItem(Nj,JSON.stringify(e))}catch{}}function Jj(e){return Y===null?(Ij+=1,Y={holdId:Ij,sending:!1,targetChatId:e.targetChatId,targetLabel:e.targetLabel,text:e.text,interim:e.recording===!0?e.interim??``:``,recording:e.recording??!1,finalizing:!1,geom:Kj(),pendingSend:null,pendingSendId:0,pendingRestore:null,voiceEnabled:e.voiceEnabled,voiceLang:e.voiceLang},Rj=e.stop??null,zj++,Vj(),!0):!1}function Yj(e){Y!==null&&(Rj=e,zj++,Y.recording||Y.finalizing?(Y={...Y,text:dM(Y.text,Y.interim),interim:``,recording:!0,finalizing:!1},Vj()):Y.recording||(Y={...Y,recording:!0},Vj()))}function Xj(){return zj}function Zj(e,t){Y!==null&&(Y={...Y,text:_M(Y.text,e,t)},Vj())}function Qj(e){Y===null||Y.interim===e||(Y={...Y,interim:e},Vj())}function $j(e){Y===null||Y.text===e||(Y={...Y,text:e},Vj())}function eM(e){if(Y===null)return;let t=Wj(e,typeof window<`u`&&window.innerWidth&&window.innerHeight?Mj():{w:e.w,h:e.h});Y={...Y,geom:t},qj(t),Vj()}function tM(e){Y!==null&&(Lj+=1,Y={...Y,pendingSend:e,pendingSendId:Lj,sending:!0},Vj())}function nM(){Y===null||Y.pendingSend===null||(Y={...Y,pendingSend:null},Vj())}function rM(e){Y===null||Y.holdId!==e||!Y.sending||(Y={...Y,sending:!1},Vj())}function iM(e){return Y===null||Y.holdId!==e?``:gM()}function aM(){if(Y!==null){if(Y.recording||Y.finalizing){let e=pM(Y);oM(),Y={...Y,text:e,interim:``,recording:!1,finalizing:!1,pendingRestore:e}}else Y={...Y,pendingRestore:Y.text};Vj()}}function oM(){try{Rj?.()}catch{}Rj=null,zj++}function sM(){Y===null||Y.pendingRestore===null||(Y={...Y,pendingRestore:null},Vj())}function cM(e){Y===null||!Y.recording&&!Y.finalizing||e!==void 0&&e!==zj||(Y={...Y,recording:!1,finalizing:!1,interim:``},Vj())}function lM(e){Y===null||!Y.recording||e!==zj||(Y={...Y,recording:!1,finalizing:!0},Vj())}function uM(){try{Rj?.()}catch{}Rj=null}function dM(e,t){return t.trim()===``?e:_M(e,t,!1)}function fM(e,t){return dM(e,t).trim()!==``}function pM(e){return e.recording||e.finalizing===!0?dM(e.text,e.interim):e.text}function mM(){oM(),Y!==null&&(Y={...Y,text:pM(Y),recording:!1,finalizing:!1,interim:``},Vj())}function hM(){let e=Y!==null&&(Y.recording||Y.finalizing)?Y.interim:``;return gM(),e.trim()===``?``:e}function gM(){let e=Y?.text??``;return oM(),Y=null,Vj(),e}function _M(e,t,n){let r=t.trim();if(r===``)return e;if(e===``)return r;let i=e.replace(/\s+$/,``);return n?`${i}\n\n${r}`:`${i} ${r}`}var vM=[],yM=new Map,bM=new Set;function xM(){for(let e of bM)e()}function SM(e){return`${e.messageId}:${e.blockIndex??`all`}`}function CM(e,t){let n=yM.get(e)??vM;return n.some(e=>SM(e)===SM(t))?`ok`:n.length>=10?`too-many`:n.reduce((e,t)=>e+t.excerpt.length,0)+t.excerpt.length>1500?`too-long`:(yM.set(e,[...n,t]),xM(),`ok`)}function wM(e,t){let n=yM.get(e);if(n===void 0)return;let r=n.filter(e=>SM(e)!==t);r.length!==n.length&&(r.length===0?yM.delete(e):yM.set(e,r),xM())}var TM=SM;function EM(e){yM.delete(e)&&xM()}function DM(e){let t=yM.get(e)??vM;return t.length>0&&(yM.delete(e),xM()),t}function OM(e,t){if(t.length===0)return{restored:0,dropped:0};let n=yM.get(e)??vM,r=new Set,i=0;for(let e of n)r.add(SM(e)),i+=e.excerpt.length;let a=[],o=0;for(let e of t)if(!r.has(SM(e))){if(n.length+a.length>=10||i+e.excerpt.length>1500){o+=1;continue}r.add(SM(e)),i+=e.excerpt.length,a.push(e)}let s=[...a,...n];return s.length===0?yM.delete(e):yM.set(e,s),xM(),{restored:a.length,dropped:o}}function kM(e,t,n){let r=t.filter(e=>!n.has(e.messageId)),{restored:i,dropped:a}=OM(e,r);return{restored:i,gone:t.length-r.length,dropped:a}}function AM(e){return(0,q.useSyncExternalStore)(e=>(bM.add(e),()=>bM.delete(e)),()=>e===null?vM:yM.get(e)??vM)}var jM=null;function MM(e,t){e.currentIndex=0,e.wipContextDeps=null,e.wipCommitCallbacks=[];let n=jM;jM=e;try{if(t(),e.isFirstRender=!1,e.cells.length!==e.currentIndex)throw Error(`Rendered ${e.currentIndex} hooks but expected ${e.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{jM=n}}function NM(){if(!jM)throw Error(`No resource fiber available`);return jM}function PM(){return jM}var FM=Symbol(`tap.Context.defaultValue`),IM=e=>e,LM=new Map,RM=new Set,zM=()=>new Map(LM),BM=(e,t)=>{let n=LM;LM=e;try{return t()}finally{LM=n}},VM=(e,t)=>{e[FM]=t},HM=e=>typeof e==`object`&&!!e&&FM in e,UM=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Symbol.for(`react.context`),WM=e=>HM(e)||UM(e),GM=e=>{if(!HM(e)){if(UM(e)){VM(e,e._currentValue??e._currentValue2);return}throw Error("A tap resource's `use()` only accepts a tap context.")}},KM=(e,t,n)=>{if(typeof e!=`object`||!e)throw Error(`useContextProvider only accepts a React context.`);GM(e);let r=e,i=NM(),a=kN(void 0),o=a.current===void 0||!Object.is(a.current.value,t);MN(()=>{a.current={value:t}},[t]);let s=LM.get(r),c=s!==void 0||LM.has(r);LM.set(r,{value:t,source:i});try{return qM(r,o,n)}finally{c?LM.set(r,s):LM.delete(r)}},qM=(e,t,n)=>{let r=RM.has(e);t?RM.add(e):RM.delete(e);try{return n()}finally{r?RM.add(e):RM.delete(e)}},JM=e=>{GM(e);let t=e,n=YM(t,e),r=NM();return(r.wipContextDeps??=new Map).set(t,n.source),n.value},YM=(e,t)=>LM.get(e)??{value:IM(t)[FM],source:null},XM=(e,t,n,r)=>{if(!r)return n;let i=n;for(let[n,a]of r)a===t||a===e||(i??=new Map).set(n,a);return i},ZM=(e,t=e.wipContextDeps)=>{let n=PM();!n||!t||(n.wipContextDeps=XM(n,e,n.wipContextDeps,t))},QM=()=>RM.size>0,$M=e=>{if(!e.contextDeps||!QM())return!1;for(let t of RM.keys())if(e.contextDeps.has(t))return!0;return!1},eN=[0,1,2,3];function tN(e){let t=[];for(let n of eN){let r=e[n];if(r!==void 0)for(let e=0;e<r.length;e++)try{r[e]()}catch(e){t.push(e)}}if(t.length>0){if(t.length===1)throw t[0];for(let e of t)console.error(e);throw AggregateError(t,`Errors during commit`)}}function nN(e){let t=[];for(let n of e.cells)if(n?.type===`effect`&&(n.deps=null,n.cleanup))try{n.cleanup?.()}catch(e){t.push(e)}finally{n.cleanup=void 0}if(t.length>0){if(t.length===1)throw t[0];for(let e of t)console.error(e);throw AggregateError(t,`Errors during cleanup`)}}var rN=typeof process<`u`&&!1,iN=e=>({version:0,committedVersion:0,context:zM(),dispatchUpdate:e,changelog:[],rollbackCallbacks:[]}),aN=e=>{e.committedVersion=e.version,e.changelog.length=0,e.rollbackCallbacks.length=0},oN=(e,t)=>{let n=e.version>t;if(e.version=t,n){for(let t=0;t<e.rollbackCallbacks.length;t++)e.rollbackCallbacks[t]();if(e.rollbackCallbacks.length=0,t===e.committedVersion)e.changelog.length=0;else{if(e.committedVersion>t)throw Error(`Version is less than committed version`);for(;e.committedVersion+e.changelog.length>t;)e.changelog.pop();for(let t=0;t<e.changelog.length;t++)sN(e.changelog[t]);aN(e)}}},sN=e=>{uN(e.fiber,e.cell),e.queued||(e.queued=!0,(e.cell.queue??=[]).push(e))},cN=(e,t,n)=>{let r=e.wipCommitCallbacks;(r[t]??=[]).push(n)},lN=(e,t)=>{e.rollbackCallbacks.push(t)},uN=(e,t)=>{t.isDirty||(t.isDirty=!0,e.markDirty?.(),lN(e.root,()=>{if(t.queue!==null){for(let e of t.queue)e.queued=!1;t.queue=null}t.workInProgress=t.current,t.isDirty=!1}))},dN=()=>{throw Error(`Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.`)},fN=()=>{throw Error(`Hook order changed between renders`)},Ene=(e,t,n)=>{if(e.isNeverMounted)throw Error(`Resource updated before mount`);let r=!1,i=!0;e.root.dispatchUpdate(()=>r?i:(r=!0,n&&e.root.changelog.length===0&&!t.cell.isDirty&&!t.hasEagerState&&(t.eagerState=n(t.cell.workInProgress,t.action),t.hasEagerState=!0,i=!Object.is(t.cell.current,t.eagerState)),i),()=>(r=!0,i=!0,sN(t),e.root.changelog.push(t),!0))},Dne=(e,t,n,r,i)=>{let a=r?r(n):n;rN&&e.devStrictMode&&r&&r(n);let o={type:`reducer`,workInProgress:a,current:a,isDirty:!1,queue:null,renderQueue:null,reducer:t,dispatch:n=>{let r=PM();if(r!==null){if(r!==e)throw Error(`Cannot update a resource while rendering a different resource.`);(e.renderPendingCells??=new Set).add(o),(o.renderQueue??=[]).push(n)}else Ene(e,{fiber:e,cell:o,action:n,hasEagerState:!1,eagerState:void 0,queued:!1},i?t:void 0)}};return o};function pN(e,t,n,r){let i=NM(),a=i.currentIndex++,o=i.cells[a],s=(()=>{if(o!==void 0)return o.type===`reducer`?o:fN();!i.isFirstRender&&a>=i.cells.length&&dN();let s=Dne(i,e,t,n,r);return i.cells[a]=s,s})(),c=s.queue;if(c!==null){let t=e===s.reducer;for(let n=0;n<c.length;n++){let r=c[n];!r.hasEagerState||!t?(r.eagerState=e(s.workInProgress,r.action),r.hasEagerState=!0,rN&&i.devStrictMode&&(r.eagerState=e(s.workInProgress,r.action))):rN&&i.devStrictMode&&e(s.workInProgress,r.action),r.queued=!1,s.workInProgress=r.eagerState}s.queue=null}if(s.reducer=e,s.renderQueue!==null){let t=s.workInProgress;for(let n of s.renderQueue)t=e(t,n);s.renderQueue=null,i.renderPendingCells?.delete(s),Object.is(t,s.workInProgress)||(uN(i,s),s.workInProgress=t)}return s.isDirty&&cN(i,0,()=>{s.current=s.workInProgress,s.isDirty=!1}),[s.workInProgress,s.dispatch]}function mN(e,t,n){return pN(e,t,n,!1)}var One=(e,t)=>typeof t==`function`?t(e):t,kne=e=>e===void 0?void 0:typeof e==`function`?e():e;function hN(e){return pN(One,e,kne,!0)}var gN=(e,t)=>{rN&&e.length!==t.length&&console.error(`The final argument passed to a hook changed size between renders. The order and size of this array must remain constant.
11
+
12
+ Previous: [${e.join(`, `)}]\nIncoming: [${t.join(`, `)}]`);for(let n=0;n<e.length&&n<t.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0},_N=(e,t)=>{cN(e,0,()=>{t.current=t.wip,t.currentDeps=t.wipDeps,t.isDirty=!1})},vN=(e,t)=>{let n=NM(),r=n.currentIndex++,i=n.cells[r];if(i===void 0){!n.isFirstRender&&r>=n.cells.length&&dN();let a=e();return rN&&n.devStrictMode&&e(),i={type:`memo`,current:a,currentDeps:t,wip:a,wipDeps:t,isDirty:!1},n.cells[r]=i,a}i.type!==`memo`&&fN();let a=i;if(gN(a.wipDeps,t))return a.isDirty&&_N(n,a),a.wip;let o=e();return rN&&n.devStrictMode&&e(),a.wip=o,a.wipDeps=t,a.isDirty||(a.isDirty=!0,lN(n.root,()=>{a.wip=a.current,a.wipDeps=a.currentDeps,a.isDirty=!1})),_N(n,a),o};function yN(e){return vN(()=>({current:e}),[])}var bN=(e,t)=>vN(()=>e,t),Ane=()=>({type:`effect`,cleanup:void 0,deps:null});function xN(e,t){let n=NM(),r=n.currentIndex++,i=n.cells[r],a=i===void 0?Ane():i.type===`effect`?i:fN();if(i===void 0&&(!n.isFirstRender&&r>=n.cells.length&&dN(),n.cells[r]=a),!(t&&a.deps&&gN(a.deps,t))){if(a.deps!==null&&!!t!=!!a.deps)throw Error(`useEffect called with and without dependencies across re-renders`);cN(n,2,()=>{try{a.cleanup?.()}finally{a.cleanup=void 0}}),cN(n,3,()=>{try{let t=e();if(t!==void 0&&typeof t!=`function`)throw Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof t}`);a.cleanup=t}finally{a.deps=t}})}}function SN(e){let t=NM(),n=yN(e);return n.current!==e&&cN(t,1,()=>{n.current=e}),bN(((...e)=>{if(rN&&PM())throw Error(`useEffectEvent cannot be called during render`);return n.current(...e)}),[])}var CN=e=>{if(!WM(e))throw Error("A tap resource's `use()` only accepts a tap context.");return JM(e)},wN=(e,t,n=t)=>{let r=yN(!0),i=r.current?n():t();r.current=!1;let[,a]=hN(0),o=SN(()=>{Object.is(i,t())||a(e=>e+1)});return xN(()=>(o(),e(o)),[e]),i},jne=(e,t)=>{},Mne=q.default;function Nne(e){let t=(0,q.useRef)(e);return(0,q.useInsertionEffect)(()=>{t.current=e}),(0,q.useCallback)(((...e)=>t.current(...e)),[])}var Pne=Mne.useEffectEvent??Nne,X=o({createContext:()=>LN,default:()=>q.default,use:()=>RN,useCallback:()=>jN,useContext:()=>zN,useDebugValue:()=>IN,useEffect:()=>MN,useEffectEvent:()=>PN,useLayoutEffect:()=>NN,useMemo:()=>AN,useReducer:()=>ON,useRef:()=>kN,useState:()=>DN,useSyncExternalStore:()=>FN});t(X,r(e(),1));var TN=()=>PM()!==null,EN=q.default,DN=e=>TN()?hN(e):EN.useState(e),ON=(e,t,n)=>TN()?mN(e,t,n):EN.useReducer(e,t,n),kN=e=>TN()?yN(e):EN.useRef(e),AN=(e,t)=>TN()?vN(e,t):EN.useMemo(e,t),jN=(e,t)=>TN()?bN(e,t):EN.useCallback(e,t),MN=(e,t)=>TN()?xN(e,t):EN.useEffect(e,t),NN=(e,t)=>TN()?xN(e,t):EN.useLayoutEffect(e,t),PN=e=>TN()?SN(e):Pne(e),FN=(e,t,n)=>TN()?wN(e,t,n):EN.useSyncExternalStore(e,t,n),IN=(e,t)=>TN()?void 0:EN.useDebugValue(e,t),LN=e=>{let t=EN.createContext(e);return VM(t,e),t},RN=e=>TN()&&WM(e)?CN(e):EN.use(e),zN=e=>TN()&&WM(e)?CN(e):EN.useContext(e),BN=q.default,VN=Symbol.for(`react.memo_cache_sentinel`),HN=e=>Array(e).fill(VN),Fne=e=>BN.useMemo(()=>{let t=HN(e);return t[VN]=!0,t},[]),Z=e=>{let t=PM();if(t===null)return(BN.__COMPILER_RUNTIME?.c??Fne)(e);let n=t.memoCache,r=n.workInProgress;if(r===null){let e=n.current;r=e===null?[]:e.map(e=>e.slice()),n.workInProgress=r}let i=n.index++,a=r[i];return a===void 0?(a=HN(e),r[i]=a):rN&&a.length!==e&&console.error(`Expected a constant size argument for each invocation of c(). The previous cache was allocated with size ${a.length} but size ${e} was requested.`),a};function UN(e){return(...t)=>({hook:e,args:t})}function WN(e,t,n){return n?{...t,key:e,deps:n}:{...t,key:e}}var Ine=50,GN={schedulers:new Set([]),isScheduled:!1},Lne=class{_task;_isDirty=!1;constructor(e){this._task=e}get isDirty(){return this._isDirty}markDirty(){this._isDirty=!0,GN.schedulers.add(this),Rne()}runTask(){this._isDirty=!1,this._task()}},Rne=()=>{GN.isScheduled||(GN.isScheduled=!0,zne())},KN=()=>{try{let e=[],t=0;for(let n of GN.schedulers)if(GN.schedulers.delete(n),n.isDirty){if(t++,t>Ine)throw Error(`Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.`);try{n.runTask()}catch(t){e.push(t)}}if(e.length>0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e,`Errors occurred during flushSync`)}}finally{GN.schedulers.clear(),GN.isScheduled=!1}},zne=(()=>{if(typeof MessageChannel<`u`){let e=new MessageChannel;return e.port1.onmessage=KN,()=>e.port2.postMessage(null)}return()=>setTimeout(KN,0)})(),qN=e=>{let t=GN;GN={schedulers:new Set([]),isScheduled:!0};try{let t=e();return KN(),t}finally{GN=t}},Bne={useState:hN,useReducer:mN,useRef:yN,useMemo:vN,useCallback:bN,useEffect:xN,useLayoutEffect:xN,useInsertionEffect:xN,useEffectEvent:SN,useContext:CN,use:CN,useSyncExternalStore:wN,useDebugValue:jne},JN=q.default,YN=JN.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??JN.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,XN=YN==null?null:`H`in YN?{get current(){return YN.H},set current(e){YN.H=e}}:`ReactCurrentDispatcher`in YN?{get current(){return YN.ReactCurrentDispatcher.current},set current(e){YN.ReactCurrentDispatcher.current=e}}:null;function Vne(e){if(!XN)return e();let t=XN.current;XN.current=Bne;try{return e()}finally{XN.current=t}}function ZN(e,t,n=void 0,r){return{hook:e,root:t,markDirty:n,devStrictMode:r,cells:[],contextDeps:null,wipContextDeps:null,commitCallbacks:null,wipCommitCallbacks:null,memoCache:{current:null,workInProgress:null,index:0},renderPendingCells:null,currentIndex:0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function QN(e){if(!e.isMounted)throw Error(`Tried to unmount a fiber that is already unmounted`);e.isMounted=!1,nN(e)}function $N(e,t){if(e.memoCache.workInProgress=null,e.renderPendingCells!==null){for(let t of e.renderPendingCells)t.renderQueue=null;e.renderPendingCells.clear()}let n=0,r;do{if(++n>25)throw Error(`Too many re-renders. tap limits the number of renders to prevent an infinite loop.`);e.memoCache.index=0,MM(e,()=>{r=Vne(()=>e.hook(...t))})}while((e.renderPendingCells?.size??0)>0);return ZM(e),r}function eP(e){let t=e.wipCommitCallbacks??e.commitCallbacks??[];e.wipCommitCallbacks=null,e.commitCallbacks=t,e.isMounted=!0,e.contextDeps=e.wipContextDeps,aN(e.root),e.memoCache.workInProgress!==null&&(e.memoCache.current=e.memoCache.workInProgress,e.memoCache.workInProgress=null),rN&&e.isNeverMounted&&e.devStrictMode===`root`&&(e.isNeverMounted=!1,tN(t),nN(e)),e.isNeverMounted=!1,tN(t)}var Hne=()=>{let e=NM();return e.devStrictMode?e.isFirstRender?`child`:`root`:null},Une=()=>`child`,tP=()=>null,Wne=()=>{if(!rN)return tP;let e=kN(0);return DN(()=>e.current++),e.current===2?Une:tP},nP=()=>PM()?Hne:Wne(),Gne=e=>e(),Kne=e=>{let t=AN(()=>new Lne(()=>p()),[]),n=AN(()=>[],[]),r=nP(),i=AN(()=>{let e=iN((r,i)=>{if(!t.isDirty){if(!r())return;i()}oN(e,e.committedVersion+e.changelog.length),n.push(i),t.markDirty()});return ZN(Gne,e,void 0,r())},[n,t,r]),a=zM(),o=i.root.version-i.root.committedVersion,s=BM(a,()=>$N(i,[e])),c=kN(!1),l=kN([e]),u=kN(s),d=AN(()=>new Set,[]),f=e=>{t.isDirty||u.current===e||(u.current=e,d.forEach(e=>e()))},p=PN(()=>{oN(i.root,i.root.committedVersion),n.forEach(e=>{rN&&i.devStrictMode&&e(),e()}),oN(i.root,i.root.committedVersion+i.root.changelog.length),rN&&i.devStrictMode&&BM(i.root.context,()=>$N(i,l.current));let e=BM(i.root.context,()=>$N(i,l.current));if(t.isDirty)throw Error(`Scheduler is dirty, this should never happen`);aN(i.root),n.length=0,c.current&&eP(i),f(e)});return MN(()=>(c.current=!0,()=>{c.current=!1,QN(i)}),[i]),MN(()=>{l.current=[e],aN(i.root),n.splice(0,o),i.root.context=a,eP(i),f(s)}),AN(()=>({getValue:()=>u.current,subscribe:e=>(d.add(e),()=>d.delete(e))}),[d])},qne=()=>{let e=kN(0),t=e.current,n=NM();return{version:t,markDirty:AN(()=>()=>{e.current++,n?.markDirty?.()},[n]),root:n.root}},Jne=()=>{let e=AN(()=>iN((e,t)=>{let i=!1;r(t=>(i=!e(),i?t:t+1)),i||n(t)}),[]),[t,n]=ON((t,n)=>(oN(e,t),t+ +!!n()),0),[,r]=DN(0);return oN(e,t),{root:e,version:t,markDirty:void 0}},rP=()=>{let e=nP(),{root:t,version:n,markDirty:r}=PM()?qne():Jne();return{version:n,createFiber:jN((n,i,a)=>ZN(n,t,a?()=>{a(),r?.()}:r,e()),[])}},iP=(e,t,n)=>{let r=kN(null),i=r.current??={wipDeps:null,wip:null,currentDeps:null,current:null};return i.wipDeps=i.currentDeps,i.wip=i.current,MN(()=>{i.currentDeps=i.wipDeps,i.current=i.wip}),!n&&i.currentDeps&&gN(i.currentDeps,t)?i.current:(i.wipDeps=t,i.wip=e(),i.wip)};function aP(e){let{version:t,createFiber:n}=rP(),r=AN(()=>n(e.hook,e.key),[e.hook,e.key,n]),i=iP(()=>({value:$N(r,e.args)}),[r,t,e.args],$M(r));return MN(()=>()=>QN(r),[r]),MN(()=>{eP(r)},[r,i]),i.value}var oP=(e,t)=>{let n=e.get(t);n&&(n.isDirty=!0)},Yne=(e,t)=>!e.isDirty&&!$M(e.fiber)&&t!==void 0&&e.committedDeps!==void 0&&gN(e.committedDeps,t),Xne=e=>{if(!QM())return!1;for(let{fiber:t}of e.values())if($M(t))return!0;return!1};function sP(e){let t=AN(()=>new Map,[]),{version:n,createFiber:r}=rP(),i=Xne(t),a=iP(()=>{let n=new Set,i=[],a=0;for(let o=0;o<e.length;o++){let s=e[o],c=s.key;if(c===void 0)throw Error(`useResources did not provide a key for array at index ${o}`);if(n.has(c))throw Error(`Duplicate key ${c} in useResources`);n.add(c);let l=t.get(c);if(!l){let e=r(s.hook,s.key,()=>oP(t,c));l={fiber:e,next:{value:$N(e,s.args),deps:s.deps},isDirty:!1,committedDeps:void 0,committedValue:void 0},a++,t.set(c,l)}else if(l.fiber.hook!==s.hook){let e=r(s.hook,s.key,()=>oP(t,c)),n=$N(e,s.args);l.next={value:n,deps:s.deps,remount:e}}else if(Yne(l,s.deps))l.fiber.contextDeps&&ZM(l.fiber,l.fiber.contextDeps),l.next=`skip`;else{let e=$N(l.fiber,s.args);l.next={value:e,deps:s.deps}}i.push(typeof l.next==`object`?l.next.value:l.committedValue)}if(t.size>i.length-a)for(let e of t.keys())n.has(e)||(t.get(e).next=`delete`);return i},[e,t,r,n],i);return MN(()=>()=>{for(let e of t.keys()){let n=t.get(e).fiber;QN(n)}},[t]),MN(()=>{for(let[e,n]of t.entries()){let r=n.next;r===`delete`?(n.fiber.isMounted&&QN(n.fiber),t.delete(e)):r===`skip`||(r.remount&&(QN(n.fiber),n.fiber=r.remount),eP(n.fiber),n.committedDeps=r.deps,n.committedValue=r.value,n.isDirty=!1)}},[a,t]),a}var Zne=e=>e(),Qne=e=>{let{createFiber:t}=rP(),n=AN(()=>t(Zne,void 0),[t]),r=$N(n,[e]);MN(()=>()=>{QN(n)},[n]);let i=!1,a=()=>{i&&n.isMounted||(i=!0,eP(n))};return MN(a),{value:r,effects:a}},$ne=UN(()=>{let e=Z(4),[t,n]=DN(ere),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(e,t)=>(n(n=>({...n,renderers:{...n.renderers,[e]:[...n.renderers[e]??[],t]}})),()=>{n(n=>({...n,renderers:{...n.renderers,[e]:n.renderers[e]?.filter(e=>e!==t)??[]}}))}),e[0]=r):r=e[0];let i=r,a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n(t=>({...t,fallbacks:[...t.fallbacks,e]})),()=>{n(t=>({...t,fallbacks:t.fallbacks.filter(t=>t!==e)}))}),e[1]=a):a=e[1];let o=a,s;return e[2]===t?s=e[3]:(s={getState:()=>t,setDataUI:i,setFallbackDataUI:o},e[2]=t,e[3]=s),s});function ere(){return{renderers:{},fallbacks:[]}}var tre=e=>{let t=Array.from(e).map(e=>e.getModelContext()).sort((e,t)=>(t.priority??0)-(e.priority??0)),n={};return t.reduce((e,t)=>{let r=t.priority??0;if(t.system&&(e.system?e.system+=`\n\n${t.system}`:e.system=t.system),t.tools)for(let[i,a]of Object.entries(t.tools)){let t=e.tools?.[i];if(t&&t!==a){let o=n[i];if(o===r)throw Error(`You tried to define a tool with the name ${i}, but it already exists.`);let s=o>r?t:a,c=o>r?a:t;e.tools[i]={...c,...s},n[i]=Math.max(o,r);continue}e.tools||={},e.tools[i]=a,n[i]??=r}return t.config&&(e.config={...e.config,...t.config}),t.callSettings&&(e.callSettings={...e.callSettings,...t.callSettings}),e},{})},cP=class{_providers=new Set;getModelContext(){return tre(this._providers)}registerModelContextProvider(e){this._providers.add(e);let t=e.subscribe?.(()=>{this.notifySubscribers()});return this.notifySubscribers(),()=>{this._providers.delete(e),t?.(),this.notifySubscribers()}}_subscribers=new Set;notifySubscribers(){for(let e of this._subscribers)e()}subscribe(e){return this._subscribers.add(e),()=>{this._subscribers.delete(e)}}},lP=[],nre={modelName:void 0,toolNames:lP},rre=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>e===t[n]),uP=(e,t)=>{let n=e.getModelContext(),r=n.config?.modelName,i=n.tools?Object.keys(n.tools).sort():lP,a=i.length?i:lP;return r===t.modelName&&rre(a,t.toolNames)?t:{modelName:r,toolNames:a}},dP=UN(()=>{let e=Z(11),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new cP,e[0]=t):t=e[0];let n=t,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>uP(n,nre),e[1]=r):r=e[1];let[i,a]=DN(r),o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>(a(e=>uP(n,e)),n.subscribe(()=>{a(e=>uP(n,e))})),s=[n],e[2]=o,e[3]=s):(o=e[2],s=e[3]),MN(o,s);let c;e[4]===i?c=e[5]:(c=()=>uP(n,i),e[4]=i,e[5]=c);let l,u,d;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>n.getModelContext(),u=e=>n.subscribe(e),d=e=>n.registerModelContextProvider(e),e[6]=l,e[7]=u,e[8]=d):(l=e[6],u=e[7],d=e[8]);let f;return e[9]===c?f=e[10]:(f={getState:c,getModelContext:l,subscribe:u,register:d},e[9]=c,e[10]=f),f}),ire=e=>e.display===void 0?e.type===`human`:e.display===`standalone`,are=(e,t)=>{if(!(t.status?.type===`running`||t.status?.type===`requires-action`)){let n=e.complete;return typeof n==`function`?n({args:t.args,result:t.result}):n??null}let n=e.running;return typeof n==`function`?n({args:t.args}):n??null},ore=e=>function(t){return are(e,t)},fP=Symbol(`assistant-ui.store.clientIndex`),sre=e=>e[fP],pP=LN([]),mP=()=>RN(pP),cre=(e,t)=>{let n=Z(3),r=mP(),i;return n[0]!==e||n[1]!==r?(i=[...r,e],n[0]=e,n[1]=r,n[2]=i):i=n[2],KM(pP,i,t)},lre=new Set([`$$typeof`,`nodeType`,`then`]),hP=(e,t)=>{if(e===Symbol.toStringTag)return t;if(typeof e!=`symbol`){if(e===`toJSON`)return()=>t;if(!lre.has(e))return!1}},gP=class{getOwnPropertyDescriptor(e,t){let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!0,configurable:!1}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}},_P=Symbol(`assistant-ui.store.getValue`),ure=e=>{let t=e[_P];if(!t)throw Error(`Client scope contains a non-client resource. Ensure your Derived get() returns a client created with useClientResource(), not a plain resource.`);return t.getState?.()},vP=new Map;function dre(e){let t=vP.get(e);return t||(t=function(...t){if(!this||typeof this!=`object`)throw Error(`Method "${String(e)}" called without proper context. This may indicate the function was called incorrectly.`);let n=this[_P];if(!n)throw Error(`Method "${String(e)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);let r=n[e];if(!r)throw Error(`Method "${String(e)}" is not implemented.`);if(typeof r!=`function`)throw Error(`"${String(e)}" is not a function.`);return r(...t)},vP.set(e,t)),t}var fre=class extends gP{outputRef;index;boundFns;cachedReceiver;constructor(e,t){super(),this.outputRef=e,this.index=t}get(e,t,n){if(t===_P)return this.outputRef.current;if(t===fP)return this.index;let r=hP(t,`ClientProxy`);if(r!==!1)return r;let i=this.outputRef.current[t];if(typeof i==`function`){this.cachedReceiver!==n&&(this.boundFns=new Map,this.cachedReceiver=n);let e=this.boundFns.get(t);return e||(e=dre(t).bind(n),this.boundFns.set(t,e)),e}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(e,t){return t===_P||t===fP||t in this.outputRef.current}},yP=e=>{let t=kN(null),n=mP().length,r=AN(()=>new Proxy({},new fre(t,n)),[n]),i=cre(r,function(){return aP(e)});return t.current||=i,MN(()=>{t.current=i}),{methods:r,state:i.getState?.(),key:e.key}},pre=UN(yP),bP=Symbol(`assistant-ui.store.proxiedAssistantState`),xP=e=>e===`on`||e===`subscribe`||typeof e==`symbol`,SP=e=>{class t extends gP{get(t,n){let r=hP(n,`AssistantState`);if(r!==!1)return r;let i=n;if(!xP(i))return ure(e[i]())}ownKeys(){return Object.keys(e).filter(e=>!xP(e))}has(t,n){return!xP(n)&&n in e}}return new Proxy({},new t)},mre=e=>e[bP],hre=()=>()=>{},CP=e=>{let t=(()=>{throw Error(e)});return t.source=null,t.query=null,t},wP=new Proxy({},new class extends gP{get(e,t){if(t===`subscribe`||t===`on`)return hre;if(t===bP)return gre;let n=hP(t,`DefaultAssistantClient`);return n===!1?CP(`You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.`):n}ownKeys(){return[`subscribe`,`on`,bP]}has(e,t){return t===`subscribe`||t===`on`||t===bP}}),gre=SP(wP),_re=()=>new Proxy({},{get(e,t){let n=hP(t,`AssistantClient`);return n===!1?CP(`The current scope does not have a "${String(t)}" property.`):n}}),TP=LN(wP),EP=Symbol(`assistant-ui.store.useEffects`),DP=()=>{},OP=e=>e[EP]??DP,kP=()=>{"use no memo";return MN(OP(AP())),null},AP=()=>zN(TP),jP=({value:e,children:t})=>{"use no memo";return(0,J.jsxs)(TP.Provider,{value:e,children:[(0,J.jsx)(kP,{}),t]})},MP=e=>null,NP=UN(MP),PP=Symbol(`assistant-ui.transform-scopes`);function FP(e,t){let n=e;if(n[PP])throw Error(`transformScopes is already attached to this resource`);n[PP]=t}function IP(e){return e[PP]}var LP=e=>typeof e==`string`?{scope:e.split(`.`)[0],event:e}:{scope:e.scope,event:e.event},RP=LN(null),zP=(e,t)=>KM(RP,e,t),BP=()=>{let e=RN(RP);if(!e)throw Error(`AssistantTapContext is not available`);return e},VP=()=>BP().clientRef,HP=()=>{let e=Z(3),{emit:t}=BP(),n=mP(),r;return e[0]!==n||e[1]!==t?(r=(e,r)=>{t(e,r,n)},e[0]=n,e[1]=t,e[2]=r):r=e[2],PN(r)};function UP(e,t){let n={...e},r=new Set,i=!0;for(;i;){i=!1;for(let e of Object.values(n)){if(e.hook===MP||r.has(e.hook))continue;r.add(e.hook);let a=IP(e.hook);if(a){a(n,t),i=!0;break}}}let a={},o={};for(let[e,t]of Object.entries(n))t.hook===MP?o[e]=t:a[e]=t;return{rootClients:a,derivedClients:o}}var WP=e=>AN(()=>e,[...Object.entries(e).flat()]),GP=(e,t)=>{let n=Z(6),r;n[0]!==t||n[1]!==e?(r=UP(e,t),n[0]=t,n[1]=e,n[2]=r):r=n[2];let{rootClients:i,derivedClients:a}=r,o=WP(i),s=WP(a),c;return n[3]!==o||n[4]!==s?(c={rootClients:o,derivedClients:s},n[3]=o,n[4]=s,n[5]=c):c=n[5],c},KP=UN(()=>{let e=Z(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new Map,e[0]=t):t=e[0];let n=t,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Set,e[1]=r):r=e[1];let i=r,a;if(e[2]===Symbol.for(`react.memo_cache_sentinel`)){let t=new Set;a={on(e,t){let r=t;if(e===`*`)return i.add(r),()=>i.delete(r);let a=n.get(e);return a||(a=new Set,n.set(e,a)),a.add(r),()=>{a.delete(r),a.size===0&&n.delete(e)}},emit(e,t,r){let a=n.get(e);!a&&i.size===0||queueMicrotask(()=>{let n=[];if(a)for(let e of a)try{e(t,r)}catch(e){let t=e;n.push(t)}if(i.size>0){let a={event:e,payload:t};for(let e of i)try{e(a,r)}catch(e){let t=e;n.push(t)}}if(n.length>0){if(n.length===1)throw n[0];for(let e of n)console.error(e);throw AggregateError(n,`Errors occurred during event emission`)}})},subscribe(e){return t.add(e),()=>t.delete(e)},notifySubscribers(){for(let e of t)try{e()}catch(e){console.error(`NotificationManager: subscriber callback error`,e)}}},e[2]=a}else a=e[2];return a}),qP=e=>AN(()=>e,e),JP=({element:e,emit:t,clientRef:n})=>{let{methods:r,state:i}=zP({clientRef:n,emit:t},function(){return yP(e)});return AN(()=>({state:i,methods:r}),[r,i])},YP=UN(({element:e,notifications:t,clientRef:n,name:r})=>{let i=Kne(function(){return JP({element:e,emit:t.emit,clientRef:n})});return MN(()=>i.subscribe(t.notifySubscribers),[i,t]),AN(()=>{let e=()=>i.getValue().methods;return Object.defineProperties(e,{source:{value:`root`,writable:!1},query:{value:{},writable:!1},name:{value:r,configurable:!0}}),e},[i,r])}),XP=UN(()=>{let e=Z(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n={clients:t,subscribe:void 0,on:void 0},e[1]=n):n=e[1],n}),ZP=e=>{let t=Z(14),{clients:n,clientRef:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=KP(),t[0]=i):i=t[0];let a=aP(i),o;t[1]!==r.parent||t[2]!==a.notifySubscribers?(o=()=>r.parent.subscribe(a.notifySubscribers),t[1]=r.parent,t[2]=a.notifySubscribers,t[3]=o):o=t[3];let s;t[4]!==r||t[5]!==a?(s=[r,a],t[4]=r,t[5]=a,t[6]=s):s=t[6],MN(o,s);let c;t[7]!==r||t[8]!==n||t[9]!==a?(c=Object.keys(n).map(e=>WN(e,YP({element:n[e],notifications:a,clientRef:r,name:e}))),t[7]=r,t[8]=n,t[9]=a,t[10]=c):c=t[10];let l=qP(sP(c)),u;return t[11]!==a||t[12]!==l?(u={notifications:a,results:l},t[11]=a,t[12]=l,t[13]=u):u=t[13],u},QP=UN(e=>{let{clientRef:t}=e,{notifications:n,results:r}=ZP(e);return AN(()=>({clients:r,subscribe:n.subscribe,on:function(e,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=LP(e);if(i!==`*`&&this[i].source===null)throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);let o=n.on(a,(e,t)=>{if(i===`*`){r(e);return}let n=this[i]();n===t[sre(n)]&&r(e)});if(i!==`*`&&t.parent[i].source===null)return o;let s=t.parent.on(e,r);return()=>{o(),s()}}}),[r,n,t])}),$P=UN(({element:e,clientRef:t,name:n})=>{let r=kN(e.args[0]);return r.current=e.args[0],AN(()=>{let e=()=>r.current.get(t.current);return Object.defineProperties(e,{source:{value:r.current.source},query:{value:r.current.query},name:{value:n,configurable:!0}}),e},[t,n])}),eF=(e,t)=>{let n;try{let e={};for(let n of Object.keys(t.query).sort())e[n]=t.query[n];n=JSON.stringify(e)}catch{n=String(t.query)}return`${e}::${t.source}::${n}`},tF=e=>{let t=Z(3),{clients:n,clientRef:r}=e,i;return t[0]!==r||t[1]!==n?(i=Object.keys(n).map(e=>{let t=e,i=n[t];return WN(eF(t,i.args[0]),$P({element:i,clientRef:r,name:t}))}),t[0]=r,t[1]=n,t[2]=i):i=t[2],qP(sP(i))},nF=e=>{let t=Z(3),{rootClients:n,clientRef:r}=e,i;return t[0]!==r||t[1]!==n?(i=Object.keys(n).length>0?QP({clients:n,clientRef:r}):XP(),t[0]=r,t[1]=n,t[2]=i):i=t[2],aP(i)},rF=({parent:e,clients:t})=>{let{rootClients:n,derivedClients:r}=GP(t,e),i=kN({parent:e,current:null}).current;MN(()=>{i.current=s});let a=nF({rootClients:n,clientRef:i}),o=tF({clients:r,clientRef:i}),s=AN(()=>{let t=e===wP?_re():e,n=Object.create(t);Object.assign(n,{subscribe:a.subscribe??e.subscribe,on:a.on??e.on,[bP]:SP(n)});for(let e of a.clients)n[e.name]=e;for(let e of o)n[e.name]=e;return n},[e,a,o]);return i.current===null&&(i.current=s),s},iF=e=>{let{value:t,effects:n}=Qne(function(){return rF(e)});return t[EP]=n,t};function aF(e,{parent:t}={parent:AP()}){if(e)return iF({parent:t??wP,clients:e});if(t===null)throw Error(`received null parent, this usage is not allowed`);return t}var Q=e=>{let t=Z(6),n=aF(),r;t[0]===n?r=t[1]:(r=mre(n),t[0]=n,t[1]=r);let i=r,a,o;t[2]!==i||t[3]!==e?(a=()=>e(i),o=()=>e(i),t[2]=i,t[3]=e,t[4]=a,t[5]=o):(a=t[4],o=t[5]);let s=FN(n.subscribe,a,o);if(s===i)throw Error(`You tried to return the entire AssistantState. This is not supported due to technical limitations.`);return IN(s),s},oF=e=>{let t=aF(),n=kN(!1),r=n.current?null:e(t);return Q(()=>n.current?e(t):r),()=>(n.current=!0,e(t))},sF=Object.freeze({});function cF(e){let t=Z(3),{getItemState:n,children:r}=e,i=oF(n),a;return t[0]!==r||t[1]!==i?(a=r(i),t[0]=r,t[1]=i,t[2]=a):a=t[2],lF(a)}var lF=e=>{let t=typeof e==`object`&&e&&`type`in e?e:null,n=t?.type,r=t?.key;return AN(()=>t,[n,r,typeof t?.props==`object`&&t.props!=null&&Object.entries(t.props).length===0?sF:t?.props])??e},uF=q.createContext(!0);function dF(){throw Error(`A function wrapped in useEffectEvent can't be called during rendering.`)}var fF=`use`in q.default?()=>{try{return q.use(uF)}catch{return!1}}:()=>!1;function pF(e){let t=q.useRef(dF);return q.useInsertionEffect(()=>{t.current=e},[e]),(...e)=>{fF()&&dF();let n=t.current;return n(...e)}}var mF=(e,t)=>{let n=Z(11),r=aF(),i=pF(t),a;n[0]===e?a=n[1]:(a=LP(e),n[0]=e,n[1]=a);let{scope:o,event:s}=a,c;n[2]!==r||n[3]!==i||n[4]!==s||n[5]!==o?(c=()=>r.on({scope:o,event:s},i),n[2]=r,n[3]=i,n[4]=s,n[5]=o,n[6]=c):c=n[6];let l;n[7]!==r||n[8]!==s||n[9]!==o?(l=[r,o,s],n[7]=r,n[8]=s,n[9]=o,n[10]=l):l=n[10],MN(c,l)},hF=e=>{if(e.key===void 0)throw Error(`useClientLookup: Element has no key`);return e.key};function gF(e){let t=Z(15),n;t[0]===e?n=t[1]:(n=e.map(yF),t[0]=e,t[1]=n);let r=sP(n),i;t[2]===r?i=t[3]:(i=Object.keys(r),t[2]=r,t[3]=i);let a=i,o;t[4]===r?o=t[5]:(o=r.reduce(vF,{}),t[4]=r,t[5]=o);let s=o,c;t[6]===r?c=t[7]:(c=r.map(_F),t[6]=r,t[7]=c);let l=c,u;t[8]!==s||t[9]!==a||t[10]!==r?(u=e=>{if(`index`in e){if(e.index<0||e.index>=a.length)throw Error(`useClientLookup: Index ${e.index} out of bounds (length: ${a.length})`);return r[e.index].methods}let t=s[e.key];if(t===void 0)throw Error(`useClientLookup: Key "${e.key}" not found`);return r[t].methods},t[8]=s,t[9]=a,t[10]=r,t[11]=u):u=t[11];let d;return t[12]!==l||t[13]!==u?(d={state:l,get:u},t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function _F(e){return e.state}function vF(e,t,n){return e[t.key]=n,e}function yF(e){return WN(hF(e),pre(e),e.deps)}var bF=e=>{let t=Z(15),{toolkit:n,mcpApp:r}=e,i;t[0]===r?i=t[1]:(i=r?[WN(`mcpApp`,r)]:[],t[0]=r,t[1]=i);let a=sP(i)[0],[o,s]=DN(SF),c;t[2]===o?c=t[3]:(c=Object.fromEntries(Object.entries(o).map(wF)),t[2]=o,t[3]=c);let l;t[4]!==a||t[5]!==c||t[6]!==o?(l={toolUIs:o,mcpApp:a,tools:c},t[4]=a,t[5]=c,t[6]=o,t[7]=l):l=t[7];let u=l,d=VP(),f;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=(e,t,n)=>{let r={render:t,standalone:n?.standalone??!1};return s(t=>({...t,[e]:[...t[e]??[],r]})),()=>{s(t=>{let n=t[e]?.filter(e=>e!==r)??[];if(n.length>0)return{...t,[e]:n};let i={...t};return delete i[e],i})}},t[8]=f):f=t[8];let p=f,m,h;t[9]!==d||t[10]!==n?(m=()=>{if(!n)return;let e=[];for(let[t,r]of Object.entries(n)){let n=`render`in r?r.render:void 0,i=`renderText`in r?r.renderText:void 0,a=n??(i?ore(i):void 0);a&&e.push(p(t,a,{standalone:ire(r)}))}let t=Object.entries(n).reduce(TF,{});return e.push(d.current.modelContext().register({getModelContext:()=>({tools:t})})),()=>{e.forEach(EF)}},h=[n,p,d],t[9]=d,t[10]=n,t[11]=m,t[12]=h):(m=t[11],h=t[12]),MN(m,h);let g;return t[13]===u?g=t[14]:(g={getState:()=>u,setToolUI:p},t[13]=u,t[14]=g),g},xF=UN(bF);FP(bF,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=dP())});function SF(){return{}}function CF(e){return e.render}function wF(e){let[t,n]=e;return[t,n.map(CF)]}function TF(e,t){let[n,r]=t;if(r.type===`mcp`)return e;let{display:i,render:a,renderText:o,...s}=r;return e[n]=s,e}function EF(e){return e()}var DF=e=>FN(e.subscribe,e.getState),OF=UN(e=>{let t=Z(8),{runtime:n}=e,r=DF(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=()=>n,t[2]=n,t[3]=a);let o;return t[4]!==n.remove||t[5]!==i||t[6]!==a?(o={getState:i,remove:n.remove,__internal_getRuntime:a},t[4]=n.remove,t[5]=i,t[6]=a,t[7]=o):o=t[7],o}),kF=UN(e=>{let t=Z(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=OF({runtime:a}),t[3]=a,t[4]=o),aP(o)}),AF=UN(({item:e,onSteer:t,onRemove:n})=>({getState:()=>e,steer:t,remove:n})),jF=UN(e=>{let t=Z(55),{threadIdRef:n,messageIdRef:r,runtime:i}=e,a=DF(i),o=HP(),s,c;t[0]!==o||t[1]!==r||t[2]!==i||t[3]!==n?(s=()=>{let e=[];for(let t of[`send`,`attachmentAdd`]){let a=i.unstable_on(t,()=>{o(`composer.${t}`,{threadId:n.current,...r&&{messageId:r.current}})});e.push(a)}return e.push(i.unstable_on(`attachmentAddError`,e=>{o(`composer.attachmentAddError`,{threadId:n.current,...r&&{messageId:r.current},...e.attachmentId&&{attachmentId:e.attachmentId},reason:e.reason,message:e.message})})),()=>{for(let t of e)t()}},c=[i,o,n,r],t[0]=o,t[1]=r,t[2]=i,t[3]=n,t[4]=s,t[5]=c):(s=t[4],c=t[5]),MN(s,c);let l;if(t[6]!==i||t[7]!==a.attachments){let e;t[9]===i?e=t[10]:(e=(e,t)=>WN(e.id,kF({runtime:i,index:t}),[i,t]),t[9]=i,t[10]=e),l=a.attachments.map(e),t[6]=i,t[7]=a.attachments,t[8]=l}else l=t[8];let u=gF(l),d=a.queue,f;if(t[11]!==d||t[12]!==i){let e;t[14]===i?e=t[15]:(e=e=>WN(e.id,AF({item:e,onSteer:()=>i.steerQueueItem(e.id),onRemove:()=>i.removeQueueItem(e.id)})),t[14]=i,t[15]=e),f=d.map(e),t[11]=d,t[12]=i,t[13]=f}else f=t[13];let p=gF(f),m=a.type??`thread`,h;t[16]!==u.state||t[17]!==d||t[18]!==a.attachmentAccept||t[19]!==a.canCancel||t[20]!==a.canSend||t[21]!==a.dictation||t[22]!==a.isEditing||t[23]!==a.isEmpty||t[24]!==a.quote||t[25]!==a.role||t[26]!==a.runConfig||t[27]!==a.text||t[28]!==m?(h={text:a.text,role:a.role,attachments:u.state,runConfig:a.runConfig,isEditing:a.isEditing,canCancel:a.canCancel,canSend:a.canSend,attachmentAccept:a.attachmentAccept,isEmpty:a.isEmpty,type:m,dictation:a.dictation,quote:a.quote,queue:d},t[16]=u.state,t[17]=d,t[18]=a.attachmentAccept,t[19]=a.canCancel,t[20]=a.canSend,t[21]=a.dictation,t[22]=a.isEditing,t[23]=a.isEmpty,t[24]=a.quote,t[25]=a.role,t[26]=a.runConfig,t[27]=a.text,t[28]=m,t[29]=h):h=t[29];let g=h,_;t[30]===g?_=t[31]:(_=()=>g,t[30]=g,t[31]=_);let v=i.beginEdit??MF,y;t[32]===u?y=t[33]:(y=e=>`id`in e?u.get({key:e.id}):u.get(e),t[32]=u,t[33]=y);let b;t[34]===p?b=t[35]:(b=e=>p.get(e),t[34]=p,t[35]=b);let x;t[36]===i?x=t[37]:(x=()=>i,t[36]=i,t[37]=x);let S;return t[38]!==i.addAttachment||t[39]!==i.cancel||t[40]!==i.clearAttachments||t[41]!==i.reset||t[42]!==i.send||t[43]!==i.setQuote||t[44]!==i.setRole||t[45]!==i.setRunConfig||t[46]!==i.setText||t[47]!==i.startDictation||t[48]!==i.stopDictation||t[49]!==b||t[50]!==x||t[51]!==_||t[52]!==v||t[53]!==y?(S={getState:_,setText:i.setText,setRole:i.setRole,setRunConfig:i.setRunConfig,addAttachment:i.addAttachment,reset:i.reset,clearAttachments:i.clearAttachments,send:i.send,cancel:i.cancel,beginEdit:v,startDictation:i.startDictation,stopDictation:i.stopDictation,setQuote:i.setQuote,attachment:y,queueItem:b,__internal_getRuntime:x},t[38]=i.addAttachment,t[39]=i.cancel,t[40]=i.clearAttachments,t[41]=i.reset,t[42]=i.send,t[43]=i.setQuote,t[44]=i.setRole,t[45]=i.setRunConfig,t[46]=i.setText,t[47]=i.startDictation,t[48]=i.stopDictation,t[49]=b,t[50]=x,t[51]=_,t[52]=v,t[53]=y,t[54]=S):S=t[54],S});function MF(){throw Error(`beginEdit is not supported in this runtime`)}var NF=e=>({get current(){return e()}}),PF=UN(e=>{let t=Z(13),{runtime:n}=e,r=DF(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o,s,c;t[2]===n?(a=t[3],o=t[4],s=t[5],c=t[6]):(a=e=>n.addToolResult(e),o=e=>n.resumeToolCall(e),s=e=>n.respondToToolApproval(e),c=()=>n,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c);let l;return t[7]!==i||t[8]!==a||t[9]!==o||t[10]!==s||t[11]!==c?(l={getState:i,addToolResult:a,resumeToolCall:o,respondToToolApproval:s,__internal_getRuntime:c},t[7]=i,t[8]=a,t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}),FF=UN(e=>{let t=Z(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=OF({runtime:a}),t[3]=a,t[4]=o),aP(o)}),IF=UN(e=>{let t=Z(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getMessagePartByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=PF({runtime:a}),t[3]=a,t[4]=o),aP(o)}),LF=UN(e=>{let t=Z(55),{runtime:n,threadIdRef:r}=e,i=DF(n),[a,o]=DN(!1),[s,c]=DN(!1),l;t[0]===n?l=t[1]:(l=NF(()=>n.getState().id),t[0]=n,t[1]=l);let u=l,d;t[2]!==u||t[3]!==n.composer||t[4]!==r?(d=jF({runtime:n.composer,threadIdRef:r,messageIdRef:u}),t[2]=u,t[3]=n.composer,t[4]=r,t[5]=d):d=t[5];let f=yP(d),p;if(t[6]!==n||t[7]!==i.content){let e;t[9]===n?e=t[10]:(e=(e,t)=>WN(`toolCallId`in e&&e.toolCallId!=null?`toolCallId-${e.toolCallId}`:`index-${t}`,IF({runtime:n,index:t}),[n,t]),t[9]=n,t[10]=e),p=i.content.map(e),t[6]=n,t[7]=i.content,t[8]=p}else p=t[8];let m=gF(p),h;t[11]===i.attachments?h=t[12]:(h=i.attachments??[],t[11]=i.attachments,t[12]=h);let g;if(t[13]!==n||t[14]!==h){let e;t[16]===n?e=t[17]:(e=(e,t)=>WN(e.id,FF({runtime:n,index:t}),[n,t]),t[16]=n,t[17]=e),g=h.map(e),t[13]=n,t[14]=h,t[15]=g}else g=t[15];let _=gF(g),v=i,y;t[18]!==f.state||t[19]!==a||t[20]!==s||t[21]!==m.state||t[22]!==v?(y={...v,parts:m.state,composer:f.state,isCopied:a,isHovering:s},t[18]=f.state,t[19]=a,t[20]=s,t[21]=m.state,t[22]=v,t[23]=y):y=t[23];let b=y,x;t[24]===b?x=t[25]:(x=()=>b,t[24]=b,t[25]=x);let S;t[26]===f.methods?S=t[27]:(S=()=>f.methods,t[26]=f.methods,t[27]=S);let C,w,T,E,D,O,k;t[28]===n?(C=t[29],w=t[30],T=t[31],E=t[32],D=t[33],O=t[34],k=t[35]):(C=()=>n.delete(),w=e=>n.reload(e),T=()=>n.speak(),E=()=>n.stopSpeaking(),D=e=>n.submitFeedback(e),O=e=>n.switchToBranch(e),k=()=>n.unstable_getCopyText(),t[28]=n,t[29]=C,t[30]=w,t[31]=T,t[32]=E,t[33]=D,t[34]=O,t[35]=k);let A;t[36]===m?A=t[37]:(A=e=>`index`in e?m.get({index:e.index}):m.get({key:`toolCallId-${e.toolCallId}`}),t[36]=m,t[37]=A);let j;t[38]===_?j=t[39]:(j=e=>`id`in e?_.get({key:e.id}):_.get(e),t[38]=_,t[39]=j);let M;t[40]===n?M=t[41]:(M=()=>n,t[40]=n,t[41]=M);let N;return t[42]!==C||t[43]!==w||t[44]!==T||t[45]!==E||t[46]!==D||t[47]!==O||t[48]!==k||t[49]!==A||t[50]!==j||t[51]!==M||t[52]!==x||t[53]!==S?(N={getState:x,composer:S,delete:C,reload:w,speak:T,stopSpeaking:E,submitFeedback:D,switchToBranch:O,getCopyText:k,part:A,attachment:j,setIsCopied:o,setIsHovering:c,__internal_getRuntime:M},t[42]=C,t[43]=w,t[44]=T,t[45]=E,t[46]=D,t[47]=O,t[48]=k,t[49]=A,t[50]=j,t[51]=M,t[52]=x,t[53]=S,t[54]=N):N=t[54],N}),RF=UN(e=>{let t=Z(6),{runtime:n,id:r,threadIdRef:i}=e,a;t[0]!==r||t[1]!==n?(a=n.getMessageById(r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s;return t[3]!==o||t[4]!==i?(s=LF({runtime:o,threadIdRef:i}),t[3]=o,t[4]=i,t[5]=s):s=t[5],aP(s)}),zF=UN(e=>{let t=Z(58),{runtime:n}=e,r=DF(n),i=HP(),a,o;t[0]!==i||t[1]!==n?(a=()=>{let e=[];for(let t of[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`]){let r=n.unstable_on(t,()=>{let e=n.getState()?.threadId||`unknown`;i(`thread.${t}`,{threadId:e})});e.push(r)}return()=>{for(let t of e)t()}},o=[n,i],t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]),MN(a,o);let s;t[4]===n?s=t[5]:(s=NF(()=>n.getState().threadId),t[4]=n,t[5]=s);let c=s,l;t[6]!==n.composer||t[7]!==c?(l=jF({runtime:n.composer,threadIdRef:c}),t[6]=n.composer,t[7]=c,t[8]=l):l=t[8];let u=yP(l),d;if(t[9]!==n||t[10]!==r.messages||t[11]!==c){let e;t[13]!==n||t[14]!==c?(e=e=>WN(e.id,RF({runtime:n,id:e.id,threadIdRef:c}),[n,e.id,c]),t[13]=n,t[14]=c,t[15]=e):e=t[15],d=r.messages.map(e),t[9]=n,t[10]=r.messages,t[11]=c,t[12]=d}else d=t[12];let f=gF(d),p=f.state.length===0&&!r.isLoading,m;t[16]!==u.state||t[17]!==f.state||t[18]!==r.capabilities||t[19]!==r.extras||t[20]!==r.isDisabled||t[21]!==r.isLoading||t[22]!==r.isRunning||t[23]!==r.speech||t[24]!==r.state||t[25]!==r.suggestions||t[26]!==r.voice||t[27]!==p?(m={isEmpty:p,isDisabled:r.isDisabled,isLoading:r.isLoading,isRunning:r.isRunning,capabilities:r.capabilities,state:r.state,suggestions:r.suggestions,extras:r.extras,speech:r.speech,voice:r.voice,composer:u.state,messages:f.state},t[16]=u.state,t[17]=f.state,t[18]=r.capabilities,t[19]=r.extras,t[20]=r.isDisabled,t[21]=r.isLoading,t[22]=r.isRunning,t[23]=r.speech,t[24]=r.state,t[25]=r.suggestions,t[26]=r.voice,t[27]=p,t[28]=m):m=t[28];let h=m,g;t[29]===h?g=t[30]:(g=()=>h,t[29]=h,t[30]=g);let _;t[31]===u.methods?_=t[32]:(_=()=>u.methods,t[31]=u.methods,t[32]=_);let v;t[33]===f?v=t[34]:(v=e=>`id`in e?f.get({key:e.id}):f.get(e),t[33]=f,t[34]=v);let y;t[35]===n?y=t[36]:(y=()=>n,t[35]=n,t[36]=y);let b;return t[37]!==n.append||t[38]!==n.cancelRun||t[39]!==n.connectVoice||t[40]!==n.deleteMessage||t[41]!==n.disconnectVoice||t[42]!==n.export||t[43]!==n.getModelContext||t[44]!==n.getVoiceVolume||t[45]!==n.import||t[46]!==n.muteVoice||t[47]!==n.reset||t[48]!==n.resumeRun||t[49]!==n.startRun||t[50]!==n.stopSpeaking||t[51]!==n.subscribeVoiceVolume||t[52]!==n.unmuteVoice||t[53]!==v||t[54]!==y||t[55]!==g||t[56]!==_?(b={getState:g,composer:_,append:n.append,deleteMessage:n.deleteMessage,startRun:n.startRun,resumeRun:n.resumeRun,cancelRun:n.cancelRun,getModelContext:n.getModelContext,export:n.export,import:n.import,reset:n.reset,stopSpeaking:n.stopSpeaking,connectVoice:n.connectVoice,disconnectVoice:n.disconnectVoice,getVoiceVolume:n.getVoiceVolume,subscribeVoiceVolume:n.subscribeVoiceVolume,muteVoice:n.muteVoice,unmuteVoice:n.unmuteVoice,message:v,__internal_getRuntime:y},t[37]=n.append,t[38]=n.cancelRun,t[39]=n.connectVoice,t[40]=n.deleteMessage,t[41]=n.disconnectVoice,t[42]=n.export,t[43]=n.getModelContext,t[44]=n.getVoiceVolume,t[45]=n.import,t[46]=n.muteVoice,t[47]=n.reset,t[48]=n.resumeRun,t[49]=n.startRun,t[50]=n.stopSpeaking,t[51]=n.subscribeVoiceVolume,t[52]=n.unmuteVoice,t[53]=v,t[54]=y,t[55]=g,t[56]=_,t[57]=b):b=t[57],b}),BF=UN(e=>{let t=Z(20),{runtime:n}=e,r=DF(n),i=HP(),a,o;t[0]!==i||t[1]!==n?(a=()=>{let e=[];for(let t of[`switchedTo`,`switchedAway`]){let r=n.unstable_on(t,()=>{i(`threadListItem.${t}`,{threadId:n.getState().id})});e.push(r)}return()=>{for(let t of e)t()}},o=[n,i],t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]),MN(a,o);let s;t[4]===r?s=t[5]:(s=()=>r,t[4]=r,t[5]=s);let c;t[6]===n?c=t[7]:(c=()=>n,t[6]=n,t[7]=c);let l;return t[8]!==n.archive||t[9]!==n.delete||t[10]!==n.detach||t[11]!==n.generateTitle||t[12]!==n.initialize||t[13]!==n.rename||t[14]!==n.switchTo||t[15]!==n.unarchive||t[16]!==n.updateCustom||t[17]!==s||t[18]!==c?(l={getState:s,switchTo:n.switchTo,rename:n.rename,updateCustom:n.updateCustom,archive:n.archive,unarchive:n.unarchive,delete:n.delete,generateTitle:n.generateTitle,initialize:n.initialize,detach:n.detach,__internal_getRuntime:c},t[8]=n.archive,t[9]=n.delete,t[10]=n.detach,t[11]=n.generateTitle,t[12]=n.initialize,t[13]=n.rename,t[14]=n.switchTo,t[15]=n.unarchive,t[16]=n.updateCustom,t[17]=s,t[18]=c,t[19]=l):l=t[19],l}),VF=UN(e=>{let t=Z(5),{runtime:n,id:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getItemById(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=BF({runtime:a}),t[3]=a,t[4]=o),aP(o)}),HF=UN(e=>{let t=Z(40),{runtime:n,__internal_assistantRuntime:r}=e,i=DF(n),a;t[0]===n.main?a=t[1]:(a=zF({runtime:n.main}),t[0]=n.main,t[1]=a);let o=yP(a),s;t[2]!==n||t[3]!==i.threadItems?(s=Object.keys(i.threadItems).map(e=>WN(e,VF({runtime:n,id:e}),[n,e])),t[2]=n,t[3]=i.threadItems,t[4]=s):s=t[4];let c=gF(s),l=i.newThreadId??null,u;t[5]!==o.state||t[6]!==i.archivedThreadIds||t[7]!==i.hasMore||t[8]!==i.isLoading||t[9]!==i.isLoadingMore||t[10]!==i.mainThreadId||t[11]!==i.threadIds||t[12]!==l||t[13]!==c.state?(u={mainThreadId:i.mainThreadId,newThreadId:l,isLoading:i.isLoading,isLoadingMore:i.isLoadingMore,hasMore:i.hasMore,threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadItems:c.state,main:o.state},t[5]=o.state,t[6]=i.archivedThreadIds,t[7]=i.hasMore,t[8]=i.isLoading,t[9]=i.isLoadingMore,t[10]=i.mainThreadId,t[11]=i.threadIds,t[12]=l,t[13]=c.state,t[14]=u):u=t[14];let d=u,f;t[15]===d?f=t[16]:(f=()=>d,t[15]=d,t[16]=f);let p;t[17]===o.methods?p=t[18]:(p=()=>o.methods,t[17]=o.methods,t[18]=p);let m;t[19]!==d||t[20]!==c?(m=e=>{if(e===`main`)return c.get({key:d.mainThreadId});if(`id`in e)return c.get({key:e.id});let{index:t,archived:n}=e,r=n!==void 0&&n?d.archivedThreadIds[t]:d.threadIds[t];return c.get({key:r})},t[19]=d,t[20]=c,t[21]=m):m=t[21];let h,g,_,v,y;t[22]===n?(h=t[23],g=t[24],_=t[25],v=t[26],y=t[27]):(v=async(e,t)=>{await n.switchToThread(e,t)},y=async()=>{await n.switchToNewThread()},h=()=>n.getLoadThreadsPromise(),g=()=>n.reload(),_=()=>n.loadMore(),t[22]=n,t[23]=h,t[24]=g,t[25]=_,t[26]=v,t[27]=y);let b;t[28]===r?b=t[29]:(b=()=>r,t[28]=r,t[29]=b);let x;return t[30]!==h||t[31]!==g||t[32]!==_||t[33]!==b||t[34]!==f||t[35]!==p||t[36]!==m||t[37]!==v||t[38]!==y?(x={getState:f,thread:p,item:m,switchToThread:v,switchToNewThread:y,getLoadThreadsPromise:h,reload:g,loadMore:_,__internal_getAssistantRuntime:b},t[30]=h,t[31]=g,t[32]=_,t[33]=b,t[34]=f,t[35]=p,t[36]=m,t[37]=v,t[38]=y,t[39]=x):x=t[39],x}),UF=UN(e=>({getState:()=>e})),WF=UN(e=>{let t=Z(11),n;t[0]===e?n=t[1]:(n=()=>({suggestions:(e??[]).map(GF)}),t[0]=e,t[1]=n);let[r]=DN(n),i;t[2]===r.suggestions?i=t[3]:(i=r.suggestions.map(KF),t[2]=r.suggestions,t[3]=i);let a=gF(i),o;t[4]===r?o=t[5]:(o=()=>r,t[4]=r,t[5]=o);let s;t[6]===a?s=t[7]:(s=e=>{let{index:t}=e;return a.get({index:t})},t[6]=a,t[7]=s);let c;return t[8]!==o||t[9]!==s?(c={getState:o,suggestion:s},t[8]=o,t[9]=s,t[10]=c):c=t[10],c});function GF(e){return typeof e==`string`?{title:e,label:``,prompt:e}:{title:e.title,label:e.label,prompt:e.prompt}}function KF(e,t){return WN(t,UF(e),[e])}var qF=(e,t)=>{e.thread??=NP({source:`threads`,query:{type:`main`},get:e=>e.threads().thread(`main`)}),e.threadListItem??=NP({source:`threads`,query:{type:`main`},get:e=>e.threads().item(`main`)}),e.composer??=NP({source:`thread`,query:{},get:e=>e.threads().thread(`main`).composer()}),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=dP()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=WF())},JF=e=>{let t=Z(6),n=VP(),r,i;t[0]!==n||t[1]!==e?(r=()=>e.registerModelContextProvider(n.current.modelContext()),i=[e,n],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),MN(r,i);let a;return t[4]===e?a=t[5]:(a=HF({runtime:e.threads,__internal_assistantRuntime:e}),t[4]=e,t[5]=a),aP(a)},YF=UN(JF);FP(JF,(e,t)=>{qF(e,t),!e.tools&&t.tools.source===null&&(e.tools=xF({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=$ne())});var XF=e=>e._core?.RenderComponent,ZF=(0,X.memo)(({runtime:e,aui:t=null,children:n})=>{"use no memo";let r=aF({threads:YF(e)},{parent:t}),i=XF(e),a=(0,J.jsxs)(jP,{value:r,children:[i&&(0,J.jsx)(i,{}),n]});return t?(0,J.jsx)(jP,{value:t,children:a}):a}),QF=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},$F=(e=>e?QF(e):QF),eI=e=>e;function tI(e,t=eI){let n=q.useSyncExternalStore(e.subscribe,q.useCallback(()=>t(e.getState()),[e,t]),q.useCallback(()=>t(e.getInitialState()),[e,t]));return q.useDebugValue(n),n}var nI=e=>{let t=$F(e),n=e=>tI(t,e);return Object.assign(n,t),n},rI=(e=>e?nI(e):nI),iI=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});if(!e||!t)throw Error(`Failed to create promise`);return{promise:n,resolve:e,reject:t}},aI=()=>{let e=[],t=!1,n,r,i=i=>{i.promise||=i.reader.read().then(({done:a,value:o})=>{i.promise=void 0,a?(e.splice(e.indexOf(i),1),t&&e.length===0&&n.close()):n.enqueue(o),r?.resolve(),r=void 0}).catch(t=>{console.error(t),e.forEach(e=>{e.reader.cancel()}),e.length=0,n.error(t),r?.reject(t),r=void 0})};return{readable:new ReadableStream({start(e){n=e},pull(){return r=iI(),e.forEach(e=>{i(e)}),r.promise},cancel(){e.forEach(e=>{e.reader.cancel()}),e.length=0}}),isSealed(){return t},seal(){t=!0,e.length===0&&n.close()},addStream(n){if(t)throw Error(`Cannot add streams after the run callback has settled.`);let r={reader:n.getReader()};e.push(r),i(r)},enqueue(e){this.addStream(new ReadableStream({start(t){t.enqueue(e),t.close()}}))}}},oI=class{_controller;_isClosed=!1;constructor(e){this._controller=e}append(e){return this._controller.enqueue({type:`text-delta`,path:[],textDelta:e}),this}close(){this._isClosed||(this._isClosed=!0,this._controller.enqueue({type:`part-finish`,path:[]}),this._controller.close())}},sI=e=>new ReadableStream({start(t){return e.start?.(new oI(t))},pull(t){return e.pull?.(new oI(t))},cancel(t){return e.cancel?.(t)}}),cI=()=>{let e;return[sI({start(t){e=t}}),e]},lI=class{_controller;_isClosed=!1;_mergeTask;constructor(e){this._controller=e;let t=sI({start:e=>{this._argsTextController=e}}),n=!1;this._mergeTask=t.pipeTo(new WritableStream({write:e=>{switch(e.type){case`text-delta`:n=!0,this._controller.enqueue(e);break;case`part-finish`:n||this._controller.enqueue({type:`text-delta`,textDelta:`{}`,path:[]}),this._controller.enqueue({type:`tool-call-args-text-finish`,path:[]});break;default:throw Error(`Unexpected chunk type: ${e.type}`)}}}))}get argsText(){return this._argsTextController}_argsTextController;async setResponse(e){this._argsTextController.close(),await Promise.resolve(),this._controller.enqueue({type:`result`,path:[],...e.artifact===void 0?{}:{artifact:e.artifact},result:e.result,isError:e.isError??!1,...e.modelContent===void 0?{}:{modelContent:e.modelContent},...e.messages===void 0?{}:{messages:e.messages}})}async close(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),await this._mergeTask,this._controller.enqueue({type:`part-finish`,path:[]}),this._controller.close())}},uI=e=>new ReadableStream({start(t){return e.start?.(new lI(t))},pull(t){return e.pull?.(new lI(t))},cancel(t){return e.cancel?.(t)}}),dI=()=>{let e;return[uI({start(t){e=t}}),e]},fI=class{value=-1;up(){return++this.value}},pI=class extends TransformStream{constructor(e){super({transform(t,n){n.enqueue({...t,path:[e,...t.path]})}})}};TransformStream;var mI=class extends TransformStream{constructor(e){let t=new fI,n=new Map;super({transform(r,i){r.type===`part-start`&&r.path.length===0&&n.set(t.up(),e.up());let[a,...o]=r.path;if(a===void 0){i.enqueue(r);return}let s=n.get(a);if(s===void 0)throw Error(`Path not found`);i.enqueue({...r,path:[s,...o]})}})}},hI=class extends TransformStream{constructor(e){super();let t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},gI=class extends TransformStream{constructor(){let e=[];super({transform(t,n){if(t.type===`part-start`){if(t.path.length!==0){n.error(Error(`Nested parts are not supported`));return}e.push(t.part),n.enqueue(t);return}if(t.type===`text-delta`||t.type===`result`||t.type===`part-finish`||t.type===`tool-call-args-text-finish`){if(t.path.length!==1){n.error(Error(`${t.type} chunks must have a path of length 1`));return}let r=t.path[0];if(r<0||r>=e.length){n.error(Error(`Invalid path index: ${r}`));return}let i=e[r];n.enqueue({...t,meta:i});return}n.enqueue(t)}})}},_I=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i-->0;)r+=e[Math.random()*e.length|0];return r},vI=_I(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),yI=class e{_state;_parentId;constructor(e){this._state=e||{merger:aI(),contentCounter:new fI}}get __internal_isClosed(){return this._state.merger.isSealed()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(e){this._state.closeSubscriber=e}_addPart(e,t){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:`part-start`,part:e,path:[]}),this._state.merger.addStream(t.pipeThrough(new pI(this._state.contentCounter.value)))}merge(e){this._state.merger.addStream(e.pipeThrough(new mI(this._state.contentCounter)))}appendText(e){(this._state.append?.kind!==`text`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`text`,parentId:this._parentId,controller:this.addTextPart()}),this._state.append.controller.append(e)}appendReasoning(e){(this._state.append?.kind!==`reasoning`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`reasoning`,parentId:this._parentId,controller:this.addReasoningPart()}),this._state.append.controller.append(e)}addTextPart(){let[e,t]=cI();return this._addPart(this._withParentIdOption({type:`text`}),e),t}addReasoningPart(){let[e,t]=cI();return this._addPart(this._withParentIdOption({type:`reasoning`}),e),t}addToolCallPart(e){let t=typeof e==`string`?{toolName:e}:e,n=t.toolName,r=t.toolCallId??vI(),[i,a]=dI();return this._addPart({type:`tool-call`,toolName:n,toolCallId:r,...this._parentId&&{parentId:this._parentId}},i),t.argsText!==void 0&&(a.argsText.append(t.argsText),a.argsText.close()),t.args!==void 0&&(a.argsText.append(JSON.stringify(t.args)),a.argsText.close()),t.response!==void 0&&a.setResponse(t.response),a}_finishedPartStream(){return new ReadableStream({start(e){e.enqueue({type:`part-finish`,path:[]}),e.close()}})}_withParentIdOption(e){return this._parentId?{...e,parentId:this._parentId}:e}appendSource(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendFile(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendData(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}enqueue(e){this._state.merger.enqueue(e),e.type===`part-start`&&e.path.length===0&&this._state.contentCounter.up()}withParentId(t){let n=new e(this._state);return n._parentId=t,n}close(){this._state.append?.controller?.close(),this._state.merger.seal(),this._state.closeSubscriber?.()}};function bI(e){let t=new yI;return(async()=>{try{await e(t)}catch(e){throw t.__internal_isClosed||t.enqueue({type:`error`,path:[],error:String(e)}),e}finally{t.__internal_isClosed||t.close()}})(),t.__internal_getReadable()}function xI(){let{resolve:e,promise:t}=iI(),n;return[bI(r=>(n=r,n.__internal_subscribeToClose(e),t)),n]}function SI(e){let t=[`ROOT`],n=-1,r=null,i=[],a;function o(){a!==void 0&&(i.push(JSON.parse(`"${a}"`)),a=void 0)}function s(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`),o();break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),o();break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),o();break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`),o();break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`),o();break}}function c(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop(),a=i.pop();break}}function l(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),a=(Number(a)+1).toString();break;case`]`:n=r,t.pop(),a=i.pop();break}}for(let o=0;o<e.length;o++){let u=e[o];switch(t[t.length-1]){case`ROOT`:s(u,o,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`),a=``;break;case`}`:n=o,t.pop(),a=i.pop();break}break;case`INSIDE_OBJECT_AFTER_COMMA`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`),a=``;break}break;case`INSIDE_OBJECT_KEY`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`);break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`),a+=u;break;default:a+=u;break}break;case`INSIDE_OBJECT_AFTER_KEY`:switch(u){case`:`:t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`);break}break;case`INSIDE_OBJECT_BEFORE_VALUE`:s(u,o,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:c(u,o);break;case`INSIDE_STRING`:switch(u){case`"`:t.pop(),n=o,a=i.pop();break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=o}break;case`INSIDE_ARRAY_START`:switch(u){case`]`:n=o,t.pop(),a=i.pop();break;default:n=o,a=`0`,s(u,o,`INSIDE_ARRAY_AFTER_VALUE`);break}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(u){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),a=(Number(a)+1).toString();break;case`]`:n=o,t.pop(),a=i.pop();break;default:n=o;break}break;case`INSIDE_ARRAY_AFTER_COMMA`:s(u,o,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:t.pop(),t[t.length-1]===`INSIDE_STRING`?n=o:t[t.length-1]===`INSIDE_OBJECT_KEY`&&(a+=u);break;case`INSIDE_NUMBER`:switch(u){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=o;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),a=i.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&l(u,o),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&c(u,o);break;case`}`:t.pop(),a=i.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&c(u,o);break;case`]`:t.pop(),a=i.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&l(u,o);break;default:t.pop(),a=i.pop();break}break;case`INSIDE_LITERAL`:{let i=e.substring(r,o+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?c(u,o):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&l(u,o)):n=o;break}}}let u=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:u+=`"`;break;case`INSIDE_OBJECT_KEY`:case`INSIDE_OBJECT_AFTER_KEY`:case`INSIDE_OBJECT_AFTER_COMMA`:case`INSIDE_OBJECT_START`:case`INSIDE_OBJECT_BEFORE_VALUE`:case`INSIDE_OBJECT_AFTER_VALUE`:u+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:u+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?u+=`true`.slice(t.length):`false`.startsWith(t)?u+=`false`.slice(t.length):`null`.startsWith(t)&&(u+=`null`.slice(t.length))}}return[u,i]}var CI=r(i(((e,t)=>{var n=typeof Buffer<`u`,r=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,i=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function a(e,t,a){a==null&&typeof t==`object`&&t&&(a=t,t=void 0),n&&Buffer.isBuffer(e)&&(e=e.toString()),e&&e.charCodeAt(0)===65279&&(e=e.slice(1));let s=JSON.parse(e,t);if(typeof s!=`object`||!s)return s;let c=a&&a.protoAction||`error`,l=a&&a.constructorAction||`error`;if(c===`ignore`&&l===`ignore`)return s;if(c!==`ignore`&&l!==`ignore`){if(r.test(e)===!1&&i.test(e)===!1)return s}else if(c!==`ignore`&&l===`ignore`){if(r.test(e)===!1)return s}else if(i.test(e)===!1)return s;return o(s,{protoAction:c,constructorAction:l,safe:a&&a.safe})}function o(e,{protoAction:t=`error`,constructorAction:n=`error`,safe:r}={}){let i=[e];for(;i.length;){let e=i;i=[];for(let a of e){if(t!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`__proto__`)){if(r===!0)return null;if(t===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.__proto__}if(n!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`constructor`)&&a.constructor!==null&&typeof a.constructor==`object`&&Object.prototype.hasOwnProperty.call(a.constructor,`prototype`)){if(r===!0)return null;if(n===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.constructor}for(let e in a){let t=a[e];t&&typeof t==`object`&&i.push(t)}}}return e}function s(e,t,n){let{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return a(e,t,n)}finally{Error.stackTraceLimit=r}}function c(e,t){let{stackTraceLimit:n}=Error;Error.stackTraceLimit=0;try{return a(e,t,{safe:!0})}catch{return}finally{Error.stackTraceLimit=n}}t.exports=s,t.exports.default=s,t.exports.parse=s,t.exports.safeParse=c,t.exports.scan=o}))(),1),wI=Symbol(`aui.parse-partial-json-object.meta`),TI=e=>e?.[wI],EI=e=>{if(e.length===0)return{[wI]:{state:`partial`,partialPath:[]}};try{let t=CI.default.parse(e);if(typeof t!=`object`||!t)throw Error(`argsText is expected to be an object`);return t[wI]={state:`complete`,partialPath:[]},t}catch{try{let[t,n]=SI(e),r=CI.default.parse(t);if(typeof r!=`object`||!r)throw Error(`argsText is expected to be an object`);return r[wI]={state:`partial`,partialPath:n},r}catch{return}}},DI=(e,t,n)=>{if(typeof e!=`object`||!e)return t.state;if(t.state===`complete`)return`complete`;if(n.length===0)return t.state;let[r,...i]=n;if(!Object.hasOwn(e,r))return`partial`;let[a,...o]=t.partialPath;if(r!==a)return`complete`;let s=e[r];return DI(s,{state:`partial`,partialPath:o},i)},OI=(e,t)=>{let n=TI(e);if(!n)throw Error(`unable to determine object state`);return DI(e,n,t.map(String))};async function*kI(){let e=this.getReader();try{for(;;){let{done:t,value:n}=await e.read();if(t)break;yield n}}finally{e.releaseLock()}}function AI(e){return e[Symbol.asyncIterator]??=kI,e}var jI=Symbol.for(`aui.tool-response`),MI=class e{get[jI](){return!0}artifact;result;isError;modelContent;messages;constructor(e){e.artifact!==void 0&&(this.artifact=e.artifact),this.result=e.result,this.isError=e.isError??!1,e.modelContent!==void 0&&(this.modelContent=e.modelContent),e.messages!==void 0&&(this.messages=e.messages)}static[Symbol.hasInstance](e){return typeof e==`object`&&!!e&&jI in e}static toResponse(t){return t instanceof e?t:new e({result:t===void 0?`<no result>`:t})}};function NI(e,t,n){try{let r=e();if(typeof r==`object`&&r&&`then`in r)return r.then(t,n);t(r)}catch(e){n(e)}}function PI(e,t){let n=e;for(let e of t){if(n==null)return;n=n[e]}return n}var FI=class{resolve;reject;disposed=!1;fieldPath;constructor(e,t,n){this.resolve=e,this.reject=t,this.fieldPath=n}update(e){if(!this.disposed)try{if(OI(e,this.fieldPath)===`complete`){let t=PI(e,this.fieldPath);t!==void 0&&(this.resolve(t),this.dispose())}}catch(e){this.reject(e),this.dispose()}}end(e){if(!this.disposed)try{let t=PI(e,this.fieldPath);this.resolve(t)}catch(e){this.reject(e)}finally{this.dispose()}}dispose(){this.disposed=!0}},II=class{controller;disposed=!1;fieldPath;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=PI(e,this.fieldPath);t!==void 0&&this.controller.enqueue(t),OI(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},LI=class{controller;disposed=!1;fieldPath;lastValue=void 0;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=PI(e,this.fieldPath);if(t!==void 0&&typeof t==`string`){let e=t.substring(this.lastValue?.length||0);this.lastValue=t,this.controller.enqueue(e)}OI(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},RI=class{controller;disposed=!1;fieldPath;processedIndexes=new Set;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=PI(e,this.fieldPath);if(!Array.isArray(t))return;for(let n=0;n<t.length;n++)this.processedIndexes.has(n)||OI(e,[...this.fieldPath,n])===`complete`&&(this.controller.enqueue(t[n]),this.processedIndexes.add(n));OI(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},zI=class{argTextDeltas;handles=new Set;args=EI(``);finished=!1;constructor(e){this.argTextDeltas=e,this.processStream()}async processStream(){try{let e=``,t=this.argTextDeltas.getReader();for(;;){let{value:n,done:r}=await t.read();if(r)break;e+=n;let i=EI(e);if(i!==void 0){this.args=i;for(let e of this.handles)e.update(i)}}}catch(e){console.error(`Error processing argument stream:`,e)}finally{this.finished=!0;for(let e of this.handles)e.end(this.args);this.handles.clear()}}get(...e){return new Promise((t,n)=>{let r=new FI(t,n,e);if(this.args&&OI(this.args,e)===`complete`){let n=PI(this.args,e);if(n!==void 0){t(n);return}}if(this.finished){r.end(this.args);return}this.handles.add(r),r.update(this.args)})}streamValues(...e){let t=e,n;return AI(new ReadableStream({start:e=>{n=new II(e,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}streamText(...e){let t=e,n;return AI(new ReadableStream({start:e=>{n=new LI(e,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}forEach(...e){let t=e,n;return AI(new ReadableStream({start:e=>{n=new RI(e,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}},BI=class{promise;constructor(e){this.promise=e}get(){return this.promise}},VI=class{args;response;writable;resolve;argsText=``;constructor(){let e=new TransformStream;this.writable=e.writable,this.args=new zI(e.readable);let{promise:t,resolve:n}=iI();this.resolve=n,this.response=new BI(t)}async appendArgsTextDelta(e){let t=this.writable.getWriter();try{await t.write(e)}catch(e){console.warn(e)}finally{t.releaseLock()}this.argsText+=e}async finishArgsText(){let e=this.writable.getWriter();try{await e.close()}catch(e){console.warn(e)}finally{e.releaseLock()}}setResponse(e){this.resolve(e)}result={get:async()=>(await this.response.get()).result}},HI=class extends hI{constructor(e){let t=new Map,n=new Map;super(r=>{let i=new TransformStream({async transform(r,i){switch((r.type!==`part-finish`||r.meta.type!==`tool-call`)&&i.enqueue(r),r.type){case`part-start`:if(r.part.type===`tool-call`){let t=new VI;n.set(r.part.toolCallId,t),e.streamCall({reader:t,toolCallId:r.part.toolCallId,toolName:r.part.toolName})}break;case`text-delta`:if(r.meta.type===`tool-call`){let e=r.meta.toolCallId,t=n.get(e);if(!t)throw Error(`No controller found for tool call`);await t.appendArgsTextDelta(r.textDelta)}break;case`result`:{if(r.meta.type!==`tool-call`)break;let{toolCallId:e}=r.meta,t=n.get(e);if(!t)throw Error(`No controller found for tool call`);t.setResponse(new MI({result:r.result,artifact:r.artifact,isError:r.isError,modelContent:r.modelContent}));break}case`tool-call-args-text-finish`:{if(r.meta.type!==`tool-call`)break;let{toolCallId:a,toolName:o}=r.meta,s=n.get(a);if(!s)throw Error(`No controller found for tool call`);await s.finishArgsText();let c=!1,l=NI(()=>{let t;try{t=CI.default.parse(s.argsText)}catch(e){throw Error(`Function parameter parsing failed. ${JSON.stringify(e.message)}`)}let n=e.execute({toolCallId:a,toolName:o,args:t});return n!==void 0&&(c=!0,e.onExecutionStart?.(a,o)),n},t=>{if(c&&e.onExecutionEnd?.(a,o),t===void 0)return;let n=new MI({artifact:t.artifact,result:t.result,isError:t.isError,messages:t.messages,modelContent:t.modelContent});s.setResponse(n),i.enqueue({type:`result`,path:r.path,...n})},t=>{c&&e.onExecutionEnd?.(a,o);let n=new MI({result:String(t),isError:!0});s.setResponse(n),i.enqueue({type:`result`,path:r.path,...n})});l&&t.set(a,l);break}case`part-finish`:{if(r.meta.type!==`tool-call`)break;let{toolCallId:e}=r.meta,a=t.get(e);a?a.then(()=>{t.delete(e),n.delete(e),i.enqueue(r)}):i.enqueue(r)}}},async flush(){await Promise.all(t.values())}});return r.pipeThrough(new gI).pipeThrough(i)})}},UI=e=>typeof e==`object`&&!!e&&`~standard`in e&&e[`~standard`].version===1;function WI(e,t,n,r){let i=e?.[n.toolName];return i?.execute?(async e=>{if(t.aborted)return new MI({result:`Tool execution was cancelled.`,isError:!0});let a=e;if(UI(i.parameters)){let e=i.parameters[`~standard`].validate(n.args);e instanceof Promise&&(e=await e),e.issues&&(a=i.experimental_onSchemaValidationError??(()=>{throw Error(`Function parameter validation failed. ${JSON.stringify(e.issues)}`)}))}let o=new Promise(e=>{let n=()=>{queueMicrotask(()=>{queueMicrotask(()=>{e(new MI({result:`Tool execution was cancelled.`,isError:!0}))})})};t.aborted?n():t.addEventListener(`abort`,n,{once:!0})}),s=(async()=>{let e=await a(n.args,{toolCallId:n.toolCallId,abortSignal:t,human:e=>r(n.toolCallId,e)}),o=MI.toResponse(e);if(i.toModelOutput&&!o.isError&&o.modelContent===void 0)try{let e=await i.toModelOutput({toolCallId:n.toolCallId,input:n.args,output:o.result});return new MI({result:o.result,artifact:o.artifact,isError:o.isError,messages:o.messages,modelContent:e})}catch(e){console.warn(`[assistant-stream] tool "${n.toolName}" toModelOutput threw; falling back to default projection.`,e)}return o})();return Promise.race([s,o])})(i.execute):void 0}function GI(e,t,n,r,i){e?.[r.toolName]?.streamCall?.(n,{toolCallId:r.toolCallId,abortSignal:t,human:e=>i(r.toolCallId,e)})}function KI(e,t,n,r){let i=typeof e==`function`?e:()=>e,a=typeof t==`function`?t:()=>t;return new HI({execute:e=>WI(i(),a(),e,n),streamCall:({reader:e,...t})=>GI(i(),a(),e,t,n),onExecutionStart:r?.onExecutionStart,onExecutionEnd:r?.onExecutionEnd})}var qI=e=>{let t=Z(7),{index:n,children:r}=e,i;t[0]===n?i=t[1]:(i=NP({source:`message`,query:{type:`index`,index:n},get:e=>e.message().attachment({index:n})}),t[0]=n,t[1]=i);let a;t[2]===i?a=t[3]:(a={attachment:i},t[2]=i,t[3]=a);let o=aF(a),s;return t[4]!==o||t[5]!==r?(s=(0,J.jsx)(jP,{value:o,children:r}),t[4]=o,t[5]=r,t[6]=s):s=t[6],s},JI=e=>{let t=Z(7),{index:n,children:r}=e,i;t[0]===n?i=t[1]:(i=NP({source:`composer`,query:{type:`index`,index:n},get:e=>e.composer().attachment({index:n})}),t[0]=n,t[1]=i);let a;t[2]===i?a=t[3]:(a={attachment:i},t[2]=i,t[3]=a);let o=aF(a),s;return t[4]!==o||t[5]!==r?(s=(0,J.jsx)(jP,{value:o,children:r}),t[4]=o,t[5]=r,t[6]=s):s=t[6],s},YI=e=>{let t=Z(10),{index:n,children:r}=e,i;t[0]===n?i=t[1]:(i=NP({source:`thread`,query:{type:`index`,index:n},get:e=>e.thread().message({index:n})}),t[0]=n,t[1]=i);let a;t[2]===n?a=t[3]:(a=NP({source:`message`,query:{},get:e=>e.thread().message({index:n}).composer()}),t[2]=n,t[3]=a);let o;t[4]!==i||t[5]!==a?(o={message:i,composer:a},t[4]=i,t[5]=a,t[6]=o):o=t[6];let s=aF(o),c;return t[7]!==s||t[8]!==r?(c=(0,J.jsx)(jP,{value:s,children:r}),t[7]=s,t[8]=r,t[9]=c):c=t[9],c},XI=e=>{let t=Z(7),{index:n,children:r}=e,i;t[0]===n?i=t[1]:(i=NP({source:`message`,query:{type:`index`,index:n},get:e=>e.message().part({index:n})}),t[0]=n,t[1]=i);let a;t[2]===i?a=t[3]:(a={part:i},t[2]=i,t[3]=a);let o=aF(a),s;return t[4]!==o||t[5]!==r?(s=(0,J.jsx)(jP,{value:o,children:r}),t[4]=o,t[5]=r,t[6]=s):s=t[6],s},ZI=UN(e=>{let t=Z(7),{text:n,isRunning:r}=e,i;t[0]===r?i=t[1]:(i=r?{type:`running`}:{type:`complete`},t[0]=r,t[1]=i);let a;t[2]!==i||t[3]!==n?(a={type:`text`,text:n,status:i},t[2]=i,t[3]=n,t[4]=a):a=t[4];let o=a,s;return t[5]===o?s=t[6]:(s={getState:()=>o,addToolResult:$I,resumeToolCall:eL,respondToToolApproval:tL},t[5]=o,t[6]=s),s}),QI=e=>{let t=Z(8),{text:n,isRunning:r,children:i}=e,a=r!==void 0&&r,o;t[0]!==a||t[1]!==n?(o=ZI({text:n,isRunning:a}),t[0]=a,t[1]=n,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s={part:o},t[3]=o,t[4]=s);let c=aF(s),l;return t[5]!==c||t[6]!==i?(l=(0,J.jsx)(jP,{value:c,children:i}),t[5]=c,t[6]=i,t[7]=l):l=t[7],l};function $I(){throw Error(`Not supported`)}function eL(){throw Error(`Not supported`)}function tL(){throw Error(`Not supported`)}var nL=Object.freeze({type:`complete`}),rL=UN(e=>{let t=Z(9),{parts:n,getMessagePart:r}=e,[i,a]=DN(!0),o=n[n.length-1]?.status??nL,s;t[0]!==i||t[1]!==n||t[2]!==o?(s={parts:n,collapsed:i,status:o},t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3];let c=s,l;t[4]===c?l=t[5]:(l=()=>c,t[4]=c,t[5]=l);let u;return t[6]!==r||t[7]!==l?(u={getState:l,setCollapsed:a,part:r},t[6]=r,t[7]=l,t[8]=u):u=t[8],u}),iL=e=>{let t=Z(5),{startIndex:n,endIndex:r,children:i}=e,a=Q(aL).slice(n,r+1),o=aF(),s=rL({parts:a,getMessagePart:e=>{let{index:t}=e;if(t<0||t>=a.length)throw Error(`ChainOfThought part index ${t} is out of bounds (0..${a.length-1})`);return o.message().part({index:n+t})}}),c;t[0]===s?c=t[1]:(c={chainOfThought:s},t[0]=s,t[1]=c);let l=aF(c),u;return t[2]!==l||t[3]!==i?(u=(0,J.jsx)(jP,{value:l,children:i}),t[2]=l,t[3]=i,t[4]=u):u=t[4],u};function aL(e){return e.message.parts}var oL=e=>{let t=Z(7),{index:n,children:r}=e,i;t[0]===n?i=t[1]:(i=NP({source:`suggestions`,query:{index:n},get:e=>e.suggestions().suggestion({index:n})}),t[0]=n,t[1]=i);let a;t[2]===i?a=t[3]:(a={suggestion:i},t[2]=i,t[3]=a);let o=aF(a),s;return t[4]!==o||t[5]!==r?(s=(0,J.jsx)(jP,{value:o,children:r}),t[4]=o,t[5]=r,t[6]=s):s=t[6],s},sL=e=>{let t=Z(7),{index:n,children:r}=e,i;t[0]===n?i=t[1]:(i=NP({source:`composer`,query:{index:n},get:e=>e.composer().queueItem({index:n})}),t[0]=n,t[1]=i);let a;t[2]===i?a=t[3]:(a={queueItem:i},t[2]=i,t[3]=a);let o=aF(a),s;return t[4]!==o||t[5]!==r?(s=(0,J.jsx)(jP,{value:o,children:r}),t[4]=o,t[5]=r,t[6]=s):s=t[6],s},cL=Symbol(`innerMessage`),lL=Symbol(`innerMessages`),uL=[],dL=(e,t)=>{cL in e||(e[cL]=t)},fL=e=>{let t=`messages`in e?e.messages:e,n=t[lL]||t[cL];return n?Array.isArray(n)?n:(t[lL]=[n],t[lL]):uL},pL=Symbol(`skip-update`);function mL(e,t){if(e===void 0&&t===void 0)return!0;if(e===void 0||t===void 0)return!1;for(let n of Object.keys(e)){let r=e[n],i=t[n];if(!Object.is(r,i))return!1}return!0}var hL=class{_subscribers=new Set;subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}waitForUpdate(){return new Promise(e=>{let t=this.subscribe(()=>{t(),e()})})}_notifySubscribers(){let e=[];for(let t of this._subscribers)try{t()}catch(t){e.push(t)}if(e.length>0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e)}}},gL=class{_subscriptions=new Set;_connection;get isConnected(){return!!this._connection}notifySubscribers(e){for(let t of this._subscriptions)t(e)}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else this._connection?.(),this._connection=void 0}subscribe(e){return this._subscriptions.add(e),this._updateConnection(),()=>{this._subscriptions.delete(e),this._updateConnection()}}},_L=class extends gL{binding;get path(){return this.binding.path}constructor(e){super(),this.binding=e;let t=e.getState();if(t===pL)throw Error(`Entry not available in the store`);this._previousState=t}_previousState;getState=()=>(this.isConnected||this._syncState(),this._previousState);_syncState(){let e=this.binding.getState();return e===pL||mL(e,this._previousState)?!1:(this._previousState=e,!0)}_connect(){return this.binding.subscribe(()=>{this._syncState()&&this.notifySubscribers()})}},vL=class extends gL{binding;get path(){return this.binding.path}constructor(e){super(),this.binding=e}_previousStateDirty=!0;_previousState;getState=()=>{if(!this.isConnected||this._previousStateDirty){let e=this.binding.getState();e!==pL&&(this._previousState=e),this._previousStateDirty=!1}if(this._previousState===void 0)throw Error(`Entry not available in the store`);return this._previousState};_connect(){return this.binding.subscribe(()=>{this._previousStateDirty=!0,this.notifySubscribers()})}},yL=class extends gL{binding;get path(){return this.binding.path}constructor(e){super(),this.binding=e}getState(){return this.binding.getState()}outerSubscribe(e){return this.binding.subscribe(e)}_connect(){let e=()=>{this.notifySubscribers()},t=this.binding.getState(),n=t?.subscribe(e),r=this.outerSubscribe(()=>{let r=this.binding.getState();r!==t&&(t=r,n?.(),n=r?.subscribe(e),e())});return()=>{r?.(),n?.()}}},bL=class extends gL{config;constructor(e){super(),this.config=e}getState(){return this.config.binding.getState()}outerSubscribe(e){return this.config.binding.subscribe(e)}_connect(){let e=e=>{this.notifySubscribers(e)},t=this.config.binding.getState(),n=t?.unstable_on(this.config.event,e),r=this.outerSubscribe(()=>{let r=this.config.binding.getState();r!==t&&(t=r,n?.(),n=r?.unstable_on(this.config.event,e))});return()=>{r?.(),n?.()}}},xL=class{_core;get path(){return this._core.path}constructor(e){this._core=e,this.__internal_bindMethods()}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(e){return this._core.subscribe(e)}},SL=class extends xL{_composerApi;constructor(e,t){super(e),this._composerApi=t}remove(){let e=this._composerApi.getState();if(!e)throw Error(`Composer is not available`);return e.removeAttachment(this.getState().id)}},CL=class extends SL{get source(){return`thread-composer`}},wL=class extends SL{get source(){return`edit-composer`}},TL=class extends xL{get source(){return`message`}remove(){throw Error(`Message attachments cannot be removed`)}},EL=Object.freeze([]),DL=Object.freeze({}),OL=e=>Object.freeze({type:`thread`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,attachments:e?.attachments??EL,text:e?.text??``,role:e?.role??`user`,runConfig:e?.runConfig??DL,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??EL,value:e?.text??``}),kL=e=>Object.freeze({type:`edit`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,text:e?.text??``,role:e?.role??`user`,attachments:e?.attachments??EL,runConfig:e?.runConfig??DL,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??EL,parentId:e?.parentId??null,sourceId:e?.sourceId??null,value:e?.text??``}),AL=class{_core;get path(){return this._core.path}constructor(e){this._core=e}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.steerQueueItem=this.steerQueueItem.bind(this),this.removeQueueItem=this.removeQueueItem.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.startDictation=this.startDictation.bind(this),this.stopDictation=this.stopDictation.bind(this),this.setQuote=this.setQuote.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setText(e)}setRunConfig(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRunConfig(e)}addAttachment(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);return t.addAttachment(e)}reset(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.reset()}clearAttachments(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.clearAttachments()}send(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.send(e)}cancel(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.cancel()}steerQueueItem(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.steerQueueItem(e)}removeQueueItem(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.removeQueueItem(e)}setRole(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRole(e)}startDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.startDictation()}stopDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.stopDictation()}setQuote(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setQuote(e)}subscribe(e){return this._core.subscribe(e)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new bL({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},jL=class extends AL{get path(){return this._core.path}get type(){return`thread`}_getState;constructor(e){let t=new vL({path:e.path,getState:()=>OL(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>t.subscribe(e)}),this._getState=t.getState.bind(t),this.__internal_bindMethods()}getState(){return this._getState()}getAttachmentByIndex(e){return new CL(new _L({path:{...this.path,attachmentSource:`thread-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`thread-composer`}:pL},subscribe:e=>this._core.subscribe(e)}),this._core)}},ML=class extends AL{_beginEdit;get path(){return this._core.path}get type(){return`edit`}_getState;constructor(e,t){let n=new vL({path:e.path,getState:()=>kL(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>n.subscribe(e)}),this._beginEdit=t,this._getState=n.getState.bind(n),this.__internal_bindMethods()}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(e){return new wL(new _L({path:{...this.path,attachmentSource:`edit-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`edit-composer`}:pL},subscribe:e=>this._core.subscribe(e)}),this._core)}},NL=e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
13
+
14
+ `),PL={"allow-once":!0,"allow-always":!0,"reject-once":!1,"reject-always":!1},FL=(e,t)=>{let n,r;if(`optionId`in t){let i=e.options?.find(e=>e.id===t.optionId);if(!i)throw Error(`Tool approval has no option with id "${t.optionId}"`);if(`approved`in t)n=t.approved;else{if(!Object.hasOwn(PL,i.kind))throw Error(`Tool approval option "${i.id}" has a custom kind "${i.kind}"; respond with an explicit approved value instead`);n=PL[i.kind]}r=i.id}else n=t.approved;return{approvalId:e.id,approved:n,...r!==void 0&&{optionId:r},...t.reason!=null&&{reason:t.reason}}},IL=class{contentBinding;messageApi;threadApi;get path(){return this.contentBinding.path}constructor(e,t,n){this.contentBinding=e,this.messageApi=t,this.threadApi=n,this.__internal_bindMethods()}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.respondToToolApproval=this.respondToToolApproval.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to add tool result to non-tool message part`);if(!this.messageApi)throw Error(`Message API is not available. This is likely a bug in assistant-ui.`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=this.messageApi.getState();if(!n)throw Error(`Message is not available`);let r=t.toolName,i=t.toolCallId,a=MI.toResponse(e);this.threadApi.getState().addToolResult({messageId:n.id,toolName:r,toolCallId:i,result:a.result,artifact:a.artifact,isError:a.isError})}resumeToolCall(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to resume tool call on non-tool message part`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=t.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:n,payload:e})}respondToToolApproval(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to respond to tool approval on non-tool message part`);if(!t.approval||t.approval.approved!==void 0||t.approval.resolution!==void 0)throw Error(`Tool call has no pending approval`);if(!this.threadApi)throw Error(`Thread API is not available`);this.threadApi.getState().respondToToolApproval(FL(t.approval,e))}subscribe(e){return this.contentBinding.subscribe(e)}},LL=Object.freeze({type:`complete`}),RL=(e,t,n)=>{if(e.role!==`assistant`)return LL;if(n.type===`tool-call`)return n.result?LL:e.status;let r=t===Math.max(0,e.content.length-1);return e.status.type===`requires-action`?LL:r?e.status:LL},zL=(e,t)=>{let n=e.content[t];if(!n)return pL;let r=RL(e,t,n);return Object.freeze({...n,[cL]:n[cL],status:r})},BL=class{_core;_threadBinding;get path(){return this._core.path}constructor(e,t){this._core=e,this._threadBinding=t,this.composer=new ML(new yL({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.composer`,composerSource:`edit`},getState:this._getEditComposerRuntimeCore,subscribe:e=>this._threadBinding.subscribe(e)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}__internal_bindMethods(){this.reload=this.reload.bind(this),this.delete=this.delete.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getMessagePartByIndex=this.getMessagePartByIndex.bind(this),this.getMessagePartByToolCallId=this.getMessagePartByToolCallId.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_getCopyText=this.unstable_getCopyText.bind(this),this.speak=this.speak.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.submitFeedback=this.submitFeedback.bind(this),this.switchToBranch=this.switchToBranch.bind(this)}composer;_getEditComposerRuntimeCore=()=>this._threadBinding.getState().getEditComposer(this._core.getState().id);getState(){return this._core.getState()}delete(){let e=this._core.getState();return this._threadBinding.getState().deleteMessage(e.id)}reload(e={}){let t=this._getEditComposerRuntimeCore(),n=t??this._threadBinding.getState().composer,r=t??n,{runConfig:i=r.runConfig}=e,a=this._core.getState();if(a.role!==`assistant`)throw Error(`Can only reload assistant messages`);this._threadBinding.getState().startRun({parentId:a.parentId,sourceId:a.id,runConfig:i})}speak(){let e=this._core.getState();return this._threadBinding.getState().speak(e.id)}stopSpeaking(){let e=this._core.getState();if(this._threadBinding.getState().speech?.messageId===e.id)this._threadBinding.getState().stopSpeaking();else throw Error(`Message is not being spoken`)}submitFeedback({type:e}){let t=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:t.id,type:e})}switchToBranch({position:e,branchId:t}){let n=this._core.getState();if(t&&e)throw Error(`May not specify both branchId and position`);if(!t&&!e)throw Error(`Must specify either branchId or position`);let r=this._threadBinding.getState().getBranches(n.id),i=t;if(e===`previous`?i=r[n.branchNumber-2]:e===`next`&&(i=r[n.branchNumber]),!i)throw Error(`Branch not found`);this._threadBinding.getState().switchToBranch(i)}unstable_getCopyText(){return NL(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw Error(`Message part index must be >= 0`);return new IL(new _L({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.content[${e}]`,messagePartSelector:{type:`index`,index:e}},getState:()=>zL(this.getState(),e),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new IL(new _L({path:{...this.path,ref:this.path.ref+`${this.path.ref}.content[toolCallId=${JSON.stringify(e)}]`,messagePartSelector:{type:`toolCallId`,toolCallId:e}},getState:()=>{let t=this._core.getState(),n=t.content.findIndex(t=>t.type===`tool-call`&&t.toolCallId===e);return n===-1?pL:zL(t,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new TL(new _L({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.attachments[${e}]`,attachmentSource:`message`,attachmentSelector:{type:`index`,index:e}},getState:()=>{let t=this.getState().attachments?.[e];return t?{...t,source:`message`}:pL},subscribe:e=>this._core.subscribe(e)}))}},VL=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{},...e.stream?{stream:e.stream}:{}}),HL=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{}}),UL=(e,t)=>typeof t==`string`?{createdAt:new Date,parentId:e.at(-1)?.id??null,sourceId:null,runConfig:{},role:`user`,content:[{type:`text`,text:t}],attachments:[],metadata:{custom:{}}}:{createdAt:t.createdAt??new Date,parentId:t.parentId??e.at(-1)?.id??null,sourceId:t.sourceId??null,role:t.role??`user`,content:t.content,attachments:t.attachments??[],metadata:t.metadata??{custom:{}},runConfig:t.runConfig??{},startRun:t.startRun},WL=(e,t)=>{let n=e.messages.at(-1);return Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:e.isRunning??(n?.role===`assistant`&&n.status.type===`running`),messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice})},GL=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;constructor(e,t){let n=new _L({path:e.path,getState:()=>WL(e.getState(),t.getState()),subscribe:n=>{let r=e.subscribe(n),i=t.subscribe(n);return()=>{r(),i()}}});this._threadBinding={path:e.path,getState:()=>e.getState(),getStateState:()=>n.getState(),outerSubscribe:t=>e.outerSubscribe(t),subscribe:t=>e.subscribe(t)},this.composer=new jL(new yL({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`thread`},getState:()=>this._threadBinding.getState().composer,subscribe:e=>this._threadBinding.subscribe(e)})),this.__internal_bindMethods()}__internal_bindMethods(){this.append=this.append.bind(this),this.deleteMessage=this.deleteMessage.bind(this),this.resumeRun=this.resumeRun.bind(this),this.importExternalState=this.importExternalState.bind(this),this.exportExternalState=this.exportExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.connectVoice=this.connectVoice.bind(this),this.disconnectVoice=this.disconnectVoice.bind(this),this.muteVoice=this.muteVoice.bind(this),this.unmuteVoice=this.unmuteVoice.bind(this),this.getVoiceVolume=this.getVoiceVolume.bind(this),this.subscribeVoiceVolume=this.subscribeVoiceVolume.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getState=this.getState.bind(this)}composer;getState(){return this._threadBinding.getStateState()}append(e){this._threadBinding.getState().append(UL(this._threadBinding.getState().messages,e))}deleteMessage(e){return this._threadBinding.getState().deleteMessage(e)}subscribe(e){return this._threadBinding.subscribe(e)}getModelContext(){return this._threadBinding.getState().getModelContext()}startRun(e){return this._threadBinding.getState().startRun(HL(e))}resumeRun(e){return this._threadBinding.getState().resumeRun(VL(e))}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(e){this._threadBinding.getState().importExternalState(e)}cancelRun(){this._threadBinding.getState().cancelRun()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}connectVoice(){this._threadBinding.getState().connectVoice()}disconnectVoice(){this._threadBinding.getState().disconnectVoice()}getVoiceVolume(){return this._threadBinding.getState().getVoiceVolume()}subscribeVoiceVolume(e){return this._threadBinding.getState().subscribeVoiceVolume(e)}muteVoice(){this._threadBinding.getState().muteVoice()}unmuteVoice(){this._threadBinding.getState().unmuteVoice()}export(){return this._threadBinding.getState().export()}import(e){this._threadBinding.getState().import(e)}reset(e){this._threadBinding.getState().reset(e)}getMessageByIndex(e){if(e<0)throw Error(`Message index must be >= 0`);return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[${e}]`,messageSelector:{type:`index`,index:e}},()=>{let t=this._threadBinding.getState().messages,n=t[e];if(n)return{message:n,parentId:t[e-1]?.id??null,index:e}})}getMessageById(e){return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[messageId=${JSON.stringify(e)}]`,messageSelector:{type:`messageId`,messageId:e}},()=>this._threadBinding.getState().getMessageById(e))}_getMessageRuntime(e,t){return new BL(new _L({path:e,getState:()=>{let{message:e,parentId:n,index:r}=t()??{},{messages:i,speech:a}=this._threadBinding.getState();if(!e||n===void 0||r===void 0)return pL;let o=this._threadBinding.getState().getBranches(e.id);return{...e,[cL]:e[cL],index:r,isLast:i.at(-1)?.id===e.id,parentId:n,branchNumber:o.indexOf(e.id)+1,branchCount:o.length,speech:a?.messageId===e.id?a:void 0}},subscribe:e=>this._threadBinding.subscribe(e)}),this._threadBinding)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new bL({event:e,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},KL=LN(null),qL=()=>zN(KL),JL=class{_core;_threadListBinding;get path(){return this._core.path}constructor(e,t){this._core=e,this._threadListBinding=t,this.__internal_bindMethods()}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.updateCustom=this.updateCustom.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(e){let t=this._core.getState();return this._threadListBinding.switchToThread(t.id,e)}rename(e){let t=this._core.getState();return this._threadListBinding.rename(t.id,e)}updateCustom(e){let t=this._core.getState();if(!this._threadListBinding.updateCustom)throw Error(`Thread list runtime does not support updating custom metadata`);return this._threadListBinding.updateCustom(t.id,e)}archive(){let e=this._core.getState();return this._threadListBinding.archive(e.id)}unarchive(){let e=this._core.getState();return this._threadListBinding.unarchive(e.id)}delete(){let e=this._core.getState();return this._threadListBinding.delete(e.id)}initialize(){let e=this._core.getState();return this._threadListBinding.initialize(e.id)}generateTitle(){let e=this._core.getState();return this._threadListBinding.generateTitle(e.id)}unstable_on(e,t){let n=this._core.getState().isMain,r=this._core.getState().id;return this.subscribe(()=>{let i=this._core.getState(),a=i.isMain,o=i.id;n===a&&r===o||(n=a,r=o,!(e===`switchedTo`&&!a)&&(e===`switchedAway`&&a||t({})))})}subscribe(e){return this._core.subscribe(e)}detach(){let e=this._core.getState();this._threadListBinding.detach(e.id)}__internal_getRuntime(){return this}},YL=Promise.resolve(),XL=e=>({mainThreadId:e.mainThreadId,newThreadId:e.newThreadId,threadIds:e.threadIds,archivedThreadIds:e.archivedThreadIds,isLoading:e.isLoading,isLoadingMore:e.isLoadingMore??!1,hasMore:e.hasMore??!1,threadItems:e.threadItems}),ZL=(e,t)=>{if(t===void 0)return pL;let n=e.getItemById(t);return n?{id:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,status:n.status,lastMessageAt:n.lastMessageAt,custom:n.custom,isMain:n.id===e.mainThreadId}:pL},QL=class{_core;_runtimeFactory;_getState;constructor(e,t=GL){this._core=e,this._runtimeFactory=t;let n=new vL({path:{},getState:()=>XL(e),subscribe:t=>e.subscribe(t)});this._getState=n.getState.bind(n),this._mainThreadListItemRuntime=new JL(new _L({path:{ref:`threadItems[main]`,threadSelector:{type:`main`}},getState:()=>ZL(this._core,this._core.mainThreadId),subscribe:e=>this._core.subscribe(e)}),this._core),this.main=new t(new yL({path:{ref:`threads.main`,threadSelector:{type:`main`}},getState:()=>e.getMainThreadRuntimeCore(),subscribe:t=>e.subscribe(t)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.reload=this.reload.bind(this),this.loadMore=this.loadMore.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(e,t){return this._core.switchToThread(e,t)}switchToNewThread(){return this._core.switchToNewThread()}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){return this._core.reload?.()??YL}loadMore(){return this._core.loadMore?.()??YL}getState(){return this._getState()}subscribe(e){return this._core.subscribe(e)}_mainThreadListItemRuntime;main;get mainItem(){return this._mainThreadListItemRuntime}getById(e){return new this._runtimeFactory(new yL({path:{ref:`threads[threadId=${JSON.stringify(e)}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>this._core.getThreadRuntimeCore(e),subscribe:e=>this._core.subscribe(e)}),this.mainItem)}getItemByIndex(e){return new JL(new _L({path:{ref:`threadItems[${e}]`,threadSelector:{type:`index`,index:e}},getState:()=>ZL(this._core,this._core.threadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(e){return new JL(new _L({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:`archiveIndex`,index:e}},getState:()=>ZL(this._core,this._core.archivedThreadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(e){return new JL(new _L({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>ZL(this._core,e),subscribe:e=>this._core.subscribe(e)}),this._core)}},$L=class{_core;threads;_thread;constructor(e){this._core=e,this.threads=new QL(e.threads),this._thread=this.threads.main,this.__internal_bindMethods()}__internal_bindMethods(){this.registerModelContextProvider=this.registerModelContextProvider.bind(this)}get thread(){return this._thread}registerModelContextProvider(e){return this._core.registerModelContextProvider(e)}},eR=class{_contextProvider=new cP;registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}},tR=Object.freeze([]),nR=`DEFAULT_THREAD_ID`,rR=Object.freeze([nR]),iR=Object.freeze({id:nR,remoteId:void 0,externalId:void 0,status:`regular`}),aR=Promise.resolve(),oR=Object.freeze({[nR]:iR}),sR=class{threadFactory;_mainThreadId=nR;_threads=rR;_archivedThreads=tR;_threadData=oR;adapter={};get isLoading(){return this.adapter.isLoading??!1}get newThreadId(){}get threadIds(){return this._threads}get archivedThreadIds(){return this._archivedThreads}get threadItems(){return this._threadData}getLoadThreadsPromise(){return aR}_mainThread;get mainThreadId(){return this._mainThreadId}constructor(e={},t){this.threadFactory=t,this.__internal_setAdapter(e,!0)}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw Error(`Method not implemented.`)}getItemById(e){return this._threadData[e]}__internal_setAdapter(e,t=!1){let n=this.adapter;this.adapter=e;let r=e.threadId??nR,i=e.threads??tR,a=e.archivedThreads??tR,o=n.threadId??nR,s=n.threads??tR,c=n.archivedThreads??tR;!t&&o===r&&s===i&&c===a||((s!==i||c!==a||o!==r)&&(this._threadData={...oR,...Object.fromEntries(e.threads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`regular`}])??[]),...Object.fromEntries(e.archivedThreads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`archived`}])??[])}),s!==i&&(this._threads=this.adapter.threads?.map(e=>e.id)??tR),c!==a&&(this._archivedThreads=this.adapter.archivedThreads?.map(e=>e.id)??tR),(t||o!==r)&&(this._mainThreadId=r,this._mainThread=this.threadFactory()),this._threadData[this._mainThreadId]||(this._threadData={...this._threadData,[this._mainThreadId]:{id:this._mainThreadId,remoteId:void 0,externalId:void 0,status:`regular`}}),this._notifySubscribers())}async switchToThread(e,t){if(this._mainThreadId===e)return;let n=this.adapter.onSwitchToThread;if(!n)throw Error(`External store adapter does not support switching to thread`);await n(e)}async switchToNewThread(){let e=this.adapter.onSwitchToNewThread;if(!e)throw Error(`External store adapter does not support switching to new thread`);await e()}async rename(e,t){let n=this.adapter.onRename;if(!n)throw Error(`External store adapter does not support renaming`);await n(e,t)}async updateCustom(e,t){let n=this.adapter.onUpdateCustom;if(!n)throw Error(`External store adapter does not support updating custom metadata`);await n(e,t)}async detach(){}async archive(e){let t=this.adapter.onArchive;if(!t)throw Error(`External store adapter does not support archiving`);await t(e)}async unarchive(e){let t=this.adapter.onUnarchive;if(!t)throw Error(`External store adapter does not support unarchiving`);await t(e)}async delete(e){let t=this.adapter.onDelete;if(!t)throw Error(`External store adapter does not support deleting`);await t(e)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw Error(`Method not implemented.`)}_subscriptions=new Set;subscribe(e){return this._subscriptions.add(e),()=>this._subscriptions.delete(e)}_notifySubscribers(){for(let e of this._subscriptions)e()}},cR=_I(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),lR=(e,t)=>{if(e.startsWith(`data-`))return{type:`data`,name:e.substring(5),data:t}},uR=(e,t,n)=>{let{role:r,id:i,createdAt:a,attachments:o,status:s,metadata:c}=e,l={id:i??t,createdAt:a??new Date},u=typeof e.content==`string`?[{type:`text`,text:e.content}]:e.content,d=({image:e,...t})=>e.match(/^data:image\/(png|jpeg|jpg|gif|webp|svg\+xml);base64,(.*)$/)||/^(https:\/\/|blob:)/.test(e)?{...t,image:e}:(console.warn(`Invalid image data format detected`),null);if(r!==`user`&&o?.length)throw Error(`attachments are only supported for user messages`);if(r!==`assistant`&&s)throw Error(`status is only supported for assistant messages`);if(r!==`assistant`&&c?.steps)throw Error(`metadata.steps is only supported for assistant messages`);switch(r){case`assistant`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:case`reasoning`:return e.text.trim().length===0?null:e;case`file`:case`source`:return e;case`image`:return d(e);case`data`:return e;case`generative-ui`:return e;case`tool-call`:{let{parentId:t,messages:n,...r}=e,i={...r,toolCallId:e.toolCallId??`tool-${cR()}`,...t!==void 0&&{parentId:t},...n!==void 0&&{messages:n}};return e.args?{...i,args:e.args,argsText:e.argsText??JSON.stringify(e.args)}:{...i,args:EI(e.argsText??``)??{},argsText:e.argsText??``}}default:{let n=lR(t,e.data);if(n)return n;throw Error(`Unsupported assistant message part type: ${t}`)}}}).filter(e=>!!e),status:s??n,metadata:{unstable_state:c?.unstable_state??null,unstable_annotations:c?.unstable_annotations??[],unstable_data:c?.unstable_data??[],custom:c?.custom??{},steps:c?.steps??[],...c?.timing&&{timing:c.timing},...c?.submittedFeedback&&{submittedFeedback:c.submittedFeedback},...c?.isOptimistic&&{isOptimistic:!0}}};case`user`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:case`image`:case`audio`:case`file`:case`data`:return e;default:{let n=lR(t,e.data);if(n)return n;throw Error(`Unsupported user message part type: ${t}`)}}}),attachments:(o??[]).map(e=>({...e,content:e.content.map(e=>lR(e.type,e.data)??e)})),metadata:{custom:c?.custom??{}}};case`system`:if(u.length!==1||u[0].type!==`text`)throw Error(`System messages must have exactly one text message part.`);return{...l,role:r,content:u,metadata:{custom:c?.custom??{}}};default:throw Error(`Unknown message role: ${r}`)}},dR=Symbol(`autoStatus`),fR=Object.freeze(Object.assign({type:`running`},{[dR]:!0})),pR=Object.freeze(Object.assign({type:`complete`,reason:`unknown`},{[dR]:!0})),mR=Object.freeze(Object.assign({type:`requires-action`,reason:`tool-calls`},{[dR]:!0})),hR=Object.freeze(Object.assign({type:`requires-action`,reason:`interrupt`},{[dR]:!0})),gR=e=>e[dR]===!0,_R=(e,t,n,r,i)=>e&&i?Object.assign({type:`incomplete`,reason:`error`,error:i},{[dR]:!0}):e&&t?fR:n?hR:r?mR:pR,vR={fromArray:e=>{let t=e.map(e=>uR(e,cR(),_R(!1,!1,!1,!1,void 0)));return{messages:t.map((e,n)=>({parentId:n>0?t[n-1].id:null,message:e}))}},fromBranchableArray:(e,t)=>{let n=_R(!1,!1,!1,!1,void 0);return{...t?.headId===void 0?void 0:{headId:t.headId},messages:e.map(({message:e,parentId:t})=>{if(!e.id)throw Error(`ExportedMessageRepository.fromBranchableArray: Each message must have an 'id' field set.`);return{parentId:t,message:uR(e,e.id,n)}})}}},yR=e=>e.next?yR(e.next):`current`in e?e:null,bR=class{func;_value=null;constructor(e){this.func=e}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},xR=class{messages=new Map;head=null;root={children:[],next:null};updateLevels(e,t){e.level=t;for(let n of e.children){let e=this.messages.get(n);e&&this.updateLevels(e,t+1)}}performOp(e,t,n){let r=t.prev??this.root,i=e??this.root;if(!(n===`relink`&&r===i)){if(n!==`link`&&(r.children=r.children.filter(e=>e!==t.current.id),r.next===t)){let e=r.children.at(-1),t=e?this.messages.get(e):null;if(t===void 0)throw Error(`MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.`);r.next=t}if(n!==`cut`){for(let n=e;n;n=n.prev)if(n.current.id===t.current.id)throw Error(`MessageRepository(performOp/link): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.`);i.children=[...i.children,t.current.id],(yR(t)===this.head||i.next===null)&&(i.next=t),t.prev=e;let n=e?e.level+1:0;this.updateLevels(t,n)}}}_messages=new bR(()=>{let e=Array((this.head?.level??-1)+1);for(let t=this.head;t;t=t.prev)e[t.level]=t.current;return e});get headId(){return this.head?.current.id??null}getMessages(e){if(e===void 0||e===this.head?.current.id)return this._messages.value;let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.`);let n=Array(t.level+1);for(let e=t;e;e=e.prev)n[e.level]=e.current;return n}addOrUpdateMessage(e,t){let n=this.messages.get(t.id),r=e?this.messages.get(e):null;if(r===void 0)throw Error(`MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.`);if(n){n.current=t,this.performOp(r,n,`relink`),this._messages.dirty();return}let i={prev:r,current:t,next:null,children:[],level:r?r.level+1:0};this.messages.set(t.id,i),this.performOp(r,i,`link`),this.head===r&&(this.head=i),this._messages.dirty()}getMessage(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.`);return{parentId:t.prev?.current.id??null,message:t.current,index:t.level}}deleteMessage(e,t){let n=this.messages.get(e);if(!n)throw Error(`MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.`);let r=t===void 0?n.prev:t===null?null:this.messages.get(t);if(r===void 0)throw Error(`MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.`);for(let e of n.children){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.`);this.performOp(r,t,`relink`)}this.performOp(null,n,`cut`),this.messages.delete(e),this.head===n&&(this.head=yR(r??this.root)),this._messages.dirty()}getBranches(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.`);let{children:n}=t.prev??this.root;return n}evictOffBranchOptimisticMessages(e,t){if(!e)return;let n=new Set;for(let e=t;e;e=e.prev)n.add(e.current.id);let r=[];for(let t=e;t&&!n.has(t.current.id);t=t.prev)t.current.metadata?.isOptimistic&&r.push(t.current.id);for(let e of r)this.messages.has(e)&&this.deleteMessage(e)}switchToBranch(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head,r=t.prev??this.root;r.next=t,this.head=yR(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}resetHead(e){if(e===null){this.clear();return}let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;if(t.children.length>0){let e=t=>{for(let n of t.children){let t=this.messages.get(n);t&&(e(t),this.messages.delete(n))}};e(t),t.children=[],t.next=null}this.head=t;for(let e=t;e;e=e.prev)e.prev?e.prev.next=e:this.root.next=e;this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){let e=[];for(let[,t]of this.messages)t.current.metadata?.isOptimistic||e.push({message:t.current,parentId:t.prev?.current.id??null});let t=this.head;for(;t?.current.metadata?.isOptimistic;)t=t.prev;return{headId:t?.current.id??null,messages:e}}import({headId:e,messages:t}){for(let{message:e,parentId:n}of t)this.addOrUpdateMessage(n,e);this.resetHead(e??t.at(-1)?.message.id??null)}},SR=Object.freeze([]);function CR(e,t){if(t===`*`)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase()),r=`.${e.name.split(`.`).pop().toLowerCase()}`,i=e.type.toLowerCase();for(let e of n){if(e.startsWith(`.`)&&e===r||e.includes(`/`)&&e===i)return!0;if(e.endsWith(`/*`)){let t=e.split(`/`)[0];if(i.startsWith(`${t}/`))return!0}}return!1}function wR(e,t){return e.length===t.length&&e.every((e,n)=>e.id===t[n].id)}function TR(e){let t=cR();return e.type===`image`?{id:t,type:`image`,name:e.filename??`image`,content:[e],status:{type:`complete`}}:e.type===`file`?{id:t,type:`document`,name:e.filename??`document`,contentType:e.mimeType,content:[e],status:{type:`complete`}}:e.type===`audio`?{id:t,type:`audio`,name:`audio.${e.audio.format}`,contentType:`audio/${e.audio.format}`,content:[e],status:{type:`complete`}}:{id:t,type:`data`,name:e.name,content:[e],status:{type:`complete`}}}function ER(e){let t=[];for(let n of e)n.type!==`text`&&t.push(TR(n));return t}var DR=e=>e.status.type===`complete`,OR=class extends hL{isEditing=!0;get attachmentAccept(){return this.getAttachmentAdapter()?.accept??`*`}_attachments=[];get attachments(){return this._attachments}setAttachments(e){this._attachments=e,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}_text=``;get text(){return this._text}_role=`user`;get role(){return this._role}_runConfig={};get runConfig(){return this._runConfig}_quote=void 0;get quote(){return this._quote}setQuote(e){this._quote!==e&&(this._quote=e,this._notifySubscribers())}setText(e){if(this._text!==e){if(this._text=e,this._dictation){this._dictationBaseText=e,this._currentInterimText=``;let{status:t,inputDisabled:n}=this._dictation;this._dictation=n?{status:t,inputDisabled:n}:{status:t}}this._notifySubscribers()}}setRole(e){this._role!==e&&(this._role=e,this._notifySubscribers())}setRunConfig(e){this._runConfig!==e&&(this._runConfig=e,this._notifySubscribers())}_emptyTextAndAttachments(){this._attachments=[],this._text=``,this._notifySubscribers()}async _onClearAttachments(){let e=this.getAttachmentAdapter();if(e){let t=this._attachments.filter(e=>!DR(e));await Promise.all(t.map(t=>e.remove(t)))}}async reset(){if(this._attachments.length===0&&this._text===``&&this._role===`user`&&Object.keys(this._runConfig).length===0&&this._quote===void 0)return;this._role=`user`,this._runConfig={},this._quote=void 0;let e=this._onClearAttachments();this._emptyTextAndAttachments(),await e}async clearAttachments(){let e=this._onClearAttachments();this.setAttachments([]),await e}async send(e){if(!this.canSend)return;this._dictationSession&&(this._dictationSession.cancel(),this._cleanupDictation());let t=this.getAttachmentAdapter(),n=this.attachments.length>0?Promise.all(this.attachments.map(async e=>{if(DR(e))return e;if(!t)throw Error(`Attachments are not supported`);return await t.send(e)})):[],r=this.text,i=this._quote;this._quote=void 0,this._emptyTextAndAttachments();let a={createdAt:new Date,role:this.role,content:r?[{type:`text`,text:r}]:[],attachments:await n,runConfig:this.runConfig,metadata:{custom:{...i?{quote:i}:{}}}};this.handleSend(a,e),this._notifyEventSubscribers(`send`,{})}cancel(){this.handleCancel()}get queue(){return SR}steerQueueItem(e){}removeQueueItem(e){}async addAttachment(e){if(!(e instanceof File)){let t=this.getAttachmentAdapter();if(t&&!CR({name:e.name,type:e.contentType??``},t.accept)){let n=`File type ${e.contentType||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r),r}let n={id:e.id??cR(),type:e.type??`document`,name:e.name,contentType:e.contentType,content:e.content,status:{type:`complete`}};this._attachments=[...this._attachments,n],this._notifySubscribers(),this._notifyEventSubscribers(`attachmentAdd`,{});return}let t=e=>{let t=this._attachments.findIndex(t=>t.id===e.id);t===-1?this._attachments=[...this._attachments,e]:this._attachments=[...this._attachments.slice(0,t),e,...this._attachments.slice(t+1)],this._notifySubscribers()},n=this.getAttachmentAdapter();if(!n){let e=`Attachments are not supported`,t=Error(e);throw this._safeEmitAttachmentAddError(`no-adapter`,e,void 0,t),t}if(!CR({name:e.name,type:e.type},n.accept)){let t=`File type ${e.type||`unknown`} is not accepted. Accepted types: ${n.accept}`,r=Error(t);throw this._safeEmitAttachmentAddError(`not-accepted`,t,void 0,r),r}let r;try{let i=n.add({file:e});if(Symbol.asyncIterator in i)for await(let e of i)r=e,t(e);else r=await i,t(r)}catch(e){throw r&&t({...r,status:{type:`incomplete`,reason:`error`}}),this._safeEmitAttachmentAddError(`adapter-error`,e instanceof Error?e.message:String(e),r?.id,e instanceof Error?e:void 0),e}r?.status.type===`incomplete`&&r.status.reason===`error`?this._safeEmitAttachmentAddError(`adapter-error`,`Attachment upload did not complete successfully.`,r?.id):this._notifyEventSubscribers(`attachmentAdd`,{})}_safeEmitAttachmentAddError(e,t,n,r){try{this._notifyEventSubscribers(`attachmentAddError`,{reason:e,message:t,...n!==void 0&&{attachmentId:n},...r!==void 0&&{error:r}})}catch(e){console.error(`[assistant-ui] attachmentAddError subscriber threw:`,e)}}async removeAttachment(e){let t=this._attachments.findIndex(t=>t.id===e);if(t===-1)throw Error(`Attachment not found`);let n=this._attachments[t];if(!DR(n)){let e=this.getAttachmentAdapter();if(!e)throw Error(`Attachments are not supported`);await e.remove(n)}this._attachments=this._attachments.filter(t=>t.id!==e),this._notifySubscribers()}_dictation;_dictationSession;_dictationUnsubscribes=[];_dictationBaseText=``;_currentInterimText=``;_dictationSessionIdCounter=0;_activeDictationSessionId;_isCleaningDictation=!1;get dictation(){return this._dictation}_isActiveSession(e,t){return this._activeDictationSessionId===e&&this._dictationSession===t}startDictation(){let e=this.getDictationAdapter();if(!e)throw Error(`Dictation adapter not configured`);if(this._dictationSession){for(let e of this._dictationUnsubscribes)e();this._dictationUnsubscribes=[],this._dictationSession.stop().catch(()=>{}),this._dictationSession=void 0}let t=e.disableInputDuringDictation??!1;this._dictationBaseText=this._text,this._currentInterimText=``;let n=e.listen();this._dictationSession=n;let r=++this._dictationSessionIdCounter;this._activeDictationSessionId=r,this._dictation={status:n.status,inputDisabled:t},this._notifySubscribers();let i=n.onSpeech(e=>{if(!this._isActiveSession(r,n))return;let t=e.isFinal!==!1,i=this._dictationBaseText&&!this._dictationBaseText.endsWith(` `)&&e.transcript?` `:``;if(t){if(this._dictationBaseText=this._dictationBaseText+i+e.transcript,this._currentInterimText=``,this._text=this._dictationBaseText,this._dictation){let{transcript:e,...t}=this._dictation;this._dictation=t}this._notifySubscribers()}else this._currentInterimText=i+e.transcript,this._text=this._dictationBaseText+this._currentInterimText,this._dictation&&={...this._dictation,transcript:e.transcript},this._notifySubscribers()});this._dictationUnsubscribes.push(i);let a=n.onSpeechStart(()=>{this._isActiveSession(r,n)&&(this._dictation={status:{type:`running`},inputDisabled:t,...this._dictation?.transcript&&{transcript:this._dictation.transcript}},this._notifySubscribers())});this._dictationUnsubscribes.push(a);let o=n.onSpeechEnd(()=>{this._cleanupDictation({sessionId:r})});this._dictationUnsubscribes.push(o);let s=setInterval(()=>{this._isActiveSession(r,n)&&n.status.type===`ended`&&this._cleanupDictation({sessionId:r})},100);this._dictationUnsubscribes.push(()=>clearInterval(s))}stopDictation(){if(!this._dictationSession)return;let e=this._dictationSession,t=this._activeDictationSessionId;e.stop().finally(()=>{this._cleanupDictation({sessionId:t})})}_cleanupDictation(e){if(!(e?.sessionId!==void 0&&e.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)){this._isCleaningDictation=!0;try{for(let e of this._dictationUnsubscribes)e();this._dictationUnsubscribes=[],this._dictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText=``,this._currentInterimText=``,this._notifySubscribers()}finally{this._isCleaningDictation=!1}}}_eventSubscribers=new Map;_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);if(n)for(let e of n)e(t)}unstable_on(e,t){let n=t,r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),()=>{this._eventSubscribers.get(e)?.delete(n)}}},kR=class extends OR{runtime;_canCancel=!1;get canCancel(){return this._canCancel}get canSend(){return!this.isEmpty&&!this.runtime.isSendDisabled}get queue(){return this.runtime.getQueueItems?.()??SR}steerQueueItem(e){this.runtime.steerQueueItem?.(e)}removeQueueItem(e){this.runtime.removeQueueItem?.(e)}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}constructor(e){super(),this.runtime=e,this.connect()}connect(){let e=this.runtime.isSendDisabled,t=this.queue;return this.runtime.subscribe(()=>{let n=!1;this.canCancel!==this.runtime.capabilities.cancel&&(this._canCancel=this.runtime.capabilities.cancel,n=!0),e!==this.runtime.isSendDisabled&&(e=this.runtime.isSendDisabled,n=!0),t!==this.queue&&(t=this.queue,n=!0),n&&this._notifySubscribers()})}async handleSend(e,t){this.runtime.append({...e,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null,startRun:t?.startRun,steer:t?.steer})}async handleCancel(){this.runtime.cancelRun()}},AR=class extends OR{runtime;endEditCallback;get canCancel(){return!0}get canSend(){return!this.isEmpty}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}_previousText;_previousAttachments;_nonTextPassthrough;_parentId;_sourceId;constructor(e,t,{parentId:n,message:r}){super(),this.runtime=e,this.endEditCallback=t,this._parentId=n,this._sourceId=r.id,this._previousText=NL(r),this.setText(this._previousText),this.setRole(r.role),r.role===`user`?(this._previousAttachments=[...r.attachments??[],...ER(r.content)],this._nonTextPassthrough=[]):(this._previousAttachments=r.attachments??[],this._nonTextPassthrough=r.content.filter(e=>e.type!==`text`)),this.setAttachments(this._previousAttachments),this.setRunConfig({...e.composer.runConfig})}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(e,t){let n=NL(e),r=!wR(e.attachments??[],this._previousAttachments);if(n!==this._previousText||r||t?.startRun){let n=this._nonTextPassthrough.length>0?[...e.content,...this._nonTextPassthrough]:e.content;this.runtime.append({...e,content:n,parentId:this._parentId,sourceId:this._sourceId,startRun:t?.startRun})}this.handleCancel()}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},jR=class{_contextProvider;_subscriptions=new Set;_isInitialized=!1;repository=new xR;_voiceMessages=[];_voiceGeneration=0;_cachedMergedMessages=null;_cachedVoiceGeneration=-1;_cachedMergedBase=null;_markVoiceMessagesDirty(){this._voiceGeneration++,this._cachedMergedMessages=null}_getBaseMessages(){return this.repository.getMessages()}get messages(){if(this._voiceMessages.length===0)return this._getBaseMessages();let e=this._getBaseMessages();return(this._cachedVoiceGeneration!==this._voiceGeneration||this._cachedMergedBase!==e)&&(this._cachedMergedMessages=[...e,...this._voiceMessages],this._cachedVoiceGeneration=this._voiceGeneration,this._cachedMergedBase=e),this._cachedMergedMessages}get state(){let e;for(let t of this.messages)t.role===`assistant`&&(e=t);return e?.metadata.unstable_state??null}composer=new kR(this);constructor(e){this._contextProvider=e}getModelContext(){return this._contextProvider.getModelContext()}_editComposers=new Map;getEditComposer(e){return this._editComposers.get(e)}beginEdit(e){if(this._editComposers.has(e))throw Error(`Edit already in progress`);this._editComposers.set(e,new AR(this,()=>this._editComposers.delete(e),this.repository.getMessage(e))),this._notifySubscribers()}getMessageById(e){try{return this.repository.getMessage(e)}catch{let t=this.repository.getMessages(),n=this._voiceMessages.findIndex(t=>t.id===e);return n===-1?void 0:{parentId:n>0?this._voiceMessages[n-1].id:t.at(-1)?.id??null,message:this._voiceMessages[n],index:t.length+n}}}getBranches(e){return this._voiceMessages.some(t=>t.id===e)?[]:this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifySubscribers(){for(let e of this._subscriptions)e()}_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);if(n)for(let e of n)e(t)}subscribe(e){return this._subscriptions.add(e),()=>this._subscriptions.delete(e)}submitFeedback({messageId:e,type:t}){let n=this.adapters?.feedback;if(!n)throw Error(`Feedback adapter not configured`);let{message:r,parentId:i}=this.repository.getMessage(e);if(n.submit({message:r,type:t}),r.role===`assistant`){let e={...r,metadata:{...r.metadata,submittedFeedback:{type:t}}};this.repository.addOrUpdateMessage(i,e)}this._notifySubscribers()}_stopSpeaking;speech;speak(e){let t=this.adapters?.speech;if(!t)throw Error(`Speech adapter not configured`);let{message:n}=this.repository.getMessage(e);this._stopSpeaking?.();let r=t.speak(NL(n)),i=r.subscribe(()=>{r.status.type===`ended`?(this._stopSpeaking=void 0,this.speech=void 0):this.speech={messageId:e,status:r.status},this._notifySubscribers()});this.speech={messageId:e,status:r.status},this._notifySubscribers(),this._stopSpeaking=()=>{r.cancel(),i(),this.speech=void 0,this._stopSpeaking=void 0}}stopSpeaking(){if(!this._stopSpeaking)throw Error(`No message is being spoken`);this._stopSpeaking(),this._notifySubscribers()}_voiceSession;_voiceUnsubs=[];voice;_voiceVolume=0;_voiceVolumeSubscribers=new Set;getVoiceVolume=()=>this._voiceVolume;subscribeVoiceVolume=e=>(this._voiceVolumeSubscribers.add(e),()=>this._voiceVolumeSubscribers.delete(e));connectVoice(){let e=this.adapters?.voice;if(!e)throw Error(`Voice adapter not configured`);this.disconnectVoice();let t=e.connect({});this._voiceSession=t;let n=[],r=`listening`;this.voice={status:t.status,isMuted:t.isMuted,mode:r},this._voiceVolume=0,this._notifySubscribers(),n.push(t.onStatusChange(e=>{e.type===`ended`?(this._finishVoiceAssistantMessage(),this._voiceSession=void 0,this.voice=void 0):this.voice={status:e,isMuted:t.isMuted,mode:r},this._notifySubscribers()})),n.push(t.onModeChange(e=>{r=e,this.voice&&(this.voice={...this.voice,mode:e},this._notifySubscribers())})),n.push(t.onVolumeChange(e=>{this._voiceVolume=e;for(let e of this._voiceVolumeSubscribers)e()})),n.push(t.onTranscript(e=>{this._handleVoiceTranscript(e)})),this._voiceUnsubs=n}_currentAssistantMsg=null;_handleVoiceTranscript(e){if(this.ensureInitialized(),e.role===`user`)this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null,e.isFinal&&(this._voiceMessages.push({id:cR(),role:`user`,content:[{type:`text`,text:e.text}],metadata:{custom:{}},createdAt:new Date,status:{type:`complete`,reason:`unknown`},attachments:[]}),this._markVoiceMessagesDirty(),this._notifySubscribers());else{if(!this._currentAssistantMsg)this._currentAssistantMsg={id:cR(),role:`assistant`,content:[{type:`text`,text:e.text}],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],custom:{}},status:{type:`running`},createdAt:new Date},this._voiceMessages.push(this._currentAssistantMsg);else{let t=this._voiceMessages.indexOf(this._currentAssistantMsg);if(t===-1)return;let n={...this._currentAssistantMsg,content:[{type:`text`,text:e.text}],...e.isFinal?{status:{type:`complete`,reason:`stop`}}:{}};this._voiceMessages[t]=n,this._currentAssistantMsg=n}e.isFinal&&(this._currentAssistantMsg=null),this._markVoiceMessagesDirty(),this._notifySubscribers()}}_finishVoiceAssistantMessage(){let e=this._voiceMessages.at(-1);if(e?.role===`assistant`&&e.status.type===`running`){let t=this._voiceMessages.length-1;this._voiceMessages[t]={...e,status:{type:`complete`,reason:`stop`}},this._markVoiceMessagesDirty(),this._notifySubscribers()}}disconnectVoice(){this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null;for(let e of this._voiceUnsubs)e();this._voiceUnsubs=[],this._voiceSession?.disconnect(),this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;for(let e of this._voiceVolumeSubscribers)e();this._voiceMessages=[],this._markVoiceMessagesDirty(),this._notifySubscribers()}muteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.mute(),this.voice={...this.voice,isMuted:!0},this._notifySubscribers()}unmuteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.unmute(),this.voice={...this.voice,isMuted:!1},this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers(`initialize`,{}))}export(){return this.repository.export()}import(e){this.ensureInitialized(),this.repository.clear(),this.repository.import(e),this._notifySubscribers()}reset(e){this.import(vR.fromArray(e??[]))}_eventSubscribers=new Map;unstable_on(e,t){let n=t;if(e===`modelContextUpdate`)return this._contextProvider.subscribe?.(()=>n({}))??(()=>{});let r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),e===`initialize`&&this._isInitialized&&queueMicrotask(()=>{r.has(n)&&n({})}),()=>{this._eventSubscribers.get(e)?.delete(n)}}},MR=class{cache=new WeakMap;convertMessages(e,t){return e.map((e,n)=>{let r=t(this.cache.get(e),e,n);return this.cache.set(e,r),r})}};function NR(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function PR(e,t=0){return t>100?!1:e===null||typeof e==`string`||typeof e==`boolean`?!0:typeof e==`number`?!Number.isNaN(e)&&Number.isFinite(e):Array.isArray(e)?e.every(e=>PR(e,t+1)):NR(e)?Object.entries(e).every(([e,n])=>typeof e==`string`&&PR(n,t+1)):!1}var FR=100,IR=(e,t,n)=>{if(e===t)return!0;if(n>FR||e==null||t==null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((e,r)=>IR(e,t[r],n+1));if(Array.isArray(t)||!NR(e)||!NR(t))return!1;let r=Object.keys(e),i=Object.keys(t);return r.length===i.length&&r.every(r=>Object.hasOwn(t,r)&&IR(e[r],t[r],n+1))},LR=(e,t)=>!PR(e)||!PR(t)?!1:IR(e,t,0),RR=e=>{try{return JSON.parse(e),!0}catch{return!1}},zR=e=>{try{return JSON.parse(e)}catch{return}},BR=(e,t)=>{let n=zR(e),r=zR(t);return n===void 0||r===void 0?!1:LR(n,r)},VR=class{_getTools;_callbacks;_entries=new Map;_skipExecuteStreamIds=new Set;_humanInput=new Map;_executing=new Set;_settledResolvers=[];_statuses=new Map;_ac=new AbortController;_pendingRestore=!0;_lastSnapshot=null;_isRunning=!1;_controller;_pipelineDead=!1;_pipelineRestartUsed=!1;constructor(e,t){this._getTools=e,this._callbacks=t,this._initPipeline()}_initPipeline(){let[e,t]=xI();this._controller=t;let n=KI(()=>this._getWrappedTools(),()=>this._ac.signal,(e,t)=>this._onHumanInput(e,t),{onExecutionStart:e=>this._onExecutionStart(e),onExecutionEnd:e=>this._onExecutionEnd(e)});e.pipeThrough(n).pipeThrough(new gI).pipeTo(new WritableStream({write:e=>{try{if(e.type!==`result`)return;this._handleResultChunk(e)}catch(e){console.error(`[ToolInvocationTracker] result chunk handling failed`,e)}}})).catch(e=>{console.error(`[ToolInvocationTracker] stream pipeline failed; will attempt single restart on next setState`,e),this._pipelineDead=!0})}setState(e){try{if(this._pipelineDead){if(this._pipelineRestartUsed)return;this._pipelineRestartUsed=!0,this._pipelineDead=!1,this._demoteEntriesToRestored(),this._executing.clear(),this._ac=new AbortController,this._initPipeline()}if(this._lastSnapshot&&this._lastSnapshot.messages===e.messages&&this._lastSnapshot.isRunning===e.isRunning&&this._lastSnapshot.isLoading===e.isLoading)return;e.isLoading===!0&&(this._pendingRestore=!0);let t=this._isRunning;this._isRunning=e.isRunning;try{this._processMessages(e.messages)}catch(e){throw this._isRunning=t,e}this._lastSnapshot=e,this._pendingRestore=!1}catch(e){console.error(`[ToolInvocationTracker] setState failed; snapshot dropped`,e)}}reset(){try{this._pendingRestore=!0,this._entries.clear(),this._lastSnapshot=null,this.abort().finally(()=>{this._executing.clear()})}catch(e){console.error(`[ToolInvocationTracker] reset failed`,e)}}abort(){try{return this._humanInput.forEach(({reject:e})=>{try{e(Error(`Tool execution aborted`))}catch{}}),this._humanInput.clear(),this._ac.abort(),this._ac=new AbortController,this._executing.size===0?Promise.resolve():new Promise(e=>{this._settledResolvers.push(e)})}catch(e){return console.error(`[ToolInvocationTracker] abort failed`,e),Promise.resolve()}}resume(e,t){try{let n=this._humanInput.get(e);return n?(this._humanInput.delete(e),this._setStatus(e,{type:`executing`}),n.resolve(t),!0):!1}catch(e){return console.error(`[ToolInvocationTracker] resume failed`,e),!1}}getStatuses(){return this._statuses}_getWrappedTools(){let e=this._getTools();if(e)return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.execute;return n===void 0?[e,t]:[e,{...t,execute:(...[e,t])=>this._skipExecuteStreamIds.has(t.toolCallId)?new Promise(()=>{}):n(e,t)}]}))}_onHumanInput(e,t){return new Promise((n,r)=>{let i=this._humanInput.get(e);if(i)try{i.reject(Error(`Human input request was superseded by a new request`))}catch{}this._humanInput.set(e,{resolve:n,reject:r}),this._setStatus(e,{type:`interrupt`,payload:{type:`human`,payload:t}})})}_onExecutionStart(e){this._skipExecuteStreamIds.has(e)||(this._executing.add(e),this._setStatus(e,{type:`executing`}))}_onExecutionEnd(e){this._executing.delete(e)&&(this._deleteStatus(e),this._executing.size===0&&this._settledResolvers.splice(0).forEach(e=>{try{e()}catch{}}))}_handleResultChunk(e){let t=e.meta.toolCallId,n=this._entries.get(t);!n&&this._skipExecuteStreamIds.has(t)||n?.hasResult||this._invokeOnResult({type:`add-tool-result`,toolCallId:t,toolName:e.meta.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}})}_invokeOnResult(e){try{this._callbacks.onResult(e)}catch(e){console.error(`[ToolInvocationTracker] onResult callback threw; result dropped`,e)}}_invokeOnStatusesChange(){try{this._callbacks.onStatusesChange(this._statuses)}catch(e){console.error(`[ToolInvocationTracker] onStatusesChange callback threw; status change not propagated`,e)}}_setStatus(e,t){let n=new Map(this._statuses);n.set(e,t),this._statuses=n,this._invokeOnStatusesChange()}_deleteStatus(e){if(!this._statuses.has(e))return;let t=new Map(this._statuses);t.delete(e),this._statuses=t,this._invokeOnStatusesChange()}_hasExecutableTool(e){let t=this._getTools()?.[e];return t?.execute!==void 0||t?.streamCall!==void 0}_shouldCloseArgsStream({toolName:e,argsText:t,hasResult:n}){return n?!0:(this._hasExecutableTool(e)||!this._isRunning)&&RR(t)}_startActiveEntry(e,t,n){let r=this._controller.addToolCallPart({toolName:t,toolCallId:e});n&&this._skipExecuteStreamIds.add(e);let i={toolName:t,controller:r,argsText:``,hasResult:!1,argsComplete:!1};return this._entries.set(e,i),i}_demoteEntriesToRestored(){for(let[e,t]of this._entries)t.controller&&this._entries.set(e,{toolName:t.toolName,argsText:t.argsText,hasResult:t.hasResult})}_processArgsText(e,t){if(!e.controller)return;let n=t.result!==void 0;if(t.argsText!==e.argsText){let r=!0;if(e.argsComplete)BR(e.argsText,t.argsText)&&(e.argsText=t.argsText),r=!1;else if(!t.argsText.startsWith(e.argsText))if(RR(e.argsText)&&RR(t.argsText)&&BR(e.argsText,t.argsText)){let i=this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i,r=!1}else r=!1;if(r&&e.controller){let r=t.argsText.slice(e.argsText.length);e.controller.argsText.append(r);let i=this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i}}!e.argsComplete&&e.controller&&this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n})&&(e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=!0)}_processMessages(e){let t=this._pendingRestore;for(let n of e)if(!(!n||!Array.isArray(n.content)))for(let e of n.content){if(!e||e.type!==`tool-call`)continue;let n=this._entries.get(e.toolCallId);if(t){n?.controller||this._entries.set(e.toolCallId,{toolName:e.toolName,argsText:e.argsText,hasResult:e.result!==void 0}),e.messages&&this._processMessages(e.messages);continue}let r=n;if(r&&!r.controller){if(!(e.argsText!==r.argsText||e.result!==void 0!==r.hasResult)){e.messages&&this._processMessages(e.messages);continue}this._entries.delete(e.toolCallId),r=void 0}if(r||=this._startActiveEntry(e.toolCallId,e.toolName,e.result!==void 0),this._processArgsText(r,e),e.result!==void 0&&!r.hasResult){let{controller:t}=r;if(!t)continue;r.hasResult=!0,r.argsComplete=!0,t.setResponse(new MI({result:e.result,artifact:e.artifact,isError:e.isError,...e.modelContent===void 0?{}:{modelContent:e.modelContent}})),t.close()}e.messages&&this._processMessages(e.messages)}}},HR=Object.freeze([]),UR=(e,t)=>{let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0},WR=(e,t)=>e&&t[t.length-1]?.role!==`assistant`,GR=class extends jR{_capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};get capabilities(){return this._capabilities}_messages;isDisabled;isSendDisabled;get isLoading(){return this._store.isLoading??!1}get isRunning(){return this._store.isRunning}_getBaseMessages(){return this._messages}get state(){return this._store.state??super.state}get adapters(){return this._store.adapters}suggestions=[];extras=void 0;_converter=new MR;_store;_toolInvocations=null;beginEdit(e){if(!this._store.onEdit)throw Error(`Runtime does not support editing.`);super.beginEdit(e)}constructor(e,t){super(e),this.__internal_setAdapter(t)}__internal_setAdapter(e){if(this._store===e)return;let t=e.isRunning??!1;this.isDisabled=e.isDisabled??!1,this.isSendDisabled=e.isSendDisabled??!1;let n=this._store;this._store=e,this.extras!==e.extras&&(this.extras=e.extras);let r=e.suggestions??HR;UR(this.suggestions,r)||(this.suggestions=r);let i={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,delete:this._store.onDelete!==void 0||this._store.setMessages!==void 0,reload:this._store.onReload!==void 0,cancel:this._store.onCancel!==void 0,speech:this._store.adapters?.speech!==void 0,dictation:this._store.adapters?.dictation!==void 0,voice:this._store.adapters?.voice!==void 0,unstable_copy:this._store.unstable_capabilities?.copy!==!1,attachments:!!this._store.adapters?.attachments,feedback:!!this._store.adapters?.feedback,queue:this._store.queue!==void 0};UR(this._capabilities,i)||(this._capabilities=i);let a;if(e.messageRepository){if(n&&n.isRunning===e.isRunning&&n.messageRepository===e.messageRepository){this._notifySubscribers();return}let t=e.messageRepository.messages,r=e.messageRepository.headId??t.at(-1)?.message.id??null;if(n&&n.messageRepository===e.messageRepository)this.repository.resetHead(r),a=this.repository.getMessages();else{let e=new Set(t.map(({message:e})=>e.id));for(let{message:e,parentId:n}of t)this.repository.addOrUpdateMessage(n,e);for(let{message:t}of this.repository.export().messages)e.has(t.id)||this.repository.deleteMessage(t.id);this.repository.resetHead(r),a=this.repository.getMessages()}}else if(e.messages){if(n){if(n.convertMessage!==e.convertMessage)this._converter=new MR;else if(n.isRunning===e.isRunning&&n.messages===e.messages){this._notifySubscribers();return}}a=e.convertMessage?this._converter.convertMessages(e.messages,(n,r,i)=>{if(!e.convertMessage)return r;let a=_R(i===(e.messages?.length??0)-1,t,!1,!1,void 0);if(n&&(n.role!==`assistant`||!gR(n.status)||n.status===a))return n;let o=uR(e.convertMessage(r,i),i.toString(),a);return dL(o,r),o}):e.messages;for(let e=0;e<a.length;e++){let t=a[e],n=a[e-1];this.repository.addOrUpdateMessage(n?.id??null,t)}}else throw Error(`ExternalStoreAdapter must provide either 'messages' or 'messageRepository'`);a.length>0&&this.ensureInitialized(),(n?.isRunning??!1)!==(e.isRunning??!1)&&(e.isRunning?this._notifyEventSubscribers(`runStart`,{}):this._notifyEventSubscribers(`runEnd`,{}));let o=null;WR(t,a)&&(o=cR(),this.repository.addOrUpdateMessage(a.at(-1)?.id??null,uR({role:`assistant`,content:[],metadata:{isOptimistic:!0}},o,{type:`running`}))),this.repository.resetHead(o??a.at(-1)?.id??null),this._messages=this.repository.getMessages(),this._driveToolInvocations(),this._notifySubscribers()}_driveToolInvocations(){if(!this._store.unstable_enableToolInvocations){this._toolInvocations&&(this._toolInvocations.reset(),this._toolInvocations=null,this._store.setToolStatuses?.({}));return}this._toolInvocations||=new VR(()=>this.getModelContext().tools,{onResult:e=>{try{let t=this._findMessageIdForToolCall(e.toolCallId);if(t===void 0)return;this._store.onAddToolResult?.({messageId:t,toolCallId:e.toolCallId,toolName:e.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}})}catch(e){console.error(`[ExternalStoreThreadRuntimeCore] onAddToolResult dispatch failed`,e)}},onStatusesChange:e=>{this._store.setToolStatuses?.(Object.fromEntries(e))}}),this._toolInvocations.setState({messages:this._messages,isRunning:this._store.isRunning??!1,...this._store.isLoading!==void 0&&{isLoading:this._store.isLoading}})}_toolCallToMessageId=new Map;_messagesForToolCallIndex=null;_findMessageIdForToolCall(e){if(this._messagesForToolCallIndex!==this._messages){this._toolCallToMessageId.clear();let e=t=>{for(let n of t)if(Array.isArray(n.content))for(let t of n.content)!t||t.type!==`tool-call`||(this._toolCallToMessageId.set(t.toolCallId,n.id),t.messages&&e(t.messages))};e(this._messages),this._messagesForToolCallIndex=this._messages}return this._toolCallToMessageId.get(e)}switchToBranch(e){if(!this._store.setMessages)throw Error(`Runtime does not support switching branches.`);this._store.isRunning||(this.repository.switchToBranch(e),this.updateMessages(this.repository.getMessages()))}async append(e){let t=e.parentId!==(this.messages.at(-1)?.id??null);if(!t&&this._store.queue){this._store.queue.enqueue(e,{steer:e.steer??!1});return}if((e.startRun??e.role===`user`)&&await this._toolInvocations?.abort(),t){if(!this._store.onEdit)throw Error(`Runtime does not support editing messages.`);this._store.queue?.clear(`edit`),await this._store.onEdit(e)}else await this._store.onNew(e)}async deleteMessage(e){if(this._store.onDelete){await this._store.onDelete(e);return}if(!this._store.setMessages)throw Error(`Runtime does not support deleting messages.`);this._store.isRunning&&await this._toolInvocations?.abort();let t=this.repository.getMessages();if(t.findIndex(t=>t.id===e)===-1)throw Error(`Message not found.`);this.updateMessages(t.filter(t=>t.id!==e))}getQueueItems(){return this._store?.queue?.items??SR}steerQueueItem(e){this._store?.queue?.steer(e)}removeQueueItem(e){this._store?.queue?.remove(e)}async startRun(e){if(!this._store.onReload)throw Error(`Runtime does not support reloading messages.`);this._store.queue?.clear(`reload`),await this._toolInvocations?.abort(),await this._store.onReload(e.parentId,e)}async resumeRun(e){if(!this._store.onResume)throw Error(`Runtime does not support resuming runs.`);await this._store.onResume(e)}exportExternalState(){if(!this._store.onExportExternalState)throw Error(`Runtime does not support exporting external states.`);return this._store.onExportExternalState()}importExternalState(e){if(!this._store.onLoadExternalState)throw Error(`Runtime does not support importing external states.`);this._toolInvocations&&(this._toolInvocations.reset(),this._store.setToolStatuses?.({})),this._store.onLoadExternalState(e)}cancelRun(){if(!this._store.onCancel)throw Error(`Runtime does not support cancelling runs.`);this._store.queue?.clear(`cancel-run`),this._toolInvocations?.abort(),this._store.onCancel();let e=this.repository.getMessages().at(-1);e&&e.metadata.isOptimistic&&e.content.length===0&&this.repository.deleteMessage(e.id);let t=this.repository.getMessages(),n=t[t.length-1];n?.role===`user`&&n.id===t.at(-1)?.id?(this.repository.deleteMessage(n.id),this.composer.text.trim()||this.composer.setText(NL(n)),t=this.repository.getMessages()):this._notifySubscribers(),setTimeout(()=>{this.updateMessages(t)},0)}addToolResult(e){if(!this._store.onAddToolResult)throw Error(`Runtime does not support tool results.`);this._store.onAddToolResult?.(e)}resumeToolCall(e){if(!(this._toolInvocations?.resume(e.toolCallId,e.payload)??!1)){if(this._store.onResumeToolCall){this._store.onResumeToolCall(e);return}throw Error(`Tool call ${e.toolCallId} is not waiting for resume.`)}}respondToToolApproval(e){if(!this._store.onRespondToToolApproval)throw Error(`Runtime does not support tool approvals.`);this._store.onRespondToToolApproval(e)}reset(e){let t=new xR;t.import(vR.fromArray(e??[])),this.updateMessages(t.getMessages())}import(e){super.import(e),this._store.onImport&&this._store.onImport(this.repository.getMessages())}updateMessages=e=>{this._store.convertMessage===void 0?this._store.setMessages?.(e):this._store.setMessages?.(e.flatMap(fL))}},KR=e=>e.adapters?.threadList??{},qR=class extends eR{threads;constructor(e){super(),this.threads=new sR(KR(e),()=>new GR(this._contextProvider,e))}setAdapter(e){this.threads.__internal_setAdapter(KR(e)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(e)}},JR=e=>{let t=Z(11),n;t[0]===e?n=t[1]:(n=()=>new qR(e),t[0]=e,t[1]=n);let[r]=DN(n),i;t[2]!==r||t[3]!==e?(i=()=>{r.setAdapter(e)},t[2]=r,t[3]=e,t[4]=i):i=t[4],MN(i);let{modelContext:a}=qL()??{},o,s;t[5]!==a||t[6]!==r?(o=()=>{if(a)return r.registerModelContextProvider(a)},s=[a,r],t[5]=a,t[6]=r,t[7]=o,t[8]=s):(o=t[7],s=t[8]),MN(o,s);let c;return t[9]===r?c=t[10]:(c=new $L(r),t[9]=r,t[10]=c),c},YR=(e,t)=>e.Message===t.Message&&e.EditComposer===t.EditComposer&&e.UserEditComposer===t.UserEditComposer&&e.AssistantEditComposer===t.AssistantEditComposer&&e.SystemEditComposer===t.SystemEditComposer&&e.UserMessage===t.UserMessage&&e.AssistantMessage===t.AssistantMessage&&e.SystemMessage===t.SystemMessage,XR=()=>null,ZR=(e,t,n)=>{switch(t){case`user`:return n?e.UserEditComposer??e.EditComposer??e.UserMessage??e.Message:e.UserMessage??e.Message;case`assistant`:return n?e.AssistantEditComposer??e.EditComposer??e.AssistantMessage??e.Message:e.AssistantMessage??e.Message;case`system`:return n?e.SystemEditComposer??e.EditComposer??e.SystemMessage??e.Message:e.SystemMessage??e.Message??XR;default:throw Error(`Unknown message role: ${t}`)}},QR=e=>{let t=Z(6),{components:n}=e,r=Q(rz),i=Q(iz),a;t[0]!==n||t[1]!==i||t[2]!==r?(a=ZR(n,r,i),t[0]=n,t[1]=i,t[2]=r,t[3]=a):a=t[3];let o=a,s;return t[4]===o?s=t[5]:(s=(0,J.jsx)(o,{}),t[4]=o,t[5]=s),s},$R=(0,X.memo)(e=>{let t=Z(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(QR,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(YI,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&YR(e.components,t.components));$R.displayName=`ThreadPrimitive.MessageByIndex`;var ez=({children:e})=>{let t=Q(e=>e.thread.messages.length);return AN(()=>t===0?null:Array.from({length:t},(t,n)=>(0,J.jsx)(YI,{index:n,children:(0,J.jsx)(cF,{getItemState:e=>e.thread().message({index:n}).getState(),children:t=>e({get message(){return t()}})})},n)),[t,e])},tz=e=>{let t=Z(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,J.jsx)(ez,{children:()=>(0,J.jsx)(QR,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,J.jsx)(ez,{children:r}),t[2]=r,t[3]=i),i};tz.displayName=`ThreadPrimitive.Messages`;var nz=(0,X.memo)(tz,(e,t)=>e.children||t.children?e.children===t.children:YR(e.components,t.components));function rz(e){return e.message.role}function iz(e){return e.message.composer.isEditing}var az=e=>{let t=e.message.metadata;if(!(!t||typeof t!=`object`))return t.custom?.quote},oz=class extends Error{componentName;constructor(e,t=`Component "${e}" is not in the generative-ui allowlist.`){super(t),this.name=`GenerativeUIRenderError`,this.componentName=e}},sz=e=>typeof e==`object`&&!!e,cz=(e,t,n,r)=>{if(e==null)return null;if(typeof e==`string`)return e;if(!sz(e)||!(`component`in e))return null;let{component:i,props:a,children:o,key:s}=e,c=t[i];if(!c){if(n)return(0,J.jsx)(n,{component:i,props:a},s??r);throw new oz(i)}let l=o?.length?o.map((e,i)=>cz(e,t,n,`${r}/${i}`)):void 0;return(0,X.createElement)(c,{...a??{},key:s??r},...l??[])},lz=e=>{if(!e||e.root===void 0||e.root===null)return[];let t=e.root;return Array.isArray(t)?t:[t]},uz=e=>{let t=Z(11),{spec:n,components:r,Fallback:i}=e,a;t[0]===n?a=t[1]:(a=lz(n),t[0]=n,t[1]=a);let o=a,s;if(t[2]!==i||t[3]!==r||t[4]!==o){let e;t[6]!==i||t[7]!==r?(e=(e,t)=>cz(e,r,i,`${t}`),t[6]=i,t[7]=r,t[8]=e):e=t[8],s=o.map(e),t[2]=i,t[3]=r,t[4]=o,t[5]=s}else s=t[5];let c;return t[9]===s?c=t[10]:(c=(0,J.jsx)(J.Fragment,{children:s}),t[9]=s,t[10]=c),c};uz.displayName=`GenerativeUIRender`;var dz=e=>{let t=Z(4),{components:n,spec:r,Fallback:i}=e,a=Q(fz),o=r??a;if(!o)return null;let s;return t[0]!==i||t[1]!==n||t[2]!==o?(s=(0,J.jsx)(uz,{spec:o,components:n,Fallback:i}),t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3],s};dz.displayName=`MessagePrimitive.GenerativeUI`;function fz(e){let t=e.part;return t?.type===`generative-ui`?t.spec:void 0}var pz=`ui://`,mz=e=>!!e?.startsWith(pz),hz=e=>Symbol.iterator in e,gz=e=>`entries`in e,_z=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},vz=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function yz(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:hz(e)&&hz(t)?gz(e)&&gz(t)?_z(e,t):vz(e,t):_z({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function bz(e){let t=q.useRef(void 0);return n=>{let r=e(n);return yz(t.current,r)?t.current:t.current=r}}var xz=e=>{let t=-1;return{startGroup:e=>{t===-1&&(t=e)},endGroup:(n,r)=>{t!==-1&&(r.push({type:e,startIndex:t,endIndex:n}),t=-1)},finalize:(n,r)=>{t!==-1&&r.push({type:e,startIndex:t,endIndex:n})}}},Sz=(e,t,n)=>{let r=[];if(t){let t=xz(`chainOfThoughtGroup`);for(let n=0;n<e.length;n++){let i=e[n];i===`tool-call`||i===`reasoning`?t.startGroup(n):(t.endGroup(n-1,r),r.push({type:`single`,index:n}))}t.finalize(e.length-1,r)}else{let t=xz(`toolGroup`),n=xz(`reasoningGroup`);for(let i=0;i<e.length;i++){let a=e[i];a===`tool-call`?(n.endGroup(i-1,r),t.startGroup(i)):a===`reasoning`?(t.endGroup(i-1,r),n.startGroup(i)):(t.endGroup(i-1,r),n.endGroup(i-1,r),r.push({type:`single`,index:i}))}t.finalize(e.length-1,r),n.finalize(e.length-1,r)}if(n){let e=new Set;for(let t of r){if(t.type===`single`)continue;let r=n[t.startIndex];r!==void 0&&!e.has(r)&&(e.add(r),t.idKey=`id:${r}`)}}return r},Cz=e=>{let t=Z(10),n=Q(bz(Kz)),r=Q(bz(Jz)),i;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0];let n;t[1]===r?n=t[2]:(n={ranges:e,partIds:r},t[1]=r,t[2]=n),i=n;break bb0}let a;t[3]!==n||t[4]!==r||t[5]!==e?(a=Sz(n,e,r),t[3]=n,t[4]=r,t[5]=e,t[6]=a):a=t[6];let o;t[7]!==r||t[8]!==a?(o={ranges:a,partIds:r},t[7]=r,t[8]=a,t[9]=o):o=t[9],i=o}return i},wz=e=>{let t=Z(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.toolName?(i=e=>e.tools.toolUIs[r.toolName]?.[0]?.render??n,t[3]=n,t[4]=r.toolName,t[5]=i):i=t[5];let a=Q(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,J.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},Tz=(e,t,n)=>e.renderers[t]?.[0]||(e.fallbacks[0]??n),Ez=e=>{let t=Z(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.name?(i=e=>Tz(e.dataRenderers,r.name,n),t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=Q(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,J.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},Dz={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:e})=>e,ReasoningGroup:({children:e})=>e},Oz=e=>{let t=Z(47),{components:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?{}:n,t[0]=n,t[1]=r);let{Text:i,Reasoning:a,Image:o,Source:s,File:c,Unstable_Audio:l,tools:u,data:d,generativeUI:f}=r,p=i===void 0?Dz.Text:i,m=a===void 0?Dz.Reasoning:a,h=o===void 0?Dz.Image:o,g=s===void 0?Dz.Source:s,_=c===void 0?Dz.File:c,v=l===void 0?Dz.Unstable_Audio:l,y;t[2]===u?y=t[3]:(y=u===void 0?{}:u,t[2]=u,t[3]=y);let b=y,x=aF(),S=Q(Yz),C=S.type;if(C===`tool-call`){let e;t[4]===x?e=t[5]:(e=x.part(),t[4]=x,t[5]=e);let n=e.addToolResult,r;t[6]===x?r=t[7]:(r=x.part(),t[6]=x,t[7]=r);let i=r.resumeToolCall,a;t[8]===x?a=t[9]:(a=x.part(),t[8]=x,t[9]=a);let o=a.respondToToolApproval;if(`Override`in b){let e;return t[10]!==n||t[11]!==S||t[12]!==o||t[13]!==i||t[14]!==b.Override?(e=(0,J.jsx)(b.Override,{...S,addResult:n,resume:i,respondToApproval:o}),t[10]=n,t[11]=S,t[12]=o,t[13]=i,t[14]=b.Override,t[15]=e):e=t[15],e}let s=b.by_name?.[S.toolName]??b.Fallback,c;return t[16]!==s||t[17]!==n||t[18]!==S||t[19]!==o||t[20]!==i?(c=(0,J.jsx)(wz,{...S,Fallback:s,addResult:n,resume:i,respondToApproval:o}),t[16]=s,t[17]=n,t[18]=S,t[19]=o,t[20]=i,t[21]=c):c=t[21],c}if(S.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(C){case`text`:{let e;return t[22]!==p||t[23]!==S?(e=(0,J.jsx)(p,{...S}),t[22]=p,t[23]=S,t[24]=e):e=t[24],e}case`reasoning`:{let e;return t[25]!==m||t[26]!==S?(e=(0,J.jsx)(m,{...S}),t[25]=m,t[26]=S,t[27]=e):e=t[27],e}case`source`:{let e;return t[28]!==g||t[29]!==S?(e=(0,J.jsx)(g,{...S}),t[28]=g,t[29]=S,t[30]=e):e=t[30],e}case`image`:{let e;return t[31]!==h||t[32]!==S?(e=(0,J.jsx)(h,{...S}),t[31]=h,t[32]=S,t[33]=e):e=t[33],e}case`file`:{let e;return t[34]!==_||t[35]!==S?(e=(0,J.jsx)(_,{...S}),t[34]=_,t[35]=S,t[36]=e):e=t[36],e}case`audio`:{let e;return t[37]!==v||t[38]!==S?(e=(0,J.jsx)(v,{...S}),t[37]=v,t[38]=S,t[39]=e):e=t[39],e}case`data`:{let e=d?.by_name?.[S.name]??d?.Fallback,n;return t[40]!==e||t[41]!==S?(n=(0,J.jsx)(Ez,{...S,Fallback:e}),t[40]=e,t[41]=S,t[42]=n):n=t[42],n}case`generative-ui`:{if(!f?.components)return null;let e=S,n;return t[43]!==f.Fallback||t[44]!==f.components||t[45]!==e.spec?(n=(0,J.jsx)(uz,{spec:e.spec,components:f.components,Fallback:f.Fallback}),t[43]=f.Fallback,t[44]=f.components,t[45]=e.spec,t[46]=n):n=t[46],n}default:return console.warn(`Unknown message part type: ${C}`),null}},kz=(0,X.memo)(e=>{let t=Z(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(Oz,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(XI,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.generativeUI===t.components?.generativeUI&&e.components?.ToolGroup===t.components?.ToolGroup&&e.components?.ReasoningGroup===t.components?.ReasoningGroup);kz.displayName=`MessagePrimitive.PartByIndex`;var Az=e=>{let t=Z(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,J.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,J.jsx)(QI,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},jz=Object.freeze({type:`complete`}),Mz=Object.freeze({type:`running`}),Nz=(0,X.memo)(e=>{let t=Z(6),{components:n}=e,r=Q(Xz);if(n?.Empty){let e;return t[0]!==n.Empty||t[1]!==r?(e=(0,J.jsx)(n.Empty,{status:r}),t[0]=n.Empty,t[1]=r,t[2]=e):e=t[2],e}if(r.type!==`running`)return null;let i=n?.Text??Dz.Text,a;return t[3]!==r||t[4]!==i?(a=(0,J.jsx)(Az,{status:r,component:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),Pz=(0,X.memo)(e=>{let t=Z(4),{components:n,enabled:r}=e,i;if(t[0]===r?i=t[1]:(i=e=>{if(!r||e.message.parts.length===0)return!1;let t=e.message.parts[e.message.parts.length-1];return t?.type!==`text`&&t?.type!==`reasoning`},t[0]=r,t[1]=i),!Q(i))return null;let a;return t[2]===n?a=t[3]:(a=(0,J.jsx)(Nz,{components:n}),t[2]=n,t[3]=a),a},(e,t)=>e.enabled===t.enabled&&e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),Fz=(0,X.memo)(e=>{let t=Z(4),{Quote:n}=e,r=Q(az);if(!r)return null;let i;return t[0]!==n||t[1]!==r.messageId||t[2]!==r.text?(i=(0,J.jsx)(n,{text:r.text,messageId:r.messageId}),t[0]=n,t[1]=r.messageId,t[2]=r.text,t[3]=i):i=t[3],i});function Iz(e,t){return(e.toolUIs[t.toolName]?.[0]?.render??null)||(mz(t.mcp?.app?.resourceUri)&&e.mcpApp?e.mcpApp.render:null)}var Lz=()=>{let e=Z(12),t=aF(),n=Q(Zz),r=Q(Qz);if(!r||n.type!==`tool-call`)return null;let i;e[0]===t?i=e[1]:(i=t.part(),e[0]=t,e[1]=i);let a=i.addToolResult,o;e[2]===t?o=e[3]:(o=t.part(),e[2]=t,e[3]=o);let s=o.resumeToolCall,c;e[4]===t?c=e[5]:(c=t.part(),e[4]=t,e[5]=c);let l;return e[6]!==r||e[7]!==n||e[8]!==i.addToolResult||e[9]!==o.resumeToolCall||e[10]!==c.respondToToolApproval?(l=(0,J.jsx)(r,{...n,addResult:a,resume:s,respondToApproval:c.respondToToolApproval}),e[6]=r,e[7]=n,e[8]=i.addToolResult,e[9]=o.resumeToolCall,e[10]=c.respondToToolApproval,e[11]=l):l=e[11],l},Rz=()=>{let e=Z(3),t=Q($z),n=Q(eB);if(!n||t.type!==`data`)return null;let r=t,i;return e[0]!==n||e[1]!==r?(i=(0,J.jsx)(n,{...r}),e[0]=n,e[1]=r,e[2]=i):i=e[2],i},zz=()=>{let e=Z(2),t=Q(tB);if(t===`tool-call`){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,J.jsx)(Lz,{}),e[0]=t):t=e[0],t}if(t===`data`){let t;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,J.jsx)(Rz,{}),e[1]=t):t=e[1],t}return null},Bz=Object.freeze({type:`text`,text:``,status:Mz}),Vz=({index:e,children:t})=>{let n=aF(),r=Q(e=>e.dataRenderers);return(0,J.jsx)(XI,{index:e,children:(0,J.jsx)(cF,{getItemState:t=>t.message().part({index:e}).getState(),children:i=>t({get part(){let t=i();if(t.type===`tool-call`){let r=Iz(n.tools().getState(),t)!==null,i=n.message().part({index:e});return{...t,toolUI:r?(0,J.jsx)(Lz,{}):null,addResult:i.addToolResult,resume:i.resumeToolCall,respondToApproval:i.respondToToolApproval}}if(t.type===`data`){let e=Tz(r,t.name,void 0)!==void 0;return{...t,dataRendererUI:e?(0,J.jsx)(Rz,{}):null}}return t}})})})},Hz=e=>{let t=Z(9),{children:n}=e,r=Q(nB),i=Q(rB),a=r===0&&i;if(r===0){if(!a)return null;let e;t[0]===n?e=t[1]:(e=n({part:Bz}),t[0]=n,t[1]=e);let r;return t[2]===e?r=t[3]:(r=(0,J.jsx)(QI,{text:``,isRunning:!0,children:e}),t[2]=e,t[3]=r),r}let o;if(t[4]!==n||t[5]!==r){let e;t[7]===n?e=t[8]:(e=(e,t)=>(0,J.jsx)(Vz,{index:t,children:e=>n(e)??(0,J.jsx)(zz,{})},t),t[7]=n,t[8]=e),o=(0,J.jsx)(J.Fragment,{children:Array.from({length:r},e)}),t[4]=n,t[5]=r,t[6]=o}else o=t[6];return o},Uz=e=>{let t=Z(5),{components:n,unstable_showEmptyOnNonTextEnd:r,children:i}=e,a=r===void 0||r;if(i){let e;return t[0]===i?e=t[1]:(e=(0,J.jsx)(Hz,{children:i}),t[0]=i,t[1]=e),e}let o;return t[2]!==n||t[3]!==a?(o=(0,J.jsx)(Wz,{components:n,unstable_showEmptyOnNonTextEnd:a}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o};Uz.displayName=`MessagePrimitive.Parts`;var Wz=e=>{let t=Z(15),{components:n,unstable_showEmptyOnNonTextEnd:r}=e,i=Q(iB),{ranges:a,partIds:o}=Cz(!!n?.ChainOfThought),s;bb0:{if(i===0){let e;t[0]===n?e=t[1]:(e=(0,J.jsx)(Nz,{components:n}),t[0]=n,t[1]=e),s=e;break bb0}let e;if(t[2]!==n||t[3]!==a||t[4]!==o){let r=new Set,i=e=>{let t=o[e];return t!==void 0&&!r.has(t)?(r.add(t),`part-id:${t}`):`part-${e}`};e=a.map(e=>{if(e.type===`single`)return(0,J.jsx)(kz,{index:e.index,components:n},e.index);if(e.type===`chainOfThoughtGroup`){let t=n?.ChainOfThought;return t?(0,J.jsx)(iL,{startIndex:e.startIndex,endIndex:e.endIndex,children:(0,J.jsx)(t,{})},`chainOfThought-${e.idKey??e.startIndex}`):null}else if(e.type===`toolGroup`)return(0,J.jsx)(n?.ToolGroup??Dz.ToolGroup,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let a=e.startIndex+r;return(0,J.jsx)(kz,{index:a,components:n},i(a))})},`tool-${e.idKey??e.startIndex}`);else return(0,J.jsx)(n?.ReasoningGroup??Dz.ReasoningGroup,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let i=e.startIndex+r;return(0,J.jsx)(kz,{index:i,components:n},`part-${i}`)})},`reasoning-${e.startIndex}`)}),t[2]=n,t[3]=a,t[4]=o,t[5]=e}else e=t[5];s=e}let c=s,l;t[6]===n?l=t[7]:(l=n?.Quote&&(0,J.jsx)(Fz,{Quote:n.Quote}),t[6]=n,t[7]=l);let u;t[8]!==n||t[9]!==r?(u=(0,J.jsx)(Pz,{components:n,enabled:r}),t[8]=n,t[9]=r,t[10]=u):u=t[10];let d;return t[11]!==c||t[12]!==l||t[13]!==u?(d=(0,J.jsxs)(J.Fragment,{children:[l,c,u]}),t[11]=c,t[12]=l,t[13]=u,t[14]=d):d=t[14],d};function Gz(e){return e.type}function Kz(e){return e.message.parts.map(Gz)}function qz(e){return e.type===`tool-call`?e.toolCallId:void 0}function Jz(e){return e.message.parts.map(qz)}function Yz(e){return e.part}function Xz(e){return e.message.status??jz}function Zz(e){return e.part}function Qz(e){return e.part.type===`tool-call`?Iz(e.tools,e.part):null}function $z(e){return e.part}function eB(e){return e.part.type===`data`?Tz(e.dataRenderers,e.part.name,void 0)??null:null}function tB(e){return e.part.type}function nB(e){return e.message.parts.length}function rB(e){return(e.message.status?.type??`complete`)===`running`}function iB(e){return e.message.parts.length}var aB=Symbol.for(`@assistant-ui/groupBy.memoKey`),oB=e=>{let t=e.nextChildIdx++;return e.nodeKey===``?String(t):`${e.nodeKey}.${t}`},sB=(e,t)=>{if(!(t===void 0||e.claimed.has(t)))return e.claimed.add(t),`id:${t}`},cB=(e,t)=>{let n={key:``,nodeKey:``,indices:[],children:[],nextChildIdx:0,claimed:new Set},r=[n],i=()=>{let e=r.pop(),n=r[r.length-1];n.children.push({type:`group`,key:e.key,nodeKey:e.nodeKey,idKey:sB(n,t?.[e.indices[0]]),indices:e.indices,children:e.children})};for(let n=0;n<e.length;n++){let a=e[n],o=0;for(;o<r.length-1&&o<a.length&&r[o+1].key===a[o];)o++;for(;r.length-1>o;)i();for(;r.length-1<a.length;){let e=r[r.length-1];r.push({key:a[r.length-1],nodeKey:oB(e),indices:[],children:[],nextChildIdx:0,claimed:new Set})}let s=r[r.length-1];s.children.push({type:`part`,index:n,nodeKey:oB(s),idKey:sB(s,t?.[n])});for(let e=1;e<r.length;e++)r[e].indices.push(n)}for(;r.length>1;)i();return n.children},lB=Object.freeze({type:`complete`}),uB=(e,t,n)=>{if(!n)return!1;switch(e){case`never`:return!1;case`always`:return!0;case`empty`:return t.length===0;case`no-text`:{let e=t[t.length-1];return e===void 0||e.type!==`text`&&e.type!==`reasoning`}}},dB=()=>{throw Error("MessagePrimitive.GroupedParts: rendered `children` under a leaf part. `children` is only meaningful for `group-…` cases — add a matching case for the part type or return `null` to skip it.")},fB=(e,t,n)=>{if(e.type===`part`)return(0,J.jsx)(Vz,{index:e.index,children:({part:e})=>n({part:e,children:(0,J.jsx)(dB,{})})},e.idKey?`part-${e.idKey}`:`part-${e.index}`);let r=t[e.indices.at(-1)]?.status??lB;return(0,J.jsx)(X.Fragment,{children:n({part:{type:e.key,status:r,indices:e.indices},children:(0,J.jsx)(J.Fragment,{children:e.children.map(e=>fB(e,t,n))})})},e.idKey??e.nodeKey)},pB=({groupBy:e,indicator:t=`no-text`,children:n})=>{let r=Q(bz(e=>e.message.parts)),i=Q(e=>e.tools.toolUIs),a=Q(e=>t!==`never`&&e.message.status?.type===`running`);return(0,J.jsxs)(J.Fragment,{children:[AN(()=>{let t={toolUIs:i};return cB(r.map(n=>e(n,t)??[]),r.map(e=>e.type===`tool-call`?e.toolCallId:void 0))},[r,e[aB]??e,i]).map(e=>fB(e,r,n)),uB(t,r,a)&&n({part:{type:`indicator`},children:(0,J.jsx)(dB,{})})]})};pB.displayName=`MessagePrimitive.GroupedParts`;var mB=(0,X.memo)(e=>{let t=Z(5),{children:n}=e,r=Q(az);if(!r)return null;let i;t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,J.jsx)(J.Fragment,{children:i}),t[3]=i,t[4]=a),a});mB.displayName=`MessagePrimitive.Quote`;var hB=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},gB=e=>{let t=Z(5),{components:n}=e,r=Q(bB);if(!r)return null;let i=r,a;t[0]!==n||t[1]!==i?(a=hB(n,i),t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a;if(!o)return null;let s;return t[3]===o?s=t[4]:(s=(0,J.jsx)(o,{}),t[3]=o,t[4]=s),s},_B=(0,X.memo)(e=>{let t=Z(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(gB,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(qI,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);_B.displayName=`MessagePrimitive.AttachmentByIndex`;var vB=({children:e})=>{let t=Q(e=>e.message.role===`user`?(e.message.attachments??[]).length:0);return AN(()=>Array.from({length:t},(t,n)=>(0,J.jsx)(qI,{index:n,children:(0,J.jsx)(cF,{getItemState:e=>e.message().attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},n)),[t,e])},yB=e=>{let t=Z(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,J.jsx)(vB,{children:e=>{let{attachment:t}=e,r=hB(n,t);return r?(0,J.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,J.jsx)(vB,{children:r}),t[2]=r,t[3]=i),i};yB.displayName=`MessagePrimitive.Attachments`;function bB(e){return e.attachment}var xB=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},SB=e=>{let t=Z(5),{components:n}=e,r=Q(EB);if(!r)return null;let i;t[0]!==r||t[1]!==n?(i=xB(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i;if(!a)return null;let o;return t[3]===a?o=t[4]:(o=(0,J.jsx)(a,{}),t[3]=a,t[4]=o),o},CB=(0,X.memo)(e=>{let t=Z(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(SB,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(JI,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);CB.displayName=`ComposerPrimitive.AttachmentByIndex`;var wB=({children:e})=>{let t=Q(e=>e.composer.attachments.length);return AN(()=>Array.from({length:t},(t,n)=>(0,J.jsx)(JI,{index:n,children:(0,J.jsx)(cF,{getItemState:e=>e.composer().attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},n)),[t,e])},TB=e=>{let t=Z(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,J.jsx)(wB,{children:e=>{let{attachment:t}=e,r=xB(n,t);return r?(0,J.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,J.jsx)(wB,{children:r}),t[2]=r,t[3]=i),i};TB.displayName=`ComposerPrimitive.Attachments`;function EB(e){return e.attachment}var DB=(0,X.memo)(({children:e})=>{let t=Q(e=>e.composer.queue.length);return AN(()=>Array.from({length:t},(t,n)=>(0,J.jsx)(sL,{index:n,children:(0,J.jsx)(cF,{getItemState:e=>e.composer().queueItem({index:n}).getState(),children:t=>e({get queueItem(){return t()}})})},n)),[t,e])});DB.displayName=`ComposerPrimitive.Queue`;var OB=e=>{let{children:t}=e;return Q(kB)?t:null};OB.displayName=`MessagePartPrimitive.InProgress`;function kB(e){return e.part.status.type===`running`}var AB=e=>{let t=Z(2),{components:n}=e,r=n.Suggestion,i;return t[0]===r?i=t[1]:(i=(0,J.jsx)(r,{}),t[0]=r,t[1]=i),i},jB=(0,X.memo)(e=>{let t=Z(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(AB,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(oL,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components.Suggestion===t.components.Suggestion);jB.displayName=`ThreadPrimitive.SuggestionByIndex`;var MB=({children:e})=>{let t=Q(e=>e.suggestions.suggestions.length);return AN(()=>t===0?null:Array.from({length:t},(t,n)=>(0,J.jsx)(oL,{index:n,children:(0,J.jsx)(cF,{getItemState:e=>e.suggestions().suggestion({index:n}).getState(),children:t=>e({get suggestion(){return t()}})})},n)),[t,e])},NB=e=>{let t=Z(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,J.jsx)(MB,{children:()=>(0,J.jsx)(AB,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,J.jsx)(MB,{children:r}),t[2]=r,t[3]=i),i};NB.displayName=`ThreadPrimitive.Suggestions`;var PB=(0,X.memo)(NB,(e,t)=>e.children||t.children?e.children===t.children:e.components.Suggestion===t.components.Suggestion),FB=e=>{let t=Z(3),n;return t[0]!==e.dictation||t[1]!==e.editing?(n=t=>{if(e.editing===!0&&!t.composer.isEditing||e.editing===!1&&t.composer.isEditing)return!1;let n=t.composer.dictation!=null;return!(e.dictation===!0&&!n||e.dictation===!1&&n)},t[0]=e.dictation,t[1]=e.editing,t[2]=n):n=t[2],Q(n)},IB=e=>{let t=Z(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),FB(r)?n:null};IB.displayName=`ComposerPrimitive.If`;var LB=()=>{let e=Z(5),t=aF(),n=Q(RB),r;e[0]===t?r=e[1]:(r=e=>{t.composer().send(e)},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={send:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function RB(e){return!e.composer.canSend||e.thread.isRunning&&!e.thread.capabilities.queue}var zB=()=>{let e=Z(5),t=aF(),n=Q(BB),r;e[0]===t?r=e[1]:(r=()=>{t.composer().cancel()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={cancel:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a};function BB(e){return!e.composer.canCancel}var VB=()=>{let e=Z(5),t=aF(),n=Q(HB),r;e[0]===t?r=e[1]:(r=()=>{t.composer().startDictation()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={startDictation:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function HB(e){return e.composer.dictation!=null||!e.thread.capabilities.dictation||!e.composer.isEditing}var UB=()=>{let e=Z(5),t=aF(),n=Q(WB),r;e[0]===t?r=e[1]:(r=e=>t.composer().addAttachment(e),e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={addAttachment:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a};function WB(e){return!e.composer.isEditing}var GB=e=>{let t=Z(12),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{copiedDuration:r,copyToClipboard:i}=n,a=r===void 0?3e3:r,o=aF(),s=Q(qB),c=Q(JB),l=Q(YB),u=Q(XB),d;t[2]!==o||t[3]!==u||t[4]!==a||t[5]!==i||t[6]!==l?(d=()=>{let e=l?u:o.message().getCopyText();if(!e)return;let t=i??ZB;Promise.resolve(t(e)).then(()=>{o.message().setIsCopied(!0),setTimeout(()=>o.message().setIsCopied(!1),a)},QB)},t[2]=o,t[3]=u,t[4]=a,t[5]=i,t[6]=l,t[7]=d):d=t[7];let f=d,p;return t[8]!==f||t[9]!==s||t[10]!==c?(p={copy:f,disabled:s,isCopied:c},t[8]=f,t[9]=s,t[10]=c,t[11]=p):p=t[11],p};function KB(e){return e.type===`text`&&e.text.length>0}function qB(e){return!((e.message.role!==`assistant`||e.message.status?.type!==`running`)&&e.message.parts.some(KB))}function JB(e){return e.message.isCopied}function YB(e){return e.composer.isEditing}function XB(e){return e.composer.text}function ZB(){}function QB(){}var $B=()=>{let e=Z(5),t=aF(),n=Q(eV),r;e[0]===t?r=e[1]:(r=()=>{t.composer().beginEdit()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={edit:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function eV(e){return e.composer.isEditing}var tV=()=>{let e=Z(5),t=aF(),n=Q(nV),r;e[0]===t?r=e[1]:(r=()=>{t.message().reload()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={reload:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function nV(e){return e.thread.isRunning||e.thread.isDisabled||e.message.role!==`assistant`}var rV=()=>{let e=Z(5),t=aF(),n=Q(aV),r;e[0]===t?r=e[1]:(r=()=>{t.message().submitFeedback({type:`positive`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={submit:i,isSubmitted:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},iV=()=>{let e=Z(5),t=aF(),n=Q(oV),r;e[0]===t?r=e[1]:(r=()=>{t.message().submitFeedback({type:`negative`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={submit:i,isSubmitted:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function aV(e){return e.message.metadata.submittedFeedback?.type===`positive`}function oV(e){return e.message.metadata.submittedFeedback?.type===`negative`}var sV=()=>{let e=Z(5),t=aF(),n=Q(lV),r;e[0]===t?r=e[1]:(r=async()=>{t.message().speak()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={speak:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function cV(e){return e.type===`text`&&e.text.length>0}function lV(e){return!((e.message.role!==`assistant`||e.message.status?.type!==`running`)&&e.message.parts.some(cV))}var uV=()=>{let e=Z(5),t=aF(),n=Q(dV),r;e[0]===t?r=e[1]:(r=()=>{t.message().stopSpeaking()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={stopSpeaking:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function dV(e){return e.message.speech==null}var fV=e=>{let t=Z(8),{prompt:n,send:r,clearComposer:i}=e,a=i===void 0||i,o=aF(),s=Q(pV),c=r??!1,l;t[0]!==o||t[1]!==a||t[2]!==n||t[3]!==c?(l=()=>{let e=o.thread().getState().isRunning;if(c&&!e)o.thread().append({content:[{type:`text`,text:n}],runConfig:o.composer().getState().runConfig}),a&&o.composer().setText(``);else if(a)o.composer().setText(n);else{let e=o.composer().getState().text;o.composer().setText(e.trim()?`${e} ${n}`:n)}},t[0]=o,t[1]=a,t[2]=n,t[3]=c,t[4]=l):l=t[4];let u=l,d;return t[5]!==s||t[6]!==u?(d={trigger:u,disabled:s},t[5]=s,t[6]=u,t[7]=d):d=t[7],d};function pV(e){return e.thread.isDisabled}var mV=()=>Q(hV);function hV(e){return e.message.status?.type===`incomplete`&&e.message.status.reason===`error`?e.message.status.error??`An error occurred`:void 0}var gV=/:([\w-]{1,64})\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?/gu,_V={serialize(e){let t=e.id===e.label?``:`{name=${e.id}}`;return`:${e.type}[${e.label}]${t}`},parse(e){let t=[],n=0;for(let r of e.matchAll(gV)){r.index>n&&t.push({kind:`text`,text:e.slice(n,r.index)});let i=r[2];t.push({kind:`mention`,type:r[1],label:i,id:r[3]??i}),n=r.index+r[0].length}return n<e.length&&t.push({kind:`text`,text:e.slice(n)}),t}};function vV(e,t){function n(n){let r=zN(e);if(!n?.optional&&!r)throw Error(`This component must be used within ${t}.`);return r}return n}function yV(e,t){function n(n){let r=e(n);return r?r[t]:null}function r(e){let t=!1,r;typeof e==`function`?r=e:e&&typeof e==`object`&&(t=!!e.optional,r=e.selector);let i=n({optional:t});return i?r?i(r):i():null}return{[t]:r,[`${t}Store`]:n}}var bV=LN(null),{useThreadViewport:xV,useThreadViewportStore:SV}=yV(vV(bV,`ThreadPrimitive.Viewport`),`useThreadViewport`),CV=e=>{let t=new Map,n=()=>{let n=0;for(let e of t.values())n+=e;e(n)};return{register:()=>{let e=Symbol();return t.set(e,0),{setHeight:r=>{t.get(e)!==r&&(t.set(e,r),n())},unregister:()=>{t.delete(e),n()}}}}},wV=(e={})=>{let t=new Set,n=CV(e=>{a.setState({height:{...a.getState().height,viewport:e}})}),r=CV(e=>{a.setState({height:{...a.getState().height,inset:e}})}),i=(e,t)=>(a.setState({element:{...a.getState().element,[e]:t}}),()=>{a.getState().element[e]===t&&a.setState({element:{...a.getState().element,[e]:null}})}),a=rI(()=>({isAtBottom:!0,scrollToBottom:({behavior:e=`auto`}={})=>{for(let n of t)n({behavior:e})},onScrollToBottom:e=>(t.add(e),()=>{t.delete(e)}),turnAnchor:e.turnAnchor??`bottom`,topAnchorMessageClamp:{tallerThan:e.topAnchorMessageClamp?.tallerThan??`10em`,visibleHeight:e.topAnchorMessageClamp?.visibleHeight??`6em`},height:{viewport:0,inset:0},element:{viewport:null,anchor:null,target:null},targetConfig:null,topAnchorTurn:null,registerViewport:n.register,registerContentInset:r.register,registerViewportElement:e=>i(`viewport`,e),registerAnchorElement:e=>i(`anchor`,e),registerAnchorTargetElement:(e,t)=>(a.setState({element:{...a.getState().element,target:e},targetConfig:e&&t?t:null}),()=>{a.getState().element.target===e&&a.setState({element:{...a.getState().element,target:null},targetConfig:null})}),setTopAnchorTurn:e=>{a.setState({topAnchorTurn:e})}}));return a},TV=e=>e,EV=e=>{let t=Z(11),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={optional:!0},t[0]=n):n=t[0];let r=SV(n),i;t[1]===e?i=t[2]:(i=()=>wV(e),t[1]=e,t[2]=i);let[a]=DN(i),o,s;t[3]!==r||t[4]!==a?(o=()=>r?.getState().onScrollToBottom(()=>{a.getState().scrollToBottom()}),s=[r,a],t[3]=r,t[4]=a,t[5]=o,t[6]=s):(o=t[5],s=t[6]),MN(o,s);let c,l;return t[7]!==r||t[8]!==a?(c=()=>{if(r)return a.subscribe(e=>{r.getState().isAtBottom!==e.isAtBottom&&TV(r).setState({isAtBottom:e.isAtBottom})})},l=[a,r],t[7]=r,t[8]=a,t[9]=c,t[10]=l):(c=t[9],l=t[10]),MN(c,l),a},DV=e=>{let t=Z(7),{children:n,options:r}=e,i;t[0]===r?i=t[1]:(i=r===void 0?{}:r,t[0]=r,t[1]=i);let a=EV(i),o;t[2]===a?o=t[3]:(o=()=>({useThreadViewport:a}),t[2]=a,t[3]=o);let[s]=DN(o),c;return t[4]!==n||t[5]!==s?(c=(0,J.jsx)(bV.Provider,{value:s,children:n}),t[4]=n,t[5]=s,t[6]=c):c=t[6],c},OV=()=>{let e=Z(3),t=aF(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{},r=[t],e[0]=t,e[1]=n,e[2]=r),MN(n,r),null},kV=(0,X.memo)(e=>{let t=Z(7),{children:n,aui:r,runtime:i}=e,a=r??null,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,J.jsx)(OV,{}),t[0]=o):o=t[0];let s;t[1]===n?s=t[2]:(s=(0,J.jsx)(DV,{children:n}),t[1]=n,t[2]=s);let c;return t[3]!==i||t[4]!==a||t[5]!==s?(c=(0,J.jsxs)(ZF,{runtime:i,aui:a,children:[o,s]}),t[3]=i,t[4]=a,t[5]=s,t[6]=c):c=t[6],c}),AV=e=>{let t=e;t.__isBound||=(t.__internal_bindMethods?.(),!0)};function jV(e,t){let n=Z(4),r=t===void 0?MV:t;AV(e);let i,a;n[0]!==e||n[1]!==r?(i=()=>r(e.getState()),a=()=>r(e.getState()),n[0]=e,n[1]=r,n[2]=i,n[3]=a):(i=n[2],a=n[3]);let o=FN(e.subscribe,i,a);return IN(o),o}var MV=e=>e;function NV(e){function t(t){let n=!1,r;typeof t==`function`?r=t:t&&(n=!!t.optional,r=t.selector);let i=e({optional:n});return i?jV(i,r):null}return t}function PV(e){let t=Z(2),n=aF(),r;t[0]===n?r=t[1]:(r=()=>n.attachment.source?n.attachment().__internal_getRuntime?.()??null:null,t[0]=n,t[1]=r);let i=Q(r);if(!i&&!e?.optional)throw Error(`AttachmentRuntime is not available`);return i}var FV=NV(PV);function IV(e){let t=Z(2),n=aF(),r;t[0]===n?r=t[1]:(r=()=>n.composer.source?n.composer().__internal_getRuntime?.()??null:null,t[0]=n,t[1]=r);let i=Q(r);if(!i&&!e?.optional)throw Error(`ComposerRuntime is not available`);return i}var LV=NV(IV);function RV(e){let t=Z(2),n=aF(),r;t[0]===n?r=t[1]:(r=()=>n.message.source?n.message().__internal_getRuntime?.()??null:null,t[0]=n,t[1]=r);let i=Q(r);if(!i&&!e?.optional)throw Error(`MessageRuntime is not available`);return i}var $=NV(RV);function zV(e){let t=Z(2),n=aF(),r;t[0]===n?r=t[1]:(r=()=>n.thread.source?n.thread().__internal_getRuntime?.()??null:null,t[0]=n,t[1]=r);let i=Q(r);if(!i&&!e?.optional)throw Error(`ThreadRuntime is not available`);return i}var BV=NV(zV),VV=Object.defineProperty,HV=(e,t)=>{let n={};for(var r in e)VV(n,r,{get:e[r],enumerable:!0});return t||VV(n,Symbol.toStringTag,{value:`Module`}),n},UV=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`];function WV(e){let t=(0,X.forwardRef)((t,n)=>{let r=Z(17),i,a,o,s;r[0]===t?(i=r[1],a=r[2],o=r[3],s=r[4]):({render:o,asChild:i,children:a,...s}=t,r[0]=t,r[1]=i,r[2]=a,r[3]=o,r[4]=s);let c=e;if(o&&(0,X.isValidElement)(o)){let e=a===void 0?o.props.children:a,t=s,i;r[5]!==o||r[6]!==e?(i=(0,X.cloneElement)(o,void 0,e),r[5]=o,r[6]=e,r[7]=i):i=r[7];let l;return r[8]!==n||r[9]!==t||r[10]!==i?(l=(0,J.jsx)(c,{...t,asChild:!0,ref:n,children:i}),r[8]=n,r[9]=t,r[10]=i,r[11]=l):l=r[11],l}let l=s,u;return r[12]!==i||r[13]!==a||r[14]!==n||r[15]!==l?(u=(0,J.jsx)(c,{...l,asChild:i,ref:n,children:a}),r[12]=i,r[13]=a,r[14]=n,r[15]=l,r[16]=u):u=r[16],u});return t.displayName=typeof e==`string`?e:e.displayName??e.name??`Component`,t}function GV(e){let t=gc[e],n=WV(t);return n.displayName=`Primitive.${e}`,n}var KV=UV.reduce((e,t)=>(e[t]=GV(t),e),{}),qV=e=>{let t=Z(5),{hideWhenRunning:n,autohide:r,autohideFloat:i,forceVisible:a}=e,o;return t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==n?(o=e=>{if(n&&e.thread.isRunning)return`hidden`;let t=r===`always`||r===`not-last`&&!e.message.isLast,o=a||e.message.isHovering;return t?o?i===`always`||i===`single-branch`&&e.message.branchCount<=1?`floating`:`normal`:`hidden`:`normal`},t[0]=r,t[1]=i,t[2]=a,t[3]=n,t[4]=o):o=t[4],Q(o)},JV=LN(null),YV=()=>zN(JV),XV=(0,X.forwardRef)((e,t)=>{let n=Z(18),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({hideWhenRunning:a,autohide:r,autohideFloat:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let[s,c]=DN(0),l;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=!1;return c(ZV),()=>{e||(e=!0,c(QV))}},n[5]=l):l=n[5];let u=l,d;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(d={acquireInteractionLock:u},n[6]=d):d=n[6];let f=d,p=s>0,m;n[7]!==r||n[8]!==i||n[9]!==a||n[10]!==p?(m={hideWhenRunning:a,autohide:r,autohideFloat:i,forceVisible:p},n[7]=r,n[8]=i,n[9]=a,n[10]=p,n[11]=m):m=n[11];let h=qV(m);if(h===`hidden`)return null;let g;n[12]===h?g=n[13]:(g=h===`floating`?{"data-floating":`true`}:null,n[12]=h,n[13]=g);let _;return n[14]!==t||n[15]!==o||n[16]!==g?(_=(0,J.jsx)(JV.Provider,{value:f,children:(0,J.jsx)(KV.div,{...g,...o,ref:t})}),n[14]=t,n[15]=o,n[16]=g,n[17]=_):_=n[17],_});XV.displayName=`ActionBarPrimitive.Root`;function ZV(e){return e+1}function QV(e){return Math.max(0,e-1)}var $V=e=>{let t=Z(4),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{copiedDuration:r}=n,i=r===void 0?3e3:r,a;t[2]===i?a=t[3]:(a={copiedDuration:i,copyToClipboard:tH},t[2]=i,t[3]=a);let{copy:o,disabled:s}=GB(a);return s?null:o},eH=(0,X.forwardRef)((e,t)=>{let n=Z(20),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({copiedDuration:r,onClick:a,disabled:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=Q(nH),c;n[5]===r?c=n[6]:(c={copiedDuration:r},n[5]=r,n[6]=c);let l=$V(c),u;n[7]===s?u=n[8]:(u=s?{"data-copied":`true`}:{},n[7]=s,n[8]=u);let d=i||!l,f;n[9]===l?f=n[10]:(f=()=>{l?.()},n[9]=l,n[10]=f);let p;n[11]!==a||n[12]!==f?(p=$b(a,f),n[11]=a,n[12]=f,n[13]=p):p=n[13];let m;return n[14]!==t||n[15]!==o||n[16]!==u||n[17]!==d||n[18]!==p?(m=(0,J.jsx)(KV.button,{type:`button`,...u,...o,ref:t,disabled:d,onClick:p}),n[14]=t,n[15]=o,n[16]=u,n[17]=d,n[18]=p,n[19]=m):m=n[19],m});eH.displayName=`ActionBarPrimitive.Copy`;function tH(e){return typeof navigator>`u`||!navigator.clipboard?Promise.reject(Error(`Clipboard API is unavailable`)):navigator.clipboard.writeText(e)}function nH(e){return e.message.isCopied}var rH=(e,t,n=[])=>{let r=(0,X.forwardRef)((e,r)=>{let i=Z(6),a={},o={};Object.keys(e).forEach(t=>{n.includes(t)?a[t]=e[t]:o[t]=e[t]});let s=t(a)??void 0,c=KV,l=o.disabled||!s,u=$b(o.onClick,s),d;return i[0]!==r||i[1]!==o||i[2]!==c.button||i[3]!==l||i[4]!==u?(d=(0,J.jsx)(c.button,{...o,type:`button`,ref:r,disabled:l,onClick:u}),i[0]=r,i[1]=o,i[2]=c.button,i[3]=l,i[4]=u,i[5]=d):d=i[5],d});return r.displayName=e,r},iH=rH(`ActionBarPrimitive.Reload`,()=>{let{disabled:e,reload:t}=tV();return e?null:t}),aH=rH(`ActionBarPrimitive.Edit`,()=>{let{disabled:e,edit:t}=$B();return e?null:t}),oH=rH(`ActionBarPrimitive.Speak`,()=>{let{disabled:e,speak:t}=sV();return e?null:t}),sH=()=>{let{disabled:e,stopSpeaking:t}=uV();return e?null:t},cH=(0,X.forwardRef)((e,t)=>{let n=Z(12),r=sH(),i;n[0]===r?i=n[1]:(i=e=>{r&&(e.preventDefault(),r())},n[0]=r,n[1]=i),tx(i);let a=!r,o;n[2]===r?o=n[3]:(o=()=>{r?.()},n[2]=r,n[3]=o);let s;n[4]!==e.onClick||n[5]!==o?(s=$b(e.onClick,o),n[4]=e.onClick,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==e||n[8]!==t||n[9]!==a||n[10]!==s?(c=(0,J.jsx)(KV.button,{type:`button`,disabled:a,...e,ref:t,onClick:s}),n[7]=e,n[8]=t,n[9]=a,n[10]=s,n[11]=c):c=n[11],c});cH.displayName=`ActionBarPrimitive.StopSpeaking`;var lH=()=>{let{submit:e}=rV();return e},uH=(0,X.forwardRef)((e,t)=>{let n=Z(17),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=Q(dH),s=lH(),c;n[4]===o?c=n[5]:(c=o?{"data-submitted":`true`}:{},n[4]=o,n[5]=c);let l=r||!s,u;n[6]===s?u=n[7]:(u=()=>{s?.()},n[6]=s,n[7]=u);let d;n[8]!==i||n[9]!==u?(d=$b(i,u),n[8]=i,n[9]=u,n[10]=d):d=n[10];let f;return n[11]!==t||n[12]!==a||n[13]!==c||n[14]!==l||n[15]!==d?(f=(0,J.jsx)(KV.button,{type:`button`,...c,...a,ref:t,disabled:l,onClick:d}),n[11]=t,n[12]=a,n[13]=c,n[14]=l,n[15]=d,n[16]=f):f=n[16],f});uH.displayName=`ActionBarPrimitive.FeedbackPositive`;function dH(e){return e.message.metadata.submittedFeedback?.type===`positive`}var fH=()=>{let{submit:e}=iV();return e},pH=(0,X.forwardRef)((e,t)=>{let n=Z(17),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=Q(mH),s=fH(),c;n[4]===o?c=n[5]:(c=o?{"data-submitted":`true`}:{},n[4]=o,n[5]=c);let l=r||!s,u;n[6]===s?u=n[7]:(u=()=>{s?.()},n[6]=s,n[7]=u);let d;n[8]!==i||n[9]!==u?(d=$b(i,u),n[8]=i,n[9]=u,n[10]=d):d=n[10];let f;return n[11]!==t||n[12]!==a||n[13]!==c||n[14]!==l||n[15]!==d?(f=(0,J.jsx)(KV.button,{type:`button`,...c,...a,ref:t,disabled:l,onClick:d}),n[11]=t,n[12]=a,n[13]=c,n[14]=l,n[15]=d,n[16]=f):f=n[16],f});pH.displayName=`ActionBarPrimitive.FeedbackNegative`;function mH(e){return e.message.metadata.submittedFeedback?.type===`negative`}var hH=e=>{let t=Z(6),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{filename:r,onExport:i}=n,a=aF(),o=Q(vH),s;return t[2]!==a||t[3]!==r||t[4]!==i?(s=async()=>{let e=a.message().getCopyText();if(!e)return;if(i){await i(e);return}let t=new Blob([e],{type:`text/markdown`}),n=URL.createObjectURL(t),o=document.createElement(`a`);o.href=n,o.download=r??`message-${Date.now()}.md`,o.click(),URL.revokeObjectURL(n)},t[2]=a,t[3]=r,t[4]=i,t[5]=s):s=t[5],o?s:null},gH=(0,X.forwardRef)((e,t)=>{let n=Z(19),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({filename:i,onExport:o,onClick:a,disabled:r,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let c;n[6]!==i||n[7]!==o?(c={filename:i,onExport:o},n[6]=i,n[7]=o,n[8]=c):c=n[8];let l=hH(c),u=r||!l,d;n[9]===l?d=n[10]:(d=()=>{l?.()},n[9]=l,n[10]=d);let f;n[11]!==a||n[12]!==d?(f=$b(a,d),n[11]=a,n[12]=d,n[13]=f):f=n[13];let p;return n[14]!==t||n[15]!==s||n[16]!==u||n[17]!==f?(p=(0,J.jsx)(KV.button,{type:`button`,...s,ref:t,disabled:u,onClick:f}),n[14]=t,n[15]=s,n[16]=u,n[17]=f,n[18]=p):p=n[18],p});gH.displayName=`ActionBarPrimitive.ExportMarkdown`;function _H(e){return e.type===`text`&&e.text.length>0}function vH(e){return(e.message.role!==`assistant`||e.message.status?.type!==`running`)&&e.message.parts.some(_H)}var yH=HV({Copy:()=>eH,Edit:()=>aH,ExportMarkdown:()=>gH,FeedbackNegative:()=>pH,FeedbackPositive:()=>uH,Reload:()=>iH,Root:()=>XV,Speak:()=>oH,StopSpeaking:()=>cH}),bH=one(),xH=e=>{let t=Z(25),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({__scopeActionBarMore:n,open:i,onOpenChange:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=bH(n),s=YV(),c=kN(null),l=i!==void 0,u;t[5]===s?u=t[6]:(u=e=>{if(e){if(c.current)return;c.current=s?.acquireInteractionLock()??null;return}c.current?.(),c.current=null},t[5]=s,t[6]=u);let d=u,f;t[7]!==l||t[8]!==r||t[9]!==d?(f=e=>{l||d(e),r?.(e)},t[7]=l,t[8]=r,t[9]=d,t[10]=f):f=t[10];let p=f,m,h;t[11]!==l||t[12]!==i||t[13]!==d?(m=()=>{l&&d(!!i)},h=[l,i,d],t[11]=l,t[12]=i,t[13]=d,t[14]=m,t[15]=h):(m=t[14],h=t[15]),MN(m,h);let g,_;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>()=>{c.current?.(),c.current=null},_=[],t[16]=g,t[17]=_):(g=t[16],_=t[17]),MN(g,_);let v;t[18]===i?v=t[19]:(v=i===void 0?null:{open:i},t[18]=i,t[19]=v);let y;return t[20]!==p||t[21]!==a||t[22]!==o||t[23]!==v?(y=(0,J.jsx)(cC,{...o,...a,...v,onOpenChange:p}),t[20]=p,t[21]=a,t[22]=o,t[23]=v,t[24]=y):y=t[24],y};xH.displayName=`ActionBarMorePrimitive.Root`;var SH=WV(cne),CH=WV(sne),wH=WV(gC),TH=WV(lne),EH=(0,X.forwardRef)((e,t)=>{let n=Z(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=bH(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,J.jsx)(SH,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});EH.displayName=`ActionBarMorePrimitive.Trigger`;var DH=(0,X.forwardRef)((e,t)=>{let n=Z(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({__scopeActionBarMore:r,portalProps:i,sideOffset:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=o===void 0?4:o,c=bH(r),l;n[5]!==t||n[6]!==a||n[7]!==c||n[8]!==s?(l=(0,J.jsx)(CH,{...c,...a,ref:t,sideOffset:s}),n[5]=t,n[6]=a,n[7]=c,n[8]=s,n[9]=l):l=n[9];let u;return n[10]!==i||n[11]!==c||n[12]!==l?(u=(0,J.jsx)(sC,{...c,...i,children:l}),n[10]=i,n[11]=c,n[12]=l,n[13]=u):u=n[13],u});DH.displayName=`ActionBarMorePrimitive.Content`;var OH=(0,X.forwardRef)((e,t)=>{let n=Z(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=bH(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,J.jsx)(wH,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});OH.displayName=`ActionBarMorePrimitive.Item`;var kH=(0,X.forwardRef)((e,t)=>{let n=Z(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=bH(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,J.jsx)(TH,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});kH.displayName=`ActionBarMorePrimitive.Separator`;var AH=HV({Content:()=>DH,Item:()=>OH,Root:()=>xH,Separator:()=>kH,Trigger:()=>EH}),jH=(0,X.forwardRef)((e,t)=>{let n=Z(3),r;return n[0]!==e||n[1]!==t?(r=(0,J.jsx)(KV.div,{...e,ref:t}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});jH.displayName=`AttachmentPrimitive.Root`;var MH=(0,X.forwardRef)((e,t)=>{let n=Z(4),r=Q(NH),i;return n[0]!==r||n[1]!==e||n[2]!==t?(i=(0,J.jsxs)(KV.div,{...e,ref:t,children:[`.`,r]}),n[0]=r,n[1]=e,n[2]=t,n[3]=i):i=n[3],i});MH.displayName=`AttachmentPrimitive.unstable_Thumb`;function NH(e){let t=e.attachment.name.split(`.`);return t.length>1?t.pop():``}var PH=()=>{let e=Z(2),t=Q(FH),n;return e[0]===t?n=e[1]:(n=(0,J.jsx)(J.Fragment,{children:t}),e[0]=t,e[1]=n),n};PH.displayName=`AttachmentPrimitive.Name`;function FH(e){return e.attachment.name}var IH=rH(`AttachmentPrimitive.Remove`,()=>{let e=Z(2),t=aF(),n;return e[0]===t?n=e[1]:(n=()=>{t.attachment().remove()},e[0]=t,e[1]=n),n}),LH=HV({Name:()=>PH,Remove:()=>IH,Root:()=>jH,unstable_Thumb:()=>MH}),RH=e=>{let t=Z(12),n;return t[0]!==e.assistant||t[1]!==e.copied||t[2]!==e.hasAttachments||t[3]!==e.hasBranches||t[4]!==e.hasContent||t[5]!==e.last||t[6]!==e.lastOrHover||t[7]!==e.speaking||t[8]!==e.submittedFeedback||t[9]!==e.system||t[10]!==e.user?(n=t=>{let{role:n,attachments:r,parts:i,branchCount:a,isLast:o,speech:s,isCopied:c,isHovering:l}=t.message;return!(e.hasBranches===!0&&a<2||e.user&&n!==`user`||e.assistant&&n!==`assistant`||e.system&&n!==`system`||e.lastOrHover===!0&&!l&&!o||e.last!==void 0&&e.last!==o||e.copied===!0&&!c||e.copied===!1&&c||e.speaking===!0&&s==null||e.speaking===!1&&s!=null||e.hasAttachments===!0&&(n!==`user`||!r?.length)||e.hasAttachments===!1&&n===`user`&&r?.length||e.hasContent===!0&&i.length===0||e.hasContent===!1&&i.length>0||e.submittedFeedback!==void 0&&(t.message.metadata.submittedFeedback?.type??null)!==e.submittedFeedback)},t[0]=e.assistant,t[1]=e.copied,t[2]=e.hasAttachments,t[3]=e.hasBranches,t[4]=e.hasContent,t[5]=e.last,t[6]=e.lastOrHover,t[7]=e.speaking,t[8]=e.submittedFeedback,t[9]=e.system,t[10]=e.user,t[11]=n):n=t[11],Q(n)},zH=e=>{let t=Z(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),RH(r)?n:null};zH.displayName=`MessagePrimitive.If`;var BH=LN(null),VH=()=>zN(BH),HH=e=>{let t=Z(8),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=kN(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],t[1]=a):a=t[1];let o=kN(a),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=Array.from(i.current.entries());e.sort(UH),o.current=e.map(WH)},t[2]=s):s=t[2];let c=s,l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(e,t)=>{let n=t?.priority??0;return i.current.set(e,n),c(),()=>{i.current.delete(e),c()}},t[3]=l):l=t[3];let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>o.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={register:u,getPlugins:f},t[5]=p):p=t[5];let m=p,h;return t[6]===n?h=t[7]:(h=(0,J.jsx)(BH.Provider,{value:m,children:n}),t[6]=n,t[7]=h),h};function UH(e,t){return t[1]-e[1]}function WH(e){let[t]=e;return t}var GH=LN(null),KH=LN(null),qH=()=>{let e=zN(GH);if(!e)throw Error(`useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},JH=()=>zN(GH),YH=()=>{let e=zN(KH);if(!e)throw Error(`useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},XH=()=>{let e=qH();return FN(e.subscribe,e.getTriggers,e.getTriggers)},ZH=new Map,QH=()=>()=>{},$H=()=>ZH,eU=()=>{let e=JH();return FN(e?e.subscribe:QH,e?e.getTriggers:$H,e?e.getTriggers:$H)},tU=()=>null,nU=()=>{let e=JH();return FN(e?e.subscribeAria:QH,e?e.getActiveAria:tU,e?e.getActiveAria:tU)};function rU(){let e=Z(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new Set,e[0]=t):t=e[0];let n=kN(t),r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{for(let e of n.current)e()},e[1]=r):r=e[1];let i=r,a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n.current.add(e),()=>{n.current.delete(e)}),e[2]=a):a=e[2];let o=a,s;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s={notify:i,subscribe:o},e[3]=s):s=e[3],s}var iU=e=>{let t=Z(21),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=kN(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,t[1]=a):a=t[1];let o=kN(a),{notify:s,subscribe:c}=rU(),l;t[2]===s?l=t[3]:(l=e=>{let{char:t}=e;if(i.current.has(t))return oU;let n=new Map(i.current);n.set(t,e),i.current=n,s();for(let t of o.current)t.added(e);return()=>{let e=new Map(i.current);e.delete(t),i.current=e,s();for(let e of o.current)e.removed(t)}},t[2]=s,t[3]=l);let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>i.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>(o.current.add(e),()=>{o.current.delete(e)}),t[5]=p):p=t[5];let m=p,h=kN(null),g=kN(null),{notify:_,subscribe:v}=rU(),y;t[6]===_?y=t[7]:(y=(e,t)=>{if(t===null){if(g.current!==e)return;h.current=null,g.current=null,_();return}let n=h.current;g.current===e&&n!==null&&n.popoverId===t.popoverId&&n.highlightedItemId===t.highlightedItemId||(h.current=t,g.current=e,_())},t[6]=_,t[7]=y);let b=y,x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>h.current,t[8]=x):x=t[8];let S=x,C;t[9]!==u||t[10]!==c||t[11]!==v?(C={register:u,getTriggers:f,subscribe:c,subscribeLifecycle:m,getActiveAria:S,subscribeAria:v},t[9]=u,t[10]=c,t[11]=v,t[12]=C):C=t[12];let w=C,T;t[13]===b?T=t[14]:(T={setActiveAria:b},t[13]=b,t[14]=T);let E=T,D;t[15]!==E||t[16]!==n?(D=(0,J.jsx)(KH.Provider,{value:E,children:n}),t[15]=E,t[16]=n,t[17]=D):D=t[17];let O;return t[18]!==D||t[19]!==w?(O=(0,J.jsx)(GH.Provider,{value:w,children:D}),t[18]=D,t[19]=w,t[20]=O):O=t[20],O},aU=e=>{let t=Z(4),{children:n}=e;if(VH()){let e;return t[0]===n?e=t[1]:(e=(0,J.jsx)(iU,{children:n}),t[0]=n,t[1]=e),e}let r;return t[2]===n?r=t[3]:(r=(0,J.jsx)(HH,{children:(0,J.jsx)(iU,{children:n})}),t[2]=n,t[3]=r),r};aU.displayName=`ComposerPrimitive.TriggerPopoverRoot`;function oU(){}var sU=/\s/u;function cU(e,t,n){let r=e.slice(0,n);for(let e=r.length-1;e>=0;e--){let n=r[e];if(sU.test(n))return null;if(r.startsWith(t,e)){if(e>0&&!sU.test(r[e-1]))continue;return{query:r.slice(e+t.length),offset:e}}}return null}var lU=UN(e=>{let t=Z(7),{text:n,triggerChar:r}=e,[i,a]=DN(n.length),o=Math.min(i,n.length),s;t[0]!==o||t[1]!==n||t[2]!==r?(s=cU(n,r,o),t[0]=o,t[1]=n,t[2]=r,t[3]=s):s=t[3];let c=s,l=c?.query??``,u;return t[4]!==l||t[5]!==c?(u={trigger:c,query:l,setCursorPosition:a},t[4]=l,t[5]=c,t[6]=u):u=t[6],u});function uU(e){return`type`in e}var dU=UN(e=>{let t=Z(25),{navigableList:n,isSearchMode:r,activeCategoryId:i,query:a,popoverId:o,open:s,selectItem:c,selectCategory:l,goBack:u,close:d}=e,[f,p]=DN(0),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{p(0)},t[0]=m):m=t[0];let h;t[1]===n?h=t[2]:(h=[n],t[1]=n,t[2]=h),MN(m,h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{p(0)},t[3]=g):g=t[3];let _;t[4]!==i||t[5]!==r?(_=[r,i],t[4]=i,t[5]=r,t[6]=_):_=t[6],MN(g,_);let v;t[7]!==f||t[8]!==n.length?(v=e=>{e<0||e>=n.length||e!==f&&p(e)},t[7]=f,t[8]=n.length,t[9]=v):v=t[9];let y=PN(v),b;t[10]!==i||t[11]!==d||t[12]!==u||t[13]!==f||t[14]!==n||t[15]!==s||t[16]!==a||t[17]!==l||t[18]!==c?(b=e=>{if(!s)return!1;switch(e.key){case`ArrowDown`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e<t-1?e+1:0}),!0;case`ArrowUp`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e>0?e-1:t-1}),!0;case`Enter`:case`Tab`:{if(e.shiftKey)return!1;e.preventDefault();let t=n[f];return t&&(uU(t)?c(t):l(t.id)),!0}case`Escape`:return e.preventDefault(),d(),!0;case`Backspace`:return i&&a===``?(e.preventDefault(),u(),!0):!1;default:return!1}},t[10]=i,t[11]=d,t[12]=u,t[13]=f,t[14]=n,t[15]=s,t[16]=a,t[17]=l,t[18]=c,t[19]=b):b=t[19];let x=PN(b),S=n[f],C=s&&S?`${o}-option-${S.id}`:void 0,w;return t[20]!==x||t[21]!==y||t[22]!==f||t[23]!==C?(w={highlightedIndex:f,highlightedItemId:C,highlightIndex:y,handleKeyDown:x},t[20]=x,t[21]=y,t[22]=f,t[23]=C,t[24]=w):w=t[24],w});function fU(e,t){return e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||(e.description?.toLowerCase().includes(t)??!1)}var pU=UN(e=>{let t=Z(38),{adapter:n,query:r,open:i}=e,[a,o]=DN(null),s,c;t[0]===i?(s=t[1],c=t[2]):(s=()=>{i||o(null)},c=[i],t[0]=i,t[1]=s,t[2]=c),MN(s,c);let l;bb0:{if(!i||!n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[3]=e):e=t[3],l=e;break bb0}let e;t[4]===n?e=t[5]:(e=n.categories(),t[4]=n,t[5]=e),l=e}let u=l,d=i?a:null,f;bb1:{if(!d||!n){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[6]=e):e=t[6],f=e;break bb1}let e;t[7]!==n||t[8]!==d?(e=n.categoryItems(d),t[7]=n,t[8]=d,t[9]=e):e=t[9],f=e}let p=f,m;bb2:{if(!i||!n||d){m=null;break bb2}if(!r&&u.length>0){m=null;break bb2}if(n.search){let e;t[10]!==n||t[11]!==r?(e=n.search(r),t[10]=n,t[11]=r,t[12]=e):e=t[12],m=e;break bb2}let e;if(t[13]!==n||t[14]!==u||t[15]!==r){e=[];let i=r.toLowerCase();for(let t of u)for(let r of n.categoryItems(t.id))fU(r,i)&&e.push(r);t[13]=n,t[14]=u,t[15]=r,t[16]=e}else e=t[16];m=e}let h=m,g=h!==null,_;bb3:{if(g){let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[17]=e):e=t[17],_=e;break bb3}if(!r){_=u;break bb3}let e;if(t[18]!==u||t[19]!==r){let n=r.toLowerCase();e=u.filter(e=>e.label.toLowerCase().includes(n)),t[18]=u,t[19]=r,t[20]=e}else e=t[20];_=e}let v=_,y;bb4:{if(g){let e;t[21]===h?e=t[22]:(e=h??[],t[21]=h,t[22]=e),y=e;break bb4}if(!r){y=p;break bb4}let e;if(t[23]!==p||t[24]!==r){let n=r.toLowerCase();e=p.filter(e=>fU(e,n)),t[23]=p,t[24]=r,t[25]=e}else e=t[25];y=e}let b=y,x;bb5:{if(g){let e;t[26]===h?e=t[27]:(e=h??[],t[26]=h,t[27]=e),x=e;break bb5}if(d){x=b;break bb5}x=v}let S=x,C;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{o(e)},t[28]=C):C=t[28];let w=PN(C),T;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{o(null)},t[29]=T):T=t[29];let E=PN(T),D;return t[30]!==d||t[31]!==v||t[32]!==b||t[33]!==E||t[34]!==g||t[35]!==S||t[36]!==w?(D={categories:v,items:b,isSearchMode:g,activeCategoryId:d,navigableList:S,selectCategory:w,goBack:E},t[30]=d,t[31]=v,t[32]=b,t[33]=E,t[34]=g,t[35]=S,t[36]=w,t[37]=D):D=t[37],D}),mU=UN(e=>{let t=Z(15),{behavior:n,trigger:r,aui:i,triggerChar:a,setCursorPosition:o,onSelected:s}=e,c=kN(null),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=e=>(c.current=e,()=>{c.current===e&&(c.current=null)}),t[0]=l):l=t[0];let u=PN(l),d;t[1]!==i||t[2]!==n||t[3]!==s||t[4]!==r||t[5]!==a?(d=e=>{if(!r||!n)return;if(c.current?.(e)){s();return}let t=i.composer().getState().text,o=t.slice(0,r.offset),l=t.slice(r.offset+a.length+r.query.length),u=()=>{let t=n.formatter.serialize(e);i.composer().setText(o+t+(l.startsWith(` `)?l:` ${l}`))};n.kind===`directive`?(u(),n.onInserted?.(e)):(n.removeOnExecute?i.composer().setText(o+(l.startsWith(` `)?l.slice(1):l)):u(),n.onExecute(e)),s()},t[1]=i,t[2]=n,t[3]=s,t[4]=r,t[5]=a,t[6]=d):d=t[6];let f=PN(d),p;t[7]!==s||t[8]!==o||t[9]!==r?(p=()=>{s(),r&&o(r.offset)},t[7]=s,t[8]=o,t[9]=r,t[10]=p):p=t[10];let m=PN(p),h;return t[11]!==m||t[12]!==u||t[13]!==f?(h={selectItem:f,close:m,registerSelectItemOverride:u},t[11]=m,t[12]=u,t[13]=f,t[14]=h):h=t[14],h}),hU=UN(e=>{let t=Z(46),{adapter:n,text:r,triggerChar:i,behavior:a,aui:o,popoverId:s,isLoading:c}=e,l;t[0]!==r||t[1]!==i?(l=lU({text:r,triggerChar:i}),t[0]=r,t[1]=i,t[2]=l):l=t[2];let u=aP(l),d=u.trigger!==null&&n!==void 0&&a!==void 0,f;t[3]!==n||t[4]!==u.query||t[5]!==d?(f=pU({adapter:n,query:u.query,open:d}),t[3]=n,t[4]=u.query,t[5]=d,t[6]=f):f=t[6];let p=aP(f),m;t[7]===p?m=t[8]:(m=()=>{p.goBack()},t[7]=p,t[8]=m);let h=PN(m),g;t[9]!==o||t[10]!==a||t[11]!==u.setCursorPosition||t[12]!==u.trigger||t[13]!==h||t[14]!==i?(g=mU({behavior:a,trigger:u.trigger,aui:o,triggerChar:i,setCursorPosition:u.setCursorPosition,onSelected:h}),t[9]=o,t[10]=a,t[11]=u.setCursorPosition,t[12]=u.trigger,t[13]=h,t[14]=i,t[15]=g):g=t[15];let _=aP(g),v;t[16]!==u.query||t[17]!==p.activeCategoryId||t[18]!==p.goBack||t[19]!==p.isSearchMode||t[20]!==p.navigableList||t[21]!==p.selectCategory||t[22]!==d||t[23]!==s||t[24]!==_.close||t[25]!==_.selectItem?(v=dU({navigableList:p.navigableList,isSearchMode:p.isSearchMode,activeCategoryId:p.activeCategoryId,query:u.query,popoverId:s,open:d,selectItem:_.selectItem,selectCategory:p.selectCategory,goBack:p.goBack,close:_.close}),t[16]=u.query,t[17]=p.activeCategoryId,t[18]=p.goBack,t[19]=p.isSearchMode,t[20]=p.navigableList,t[21]=p.selectCategory,t[22]=d,t[23]=s,t[24]=_.close,t[25]=_.selectItem,t[26]=v):v=t[26];let y=aP(v),b;return t[27]!==u.query||t[28]!==u.setCursorPosition||t[29]!==c||t[30]!==y.handleKeyDown||t[31]!==y.highlightIndex||t[32]!==y.highlightedIndex||t[33]!==y.highlightedItemId||t[34]!==p.activeCategoryId||t[35]!==p.categories||t[36]!==p.goBack||t[37]!==p.isSearchMode||t[38]!==p.items||t[39]!==p.selectCategory||t[40]!==d||t[41]!==s||t[42]!==_.close||t[43]!==_.registerSelectItemOverride||t[44]!==_.selectItem?(b={open:d,query:u.query,activeCategoryId:p.activeCategoryId,categories:p.categories,items:p.items,highlightedIndex:y.highlightedIndex,isSearchMode:p.isSearchMode,isLoading:c,popoverId:s,highlightedItemId:y.highlightedItemId,selectCategory:p.selectCategory,goBack:p.goBack,selectItem:_.selectItem,close:_.close,highlightIndex:y.highlightIndex,handleKeyDown:y.handleKeyDown,setCursorPosition:u.setCursorPosition,registerSelectItemOverride:_.registerSelectItemOverride},t[27]=u.query,t[28]=u.setCursorPosition,t[29]=c,t[30]=y.handleKeyDown,t[31]=y.highlightIndex,t[32]=y.highlightedIndex,t[33]=y.highlightedItemId,t[34]=p.activeCategoryId,t[35]=p.categories,t[36]=p.goBack,t[37]=p.isSearchMode,t[38]=p.items,t[39]=p.selectCategory,t[40]=d,t[41]=s,t[42]=_.close,t[43]=_.registerSelectItemOverride,t[44]=_.selectItem,t[45]=b):b=t[45],b}),gU=LN(null),_U=()=>{let e=zN(gU);if(!e)throw Error(`useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover`);return e},vU=()=>zN(gU),yU=LN(null),bU=()=>{let e=zN(yU);if(!e)throw Error(`TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover`);return e},xU=(0,X.forwardRef)((e,t)=>{let n=Z(61),r,i,a,o,s,c;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6]):({char:a,adapter:r,isLoading:c,"aria-label":i,children:o,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c);let l=c!==void 0&&c,u=aF(),d=Q(SU),f=(0,X.useId)(),p=kN(null),[m,h]=DN(null),g=kN(0),_;n[7]===a?_=n[8]:(_=e=>(g.current+=1,p.current=e,h(e),()=>{g.current=Math.max(0,g.current-1),p.current===e&&(p.current=null,h(null))}),n[7]=a,n[8]=_);let v=_,y;n[9]===v?y=n[10]:(y={register:v},n[9]=v,n[10]=y);let b=y,x=m??void 0,S;n[11]!==r||n[12]!==u||n[13]!==a||n[14]!==l||n[15]!==f||n[16]!==x||n[17]!==d?(S=hU({adapter:r,text:d,triggerChar:a,behavior:x,aui:u,popoverId:f,isLoading:l}),n[11]=r,n[12]=u,n[13]=a,n[14]=l,n[15]=f,n[16]=x,n[17]=d,n[18]=S):S=n[18];let C=aP(S),w;n[19]===C?w=n[20]:(w=()=>C,n[19]=C,n[20]=w);let T=PN(w),E=qH(),D;n[21]!==m||n[22]!==a||n[23]!==T||n[24]!==E?(D=()=>E.register({char:a,...m?{behavior:m}:{},resource:T()}),n[21]=m,n[22]=a,n[23]=T,n[24]=E,n[25]=D):D=n[25];let O;n[26]!==m||n[27]!==a||n[28]!==E?(O=[E,a,m],n[26]=m,n[27]=a,n[28]=E,n[29]=O):O=n[29],MN(D,O);let k=VH(),A;n[30]!==T||n[31]!==k?(A=()=>{if(k)return k.register(T())},n[30]=T,n[31]=k,n[32]=A):A=n[32];let j;n[33]===k?j=n[34]:(j=[k],n[33]=k,n[34]=j),MN(A,j);let M=m!==null&&C.open,N=YH(),P,F;n[35]!==N||n[36]!==a||n[37]!==M?(P=()=>{if(M)return()=>{N.setActiveAria(a,null)}},F=[N,a,M],n[35]=N,n[36]=a,n[37]=M,n[38]=P,n[39]=F):(P=n[38],F=n[39]),MN(P,F);let I,L;n[40]!==N||n[41]!==a||n[42]!==M||n[43]!==f||n[44]!==C.highlightedItemId?(I=()=>{M&&N.setActiveAria(a,{popoverId:f,highlightedItemId:C.highlightedItemId})},L=[N,a,f,M,C.highlightedItemId],n[40]=N,n[41]=a,n[42]=M,n[43]=f,n[44]=C.highlightedItemId,n[45]=I,n[46]=L):(I=n[45],L=n[46]),MN(I,L);let R;n[47]!==i||n[48]!==o||n[49]!==t||n[50]!==M||n[51]!==f||n[52]!==s||n[53]!==C.highlightedItemId?(R=M?(0,J.jsx)(KV.div,{role:`listbox`,id:f,"aria-label":i??`Suggestions`,"aria-activedescendant":C.highlightedItemId,"data-state":`open`,...s,ref:t,children:o}):o,n[47]=i,n[48]=o,n[49]=t,n[50]=M,n[51]=f,n[52]=s,n[53]=C.highlightedItemId,n[54]=R):R=n[54];let z;n[55]!==C||n[56]!==R?(z=(0,J.jsx)(gU.Provider,{value:C,children:R}),n[55]=C,n[56]=R,n[57]=z):z=n[57];let B;return n[58]!==b||n[59]!==z?(B=(0,J.jsx)(yU.Provider,{value:b,children:z}),n[58]=b,n[59]=z,n[60]=B):B=n[60],B});xU.displayName=`ComposerPrimitive.TriggerPopover`;function SU(e){return e.composer.text}var CU=()=>{let e=Z(2),{disabled:t,send:n}=LB(),r;return e[0]===n?r=e[1]:(r=()=>n(),e[0]=n,e[1]=r),t?null:r},wU=rH(`ComposerPrimitive.Send`,CU),TU=(0,X.forwardRef)((e,t)=>{let n=Z(12),r,i;n[0]===e?(r=n[1],i=n[2]):({onSubmit:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=CU(),o;n[3]===a?o=n[4]:(o=e=>{e.preventDefault(),a&&a()},n[3]=a,n[4]=o);let s=o,c;n[5]!==s||n[6]!==r?(c=$b(r,s),n[5]=s,n[6]=r,n[7]=c):c=n[7];let l;return n[8]!==t||n[9]!==i||n[10]!==c?(l=(0,J.jsx)(KV.form,{...i,ref:t,onSubmit:c}),n[8]=t,n[9]=i,n[10]=c,n[11]=l):l=n[11],l});TU.displayName=`ComposerPrimitive.Root`;var EU=e=>{let t=Z(4),n=Gf(e),r=xV(DU),i,a;t[0]!==n||t[1]!==r?(i=()=>r(n),a=[r,n],t[0]=n,t[1]=r,t[2]=i,t[3]=a):(i=t[2],a=t[3]),MN(i,a)};function DU(e){return e.onScrollToBottom}var OU=()=>!1,kU=()=>{},AU=e=>{let t=Z(4),n;t[0]===e?n=t[1]:(n=t=>{if(typeof window>`u`||e===null)return kU;let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},t[0]=e,t[1]=n);let r=n,i;return t[2]===e?i=t[3]:(i=()=>typeof window>`u`||e===null?!1:window.matchMedia(e).matches,t[2]=e,t[3]=i),FN(r,i,OU)};function jU(){return jU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},jU.apply(null,arguments)}function MU(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var NU=q.useLayoutEffect,PU=function(e){var t=q.useRef(e);return NU(function(){t.current=e}),t},FU=function(e,t){if(typeof e==`function`){e(t);return}e.current=t},IU=function(e,t){var n=q.useRef();return q.useCallback(function(r){e.current=r,n.current&&FU(n.current,null),n.current=t,t&&FU(t,r)},[t])},LU={"min-height":`0`,"max-height":`none`,height:`0`,visibility:`hidden`,overflow:`hidden`,position:`absolute`,"z-index":`-1000`,top:`0`,right:`0`,display:`block`},RU=function(e){Object.keys(LU).forEach(function(t){e.style.setProperty(t,LU[t],`important`)})},zU=null,BU=function(e,t){var n=e.scrollHeight;return t.sizingStyle.boxSizing===`border-box`?n+t.borderSize:n-t.paddingSize};function VU(e,t,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),zU||(zU=document.createElement(`textarea`),zU.setAttribute(`tabindex`,`-1`),zU.setAttribute(`aria-hidden`,`true`),RU(zU)),zU.parentNode===null&&document.body.appendChild(zU);var i=e.paddingSize,a=e.borderSize,o=e.sizingStyle,s=o.boxSizing;Object.keys(o).forEach(function(e){var t=e;zU.style[t]=o[t]}),RU(zU),zU.value=t;var c=BU(zU,e);zU.value=t,c=BU(zU,e),zU.value=`x`;var l=zU.scrollHeight-i,u=l*n;s===`border-box`&&(u=u+i+a),c=Math.max(u,c);var d=l*r;return s===`border-box`&&(d=d+i+a),c=Math.min(d,c),[c,l]}var HU=function(){},UU=function(e,t){return e.reduce(function(e,n){return e[n]=t[n],e},{})},WU=[`borderBottomWidth`,`borderLeftWidth`,`borderRightWidth`,`borderTopWidth`,`boxSizing`,`fontFamily`,`fontSize`,`fontStyle`,`fontWeight`,`letterSpacing`,`lineHeight`,`paddingBottom`,`paddingLeft`,`paddingRight`,`paddingTop`,`tabSize`,`textIndent`,`textRendering`,`textTransform`,`width`,`wordBreak`,`wordSpacing`,`scrollbarGutter`],GU=!!document.documentElement.currentStyle,KU=function(e){var t=window.getComputedStyle(e);if(t===null)return null;var n=UU(WU,t),r=n.boxSizing;return r===``?null:(GU&&r===`border-box`&&(n.width=parseFloat(n.width)+parseFloat(n.borderRightWidth)+parseFloat(n.borderLeftWidth)+parseFloat(n.paddingRight)+parseFloat(n.paddingLeft)+`px`),{sizingStyle:n,paddingSize:parseFloat(n.paddingBottom)+parseFloat(n.paddingTop),borderSize:parseFloat(n.borderBottomWidth)+parseFloat(n.borderTopWidth)})};function qU(e,t,n){var r=PU(n);q.useLayoutEffect(function(){var n=function(e){return r.current(e)};if(e)return e.addEventListener(t,n),function(){return e.removeEventListener(t,n)}},[])}var JU=function(e,t){qU(document.body,`reset`,function(n){e.current.form===n.target&&t(n)})},YU=function(e){qU(window,`resize`,e)},XU=function(e){qU(document.fonts,`loadingdone`,e)},ZU=[`cacheMeasurements`,`maxRows`,`minRows`,`onChange`,`onHeightChange`],QU=q.forwardRef(function(e,t){var n=e.cacheMeasurements,r=e.maxRows,i=e.minRows,a=e.onChange,o=a===void 0?HU:a,s=e.onHeightChange,c=s===void 0?HU:s,l=MU(e,ZU),u=l.value!==void 0,d=q.useRef(null),f=IU(d,t),p=q.useRef(0),m=q.useRef(),h=function(){var e=d.current,t=n&&m.current?m.current:KU(e);if(t){m.current=t;var a=VU(t,e.value||e.placeholder||`x`,i,r),o=a[0],s=a[1];p.current!==o&&(p.current=o,e.style.setProperty(`height`,o+`px`,`important`),c(o,{rowHeight:s}))}};return q.useLayoutEffect(h),JU(d,function(){if(!u){var e=d.current.value;requestAnimationFrame(function(){var t=d.current;t&&e!==t.value&&h()})}}),YU(h),XU(h),q.createElement(`textarea`,jU({},l,{onChange:function(e){u||h(),o(e)},ref:f}))}),$U=`(pointer: coarse) and (not (any-pointer: fine))`,eW=(0,X.forwardRef)(({autoFocus:e=!1,asChild:t,render:n,disabled:r,onChange:i,onKeyDown:a,onPaste:o,onSelect:s,submitOnEnter:c,submitMode:l,cancelOnEscape:u=!0,unstable_focusOnRunStart:d=!0,unstable_focusOnScrollToBottom:f=!0,unstable_focusOnThreadSwitched:p=!0,unstable_insertNewlineOnTouchEnter:m=!1,addAttachmentOnPaste:h=!0,...g},_)=>{let v=aF(),y=VH(),b=nU(),x=l??(c===!1?`none`:`enter`),S=AU(m?$U:null),C=m&&S&&x===`enter`?`none`:x,w=Q(e=>e.composer.isEditing?e.composer.text:``),T=Q(e=>e.thread.isDisabled||e.composer.dictation?.inputDisabled)||r,E=kN(null),D=So(_,E),O=kN(!1);tx(e=>{if(!E.current?.contains(e.target))return;if(y){for(let t of y.getPlugins())if(t.handleKeyDown(e))return}if(!u)return;let t=v.composer();t.getState().canCancel&&(t.cancel(),e.preventDefault())});let k=e=>{if(!T&&!e.nativeEvent.isComposing){if(y){for(let t of y.getPlugins())if(t.handleKeyDown(e))return}if(e.key===`Enter`){let t=v.thread().getState(),n=t.capabilities.queue;if(e.shiftKey&&(e.ctrlKey||e.metaKey)&&n&&x!==`none`&&v.composer().getState().canSend){e.preventDefault(),v.composer().send({steer:!0});return}if(e.shiftKey||t.isRunning&&!n)return;let r=!1;C===`ctrlEnter`?r=e.ctrlKey||e.metaKey:C===`enter`&&(r=!0),r&&(e.preventDefault(),E.current?.closest(`form`)?.requestSubmit())}}},A=async e=>{if(!h)return;let t=v.thread().getState().capabilities,n=Array.from(e.clipboardData?.files||[]);if(t.attachments&&n.length>0)try{e.preventDefault(),await Promise.all(n.map(e=>v.composer().addAttachment(e)))}catch(e){console.error(`Error adding attachment:`,e)}},j=e&&!T,M=jN(()=>{let e=E.current;!e||!j||(e.focus({preventScroll:!0}),e.setSelectionRange(e.value.length,e.value.length))},[j]);MN(()=>M(),[M]),EU(()=>{v.composer().getState().type===`thread`&&f&&M()}),MN(()=>{if(!(v.composer().getState().type!==`thread`||!d))return v.on(`thread.runStart`,M)},[d,M,v]),MN(()=>{if(!(v.composer().getState().type!==`thread`||!p))return v.on(`threadListItem.switchedTo`,M)},[p,M,v]);let N=b?{"aria-controls":b.popoverId,"aria-expanded":!0,"aria-haspopup":`listbox`,"aria-activedescendant":b.highlightedItemId}:{},P={name:`input`,value:w,...g,...N,ref:D,disabled:T,onChange:$b(i,e=>{if(!v.composer().getState().isEditing)return;let t=e.nativeEvent.isComposing===!0;O.current&&!t&&(O.current=!1);let n=t||O.current;if(qN(()=>{v.composer().setText(e.target.value)}),n)return;let r=e.target.selectionStart??e.target.value.length;if(y)for(let e of y.getPlugins())e.setCursorPosition(r)}),onKeyDown:$b(a,k),onCompositionStart:$b(g.onCompositionStart,()=>{O.current=!0}),onCompositionEnd:$b(g.onCompositionEnd,e=>{if(O.current=!1,!v.composer().getState().isEditing)return;let t=e.target;qN(()=>{v.composer().setText(t.value)});let n=t.selectionStart??t.value.length;if(y)for(let e of y.getPlugins())e.setCursorPosition(n)}),onSelect:$b(s,e=>{if(O.current)return;let t=e.target,n=t.selectionStart??t.value.length;if(y)for(let e of y.getPlugins())e.setCursorPosition(n)}),onPaste:$b(o,A)};if(n&&(0,X.isValidElement)(n)){let e=g.children===void 0?n.props.children:g.children;return(0,J.jsx)(Hb,{...P,children:(0,X.cloneElement)(n,void 0,e)})}return(0,J.jsx)(t?Hb:QU,{...P})});eW.displayName=`ComposerPrimitive.Input`;var tW=rH(`ComposerPrimitive.Cancel`,()=>{let{disabled:e,cancel:t}=zB();return e?null:t}),nW=rH(`ComposerPrimitive.AddAttachment`,e=>{let t=Z(6),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{multiple:r}=n,i=r===void 0||r,{disabled:a,addAttachment:o}=UB(),s=aF(),c;return t[2]!==o||t[3]!==s||t[4]!==i?(c=()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=i,e.hidden=!0;let t=s.composer().getState().attachmentAccept;t!==`*`&&(e.accept=t),document.body.appendChild(e),e.onchange=t=>{let n=t.target.files;if(n){for(let e of n)o(e);document.body.removeChild(e)}},e.oncancel=()=>{(!e.files||e.files.length===0)&&document.body.removeChild(e)},e.click()},t[2]=o,t[3]=s,t[4]=i,t[5]=c):c=t[5],a?null:c},[`multiple`]),rW=(0,X.forwardRef)((e,t)=>{let n=Z(30),{disabled:r,asChild:i,render:a,children:o,...s}=e,c=i!==void 0&&i,[l,u]=DN(!1),d=aF(),f;n[0]===r?f=n[1]:(f=e=>{r||(e.preventDefault(),u(!0))},n[0]=r,n[1]=f);let p=f,m;n[2]!==r||n[3]!==l?(m=e=>{r||(e.preventDefault(),l||u(!0))},n[2]=r,n[3]=l,n[4]=m):m=n[4];let h=m,g;n[5]===r?g=n[6]:(g=e=>{if(r)return;e.preventDefault();let t=e.relatedTarget;t&&e.currentTarget.contains(t)||u(!1)},n[5]=r,n[6]=g);let _=g,v;n[7]!==d||n[8]!==r?(v=async e=>{if(r)return;e.preventDefault(),u(!1);let t=Array.from(e.dataTransfer.files);await Promise.all(t.map(async e=>{try{await d.composer().addAttachment(e)}catch(e){console.error(`Failed to add attachment:`,e)}}))},n[7]=d,n[8]=r,n[9]=v):v=n[9];let y=v,b;n[10]===l?b=n[11]:(b=l?{"data-dragging":`true`}:null,n[10]=l,n[11]=b);let x=$b(s.onDragEnterCapture,p),S=$b(s.onDragOverCapture,h),C=$b(s.onDragLeaveCapture,_),w=$b(s.onDropCapture,y),T;n[12]!==t||n[13]!==s||n[14]!==w||n[15]!==b||n[16]!==x||n[17]!==S||n[18]!==C?(T={...b,...s,onDragEnterCapture:x,onDragOverCapture:S,onDragLeaveCapture:C,onDropCapture:w,ref:t},n[12]=t,n[13]=s,n[14]=w,n[15]=b,n[16]=x,n[17]=S,n[18]=C,n[19]=T):T=n[19];let E=T;if(a&&(0,X.isValidElement)(a)){let e=o===void 0?a.props.children:o,t;n[20]!==a||n[21]!==e?(t=(0,X.cloneElement)(a,void 0,e),n[20]=a,n[21]=e,n[22]=t):t=n[22];let r;return n[23]!==E||n[24]!==t?(r=(0,J.jsx)(Hb,{...E,children:t}),n[23]=E,n[24]=t,n[25]=r):r=n[25],r}let D=c?Hb:`div`,O;return n[26]!==D||n[27]!==o||n[28]!==E?(O=(0,J.jsx)(D,{...E,children:o}),n[26]=D,n[27]=o,n[28]=E,n[29]=O):O=n[29],O});rW.displayName=`ComposerPrimitive.AttachmentDropzone`;var iW=rH(`ComposerPrimitive.Dictate`,()=>{let{disabled:e,startDictation:t}=VB();return e?null:t}),aW=rH(`ComposerPrimitive.StopDictation`,()=>{let e=Z(2),t=aF(),n=Q(oW),r;return e[0]===t?r=e[1]:(r=()=>{t.composer().stopDictation()},e[0]=t,e[1]=r),n?r:null});function oW(e){return e.composer.dictation!=null}var sW=(0,X.forwardRef)((e,t)=>{let n=Z(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=Q(cW);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,J.jsx)(KV.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});sW.displayName=`ComposerPrimitive.DictationTranscript`;function cW(e){return e.composer.dictation?.transcript}var lW=(0,X.forwardRef)((e,t)=>{let n=Z(3);if(!Q(fW))return null;let r;return n[0]!==t||n[1]!==e?(r=(0,J.jsx)(KV.div,{...e,ref:t}),n[0]=t,n[1]=e,n[2]=r):r=n[2],r});lW.displayName=`ComposerPrimitive.Quote`;var uW=(0,X.forwardRef)((e,t)=>{let n=Z(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=Q(pW);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,J.jsx)(KV.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});uW.displayName=`ComposerPrimitive.QuoteText`;var dW=(0,X.forwardRef)((e,t)=>{let n=Z(12),r,i;n[0]===e?(r=n[1],i=n[2]):({onClick:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=aF(),o;n[3]===a?o=n[4]:(o=()=>{a.composer().setQuote(void 0)},n[3]=a,n[4]=o);let s=o,c;n[5]!==s||n[6]!==r?(c=$b(r,s),n[5]=s,n[6]=r,n[7]=c):c=n[7];let l;return n[8]!==t||n[9]!==i||n[10]!==c?(l=(0,J.jsx)(KV.button,{type:`button`,...i,ref:t,onClick:c}),n[8]=t,n[9]=i,n[10]=c,n[11]=l):l=n[11],l});dW.displayName=`ComposerPrimitive.QuoteDismiss`;function fW(e){return e.composer.quote}function pW(e){return e.composer.quote?.text}var mW=(0,X.forwardRef)((e,t)=>{let n=Z(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({children:i,"aria-label":r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{categories:o,activeCategoryId:s,isSearchMode:c,open:l}=_U();if(!l||s||c)return null;let u=r??`Categories`,d;n[4]!==o||n[5]!==i?(d=i(o),n[4]=o,n[5]=i,n[6]=d):d=n[6];let f;return n[7]!==t||n[8]!==a||n[9]!==u||n[10]!==d?(f=(0,J.jsx)(KV.div,{role:`group`,"aria-label":u,...a,ref:t,children:d}),n[7]=t,n[8]=a,n[9]=u,n[10]=d,n[11]=f):f=n[11],f});mW.displayName=`ComposerPrimitive.TriggerPopoverCategories`;var hW=(0,X.forwardRef)((e,t)=>{let n=Z(30),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({categoryId:r,onClick:i,onMouseMove:a,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let{selectCategory:s,highlightIndex:c,categories:l,highlightedIndex:u,activeCategoryId:d,isSearchMode:f,popoverId:p}=_U(),m;n[5]!==r||n[6]!==s?(m=()=>{s(r)},n[5]=r,n[6]=s,n[7]=m):m=n[7];let h=m,g;if(n[8]!==l||n[9]!==r){let e;n[11]===r?e=n[12]:(e=e=>e.id===r,n[11]=r,n[12]=e),g=l.findIndex(e),n[8]=l,n[9]=r,n[10]=g}else g=n[10];let _=g,v=!d&&!f&&_===u,y;n[13]!==_||n[14]!==c?(y=()=>{c(_)},n[13]=_,n[14]=c,n[15]=y):y=n[15];let b=y,x=`${p}-option-${r}`,S=v?``:void 0,C;n[16]!==h||n[17]!==i?(C=$b(i,h),n[16]=h,n[17]=i,n[18]=C):C=n[18];let w;n[19]!==b||n[20]!==a?(w=$b(a,b),n[19]=b,n[20]=a,n[21]=w):w=n[21];let T;return n[22]!==t||n[23]!==v||n[24]!==o||n[25]!==x||n[26]!==S||n[27]!==C||n[28]!==w?(T=(0,J.jsx)(KV.button,{type:`button`,role:`option`,id:x,"aria-selected":v,"data-highlighted":S,...o,ref:t,onClick:C,onMouseMove:w}),n[22]=t,n[23]=v,n[24]=o,n[25]=x,n[26]=S,n[27]=C,n[28]=w,n[29]=T):T=n[29],T});hW.displayName=`ComposerPrimitive.TriggerPopoverCategoryItem`;var gW=(0,X.forwardRef)((e,t)=>{let n=Z(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({children:i,"aria-label":r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{items:o,activeCategoryId:s,isSearchMode:c,open:l}=_U();if(!l||!s&&!c)return null;let u=r??`Items`,d;n[4]!==i||n[5]!==o?(d=i(o),n[4]=i,n[5]=o,n[6]=d):d=n[6];let f;return n[7]!==t||n[8]!==a||n[9]!==u||n[10]!==d?(f=(0,J.jsx)(KV.div,{role:`group`,"aria-label":u,...a,ref:t,children:d}),n[7]=t,n[8]=a,n[9]=u,n[10]=d,n[11]=f):f=n[11],f});gW.displayName=`ComposerPrimitive.TriggerPopoverItems`;var _W=(0,X.forwardRef)((e,t)=>{let n=Z(30),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({item:i,index:r,onClick:a,onMouseMove:o,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let{selectItem:c,highlightIndex:l,items:u,highlightedIndex:d,activeCategoryId:f,isSearchMode:p,popoverId:m}=_U(),h;n[6]!==i||n[7]!==c?(h=()=>{c(i)},n[6]=i,n[7]=c,n[8]=h):h=n[8];let g=h,_;n[9]!==r||n[10]!==i.id||n[11]!==u?(_=r??u.findIndex(e=>e.id===i.id),n[9]=r,n[10]=i.id,n[11]=u,n[12]=_):_=n[12];let v=_,y=(p||f!==null)&&v===d,b;n[13]!==l||n[14]!==v?(b=()=>{l(v)},n[13]=l,n[14]=v,n[15]=b):b=n[15];let x=b,S=`${m}-option-${i.id}`,C=y?``:void 0,w;n[16]!==g||n[17]!==a?(w=$b(a,g),n[16]=g,n[17]=a,n[18]=w):w=n[18];let T;n[19]!==x||n[20]!==o?(T=$b(o,x),n[19]=x,n[20]=o,n[21]=T):T=n[21];let E;return n[22]!==t||n[23]!==y||n[24]!==s||n[25]!==S||n[26]!==C||n[27]!==w||n[28]!==T?(E=(0,J.jsx)(KV.button,{type:`button`,role:`option`,id:S,"aria-selected":y,"data-highlighted":C,...s,ref:t,onClick:w,onMouseMove:T}),n[22]=t,n[23]=y,n[24]=s,n[25]=S,n[26]=C,n[27]=w,n[28]=T,n[29]=E):E=n[29],E});_W.displayName=`ComposerPrimitive.TriggerPopoverItem`;var vW=(0,X.forwardRef)((e,t)=>{let n=Z(10),r,i;n[0]===e?(r=n[1],i=n[2]):({onClick:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let{activeCategoryId:a,isSearchMode:o,goBack:s,open:c}=_U();if(!c||!a||o)return null;let l;n[3]!==s||n[4]!==r?(l=$b(r,s),n[3]=s,n[4]=r,n[5]=l):l=n[5];let u;return n[6]!==t||n[7]!==i||n[8]!==l?(u=(0,J.jsx)(KV.button,{type:`button`,...i,ref:t,onClick:l}),n[6]=t,n[7]=i,n[8]=l,n[9]=u):u=n[9],u});vW.displayName=`ComposerPrimitive.TriggerPopoverBack`;var yW=({formatter:e,onExecute:t,removeOnExecute:n})=>{let{register:r}=bU(),i=kN(t);return i.current=t,MN(()=>r({kind:`action`,formatter:e??_V,onExecute:e=>i.current(e),...n===void 0?{}:{removeOnExecute:n}}),[r,e,n]),null};yW.displayName=`ComposerPrimitive.TriggerPopoverAction`;var bW=({formatter:e,onInserted:t})=>{let{register:n}=bU(),r=kN(t);return r.current=t,MN(()=>n({kind:`directive`,formatter:e??_V,onInserted:e=>r.current?.(e)}),[n,e]),null};bW.displayName=`ComposerPrimitive.TriggerPopoverDirective`;var xW=Object.assign(xU,{Directive:bW,Action:yW}),SW=HV({AddAttachment:()=>nW,AttachmentByIndex:()=>CB,AttachmentDropzone:()=>rW,Attachments:()=>TB,Cancel:()=>tW,Dictate:()=>iW,DictationTranscript:()=>sW,If:()=>IB,Input:()=>eW,Queue:()=>DB,Quote:()=>lW,QuoteDismiss:()=>dW,QuoteText:()=>uW,Root:()=>TU,Send:()=>wU,StopDictation:()=>aW,Unstable_TriggerPopover:()=>xW,Unstable_TriggerPopoverBack:()=>vW,Unstable_TriggerPopoverCategories:()=>mW,Unstable_TriggerPopoverCategoryItem:()=>hW,Unstable_TriggerPopoverItem:()=>_W,Unstable_TriggerPopoverItems:()=>gW,Unstable_TriggerPopoverRoot:()=>aU,unstable_useTriggerPopoverRootContext:()=>qH,unstable_useTriggerPopoverRootContextOptional:()=>JH,unstable_useTriggerPopoverScopeContext:()=>_U,unstable_useTriggerPopoverScopeContextOptional:()=>vU,unstable_useTriggerPopoverTriggers:()=>XH,unstable_useTriggerPopoverTriggersOptional:()=>eU}),CW=()=>Q(wW);function wW(e){if(e.part.type!==`text`&&e.part.type!==`reasoning`)throw Error(`MessagePartText can only be used inside text or reasoning message parts.`);return e.part}var TW=LN(null);function EW(e){let t=zN(TW);if(!e?.optional&&!t)throw Error(`This component must be used within a SmoothContextProvider.`);return t}var{useSmoothStatus:vre,useSmoothStatusStore:DW}=yV(EW,`useSmoothStatus`),OW=250,kW=5,AW=class{currentText;setText;animationFrameId=null;lastUpdateTime=Date.now();lastCommitTime=0;targetText=``;drainMs=OW;maxCharIntervalMs=kW;maxCharsPerFrame=1/0;minCommitMs=0;constructor(e,t){this.currentText=e,this.setText=t}start(){this.animationFrameId===null&&(this.lastUpdateTime=Date.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}animate=()=>{let e=Date.now(),t=e-this.lastUpdateTime,n=this.targetText.length-this.currentText.length,r=Math.min(this.maxCharIntervalMs,this.drainMs/n),i=Math.min(n,this.maxCharsPerFrame),a=0;for(;t>=r&&a<i;)a++,t-=r;a===i&&i===this.maxCharsPerFrame&&(t=0),a===n?this.animationFrameId=null:this.animationFrameId=requestAnimationFrame(this.animate),a!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+a),this.lastUpdateTime=e-t,(a===n||e-this.lastCommitTime>=this.minCommitMs)&&(this.lastCommitTime=e,this.setText(this.currentText)))}},jW=Object.freeze({type:`running`}),MW=(e,t)=>e!==void 0&&e>0?e:t,NW=(e,t=!1)=>{let{text:n}=e,r=typeof t==`object`&&t?t:void 0,i=t!==!1&&t!==null,a=MW(r?.drainMs,OW),o=MW(r?.maxCharIntervalMs,kW),s=MW(r?.maxCharsPerFrame,1/0),c=MW(r?.minCommitMs,0),[l,u]=DN(e.status.type===`running`?``:n),d=aF(),f=Q(()=>d.part()),[p,m]=DN(f);(f!==p||!n.startsWith(l))&&(m(f),u(e.status.type===`running`?``:n));let h=DW({optional:!0}),g=Gf(t=>{if(u(t),h){let n=l!==t||e.status.type===`running`?jW:e.status;TV(h).setState(n,!0)}});MN(()=>{if(h){let t=i&&(l!==n||e.status.type===`running`)?jW:e.status;TV(h).setState(t,!0)}},[h,i,n,l,e.status]);let[_]=DN(new AW(l,g));MN(()=>{_.drainMs=a,_.maxCharIntervalMs=o,_.maxCharsPerFrame=s,_.minCommitMs=c},[_,a,o,s,c]);let v=kN(f);return MN(()=>{if(!i){_.stop();return}let t=v.current!==f;if(v.current=f,t||!n.startsWith(_.targetText)){e.status.type===`running`?(_.currentText=``,_.targetText=n,_.lastCommitTime=0,_.start()):(_.currentText=n,_.targetText=n,_.stop());return}_.targetText=n,_.start()},[_,i,n,e.status.type,f]),MN(()=>()=>{_.stop()},[_]),AN(()=>i?{...e,text:l,status:n===l?e.status:jW}:e,[i,l,e,n])},PW=()=>Q(FW);function FW(e){if(e.part.type!==`image`)throw Error(`MessagePartImage can only be used inside image message parts.`);return e.part}var IW=(0,X.forwardRef)((e,t)=>{let n=Z(10),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({smooth:i,component:a,...r}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i===void 0||i,s=a===void 0?`span`:a,{text:c,status:l}=NW(CW(),o),u;return n[4]!==s||n[5]!==t||n[6]!==r||n[7]!==l.type||n[8]!==c?(u=(0,J.jsx)(s,{"data-status":l.type,...r,ref:t,children:c}),n[4]=s,n[5]=t,n[6]=r,n[7]=l.type,n[8]=c,n[9]=u):u=n[9],u});IW.displayName=`MessagePartPrimitive.Text`;var LW=(0,X.forwardRef)((e,t)=>{let n=Z(4),{image:r}=PW(),i;return n[0]!==t||n[1]!==r||n[2]!==e?(i=(0,J.jsx)(KV.img,{src:r,...e,ref:t}),n[0]=t,n[1]=r,n[2]=e,n[3]=i):i=n[3],i});LW.displayName=`MessagePartPrimitive.Image`;var RW=e=>{let t=Z(2),n=kN(void 0),r;return t[0]===e?r=t[1]:(r=t=>{n.current&&=(n.current(),void 0),t&&(n.current=e(t))},t[0]=e,t[1]=r),r},zW=(e,t)=>{let n=e.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(em|px|rem)$/);if(!n)return 1/0;let r=Number(n[1]),i=n[2];return i===`px`?r:i===`em`?r*(parseFloat(getComputedStyle(t).fontSize)||16):i===`rem`?r*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16):1/0},BW=e=>e.dataset.messageId,VW=()=>{let e=document.createElement(`div`);return e.dataset.auiTopAnchorReserve=``,e.style.height=`0px`,e.style.flexShrink=`0`,e.style.pointerEvents=`none`,e.setAttribute(`aria-hidden`,`true`),e},HW=(e,t)=>{let n=`${t}px`;return e.style.height===n?!1:(e.style.height=n,!0)},UW=e=>{let t=window.devicePixelRatio||1;return Math.round(e*t)/t},WW=()=>{let e=Z(4),t=aF(),n;e[0]===t?n=e[1]:(n=()=>t.message(),e[0]=t,e[1]=n);let r=Q(n),i;return e[2]===r?i=e[3]:(i=e=>{let t=()=>{r.setIsHovering(!0)},n=()=>{r.setIsHovering(!1)};return e.addEventListener(`mouseenter`,t),e.addEventListener(`mouseleave`,n),e.matches(`:hover`)&&queueMicrotask(()=>r.setIsHovering(!0)),()=>{e.removeEventListener(`mouseenter`,t),e.removeEventListener(`mouseleave`,n),r.setIsHovering(!1)}},e[2]=r,e[3]=i),RW(i)},GW=()=>{let e=Z(2),t=xV(QW),n;return e[0]===t?n=e[1]:(n=e=>e.message.role===`user`&&e.message.index>0&&e.message.index===e.thread.messages.length-2&&e.thread.messages.at(-1)?.role===`assistant`&&(e.message.id===t||e.thread.isRunning),e[0]=t,e[1]=n),Q(n)},KW=()=>{let e=Z(2),t=xV($W),n;return e[0]===t?n=e[1]:(n=e=>e.message.isLast&&e.message.role===`assistant`&&e.message.index>=1&&e.thread.messages.at(e.message.index-1)?.role===`user`&&(e.message.id===t||e.thread.isRunning),e[0]=t,e[1]=n),Q(n)},qW=(e,t)=>{let n=Z(3),r;return n[0]!==e||n[1]!==t?(r=n=>{if(e)return t.getState().registerAnchorElement(n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],RW(r)},JW=e=>{let t=Z(3),{active:n,threadViewportStore:r}=e,i;return t[0]!==n||t[1]!==r?(i=e=>{if(!n)return;let t=r.getState(),i=t.topAnchorMessageClamp;return t.registerAnchorTargetElement(e,{tallerThan:zW(i.tallerThan,e),visibleHeight:zW(i.visibleHeight,e)})},t[0]=n,t[1]=r,t[2]=i):i=t[2],RW(i)},YW=e=>{let t=Z(7),n,r;t[0]===e?(n=t[1],r=t[2]):({forwardedRef:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=WW(),a=So(n,i),o=Q(eG),s;return t[3]!==o||t[4]!==r||t[5]!==a?(s=(0,J.jsx)(KV.div,{...r,ref:a,"data-message-id":o}),t[3]=o,t[4]=r,t[5]=a,t[6]=s):s=t[6],s},XW=e=>{let t=Z(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({forwardedRef:n,threadViewportStore:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=WW(),o=GW(),s=KW(),c=qW(o,i),l;t[4]!==s||t[5]!==i?(l={active:s,threadViewportStore:i},t[4]=s,t[5]=i,t[6]=l):l=t[6];let u=JW(l),d=So(n,a,c,u),f=Q(tG),p=o?``:void 0,m=s?``:void 0,h;return t[7]!==f||t[8]!==r||t[9]!==d||t[10]!==p||t[11]!==m?(h=(0,J.jsx)(KV.div,{...r,ref:d,"data-message-id":f,"data-aui-top-anchor-user":p,"data-aui-top-anchor-target":m}),t[7]=f,t[8]=r,t[9]=d,t[10]=p,t[11]=m,t[12]=h):h=t[12],h},ZW=(0,X.forwardRef)((e,t)=>{let n=Z(7),r=SV();if(r.getState().turnAnchor===`top`){let i;return n[0]!==t||n[1]!==e||n[2]!==r?(i=(0,J.jsx)(XW,{...e,forwardedRef:t,threadViewportStore:r}),n[0]=t,n[1]=e,n[2]=r,n[3]=i):i=n[3],i}let i;return n[4]!==t||n[5]!==e?(i=(0,J.jsx)(YW,{...e,forwardedRef:t}),n[4]=t,n[5]=e,n[6]=i):i=n[6],i});ZW.displayName=`MessagePrimitive.Root`;function QW(e){return e.topAnchorTurn?.anchorId}function $W(e){return e.topAnchorTurn?.targetId}function eG(e){return e.message.id}function tG(e){return e.message.id}var nG={...Dz,Text:()=>(0,J.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,J.jsx)(IW,{}),(0,J.jsx)(OB,{children:(0,J.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Image:()=>(0,J.jsx)(LW,{})},rG=e=>{let t=Z(10);if(`children`in e){let n;return t[0]===e.children?n=t[1]:(n=(0,J.jsx)(Uz,{children:e.children}),t[0]=e.children,t[1]=n),n}let n,r;t[2]===e?(n=t[3],r=t[4]):({components:n,...r}=e,t[2]=e,t[3]=n,t[4]=r);let i;t[5]===n?i=t[6]:(i=n?{Text:n.Text??nG.Text,Image:n.Image??nG.Image,Reasoning:n.Reasoning??Dz.Reasoning,Source:n.Source??Dz.Source,File:n.File??Dz.File,Unstable_Audio:n.Unstable_Audio??Dz.Unstable_Audio,...`ChainOfThought`in n?{ChainOfThought:n.ChainOfThought}:{tools:n.tools,data:n.data,ToolGroup:n.ToolGroup??Dz.ToolGroup,ReasoningGroup:n.ReasoningGroup??Dz.ReasoningGroup},Empty:n.Empty,Quote:n.Quote,generativeUI:n.generativeUI}:nG,t[5]=n,t[6]=i);let a=i,o;return t[7]!==r||t[8]!==a?(o=(0,J.jsx)(Uz,{components:a,...r}),t[7]=r,t[8]=a,t[9]=o):o=t[9],o};rG.displayName=`MessagePrimitive.Parts`;var iG=e=>{let{children:t}=e;return mV()===void 0?null:t};iG.displayName=`MessagePrimitive.Error`;var aG=e=>{let t=new Map;for(let n=0;n<e.length;n++){let r=e[n]?.parentId??`__ungrouped_${n}`,i=t.get(r)??[];i.push(n),t.set(r,i)}let n=[];for(let[e,r]of t){let t=e.startsWith(`__ungrouped_`)?void 0:e;n.push({groupKey:t,indices:r})}return n},oG=e=>{let t=Z(4),n=Q(_G),r;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],r=e;break bb0}let i;t[1]!==e||t[2]!==n?(i=e(n),t[1]=e,t[2]=n,t[3]=i):i=t[3],r=i}return r},sG=e=>{let t=Z(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.toolName?(i=e=>{let t=e.tools.tools[r.toolName]??n;return Array.isArray(t)?t[0]??n:t},t[3]=n,t[4]=r.toolName,t[5]=i):i=t[5];let a=Q(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,J.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},cG=e=>{let t=Z(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.name?(i=e=>{let t=e.dataRenderers.renderers[r.name]??n;return Array.isArray(t)?t[0]??n:t},t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=Q(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,J.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},lG={Text:()=>(0,J.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,J.jsx)(IW,{}),(0,J.jsx)(OB,{children:(0,J.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>(0,J.jsx)(LW,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:e})=>e},uG=e=>{let t=Z(43),{components:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?{}:n,t[0]=n,t[1]=r);let{Text:i,Reasoning:a,Image:o,Source:s,File:c,Unstable_Audio:l,tools:u,data:d}=r,f=i===void 0?lG.Text:i,p=a===void 0?lG.Reasoning:a,m=o===void 0?lG.Image:o,h=s===void 0?lG.Source:s,g=c===void 0?lG.File:c,_=l===void 0?lG.Unstable_Audio:l,v;t[2]===u?v=t[3]:(v=u===void 0?{}:u,t[2]=u,t[3]=v);let y=v,b=aF(),x=Q(vG),S=x.type;if(S===`tool-call`){let e;t[4]===b?e=t[5]:(e=b.part(),t[4]=b,t[5]=e);let n=e.addToolResult,r;t[6]===b?r=t[7]:(r=b.part(),t[6]=b,t[7]=r);let i=r.resumeToolCall,a;t[8]===b?a=t[9]:(a=b.part(),t[8]=b,t[9]=a);let o=a.respondToToolApproval;if(`Override`in y){let e;return t[10]!==n||t[11]!==x||t[12]!==o||t[13]!==i||t[14]!==y.Override?(e=(0,J.jsx)(y.Override,{...x,addResult:n,resume:i,respondToApproval:o}),t[10]=n,t[11]=x,t[12]=o,t[13]=i,t[14]=y.Override,t[15]=e):e=t[15],e}let s=y.by_name?.[x.toolName]??y.Fallback,c;return t[16]!==s||t[17]!==n||t[18]!==x||t[19]!==o||t[20]!==i?(c=(0,J.jsx)(sG,{...x,Fallback:s,addResult:n,resume:i,respondToApproval:o}),t[16]=s,t[17]=n,t[18]=x,t[19]=o,t[20]=i,t[21]=c):c=t[21],c}if(x.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(S){case`text`:{let e;return t[22]!==f||t[23]!==x?(e=(0,J.jsx)(f,{...x}),t[22]=f,t[23]=x,t[24]=e):e=t[24],e}case`reasoning`:{let e;return t[25]!==p||t[26]!==x?(e=(0,J.jsx)(p,{...x}),t[25]=p,t[26]=x,t[27]=e):e=t[27],e}case`source`:{let e;return t[28]!==h||t[29]!==x?(e=(0,J.jsx)(h,{...x}),t[28]=h,t[29]=x,t[30]=e):e=t[30],e}case`image`:{let e;return t[31]!==m||t[32]!==x?(e=(0,J.jsx)(m,{...x}),t[31]=m,t[32]=x,t[33]=e):e=t[33],e}case`file`:{let e;return t[34]!==g||t[35]!==x?(e=(0,J.jsx)(g,{...x}),t[34]=g,t[35]=x,t[36]=e):e=t[36],e}case`audio`:{let e;return t[37]!==_||t[38]!==x?(e=(0,J.jsx)(_,{...x}),t[37]=_,t[38]=x,t[39]=e):e=t[39],e}case`data`:{let e=d?.by_name?.[x.name]??d?.Fallback,n;return t[40]!==e||t[41]!==x?(n=(0,J.jsx)(cG,{...x,Fallback:e}),t[40]=e,t[41]=x,t[42]=n):n=t[42],n}default:return console.warn(`Unknown message part type: ${S}`),null}},dG=(0,X.memo)(e=>{let t=Z(5),{partIndex:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(uG,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(XI,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.partIndex===t.partIndex&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.Group===t.components?.Group),fG=e=>{let t=Z(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,J.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,J.jsx)(QI,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},pG=Object.freeze({type:`complete`}),mG=(0,X.memo)(e=>{let t=Z(6),{components:n}=e,r=Q(yG);if(n?.Empty){let e;return t[0]!==n.Empty||t[1]!==r?(e=(0,J.jsx)(n.Empty,{status:r}),t[0]=n.Empty,t[1]=r,t[2]=e):e=t[2],e}let i=n?.Text??lG.Text,a;return t[3]!==r||t[4]!==i?(a=(0,J.jsx)(fG,{status:r,component:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),hG=e=>{let t=Z(9),{groupingFunction:n,components:r}=e,i=Q(bG),a=oG(n),o;bb0:{if(i===0){let e;t[0]===r?e=t[1]:(e=(0,J.jsx)(mG,{components:r}),t[0]=r,t[1]=e),o=e;break bb0}let e;if(t[2]!==r||t[3]!==a){let n;t[5]===r?n=t[6]:(n=(e,t)=>(0,J.jsx)(r?.Group??lG.Group,{groupKey:e.groupKey,indices:e.indices,children:e.indices.map(e=>(0,J.jsx)(dG,{partIndex:e,components:r},e))},`group-${t}-${e.groupKey??`ungrouped`}`),t[5]=r,t[6]=n),e=a.map(n),t[2]=r,t[3]=a,t[4]=e}else e=t[4];o=e}let s=o,c;return t[7]===s?c=t[8]:(c=(0,J.jsx)(J.Fragment,{children:s}),t[7]=s,t[8]=c),c};hG.displayName=`MessagePrimitive.Unstable_PartsGrouped`;var gG=e=>{let t=Z(6),n,r;t[0]===e?(n=t[1],r=t[2]):({components:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,J.jsx)(hG,{...r,components:n,groupingFunction:aG}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i};gG.displayName=`MessagePrimitive.Unstable_PartsGroupedByParentId`;function _G(e){return e.message.parts}function vG(e){return e.part}function yG(e){return e.message.status??pG}function bG(e){return e.message.parts.length}var xG=HV({AttachmentByIndex:()=>_B,Attachments:()=>yB,Content:()=>rG,Error:()=>iG,GenerativeUI:()=>dz,GroupedParts:()=>pB,If:()=>zH,PartByIndex:()=>kz,Parts:()=>rG,Quote:()=>mB,Root:()=>ZW,Unstable_PartsGrouped:()=>hG,Unstable_PartsGroupedByParentId:()=>gG}),SG=e=>{let t=Z(2),n=Gf(e),r;return t[0]===n?r=t[1]:(r=e=>{let t=new ResizeObserver(()=>{n()}),r=new MutationObserver(e=>{e.some(CG)&&n()});return t.observe(e),r.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{t.disconnect(),r.disconnect()}},t[0]=n,t[1]=r),RW(r)};function CG(e){return e.type!==`attributes`||e.attributeName!==`style`}var wG=({autoScroll:e,scrollToBottomOnRunStart:t=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:r=!0})=>{let i=kN(null),a=Q(e=>e.thread.messages.length>0),o=kN(!1),s=kN(null),c=SV();e===void 0&&(e=c.getState().turnAnchor!==`top`);let l=kN(0),u=kN(0),d=kN(0),f=kN(0),p=kN(null),m=jN(e=>{let t=i.current;t&&(p.current=e,t.scrollTo({top:t.scrollHeight,behavior:e}))},[]),h=jN(e=>{p.current=e,s.current!==null&&cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{s.current=null,m(e)})},[m]);NN(()=>()=>{s.current!==null&&cancelAnimationFrame(s.current)},[]);let g=jN(()=>{let e=c.getState();return e.turnAnchor===`top`&&e.element.viewport===i.current&&e.element.anchor!==null},[c]),_=()=>{let e=i.current;if(!e)return;let t=c.getState().isAtBottom,n=Math.abs(e.scrollHeight-e.scrollTop-e.clientHeight)<=1||e.scrollHeight<=e.clientHeight;!n&&l.current<e.scrollTop||(n?e.scrollHeight>e.clientHeight+1&&(p.current=null):l.current>e.scrollTop&&u.current===e.scrollHeight&&(p.current=null),(n||p.current===null)&&n!==t&&TV(c).setState({isAtBottom:n})),l.current=e.scrollTop,u.current=e.scrollHeight},v=SG(()=>{let t=i.current;if(!t)return;let{scrollHeight:n,clientHeight:r}=t;if(n===d.current&&r===f.current)return;d.current=n,f.current=r;let a=p.current;a&&g()?p.current=null:a?m(a):e&&c.getState().isAtBottom&&m(`instant`),_()}),y=RW(e=>{let t=()=>{p.current=null};return e.addEventListener(`scroll`,_),e.addEventListener(`pointerdown`,t),()=>{e.removeEventListener(`scroll`,_),e.removeEventListener(`pointerdown`,t)}});return NN(()=>{if(n){if(!a){o.current=!1;return}o.current||(o.current=!0,p.current===null&&h(`instant`))}},[a,h,n]),EU(({behavior:e})=>{m(e)}),mF(`thread.runStart`,()=>{t&&c.getState().turnAnchor!==`top`&&h(`auto`)}),mF(`threadListItem.switchedTo`,()=>{r&&h(`instant`)}),So(v,y,i)},TG=(0,X.forwardRef)((e,t)=>{let n=Z(3),r;return n[0]!==e||n[1]!==t?(r=(0,J.jsx)(KV.div,{...e,ref:t}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});TG.displayName=`ThreadPrimitive.Root`;var EG=e=>{let{children:t}=e;return Q(DG)?t:null};EG.displayName=`ThreadPrimitive.Empty`;function DG(e){return e.thread.isEmpty}var OG=e=>{let t=Z(4),n;return t[0]!==e.disabled||t[1]!==e.empty||t[2]!==e.running?(n=t=>!(e.empty===!0&&!t.thread.isEmpty||e.empty===!1&&t.thread.isEmpty||e.running===!0&&!t.thread.isRunning||e.running===!1&&t.thread.isRunning||e.disabled===!0&&!t.thread.isDisabled||e.disabled===!1&&t.thread.isDisabled),t[0]=e.disabled,t[1]=e.empty,t[2]=e.running,t[3]=n):n=t[3],Q(n)},kG=e=>{let t=Z(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),OG(r)?n:null};kG.displayName=`ThreadPrimitive.If`;var AG=(e,t)=>{let n=Z(3),r;return n[0]!==t||n[1]!==e?(r=n=>{if(!e)return;let r=e(),i=()=>{let e=t?t(n):n.offsetHeight;r.setHeight(e)},a=new ResizeObserver(i);return a.observe(n),i(),()=>{a.disconnect(),r.unregister()}},n[0]=t,n[1]=e,n[2]=r):r=n[2],RW(r)},jG=e=>{let t=0,n=e;for(;n;)t+=n.offsetTop,n=n.offsetParent;return t},MG=(e,t)=>{let n=0,r=e;for(;r&&r!==t;)n+=r.offsetTop,r=r.offsetParent;return r===t?n:jG(e)-jG(t)},NG=({viewport:e,anchor:t,tallerThan:n,visibleHeight:r})=>{let i=MG(t,e),a=t.offsetHeight;return i+Math.max(0,a-(a<=n?a:r))},PG=({scrollHeight:e,...t})=>{let{viewport:n}=t,r=NG(t)+n.clientHeight;return Math.max(0,r-e)},FG=({viewport:e,reserve:t,...n})=>PG({viewport:e,...n,scrollHeight:e.scrollHeight-t.offsetHeight}),IG=e=>{let t=new ResizeObserver(e),n=new MutationObserver(e),r=null,i=null,a=null,o=()=>{t.disconnect(),n.disconnect(),r=null,i=null,a=null};return{target:(e,s,c)=>{r===e&&i===s&&a===c||(o(),t.observe(e),t.observe(s),t.observe(c),n.observe(c,{childList:!0,subtree:!0,characterData:!0}),r=e,i=s,a=c)},disconnect:o}},LG=e=>{let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}},RG=e=>{let t=null,n;function r(){let r=e.getState(),{viewport:o,anchor:s,target:c}=r.element,l=r.targetConfig;if(r.turnAnchor!==`top`||!o||!s||!c||!l){a.disconnect(),t&&(HW(t,0),t.remove());return}if(t??=VW(),(t.parentElement!==c.parentElement||t.previousElementSibling!==c)&&c.after(t),a.target(o,s,c),HW(t,FG({viewport:o,anchor:s,reserve:t,...l}))){i.schedule();return}let u=BW(s);if(u!==void 0&&n===u)return;let d=UW(NG({viewport:o,anchor:s,...l}));Math.abs(o.scrollTop-d)>1&&o.scrollTo({top:d,behavior:`smooth`}),u!==void 0&&(n=u)}let i=LG(r),a=IG(i.schedule);i.schedule();let o=e.subscribe(i.schedule);return()=>{i.cancel(),o(),a.disconnect(),t?.remove()}},zG=e=>{let t=Z(4),n=SV(),r,i;t[0]!==e||t[1]!==n?(r=()=>{if(e)return RG(n)},i=[e,n],t[0]=e,t[1]=n,t[2]=r,t[3]=i):(r=t[2],i=t[3]),NN(r,i)},BG=({isRunning:e,messages:t})=>{if(!e)return null;let n=t.at(-1),r=t.at(-2);return r?.role!==`user`||n?.role!==`assistant`?null:{anchorId:r.id,targetId:n.id}},VG=e=>BG(e)?.anchorId,HG=e=>BG(e)?.targetId,UG=()=>AG(xV(JG),YG),WG=()=>RW(xV(XG)),GG=e=>{let t=Z(13),n=SV(),r;t[0]===e?r=t[1]:(r=t=>{if(e)return VG(t.thread)},t[0]=e,t[1]=r);let i=Q(r),a;t[2]===e?a=t[3]:(a=t=>{if(e)return HG(t.thread)},t[2]=e,t[3]=a);let o=Q(a),s;bb0:{if(!i||!o){s=null;break bb0}let e;t[4]!==i||t[5]!==o?(e={anchorId:i,targetId:o},t[4]=i,t[5]=o,t[6]=e):e=t[6],s=e}let c=s,l,u;t[7]!==c||t[8]!==n?(l=()=>{if(!c)return;let e=n.getState(),t=e.topAnchorTurn;t?.anchorId===c.anchorId&&t.targetId===c.targetId||e.setTopAnchorTurn(c)},u=[c,n],t[7]=c,t[8]=n,t[9]=l,t[10]=u):(l=t[9],u=t[10]),NN(l,u);let d;t[11]===n?d=t[12]:(d=()=>{n.getState().setTopAnchorTurn(null)},t[11]=n,t[12]=d);let f=d;mF(`thread.initialize`,f),mF(`threadListItem.switchedTo`,f)},KG=(0,X.forwardRef)((e,t)=>{let n=Z(18),r,i,a,o,s,c;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6]):({autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c,children:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c);let l;n[7]!==r||n[8]!==o||n[9]!==s||n[10]!==c?(l={autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c},n[7]=r,n[8]=o,n[9]=s,n[10]=c,n[11]=l):l=n[11];let u=wG(l),d=UG(),f=WG(),p=SV(),m;n[12]===p?m=n[13]:(m=p.getState(),n[12]=p,n[13]=m);let h=m.turnAnchor===`top`;GG(h),zG(h);let g=So(t,u,d,f),_;return n[14]!==i||n[15]!==g||n[16]!==a?(_=(0,J.jsx)(KV.div,{...a,ref:g,children:i}),n[14]=i,n[15]=g,n[16]=a,n[17]=_):_=n[17],_});KG.displayName=`ThreadPrimitive.ViewportScrollable`;var qG=(0,X.forwardRef)((e,t)=>{let n=Z(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({turnAnchor:a,topAnchorMessageClamp:i,...r}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]!==i||n[5]!==a?(o={turnAnchor:a,topAnchorMessageClamp:i},n[4]=i,n[5]=a,n[6]=o):o=n[6];let s;n[7]!==r||n[8]!==t?(s=(0,J.jsx)(KG,{...r,ref:t}),n[7]=r,n[8]=t,n[9]=s):s=n[9];let c;return n[10]!==o||n[11]!==s?(c=(0,J.jsx)(DV,{options:o,children:s}),n[10]=o,n[11]=s,n[12]=c):c=n[12],c});qG.displayName=`ThreadPrimitive.Viewport`;function JG(e){return e.registerViewport}function YG(e){return e.clientHeight}function XG(e){return e.registerViewportElement}var ZG=(0,X.forwardRef)((e,t)=>{let n=Z(3),r=So(t,AG(xV(QG),$G)),i;return n[0]!==e||n[1]!==r?(i=(0,J.jsx)(KV.div,{...e,ref:r}),n[0]=e,n[1]=r,n[2]=i):i=n[2],i});ZG.displayName=`ThreadPrimitive.ViewportFooter`;function QG(e){return e.registerContentInset}function $G(e){let t=parseFloat(getComputedStyle(e).marginTop)||0;return e.offsetHeight+t}var eK=rH(`ThreadPrimitive.ScrollToBottom`,e=>{let t=Z(5),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{behavior:r}=n,i=xV(tK),a=SV(),o;return t[2]!==r||t[3]!==a?(o=()=>{a.getState().scrollToBottom({behavior:r})},t[2]=r,t[3]=a,t[4]=o):o=t[4],i?null:o},[`behavior`]);function tK(e){return e.isAtBottom}var nK=rH(`ThreadPrimitive.Suggestion`,e=>{let t=Z(4),{prompt:n,send:r,clearComposer:i,autoSend:a}=e,o=r??a??!1,s;t[0]!==i||t[1]!==n||t[2]!==o?(s={prompt:n,send:o,clearComposer:i},t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3];let{disabled:c,trigger:l}=fV(s);return c?null:l},[`prompt`,`send`,`clearComposer`,`autoSend`,`method`]),rK=HV({Empty:()=>EG,If:()=>kG,MessageByIndex:()=>$R,Messages:()=>nz,Root:()=>TG,ScrollToBottom:()=>eK,Suggestion:()=>nK,SuggestionByIndex:()=>jB,Suggestions:()=>PB,Viewport:()=>qG,ViewportFooter:()=>ZG,ViewportProvider:()=>DV});function iK(e,t){let n=null,r=()=>{n?.(),n=null};return{say(i,a){r(),e(``),n=t(()=>{n=null,e(i),a!==void 0&&(n=t(()=>e(``),a))},150)},clear(){r(),e(``)}}}var aK=(e,t)=>{let n=window.setTimeout(e,t);return()=>window.clearTimeout(n)};function oK(e){switch(e){case`ok`:return null;case`too-many`:return Jn({count:10});case`too-long`:return Du()}}async function sK(e,t){if(e)return{done:!1,reason:`impersonating`};try{return{done:!0,placed:(await t())?.placed===!0}}catch{return{done:!1,reason:`server`}}}function cK(e){return e.done?null:e.reason===`impersonating`?up():Nte()}function lK(e,t){let n=[],r=0;for(let i of e)t.has(i.messageId)?n.push(i):r++;return n.sort((e,n)=>{let r=t.get(e.messageId),i=t.get(n.messageId);if(r!==i)return r-i;let a=e.blockIndex??-1,o=n.blockIndex??-1;return a===o?e.createdAt-n.createdAt:a-o}),{ordered:n,unreachableCount:r}}function uK(e,t,n){if(e.length===0)return null;let r=t===null?-1:e.indexOf(t);return r===-1?n===1?e[0]:e[e.length-1]:e[(r+n+e.length)%e.length]}function dK(e){let t=[];for(let n of e.querySelectorAll(`.oc-md`))if(n.closest(`.oc-msg__meta`)===null)for(let e of n.children)e.tagName===`OL`||e.tagName===`UL`?t.push(...e.children):t.push(e);return t}var fK=`img, picture, video, audio, canvas, svg, iframe`;function pK(e){let t=e.matches(`img`)?[e]:[...e.querySelectorAll(`img`)];return{text:e.textContent??``,alt:t.map(e=>e.getAttribute(`alt`)?.trim()??``).filter(e=>e!==``).join(`, `),media:e.matches(fK)||e.querySelector(fK)!==null,print:yK(e)}}var mK=1,hK=3,gK=new Set([`class`,`style`,`id`,`role`,`tabindex`,`open`,`data-incomplete`]);function _K(e){return e.tagName===`BUTTON`||e.getAttribute(`data-streamdown`)===`image-fallback`}function vK(e){let t=[];for(let n of e.getAttributeNames().sort())gK.has(n)||n.startsWith(`aria-`)||t.push([n,e.getAttribute(n)??``]);let n=[];for(let t of e.childNodes)if(t.nodeType===hK){let e=n.length-1;typeof n[e]==`string`?n[e]+=t.nodeValue??``:n.push(t.nodeValue??``)}else t.nodeType===mK&&!_K(t)&&n.push(vK(t));return e.tagName===`INPUT`?[e.tagName,t,n,e.checked]:[e.tagName,t,n]}function yK(e){let t=e.tagName===`LI`?e.parentElement?.tagName??``:``;return JSON.stringify([t,vK(e)])}function bK(e,t){return t===null?e:dK(e)[t]??e}function xK(e,t){let n=null,r=1/0;for(let i of e){let e=Math.abs(i.center-t);e<r&&(r=e,n=i.id)}return n}function SK(e,t=48){let n=e.replace(/\s+/g,` `).trim(),r=Array.from(n);if(r.length<=t)return n;let i=r.slice(0,t).join(``),a=i.lastIndexOf(` `);return(a>t*.6?i.slice(0,a):i)+`…`}function CK(e){let t=SK(e.text,280);return t===``?e.media?{quote:``,label:SK(e.alt,280)}:null:{quote:t,label:t}}function wK(e,t,n){if(t===null||n===null||t[e.blockIndex]!==e.print)return null;if(t.length===n.length&&t.every((e,t)=>e===n[t]))return e.blockIndex;let r=t=>t.flatMap((t,n)=>t===e.print?[n]:[]);if(r(t).length!==1)return null;let i=r(n);return i.length===1?i[0]:null}function TK(e,t,n,r,i){let a=wK(e,n,r);return a===null||t!==`bookmark`||(i?.has(OK(e.messageId,e.blockIndex))??!1)===(i?.has(OK(e.messageId,a))??!1)?a:null}function EK(e,t){let n=[];for(let{messageId:r,faces:i}of e)i.forEach((e,i)=>{let a=CK(e);a===null||t===`quote`&&a.quote===``||n.push({messageId:r,blockIndex:i,excerpt:a.quote,label:a.label,print:e.print})});return n}function DK(e,t,n){return n===null?t?[]:[e]:n.filter(e=>!e.live).map(e=>e.id)}var OK=(e,t)=>`${e}#${t}`,kK=[`trigger`,`message`,`composer`];function AK(e){return e?[`composer`,...kK]:[...kK]}function jK(e){let t=0;for(let n of e.split(`,`)){let e=n.trim(),r=parseFloat(e);Number.isFinite(r)&&(t=Math.max(t,e.endsWith(`ms`)?r:r*1e3))}return t}var MK=`input, textarea, select, [contenteditable]:not([contenteditable='false'])`,NK=`button, summary, [role='button'], [role='checkbox'], [role='switch'], [role='radio'], [role='tab'], [role='option'], [role='menuitem'], [role='menuitemcheckbox'], [role='menuitemradio']`;function PK(e,t){let n=e.key===` `;if(!(e.key===`PageUp`||e.key===`ArrowUp`||e.key===`Home`||n&&e.shiftKey))return!1;let r=e.target;if(r===null||r.nodeType!==1)return!1;let i=r,a=t.ownerDocument;return i===a.body||i===a.documentElement?!0:!t.contains(i)||i.closest(MK)!==null?!1:!(n&&i.closest(NK)!==null)}function FK(e,t){let n=e;if(n===null||n.nodeType!==1||n===t)return!1;let r=n.getBoundingClientRect(),i=t.getBoundingClientRect();return r.top<i.top-.5||r.bottom>i.bottom+.5}var IK=e=>2+2/(e.devicePixelRatio||1),LK=new WeakMap;function RK(e){e!==null&&LK.get(e)?.()}function zK(e,t){LK.get(e)?.();let n=e.ownerDocument,r=n.defaultView??window,i=r.getComputedStyle(e,`::after`),a=jK(i.transitionDuration)+jK(i.transitionDelay)+100,o=1/0,s=()=>parseFloat(i.height)||0,c=()=>e.scrollHeight-e.scrollTop-e.clientHeight,l=()=>e.scrollHeight-s(),u=0,d=!1,f=0,p=0,m=0,h=()=>{f=e.scrollTop,p=l(),m=e.clientHeight};h();let g=()=>Math.abs(l()-p)<=1&&e.clientHeight===m,_=()=>c()<=1?(h(),!1):g()&&f-e.scrollTop>Math.max(0,p-l())+IK(r),v=()=>{e.scrollTo({top:e.scrollHeight,behavior:`instant`}),h()},y=t=>{PK(t,e)&&w()},b=e=>{e.deltaY<0&&w()},x=t=>{FK(t.target,e)&&w()},S=()=>{c()>1&&!(g()&&e.scrollTop>f)&&v(),w()},C=t=>{t.target===e&&(_()?w():r.performance.now()>=o?S():c()>1&&v())},w=()=>{d||(d=!0,LK.get(e)===w&&LK.delete(e),r.cancelAnimationFrame(u),e.removeEventListener(`pointerdown`,w),e.removeEventListener(`touchstart`,w),e.removeEventListener(`wheel`,b),e.removeEventListener(`focusin`,x),n.removeEventListener(`scroll`,C,!0),n.removeEventListener(`keydown`,y,!0))},T=()=>{if(!d){if(!t.getState().isAtBottom||_()){w();return}if(r.performance.now()>=o){S();return}v(),u=r.requestAnimationFrame(E)}},E=()=>{o===1/0&&(o=r.performance.now()+a),T()};return e.addEventListener(`pointerdown`,w,{passive:!0}),e.addEventListener(`touchstart`,w,{passive:!0}),e.addEventListener(`wheel`,b,{passive:!0}),e.addEventListener(`focusin`,x),n.addEventListener(`scroll`,C,{capture:!0,passive:!0}),n.addEventListener(`keydown`,y,!0),LK.set(e,w),T(),w}var BK=(0,q.createContext)(null);function VK(){return(0,q.useContext)(BK)}function HK(e,t,n,r){let i=!1,a=0,o=0,s=()=>{if(i)return;let c=document.querySelector(`[data-message-id="${CSS.escape(e)}"]`);if(c){let e=bK(c,t),i=c.closest(`.oc-thread__viewport`);if(!(()=>{if(!r?.skipScrollIfVisible||!i)return!1;let t=e.getBoundingClientRect(),n=i.getBoundingClientRect();return t.top>=n.top&&t.top<=n.bottom-48})())if(i){RK(i);let t=e.getBoundingClientRect().top-i.getBoundingClientRect().top;i.scrollTo({top:i.scrollTop+t-Math.max(24,i.clientHeight*.3),behavior:n})}else e.scrollIntoView({block:`center`,behavior:n});let a=t===null?c:e,o=t===null?`oc-msg--highlight`:`oc-anchor--flash`;a.classList.remove(o),a.offsetWidth,a.classList.add(o),window.setTimeout(()=>a.classList.remove(o),2400);return}a++<40&&(o=window.setTimeout(s,150))};return o=window.setTimeout(s,0),()=>{i=!0,window.clearTimeout(o)}}function UK({chatId:e,focusMessageId:t,children:n}){let r=H(G.chatBookmarks.getBookmarks,{chatId:e}),i=U(G.chatBookmarks.toggleBookmark),a=H(G.me.getImpersonation)?.impersonating===!0,o=U(G.chatBookmarks.removeBookmark),s=U(G.chatBookmarks.renameBookmark),c=U(G.chatBookmarks.setActiveBookmark),[l,u]=(0,q.useState)(null);(0,q.useEffect)(()=>{u(null)},[e]);let d=r?.activeBookmarkId??null;(0,q.useEffect)(()=>{l!==null&&d===l&&u(null)},[d,l]);let f=(0,q.useMemo)(()=>(r?.bookmarks??[]).map(e=>({id:e._id,messageId:e.messageId,blockIndex:e.blockIndex,label:e.label,createdAt:e.createdAt})),[r?.bookmarks]),p=l??d,m=(0,q.useMemo)(()=>{let e=new Map;for(let t of f){let n=e.get(t.messageId);n?n.push(t):e.set(t.messageId,[t])}return e},[f]),h=(0,q.useCallback)(t=>{u(t.id),HK(t.messageId,t.blockIndex,`smooth`),c({chatId:e,bookmarkId:t.id})},[e,c]),g=(0,q.useCallback)(t=>{u(t),c({chatId:e,bookmarkId:t})},[e,c]),_=(0,q.useMemo)(()=>({rows:f,activeId:p,byMessage:m,toggle:(t,n)=>sK(a,()=>i({chatId:e,messageId:t,...n===null?{}:{blockIndex:n}}).then(e=>(e?.placed===!0&&HK(t,n,`smooth`,{skipScrollIfVisible:!0}),e))),remove:e=>void o({bookmarkId:e}),rename:(e,t)=>void s({bookmarkId:e,label:t}),jumpTo:h,setActiveQuiet:g}),[f,p,m,e,a,i,o,s,h,g]),v=(0,q.useRef)(null);return(0,q.useEffect)(()=>{if(v.current===e||r===void 0||(v.current=e,t!==null)||p===null)return;let n=f.find(e=>e.id===p);if(n!==void 0)return HK(n.messageId,n.blockIndex,`auto`)},[e,r===void 0]),(0,J.jsx)(BK.Provider,{value:_,children:n})}function WK(e){let t=e.target;return t instanceof HTMLElement?t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable:!1}function GK(e){if(e.label!==null&&e.label.length>0)return e.label;let t=document.querySelector(`[data-message-id="${CSS.escape(e.messageId)}"]`);if(t){let n=SK(bK(t,e.blockIndex).textContent??``);if(n.length>0)return n}return db()}function KK(){let e=VK(),t=BV(e=>e.messages.length),[n,r]=(0,q.useState)([]),[i,a]=(0,q.useState)(0),o=e?.rows;(0,q.useEffect)(()=>{if(!o||o.length===0){r([]),a(0);return}let e=!1,t=0,n=0,i=()=>{if(e)return;let s=new Map;document.querySelectorAll(`.oc-thread__viewport [data-message-id]`).forEach((e,t)=>s.set(e.dataset.messageId??``,t));let c=lK(o,s);r(c.ordered),a(c.unreachableCount),c.ordered.length===0&&t++<40&&(n=window.setTimeout(i,150))};return i(),()=>{e=!0,window.clearTimeout(n)}},[o,t]);let[s,c]=(0,q.useState)(null),l=(0,q.useRef)(0),u=(0,q.useRef)(null),d=s!==null&&n.some(e=>e.id===s)?s:e?.activeId??null;(0,q.useEffect)(()=>{if(!e||n.length===0)return;let t=document.querySelector(`.oc-thread__viewport`);if(!t)return;let r=0,i=0,a=()=>{r===0&&(r=window.requestAnimationFrame(()=>{if(r=0,Date.now()-l.current<1200)return;let a=t.getBoundingClientRect(),o=a.top+a.height/2,s=[];for(let e of n){let n=t.querySelector(`[data-message-id="${CSS.escape(e.messageId)}"]`);if(!n)continue;let r=bK(n,e.blockIndex).getBoundingClientRect();s.push({id:e.id,center:(r.top+r.bottom)/2})}let d=xK(s,o);d!==null&&(c(d),u.current=d===e.activeId?null:d,window.clearTimeout(i),i=window.setTimeout(()=>{let t=u.current;u.current=null,t!==null&&e.setActiveQuiet(t)},800))}))};return t.addEventListener(`scroll`,a,{passive:!0}),()=>{t.removeEventListener(`scroll`,a),r!==0&&window.cancelAnimationFrame(r),window.clearTimeout(i);let n=u.current;u.current=null,n!==null&&e.setActiveQuiet(n)}},[e,n]);let f=(0,q.useCallback)(t=>{e&&(l.current=Date.now(),c(t.id),e.jumpTo(t))},[e]),p=(0,q.useCallback)(e=>{let t=uK(n.map(e=>e.id),d,e),r=n.find(e=>e.id===t);r&&f(r)},[n,d,f]);if((0,q.useEffect)(()=>{if(n.length===0)return;let e=e=>{WK(e)||(Aw(e,Ew)?(e.preventDefault(),p(-1)):Aw(e,kw)&&(e.preventDefault(),p(1)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n.length,p]),!e||e.rows.length===0)return null;let m=n.findIndex(e=>e.id===d),h=`${m===-1?`–`:m+1}/${n.length}`;return(0,J.jsxs)(`div`,{className:`oc-bmk-rail`,role:`navigation`,"aria-label":vy(),title:i>0?F_({count:String(i)}):void 0,children:[(0,J.jsx)(K,{variant:`ghost`,size:`icon`,className:`oc-bmk-rail__btn`,onClick:()=>p(-1),disabled:n.length===0,title:`${t_()} (${Ow(Ew,Dw())})`,"aria-label":t_(),children:(0,J.jsx)(tC,{size:14})}),(0,J.jsxs)(hC,{children:[(0,J.jsx)(oC,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`oc-bmk-rail__count`,title:qh(),"aria-label":qh(),children:[(0,J.jsx)(uA,{size:11,"aria-hidden":!0}),(0,J.jsx)(`span`,{"aria-live":`polite`,children:h})]})}),(0,J.jsxs)(dC,{side:`left`,align:`center`,className:`oc-bmk-menu`,children:[n.map(e=>(0,J.jsxs)(pC,{className:e.id===d?`oc-bmk-menu__item--current`:void 0,onSelect:()=>f(e),children:[(0,J.jsx)(uA,{size:12,"aria-hidden":!0,className:`oc-bmk-menu__flag`}),(0,J.jsx)(`span`,{className:`oc-bmk-menu__text`,children:GK(e)})]},e.id)),i>0?(0,J.jsx)(`div`,{className:`oc-bmk-menu__foot`,children:F_({count:String(i)})}):null]})]}),(0,J.jsx)(K,{variant:`ghost`,size:`icon`,className:`oc-bmk-rail__btn`,onClick:()=>p(1),disabled:n.length===0,title:`${Ap()} (${Ow(kw,Dw())})`,"aria-label":Ap(),children:(0,J.jsx)(QS,{size:14})})]})}var qK=6e3,JK=120;function YK(e,t){let n=dK(e),r=n.map(pK),i=r.map(e=>e.print),a=e.getBoundingClientRect().top,o=null,s=1/0;for(let e=0;e<n.length;e++){let c=CK(r[e]);if(c===null)continue;let l=n[e].getBoundingClientRect(),u={top:l.top-a,blockIndex:e,quotable:c.quote!==``,print:i[e],seen:i};if(t>=l.top&&t<=l.bottom)return u;let d=t<l.top?l.top-t:t-l.bottom;d<s&&(s=d,o=u)}return s<=16?o:null}function XK(e,t){let n=dK(e),r=wK(t,t.seen,n.map(yK));if(r!==t.blockIndex)return null;let i=n[r].getBoundingClientRect().top-e.getBoundingClientRect().top;return Math.abs(i-t.top)<1?r:null}var ZK=class extends q.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(){}render(){return this.state.failed?null:this.props.children}};function QK(e={}){return(0,J.jsx)(ZK,{children:(0,J.jsx)($K,{...e})})}function $K({messageLevelMarkers:e=!0,onReplyToBlock:t}={}){let n=VK(),r=$(e=>e.id),i=$(e=>e.status?.type===`running`),a=(0,q.useRef)(null),[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(``),f=(0,q.useMemo)(()=>iK(d,aK),[]);(0,q.useEffect)(()=>()=>f.clear(),[f]);let[p,m]=(0,q.useState)(0),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(new Map),y=n?.byMessage.get(r),b=(0,q.useMemo)(()=>e?y:y?.filter(e=>e.blockIndex!==null),[y,e]);if((0,q.useEffect)(()=>{let e=a.current?.closest(`.oc-msg`);s(e?.querySelector(`.oc-msg__body`)??e?.querySelector(`.oc-msg__bubble`)??null)},[r]),(0,q.useEffect)(()=>{if(!o||i||!n)return;let e=o.closest(`.oc-msg`)??o,t=0,r=e=>{t===0&&(t=window.requestAnimationFrame(()=>{t=0,l(YK(o,e.clientY))}))},a=()=>{t!==0&&(window.cancelAnimationFrame(t),t=0),l(null)};return e.addEventListener(`mousemove`,r),e.addEventListener(`mouseleave`,a),()=>{e.removeEventListener(`mousemove`,r),e.removeEventListener(`mouseleave`,a),t!==0&&window.cancelAnimationFrame(t)}},[o,i,n]),(0,q.useEffect)(()=>{if(!o||!b||b.length===0){v(new Map);return}let e=()=>{let e=o.getBoundingClientRect().top,t=new Map;for(let n of b){let r=bK(o,n.blockIndex);t.set(n.id,r.getBoundingClientRect().top-e)}v(t)};e();let t=new ResizeObserver(e);return t.observe(o),()=>t.disconnect()},[o,b]),!n||!o)return(0,J.jsx)(`span`,{ref:a,hidden:!0});let x=c!==null&&(b??[]).some(e=>e.blockIndex===c.blockIndex),S=(e,t)=>{let n=o.closest(`.oc-thread__viewport`),r=o.getBoundingClientRect().top+t,i=n===null?1/0:n.getBoundingClientRect().bottom-r;g(i<JK),m(t),f.say(e,qK)},C=(e,t)=>{let n=YK(o,e);l(n),S(Fc(),n?.top??t)};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{ref:a,hidden:!0}),(0,bk.createPortal)((0,J.jsxs)(J.Fragment,{children:[c!==null&&!i?(0,J.jsxs)(`span`,{className:`oc-bmk-gutterrow`,style:{top:c.top},children:[t&&c.quotable?(0,J.jsx)(`button`,{type:`button`,className:`oc-bmk-gutter oc-bmk-gutter--reply`,title:fc(),"aria-label":fc(),onClick:e=>{let n=XK(o,c);if(n===null){C(e.clientY,c.top);return}let r=SK(bK(o,n).textContent??``,280);if(r===``){C(e.clientY,c.top);return}let i=t(n,r);i===null?f.clear():S(i,c.top)},children:(0,J.jsx)(aj,{size:14})}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-bmk-gutter${x?` is-set`:``}`,title:x?o_():Eh(),"aria-label":x?o_():Eh(),onClick:e=>{let t=XK(o,c);if(t===null){C(e.clientY,c.top);return}let i=c.top;n.toggle(r,t).then(e=>{let t=cK(e);t===null?f.clear():S(t,i)})},children:(0,J.jsx)(uA,{size:14})})]}):null,(b??[]).map(e=>{let t=_.get(e.id);return t===void 0?null:(0,J.jsx)(tq,{bookmark:e,top:t},e.id)}),(0,J.jsx)(`p`,{className:`oc-bmk-status`,role:`status`,style:{top:p},"data-above":h||void 0,children:u})]}),o)]})}function eq({bookmark:e,trigger:t}){let n=VK(),[r,i]=(0,q.useState)(e.label??``),[a,o]=(0,q.useState)(!1);return n?(0,J.jsxs)(vw,{open:a,onOpenChange:t=>{o(t),t&&i(e.label??``)},children:[(0,J.jsx)(_w,{asChild:!0,children:t}),(0,J.jsx)(gw,{side:`left`,align:`start`,className:`oc-bmk-pop`,children:(0,J.jsxs)(`form`,{className:`oc-bmk-pop__form`,onSubmit:t=>{t.preventDefault(),n.rename(e.id,r),o(!1)},children:[(0,J.jsx)(Tw,{value:r,onChange:e=>i(e.target.value),placeholder:em(),maxLength:60,autoFocus:!0}),(0,J.jsxs)(`div`,{className:`oc-bmk-pop__actions`,children:[(0,J.jsx)(K,{type:`submit`,size:`sm`,variant:`secondary`,children:iv()}),(0,J.jsxs)(K,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{n.remove(e.id),o(!1)},children:[(0,J.jsx)(WC,{size:14,"aria-hidden":!0}),dee()]})]})]})})]}):null}function tq({bookmark:e,top:t}){return(0,J.jsx)(eq,{bookmark:e,trigger:(0,J.jsx)(`button`,{type:`button`,className:`oc-bmk-marker`,style:{top:t},title:e.label??db(),"aria-label":e.label??db(),children:(0,J.jsx)(uA,{size:14})})})}function nq(e){return(0,J.jsx)(ZK,{children:(0,J.jsx)(rq,{...e})})}function rq({header:e=!1}){let t=VK(),n=$(e=>e.id),r=t?.byMessage.get(n)?.find(e=>e.blockIndex===null)??null;if(!t)return null;let i=r!==null,a=e?`oc-bmk-headbtn oc-reveal oc-hit${i?` is-set`:``}`:`oc-iconbtn${i?` oc-iconbtn--bmk-set`:``}`;return e&&r!==null?(0,J.jsx)(eq,{bookmark:r,trigger:(0,J.jsx)(`button`,{type:`button`,className:a,title:r.label??db(),"aria-label":r.label??db(),children:(0,J.jsx)(uA,{size:13})})}):(0,J.jsx)(`button`,{type:`button`,className:a,title:i?o_():Eh(),"aria-label":i?o_():Eh(),onClick:()=>t.toggle(n,null),children:(0,J.jsx)(uA,{size:e?13:15})})}function iq(e){let t=(0,q.useRef)(null),n=(0,q.useRef)(e);return n.current=e,(0,q.useEffect)(()=>{let e=e=>{t.current!==null&&(n.current(e.clientX-t.current.x,e.clientY-t.current.y),t.current={x:e.clientX,y:e.clientY})},r=()=>{t.current=null};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,r),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,r)}},[]),e=>{t.current={x:e.clientX,y:e.clientY}}}function aq(){let e=(0,q.useSyncExternalStore)(Hj,Uj),t=Kx(),n=Iw();(0,q.useEffect)(()=>()=>void gM(),[]);let r=(0,q.useCallback)((e,t)=>{let n=Uj()?.geom;if(n===void 0)return;let r=Wj(n,Mj());eM({...r,x:r.x+e,y:r.y+t})},[]),i=(0,q.useCallback)((e,t)=>{let n=Uj()?.geom;if(n===void 0)return;let r=Wj(n,Mj());eM({...r,w:r.w+e,h:r.h+t})},[]),a=iq(r),o=iq(i),[,s]=(0,q.useReducer)(e=>e+1,0);(0,q.useEffect)(()=>{let e=window.visualViewport;return window.addEventListener(`resize`,s),e?.addEventListener(`resize`,s),e?.addEventListener(`scroll`,s),()=>{window.removeEventListener(`resize`,s),e?.removeEventListener(`resize`,s),e?.removeEventListener(`scroll`,s)}},[]);let c=(0,q.useRef)(null);(0,q.useEffect)(()=>()=>c.current?.stop(),[]);let l=e?.recording??!1,u=(0,q.useCallback)(()=>{if(Uj()?.recording===!0){let e=Xj();c.current?.stop(),c.current=null,uM(),lM(e),window.setTimeout(()=>cM(e),GS+1e3);return}if(!JS())return;let e=Uj()?.voiceLang||RS(``,ut()),t={h:null,gen:0},r=()=>{c.current===t.h&&(c.current=null),cM(t.gen)},i=YS({lang:e,onText:(e,n)=>{t.gen===Xj()&&Zj(e,n.paragraph)},onInterim:e=>{t.gen===Xj()&&Qj(e)},onEnd:r,onError:e=>{r(),e===`not-allowed`||e===`service-not-allowed`?n.error(bd()):e===`engine-gave-up`?n.error(Hi()):e!==`no-speech`&&e!==`aborted`&&n.error(kv({code:e}))}});if(i===null){n.error(hi());return}t.h=i,c.current=i,Yj(()=>i.stop()),t.gen=Xj()},[n]),d=AM(e?.targetChatId??null);if(e===null)return null;let f=Wj(e.geom,Mj());return(0,bk.createPortal)((0,J.jsxs)(`div`,{className:`oc-detach${l?` oc-detach--live`:``}`,style:{left:`${f.x}px`,top:`${f.y}px`,width:`${f.w}px`,height:`${f.h}px`},role:`dialog`,"aria-label":Dt(),children:[(0,J.jsx)(`div`,{className:`oc-detach__handle`,onPointerDown:a,title:Ko(),"aria-label":Ko(),children:(0,J.jsx)(MA,{size:16,"aria-hidden":!0})}),(0,J.jsxs)(`div`,{className:`oc-detach__head`,onPointerDown:a,children:[l?(0,J.jsxs)(`span`,{className:`oc-detach__wave`,"aria-hidden":!0,children:[(0,J.jsx)(`i`,{}),(0,J.jsx)(`i`,{}),(0,J.jsx)(`i`,{})]}):null,(0,J.jsx)(`span`,{className:`oc-detach__chip`,title:e.targetLabel,children:e.targetLabel||Dt()}),(0,J.jsx)(`button`,{type:`button`,className:`oc-detach__close`,title:Xt(),"aria-label":Xt(),onPointerDown:e=>e.stopPropagation(),onClick:()=>{EM(e.targetChatId),gM()},children:(0,J.jsx)(YC,{size:14,"aria-hidden":!0})})]}),d.length>0?(0,J.jsx)(`div`,{className:`oc-detach__quotes`,children:d.map(n=>(0,J.jsxs)(`div`,{className:`oc-detach__quote`,role:`group`,"aria-label":gs(),children:[(0,J.jsx)(aj,{size:12,"aria-hidden":!0,className:`oc-detach__quote-ico`}),(0,J.jsx)(`button`,{type:`button`,className:`oc-detach__quote-text`,title:xn(),onClick:()=>{HK(n.messageId,n.blockIndex,`smooth`),t({to:`/chat/$chatId`,params:{chatId:e.targetChatId}})},children:n.excerpt}),(0,J.jsx)(`button`,{type:`button`,className:`oc-detach__quote-x`,"aria-label":vo(),onClick:()=>wM(e.targetChatId,TM(n)),children:(0,J.jsx)(YC,{size:12,"aria-hidden":!0})})]},TM(n)))}):null,(0,J.jsx)(`textarea`,{className:`oc-detach__input`,value:e.text,placeholder:Dt(),onChange:e=>$j(e.target.value),readOnly:e.sending,autoFocus:!0}),(l||e.finalizing)&&e.interim!==``?(0,J.jsx)(`div`,{className:`oc-detach__interim`,"aria-hidden":!0,children:(0,J.jsx)(`span`,{className:`oc-detach__interim-text`,children:e.interim})}):null,(0,J.jsxs)(`div`,{className:`oc-detach__bar`,children:[e.voiceEnabled&&JS()?(0,J.jsx)(`button`,{type:`button`,className:`oc-detach__icon${l?` oc-detach__icon--rec`:``}`,title:l?qu():Gd(),"aria-label":l?qu():Gd(),"aria-pressed":l,disabled:e.sending,onClick:u,children:l?(0,J.jsx)(XA,{size:16,"aria-hidden":!0}):(0,J.jsx)(qS,{size:16,"aria-hidden":!0})}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-detach__icon`,title:l||e.finalizing?fte():cl(),"aria-label":cl(),disabled:e.sending||l||e.finalizing,onClick:()=>{aM(),t({to:`/chat/$chatId`,params:{chatId:e.targetChatId}})},children:(0,J.jsx)(LS,{size:16,"aria-hidden":!0})}),(0,J.jsxs)(`button`,{type:`button`,className:`oc-detach__send`,disabled:pM(e).trim()===``||e.sending,title:le(),"aria-label":le(),onClick:()=>{let n=pM(e);(l||e.finalizing)&&(c.current?.discard(),c.current=null,mM()),tM(n),t({to:`/chat/$chatId`,params:{chatId:e.targetChatId}})},children:[(0,J.jsx)(cj,{size:15,"aria-hidden":!0}),le()]})]}),(0,J.jsx)(`button`,{type:`button`,className:`oc-detach__resize`,"aria-label":Ug(),onPointerDown:o})]}),document.body)}function oq({icon:e,label:t,sublabel:n,trailing:r,tone:i=`default`,active:a,open:o,onClick:s,title:c,ariaLabel:l,ariaExpanded:u,ariaControls:d,ariaHasPopup:f,inert:p=!1}){return p?(0,J.jsxs)(`div`,{className:`oc-actrow oc-actrow--${i} oc-actrow--inert`,title:c,children:[(0,J.jsxs)(`span`,{className:`oc-actrow__top`,children:[(0,J.jsx)(`span`,{className:`oc-actrow__icon`,"aria-hidden":!0,children:e}),(0,J.jsx)(`span`,{className:`oc-actrow__label`,children:t}),r?(0,J.jsx)(`span`,{className:`oc-actrow__trail`,children:r}):null]}),n?(0,J.jsx)(`span`,{className:`oc-actrow__sub`,children:n}):null]}):(0,J.jsxs)(`button`,{type:`button`,className:`oc-actrow oc-actrow--${i}${a?` is-active`:``}${o?` is-open`:``}`,onClick:s,title:c,"aria-label":l,"aria-expanded":u,"aria-controls":d,"aria-haspopup":f?`dialog`:void 0,children:[(0,J.jsxs)(`span`,{className:`oc-actrow__top`,children:[(0,J.jsx)(`span`,{className:`oc-actrow__icon`,"aria-hidden":!0,children:e}),(0,J.jsx)(`span`,{className:`oc-actrow__label`,children:t}),r?(0,J.jsx)(`span`,{className:`oc-actrow__trail`,children:r}):null,(0,J.jsx)(eC,{size:14,className:`oc-actrow__chev`,"aria-hidden":!0})]}),n?(0,J.jsx)(`span`,{className:`oc-actrow__sub`,children:n}):null]})}var sq=(0,q.createContext)(null),cq=[];function lq(e){return e===`created`?(0,J.jsx)(LC,{size:12,"aria-hidden":!0}):e===`removed`?(0,J.jsx)(WC,{size:12,"aria-hidden":!0}):e===`unchanged`?(0,J.jsx)(mA,{size:12,"aria-hidden":!0}):(0,J.jsx)(IC,{size:12,"aria-hidden":!0})}function uq(e){return e===`created`?sr():e===`removed`?Se():e===`unchanged`?hx():Wl()}function dq(){let e=$(e=>e.metadata?.custom?.cronParts??cq),t=$(e=>e.metadata?.custom?.routedInstanceName??null),n=$(e=>e.id),r=(0,q.useContext)(sq),[i,a]=(0,q.useState)(!0);return e.length===0?null:(0,J.jsxs)(`div`,{className:`oc-cronact`,children:[(0,J.jsx)(oq,{icon:(0,J.jsx)(fA,{size:14}),label:Pi({count:e.length}),open:i,ariaExpanded:i,title:In(),onClick:()=>a(!i)}),i?(0,J.jsx)(`div`,{className:`oc-cronact__list`,children:e.map((e,i)=>(0,J.jsxs)(`button`,{type:`button`,className:`oc-cronact__item${r?.active!==null&&r?.active!==void 0&&r.active.jobId===(e.jobId??null)&&r.active.occurrenceId===`${n}#${i}`?` oc-cronact__item--active`:``}`,onClick:()=>r?.openFor(e,t,`${n}#${i}`),title:mu(),children:[(0,J.jsxs)(`span`,{className:`oc-cronact__op oc-cronact__op--${e.op}`,children:[lq(e.op),uq(e.op)]}),(0,J.jsx)(`span`,{className:`oc-cronact__name`,children:e.name??e.jobId??bl()}),e.schedule===void 0?null:(0,J.jsx)(`span`,{className:`oc-cronact__sched`,children:e.schedule})]},`${e.jobId??`job`}-${i}`))}):null]})}function fq(e){return typeof e==`number`?new Intl.DateTimeFormat(ut(),{dateStyle:`medium`,timeStyle:`short`}).format(e):`—`}function pq(e){return e===`ok`?(0,J.jsx)(Rw,{variant:`secondary`,children:Kp()}):e===`error`?(0,J.jsx)(Rw,{variant:`destructive`,children:pee()}):e===`skipped`?(0,J.jsx)(Rw,{variant:`outline`,children:z()}):(0,J.jsx)(Rw,{variant:`outline`,children:e??`—`})}function mq({instanceName:e,part:t,onClose:n,onChanged:r}){let i=Aa(G.scheduled.getCronDetail),a=Aa(G.scheduled.listCronRuns),o=Aa(G.scheduled.updateCron),s=Aa(G.scheduled.removeCron),c=Aa(G.scheduled.runCronNow),l=Iw(),u=t.jobId??null,[d,f]=(0,q.useState)(null),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(null),[_,v]=(0,q.useState)(`loading`),[y,b]=(0,q.useState)(null),[x,S]=(0,q.useState)(!1),C=(0,q.useRef)(0),w=(0,q.useCallback)(async()=>{let n=++C.current;if(f(null),m(null),g(null),u===null||t.op===`removed`){v(t.op===`removed`?`gone`:`error`);return}v(`loading`);try{let t=await i({instanceName:e,jobId:u});if(n!==C.current)return;if(f(t.job),m(t.capabilities),v(`ready`),t.capabilities.canHistory)try{let t=await a({instanceName:e,jobId:u,limit:5});if(n!==C.current)return;g(t)}catch{n===C.current&&g(null)}}catch(e){if(n!==C.current)return;let t=e?.data?.code;v(t===`not_found`?`gone`:`error`)}},[i,a,e,u,t.op]);(0,q.useEffect)(()=>{w()},[w]);let T=(0,q.useRef)(``);(0,q.useEffect)(()=>{T.current=`${e}:${u??``}`,b(null)},[e,u]);let E=async(t,n,i)=>{let a=`${e}:${u??``}`;b(t);try{if(await n(),T.current!==a)return;l.success(i),r?.(),await w()}catch(e){let t=e?.data?.code??`unknown`;l.toast({variant:`error`,title:Ste({code:t})})}finally{T.current===a&&b(e=>e===t?null:e)}},D=d??{id:u,name:t.name??null,enabled:t.enabled??null,schedule:t.schedule??null,message:t.message??null,deliveryMode:t.deliveryMode??null,agentId:t.agentId??null,nextRunAtMs:t.nextRunAtMs??null,lastRunStatus:null,lastDelivered:null,lastDeliveryError:null,updatedAtMs:null};return(0,J.jsxs)(`div`,{className:`oc-cronpanel`,children:[(0,J.jsxs)(`div`,{className:`oc-cronpanel__head`,children:[(0,J.jsx)(fA,{size:16,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-cronpanel__title`,title:D.name??void 0,children:D.name??bl()}),(0,J.jsx)(Rw,{variant:`outline`,children:uq(t.op)}),(0,J.jsx)(K,{variant:`ghost`,size:`icon`,onClick:n,"aria-label":ec(),children:(0,J.jsx)(YC,{"aria-hidden":!0})})]}),_===`loading`?(0,J.jsxs)(`div`,{className:`oc-cronpanel__loading`,children:[(0,J.jsx)(OC,{size:16,className:`oc-actrow__spin`,"aria-hidden":!0}),sa()]}):null,_===`gone`?(0,J.jsx)(`div`,{className:`oc-cronpanel__notice`,children:Nr()}):null,_===`error`?(0,J.jsx)(`div`,{className:`oc-cronpanel__notice`,children:ln()}):null,(0,J.jsxs)(`dl`,{className:`oc-cronpanel__facts`,children:[(0,J.jsx)(`dt`,{children:is()}),(0,J.jsx)(`dd`,{children:D.enabled===!0?(0,J.jsx)(Rw,{variant:`secondary`,children:si()}):D.enabled===!1?(0,J.jsx)(Rw,{variant:`outline`,children:fd()}):`—`}),(0,J.jsx)(`dt`,{children:ao()}),(0,J.jsxs)(`dd`,{children:[(0,J.jsx)(`span`,{className:`oc-cronpanel__mono`,children:D.schedule??`—`}),(()=>{let e=FC(D.schedule),t=e===null?null:NC(e);return t===null?null:(0,J.jsx)(`span`,{className:`oc-cronpanel__plain`,children:t})})()]}),(0,J.jsx)(`dt`,{children:Fa()}),(0,J.jsx)(`dd`,{children:fq(D.nextRunAtMs)}),(0,J.jsx)(`dt`,{children:ug()}),(0,J.jsx)(`dd`,{children:D.agentId??`—`}),D.deliveryMode===null?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`dt`,{children:R()}),(0,J.jsx)(`dd`,{children:D.deliveryMode})]}),D.lastDelivered===!1?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`dt`,{children:jg()}),(0,J.jsxs)(`dd`,{className:`oc-cronpanel__undelivered`,children:[Mo(),D.lastDeliveryError===null?null:(0,J.jsx)(`span`,{className:`oc-cronpanel__plain`,children:D.lastDeliveryError})]})]}):null]}),D.message===null?null:(0,J.jsxs)(`div`,{className:`oc-cronpanel__message`,children:[(0,J.jsx)(`div`,{className:`oc-cronpanel__message-label`,children:mt()}),(0,J.jsx)(`div`,{className:`oc-cronpanel__message-body`,children:D.message})]}),_===`ready`&&p!==null&&u!==null?(0,J.jsxs)(`div`,{className:`oc-cronpanel__actions`,children:[p.canRunNow?(0,J.jsxs)(K,{variant:`outline`,size:`sm`,disabled:y!==null,onClick:()=>E(`run`,async()=>{let t=await c({instanceName:e,jobId:u});if(t.ran!==!0&&t.runId===null)throw{data:{code:t.reason??`run_not_started`}}},ep()),children:[y===`run`?(0,J.jsx)(OC,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,J.jsx)(PC,{size:14,"aria-hidden":!0}),Rt()]}):null,p.canToggle&&D.enabled!==null?(0,J.jsxs)(K,{variant:`outline`,size:`sm`,disabled:y!==null,onClick:()=>E(`toggle`,()=>o({instanceName:e,jobId:u,patch:{enabled:!(D.enabled??!1)}}),D.enabled===!0?Ute():Ob()),children:[D.enabled===!0?(0,J.jsx)(jC,{size:14,"aria-hidden":!0}):(0,J.jsx)(MC,{size:14,"aria-hidden":!0}),D.enabled===!0?Yc():Zb()]}):null,p.canDelete?(0,J.jsxs)(K,{variant:`outline`,size:`sm`,disabled:y!==null,"data-focus-key":`cron-panel:delete:${e}:${u??``}`,onClick:()=>S(!0),children:[(0,J.jsx)(WC,{size:14,"aria-hidden":!0}),Ge()]}):null,(0,J.jsx)(K,{variant:`ghost`,size:`sm`,asChild:!0,children:(0,J.jsxs)(Mk,{to:`/settings/$tab`,params:{tab:`scheduled`},search:u===null?void 0:{job:u},children:[(0,J.jsx)(CA,{size:14,"aria-hidden":!0}),Tc()]})})]}):null,h!==null&&h.length>0?(0,J.jsxs)(`div`,{className:`oc-cronpanel__runs`,children:[(0,J.jsx)(`div`,{className:`oc-cronpanel__runs-label`,children:oee()}),h.map((e,t)=>(0,J.jsxs)(`div`,{className:`oc-cronpanel__run`,children:[(0,J.jsxs)(`div`,{className:`oc-cronpanel__run-head`,children:[pq(e.status),(0,J.jsx)(`span`,{children:fq(e.runAtMs??e.ts)}),typeof e.durationMs==`number`?(0,J.jsxs)(`span`,{className:`oc-cronpanel__run-dur`,children:[Math.round(e.durationMs/1e3),`s`]}):null]}),e.summary===null?null:(0,J.jsx)(`div`,{className:`oc-cronpanel__run-summary`,children:e.summary}),e.error===null?null:(0,J.jsx)(`div`,{className:`oc-cronpanel__run-error`,children:e.error}),e.delivered===!1?(0,J.jsxs)(`div`,{className:`oc-cronpanel__run-undelivered`,children:[rb({channel:e.deliveryChannel??`—`}),e.deliveryError===null?null:(0,J.jsx)(`span`,{className:`oc-cronpanel__plain`,children:e.deliveryError})]}):null]},t))]}):null,(0,J.jsx)(hw,{open:x,onOpenChange:S,children:(0,J.jsxs)(uw,{children:[(0,J.jsxs)(mw,{children:[(0,J.jsx)(lw,{children:Ym()}),(0,J.jsx)(cw,{children:yh({name:D.name??u??``})})]}),(0,J.jsxs)(fw,{children:[(0,J.jsx)(pw,{children:Mee()}),(0,J.jsx)(dw,{onClick:()=>{u!==null&&E(`delete`,()=>s({instanceName:e,jobId:u}),sf())},children:Z_()})]})]})})]})}var hq=class extends q.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(){}render(){return this.state.failed?(0,J.jsxs)(`div`,{className:`oc-panel-failed`,children:[(0,J.jsx)(`p`,{children:Rl()}),this.props.onClose===void 0?null:(0,J.jsx)(`button`,{type:`button`,className:`oc-panel-failed__close`,onClick:this.props.onClose,children:he()})]}):this.props.children}},gq=[`github-light`,`github-dark`],_q=[`code`,`math`,`cjk`];function vq(e,t){let n={};for(let r of _q){let i=e?.[r];if(i===!1)continue;let a=i||t[r];a&&(n[r]=a)}let r=e?.mermaid;return r&&r!==!1&&(n.mermaid=r),n}function yq(e){return typeof e==`object`&&!!e&&`type`in e&&`key`in e}function bq(e,t){return e===t?!0:!yq(e)||!yq(t)?!1:e.type===t.type&&e.key===t.key}function xq(e,t){let n=Object.keys(e).filter(e=>e!==`children`),r=Object.keys(t).filter(e=>e!==`children`);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return bq(e.children,t.children)}var Sq=(0,q.createContext)(null),Cq=(0,q.memo)(function({children:e,node:t,...n}){let r=(0,q.isValidElement)(e)?(0,q.cloneElement)(e,{"data-block":`true`}):e;return(0,J.jsx)(Sq.Provider,{value:{node:t,...n},children:r})},xq),wq=96,Tq=126,Eq=32,Dq=9,Oq=13,kq=92,Aq=e=>e===Eq||e===Dq||e===Oq;function jq(e,t,n){for(let r=t;r<n;r+=1)if(!Aq(e.charCodeAt(r)))return!1;return!0}function Mq(e){let t=e.length,n=!1,r=0,i=0,a=!1,o=0,s=-1;for(let c=0;c<=t;){let l=e.indexOf(`
15
+ `,c);l===-1&&(l=t);let u=c;for(;u<l&&Aq(e.charCodeAt(u));)u+=1;let d=u<l?e.charCodeAt(u):-1,f=!1;if((d===wq||d===Tq)&&u-c<=3){let t=u;for(;t<l&&e.charCodeAt(t)===d;)t+=1;t-u>=3&&(f=!0,n?d===r&&t-u>=i&&jq(e,t,l)&&(n=!1):(n=!0,r=d,i=t-u))}if(!n&&!f)for(let t=e.indexOf(`$$`,c);t!==-1&&t<l-1;t=e.indexOf(`$$`,t+2))(t===0||e.charCodeAt(t-1)!==kq)&&(a=!a);d===-1&&!n&&!a?s=l+1:s!==-1&&(o=s,s=-1),c=l+1}return o}function Nq(e,t){let n=Mq(e);return n<=0?Vw(e,t):e.slice(0,n)+Vw(e.slice(n),t)}var Pq=/language-([^\s]+)/;function Fq(e){if(typeof e==`string`)return e;if(!(0,q.isValidElement)(e))return``;let t=e.props;return t&&typeof t.children==`string`?t.children:``}function Iq({node:e,...t}){return(0,J.jsx)(`pre`,{...t})}function Lq({node:e,...t}){return(0,J.jsx)(`code`,{...t})}function Rq(e){let{SyntaxHighlighter:t,CodeHeader:n,componentsByLanguage:r={}}=e;function i({node:e,className:i,children:a,"data-block":o,...s}){if(!o)return(0,J.jsx)(`code`,{className:`aui-streamdown-inline-code ${i??``}`.trim(),...s,children:a});let c=i?.match(Pq)?.[1]??``,l=Fq(a),u=r[c]?.SyntaxHighlighter??t,d=r[c]?.CodeHeader??n,f=d?(0,J.jsx)(d,{node:e,language:c,code:l}):null;return u?(0,J.jsxs)(J.Fragment,{children:[f,(0,J.jsx)(u,{node:e,components:{Pre:Iq,Code:Lq},language:c,code:l})]}):(0,J.jsxs)(J.Fragment,{children:[f,(0,J.jsx)(Iq,{node:e,children:(0,J.jsx)(`code`,{className:i,...s,children:a})})]})}let a=(0,q.memo)(i,(e,t)=>e.className===t.className&&e[`data-block`]===t[`data-block`]&&e.children===t.children&&e.node?.position?.start.line===t.node?.position?.start.line&&e.node?.position?.end.line===t.node?.position?.end.line);return a.displayName=`AdaptedCode`,a}function zq(e){return!!(e.SyntaxHighlighter||e.CodeHeader||e.componentsByLanguage&&Object.keys(e.componentsByLanguage).length>0)}function Bq({components:e,componentsByLanguage:t}){return(0,q.useMemo)(()=>{let{SyntaxHighlighter:n,CodeHeader:r,...i}=e??{},a={SyntaxHighlighter:n,CodeHeader:r,componentsByLanguage:t},o={pre:Cq};if(!zq(a))return{...i,...o};let s=Rq(a);return{...i,...o,code:s}},[e,t])}function Vq(e){return[Kw,[Hw,{}],[Bw,{allowedImagePrefixes:e.allowedImagePrefixes??[`*`],allowedLinkPrefixes:e.allowedLinkPrefixes??[`*`],allowedProtocols:e.allowedProtocols??[`*`],allowDataImages:e.allowDataImages??!0,defaultOrigin:e.defaultOrigin,blockedLinkClass:e.blockedLinkClass,blockedImageClass:e.blockedImageClass}]]}var Hq=(0,q.forwardRef)(({components:e,componentsByLanguage:t,preprocess:n,defer:r=!1,smooth:i=!1,plugins:a,containerProps:o,containerClassName:s,caret:c,controls:l,linkSafety:u,remend:d,mermaid:f,parseIncompleteMarkdown:p,allowedTags:m,remarkRehypeOptions:h,security:g,BlockComponent:_,parseMarkdownIntoBlocksFn:v,mode:y=`streaming`,className:b,shikiTheme:x,...S},C)=>{let w=CW(),{text:T,status:E}=NW((0,q.useMemo)(()=>n?{...w,text:n(w.text)}:w,[w,n]),i),D=(0,q.useDeferredValue)(T),O=r?D:T,k=y===`streaming`&&p!==!1&&!v,A=(0,q.useMemo)(()=>k?Nq(O,d):O,[k,O,d]),j=!k&&p,M=(0,q.useMemo)(()=>{let e=vq(a,{});return Object.keys(e).length>0?e:void 0},[a]),N=(0,q.useMemo)(()=>x??(M?.code?gq:void 0),[x,M?.code]),P=Bq({components:e,componentsByLanguage:t}),F=(0,q.useMemo)(()=>{let{SyntaxHighlighter:t,CodeHeader:n,...r}=e??{};return{...r,...P}},[e,P]),I=(0,q.useMemo)(()=>[s,o?.className].filter(Boolean).join(` `)||void 0,[s,o?.className]),L=(0,q.useMemo)(()=>g?Vq(g):void 0,[g]),R={...b&&{className:b},...c&&{caret:c},...l!==void 0&&{controls:l},...u&&{linkSafety:u},...d&&{remend:d},...f&&{mermaid:f},...j!==void 0&&{parseIncompleteMarkdown:j},...m&&{allowedTags:m},...M&&{plugins:M},...N&&{shikiTheme:N},...h&&{remarkRehypeOptions:h},...L&&{rehypePlugins:L},..._&&{BlockComponent:_},...v&&{parseMarkdownIntoBlocksFn:v}};return(0,J.jsx)(`div`,{ref:C,"data-status":E.type,...o,className:I,children:(0,J.jsx)(Ww,{mode:y,isAnimating:E.type===`running`,components:F,...R,...S,children:A})})});Hq.displayName=`StreamdownTextPrimitive`;function Uq(e){return typeof e==`string`&&/^(https?:|mailto:)/i.test(e.trim())}function Wq(e){return e?`none`:void 0}var Gq=`(max-height: 499px) and (pointer: coarse)`,Kq=`(max-width: 767px), ${Gq}`,qq=`oc.sidebar.width`,Jq=`oc.sidebar.collapsed`,Yq=200,Xq=520,Zq=260;function Qq(){return $C(Kq)}function $q(){return $C(Gq)}var eJ=new Map;function tJ(e,t,n){let r=eJ.get(e);if(r!==void 0)for(let e of[...r])e!==n&&e(t)}function nJ(e){let{storageKey:t,defaultWidth:n,min:r,max:i,edge:a,maxViewportFraction:o}=e,s=e.fit??(e=>e),c=(0,q.useRef)(s);c.current=s;let l=(0,q.useCallback)(e=>Math.min(i,Math.max(r,e)),[r,i]),[u,d]=(0,q.useState)(()=>{let e=Number(localStorage.getItem(t));return l(e||n)}),[f,p]=(0,q.useState)(()=>window.innerWidth);(0,q.useEffect)(()=>{let e=()=>p(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let m=(0,q.useCallback)(e=>{let t=o===void 0?1/0:Math.round(f*o);return Math.min(Math.max(r,Math.min(i,t)),Math.max(r,e))},[r,i,o,f]),h=(0,q.useRef)(m);h.current=m;let g=(0,q.useRef)(u);g.current=u;let[_,v]=(0,q.useState)(null),y=s(m(_??u)),b=(0,q.useRef)(()=>{});(0,q.useEffect)(()=>{localStorage.setItem(t,String(u)),tJ(t,u,b.current)},[t,u]);let x=(0,q.useCallback)(e=>{localStorage.setItem(t,String(e)),tJ(t,e,b.current),d(e)},[t]);(0,q.useEffect)(()=>{let e=e=>d(e);b.current=e;let n=eJ.get(t)??new Set;return n.add(e),eJ.set(t,n),()=>{n.delete(e),n.size===0&&eJ.delete(t)}},[t]);let S=(0,q.useRef)(!1),C=(0,q.useRef)(null),w=(0,q.useRef)(null);return(0,q.useEffect)(()=>()=>w.current?.(),[]),{width:y,startResize:(0,q.useCallback)(e=>{if(w.current!==null)return;e.preventDefault(),S.current=!0;let t=e.pointerId,n=e.currentTarget;try{n.setPointerCapture(t)}catch{}let r=e.clientX,i=y,o=!1,s=a===`left`?1:-1,u=i,d=0,f=e=>c.current(h.current(e)),p=()=>{d=0;let e=C.current;if(e){let t=f(u);e.style.width=`${t}px`,e.style.flex=`0 0 ${t}px`}},m=e=>{if(!S.current||e.pointerId!==t)return;let n=l(i+s*(e.clientX-r));f(n)!==f(u)&&(o=!0),u=n,C.current?d===0&&(d=requestAnimationFrame(p)):v(u)},_=e=>{if(e instanceof PointerEvent&&e.pointerId!==t)return;S.current=!1,d!==0&&cancelAnimationFrame(d),v(null),window.removeEventListener(`pointermove`,m),window.removeEventListener(`pointerup`,_),window.removeEventListener(`pointercancel`,_),window.removeEventListener(`blur`,_),document.removeEventListener(`lostpointercapture`,_);try{n.hasPointerCapture(t)&&n.releasePointerCapture(t)}catch{}w.current=null,document.body.style.cursor=``,document.body.style.userSelect=``;let r=o&&u!==i,a=r?u:g.current,s=C.current;if(s){let e=f(a);s.style.width=`${e}px`,s.style.flex=`0 0 ${e}px`}r&&x(u)};w.current=_,window.addEventListener(`pointermove`,m),window.addEventListener(`pointerup`,_),window.addEventListener(`pointercancel`,_),window.addEventListener(`blur`,_),document.addEventListener(`lostpointercapture`,_),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},[y,a,m,l,x]),setWidth:d,columnRef:C}}function rJ(){let{width:e,startResize:t,columnRef:n}=nJ({storageKey:qq,defaultWidth:Zq,min:Yq,max:Xq,edge:`left`}),[r,i]=(0,q.useState)(()=>localStorage.getItem(Jq)===`1`),[a,o]=(0,q.useState)(!1),s=Qq();return(0,q.useEffect)(()=>{localStorage.setItem(Jq,r?`1`:`0`)},[r]),(0,q.useEffect)(()=>{s||o(!1)},[s]),{width:e,columnRef:n,collapsed:r,startResize:t,isMobile:s,drawerOpen:a,setDrawerOpen:o,toggleSidebar:(0,q.useCallback)(()=>{s?o(e=>!e):i(e=>!e)},[s]),closeDrawer:(0,q.useCallback)(()=>o(!1),[]),MIN_WIDTH:Yq,MAX_WIDTH:Xq}}function iJ({href:e,children:t,node:n,...r}){return Uq(e)?(0,J.jsx)(`a`,{...r,href:e,target:`_blank`,rel:`noopener noreferrer`,children:t}):(0,J.jsx)(`span`,{...r,children:t})}var aJ={a:iJ},oJ={a:iJ};function sJ({text:e}){let t=$q();return(0,J.jsx)(Ww,{className:`oc-md`,components:oJ,tableMaxHeight:Wq(t),children:e})}var cJ=(0,q.memo)(function(){let e=$(e=>e.metadata?.custom?.hasMergedRuns===!0);return(0,J.jsx)(Hq,{className:`oc-md`,tableMaxHeight:Wq($q()),smooth:!e,components:aJ})}),lJ=new Set(`txt.md.markdown.csv.tsv.log.json.yaml.yml.xml.html.css.js.ts.tsx.jsx.py.rb.go.rs.java.c.h.cpp.hpp.sh.bash.sql.toml.ini.env`.split(`.`)),uJ=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`avif`,`bmp`]),dJ=new Set([`application/vnd.openxmlformats-officedocument.presentationml.presentation`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/vnd.ms-powerpoint`,`application/msword`,`application/vnd.ms-excel`,`application/vnd.oasis.opendocument.text`,`application/vnd.oasis.opendocument.presentation`,`application/vnd.oasis.opendocument.spreadsheet`,`application/rtf`]),fJ=new Set([`pptx`,`ppt`,`docx`,`doc`,`xlsx`,`xls`,`odt`,`odp`,`ods`,`rtf`]);function pJ(e,t){let n=(e??``).toLowerCase();if(dJ.has(n))return!0;let r=mJ(t);return r!==null&&fJ.has(r)}function mJ(e){if(!e)return null;let t=e.lastIndexOf(`.`);return t<=0||t===e.length-1?null:e.slice(t+1).toLowerCase()}function hJ(e,t){let n=(e??``).split(`;`)[0].trim().toLowerCase(),r=mJ(t);if(n===`application/pdf`)return`pdf`;if(n.startsWith(`image/`))return`image`;if(n.startsWith(`video/`))return`video`;if(n.startsWith(`audio/`))return`audio`;if(n===`text/markdown`)return`markdown`;if(n===`text/csv`||n===`text/tab-separated-values`)return`csv`;if(n===`application/json`||n.endsWith(`+json`))return`json`;if(n===`text/x-log`)return`log`;if(n===``||n===`text/plain`||n===`application/octet-stream`||n===`binary/octet-stream`){if(r===`md`||r===`markdown`)return`markdown`;if(r===`csv`||r===`tsv`)return`csv`;if(r===`json`)return`json`;if(r===`log`)return`log`}return n.startsWith(`text/`)||n===`application/json`||n===`application/xml`||n===`application/x-yaml`?`text`:r===`pdf`?`pdf`:r!==null&&uJ.has(r)?`image`:r!==null&&lJ.has(r)?`text`:`none`}var gJ=[`fit`,.5,.75,1,1.5,2];function _J(e,t){return Number.isFinite(e)?Math.min(Math.max(1,Math.floor(e)),Math.max(1,Math.floor(t))):1}var vJ=512*1024,yJ=1e3,bJ=5e3;function xJ(e,t){if((e??``).split(`;`)[0].trim().toLowerCase()===`text/tab-separated-values`||mJ(t)===`tsv`)return` `}function SJ(e){let t=`,`,n=0;for(let r of[`,`,`;`,` `]){let i=CJ(e,r).length;i>n&&(t=r,n=i)}return t}function CJ(e,t){let n=[],r=``,i=!1;for(let a=0;a<e.length;a++){let o=e[a];i?o===`"`?e[a+1]===`"`?(r+=`"`,a++):i=!1:r+=o:o===`"`?i=!0:o===t?(n.push(r),r=``):r+=o}return n.push(r),n}function wJ(e,t=yJ,n){let r=[],i=``,a=!1,o=e.replace(/\r\n/g,`
16
+ `).replace(/\r/g,`
17
+ `);for(let e of o)e===`"`&&(a=!a),e===`
18
+ `&&!a?(r.push(i),i=``):i+=e;i!==``&&r.push(i);let s=r.findIndex(e=>e.trim()!==``);if(s===-1)return{header:[],rows:[],totalRows:0,truncatedRows:!1,delimiter:`,`};let c=n??SJ(r[s]),l=CJ(r[s],c),u=r.slice(s+1);return{header:l,rows:u.slice(0,t).map(e=>CJ(e,c)),totalRows:u.length,truncatedRows:u.length>t,delimiter:c}}function TJ(e,t){let n=e.trim(),r=t.trim();if(/^-?\d+$/.test(n)&&/^-?\d+$/.test(r)){let e=BigInt(n),t=BigInt(r);return e<t?-1:+(e>t)}let i=Number(e),a=Number(t);return n!==``&&r!==``&&!Number.isNaN(i)&&!Number.isNaN(a)?i-a:e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function EJ(e){return/\b(error|err|fatal|critical|panic)\b/i.test(e)?`error`:/\b(warn|warning)\b/i.test(e)?`warn`:/\b(info|notice)\b/i.test(e)?`info`:/\b(debug|trace|verbose)\b/i.test(e)?`debug`:`plain`}var DJ=60;function OJ({url:e,filename:t}){let[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(1),[c,l]=(0,q.useState)(`fit`);if((0,q.useEffect)(()=>{let t=!1,n=null;return r(null),a(!1),s(1),(async()=>{try{let i=await qw(()=>import(`./pdf-EQHMWEbX.js`),__vite__mapDeps([0,1]));i.GlobalWorkerOptions.workerSrc=new URL(`/assets/pdf.worker.min-CHFwMXne.mjs`,``+import.meta.url).toString();let a=i.getDocument({url:e}),o=await a.promise;if(t){a.destroy().catch(()=>{});return}n=a,r(o)}catch(e){console.error(`[docviewer] pdf load failed:`,e?.message??e),t||a(!0)}})(),()=>{t=!0,n&&n.destroy().catch(()=>{})}},[e]),i)return(0,J.jsxs)(`div`,{className:`oc-docviewer__fallback`,children:[(0,J.jsx)(`p`,{children:nv()}),(0,J.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`oc-docviewer__fallbacklink`,children:ff()})]});if(n===null)return(0,J.jsx)(`div`,{className:`oc-docviewer__loading`,children:i_()});let u=n.numPages,d=_J(o,u);return(0,J.jsxs)(`div`,{className:`oc-docviewer__pdf`,children:[(0,J.jsxs)(`div`,{className:`oc-docviewer__toolbar`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-docviewer__navbtn`,onClick:()=>s(e=>_J(e-1,u)),disabled:d<=1,"aria-label":hy(),children:(0,J.jsx)($S,{size:15})}),(0,J.jsxs)(`span`,{className:`oc-docviewer__pageinfo`,children:[d,` / `,u]}),(0,J.jsx)(`button`,{type:`button`,className:`oc-docviewer__navbtn`,onClick:()=>s(e=>_J(e+1,u)),disabled:d>=u,"aria-label":M_(),children:(0,J.jsx)(eC,{size:15})}),(0,J.jsx)(`select`,{className:`oc-docviewer__zoom`,value:String(c),onChange:e=>{let t=e.target.value;l(t===`fit`?`fit`:Number(t))},"aria-label":wh(),children:gJ.map(e=>(0,J.jsx)(`option`,{value:String(e),children:e===`fit`?eh():`${Math.round(e*100)}%`},String(e)))})]}),(0,J.jsxs)(`div`,{className:`oc-docviewer__pdfbody`,children:[u>1?(0,J.jsxs)(`div`,{className:`oc-docviewer__rail`,"aria-label":Dp(),children:[Array.from({length:Math.min(u,DJ)},(e,t)=>(0,J.jsx)(AJ,{doc:n,page:t+1,active:t+1===d,onClick:()=>s(t+1)},t+1)),u>DJ?(0,J.jsxs)(`span`,{className:`oc-docviewer__railmore`,children:[`+`,u-DJ]}):null]}):null,(0,J.jsx)(kJ,{doc:n,page:d,zoom:c,filename:t})]})]})}function kJ({doc:e,page:t,zoom:n,filename:r}){let i=(0,q.useRef)(null),a=(0,q.useRef)(null),[o,s]=(0,q.useState)(0);return(0,q.useEffect)(()=>{let e=i.current;if(!e)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width??0;s(e=>Math.abs(e-t)>1?t:e)});return t.observe(e),()=>t.disconnect()},[]),(0,q.useEffect)(()=>{let r=!1,i=null;return(async()=>{try{let s=await e.getPage(t),c=a.current;if(r||!c)return;let l=s.getViewport({scale:1}),u=n===`fit`?Math.max(.1,(o-16)/l.width):n,d=window.devicePixelRatio||1,f=s.getViewport({scale:u*d});c.width=Math.floor(f.width),c.height=Math.floor(f.height),c.style.width=`${Math.floor(f.width/d)}px`,c.style.height=`${Math.floor(f.height/d)}px`;let p=s.render({canvas:c,viewport:f});i=p,await p.promise}catch(e){e?.name!==`RenderingCancelledException`&&console.error(`[docviewer] page render failed:`,e?.message??e)}})(),()=>{r=!0,i?.cancel()}},[e,t,n,o]),(0,J.jsx)(`div`,{ref:i,className:`oc-docviewer__main`,children:(0,J.jsx)(`canvas`,{ref:a,className:`oc-docviewer__canvas`,"aria-label":r})})}function AJ({doc:e,page:t,active:n,onClick:r}){let i=(0,q.useRef)(null);return(0,q.useEffect)(()=>{let n=!1,r=null;return(async()=>{try{let a=await e.getPage(t),o=i.current;if(n||!o)return;let s=104/a.getViewport({scale:1}).width,c=a.getViewport({scale:s});o.width=Math.floor(c.width),o.height=Math.floor(c.height);let l=a.render({canvas:o,viewport:c});r=l,await l.promise}catch(e){e?.name!==`RenderingCancelledException`&&console.error(`[docviewer] thumbnail render failed:`,e?.message??e)}})(),()=>{n=!0,r?.cancel()}},[e,t]),(0,J.jsxs)(`button`,{type:`button`,className:`oc-docviewer__thumb${n?` is-active`:``}`,onClick:r,"aria-label":Nf({page:t}),"aria-current":n?`true`:void 0,children:[(0,J.jsx)(`canvas`,{ref:i,className:`oc-docviewer__thumbcanvas`}),(0,J.jsx)(`span`,{className:`oc-docviewer__thumbnum`,children:t})]})}var jJ={current:null},MJ=(0,q.createContext)(jJ);function NJ(e){let t=0,n=e.match(/`+/g);if(n!==null)for(let e of n)t=Math.max(t,e.length);return"`".repeat(Math.max(3,t+1))}function PJ(e,t,n){let r=NJ(t);return`\n${e} ${n}\n${r}\n${t}\n${r}\n`}function FJ(e,t){let n=e.length,r=1;for(let t=0;t<e.length;t++)e.charCodeAt(t)===10&&r++;return n<=8e3&&r<=150?{kind:`inline`,lines:r,chars:n}:{kind:`file`,filename:`texte-colle-${t}.txt`,lines:r,chars:n}}var IJ=new WeakSet;function LJ(e){IJ.add(e)}function RJ(e){return IJ.has(e)}var zJ=(0,q.createContext)({activeDoc:null,openFor:()=>{},openNewerVersion:()=>{},close:()=>{}});function BJ(){return(0,q.useContext)(zJ)}function VJ({doc:e,chatId:t,onClose:n}){let r=hJ(e.mimeType,e.filename),i=r===`none`&&e.sourceStorageId!==void 0,a=BJ(),o=H(G.documentDrafts.latestDeliveredFile,t===null?`skip`:{chatId:t,filename:e.filename,...e.storageId===void 0?{}:{currentStorageId:e.storageId}}),s=o!=null&&(e.storageId===void 0?o.url!==e.url:o.storageId!==e.storageId)?o:null;return(0,J.jsxs)(`div`,{className:`oc-docviewer`,children:[(0,J.jsxs)(`header`,{className:`oc-docviewer__header`,children:[(0,J.jsx)(TA,{size:15,"aria-hidden":!0,className:`oc-docviewer__icon`}),(0,J.jsx)(`span`,{className:`oc-docviewer__name`,title:e.filename,children:e.filename}),(0,J.jsx)(`a`,{className:`oc-docviewer__action`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:ff(),"aria-label":ff(),children:(0,J.jsx)(CA,{size:14})}),(0,J.jsx)(`a`,{className:`oc-docviewer__action`,href:e.url,download:e.filename,title:Ra(),"aria-label":Ra(),children:(0,J.jsx)(bC,{size:14})}),(0,J.jsx)(K,{type:`button`,size:`icon-sm`,variant:`ghost`,onClick:n,"aria-label":uo(),children:(0,J.jsx)(YC,{size:15})})]}),(0,J.jsxs)(`div`,{className:`oc-docviewer__body`,children:[s===null?null:(0,J.jsxs)(`div`,{className:`oc-docviewer__newversion`,role:`status`,children:[(0,J.jsx)(`span`,{children:yx()}),(0,J.jsx)(K,{type:`button`,size:`sm`,variant:`secondary`,onClick:()=>a.openNewerVersion({url:s.url,filename:e.filename,mimeType:s.mimeType||null,storageId:s.storageId,sourceStorageId:pJ(s.mimeType,e.filename)?s.storageId:void 0}),children:ic()})]}),r===`pdf`?(0,J.jsx)(OJ,{url:e.url,filename:e.filename}):r===`image`?(0,J.jsx)(`div`,{className:`oc-docviewer__imagewrap`,children:(0,J.jsx)(`img`,{src:e.url,alt:e.filename,className:`oc-docviewer__image`})}):r===`video`?(0,J.jsx)(`video`,{controls:!0,preload:`metadata`,src:e.url,className:`oc-docviewer__video`}):r===`audio`?(0,J.jsx)(`div`,{className:`oc-docviewer__audiowrap`,children:(0,J.jsx)(`audio`,{controls:!0,preload:`metadata`,src:e.url,className:`oc-docviewer__audio`})}):r===`text`?(0,J.jsx)(GJ,{url:e.url,chatId:t,filename:e.filename,mimeType:e.mimeType,storageId:e.storageId??null},e.url):r===`markdown`||r===`csv`||r===`log`||r===`json`?(0,J.jsx)(GJ,{url:e.url,chatId:t,filename:e.filename,mimeType:e.mimeType,storageId:e.storageId??null,rich:r,csvDelimiter:r===`csv`?xJ(e.mimeType,e.filename):void 0},e.url):i?(0,J.jsx)(HJ,{sourceStorageId:e.sourceStorageId,chatId:t,downloadUrl:e.url,filename:e.filename}):(0,J.jsxs)(`div`,{className:`oc-docviewer__fallback`,children:[(0,J.jsx)(`p`,{children:Nm()}),(0,J.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`oc-docviewer__fallbacklink`,children:Ra()})]})]})]})}function HJ({sourceStorageId:e,chatId:t,downloadUrl:n,filename:r}){let i=t===null?{}:{chatId:t},a=H(G.fileRenditions.getRendition,{sourceStorageId:e,...i}),o=U(G.fileRenditions.requestRendition),s=(0,q.useRef)(null);return(0,q.useEffect)(()=>{s.current=null},[e]),(0,q.useEffect)(()=>{a?.status===`pending`&&s.current!==e&&(s.current=e,o({sourceStorageId:e,...i}).catch(e=>{console.error(`[docviewer] rendition request failed:`,e)}))},[a?.status,e,o]),a===void 0?(0,J.jsx)(`div`,{className:`oc-docviewer__loading`,children:i_()}):a.status===`ready`?(0,J.jsx)(OJ,{url:a.pdfUrl,filename:a.filename}):a.status===`pending`?(0,J.jsxs)(`div`,{className:`oc-docviewer__preparing`,children:[(0,J.jsx)(`span`,{className:`oc-docviewer__spinner`,"aria-hidden":!0}),(0,J.jsx)(`p`,{children:Zp()}),(0,J.jsx)(`a`,{href:n,download:r,className:`oc-docviewer__fallbacklink`,children:Ra()})]}):(0,J.jsxs)(`div`,{className:`oc-docviewer__fallback`,children:[(0,J.jsx)(`p`,{children:a.status===`unconfigured`?Nm():sb()}),(0,J.jsx)(`a`,{href:n,download:r,className:`oc-docviewer__fallbacklink`,children:Ra()})]})}function UJ(e){switch(e){case`markdown`:return Pg();case`csv`:return Lo();case`log`:return vt();case`json`:return Ht()}}var WJ=e=>`oc.docviewer.raw.${e}`;function GJ({url:e,chatId:t,filename:n,mimeType:r,storageId:i,rich:a,csvDelimiter:o}){let[s,c]=(0,q.useState)({phase:`loading`}),[l,u]=(0,q.useState)(()=>a?localStorage.getItem(WJ(a))===`1`:!1),d=e=>{u(e),a&&localStorage.setItem(WJ(a),e?`1`:`0`)},[f,p]=(0,q.useState)(!1),m=H(G.documentDrafts.getDraft,t===null?`skip`:{chatId:t,filename:n}),h=t!==null&&s.phase===`ready`&&!s.truncated&&m!==void 0;if((0,q.useEffect)(()=>{let t=!1;return c({phase:`loading`}),(async()=>{try{let n=await fetch(e);if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.blob(),i=r.size>vJ,a=await(i?r.slice(0,vJ):r).text();t||c({phase:`ready`,text:a,truncated:i})}catch(e){console.error(`[docviewer] text fetch failed:`,e?.message??e),t||c({phase:`error`})}})(),()=>{t=!0}},[e]),s.phase===`loading`)return(0,J.jsx)(`div`,{className:`oc-docviewer__loading`,children:i_()});if(s.phase===`error`)return(0,J.jsxs)(`div`,{className:`oc-docviewer__fallback`,children:[(0,J.jsx)(`p`,{children:nv()}),(0,J.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`oc-docviewer__fallbacklink`,children:ff()})]});let g=a!==void 0&&!l,_=s.truncated?(0,J.jsx)(`p`,{className:`oc-docviewer__truncated`,children:_ee()}):null,v=m?.text??s.text,y=m==null?null:(0,J.jsx)(KJ,{chatId:t,filename:n,diverged:m.sourceStorageId!==null&&i!==null&&m.sourceStorageId!==i}),b=f?(0,J.jsx)(qJ,{chatId:t,filename:n,mimeType:r,sourceStorageId:i,initialText:v,hasDraft:m!=null,onExit:()=>p(!1)}):g&&a===`markdown`?(0,J.jsx)(`div`,{className:`oc-docviewer__mdwrap`,children:(0,J.jsx)(sJ,{text:v})}):g&&a===`csv`?(0,J.jsx)(JJ,{text:v,textTruncated:s.truncated,delimiter:o}):g&&a===`log`?(0,J.jsx)(YJ,{text:v,textTruncated:s.truncated}):g&&a===`json`?(0,J.jsx)(XJ,{text:v}):(0,J.jsx)(`pre`,{className:`oc-docviewer__text`,children:v});return a===void 0&&!h?(0,J.jsxs)(`div`,{className:`oc-docviewer__textwrap`,children:[_,y,b]}):(0,J.jsxs)(`div`,{className:`oc-docviewer__textwrap oc-docviewer__textwrap--bar`,children:[(0,J.jsxs)(`div`,{className:`oc-docviewer__mdbar`,role:`group`,"aria-label":pg(),children:[a===void 0?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(K,{type:`button`,size:`sm`,variant:g&&!f?`secondary`:`ghost`,"aria-pressed":g&&!f,onClick:()=>{p(!1),d(!1)},children:UJ(a)}),(0,J.jsx)(K,{type:`button`,size:`sm`,variant:l&&!f?`secondary`:`ghost`,"aria-pressed":l&&!f,onClick:()=>{p(!1),d(!0)},children:te()})]}),h?(0,J.jsxs)(K,{type:`button`,size:`sm`,variant:f?`secondary`:`ghost`,"aria-pressed":f,onClick:()=>p(e=>!e),className:`oc-docviewer__editbtn`,children:[(0,J.jsx)(IC,{size:13,"aria-hidden":!0}),Ms(),m==null?null:(0,J.jsx)(`span`,{className:`oc-docviewer__draftdot`,"aria-hidden":!0})]}):null]}),f?b:(0,J.jsx)(`div`,{className:`oc-docviewer__textscroll`,children:(0,J.jsxs)(`div`,{className:`oc-docviewer__scrollpad`,children:[_,y,b]})})]})}function KJ({chatId:e,filename:t,diverged:n}){let r=U(G.documentDrafts.deleteDraft),i=Iw();return(0,J.jsxs)(`p`,{className:`oc-docviewer__draftnote`,children:[n?Ee():Jl(),(0,J.jsx)(`button`,{type:`button`,className:`oc-docviewer__draftnote-discard`,onClick:()=>void r({chatId:e,filename:t}).then(e=>{e.applied===!1&&i.error(cs())}).catch(()=>i.error(pn())),children:wv()})]})}function qJ({chatId:e,filename:t,mimeType:n,sourceStorageId:r,initialText:i,hasDraft:a,onExit:o}){let s=U(G.documentDrafts.saveDraft),c=U(G.documentDrafts.deleteDraft),l=(0,q.useContext)(MJ),u=Iw(),d=`oc.docdraft.fallback.${e}.${t}`,[f,p]=(0,q.useState)(()=>{try{let e=localStorage.getItem(d);if(e!==null)return e}catch{}return i}),[m,h]=(0,q.useState)(`idle`),g=(0,q.useRef)(0),_=(0,q.useRef)(f);_.current=f;let v=(0,q.useRef)(!1),y=(0,q.useRef)(!1),b=(0,q.useCallback)(n=>{h(`saving`),s({chatId:e,filename:t,text:n,...r!==null&&(y.current||!a)?{sourceStorageId:r}:{}}).then(e=>{if(e.applied===!1){u.error(cs()),h(`idle`);return}h(`saved`)}).catch(e=>{console.error(`[docviewer] draft save failed:`,e),u.error(String(e?.message??e).includes(`draft_limit_reached`)?ui():hd()),h(`idle`)})},[s,e,t,r,a,u]),x=e=>{y.current=!0,p(e),window.clearTimeout(g.current),g.current=window.setTimeout(()=>b(e),800)};return(0,q.useEffect)(()=>{try{localStorage.getItem(d)!==null&&(y.current=!0,s({chatId:e,filename:t,text:_.current,...r===null?{}:{sourceStorageId:r}}).then(()=>localStorage.removeItem(d)))}catch{}let n=()=>{if(!(!y.current||v.current))try{localStorage.setItem(d,_.current)}catch{}};return window.addEventListener(`pagehide`,n),()=>{if(window.removeEventListener(`pagehide`,n),window.clearTimeout(g.current),!v.current&&y.current){try{localStorage.setItem(d,_.current)}catch{}s({chatId:e,filename:t,text:_.current,...r===null?{}:{sourceStorageId:r}}).then(()=>{try{localStorage.removeItem(d)}catch{}}).catch(()=>{})}}},[]),(0,J.jsxs)(`div`,{className:`oc-docviewer__editor`,children:[(0,J.jsx)(`textarea`,{className:`oc-docviewer__editarea`,value:f,onChange:e=>x(e.target.value),spellCheck:!1,"aria-label":Ms()}),(0,J.jsxs)(`div`,{className:`oc-docviewer__editbar`,children:[(0,J.jsx)(`span`,{className:`oc-docviewer__savestate`,role:`status`,children:m===`saving`?Hd():m===`saved`?Wu():`\xA0`}),(0,J.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{v.current=!0,window.clearTimeout(g.current);try{localStorage.removeItem(d)}catch{}c({chatId:e,filename:t}).then(e=>{if(e.applied===!1){v.current=!1,u.error(cs());return}o()}).catch(e=>{console.error(`[docviewer] draft discard failed:`,e),v.current=!1,u.error(pn())})},children:wv()}),(0,J.jsx)(K,{type:`button`,size:`sm`,variant:`secondary`,onClick:()=>{let e=l?.current??null;if(e===null){u.error(ur());return}if(window.clearTimeout(g.current),b(f),e.canAttach){let r=(n??`text/plain`).split(`;`)[0].trim(),i=new File([f],t,{type:`${r}; charset=utf-8`});e.attachFile(i).catch(e=>{console.error(`[docviewer] attach failed:`,e),u.error(Cl())})}else{if(f.length>8e3){u.error(Lr());return}e.insertText(PJ(t,f,da()))}},children:Li()})]})]})}function JJ({text:e,textTruncated:t,delimiter:n}){let r=(0,q.useMemo)(()=>wJ(e,void 0,n),[e,n]),[i,a]=(0,q.useState)(null),o=(0,q.useMemo)(()=>i?[...r.rows].sort((e,t)=>TJ(e[i.col]??``,t[i.col]??``)*i.dir):r.rows,[r.rows,i]);if(r.header.length===0)return(0,J.jsx)(`pre`,{className:`oc-docviewer__text`,children:e});let s=r.header.slice(0,100),c=r.header.length>s.length;return(0,J.jsxs)(`div`,{className:`oc-docviewer__csvwrap`,children:[r.truncatedRows?(0,J.jsx)(`p`,{className:`oc-docviewer__truncated`,children:t?ite({shown:r.rows.length}):el({shown:r.rows.length,total:r.totalRows})}):null,c?(0,J.jsx)(`p`,{className:`oc-docviewer__truncated`,children:Ye({shown:s.length,total:r.header.length})}):null,(0,J.jsxs)(`table`,{className:`oc-docviewer__csv`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsx)(`tr`,{children:s.map((e,t)=>(0,J.jsx)(`th`,{children:(0,J.jsxs)(`button`,{type:`button`,className:`oc-docviewer__csvsort`,onClick:()=>a(e=>e?.col===t?e.dir===1?{col:t,dir:-1}:null:{col:t,dir:1}),"aria-label":Ac({column:e}),children:[e,i?.col===t?i.dir===1?` ▲`:` ▼`:``]})},t))})}),(0,J.jsx)(`tbody`,{children:o.map((e,t)=>(0,J.jsx)(`tr`,{children:s.map((t,n)=>(0,J.jsx)(`td`,{children:e[n]??``},n))},t))})]})]})}function YJ({text:e,textTruncated:t}){let n=(0,q.useMemo)(()=>{let t=e.split(`
19
+ `);return t.length>1&&t[t.length-1]===``&&t.pop(),t},[e]),r=(0,q.useMemo)(()=>n.slice(0,bJ),[n]);return(0,J.jsxs)(J.Fragment,{children:[n.length>r.length?(0,J.jsx)(`p`,{className:`oc-docviewer__truncated`,children:t?ap({shown:r.length}):Dte({shown:r.length,total:n.length})}):null,(0,J.jsx)(`pre`,{className:`oc-docviewer__text oc-docviewer__logview`,children:r.map((e,t)=>(0,J.jsxs)(`span`,{className:`oc-logline oc-logline--${EJ(e)}`,children:[e,`
20
+ `]},t))})]})}function XJ({text:e}){let t=(0,q.useMemo)(()=>{try{return{ok:!0,value:JSON.parse(e,(e,t,n)=>{if(typeof t==`number`&&Number.isInteger(t)&&!Number.isSafeInteger(t)&&typeof n?.source==`string`&&/^-?\d+$/.test(n.source))try{return BigInt(n.source)}catch{return t}return t})}}catch{return{ok:!1}}},[e]);return t.ok?(0,J.jsx)(`div`,{className:`oc-docviewer__jsonwrap`,children:(0,J.jsx)($J,{value:t.value,depth:0})}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`oc-docviewer__truncated`,children:qte()}),(0,J.jsx)(`pre`,{className:`oc-docviewer__text`,children:e})]})}function ZJ(e){if(Array.isArray(e))return e.length;let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function QJ(e,t){if(Array.isArray(e))return e.slice(0,t).map((e,t)=>[String(t),e]);let n=[];for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(n.length>=t)break;n.push([r,e[r]])}return n}function $J({value:e,depth:t,name:n}){let r=typeof e==`object`&&!!e,i=r?ZJ(e):0,[a,o]=(0,q.useState)(t<2&&i<=100),s=n===void 0?null:(0,J.jsxs)(`span`,{className:`oc-json__key`,children:[n,`: `]});if(!r)return(0,J.jsxs)(`div`,{className:`oc-json__leaf`,children:[s,(0,J.jsx)(`span`,{className:`oc-json__val oc-json__val--${e===null?`null`:typeof e==`bigint`?`number`:typeof e}`,children:typeof e==`bigint`?e.toString():JSON.stringify(e)})]});let c=a?QJ(e,500):[];return(0,J.jsxs)(`details`,{className:`oc-json__node`,open:a,onToggle:e=>o(e.target.open),children:[(0,J.jsxs)(`summary`,{children:[s,(0,J.jsx)(`span`,{className:`oc-json__summary`,children:Array.isArray(e)?`[${i}]`:`{${i}}`})]}),a?(0,J.jsxs)(`div`,{className:`oc-json__children`,children:[c.map(([e,n])=>(0,J.jsx)($J,{name:e,value:n,depth:t+1},e)),i>c.length?(0,J.jsx)(`div`,{className:`oc-json__more`,children:Pb({count:i-c.length})}):null]}):null]})}var eY=(0,q.createContext)(null);function tY(){return(0,q.useContext)(eY)??{open:()=>{}}}function nY({children:e}){let[t,n]=(0,q.useState)(null),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1),s=(0,q.useRef)(null),c=(0,q.useCallback)(e=>{n(e),i(!1)},[]),l=(0,q.useCallback)(()=>{document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),n(null),o(!1)},[]);(0,q.useEffect)(()=>{if(t===null)return;let e=e=>{e.key===`Escape`&&l()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,l]),(0,q.useEffect)(()=>{let e=()=>o(document.fullscreenElement!==null);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let u=(0,q.useCallback)(()=>{let e=s.current;e&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):e.requestFullscreen().catch(()=>{}))},[]);return(0,J.jsxs)(eY.Provider,{value:{open:c},children:[e,t===null?null:(0,bk.createPortal)((0,J.jsxs)(`div`,{ref:s,className:`oc-lightbox`,role:`dialog`,"aria-modal":`true`,"aria-label":t.name,onClick:e=>{e.target===e.currentTarget&&l()},children:[(0,J.jsxs)(`div`,{className:`oc-lightbox__bar`,children:[(0,J.jsx)(`span`,{className:`oc-lightbox__name`,title:t.name,children:t.name}),(0,J.jsx)(`button`,{type:`button`,className:`oc-lightbox__btn`,onClick:()=>i(e=>!e),"aria-label":r?ae():zg(),title:r?ae():zg(),children:r?(0,J.jsx)(Tj,{size:18}):(0,J.jsx)(wj,{size:18})}),(0,J.jsx)(`button`,{type:`button`,className:`oc-lightbox__btn`,onClick:u,"aria-label":a?Ct():Ho(),title:a?Ct():Ho(),children:a?(0,J.jsx)(ZA,{size:18}):(0,J.jsx)(qA,{size:18})}),(0,J.jsx)(`a`,{className:`oc-lightbox__btn`,href:t.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":Kt(),title:Kt(),children:(0,J.jsx)(CA,{size:18})}),(0,J.jsx)(`button`,{type:`button`,className:`oc-lightbox__btn`,onClick:l,"aria-label":il(),title:il(),children:(0,J.jsx)(YC,{size:18})})]}),(0,J.jsx)(`div`,{className:`oc-lightbox__stage${r?` oc-lightbox__stage--scroll`:``}`,onClick:e=>{e.target===e.currentTarget&&l()},children:(0,J.jsx)(`img`,{src:t.url,alt:t.name,className:r?`oc-lightbox__img--actual`:`oc-lightbox__img--fit`,decoding:`async`})})]}),document.body)]})}function rY(e,t){return t===`memory`?`memory`:e.context===!0||!e.file_name?`context`:`document`}function iY(e){let t={memory:0,documents:0,context:0};for(let n of e)for(let e of n.items){let r=rY(e,n.group);r===`memory`?t.memory+=1:r===`document`?t.documents+=1:t.context+=1}return t}function aY(e){return e.memory+e.documents+e.context>0}function oY(e){let t=[];return e.memory>0&&t.push(e.memory===1?Yb():Ue({count:e.memory})),e.documents>0&&t.push(e.documents===1?Cc():bte({count:e.documents})),e.context>0&&t.push(e.context===1?af():qm({count:e.context})),t.join(` · `)}function sY(e){return e.title??e.file_name??e.id??e.type??Y_()}function cY(e){return e.title&&e.file_name?e.file_name:void 0}function lY(e){return e.file_name??sY(e)}function uY(e){let t=[];return e.type&&sY(e)!==e.type&&t.push(e.type),e.date&&t.push(e.date),e.collection&&t.push(e.collection),typeof e.score==`number`&&t.push(r_({score:e.score.toFixed(2)})),t}function dY(e,t){let n=[];return e.forEach((e,r)=>{e.group===t&&e.items.forEach((t,i)=>{n.push({key:`${e.pluginId}|${e.group}|${t.id??t.file_name??`?`}|${r}.${i}`,group:e.group,pluginId:e.pluginId,source:e.source,item:t})})}),n.sort((e,t)=>(t.item.score??0)-(e.item.score??0))}function fY(e,t){let n=t.trim().toLowerCase();return n===``||[hY(e),e.item.file_name??``,e.item.text??``,...uY(e.item)].join(` `).toLowerCase().includes(n)}function pY(e){return rY(e.item,e.group)===`document`}function mY(e){return rY(e.item,e.group)===`context`}function hY(e){return mY(e)?_h():sY(e.item)}var gY=(0,q.createContext)(null),_Y=[];function vY(){let e=$(e=>e.metadata?.custom?.provenanceParts??_Y),t=$(e=>e.metadata?.custom?.messageId),n=$(e=>e.metadata?.custom?.attachedDocCount??0),r=(0,q.useContext)(gY),i=iY(e);if(e.length===0||!aY(i))return null;let a=r?.activeMessageId===t&&t!==void 0,o=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`oc-actrow__counts`,children:oY(i)}),n>0?(0,J.jsxs)(`span`,{className:`oc-actrow__badge`,title:Vh({count:n}),children:[(0,J.jsx)(bC,{size:12,"aria-hidden":!0}),n]}):null]});return(0,J.jsx)(oq,{icon:(0,J.jsx)(TA,{size:14}),label:qc(),trailing:o,active:a,ariaExpanded:a,ariaHasPopup:!0,ariaLabel:Wp(),onClick:()=>t&&r?.openFor(t)})}function yY({messageId:e,onClose:t}){let n=H(G.messages.getProvenanceParts,{messageId:e}),r=(0,q.useMemo)(()=>n??[],[n]),i=H(G.agents.documentaryAvailable,{}),a=H(G.documentAttachments.getDocumentAttachments,{sourceMessageId:e}),o=U(G.documentAttachments.attachDocuments),s=Iw(),c=(0,q.useMemo)(()=>{let e=new Map;for(let t of a??[])e.set(t.entryKey,t);return e},[a]),u=(a??[]).some(e=>e.status===`pending`),[d,f]=(0,q.useState)(``),[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(!1),[y,b]=(0,q.useState)(new Set);(0,q.useEffect)(()=>{f(``),m(!1),g(!1),v(!1),b(new Set)},[e]);let x=(0,q.useMemo)(()=>dY(r,`documents`).filter(e=>pY(e)&&fY(e,d)),[r,d]),S=(0,q.useMemo)(()=>dY(r,`documents`).filter(e=>mY(e)&&fY(e,d)),[r,d]),C=(0,q.useMemo)(()=>dY(r,`memory`).filter(e=>fY(e,d)),[r,d]),w=iY(r),T=e=>b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),E=(e,t)=>b(n=>{let r=new Set(n);for(let n of e)t?r.add(n):r.delete(n);return r}),D=(0,q.useMemo)(()=>dY(r,`documents`).filter(e=>pY(e)&&y.has(e.key)),[r,y]),O=i!=null&&D.length>0&&!u;async function k(){if(O)try{await o({sourceMessageId:e,items:D.map(e=>({entryKey:e.key,reference:lY(e.item)}))}),s.success(hm())}catch(e){let t=Fw(e);t.includes(`fetch_in_flight`)?s.error(Ny()):t.includes(`no_documentary_agent`)?s.error(l_()):s.error(l(),e)}}let A=n===void 0;return(0,J.jsxs)(`div`,{className:`oc-sources-panel`,children:[(0,J.jsxs)(`div`,{className:`oc-sources-panel__head`,children:[(0,J.jsxs)(`div`,{className:`oc-sources-panel__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-sources-panel__title`,children:iee()}),(0,J.jsx)(`p`,{className:`oc-sources-panel__sub`,children:oY(w)})]}),(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn`,onClick:t,"aria-label":mv(),title:mv(),children:(0,J.jsx)(YC,{size:16,"aria-hidden":!0})})]}),(0,J.jsxs)(`div`,{className:`oc-sources-panel__search`,children:[(0,J.jsx)(vC,{size:15,"aria-hidden":!0}),(0,J.jsx)(Tw,{value:d,onChange:e=>f(e.target.value),placeholder:tb(),"aria-label":tb()})]}),(0,J.jsx)(`div`,{className:`oc-sources-panel__body`,children:A?(0,J.jsx)(`p`,{className:`oc-sources-panel__empty`,children:(0,J.jsx)(OC,{size:14,className:`oc-iconbtn__spin`,"aria-hidden":!0})}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(bY,{icon:(0,J.jsx)(TA,{size:14,"aria-hidden":!0}),label:Hte(),count:x.length,expanded:p,onToggle:()=>m(e=>!e),entries:x,selectable:!0,selected:y,onToggle1:T,onToggleAll:e=>E(x.map(e=>e.key),e),attachmentByKey:c}),(0,J.jsx)(bY,{icon:(0,J.jsx)(ej,{size:14,"aria-hidden":!0}),label:Eb(),count:S.length,expanded:h,onToggle:()=>g(e=>!e),entries:S,selectable:!1,selected:y,onToggle1:T,onToggleAll:e=>E(S.map(e=>e.key),e),attachmentByKey:c}),(0,J.jsx)(bY,{icon:(0,J.jsx)(dA,{size:14,"aria-hidden":!0}),label:Qf(),count:C.length,expanded:_,onToggle:()=>v(e=>!e),entries:C,selectable:!1,selected:y,onToggle1:T,onToggleAll:e=>E(C.map(e=>e.key),e),attachmentByKey:c}),x.length===0&&S.length===0&&C.length===0?(0,J.jsx)(`p`,{className:`oc-sources-panel__empty`,children:Qg()}):null]})}),D.length>0?(0,J.jsxs)(`div`,{className:`oc-sources-panel__actions`,children:[(0,J.jsxs)(`div`,{className:`oc-sources-panel__actrow`,children:[(0,J.jsx)(`span`,{className:`oc-sources-panel__selcount`,children:ly({count:D.length})}),(0,J.jsxs)(K,{variant:`outline`,size:`sm`,disabled:!O,onClick:()=>void k(),children:[u?(0,J.jsx)(OC,{size:14,className:`oc-iconbtn__spin`,"aria-hidden":!0}):(0,J.jsx)(hj,{size:14,"aria-hidden":!0}),E_()]})]}),(0,J.jsx)(`p`,{className:`oc-sources-panel__acthint`,children:i==null?l_():u?Ny():kf()})]}):null]})}function bY({icon:e,label:t,count:n,expanded:r,onToggle:i,entries:a,selectable:o,selected:s,onToggle1:c,onToggleAll:l,attachmentByKey:u}){if(n===0)return null;let d=a.every(e=>s.has(e.key));return(0,J.jsxs)(`section`,{className:`oc-srcsec${r?` is-open`:``}`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-srcsec__head`,"aria-expanded":r,onClick:i,children:[r?(0,J.jsx)(QS,{size:14,"aria-hidden":!0}):(0,J.jsx)(eC,{size:14,"aria-hidden":!0}),e,(0,J.jsx)(`span`,{className:`oc-srcsec__label`,children:t}),(0,J.jsx)(`span`,{className:`oc-srcsec__count`,children:n})]}),r?(0,J.jsxs)(`div`,{className:`oc-srcsec__body`,children:[o?(0,J.jsxs)(`label`,{className:`oc-srcsec__all`,children:[(0,J.jsx)(AC,{checked:d,onCheckedChange:e=>l(e===!0)}),(0,J.jsx)(`span`,{children:Sp()})]}):null,a.map(e=>(0,J.jsx)(xY,{entry:e,selectable:o,selected:s.has(e.key),onToggle:()=>c(e.key),attachment:u.get(e.key)},e.key))]}):null]})}function xY({entry:e,selectable:t,selected:n,onToggle:r,attachment:i}){let[a,o]=(0,q.useState)(!1),s=(0,q.useRef)(null),[c,l]=(0,q.useState)(!1),{item:u}=e;(0,q.useEffect)(()=>{let e=s.current;if(!e)return;let t=()=>l(e.scrollHeight>e.clientHeight+1);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[u.text]);let d=uY(u),f=typeof u.score==`number`?Math.max(0,Math.min(1,u.score)):null,p=pY(e);return(0,J.jsxs)(`div`,{className:`oc-srccard${t&&n?` is-selected`:``}`,children:[t?(0,J.jsx)(`label`,{className:`oc-srccard__pick`,children:(0,J.jsx)(AC,{checked:n,onCheckedChange:r})}):null,(0,J.jsxs)(`div`,{className:`oc-srccard__body`,children:[(0,J.jsx)(`div`,{className:`oc-srccard__title`,children:hY(e)}),p&&cY(e.item)?(0,J.jsx)(`div`,{className:`oc-srccard__subid`,title:cY(e.item),children:cY(e.item)}):null,d.length>0||f!==null?(0,J.jsxs)(`div`,{className:`oc-srccard__meta`,children:[d.map(e=>(0,J.jsx)(`span`,{className:`oc-srccard__chip`,children:e},e)),f===null?null:(0,J.jsx)(`span`,{className:`oc-srccard__relev`,title:r_({score:f.toFixed(2)}),children:(0,J.jsx)(`span`,{className:`oc-srccard__relev-track`,"aria-hidden":!0,children:(0,J.jsx)(`span`,{className:`oc-srccard__relev-fill`,style:{width:`${Math.round(f*100)}%`}})})})]}):null,u.text?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`blockquote`,{ref:s,className:`oc-srccard__excerpt${a?` is-full`:``}`,children:u.text}),c||a?(0,J.jsx)(`button`,{type:`button`,className:`oc-srccard__more`,onClick:()=>o(e=>!e),children:a?$r():id()}):null]}):null,p?(0,J.jsx)(SY,{attachment:i}):null]})]})}function SY({attachment:e}){if(e?.status===`ready`&&e.url){let t=e.filename??jd();return(0,J.jsxs)(`a`,{className:`oc-srccard__origin oc-srccard__origin--ready`,href:e.url,download:e.filename??void 0,target:`_blank`,rel:`noreferrer`,title:jd(),children:[(0,J.jsx)(bC,{size:13,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-srccard__origin-name`,children:t})]})}return e?.status===`pending`?(0,J.jsxs)(`div`,{className:`oc-srccard__origin oc-srccard__origin--pending`,children:[(0,J.jsx)(OC,{size:13,"aria-hidden":!0}),Cs()]}):e?.status===`not_found`||e?.status===`failed`?(0,J.jsxs)(`div`,{className:`oc-srccard__origin oc-srccard__origin--missing`,"aria-disabled":!0,children:[(0,J.jsx)(YC,{size:13,"aria-hidden":!0}),Mu()]}):(0,J.jsxs)(`div`,{className:`oc-srccard__origin`,"aria-disabled":!0,children:[(0,J.jsx)(bC,{size:13,"aria-hidden":!0}),Uv()]})}function CY(e){return typeof e==`string`&&e.trim()||null}function wY(e){return CY(e)??void 0}function TY(e){return wY(e)?.toLowerCase()}function EY(e){return TY(e)??``}var DY=new Set(`token.key.api_key.apikey.secret.access_token.auth_token.password.pass.passwd.auth.jwt.session.id_token.code.client_secret.app_secret.hook_token.refresh_token.signature.x_amz_signature.x_amz_security_token.private_key.credential.authorization.sig.x_api_key.x_access_token.x_auth_token`.split(`.`)),OY=/[\p{C}\p{Z}\u115F\u1160\u3164\uFFA0+]/gu,kY=/(?:^|_)token(?:_[a-f0-9]{16,})?$/u,AY=8;function jY(e){let t=e.replace(OY,``);for(let e=0;e<=AY;e+=1){let e;try{e=decodeURIComponent(t).replace(OY,``)}catch{break}if(e===t)return{value:EY(t).replaceAll(`-`,`_`),unresolvedEncoding:!1};t=e}return{value:EY(t).replaceAll(`-`,`_`),unresolvedEncoding:t.includes(`%`)}}function MY(e){let t=jY(e);return t.unresolvedEncoding||DY.has(t.value)||kY.test(t.value)}function NY(e){return e>=55296&&e<=56319}function PY(e){return e>=56320&&e<=57343}function FY(e,t,n){let r=e.length,i=t<0?Math.max(r+t,0):Math.min(t,r),a=n===void 0?r:n<0?Math.max(r+n,0):Math.min(n,r);return a<=i?``:(i>0&&i<r&&PY(e.charCodeAt(i))&&NY(e.charCodeAt(i-1))&&(i+=1),a>0&&a<r&&NY(e.charCodeAt(a-1))&&PY(e.charCodeAt(a))&&--a,e.slice(i,a))}function IY(e){let t=e.match(/^\/(.+)\/([gimsuy]*)$/);if(!t)return[e,`gi`];let n=t[1]??``,r=t[2]??``;return[n,r.includes(`g`)?r:`${r}g`]}function LY(e){let t=e.length>0&&typeof e[e.length-1]==`object`&&e[e.length-1]!==null?e.length-2:e.length-1,n=t-1,r=typeof e[0]==`string`?e[0]:``,i=e.slice(1,n).map(e=>typeof e==`string`?e:``),a=typeof e[n]==`number`?e[n]:-1;return{match:r,groups:i,input:typeof e[t]==`string`?e[t]:``,offset:a}}var RY=new WeakMap;function*zY(e,t){if(!(t instanceof RegExp)){yield*t.exec(e);return}let n=t;if(!t.global){let e=RY.get(t);n=e??new RegExp(t.source,`${t.flags}g`),e||RY.set(t,n)}let r=n.unicode||n.flags.includes(`v`),i=0;for(;i<=e.length;){let t=n.lastIndex,a;try{n.lastIndex=i,a=n.exec(e)}finally{n.lastIndex=t}if(!a)return;if(i=a.index+a[0].length,!a[0]){let t=e.codePointAt(i);i+=r&&t!==void 0&&t>65535?2:1}yield{match:a[0],groups:a.slice(1).map(e=>e??``),input:e,offset:a.index}}}function BY(e,t,n,r){if(t instanceof RegExp)return e.replace(t,r??((...e)=>n(LY(e))));let i=[],a=0;for(let r of zY(e,t))i.push(e.slice(a,r.offset),n(r)),a=r.offset+r.match.length;return i.length?i.join(``)+e.slice(a):e}function VY(e,t){let n=e.split(/\r?\n/).filter(Boolean);return n.length<2?`***`:`${n[0]}\n${t}\n${n[n.length-1]}`}var HY="[A-Za-z0-9!#$%&'*+.^_`|~-]+",UY=String.raw`(?:\[REDACTED\]|[^\s\\"',;&#?<>)}\]]+)`,WY=String.raw`\\{1,64}t`,GY=String.raw`(?:[ \t]+|${WY})`,KY=String.raw`(?:[ \t]*\r?\n${GY}|[ \t]*\\{1,64}r\\{1,64}n${GY}|[ \t]*\\{1,64}n${GY}|[ \t]*${WY}[ \t]*|[ \t]*)`,qY=String.raw`(?:[ \t]*\r?\n${GY}|[ \t]*\\{1,64}r\\{1,64}n${GY}|[ \t]*\\{1,64}n${GY}|[ \t]*${WY}[ \t]*|[ \t]+)`,JY=String.raw`(?:[ \t\r\n]*|[ \t]*\\{1,64}r\\{1,64}n(?:[ \t]*|${WY})|[ \t]*\\{1,64}n(?:[ \t]*|${WY})|[ \t]*${WY}[ \t]*)`,YY=String.raw`(^|[^A-Za-z0-9_-]|\\{1,64}[rn])`,XY=String.raw`(?:\\{1,64}["']|["']|)`;String.raw`${YY}(?:x-goog-api-key|api-key|apikey|x-api-token|x-access-token)${XY}[ \t]*[:=]${KY}${XY}([^\s\\"',;]+)`,new RegExp(String.raw`${YY}(?:Proxy-)?Authorization${XY}[ \t]*[:=]${KY}${XY}(${HY})${qY}`,`giu`);var ZY=String.raw`-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]+?-----END [A-Z ]*PRIVATE KEY-----`,QY=String.raw`CARD[_-]?NUMBER|CARD[_-]?CVC|CARD[_-]?CVV|CVC|CVV|SECURITY[_-]?CODE|PAYMENT[_-]?CREDENTIAL|SHARED[_-]?PAYMENT[_-]?TOKEN`,$Y=String.raw`card[-_]?number|card[-_]?cvc|card[-_]?cvv|cvc|cvv|security[-_]?code|payment[-_]?credential|shared[-_]?payment[-_]?token`,eX=String.raw`cardNumber|card_number|cardCvc|card_cvc|cardCvv|card_cvv|cvc|cvv|securityCode|security_code|paymentCredential|payment_credential|sharedPaymentToken|shared_payment_token`,tX=String.raw`aws[-_]?secret[-_]?access[-_]?key|awsSecretAccessKey|SecretAccessKey`,nX=String.raw`access[-_]?token|auth[-_]?token|hook[-_]?token|refresh[-_]?token|id[-_]?token|api[-_]?key|apikey|client[-_]?secret|app[-_]?secret|private[-_]?key|${tX}|credential|authorization|token|key|secret|password|pass|passwd|auth|jwt|session|code|signature|x[-_]?amz[-_]?(?:signature|security[-_]?token)`,rX=String.raw`${nX}|app[-_]?secret|credential|${$Y}`,iX=String.raw`access_token|refresh_token|id_token|auth[-_]?token|hook[-_]?token|api[-_]?key|client[-_]?secret|app[-_]?secret|private[-_]?key|authorization|jwt|token|secret|password|pass|passwd|credential|${$Y}`,aX=String.raw`access[-_]?token|refresh[-_]?token|id[-_]?token|auth[-_]?token|hook[-_]?token|api[-_]?(?:key|secret)|client[-_]?secret|app[-_]?secret|private[-_]?key|secret[-_]?key|key[-_]?material|authorization|jwt|token|secret|password|passphrase|pass|passwd|credential|${$Y}`,oX=String.raw`access-token|refresh-token|id-token|auth-token|hook-token|api[-_]?(?:key|secret)|secret[-_]?key|key[-_]?material|passphrase`,sX=String.raw`password|passphrase|pass|passwd`,cX=String.raw`${tX}|api[-_]?key|hook[-_]?token|access[-_]?token|refresh[-_]?token|id[-_]?token|token|secret|password|passwd|credential|private[-_]?key|client[-_]?secret|${$Y}`;String.raw`\p{C}\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\u115F\u1160\u3164\uFFA0`;var lX=String.raw`/\b[A-Z0-9_]*(?:KEY|TOKEN|SECRET|PASSWORD|PASSWD|${QY})\b\s*[=:]\s*(["']?)([^\s"'\\]+)\1/g`,uX=String.raw`/\b[A-Z0-9_]*(?:KEY|TOKEN|SECRET|PASSWORD|PASSWD|${QY})\b\s*[=:]\s*\\+(["'])([^\s"'\\]+)\\+\1/g`,dX=String.raw`(^|[\s,;({\["])(?:${iX})=(["'\x60])((?:(?!\2)[^\r\n])+)\2`,fX=String.raw`(^|[\s,;({\["])(?:${iX})=(["'\x60]?[^\s&#"'\x60<>]+)`,pX=String.raw`access[-_]?token|refresh[-_]?token|id[-_]?token|auth[-_]?token|hook[-_]?token|api[-_]?(?:key|secret)|secret[-_]?key|key[-_]?material|authorization|jwt|token|secret|password|passphrase|pass|passwd|${$Y}`,mX=String.raw`/(^|[\s,{])(?:(?:${pX})(?:\s*:\s*|\s+=\s*|=\s*)|[a-z0-9][a-z0-9._-]{0,79}[-_](?:${sX})\s*[:=]\s*|[a-z0-9_.-]{1,80}\.(?:${aX})\s*[:=]\s*)(["'\x60])((?:(?!\2)[^\r\n])+)\2/g`,hX=String.raw`/(^|[\s,{])(?:${aX})(?:\s*:\s*|\s+=\s*|=\s+)([^\s#"'\x60<>]+)/g`,gX=String.raw`/(^|[\s,{])(?:${oX})=([^\s#"'\x60<>]+)/g`,_X=String.raw`/(^|[\s,{])[a-z0-9][a-z0-9._-]{0,79}[-_](?:${sX})\s*[:=]\s*([^\s#"'\x60<>]+)/g`,vX=String.raw`/(^|[\s,{])[a-z0-9_.-]{1,80}\.(?:${aX})\s*[:=]\s*([^\s#"'\x60<>]+)/g`,yX=String.raw`"(?:apiKey|api_key|apiToken|api_token|bearerToken|bearer_token|token|secret|password|passwd|${tX}|credential|authorization|proxy-authorization|cookie|set-cookie|x-api-key|x-auth-token|accessToken|access_token|refreshToken|refresh_token|idToken|id_token|authToken|auth_token|clientSecret|client_secret|privateKey|private_key|secret_value|raw_secret|secret_input|key_material)"\s*:\s*"([^"]+)"`,bX=String.raw`"(?:${eX})"\s*:\s*"([^"]+)"`,xX=String.raw`(^|[\s,{])["']?(?:api[-_]key|access[-_]token|refresh[-_]token|id[-_]token|authToken|auth[-_]token|clientSecret|client[-_]secret|appSecret|app[-_]secret|private[-_]key|credential|authorization|secret[-_]value|raw[-_]secret|secret[-_]input|key[-_]material)["']?\s*[:=]\s*(["'])([^"'\r\n]+)\2`,SX=String.raw`(^|[\s,{])["']?(?:authorization|proxy-authorization|cookie|set-cookie|x-api-key|x-auth-token)["']?\s*[:=]\s*(["'])([^"'\r\n]+)\2`,CX=String.raw`(^|[^A-Za-z0-9])(?<!;base64,[A-Za-z0-9+/=]*)`,wX=String.raw`(^|[^A-Za-z0-9_])`;function TX(e){let t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57||e===`/`||e===`+`||e===`=`}var EX=/(?=[A-Za-z0-9/+=]{0,39}[A-Z])(?=[A-Za-z0-9/+=]{0,39}[a-z])(?=[A-Za-z0-9/+=]{0,39}[0-9/+=])(?=[A-Za-z0-9/+=]{0,39}[G-Zg-z/+=])[A-Za-z0-9/+=]{40}/u,DX=/[A-Za-z0-9/+=]{40}/u;function OX(e){return e.length>=40&&DX.test(e)&&EX.test(e)}var kX=/\s/,AX=/[A-Za-z0-9+.-]/,jX=/[A-Za-z]/;function*MX(e){if(!OX(e))return;let t={'"':`"`,"'":`'`,"`":"`","<":`>`,"(":`)`,"[":`]`,"{":`}`},n=-1,r=-1,i,a=0,o=[];for(let s=0;s<=e.length;s++){let c=e[s]??``,l=s===e.length||kX.test(c),u=a;if(a=c===`\\`?a+1:0,c&&TX(c)?n===-1&&(n=s):n!==-1&&(s-n===40?o.push({start:n,end:s,origin:n,url:i}):s-n>40&&c===`@`&&e[s-41]===`/`&&o.push({start:s-40,end:s,origin:n,url:i}),n=-1),l){i&&(i.end=Math.min(i.end,s));for(let t of o){let n=t.url,r=n&&!n.hasAt&&n.portValid&&(n.portStart===-1||(n.authorityEnd===-1?n.end:n.authorityEnd)>n.portStart+1),i=e[t.start-1]??``,a=e[t.end]??``,o=t.start!==t.origin,s=n&&n.portStart!==-1&&t.origin===n.portStart+1&&n.authorityEnd>t.origin&&t.end>n.authorityEnd&&a===`@`;if(!o&&(i===`_`||TX(i))||a===`_`||e.slice(t.origin-8,t.origin)===`;base64,`||r&&!s&&t.start>=n.start&&t.end<=n.end)continue;let c=e.slice(t.start,t.end);EX.test(c)&&(yield{match:c,groups:[c],input:e,offset:t.start})}o.length=0,r=-1,i=void 0;continue}if(i&&s>=i.start&&(c===i.closing&&u===i.closingEscapeDepth?(i.end=Math.min(i.end,s),i=void 0):(`?#"'<>\`|()[]{}`.includes(c)&&(i.end=Math.min(i.end,s)),i.queryOrFragment||=c===`?`||c===`#`,i.authorityEnd===-1&&(i.hasAt||=c===`@`,`/?#`.includes(c)?i.authorityEnd=s:s<i.end&&(c===`:`?(i.portValid&&=i.portStart===-1,i.portStart=s):i.portStart!==-1&&(c<`0`||c>`9`)&&(i.portValid=!1))))),AX.test(c))r===-1&&(r=s);else{if((!i||s>=i.end&&!i.queryOrFragment)&&c===`:`&&e.startsWith(`//`,s+1)&&r!==-1&&jX.test(e[r])){let n=e[r-1],a=0;for(let t=r-2;t>=0&&e[t]===`\\`;t--)a++;i={start:s+3,end:e.length,authorityEnd:-1,portStart:-1,portValid:!0,hasAt:!1,queryOrFragment:!1,closing:n?t[n]:void 0,closingEscapeDepth:a}}r=-1}}}var NX=Object.freeze({source:`aws-secret-access-key`,exec:MX,couldMatch:OX}),PX=String.raw`\bbot(\d{6,}:[A-Za-z0-9_-]{20,})\b`,FX=String.raw`\b(\d{6,}:[A-Za-z0-9_-]{20,})\b`,IX=`x-goog-api-key|api-key|apikey|x-api-token|x-access-token`,LX=`X-OpenClaw-Token|x-pomerium-jwt-assertion|X-Api-Key|X-Auth-Token`;RegExp(`^(?:${IX}|${LX})$`,`i`);var RX=String.raw`(^|[^A-Za-z0-9_?&-]|\\{1,64}[rn])`,zX=String.raw`${RX}(?:${IX})${XY}[ \t]*:${KY}${XY}([^\s\\"',;]+)`,BX=String.raw`${RX}(?:${IX})${XY}[ \t]*=${KY}${XY}([^\s\\"',;]+)`,VX=String.raw`${RX}(?:${LX})\s*:\s*([^\s"',;]+)`,HX=String.raw`${RX}(?:${LX})\s*=\s*([^\s"',;]+)`,UX=[String.raw`${YY}Proxy-Authorization${XY}[ \t]*[:=]${KY}${XY}${HY}${qY}(${UY})`,String.raw`${YY}Proxy-Authorization${XY}[ \t]*[:=]${KY}${XY}(${UY})[ \t]*(?=${XY}(?:$|[,;)}\]]|\r?\n(?![ \t])))`,String.raw`${YY}Authorization${XY}[ \t]*[:=]${KY}${XY}(?!(?:Bearer|Basic|Bot)(?=${qY}))${HY}${qY}(${UY})`,String.raw`${YY}Authorization${XY}[ \t]*[:=]${KY}${XY}(?!(?:Bearer|Basic|Bot)(?=${qY}))(${UY})[ \t]*(?=${XY}(?:$|[,;)}\]]|\r?\n(?![ \t])))`,zX,BX],WX=String.raw`Authorization${XY}[ \t]*[:=]${JY}${XY}Bearer${qY}(${UY})`,GX=String.raw`Authorization${XY}[ \t]*[:=]${JY}${XY}Basic${qY}(${UY})`,KX=String.raw`Authorization${XY}[ \t]*[:=]${JY}${XY}Bot${qY}(${UY})`,qX=String.raw`\bBearer\s+([-A-Za-z0-9._~+/=]{18,})(?![-A-Za-z0-9._~+/=])`;[...UX];var JX=[lX,uX,yX,bX,xX,SX,String.raw`--(?:${cX})=([^\s"']+)`,String.raw`--(?:${cX})\s+(?!(?:or|and)\b(?=\s+--))(["']?)([^\s"']+)\1`,WX,GX,KX,...UX,VX,HX,qX,String.raw`\b(?:https?|wss?|ftp):\/\/[^\/\s:@]*:([^\/\s@]+)@`,String.raw`\b(?:postgres(?:ql)?|mysql|mongodb(?:\+srv)?|rediss?|amqps?):\/\/[^:\s/@]*:([^@\s]+)@`,String.raw`(^|[\s,;])(?:${rX})=([^&\s]+)(?=&[A-Za-z_][A-Za-z0-9_.-]*=)`,dX,fX,mX,hX,gX,_X,vX,ZY,String.raw`(^|[\s,{])["']?(?:${tX})["']?\s*[:=]\s*(["']?)([A-Za-z0-9/+=]{40})(?![A-Za-z0-9/+=])\2`],YX=[String.raw`\b(sk-[A-Za-z0-9_-]{8,})\b`,String.raw`(ghp_[A-Za-z0-9]{10,})`,String.raw`(github_pat_[A-Za-z0-9_]{10,})`,String.raw`(gho_[A-Za-z0-9]{10,})`,String.raw`(ghu_[A-Za-z0-9]{10,})`,String.raw`(ghs_[A-Za-z0-9]{10,})`,String.raw`(ghr_[A-Za-z0-9]{10,})`,String.raw`(glpat-[A-Za-z0-9._=\-]{20,})`,String.raw`(gloas-(?:[A-Fa-f0-9]{65,}|[A-Za-z0-9_-]{64}|[A-Fa-f0-9]{32,}))`,String.raw`(gldt-[A-Za-z0-9_-]{20,})`,String.raw`(glcbt-[A-Za-z0-9]{1,5}_[A-Za-z0-9_-]{20,})`,String.raw`(glptt-[A-Za-z0-9_-]{40,})`,String.raw`(glft-(?:[A-Za-z0-9_-]{20,}|[a-h0-9]+-[0-9]+_))`,String.raw`(glimt-[A-Za-z0-9_-]{25,})`,String.raw`(glagent-[A-Za-z0-9_-]{50,})`,String.raw`(glwt-[A-Za-z0-9_-]{20,})`,String.raw`(glsoat-[A-Za-z0-9_-]{20,})`,String.raw`(glffct-[A-Za-z0-9_-]{20,})`,String.raw`(glrt-[A-Za-z0-9._-]{20,})`,String.raw`(glrtr?-[A-Za-z0-9_-]{27,300}\.[0-9a-z]{2}\.[0-9a-z]{9})`,String.raw`(GR1348941[A-Za-z0-9_-]{20,})`,String.raw`(_gitlab_session=[A-Za-z0-9%._-]{20,})`,String.raw`(xox[baprs]-[A-Za-z0-9-]{10,})`,String.raw`(xapp-[A-Za-z0-9-]{10,})`,String.raw`(https:\/\/hooks\.slack\.com\/(?:services\/T[A-Z0-9]+\/B[A-Z0-9]+|workflows\/T[A-Z0-9]+\/A[A-Z0-9]+\/[0-9]{17,19})\/[A-Za-z0-9]{20,})`,String.raw`(https:\/\/discord(?:app)?\.com\/api\/webhooks\/[0-9]{17,20}\/[A-Za-z0-9_-]{60,})`,String.raw`discord(?:.|\n|\r){0,40}?\b([A-Za-z0-9_-]{24}\.[A-Za-z0-9_-]{6}\.[A-Za-z0-9_-]{27})\b`,String.raw`(gsk_[A-Za-z0-9_-]{10,})`,String.raw`(AIza[0-9A-Za-z\-_]{20,})`,String.raw`(ya29\.[0-9A-Za-z_\-./+=]{10,})`,String.raw`(1//0[0-9A-Za-z_\-./+=]{10,})`,String.raw`(eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,})`,String.raw`(pplx-[A-Za-z0-9_-]{10,})`,String.raw`(fal_[A-Za-z0-9_-]{10,})`,String.raw`${wX}(fc-[A-Za-z0-9]{10,})`,String.raw`(bb_live_[A-Za-z0-9_-]{10,})`,String.raw`${CX}(gAAAA[A-Za-z0-9_=-]{20,})`,String.raw`(sk_live_[A-Za-z0-9]{10,})`,String.raw`(sk_test_[A-Za-z0-9]{10,})`,String.raw`(rk_live_[A-Za-z0-9]{10,})`,String.raw`(SG\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,})`,String.raw`(npm_[A-Za-z0-9]{10,})`,String.raw`(pypi-[A-Za-z0-9_-]{10,})`,String.raw`(dop_v1_[A-Za-z0-9]{10,})`,String.raw`(doo_v1_[A-Za-z0-9]{10,})`,String.raw`(dor_v1_[A-Za-z0-9]{10,})`,String.raw`(dp\.(?:ct|pt|sa|scim|audit)\.[A-Za-z0-9]{40,44})`,String.raw`(dp\.st\.[A-Za-z0-9]{40,44})`,String.raw`(dp\.st\.[a-z0-9_-]{2,35}\.[A-Za-z0-9]{40,44})`,String.raw`(dckr_(?:pat|oat)_[A-Za-z0-9_-]{27,32})`,String.raw`(bkua_[a-z0-9]{40})`,String.raw`(CCIPAT_[A-Za-z0-9]{22}_[A-Fa-f0-9]{40})`,String.raw`(sbp_[a-z0-9]{40})`,String.raw`${CX}(dapi[0-9a-f]{32}(?:-\d)?)`,String.raw`(dd[pw]_[A-Za-z0-9]{36})`,String.raw`(glsa_[A-Za-z0-9_]{41})`,String.raw`(glc_eyJ[A-Za-z0-9+/=]{60,160})`,String.raw`(nfp_[A-Za-z0-9_]{36})`,String.raw`(CFPAT-[A-Za-z0-9_\-]{40,})`,String.raw`${CX}(ATCTT3xFfG[A-Za-z0-9+/=_-]+=[A-Za-z0-9]{8})`,String.raw`${CX}(ATATT[A-Za-z0-9+/=_-]+=[A-Za-z0-9]{8})`,String.raw`${CX}(ATBB[A-Za-z0-9_=.-]{16,})`,String.raw`(BBDC-[A-Za-z0-9+/@_-]{40,50})`,String.raw`(HRKU-AA[A-Za-z0-9_-]{20,})`,String.raw`(pat-(?:eu|na)1-[A-Za-z0-9]{8}\-[A-Za-z0-9]{4}\-[A-Za-z0-9]{4}\-[A-Za-z0-9]{4}\-[A-Za-z0-9]{12})`,String.raw`(apify_api_[A-Za-z0-9\-]{20,})`,String.raw`(FlyV1 fm\d+_[A-Za-z0-9+/=,_-]{100,})`,String.raw`(fio-u-[A-Za-z0-9_-]{40,})`,String.raw`(^|[^A-Za-z0-9_])(am_[A-Za-z0-9_-]{10,})`,String.raw`(^|[^A-Za-z0-9_])(sk_[A-Za-z0-9_]{10,})`,String.raw`(tvly-[A-Za-z0-9]{10,})`,String.raw`(exa_[A-Za-z0-9]{10,})`,String.raw`(syt_[A-Za-z0-9]{10,})`,String.raw`(retaindb_[A-Za-z0-9]{10,})`,String.raw`(hsk-[A-Za-z0-9]{10,})`,String.raw`(mem0_[A-Za-z0-9]{10,})`,String.raw`(brv_[A-Za-z0-9]{10,})`,String.raw`(xai-[A-Za-z0-9]{30,})`,String.raw`${wX}(fw-[A-Za-z0-9]{30,})`,String.raw`${wX}(fw_[A-Za-z0-9]{30,})`,String.raw`${wX}(fpk_[A-Za-z0-9]{30,})`,String.raw`${CX}(AKIA[A-Z0-9]{16})`,String.raw`${CX}(ASIA[A-Z0-9]{16})`,String.raw`(AKID[A-Za-z0-9]{10,})`,String.raw`(LTAI[A-Za-z0-9]{10,})`,String.raw`(hf_[A-Za-z0-9]{10,})`,String.raw`(api_org_[A-Za-z0-9]{20,})`,String.raw`(r8_[A-Za-z0-9]{10,})`,PX,FX],XX=[...JX,...YX,NX],ZX=new Set([lX,uX,yX,xX,SX,dX,fX,mX,hX,gX,_X,vX]);XX.filter(e=>typeof e!=`string`||!ZX.has(e));var QX=/([?&])([^=&#\s]+)=([^&#\s"'<>]+)/gu,$X=XX.map(e=>typeof e==`string`?new RegExp(...IY(e)):e),eZ=[[/\b(Authorization|Cookie|Set-Cookie)\s*:\s*[^\n\r]+/gi,`$1: [redacted]`],[/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{12,}/gi,`$1[redacted]`],[/\b(api[_.-]?key|token|secret|password|passwd|authorization)\b(["'])(\s*:\s*)"(?:\\.|[^"\\\r\n])*"/gi,`$1$2$3"[redacted]"`],[/\b(api[_.-]?key|token|secret|password|passwd|authorization)\b(["'])(\s*:\s*)'(?:\\.|[^'\\\r\n])*'/gi,`$1$2$3'[redacted]'`],[/\b(api[_.-]?key|token|secret|password|passwd|authorization)\b(\s*[:=]\s*)["']?[^"',\s}]+/gi,`$1$2[redacted]`],[/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,`[redacted private key]`]];function tZ(e){return e.length<=10?`***`:`${FY(e,0,6)}...${FY(e,-4)}`}function nZ({match:e,groups:t,input:n,offset:r}){let i=r<0?``:n.slice(r+e.length);if(e.includes(`PRIVATE KEY-----`))return VY(e,`...redacted...`);let a=t.findLast(e=>typeof e==`string`&&e.length>0)??e;if(a===`$`&&i.startsWith("`"))return e;let o=tZ(a);if(a===e)return o;let s=e.lastIndexOf(a);return s<0?`***`:`${e.slice(0,s)}${o}${e.slice(s+a.length)}`}function rZ(e){return e.replace(QX,(e,t,n,r)=>MY(n)?`${t}${n}=${tZ(r)}`:e)}function iZ(e){let t=rZ(e);for(let e of $X)t=BY(t,e,nZ);return eZ.reduce((e,[t,n])=>e.replace(t,n),t)}var aZ=iZ,oZ=new Set([`status`,`exitCode`,`durationMs`]);function sZ(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function cZ(e){if(typeof e==`string`)return{kind:`text`,text:e};if(typeof e==`object`&&e&&!Array.isArray(e)){let t=e,n=Object.keys(t);if(typeof t.exitCode==`number`&&n.every(e=>oZ.has(e)))return{kind:`outcome`,status:typeof t.status==`string`?t.status:null,exitCode:t.exitCode,durationMs:typeof t.durationMs==`number`?t.durationMs:null}}return{kind:`json`,text:sZ(e)}}function lZ(e){let t=[(e.exitCode===null?e.status===`completed`:e.exitCode===0)?px():Qs()];return e.exitCode!==null&&t.push(aa({code:e.exitCode})),e.durationMs!==null&&t.push(jr({ms:e.durationMs})),t.join(` · `)}var uZ=new Set([`complete`,`error`,`aborted`]),dZ=new Set([`completed`,`error`]);function fZ(e,t){if(e.length===0)return!1;if(t===`streaming`)return!0;if(t!==void 0&&uZ.has(t))return!1;let n=e[e.length-1];return n.phase!==void 0&&dZ.has(n.phase)?!1:n.result===void 0||n.result===null}var pZ=[`command`,`query`,`url`,`path`,`pattern`,`file`,`cmd`,`prompt`];function mZ(e,t){let n=``;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e;for(let e of pZ){let r=t[e];if(typeof r==`string`&&r.trim()){n=r;break}}}return n||=t??(typeof e==`string`?e:``),n}function hZ(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function gZ(e){let t=e.argsText??hZ(e.args),n=mZ(e.args,e.argsText);return e.inputFromTranscript===!0?{inputText:aZ(t.trim()),preview:aZ(n).replace(/\s+/g,` `).trim()}:{inputText:t,preview:n.replace(/\s+/g,` `).trim()}}function _Z(e,t){let n=e.length,r=n===1?Hl({count:n}):be({count:n});return{count:n,running:fZ(e,t),label:r}}function vZ({text:e}){let[t,n]=(0,q.useState)(!1);return(0,J.jsx)(`button`,{type:`button`,className:`oc-copybtn oc-reveal oc-hit`,title:yu(),"aria-label":Tl(),onClick:()=>{navigator.clipboard?.writeText(e).then(()=>{n(!0),window.setTimeout(()=>n(!1),1200)})},children:t?(0,J.jsx)(ZS,{size:13,"aria-hidden":!0}):(0,J.jsx)(yC,{size:13,"aria-hidden":!0})})}function yZ(e,t,n,r){let i=typeof e==`string`?e:void 0;return i===`error`?`error`:t||i===`completed`?`completed`:r?`interrupted`:n?`completed`:`running`}function bZ({toolName:e,args:t,argsText:n,inputFromTranscript:r,result:i,status:a,turnSettled:o,turnInterrupted:s,nested:c}){let l=i!=null,u=yZ(a?.type,l,o,s),{inputText:d,preview:f}=gZ({args:t,argsText:n,inputFromTranscript:r}),p=l?cZ(i):null,m=u===`running`?OC:u===`error`?pA:mA;return(0,J.jsxs)(`details`,{className:`oc-tool oc-tool--${u}`,children:[(0,J.jsxs)(`summary`,{className:`oc-tool__header`,children:[(0,J.jsx)(m,{className:`oc-tool__status${u===`running`?` oc-tool__status--spin`:``}`,size:14,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-tool__name`,children:e}),f?(0,J.jsx)(`span`,{className:`oc-tool__preview`,title:f,children:f}):null,(0,J.jsx)(`span`,{className:`oc-tool__phase`,children:u===`interrupted`?_g():u}),(0,J.jsx)(eC,{size:15,className:`oc-tool__chevron`,"aria-hidden":!0})]}),(0,J.jsxs)(`div`,{className:`oc-tool__body`,children:[d?(0,J.jsxs)(`details`,{className:`oc-tool__io`,children:[(0,J.jsx)(`summary`,{children:`input`}),(0,J.jsxs)(`div`,{className:`oc-tool__prewrap oc-reveal-host`,children:[(0,J.jsx)(`pre`,{className:`oc-tool__pre`,children:d}),(0,J.jsx)(vZ,{text:d})]})]}):null,p&&p.kind===`outcome`?(0,J.jsxs)(`div`,{className:`oc-tool__outcome`,children:[(0,J.jsx)(`span`,{className:`oc-tool__outcome-label`,children:lZ(p)}),(0,J.jsx)(`span`,{className:`oc-tool__outcome-note`,children:sn()})]}):p?(0,J.jsxs)(`details`,{className:`oc-tool__io`,open:!0,children:[(0,J.jsx)(`summary`,{children:`output`}),(0,J.jsxs)(`div`,{className:`oc-tool__prewrap oc-reveal-host`,children:[(0,J.jsx)(`pre`,{className:`oc-tool__pre`,children:p.text}),(0,J.jsx)(vZ,{text:p.text})]})]}):null,c?(0,J.jsx)(`div`,{className:`oc-tool__nested`,children:c}):null]})]})}var xZ=1e3;function SZ(){return[{id:`hung`,label:pr()},{id:`wrong_result`,label:Zl()},{id:`error`,label:ke()},{id:`other`,label:xx()}]}function CZ({target:e,onClose:t}){let n=U(G.subAgentReports.createSubAgentReport),[r,i]=(0,q.useState)(``),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1);(0,q.useEffect)(()=>{e&&(i(``),o(``),c(!1),u(!1))},[e]);function d(e){e||t()}async function f(){if(!(!e||s)){c(!0);try{await n({subAgentId:e.subAgentId,category:r||void 0,comment:a.trim()||void 0}),u(!0)}catch{c(!1)}}}return(0,J.jsx)(rT,{open:e!==null,onOpenChange:d,children:e?(0,J.jsxs)(eT,{className:`sm:max-w-md`,children:[(0,J.jsxs)(Qw,{children:[(0,J.jsx)(tT,{children:fi()}),(0,J.jsx)(nT,{children:l?zi():Ev({label:e.label})})]}),l?(0,J.jsx)(`div`,{className:`oc-feedback__result`,role:`status`,children:(0,J.jsx)(`p`,{className:`oc-feedback__fidelity is-ok`,children:Vn()})}):(0,J.jsxs)(`div`,{className:`oc-feedback__form`,children:[(0,J.jsx)(`label`,{className:`oc-feedback__label`,children:bu()}),(0,J.jsxs)(sw,{value:r,onValueChange:i,children:[(0,J.jsx)(iw,{children:(0,J.jsx)(rw,{placeholder:El()})}),(0,J.jsx)(aw,{children:SZ().map(e=>(0,J.jsx)(ow,{value:e.id,children:e.label},e.id))})]}),(0,J.jsx)(`label`,{className:`oc-feedback__label`,htmlFor:`oc-subagentreport-comment`,children:sc()}),(0,J.jsx)(`textarea`,{id:`oc-subagentreport-comment`,className:`oc-feedback__textarea`,placeholder:ma(),value:a,maxLength:xZ,onChange:e=>o(e.target.value.slice(0,xZ)),rows:4}),(0,J.jsxs)(`div`,{className:`oc-feedback__count`,children:[a.length,`/`,xZ]})]}),(0,J.jsx)($w,{children:l?(0,J.jsx)(K,{onClick:()=>d(!1),children:fo()}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(K,{variant:`outline`,onClick:()=>d(!1),children:Br()}),(0,J.jsx)(K,{onClick:()=>void f(),disabled:s,children:s?us():gn()})]})})]}):null})}function wZ(e,t=`md`){let n=(e??``).trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40);return`sous-agent${n?`-${n}`:``}.${t}`}function TZ(e){return JSON.stringify({kind:`sub-agent`,taskName:e.taskName??null,status:e.status,exportedAt:new Date(e.exportedAt).toISOString(),parentAgent:e.parentAgentLabel??null,config:e.sessionMeta??null,telemetry:e.telemetry??null,tools:e.tools.map(e=>({name:e.name,status:e.status,input:e.argsText??null,output:e.resultText??null})),result:e.result??null,error:e.error??null},null,2)}function EZ(e){let t=[],n=e.taskName?.trim()||sx();t.push(`# ${sx()} — ${n}`,``);let r=[];e.parentAgentLabel&&r.push(`- ${pd()} : ${e.parentAgentLabel}`);let i=e.sessionMeta;if(i?.model&&r.push(`- ${Qh()} : ${i.model}${i.modelProvider?` (${i.modelProvider})`:``}`),i?.thinkingLevel&&r.push(`- ${__()} : ${i.thinkingLevel}`),i?.fastMode!==void 0&&r.push(`- ${Ky()} : ${i.fastMode?km():_()}`),i?.controlScope&&r.push(`- ${As()} : ${i.controlScope}`),i?.subagentRole&&r.push(`- ${Bd()} : ${i.subagentRole}`),i?.spawnDepth!==void 0&&r.push(`- ${Vu()} : ${i.spawnDepth}`),r.length&&t.push(...r,``),e.tools.length>0){t.push(`## ${Nh()} (${e.tools.length})`,``);for(let n of e.tools)t.push(`### ${n.name} — ${n.status}`,``),n.argsText&&t.push(`**Input**`,``,"```",n.argsText,"```",``),n.resultText&&t.push(`**Output**`,``,"```",n.resultText,"```",``)}return e.error&&t.push(`## ${s_()}`,``,e.error,``),e.result&&t.push(`## ${Bm()}`,``,e.result,``),`${t.join(`
21
+ `).trim()}\n`}function DZ(e,t,n=!1){if(e===void 0)return`thinking`;switch(e){case`streaming`:return t?`generating`:`thinking`;case`error`:return`error`;case`aborted`:return`aborted`;default:return n?`aborted`:null}}function OZ(e){return e?e.some(e=>e?.type===`text`&&typeof e.text==`string`&&e.text.trim().length>0):!1}var kZ=/\b(?:profile|api\s*key)\s+"/i;function AZ(e){if(typeof e!=`string`||!kZ.test(e))return e;let t=e.indexOf(`"`);return t===-1?e:`${e.slice(0,t+1)}…`}var jZ=/(?:^|[\s:(\[])401(?=[:)\s,.{]|$)/,MZ=/(?:^|[\s:(\[])403(?=[:)\s,.{]|$)/,NZ=/api[_ ]?key[_ ]?(?:revoked|deactivated|deleted)|deactivated[_ ]workspace|key has been (?:disabled|revoked)|account has been deactivated|not allowed for this organization/i,PZ=/forbidden|permission|not allowed|access denied|access to this|unsupported[_ ](?:country|region)|region|territory|deactivated|re-authenticate with:/i,FZ=/context overflow|prompt too large|maximum context length|context[- ]length exceeded|request_too_large|request too large|input (?:token count )?exceeds the maximum number of (?:input )?tokens|input is too long for the model|too many tokens|reduce the length|exceeds? (?:the )?(?:model'?s )?(?:maximum )?context/i,IZ=/\btpm\b|tokens per (?:minute|day)|rate[_ -]?limit|too many requests|requests per (?:minute|hour|day)|throttl|please wait before trying again|\bquota\b|resource[_ -]?exhausted|usage limit|^(?:throttling error|service unavailable):|payment required|insufficient (?:credits|balance|funds)|insufficient[_ ]quota|credit balance|billing/i,LZ=/(?:\btpm\b|tokens per minute)[^.\n]{0,120}?\blimit\s+([\d,]{1,12})[^.\n]{0,120}?\brequested\s+([\d,]{1,12})/i,RZ=/reply session initialization conflicted/i,zZ=/session file changed while embedded prompt lock/i,BZ=/session writer claim changed before transcript persistence/i,VZ=/the transcript writer no longer owned this session|this conversation changed while openclaw was working/i,HZ=/session .* already has an active turn claim/i,UZ=/session .* (?:changed|was deleted) while starting work/i,WZ=/session transcript is rebuilding;?\s*retry shortly/i,GZ=/is still initializing\.?\s*retry after initialization completes/i,KZ=/session preparation changed; retry|worker placement owner changed during chat admission; retry|restart-safe chat freshness was not prepared; retry/i,qZ=/database is locked|database table is locked|state database was (?:busy|locked)\b|sqlite transaction admission remained busy|openclaw is busy saving your conversation/i,JZ=/database or disk is full|attempt to write a readonly database|disk i\/o error|state database was (?:full|read-only)|state database had an i\/o error|couldn't save your conversation because the disk is full|doesn't have permission to save your conversation|couldn't save your conversation\. check the storage/i,YZ=/\benospc\b|\bedquot\b|no space left on device|disk quota exceeded|could not write local session data because the disk is full|free disk space\/quota or set xdg_cache_home to a writable filesystem/i,XZ=/agent database execution admission is closed|sessions remain unavailable|preserve and inspect this database before accepting a fresh agent|restart the gateway to retry admission/i,ZZ=/pending input is no longer active in its admitted transcript/i,QZ=/^\s*all (?:[a-z][\w -]{0,60}? )?models failed \(\d+\):\s*/i,$Z=/^[^\s/|]+\/\S+?:\s+/,eQ=/\.\s+(?:re-authenticate with:\s|authenticate in gemini cli directly, or configure a supported google api key with:\s)[\s\S]*$/i,tQ=/\s\(([a-z_]+)\)\s*\.?\s*$/,nQ=/^[\s⚠️]*(?:context is too large and auto-compaction could not recover this turn|this conversation is too long, and openclaw couldn't shorten it)\.\s*/i,rQ=/^[\s⚠️]*(?:context is too large and auto-compaction timed out before it could finish|this conversation is too long, and shortening it took too long)\.\s*/i,iQ=/^reason:\s*/i,aQ=/\.?\s*try again, use \/compact, or use \/new to start a fresh session\.?\s*$/i,oQ=/^[\s⚠️]*context compaction succeeded, but the later model request still failed\.\s*/i,sQ=/^[\s⚠️]*agent failed before reply:\s*/i,cQ=/\.?\s*please try again, or use \/new to start a fresh session\.?\s*$/i,lQ=/^\s*(?:this turn ended before a reply|your request couldn't be completed):\s*/i,uQ=/^[\s⚠️]*(?:something went wrong while processing your request|openclaw couldn't finish this (?:request|reply))\./i,dQ=/\.\.\.\s*$/,fQ=/the ai service returned an (?:internal )?error|the ai service is temporarily (?:overloaded|unavailable)|the ai service is busy\. please try again in a moment|the ai service is having trouble\. please try again in a moment|couldn't reach the ai service\. try again in a moment|returned an html error page|malformed_streaming_fragment|malformed fragment|an error occurred while processing your request|http\s*5\d\d\b|\b5\d\d\s+(?:internal server error|bad gateway|service unavailable|gateway timeout)|internal server error|\bupstream (?:error|connect)|server_error|overloaded_error|fetch failed|socket hang ?up|network error|econnreset|econnrefused|etimedout|enotfound|eai_again|epipe|und_err|terminated unexpectedly/i,pQ=/rate[- ]?limit|too many requests|http\s*4\d\d\b|unauthorized|forbidden|invalid[_ ](?:api[_ ]?key|request|model)|api[_ ]?key|authentication|billing|quota|insufficient|not[_ ]found|unsupported|refus|content[_ ]policy|context overflow|prompt too large/i,mQ=/is paused as a precaution\.?\s*review the provider findings|provider review changed\.?\s*refresh the findings/i,hQ=/is archived\.?\s*restore it before starting new work/i,gQ=/\bauth profile\s+"[\s\S]*?"\s+is temporarily unavailable\s+for\b/i,_Q=/\bre-authenticate with:\s/i,vQ=/(?:^|[\s:(\[])401[:)\s][^|\n]{0,120}?(?:\b(?:invalidated|expired|revoked)\b[^|\n]{0,60}?\btokens?\b|\btokens?\s+(?:has|have)\s+(?:been\s+)?(?:invalidated|expired|revoked)\b|\btokens?\s+(?:was|were|is|are)\s+(?:invalidated|expired|revoked)\b)/i,yQ=/\b(?:invalidated|revoked)\b[^|\n]{0,60}?\btokens?\b|\btokens?\s+(?:has|have)\s+been\s+(?:invalidated|expired|revoked)\b|\b(?:refresh|access|oauth)\s+tokens?\s+(?:is|was|has)\s+(?:been\s+)?(?:invalidated|expired|revoked)\b/i,bQ=/\bmodel login expired on the gateway\b/i,xQ=/\breturned a billing error\b|\bthe ai service reported a billing problem\b/i,SQ=/\bthe selected model was not found by the provider\b|\bthis model was not found\. choose another model in the control ui\b|\bcan'?t find the model you'?re using right now\b/i,CQ=/\bapi rate limit reached\b|\bthe model request was rate-limited\b|\bthe ai service needs a short break\b/i,wQ=/(?:^|[\s:(\[|])(?:http\s*)?[45]\d\d\b[^{"\n|]{0,40}?\{/gi,TQ=/(?:(?:auto-compaction|preflight compaction)(?:[^\n.!?;,:—-]{0,200}?failed\s*:\s*|[^\n.!?;,:—-]{0,200}?[.!?]\s*reason\s*:\s*)|openclaw couldn't shorten it\.\s*reason\s*:\s*)(?:no conversation found|conversation (?:not found|does not exist|expired|invalid)|session (?:not found|does not exist|expired|invalid)|no such session|invalid session|(?:session|conversation) id not found)(?=[.,;:!)\]]|\s*$|\s+(?:for|on|in|with)\b|\s+[—-]\s)/,EQ=/\bMCP server "|\bAgent harness runtime "|\(reason=owner-plugin-(?:degraded|not-activatable), ownerPluginIds?=|\bre-authenticate with:\s+openclaw\b|\bmodel login (?:expired|failed) on the gateway for |`+openclaw models (?:list --refresh --provider |auth login\b)|\bopenclaw --(?:profile|container)\b/i,DQ=RegExp(`${MZ.source}[^|\\n]{0,200}?(?:${PZ.source})`,`i`),OQ=`message|type|code|status|reason|detail|error`,kQ=RegExp(`"(?:${OQ})"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)"`,`gi`),AQ=RegExp(`"(?:${OQ})"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)$`,`i`),jQ=new Set([`auth`,`auth_permanent`,`format`,`rate_limit`,`overloaded`,`billing`,`server_error`,`timeout`,`tls_certificate`,`context_overflow`,`model_not_found`,`session_expired`,`empty_response`,`no_error_details`,`unclassified`,`unknown`]),MQ=[`gateway_storage_unavailable`,`gateway_agent_db_closed`,`gateway_storage_busy`,`pending_input_dropped`,`session_gone`,`provider_auth_revoked`,`provider_permission_denied`,`provider_billing`,`provider_auth_failed`,`auth_profile_cooldown`,`model_not_found`,`context_length`,`session_write_conflict`,`session_init_conflict`,`session_archived`,`session_paused_review`,`rate_limit`,`provider_internal`],NQ=new Set([`gateway_storage_unavailable`,`gateway_agent_db_closed`,`gateway_storage_busy`,`pending_input_dropped`,`session_gone`,`auth_profile_cooldown`,`session_write_conflict`,`session_init_conflict`,`session_archived`,`session_paused_review`]),PQ=new Set([`pending_input_dropped`,`auth_profile_cooldown`]);function FQ(e){return/\b(?:profile|api\s*key)\s+"/i.test(e)}function IQ(e,t){let n=0,r=!1;for(let i=t;i<e.length;i++){let t=e[i];if(r){t===`\\`?i++:t===`"`&&(r=!1);continue}if(t===`"`)r=!0;else if(t===`{`)n++;else if(t===`}`&&--n===0)return i}return-1}function LQ(e){return e.replace(/\\(.)/g,`$1`).replace(/"/g,``)}function RQ(e){let t=``,n=0,r=new RegExp(wQ.source,wQ.flags);for(let i=r.exec(e);i!==null;i=r.exec(e)){let a=i.index+i[0].length-1;if(a<n)continue;let o=IQ(e,a),s=o===-1?e.length-1:o,c=e.slice(a,s+1),l=[],u=new RegExp(kQ.source,kQ.flags);for(let e=u.exec(c);e!==null;e=u.exec(c))l.push(LQ(e[1]??``));if(o===-1){let e=AQ.exec(c);e!==null&&l.push(LQ(e[1]??``))}t+=`${e.slice(n,a)}${l.join(` `)}`,n=s+1,r.lastIndex=n}return n===0?e:t+e.slice(n)}function zQ(e){let t=e;return(t.match(/"/g)??[]).length%2==1&&(t=t.replace(/"[^"]*$/,`"…`)),t.replace(/"[^"]*"/g,`"…"`)}function BQ(e){let t=EQ.exec(e);return t===null?e:`${e.slice(0,t.index+t[0].length)}…`}function VQ(e){let t=BQ(e);if(!FQ(e))return zQ(RQ(t));let n=t.indexOf(`"`),r=n===-1?t:t.slice(0,n);if(/\bauth profile\s+$/i.test(r)){let e=t.replace(/(\bauth profile\s+")[\s\S]*?("\s+is temporarily unavailable\s+for\b)[\s\S]*$/i,`$1…$2 …`);if(e!==t)return e}return n===-1?t:`${t.slice(0,n+1)}…`}function HQ(e){if(!FZ.test(e))return!1;let t=LZ.exec(e);if(t!==null){let e=Number(t[1]?.replaceAll(`,`,``)),n=Number(t[2]?.replaceAll(`,`,``));if(e>0&&n>e)return!0}return!IZ.test(e)}function UQ(e){return RZ.test(e)||zZ.test(e)||UZ.test(e)||HZ.test(e)||WZ.test(e)||KZ.test(e)||GZ.test(VQ(e))}function WQ(e){let t=VQ(e).toLowerCase();return!t.includes(`auto-compaction`)&&!t.includes(`preflight compaction`)&&!t.includes(`openclaw couldn't shorten it`)?!1:TQ.test(t)}function GQ(e){return vQ.test(e)||bQ.test(e)?`provider_auth_revoked`:NZ.test(e)||DQ.test(e)?`provider_permission_denied`:_Q.test(e)?`provider_auth_failed`:null}function KQ(e,t){if(e===`auth_permanent`)return`provider_permission_denied`;let n=jZ.test(t),r=MZ.test(t);return r&&!n||NZ.test(t)?`provider_permission_denied`:n&&!r||vQ.test(t)||yQ.test(t)?`provider_auth_revoked`:`provider_auth_failed`}function qQ(e,t){switch(e){case`auth`:case`auth_permanent`:return KQ(e,t);case`billing`:return`provider_billing`;case`rate_limit`:return`rate_limit`;case`overloaded`:case`server_error`:case`timeout`:return`provider_internal`;case`context_overflow`:return`context_length`;case`model_not_found`:return`model_not_found`;default:return null}}function JQ(e){let t=VQ(e);if(JZ.test(t)||YZ.test(t))return`gateway_storage_unavailable`;if(XZ.test(t))return`gateway_agent_db_closed`;if(qZ.test(t))return`gateway_storage_busy`;if(ZZ.test(t))return`pending_input_dropped`;if(WQ(t))return`session_gone`;let n=GQ(t);return n===`provider_auth_revoked`||n===`provider_permission_denied`?n:xQ.test(t)?`provider_billing`:n===null?gQ.test(t)?`auth_profile_cooldown`:SQ.test(t)?`model_not_found`:HQ(t)?`context_length`:BZ.test(t)||VZ.test(t)?`session_write_conflict`:UQ(t)?`session_init_conflict`:hQ.test(VQ(t))?`session_archived`:mQ.test(VQ(t))?`session_paused_review`:CQ.test(t)?`rate_limit`:fQ.test(t)&&!pQ.test(t)?`provider_internal`:null:n}function YQ(e){let t=MQ.indexOf(e);return t===-1?MQ.length:t}function XQ(e){let t=null;for(let n of e)n!==null&&(t===null||YQ(n)<YQ(t))&&(t=n);return t}function ZQ(e){let t=QZ.exec(e);if(t===null)return null;let n=e.slice(t[0].length),r=eQ.exec(n);r!==null&&(n=n.slice(0,r.index));let i=n.split(` | `).map(e=>e.trim()).filter(e=>$Z.test(e)).map(e=>{let t=e.replace($Z,``),n=tQ.exec(t),r=n?.[1];return n!==null&&r!==void 0&&jQ.has(r)?{text:t.slice(0,n.index),reason:r}:{text:t,reason:null}});return i.length>0?{attempts:i,authHint:r!==null}:null}function QQ(e){let t=JQ(e.text);return t!==null&&NQ.has(t)?t:(e.reason===null?null:qQ(e.reason,VQ(e.text)))??t}function $Q(e){let t=ZQ(e);if(t===null)return JQ(e);let n=t.attempts.map(QQ),r=t.authHint?`provider_auth_failed`:null;return n.includes(`pending_input_dropped`)?n.every(e=>e!==null&&PQ.has(e))?`pending_input_dropped`:XQ([...n.filter(e=>e!==`pending_input_dropped`),r]):XQ([...n,r])}function e$(e){let t=null,n=e.replace(dQ,``);for(let e=0;e<4&&n!==null;e++){let e,r,i=nQ.exec(n),a=i===null?rQ.exec(n):null,o=i??a;if(o!==null){r=i===null?`compaction_timeout`:`preflight_compaction`;let t=n.slice(o[0].length),a=iQ.exec(t);e=a===null?null:t.slice(a[0].length).replace(aQ,``)}else oQ.test(n)?(r=`run_failure`,e=n.replace(oQ,``)):sQ.test(n)?(r=`run_failure`,e=n.replace(sQ,``).replace(cQ,``)):lQ.test(n)?(r=`run_failure`,e=n.replace(lQ,``)):uQ.test(n)&&(r=`run_failure`,e=null);if(r===void 0)break;t??=r,n=e==null||e.trim()===``?null:e.trim()}return t===null?{wrapper:null,inner:e}:{wrapper:t,inner:n}}function t$(e){if(!e)return null;let{wrapper:t,inner:n}=e$(e),r=n===null?null:$Q(n);return WQ(e)&&(r=XQ([r,`session_gone`])),r===null?t===`compaction_timeout`?`compaction_timeout`:t===`preflight_compaction`?`compaction_failed_no_cause`:t===`run_failure`?`run_failed_no_cause`:null:r}var n$=new Set([`awaiting_approval`,`awaiting_input`]),r$={thinking:Zr,generating:tg,error:Gee,aborted:vv},i$={processing_history:fv,compacting:wi,querying_gateway:Dn,awaiting_subagents:ou,post_processing:dl,awaiting_approval:Ta,awaiting_input:Qee,retrying:Qn},a$={rate_limit:pe,overloaded:$te,server_error:Ws,timeout:Zi},o$=3600*1e3;function s$(e,t){let n={attempt:String(e.attempt),maxAttempts:String(e.maxAttempts)},r=e.reason!==void 0&&Object.hasOwn(a$,e.reason)?a$[e.reason](n):Il(n),i=e.retryAt;return typeof i!=`number`||typeof t!=`number`||i<=t||i-t>o$?r:Cr({label:r,time:new Intl.DateTimeFormat(ut(),{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}).format(new Date(i))})}var c$=[[`read`,/^(read|read_file|cat|open|view|notebook_read)$/i],[`exec`,/^(exec|bash|shell|run|command|terminal)$/i],[`search`,/^(web_search|search|grep|find|glob|rg)$/i],[`fetch`,/^(web_fetch|fetch|browser|http_get)$/i],[`write`,/^(write|write_file|apply_patch|edit|str_replace|notebook_edit)$/i]];function l$(e){for(let[t,n]of c$)if(n.test(e))return t;return`other`}var u$={read:()=>A(),exec:()=>wg(),search:()=>wo(),fetch:()=>ot(),write:()=>At(),other:e=>Vc({tool:e})};function d$(e){if(!e||e.length===0)return null;let t=e=>e.toolCallId??e.toolName,n=new Set;for(let r=e.length-1;r>=0;r--){let i=e[r],a=i.phase??`completed`;if(a===`completed`||a===`error`){n.add(t(i));continue}if((a===`start`||a===`started`||a===`running`)&&!n.has(t(i)))return{name:i.toolName,family:l$(i.toolName)}}return null}function f$(e,t,n,r,i,a,o,s){let c=DZ(e,t,i??!1);if(c===null)return null;if(c===`thinking`||c===`generating`){if(o&&!(n&&n$.has(n)))return{kind:c,label:oS(o),phased:!0,struggling:!0};if(r)return{kind:c,label:u$[r.family](r.name),phased:!0};if(n===`retrying`&&a)return{kind:c,label:s$(a,s),phased:!0};if(n&&i$[n])return{kind:c,label:i$[n](),phased:!0}}return{kind:c,label:r$[c]()}}function p$(e,t){return!t||e!==`thinking`&&e!==`generating`?null:nd()}var m$=new Set([`context_length`,`context_length_compacted`,`context_length_presend`]),h$=new Set([`session_gone`,`session_archived`,`session_archived_historic`,`session_paused_review`,`gateway_agent_db_closed`,`provider_auth_revoked`,`provider_permission_denied`,`provider_auth_failed`]),g$=new Set([`provider_billing`,`model_not_found`,`compaction_failed_no_cause`,`run_failed_no_cause`,`compaction_timeout`]),_$={context_length:rd,context_length_compacted:Qr,context_length_presend:pv,rate_limit:Lu,timeout:cd,refusal:ri,stream_orphaned:Dy,connection_lost:lm,gateway_restarting:c,gateway_stopping:Ss,connection_saturated:Ad,GATEWAY_RESTARTING:c,GATEWAY_STOPPING:Ss,CONNECTION_SATURATED:Ad,response_timeout:ju,compaction_timeout:ene,empty_response:Gs,msgtool_args_unreadable:Qi,awaiting_approval:wr,empty_response_silent:en,unclassified_error:Xo,provider_internal:Xa,session_init_conflict:Gb,session_write_conflict:ze,session_gone:yc,session_archived:gte,session_archived_historic:Jf,session_paused_review:zte,session_visibility_refused:xb,session_settings_changed:ef,permission_mode_not_applied:ph,knowledge_policy_not_applied:Vee,gateway_version_unsupported:Dee,auth_profile_cooldown:G_,provider_auth_revoked:eee,provider_permission_denied:Bp,provider_auth_failed:Xy,provider_billing:qg,model_not_found:_p,provider_access_removed:ay,compaction_failed_no_cause:S_,run_failed_no_cause:Tf,pending_input_dropped:Um,gateway_storage_busy:Oy,gateway_state_contention:um,gateway_storage_unavailable:Es,gateway_agent_db_closed:Id,not_configured:Yl,no_agent:De,agent_restricted:bx,AGENT_LEFT_ROOM:ac,send_failed:fa,DISPATCH_STALLED:lo,ATTACHMENT_TOO_LARGE:Rr,ATTACHMENT_REJECTED:mn,attachment_name_too_long:Bf,attachment_path_refused:sh,attachment_staging_failed:sh,attachment_cleanup_unconfirmed:sh,message_too_large:w,subagent_reply_pending:h_,gateway_media_unavailable:Ah},v$=/^\s*all (?:[a-z][\w -]{0,60}? )?models failed \(\d+\):\s*/i,y$=/^[^\s/|]+\/\S+?:\s+/,b$=/pending input is no longer active in its admitted transcript/i;function x$(e){let t=v$.exec(e);if(t===null)return b$.test(e);let n=e.slice(t[0].length).split(` | `).map(e=>e.trim()).filter(e=>y$.test(e)).map(e=>e.replace(y$,``));return n.length>0&&n.every(e=>b$.test(e))}var S$=new Set([`session_gone`,`session_paused_review`,`provider_auth_revoked`,`provider_permission_denied`,`provider_auth_failed`,`provider_billing`,`model_not_found`,`rate_limit`,`context_length`,`compaction_timeout`,`compaction_failed_no_cause`,`run_failed_no_cause`]),C$=new Set([`provider_auth_revoked`,`provider_permission_denied`,`provider_auth_failed`]);function w$(e){let t=t$(e);return t===null?null:t===`session_archived`?`session_archived_historic`:t===`pending_input_dropped`?x$(e)?`pending_input_dropped`:null:S$.has(t)?t:null}var T$=new Set([`stream_orphaned`,`connection_lost`,`gateway_restarting`,`gateway_stopping`,`connection_saturated`,`response_timeout`,`not_configured`,`no_agent`,`agent_restricted`,`send_failed`,`ATTACHMENT_TOO_LARGE`,`ATTACHMENT_REJECTED`,`attachment_path_refused`,`attachment_name_too_long`,`attachment_staging_failed`,`attachment_cleanup_unconfirmed`,`message_too_large`,`subagent_reply_pending`,`gateway_media_unavailable`,`provider_access_removed`]);function E$(e,t){let n=AZ((e??``).trim()),r=n===``?null:w$(n),i;i=t&&_$[t]&&t!==`unclassified_error`?t===`provider_auth_revoked`&&r!==null&&r!==t&&C$.has(r)?r:t:T$.has(n)?n:r??t??null;let a=i===null?null:_$[i]?.()??null,o=n===``||n===i||T$.has(n),s=i!==null&&h$.has(i),c=!o&&!s&&(e$(n).wrapper!==null||i!==null&&g$.has(i));return{headline:a,detail:o||s||c?null:n,rawDetail:c?n:null,code:i}}var D$=OZ,O$=new Set([`chat_busy`,`not_last_message`,`no_preceding_user_turn`]);function k$(e){return e==null?null:e.outcome===`exhausted`?j({attempt:String(e.attempt),max:String(e.maxAttempts)}):e.reason===`another_turn_streaming`?Tg():e.reason===`delegated_work`?To():e.reason===`concurrent_writer`?st():e.reason!==void 0&&O$.has(e.reason)?jt():Hc()}var A$=new Map([[`gateway_state_contention`,p]]);function j$(e){switch(e){case`queued`:case`live`:case`running`:return`running`;case`done`:return`done`;case`failed`:case`timeout`:return`error`;case`killed`:case`interrupted`:return`aborted`;case`idle`:case`unknown`:return null}}function M$(e){let t=e.trim();if(t===``)return``;let n=t.slice(t.lastIndexOf(`:`)+1)||t;return n.length>10?`${n.slice(0,8)}…`:n}var N$=RegExp(`^agent:(.+?):(?:${[`subagent`,`dashboard`].join(`|`)}):`);function P$(e){return N$.exec(e.trim())?.[1]?.trim()||void 0}function F$(e){if(!Number.isFinite(e)||e<0)return``;if(e<1e3)return`< 1 s`;let t=Math.round(e/1e3);if(t<60)return`${t} s`;let n=Math.floor(t/60),r=t%60;if(n<60)return r>0?`${n} min ${r} s`:`${n} min`;let i=Math.floor(n/60),a=n%60;return a>0?`${i} h ${String(a).padStart(2,`0`)} min`:`${i} h`}function I$(e){if(!Number.isFinite(e)||e<0)return``;let t=e>0&&e<.01?4:2;return`${e.toFixed(t).replace(`.`,`,`)} $`}function L$(e){return e.moaRole===`moa_aggregator`?Nb():e.moaRole===`moa_reference`?Kte():sx()}function R$(e){return e.kind===`task`?u({tool:e.taskName?.trim()||`task`}):e.taskName?.trim()||M$(e.childSessionKey)||mp()}function z$(e){return e.some(e=>e.status===`running`&&e.kind!==`task`)}function B$(e,t){return e===`running`?`running`:e===`done`?`done`:e===`aborted`?t===`killed`?`failed`:`aborted`:`failed`}function V$(e,t){return e===`running`?Tn():e===`done`?bs():e===`error`?t===`timeout`?qa():xo():t===`killed`?Sg():t===`interrupted`?ue():Wg()}var H$={queued:()=>({tone:`running`,label:qo()}),live:()=>({tone:`running`,label:Tn()}),running:()=>({tone:`running`,label:Tn()}),idle:()=>({tone:`aborted`,label:Ot()}),unknown:()=>({tone:`aborted`,label:Zt()}),done:()=>({tone:`done`,label:bs()}),failed:()=>({tone:`failed`,label:xo()}),timeout:()=>({tone:`failed`,label:qa()}),killed:()=>({tone:`failed`,label:Sg()}),interrupted:()=>({tone:`aborted`,label:ue()})};function U$(e){let t=e.stoppedRunId??e.childRunId,n=e.gatewayRow?.runId!==void 0&&t!==void 0&&e.gatewayRow.runId!==t;if(e.stopRequestedAt!==void 0&&e.status!==`running`&&!n)return{tone:`aborted`,label:Wg()};let r=e.gatewayRow?.display,i=r===void 0?void 0:H$[r];return i!==void 0&&(j$(r)??e.status)===e.status?i():{tone:B$(e.status,e.providerStatus),label:V$(e.status,e.providerStatus)}}function W$(e){return e!==`running`}function G$(e){return e!==void 0&&e.tone!==`running`&&e.sessionMeta?.cleanup===`delete`}function K$(e){return e.startsWith(`fork:`)}function q$(e){let{tone:t,label:n}=U$(e),r=e.sessionMeta?.subagentRole;return{id:e._id,childSessionKey:e.childSessionKey,...e.kind===`task`?{isTask:!0}:{},...r===`moa_reference`||r===`moa_aggregator`?{moaRole:r}:{},taskName:e.taskName?.trim()||void 0,label:R$(e),status:e.status,tone:t,statusLabel:n,failure:t===`failed`,phase:e.status===`running`?e.phase:void 0,errorMessage:e.errorMessage,errorCode:e.errorCode,runTimeoutSeconds:e.runTimeoutSeconds,resultText:e.resultText,tools:e.tools?.map(e=>({name:e.name,status:e.status,toolCallId:e.toolCallId})),sessionMeta:e.sessionMeta,telemetry:e.telemetry,childAgentId:P$(e.childSessionKey)}}function J$(e){let t=[...e].sort((e,t)=>t.createdAt-e.createdAt).map(q$).sort((e,t)=>{let n=e=>e.moaRole===`moa_aggregator`?0:e.moaRole===`moa_reference`?1:2,r=e=>e.moaRole?e.childSessionKey.replace(/:(ref\d+|aggregate)$/,``):``,i=r(e).localeCompare(r(t));if(e.moaRole&&t.moaRole&&i!==0)return i;let a=n(e),o=n(t);if(a!==o)return a-o;if(a===1){let n=e=>{let t=/ref(\d+)$/.exec(e.childSessionKey);return t?.[1]?Number.parseInt(t[1],10):0};return n(e)-n(t)}return 0});return{cards:t,total:t.length,done:t.filter(e=>e.tone===`done`).length,running:t.filter(e=>e.tone===`running`).length,failed:t.filter(e=>e.tone===`failed`).length,aborted:t.filter(e=>e.tone===`aborted`).length}}function Y$(e){if(e.total<=1)return[];let t={done:e.done,running:e.running,failed:e.failed,aborted:e.aborted};return[`done`,`running`,`failed`,`aborted`].filter(e=>t[e]>0).map(e=>({tone:e,count:t[e]}))}function X$(e,t,n){let r=new Set(t);return e.filter(e=>n!==void 0&&e.parentMessageId===n||r.has(e.childSessionKey))}function Z$(e){return e===1?Ca({count:e}):Yr({count:e})}var Q$=120,$$=/EXTERNAL_UNTRUSTED_CONTENT|SECURITY\s*NOTICE|UNTRUSTED\s*CONTENT/i,e1=/DO NOT/;function t1(e){return $$.test(e)||e1.test(e)}function n1(e){return e.length<=Q$?e:`${e.slice(0,Q$-1)}…`}function r1(e){for(let t of e.split(/\r?\n/)){let e=t.replace(/\s+/g,` `).trim();if(!(e.length<3)&&/[\p{L}\p{N}]/u.test(e)&&!t1(e))return e}return null}function i1(e,t,n){let r=ll();if(t===`timeout`)return n1(typeof n==`number`&&Number.isInteger(n)&&n>0?pte({seconds:n}):it());if(t===`subagent_no_activity`)return n1(Ite());if(t===`spawn_refused`)return n1(zc());if(t){let e=_$[t]?.();if(e)return n1(e)}if(e==null)return r;let i=e.trim();if(i===``)return r;let a=/([A-Za-z][\w.-]*)\s+failed\s*\(([^)]{1,40})\)/i.exec(i);if(a)return n1(`${a[1]} (${a[2].trim()})`);let o=r1(i);return o&&!t1(o)?n1(o):r}function a1(e,t){if(!t||t!==`timeout`&&t!==`spawn_refused`&&_$[t]===void 0)return null;let n=e?.trim()??``;return n===``||r1(n)===null?null:n}function o1(e){return e===`message_too_large`?w():e===`attachment_too_large`?Rr():e??Ec()}function s1(e){let t=document.querySelector(`[data-message-id="${CSS.escape(e)}"]`);if(!t)return;let n=t.closest(`.oc-thread__viewport`);if(RK(n),n){let e=t.getBoundingClientRect().top-n.getBoundingClientRect().top;n.scrollTo({top:n.scrollTop+e-12,behavior:`smooth`})}else t.scrollIntoView({block:`start`,behavior:`smooth`});t.classList.remove(`oc-msg--highlight`),t.offsetWidth,t.classList.add(`oc-msg--highlight`),window.setTimeout(()=>t.classList.remove(`oc-msg--highlight`),2400)}function c1(e,t){let n=new Blob([t],{type:`text/markdown;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}var l1=(0,q.createContext)(null);function u1({card:e}){return(0,J.jsxs)(`span`,{className:`oc-subpanel__status oc-subpanel__status--${e.tone}`,children:[e.statusLabel,e.tone===`running`?(0,J.jsx)(OC,{size:13,className:`oc-subagent__spin`,"aria-hidden":!0}):e.tone===`failed`?(0,J.jsx)(pA,{size:13,"aria-hidden":!0}):e.tone===`aborted`?(0,J.jsx)(hA,{size:13,"aria-hidden":!0}):(0,J.jsx)(ZS,{size:13,"aria-hidden":!0})]})}function d1(e){if(e)try{return JSON.parse(e)}catch{return}}function f1(e){return{type:e===`error`?`error`:e===`done`?`completed`:`running`}}function p1(e){return e.toolCallId??`name:${e.name}`}function m1({summary:e,parts:t,subAgentRunning:n}){let[r,i]=(0,q.useState)(!1),a=n,o=e.length===1?Hl({count:e.length}):be({count:e.length}),s=a?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(OC,{size:13,className:`oc-actrow__status-icon oc-actrow__spin`,"aria-hidden":!0}),Pl()]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ZS,{size:13,className:`oc-actrow__status-icon`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-sr-only`,children:de()})]}),c=new Map;for(let e of t??[])c.set(e.toolCallId,e);return(0,J.jsxs)(`div`,{className:`oc-toolact`,children:[(0,J.jsx)(oq,{icon:(0,J.jsx)(Cj,{size:14}),label:o,trailing:s,open:r,ariaExpanded:r,title:r?Hs():cx(),onClick:()=>i(!r)}),r?(0,J.jsx)(`div`,{className:`oc-toolact__detail`,children:e.map((e,t)=>{let r=c.get(p1(e));return(0,J.jsx)(bZ,{toolName:e.name,args:r?d1(r.argsText):void 0,argsText:r?.argsText,result:r?.resultText,status:f1(r?.status??e.status),turnSettled:!n},`${p1(e)}-${t}`)})}):null]})}function h1({meta:e,telemetry:t,childAgentId:n,instanceName:r,parentAgentLabel:i,onExport:a,panelKey:o}){let[s,c]=(0,q.useState)(!1),l=!!e&&Object.values(e).some(e=>e!==void 0)||!!t&&Object.values(t).some(e=>e!==void 0)||n!==void 0;if(!l&&!i&&!a)return(0,J.jsx)(`div`,{className:`oc-subpanel__barslot`,"aria-hidden":!0});let u=e?.fastMode===void 0?null:e.fastMode?km():_();return(0,J.jsxs)(`div`,{className:`oc-subpanel__bar`,children:[(0,J.jsxs)(`div`,{className:`oc-subpanel__bar-chips`,children:[e?.model?(0,J.jsxs)(`span`,{className:`oc-chip oc-chip--info`,title:e.modelProvider?dm({provider:e.modelProvider}):Qh(),children:[(0,J.jsx)(bA,{size:12,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-chip__label`,children:e.model})]}):null,e?.thinkingLevel?(0,J.jsxs)(`span`,{className:`oc-chip`,title:__(),children:[(0,J.jsx)(dA,{size:12,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-chip__label`,children:e.thinkingLevel})]}):null,u?(0,J.jsxs)(`span`,{className:`oc-chip`,title:Ky(),children:[(0,J.jsx)(EC,{size:12,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-chip__label`,children:u})]}):null,e?.context?(0,J.jsxs)(`span`,{className:`oc-chip`,title:e.context===`fork`?Fi():Sv(),children:[(0,J.jsx)(gj,{size:12,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-chip__label`,children:e.context})]}):null,i?(0,J.jsxs)(`span`,{className:`oc-chip`,title:pd(),children:[(0,J.jsx)(kS,{size:12,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-chip__label`,children:i})]}):null,a?(0,J.jsxs)(hC,{children:[(0,J.jsx)(oC,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`oc-chip oc-chip--btn oc-subpanel__bar-export`,title:Uf(),"data-focus-key":`subagent:export:${o}`,children:[(0,J.jsx)(bC,{size:12,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-chip__label`,children:V_()}),(0,J.jsx)(QS,{size:12,className:`oc-chip__chev`,"aria-hidden":!0})]})}),(0,J.jsxs)(dC,{align:`end`,className:`w-44`,children:[(0,J.jsx)(uC,{children:V_()}),(0,J.jsx)(pC,{onClick:()=>a(`md`),children:ye()}),(0,J.jsx)(pC,{onClick:()=>a(`json`),children:fx()})]})]}):null]}),l?(0,J.jsxs)(`button`,{type:`button`,className:`oc-subpanel__adv-toggle${s?` is-open`:``}`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[(0,J.jsx)(HC,{size:13,"aria-hidden":!0}),ci(),(0,J.jsx)(eC,{size:13,className:`oc-subpanel__adv-chevron`,"aria-hidden":!0})]}):null,s&&l?(0,J.jsx)(_1,{meta:e??{},telemetry:t,childAgentId:n,instanceName:r}):null]})}function g1(e){return e===`leaf`?No():e===`orchestrator`?ht():null}function _1({meta:e,telemetry:t,childAgentId:n,instanceName:r}){let i=[];e.model&&i.push([Qh(),e.model]),e.modelProvider&&i.push([ty(),e.modelProvider]);let a=e.agentId??n;a&&i.push([gx(),a]),r&&i.push([uf(),r]),e.label&&i.push([tc(),e.label]),e.thinkingLevel&&i.push([__(),e.thinkingLevel]),e.fastMode!==void 0&&i.push([Ky(),e.fastMode?km():_()]),e.context&&i.push([Sv(),e.context]),e.lightContext!==void 0&&i.push([ca(),e.lightContext?Pr():un()]),e.runtime&&i.push([Ln(),e.runtime]),e.mode&&i.push([hu(),e.mode]),e.cleanup&&i.push([xl(),e.cleanup]),e.sandbox&&i.push([cr(),e.sandbox]),e.controlScope&&i.push([As(),e.controlScope]),e.subagentRole&&i.push([Bd(),e.subagentRole]),e.spawnDepth!==void 0&&i.push([Vu(),String(e.spawnDepth)]);let o=g1(e.subagentRole);if(o&&i.push([Ce(),o]),e.sessionId&&i.push([as(),e.sessionId]),e.gatewayKind&&i.push([Gl(),e.gatewayKind]),t?.runtimeMs!==void 0){let e=F$(t.runtimeMs);e&&i.push([oo(),e])}if(t?.totalTokens!==void 0&&i.push([Ia(),Yw(t.totalTokens)]),t?.estimatedCostUsd!==void 0){let e=typeof t.totalTokens==`number`&&t.totalTokens>0;if(t.estimatedCostUsd<=0&&e)i.push([dg(),xd()]);else{let e=I$(t.estimatedCostUsd);e&&i.push([dg(),e])}}return(0,J.jsx)(`dl`,{className:`oc-subpanel__adv-list`,children:i.map(([e,t])=>(0,J.jsxs)(`div`,{className:`oc-subpanel__adv-row`,children:[(0,J.jsx)(`dt`,{children:e}),(0,J.jsx)(`dd`,{children:t})]},e))})}function v1({chatId:e,childKey:t,onClose:n,parentAgentLabel:r}){let i=H(G.subAgents.listSubAgents,{chatId:e}),a=H(G.agents.getChatAgent,{chatId:e}),o=H(G.messages.getSessionMeta,{chatId:e}),s=o?.viewerRole===`participant`,c=o?.perTurnRouting===!0?void 0:a?.agent?.instanceName,l=(i??[]).find(e=>e.childSessionKey===t),u=l?J$([l]).cards[0]:void 0,d=l?.taskName?.trim(),f=G$(u),p=u?.failure?a1(u.errorMessage,u.errorCode):null,m=K$(t),h=H(G.subAgentReports.myReportedSubAgentIds,{chatId:e}),g=H(G.subAgents.listSubAgentToolParts,{chatId:e,childSessionKey:t}),_=H(G.subAgentInteractions.listSubAgentInteractions,{chatId:e,childSessionKey:t}),v=Aa(G.subAgentInteractions.sendToSubAgent),y=U(G.chats.generateUploadUrl),b=U(G.uploads.registerUpload),[x,S]=(0,q.useState)(!1),[C,w]=(0,q.useState)(!0),[T,E]=(0,q.useState)(!1),[D,O]=(0,q.useState)(``),[k,A]=(0,q.useState)(!1),[j,M]=(0,q.useState)([]),[N,P]=(0,q.useState)(!1),[F,I]=(0,q.useState)(!0),L=(0,q.useRef)(null),R=(0,q.useRef)(null),z=(0,q.useCallback)(async e=>{if(!(!e||e.length===0)){P(!0);try{for(let t of Array.from(e)){if(j.length>=6)break;let e=await y(),{storageId:n}=await(await fetch(e,{method:`POST`,headers:{"Content-Type":t.type||`application/octet-stream`},body:t})).json();await b({storageId:n}),M(e=>e.length>=6?e:[...e,{storageId:n,filename:t.name,mimeType:t.type||`application/octet-stream`}])}}finally{P(!1),L.current&&(L.current.value=``)}}},[j.length,y,b]),[V,ee]=(0,q.useState)(null),te=u?(h??[]).includes(u.id):!1,ne=(0,q.useCallback)(e=>{if(!u)return;let t=g&&g.length>0?g.map(e=>({name:e.name,status:e.status,argsText:e.argsText,resultText:e.resultText})):(u.tools??[]).map(e=>({name:e.name,status:e.status})),n={taskName:d,status:u.status,parentAgentLabel:r,sessionMeta:u.sessionMeta,telemetry:u.telemetry,result:u.resultText,error:u.failure?i1(u.errorMessage,u.errorCode,u.runTimeoutSeconds):void 0,tools:t};c1(wZ(d,e),e===`md`?EZ(n):TZ({...n,exportedAt:Date.now()}))},[u,g,d,r]);(0,q.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,q.useEffect)(()=>{i!==void 0&&!l&&n()},[i,l,n]);let re=_&&_.length>0?`${_.length}:${_[_.length-1].status}`:``;(0,q.useEffect)(()=>{if(!re)return;let e=R.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`smooth`})},[re]);let ie=Iw(),ae=async()=>{let n=D.trim();if(!(f||m)&&!(!n&&j.length===0||x||N)){S(!0);try{await v({chatId:e,childSessionKey:t,text:n,...j.length>0?{attachments:j.map(e=>({storageId:e.storageId,filename:e.filename,mimeType:e.mimeType}))}:{}}),O(``),M([])}catch(e){let t=String(e?.message??``);ie.error(t.includes(`TALK_CALL_ACTIVE`)?Cf():t.includes(`SUBAGENT_RECOVERING`)?nte():Fh())}finally{S(!1)}}};return(0,J.jsxs)(`div`,{className:`oc-subpanel`,children:[(0,J.jsxs)(`header`,{className:`oc-subpanel__head`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-subpanel__avatar oc-subpanel__back${u?` oc-subpanel__avatar--${u.tone}`:``}`,disabled:!l?.parentMessageId,title:wee(),"aria-label":vb(),onClick:()=>l?.parentMessageId&&s1(l.parentMessageId),children:(0,J.jsx)(iA,{size:16})}),(0,J.jsxs)(`div`,{className:`oc-subpanel__headmain`,children:[(0,J.jsxs)(`div`,{className:`oc-subpanel__head-top`,children:[(0,J.jsx)(`span`,{className:`oc-subpanel__kind`,children:u?L$(u):sx()}),(0,J.jsxs)(`div`,{className:`oc-subpanel__head-ctrls`,children:[u?(0,J.jsx)(u1,{card:u}):null,u&&W$(u.status)&&!s?(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn oc-subpanel__report${te?` is-on`:``}`,title:te?_d():wy(),"aria-label":wy(),disabled:te,"data-focus-key":`subagent:report:${t}`,onClick:()=>ee({subAgentId:u.id,label:u.label}),children:(0,J.jsx)(DA,{size:15,"aria-hidden":!0})}):null,(0,J.jsx)(K,{variant:`ghost`,size:`icon-sm`,onClick:n,"aria-label":xf(),className:`oc-subpanel__close`,children:(0,J.jsx)(YC,{size:16})})]})]}),d?(0,J.jsx)(`button`,{type:`button`,className:`oc-subpanel__task${k?` is-expanded`:``}`,title:Ip(),"aria-expanded":k,onClick:()=>A(e=>!e),children:d}):null]})]}),(0,J.jsx)(h1,{meta:u?.sessionMeta,telemetry:u?.telemetry,childAgentId:u?.childAgentId,instanceName:c,parentAgentLabel:r,onExport:u?ne:void 0,panelKey:t}),(0,J.jsx)(`div`,{className:`oc-subpanel__body`,ref:R,children:u?(0,J.jsxs)(J.Fragment,{children:[u.tools&&u.tools.length>0&&F?(0,J.jsxs)(`section`,{className:`oc-subpanel__section`,children:[(0,J.jsx)(`h3`,{className:`oc-subpanel__section-title`,children:Nh()}),(0,J.jsx)(m1,{summary:u.tools,parts:g,subAgentRunning:u.tone===`running`})]}):null,u.failure?(0,J.jsxs)(`section`,{className:`oc-subpanel__section`,children:[(0,J.jsx)(`h3`,{className:`oc-subpanel__section-title`,children:s_()}),(0,J.jsx)(`p`,{className:`oc-subpanel__error`,children:i1(u.errorMessage,u.errorCode,u.runTimeoutSeconds)}),p===null?null:(0,J.jsxs)(`details`,{className:`oc-subpanel__error-detail`,children:[(0,J.jsx)(`summary`,{children:uv()}),(0,J.jsx)(`p`,{className:`oc-subpanel__muted`,children:p})]})]}):null,u.resultText?(0,J.jsxs)(`section`,{className:`oc-subpanel__section oc-subpanel__result${C?` is-open`:``}`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-subpanel__result-toggle`,"aria-expanded":C,onClick:()=>w(!C),children:[(0,J.jsx)(eC,{size:13,className:`oc-subpanel__result-chevron`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-subpanel__section-title`,children:Bm()})]}),C?(0,J.jsx)(sJ,{text:u.resultText}):null]}):u.tone===`running`?(0,J.jsxs)(`p`,{className:`oc-subpanel__muted oc-subpanel__working`,children:[(0,J.jsx)(OC,{size:14,className:`oc-subagent__spin`,"aria-hidden":!0}),sm()]}):null,_&&_.length>0?(0,J.jsxs)(`section`,{className:`oc-subpanel__section`,children:[(0,J.jsx)(`h3`,{className:`oc-subpanel__section-title`,children:zt()}),(0,J.jsx)(`div`,{className:`oc-subpanel__thread`,children:_.map(e=>(0,J.jsxs)(`div`,{className:`oc-subpanel__exchange`,children:[(0,J.jsxs)(`div`,{className:`oc-subpanel__msg oc-subpanel__msg--user`,children:[e.userText,e.attachments&&e.attachments.length>0?(0,J.jsx)(`div`,{className:`oc-subpanel__msg-atts`,children:e.attachments.map((t,n)=>(0,J.jsxs)(`span`,{className:`oc-subpanel__attchip oc-subpanel__attchip--sent`,title:t.filename,children:[(0,J.jsx)(rj,{size:11,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-subpanel__attchip-name`,children:t.filename})]},`${e._id}-att-${n}`))}):null]}),e.status===`pending`?(0,J.jsxs)(`div`,{className:`oc-subpanel__msg oc-subpanel__msg--pending`,children:[(0,J.jsx)(OC,{size:13,className:`oc-actrow__spin`,"aria-hidden":!0}),Xc()]}):e.status===`error`?(0,J.jsx)(`div`,{className:`oc-subpanel__msg oc-subpanel__msg--err`,children:o1(e.errorMessage)}):(0,J.jsxs)(`div`,{className:`oc-subpanel__msg oc-subpanel__msg--reply`,children:[(0,J.jsx)(sJ,{text:e.replyText??``}),e.widgetOmitted===!0?(0,J.jsx)(`p`,{className:`oc-subpanel__note`,children:Ke()}):null]})]},e._id))})]}):null]}):(0,J.jsx)(`p`,{className:`oc-subpanel__muted`,children:uh()})}),s?null:(0,J.jsx)(`footer`,{className:`oc-subpanel__foot`,children:T?(0,J.jsxs)(`div`,{className:`oc-subpanel__prompt`,children:[j.length>0?(0,J.jsx)(`div`,{className:`oc-subpanel__attstrip`,children:j.map((e,t)=>(0,J.jsxs)(`span`,{className:`oc-subpanel__attchip`,title:e.filename,children:[(0,J.jsx)(rj,{size:12,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-subpanel__attchip-name`,children:e.filename}),(0,J.jsx)(`button`,{type:`button`,className:`oc-subpanel__attchip-x`,"aria-label":cf(),onClick:()=>M(e=>e.filter((e,n)=>n!==t)),children:(0,J.jsx)(YC,{size:11,"aria-hidden":!0})})]},`${e.storageId}-${t}`))}):null,(0,J.jsx)(`textarea`,{className:`oc-subpanel__prompt-input`,rows:2,value:D,onChange:e=>O(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ae())},placeholder:bh(),autoFocus:!0}),(0,J.jsxs)(`div`,{className:`oc-subpanel__prompt-bar`,children:[(0,J.jsxs)(`div`,{className:`oc-subpanel__composer-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-subpanel__composer-btn`,title:ix(),"aria-label":ix(),disabled:N||j.length>=6,onClick:()=>L.current?.click(),children:N?(0,J.jsx)(OC,{size:15,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,J.jsx)(LC,{size:15,"aria-hidden":!0})}),u?.tools&&u.tools.length>0?(0,J.jsxs)(`button`,{type:`button`,className:`oc-subpanel__composer-btn oc-subpanel__composer-btn--label${F?` is-on`:``}`,title:kb(),"aria-pressed":F,onClick:()=>I(e=>!e),children:[(0,J.jsx)(Cj,{size:14,"aria-hidden":!0}),Nh()]}):null]}),u?.tone===`running`?(0,J.jsx)(`span`,{className:`oc-subpanel__prompt-hint`,children:Cte()}):m?(0,J.jsx)(`span`,{className:`oc-subpanel__prompt-hint`,children:Mg()}):f?(0,J.jsx)(`span`,{className:`oc-subpanel__prompt-hint`,children:B()}):(_??[]).some(e=>e.status===`pending`)?(0,J.jsx)(`span`,{className:`oc-subpanel__prompt-hint`,children:tp()}):null,(0,J.jsxs)(K,{variant:`default`,size:`sm`,className:`gap-1.5`,disabled:!D.trim()&&j.length===0||x||N||u?.tone===`running`||f||m||(_??[]).some(e=>e.status===`pending`),onClick:()=>void ae(),children:[x?(0,J.jsx)(OC,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,J.jsx)(sj,{size:14,"aria-hidden":!0}),Nee()]})]}),(0,J.jsx)(`input`,{ref:L,type:`file`,multiple:!0,className:`oc-subpanel__fileinput`,onChange:e=>void z(e.target.files)})]}):(0,J.jsxs)(`button`,{type:`button`,className:`oc-subpanel__interact`,onClick:()=>E(!0),children:[(0,J.jsx)(pS,{size:15,"aria-hidden":!0}),Xm()]})}),(0,J.jsx)(CZ,{target:V,onClose:()=>ee(null)})]})}var y1=[`op`,`jobId`,`name`,`enabled`,`schedule`,`message`,`deliveryMode`,`agentId`,`nextRunAtMs`],b1=null,x1=1,S1=new Set;function C1(){for(let e of[...S1])e()}function w1(e){return S1.add(e),()=>S1.delete(e)}function T1(){return b1}function E1(e){return b1={pinId:x1++,kind:e.kind,ownerUserId:e.ownerUserId,originChatId:e.originChatId,originLabel:e.originLabel,params:e.params,pinned:!1},C1(),b1}function D1(e,t){b1===null||b1.pinId!==e||b1.pinned!==t&&(b1={...b1,pinned:t},C1())}function O1(e){b1!==null&&(e!==void 0&&e!==b1.pinId||(b1=null,C1()))}function k1(e,t){b1===null||b1.pinId!==e||(b1={...b1,params:t},C1())}function A1(e,t){return e===null||e.ownerUserId!==t.userId?`none`:e.pinned||P1(e,t)?`dock`:`none`}function j1(e,t){switch(e){case`sources`:return`sources:${String(t.messageId??``)}`;case`subagent`:return`subagent:${String(t.childKey??``)}`;case`cron`:{let e=t.part??{};return`cron:${JSON.stringify([String(t.instanceName??``),String(t.jobId??``),String(t.occurrenceId??``),y1.map(t=>e[t]??null)])}`}case`document`:{let e=t.doc??{};return`document:${JSON.stringify([e.filename??null,e.storageId??e.url??null])}`}}}function M1(e,t){return e-420>=t}function N1(e,t,n){return Math.max(n,Math.min(e,t-420))}function P1(e,t){return e===null||e.ownerUserId!==t.userId?!1:e.originChatId!==null&&e.originChatId===t.chatId}function F1(e,t){return e===null||e.ownerUserId!==t.userId?!1:!e.pinned&&!P1(e,t)}function I1(e,t){return P1(e,t)?`keep`:`close`}function L1(e,t){return P1(e,t)?e:null}function R1(){let[e,t]=(0,q.useState)(()=>window.innerWidth);return(0,q.useLayoutEffect)(()=>{let e=()=>{let e=document.querySelector(`.oc-workspace`);if(e===null)return;let n=e.querySelector(`.oc-sidebar-col`),r=n===null?0:n.getBoundingClientRect().width,i=e.getBoundingClientRect().width-r;i>0&&t(i)},n=new ResizeObserver(e);n.observe(document.documentElement);let r=new Set,i=()=>{let t=document.querySelector(`.oc-workspace`),i=new Set;if(t!==null){let e=t.querySelector(`.oc-sidebar-col`);e!==null&&i.add(e)}for(let e of r)i.has(e)||n.unobserve(e);for(let e of i)r.has(e)||n.observe(e);r.clear();for(let e of i)r.add(e);e()};i();let a=new MutationObserver(i);return a.observe(document.body,{childList:!0,subtree:!0}),()=>{n.disconnect(),a.disconnect()}},[]),e}function z1(e){let t=nJ({storageKey:`oc.sources.width`,fit:e(300),defaultWidth:380,min:300,max:680,edge:`right`}),n=nJ({storageKey:`oc.subagent.width`,fit:e(320),defaultWidth:460,min:320,max:720,edge:`right`}),r=nJ({storageKey:`oc.docviewer.width`,fit:e(380),defaultWidth:560,min:380,max:1800,maxViewportFraction:.72,edge:`right`}),i={...t,min:300},a={...r,min:380};return{sources:i,subagent:{...n,min:320},cron:i,document:a}}function B1({viewerUserId:e,currentChatId:t}){let n=(0,q.useSyncExternalStore)(w1,T1,T1),r=Kx(),i=Qq(),a=R1(),o=z1((0,q.useCallback)(e=>t=>N1(t,a,e),[a])),s={userId:e,chatId:t};(0,q.useEffect)(()=>()=>O1(),[]);let c=F1(n,s),l=n?.pinId;if((0,q.useEffect)(()=>{c&&l!==void 0&&O1(l)},[c,l]),n===null||A1(n,s)!==`dock`)return null;let u=n.params,d=()=>O1(n.pinId),{width:f,startResize:p,columnRef:m,min:h}=o[n.kind],g=i||!M1(a,h);if(g&&!n.pinned)return null;let _=N1(f,a,h);return(0,J.jsx)(nY,{children:(0,J.jsxs)(`aside`,{className:`oc-pinpanel`,ref:m,hidden:g,style:g?{display:`none`}:{width:_,flex:`0 0 ${_}px`},"aria-label":Ei({origin:n.originLabel}),children:[(0,J.jsx)(`div`,{className:`oc-pinpanel__resizer`,onPointerDown:p,role:`separator`,"aria-orientation":`vertical`,"aria-label":cu()}),(0,J.jsxs)(`div`,{className:`oc-pinpanel__head`,children:[(0,J.jsx)(`span`,{className:`oc-pinpanel__origin`,title:n.originLabel,children:n.originLabel}),(0,J.jsxs)(`span`,{className:`oc-pinpanel__ctrls`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-pinpanel__btn${n.pinned?` is-on`:``}`,"aria-pressed":n.pinned,title:n.pinned?pl():er(),"aria-label":n.pinned?pl():er(),onClick:()=>{if(!n.pinned){D1(n.pinId,!0);return}I1(n,s)===`close`?d():D1(n.pinId,!1)},children:n.pinned?(0,J.jsx)(LS,{size:14,"aria-hidden":!0}):(0,J.jsx)(Xx,{size:14,"aria-hidden":!0})}),n.originChatId!==null&&!P1(n,s)?(0,J.jsx)(`button`,{type:`button`,className:`oc-pinpanel__btn`,title:kn(),"aria-label":kn(),onClick:()=>void r({to:`/chat/$chatId`,params:{chatId:n.originChatId}}),children:(0,J.jsx)(CA,{size:14,"aria-hidden":!0})}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-pinpanel__btn`,title:he(),"aria-label":he(),onClick:d,children:(0,J.jsx)(YC,{size:14,"aria-hidden":!0})})]})]}),(0,J.jsx)(hq,{onClose:d,children:(0,J.jsx)(`div`,{className:`oc-pinpanel__body`,children:n.kind===`cron`?(0,J.jsx)(mq,{instanceName:u.instanceName,part:u.part,onClose:d}):n.kind===`document`?(0,J.jsx)(zJ.Provider,{value:{activeDoc:u.doc,openFor:e=>k1(n.pinId,{...u,doc:e}),openNewerVersion:e=>k1(n.pinId,{...u,doc:e}),close:d},children:(0,J.jsx)(VJ,{doc:u.doc,chatId:n.originChatId,onClose:d})}):n.kind===`subagent`?(0,J.jsx)(v1,{chatId:n.originChatId,childKey:u.childKey,onClose:d,parentAgentLabel:u.parentAgentLabel??``}):(0,J.jsx)(yY,{messageId:u.messageId,onClose:d})})},n.pinId)]})})}var V1=`atrium:lastChatId`;function H1(e){try{localStorage.setItem(V1,e)}catch{}}function U1(){try{return localStorage.getItem(V1)}catch{return null}}function W1(e){let t=e instanceof Error?`${e.name}: ${e.message}`:String(e??``);return t.includes(`Failed to fetch dynamically imported module`)||t.includes(`Importing a module script failed`)||t.includes(`error loading dynamically imported module`)||t.includes(`Unable to preload CSS`)}var G1=`atrium:chunkReloadAt`,K1=6e4;function q1(){try{return typeof sessionStorage>`u`?null:sessionStorage}catch{return null}}function J1(e,t=q1()){if(t===null)return!1;try{let n=Number(t.getItem(G1)??0);return Number.isFinite(n)&&e-n<K1?!1:(t.setItem(G1,String(e)),!0)}catch{return!1}}var Y1=null,X1=null,Z1=null;async function Q1(){try{let e=await fetch(`/config.json`,{cache:`no-store`});if(e.ok){let t=await e.json(),n=t?.convexSiteUrl;typeof n==`string`&&n.trim()&&(X1=n.trim());let r=t?.widgetSandboxOrigin;typeof r==`string`&&r.trim()&&(Z1=r.trim());let i=t?.convexUrl;if(typeof i==`string`&&i.trim())return Y1=i.trim(),Y1}}catch{}throw Error(`No Convex URL configured: serve /config.json {"convexUrl":"…"} (production) or set VITE_CONVEX_URL (local dev).`)}function $1(e){try{let t=new URL(e);return t.hostname.endsWith(`.convex.cloud`)?(t.hostname=t.hostname.replace(/\.convex\.cloud$/,`.convex.site`),t.origin):t.port?(t.port=String(Number(t.port)+1),t.origin):e}catch{return e}}function e0(){return X1||(Y1?$1(Y1):null)}function t0(){return Y1||null}function n0(){return Z1||null}var r0=`<!doctype html>
22
+ <meta charset="utf-8" />
23
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
24
+ <title>MCP App sandbox</title>
25
+ <style>html,body{height:100%;margin:0;background:transparent}iframe{display:block;width:100%;height:100%;border:0;background:transparent}</style>
26
+ <body>
27
+ <script>
28
+ (() => {
29
+ if (window.self === window.top) throw new Error("invalid MCP App sandbox host");
30
+ let hostOrigin;
31
+ try {
32
+ const referrer = new URL(document.referrer);
33
+ if (referrer.protocol !== "http:" && referrer.protocol !== "https:") throw new Error();
34
+ hostOrigin = referrer.origin;
35
+ } catch { throw new Error("invalid MCP App sandbox parent"); }
36
+ try { void window.top.document; throw new Error("MCP App sandbox isolation failed"); } catch (error) {
37
+ if (error instanceof Error && error.message === "MCP App sandbox isolation failed") throw error;
38
+ }
39
+ const createInner = (allowScripts = true) => {
40
+ const frame = document.createElement("iframe");
41
+ // Block native popups here without reserving widget globals such as open.
42
+ frame.setAttribute("sandbox", allowScripts ? "allow-scripts allow-forms" : "");
43
+ return frame;
44
+ };
45
+ let inner = createInner();
46
+ document.body.appendChild(inner);
47
+ const widgetPortsOffered = new Set();
48
+ const blockDescendantFrames = true;
49
+ const descendantSelector = "iframe,frame,object,embed,portal,fencedframe,webview,browser";
50
+ const hasBlockedDescendant = root => {
51
+ if (root.querySelector(descendantSelector)) return true;
52
+ for (const template of root.querySelectorAll("template")) {
53
+ if (hasBlockedDescendant(template.content)) return true;
54
+ }
55
+ return false;
56
+ };
57
+ const documentGuard = "\\u003cscript>(()=>{\\n const blocked=[\\"iframe\\",\\"frame\\",\\"object\\",\\"embed\\",\\"portal\\",\\"fencedframe\\",\\"webview\\",\\"browser\\"];\\n const apply=Reflect.apply;\\n const defineProperty=Object.defineProperty;\\n const getOwnPropertyDescriptor=Object.getOwnPropertyDescriptor;\\n const toString=String;\\n const toLowerCase=String.prototype.toLowerCase;\\n const lastIndexOf=String.prototype.lastIndexOf;\\n const slice=String.prototype.slice;\\n const includes=Array.prototype.includes;\\n const regexpTest=RegExp.prototype.test;\\n const descendantMarkup=/\\u003c\\\\s*(?:iframe|frame|object|embed|portal|fencedframe|webview|browser)\\\\b/iu;\\n const reject=()=>{throw new Error(\\"sandbox descendant browsing contexts are disabled\\");};\\n const assertName=name=>{const value=apply(toLowerCase,toString(name),[]);const separator=apply(lastIndexOf,value,[\\":\\"]);const localName=separator\\u003c0?value:apply(slice,value,[separator+1]);if(apply(includes,blocked,[localName]))reject();};\\n const assertMarkup=value=>{if(apply(regexpTest,descendantMarkup,[toString(value)]))reject();};\\n const lock=(target,name,value)=>{try{defineProperty(target,name,{value,writable:false,configurable:false});}catch{}};\\n for(const name of [\\"RTCPeerConnection\\",\\"webkitRTCPeerConnection\\",\\"RTCIceGatherer\\",\\"RTCIceTransport\\",\\"RTCDtlsTransport\\",\\"RTCSctpTransport\\",\\"RTCDataChannel\\"])lock(globalThis,name,undefined);\\n const createElement=Document.prototype.createElement;\\n lock(Document.prototype,\\"createElement\\",function(name,...args){assertName(name);return Reflect.apply(createElement,this,[name,...args]);});\\n const createElementNS=Document.prototype.createElementNS;\\n lock(Document.prototype,\\"createElementNS\\",function(namespace,name,...args){assertName(name);return Reflect.apply(createElementNS,this,[namespace,name,...args]);});\\n const wrapSetter=(target,name)=>{const descriptor=getOwnPropertyDescriptor(target,name);if(!descriptor?.set)return;try{defineProperty(target,name,{get:descriptor.get,set(value){assertMarkup(value);return apply(descriptor.set,this,[value]);},enumerable:descriptor.enumerable,configurable:false});}catch{}};\\n wrapSetter(Element.prototype,\\"innerHTML\\");wrapSetter(Element.prototype,\\"outerHTML\\");\\n if(globalThis.ShadowRoot)wrapSetter(ShadowRoot.prototype,\\"innerHTML\\");\\n const wrapMethod=(target,name,indexes)=>{const original=target?.[name];if(typeof original!==\\"function\\")return;lock(target,name,function(...args){if(indexes){for(let index=0;index\\u003cindexes.length;index+=1)assertMarkup(args[indexes[index]]);}else{for(let index=0;index\\u003cargs.length;index+=1)assertMarkup(args[index]);}return apply(original,this,args);});};\\n wrapMethod(Element.prototype,\\"insertAdjacentHTML\\",[1]);wrapMethod(Document.prototype,\\"write\\");wrapMethod(Document.prototype,\\"writeln\\");wrapMethod(Range.prototype,\\"createContextualFragment\\",[0]);wrapMethod(DOMParser.prototype,\\"parseFromString\\",[0]);\\n wrapMethod(Element.prototype,\\"setHTMLUnsafe\\",[0]);wrapMethod(Element.prototype,\\"setHTML\\",[0]);\\n if(globalThis.ShadowRoot){wrapMethod(ShadowRoot.prototype,\\"setHTMLUnsafe\\",[0]);wrapMethod(ShadowRoot.prototype,\\"setHTML\\",[0]);}\\n})();\\u003c/script>";
58
+ const resolveLeadingDoctypeEnd = (html) => {
59
+ let index = html.charCodeAt(0) === 0xfeff ? 1 : 0;
60
+ const whitespace = new Set([9, 10, 12, 13, 32]);
61
+ while (true) {
62
+ while (index < html.length && whitespace.has(html.charCodeAt(index))) index += 1;
63
+ if (html.slice(index, index + 4) !== "<!--") break;
64
+ const commentEnd = html.indexOf("-->", index + 4);
65
+ if (commentEnd < 0) return 0;
66
+ index = commentEnd + 3;
67
+ }
68
+ if (html.slice(index, index + 9).toLowerCase() !== "<!doctype") return 0;
69
+ let quote = "";
70
+ for (let cursor = index + 9; cursor < html.length; cursor += 1) {
71
+ const char = html[cursor];
72
+ if (quote) { if (char === quote) quote = ""; continue; }
73
+ if (char === '"' || char === "'") { quote = char; continue; }
74
+ if (char === ">") return cursor + 1;
75
+ }
76
+ return 0;
77
+ };
78
+ const guardDocument = html => {
79
+ if (!blockDescendantFrames) return html;
80
+ if (hasBlockedDescendant(new DOMParser().parseFromString(html, "text/html"))) {
81
+ throw new Error("sandbox descendant browsing contexts are disabled");
82
+ }
83
+ const doctypeEnd = resolveLeadingDoctypeEnd(html);
84
+ return html.slice(0, doctypeEnd) + documentGuard + html.slice(doctypeEnd);
85
+ };
86
+ window.addEventListener("message", (event) => {
87
+ if (event.source === window.parent) {
88
+ if (event.origin !== hostOrigin) return;
89
+ if (event.data?.method === "ui/notifications/sandbox-resource-ready") {
90
+ const params = event.data.params ?? {};
91
+ if (typeof params.html === "string") {
92
+ const guardedHtml = guardDocument(params.html);
93
+ // Replace the browsing context so a superseded document cannot race
94
+ // the new wrapper's first private bridge-port offer.
95
+ const nextInner = createInner(params.allowScripts !== false);
96
+ nextInner.addEventListener("load", () => {
97
+ if (inner !== nextInner || typeof params.renderId !== "string") return;
98
+ window.parent.postMessage({
99
+ jsonrpc: "2.0",
100
+ method: "ui/notifications/sandbox-resource-loaded",
101
+ params: { renderId: params.renderId },
102
+ }, hostOrigin);
103
+ }, { once: true });
104
+ widgetPortsOffered.clear();
105
+ nextInner.srcdoc = guardedHtml;
106
+ inner.replaceWith(nextInner);
107
+ inner = nextInner;
108
+ }
109
+ return;
110
+ }
111
+ if (typeof event.data?.method === "string" && event.data.method.startsWith("ui/notifications/sandbox-")) return;
112
+ inner.contentWindow?.postMessage(event.data, "*");
113
+ return;
114
+ }
115
+ if (event.source === inner.contentWindow) {
116
+ if (typeof event.data?.method === "string" && event.data.method.startsWith("ui/notifications/sandbox-")) return;
117
+ if (event.data?.type === "openclaw:widget-bridge-port-offer" || event.data?.type === "openclaw:widget-prompt-offer") {
118
+ const port = event.ports[0];
119
+ // Each wrapper offers its private channels before untrusted code runs.
120
+ // Only the first offer of each kind belongs to this document instance.
121
+ if (!widgetPortsOffered.has(event.data.type) && port) {
122
+ widgetPortsOffered.add(event.data.type);
123
+ window.parent.postMessage(event.data, hostOrigin, [port]);
124
+ } else {
125
+ port?.close();
126
+ }
127
+ return;
128
+ }
129
+ window.parent.postMessage(event.data, hostOrigin);
130
+ }
131
+ });
132
+ window.parent.postMessage({
133
+ jsonrpc: "2.0",
134
+ method: "ui/notifications/sandbox-proxy-ready",
135
+ params: { sandboxUrl: window.location.href },
136
+ }, hostOrigin);
137
+ })();
138
+ <\/script>
139
+ </body>`,i0={"Content-Type":`text/html; charset=utf-8`,"Content-Security-Policy":`default-src 'none'; script-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://esm.sh https://unpkg.com https://fonts.googleapis.com https://fonts.gstatic.com https://fonts.bunny.net; style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://esm.sh https://unpkg.com https://fonts.googleapis.com https://fonts.gstatic.com https://fonts.bunny.net; img-src 'self' data: https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://esm.sh https://unpkg.com https://fonts.googleapis.com https://fonts.gstatic.com https://fonts.bunny.net; media-src 'self' data: https: blob:; font-src 'self' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://esm.sh https://unpkg.com https://fonts.googleapis.com https://fonts.gstatic.com https://fonts.bunny.net; connect-src 'none'; webrtc 'block'; frame-src 'none'; base-uri 'self'; object-src 'none'; form-action 'none'; frame-ancestors http: https:`,"Permissions-Policy":`camera=(), microphone=(), geolocation=(), clipboard-write=()`,"Cross-Origin-Resource-Policy":`cross-origin`,"Origin-Agent-Cluster":`?1`,"Referrer-Policy":`no-referrer`,"X-Content-Type-Options":`nosniff`},a0=new Set([`youtube.com`,`www.youtube.com`,`m.youtube.com`]),o0=new Set([`youtube-nocookie.com`,`www.youtube-nocookie.com`]),s0=/^[A-Za-z0-9_-]{11}$/u,c0=`https://www.youtube-nocookie.com`;function l0(e){if(e===null)return 0;let t;if(/^\d+$/u.test(e))t=Number(e);else{let n=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/iu.exec(e);if(!n||!e)return;t=Number(n[1]??0)*3600+Number(n[2]??0)*60+Number(n[3]??0)}return Number.isSafeInteger(t)&&t>=0?t:void 0}function u0(e){let{videoId:t,startSeconds:n}=e;if(typeof t!=`string`||!s0.test(t)||typeof n!=`number`||!Number.isSafeInteger(n)||n<0)return null;let r=n>0?String(n):null;return{videoId:t,startSeconds:n,watchUrl:`https://www.youtube.com/watch?v=${t}${r?`&t=${r}`:``}`,embedUrl:`${c0}/embed/${t}?playsinline=1${r?`&start=${r}`:``}`,thumbnailUrl:`https://i.ytimg.com/vi/${t}/hqdefault.jpg`}}function d0(e){return`${e.embedUrl}&autoplay=1`}function f0(e){if(!e)return null;let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`||t.username||t.password||t.port)return null;let n=t.searchParams,r=new URLSearchParams(t.hash.slice(1));if([`v`,`start`,`t`].some(e=>n.getAll(e).length>1)||r.getAll(`t`).length>1)return null;let i;if(a0.has(t.hostname)&&t.pathname===`/watch`)i=n.get(`v`)??void 0;else{if(n.has(`v`))return null;t.hostname===`youtu.be`?i=/^\/([A-Za-z0-9_-]{11})\/?$/u.exec(t.pathname)?.[1]:a0.has(t.hostname)?i=/^\/(?:shorts|live|embed)\/([A-Za-z0-9_-]{11})\/?$/u.exec(t.pathname)?.[1]:o0.has(t.hostname)&&(i=/^\/embed\/([A-Za-z0-9_-]{11})\/?$/u.exec(t.pathname)?.[1])}if(!i)return null;let a=l0(n.get(`start`)??n.get(`t`)??r.get(`t`));return a===void 0?null:u0({videoId:i,startSeconds:a})}function p0(e){return e.flatMap(e=>{if(e.type===`text`&&typeof e.text==`string`)return[e.text];if(e.type!==`data-youtube`)return[];let t=u0(e.data??{});if(!t)return[];let n=typeof e.data?.title==`string`?e.data.title.trim():``;return[n?`${n} — ${t.watchUrl}`:t.watchUrl]}).join(`
140
+ `)}var m0=`openclaw:widget-size`,h0=`openclaw:widget-theme`,g0=`openclaw:widget-chat-host`,_0=`openclaw:widget-bridge-ready`,v0=`openclaw:widget-prompt-offer`,y0=`openclaw:widget-prompt-host-ready`,b0=`openclaw:widget-bridge-port-offer`,x0=`openclaw:widget-runtime-error`,S0=`ui/notifications/sandbox-resource-ready`,C0=`allow-scripts allow-forms`,w0=`allow-scripts allow-same-origin allow-forms`,T0=8e3,E0=1e4;function D0(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?null:Math.min(T0,Math.max(48,Math.trunc(e)))}function O0(e,t,n){return t!=null&&e.source===t&&e.origin===n}function k0(e,t,n=[]){if(!e||!e.trim())return{mode:`simple`,reason:`unset`};let r;try{r=new URL(e.trim())}catch{return{mode:`simple`,reason:`invalid`}}if(r.protocol!==`https:`&&r.protocol!==`http:`||r.username!==``||r.password!==``||r.pathname!==`/`&&r.pathname!==``||r.search!==``||r.hash!==``)return{mode:`simple`,reason:`invalid`};let i=r.origin,a=e=>{if(!e)return!1;try{return new URL(e).origin===i}catch{return!1}};return a(t)||n.some(a)?{mode:`simple`,reason:`same-origin`}:r.protocol===`http:`&&t.startsWith(`https:`)?{mode:`simple`,reason:`insecure`}:{mode:`dedicated`,origin:i}}function A0(e){return e.mode===`dedicated`?`frame-src ${e.origin} ${c0}`:`frame-src ${c0}`}var j0=`data-atrium-frame-policy`;function M0(e,t){if(e.head.querySelector(`meta[data-atrium-frame-policy]`))return;let n=e.createElement(`meta`);n.httpEquiv=`Content-Security-Policy`,n.content=t,n.setAttribute(j0,``),e.head.prepend(n)}function N0(e){return`${e}/`}function P0(e,t){let n=e;return n?.method===`ui/notifications/sandbox-proxy-ready`&&n.params?.sandboxUrl===t}function F0(e,t){return{jsonrpc:`2.0`,method:S0,params:{html:e,renderId:t}}}function I0(){let e=/const documentGuard = ("(?:[^"\\]|\\.)*");/.exec(r0);if(!e)throw Error(`vendored widget sandbox proxy has no documentGuard`);return JSON.parse(e[1])}var L0=I0(),R0=`media-src 'self' data: blob:`;function z0(e){let t=e.split(`;`).map(e=>e.trim()).filter(e=>e!==``),n=!1,r=t.map(e=>e.split(/\s+/)[0].toLowerCase()===`media-src`?(n=!0,R0):e);return n||r.push(R0),r.join(`; `)}var B0={...i0,"Content-Security-Policy":z0(i0[`Content-Security-Policy`])}[`Content-Security-Policy`].split(`;`).map(e=>e.trim()).filter(e=>e!==``&&!e.startsWith(`frame-ancestors`)).join(`; `),V0=`iframe,frame,object,embed,portal,fencedframe,webview,browser`;function H0(e){let t=+(e.charCodeAt(0)===65279),n=new Set([9,10,12,13,32]);for(;;){for(;t<e.length&&n.has(e.charCodeAt(t));)t+=1;if(e.slice(t,t+4)!==`<!--`)break;let r=e.indexOf(`-->`,t+4);if(r<0)return 0;t=r+3}if(e.slice(t,t+9).toLowerCase()!==`<!doctype`)return 0;let r=``;for(let n=t+9;n<e.length;n+=1){let t=e[n];if(r){t===r&&(r=``);continue}if(t===`"`||t===`'`){r=t;continue}if(t===`>`)return n+1}return 0}var U0=class extends Error{};function W0(e){if(e.querySelector(V0))return!0;for(let t of e.querySelectorAll(`template`))if(W0(t.content))return!0;return!1}function G0(e,t){if(W0(t(e)))throw new U0(`widget documents may not embed frames`);let n=H0(e),r=`<meta http-equiv="Content-Security-Policy" content="${B0.replaceAll(`"`,`&quot;`)}">`;return e.slice(0,n)+r+L0+e.slice(n)}var K0=[`surface`,`card`,`elevated`,`text`,`text-strong`,`muted`,`border`,`border-strong`,`accent`,`accent-fill`,`accent-fg`,`ok`,`warn`,`danger`,`info`,`radius`,`radius-full`,`scrollbar-size`,`scrollbar-thumb-inset`,`scrollbar-thumb`,`scrollbar-thumb-hover`,`font-body`,`font-mono`],q0={surface:{cssVar:`--background`},card:{cssVar:`--card`},elevated:{cssVar:`--popover`},text:{cssVar:`--foreground`},"text-strong":{cssVar:`--foreground`},muted:{cssVar:`--muted-foreground`},border:{cssVar:`--border`},"border-strong":{cssVar:`--ring`},accent:{cssVar:`--primary`},"accent-fill":{cssVar:`--primary`},"accent-fg":{cssVar:`--primary-foreground`},ok:{light:`#15803d`,dark:`#22c55e`},warn:{light:`#b45309`,dark:`#f59e0b`},danger:{cssVar:`--destructive`},info:{light:`#2563eb`,dark:`#3b82f6`},radius:{cssVar:`--radius`},"radius-full":{value:`9999px`},"scrollbar-size":{value:`12px`},"scrollbar-thumb-inset":{value:`3px`},"scrollbar-thumb":{value:`color-mix(in srgb,var(--muted) 32%,transparent)`},"scrollbar-thumb-hover":{value:`color-mix(in srgb,var(--muted) 64%,transparent)`},"font-body":{cssVar:`--ui-font-sans`},"font-mono":{cssVar:`--ui-font-mono`}};function J0(e,t){let n={};for(let r of K0){let i=q0[r],a=`cssVar`in i?e(i.cssVar).trim():`value`in i?i.value:i[t];a&&a.length<=256&&(n[r]=a)}return{type:h0,mode:t,tokens:n}}var Y0=6e4,X0=100;function Z0(e){if(typeof e!=`string`)return null;let t=e.trim();return!t||t.length>4e3||t.startsWith(`/`)||t.startsWith(`!`)?null:t}var Q0=new class{byKey=new Map;allow(e,t){let n=t-Y0,r=(this.byKey.get(e)??[]).filter(e=>e>n);if(!this.byKey.has(e)&&this.byKey.size>=X0){let e=this.byKey.keys().next().value;e!==void 0&&this.byKey.delete(e)}return r.length>=10?(this.byKey.set(e,r),!1):(r.push(t),this.byKey.set(e,r),!0)}};function $0(e,t,n,r,i=Q0){let a=Z0(e);return a===null?{ok:!1,reason:`text`}:!t.connected||!t.visible||!t.focused?{ok:!1,reason:`not-interactable`}:i.allow(n,r)?{ok:!0,text:a}:{ok:!1,reason:`rate`}}var e2=class{offered=!1;loaded=!1;pending=null;adopted=null;offer(e){return e?this.offered?(e.close(),null):(this.offered=!0,this.loaded?(this.adopted=e,e):(this.pending=e,null)):null}load(){return this.loaded=!0,this.pending&&!this.adopted?(this.adopted=this.pending,this.pending=null,this.adopted):null}dispose(){this.pending?.close(),this.adopted?.close(),this.pending=null,this.adopted=null}},t2=class{deps;pendingText=null;constructor(e){this.deps=e}get pending(){return this.pendingText}offer(e){return this.pendingText===null?this.deps.mustConfirm()?(this.pendingText=e,this.deps.onPending(e),`pending`):(this.dispatch(e),`sent`):`ignored`}confirm(){let e=this.pendingText;e!==null&&(this.pendingText=null,this.deps.onPending(null),this.dispatch(e))}cancel(){this.pendingText!==null&&(this.pendingText=null,this.deps.onPending(null))}dispatch(e){this.deps.send(e).then(e=>{e||this.deps.onFailed()},()=>this.deps.onFailed())}};function n2(e,t,n,r){return{chatId:e,text:t,clientMessageId:r,...n?{routedAgent:n}:{}}}function r2(){let e=document.documentElement,t=getComputedStyle(e);return J0(e=>t.getPropertyValue(e),e.classList.contains(`dark`)?`dark`:`light`)}function i2(e){return new DOMParser().parseFromString(e,`text/html`)}async function a2(e,t,n){let r=e0();if(!r)return{ok:!1,unavailable:!1};let i=new URLSearchParams(t),a=await fetch(`${r.replace(/\/$/,``)}/api/v1/widget-view?${i}`,{headers:{Authorization:`Bearer ${e}`},cache:`no-store`,signal:n});return a.ok?{ok:!0,html:await a.text()}:{ok:!1,unavailable:a.status===404}}function o2({data:e}){let t=e?.viewId??``,n=e?.title?.trim()||ih(),r=$(e=>e.metadata?.custom?.chatId??``),i=$(e=>e.metadata?.custom?.messageId??``),a=$(e=>{let t=e.metadata?.custom;return t?.routedInstanceName&&t.routedAgentId?`${t.routedInstanceName}\u0000${t.routedAgentId}`:null}),o=NE(),s=(0,q.useRef)(o);s.current=o;let c=o!=null&&o!==``,l=H(G.widgets.widgetConfigForMessage,r&&i?{chatId:r,messageId:i}:`skip`),u=l?.effective===!0,d=U(G.send.sendMessage),[f,p]=(0,q.useState)(0),[m,h]=(0,q.useState)({state:`loading`}),[g,_]=(0,q.useState)(e?.preferredHeight??320),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(null),w=(0,q.useRef)(null),T=(0,q.useMemo)(()=>k0(n0(),window.location.origin,[e0(),t0()]),[]),E=T.mode===`dedicated`?T.origin:`null`,D=T.mode===`dedicated`?N0(T.origin):null;(0,q.useEffect)(()=>{let e=s.current;if(!u||!e||!r||!i||!t)return;let n=new AbortController,a=!1,o=window.setTimeout(()=>n.abort(),E0*2);return h({state:`loading`}),a2(e,{chatId:r,messageId:i,viewId:t},n.signal).then(e=>{a||h(e.ok?{state:`ready`,html:e.html}:{state:`error`,unavailable:e.unavailable})}).catch(()=>{a||h({state:`error`,unavailable:!1})}).finally(()=>window.clearTimeout(o)),()=>{a=!0,window.clearTimeout(o),n.abort()}},[u,c,r,i,t,f]);let O=(0,q.useMemo)(()=>{if(m.state!==`ready`||T.mode!==`simple`)return null;try{return G0(m.html,i2)}catch(e){return e instanceof U0?``:null}},[m,T.mode]),k=(0,q.useRef)(new e2),A=(0,q.useRef)(null),j=(0,q.useCallback)(()=>{let e=w.current?.contentWindow;if(!e)return;let t=T.mode===`dedicated`?T.origin:`*`;e.postMessage(r2(),t),e.postMessage({type:g0},t)},[T]),M=`${r}\u0000${t}\u0000${f}`,N=(0,q.useRef)(!1);N.current=l?.promptConfirm===!0;let P=(0,q.useRef)(async()=>!1);P.current=async e=>{if(!r)return!1;let[t,n]=a?.split(`\0`)??[];try{let i=n2(r,e,t&&n?{instanceName:t,agentId:n}:null,crypto.randomUUID());return await d({...i,chatId:i.chatId}),!0}catch{return!1}};let[F]=(0,q.useState)(()=>new t2({mustConfirm:()=>N.current,send:e=>P.current(e),onPending:e=>x(e),onFailed:()=>C(Jh())})),I=(0,q.useCallback)(e=>{let t=w.current,n=$0(e,{connected:t?.isConnected===!0,visible:t!==null&&(typeof t.checkVisibility==`function`?t.checkVisibility():t.getClientRects().length>0),focused:t!==null&&t.ownerDocument.activeElement===t},M,Date.now());n.ok&&F.offer(n.text)},[M,F]),L=(0,q.useCallback)(e=>{e&&(e.addEventListener(`message`,e=>{let t=e.data;t?.type===`openclaw:widget-prompt`&&I(t.prompt)}),e.start(),e.postMessage({type:y0}))},[I]);(0,q.useEffect)(()=>{let e=new e2;return k.current=e,()=>e.dispose()},[m,f]),(0,q.useEffect)(()=>{if(m.state!==`ready`)return;let e=e=>{let t=w.current;if(!O0(e,t?.contentWindow,E))return;let n=e.data;if(!(!n||typeof n!=`object`)){if(T.mode===`dedicated`&&D){if(P0(n,D)){let e=crypto.randomUUID();A.current=e,t.contentWindow.postMessage(F0(m.html,e),T.origin),L(k.current.load()),j();return}if(n.method===`ui/notifications/sandbox-resource-loaded`)return}switch(n.type){case m0:{let e=D0(n.height);e!==null&&_(e);return}case _0:j();return;case v0:L(k.current.offer(e.ports[0]));return;case b0:e.ports[0]?.close();return;case x0:typeof n.message==`string`&&y(e=>e??n.message.toString().slice(0,300));return}}};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[m,E,T,D,L,j]),(0,q.useEffect)(()=>{if(m.state!==`ready`)return;let e=new MutationObserver(()=>j());return e.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`]}),()=>e.disconnect()},[m.state,j]);let R=(0,q.useCallback)(()=>{T.mode===`simple`&&(L(k.current.load()),j())},[T.mode,L,j]);return t?l===void 0?(0,J.jsx)(`figure`,{className:`oc-widget`,"aria-label":n,children:(0,J.jsx)(`div`,{className:`oc-widget__skeleton`,role:`status`,"aria-label":Dh(),style:{minHeight:e?.preferredHeight??320}})}):u?(0,J.jsxs)(`figure`,{className:`oc-widget`,"aria-label":n,children:[(0,J.jsxs)(`figcaption`,{className:`oc-widget__title`,children:[(0,J.jsx)(BA,{className:`size-4`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:n})]}),m.state===`loading`?(0,J.jsx)(`div`,{className:`oc-widget__skeleton`,role:`status`,"aria-label":Dh(),style:{minHeight:e?.preferredHeight??320}}):m.state===`error`||O===``?(0,J.jsxs)(`div`,{className:`oc-widget__error`,role:`alert`,children:[(0,J.jsx)(GC,{className:`size-4`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:O===``?Fm():m.state===`error`&&m.unavailable?zee():av()}),(0,J.jsxs)(K,{variant:`outline`,size:`sm`,onClick:()=>p(e=>e+1),children:[(0,J.jsx)(oj,{className:`size-4`,"aria-hidden":`true`}),nm()]})]}):(0,J.jsxs)(J.Fragment,{children:[v?(0,J.jsxs)(`details`,{className:`oc-widget__notice`,role:`status`,children:[(0,J.jsx)(`summary`,{children:pb()}),(0,J.jsx)(`code`,{className:`oc-widget__notice-detail`,children:v})]}):null,T.mode===`simple`?O===null?null:(0,J.jsx)(`iframe`,{ref:w,className:`oc-widget__frame`,title:n,sandbox:C0,referrerPolicy:`no-referrer`,srcDoc:O,style:{height:g},onLoad:R},`${t}:${f}`):(0,J.jsx)(`iframe`,{ref:w,className:`oc-widget__frame`,title:n,sandbox:w0,referrerPolicy:`origin`,src:D,style:{height:g}},`${t}:${f}`),b===null?null:(0,J.jsxs)(`div`,{className:`oc-widget__confirm`,role:`alertdialog`,"aria-label":jp(),children:[(0,J.jsx)(`p`,{className:`oc-widget__confirm-text`,children:yy()}),(0,J.jsx)(`blockquote`,{className:`oc-widget__confirm-quote`,children:b}),(0,J.jsxs)(`div`,{className:`oc-widget__confirm-actions`,children:[(0,J.jsx)(K,{variant:`ghost`,size:`sm`,onClick:()=>F.cancel(),children:I_()}),(0,J.jsx)(K,{size:`sm`,onClick:()=>F.confirm(),children:Lf()})]})]}),S?(0,J.jsx)(`p`,{className:`oc-widget__notice`,role:`status`,children:S}):null]})]}):(0,J.jsxs)(`div`,{className:`oc-widget oc-widget--off`,role:`note`,children:[(0,J.jsx)(BA,{className:`size-4`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:bee()})]}):null}var s2=`allow-scripts allow-same-origin allow-presentation allow-popups allow-popups-to-escape-sandbox`,c2=`autoplay; encrypted-media; fullscreen; picture-in-picture`,l2=`strict-origin-when-cross-origin`,u2=200,d2=null;function f2({data:e}){let t=(0,q.useMemo)(()=>u0({videoId:e?.videoId,startSeconds:e?.startSeconds}),[e?.videoId,e?.startSeconds]),n=e?.title?.trim()||Hy(),r=t?.watchUrl??null,[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(null),c=r!==null&&i===r,l=t!==null&&o===t.thumbnailUrl,[u,d]=(0,q.useState)(r);u!==r&&(d(r),a(null));let[f,p]=(0,q.useState)(!0),m=(0,q.useRef)(null),h=(0,q.useRef)(null),g=(0,q.useRef)(!1),_=(0,q.useCallback)(()=>a(null),[]),v=(0,q.useCallback)(()=>{d2===_&&(d2=null)},[_]);return(0,q.useEffect)(()=>v,[r,v]),(0,q.useEffect)(()=>{let e=m.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(([e])=>{e&&p(e.contentRect.width>=u2)});return t.observe(e),()=>t.disconnect()},[r]),(0,q.useEffect)(()=>{!c&&g.current&&(g.current=!1,h.current?.focus())},[c]),t?(0,J.jsx)(p2,{video:t,title:n,playing:c,wideEnough:f,thumbnailFailed:l,cardRef:m,playRef:h,onPlay:()=>{d2?.(),d2=_,a(t.watchUrl)},onClose:()=>{g.current=!0,v(),a(null)},onThumbnailError:()=>s(t.thumbnailUrl)}):null}function p2({video:e,title:t,playing:n,wideEnough:r,thumbnailFailed:i,cardRef:a,playRef:o,onPlay:s,onClose:c,onThumbnailError:l}){let u=n&&r,d=i?null:(0,J.jsx)(`img`,{className:`oc-youtube__thumb`,src:e.thumbnailUrl,alt:``,loading:`lazy`,referrerPolicy:`no-referrer`,onError:l});return(0,J.jsxs)(`section`,{className:`oc-youtube`,"aria-label":t,ref:a,children:[(0,J.jsx)(`div`,{className:`oc-youtube__stage`,children:u?(0,J.jsx)(`iframe`,{className:`oc-youtube__frame`,src:d0(e),title:Tm({title:t}),sandbox:s2,allow:c2,allowFullScreen:!0,referrerPolicy:l2}):r?(0,J.jsxs)(`button`,{type:`button`,className:`oc-youtube__preview`,"aria-label":D({title:t}),ref:o,onClick:s,children:[d,(0,J.jsx)(`span`,{className:`oc-youtube__play`,"aria-hidden":`true`,children:(0,J.jsx)(MC,{})})]}):(0,J.jsxs)(`a`,{className:`oc-youtube__preview`,href:e.watchUrl,target:`_blank`,rel:`noopener noreferrer`,"aria-label":Xd({title:t}),children:[d,(0,J.jsx)(`span`,{className:`oc-youtube__play`,"aria-hidden":`true`,children:(0,J.jsx)(CA,{})})]})}),(0,J.jsxs)(`div`,{className:`oc-youtube__footer`,children:[(0,J.jsxs)(`div`,{className:`oc-youtube__caption`,children:[(0,J.jsx)(`span`,{className:`oc-youtube__provider`,children:f_()}),(0,J.jsx)(`p`,{className:`oc-youtube__title`,children:t})]}),(0,J.jsx)(K,{asChild:!0,variant:`ghost`,size:`sm`,children:(0,J.jsxs)(`a`,{href:e.watchUrl,target:`_blank`,rel:`noopener noreferrer`,children:[Bs(),(0,J.jsx)(CA,{"aria-hidden":`true`})]})}),u?(0,J.jsx)(K,{type:`button`,variant:`outline`,size:`icon-sm`,"aria-label":$u(),title:$u(),onClick:c,children:(0,J.jsx)(YC,{"aria-hidden":`true`})}):null]}),r?null:(0,J.jsx)(`p`,{className:`oc-youtube__notice`,role:`status`,children:Ed()})]})}var m2=new Map,h2={active:!1,percent:0,count:0},g2=new Set;function _2(){let e=0,t=0;for(let n of m2.values())e+=n.loaded,t+=n.total;let n=m2.size;h2={active:n>0,percent:t>0?Math.min(100,Math.round(e/t*100)):0,count:n};for(let e of g2)e()}var v2={subscribe(e){return g2.add(e),()=>g2.delete(e)},getSnapshot(){return h2},report(e,t,n){m2.set(e,{loaded:t,total:n}),_2()},clear(e){m2.delete(e)&&_2()}},y2=0;function b2(){y2+=1}function x2(){y2=Math.max(0,y2-1)}function S2(){return y2>0}function C2(e,t=document){let n=(e?.isConnected===!0?e.closest(`.oc-composer__bar`):null)??t.querySelector(`.oc-composer__bar:not(.oc-composer__bar--measure)`),r=n?.closest(`.oc-composer`)??null;return{bar:n,more:n?.querySelector(`.oc-composer__more`)??null,field:r?.querySelector(`.oc-composer__input`)??null}}var w2=`button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])`;function T2(e,t){if(e===null||t===null)return null;let n=e.querySelector(`[data-overflow="${t}"]`);return n===null?null:n.tabIndex>=0?n:n.querySelector(w2)}function E2(e,t=document){let n=t.activeElement;return n!==null&&n!==t.body&&n.isConnected?!1:Sf(e)!==null}var D2={phase:`idle`,model:null,voice:null,muted:!1,errorCode:null};function O2(e,t){switch(t){case`start`:return e===`idle`?`minting`:null;case`minted`:return e===`minting`?`connecting`:null;case`connected`:return e===`connecting`?`live`:null;case`hangup`:return e===`minting`||e===`connecting`||e===`live`?`ending`:null;case`failed`:return e===`minting`||e===`connecting`||e===`live`?`ending`:null;case`ended`:return e===`ending`?`idle`:null}}function k2(e,t){return t===null||t===``?e:`${e}${e.includes(`?`)?`&`:`?`}model=${encodeURIComponent(t)}`}function A2(e,t){return t?`connect`:`hangup-now`}var j2=new Set([`authorization`,`content-type`]);async function M2(e,t=[1e3,3e3],n=e=>new Promise(t=>setTimeout(t,e))){for(let r=0;;r+=1){try{if((await e()).ok)return!0}catch{}if(r>=t.length)return!1;await n(t[r])}}async function N2(e,t,n=fetch,r){if(e.offerRelay){if(!r)return{ok:!1,code:`relay_unavailable`};try{let n=await r(e.offerRelay.relayId,t);return n.ok&&n.answerSdp.trim()===``?{ok:!1,code:`sdp_empty`}:n}catch{return{ok:!1,code:`relay_failed`}}}if(!e.offerUrl||!e.clientSecret)return{ok:!1,code:`talk_malformed`};try{let r=Object.fromEntries(Object.entries(e.offerHeaders??{}).filter(([e])=>!j2.has(e.toLowerCase()))),i=await n(k2(e.offerUrl,e.model??null),{method:`POST`,headers:{...r,Authorization:`Bearer ${e.clientSecret}`,"Content-Type":`application/sdp`},body:t});if(!i.ok)return{ok:!1,code:i.status===401?`talk_secret_expired`:`sdp_${i.status}`};let a=await i.text();return a.trim()===``?{ok:!1,code:`sdp_empty`}:{ok:!0,answerSdp:a}}catch{return{ok:!1,code:`sdp_unreachable`}}}var P2=[`marin`,`cedar`,`alloy`,`ash`,`ballad`,`coral`,`echo`,`sage`,`shimmer`,`verse`],F2=`oc.talk.voice`,I2=`oc.talk.vad`,L2=[{id:`low`,threshold:.8},{id:`medium`,threshold:.5},{id:`high`,threshold:.3}];function R2(e){return L2.some(t=>t.id===e)?e:``}function z2(e){let t=L2.find(t=>t.id===e);return t?t.threshold:null}function B2(){try{return R2(localStorage.getItem(I2))}catch{return``}}function V2(e){try{R2(e)===``?localStorage.removeItem(I2):localStorage.setItem(I2,e)}catch{}}function H2(e){return P2.includes(e??``)?e:``}function U2(){try{return H2(localStorage.getItem(F2))}catch{return``}}function W2(e){try{H2(e)===``?localStorage.removeItem(F2):localStorage.setItem(F2,e)}catch{}}function G2(e){let t;try{let n=JSON.parse(e);if(typeof n!=`object`||!n)return null;t=n}catch{return null}let n,r,i;if(t.type===`response.output_item.done`){let e=t.item;if(!e||e.type!==`function_call`)return null;n=e.call_id,r=e.name,i=e.arguments}else if(t.type===`response.function_call_arguments.done`)n=t.call_id,r=t.name,i=t.arguments;else return null;if(typeof n!=`string`||n===``||typeof r!=`string`||r===``)return null;let a={};if(typeof i==`string`&&i!==``)try{let e=JSON.parse(i);typeof e==`object`&&e&&(a=e)}catch{}return{callId:n,name:r,args:a}}function K2(e){return e.phase!==`idle`||e.serverCall===!0?!1:e.available!==!0}var q2=new Set([`talk_session_stale`,`agent_restricted`,`talk_disabled`,`talk_unsupported`,`provider_unsupported`,`no_agent`]);function J2(e){return q2.has(e)}function Y2(e){switch(e){case`talk_disabled`:return`talk_error_disabled`;case`call_active`:case`talk_call_active`:return`talk_error_call_active`;case`turn_in_flight`:return`talk_error_turn_in_flight`;case`talk_session_stale`:return`talk_error_session_stale`;case`talk_unsupported`:case`provider_unsupported`:return`talk_error_unsupported`;case`mic_denied`:return`talk_error_mic_denied`;case`talk_secret_expired`:return`talk_error_secret_expired`;default:return`talk_error_generic`}}function X2(e){switch(Y2(e)){case`talk_error_disabled`:return Mh();case`talk_error_unsupported`:return lv();case`talk_error_mic_denied`:return bd();case`talk_error_secret_expired`:return zm();case`talk_error_session_stale`:return _b();case`talk_error_call_active`:return om();case`talk_error_turn_in_flight`:return Uee();case`talk_error_generic`:return`${Fp()} (${e})`}}function Z2({voice:e,vad:t,onVoice:n,onVad:r}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`label`,{className:`oc-talk__setting`,children:[(0,J.jsx)(`span`,{className:`oc-talk__settinglabel`,children:Cy()}),(0,J.jsxs)(sw,{value:e===``?`__default__`:e,onValueChange:e=>n(e===`__default__`?``:e),children:[(0,J.jsx)(iw,{size:`sm`,"aria-label":Cy(),children:(0,J.jsx)(rw,{})}),(0,J.jsxs)(aw,{children:[(0,J.jsx)(ow,{value:`__default__`,children:B_()}),P2.map(e=>(0,J.jsx)(ow,{value:e,children:e},e))]})]})]}),(0,J.jsxs)(`label`,{className:`oc-talk__setting`,children:[(0,J.jsx)(`span`,{className:`oc-talk__settinglabel`,children:Zh()}),(0,J.jsxs)(sw,{value:t===``?`__default__`:t,onValueChange:e=>r(e===`__default__`?``:e),children:[(0,J.jsx)(iw,{size:`sm`,"aria-label":Zh(),children:(0,J.jsx)(rw,{})}),(0,J.jsxs)(aw,{children:[(0,J.jsx)(ow,{value:`__default__`,children:ey()}),L2.map(e=>(0,J.jsx)(ow,{value:e.id,children:e.id===`low`?g_():e.id===`medium`?Gy():Om()},e.id))]})]})]})]})}function Q2({chatId:e,routedAgent:t=null,onCallActiveChange:n,serverCallSessionId:r=null,onPresenceChange:i,more:a}){let[o,s]=(0,q.useState)(D2),c=(0,q.useRef)(null),[l,u]=(0,q.useState)(()=>U2()),[d,f]=(0,q.useState)(()=>B2()),p=H(G.talk.talkAvailable,{chatId:e,...t?{routedAgent:t}:{}}),m=Aa(G.talk.mintTalkSession),h=Aa(G.talk.relayTalkToolCall),g=Aa(G.talk.relayTalkOffer),_=Aa(G.talk.hangupTalkSession),v=(0,q.useRef)(null),y=Iw(),b=(0,q.useRef)(0),x=(0,q.useRef)(null),S=(0,q.useRef)(`idle`),C=(0,q.useRef)({pc:null,mic:null}),w=(0,q.useRef)(null),T=(0,q.useCallback)(e=>{let t=O2(S.current,e);return t===null?null:(S.current=t,s(e=>({...e,phase:t})),t)},[]),E=(0,q.useCallback)(()=>{let e=C.current;try{e.mic?.getTracks().forEach(e=>e.stop())}catch{}try{e.pc?.close()}catch{}e.mic=null,e.pc=null,x.current=null,A(null),w.current&&(w.current.srcObject=null)},[]),D=(0,q.useCallback)(()=>{let t=v.current;v.current=null,t!==null&&M2(()=>_({chatId:e,sessionId:t.sessionId}))},[e,_]),O=(0,q.useCallback)(()=>{T(`hangup`)!==null&&(b.current++,D(),E(),T(`ended`),s(e=>({...e,muted:!1})))},[T,D,E]),[k,A]=(0,q.useState)(null),j=H(G.talk.talkCallLive,k===null?`skip`:{sessionId:k}),M=S.current!==`idle`&&j===!1;(0,q.useEffect)(()=>{M&&(b.current++,D(),E(),T(`ended`),s(e=>({...e,muted:!1})),y.error(Cee()))},[M,T,D,E,y]),(0,q.useEffect)(()=>()=>{b.current++,D(),E()},[D,E]);let N=(0,q.useCallback)(async()=>{if(T(`start`)===null)return;let n=++b.current;s(e=>({...e,errorCode:null,muted:!1}));let r=e=>{b.current===n&&(T(`failed`),D(),E(),T(`ended`),s(t=>({...t,errorCode:e})),y.error(X2(e)))},i=z2(d),a=await m({chatId:e,...l===``?{}:{voice:l},...i===null?{}:{vadThreshold:i},...t?{routedAgent:t}:{}}).catch(()=>({ok:!1,code:`mint_failed`}));if(a.ok){if(A2(a.session,b.current===n)===`hangup-now`){M2(()=>_({chatId:e,sessionId:a.sessionId}));return}}else if(b.current!==n)return;if(!a.ok){r(a.code);return}x.current=a.sessionId,A(a.sessionId),v.current={sessionId:a.sessionId};let o;try{o=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{r(`mic_denied`);return}if(b.current!==n){o.getTracks().forEach(e=>e.stop());return}C.current.mic=o,s(e=>({...e,model:a.session.model,voice:a.session.voice})),T(`minted`);let c=new RTCPeerConnection;C.current.pc=c;for(let e of o.getTracks())c.addTrack(e,o);c.ontrack=e=>{b.current!==n||w.current===null||(w.current.srcObject=e.streams[0]??null)};let u=c.createDataChannel(`oai-events`),f=e=>{try{u.send(JSON.stringify(e))}catch{}},p=async t=>{if(t.name!==`openclaw_agent_consult`){f({type:`conversation.item.create`,item:{type:`function_call_output`,call_id:t.callId,output:`Task-control is not available in this interface yet; tell the user so.`}}),f({type:`response.create`});return}f({type:`response.create`,response:{instructions:`Briefly tell the user, in their language, that you are checking with the agent. Do not invent the result.`}});let r=await h({chatId:e,callId:t.callId,...x.current?{sessionId:x.current}:{},args:{question:typeof t.args.question==`string`?t.args.question:``,...typeof t.args.context==`string`?{context:t.args.context}:{},...typeof t.args.responseStyle==`string`?{responseStyle:t.args.responseStyle}:{}}}).catch(()=>({ok:!1,code:`relay_failed`}));if(b.current!==n)return;if(!r.ok&&J2(r.code)){O(),s(e=>({...e,errorCode:r.code})),y.error(X2(r.code));return}let i=r.ok?r.pending?`The agent is still working on it. Tell the user the task continues and its result will arrive in the conversation.`:typeof r.errorText==`string`?`The agent run failed: ${r.errorText}`:r.resultText??``:`The agent could not be reached (${r.code}). Tell the user and suggest typing the request in the conversation instead.`;f({type:`conversation.item.create`,item:{type:`function_call_output`,call_id:t.callId,output:i===``?`(the agent returned an empty result)`:i}}),f({type:`response.create`})},S=new Set;u.onmessage=e=>{if(b.current!==n)return;let t=G2(typeof e.data==`string`?e.data:``);t===null||S.has(t.callId)||(S.add(t.callId),p(t))},c.onconnectionstatechange=()=>{b.current===n&&c.connectionState===`failed`&&r(`rtc_lost`)};try{let t=await c.createOffer();if(await c.setLocalDescription(t),b.current!==n)return;let i=await N2(a.session,t.sdp??``,fetch,(t,n)=>g({chatId:e,sessionId:a.sessionId,relayId:t,sdp:n}));if(b.current!==n)return;if(!i.ok){r(i.code);return}await c.setRemoteDescription({type:`answer`,sdp:i.answerSdp})}catch{r(`rtc_setup`);return}b.current===n&&T(`connected`)},[T,e,_,m,g,D,E,l,d,t]),P=(0,q.useCallback)(()=>{let e=C.current.mic;if(e===null)return;let t=!o.muted;for(let n of e.getAudioTracks())n.enabled=!t;s(e=>({...e,muted:t}))},[o.muted]),F=o.phase,I=F!==`idle`;(0,q.useEffect)(()=>{n?.(I)},[I,n]),(0,q.useEffect)(()=>()=>{n?.(!1)},[n]);let L=F===`idle`&&r===null&&!K2({phase:F,available:p,serverCall:!1});(0,q.useEffect)(()=>{i?.({settings:L,start:L})},[L,i]),(0,q.useEffect)(()=>()=>{i?.({settings:!1,start:!1})},[i]);let R=e=>{u(e),W2(e)},z=e=>{f(e),V2(e)};return K2({phase:F,available:p,serverCall:r!==null})?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`audio`,{ref:w,autoPlay:!0,className:`oc-talk__audio`}),F===`idle`&&r!==null?(0,J.jsx)(`span`,{className:`oc-talk__pill`,children:(0,J.jsx)(`button`,{type:`button`,className:`oc-talk__pillmain`,title:pp(),"aria-label":pp(),onClick:()=>{M2(()=>_({chatId:e,sessionId:r}))},children:(0,J.jsx)(ij,{size:16,"aria-hidden":!0})})}):F===`idle`?(0,J.jsxs)(`span`,{className:`oc-talk__pill`,"data-overflow":`talk`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-talk__pillmain`,title:ex(),"aria-label":ex(),onClick:()=>void N(),children:(0,J.jsx)(WS,{size:16,"aria-hidden":!0})}),(0,J.jsxs)(vw,{children:[(0,J.jsx)(_w,{asChild:!0,children:(0,J.jsx)(`button`,{ref:c,type:`button`,className:`oc-talk__pillchev`,title:Hf(),"aria-label":Hf(),"data-overflow":`talk-settings`,children:(0,J.jsx)(QS,{size:13,"aria-hidden":!0})})}),(0,J.jsx)(gw,{align:`end`,className:`oc-talk__settings`,returnFocus:()=>{let{more:e,field:t}=C2(c.current);return[e,t]},children:(0,J.jsx)(Z2,{voice:l,vad:d,onVoice:R,onVad:z})})]}),a?.moved.settings&&a.settingsSlot!==null?(0,bk.createPortal)((0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`oc-composer__more-heading`,children:ys()}),(0,J.jsx)(`div`,{className:`oc-composer__more-fields`,children:(0,J.jsx)(Z2,{voice:l,vad:d,onVoice:R,onVad:z})})]}),a.settingsSlot):null,a?.moved.start&&a.startSlot!==null?(0,bk.createPortal)((0,J.jsxs)(K,{variant:`ghost`,className:`oc-composer__more-item w-full justify-start`,onClick:()=>{a.onDone(),N()},children:[(0,J.jsx)(WS,{"aria-hidden":!0}),ex()]}),a.startSlot):null]}):(0,J.jsxs)(`span`,{className:`oc-talk${F===`live`?` oc-talk--live`:``}`,role:`status`,children:[(0,J.jsx)(`i`,{className:`oc-talk__dot`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-talk__label`,children:F===`live`?o.voice||Bb():Zte()}),F===`live`?(0,J.jsx)(`button`,{type:`button`,className:`oc-talk__btn`,title:o.muted?lh():bf(),"aria-label":o.muted?lh():bf(),"aria-pressed":o.muted,onClick:P,children:o.muted?(0,J.jsx)(XA,{size:14,"aria-hidden":!0}):(0,J.jsx)(qS,{size:14,"aria-hidden":!0})}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-talk__btn oc-talk__btn--end`,title:pp(),"aria-label":pp(),onClick:O,children:(0,J.jsx)(ij,{size:14,"aria-hidden":!0})})]})]})}function $2(e,t){if(!e)return null;let n=e.logoLightHasAlpha&&e.logoLightUrl||e.logoDarkHasAlpha&&e.logoDarkUrl||null;if(n)return{url:n,masked:!0};let r=e4(e,t);return r?{url:r,masked:!1}:null}function e4(e,t){return(t===`dark`?e?.logoDarkUrl:e?.logoLightUrl)??(t===`dark`?e?.logoLightUrl:e?.logoDarkUrl)??null}function t4(e){if(!e)return null;let t=/oklch\(\s*([0-9]*\.?[0-9]+)(%?)/i.exec(e);if(!t)return null;let n=parseFloat(t[1]);return Number.isFinite(n)?t[2]===`%`?n/100:n:null}function n4(e,t,n){let r=t4(e),i=t4(t);return r===null||i===null?n:i>r?`dark`:`light`}function r4(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?`?`:t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[1][0]).toUpperCase()}function i4({className:e}){return(0,J.jsxs)(`svg`,{className:e,viewBox:`0 0 64 64`,fill:`none`,"aria-hidden":`true`,children:[(0,J.jsx)(`path`,{d:`M25 15H15V49H25`,stroke:`currentColor`,strokeWidth:`6.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,J.jsx)(`path`,{d:`M39 15H49V49H39`,stroke:`currentColor`,strokeWidth:`6.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,J.jsx)(`polyline`,{points:`20 33 26 33 29 25 33 41 37 29 41 33 44 33`,stroke:`currentColor`,strokeWidth:`3.4`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}var a4=(0,q.createContext)({label:`Atrium`,logoUrl:null,logoMasked:!1,isDefault:!0,initials:`A`,agentName:null,agentEmoji:null});function o4(){return(0,q.useContext)(a4)}function s4(e){return e.agentName??e.label}function c4(e){return e.agentName?ct({name:e.agentName}):Eo({name:e.label})}var l4=[`viewer`,`member`,`manager`];function u4(e){return e===`owner`||e===`manager`}function d4(e,t,n){return e===`owner`?[...l4]:e!==`manager`||n||t===`manager`?[]:l4.filter(e=>e!==`manager`)}function f4(e,t,n){return n?!1:e===`owner`||e===`manager`&&t!==`manager`}function p4(e,t){return t.roomRole!==`owner`&&f4(e,t.roomRole,t.isSelf)}function m4(e){return e===`owner`?[...l4]:e===`manager`?[`viewer`,`member`]:[]}function h4(e,t){return m4(t).includes(e)?e:`member`}function g4(e,t){return e===null||t===null?e===t:e.instanceName===t.instanceName&&e.agentId===t.agentId}function _4(e){return e.routedInstanceName&&e.routedAgentId?{instanceName:e.routedInstanceName,agentId:e.routedAgentId}:null}function v4(e){let t=new Map,n=null;for(let r of e){let e=_4(r);r.role===`user`?(n=e,t.set(r._id,e)):r.role===`assistant`?t.set(r._id,e??n):t.set(r._id,e)}return t}function y4(e){for(let t=e.length-1;t>=0;t--){let n=_4(e[t]);if(n)return n}return null}function b4(e,t){if(!t)return!1;let n=e.find(e=>g4(e,t));return n!==void 0&&n.state!==`deleted`}function x4(e){let{lastRouted:t,primary:n,pool:r}=e,i=e=>({instanceName:e.instanceName,agentId:e.agentId});if(b4(r,t))return i(t);if(b4(r,n))return i(n);let a=r.filter(e=>e.state!==`deleted`);return a.length===0?null:i(a.find(e=>e.isDefault)??a[0])}function S4(e){let{selected:t,lastRouted:n,primary:r,pool:i,poolLoading:a,messagesLoading:o,canRoute:s}=e;if(!s)return null;let c=t??n;return a||o?c??r:x4({lastRouted:c,primary:r,pool:i})}function C4(e){let{readOnly:t,multiAgent:n,poolSize:r}=e,i=r===0||!n;return e.callActive===!0?{hidden:i,disabled:!0,reason:`call-active`,onCall:e.onCall??null}:t?{hidden:i,disabled:!0,reason:`read-only`}:{hidden:i,disabled:!1}}function w4(e,t){if(!t)return null;let n=e.find(e=>g4(e,t));return n?{displayName:n.displayName,emoji:n.emoji}:null}function T4(e){let{mentioned:t,primary:n,severalAgents:r,perTurnRouting:i,canRoute:a}=e;if(!a)return;let o=t[0];if(o!==void 0)return{instanceName:o.instanceName,agentId:o.agentId};if(!(n===null||!(r||i)))return{instanceName:n.instanceName,agentId:n.agentId}}function E4(e){let t=new Map,n=null;for(let r of e){if(r.role===`user`){n=r.importedAgentLabel??null,t.set(r._id,n??r.chatImportedAgentLabel??null);continue}t.set(r._id,r.importedAgentLabel??n??r.chatImportedAgentLabel??null)}return t}function D4(e,t,n){let r=e.find(e=>g4(e,t))??null,i=n.map(t=>e.find(e=>g4(e,t))??null).filter(e=>e!==null&&!g4(e,t)),a=e=>g4(e,t)||i.some(t=>g4(t,e)),o=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`}),s=e=>e.displayName??e.agentId,c=e.filter(e=>!a(e)).sort((e,t)=>o.compare(s(e),s(t))||o.compare(e.instanceName,t.instanceName));return i.length===0?{room:[],others:r?[r,...c]:c}:{room:r?[r,...i]:i,others:c}}function O4(e){let t=e=>(e.displayName??e.agentId).trim().toLocaleLowerCase(),n=new Map;for(let r of e){let e=n.get(t(r))??new Set;e.add(`${r.instanceName}\u0000${r.agentId}`),n.set(t(r),e)}let r=new Set;for(let e of n.values())if(e.size>1)for(let t of e)r.add(t);return r}function k4(e,t,n,r){return!u4(e)||g4(t,n)?!1:r.some(e=>g4(e,t))}function A4(e,t){let n=[];for(let r of t)r===null||e.some(e=>g4(e,r))||n.push({instanceName:r.instanceName,agentId:r.agentId,isDefault:r.role===`primary`,displayName:r.displayName,emoji:r.emoji,model:r.model,description:r.description,kind:r.kind,state:`deleted`});return n.length===0?e:[...e,...n]}function j4(e,t){return e.every(e=>e.isSelf)&&t.length<=1?null:{people:e,agents:t}}function M4(e,t){if(t===null)return[...e];let n=new Set(t.filter(e=>e!==null).map(e=>`${e.instanceName}\u0000${e.agentId}`));return e.filter(e=>n.has(`${e.instanceName}\u0000${e.agentId}`))}function N4(e){return e.unfolded||e.searching||e.hereCount===0}var P4=e=>`${e.instanceName}\u0000${e.agentId}`;function F4(e,t,n){let r=new Set(e.map(P4)),i=n.trim().toLocaleLowerCase();return t.filter(e=>!r.has(P4(e))).filter(e=>i===``||[e.displayName,e.agentId,e.instanceName].filter(e=>!!e).some(e=>e.toLocaleLowerCase().includes(i)))}var I4={user:an(),assistant:`OpenClaw`,system:es()},L4=e=>to({count:e}),R4=200;function z4(e){return e.some(e=>e.windowTruncated===!0)||e.length>=R4}function B4(e){return new Date(e).toISOString().slice(0,16).replace(`T`,` `)+` UTC`}function V4(e){return e?e.filter(e=>e.kind===`file`||e.kind===`media`).map(e=>e.filename).filter(e=>typeof e==`string`&&e.length>0):[]}function H4(e,t={}){let n=[];n.push(`# ${t.title?.trim()||ja()}`),t.exportedAt!=null&&(n.push(``),n.push(`_${sg({date:B4(t.exportedAt)})}_`)),t.truncated&&(n.push(``),n.push(L4(e.length)));for(let t of e){n.push(``),n.push(`## ${I4[t.role]} · ${B4(t.createdAt)}`);for(let e of t.quotedExcerpts??[])e!==``&&(n.push(``),n.push(`> ${xn()} : ${e}`));let e=t.text.trim();e.length>0&&(n.push(``),n.push(e));for(let e of V4(t.parts))n.push(``),n.push(F({name:e}))}return n.join(`
141
+ `)+`
142
+ `}function U4(e,t={}){let n={title:t.title?.trim()||ja(),exportedAt:t.exportedAt??null,truncated:!!t.truncated,messageCount:e.length,messages:e.map(e=>({role:e.role,createdAt:e.createdAt,text:e.text,...e.quotedExcerpts!==void 0&&e.quotedExcerpts.length>0?{quotedExcerpts:e.quotedExcerpts.filter(e=>e!==``)}:{},attachments:V4(e.parts)}))};return JSON.stringify(n,null,2)+`
143
+ `}function W4(e){return((e??``).trim()||`conversation`).toLowerCase().normalize(`NFD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,60)||`conversation`}var G4=AH.Root,K4=AH.Trigger,q4=AH.Item,J4=AH.Separator;function Y4({className:e,returnFocus:t,...n}){let r=Ph(`menu`,t);return(0,J.jsx)(AH.Content,{"data-slot":`dropdown-menu-content`,className:y_(`max-h-(--radix-dropdown-menu-content-available-height) max-w-(--radix-dropdown-menu-content-available-width) min-w-[min(8rem,var(--radix-dropdown-menu-content-available-width))]`,e),...n,ref:r.ref,onCloseAutoFocus:r.onCloseAutoFocus})}var X4=null,Z4=new Set,Q4=null,$4=4e3;function e3(){for(let e of Z4)e()}function t3(e,t){X4={chatId:e,expand:t?.expand===!0},Q4!==null&&clearTimeout(Q4),Q4=setTimeout(()=>{Q4=null,X4=null,e3()},$4),e3()}function n3(e){X4?.chatId===e&&(Q4!==null&&(clearTimeout(Q4),Q4=null),X4=null,e3())}function r3(){return(0,q.useSyncExternalStore)(e=>(Z4.add(e),()=>{Z4.delete(e)}),()=>X4)}function i3(e){let t=-1,n=-1/0,r=-1/0;for(let i=0;i<e.length;i++){let a=e[i]?.stamp,o=a??r;o>=n&&(t=i,n=o),a!==void 0&&a>r&&(r=a)}return t}function a3(e){let t=e[i3(e)];return t===void 0||t.steps.length===0?null:t}var o3=[];function s3({status:e,settled:t}){return e===`completed`?(0,J.jsx)(ZS,{size:13,className:`oc-planact__icon oc-planact__icon--done`,"aria-hidden":!0}):e===`in_progress`&&!t?(0,J.jsx)(OC,{size:13,className:`oc-planact__icon oc-planact__icon--current oc-actrow__spin`,"aria-hidden":!0}):(0,J.jsx)(iC,{size:13,className:`oc-planact__icon`,"aria-hidden":!0})}function c3(){let e=$(e=>e.metadata?.custom?.planParts??o3),t=$(e=>e.metadata?.custom?.status!==`streaming`),[n,r]=(0,q.useState)(null),i=a3(e);if(i===null)return null;let a=i.steps.length,o=i.steps.filter(e=>e.status===`completed`).length,s=n??o!==a,c=i.steps.find(e=>e.status===`in_progress`);return(0,J.jsxs)(`div`,{className:`oc-planact`,children:[(0,J.jsx)(oq,{icon:(0,J.jsx)(WA,{size:14}),label:i.estimated?`${Gv({done:o,total:a})} \u00b7 ${Zee()}`:Gv({done:o,total:a}),sublabel:!s&&c!==void 0?c.step:void 0,trailing:(0,J.jsx)(`span`,{className:`oc-planact__bar`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":a,"aria-valuenow":o,children:(0,J.jsx)(`span`,{className:`oc-planact__bar-fill`,style:{width:`${a>0?o/a*100:0}%`}})}),open:s,ariaExpanded:s,title:s?_m():Fy(),onClick:()=>r(!s)}),s?(0,J.jsx)(`ol`,{className:`oc-planact__steps`,children:i.steps.map((e,n)=>(0,J.jsxs)(`li`,{className:`oc-planact__step oc-planact__step--${e.status}`,children:[(0,J.jsx)(s3,{status:e.status,settled:t}),(0,J.jsx)(`span`,{className:`oc-planact__step-text`,children:e.step})]},n))}):null,s&&i.explanation!==void 0?(0,J.jsx)(`div`,{className:`oc-planact__note`,children:i.explanation}):null]})}function l3(e){let t=e.split(/[\s._-]+/).map(e=>e.trim()).filter(e=>e.length>0);return t.length===0?`?`:t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[1][0]).toUpperCase()}function u3(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*31+e.charCodeAt(n)>>>0;return t%8}function d3({userId:e,name:t,showTitle:n=!0}){return(0,J.jsx)(`span`,{className:`oc-avatar`,"data-tone":u3(e),title:n?t:void 0,"aria-hidden":!0,children:l3(t)})}function f3({kind:e,size:t=16,className:n}){let r=e===`hermes`?`Hermes`:`OpenClaw`;return e===`hermes`?(0,J.jsx)(wA,{size:t,className:n,"aria-label":r,role:`img`}):(0,J.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:n,role:`img`,"aria-label":r,children:[(0,J.jsx)(`path`,{d:`M4 20l3-3`}),(0,J.jsx)(`path`,{d:`M7 17a4 4 0 0 1 0-6l1-1`}),(0,J.jsx)(`path`,{d:`M8 10c1-4 5-6.5 11-6-2.5 3-5 4.5-8 5.5`}),(0,J.jsx)(`path`,{d:`M11 12.5c3 0 6 1 8.5 3.5-3 1-6 .5-8.5-1.5`}),(0,J.jsx)(`path`,{d:`M7 17a4 4 0 0 0 5.5-1.5`})]})}var p3=2.4;function m3(e,t,n=p3,r=56){return t===null||!Number.isFinite(t)?e.map(()=>1):e.map(e=>{let i=Math.abs(e-t);return i>=r?1:1+(n-1)*Math.cos(i/r*(Math.PI/2))})}function h3(e){let t=-1,n=1;return e.forEach((e,r)=>{e>n&&(t=r,n=e)}),t===-1?null:t}function g3(e,t,n){return e.map((r,i)=>{let a=0;return e.forEach((e,o)=>{if(o===i)return;let s=((t[o]??1)-1)*n;a+=s/2*(r>e?1:r<e?-1:0)}),a})}var _3=e=>e===`owner`?Yv():e===`manager`?u_():e===`member`?By():Sm(),v3=e=>{let t=_3(e);return t.charAt(0).toUpperCase()+t.slice(1)},y3=e=>e===`manager`?T():e===`member`?Rs():Jd();function b3({agent:e}){return(0,J.jsx)(`span`,{className:`oc-convpanel__face`,"aria-hidden":!0,children:e.emoji?e.emoji:(0,J.jsx)(kS,{size:14})})}var x3=e=>e.displayName??e.agentId;function S3(e,t){let n=e.trim().toLowerCase();return n===``||t.some(e=>(e??``).toLowerCase().includes(n))}function C3({open:e,onOpenChange:t,title:n,description:r,items:i,keyOf:a,searchFields:o,render:s,actionLabel:c,onPick:l,closeOnPick:u=!1,empty:d,header:f}){let[p,m]=(0,q.useState)(``),[h,g]=(0,q.useState)(new Set),[_,v]=(0,q.useState)(null),y=(0,q.useRef)(null);(0,q.useEffect)(()=>{e||(m(``),g(new Set))},[e]);let b=(i??[]).filter(e=>S3(p,o(e)));return(0,J.jsx)(rT,{open:e,onOpenChange:t,children:(0,J.jsxs)(eT,{className:`oc-convpicker`,onOpenAutoFocus:e=>{e.preventDefault(),y.current?.focus()},children:[(0,J.jsxs)(Qw,{children:[(0,J.jsx)(tT,{children:n}),(0,J.jsx)(nT,{children:r})]}),(0,J.jsx)(Tw,{ref:y,value:p,onChange:e=>m(e.target.value),placeholder:Zu(),"aria-label":Zu()}),f,(0,J.jsx)(`ul`,{className:`oc-convpicker__list`,children:i===void 0?(0,J.jsx)(`li`,{className:`oc-convpicker__empty`,children:mc()}):b.length===0?(0,J.jsx)(`li`,{className:`oc-convpicker__empty`,children:d}):b.map(e=>{let n=a(e),r=h.has(n);return(0,J.jsxs)(`li`,{className:`oc-convpicker__row`,children:[s(e),(0,J.jsxs)(K,{variant:r?`ghost`:`outline`,size:`sm`,disabled:r||_!==null,onClick:()=>{v(n),l(e).then(()=>{g(e=>new Set(e).add(n)),u&&t(!1)}).catch(()=>{}).finally(()=>v(null))},children:[r?(0,J.jsx)(ZS,{size:14,"aria-hidden":!0}):null,r?op():c]})]},n)})})]})})}var w3=6;function T3({chatId:e,onOpen:t}){let n=H(G.chatParticipants.listMembers,{chatId:e}),r=H(G.chatAgents.listChatAgents,{chatId:e}),i=(0,q.useRef)([]),a=(0,q.useRef)([]),o=(0,q.useRef)(20),[s,c]=(0,q.useState)(null),l=(0,q.useRef)(0),u=j4(n??[],r?[r.primary,...r.agents].filter(e=>e!==null):[]);if(u===null)return null;let{people:d,agents:f}=u,p=[...d.map(e=>({kind:`person`,key:`p/${String(e.userId)}`,name:e.isSelf?`${e.name} (${Ae()})`:e.name,userId:String(e.userId),role:_3(e.roomRole),self:e.isSelf})),...f.map(e=>({kind:`agent`,key:`a/${e.instanceName}/${e.agentId}`,name:e.displayName??e.agentId,gateway:e.kind,primary:e.role===`primary`}))],m=p.slice(0,w3),h=p.slice(w3),g=typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0?m.map(()=>1):m3(a.current.slice(0,m.length),s),_=h3(g),v=g3(a.current.slice(0,m.length),g,o.current);return(0,J.jsxs)(`button`,{type:`button`,className:`oc-presence`,onClick:t,onMouseEnter:e=>{let t=e.currentTarget.getBoundingClientRect();l.current=t.left,a.current=i.current.slice(0,m.length).map(e=>{let n=e?.getBoundingClientRect();return n?n.left+n.width/2-t.left:NaN}),o.current=i.current[0]?.getBoundingClientRect().width||20,c(e.clientX-t.left)},onMouseMove:e=>c(e.clientX-l.current),onMouseLeave:()=>c(null),"aria-label":Ml({people:d.length,agents:f.length}),children:[m.map((e,t)=>e.kind===`person`?(0,J.jsx)(`span`,{ref:e=>{i.current[t]=e},className:`oc-presence__face${e.self?` is-self`:``}${_===t?` is-focus`:``}`,style:{"--dock-s":g[t]??1,"--dock-x":`${v[t]??0}px`},"data-name":`${e.name} · ${e.role}`,children:(0,J.jsx)(d3,{userId:e.userId,name:e.name,showTitle:!1})},e.key):(0,J.jsxs)(`span`,{ref:e=>{i.current[t]=e},className:`oc-presence__face oc-presence__agent${e.primary?` is-primary`:``}${_===t?` is-focus`:``}`,style:{"--dock-s":g[t]??1,"--dock-x":`${v[t]??0}px`},"data-name":e.name,children:[(0,J.jsx)(f3,{kind:e.gateway,size:12}),e.primary?(0,J.jsx)(xA,{size:8,className:`oc-presence__crown`,"aria-hidden":!0}):null]},e.key)),h.length>0?(0,J.jsxs)(`span`,{className:`oc-presence__more`,title:h.map(e=>e.name).join(`
144
+ `),children:[`+`,h.length]}):null]})}function E3({chatId:e,routing:t,open:n,onOpenChange:r,tab:i,onTabChange:a,intent:o,onIntentDone:s}){let c=H(G.chatAgents.listChatAgents,n?{chatId:e}:`skip`),l=H(G.chatParticipants.listMembers,n?{chatId:e}:`skip`),u=c?.viewerRoomRole,d=c?c.agents.length+ +!!c.primary:0;return(0,J.jsx)(ST,{open:n,onOpenChange:r,children:(0,J.jsxs)(xT,{side:`right`,className:`oc-spanel oc-convpanel`,returnFocus:()=>{let{bar:e,more:t,field:n}=C2(null);return[T2(e,`room-settings`),t,n]},children:[(0,J.jsxs)(CT,{children:[(0,J.jsx)(bT,{children:Iy()}),(0,J.jsx)(yT,{children:u===void 0?``:u4(u)?vm():b({role:_3(u)})})]}),(0,J.jsx)(`div`,{className:`oc-spanel__body`,children:c===void 0?(0,J.jsx)(`p`,{className:`oc-spanel__loading`,children:qb()}):c===null?null:(0,J.jsxs)(ww,{value:i,onValueChange:e=>a(e),children:[(0,J.jsxs)(Cw,{className:`oc-convpanel__tabs`,children:[(0,J.jsxs)(bw,{value:`agents`,children:[(0,J.jsx)(kS,{size:14,"aria-hidden":!0}),` `,wd(),(0,J.jsx)(`span`,{className:`oc-convpanel__count`,children:d})]}),(0,J.jsxs)(bw,{value:`people`,children:[(0,J.jsx)(UC,{size:14,"aria-hidden":!0}),` `,yi(),(0,J.jsx)(`span`,{className:`oc-convpanel__count`,children:l?.length??``})]})]}),(0,J.jsx)(xw,{value:`agents`,children:(0,J.jsx)(D3,{chatId:e,routing:t,room:c,intent:o,onIntentDone:s})}),(0,J.jsx)(xw,{value:`people`,children:(0,J.jsx)(O3,{chatId:e,viewer:c.viewerRoomRole,authMode:c.authMode,participantIdentity:c.participantIdentity,intent:o,onIntentDone:s,onLeft:()=>r(!1)})})]})})]})})}function D3({chatId:e,routing:t,room:n,intent:r,onIntentDone:i}){let a=Iw(),o=u4(n.viewerRoomRole),s=n.viewerRoomRole===`owner`,[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1);(0,q.useEffect)(()=>{r===`add-agent`?(l(!0),i()):r===`primary`&&(d(!0),i())},[r,i]);let m=H(G.chatAgents.listAddableAgents,c&&o?{chatId:e}:`skip`),h=U(G.chatAgents.addChatAgent),g=U(G.chatAgents.removeChatAgent),_=U(G.chats.rebindChatAgent),v=U(G.chatAgents.setPrimaryAgent),y=t=>void v({chatId:e,instanceName:t.instanceName,agentId:t.agentId}).then(e=>{!e.changed&&e.reason===`busy`&&a.error(vd()),!e.changed&&e.reason===`preparing`&&a.error(pi())}).catch(e=>{let t=e instanceof Error?e.message:String(e);a.error(t.includes(`TALK_CALL_ACTIVE`)?Rh():AT(e)?Uu():Sx())}),b=H(G.messages.getSessionMeta,s?{chatId:e}:`skip`),x=b?.sessionMeta??null,S=b?.sessionSettings??null,C=t?.emptyThread===!0,w=(0,q.useMemo)(()=>(t?.pool??[]).filter(e=>e.state!==`deleted`&&!g4(e,n.primary)),[t?.pool,n.primary]),T=e=>{let t=e instanceof Error?e.message:String(e),n=/chat_agents_limit:(\d+)/.exec(t);throw a.error(n===null?AT(e)?Uu():Sx():Bi({count:Number(n[1])})),e},E=(t,n)=>(0,J.jsxs)(`li`,{className:`oc-convpanel__member${t.gone?` is-gone`:``}`,children:[(0,J.jsx)(b3,{agent:t}),(0,J.jsxs)(`span`,{className:`oc-convpanel__who`,children:[(0,J.jsxs)(`span`,{className:`oc-convpanel__name`,children:[(0,J.jsx)(`span`,{className:`oc-convpanel__nametext`,children:x3(t)}),n?(0,J.jsx)(xA,{size:12,className:`oc-convpanel__crown`,"aria-label":oh(),children:(0,J.jsx)(`title`,{children:oh()})}):null,t.gone?(0,J.jsx)(`span`,{className:`oc-convpanel__badge is-warn`,children:mr()}):t.usable?null:(0,J.jsx)(`span`,{className:`oc-convpanel__badge is-muted`,children:Ql()})]}),(0,J.jsxs)(`span`,{className:`oc-convpanel__sub`,children:[(0,J.jsx)(zC,{size:10,"aria-hidden":!0}),` `,(0,J.jsxs)(`span`,{className:`oc-convpanel__subtext`,children:[t.instanceName,t.model?` · ${t.model}`:``]})]})]}),!n&&o?(0,J.jsxs)(hC,{children:[(0,J.jsx)(oC,{asChild:!0,children:(0,J.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":Mc(),children:(0,J.jsx)(SA,{})})}),(0,J.jsxs)(dC,{align:`end`,children:[s&&t.usable&&!t.gone?(0,J.jsxs)(pC,{onSelect:()=>y(t),children:[(0,J.jsx)(xA,{"aria-hidden":!0}),Ud()]}):null,(0,J.jsx)(pC,{variant:`destructive`,onSelect:()=>void g({chatId:e,instanceName:t.instanceName,agentId:t.agentId}).catch(()=>a.error(Sx())),children:xu()})]})]}):null]},`${t.instanceName}/${t.agentId}`);return(0,J.jsxs)(`div`,{className:`oc-convpanel__tab`,children:[(0,J.jsxs)(`ul`,{className:`oc-convpanel__members`,children:[n.primary?E(n.primary,!0):null,n.agents.map(e=>E(e,!1))]}),s&&n.primary?C?w.length>0?(0,J.jsx)(K,{variant:`ghost`,size:`sm`,className:`oc-convpanel__link`,onClick:()=>d(!0),children:Ns()}):null:(0,J.jsx)(`p`,{className:`oc-convpanel__hint`,children:Gu()}):null,s&&b?(0,J.jsxs)(`div`,{className:`oc-convpanel__settings`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-convpanel__disclosure`,"aria-expanded":f,onClick:()=>p(e=>!e),children:[f?(0,J.jsx)(QS,{size:14,"aria-hidden":!0}):(0,J.jsx)(eC,{size:14,"aria-hidden":!0}),Kh()]}),f?(0,J.jsx)(`div`,{className:`oc-convpanel__knobs`,children:(0,J.jsx)(DT,{chatId:e,sm:x,settings:S})}):null]}):null,o?(0,J.jsxs)(K,{variant:`outline`,size:`sm`,className:`oc-convpanel__add`,disabled:n.agents.length>=n.limit,onClick:()=>l(!0),children:[(0,J.jsx)(LC,{size:14,"aria-hidden":!0}),Hn(),(0,J.jsxs)(`span`,{className:`oc-convpanel__count`,children:[n.agents.length,`/`,n.limit]})]}):null,(0,J.jsx)(`p`,{className:`oc-convpanel__hint`,children:Fb()}),(0,J.jsx)(C3,{open:c,onOpenChange:l,title:Hn(),description:Jte(),items:o?m:[],keyOf:e=>`${e.instanceName}/${e.agentId}`,searchFields:e=>[e.displayName,e.agentId,e.instanceName,e.description],render:e=>(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(b3,{agent:e}),(0,J.jsxs)(`span`,{className:`oc-convpanel__who`,children:[(0,J.jsx)(`span`,{className:`oc-convpanel__name`,children:(0,J.jsx)(`span`,{className:`oc-convpanel__nametext`,children:x3(e)})}),(0,J.jsxs)(`span`,{className:`oc-convpanel__sub`,children:[(0,J.jsx)(zC,{size:10,"aria-hidden":!0}),` `,(0,J.jsxs)(`span`,{className:`oc-convpanel__subtext`,children:[e.instanceName,e.description?` · ${e.description}`:``]})]})]})]}),actionLabel:kte(),onPick:t=>h({chatId:e,instanceName:t.instanceName,agentId:t.agentId}).catch(T),empty:Dl()}),(0,J.jsx)(C3,{open:u,onOpenChange:d,title:Ns(),description:Ff(),items:w,keyOf:e=>`${e.instanceName}/${e.agentId}`,searchFields:e=>[e.displayName,e.agentId,e.instanceName],render:e=>(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(b3,{agent:e}),(0,J.jsxs)(`span`,{className:`oc-convpanel__who`,children:[(0,J.jsx)(`span`,{className:`oc-convpanel__name`,children:(0,J.jsx)(`span`,{className:`oc-convpanel__nametext`,children:x3(e)})}),(0,J.jsxs)(`span`,{className:`oc-convpanel__sub`,children:[(0,J.jsx)(zC,{size:10,"aria-hidden":!0}),` `,(0,J.jsx)(`span`,{className:`oc-convpanel__subtext`,children:e.instanceName})]})]})]}),actionLabel:pf(),closeOnPick:!0,onPick:t=>_({chatId:e,instanceName:t.instanceName,agentId:t.agentId}).catch(e=>{throw a.error(AT(e)?Uu():qee()),e}),empty:Dl()})]})}function O3({chatId:e,viewer:t,authMode:n,participantIdentity:r,intent:i,onIntentDone:a,onLeft:o}){let s=Iw(),c=u4(t),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(`member`),p=h4(d,t);(0,q.useEffect)(()=>{f(`member`)},[e]),(0,q.useEffect)(()=>{i===`invite`&&(u(!0),a())},[i,a]);let m=H(G.chatParticipants.listMembers,{chatId:e}),h=H(G.chatParticipants.listInvitable,l&&c?{chatId:e}:`skip`),g=U(G.chatParticipants.addMember),_=U(G.chatParticipants.removeMember),v=U(G.chatParticipants.setMemberRole),y=U(G.chatParticipants.leaveChat),b=e=>{let t=e instanceof Error?e.message:String(e),n=/participants_limit:(\d+)/.exec(t);throw s.error(n===null?vf():Rb({count:Number(n[1])})),e};return(0,J.jsxs)(`div`,{className:`oc-convpanel__tab`,children:[(0,J.jsx)(`ul`,{className:`oc-convpanel__members`,children:(m??[]).map(n=>{let r=n.roomRole===`owner`?null:n.roomRole,i=r===null?[]:d4(t,r,n.isSelf),a=p4(t,n);return(0,J.jsxs)(`li`,{className:`oc-convpanel__member`,children:[(0,J.jsx)(d3,{userId:String(n.userId),name:n.name}),(0,J.jsxs)(`span`,{className:`oc-convpanel__who`,children:[(0,J.jsxs)(`span`,{className:`oc-convpanel__name`,children:[(0,J.jsx)(`span`,{className:`oc-convpanel__nametext`,children:n.name}),n.isSelf?(0,J.jsx)(`span`,{className:`oc-convpanel__you`,children:Ae()}):null]}),i.length===0?(0,J.jsx)(`span`,{className:`oc-convpanel__sub`,children:v3(n.roomRole)}):null]}),r!==null&&i.length>0?(0,J.jsxs)(sw,{value:r,onValueChange:t=>void v({chatId:e,memberId:n.userId,role:t}).catch(()=>s.error(vf())),children:[(0,J.jsx)(iw,{size:`sm`,className:`oc-convpanel__role`,children:(0,J.jsx)(rw,{})}),(0,J.jsx)(aw,{align:`end`,children:i.map(e=>(0,J.jsx)(ow,{value:e,children:v3(e)},e))})]}):null,a?(0,J.jsxs)(hC,{children:[(0,J.jsx)(oC,{asChild:!0,children:(0,J.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":Mc(),children:(0,J.jsx)(SA,{})})}),(0,J.jsx)(dC,{align:`end`,children:(0,J.jsx)(pC,{variant:`destructive`,onSelect:()=>void _({chatId:e,memberId:n.userId}).catch(()=>s.error(vf())),children:Fe()})})]}):null]},String(n.userId))})}),c?(0,J.jsxs)(K,{variant:`outline`,size:`sm`,className:`oc-convpanel__add`,onClick:()=>u(!0),children:[(0,J.jsx)(VC,{size:14,"aria-hidden":!0}),th()]}):null,(0,J.jsxs)(`div`,{className:`oc-convpanel__callout`,children:[(0,J.jsx)(BC,{size:14,"aria-hidden":!0}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`oc-convpanel__callout-title`,children:n===`mixed`?lb():n===`trusted-proxy`?_y():Qp()}),(0,J.jsx)(`p`,{children:n===`mixed`?yee():n===`trusted-proxy`?r===`self`?tt():P_():kp()}),(0,J.jsx)(`dl`,{className:`oc-convpanel__roles`,children:[`viewer`,`member`,`manager`].map(e=>(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{children:v3(e)}),(0,J.jsx)(`dd`,{children:y3(e)})]},e))})]})]}),t===`owner`?null:(0,J.jsxs)(K,{variant:`ghost`,size:`sm`,className:`oc-convpanel__leave`,onClick:()=>void y({chatId:e}).then(o).catch(()=>s.error(vf())),children:[(0,J.jsx)(KA,{size:14,"aria-hidden":!0}),Dx()]}),(0,J.jsx)(C3,{open:l,onOpenChange:u,title:th(),description:rv(),items:c?h:[],keyOf:e=>String(e.userId),searchFields:e=>[e.name],header:(0,J.jsxs)(`label`,{className:`oc-convpicker__role`,children:[(0,J.jsx)(`span`,{children:a_()}),(0,J.jsxs)(sw,{value:p,onValueChange:e=>f(e),children:[(0,J.jsx)(iw,{size:`sm`,className:`w-40`,children:(0,J.jsx)(rw,{})}),(0,J.jsx)(aw,{children:m4(t).map(e=>(0,J.jsx)(ow,{value:e,children:v3(e)},e))})]})]}),render:e=>(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(d3,{userId:String(e.userId),name:e.name}),(0,J.jsx)(`span`,{className:`oc-convpanel__who`,children:(0,J.jsx)(`span`,{className:`oc-convpanel__name`,children:(0,J.jsx)(`span`,{className:`oc-convpanel__nametext`,children:e.name})})})]}),actionLabel:Th(),onPick:t=>g({chatId:e,memberId:t.userId,role:p}).catch(b),empty:xa()})]})}function k3(e){let t=e.trim().replace(/\s+/g,`.`);return`@${t.length>0?t:`?`}`}var A3=/[\p{L}\p{N}_\-]/u;function j3(e,t,n=[],r=0){if(t.length===0)return null;for(let i=e.indexOf(t,r);i!==-1;i=e.indexOf(t,i+1)){let r=i+t.length,a=i>0?e[i-1]:``;if(a!==``&&(A3.test(a)||a===`@`))continue;let o=e[r]??``;if(!A3.test(o)&&!((o===`.`||o===`'`)&&A3.test(e[r+1]??``))&&!n.some(e=>i<e.end&&r>e.start))return{start:i,end:r}}return null}var M3=e=>`agent`in e;function N3(e){return M3(e)?`agent\u0000${e.agent.instanceName}\u0000${e.agent.agentId}`:`user\u0000${e.userId}`}var P3=[],F3=new Map,I3=new Set;function L3(){for(let e of I3)e()}function R3(e){return I3.add(e),()=>I3.delete(e)}function z3(e){return F3.get(e)??P3}function B3(e,t){let n=F3.get(e)??[],r=n.findIndex(e=>N3(e)===N3(t));r!==-1&&n[r].token===t.token||(F3.set(e,r===-1?[...n,t]:n.map((e,n)=>n===r?t:e)),L3())}function V3(e){let t=F3.get(e)??P3;return t.length>0&&(F3.delete(e),L3()),t}function H3(e,t){if(t.length===0)return;let n=F3.get(e)??[],r=new Set(n.map(N3)),i=[...n];for(let e of t)r.has(N3(e))||i.push(e);F3.set(e,i),L3()}function U3(e,t){let n=[],r=[],i=[];for(let a of t){let t=j3(e,a.token,i);t!==null&&(M3(a)?r.push({...a.agent,start:t.start,end:t.end}):n.push({userId:a.userId,start:t.start,end:t.end}),i.push(t))}return{people:n.sort((e,t)=>e.start-t.start),agents:r.sort((e,t)=>e.start-t.start)}}function W3(e,t){let n=V3(e),{people:r,agents:i}=U3(t,n);return{staged:n,mentions:r,agentMentions:i}}function G3(e){return e.filter(M3).map(e=>({...e.agent}))}function K3(e,t,n,r){return J3(e,t,{userId:n,token:r})}function q3(e,t,n,r){return J3(e,t,{agent:{instanceName:n.instanceName,agentId:n.agentId},token:r})}function J3(e,t,n){let r=N3(n),i=n.token,a=z3(e),o=a.find(e=>N3(e)===r);if(o!==void 0&&j3(t,o.token)!==null)return null;let s=new Set(a.filter(e=>N3(e)!==r).map(e=>e.token)),c=i;for(let e=2;s.has(c);e+=1)c=`${i}-${e}`;return B3(e,{...n,token:c}),`${t}${t.length===0||t.endsWith(` `)?``:` `}${c} `}function Y3(e){return e.kind===`tool`}function X3(e){return e.kind===`media`}function Z3(e){return e.kind===`file`}function Q3(e){return e.kind===`reasoning`}function $3(e){return e.kind===`plan`}function e6(e){return e.kind===`cron`}function t6(e){return e.kind===`widget`}function n6(e){return e.kind===`model_fallback`}function r6(e){return e.kind===`gateway_notice`}function i6(e){return e.kind===`compaction`}function a6(e){let t=[],n=/^ {0,3}(`{3,}|~{3,})(.*)$/gm,r=-1,i=``,a=0;for(let o=n.exec(e);o!==null;o=n.exec(e)){let e=o[1][0];r===-1?(r=o.index,i=e,a=o[1].length):e===i&&o[1].length>=a&&/^[ \t]*$/.test(o[2])&&(t.push([r,o.index+o[1].length]),r=-1)}return r!==-1&&t.push([r,e.length]),t}function o6(e,t){let n=Math.max(0,t);if(n===0)return 0;if(n>=e.length)return n;for(let[t,r]of a6(e))if(n>t&&n<r)return t;return n}function s6(e,t,n){if((n?.settled??!0)||(t=t.filter(t=>t.offset<=e.length)),t.length===0)return e.length>0?[{kind:`text`,text:e}]:[];let r=[],i=0;for(let n of t){let t=Math.max(i,o6(e,n.offset));if(i=t,n.note!==void 0){r.push({cut:t,note:n.note});continue}let a=r[r.length-1];a!==void 0&&a.parts!==void 0&&a.cut===t?a.parts.push(n.activity):r.push({cut:t,parts:[n.activity]})}let a=[];for(let t of r){let n=a[a.length-1];n!==void 0&&n.parts!==void 0&&t.parts!==void 0&&e.slice(Math.min(n.cut,e.length),Math.min(t.cut,e.length)).trim()===``?n.parts.push(...t.parts):a.push(t)}let o=[],s=0;for(let t of a){let n=Math.min(t.cut,e.length),r=e.slice(s,n);r.trim()!==``&&o.push({kind:`text`,text:r}),t.note===void 0?o.push({kind:`activity`,parts:t.parts,cut:t.cut}):o.push({kind:`note`,key:t.note.key,text:t.note.text,cut:t.cut}),s=Math.max(s,n)}let c=e.slice(s);return c.trim()!==``&&o.push({kind:`text`,text:c}),o}var c6=[`read`,`exec`,`search`,`fetch`,`write`,`other`],l6={read:{one:()=>qf(),many:e=>Rte({count:String(e)})},exec:{one:()=>bb(),many:e=>$d({count:String(e)})},search:{one:()=>Hm(),many:e=>fh({count:String(e)})},fetch:{one:()=>Eee(),many:e=>W_({count:String(e)})},write:{one:()=>Mm(),many:e=>zp({count:String(e)})},other:{one:e=>Yy({tool:e}),many:e=>Kg({count:String(e)})}};function u6(e){return e===`started`||e===`running`||e===`start`}function d6(e){let t=new Map;for(let n of e){let e=l$(n.toolName);t.set(e,(t.get(e)??0)+1)}let n=`other`,r=-1;for(let e of c6){let i=t.get(e)??0;i>r&&(n=e,r=i)}return n}function f6(e,t){let n=t?.live===!1?void 0:[...e].reverse().find(e=>u6(e.phase));if(n!==void 0)switch(l$(n.toolName)){case`read`:return A();case`exec`:return wg();case`search`:return wo();case`fetch`:return ot();case`write`:return At();default:return Vc({tool:n.toolName})}let r=new Map;for(let t of e){let e=l$(t.toolName),n=r.get(e)??[];n.push(t),r.set(e,n)}let i=[];for(let e of c6){let t=r.get(e);t!==void 0&&i.push(t.length===1?l6[e].one(t[0].toolName):l6[e].many(t.length))}let a=i.length===1?i[0]:i.slice(0,-1).join(vc())+hte()+i[i.length-1],o=Re()+a;return o.charAt(0).toUpperCase()+o.slice(1)}var p6=/---[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(?=\.[^.]+$|$)/i;function m6(e){return e.replace(p6,``)}var h6={disable:{null:[`htmlFlow`,`htmlText`]}};function g6(e){if(!e)return[];let t=Uw(e,{extensions:[h6,Gw()],mdastExtensions:[zw()]}),n=[];for(let e of t.children??[]){let t=[e];for(;t.length>0;){let e=t.pop(),r=e.position?.start?.offset,i=e.position?.end?.offset;(e.type===`code`||e.type===`inlineCode`)&&r!==void 0&&i!==void 0&&n.push({start:r,end:i,block:e.type===`code`});for(let n of[...e.children??[]].reverse())t.push(n)}}return n.sort((e,t)=>e.start-t.start),n}function _6(e){return/[`~\t]| {4}/u.test(e)?g6(e):[]}function v6(e,t){return t.some(t=>e>=t.start&&e<t.end)}var y6=`/__openclaw__/canvas/documents/`,b6=/^cv_[A-Za-z0-9._-]{1,253}$/;function x6(e){let t={},n=/([A-Za-z_][A-Za-z0-9_-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,r;for(;r=n.exec(e);){let e=r[1]?.trim().toLowerCase(),n=(r[2]??r[3]??``).trim();e&&n&&(t[e]=n)}return t}function S6(e){if(e.target&&e.target!==`assistant_message`)return null;let t=e.ref?.trim();if(!t||!b6.test(t))return null;let n=e.url?.trim()||`${y6}${encodeURIComponent(t)}/index.html`;try{let e=new URL(n,`http://localhost`);if(e.origin!==`http://localhost`||!e.pathname.startsWith(y6))return null;let[r,i]=e.pathname.slice(31).split(`/`,2);if(!r||!i)return null;let a=decodeURIComponent(r);return/^[A-Za-z0-9._-]+$/u.test(a)&&a===t?t:null}catch{return null}}var C6=`/__openclaw__/`;function w6(e){if(e.target&&e.target!==`assistant_message`)return null;let t=e.url;if(!t)return null;let n=e.title?.replace(/\s+/g,` `).trim()||void 0,r=f0(t);if(r)return{kind:`youtube`,videoId:r.videoId,startSeconds:r.startSeconds,...n?{title:n}:{}};let i;try{i=new URL(t)}catch{return null}return i.protocol!==`https:`||i.username||i.password||i.pathname.startsWith(C6)?null:{kind:`link`,href:i.href,...n?{title:n}:{}}}function T6(e,t){return`[${t.replace(/\s+/g,` `).replace(/[!-/:-@[-`{-~]/g,`\\$&`)}](<${e.replace(/\\/g,`%5C`)}>)`}function E6(e){if(!e.trim()||!e.toLowerCase().includes(`[embed`))return[];let t=_6(e),n=[];for(let r of[/\[embed\s+([^\]]*?[^\]/]|)\]([\s\S]*?)\[\/embed\]/gi,/\[embed\s+([^\]]*?)\/\]/gi]){let i;for(;i=r.exec(e);){let e=i.index;if(v6(e,t))continue;let r=x6(i[1]??``),a=S6(r);n.push({start:e,end:e+i[0].length,viewId:a,embed:a===null?w6(r):null})}}n.sort((e,t)=>e.start-t.start);let r=[],i=0;for(let e of n)e.start<i||(r.push(e),i=e.end);return r}function D6(e){let t=e.toLowerCase(),n=t=>v6(t,_6(e))?e:e.slice(0,t),r=e.lastIndexOf(`[`);if(r!==-1){let e=t.slice(r);if(e.length<6&&`[embed`.startsWith(e))return n(r)}let i=t.lastIndexOf(`[embed`);if(i===-1)return e;let a=e.slice(i);if(!/^\[embed(?:\s|$)/i.test(a))return e;let o=a.indexOf(`]`);return o===-1?n(i):a[o-1]===`/`||/\[\/embed\]/i.test(a)?e:n(i)}function O6(e,t,n){let r=n?D6(e):e,i=[],a=``,o=0;for(let e of E6(r)){let n=e.viewId!==null&&t.has(e.viewId);if(!n&&e.embed===null||(a+=r.slice(o,e.start),o=e.end,n))continue;if(e.embed.kind===`link`){a+=T6(e.embed.href,e.embed.title??e.embed.href);continue}let{kind:s,...c}=e.embed;i.push({kind:`text`,text:a},{kind:`youtube`,...c}),a=``}return i.push({kind:`text`,text:a+r.slice(o)}),i}function k6(e,t,n){return O6(e,t,n).map(e=>{if(e.kind===`text`)return e.text;let t=u0(e);return t?T6(t.watchUrl,e.title??t.watchUrl):``}).join(``)}var A6=e=>e.kind===`media`||e.kind===`file`;function j6(e,t,n,r){let i=t?.find(e=>e.entryId===n&&e.blockIndex===r),a=i?.fileId===void 0?void 0:e.parts.filter(A6).find(e=>e.transcriptFileId===i.fileId),o=a?.filename??i?.label??`file`,s=a?.mimeType??i?.mimeType??`application/octet-stream`;if(i?.state===`remote`&&i.url!==void 0)return{kind:`file`,entryId:n,blockIndex:r,file:{kind:`remote`,url:i.url,filename:o,mimeType:s}};let c=a?.url??(i?.state===`copied`?i.url:void 0),l=a?.storageId??i?.storageId;return i?.state===`copied`&&c&&l!==void 0?{kind:`file`,entryId:n,blockIndex:r,file:{kind:`copied`,url:c,filename:o,mimeType:s,storageId:l}}:{kind:`file`,entryId:n,blockIndex:r,file:{kind:`unavailable`,state:i===void 0||i.state===`copied`||i.state===`remote`?`pending`:i.state,...i?.reason===void 0?{}:{reason:i.reason},filename:o,mimeType:s}}}function M6(e){let t=e.rowLayout;if(e.role!==`assistant`||t===void 0||t.length===0)return null;let n=new Set,r=new Set;for(let t of e.displayHidden??[])t.rule===`repeated_text_in_group`?n.add(t.entryId):`entryId`in t&&r.add(`${t.entryId}\u0000${t.blockIndex}`);let i=[],a=e.text??``,o=(t,n)=>{r.has(`${t}\u0000${n}`)||i.push(j6(e,e.rowFiles,t,n))};for(let e of t){e.thinking===!0&&i.push({kind:`thinking`,entryId:e.entryId});let t=e.commentary===!0?{commentary:!0}:{};if(e.items!==void 0){for(let r of e.items)if(r.kind===`file`)o(e.entryId,r.blockIndex);else if(!n.has(e.entryId)){let n=a.slice(r.start,r.end);n.trim()!==``&&i.push({kind:`text`,entryId:e.entryId,text:n,...r.capped===!0?{capped:!0}:{},...t})}}else{let r=a.slice(e.start,e.end);r.trim()!==``&&!n.has(e.entryId)&&i.push({kind:`text`,entryId:e.entryId,text:r,...t});for(let t of e.files??[])o(e.entryId,t.blockIndex)}let r=e.tools??[];if(r.length>0){let t=i[i.length-1],n=t?.kind===`tools`?t:{kind:`tools`,entryId:e.entryId,toolCallIds:[]};n!==t&&i.push(n);for(let e of r)n.toolCallIds.push(e.toolCallId),e.parentToolCallId!==void 0&&((n.parents??={})[e.toolCallId]=e.parentToolCallId)}}let s=t[t.length-1]?.cut,c=(s?.rows??0)+(s?.files??0)+(s?.tools??0)+(s?.widgets??0);return c>0&&i.push({kind:`cut`,count:c}),i}function N6(e){let t=e.rowLayout??[];return{cardsOfBlockRows:new Set(t.flatMap(e=>e.blocks===!0?(e.tools??[]).map(e=>e.toolCallId):[])),rowsWithoutBlocks:t.some(e=>e.blocks!==!0)}}function P6(e){return new Set((e.displayHidden??[]).flatMap(e=>e.rule===`same_sha256_in_group`&&`storageId`in e?[e.storageId]:[]))}function F6(e){return new Set((e.rowFiles??[]).flatMap(e=>e.fileId===void 0?[]:[e.fileId]))}var I6=RegExp(`^([a-z][a-z0-9_]*):((?:tool:[a-z][a-z0-9_]*:)?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}):(ok|error)(?::agent-loop)?$`),L6=[`agent-loop`,`wake`];function R6(e){return typeof e==`string`&&e.startsWith(`announce:requester-settle:`)}var z6=/^[A-Za-z0-9_-]{1,128}$/,B6=32;function V6(e){if(!R6(e))return null;let t=e.split(`:`);/^retry-\d+$/.test(t[t.length-1]??``)&&t.pop();let n=t[t.length-1]===`pause`;n&&t.pop();let r=null,i=/^yield-(\d+)$/.exec(t[t.length-1]??``);i!==null&&i[1]!==void 0&&(r=Number(i[1]),t.pop());let a=(t.pop()??``).split(`,`);return t.length<4||a.length===0||a.length>B6||!a.every(e=>z6.test(e))?null:n?{childRunIds:[],yieldGeneration:null,pause:{childRunIds:a,yieldGeneration:r}}:{childRunIds:a,yieldGeneration:r}}function H6(e){if(R6(e))return null;if(e.startsWith(`announce:`)){let t=e.split(`:`),n=t[t.length-1];if(n!==void 0&&L6.includes(n)&&t.pop(),t.length<4)return null;let r=t.slice(2,-1).join(`:`);return r===``?null:r}let t=I6.exec(e);return t!==null&&t[2]!==void 0?`task:${t[2]}`:null}var U6={childRunIds:[],childKeys:[],lastUserAt:null};function W6(e,t=!1){let n=new Set,r=new Set,i=null;for(let t of e){if(t.role===`user`){let e=t.orderTime??t._creationTime;(i===null||e>i)&&(i=e);continue}if(t.role!==`assistant`||typeof t.runId!=`string`)continue;let e=V6(t.runId);if(e!==null){for(let t of e.childRunIds)n.add(t);continue}let a=H6(t.runId);a!==null&&r.add(a)}return n.size===0&&r.size===0&&i===null&&!t?U6:{childRunIds:[...n].sort(),childKeys:[...r].sort(),lastUserAt:i,...t?{projected:!0}:{}}}function G6(e,t){if(e.role!==`assistant`||e.rowLayout===void 0)return;let n=e.orderTime??e._creationTime;return{projected:!0,resumedChildRunIds:t.childRunIds,resumedChildKeys:t.childKeys,laterUserTurn:t.lastUserAt!==null&&t.lastUserAt>n}}function K6(e,t=e.length){for(let n=Math.min(t,e.length)-1;n>=0;--n)if(e[n].role===`user`)return n;return-1}function q6(e,t,n,r=e.length,i){let a=-1;for(let o=0;o<r;o+=1){let r=e[o],s=r.commentaryItemId!==void 0&&(i===void 0||i.has(r.commentaryItemId)),c=r.runId===n&&!s?r.text:null;if(r.role===`assistant`&&c&&(t.startsWith(c)||c.startsWith(t))){a=o;break}}let o=a>=0?a:K6(e,r)+1;return J6(e.slice(o,r).map(e=>{let t=e.commentaryItemId!==void 0&&(i===void 0||i.has(e.commentaryItemId));return{text:e.role===`assistant`&&(!e.runId||e.runId===n)&&!t?e.text:null,skipOnMismatch:e.commentaryItemId!==void 0}}),t)}function J6(e,t){let n=0;for(let{text:r,skipOnMismatch:i}of e){if(!r)continue;let e=t.slice(n);if(e.startsWith(r)){n+=r.length;continue}if(r.startsWith(e))return null;let a=n>0?/^\s+/u.exec(e)?.[0]:void 0;if(a&&e.slice(a.length).startsWith(r)){n+=a.length+r.length;continue}if(a&&r.startsWith(e.slice(a.length)))return null;if(!i&&n>0)break}return t.slice(n)}function Y6(e,t,n){return q6(e,t,n,e.length,new Set)}function X6(e){return e?.row!==void 0||(e?.text??``).trim()!==``||e?.capped===!0}function Z6(e){return(e??``).trim()!==``}function Q6(e){return e.type===`data-thinking`?X6(e.data)?`thinking`:`nothing`:e.type===`data-commentary`?Z6(e.data?.text)?`note`:`nothing`:e.type===`tool-call`&&e.toolName===`__turn_flow__`?(e.args?.parts??[]).length>0?`action`:`nothing`:e.type===`text`&&(e.text??``).trim()===``?`nothing`:null}function $6(e,t){let n=e,r=[],i=()=>{let e=r;r=[];let i=e.filter(e=>e.kind===`thinking`);if(i.length===0)return;let a=i.map(e=>`${t}:${n[e.at].data?.key??e.at}`);s8(a);let o=e.find(e=>e.kind!==`action`).at,s={key:a[0],thoughtIds:a,thoughts:i.length,notes:e.filter(e=>e.kind===`note`).length,actions:e.filter(e=>e.kind===`action`).length,live:e.some(e=>n[e.at].data?.live===!0)};e.forEach(({at:e,kind:t},r)=>{let i=n[e],a={...s,head:r===0,proseHead:e===o};n[e]=t===`action`?{...i,args:{...i.args,zone:a}}:{...i,data:{...i.data,zone:a}}})};n.forEach((e,t)=>{let n=Q6(e);n===null?i():n!==`nothing`&&r.push({at:t,kind:n})}),i()}function e8(e,t){return e!==void 0&&(t?e.head:e.proseHead)}function t8(e,t){return e.thoughts+e.notes+(t?e.actions:0)}function n8(e){return e??!0}var r8=new Map,i8=0,a8=new Set;function o8(e){let t;for(let n of e.thoughtIds){let e=r8.get(n);e!==void 0&&(t===void 0||e.turn>t.turn)&&(t=e)}return t?.open}function s8(e){let t;for(let n of e){let e=r8.get(n);e!==void 0&&(t===void 0||e.turn>t.turn)&&(t=e)}if(t!==void 0)for(let n of e)r8.has(n)||r8.set(n,t)}function c8(e,t){i8+=1;for(let n of e.thoughtIds)r8.set(n,{open:t,turn:i8});for(let e of a8)e()}function l8(e){return a8.add(e),()=>a8.delete(e)}function u8(e){return e.file.kind===`copied`?{type:`file`,mimeType:e.file.mimeType,data:e.file.url,filename:y8(e.file.filename),storageId:e.file.storageId}:e.file.kind===`remote`?{type:`file`,mimeType:e.file.mimeType,data:e.file.url,filename:y8(e.file.filename),remote:!0}:{type:`file`,mimeType:e.file.mimeType,data:``,filename:y8(e.file.filename),unavailable:e.file.state,...e.file.reason===void 0?{}:{reason:e.file.reason}}}function d8(e){let t=e.activeRows;if(e.status!==`streaming`||t===void 0)return{message:e,liveTail:null};let n=e.text??``,r=n===t.text||e.runId===void 0?null:Y6(t.persisted,n,e.runId);return{message:{...e,text:t.text},liveTail:r!==null&&r.trim()!==``?r:null}}function f8(e,t){return{type:`data-thinking`,data:{key:e,...t,live:!1}}}function p8(e,t,n,r){let i=O6(t,n,r);for(let t of i)if(t.kind===`text`)(i.length===1||t.text.trim()!==``)&&e.push({type:`text`,text:t.text});else{let{kind:n,...r}=t;e.push({type:`data-youtube`,data:r})}}function m8(e,t,n=!1){return{type:`data-commentary`,data:{key:e,text:t,...n?{capped:!0}:{}}}}function h8(e,t){let n=!1;for(let r=e.length-1;r>=0;r--){let i=e[r];i.type===`text`&&(i.text??``).trim()!==``?n=!0:i.type===`data-thinking`&&i.data!==void 0&&(e[r]={...i,data:{...i.data,live:t&&!n}})}}function g8(e){return ns({size:String(Math.round((e??0)/1024))})}function _8(e,t){let n=e.runId??`norun`;return`${e._id}:${n}:${t}`}function v8(e,t,n){return{toolCallId:n.toolCallId??_8(e,t),toolName:n.name,args:n.input??{},result:n.outputOmitted?g8(n.outputBytes):n.output,...n.outputDetails===void 0?{}:{resultDetails:n.outputDetails},argsText:n.inputOmitted?g8(n.inputBytes):n.input===void 0?void 0:w8(n.input),phase:typeof n.phase==`string`?n.phase:void 0,...n.inputFromTranscript===!0?{inputFromTranscript:!0}:{},...n.parentToolCallId===void 0?{}:{parentToolCallId:n.parentToolCallId}}}function y8(e){return e&&m6(e)}function b8(e){return e.url?{type:`file`,mimeType:e.mimeType,data:e.url,filename:y8(e.filename),storageId:e.storageId}:null}function x8(e,t,n){return t.length>0?s6(e,t,{settled:n}):e.length>0?[{kind:`text`,text:e}]:[]}function S8(e,t,n,r){let i=[...n].sort((e,t)=>e.at-t.at),a=[],o=0;for(let n=0;n<=i.length;n++){let s=i[n],c=s===void 0?1/0:s.at,l=Math.max(0,Math.min(o,e.length)),u=Math.max(l,Math.min(c,e.length));a.push(...x8(e.slice(l,u),t.filter(e=>e.offset>=o&&e.offset<c).map(e=>({...e,offset:e.offset-l})),r).map(e=>e.kind===`activity`||e.kind===`note`?{...e,cut:e.cut+l}:e)),s!==void 0&&(a.push({kind:`delegated`,key:s.key,...s.slot===void 0?{}:{slot:s.slot}}),o=Math.max(o,s.at))}return a}function C8(e){if(e.role!==`assistant`)return[];let t=e.continuations??[];if(t.length===0)return e.continuationAt===void 0?[]:[{at:e.continuationAt,key:``}];let n=t.flatMap(e=>e.childRunIds);return[...t.map((e,t)=>({at:e.at,key:String(t),slot:{kind:`batch`,childRunIds:e.childRunIds}})),{at:e.continuationAt??1/0,key:`rest`,slot:{kind:`rest`,claimed:n}}]}function w8(e){try{return typeof e==`string`?e:JSON.stringify(e,null,2)}catch{return String(e)}}function T8(e,t,n,r,i){let{message:a,liveTail:o}=d8(e),s=[],c=[],l=[],u=[],d=[],f=[],p=[],m=null,h=null,g=[],_=M6(a),v=_===null?null:N6(a),y=new Map,b=[],x=new Set((a.rowLayout??[]).flatMap(e=>{let t=e.entryId.lastIndexOf(`:segment:`);return t<0?[]:[e.entryId.slice(t+9)]}));a.parts.forEach((e,t)=>{if(Q3(e)){let n=e.textOmitted?g8(e.textBytes):e.text??``;if(n.trim()===``&&!(e.nature===`thinking`&&e.textCapped===!0))return;if(e.nature===`thinking`){s.push(f8(`p${t}`,{text:n,...e.textCapped===!0?{capped:!0}:{}}));return}let r=e.itemKey??`p${t}`;_===null?e.textOffset===void 0?s.push(m8(r,n)):l.push({offset:e.textOffset,note:{key:r,text:n}}):a.status===`streaming`&&e.itemKey!==void 0&&!x.has(e.itemKey)&&b.push({key:r,text:n})}else if(Y3(e)){let n=v8(a,t,e);u.push(n),v===null?e.textOffset===void 0?c.push(n):l.push({offset:e.textOffset,activity:n}):e.toolCallId!==void 0&&v.cardsOfBlockRows.has(e.toolCallId)?y.set(e.toolCallId,n):(v.rowsWithoutBlocks||a.status===`streaming`)&&c.push(n)}else e.kind===`provenance`?d.push(e):e6(e)?f.push(e):$3(e)?p.push(e):i6(e)&&m===null?m={phase:e.phase,at:e.at,...typeof e.reason==`string`&&e.reason?{reason:e.reason}:{}}:r6(e)?typeof e.text==`string`&&e.text.trim()!==``&&g.push(e.text):n6(e)&&(h={state:e.state,model:e.model,...e.state===`active`&&typeof e.selected==`string`&&e.selected?{selected:e.selected}:{}})});let S=a.status!==`streaming`,C=C8(a),w=C.length>0?S8(a.text??``,l,C,S):l.length>0?s6(a.text??``,l,{settled:S}):a.text&&a.text.length>0?[{kind:`text`,text:a.text}]:[],T=new Set(a.role===`assistant`?a.parts.filter(t6).map(e=>e.viewId):[]),E=a.role===`assistant`&&!S&&w[w.length-1]?.kind===`text`?w.length-1:-1;if(_!==null)for(let e of _)if(e.kind===`thinking`)s.push(f8(`row:${e.entryId}`,{row:{messageId:a._id,entryId:e.entryId}}));else if(e.kind===`text`&&e.commentary===!0)s.push(m8(`row:${e.entryId}`,k6(e.text,T,!1),e.capped===!0));else if(e.kind===`text`)p8(s,e.text,T,!1),e.capped===!0&&s.push({type:`text`,text:`_${ro()}_`});else if(e.kind===`cut`)s.push({type:`text`,text:`_${Na({count:String(e.count)})}_`});else if(e.kind===`file`)s.push(u8(e));else{let t=e.toolCallIds.flatMap(t=>{let n=y.get(t);if(n===void 0)return[];let r=e.parents?.[t];return[r===void 0?n:{...n,parentToolCallId:r}]});t.length>0&&s.push({type:`tool-call`,toolCallId:`flow:${a._id}:row:${e.entryId}`,toolName:`__turn_flow__`,args:{parts:t,rows:!0}})}let D=new Map;(_===null?w:[]).forEach((e,t)=>{e.kind===`text`?a.role===`assistant`?p8(s,e.text,T,t===E):s.push({type:`text`,text:e.text}):e.kind===`note`?s.push(m8(e.key,e.text)):e.kind===`delegated`?s.push({type:`tool-call`,toolCallId:e.key===``?`delegated:${a._id}`:`delegated:${a._id}:${e.key}`,toolName:`__delegated_reply__`,args:e.slot===void 0?{}:{slot:e.slot}}):s.push({type:`tool-call`,toolCallId:(()=>{let t=D.get(e.cut)??0;return D.set(e.cut,t+1),t===0?`flow:${a._id}:${e.cut}`:`flow:${a._id}:${e.cut}:${t}`})(),toolName:`__turn_flow__`,args:{parts:e.parts,...i?.projected===!0?{rows:!0}:{}}})});for(let e of b)s.push(m8(e.key,e.text));o!==null&&p8(s,o,T,!0),h8(s,a.status===`streaming`),a.role===`assistant`&&$6(s,a._id),a.role===`assistant`&&a.parts.forEach(e=>{t6(e)&&s.push({type:`data-widget`,data:{viewId:e.viewId,...e.title===void 0?{}:{title:e.title},...e.preferredHeight===void 0?{}:{preferredHeight:e.preferredHeight}}})});let O=_===null?new Set:F6(a),k=P6(a);a.parts.forEach(e=>{if(X3(e)||Z3(e)){if(e.transcriptFileId!==void 0&&O.has(e.transcriptFileId)||k.has(String(e.storageId)))return;let t=b8(e);t&&s.push(t)}}),s.length===0&&s.push({type:`text`,text:``});let A=a.role===`assistant`?a.status===`streaming`?{type:`running`}:a.status===`complete`?{type:`complete`,reason:`stop`}:a.status===`error`?{type:`incomplete`,reason:`error`,error:a.error??a.errorCode??`error`}:a.status===`aborted`?{type:`incomplete`,reason:`cancelled`}:void 0:void 0;return{id:a._id,role:a.role,createdAt:new Date(a.updatedAt??a._creationTime),...A===void 0?{}:{status:A},content:s,metadata:{custom:{messageId:a._id,authorName:a.authorName??null,mentions:a.mentions??null,importedAgentLabel:n??null,sentAt:a.orderTime??a._creationTime,settledAt:a.finalizedAt??a.updatedAt??null,generationMs:a.role===`assistant`&&(a.status===`complete`||a.status===`aborted`)&&a.orderTime===void 0&&typeof a.finalizedAt==`number`?Math.max(0,a.finalizedAt-a._creationTime):null,chatId:a.chatId,status:a.status,runId:a.runId??null,hasMergedRuns:a.hasMergedRuns??!1,continuationAt:a.continuationAt??null,hasContinuation:C8(a).length>0,answeredChildRunIds:a.role===`assistant`?[...a.followedUpChildRunIds??[]]:[],...(a.displayHidden??[]).some(e=>e.rule===`repeated_text_in_group`)?{repeatWithheld:!0}:{},...i!==void 0&&a.status===`complete`?(()=>{let e=G6(a,i);return e===void 0?{}:{handOff:e}})():{},error:a.error??null,errorCode:a.errorCode??null,autoRetry:a.autoRetry??null,autoRetryOutcome:a.autoRetryOutcome??null,interruptedAt:a.interruptedAt??null,phase:a.phase??null,phaseRetry:a.phaseRetry??null,toolParts:c,allToolParts:u,activeToolName:d$(u)?.name??null,provenanceParts:d,cronParts:f,planParts:p,routedInstanceName:t?.instanceName??a.routedInstanceName??null,routedAgentId:t?.agentId??a.routedAgentId??null,compaction:m,...h===null?{}:{modelFallback:h},...g.length>0?{gatewayNotices:g}:{},...a.interruption===void 0?{}:{interruption:a.interruption},attachedDocCount:a.attachedDocCount??0,queued:a.role===`user`&&a.outbox?.status===`queued`,custody:a.role===`user`?a.custody??null:null,steerSegment:a.steerSegment===!0,groupFollows:r?.follows===!0,groupContinues:r?.continues===!0,groupText:r?.groupText??null,groupFirstId:r?.firstId??null,groupMembers:r?.members??null,rawText:a.text,quotedRefs:a.quotedRefs??null}}}}function E8(e){let t=new Map,n=[],r=()=>{if(n.length>1){let e=n.map(e=>e.text.trim()).filter(e=>e!==``).join(`
145
+
146
+ `),r=n[0]._id,i=n.map(e=>({id:e._id,live:e.status===`streaming`}));n.forEach((a,o)=>{t.set(a._id,{follows:o>0,continues:o<n.length-1,firstId:r,groupText:e,members:i})})}n=[]};for(let t of e)t.role===`assistant`&&t.displayGroupId!==void 0&&n.length>0&&n[n.length-1].displayGroupId===t.displayGroupId||r(),t.role===`assistant`&&t.displayGroupId!==void 0&&n.push(t);return r(),t}function D8(e){let t=e.filter(e=>e.displayGroupId!==void 0);return{key:e.map(e=>e.displayGroupId===void 0?e._id:`${e._id}:${e.displayGroupId}:${e.status===`streaming`?`live`:``}`).join(`|`),texts:t.map(e=>e.status===`streaming`?null:e.text)}}function O8(e,t){if(e===null||e.key!==t.key||e.texts.length!==t.texts.length)return!0;for(let n=0;n<t.texts.length;n++)if(e.texts[n]!==t.texts[n])return!0;return!1}function k8(e){return e?.messageId}var A8=128*1024;function j8(e){let t=e-A8;return t<=0?0:Math.floor(t/4)*3}function M8(e){if(!e||e.length<12)return!1;let t=(t,...n)=>n.every((n,r)=>e[t+r]===n);return t(0,137,80,78,71,13,10,26,10)||t(0,255,216,255)||t(0,71,73,70,56)||t(0,82,73,70,70)&&t(8,87,69,66,80)}var N8=new Set([`image/png`,`image/jpeg`,`image/jpg`,`image/gif`,`image/webp`]);function P8(e){if(typeof e!=`string`)return!1;let t=e.toLowerCase().split(`;`)[0]?.trim()??``;return N8.has(t)}function F8(e){let t=e.split(`;`)[0]?.trim().toLowerCase()??``;return!(t.startsWith(`text/`)||t===`application/json`||t===`application/xml`||t===`image/svg+xml`)||e.toLowerCase().includes(`charset`)?e:`${e}; charset=utf-8`}function I8(){return`att_${Math.random().toString(36).slice(2)}_${Date.now()}`}function yre(e){if(!e)return[];let t=[];for(let n of e){let e=n.convex;e?.storageId&&t.push({storageId:e.storageId,filename:e.filename,mimeType:e.mimeType,...e.origin?{origin:e.origin}:{}})}return t}var bre=`image/*`;async function xre(e){try{return M8(new Uint8Array(await e.slice(0,12).arrayBuffer()))}catch{return!1}}function Sre(e,t,n,r){return{accept:`*`,async add({file:i}){b2();try{let a=null,o=null;try{let t=r?.()??null,i=await e.query(G.bridgeHealth.getBridgeAvailability,n?{chatId:n,...t?{routedAgent:t}:{}}:{});a=i?.maxInboundBytes??null,o=i?.maxInboundImageBytes??null}catch{}let s=a??j8(26214400),c=!1;if(n&&!P8(i.type))try{let t=r?.()??null,i=await e.query(G.bridge.getChatInboundPolicy,{chatId:n,...t?{routedAgent:t}:{}});i?.inboundMediaMode===`shared-fs`&&(s=i.sharedFsMaxBytes,c=!0)}catch{}if(!c&&o!==null&&i.size>o&&i.size<=s&&await xre(i)){let e=ut(),n=Gc({size:jT(i.size,e),max:jT(o,e)});throw t?.(n),Error(n)}if(i.size>s){let e=e=>Math.floor(e/1024/1024),n=Pt({size:e(i.size),max:e(s)});throw t?.(n),Error(n)}return{id:I8(),type:Cre(i.type),name:i.name,contentType:i.type||`application/octet-stream`,file:i,status:{type:`running`,reason:`uploading`,progress:0}}}finally{x2()}},async send(t){let n=t.file;v2.report(t.id,0,n.size||1);try{let r;try{r=await e.mutation(G.chats.generateUploadUrl,{})}catch(e){throw console.error(`[attach] generateUploadUrl failed:`,e),e}let i=await new Promise((e,i)=>{let a=new XMLHttpRequest;a.open(`POST`,r),a.setRequestHeader(`Content-Type`,F8(n.type||`application/octet-stream`)),a.upload.onprogress=e=>{e.lengthComputable&&v2.report(t.id,e.loaded,e.total)},a.onload=()=>{if(a.status>=200&&a.status<300)try{e(JSON.parse(a.responseText).storageId)}catch(e){i(e)}else i(Error(`Upload failed (${a.status})`))},a.onerror=()=>{console.error(`[attach] upload POST failed (network/CORS/CSP)`),i(Error(`Upload failed (network)`))},a.send(n)});return await e.mutation(G.uploads.registerUpload,{storageId:i}),{id:t.id,type:t.type,name:t.name,contentType:t.contentType,status:{type:`complete`},content:[{type:`text`,text:n.name}],convex:{storageId:i,filename:n.name,mimeType:n.type||`application/octet-stream`,...RJ(n)?{origin:`pasted`}:{}}}}finally{v2.clear(t.id)}},async remove(){}}}function Cre(e){return e.startsWith(`image/`)?`image`:`document`}function wre(e){let t=[],n=e.replace(/\r\n/g,`
147
+ `).split(`
148
+
149
+ `),r=n.pop()??``;for(let e of n){if(e.trim()===``)continue;let n={data:``},r=[];for(let t of e.split(`
150
+ `))if(t.startsWith(`id:`)){let e=Number.parseInt(t.slice(3).trim(),10);Number.isFinite(e)&&(n.id=e)}else t.startsWith(`event:`)?n.event=t.slice(6).trim():t.startsWith(`data:`)&&r.push(t.slice(5).trim());n.data=r.join(`
151
+ `),t.push(n)}return{events:t,rest:r}}var Tre={text:``,lastSeq:0,done:!1};function Ere(e){if(e.event===`done`||e.event===`final`||e.data===``)return null;try{let t=JSON.parse(e.data);return typeof t.recTimingId==`string`?t.recTimingId:null}catch{return null}}function Dre(e,t){if(t.event===`done`)return{...e,done:!0};if(t.event===`final`){try{let n=JSON.parse(t.data);if(typeof n.text==`string`)return{...e,text:n.text}}catch{}return e}if(t.data===``)return e;try{let n=JSON.parse(t.data);if(typeof n.text!=`string`)return e;let r=n.kind===`replace`?n.text:e.text+n.text;return{...e,text:r,lastSeq:t.id??e.lastSeq}}catch{return e}}function Ore(){return!1}function kre(e,t,n,r){let i=NE(),a=(0,q.useRef)(r);a.current=r;let[o,s]=(0,q.useState)(null);return(0,q.useEffect)(()=>{let r=e0();if(!n||!e||!i||!r){s(null);return}let o=!1,c=new AbortController,l=Tre;return s(null),(async()=>{for(;!o&&!l.done;){try{let n=await fetch(`${r}/api/v1/message-stream?messageId=${encodeURIComponent(e)}`,{headers:{Authorization:`Bearer ${i}`,...l.lastSeq>0?{"Last-Event-ID":String(l.lastSeq)}:{}},signal:c.signal});if(!n.ok||!n.body){s(null);return}let u=n.body.getReader(),d=new TextDecoder,f=``;for(;!o;){let{value:n,done:r}=await u.read();if(r)break;f+=d.decode(n,{stream:!0});let i=wre(f);f=i.rest;for(let e of i.events){l=Dre(l,e);let t=Ere(e);t!==null&&a.current?.(t,e.id??0)}if(o||s({text:l.text,lastSeq:l.lastSeq,messageId:e,generationKey:t}),l.done)break}}catch{if(o)return;s(null)}if(l.done||o)break;await new Promise(e=>setTimeout(e,500))}})(),()=>{o=!0,c.abort()}},[n,e,i,t]),o}var Are=1e3,L8=2e3,R8=500;function jre(e,t){let n=H(G.messages.getStreamingText,e?{chatId:e}:`skip`),r=U(G.deliveryTiming.recordFrontendTiming),i=U(G.deliveryTiming.calibrateClock),a=(0,q.useRef)(new Map),o=(0,q.useRef)(new Set),s=(0,q.useRef)([]),c=(0,q.useRef)(void 0),l=(0,q.useRef)(!1),u=(0,q.useCallback)(()=>{if(c.current!==void 0||l.current)return;l.current=!0;let e=Date.now();i({clientSentAt:e}).then(t=>{c.current=CC(e,t.serverNow,Date.now())}).catch(()=>{l.current=!1})},[i]);(0,q.useEffect)(()=>{n&&(TC(a.current,wC(n,Date.now()),o.current),a.current.size>0&&u(),o.current.size>0&&!n.some(e=>e.recTimingId!==void 0)&&o.current.clear())},[n,u]),(0,q.useEffect)(()=>{let e=()=>{TC(a.current,t.current??[],o.current),t.current&&(t.current.length=0),a.current.size>0&&u();for(let[e,t]of a.current)s.current.push({timingId:e,t4:t,clientSkew:c.current}),o.current.add(e);a.current.clear(),s.current.length>L8&&s.current.splice(0,s.current.length-L8);let e=DC(s.current,c.current,R8);e!==null&&(s.current.splice(0,e.length),r({samples:e}).catch(()=>{}))},n=window.setInterval(e,Are);return()=>{for(window.clearInterval(n),e();DC(s.current,c.current,R8)!==null;)e()}},[r,t,u])}function z8(e,t){return e===null?{kind:t===`steer`?`steer`:`send`,mode:void 0}:{kind:e,mode:e}}function Mre(e){return e.kind===`queue`?`steer`:`queue`}function B8(e){switch(e){case`queued`:case`steered`:case`cancelled`:case`interrupted`:return e;default:return null}}function Nre(e,t,n){return e!==null&&e>n&&t===`user`}function Pre(e){return e instanceof Error?null:e}function V8(e,t){let n=t===`skip`,r=Og((0,q.useMemo)(()=>t===`skip`?{}:{q:{query:e,args:t}},[Or(e),n?``:JSON.stringify(rr(t)),n])).q;return r instanceof Error&&console.warn(`[follow-up] state unavailable:`,r.message),Pre(r)}function Fre(e,t,n){return!e||t==null?[]:t.sessions.filter(e=>e.count>0&&n<e.until)}function Ire(e){return new Set(e.flatMap(e=>e.sendIds))}function Lre(e,t,n){return e.role===`user`?e.outbox?.status===`queued`||t.has(String(e._id))?`atrium`:e.custody===`queued`&&typeof e.queuedSendId==`string`&&n.has(e.queuedSendId)?`gateway`:`thread`:`thread`}function Rre(e,t){let n=0;for(let r of e){let e=r.sendIds.filter(e=>t.has(e)).length;n+=Math.max(0,r.count-e)}return n}var zre=[];function H8(e){let t=e instanceof Error?e.message:``;return new Set([...t.matchAll(/Invalid: quote target gone \[([^\]]+)\]/g)].map(e=>e[1]))}function U8(e){let t=e instanceof Error?e.message:``;return H8(e).size>0?!1:/Invalid:.*quote/i.test(t)}function W8(e){let t=e instanceof Error?e.message:String(e??``);return t.includes(`agent_mentions_invalid:too_many_agents`)?`too_many`:t.includes(`agent_mentions_invalid:`)||t.includes(`Forbidden: agent is not part of this conversation`)||t.includes(`Forbidden: routed agent is not dispatchable`)?`invalid`:null}function G8(e){return(e instanceof Error?e.message:String(e??``)).includes(`COMMAND_WITH_ATTACHMENTS`)}function Bre({chatId:e}){let t=eo(),n=Iw(),r=U(G.send.sendMessage).withOptimisticUpdate((e,t)=>{let n={chatId:t.chatId},r=e.getQuery(G.messages.listByChat,n)??[],i=`optimistic-${t.clientMessageId}`;if(r.some(e=>e._id===i))return;let a=Date.now(),o={_id:i,chatId:t.chatId,_creationTime:a,orderTime:void 0,role:`user`,status:`complete`,runId:void 0,error:void 0,errorCode:void 0,attachedDocCount:void 0,finalizedAt:void 0,text:t.text,updatedAt:a,routedInstanceName:t.routedAgent?.instanceName??t.agentMentions?.[0]?.instanceName,routedAgentId:t.routedAgent?.agentId??t.agentMentions?.[0]?.agentId,quotedRefs:t.quotes,hasMergedRuns:!1,hasAnnouncePrefix:!1,mergedIntoTurn:void 0,continuationAt:void 0,continuations:void 0,followedUpChildRunIds:void 0,autoRetry:void 0,autoRetryOutcome:void 0,interruptedAt:void 0,parts:[],outbox:null,finalizeCause:void 0,priorFinalizeCauses:void 0,importedAgentLabel:void 0,chatImportedAgentLabel:void 0};e.setQuery(G.messages.listByChat,n,[...r,o])}),i=H(G.messages.listByChat,e?{chatId:e}:`skip`),a=H(G.messages.getStreamingText,e?{chatId:e}:`skip`),o=a&&a.length>0?a[0].messageId:null,s=H(G.messages.getChatStreamTransport,e?{chatId:e}:`skip`)===`sse`||Ore(),c=(0,q.useRef)([]),l=(0,q.useRef)(0),u=(0,q.useCallback)((e,t)=>{t<l.current||c.current.push({timingId:e,t4:Date.now()})},[]),d=a&&a.length>0?a[0].streamRowId??null:null,f=kre(o,d,s,u);l.current=(a?.[0]?.chunkSeq??1)-1,jre(e,c);let p=H(G.agents.getChatAgent,e?{chatId:e}:`skip`),m=H(G.messages.getSessionMeta,e?{chatId:e}:`skip`),g=H(G.agents.listMyAgents,e?{}:`skip`),_=H(G.chatAgents.listChatAgents,e?{chatId:e}:`skip`),v=(_?.viewerRole??m?.viewerRole)===`participant`,y=_?[_.primary,..._.agents].filter(e=>e!==null).map(e=>`${e.instanceName}\0${e.agentId}`).join(`|`):``,b=(0,q.useMemo)(()=>(_?.agents??[]).map(e=>({instanceName:e.instanceName,agentId:e.agentId})),[y]),x=g===void 0||e!==null&&_===void 0,S=(0,q.useMemo)(()=>e!==null&&_===void 0?[]:!v||!_?g??[]:[_.primary,..._.agents].filter(e=>e!==null).map(e=>({instanceName:e.instanceName,agentId:e.agentId,isDefault:e.role===`primary`,displayName:e.displayName,emoji:e.emoji,model:e.model,description:e.description,kind:e.kind,state:e.usable?`ok`:`deleted`})),[e,g,v,y,_]),C=(0,q.useMemo)(()=>M4(S,_?[_.primary,..._.agents]:null),[S,y,_===void 0]),w=p?.multiAgent===!0,T=m?.perTurnRouting===!0,E=w||T,D=(0,q.useMemo)(()=>p?.agent?{instanceName:p.agent.instanceName,agentId:p.agent.agentId}:null,[p?.agent?`${p.agent.instanceName}\0${p.agent.agentId}`:``]),O=(0,q.useMemo)(()=>m?.lastRoutedInstanceName&&m?.lastRoutedAgentId?{instanceName:m.lastRoutedInstanceName,agentId:m.lastRoutedAgentId}:null,[m?.lastRoutedInstanceName&&m?.lastRoutedAgentId?`${m.lastRoutedInstanceName}\0${m.lastRoutedAgentId}`:``]),k=(0,q.useSyncExternalStore)(R3,()=>e?z3(e):zre),A=G3(k).map(e=>`${e.instanceName}\0${e.agentId}`).join(`|`),j=b.length>0,M=i===void 0,N=(0,q.useMemo)(()=>v4(i??[]),[i]),P=(0,q.useMemo)(()=>(i?y4(i):null)??O,[i,O]),F=(0,q.useMemo)(()=>S4({selected:null,lastRouted:P,primary:D,pool:C,poolLoading:x,messagesLoading:M,canRoute:E}),[P,D,C,x,M,E]),I=(0,q.useMemo)(()=>T4({mentioned:G3(k),primary:D,severalAgents:j,perTurnRouting:T,canRoute:E})??null,[A,D,j,T,E]),L=i!==void 0&&i.length===0,R=(0,q.useRef)({primary:null,severalAgents:!1,perTurnRouting:!1,canRoute:!1,nextTarget:null});R.current={primary:D,severalAgents:j,perTurnRouting:T,canRoute:E,nextTarget:I};let z=(0,q.useCallback)(e=>{let t=R.current;if(e.length>0&&t.canRoute)return{agentMentions:e.map(e=>({instanceName:e.instanceName,agentId:e.agentId,start:e.start,end:e.end}))};let n=T4({mentioned:[],primary:t.primary,severalAgents:t.severalAgents,perTurnRouting:t.perTurnRouting,canRoute:t.canRoute});return n?{routedAgent:n}:{}},[]),B=(0,q.useMemo)(()=>Sre(t,e=>n.error(e),e,()=>R.current.nextTarget),[t,n,e]),V=(0,q.useMemo)(()=>{let e=i??[];if(!a||a.length===0)return e;let t=new Map(a.map(e=>[e.messageId,{text:e.text,chunkSeq:e.chunkSeq,phase:e.phase,phaseRetry:e.phaseRetry}]));return e.map(e=>{if(e.status!==`streaming`)return e;let n=e._id,r=t.get(n);if(typeof e.runId==`string`&&e.runId.startsWith(`announce:v1:`)){let t=r?.phase,n=r?.phaseRetry;return t===void 0?e:{...e,phase:t,phaseRetry:n}}if(f!==null&&f.messageId===o&&f.generationKey===d&&n===o){let t=(r?.chunkSeq??1)-1,n=f.lastSeq>=t;return{...e,text:n?f.text:r?.text??f.text,...r?.phase===void 0?{}:{phase:r.phase},...r?.phaseRetry===void 0?{}:{phaseRetry:r.phaseRetry}}}return r===void 0?e:{...e,text:r.text,...r.phase===void 0?{}:{phase:r.phase},...r.phaseRetry===void 0?{}:{phaseRetry:r.phaseRetry}}})},[i,a,f,o]),ee=(0,q.useRef)(new Set),te=V8(G.followUp.followUpState,e?{chatId:e}:`skip`),ne=te?.projection===!0?te.gatewayQueue:null,[,re]=(0,q.useState)(0),ie=(ne?.sessions??[]).map(e=>e.until).filter(e=>e>Date.now()).reduce((e,t)=>e===null||t<e?t:e,null);(0,q.useEffect)(()=>{if(ie===null)return;let e=ie-Date.now();if(e<=0)return;let t=window.setTimeout(()=>re(e=>e+1),e+50);return()=>window.clearTimeout(t)},[ie]);let ae=Fre(te?.projection===!0,ne,Date.now()),oe=Ire(ae),se=[...oe].sort().join(`,`),ce=e=>Lre(e,ee.current,oe),le=e=>ce(e)!==`thread`,ue=V.filter(le).map(e=>{let t=ce(e)===`gateway`;return{messageId:String(e._id),text:e.text,mine:!t&&e.mine!==!1,canCancel:e.mine!==!1||!v,pending:String(e._id).startsWith(`optimistic-`),gateway:t,sendId:e.queuedSendId}}),de=Rre(ae,new Set(ue.flatMap(e=>e.gateway&&e.sendId!==void 0?[e.sendId]:[]))),fe=(0,q.useMemo)(()=>V.filter(e=>!le(e)),[V,se]),pe=fe.length>0?fe[fe.length-1].role:null,me=fe.some(e=>e.status===`streaming`),[he,ge]=(0,q.useState)(null);(0,q.useEffect)(()=>{ge(null)},[e]),(0,q.useEffect)(()=>{pe===`assistant`&&ge(null)},[pe,V]),(0,q.useEffect)(()=>{if(he===null)return;let e=window.setTimeout(()=>ge(null),12e4);return()=>window.clearTimeout(e)},[he]);let _e=te?.projection===!0&&typeof te.workingUntil==`number`?te.workingUntil:null,[,ve]=(0,q.useState)(0);(0,q.useEffect)(()=>{if(_e===null)return;let e=_e-Date.now();if(e<=0)return;let t=window.setTimeout(()=>ve(e=>e+1),e+50);return()=>window.clearTimeout(t)},[_e]);let ye=Nre(_e,pe,Date.now()),be=he!==null||me||ye,xe=ue.length>0&&!me,Se=(0,q.useMemo)(()=>E4(i??[]),[i]),Ce=D8(fe),we=(0,q.useRef)(null);(we.current===null||O8(we.current.inputs,Ce))&&(we.current={inputs:Ce,places:E8(fe)});let Te=we.current.places,Ee=W6(fe,te?.projection===!0),De=(0,q.useRef)(null),Oe=JSON.stringify(Ee);(De.current===null||De.current.key!==Oe)&&(De.current={key:Oe,index:Ee});let ke=De.current.index,Ae=(0,q.useCallback)(e=>T8(e,N.get(e._id)??null,Se.get(e._id)??null,Te.get(e._id)??null,ke),[N,Se,Te,ke]),je=(0,q.useMemo)(()=>({messages:fe,isRunning:be,convertMessage:Ae,onNew:async t=>{if(!e)throw Error(`No chat selected`);let i=t.content.filter(e=>e.type===`text`).map(e=>e.text).join(``),a=yre(t.attachments).map(e=>({storageId:e.storageId,filename:e.filename,mimeType:e.mimeType,...e.origin?{origin:e.origin}:{}})),o=DM(e),{staged:s,mentions:c,agentMentions:l}=W3(e,i),u=c.map(e=>({userId:e.userId,start:e.start,end:e.end})),d=z(l);ge(Date.now());try{await r({chatId:e,text:i,clientMessageId:crypto.randomUUID(),attachments:a,...d,...o.length>0?{quotes:o.map(e=>({messageId:e.messageId,blockIndex:e.blockIndex,excerpt:e.excerpt}))}:{},...u.length>0?{mentions:u}:{}})}catch(t){if(H3(e,s),!U8(t)){let r=kM(e,o,H8(t));r.gone>0&&n.error(yr({count:r.gone})),r.dropped>0&&n.error(ru({count:r.dropped}))}let r=W8(t);throw r!==null&&n.error(r===`too_many`?fm():h()),G8(t)&&n.error(b_()),ge(null),t}},adapters:{attachments:B}}),[V,be,e,r,B,z]),Me=(0,q.useMemo)(()=>({begin:()=>ge(Date.now()),cancel:()=>ge(null)}),[]),Ne=U(G.messages.abortTurn),Pe=U(G.send.cancelQueuedMessage),Fe=U(G.followUp.cancelGatewayQueuedInput),Ie=(0,q.useCallback)(async e=>{try{let t=await Fe({messageId:e});return t.ok||n.error(Rp()),t.ok}catch{return n.error(Rp()),!1}},[Fe,n]),Le=(0,q.useCallback)(async e=>{try{return await Pe({messageId:e}),!0}catch{return n.error(Lv()),!1}},[Pe,n]),Re=(0,q.useCallback)(async(t,i)=>{let a=t.trim();if(!e||a===``)return!1;let o=DM(e),{staged:s,mentions:c,agentMentions:l}=W3(e,t),u=z(l),d=c.map(e=>({userId:e.userId,start:e.start,end:e.end})),f=crypto.randomUUID();i?.immediate!==!0&&ee.current.add(`optimistic-${f}`);try{return await r({chatId:e,text:t,clientMessageId:f,...i?.mode===void 0?{}:{followUpMode:i.mode},...u,...o.length>0?{quotes:o.map(e=>({messageId:e.messageId,blockIndex:e.blockIndex,excerpt:e.excerpt}))}:{},...d.length>0?{mentions:d}:{}}),!0}catch(t){if(H3(e,s),!U8(t)){let r=kM(e,o,H8(t));r.gone>0&&n.error(yr({count:r.gone})),r.dropped>0&&n.error(ru({count:r.dropped}))}let r=t?.message??``,i=W8(t);return n.error(i===`too_many`?fm():i===`invalid`?h():r.includes(`QUEUE_FULL`)?ry():G8(t)?b_():r.includes(`TALK_CALL_ACTIVE`)?Cf():Fh()),!1}},[e,r,n,z]),ze=(0,q.useMemo)(()=>({pool:S,roomAgents:b,multiAgent:w,perTurnRouting:T,emptyThread:L,primary:D,nextTarget:I,messageAgents:N,fallbackAgent:F}),[S,b,w,T,L,D,I,N,F]),Be=(0,q.useCallback)(async()=>{if(e)try{if((await Ne({chatId:e})).ok){ge(null);return}n.error(wa())}catch(e){n.error(Ja(),e)}},[e,Ne,n]);return{runtime:JR(je),turnGate:Me,queueSend:Re,abortTurn:Be,routing:ze,lastUserTurnQueued:xe,queuedTurns:ue,cancelQueued:Le,withdrawGatewayQueued:Ie,gatewayOthers:de,initialLoading:M}}function Vre(e,t,n=-1/0){let r=t.displayGroupId;if(t.role!==`assistant`||r===void 0||r===t._id)return t;let i=e.findIndex(e=>e._id===t._id),a=e.findIndex(e=>e._id===r);if(i<0||a<0||a>=i)return t;let o=e[a];if(o._creationTime!==void 0&&Math.min(o._creationTime,o.orderTime??o._creationTime)<n)return t;for(let n=a;n<i;n++){let i=e[n];if(i.role!==`assistant`||i.displayGroupId!==r)return t}return e[a]}function Hre(e,{messageId:t}){for(let{args:n,value:r}of e.getAllQueries(G.messages.listByChat)){if(r===void 0)continue;let i=r.find(e=>e._id===t);if(i===void 0)continue;let a=Vre(r,i,r.reduce((e,t)=>Math.min(e,t._creationTime),1/0))._creationTime;e.setQuery(G.messages.listByChat,n,r.filter(e=>e._creationTime<a))}}function Ure(e){let t=e instanceof Error?e.message:typeof e?.data==`string`?String(e.data):String(e??``);return/compact_refused|already_active|already_in_flight|deferred_compaction_not_scheduled|below_threshold|already_compacted_recently|unsupported_harness_compaction|no transcript|no sessionId/i.test(t)}function Wre(e){let t=Aa(G.agentFiles.compactSession),n=U(G.chatFork.forkChat),r=H(G.messages.getSessionMeta,{chatId:e.chatId})?.viewerRole===`participant`,[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(null),u=async()=>{a(`compact`),s(null);try{await t({chatId:e.chatId}),l(`compact`),s(su())}catch(e){s(Ure(e)?me():Ll())}finally{a(null)}},d=async()=>{if(e.messageId!==null){a(`branch`),s(null);try{let{chatId:t}=await n({branchMessageId:e.messageId});t3(t,{expand:!0}),l(`branch`),s(fl())}catch{s(Ll())}finally{a(null)}}};return r?null:(0,J.jsxs)(`div`,{className:`oc-error-card__actions`,children:[(0,J.jsx)(K,{type:`button`,size:`sm`,variant:`outline`,disabled:i!==null||c!==null,onClick:()=>void u(),children:i===`compact`?$n():Ti()}),e.messageId===null?null:(0,J.jsx)(K,{type:`button`,size:`sm`,variant:`outline`,disabled:i!==null||c===`branch`,onClick:()=>void d(),children:i===`branch`?$n():On()}),o===null?null:(0,J.jsx)(`p`,{className:`oc-error-card__notice`,role:`status`,children:o})]})}var K8=(0,q.createContext)(!1);function Gre({text:e}){let[t,n]=(0,q.useState)(!1);return(0,J.jsxs)(`details`,{className:`oc-error-card__details`,children:[(0,J.jsx)(`summary`,{children:Lh()}),(0,J.jsx)(`pre`,{children:e}),(0,J.jsxs)(K,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),window.setTimeout(()=>n(!1),1500)})},children:[t?(0,J.jsx)(ZS,{"aria-hidden":!0}):(0,J.jsx)(yC,{"aria-hidden":!0}),t?Kee():Rv()]})]})}function Kre({retry:e}){let[,t]=(0,q.useState)(0);(0,q.useEffect)(()=>{let e=window.setInterval(()=>t(e=>e+1),1e3);return()=>window.clearInterval(e)},[]);let n=Math.max(0,Math.ceil((e.firesAt-Date.now())/1e3));return(0,J.jsxs)(`span`,{className:`oc-error-card__retry`,role:`status`,children:[(0,J.jsx)(oj,{size:13,className:`oc-error-card__retry-spin`,"aria-hidden":!0}),n>0?Ea({attempt:String(e.attempt),max:String(e.maxAttempts),seconds:String(n)}):ng({attempt:String(e.attempt),max:String(e.maxAttempts)})]})}function qre(){let e=o4(),t=$(e=>e.metadata?.custom?.status),n=$(e=>e.metadata?.custom?.runId),r=$(e=>e.metadata?.custom?.error),i=$(e=>e.metadata?.custom?.errorCode),a=$(e=>e.metadata?.custom?.autoRetry??null),o=$(e=>k$(e.metadata?.custom?.autoRetryOutcome)),s=$(e=>e.metadata?.custom?.chatId),c=$(e=>e.metadata?.custom?.messageId??e.id),l=$(e=>D$(e.content)),u=$(e=>e.metadata?.custom?.phase),d=$(e=>e.metadata?.custom?.phaseRetry),f=$(e=>{let t=e.metadata?.custom;return t?.activeToolName??d$(t?.toolParts)?.name??null}),p=f===null?null:{name:f,family:l$(f)},m=(0,q.useContext)(K8),h=$(e=>e.metadata?.custom?.interruptedAt!=null),{byMessage:g}=dS(t===`streaming`&&s?[s]:null),_=f$(t,l,u,p,h,d,g.get(c??``)??null,Date.now()),v=_?.kind===`thinking`,[y,b]=(0,q.useState)(!1);if((0,q.useEffect)(()=>{if(!v){b(!1);return}let e=window.setTimeout(()=>b(!0),6e3);return()=>window.clearTimeout(e)},[v]),!_)return null;if(_.kind===`error`){let{headline:e,detail:t,rawDetail:l,code:u}=E$(r,i),d=u===null?void 0:A$.get(u);return(0,J.jsxs)(`div`,{className:d?`oc-error-card oc-error-card--status`:`oc-error-card`,role:d?`status`:`alert`,title:n?`run ${n}`:void 0,children:[(0,J.jsx)(pA,{size:18,className:`oc-error-card__icon`,"aria-hidden":!0}),(0,J.jsxs)(`div`,{className:`oc-error-card__body`,children:[(0,J.jsx)(`span`,{className:`oc-error-card__title`,children:d?d():_.label}),e?(0,J.jsx)(`span`,{className:`oc-error-card__msg`,children:e}):null,t?(0,J.jsx)(`span`,{className:e?`oc-error-card__msg oc-error-card__msg--detail`:`oc-error-card__msg`,children:t}):null,l?(0,J.jsx)(Gre,{text:l}):null,a?(0,J.jsx)(Kre,{retry:a}):o?(0,J.jsx)(`span`,{className:`oc-error-card__msg oc-error-card__msg--detail`,children:o}):null,u&&m$.has(u)&&s?(0,J.jsx)(Wre,{chatId:s,messageId:c??null}):null]})]})}return(0,J.jsxs)(`div`,{className:`oc-run-status oc-run-status--${_.kind}${_.struggling?` oc-run-status--struggling`:``}`,role:`status`,title:n?`run ${n}`:void 0,children:[_.kind===`thinking`?(0,J.jsxs)(`span`,{className:`oc-dots`,"aria-hidden":!0,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{})]}):_.kind===`generating`?(0,J.jsx)(`span`,{className:`oc-run-status__pulse`,"aria-hidden":!0}):(0,J.jsx)(vj,{size:13,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:_.phased&&!m?`oc-run-status__label oc-shimmer-text`:`oc-run-status__label`,children:p$(_.kind,m)??(_.kind===`thinking`&&y&&!_.phased?c4(e):_.label)})]})}function q8(e,t){return Math.max(0,t-e)}function J8(e,t,n){return e+Math.max(0,n-t)}function Jre(e,t,n){return e?!0:n!==void 0&&t===n}function Y8(e){return Zw(e)}var X8=(0,q.createContext)(null);function Yre(e){return e!==void 0&&e.some(e=>e.status===`streaming`)}function Xre(e,t,n,r){return t===null||n===null||n<=0?!1:!(r?.chatId===e&&r.key===t)}function Zre(){let e=$(e=>e.metadata?.custom?.status),t=$(e=>e.metadata?.custom?.messageId),n=$(e=>e.metadata?.custom?.sentAt),r=Jre(e===`streaming`,(0,q.useContext)(X8)?.messageId??null,t),i=(0,q.useRef)(null);if(r&&t!==void 0&&n!==void 0&&i.current?.id!==t){let e=Date.now();i.current={id:t,baselineMs:q8(n,e),firstLocalMs:e}}let[,a]=(0,q.useState)(0);if((0,q.useEffect)(()=>{if(!r)return;let e=window.setInterval(()=>a(e=>e+1),1e3);return()=>window.clearInterval(e)},[r]),!r||i.current===null||i.current.id!==t)return null;let o=Y8(J8(i.current.baselineMs,i.current.firstLocalMs,Date.now()));return o===null?null:(0,J.jsx)(`div`,{className:`oc-turn-clock`,role:`timer`,children:(0,J.jsx)(`span`,{className:`oc-turn-clock__label`,children:Wb({duration:o})})})}function Qre(e){let t=null;for(let n of e??[]){if(n.role!==`user`)continue;let e=n.orderTime??n._creationTime;e!==void 0&&(t===null||e>t)&&(t=e)}return t}function $re(e,t,n,r){return e===null||n===null||n<=r?!1:!(t!==null&&t>e)}function eie(e,t,n){return!e&&t!==null&&n!==null&&n>0}function tie({chatId:e,projected:t,anyStreaming:n,runningLive:r,deliveringSince:i,deliveringTtlRemainingMs:a,lastUserAt:o,gatewayWorkingUntil:s,runningSince:c=null,now:l=Date.now()}){let[u,d]=(0,q.useState)(null);(0,q.useEffect)(()=>{if(!eie(t,i,a)||i===null||a===null)return;let n=window.setTimeout(()=>d({chatId:e,key:i}),a);return()=>window.clearTimeout(n)},[t,i,a,e]);let[,f]=(0,q.useState)(0);(0,q.useEffect)(()=>{if(!t||s===null)return;let e=s-Date.now();if(e<=0)return;let n=window.setTimeout(()=>f(e=>e+1),e+50);return()=>window.clearTimeout(n)},[t,s]);let p=t?$re(i,o,s,l):Xre(e,i,a,u),m=t?nie(r,c,o):r;return{deliveringFresh:p,showTurnActivity:!n&&(m||p)}}function nie(e,t,n){return e?!(t!==null&&n!==null&&n>t):!1}function rie(e){if(e.writing)return jh();if(e.generationMs!==null&&Number.isFinite(e.generationMs)&&!e.hasToolActivity){let t=Zw(e.generationMs);if(t!==null)return Hee({duration:t})}return ch()}function iie(e){return n8((0,q.useSyncExternalStore)(l8,()=>e===void 0?void 0:o8(e)))}function aie({zone:e,open:t}){let{showTools:n}=T7(),[r,i,a]=$(e=>{let t=e.metadata?.custom;return`${t?.status??``}|${t?.generationMs??``}|${(t?.allToolParts??[]).length}`}).split(`|`),o=rie({writing:e.live&&r===`streaming`,generationMs:i===``?null:Number(i),hasToolActivity:Number(a)>0}),s=t8(e,n);return(0,J.jsx)(`div`,{className:`oc-msg__meta oc-work oc-workhead`,"data-open":t?`true`:`false`,children:(0,J.jsx)(oq,{icon:(0,J.jsx)(dA,{size:14}),label:o,trailing:t?void 0:(0,J.jsx)(`span`,{className:`oc-workhead__steps`,children:s===1?am():gb({count:String(s)})}),open:t,ariaExpanded:t,title:t?Rm():cv(),onClick:()=>c8(e,!t)})})}function Z8(e){let{showTools:t}=T7(),n=iie(e);return{header:e!==void 0&&e8(e,t)?(0,J.jsx)(aie,{zone:e,open:n}):null,folded:e!==void 0&&!n}}function Q8(e){let t=e.map(e=>({card:e,children:[]})),n=new Map;for(let e of t){let{runId:t,callId:r}=e.card;if(t&&r){let i=JSON.stringify([t,r]);n.set(i,n.has(i)?null:e)}}let r=new Map;for(let e of t){let{runId:t,callId:i,parentToolCallId:a}=e.card;if(!t||!a||a===i||i&&n.get(JSON.stringify([t,i]))!==e)continue;let o=n.get(JSON.stringify([t,a]));o&&r.set(e,o)}let i=new Set;for(let e of t){let t=[],n=e;for(;n&&!i.has(n);)i.add(n),t.push(n),n=r.get(n);let a=n?t.indexOf(n):-1;if(a>=0)for(let e of t.slice(a))r.delete(e)}let a=[];for(let e of t){let t=r.get(e);(t?t.children:a).push(e)}return a}function oie(e){let t=new Set,n=Q8(e);for(;n.length>0;){let e=n.pop();e.children.length>0&&e.card.activity?.status===`completed`&&t.add(e.card);for(let t of e.children)n.push(t)}return t}var $8=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:void 0,sie=new Set([`progress_card`,`update_plan`]);function cie(e){return sie.has(e?.trim().toLowerCase()??``)}function lie(e){let t=$8(e);return!!(t&&typeof t.sessionId==`string`&&(t.status===`running`||t.status===`completed`)&&(typeof t.aggregated==`string`||t.persistedDetailsTruncated===!0&&Array.isArray(t.originalDetailKeys)&&t.originalDetailKeys.includes(`aggregated`)))}function uie(e,t={}){if(e.kind===`analysis`)return{...e,hideFromChannelProgress:!0};let n=(e.name??``).toLowerCase(),r=$8($8(t.result)?.details);return e.phase===`end`&&e.status===`completed`&&(n===`exec`||n===`bash`||n===`process`)&&r?.status===`completed`&&r.exitReason!==`manual-cancel`&&typeof r.exitCode==`number`&&Number.isFinite(r.exitCode)&&r.exitCode!==0?{...e,status:`failed`}:(t.nativeOperation===`wait`||t.nativeOperation===`process.poll`||cie(n)||n===`sessions_yield`||n===`process`&&$8(t.args)?.action===`poll`)&&(e.status===`running`||e.status===`completed`)?{...e,hideFromChannelProgress:!0}:e}function e5(e){let t=new Map(e.filter(e=>!e.suppressChannelProgress).map(e=>[e.toolCallId??e.itemId,e])),n={commands:0,reads:0,edits:0,writes:0,searches:0,fetches:0,other:0},r={failed:0,blocked:0,skipped:0,unknown:0},i=0;for(let e of t.values()){if(e.hideFromChannelProgress||e.suppressChannelProgress)continue;let t=(e.name??``).toLowerCase(),a=e.commandBearing?`commands`:die.get(t)??`other`;n[a]+=1,i+=1,e.status===`failed`||e.status===`blocked`||e.status===`skipped`?r[e.status]+=1:e.status||(r.unknown+=1)}return{total:i,counts:n,outcomes:r}}var die=new Map([[`exec`,`commands`],[`bash`,`commands`],[`shell`,`commands`],[`run_command`,`commands`],[`run_terminal_cmd`,`commands`],[`read`,`reads`],[`read_file`,`reads`],[`readfile`,`reads`],[`notebookread`,`reads`],[`notebook_read`,`reads`],[`edit`,`edits`],[`apply_patch`,`edits`],[`applypatch`,`edits`],[`patch`,`edits`],[`edit_file`,`edits`],[`multiedit`,`edits`],[`multi_edit`,`edits`],[`notebookedit`,`edits`],[`notebook_edit`,`edits`],[`write`,`writes`],[`write_file`,`writes`],[`create_file`,`writes`],[`grep`,`searches`],[`glob`,`searches`],[`find`,`searches`],[`ls`,`searches`],[`list`,`searches`],[`codebase_search`,`searches`],[`web_search`,`searches`],[`web_fetch`,`fetches`],[`webfetch`,`fetches`],[`fetch`,`fetches`]]),fie={commands:e=>e===1?Cn():vs({count:String(e)}),reads:e=>e===1?yo():Ga({count:String(e)}),edits:e=>e===1?bg():ce({count:String(e)}),writes:e=>e===1?Hg():Go({count:String(e)}),searches:e=>e===1?Et():Yt({count:String(e)}),fetches:e=>e===1?sl():dte({count:String(e)}),other:e=>e===1?nt():Lc({count:String(e)})},pie={failed:e=>Fte({count:String(e)}),blocked:e=>fp({count:String(e)}),skipped:e=>Xte({count:String(e)}),unknown:e=>zb({count:String(e)})};function mie(e){let t=e5(e),n=Object.entries(t.counts).filter(([,e])=>e>0).map(([e,t])=>fie[e](t)).join(` · `),r=Object.entries(t.outcomes).filter(([,e])=>e>0).map(([e,t])=>({kind:e,label:pie[e](t)}));return{total:t.total,label:n,outcomes:r}}function hie(e,t={}){let n=mie(e);return[n.label,...n.outcomes.filter(({kind:e})=>t.includeInlineOutcomes!==!1||e!==`failed`&&e!==`skipped`).map(({label:e})=>e)].filter(Boolean).join(` · `)||yf()}function t5(e,t){return e==null||t===void 0||t===`streaming`?!1:e.recoveryRunId!==void 0}function gie(e,t){return new Set(t5(e,t)?e?.cutCallIds??[]:[])}function _ie(e,t){return e.some(e=>e.toolCallId!==void 0&&t.has(e.toolCallId)&&e.phase!==`error`&&e.phase!==`completed`&&(e.result===void 0||e.result===null))}function vie(e,t){if(!t5(e,t))return null;let{shutdown:n}=e;return n===`restart`?ms():n===`stop`?go():Ha()}var yie=`block`;function bie(e){return e===`error`?`failed`:e===`completed`?`completed`:`running`}function xie(e){return e?.details}function Sie(e){let t=e.result;if(typeof t==`object`&&t&&!Array.isArray(t)){if(`details`in t)return t;if(`exitCode`in t&&`status`in t)return{details:t}}return e.resultDetails===void 0?void 0:{details:e.resultDetails}}function n5(e,t){let n=e.map(e=>{let t=bie(e.phase),n=Sie(e),r=e.toolName,i=uie({kind:`tool`,name:r,status:t,phase:t===`running`?`start`:`end`},{args:e.args,result:n,...r===`collab.wait`?{nativeOperation:`wait`}:r===`process`&&lie(xie(n))?{nativeOperation:`process.poll`}:{}});return{runId:yie,callId:e.toolCallId,...e.parentToolCallId===void 0?{}:{parentToolCallId:e.parentToolCallId},part:e,activity:i}}),r=e=>({part:e.card.part,children:e.children.map(r)}),i=Q8(n).map(r),a=oie(n),o=n.map(e=>({itemId:e.callId,toolCallId:e.callId,title:e.part.toolName,name:e.part.toolName,status:e.activity.status,...a.has(e)||e.activity.hideFromChannelProgress===!0?{hideFromChannelProgress:!0}:{}}));return{roots:i,visible:n.filter(e=>!a.has(e)).map(e=>e.part),summary:hie(o),failed:e5(o).outcomes.failed}}function r5(e,t,n=0){return n>0||e.some(e=>e.phase===`error`)?`failed`:_ie(e,t)?`interrupted`:`done`}function Cie(e,t){return r5(e,t,n5(e,!0).failed)}var wie={read:lA,exec:bj,search:vC,fetch:jA,write:IC,other:Cj};function i5({node:e,settled:t,cut:n}){let r=e.part;return(0,J.jsx)(bZ,{toolName:r.toolName,args:r.args,argsText:r.argsText,inputFromTranscript:r.inputFromTranscript,result:r.result,status:r.phase?{type:r.phase}:void 0,turnSettled:t,turnInterrupted:r.toolCallId!==void 0&&n.has(r.toolCallId),nested:e.children.length>0?e.children.map(e=>(0,J.jsx)(i5,{node:e,settled:t,cut:n},e.part.toolCallId)):void 0})}function Tie(e){let t=$(e=>e.metadata?.custom?.status),n=$(e=>{let t=e.metadata?.custom;return[...gie(t?.interruption,t?.status)].join(`\0`)}),r=(0,q.useMemo)(()=>new Set(n===``?[]:n.split(`\0`)),[n]),[i,a]=(0,q.useState)(!1),{showTools:o}=T7(),s=Z8(e.args?.zone),c=e.args?.parts??[];if(!o||c.length===0)return null;if(s.folded)return s.header;let l=t===`streaming`&&c.some(e=>u6(e.phase)),u=t!==void 0&&t!==`streaming`,d=e.args?.rows===!0?n5(c,u):null,f=d?.visible??c,p=d===null||l||f.length<=1?f6(d===null||l?c:f,{live:l}):d.summary,m=wie[d6(f)],h=d===null?Cie(c,r):r5(c,r,d.failed),g=l?(0,J.jsx)(OC,{size:13,className:`oc-actrow__status-icon oc-actrow__spin`,"aria-hidden":!0}):(0,J.jsxs)(J.Fragment,{children:[f.length>1?(0,J.jsx)(`span`,{className:`oc-flowact__count`,children:f.length}):null,h===`failed`?(0,J.jsxs)(`span`,{className:`inline-flex items-center`,title:Qs(),children:[(0,J.jsx)(pA,{size:13,className:`oc-actrow__status-icon oc-actrow__status-icon--failed`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`sr-only`,children:Qs()})]}):h===`interrupted`?(0,J.jsxs)(`span`,{className:`inline-flex items-center`,title:_g(),children:[(0,J.jsx)(mA,{size:13,className:`oc-actrow__status-icon`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`sr-only`,children:_g()})]}):(0,J.jsx)(ZS,{size:13,className:`oc-actrow__status-icon`,"aria-hidden":!0})]});return(0,J.jsxs)(J.Fragment,{children:[s.header,(0,J.jsxs)(`div`,{className:`oc-msg__meta oc-work oc-flowact`,role:`group`,"aria-label":gp(),children:[(0,J.jsx)(oq,{icon:(0,J.jsx)(m,{size:14}),label:p,trailing:g,open:i,ariaExpanded:i,title:i?Hs():cx(),onClick:()=>a(!i)}),i&&d!==null?(0,J.jsx)(`div`,{className:`oc-toolact__detail`,children:d.roots.map(e=>(0,J.jsx)(i5,{node:e,settled:u,cut:r},e.part.toolCallId))}):i?(0,J.jsx)(`div`,{className:`oc-toolact__detail`,children:c.map(e=>(0,J.jsx)(bZ,{toolName:e.toolName,args:e.args,argsText:e.argsText,inputFromTranscript:e.inputFromTranscript,result:e.result,status:e.phase?{type:e.phase}:void 0,turnSettled:t!==void 0&&t!==`streaming`,turnInterrupted:e.toolCallId!==void 0&&r.has(e.toolCallId)},e.toolCallId))}):null]})]})}var Eie=`.oc-thread__viewport`;function Die(e){return`${Math.max(0,Math.round(e))}px 0px`}var a5=new WeakMap,o5,Oie=()=>typeof IntersectionObserver>`u`?void 0:(e,t)=>new IntersectionObserver(e,t),kie=(e,t)=>{if(typeof ResizeObserver>`u`)return()=>{};let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()};function s5(e){return e===null?typeof window>`u`?0:window.innerHeight:e.clientHeight}function Aie(e,t,n){let r=new Map,i=s5(e),a=()=>t(e=>{for(let t of e)r.get(t.target)?.(t.isIntersecting)},{root:e,rootMargin:Die(i)}),o=a(),s=e===null?()=>{}:n(e,()=>{let t=s5(e);if(t!==i){i=t,o.disconnect(),o=a();for(let e of r.keys())o.observe(e)}});return{told:r,stop:()=>{s(),o.disconnect()},observer:()=>o}}function jie(e,t,n=Oie(),r=kie){if(n===void 0)return t(!0),()=>{};let i=e.closest(Eie),a=i===null?o5:a5.get(i);a===void 0&&(a=Aie(i,n,r),i===null?o5=a:a5.set(i,a));let o=a;return o.told.set(e,t),o.observer().observe(e),()=>{o.told.delete(e),o.observer().unobserve(e),!(o.told.size>0)&&(o.stop(),i===null?o5=void 0:a5.delete(i))}}function Mie(e){let[t,n]=(0,q.useState)(()=>typeof IntersectionObserver>`u`);return(0,q.useEffect)(()=>{let t=e.current;if(t!==null)return jie(t,n)},[e]),t}function Nie(e,t){return e?t:`skip`}function Pie(e,t,n){return t===void 0?n!==void 0&&n.row===e?n:void 0:{row:e,value:t}}function Fie({data:e}){let t=e?.row,n=e?.capped===!0,r=(e?.text??``).trim(),{header:i,folded:a}=Z8(e?.zone),o=(0,q.useRef)(null);return X6(e)?(0,J.jsxs)(J.Fragment,{children:[i,a?null:(0,J.jsxs)(`div`,{ref:o,className:`oc-msg__meta oc-work oc-thinking`,role:`region`,"aria-label":See(),children:[t===void 0?r===``?null:(0,J.jsx)(sJ,{text:r}):(0,J.jsx)(Iie,{block:o,messageId:t.messageId,entryId:t.entryId}),n?(0,J.jsx)(`p`,{className:`oc-thinking__status`,children:z_()}):null]})]}):null}function Iie({block:e,messageId:t,entryId:n}){let r=Mie(e),i=H(G.messages.getRowReasoning,Nie(r,{messageId:t,entryId:n})),a=(0,q.useRef)(void 0);a.current=Pie(`${t}:${n}`,i,a.current);let o=a.current?.value;return o===void 0?(0,J.jsx)(`p`,{className:`oc-thinking__status`,"data-reasoning":`unread`,children:Pp()}):o===null?(0,J.jsx)(`p`,{className:`oc-thinking__status`,children:Sy()}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(sJ,{text:o.text}),o.truncated===!0?(0,J.jsx)(`p`,{className:`oc-thinking__status`,children:z_()}):null]})}function Lie({data:e}){let t=(e?.text??``).trim(),{header:n,folded:r}=Z8(e?.zone);return Z6(e?.text)?(0,J.jsxs)(J.Fragment,{children:[n,r?null:(0,J.jsxs)(`div`,{className:`oc-msg__meta oc-work oc-msg__note`,role:`note`,"aria-label":Vf(),children:[(0,J.jsx)(sJ,{text:t}),e?.capped===!0?(0,J.jsx)(`p`,{className:`oc-thinking__status`,children:ro()}):null]})]}):null}var c5=(0,q.createContext)(null);function Rie(){let e=(0,q.useContext)(c5),t=zV(),n=SV(),r=(0,q.useRef)(null),i=e?.gatewayOthers??0,a=(e?.queuedTurns.length??0)+ +(i>0);if((0,q.useLayoutEffect)(()=>{let e=r.current,t=document.querySelector(`.oc-thread__viewport`);if(!t)return;if(!e||a===0){t.style.removeProperty(`--oc-dock-pad`);return}let i=()=>{},o=()=>{let r=`${e.offsetHeight}px`;t.style.getPropertyValue(`--oc-dock-pad`)!==r&&(t.style.setProperty(`--oc-dock-pad`,r),i(),i=zK(t,n))};o();let s=new ResizeObserver(o);return s.observe(e),()=>{i(),s.disconnect(),t.style.removeProperty(`--oc-dock-pad`)}},[a,n]),e===null||a===0)return null;let{queuedTurns:o,cancelQueued:s,withdrawGatewayQueued:c,canWithdrawGateway:l}=e;return(0,J.jsxs)(`div`,{ref:r,className:`oc-queue-dock`,role:`status`,"aria-label":iy(),children:[o.map(e=>e.gateway===!0?(0,J.jsxs)(`div`,{className:`oc-queue-card oc-queue-card--gateway`,children:[(0,J.jsx)(PA,{size:16,"aria-hidden":!0,className:`oc-queue-card__icon`}),(0,J.jsx)(`span`,{className:`oc-queue-card__text`,title:e.text,children:e.text}),(0,J.jsx)(`span`,{className:`oc-queue-card__state`,children:Qd()}),e.canCancel&&l===!0&&c?(0,J.jsx)(`button`,{type:`button`,className:`oc-queue-card__btn oc-queue-card__btn--danger`,title:jm(),"aria-label":jm(),disabled:e.pending,onClick:()=>void c(e.messageId),children:(0,J.jsx)(WC,{size:15})}):null]},e.messageId):(0,J.jsxs)(`div`,{className:`oc-queue-card`,children:[(0,J.jsx)(yA,{size:16,"aria-hidden":!0,className:`oc-queue-card__icon`}),(0,J.jsx)(`span`,{className:`oc-queue-card__text`,title:e.text,children:e.text}),e.mine?(0,J.jsx)(`button`,{type:`button`,className:`oc-queue-card__btn`,title:wf(),"aria-label":wf(),disabled:e.pending,onClick:()=>{s(e.messageId).then(n=>{n&&t.composer.setText(e.text)})},children:(0,J.jsx)(IC,{size:15})}):null,e.canCancel?(0,J.jsx)(`button`,{type:`button`,className:`oc-queue-card__btn oc-queue-card__btn--danger`,title:Ih(),"aria-label":Ih(),disabled:e.pending,onClick:()=>void s(e.messageId),children:(0,J.jsx)(WC,{size:15})}):null]},e.messageId)),i>0?(0,J.jsxs)(`div`,{className:`oc-queue-card oc-queue-card--gateway oc-queue-card--others`,children:[(0,J.jsx)(PA,{size:16,"aria-hidden":!0,className:`oc-queue-card__icon`}),(0,J.jsx)(`span`,{className:`oc-queue-card__text`,children:x_({count:String(i)})})]}):null]})}var l5=(0,q.createContext)(!1);function u5(e){let t=V8(G.followUp.followUpState,{chatId:e});return t==null||t.projection!==!0?null:{preference:t.preference??null,serverMode:t.serverMode??null,workingUntil:typeof t.workingUntil==`number`?t.workingUntil:null}}function zie({chatId:e,queueSend:t}){let n=u5(e),r=U(G.followUp.setFollowUpMode),i=IV(),a=LV(e=>e.text).trim().length>0,o=z8(n?.preference??null,n?.serverMode??null),s=e=>{if(t===null)return;let n=i.getState().text;n.trim()!==``&&t(n,e).then(e=>{e&&i.setText(``)})},c=o.kind===`queue`?Cg():o.kind===`steer`?at():kt();return(0,J.jsxs)(`div`,{className:`oc-composer__followup`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__send`,disabled:!a||t===null,"aria-label":o.kind===`queue`?k():o.kind===`steer`?Co():xr(),title:a?c:eg(),onClick:()=>s(o.mode),children:(0,J.jsx)(oA,{size:18,"aria-hidden":!0})}),(0,J.jsxs)(hC,{children:[(0,J.jsx)(oC,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn oc-composer__followup-menu`,"aria-label":Bc(),title:Bc(),children:(0,J.jsx)(QS,{size:14,"aria-hidden":!0})})}),(0,J.jsxs)(dC,{align:`end`,side:`top`,className:`w-64`,children:[(0,J.jsxs)(pC,{disabled:!a,onClick:()=>s(`steer`),children:[(0,J.jsx)(yA,{}),` `,Ub()]}),(0,J.jsxs)(pC,{disabled:!a,onClick:()=>s(`queue`),children:[(0,J.jsx)(UA,{}),` `,Le()]}),(0,J.jsxs)(pC,{disabled:!a,onClick:()=>s(`interrupt`),children:[(0,J.jsx)(tj,{}),` `,_c()]}),(0,J.jsx)(mC,{}),(0,J.jsx)(uC,{children:mte()}),(0,J.jsxs)(aC,{value:n?.preference??`server`,onValueChange:e=>void r({mode:e===`server`?null:e}),children:[(0,J.jsx)(fC,{value:`server`,children:Kf()}),(0,J.jsx)(fC,{value:`steer`,children:Lte()}),(0,J.jsx)(fC,{value:`queue`,children:yb()})]})]})]})]})}function Bie({custody:e,messageId:t,canWithdraw:n}){let r=B8(e),i=U(G.followUp.cancelGatewayQueuedInput),a=Iw();if(r===null)return null;let o=r===`queued`?Qd():r===`steered`?Vm():r===`cancelled`?dh():Tee();return(0,J.jsxs)(`span`,{className:`oc-msg__custody oc-msg__custody--${r}`,role:`status`,children:[r===`queued`?(0,J.jsx)(_C,{size:12,"aria-hidden":!0}):r===`steered`?(0,J.jsx)(yA,{size:12,"aria-hidden":!0}):(0,J.jsx)(tj,{size:12,"aria-hidden":!0}),o,r===`queued`&&n?(0,J.jsx)(`button`,{type:`button`,className:`oc-msg__custody-action`,"aria-label":jm(),onClick:()=>void i({messageId:t}).then(e=>{e.ok||a.error(Rp())},()=>a.error(Rp())),children:U_()}):null]})}function Vie(){let e=$(e=>e.metadata?.custom?.toolParts),t=$(e=>e.metadata?.custom?.status),[n,r]=(0,q.useState)(!1);if(!e||e.length===0)return null;let i=n,a=_Z(e,t),o=a.running?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(OC,{size:13,className:`oc-actrow__status-icon oc-actrow__spin`,"aria-hidden":!0}),Pl()]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ZS,{size:13,className:`oc-actrow__status-icon`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-sr-only`,children:de()})]});return(0,J.jsxs)(`div`,{className:`oc-toolact`,children:[(0,J.jsx)(oq,{icon:(0,J.jsx)(Cj,{size:14}),label:a.label,trailing:o,open:i,ariaExpanded:i,title:i?Hs():cx(),onClick:()=>r(!i)}),i?(0,J.jsx)(`div`,{className:`oc-toolact__detail`,children:e.map(e=>(0,J.jsx)(bZ,{toolName:e.toolName,args:e.args,argsText:e.argsText,inputFromTranscript:e.inputFromTranscript,result:e.result,status:e.phase?{type:e.phase}:void 0,turnSettled:t!==void 0&&t!==`streaming`},e.toolCallId))}):null]})}function d5(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function f5(e){if(!d5(e))return null;let t=e.details;if(d5(t)&&typeof t.status==`string`)return t.status;if(typeof e.status==`string`)return e.status;for(let t of[`content`,`contentItems`]){let n=e[t];if(Array.isArray(n)){for(let e of n)if(!(!d5(e)||typeof e.text!=`string`))try{let t=JSON.parse(e.text);if(d5(t)&&typeof t.status==`string`)return t.status}catch{}}}return null}function Hie(e,t){if(e!==`completed`)return!1;let n=f5(t);return n===null||n===`yielded`}var Uie=18e4,Wie=3e4;function p5(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function m5(e){let t=[];for(let n of e){if(n.toolName!==`sessions_spawn`)continue;let e=n.resultDetails?.childSessionKey;if(typeof e==`string`&&e!==``){t.push(e);continue}let r=n.result;if(!p5(r))continue;let i=r.details?.childSessionKey;if(typeof i==`string`&&i!==``){t.push(i);continue}let a=Array.isArray(r.content)?r.content:Array.isArray(r.contentItems)?r.contentItems:null;if(a!==null)for(let e of a){let n=p5(e)?e.text:void 0;if(typeof n==`string`)try{let e=JSON.parse(n),r=p5(e)?e.childSessionKey:void 0;typeof r==`string`&&r!==``&&t.push(r)}catch{}}}return t}var h5=new Set([`sessions_spawn`,`delegate_task`,`mixture_of_agents`]),Gie=new Set([`accepted`,`ok`,`started`,`running`]);function Kie(e){return e.some(e=>{if(!h5.has(e.toolName))return!1;let t=f5(e.resultDetails??e.result);return t===`error`||t===`forbidden`?!1:m5([e]).length>0?!0:e.phase===`error`?!1:t===null||Gie.has(t)})}function qie(e){return e.some(e=>h5.has(e.toolName))}function g5(e){return e.some(e=>{let t=e.result;if(typeof t!=`object`||!t)return!1;let n=t.details;if(typeof n!=`object`||!n)return!1;let r=n;return r.async===!0&&typeof r.taskId==`string`})}function _5(e){return e?.trim()||void 0}function v5(e,t,n,r){let i=e.childRunId;return i===void 0?!1:(r??[]).includes(i)?!0:n!==void 0&&t.some(e=>e.parentMessageId===n&&e.kind!==`task`&&(e.status===`running`||e.status===`done`)&&(V6(e.bornOfRun)?.childRunIds.includes(i)??!1))}function Jie(e,t,n,r){let i=e.filter(e=>e.status===`error`&&!v5(e,t,n,r)),a=i[0];return a===void 0?null:{task:R$(a),reason:i1(a.errorMessage,a.errorCode,a.runTimeoutSeconds),more:i.length-1}}function y5(e,t,n,r,i=Date.now()){let a=n??[],o=e.hasText||e.hasMedia,s=t.some(e=>e.toolName===`sessions_yield`&&Hie(e.phase,e.resultDetails??e.result))&&(Kie(t)||g5(t));if(o&&!s||e.status!==`complete`)return{kind:`none`};let c=new Set(m5(t)),l=a.filter(e=>r!==void 0&&e.parentMessageId===r||c.has(e.childSessionKey)),u=l.find(e=>e.status===`running`);if(u)return{kind:`waiting`,taskName:_5(u.taskName)};let d=l.filter(e=>e.kind!==`task`),f=d.find(t=>(t.status===`error`||t.status===`aborted`)&&!v5(t,a,r,e.answeredChildRunIds));if(f)return{kind:`failed`,taskName:_5(f.taskName),reason:i1(f.errorMessage,f.errorCode,f.runTimeoutSeconds),...f.status===`aborted`&&f.stopRequestedAt===void 0?{cardSilent:!0}:{}};if(o)return{kind:`none`};let p=d.find(e=>e.status===`done`);if(p&&e.projected===!0){let t=t=>t.childRunId!==void 0&&(e.resumedChildRunIds??[]).includes(t.childRunId)||(e.resumedChildKeys??[]).includes(t.childSessionKey),n=d.filter(e=>e.status===`done`);return e.laterUserTurn===!0||n.every(t)?{kind:`none`}:{kind:`composing`,taskName:_5(n.find(e=>!t(e))?.taskName)}}if(p){let t=p.updatedAt+Uie;return i<t?{kind:`composing`,taskName:_5(p.taskName),recheckAt:t}:e.delegatedInline===!0?{kind:`none`}:{kind:`done`,taskName:_5(p.taskName),resultText:p.resultText,agentId:P$(p.childSessionKey)}}if(s&&l.length===0){if(n===void 0)return{kind:`none`};if(e.settledAt!==void 0){let t=e.settledAt+Wie;if(i<t)return{kind:`waiting`,recheckAt:t}}}return{kind:`generic`}}function Yie(e,t,n){return e===void 0||t===void 0?[]:e.filter(e=>e.parentMessageId===t&&e.kind!==`task`&&e.status===`done`&&typeof e.resultText==`string`&&e.resultText.trim()!==``&&Xie(e,n)).slice().sort((e,t)=>e.createdAt-t.createdAt).map(e=>({childSessionKey:e.childSessionKey,agentId:P$(e.childSessionKey),resultText:e.resultText}))}function Xie(e,t){if(t===void 0)return!0;let n=e.childRunId;return t.kind===`batch`?n!==void 0&&t.childRunIds.includes(n):n===void 0||!t.claimed.includes(n)}function b5(e,t){return e===`done`?xm({count:t}):e===`running`?S({count:t}):Is({count:t})}function Zie({card:e}){let t=e.tone===`running`?OC:e.tone===`failed`?pA:e.tone===`aborted`?hA:ZS,n=(0,q.useContext)(l1),r=e.tools?.length??0,i=n?.activeChildKey===e.childSessionKey,a=(0,J.jsxs)(J.Fragment,{children:[r>0?(0,J.jsx)(`span`,{className:`oc-actrow__toolcount`,children:r===1?Hl({count:r}):be({count:r})}):null,(0,J.jsx)(t,{size:13,className:`oc-actrow__status-icon${e.tone===`running`?` oc-actrow__spin`:``}`,"aria-hidden":!0})]});return(0,J.jsxs)(`div`,{className:`oc-subagent oc-subagent--${e.tone}${e.moaRole===`moa_reference`?` oc-subagent--nested`:``}`,children:[(0,J.jsx)(oq,{tone:e.tone,icon:e.isTask?(0,J.jsx)(PC,{size:15}):(0,J.jsx)(kS,{size:15}),label:e.isTask?e.label:L$(e),sublabel:e.isTask?void 0:e.taskName,trailing:a,active:i,ariaExpanded:e.isTask?void 0:i,ariaHasPopup:!e.isTask,title:e.isTask?void 0:Vb(),ariaLabel:e.isTask?void 0:Vb(),inert:e.isTask,onClick:()=>{e.isTask||n?.openFor(e.childSessionKey)}}),e.failure?(0,J.jsx)(`p`,{className:`oc-subagent__error`,role:`status`,children:i1(e.errorMessage,e.errorCode,e.runTimeoutSeconds)}):null]})}var Qie=[],$ie=[];function eae(){let e=$(e=>e.metadata?.custom?.chatId),t=$(e=>{let t=e.metadata?.custom;return t?.allToolParts??t?.toolParts??Qie}),n=(0,q.useMemo)(()=>m5(t),[t]),r=(0,q.useMemo)(()=>qie(t)||g5(t),[t]),i=$(e=>e.metadata?.custom?.messageId),a=$(e=>e.metadata?.custom?.answeredChildRunIds??$ie),o=r&&e?e:null,{can:s}=kT(o),c=H(G.subAgents.listSubAgents,o?{chatId:o}:`skip`),[l,u]=(0,q.useState)(!1);if(!r||!s(`subagents`))return null;let d=X$(c??[],n,i),f=J$(d),p=[...f.cards];if(p.length===0)return null;let m=Y$(f),h=m.length>0&&!l?Jie([...d].sort((e,t)=>t.createdAt-e.createdAt),c??[],i,a):null;return(0,J.jsxs)(`div`,{className:`oc-msg-subagents`,children:[m.length>0?(0,J.jsx)(oq,{icon:(0,J.jsx)(kS,{size:15}),label:Z$(f.total),trailing:m.map(e=>(0,J.jsxs)(`span`,{className:`oc-subagent-badge oc-subagent-badge--${e.tone}`,title:b5(e.tone,e.count),"aria-label":b5(e.tone,e.count),children:[e.tone===`done`?(0,J.jsx)(ZS,{size:12,"aria-hidden":!0}):e.tone===`running`?(0,J.jsx)(OC,{size:12,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,J.jsx)(pA,{size:12,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-subagent-badge__count`,children:e.count})]},e.tone)),open:l,ariaExpanded:l,title:l?Hs():cx(),onClick:()=>u(!l)}):null,h?(0,J.jsxs)(`p`,{className:`oc-subagent__error`,role:`status`,children:[Kd({task:h.task,reason:h.reason}),h.more>0?` ${Ju({count:String(h.more)})}`:null]}):null,(m.length===0||l)&&p.map(e=>(0,J.jsx)(`div`,{className:`oc-msg-subagents__anchor`,"data-subagent-id":e.id,"data-subagent-failed":e.failure?``:void 0,children:(0,J.jsx)(Zie,{card:e})},e.id))]})}function tae(){return $(e=>e.metadata?.custom?.compaction??null)}function nae(e){switch(e){case`overflow`:return kl();case`manual`:return eu();case`heap_threshold`:case`rss_threshold`:case`pre_compaction`:case`non_manual_trigger`:return gr();case`already_active`:case`already_in_flight`:case`deferred_compaction_not_scheduled`:case`unsupported_harness_compaction`:return Me();default:return``}}function rae(){let e=tae();if(!e)return null;let t=e.phase===`failed`,n=`${t?Cu():e.phase===`midturn`?Ui():Av()}${nae(e.reason)}`;return(0,J.jsx)(ew,{delayDuration:150,children:(0,J.jsxs)(nw,{children:[(0,J.jsx)(ZC,{asChild:!0,children:(0,J.jsxs)(`div`,{className:`oc-compaction${t?` oc-compaction--failed`:``}`,role:`note`,"aria-label":n,children:[(0,J.jsx)(`span`,{className:`oc-compaction__rule`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{className:`oc-compaction__label`,children:[(0,J.jsx)(OA,{size:12,"aria-hidden":!0}),t?Wn():gi()]}),(0,J.jsx)(`span`,{className:`oc-compaction__rule`,"aria-hidden":!0})]})}),(0,J.jsx)(QC,{className:`oc-compaction__tip`,children:n})]})})}function iae(e){return!e||typeof e.model!=`string`||e.model.trim()===``?null:e.state===`cleared`?{cleared:!0,label:uc({model:e.model}),detail:null}:e.state===`active`?{cleared:!1,label:wx({model:e.model}),detail:typeof e.selected==`string`&&e.selected.trim()!==``?_a({model:e.selected}):null}:null}function aae(){let e=iae($(e=>e.metadata?.custom?.modelFallback??null));if(e===null)return null;let t=(0,J.jsxs)(`div`,{className:`oc-compaction oc-model-fallback`,role:`note`,"aria-label":e.detail===null?e.label:`${e.label} — ${e.detail}`,children:[(0,J.jsx)(`span`,{className:`oc-compaction__rule`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{className:`oc-compaction__label`,children:[e.cleared?(0,J.jsx)(ZS,{size:12,"aria-hidden":!0}):(0,J.jsx)(mj,{size:12,"aria-hidden":!0}),e.label]}),(0,J.jsx)(`span`,{className:`oc-compaction__rule`,"aria-hidden":!0})]});return e.detail===null?t:(0,J.jsx)(ew,{delayDuration:150,children:(0,J.jsxs)(nw,{children:[(0,J.jsx)(ZC,{asChild:!0,children:t}),(0,J.jsx)(QC,{className:`oc-compaction__tip`,children:e.detail})]})})}function oae(){let e=$(e=>e.metadata?.custom?.gatewayNotices);return!Array.isArray(e)||e.length===0?null:(0,J.jsx)(`div`,{className:`oc-gateway-notices`,role:`note`,"aria-label":Ur(),children:e.map((e,t)=>(0,J.jsx)(`p`,{className:`oc-gateway-notices__line`,children:e},t))})}function sae(){let e=$(e=>{let t=e.metadata?.custom;return vie(t?.interruption,t?.status)});return e===null?null:(0,J.jsx)(`div`,{className:`oc-gateway-notices`,role:`note`,"aria-label":yn(),children:(0,J.jsx)(`p`,{className:`oc-gateway-notices__line`,children:e})})}var cae=new Set([`widget`,`commentary`,`thinking`]);function lae(e,t){return e&&!D$(t)&&!t.some(e=>e?.type===`file`||e?.type===`data`&&cae.has(e.name))}var uae=/^(?:[a-z0-9][a-z0-9_.]{0,15}-)?[a-z0-9]{25,40}$/;function dae(e){let t=e.trim();return uae.test(t)?t:null}function fae(e){return e.readOnly?`read_only`:e.unavailable?`unavailable`:e.degraded?`degraded`:e.beyondValidated?`beyond_validated`:null}function pae(e){return e.turnRunning?{mode:`queue`,reason:`turn`}:e.hasRunningSubAgent?{mode:`queue`,reason:`subagent`}:{mode:`send`,reason:null}}function x5(e,t){return e||t?`always`:`hover`}function S5(e){return!e}function C5(e){let t=document.querySelector(`.oc-msg[data-message-id="${CSS.escape(e)}"] .oc-msg__body`);return t===null?null:dK(t).map(pK)}function mae(e,t){let n=e.map(e=>({messageId:e,faces:C5(e)??[]}));return{choices:EK(n,t),seen:new Map(n.map(e=>[e.messageId,e.faces.map(e=>e.print)]))}}function w5(e,t){let n=document.querySelector(`.oc-msg[data-message-id="${CSS.escape(e)}"]`),r={composer:document.querySelector(`.oc-composer__input`),trigger:n?.querySelector(`.oc-msg__actions [aria-haspopup="menu"]`)??null,message:n};return AK(t).map(e=>r[e])}var hae={quote:{title:yg,desc:se,empty:Vg},bookmark:{title:Tt,desc:Jt,empty:ol}};function T5({open:e,onOpenChange:t,messageId:n,sources:r,kind:i,marked:a,onPick:o}){let[s,c]=(0,q.useState)([]),l=(0,q.useRef)(new Map),[u,d]=(0,q.useState)(``),f=(0,q.useMemo)(()=>iK(d,aK),[]);(0,q.useEffect)(()=>()=>f.clear(),[f]);let p=(0,q.useRef)(!1),m=(0,q.useRef)(!1),[h,g]=(0,q.useState)(!1),_=r.join(` `),v=(0,q.useCallback)(()=>{let e=mae(_===``?[]:_.split(` `),i);l.current=e.seen,c(e.choices)},[_,i]);(0,q.useEffect)(()=>{f.clear(),e&&(p.current=!1,v())},[e,v,f]);let y=async e=>{if(m.current)return;let n=TK(e,i,l.current.get(e.messageId)??null,C5(e.messageId)?.map(e=>e.print)??null,a);if(n===null){v(),f.say(et());return}m.current=!0,g(!0);let r;try{r=await o({...e,blockIndex:n})}finally{m.current=!1,g(!1)}if(r!==null){v(),f.say(r);return}p.current=!0,t(!1)};(0,q.useEffect)(()=>{if(e||!p.current||i!==`quote`)return;let[t]=w5(n,!0);Sf([t])},[e,i,n]);let b=hae[i];return(0,J.jsx)(rT,{open:e,onOpenChange:t,children:(0,J.jsxs)(eT,{className:`oc-blockpick`,returnFocus:()=>w5(n,p.current&&i===`quote`),children:[(0,J.jsxs)(Qw,{children:[(0,J.jsx)(tT,{children:b.title()}),(0,J.jsx)(nT,{children:b.desc()})]}),(0,J.jsx)(`p`,{className:`oc-blockpick__changed`,role:`status`,children:u}),s.length===0?(0,J.jsx)(`p`,{className:`oc-blockpick__empty`,children:b.empty()}):(0,J.jsx)(`div`,{className:`oc-blockpick__list`,"aria-busy":h||void 0,children:s.map(e=>{let t=i===`bookmark`&&(a?.has(OK(e.messageId,e.blockIndex))??!1);return(0,J.jsxs)(K,{type:`button`,variant:`ghost`,className:`oc-blockpick__item h-auto w-full justify-start whitespace-normal text-left`,"data-message-id":e.messageId,"data-block-index":e.blockIndex,"aria-pressed":i===`bookmark`?t:void 0,onClick:()=>y(e),children:[i===`bookmark`?(0,J.jsx)(uA,{className:`oc-blockpick__mark`+(t?` is-set`:``),"aria-hidden":!0}):null,e.label===``?ute():e.label]},OK(e.messageId,e.blockIndex))})})]})})}function gae(e){if(e.metaWidth===0)return null;let t=Cne(Array.from(e.titleBlock.children));return{available:e.headWidth-Math.min(t,360)-16,required:[e.metaWidth]}}var _ae=[`hold`,`expand`,`talk-settings`,`perm`,`tools`,`room-settings`,`talk`,`mic`],vae=[`tools`,`room-settings`,`hold`,`expand`,`mic`,`talk`,`perm`,`talk-settings`];function yae(e){let t={hold:e.hold,expand:e.expand,"talk-settings":e.talkSettings,perm:e.perm,tools:e.tools,"room-settings":e.roomSettings,talk:e.talkStart,mic:e.mic&&!e.recording};return _ae.filter(e=>t[e])}function bae(e){let t=[{labels:!0,moved:[]},{labels:!1,moved:[]}];for(let n=1;n<=e.length;n++)t.push({labels:!1,moved:e.slice(0,n)});return t}function xae(e,t){return e[Math.min(t,e.length-1)]}function E5(e){return{"data-labels":e.labels?`on`:`off`,"data-moved":e.moved.join(` `)}}function Sae(e,t,n){return t===`pending`?Oe({name:e}):t===`gone`?rne({name:e}):n===`too_large`?oc({name:e}):n===`media_disabled`?pa({name:e}):n===`remote_source`?zr({name:e}):hn({name:e})}function Cae({mimeType:e,data:t,filename:n,storageId:r,unavailable:i,reason:a}){let o=e??``,s=t??``,c=n??`attachment`;return i===void 0?s?o.startsWith(`audio/`)?(0,J.jsxs)(`div`,{className:`oc-media oc-media--audio`,children:[(0,J.jsx)(`audio`,{controls:!0,preload:`metadata`,src:s,className:`oc-media__audio`,children:(0,J.jsx)(`a`,{href:s,download:c,children:Xl()})}),(0,J.jsx)(`span`,{className:`oc-media__name`,children:c})]}):o.startsWith(`image/`)?(0,J.jsx)(Eae,{url:s,name:c}):o.startsWith(`video/`)?(0,J.jsxs)(`div`,{className:`oc-media oc-media--video`,children:[(0,J.jsx)(`video`,{controls:!0,preload:`metadata`,src:s,className:`oc-media__video`}),(0,J.jsx)(`span`,{className:`oc-media__name`,children:c})]}):(0,J.jsx)(wae,{url:s,name:c,mime:o,storageId:r}):null:(0,J.jsxs)(`div`,{className:`oc-media oc-media--unavailable oc-media--${i}`,role:`note`,children:[(0,J.jsx)(RA,{className:`oc-media__icon`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`oc-media__name`,children:Sae(c,i,a)})]})}function wae({url:e,name:t,mime:n,storageId:r}){let i=BJ(),a=hJ(n,t)!==`none`,o=!!r&&pJ(n,t),s=a||o,c=n=>{n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||n.button!==0||(n.preventDefault(),(async()=>{try{let n=await fetch(e);if(!n.ok)throw Error(`HTTP ${n.status}`);let r=URL.createObjectURL(await n.blob()),i=document.createElement(`a`);i.href=r,i.download=t,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),3e4)}catch{let t=window.open(``,`_blank`);t?(t.opener=null,t.location.href=e):window.location.href=e}})())};return(0,J.jsxs)(`span`,{className:`oc-media oc-media--file oc-filechip`,title:t,children:[(0,J.jsxs)(`a`,{className:`oc-filechip__main`,href:e,target:`_blank`,rel:`noopener noreferrer`,onClick:c,"aria-label":nx({name:t}),children:[(0,J.jsx)(`span`,{className:`oc-media__icon`,"aria-hidden":!0,children:`📄`}),(0,J.jsx)(`span`,{className:`oc-media__name`,children:t})]}),(0,J.jsx)(`a`,{className:`oc-filechip__btn`,href:e,target:`_blank`,rel:`noopener noreferrer`,onClick:c,title:nx({name:t}),"aria-label":nx({name:t}),children:(0,J.jsx)(bC,{size:14,"aria-hidden":!0})}),s?(0,J.jsx)(`button`,{type:`button`,className:`oc-filechip__btn`,onClick:()=>i.openFor({url:e,filename:t,mimeType:n||null,storageId:r,sourceStorageId:o?r:void 0}),title:ls({name:t}),"aria-label":ls({name:t}),children:(0,J.jsx)(aA,{size:14,"aria-hidden":!0})}):null,r?(0,J.jsx)(Tae,{storageId:r,name:t}):null]})}function Tae({storageId:e,name:t}){let[n,r]=(0,q.useState)(!1),i=$(e=>e.id),a=H(G.files.metadata,n&&i?{storageId:e,messageId:i}:`skip`),o=ut();return(0,J.jsxs)(vw,{open:n,onOpenChange:r,children:[(0,J.jsx)(_w,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:`oc-filechip__btn`,title:Cb({name:t}),"aria-label":Cb({name:t}),children:(0,J.jsx)(RA,{size:14,"aria-hidden":!0})})}),(0,J.jsxs)(gw,{side:`top`,align:`end`,className:`oc-filemeta`,children:[(0,J.jsx)(`div`,{className:`oc-filemeta__title`,children:nf()}),a===void 0?(0,J.jsx)(`div`,{className:`oc-filemeta__note`,children:Df()}):a===null?(0,J.jsx)(`div`,{className:`oc-filemeta__note`,children:w_()}):(0,J.jsxs)(`dl`,{className:`oc-filemeta__rows`,children:[(0,J.jsx)(D5,{label:Gm(),value:y8(a.filename)??a.filename}),(0,J.jsx)(D5,{label:hh(),value:a.contentType??sy()}),(0,J.jsx)(D5,{label:kee(),value:`${jT(a.bytes,o)} (${q_({count:Sne(a.bytes,o)})})`}),(0,J.jsx)(D5,{label:Hp(),value:a.direction===`inbound`?Qy():Yg()}),(0,J.jsx)(D5,{label:yp(),value:new Intl.DateTimeFormat(o,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(a.createdAt))}),MT(a.sha256)?(0,J.jsxs)(`div`,{className:`oc-filemeta__row oc-filemeta__row--digest`,children:[(0,J.jsx)(`dt`,{children:nee()}),(0,J.jsxs)(`dd`,{children:[(0,J.jsx)(`code`,{className:`oc-filemeta__digest`,children:MT(a.sha256)}),(0,J.jsx)(`button`,{type:`button`,className:`oc-filemeta__copy`,title:zh(),"aria-label":zh(),onClick:()=>{navigator.clipboard?.writeText(MT(a.sha256)??``)},children:(0,J.jsx)(yC,{size:12,"aria-hidden":!0})})]})]}):null]})]})]})}function D5({label:e,value:t}){return(0,J.jsxs)(`div`,{className:`oc-filemeta__row`,children:[(0,J.jsx)(`dt`,{children:e}),(0,J.jsx)(`dd`,{children:t})]})}function Eae({url:e,name:t}){let{open:n}=tY();return(0,J.jsx)(`button`,{type:`button`,className:`oc-media oc-media--thumb`,onClick:()=>n({url:e,name:t}),title:t,"aria-label":t,children:(0,J.jsx)(`img`,{src:e,alt:t,className:`oc-media__thumbimg`,loading:`lazy`,decoding:`async`})})}function Dae(e,t,n=!1){let r=e.closest(`.oc-msg`)?.querySelector(`.oc-msg__source-pre`),i=r?.textContent;return r&&i!=null&&i!==`(aucun texte)`?{displayedText:n?t:i,sourceWasOpen:!0}:{displayedText:t,sourceWasOpen:!1}}var O5=1e3;function Oae(){return[{id:`incorrect`,label:Aee()},{id:`incoherence`,label:J_()},{id:`altered_words`,label:ree()},{id:`formatting`,label:Up()},{id:`latency`,label:$y()},{id:`api_error`,label:Xg()},{id:`other`,label:bp()}]}function kae(){return[{id:`altered_words`,label:cy()},{id:`formatting`,label:T_()},{id:`other`,label:bp()}]}function Aae(e){return e===`user`?kae():Oae()}var jae=[{name:`Grammarly`,selector:`grammarly-desktop-integration, grammarly-extension, [data-grammarly-shadow-root]`},{name:`LanguageTool`,selector:`[data-lt-installed], .lt-toolbar`},{name:`DeepL`,selector:`deepl-inline-translate, .deepl-translator`},{name:`ProWritingAad`,selector:`pwa-shadow-host, .pwa-tag`}];function Mae(){let e=[];try{e=Array.from(navigator.plugins??[]).map(e=>e.name).slice(0,40)}catch{e=[]}let t=[];for(let{name:e,selector:n}of jae)try{document.querySelector(n)&&t.push(e)}catch{}return{plugins:e,extensionsDetected:t}}var k5=q.createContext(null);function Nae(){let e=q.useContext(k5);if(!e)throw Error(`useFeedback must be used within <FeedbackProvider>`);return e}function Pae({children:e}){let t=U(G.feedback.submitFeedback),[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)(``),[o,s]=(0,q.useState)(``),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(null),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(!1),_=q.useCallback(e=>{a(``),s(``),l(!1),d(null),m(null),g(!1),r(e)},[]);function v(e){e||r(null)}async function y(){if(!(!n||!i||c)){l(!0);try{let e=await t({chatId:n.chatId,messageId:n.messageId,category:i,comment:o.trim()||void 0,client:{displayedText:n.displayedText,sourceWasOpen:n.sourceWasOpen,userAgent:navigator.userAgent,language:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,theme:document.documentElement.classList.contains(`dark`)?`dark`:`light`,...Mae()}});d(e.displayedMatchesStored),m(String(e.reference??e.feedbackId))}catch{l(!1)}}}let b=u!==null,x=n?.role===`user`;return(0,J.jsxs)(k5.Provider,{value:_,children:[e,(0,J.jsx)(rT,{open:n!==null,onOpenChange:v,children:n?(0,J.jsxs)(eT,{className:`sm:max-w-md`,children:[(0,J.jsxs)(Qw,{children:[(0,J.jsx)(tT,{children:Of()}),(0,J.jsx)(nT,{children:b?Bh():x?Hv():Yee()})]}),b?(0,J.jsxs)(`div`,{className:`oc-feedback__result`,role:`status`,children:[n.sourceWasOpen?u===!0?(0,J.jsx)(`p`,{className:`oc-feedback__fidelity is-ok`,children:My()}):(0,J.jsx)(`p`,{className:`oc-feedback__fidelity is-warn`,children:mm()}):(0,J.jsx)(`p`,{className:`oc-feedback__fidelity`,children:f()}),p?(0,J.jsxs)(`div`,{className:`oc-feedback__ref`,children:[(0,J.jsx)(`span`,{className:`oc-feedback__ref-label`,children:cte()}),(0,J.jsx)(`code`,{className:`oc-feedback__ref-id`,title:p,children:p}),(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn`,title:Qe(),"aria-label":Qe(),onClick:()=>{navigator.clipboard.writeText(p).then(()=>{g(!0),window.setTimeout(()=>g(!1),1500)})},children:h?(0,J.jsx)(ZS,{size:14}):(0,J.jsx)(yC,{size:14})})]}):null]}):(0,J.jsxs)(`div`,{className:`oc-feedback__form`,children:[(0,J.jsx)(`label`,{className:`oc-feedback__label`,children:Ts()}),(0,J.jsxs)(sw,{value:i,onValueChange:a,children:[(0,J.jsx)(iw,{children:(0,J.jsx)(rw,{placeholder:Pd()})}),(0,J.jsx)(aw,{children:Aae(n.role).map(e=>(0,J.jsx)(ow,{value:e.id,children:e.label},e.id))})]}),(0,J.jsx)(`label`,{className:`oc-feedback__label`,htmlFor:`oc-feedback-comment`,children:Fu()}),(0,J.jsx)(`textarea`,{id:`oc-feedback-comment`,className:`oc-feedback__textarea`,placeholder:od(),value:o,maxLength:O5,onChange:e=>s(e.target.value.slice(0,O5)),rows:4}),(0,J.jsxs)(`div`,{className:`oc-feedback__count`,children:[o.length,`/`,O5]})]}),(0,J.jsx)($w,{children:b?(0,J.jsx)(K,{onClick:()=>v(!1),children:ti()}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(K,{variant:`outline`,onClick:()=>v(!1),children:gv()}),(0,J.jsx)(K,{onClick:()=>void y(),disabled:!i||c,children:c?ki():jn()})]})})]}):null})]})}function A5(){let e=Nae(),t=$(e=>k8(e.metadata?.custom)),n=$(e=>e.metadata?.custom?.chatId),r=$(e=>e.role),i=$(e=>e.metadata?.custom?.groupText??e.metadata?.custom?.rawText??``),a=$(e=>(e.metadata?.custom?.groupText??null)!==null),o=H(G.feedback.myReportedMessageIds,n?{chatId:n}:`skip`);if(!t||!n)return null;let s=(o??[]).includes(t);function c(o){let s=Dae(o.currentTarget,i,a);e({chatId:n,messageId:t,role:r,...s})}return(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn${s?` is-on`:``}`,title:s?uu():hl(),"aria-label":nr(),onClick:c,children:(0,J.jsx)(DA,{size:15,"aria-hidden":!0})})}function j5(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function M5({label:e,state:t,destructive:n,disabled:r,disabledHint:i,onClick:a,onRetry:o}){return(0,J.jsxs)(`div`,{className:`oc-spanel__action`,children:[(0,J.jsxs)(K,{variant:n?`destructive`:`outline`,size:`sm`,disabled:t===`pending`||r===!0,onClick:a,children:[t===`pending`?(0,J.jsx)(OC,{className:`oc-spanel__spin`,"aria-hidden":!0}):null,e]}),t===`done`?(0,J.jsx)(`p`,{className:`oc-spanel__action-note`,role:`status`,children:Fv()}):null,t===`error`?(0,J.jsxs)(`p`,{className:`oc-spanel__error`,role:`alert`,children:[Ji(),(0,J.jsx)(`button`,{type:`button`,className:`oc-spanel__retry`,onClick:o,children:Fo()})]}):null,r===!0&&i?(0,J.jsx)(`p`,{className:`oc-spanel__hint`,children:i}):null]})}function Fae({chatId:e,open:t,onOpenChange:n}){let r=H(G.messages.getSessionMeta,t?{chatId:e}:`skip`),i=H(G.chatSummaries.getChatSummary,t?{chatId:e}:`skip`),a=H(G.agents.getChatAgent,t?{chatId:e}:`skip`),o=(H(G.messages.getStreamingText,t?{chatId:e}:`skip`)?.length??0)>0,s=r?.sessionMeta??null,c=r?.sessionSettings??null,{can:l}=kT(t?e:null),u=gT(),d=Aa(G.agentFiles.compactSession),f=U(G.chats.resetSession),p=U(G.chatSummaries.requestSummarize),[m,h]=(0,q.useState)(`idle`),[g,_]=(0,q.useState)(`idle`),[v,y]=(0,q.useState)(`idle`),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(null),[w,T]=(0,q.useState)(!1),[E,D]=(0,q.useState)(!1),[k,A]=(0,q.useState)(null),[j,M]=(0,q.useState)(`idle`),N=U(G.chatSummaries.updateSummary);(0,q.useEffect)(()=>{A(null),M(`idle`),D(!1),T(!1),x(null),y(`idle`),C(null),_(`idle`)},[e]);async function P(){if(i?.summary)try{await navigator.clipboard.writeText(i.summary),T(!0),window.setTimeout(()=>T(!1),2e3)}catch{}}async function F(){if(!(k===null||k.trim().length===0)){M(`saving`);try{await N({chatId:e,summary:k}),A(null),M(`idle`)}catch{M(`error`)}}}let[I,L]=(0,q.useState)(()=>Date.now()),R=i?.jobInFlight===!0;(0,q.useEffect)(()=>{if(!R)return;let e=window.setInterval(()=>L(Date.now()),1e3);return()=>window.clearInterval(e)},[R]);async function z(){h(`pending`);try{await d({chatId:e}),h(`done`)}catch{h(`error`)}}async function B(){y(`pending`),x(null);try{let{outcome:t}=await p({chatId:e});x(({dispatched:Fg,in_flight:Ro,nothing_to_do:yt,scanning:cb,bridge_outdated:zy,engine_off:Ut,no_agent:tl,backoff:yt}[t]??yt)()),y(t===`dispatched`||t===`scanning`?`done`:`idle`)}catch{y(`error`)}}async function V(){_(`pending`),C(null);try{let t=await f({chatId:e});if(t!==void 0&&t.ok===!1){_(`idle`),C(Si());return}_(`done`)}catch{_(`error`)}}async function te(){await u({title:Ly(),description:ym(),confirmLabel:O(),cancelLabel:no()})&&await z()}async function re(){await u({title:Zd(),description:ed(),confirmLabel:Dd(),cancelLabel:no(),destructive:!0})&&await V()}let ie=TT(s),ae=OT(s),oe=pne(ie??void 0,ae??void 0),se=oe==null?``:oe>=90?`is-critical`:oe>=75?`is-warn`:`is-ok`,ce=yne(ie??void 0,ae??void 0),le=bne(s),ue=mne(s?.estimatedCostUsd,s?.totalTokens),de=a?.agent??null,fe=_ne([de?de.displayName??de.agentId:null,s?.agentRuntime,s?.model]);return(0,J.jsx)(ST,{open:t,onOpenChange:n,children:(0,J.jsxs)(xT,{side:`right`,className:`oc-spanel`,children:[(0,J.jsxs)(CT,{children:[(0,J.jsx)(bT,{children:Tte()}),(0,J.jsx)(yT,{children:rp()})]}),(0,J.jsx)(`div`,{className:`oc-spanel__body`,children:r===void 0?(0,J.jsx)(`p`,{className:`oc-spanel__loading`,children:qb()}):(0,J.jsxs)(J.Fragment,{children:[r===null?null:(0,J.jsxs)(`section`,{children:[(0,J.jsx)(`h3`,{className:`oc-spanel__cat`,children:Wte()}),(0,J.jsx)(DT,{chatId:e,sm:s,settings:c})]}),(0,J.jsxs)(`section`,{children:[(0,J.jsx)(`h3`,{className:`oc-spanel__cat`,children:jb()}),ce!==null&&oe!==null?(0,J.jsxs)(`div`,{className:`oc-spanel__static`,children:[(0,J.jsx)(`span`,{className:`oc-spanel__label`,children:ev()}),(0,J.jsxs)(`span`,{className:`oc-meter oc-spanel__meter ${se}`,children:[(0,J.jsx)(`span`,{className:`oc-meter__track`,children:(0,J.jsx)(`span`,{className:`oc-meter__fill`,style:{width:`${Math.min(oe,100)}%`}})}),(0,J.jsx)(`span`,{className:`oc-meter__label`,children:ce})]})]}):null,le===null?null:(0,J.jsx)(`p`,{className:`oc-spanel__help oc-spanel__help--warn`,children:le===`compaction_failed`?Yp():lee()}),(0,J.jsxs)(`div`,{className:`oc-spanel__static`,children:[(0,J.jsx)(`span`,{className:`oc-spanel__label`,children:hee()}),(0,J.jsx)(`span`,{className:`oc-spanel__value`,children:hne(s?.verboseLevel)}),(0,J.jsx)(`p`,{className:`oc-spanel__help`,children:py()})]}),ue===null?null:(0,J.jsxs)(`div`,{className:`oc-spanel__static`,children:[(0,J.jsx)(`span`,{className:`oc-spanel__label`,children:A_()}),(0,J.jsx)(`span`,{className:`oc-spanel__value`,children:ue})]})]}),fe!==null||s?(0,J.jsxs)(`section`,{children:[(0,J.jsx)(`h3`,{className:`oc-spanel__cat`,children:Sh()}),(0,J.jsxs)(`dl`,{className:`oc-spanel__kv`,children:[de?(0,J.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,J.jsx)(`dt`,{children:gx()}),(0,J.jsxs)(`dd`,{children:[de.emoji?`${de.emoji} `:``,de.displayName??de.agentId]})]}):null,de?.instanceName?(0,J.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,J.jsx)(`dt`,{children:uf()}),(0,J.jsx)(`dd`,{children:de.instanceName})]}):null,s?.model?(0,J.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,J.jsx)(`dt`,{children:Qh()}),(0,J.jsx)(`dd`,{children:s.model})]}):null,s?.modelProvider?(0,J.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,J.jsx)(`dt`,{children:ty()}),(0,J.jsx)(`dd`,{children:s.modelProvider})]}):null,s?.agentRuntime?(0,J.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,J.jsx)(`dt`,{children:Gl()}),(0,J.jsx)(`dd`,{children:s.agentRuntime})]}):null,s?.thinkingLevel?(0,J.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,J.jsx)(`dt`,{children:__()}),(0,J.jsx)(`dd`,{children:s.thinkingLevel})]}):null,s?.thinkingDefault?(0,J.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,J.jsx)(`dt`,{children:Qm()}),(0,J.jsx)(`dd`,{children:s.thinkingDefault})]}):null]})]}):null,(0,J.jsxs)(`section`,{children:[(0,J.jsx)(`h3`,{className:`oc-spanel__cat`,children:ds()}),i?(0,J.jsxs)(`div`,{className:`oc-spanel__static`,children:[(0,J.jsx)(`span`,{className:`oc-spanel__label`,children:Xe()}),(0,J.jsxs)(`span`,{className:`oc-meter oc-spanel__meter is-ok`,children:[(0,J.jsx)(`span`,{className:`oc-meter__track`,children:(0,J.jsx)(`span`,{className:`oc-meter__fill`,style:{width:`${Math.min(i.pendingChars/Math.max(i.thresholdChars,1)*100,100)}%`}})}),(0,J.jsx)(`span`,{className:`oc-meter__label`,children:jc({pending:`${j5(i.pendingChars)}${i.pendingApprox?`+`:``}`,threshold:j5(i.thresholdChars)})})]})]}):null,i&&!i.jobInFlight&&i.pendingChars>=i.thresholdChars?(0,J.jsx)(`p`,{className:`oc-spanel__hint`,children:Ote()}):null,i?.jobInFlight?(0,J.jsxs)(`p`,{className:`oc-spanel__hint oc-spanel__job`,role:`status`,children:[(0,J.jsx)(OC,{size:13,className:`oc-spanel__job-spin`,"aria-hidden":!0}),i.jobStreaming?Op():vee(),i.jobStartedAt?` · ${Math.max(0,Math.round((I-i.jobStartedAt)/1e3))} s`:``]}):null,i&&i.summary.length>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`oc-spanel__hint`,children:[po({count:String(i.coveredCount),date:Xw(i.updatedAt,{dateStyle:`short`,timeStyle:`short`})}),i.lastAgentId?` ${ate({agent:i.lastInstanceName?`${i.lastAgentId} (${i.lastInstanceName})`:i.lastAgentId})}`:``]}),i.failureCount>0?(0,J.jsx)(`p`,{className:`oc-spanel__hint oc-spanel__hint--warn`,children:za({count:String(i.failureCount)})}):null,(0,J.jsxs)(`div`,{className:`oc-spanel__summary-tools`,children:[(0,J.jsx)(K,{variant:`ghost`,size:`sm`,className:`oc-spanel__summary-tool`,onClick:()=>void P(),title:gy(),"aria-label":gy(),children:w?(0,J.jsx)(ZS,{size:14,"aria-hidden":!0}):(0,J.jsx)(yC,{size:14,"aria-hidden":!0})}),(0,J.jsx)(K,{variant:`ghost`,size:`sm`,className:`oc-spanel__summary-tool`,onClick:()=>D(!0),title:N_(),"aria-label":N_(),children:(0,J.jsx)(qA,{size:14,"aria-hidden":!0})}),i.jobInFlight?null:(0,J.jsx)(K,{variant:`ghost`,size:`sm`,className:`oc-spanel__summary-tool`,onClick:()=>{A(i.summary),D(!0)},title:Pf(),"aria-label":Pf(),children:(0,J.jsx)(IC,{size:14,"aria-hidden":!0})})]}),(0,J.jsx)(`div`,{className:`oc-spanel__summary`,children:i.summary})]}):i&&i.failureCount>0?(0,J.jsx)(`p`,{className:`oc-spanel__hint oc-spanel__hint--warn`,children:za({count:String(i.failureCount)})}):i?.jobInFlight?null:(0,J.jsx)(`p`,{className:`oc-spanel__hint`,children:mg()})]})]})}),(0,J.jsx)(rT,{open:E,onOpenChange:e=>{D(e),e||(A(null),M(`idle`))},children:(0,J.jsxs)(eT,{className:`oc-summary-dialog`,children:[(0,J.jsxs)(Qw,{children:[(0,J.jsx)(tT,{children:ds()}),(0,J.jsx)(nT,{children:k===null?i&&i.summary.length>0?po({count:String(i.coveredCount),date:Xw(i.updatedAt,{dateStyle:`short`,timeStyle:`short`})}):``:tte()})]}),k===null?(0,J.jsx)(`div`,{className:`oc-summary-dialog__body`,children:i?.summary??``}):(0,J.jsx)(`textarea`,{className:`oc-summary-dialog__body oc-summary-dialog__edit`,value:k,onChange:e=>A(e.target.value)}),j===`error`?(0,J.jsx)(`p`,{className:`oc-spanel__hint oc-spanel__hint--warn`,children:Jv()}):null,(0,J.jsx)($w,{className:`oc-summary-dialog__actions`,children:k===null?(0,J.jsxs)(J.Fragment,{children:[i&&i.summary.length>0&&!i.jobInFlight?(0,J.jsxs)(K,{variant:`outline`,size:`sm`,onClick:()=>A(i.summary),children:[(0,J.jsx)(IC,{size:14,"aria-hidden":!0}),Pf()]}):null,(0,J.jsxs)(K,{variant:`outline`,size:`sm`,onClick:()=>void P(),children:[w?(0,J.jsx)(ZS,{size:14,"aria-hidden":!0}):(0,J.jsx)(yC,{size:14,"aria-hidden":!0}),gy()]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(K,{variant:`ghost`,size:`sm`,onClick:()=>{A(null),M(`idle`)},children:no()}),(0,J.jsx)(K,{size:`sm`,disabled:k.trim().length===0||j===`saving`,onClick:()=>void F(),children:j===`saving`?ee():Gh()})]})})]})}),(0,J.jsxs)(une,{className:`oc-spanel__actions`,children:[(0,J.jsx)(`h3`,{className:`oc-spanel__cat`,children:Fee()}),l(`sessionCompact`)?(0,J.jsx)(M5,{label:$ee(),state:m,onClick:()=>void te(),onRetry:()=>void z()}):null,(0,J.jsx)(M5,{label:ne(),state:R?`pending`:v,onClick:()=>void B(),onRetry:()=>void B()}),b===null?null:(0,J.jsx)(`p`,{className:`oc-spanel__hint`,children:b}),(0,J.jsx)(M5,{label:Vs(),state:g,destructive:!0,disabled:o,disabledHint:Si(),onClick:()=>void re(),onRetry:()=>void V()}),!o&&S!==null?(0,J.jsx)(`p`,{className:`oc-spanel__hint`,children:S}):null]})]})})}function Iae(e){let t=null;for(let n of e)(t===null||n.createdAt>=t.createdAt)&&(t=n);return t===null?{kind:`bottom`}:{kind:`bookmark`,messageId:t.messageId,blockIndex:t.blockIndex}}var Lae=class{last=-1;stable=0;observe(e){return e===this.last?(this.stable+=1,this.stable>=3):(this.last=e,this.stable=0,!1)}};function Rae(e){if(e.kind===`bottom`)return Math.max(0,e.scrollHeight-e.clientHeight);if(e.anchorDelta===void 0)return null;let t=Math.max(24,e.clientHeight*.3);return Math.max(0,e.scrollTop+e.anchorDelta-t)}function zae(e,t,n=()=>performance.now()){let r=n(),i=new Lae,a=0,o=!1,s=()=>{o||(o=!0,a&&cancelAnimationFrame(a),a=0,e.removeAttribute(`data-oc-landing`))},c=()=>{if(t.kind!==`bookmark`)return;let n=e.querySelector(`[data-message-id="${CSS.escape(t.messageId)}"]`);if(n)return(t.blockIndex===null?n:n.querySelector(`[data-block-index="${t.blockIndex}"]`)??n).getBoundingClientRect().top-e.getBoundingClientRect().top},l=()=>{if(o)return;let u=Rae({kind:t.kind,scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,anchorDelta:c()});if(u!==null&&(RK(e),e.scrollTop=u),u!==null&&i.observe(e.scrollHeight)||n()-r>=1200){s();return}a=requestAnimationFrame(l)};return a=requestAnimationFrame(l),s}function Bae(e){let t=VK()?.rows;(0,q.useEffect)(()=>{if(!e.ready||e.focusMessageId)return;let n=document.querySelector(`.oc-thread__viewport`);if(!n)return;n.setAttribute(`data-oc-landing`,``);let r=zae(n,Iae(t??[]));return()=>{r()}},[e.chatId,e.ready,e.focusMessageId])}var Vae=[`read-only`,`guarded`,`workspace`,`full`],Hae=[`admin`,`owner`,`member`,`viewer`];function N5(e){return typeof e==`string`&&Vae.includes(e)}function Uae(e){return typeof e==`string`&&Hae.includes(e)}function Wae(e){switch(e){case`admin`:return Ru();case`owner`:return ld();case`member`:return ii();case`viewer`:return yv()}}function Gae(e){let t=e?.visibility;if(t!==`read-only`&&t!==`suggest`&&t!==`draft`)return null;let n=e?.sharingRole,r=Uae(n)?n:null,[i,a]=t===`read-only`?[Wv(),gm()]:t===`suggest`?[Xee(),m()]:[Py(),Ds()],o=[a];return r!==null&&o.push(Ld({role:Wae(r)})),{visibility:t,role:r,label:i,title:o.join(`
152
+ `)}}var Kae=`https://docs.openclaw.ai/gateway/permission-modes`,P5=[`default`,`read-only`,`guarded`,`workspace`,`full`];function qae(e){return typeof e==`string`&&P5.includes(e)}function F5(e){switch(e){case`read-only`:return`ellipsis`;case`guarded`:return`lock`;case`workspace`:return`cog`;case`full`:return`alert`;default:return`check`}}function I5(e){switch(e){case`read-only`:return $s();case`guarded`:return Mr();case`workspace`:return rs();case`full`:return Pa()}}function Jae(e){switch(e){case`read-only`:return oa();case`guarded`:return cn();case`workspace`:return io();case`full`:return lg()}}function L5(e,t){return e==="default"?t===null?Ul():xe({mode:I5(t)}):I5(e)}function Yae(e){switch(e){case`scope_refused`:return Db();case`active_run`:return of();case`unsupported_gateway`:return Jm();case`full_not_authorized`:return vh();case`session_not_established`:return jee();case`bridge_unreachable`:return X_();case`no_agent`:return aee();case`not_managed`:return D_();case`reapply_exhausted`:return Af();default:return Gp()}}function Xae(e){let t=N5(e.agentDefault)?e.agentDefault:null,n=N5(e.sessionMode)?e.sessionMode:`default`,r=e.managed?e.choice??`default`:n,i=L5(r,t),a=r===`full`||r==="default"&&t===`full`,o=e.viewerRole===`owner`,s=e.viewerRole===void 0||e.target===`hermes`&&!e.multiAgent&&e.choice===null||e.target===`unknown`&&e.choice===null&&!N5(e.sessionMode)&&e.sessionMode!==null,c=e.choice!==null&&e.apply!==null&&e.apply.mode===e.choice&&e.apply.status===`pending`||e.sessionModePending,l=null;e.anyManaged?o?e.target===`unknown`?l=Xb():e.target===`unsupported`?l=Jc():e.target===`hermes`&&!e.multiAgent&&(l=pt()):l=jo():l=Cp();let u=l!==null,d=P5.map((n,i)=>{let a=n===`full`&&!e.viewerIsAdmin;return{value:n,label:L5(n,t),description:n==="default"?mx():Jae(n),icon:F5(n),shortcut:i+1,selected:n===r,disabled:u||c||a,disabledReason:a?Ag():null}}),f=null,p=!1;o&&e.choice===`full`&&!e.viewerIsAdmin?(f=nb(),p=!0):e.choice!==null&&e.apply!==null&&e.apply.mode===e.choice&&(e.apply.status===`failed`?(f=rx({reason:Yae(e.apply.reason)}),p=!0):e.apply.status===`deferred`?f=xte():e.apply.status===`applied`&&e.apply.reason===`saved_not_applied`&&(f=$f()));let m=[`${pu()}: ${i}`];m.push(l??yl()),e.multiAgent&&m.push(We()),e.target===`hermes`&&e.multiAgent&&m.push(Lt()),e.anyManaged&&!e.managed&&e.target!==`hermes`&&m.push(uy()),a&&m.push($g()),c&&m.push(wc()),f!==null&&m.push(f),e.sessionRoot&&m.push(Hh({root:e.sessionRoot}));let h=c?wc():e.target===`hermes`&&e.multiAgent?Lt():e.anyManaged&&!e.managed&&e.target!==`hermes`?uy():null;return{hidden:s,current:r,label:i,icon:F5(r),alert:a,pending:c,locked:u,lockReason:l,note:h,status:f,statusIsError:p,title:m.join(`
153
+ `),ariaLabel:L({label:pu(),mode:i}),items:d}}function Zae(e,t){if(!/^[1-5]$/.test(e))return null;let n=t.find(t=>t.shortcut===Number(e));return n&&!n.disabled?n.value:null}function Qae(e,t,n){let r=t.items.find(t=>t.value===e);return!r||r.disabled?!1:e!==n}function $ae({size:e=14}){return(0,J.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:e,height:e,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,J.jsx)(`path`,{d:`M20 9.807V6a1 1 0 0 0-1-1c-2 0-4.49-1.19-6.24-2.72a1.17 1.17 0 0 0-1.52 0C9.5 3.8 7 5 5 5a1 1 0 0 0-1 1v7c0 3.88 2.107 6.254 5 7.796`}),(0,J.jsx)(`path`,{d:`M19 17v-2a2 2 0 0 0-4 0v2`}),(0,J.jsx)(`rect`,{x:`13`,y:`17`,width:`8`,height:`5`,rx:`1`})]})}function R5({icon:e,size:t=14}){switch(e){case`ellipsis`:return(0,J.jsx)(fj,{size:t,"aria-hidden":!0});case`lock`:return(0,J.jsx)($ae,{size:t});case`cog`:return(0,J.jsx)(pj,{size:t,"aria-hidden":!0});case`alert`:return(0,J.jsx)(dj,{size:t,"aria-hidden":!0});default:return(0,J.jsx)(BC,{size:t,"aria-hidden":!0})}}function z5(e,t,n){let r=H(G.permissionMode.permissionControl,{chatId:e,...t?{routedAgent:t}:{}}),i=H(G.messages.getSessionMeta,{chatId:e}),a=kT(e,t),o=U(G.permissionMode.setPermissionMode),s=Iw(),c=(0,q.useCallback)(t=>{o({chatId:e,mode:t}).catch(e=>{s.error(rx({reason:Gp()}),e)})},[e,o,s]);if(r==null)return null;let l=a.loading||!a.resolved?`unknown`:a.provider===`hermes`?`hermes`:a.can(`permissionModes`)?`openclaw`:`unsupported`,u=i?.sessionMeta??null,d=qae(r.choice)?r.choice:null,f=Xae({viewerRole:r.viewerRole,viewerIsAdmin:r.viewerIsAdmin,choice:d,apply:r.apply,sessionMode:u?.permissionMode,sessionModePending:u?.permissionModePending===!0,sessionRoot:typeof u?.sessionRoot==`string`?u.sessionRoot:null,agentDefault:r.agentDefault,target:l,multiAgent:n,managed:r.managed,anyManaged:r.anyManaged});return{view:f,choice:d,pick:e=>{Qae(e,f,d)&&c(e)}}}function B5({item:e}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`oc-perm__opt-icon`,"aria-hidden":!0,children:(0,J.jsx)(R5,{icon:e.icon})}),(0,J.jsxs)(`span`,{className:`oc-perm__opt-copy`,children:[(0,J.jsx)(`span`,{className:`oc-perm__opt-title`,children:e.label}),(0,J.jsx)(`span`,{className:`oc-perm__opt-desc`,children:e.description}),e.disabledReason===null?null:(0,J.jsx)(`span`,{className:`oc-perm__opt-reason`,children:e.disabledReason})]}),(0,J.jsx)(`span`,{className:`oc-perm__opt-state`,"aria-hidden":!0,children:e.selected&&e.disabledReason===null?(0,J.jsx)(ZS,{size:14}):e.disabledReason===null?(0,J.jsx)(`span`,{className:`oc-perm__shortcut`,children:e.shortcut}):(0,J.jsx)(kC,{size:13})})]})}function V5(){return(0,J.jsxs)(`div`,{className:`oc-perm__heading`,children:[(0,J.jsx)(`span`,{children:pu()}),(0,J.jsx)(`a`,{className:`oc-perm__learn`,href:Kae,target:`_blank`,rel:`noopener noreferrer`,children:or()})]})}function eoe({chatId:e,routedAgent:t,multiAgent:n,onVisibleChange:r}){let i=z5(e,t,n),[a,o]=(0,q.useState)(!1),s=(0,q.useRef)(null),c=i!==null&&!i.view.hidden;if((0,q.useEffect)(()=>{r?.(c)},[c,r]),(0,q.useEffect)(()=>()=>{r?.(!1)},[r]),i===null||i.view.hidden)return null;let{view:l,pick:u}=i;return(0,J.jsxs)(hC,{open:a,onOpenChange:o,children:[(0,J.jsx)(oC,{asChild:!0,children:(0,J.jsxs)(`button`,{ref:s,type:`button`,className:`oc-composer__perm${l.alert?` is-alert`:``}${l.pending?` is-pending`:``}${i.choice===null?` is-default`:``}`,title:l.title,"aria-label":l.ariaLabel,"data-permission-mode":l.current,"data-overflow":`perm`,children:[(0,J.jsx)(R5,{icon:l.icon,size:15}),(0,J.jsx)(`span`,{className:`oc-composer__perm-label`,children:l.label}),(0,J.jsx)(QS,{size:13,"aria-hidden":!0,className:`oc-composer__perm-chev`})]})}),(0,J.jsxs)(dC,{align:`start`,side:`top`,className:`oc-perm__menu w-80`,onKeyDown:e=>{let t=Zae(e.key,l.items);t!==null&&(e.preventDefault(),e.stopPropagation(),u(t),o(!1))},returnFocus:()=>{let{more:e,field:t}=C2(s.current);return[e,t]},children:[(0,J.jsx)(V5,{}),l.items.map(e=>(0,J.jsx)(pC,{className:`oc-perm__opt${e.selected?` is-selected`:``}${e.value===`full`?` is-full`:``}`,role:`menuitemradio`,"aria-checked":e.selected,"aria-keyshortcuts":String(e.shortcut),disabled:e.disabled,title:e.disabledReason??void 0,"data-permission-option":e.value,onSelect:()=>u(e.value),children:(0,J.jsx)(B5,{item:e})},e.value)),l.status===null?null:(0,J.jsx)(`p`,{className:`oc-perm__status${l.statusIsError?` is-error`:``}`,role:l.statusIsError?`alert`:`status`,children:l.status}),l.lockReason===null?null:(0,J.jsx)(`p`,{className:`oc-perm__note`,children:l.lockReason}),l.note===null?null:(0,J.jsx)(`p`,{className:`oc-perm__note`,children:l.note})]})]})}function H5({chatId:e,routedAgent:t,multiAgent:n}){let r=z5(e,t,n);if(r===null||r.view.hidden)return null;let{view:i,pick:a}=r;return(0,J.jsxs)(`section`,{className:`oc-perm__section`,"aria-label":pu(),title:i.title,children:[(0,J.jsx)(V5,{}),(0,J.jsx)(`div`,{role:`radiogroup`,"aria-label":pu(),className:`oc-perm__list`,children:i.items.map(e=>(0,J.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.selected,disabled:e.disabled,title:e.disabledReason??void 0,className:`oc-perm__opt${e.selected?` is-selected`:``}${e.value===`full`?` is-full`:``}`,"data-permission-option":e.value,onClick:()=>a(e.value),children:(0,J.jsx)(B5,{item:e})},e.value))}),i.status===null?null:(0,J.jsx)(`p`,{className:`oc-perm__status${i.statusIsError?` is-error`:``}`,role:i.statusIsError?`alert`:`status`,children:i.status}),i.lockReason===null?null:(0,J.jsx)(`p`,{className:`oc-perm__note`,children:i.lockReason}),i.note===null?null:(0,J.jsx)(`p`,{className:`oc-perm__note`,children:i.note})]})}function U5(e){let t=H(G.widgets.widgetConfigForChat,e===null?`skip`:{chatId:e}),{can:n}=kT(e),r=U(G.widgets.setChatWidgets),i=Iw(),[a,o]=(0,q.useState)(null),s=t?.canToggle===!0&&n(`inlineWidgets`),c=a??t?.chatDisabled!==!0,l=(0,q.useCallback)(t=>{e!==null&&(o(t),r({chatId:e,enabled:t}).catch(e=>i.error(Zv(),e)).finally(()=>o(null)))},[e,r,i]);return{offered:s,enabled:c,pending:a!==null,set:l}}function W5(e,t){return e===null||e.kind==="default"?{off:t.injection===`off`,sources:t.injection===`off`?[]:[...t.defaultSources]}:e.kind===`off`?{off:!0,sources:[]}:{off:!1,sources:[...e.sources]}}var G5={hidden:!0,items:[],readOnlyReason:null,origin:`agent`,originLabel:``,allOff:!1,canReset:!1,emptyNote:null,status:null,statusIsError:!1};function K5(e){switch(e){case`plugin_absent`:return Sd();case`overrides_disabled`:return _i();case`source_not_allowed`:case`unknown_source`:return jv();case`unsupported_gateway`:return Wi();case`scope_refused`:return Gn();default:return wu()}}function toe(e){if(e==null||e.provider!==`openclaw`||!e.supported)return G5;let t=e.facts;if(t===null||!t.available)return G5;let n=e.choice,r=n!==null&&n.kind!=="default";if(t.sources.length===0&&!r)return G5;let i=W5(n,{injection:t.injection,defaultSources:t.defaultSources}),a=e.viewerRole===`owner`?t.overridesAllowed?null:C():Dm(),o=null,s=!1,c=e.apply?.status===`clamped`&&n!==null&&Array.isArray(e.apply.dropped)?e.apply.dropped:[];if(e.apply!==null&&n!==null){if(e.apply.status===`pending`)o=Ls();else if(e.apply.status===`deferred`)o=qd();else if(e.apply.status===`failed`)o=Yu({reason:K5(e.apply.reason)}),s=!0;else if(e.apply.status===`clamped`&&c.length>0){let e=c.map(e=>t.sources.find(t=>t.id===e)?.label??e);o=e.length===1?xy({source:e[0]}):R_({sources:e.join(`, `)})}}return{hidden:!1,items:t.sources.map(e=>({id:e.id,label:e.label,description:e.description,checked:!i.off&&i.sources.includes(e.id)&&!c.includes(e.id),unavailable:c.includes(e.id)})),readOnlyReason:a,origin:r?`conversation`:`agent`,originLabel:r?n.kind===`sources`&&t.injection===`off`?$v():Np():xee(),allOff:i.off||i.sources.length===0,canReset:e.viewerRole===`owner`&&r,status:o,statusIsError:s,emptyNote:t.sources.length===0?zf():null}}function noe(e,t){let n=e.facts,r=W5(e.choice,{injection:n?.injection??null,defaultSources:n?.defaultSources??[]}),i=r.off?[]:r.sources,a=new Set((n?.sources??[]).map(e=>e.id)),o=(i.includes(t)?i.filter(e=>e!==t):[...i,t]).filter(e=>a.has(e));return o.length===0?{kind:`off`}:{kind:`sources`,sources:(n?.sources??[]).map(e=>e.id).filter(e=>o.includes(e)),...n?.injection===`off`?{injection:`auto`}:{}}}function roe(e,t){return e===null||t===null?e===t:e.kind===t.kind?e.kind!==`sources`||t.kind!==`sources`||e.injection===t.injection&&e.sources.length===t.sources.length&&e.sources.every(e=>t.sources.includes(e)):!1}function q5(e,t){return t===null?e:{...e,choice:t}}function J5(e){return`${e.instanceName}\u0000${e.agentId}`}function ioe(e,t){return e[t]?.choice??null}function aoe(e,t,n,r){let i=e[t];return{...e,[t]:{choice:n,inFlight:(i?.inFlight??0)+1,gen:r}}}function Y5(e,t,n,r,i){let a=e[t];if(a===void 0)return e;let o=Math.max(0,a.inFlight-1);return!r&&a.gen===n||r&&o===0&&t!==i?X5(e,t):{...e,[t]:{...a,inFlight:o}}}function ooe(e,t,n){let r=e[t];return r===void 0||soe(n,r.choice,r.inFlight)!==null?e:X5(e,t)}function X5(e,t){let n={};for(let[r,i]of Object.entries(e))r!==t&&(n[r]=i);return n}function soe(e,t,n){return t===null?null:n>0?t:roe(e,t)?null:t}function coe({chatId:e,routedAgent:t,attachmentsSupported:n,attachDisabled:r}){let i=IV(),a=Iw(),o=(0,q.useRef)(null),s=(0,q.useRef)(null),c=H(G.knowledge.knowledgeControl,e===null?`skip`:{chatId:e,...t?{routedAgent:t}:{}}),l=U(G.knowledge.setKnowledgeChoice),u=c==null?``:J5(c.target),[d,f]=(0,q.useState)({}),p=(0,q.useRef)(new Map),m=(0,q.useRef)(u);m.current=u;let h=ioe(d,u),g=c?.choice??null;(0,q.useEffect)(()=>{c!=null&&f(e=>ooe(e,u,g))},[c,g,u,d]);let _=toe(c==null?c:q5(c,h)),v=U5(e),y=(0,q.useCallback)(e=>{let t=Array.from(e.target.files??[]);e.target.value=``;for(let e of t)i.addAttachment(e).catch(()=>{})},[i]),b=(0,q.useCallback)(t=>{if(c==null)return;let n=J5(c.target),r=(p.current.get(n)??0)+1;p.current.set(n,r),f(e=>aoe(e,n,t,r)),l({chatId:e,instanceName:c.target.instanceName,agentId:c.target.agentId,choice:t}).then(()=>f(e=>Y5(e,n,r,!0,m.current))).catch(e=>{f(e=>Y5(e,n,r,!1,m.current));let t=/overrides_disabled|source_not_allowed|unavailable|not_openclaw/.exec(String(e?.message??``))?.[0];a.error(Al({reason:K5(t===`unavailable`?`plugin_absent`:t)}),e)})},[e,c,l,a]);if(!n&&_.hidden&&!v.offered)return null;let x=_.readOnlyReason===null;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`input`,{ref:o,type:`file`,multiple:!0,hidden:!0,onChange:y,"data-testid":`composer-add-file-input`}),(0,J.jsx)(`input`,{ref:s,type:`file`,accept:bre,multiple:!0,hidden:!0,onChange:y,"data-testid":`composer-add-image-input`}),(0,J.jsxs)(hC,{children:[(0,J.jsx)(oC,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__icon`,"aria-label":sv(),title:sv(),children:(0,J.jsx)(LC,{size:18,"aria-hidden":!0})})}),(0,J.jsxs)(dC,{align:`start`,side:`top`,className:`oc-perm__menu w-80`,children:[n?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(pC,{className:`oc-perm__opt`,disabled:r,onSelect:()=>o.current?.click(),"data-add-option":`file`,children:[(0,J.jsx)(`span`,{className:`oc-perm__opt-icon`,"aria-hidden":!0,children:(0,J.jsx)(EA,{size:14})}),(0,J.jsx)(`span`,{className:`oc-perm__opt-copy`,children:(0,J.jsx)(`span`,{className:`oc-perm__opt-title`,children:Lm()})})]}),(0,J.jsxs)(pC,{className:`oc-perm__opt`,disabled:r,onSelect:()=>s.current?.click(),"data-add-option":`image`,children:[(0,J.jsx)(`span`,{className:`oc-perm__opt-icon`,"aria-hidden":!0,children:(0,J.jsx)(FA,{size:14})}),(0,J.jsx)(`span`,{className:`oc-perm__opt-copy`,children:(0,J.jsx)(`span`,{className:`oc-perm__opt-title`,children:im()})})]})]}):null,_.hidden||c==null?null:(0,J.jsxs)(J.Fragment,{children:[n?(0,J.jsx)(mC,{}):null,(0,J.jsxs)(uC,{className:`oc-perm__heading`,"data-knowledge-origin":_.origin,children:[(0,J.jsx)(`span`,{children:hb()}),(0,J.jsx)(`span`,{className:`oc-knowledge__origin`,children:_.originLabel})]}),_.items.map(e=>(0,J.jsxs)(pC,{className:`oc-perm__opt${e.checked?` is-selected`:``}`,role:`menuitemcheckbox`,"aria-checked":e.checked,disabled:!x||e.unavailable,title:e.unavailable?Xh():_.readOnlyReason??void 0,"data-knowledge-source":e.id,onSelect:t=>{t.preventDefault(),x&&!e.unavailable&&b(noe(q5(c,h),e.id))},children:[(0,J.jsxs)(`span`,{className:`oc-perm__opt-copy`,children:[(0,J.jsx)(`span`,{className:`oc-perm__opt-title`,children:e.label}),e.description===``?null:(0,J.jsx)(`span`,{className:`oc-perm__opt-desc`,children:e.description})]}),(0,J.jsx)(`span`,{className:`oc-perm__opt-state`,"aria-hidden":!0,children:!x||e.unavailable?e.checked?(0,J.jsx)(ZS,{size:14}):(0,J.jsx)(kC,{size:13}):e.checked?(0,J.jsx)(ZS,{size:14}):null})]},e.id)),_.emptyNote===null?null:(0,J.jsx)(`p`,{className:`oc-perm__note`,children:_.emptyNote}),_.allOff&&_.emptyNote===null?(0,J.jsx)(`p`,{className:`oc-perm__note`,children:Wy()}):null,_.canReset?(0,J.jsxs)(pC,{className:`oc-perm__opt`,onSelect:()=>b({kind:`default`}),"data-knowledge-reset":!0,children:[(0,J.jsx)(`span`,{className:`oc-perm__opt-icon`,"aria-hidden":!0,children:(0,J.jsx)(RC,{size:14})}),(0,J.jsx)(`span`,{className:`oc-perm__opt-copy`,children:(0,J.jsx)(`span`,{className:`oc-perm__opt-title`,children:m_()})})]}):null,_.status===null?null:(0,J.jsx)(`p`,{className:`oc-perm__status${_.statusIsError?` is-error`:``}`,role:_.statusIsError?`alert`:`status`,children:_.status}),_.readOnlyReason===null?null:(0,J.jsx)(`p`,{className:`oc-perm__note`,children:_.readOnlyReason})]}),v.offered?(0,J.jsxs)(J.Fragment,{children:[n||!_.hidden?(0,J.jsx)(mC,{}):null,(0,J.jsxs)(pC,{className:`oc-perm__opt${v.enabled?` is-selected`:``}`,role:`menuitemcheckbox`,"aria-checked":v.enabled,disabled:v.pending,"data-widgets-toggle":!0,onSelect:e=>{e.preventDefault(),v.set(!v.enabled)},children:[(0,J.jsx)(`span`,{className:`oc-perm__opt-icon`,"aria-hidden":!0,children:(0,J.jsx)(BA,{size:14})}),(0,J.jsxs)(`span`,{className:`oc-perm__opt-copy`,children:[(0,J.jsx)(`span`,{className:`oc-perm__opt-title`,children:xi()}),(0,J.jsx)(`span`,{className:`oc-perm__opt-desc`,children:Pv()})]}),(0,J.jsx)(`span`,{className:`oc-perm__opt-state`,"aria-hidden":!0,children:v.enabled?(0,J.jsx)(ZS,{size:14}):null})]})]}):null]})]})]})}function loe({open:e,onOpenChange:t,moved:n,hold:r,expand:i,tools:a,onManageConversation:o,onDictate:s,permission:c,talkSettingsSlot:l,talkStartSlot:u}){let d=()=>t(!1),f=(0,q.useRef)(null),p=(0,q.useRef)(null);return(0,q.useEffect)(()=>{if(!e)return;p.current=null;let t=e=>{let t=e instanceof Element?e.closest(`.oc-composer__more-pop [data-more-key]`)?.getAttribute(`data-more-key`):null;t&&(p.current=t)};t(document.activeElement);let n=e=>t(e.target);return document.addEventListener(`focusin`,n),()=>document.removeEventListener(`focusin`,n)},[e]),(0,q.useLayoutEffect)(()=>{let e=p.current;if(e===null||n.has(e))return;p.current=null;let{bar:t,field:r}=C2(f.current);E2([T2(t,e),r])},[[...n].join(` `)]),(0,J.jsxs)(vw,{open:e,onOpenChange:t,children:[(0,J.jsx)(_w,{asChild:!0,children:(0,J.jsx)(`button`,{ref:f,type:`button`,className:`oc-composer__icon oc-composer__more`,title:wn(),"aria-label":wn(),children:(0,J.jsx)(SA,{size:18,"aria-hidden":!0})})}),(0,J.jsx)(gw,{align:`end`,side:`top`,className:`oc-composer__more-pop w-80 p-1`,returnFocus:()=>{let{bar:e,field:t}=C2(f.current),n=T2(e,p.current);return p.current=null,[n,t]},children:vae.filter(e=>n.has(e)).map(e=>{switch(e){case`tools`:return(0,J.jsxs)(K,{"data-more-key":e,variant:`ghost`,className:`oc-composer__more-item w-full justify-start`,"aria-pressed":a.shown,onClick:a.onToggle,children:[(0,J.jsx)(HC,{"aria-hidden":!0}),ar(),a.shown?(0,J.jsx)(ZS,{className:`ml-auto`,"aria-hidden":!0}):null]},e);case`room-settings`:return(0,J.jsxs)(K,{"data-more-key":e,variant:`ghost`,className:`oc-composer__more-item w-full justify-start`,onClick:()=>{d(),o()},children:[(0,J.jsx)(lj,{"aria-hidden":!0}),Pm()]},e);case`hold`:return r.held?(0,J.jsxs)(K,{"data-more-key":e,variant:`ghost`,className:`oc-composer__more-item w-full justify-start`,onClick:()=>{d(),r.onRelease()},children:[(0,J.jsx)(Xx,{"aria-hidden":!0}),Ka()]},e):(0,J.jsxs)(K,{"data-more-key":e,variant:`ghost`,className:`oc-composer__more-item w-full justify-start`,disabled:r.disabled,onClick:()=>{d(),r.onHold()},children:[(0,J.jsx)(Xx,{"aria-hidden":!0}),bo()]},e);case`expand`:return(0,J.jsxs)(K,{"data-more-key":e,variant:`ghost`,className:`oc-composer__more-item w-full justify-start`,"aria-pressed":i.expanded,onClick:()=>{d(),i.onToggle()},children:[i.expanded?(0,J.jsx)(ZA,{"aria-hidden":!0}):(0,J.jsx)(qA,{"aria-hidden":!0}),i.expanded?Jr():Sa()]},e);case`mic`:return(0,J.jsxs)(K,{"data-more-key":e,variant:`ghost`,className:`oc-composer__more-item w-full justify-start`,onClick:()=>{d(),s()},children:[(0,J.jsx)(qS,{"aria-hidden":!0}),Gd()]},e);case`talk`:return(0,J.jsx)(`div`,{"data-more-key":e,ref:u},e);case`perm`:return(0,J.jsx)(`div`,{"data-more-key":e,className:`oc-composer__more-section`,children:c},e);case`talk-settings`:return(0,J.jsx)(`div`,{"data-more-key":e,ref:l,className:`oc-composer__more-section`,role:`group`,"aria-label":ys()},e)}})})]})}function uoe(e){let t=e instanceof Error?e.message:``;return/^useClientLookup: (Index -?\d+ out of bounds|Key ".*" not found)/.test(t)}function Z5(e,t){return uoe(e)&&t<=3?`retry`:`rethrow`}var Q5=class extends q.Component{state={error:null,tears:0};retryTimer=null;calmTimer=null;static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e){this.calmTimer!==null&&clearTimeout(this.calmTimer),this.calmTimer=null;let t=this.state.tears+1;this.setState({tears:t}),Z5(e,t)!==`rethrow`&&(this.retryTimer!==null&&clearTimeout(this.retryTimer),this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.setState({error:null})},0))}componentDidUpdate(e,t){t.error!==null&&this.state.error===null&&this.state.tears>0&&(this.calmTimer!==null&&clearTimeout(this.calmTimer),this.calmTimer=setTimeout(()=>{this.calmTimer=null,this.state.error===null&&this.setState({tears:0})},1e3))}componentWillUnmount(){this.retryTimer!==null&&clearTimeout(this.retryTimer),this.calmTimer!==null&&clearTimeout(this.calmTimer)}render(){let{error:e,tears:t}=this.state;if(e===null)return this.props.children;if(Z5(e,t)===`rethrow`)throw e;return null}};function $5(e,t,n){return!e.stale&&t===e&&n===e.startedChatId}function doe(e){if(e===null||e.stale)return null;let t=e.finalizing===!0?e.lastInterim??``:``;return e.stale=!0,e.lastInterim=``,t.trim()===``?null:t}function foe(e,t,n,r,i){return e.stale||e.boundToHold||!$5(e,t,n.chatId())?!1:(n.setText(_M(n.getText(),r,i)),!0)}function poe(e,t,n){return!e.boundToHold&&$5(e,t,n.chatId())}function moe(e,t){if(e===null)return;if(e.boundToHold){e.stale=!0;return}let n=doe(e);n!==null&&t.chatId()===e.startedChatId&&t.setText(_M(t.getText(),n,!1)),e.h?.discard()}function e7(e){return e!==null&&!e.stale&&!e.boundToHold&&(e.recording||e.finalizing===!0)}function t7(e,t){let n=t.getText();if(e7(e)){let r=e;r.startedChatId===t.chatId()&&(n=dM(n,r.lastInterim??``)),r.stale=!0,r.recording=!1,r.finalizing=!1,r.h?.discard()}return t.setText(n),n}function n7(e){return e.kind===`credential`?`credential`:e.kind===`question`?e.questions?.some(e=>e.secret)?`credential`:`question`:e.approval?.severity===`critical`?`critical`:`approval`}function r7(e){return e===`pending`||e===`submitting`}function i7(e,t){return r7(e.status)&&e.expiresAt>t}function hoe(e){return e.source!==`hermes.approval`&&e.answerById!==!0}function goe(e,t){let n=e-t;if(n<=0)return{unit:`expired`,value:0,urgent:!0};let r=Math.ceil(n/1e3);if(r<60)return{unit:`seconds`,value:r,urgent:!0};let i=Math.ceil(r/60);return i<60?{unit:`minutes`,value:i,urgent:i<=2}:{unit:`hours`,value:Math.round(i/60),urgent:!1}}function _oe(e){if(e.kind===`question`||e.kind===`credential`&&e.questions)return e.questions?.[0]?.text??``;if(e.kind===`approval`){let t=e.approval;return t?.title??t?.command??t?.description??``}return e.credential?.prompt??e.credential?.envVar??``}function a7(){return{selected:[],other:``}}function voe(e,t,n){let r=t.selected.includes(n);return e.multiSelect?{...t,selected:r?t.selected.filter(e=>e!==n):[...t.selected,n]}:{selected:r?[]:[n],other:r?t.other:``}}function yoe(e){return e>4}function o7(e,t,n){return e.multiSelect?{...t,other:n}:{selected:n.trim()===``?t.selected:[],other:n}}function boe(e,t){let n=[];for(let r of e){let e=t[r.id]??a7(),i=r.secret?e.other:e.other.trim(),a=[...e.selected];(r.allowOther||r.options.length===0)&&i!==``&&a.push(i);let o=r.multiSelect?a:a.slice(-1);if(o.length===0)return{ok:!1,problem:{code:`missing`,questionId:r.id}};if(o.some(e=>e.length>8e3))return{ok:!1,problem:{code:`too_long`,questionId:r.id}};n.push({id:r.id,values:o})}return{ok:!0,answers:n}}function s7(e,t){return e.filter(e=>i7(e,t)).sort((e,t)=>e.expiresAt-t.expiresAt)}function xoe(e,t){if(e.source!==`hermes.approval`||e.answerById)return null;let n=e.seq??e.createdAt;return t.filter(t=>t._id!==e._id&&t.source===`hermes.approval`&&!t.answerById&&!t.answerById&&t.queueKey===e.queueKey&&(t.status===`pending`||t.status===`submitting`)&&(t.seq??t.createdAt)<n).sort((e,t)=>(e.seq??e.createdAt)-(t.seq??t.createdAt))[0]??null}function Soe(e,t){return e.source!==`hermes.approval`||e.answerById?!1:t.some(t=>t._id!==e._id&&t.source===`hermes.approval`&&!t.answerById&&t.queueKey===e.queueKey&&(t.status===`pending`||t.status===`submitting`))}function Coe(e,t){let n=s7(e,t),r=new Set(n.map(e=>e._id));return{waiting:n,history:e.filter(e=>!r.has(e._id)).sort((e,t)=>(t.resolvedAt??t.createdAt)-(e.resolvedAt??e.createdAt))}}function woe(e,t){if(r7(e.status)&&e.expiresAt<=t)return`expired`;switch(e.status){case`answered`:return e.resolvedElsewhere?`answered_elsewhere`:`answered`;case`allowed`:return e.gatewayFailed===!0?`not_run`:e.resolvedElsewhere?`allowed_elsewhere`:e.decision===`allow-always`?`allowed_always`:e.decision===`allow-session`?`allowed_session`:`allowed_once`;case`denied`:return e.resolvedElsewhere?`denied_elsewhere`:`denied`;case`expired`:return`expired`;case`cancelled`:return e.answeredByMe?`skipped`:`cancelled`;case`failed`:return`failed`;default:return null}}function Toe(e){return e===`not_run`}function c7(e){return e===null?`none`:e===`not_configured`||e===`instance_not_served`||e===`provider_mismatch`?`config`:`retry`}function Eoe(e,t){return e??t}var l7=(0,q.createContext)(null);function u7(){return(0,q.useContext)(l7)}function Doe(e){let[t,n]=(0,q.useState)(()=>Date.now());return(0,q.useEffect)(()=>{let t=window.setInterval(()=>n(Date.now()),e?1e3:3e4);return()=>window.clearInterval(t)},[e]),t}function Ooe(e){let t=document.querySelector(`.oc-thread__viewport [data-agent-request-id="${CSS.escape(e._id)}"]`)??(e.messageId===null?null:document.querySelector(`[data-message-id="${CSS.escape(e.messageId)}"]`));if(!t)return;let n=t.closest(`.oc-thread__viewport`);if(RK(n),n){let e=t.getBoundingClientRect().top-n.getBoundingClientRect().top;n.scrollTo({top:n.scrollTop+e-Math.max(24,n.clientHeight*.25),behavior:`smooth`})}else t.scrollIntoView({block:`center`,behavior:`smooth`});t.classList.remove(`oc-areq--flash`),t.offsetWidth,t.classList.add(`oc-areq--flash`),window.setTimeout(()=>t.classList.remove(`oc-areq--flash`),2200)}function koe({chatId:e,children:t}){let n=H(G.agentRequests.listForChat,{chatId:e}),r=(0,q.useMemo)(()=>n??[],[n]),i=Doe(r.some(e=>r7(e.status))),a=Aa(G.agentRequests.answer),[o,s]=(0,q.useState)(!1),c=(0,q.useCallback)(async(e,t)=>{try{let n=await a({requestId:e,...t});return n.ok?{ok:!0}:{ok:!1,reason:n.reason}}catch{return{ok:!1,reason:`unreachable`}}},[a]),l=(0,q.useMemo)(()=>{let e=new Map;for(let t of[...r].sort((e,t)=>e.createdAt-t.createdAt)){if(t.messageId===null)continue;let n=e.get(t.messageId)??[];n.push(t),e.set(t.messageId,n)}return e},[r]),u=(0,q.useMemo)(()=>s7(r,i),[r,i]),d=(0,q.useMemo)(()=>({rows:r,now:i,byMessage:l,waiting:u,answer:c,openPanel:()=>s(!0),jumpTo:e=>{s(!1),window.setTimeout(()=>Ooe(e),120)}}),[r,i,l,u,c]);return(0,J.jsxs)(l7.Provider,{value:d,children:[t,(0,J.jsx)(Woe,{open:o,onOpenChange:s})]})}var d7=`atrium.agentRequests.folded`;function f7(){try{let e=window.localStorage.getItem(d7),t=e?JSON.parse(e):[];return new Set(Array.isArray(t)?t.filter(e=>typeof e==`string`):[])}catch{return new Set}}function Aoe(e){try{window.localStorage.setItem(d7,JSON.stringify([...e].slice(-200)))}catch{}}function joe(e,t){let[n,r]=(0,q.useState)(()=>t&&f7().has(e)?!1:null);return[n??t,(0,q.useCallback)(n=>{if(r(n),!t)return;let i=f7();n?i.delete(e):i.add(e),Aoe(i)},[e,t])]}var p7={question:YA,approval:BC,critical:dj,credential:zA};function m7(e){switch(e){case`question`:return Xu();case`approval`:return Cd();case`critical`:return vi();case`credential`:return Mv()}}function Moe(e,t){let n=goe(e,t);switch(n.unit){case`expired`:return{text:jl(),urgent:!0};case`seconds`:return{text:Gi({value:String(n.value)}),urgent:!0};case`minutes`:return{text:Kn({value:String(n.value)}),urgent:n.urgent};case`hours`:return{text:Tu({value:String(n.value)}),urgent:!1}}}var Noe={answered:()=>Em(),answered_elsewhere:()=>v(),skipped:()=>js(),allowed_once:()=>Vd(),allowed_session:()=>Hu(),allowed_always:()=>md(),allowed_elsewhere:()=>li(),not_run:()=>Cv(),denied:()=>Rn(),denied_elsewhere:()=>gu(),expired:()=>Sl(),cancelled:()=>lr(),failed:()=>Kl()},h7={"allow-once":()=>bn(),"allow-session":()=>hs(),"allow-always":()=>_o(),deny:()=>Ua()},Poe={"message-send":()=>$e(),payment:()=>Pc(),"external-post":()=>Mte(),"standing-grant":()=>lp()};function g7(e){if(e.startsWith(`AGENT_REQUEST_INVALID_ANSWER`))return Tp();switch(e){case`AGENT_REQUEST_EXPIRED`:return Dc();case`request_gone`:case`AGENT_REQUEST_NOT_PENDING`:return wte();case`AGENT_REQUEST_OWNER_ONLY`:return qe();case`AGENT_REQUEST_READ_ONLY`:return Ic();case`AGENT_REQUEST_AGENT_NOT_IN_ROOM`:return Pte();case`AGENT_REQUEST_IMPERSONATING`:return np();case`AGENT_REQUEST_ANSWER_OLDEST_FIRST`:return Qb();case`AGENT_REQUEST_DECISION_NOT_OFFERED`:return lf();case`session_mismatch`:return Pee();case`approval_order_unknown`:return $_();case`approval_ambiguous`:return e_();case`AGENT_REQUEST_CLIPPED`:return Jp();case`invalid_answer`:return Tp();default:return c7(e)===`config`?Zm():xh()}}function Foe(e){if(e.status!==`answered`||e.answers===null)return null;if(e.kind===`credential`||e.questions?.some(e=>e.secret))return we();let t=e.answers.flatMap(e=>e.values).filter(e=>e!==``);return t.length>0?t.join(` · `):null}function _7({request:e,mode:t,open:n,onToggle:r}){let i=u7(),a=i?.now??Date.now(),o=n7(e),s=p7[o],c=i7(e,a),l=woe(e,a),[u,d]=joe(e._id,c||Toe(l)),f=n??u,p=r??d,m=(0,q.useId)(),h=c&&hoe(e)?Moe(e.expiresAt,a):null,g=i&&c?xoe(e,i.rows):null,_=_oe(e),v=Foe(e);return(0,J.jsxs)(`section`,{className:[`oc-areq`,`oc-areq--${o}`,`oc-areq--${t}`,c?`oc-areq--waiting`:`oc-areq--settled`,f?`oc-areq--open`:``].join(` `),"data-agent-request-id":e._id,"aria-label":`${m7(o)} — ${_}`,children:[(0,J.jsxs)(`header`,{className:`oc-areq__head`,children:[(0,J.jsx)(`span`,{className:`oc-areq__icon`,"aria-hidden":!0,children:(0,J.jsx)(s,{size:15})}),(0,J.jsxs)(`button`,{type:`button`,className:`oc-areq__toggle`,"aria-expanded":f,"aria-controls":m,title:f?la():nc(),onClick:()=>p(!f),children:[(0,J.jsx)(`span`,{className:`oc-areq__kind`,children:m7(o)}),!f||!c?(0,J.jsx)(`span`,{className:`oc-areq__summary`,children:_}):null]}),l===null?null:(0,J.jsxs)(`span`,{className:`oc-areq__outcome oc-areq__outcome--${l}`,children:[l.startsWith(`allowed`)||l===`answered`?(0,J.jsx)(ZS,{size:12,"aria-hidden":!0}):l.startsWith(`denied`)?(0,J.jsx)(YC,{size:12,"aria-hidden":!0}):null,Noe[l](),v!==null&&!f?(0,J.jsx)(`span`,{className:`oc-areq__outcome-detail`,children:v}):null]}),e.status===`submitting`?(0,J.jsx)(`span`,{className:`oc-areq__outcome oc-areq__outcome--sending`,children:_x()}):null,h!==null&&e.status===`pending`?(0,J.jsxs)(`span`,{className:`oc-areq__timer${h.urgent?` oc-areq__timer--urgent`:``}`,title:new Date(e.expiresAt).toLocaleTimeString(),children:[(0,J.jsx)(xj,{size:12,"aria-hidden":!0}),h.text]}):null,t!==`inline`&&i?(0,J.jsx)(`button`,{type:`button`,className:`oc-areq__iconbtn`,title:Fr(),"aria-label":Fr(),onClick:()=>i.jumpTo(e),children:(0,J.jsx)(GA,{size:14})}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-areq__iconbtn`,"aria-hidden":!0,tabIndex:-1,onClick:()=>p(!f),children:f?(0,J.jsx)(tC,{size:14}):(0,J.jsx)(QS,{size:14})})]}),f?(0,J.jsx)(`div`,{className:`oc-areq__body`,id:m,children:(0,J.jsx)(Ioe,{request:e,waiting:c,blocker:g,outcome:l})}):null]})}function Ioe({request:e,waiting:t,blocker:n,outcome:r}){let i=u7(),a=i!==null&&Soe(e,i.rows),o=t&&e.status===`pending`&&e.canAnswer&&n===null&&!a,s=t?e.canAnswer?a?e_():n===null?null:Qb():qe():null;return(0,J.jsxs)(J.Fragment,{children:[e.kind===`approval`&&e.approval?(0,J.jsx)(Boe,{request:e,answerable:o}):e.questions===null?(0,J.jsx)(Voe,{request:e,answerable:o}):(0,J.jsx)(Loe,{request:e,answerable:o}),s===null?null:(0,J.jsx)(`p`,{className:`oc-areq__note`,children:s}),r===`not_run`?(0,J.jsx)(`p`,{className:`oc-areq__note oc-areq__note--not-run`,role:`note`,children:Ii()}):null]})}function v7(e){let t=u7(),[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(null),o=(0,q.useCallback)(async n=>{if(!t)return!1;r(!0),a(null);let i=await t.answer(e._id,n);return r(!1),i.ok||a(g7(i.reason)),i.ok},[t,e._id]),s=e.status===`pending`&&c7(e.failureCode)!==`none`?g7(e.failureCode):null;return{busy:n||e.status===`submitting`,sending:n,error:i??s,setError:a,submit:o}}function Loe({request:e,answerable:t}){let n=e.questions??[],[r,i]=(0,q.useState)({}),{busy:a,sending:o,error:s,setError:c,submit:l}=v7(e),u=e.answers,d=r7(e.status),f=!d||!t&&!o;(0,q.useEffect)(()=>{f&&i({})},[f]);let p=async()=>{let e=boe(n,r);if(!e.ok){c(e.problem.code===`missing`?ax():Ab());return}await l({answers:e.answers})&&i({})};return(0,J.jsxs)(`form`,{className:`oc-areq__form`,onSubmit:e=>{e.preventDefault(),p()},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),p())},children:[n.map(e=>(0,J.jsx)(Roe,{question:e,draft:r[e.id]??a7(),disabled:!t||a,closed:!d,settled:u?.find(t=>t.id===e.id)?.values??null,onChange:t=>{c(null),i(n=>({...n,[e.id]:t}))}},e.id)),s===null?null:(0,J.jsx)(`p`,{className:`oc-areq__error`,role:`alert`,children:s}),t?(0,J.jsxs)(`div`,{className:`oc-areq__actions`,children:[(0,J.jsx)(K,{type:`button`,variant:`ghost`,size:`sm`,disabled:a,title:Ne(),onClick:()=>{i({}),l({skip:!0})},children:tu()}),(0,J.jsx)(K,{type:`submit`,size:`sm`,disabled:a,children:a?_x():_r()})]}):null]})}function Roe({question:e,draft:t,disabled:n,closed:r,settled:i,onChange:a}){let o=(0,q.useId)(),s=e.options.length===0,[c,l]=(0,q.useState)(!1),u=i??t.selected;return(0,J.jsxs)(`fieldset`,{className:`oc-areq__q`,"aria-labelledby":o,disabled:n,children:[(0,J.jsxs)(`div`,{className:`oc-areq__qhead`,id:o,children:[e.header?(0,J.jsx)(`span`,{className:`oc-areq__qchip`,children:e.header}):null,(0,J.jsx)(`span`,{className:`oc-areq__qtext`,children:e.text})]}),e.store?(0,J.jsx)(zoe,{store:e.store}):null,e.url?(0,J.jsxs)(`a`,{className:`oc-areq__link`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:[(0,J.jsx)(CA,{size:13,"aria-hidden":!0}),Wr()]}):null,e.options.length>0?(0,J.jsxs)(`div`,{className:`oc-areq__options${yoe(e.options.length)?` oc-areq__options--many`:``}`,role:e.multiSelect?`group`:`radiogroup`,"aria-labelledby":o,children:[e.options.map(r=>{let o=u.includes(r.label);return(0,J.jsxs)(`button`,{type:`button`,className:`oc-areq__option${o?` oc-areq__option--on`:``}`,role:e.multiSelect?`checkbox`:`radio`,"aria-checked":o,disabled:n||i!==null,onClick:()=>a(voe(e,t,r.label)),children:[(0,J.jsx)(`span`,{className:`oc-areq__option-mark`,"aria-hidden":!0,children:o?(0,J.jsx)(ZS,{size:11}):null}),(0,J.jsxs)(`span`,{className:`oc-areq__option-text`,children:[(0,J.jsx)(`span`,{className:`oc-areq__option-label`,title:r.label.length>120?r.label:void 0,children:r.label}),r.description?(0,J.jsx)(`span`,{className:`oc-areq__option-desc`,children:r.description}):null]})]},r.label)}),e.multiSelect?(0,J.jsx)(`span`,{className:`oc-areq__hint`,children:va()}):null]}):null,!r&&i===null&&(e.allowOther||s)?e.secret?(0,J.jsxs)(`div`,{className:`oc-areq__secret`,children:[(0,J.jsx)(`input`,{className:`oc-areq__input`,type:c?`text`:`password`,autoComplete:`off`,spellCheck:!1,placeholder:ov(),value:t.other,onChange:n=>a(o7(e,t,n.target.value))}),(0,J.jsx)(`button`,{type:`button`,className:`oc-areq__iconbtn`,title:c?mb():rm(),"aria-label":c?mb():rm(),onClick:()=>l(e=>!e),children:c?(0,J.jsx)(xC,{size:14}):(0,J.jsx)(SC,{size:14})})]}):s?(0,J.jsx)(`textarea`,{className:`oc-areq__input oc-areq__input--area`,rows:2,placeholder:dc(),value:t.other,onChange:n=>a(o7(e,t,n.target.value))}):(0,J.jsx)(`input`,{className:`oc-areq__input`,type:`text`,placeholder:Tx(),value:t.other,onChange:n=>a(o7(e,t,n.target.value))}):null,i!==null&&i.length>0&&e.options.length===0&&!e.secret?(0,J.jsx)(`p`,{className:`oc-areq__given`,children:i.join(` · `)}):null,e.secret?(0,J.jsx)(`p`,{className:`oc-areq__hint`,children:e.store?Rf():n_()}):null]})}function zoe({store:e}){return(0,J.jsxs)(`div`,{className:`oc-areq__facts`,children:[(0,J.jsx)(`span`,{className:`oc-areq__fact oc-areq__fact--mono`,children:Mp({name:e.name})}),e.allowedHosts?(0,J.jsx)(`span`,{className:`oc-areq__fact`,children:by({hosts:e.allowedHosts.join(`, `)})}):null,e.replacesSinceMs===void 0?null:(0,J.jsx)(`span`,{className:`oc-areq__fact oc-areq__fact--warning`,children:L_({date:new Date(e.replacesSinceMs).toLocaleDateString()})}),e.reason?(0,J.jsx)(`span`,{className:`oc-areq__fact`,children:e.reason}):null]})}function Boe({request:e,answerable:t}){let n=e.approval,{busy:r,error:i,submit:a}=v7(e),[o,s]=(0,q.useState)(!1),c=n.decisions.filter(e=>e!==`deny`);return(0,J.jsxs)(`div`,{className:`oc-areq__approval`,children:[n.title?(0,J.jsx)(`p`,{className:`oc-areq__title`,children:n.title}):null,n.description?(0,J.jsx)(`p`,{className:`oc-areq__desc`,children:n.description}):null,n.command?(0,J.jsxs)(`pre`,{className:`oc-areq__command`,"aria-label":Uo(),children:[(0,J.jsx)(_j,{size:13,"aria-hidden":!0,className:`oc-areq__command-icon`}),(0,J.jsx)(`code`,{children:n.command})]}):null,n.warning?(0,J.jsxs)(`p`,{className:`oc-areq__warning`,children:[(0,J.jsx)(dj,{size:13,"aria-hidden":!0}),n.warning]}):null,n.clipped?(0,J.jsxs)(`p`,{className:`oc-areq__warning`,role:`note`,children:[(0,J.jsx)(dj,{size:13,"aria-hidden":!0}),cee()]}):null,n.detail?(0,J.jsxs)(`details`,{className:`oc-areq__detail`,children:[(0,J.jsx)(`summary`,{children:wt()}),(0,J.jsx)(`pre`,{children:n.detail})]}):null,(0,J.jsxs)(`div`,{className:`oc-areq__facts`,children:[n.severity&&n.severity!==`info`?(0,J.jsx)(`span`,{className:`oc-areq__fact oc-areq__fact--${n.severity}`,children:n.severity===`critical`?Oh():ah()}):null,n.scope?(0,J.jsxs)(`span`,{className:`oc-areq__fact`,children:[(Poe[n.scope.kind]??(()=>n.scope.kind))(),` · `,n.scope.summary]}):null,n.scope?.external?(0,J.jsx)(`span`,{className:`oc-areq__fact oc-areq__fact--warning`,children:Yte()}):null,n.scope?.grantDays===void 0?null:(0,J.jsx)(`span`,{className:`oc-areq__fact`,children:Ib({days:String(n.scope.grantDays)})}),n.host?(0,J.jsx)(`span`,{className:`oc-areq__fact`,children:lte({host:n.host})}):null,n.nodeId?(0,J.jsx)(`span`,{className:`oc-areq__fact`,children:qt({node:n.nodeId})}):null,n.pluginId?(0,J.jsx)(`span`,{className:`oc-areq__fact`,children:al({plugin:n.pluginId})}):null,n.toolName?(0,J.jsx)(`span`,{className:`oc-areq__fact oc-areq__fact--mono`,children:n.toolName}):null]}),i===null?null:(0,J.jsx)(`p`,{className:`oc-areq__error`,role:`alert`,children:i}),t?o?(0,J.jsxs)(`div`,{className:`oc-areq__confirm`,role:`group`,"aria-label":vg(),children:[(0,J.jsx)(`p`,{children:n.scope?.grantDays===void 0?oe():gf({days:String(n.scope.grantDays)})}),(0,J.jsxs)(`div`,{className:`oc-areq__actions`,children:[(0,J.jsx)(K,{type:`button`,variant:`ghost`,size:`sm`,disabled:r,onClick:()=>s(!1),children:Bg()}),(0,J.jsx)(K,{type:`button`,size:`sm`,disabled:r,onClick:()=>void a({decision:`allow-always`}),children:vg()})]})]}):(0,J.jsxs)(`div`,{className:`oc-areq__actions`,children:[(0,J.jsx)(K,{type:`button`,variant:`destructive`,size:`sm`,disabled:r,onClick:()=>void a({decision:`deny`}),children:h7.deny()}),(0,J.jsx)(`span`,{className:`oc-areq__spacer`}),c.filter(e=>e!==`allow-once`).map(e=>(0,J.jsx)(K,{type:`button`,variant:`outline`,size:`sm`,disabled:r,onClick:()=>e===`allow-always`?s(!0):void a({decision:e}),children:h7[e]()},e)),c.includes(`allow-once`)?(0,J.jsx)(K,{type:`button`,size:`sm`,disabled:r,onClick:()=>void a({decision:`allow-once`}),children:r?_x():h7[`allow-once`]()}):null]}):null]})}function Voe({request:e,answerable:t}){let n=e.credential,[r,i]=(0,q.useState)(``),[a,o]=(0,q.useState)(!1),{busy:s,sending:c,error:l,setError:u,submit:d}=v7(e),f=n?.mode===`password`,p=!r7(e.status)||!t&&!c;(0,q.useEffect)(()=>{p&&i(``)},[p]);let m=(0,q.useRef)(null);return(0,J.jsxs)(`form`,{className:`oc-areq__form`,onSubmit:e=>{if(e.preventDefault(),r.length===0){u(ax());return}d({secret:r}).then(e=>{e&&i(``)})},children:[(0,J.jsx)(`p`,{className:`oc-areq__desc`,children:n?.prompt??(f?p_():Uy())}),n?.command?(0,J.jsxs)(`pre`,{className:`oc-areq__command`,"aria-label":Uo(),children:[(0,J.jsx)(_j,{size:13,"aria-hidden":!0,className:`oc-areq__command-icon`}),(0,J.jsx)(`code`,{children:n.command})]}):null,n?.envVar?(0,J.jsx)(`span`,{className:`oc-areq__fact oc-areq__fact--mono`,children:Bee({name:n.envVar})}):null,n?.clipped||n?.commandMissing?(0,J.jsxs)(`p`,{className:`oc-areq__warning`,role:`note`,children:[(0,J.jsx)(dj,{size:13,"aria-hidden":!0}),n.clipped?Jp():ab()]}):null,t&&!n?.clipped&&!n?.commandMissing?(0,J.jsxs)(`div`,{className:`oc-areq__secret`,children:[(0,J.jsx)(`input`,{ref:m,className:`oc-areq__input`,type:a?`text`:`password`,autoComplete:f?`current-password`:`off`,spellCheck:!1,placeholder:f?Im():ov(),value:r,onChange:e=>{u(null),i(e.target.value)}}),(0,J.jsx)(`button`,{type:`button`,className:`oc-areq__iconbtn`,title:a?mb():rm(),"aria-label":a?mb():rm(),onClick:()=>{o(e=>!e),m.current?.focus()},children:a?(0,J.jsx)(xC,{size:14}):(0,J.jsx)(SC,{size:14})})]}):null,(0,J.jsx)(`p`,{className:`oc-areq__hint`,children:n_()}),l===null?null:(0,J.jsx)(`p`,{className:`oc-areq__error`,role:`alert`,children:l}),t?(0,J.jsxs)(`div`,{className:`oc-areq__actions`,children:[(0,J.jsx)(K,{type:`button`,variant:`ghost`,size:`sm`,disabled:s,onClick:()=>{i(``),d({skip:!0})},children:Qv()}),n?.clipped||n?.commandMissing?null:(0,J.jsx)(K,{type:`submit`,size:`sm`,disabled:s,children:s?_x():Yh()})]}):null]})}function Hoe(){let e=u7(),t=$(e=>e.id),n=e?.byMessage.get(t);return!n||n.length===0?null:(0,J.jsx)(`div`,{className:`oc-areq-inline`,children:n.map(e=>(0,J.jsx)(_7,{request:e,mode:`inline`},e._id))})}function Uoe(){let e=u7(),[t,n]=(0,q.useState)(!1),[r,i]=(0,q.useState)(null),a=$q(),[o,s]=(0,q.useState)(null),c=Eoe(o,a),l=(0,q.useId)(),u=e?.waiting??[];if((0,q.useEffect)(()=>{r!==null&&!u.some(e=>e._id===r)&&i(null)},[r,u]),!e||u.length===0)return null;let d=u[0],f=n7(d),p=p7[f],m=t?u:[d],h=u.length-1;return(0,J.jsxs)(`div`,{className:`oc-areq-dock oc-areq-dock--${f}`,role:`region`,"aria-label":dn(),children:[(0,J.jsxs)(`div`,{className:`oc-areq-dock__bar`,children:[(0,J.jsx)(`span`,{className:`oc-areq-dock__pulse`,"aria-hidden":!0,children:(0,J.jsx)(p,{size:14})}),(0,J.jsx)(`span`,{className:`oc-areq-dock__title`,children:dn()}),h>0?(0,J.jsxs)(`button`,{type:`button`,className:`oc-areq-dock__count`,"aria-expanded":t,title:t?la():nc(),onClick:()=>n(e=>!e),children:[os({count:String(u.length)}),t?(0,J.jsx)(QS,{size:12,"aria-hidden":!0}):(0,J.jsx)(tC,{size:12,"aria-hidden":!0})]}):null,(0,J.jsx)(`span`,{className:`oc-areq__spacer`}),(0,J.jsx)(`button`,{type:`button`,className:`oc-areq__iconbtn`,title:so(),"aria-label":so(),onClick:e.openPanel,children:(0,J.jsx)(LA,{size:14})}),(0,J.jsx)(`button`,{type:`button`,className:`oc-areq__iconbtn`,title:c?nc():la(),"aria-label":c?nc():la(),"aria-expanded":!c,"aria-controls":l,onClick:()=>s(!c),children:c?(0,J.jsx)(tC,{size:14}):(0,J.jsx)(QS,{size:14})})]}),(0,J.jsx)(`div`,{className:`oc-areq-dock__list`,id:l,hidden:c,children:m.map(e=>(0,J.jsx)(_7,{request:e,mode:`dock`,open:r===e._id,onToggle:t=>i(t?e._id:null)},e._id))})]})}function Woe({open:e,onOpenChange:t}){let n=u7(),[r,i]=(0,q.useState)(`all`),a=(0,q.useMemo)(()=>n?Coe(n.rows,n.now):{waiting:[],history:[]},[n]),o=e=>{if(r===`all`)return!0;let t=n7(e);return r===`approval`?t===`approval`||t===`critical`:t===r},s=a.waiting.filter(o),c=a.history.filter(o);return(0,J.jsx)(ST,{open:e,onOpenChange:t,children:(0,J.jsxs)(xT,{side:`right`,className:`oc-areq-panel`,children:[(0,J.jsxs)(CT,{children:[(0,J.jsx)(bT,{children:so()}),(0,J.jsx)(yT,{children:La()})]}),(0,J.jsx)(`div`,{className:`oc-areq-panel__filters`,role:`tablist`,"aria-label":Po(),children:[`all`,`question`,`approval`,`credential`].map(e=>(0,J.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r===e,className:`oc-areq-panel__filter${r===e?` oc-areq-panel__filter--on`:``}${e===`all`?``:` oc-areq-panel__filter--${e}`}`,onClick:()=>i(e),children:e===`all`?gt():m7(e)},e))}),(0,J.jsxs)(`div`,{className:`oc-areq-panel__body`,children:[s.length===0&&c.length===0?(0,J.jsx)(`p`,{className:`oc-areq-panel__empty`,children:Ng()}):null,s.length>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`h3`,{className:`oc-areq-panel__section`,children:[fg(),` `,(0,J.jsx)(`span`,{className:`oc-areq-panel__n`,children:s.length})]}),s.map(e=>(0,J.jsx)(_7,{request:e,mode:`panel`},e._id))]}):null,c.length>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h3`,{className:`oc-areq-panel__section`,children:V()}),c.map(e=>(0,J.jsx)(_7,{request:e,mode:`panel`},e._id))]}):null]})]})})}function Goe({compact:e=!1,ghost:t=!1}){let n=u7();if(!n||n.rows.length===0)return null;let r=n.waiting.length,i=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(LA,{size:13,"aria-hidden":!0}),e?null:(0,J.jsx)(`span`,{className:`oc-chip__label`,children:Bt()}),r>0?(0,J.jsx)(`span`,{className:`oc-areq-headbadge`,children:r}):null]}),a=`oc-chip oc-chip--btn${r>0?` oc-chip--areq`:``}`;return t?(0,J.jsx)(`span`,{className:a,children:i}):(0,J.jsx)(`button`,{type:`button`,className:a,title:r>0?Zc({count:String(r)}):so(),onClick:n.openPanel,children:i})}var y7={showSource:!0,showReport:!0,copyAssistant:!0,copyUser:!0,showDelete:!0,showTools:!1,voiceInput:!1,showUsage:!0,autoReadAloud:!0},b7=(0,q.createContext)({enabled:!1,lang:`auto`,rate:1,autoRead:!1,engine:`browser`,loaded:!1}),x7=(0,q.createContext)({active:null,setActive:()=>{},clearIf:()=>{}}),S7=0;function C7(){S7++,US(),zS()}var w7=(0,q.createContext)(y7);function T7(){return(0,q.useContext)(w7)}var E7=(0,q.createContext)(null),D7=(0,q.createContext)(null),O7=(0,q.createContext)(null),k7=(0,q.createContext)(!0),A7=(0,q.createContext)(null),j7=(0,q.createContext)(null);function M7(){return(0,q.useContext)(j7)}function N7({className:e}){let t=o4();return(0,J.jsx)(`div`,{className:e,"aria-hidden":!0,children:t.logoUrl?t.logoMasked?(0,J.jsx)(`span`,{className:`oc-avatar__img oc-avatar__img--mask`,style:{"--oc-logo-url":`url("${t.logoUrl}")`}}):(0,J.jsx)(`img`,{className:`oc-avatar__img`,src:t.logoUrl,alt:``}):t.isDefault?(0,J.jsx)(i4,{className:`oc-avatar__mark`}):t.initials})}function P7({chatId:e,focusMessageId:t}){let{runtime:n,turnGate:r,queueSend:i,abortTurn:a,routing:o,lastUserTurnQueued:s,queuedTurns:c,cancelQueued:l,withdrawGatewayQueued:u,gatewayOthers:d,initialLoading:f}=Bre({chatId:e}),{can:p}=kT(e),m=H(G.me.getMe,{host:hT}),h=m?.ui?.effective??y7,g=H(G.messages.getSessionMeta,e?{chatId:e}:`skip`)?.viewerRole===`participant`,_=(0,q.useMemo)(()=>g?{...h,showDelete:!1,showReport:!1}:h,[g,h]),v=h.showTools,y=qC(m?.resolvedThemeMode),b=m?.resolvedChartBrand,x=m?.resolvedChartTokens,S=H(G.agents.getChatAgent,e?{chatId:e}:`skip`),C=S?.multiAgent?S.agent:null,w=(0,q.useMemo)(()=>{let e=b?.label??`Atrium`,t=x?.colors?.[y],n=n4(t?.primary,t?.[`primary-foreground`],y),r=$2(b,n);return{label:e,logoUrl:r?.url??null,logoMasked:r?.masked??!1,isDefault:b?.isDefault??!0,initials:r4(e),agentName:C?.displayName??C?.agentId??null,agentEmoji:C?.emoji??null}},[b,y,x,C]),T=U(G.me.setUiPref).withOptimisticUpdate(Nw),E=H(G.messages.getSessionMeta,e?{chatId:e}:`skip`),D=e!==null&&E===null,O=m?.userId??``,k=e??null,A=Qq(),j=R1(),M=L1((0,q.useSyncExternalStore)(w1,T1,T1),{userId:O,chatId:k}),N=S?.agent?.instanceName??null,P=(0,q.useCallback)((e,t)=>{E1({kind:e,ownerUserId:O,originChatId:k,originLabel:E?.title||C_(),params:t})},[O,k,E?.title]),F=(0,q.useCallback)(()=>{M!==null&&O1(M.pinId)},[M]),I=M?.kind===`sources`?M.params.messageId:null,L=M?.kind===`subagent`?M.params.childKey:null,R=M?.kind===`document`?M.params.doc:null,z=M?.kind===`cron`?M.params:null,B=(0,q.useMemo)(()=>({activeMessageId:I,openFor:e=>P(`sources`,{messageId:e}),close:F}),[I,P,F]),V=s4(w),ee=(0,q.useMemo)(()=>({activeChildKey:L,openFor:e=>P(`subagent`,{childKey:e,parentAgentLabel:V}),close:F}),[L,V,P,F]),te=jJ;(0,q.useEffect)(()=>()=>{te.current=null},[te]);let ne=(0,q.useMemo)(()=>({activeDoc:R,openFor:e=>P(`document`,{doc:e}),openNewerVersion:e=>{M===null?P(`document`,{doc:e}):k1(M.pinId,{doc:e})},close:F}),[R,M,P,F]),re=(0,q.useMemo)(()=>({active:z,openFor:(e,t,n)=>{let r=t??N;r!==null&&P(`cron`,{instanceName:r,jobId:e.jobId??null,part:e,occurrenceId:n})},close:F}),[z,N,P,F]),ie=I!==null,ae=L!==null,oe=R!==null,se=z!==null,ce=M?.kind??null,le=M?.params??null,ue=ce===null?null:j1(ce,le??{}),de=se||oe||ae||ie,fe=ce===null||M1(j,oe?380:ae?320:300),pe=de&&(A||!fe)&&M?.pinned!==!0,me=H(G.voice.voiceConfigForChat,e?{chatId:e}:`skip`),[he,ge]=(0,q.useState)(null),_e=(0,q.useMemo)(()=>({active:he,setActive:ge,clearIf:e=>ge(t=>t?.messageId===e?null:t)}),[he]);(0,q.useEffect)(()=>{C7(),ge(null)},[e]);let ve=(0,q.useMemo)(()=>me?{...me,loaded:!0}:{enabled:!1,lang:`auto`,rate:1,autoRead:!1,engine:`browser`,loaded:!1},[me]);return(0,J.jsx)(kV,{runtime:n,children:(0,J.jsx)(b7.Provider,{value:ve,children:(0,J.jsx)(x7.Provider,{value:_e,children:(0,J.jsx)(E7.Provider,{value:r,children:(0,J.jsx)(D7.Provider,{value:i,children:(0,J.jsx)(c5.Provider,{value:{queuedTurns:c,cancelQueued:l,withdrawGatewayQueued:u,canWithdrawGateway:p(`discardPendingInput`),gatewayOthers:d},children:(0,J.jsx)(A7.Provider,{value:e,children:(0,J.jsx)(O7.Provider,{value:g?null:a,children:(0,J.jsx)(k7.Provider,{value:!g,children:(0,J.jsx)(l5.Provider,{value:s,children:(0,J.jsx)(j7.Provider,{value:o,children:(0,J.jsx)(w7.Provider,{value:_,children:(0,J.jsx)(a4.Provider,{value:w,children:(0,J.jsx)(gY.Provider,{value:B,children:(0,J.jsx)(l1.Provider,{value:ee,children:(0,J.jsx)(sq.Provider,{value:re,children:(0,J.jsx)(MJ.Provider,{value:te,children:(0,J.jsx)(zJ.Provider,{value:ne,children:(0,J.jsxs)(nY,{children:[(0,J.jsx)(`div`,{className:`oc-chat`,children:(0,J.jsx)(`div`,{className:`oc-chat__convo`,children:e?D?(0,J.jsx)(Koe,{}):(0,J.jsx)(Qoe,{chatId:e,showTools:v,onToggleTools:()=>void T({key:`showTools`,value:!v}),focusMessageId:t??null,initialLoading:f}):(0,J.jsx)(`div`,{className:`oc-empty`,children:Sb()})})}),ie&&pe?(0,J.jsx)(ST,{open:!0,onOpenChange:e=>{e||B.close()},children:(0,J.jsx)(xT,{side:`right`,className:`oc-sources-panel-sheet`,showCloseButton:!1,children:(0,J.jsx)(hq,{onClose:F,children:(0,J.jsx)(yY,{messageId:I,onClose:B.close})},ue??`none`)})}):null,ae&&pe?(0,J.jsx)(ST,{open:!0,onOpenChange:e=>{e||ee.close()},children:(0,J.jsx)(xT,{side:`right`,className:`oc-sources-panel-sheet`,showCloseButton:!1,children:(0,J.jsx)(hq,{onClose:F,children:(0,J.jsx)(v1,{chatId:e,childKey:L,onClose:ee.close,parentAgentLabel:s4(w)})},ue??`none`)})}):null,se&&pe?(0,J.jsx)(ST,{open:!0,onOpenChange:e=>{e||re.close()},children:(0,J.jsx)(xT,{side:`right`,className:`oc-sources-panel-sheet`,showCloseButton:!1,children:(0,J.jsx)(hq,{onClose:F,children:(0,J.jsx)(mq,{instanceName:z.instanceName,part:z.part,onClose:re.close})},ue??`none`)})}):null,oe&&pe?(0,J.jsx)(ST,{open:!0,onOpenChange:e=>{e||ne.close()},children:(0,J.jsx)(xT,{side:`right`,className:`oc-sources-panel-sheet oc-docviewer-sheet`,showCloseButton:!1,children:(0,J.jsx)(hq,{onClose:F,children:(0,J.jsx)(VJ,{doc:R,chatId:e,onClose:ne.close})},ue??`none`)})}):null]})})})})})})})})})})})})})})})})})})})}function Koe(){let e=Kx();return(0,J.jsxs)(`div`,{className:`oc-notfound`,role:`status`,children:[(0,J.jsx)(`div`,{className:`oc-notfound__icon`,"aria-hidden":!0,children:(0,J.jsx)(vC,{size:28})}),(0,J.jsx)(`h2`,{className:`oc-notfound__title`,children:tf()}),(0,J.jsx)(`p`,{className:`oc-notfound__body`,children:Wm()}),(0,J.jsxs)(`button`,{type:`button`,className:`oc-notfound__cta`,onClick:()=>void e({to:`/`}),children:[(0,J.jsx)(LC,{size:16,"aria-hidden":!0}),mh()]})]})}function qoe(e,t){let n=CSS.highlights,r=window.Highlight;if(!n||!r)return null;let i=t.map(e=>e.toLowerCase()).filter(e=>e.length>=2);if(i.length===0)return null;let a=[],o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let e=o.nextNode();e;e=o.nextNode()){let t=(e.textContent??``).toLowerCase();for(let n of i){let r=t.indexOf(n);for(;r!==-1;){let i=document.createRange();if(i.setStart(e,r),i.setEnd(e,r+n.length),a.push(i),a.length>=200)break;r=t.indexOf(n,r+n.length)}if(a.length>=200)break}if(a.length>=200)break}return a.length===0?null:(n.set(`oc-search-terms`,new r(...a)),()=>n.delete(`oc-search-terms`))}function Joe(e,t){(0,q.useEffect)(()=>{if(!t)return;let e=!1,n=0,r=0,i=null,a=()=>{if(e)return;let o=document.querySelector(`[data-message-id="${CSS.escape(t)}"]`);if(o){RK(o.closest(`.oc-thread__viewport`)),o.scrollIntoView({block:`center`,behavior:`smooth`}),o.classList.remove(`oc-msg--highlight`),o.offsetWidth,o.classList.add(`oc-msg--highlight`),window.setTimeout(()=>o.classList.remove(`oc-msg--highlight`),2400);let e=lS(t);e&&(i=qoe(o,e.split(/\s+/).filter(Boolean)));return}n++<40&&(r=window.setTimeout(a,150))};return r=window.setTimeout(a,0),()=>{e=!0,window.clearTimeout(r),i?.()}},[e,t])}function Yoe(){return(0,J.jsx)(`div`,{className:`oc-thread-skeleton`,role:`status`,"aria-label":Mi(),children:[72,38,84,56,64].map((e,t)=>(0,J.jsx)(`div`,{className:`oc-thread-skeleton__row${t%2?` oc-thread-skeleton__row--user`:``}`,children:(0,J.jsx)(`span`,{className:`oc-thread-skeleton__bubble`,style:{width:`${e}%`}})},t))})}function Xoe(e){return Bae({chatId:e.chatId,ready:e.ready,focusMessageId:e.focusMessageId}),null}var Zoe={UserMessage:()=>(0,J.jsx)(Q5,{children:(0,J.jsx)(Cse,{})}),AssistantMessage:()=>(0,J.jsx)(Q5,{children:(0,J.jsx)(Ose,{})}),SystemMessage:()=>(0,J.jsx)(Q5,{children:(0,J.jsx)(kse,{})})};function Qoe({chatId:e,showTools:t,onToggleTools:n,focusMessageId:r,initialLoading:i}){let a=H(G.bridgeHealth.getBridgeAvailability,{chatId:e}),o=M7(),s=o?.nextTarget??null,c=H(G.bridgeHealth.getBridgeAvailability,{chatId:e,...s?{routedAgent:{instanceName:s.instanceName,agentId:s.agentId}}:{}}),l=c&&!c.available?c:null,{beyondValidated:u,gatewayVersion:d}=kT(e,s?{instanceName:s.instanceName,agentId:s.agentId}:null),f=a?.available===!0&&a.degraded===!0,p=c?.available===!0&&c.degraded===!0,m=H(G.agents.getChatAgent,{chatId:e}),h=m?.readOnly===!0,g=H(G.messages.getSessionMeta,{chatId:e})?.viewerRole===`participant`,[_,v]=(0,q.useState)(!1),y=H(G.talk.chatCallState,{chatId:e}),b=C4({callActive:_||y?.active===!0,onCall:y?.active===!0&&y.instanceName!==void 0&&y.agentId!==void 0?{instanceName:y.instanceName,agentId:y.agentId}:null,unavailable:l!==null,readOnly:h,multiAgent:o?.multiAgent===!0,poolSize:(o?.pool??[]).filter(e=>e.state!==`deleted`).length}),x=!b.hidden&&!b.disabled,S=fae({readOnly:h,unavailable:l!==null,degraded:p,beyondValidated:u}),C=H(G.messages.getSessionMeta,{chatId:e})?.title??``,w=H(G.subAgents.listSubAgents,{chatId:e}),T=z$(w??[]),E=Aa(G.subAgents.reconcileTaskEngagements),D=(w??[]).some(e=>e.kind===`task`&&e.status===`running`),O=4*6e4,k=(w??[]).reduce((e,t)=>t.kind===`task`&&t.updatedAt>e?t.updatedAt:e,0),A=(0,q.useRef)({chatId:null,seenStamp:0,armedAtLocal:0});if(A.current.chatId!==(e??null)&&(A.current={chatId:e??null,seenStamp:0,armedAtLocal:0}),k>0&&A.current.seenStamp!==k){let t=A.current.seenStamp===0,n=Date.now()-k<10*6e4;A.current={chatId:e??null,seenStamp:k,armedAtLocal:t&&!n?0:Date.now()}}let j=A.current.armedAtLocal>0&&Date.now()-A.current.armedAtLocal<O;(0,q.useEffect)(()=>{if(!D&&!j||!e)return;let t=!1,n=!1,r,i=()=>{if(t||n)return;let r=A.current.armedAtLocal+O;!D&&Date.now()>r||(n=!0,E({chatId:e}).catch(()=>{}).finally(()=>{n=!1}))};return i(),r=window.setInterval(i,3e4),()=>{t=!0,window.clearInterval(r)}},[D,j,e,E]);let M=H(G.subAgents.turnActivity,{chatId:e}),N=u5(e),P=N!==null,F=H(G.messages.listByChat,{chatId:e}),I=Yre(F),L=M?.runningTtlRemainingMs??null,[R,z]=(0,q.useState)(!1);(0,q.useEffect)(()=>{if(z(!1),M?.running!==!0||L===null)return;let e=window.setTimeout(()=>z(!0),L);return()=>window.clearTimeout(e)},[M?.running,L,e]);let B=M?.running===!0&&!R,V=M?.detachedTask===!0?null:M?.workingSince??null,{showTurnActivity:ee}=tie({chatId:e,projected:P,anyStreaming:I,runningLive:B,deliveringSince:M?.deliveringSince??null,deliveringTtlRemainingMs:M?.deliveringTtlRemainingMs??null,lastUserAt:Qre(F),gatewayWorkingUntil:N?.workingUntil??null,runningSince:V}),te=M?.anchorMessageId??null,[ne,re]=(0,q.useState)(!1);(0,q.useEffect)(()=>{if(!ee||te===null){re(!1);return}let e=()=>re(document.querySelector(`[data-message-id="${CSS.escape(te)}"]`)!==null);e();let t=window.setInterval(e,2e3);return()=>window.clearInterval(t)},[ee,te]);let ie=ee&&te!==null&&ne?{messageId:te,running:B,workingSince:V,quiet:P,progressSummary:M?.progressSummary??null}:null;return Joe(e,r),(0,J.jsx)(K8.Provider,{value:f,children:(0,J.jsx)(X8.Provider,{value:ie,children:(0,J.jsx)(UK,{chatId:e,focusMessageId:r,children:(0,J.jsx)(koe,{chatId:e,children:(0,J.jsxs)(rK.Root,{className:`oc-thread`,children:[(0,J.jsx)(ase,{chatId:e}),(0,J.jsx)(rse,{chatId:e}),i?(0,J.jsx)(Yoe,{}):null,(0,J.jsx)(Xoe,{chatId:e,ready:!i,focusMessageId:r}),(0,J.jsxs)(rK.Viewport,{className:`oc-thread__viewport`,style:i?{display:`none`}:void 0,children:[(0,J.jsx)(rK.Empty,{children:(0,J.jsx)(ise,{})}),(0,J.jsx)(rK.Messages,{components:Zoe}),ee&&ie===null?(0,J.jsx)(F7,{quiet:P,running:B,since:V,progress:M?.progressSummary??null}):null]}),(0,J.jsx)(KK,{}),(0,J.jsx)(`div`,{className:`oc-scrolldown-anchor`,children:(0,J.jsx)(rK.If,{empty:!1,children:(0,J.jsxs)(rK.ScrollToBottom,{className:`oc-scrolldown`,children:[(0,J.jsx)(use,{}),(0,J.jsx)(`span`,{children:Oee()})]})})}),S===`read_only`?(0,J.jsx)(nse,{reason:m?.readOnlyReason??null,guest:g}):S===`unavailable`?(0,J.jsx)(tse,{reason:l?.reason??null,canSwitchAgent:x}):S===`degraded`?(0,J.jsx)(ese,{}):S===`beyond_validated`?(0,J.jsx)($oe,{version:d}):null,(0,J.jsx)(Rie,{}),(0,J.jsx)(Uoe,{}),(0,J.jsx)(Rse,{chatId:e,chatTitle:C,showTools:t,onToggleTools:n,unavailable:l!==null||h,agentGate:b,onTalkCallActiveChange:v,serverCallSessionId:_?null:y?.sessionId??null,subAgentBusy:T})]})})})})})}function F7({running:e,since:t=null,anchored:n=!1,progress:r=null,quiet:i=!1}){let a=(0,q.useRef)(null);if(t!==null&&a.current?.key!==t){let e=Date.now();a.current={key:t,baselineMs:q8(t,e),firstLocalMs:e}}let[,o]=(0,q.useState)(0);(0,q.useEffect)(()=>{if(t===null)return;let e=window.setInterval(()=>o(e=>e+1),1e3);return()=>window.clearInterval(e)},[t]);let s=!n&&t!==null&&a.current!==null&&a.current.key===t?Y8(J8(a.current.baselineMs,a.current.firstLocalMs,Date.now())):null;return(0,J.jsxs)(`div`,{className:`oc-turn-activity${n?` oc-turn-activity--anchored`:``}`,children:[i?(0,J.jsx)(_C,{size:13,className:`oc-turn-activity__mark`,"aria-hidden":!0}):(0,J.jsxs)(`span`,{className:`oc-dots`,"aria-hidden":!0,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{})]}),(0,J.jsx)(`span`,{role:`status`,className:r===null?void 0:`oc-sr-only`,children:e?Md():Nu()}),r===null?null:(0,J.jsx)(`span`,{className:`oc-turn-activity__progress`,title:r,children:r}),s===null?null:(0,J.jsx)(`span`,{className:`oc-turn-activity__clock`,role:`timer`,children:s})]})}function $oe({version:e}){return(0,J.jsxs)(`div`,{className:`oc-chat-banner oc-chat-banner--warn`,role:`status`,children:[(0,J.jsx)(pA,{size:16,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:e===null?tee():K_({version:e})})]})}function ese(){return(0,J.jsxs)(`div`,{className:`oc-chat-banner oc-chat-banner--warn`,role:`status`,children:[(0,J.jsx)(pA,{size:16,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:Vp()})]})}function tse({reason:e,canSwitchAgent:t}){let n=e===`instance_unreachable`?t?nh():mf():Zy();return(0,J.jsxs)(`div`,{className:`oc-chat-banner oc-chat-banner--error`,role:`status`,children:[(0,J.jsx)(pA,{size:16,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:n})]})}function nse({reason:e,guest:t}){let n=e===`viewer`?ote():t?Ze():Jg();return(0,J.jsxs)(`div`,{className:`oc-chat-banner ${e===`viewer`?`oc-chat-banner--info`:`oc-chat-banner--error`}`,role:`status`,children:[(0,J.jsx)(kC,{size:16,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:n})]})}function rse({chatId:e}){let t=H(G.messages.listByChat,{chatId:e}),[n,r]=(0,q.useState)(``),i=(0,q.useRef)(null);return(0,q.useEffect)(()=>{i.current=null,r(``)},[e]),(0,q.useEffect)(()=>{if(!t)return;let e;for(let n of t)n.role===`assistant`&&(e=n);if(!(!e||e.status!==`complete`)){if(i.current===null){i.current=e._id;return}i.current!==e._id&&(i.current=e._id,r(e=>e===vp()?`${vp()} `:vp()))}},[t]),(0,J.jsx)(`div`,{"aria-live":`polite`,"aria-atomic":`true`,className:`oc-sr-only`,children:n})}function ise(){return(0,J.jsxs)(`div`,{className:`oc-emptystate`,children:[(0,J.jsx)(N7,{className:`oc-emptystate__avatar`}),(0,J.jsx)(`h2`,{className:`oc-emptystate__title`,children:oy()})]})}function I7({chatId:e,viewerRole:t}){let n=M7()?.nextTarget??null,r=rC(H(G.agents.usageForChat,t===`participant`?`skip`:{chatId:e,...n?{routedAgent:{instanceName:n.instanceName,agentId:n.agentId}}:{}})?.usage??null,Date.now());if(!r)return null;let i=r.windows.map(e=>`${e.provider} ${e.label}: ${e.percentLeft}%`+(e.resetText?` ⏱${e.resetText}`:``)).join(` · `);return(0,J.jsxs)(`span`,{className:`oc-meter ${r.level}`,title:Nn({detail:i}),children:[(0,J.jsx)(`span`,{className:`oc-meter__track`,children:(0,J.jsx)(`span`,{className:`oc-meter__fill`,style:{width:`${r.percentLeft}%`}})}),(0,J.jsx)(`span`,{className:`oc-meter__label`,children:ji({pct:r.percentLeft})})]})}function L7({sm:e,detail:t=!0}){let n=TT(e),r=xne(e),i=OT(e),a=n!=null&&i?Math.round(n/i*100):null;if(a==null||n==null)return i?(0,J.jsx)(`span`,{className:`oc-meter is-unknown`,title:Fn(),role:`status`,children:(0,J.jsx)(`span`,{className:`oc-meter__label`,children:`—`})}):null;let o=a>=90?`is-critical`:a>=75?`is-warn`:`is-ok`,s=vne(e);return(0,J.jsxs)(`span`,{className:`oc-meter ${o}`,title:`${dd({pct:a,used:ET(n),total:ET(i)})}\n${r===`budget_estimate`?oi():xv()}${s?`\n${Ni({gateway:s.gateway,delta:s.delta})}`:``}`,children:[(0,J.jsx)(`span`,{className:`oc-meter__track`,children:(0,J.jsx)(`span`,{className:`oc-meter__fill`,style:{width:`${Math.min(a,100)}%`}})}),(0,J.jsxs)(`span`,{className:`oc-meter__label`,children:[a,`%`,t?(0,J.jsxs)(`span`,{className:`oc-meter__detail`,children:[` · `,ET(n),`/`,ET(i)]}):null]})]})}function ase({chatId:e}){let t=H(G.messages.getSessionMeta,{chatId:e}),n=Kx(),r=H(G.projects.listProjects,{}),i=(0,q.useMemo)(()=>{let e=t?.projectId??null;return e===null||r===void 0?[]:sS(r,e)},[t?.projectId,r]),a=t?.sessionMeta??null,o=t?.sessionSettings??null,s=T7(),c=u7(),[l,u]=(0,q.useState)(!1),d=(0,q.useRef)(null),f=(0,q.useRef)(null),p=(0,q.useRef)(null),m=Gae(a),h=!gne(o,`thinkingLevel`),_=(n,r)=>(0,J.jsxs)(J.Fragment,{children:[s.showTools&&!n&&a?.model?(0,J.jsxs)(`span`,{className:`oc-chip oc-chip--info`,title:a.modelProvider?dm({provider:a.modelProvider}):ky(),children:[(0,J.jsx)(cse,{}),(0,J.jsx)(`span`,{className:`oc-chip__label`,children:a.model})]}):null,s.showTools&&!n&&a?.thinkingLevel?(0,J.jsxs)(`span`,{className:`oc-chip oc-chip--info`,title:h?g():ks(),children:[(0,J.jsx)(lse,{}),(0,J.jsxs)(`span`,{className:`oc-chip__label`,children:[zd(),`\xA0: `,fne(a.thinkingLevel)]}),h?(0,J.jsx)(`span`,{className:`oc-chip__hint`,children:Bu()}):null]}):null,m?(0,J.jsxs)(`span`,{className:`oc-chip oc-chip--info`,title:m.title,children:[(0,J.jsx)(kC,{size:13,"aria-hidden":!0}),n?(0,J.jsx)(`span`,{className:`sr-only`,children:m.label}):(0,J.jsx)(`span`,{className:`oc-chip__label`,children:m.label})]}):null,s.showTools&&a?(0,J.jsx)(L7,{sm:a,detail:!n}):null,s.showUsage&&!a?(0,J.jsx)(I7,{chatId:e,viewerRole:t?.viewerRole}):null,(0,J.jsx)(Goe,{compact:n,ghost:r}),(0,J.jsx)(ose,{chatId:e,title:t?.title??null,compact:n,ghost:r}),t?.viewerRole===`owner`?(0,J.jsx)(sse,{chatId:e,viewerRole:t?.viewerRole,sm:a,settings:o,onOpenPanel:()=>u(!0),compact:n,ghost:r,showUsage:s.showUsage&&a!==null}):null]}),v=NT(()=>{let e=d.current,t=f.current;return!e||!t?null:gae({headWidth:e.clientWidth,titleBlock:t,metaWidth:p.current?.offsetWidth??0})},()=>[d.current,p.current],[[Vl(),c===null?``:`${+(c.rows.length>0)}:${c.waiting.length}`,ia(),t?.viewerRole??``,a?.model??``,a?.thinkingLevel??``,m?.label??``,t?.title??``,i.map(e=>e.name).join(`/`),s.showTools?`1`:`0`].join(`|`)])>0;return(0,J.jsxs)(`header`,{className:`oc-chathead`,ref:d,children:[(0,J.jsxs)(`div`,{className:`oc-chathead__titlebox`,ref:f,children:[i.length>0?(0,J.jsx)(`nav`,{className:`oc-chathead__crumbs`,"aria-label":Fd(),children:i.map((e,t)=>(0,J.jsxs)(`span`,{className:`oc-chathead__crumb`,children:[t>0?(0,J.jsx)(`span`,{className:`oc-chathead__crumbsep`,"aria-hidden":!0,children:`›`}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-chathead__crumblink`,onClick:()=>void n({to:`/project/$projectId`,params:{projectId:e._id}}),children:e.name})]},e._id))}):null,(0,J.jsx)(`div`,{className:`oc-chathead__title`,title:t?.title??void 0,children:t?.title||C_()})]}),(0,J.jsx)(`div`,{className:`oc-chathead__meta`,children:_(v,!1)}),(0,J.jsx)(`div`,{className:`oc-chathead-ghost`,"aria-hidden":!0,ref:p,children:_(!1,!0)}),t?.viewerRole===`owner`?(0,J.jsx)(Fae,{chatId:e,open:l,onOpenChange:u}):null]})}function R7(e,t,n){let r=new Blob([e],{type:`${n};charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}function ose({chatId:e,title:t,compact:n=!1,ghost:r=!1}){let i=eo();async function a(n){let[r,a]=await Promise.all([i.query(G.messages.listByChat,{chatId:e}),i.query(G.messages.getStreamingText,{chatId:e})]),o=new Map(a.map(e=>[e.messageId,e.text])),s=r.map(e=>({role:e.role,text:e.status===`streaming`?o.get(e._id)??e.text:e.text,createdAt:e.updatedAt??e._creationTime,...e.quotedRefs!==void 0&&e.quotedRefs.length>0?{quotedExcerpts:e.quotedRefs.map(e=>e.excerpt)}:{},parts:e.parts.map(e=>({kind:e.kind,filename:`filename`in e?e.filename:void 0,name:`name`in e?e.name:void 0}))})),c=z4(r),l={title:t??void 0,truncated:c,exportedAt:Date.now()},u=W4(t);n===`md`?R7(H4(s,l),`${u}.md`,`text/markdown`):R7(U4(s,l),`${u}.json`,`application/json`)}let o=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(bC,{size:13,"aria-hidden":!0}),n?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`oc-chip__label`,children:Vl()}),(0,J.jsx)(QS,{size:13,className:`oc-chip__chev`,"aria-hidden":!0})]})]});return r?(0,J.jsx)(`span`,{className:`oc-chip oc-chip--btn`,children:o}):(0,J.jsxs)(hC,{children:[(0,J.jsx)(oC,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:`oc-chip oc-chip--btn`,title:ir(),children:o})}),(0,J.jsxs)(dC,{align:`end`,className:`w-44`,children:[(0,J.jsx)(uC,{children:Vl()}),(0,J.jsx)(pC,{onClick:()=>void a(`md`),children:ye()}),(0,J.jsx)(pC,{onClick:()=>void a(`json`),children:fx()})]})]})}function sse({chatId:e,viewerRole:t,sm:n,settings:r,onOpenPanel:i,compact:a=!1,ghost:o=!1,showUsage:s=!1}){let[c,l]=(0,q.useState)(!1),u=M7(),d=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(HC,{size:13,"aria-hidden":!0}),a?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`oc-chip__label`,children:ia()}),(0,J.jsx)(QS,{size:13,className:`oc-chip__chev`,"aria-hidden":!0})]})]});return o?(0,J.jsx)(`span`,{className:`oc-chip oc-chip--btn`,children:d}):(0,J.jsxs)(vw,{open:c,onOpenChange:l,children:[(0,J.jsx)(_w,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:`oc-chip oc-chip--btn`,title:Zs(),children:d})}),(0,J.jsxs)(gw,{align:`end`,className:`oc-spanel-pop w-80 p-2`,children:[n!==null&&OT(n)?(0,J.jsxs)(`div`,{className:`oc-spanel-pop__usage`,children:[(0,J.jsx)(`span`,{className:`oc-spanel-pop__usage-label`,children:_l()}),(0,J.jsx)(L7,{sm:n})]}):null,s?(0,J.jsxs)(`div`,{className:`oc-spanel-pop__usage`,children:[(0,J.jsx)(`span`,{className:`oc-spanel-pop__usage-label`,children:$c()}),(0,J.jsx)(I7,{chatId:e,viewerRole:t})]}):null,(0,J.jsx)(DT,{chatId:e,sm:n,settings:r}),(0,J.jsx)(H5,{chatId:e,routedAgent:u?.nextTarget?{instanceName:u.nextTarget.instanceName,agentId:u.nextTarget.agentId}:null,multiAgent:u?.perTurnRouting===!0||(u?.roomAgents?.length??0)>0}),(0,J.jsxs)(`button`,{type:`button`,className:`oc-spanel-pop__all`,onClick:()=>{l(!1),i()},children:[(0,J.jsx)(HC,{size:13,"aria-hidden":!0}),Oc(),(0,J.jsx)(eC,{size:13,"aria-hidden":!0})]})]})]})}function cse(){return(0,J.jsxs)(`svg`,{className:`oc-chip__icon`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,J.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`}),(0,J.jsx)(`rect`,{x:`9`,y:`9`,width:`6`,height:`6`}),(0,J.jsx)(`path`,{d:`M9 1v3M15 1v3M9 20v3M15 20v3M20 9h3M20 14h3M1 9h3M1 14h3`})]})}function lse(){return(0,J.jsxs)(`svg`,{className:`oc-chip__icon`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,J.jsx)(`path`,{d:`M12 5a3 3 0 1 0-5.997.142 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`}),(0,J.jsx)(`path`,{d:`M12 5a3 3 0 1 1 5.997.142 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z`})]})}function z7({children:e}){return(0,J.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:e})}function use(){return(0,J.jsx)(z7,{children:(0,J.jsx)(`path`,{d:`M12 5v14M19 12l-7 7-7-7`})})}var dse=`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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 oc-overlay-layer origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md`,B7=`focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`;function fse({sourceShown:e,sourceActive:t,onToggleSource:n,onPickBlock:r,onPickBookmarkBlock:i}){let a=$(e=>e.metadata?.custom?.messageId),o=$(e=>e.metadata?.custom?.sentAt),s=$(e=>e.metadata?.custom?.generationMs??null),c=$(e=>e.metadata?.custom?.status===`streaming`),l=U(G.chatFork.forkChat),u=(0,q.useContext)(k7),d=_T(),f=Iw(),[p,m]=(0,q.useState)(!1);if(!a)return null;let h=async()=>{let e=await d({title:Uc(),description:bc(),label:Au(),placeholder:_te(),confirmLabel:Kb(),allowEmpty:!0});if(e!==null){m(!0);try{let{chatId:t}=await l({branchMessageId:a,...e.trim()?{title:e.trim()}:{}});t3(t,{expand:!0}),f.success(Be())}catch(e){f.error(Yf(),e)}finally{m(!1)}}};return(0,J.jsxs)(G4,{children:[(0,J.jsx)(K4,{className:`oc-iconbtn`,title:Bv(),"aria-label":Bv(),disabled:p,children:(0,J.jsx)(SA,{size:15})}),(0,J.jsxs)(Y4,{align:`end`,sideOffset:4,className:dse,children:[o===void 0?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`oc-msgmenu__when px-2 py-1.5 text-sm`,children:[Xw(o,{dateStyle:`medium`,timeStyle:`short`}),(()=>{let e=s===null?null:Zw(s);return e===null?null:(0,J.jsxs)(`span`,{className:`oc-msgmenu__duration`,children:[(0,J.jsx)(xj,{size:12,"aria-hidden":!0}),Di({duration:e})]})})()]}),(0,J.jsx)(J4,{className:`bg-border -mx-1 my-1 h-px`})]}),e?(0,J.jsxs)(q4,{className:B7,onSelect:n,children:[(0,J.jsx)(_A,{size:14,"aria-hidden":!0}),t?Zo():Za()]}):null,u?(0,J.jsxs)(q4,{className:B7,disabled:p||c,onSelect:()=>void h(),children:[(0,J.jsx)(AA,{size:14,"aria-hidden":!0}),Uc()]}):null,r?(0,J.jsxs)(q4,{className:B7,onSelect:r,children:[(0,J.jsx)(aj,{size:14,"aria-hidden":!0}),Wa()]}):null,(0,J.jsx)(pse,{}),i?(0,J.jsxs)(q4,{className:B7,onSelect:i,children:[(0,J.jsx)(uA,{size:14,"aria-hidden":!0}),Wo()]}):null]})]})}function pse(){let e=VK(),t=$(e=>e.id);if(!e)return null;let n=e.byMessage.get(t)?.some(e=>e.blockIndex===null)??!1;return(0,J.jsxs)(q4,{className:B7,onSelect:()=>e.toggle(t,null),children:[(0,J.jsx)(uA,{size:14,"aria-hidden":!0}),n?o_():Eh()]})}function mse(){let[e,t]=(0,q.useState)(!1),n=$(e=>p0(e.content)),r=$(e=>e.metadata?.custom?.groupText??null),i=r!==null&&r.trim()!==``?r:n,a=E$($(e=>e.metadata?.custom?.error??null),$(e=>e.metadata?.custom?.errorCode??null)),o=i.trim()||[a.headline,a.detail,a.rawDetail].filter(Boolean).join(`
154
+ `),s=o.length===0;return(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn`,title:Mt(),"aria-label":Mt(),disabled:s,onClick:()=>{navigator.clipboard.writeText(o).then(()=>{t(!0),window.setTimeout(()=>t(!1),1500)})},children:e?(0,J.jsx)(H7,{}):(0,J.jsx)(V7,{})})}function hse(e){let t=(0,q.useContext)(b7),n=(0,q.useContext)(x7),r=$(e=>e.metadata?.custom?.messageId??e.id),i=T7().autoReadAloud,a=$(e=>e.metadata?.custom?.status??``),o=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!t.loaded)return;let s=o.current;o.current=a,!(!t.enabled||!t.autoRead||t.engine===`gateway`||!i||!BS())&&(a!==`complete`||s===null||s===`complete`||e.trim()&&KS(XS(e),{lang:RS(t.lang,ut()),rate:t.rate,onEnd:()=>n.clearIf(r)})&&n.setActive({messageId:r,phase:`playing`}))},[a,e,t,n,r,i])}function gse(){let e=(0,q.useContext)(b7),t=(0,q.useContext)(x7),n=Aa(G.voice.gatewayTts),r=Iw(),i=$(e=>e.metadata?.custom?.messageId??e.id),a=$(e=>e.metadata?.custom?.chatId??null),o=$(e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
155
+ `)),s=$(e=>e.metadata?.custom?.groupText??null),c=s!==null&&s.trim()!==``?s:o,l=e.engine!==`gateway`;if(!e.enabled||!c.trim()||l&&!BS())return null;let u=RS(e.lang,ut()),d=t.active?.messageId===i,f=d&&t.active?.phase===`loading`,p=d&&t.active?.phase===`playing`,m=()=>{C7();let o=XS(c);if(l){let n=KS(o,{lang:u,rate:e.rate,onEnd:()=>t.clearIf(i)});t.setActive(n?{messageId:i,phase:`playing`}:null);return}if(!a)return;let s=S7;t.setActive({messageId:i,phase:`loading`}),n({chatId:a,text:o.slice(0,1500)}).then(({mime:n,audioBase64:r})=>{if(s!==S7)return;let a=HS(r,n,{rate:e.rate,onEnd:()=>t.clearIf(i)});t.setActive(a?{messageId:i,phase:`playing`}:null)}).catch(e=>{s===S7&&(r.error(Rg(),e),t.setActive(null))})};return(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn${d?` oc-iconbtn--reading`:``}`,title:d?Ou():Xn(),"aria-label":d?Ou():Xn(),"aria-pressed":d,"aria-busy":f,onClick:()=>{if(d){C7(),t.setActive(null);return}m()},children:f?(0,J.jsx)(OC,{size:16,className:`oc-actrow__spin`,"aria-hidden":!0}):p?(0,J.jsx)(yse,{}):(0,J.jsx)(vse,{})})}function _se(){let e=(0,q.useContext)(x7);if(!e.active)return null;let t=e.active.phase===`loading`;return(0,J.jsxs)(`div`,{className:`oc-reading-banner`,role:`status`,children:[t?(0,J.jsx)(OC,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,J.jsx)(VS,{size:14,className:`oc-reading-banner__pulse`,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:t?Vo():St()}),(0,J.jsx)(`button`,{type:`button`,className:`oc-reading-banner__stop`,onClick:()=>{C7(),e.setActive(null)},children:Ou()})]})}function vse(){return(0,J.jsxs)(z7,{children:[(0,J.jsx)(`path`,{d:`M11 5 6 9H2v6h4l5 4V5z`}),(0,J.jsx)(`path`,{d:`M15.5 8.5a5 5 0 0 1 0 7`})]})}function yse(){return(0,J.jsxs)(z7,{children:[(0,J.jsx)(`path`,{d:`M11 5 6 9H2v6h4l5 4V5z`}),(0,J.jsx)(`line`,{x1:`22`,y1:`9`,x2:`16`,y2:`15`}),(0,J.jsx)(`line`,{x1:`16`,y1:`9`,x2:`22`,y2:`15`})]})}function V7(){return(0,J.jsxs)(z7,{children:[(0,J.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`}),(0,J.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})}function H7(){return(0,J.jsx)(z7,{children:(0,J.jsx)(`path`,{d:`M20 6 9 17l-5-5`})})}function bse({text:e}){let t=$(e=>e.metadata?.custom?.mentions??null);if(t===null||t.length===0)return(0,J.jsx)(J.Fragment,{children:e});let n=[],r=0;for(let[i,a]of t.entries())a.start<r||a.end>e.length||(a.start>r&&n.push(e.slice(r,a.start)),n.push((0,J.jsx)(`span`,{className:`oc-mention${a.isViewer?` oc-mention--self`:``}${a.isAgent===!0?` oc-mention--agent`:``}`,title:a.name,children:e.slice(a.start,a.end)},`${a.start}-${i}`)),r=a.end);return r<e.length&&n.push(e.slice(r)),(0,J.jsx)(J.Fragment,{children:n})}var U7={File:Cae,Text:bse},xse={...U7,Text:cJ,data:{by_name:{widget:o2,youtube:f2,thinking:Fie,commentary:Lie}},tools:{by_name:{__turn_flow__:Tie,__delegated_reply__:Ese}}};function W7({kind:e}){let t=$(e=>k8(e.metadata?.custom)),n=U(G.messages.deleteMessage).withOptimisticUpdate(Hre),r=gT(),i=Iw(),a=(0,q.useContext)(E7),[o,s]=(0,q.useState)(!1),c=BV(e=>e.isRunning);if(!t)return null;async function l(){if(await r(e===`assistant`?{title:Ar(),description:on(),confirmLabel:ts(),cancelLabel:no(),destructive:!0}:{title:Ma(),description:cg(),confirmLabel:I(),cancelLabel:no(),destructive:!0})){s(!0),e===`assistant`&&a?.begin();try{await n({messageId:t})}catch(t){e===`assistant`&&a?.cancel(),i.error(It(),t)}finally{s(!1)}}}return(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn oc-iconbtn--danger`,title:c?hf():e===`assistant`?kg():Ao(),"aria-label":ft(),"aria-busy":o,disabled:o||c,onClick:()=>void l(),children:o?(0,J.jsx)(OC,{size:15,className:`oc-iconbtn__spin`,"aria-hidden":!0}):(0,J.jsx)(WC,{size:15,"aria-hidden":!0})})}function G7(){let e=$(e=>e.metadata?.custom?.rawText??``),t=$(e=>e.metadata?.custom?.chatId),n=$(e=>e.metadata?.custom?.messageId),r=$(e=>e.metadata?.custom?.allToolParts??e.metadata?.custom?.toolParts??K7),i=H(G.subAgents.listSubAgents,e===``&&t?{chatId:t}:`skip`),a=e===``?X$(i??[],m5(r),n).find(e=>e.status===`done`&&e.resultText)?.resultText??``:``,o=e===``&&a!==``,s=e===``?a:e,[c,l]=(0,q.useState)(!1),u=[...s].length;return(0,J.jsxs)(`div`,{className:`oc-msg__source`,children:[(0,J.jsxs)(`div`,{className:`oc-msg__source-head`,children:[(0,J.jsx)(`span`,{className:`oc-msg__source-label`,children:o?$i({count:u}):u>1?Ks({count:u}):tne({count:u})}),(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn`,title:Tr(),"aria-label":Tr(),onClick:()=>{navigator.clipboard?.writeText(s).then(()=>{l(!0),window.setTimeout(()=>l(!1),1200)})},children:c?(0,J.jsx)(H7,{}):(0,J.jsx)(V7,{})})]}),(0,J.jsx)(`pre`,{className:`oc-msg__source-pre`,children:s.length>0?s:tn()})]})}function Sse({active:e,onToggle:t}){return(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn${e?` is-on`:``}`,onClick:t,"aria-pressed":e,title:e?Zo():Za(),"aria-label":Da(),children:(0,J.jsx)(_A,{size:15,"aria-hidden":!0})})}function Cse(){let[e,t]=(0,q.useState)(!1),n=T7(),r=$(e=>e.id.startsWith(`optimistic-`)),i=tw(),a=$(e=>e.isLast),o=$(e=>e.metadata?.custom?.queued===!0),s=$(e=>e.id),c=$(e=>e.metadata?.custom?.custody??null),l=$(e=>e.metadata?.custom?.chatId??null),{can:u}=kT(c===`queued`?l:null),d=$(e=>e.metadata?.custom?.quotedRefs??null),f=Iw(),p=$(e=>e.metadata?.custom?.authorName??null);return(0,J.jsx)(xG.Root,{className:`oc-msg oc-msg--user${r?` is-sending`:``}${o?` is-queued`:``}`,"data-message-id":s,children:(0,J.jsxs)(`div`,{className:`oc-msg__col oc-msg__col--user`,children:[(0,J.jsx)(QK,{}),p===null?null:(0,J.jsx)(`div`,{className:`oc-msg__author`,children:qr({name:p})}),d?.map((e,t)=>(0,J.jsxs)(`button`,{type:`button`,className:`oc-msg__quote`,title:xn(),onClick:e.messageId?()=>J7(e.messageId,e.blockIndex,f):void 0,children:[(0,J.jsx)(aj,{size:12,"aria-hidden":!0,className:`oc-msg__quote-ico`}),(0,J.jsx)(`span`,{className:`oc-msg__quote-text`,children:e.excerpt})]},`${e.messageId??`orphan`}:${e.blockIndex??`all`}:${t}`))??null,(0,J.jsx)(`div`,{className:`oc-msg__bubble`,children:e?(0,J.jsx)(G7,{}):(0,J.jsx)(xG.Parts,{components:U7})}),r?(0,J.jsxs)(`span`,{className:`oc-msg__sending`,role:`status`,children:[(0,J.jsx)(`span`,{className:`oc-msg__sending-spin`,"aria-hidden":!0}),M()]}):o?(0,J.jsxs)(`span`,{className:`oc-msg__queued`,role:`status`,children:[(0,J.jsx)(_C,{size:12,"aria-hidden":!0}),Eg()]}):(0,J.jsxs)(J.Fragment,{children:[B8(c)===null?null:(0,J.jsx)(Bie,{custody:c,messageId:s,canWithdraw:u(`discardPendingInput`)}),(0,J.jsxs)(yH.Root,{className:`oc-msg__actions oc-msg__actions--user`,autohide:`never`,"data-reveal":x5(i,a),children:[(0,J.jsx)(nq,{}),n.copyUser?(0,J.jsxs)(yH.Copy,{className:`oc-iconbtn`,title:rg(),children:[(0,J.jsx)(xG.If,{copied:!0,children:(0,J.jsx)(H7,{})}),(0,J.jsx)(xG.If,{copied:!1,children:(0,J.jsx)(V7,{})})]}):null,n.showSource?(0,J.jsx)(Sse,{active:e,onToggle:()=>t(e=>!e)}):null,n.showReport?(0,J.jsx)(A5,{}):null,n.showDelete?(0,J.jsx)(W7,{kind:`user`}):null]})]})]})})}function wse({pool:e,agent:t}){let n=w4(e,t),r=n?.displayName??t.agentId;return(0,J.jsxs)(`span`,{className:`oc-chip oc-chip--agent oc-msg__agent`,title:Ef({name:r}),children:[n?.emoji?(0,J.jsx)(`span`,{className:`oc-chip__emoji`,"aria-hidden":!0,children:n.emoji}):(0,J.jsx)(kS,{size:13,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-chip__label`,children:r})]})}var K7=[],Tse=[];function q7(){let e=(0,q.useRef)(null),[t,n]=(0,q.useState)(null);return(0,q.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=()=>{let e=0;try{e=t.getTotalLength()}catch{e=0}if(!e){let n=t.getBoundingClientRect();e=2*(n.width+n.height)}e>0&&n(Math.round(e))};r();let i=new ResizeObserver(r);return i.observe(t.ownerSVGElement??t),()=>i.disconnect()},[]),(0,J.jsxs)(`svg`,{className:`oc-empty-answer__ants`,"aria-hidden":!0,children:[(0,J.jsx)(`rect`,{ref:e}),t===null?null:(0,J.jsx)(`rect`,{className:`oc-ants-accent`,style:{strokeDasharray:`3 3 3 3 3 ${Math.max(t-15,6)}`,animationDuration:`${Math.max(t*4,800)}ms`,animationTimingFunction:`steps(${Math.max(Math.round(t/6),8)}, end)`,"--oc-ants-p":`${t}px`}})]})}function Ese(e){let t=$(e=>e.metadata?.custom?.chatId),n=$(e=>e.metadata?.custom?.messageId),r=Yie(H(G.subAgents.listSubAgents,t?{chatId:t}:`skip`),n,e.args?.slot);return r.length===0?null:(0,J.jsx)(J.Fragment,{children:r.map(e=>(0,J.jsxs)(`div`,{className:`oc-delegated-reply`,children:[e.agentId?(0,J.jsxs)(`div`,{className:`oc-empty-answer__from`,role:`note`,children:[(0,J.jsx)(yA,{size:13,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:O_({agent:e.agentId})})]}):null,(0,J.jsx)(sJ,{text:e.resultText})]},e.childSessionKey))})}function Dse({show:e}){let t=$(e=>e.metadata?.custom?.status),n=$(e=>{let t=e.metadata?.custom;return t5(t?.interruption,t?.status)}),r=$(e=>e.metadata?.custom?.steerSegment===!0),i=$(e=>e.metadata?.custom?.chatId),a=$(e=>D$(e.content)),o=$(e=>e.content.some(e=>e?.type===`file`||e?.type===`data`&&e.name===`widget`)),s=$(e=>e.metadata?.custom?.allToolParts??e.metadata?.custom?.toolParts??K7),c=H(G.subAgents.listSubAgents,i?{chatId:i}:`skip`),l=$(e=>e.metadata?.custom?.messageId),u=$(e=>e.metadata?.custom?.settledAt??void 0),d=$(e=>e.metadata?.custom?.hasContinuation===!0),f=$(e=>e.metadata?.custom?.answeredChildRunIds??Tse),p=$(e=>e.metadata?.custom?.handOff??null),m=$(e=>e.metadata?.custom?.repeatWithheld===!0),[,h]=(0,q.useState)(0),g=y5({status:t,hasText:a||m,hasMedia:o,settledAt:u,delegatedInline:d,answeredChildRunIds:f,...p===null?{}:{projected:p.projected,resumedChildRunIds:p.resumedChildRunIds,resumedChildKeys:p.resumedChildKeys,laterUserTurn:p.laterUserTurn}},s,c,l),_=g.kind===`composing`||g.kind===`waiting`?g.recheckAt??null:null;return(0,q.useEffect)(()=>{if(_===null)return;let e=window.setTimeout(()=>h(e=>e+1),Math.max(_-Date.now(),0)+250);return()=>window.clearTimeout(e)},[_]),g.kind===`none`||r||n||p?.projected===!0&&(g.kind===`composing`||g.kind===`waiting`)?null:g.kind===`composing`?(0,J.jsxs)(`div`,{className:`oc-empty-answer oc-empty-answer--waiting`,role:`status`,children:[(0,J.jsx)(q7,{}),(0,J.jsx)(OC,{size:15,className:`oc-empty-answer__spin`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-empty-answer__text`,children:g.taskName?ib({task:g.taskName}):qp()})]}):g.kind===`failed`?e&&g.cardSilent!==!0?null:(0,J.jsxs)(`div`,{className:`oc-empty-answer oc-empty-answer--failed`,role:`status`,children:[(0,J.jsx)(kS,{size:15,className:`oc-empty-answer__icon`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-empty-answer__text`,children:g.taskName?wp({task:g.taskName,reason:g.reason}):mee({reason:g.reason})})]}):g.kind===`waiting`?e&&g.recheckAt===void 0?null:(0,J.jsxs)(`div`,{className:`oc-empty-answer oc-empty-answer--waiting`,role:`status`,children:[(0,J.jsx)(q7,{}),(0,J.jsx)(OC,{size:15,className:`oc-empty-answer__spin`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-empty-answer__text`,children:g.taskName?see({task:g.taskName}):Q_()})]}):g.kind===`done`?g.resultText?(0,J.jsxs)(J.Fragment,{children:[g.agentId?(0,J.jsxs)(`div`,{className:`oc-empty-answer__from`,role:`note`,children:[(0,J.jsx)(yA,{size:13,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:O_({agent:g.agentId})})]}):null,(0,J.jsx)(sJ,{text:g.resultText})]}):null:(0,J.jsxs)(`div`,{className:`oc-empty-answer oc-empty-answer--generic`,role:`status`,children:[(0,J.jsx)(kS,{size:15,className:`oc-empty-answer__icon`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-empty-answer__text`,children:dy()})]})}function Ose(){let[e,t]=(0,q.useState)(!1),n=T7(),r=tw(),i=$(e=>e.isLast),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(!1),l=VK(),u=o4(),d=$(e=>e.id),f=$(e=>e.metadata?.custom?.groupMembers??null),p=$(e=>e.status?.type===`running`),m=(0,q.useMemo)(()=>DK(d,p,f),[d,p,f]),h=l?.byMessage,g=(0,q.useMemo)(()=>new Set(m.flatMap(e=>(h?.get(e)??[]).flatMap(t=>t.blockIndex===null?[]:[OK(e,t.blockIndex)]))),[h,m]),_=(0,q.useContext)(A7),v=Iw(),y=(0,q.useCallback)((e,t)=>oK(CM(e,t)),[]),b=$(e=>e.metadata?.custom?.groupText??e.metadata?.custom?.rawText??``),x=$(e=>e.status?.type===`running`),S=$(e=>e.metadata?.custom?.chatId),C=$(e=>e.metadata?.custom?.messageId),w=$(e=>e.metadata?.custom?.status),T=$(e=>e.content.some(e=>e?.type===`file`)),E=$(e=>e.metadata?.custom?.allToolParts??e.metadata?.custom?.toolParts??K7),D=H(G.subAgents.listSubAgents,b===``&&S?{chatId:S}:`skip`),O=b===``?y5({status:w,hasText:!1,hasMedia:T},E,D,C):null,k=b===``?O?.kind===`done`?O.resultText??``:``:b,A=(0,q.useContext)(X8),j=A!==null&&A.messageId===d?A:null,M=$(e=>e.metadata?.custom?.status),N=(0,q.useContext)(l5),P=$(e=>lae(e.metadata?.custom?.steerSegment===!0,e.content)),F=$(e=>e.metadata?.custom?.groupFollows===!0),I=$(e=>e.metadata?.custom?.groupContinues===!0);hse($(e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
156
+ `)));let L=M7(),R=L&&L.perTurnRouting?L.messageAgents.has(d)?L.messageAgents.get(d)??L.primary:L.fallbackAgent:null,z=L?.pool,B=$(e=>e.metadata?.custom?.importedAgentLabel??null),V=(0,q.useMemo)(()=>{if(B!==null)return{...u,agentName:B,agentEmoji:null};if(!R)return u;let e=w4(z??[],R);return{...u,agentName:e?.displayName??R.agentId,agentEmoji:e?.emoji??null}},[B,R,u,z]);return M===void 0&&N||P&&!n.showTools?null:(0,J.jsxs)(xG.Root,{className:`oc-msg oc-msg--assistant oc-reveal-host${F?` oc-msg--group-follow`:``}${I?` oc-msg--group-continues`:``}`,"data-message-id":d,children:[F?(0,J.jsx)(`span`,{className:`oc-msg__avatar oc-msg__avatar--group`,"aria-hidden":!0}):(0,J.jsx)(N7,{className:`oc-msg__avatar`}),(0,J.jsxs)(`div`,{className:`oc-msg__col`,children:[F?null:(0,J.jsxs)(`div`,{className:`oc-msg__name`,children:[R?(0,J.jsx)(wse,{pool:L.pool,agent:R}):(0,J.jsxs)(J.Fragment,{children:[u.agentEmoji?(0,J.jsx)(`span`,{className:`oc-msg__name-emoji`,"aria-hidden":!0,children:u.agentEmoji}):null,s4(u)]}),(0,J.jsx)(nq,{header:!0}),_!==null&&!d.startsWith(`optimistic-`)&&!x&&k!==``?(0,J.jsx)(`button`,{type:`button`,className:`oc-bmk-headbtn oc-reveal oc-hit`,title:ya(),"aria-label":ya(),onClick:()=>{let e=SK(k,280);if(e===``)return;let t=y(_,{messageId:d,blockIndex:null,excerpt:e});t!==null&&v.error(t)},children:(0,J.jsx)(aj,{size:13})}):null]}),(0,J.jsxs)(`div`,{className:`oc-msg__body`,children:[(0,J.jsx)(Zre,{}),(0,J.jsx)(`div`,{className:`oc-msg__meta oc-msg__meta--cron`,children:(0,J.jsx)(dq,{})}),n.showTools?(0,J.jsxs)(`div`,{className:`oc-msg__meta`,children:[(0,J.jsx)(c3,{}),(0,J.jsx)(eae,{}),(0,J.jsx)(Vie,{}),(0,J.jsx)(vY,{})]}):null,(0,J.jsx)(rae,{}),(0,J.jsx)(aae,{}),e?(0,J.jsx)(G7,{}):(0,J.jsx)(xG.Parts,{components:xse}),(0,J.jsx)(oae,{}),(0,J.jsx)(sae,{}),e?null:(0,J.jsx)(Dse,{show:n.showTools}),(0,J.jsx)(Hoe,{}),(0,J.jsx)(a4.Provider,{value:V,children:(0,J.jsx)(qre,{})}),j===null?null:(0,J.jsx)(F7,{quiet:j.quiet===!0,running:j.running,since:j.workingSince,progress:j.progressSummary??null,anchored:!0})]}),_!==null&&!d.startsWith(`optimistic-`)&&!I?(0,J.jsx)(T5,{kind:`quote`,open:a,onOpenChange:o,messageId:d,sources:m,onPick:e=>y(_,{messageId:e.messageId,blockIndex:e.blockIndex,excerpt:e.excerpt})}):null,l!==null&&!d.startsWith(`optimistic-`)&&!I?(0,J.jsx)(T5,{kind:`bookmark`,open:s,onOpenChange:c,messageId:d,sources:m,marked:g,onPick:e=>l.toggle(e.messageId,e.blockIndex).then(cK)}):null,(0,J.jsx)(QK,{messageLevelMarkers:!1,onReplyToBlock:_!==null&&!d.startsWith(`optimistic-`)?(e,t)=>y(_,{messageId:d,blockIndex:e,excerpt:t}):void 0}),I?null:(0,J.jsxs)(yH.Root,{className:`oc-msg__actions`,autohide:`never`,"data-reveal":x5(r,i),children:[n.copyAssistant?(0,J.jsx)(mse,{}):null,(0,J.jsx)(gse,{}),n.showReport?(0,J.jsx)(A5,{}):null,n.showDelete?(0,J.jsx)(W7,{kind:`assistant`}):null,(0,J.jsx)(fse,{sourceShown:n.showSource,sourceActive:e,onToggleSource:()=>t(e=>!e),onPickBlock:_!==null&&!d.startsWith(`optimistic-`)&&m.length>0&&k!==``?()=>o(!0):void 0,onPickBookmarkBlock:l!==null&&!d.startsWith(`optimistic-`)&&m.length>0&&k!==``?()=>c(!0):void 0})]})]})]})}function kse(){let e=$(e=>e.id);return(0,J.jsx)(xG.Root,{className:`oc-msg oc-msg--system`,"data-message-id":e,children:(0,J.jsx)(`div`,{className:`oc-msg__body`,children:(0,J.jsx)(xG.Parts,{components:U7})})})}function J7(e,t,n){if(document.querySelector(`[data-message-id="${CSS.escape(e)}"]`)===null&&document.querySelector(`[data-message-id]`)!==null){n.error(Gr());return}HK(e,t,`smooth`)}function Ase({chatId:e}){let t=AM(e),n=Iw();return t.length===0?null:(0,J.jsx)(`div`,{className:`oc-composer__quotes`,role:`group`,"aria-label":gs(),children:t.map(t=>(0,J.jsxs)(`div`,{className:`oc-composer__quote`,children:[(0,J.jsx)(aj,{size:13,"aria-hidden":!0,className:`oc-composer__quote-ico`}),(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__quote-text`,title:xn(),onClick:()=>J7(t.messageId,t.blockIndex,n),children:t.excerpt}),(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__quote-x`,"aria-label":vo(),onClick:()=>wM(e,TM(t)),children:(0,J.jsx)(YC,{size:13,"aria-hidden":!0})})]},TM(t)))})}function jse(){let e=FV(e=>e.status?.type),t=FV(e=>e.type),n=FV(e=>e.file??null),[r,i]=(0,q.useState)(null);(0,q.useEffect)(()=>{if(t!==`image`||!n){i(null);return}let e=URL.createObjectURL(n);return i(e),()=>URL.revokeObjectURL(e)},[t,n]);let a=e===`incomplete`,o=n!==null&&RJ(n),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(null),d=(0,q.useRef)(null);d.current=n;let f=n!==null&&(n.type.startsWith(`text/`)||/\.(txt|md|json|csv|log|xml|yaml|yml)$/i.test(n.name));return(0,J.jsxs)(LH.Root,{className:`oc-attach${a?` oc-attach--error`:``}${r&&!a?` oc-attach--image`:``}${o?` oc-attach--flash`:``}`,"data-status":e,children:[r&&!a?(0,J.jsx)(`img`,{src:r,alt:``,className:`oc-attach__thumb`}):(0,J.jsx)(`span`,{className:`oc-attach__icon`,"aria-hidden":!0,children:a?(0,J.jsx)(pA,{size:14}):t===`image`?(0,J.jsx)(IA,{size:14}):(0,J.jsx)(rj,{size:14})}),r&&!a?null:(0,J.jsx)(`span`,{className:`oc-attach__name`,children:(0,J.jsx)(LH.Name,{})}),a?(0,J.jsx)(`span`,{className:`oc-attach__state`,children:Rd()}):null,!a&&(f||r)?(0,J.jsx)(`button`,{type:`button`,className:`oc-attach__view`,"aria-label":bv(),title:bv(),onClick:()=>{if(c(!0),u(null),f&&n){let e=n,t=2e5;e.slice(0,t).text().then(n=>{d.current===e&&u(e.size>t?n+`
157
+
158
+ `+Pn():n)}).catch(()=>{d.current===e&&u(null)})}},children:(0,J.jsx)(SC,{size:13,"aria-hidden":!0})}):null,(0,J.jsx)(LH.Remove,{className:`oc-attach__remove`,"aria-label":ai(),children:(0,J.jsx)(YC,{size:13,"aria-hidden":!0})}),(0,J.jsx)(rT,{open:s,onOpenChange:c,children:(0,J.jsxs)(eT,{className:`oc-attach__dialog`,children:[(0,J.jsx)(Qw,{children:(0,J.jsx)(tT,{className:`oc-attach__dialog-title`,children:n?.name??bv()})}),r?(0,J.jsx)(`img`,{src:r,alt:``,className:`oc-attach__dialog-img`}):l===null?(0,J.jsx)(`p`,{className:`oc-attach__dialog-text`,children:`…`}):(0,J.jsx)(`pre`,{className:`oc-attach__dialog-text`,children:l})]})})]})}function Mse(){let e=(0,q.useSyncExternalStore)(v2.subscribe,v2.getSnapshot);return e.active?(0,J.jsxs)(`div`,{className:`oc-upload`,role:`status`,"aria-live":`polite`,children:[(0,J.jsxs)(`div`,{className:`oc-upload__head`,children:[(0,J.jsx)(OC,{className:`oc-upload__spin`,size:14,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:e.count>1?ud({count:e.count,percent:e.percent}):zu({percent:e.percent})})]}),(0,J.jsx)(`div`,{className:`oc-upload__track`,"aria-hidden":!0,children:(0,J.jsx)(`div`,{className:`oc-upload__bar`,style:{width:`${e.percent}%`}})})]}):null}function Nse({reason:e}){let t=(0,q.useContext)(D7),n=IV(),r=LV(e=>e.text).trim().length>0,i=e===`subagent`;return(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__send`,disabled:!r||t===null,"aria-label":i?Gg():k(),title:r?i?hp():Cg():i?Jy():eg(),onClick:()=>{if(t===null)return;let e=n.getState().text;e.trim()!==``&&t(e).then(e=>{e&&n.setText(``)})},children:(0,J.jsx)(oA,{size:18,"aria-hidden":!0})})}function Y7(){let e=(0,q.useContext)(O7);return e===null?null:(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__send oc-composer__stop`,"aria-label":Qt(),title:Jo(),onClick:()=>void e(),children:(0,J.jsx)(vj,{size:14,"aria-hidden":!0})})}function Pse({chatId:e,gate:t,onManage:n}){let r=M7(),i=H(G.chatAgents.listChatAgents,{chatId:e}),a=i?u4(i.viewerRoomRole):!1,o=Iw(),[s,c]=(0,q.useState)(!1),l=(0,q.useRef)(null),[u,d]=(0,q.useState)(`agents`),[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(`member`),g=m4(i?.viewerRoomRole),_=h4(m,i?.viewerRoomRole),[v,y]=(0,q.useState)(!1),[b,x]=(0,q.useState)(!1);(0,q.useEffect)(()=>{h(`member`),p(``),y(!1),x(!1)},[e]);let S=H(G.chatParticipants.listInvitable,a&&s&&u===`people`?{chatId:e}:`skip`),C=U(G.chatParticipants.addMember),w=U(G.chatParticipants.removeMember),T=t=>{w({chatId:e,memberId:t.userId}).then(()=>o.success(Lb({name:t.name}))).catch(()=>o.error(vf()))},E=H(G.chatAgents.listAddableAgents,a&&s&&u===`agents`?{chatId:e}:`skip`),D=U(G.chatAgents.addChatAgent),O=U(G.chatAgents.removeChatAgent),k=t=>{let n=t.displayName??t.agentId;O({chatId:e,instanceName:t.instanceName,agentId:t.agentId}).then(e=>{e.removed&&o.success(Lb({name:n}))}).catch(()=>o.error(Sx()))},A=t=>{D({chatId:e,instanceName:t.instanceName,agentId:t.agentId}).catch(e=>{let t=e instanceof Error?e.message:String(e),n=/chat_agents_limit:(\d+)/.exec(t);o.error(n===null?AT(e)?Uu():nu():Bi({count:Number(n[1])}))})},[j,M]=(0,q.useState)(``),N=H(G.chatParticipants.listMembers,{chatId:e}),P=IV(),F=r?.pool??[],I=r?.roomAgents??[],L=i==null?r?.primary??null:i.primary?{instanceName:i.primary.instanceName,agentId:i.primary.agentId}:null,R=(0,q.useMemo)(()=>A4(F,i?[i.primary,...i.agents]:[]),[F,i]),{room:z,others:B}=(0,q.useMemo)(()=>D4(CS(R,j),L,I),[R,j,I,L]),V=(0,q.useMemo)(()=>O4([...R,...E??[]]),[R,E]),ee=t.onCall!=null&&!F.some(e=>g4(e,t.onCall));if(!r||t.hidden&&!n)return null;let te=!t.hidden,{disabled:ne}=t,re=t=>{let n=q3(String(e),P.getState().text,{instanceName:t.instanceName,agentId:t.agentId},k3(t.displayName??t.agentId));n!==null&&P.setText(n)},ie=t.onCall??r.primary,ae=w4(F,ie),oe=new Set((E??[]).map(e=>`${e.instanceName}\u0000${e.agentId}`)),se=j.trim().toLocaleLowerCase(),ce=F4(R,E??[],j),le=ce.slice(0,8),ue=B.length+ce.length,de=N4({unfolded:v,searching:se!==``,hereCount:z.length}),fe=e=>{let t=V.has(`${e.instanceName}\u0000${e.agentId}`),n=oe.has(`${e.instanceName}\u0000${e.agentId}`),r=k4(i?.viewerRoomRole,e,L,I),a=(0,J.jsxs)(`button`,{type:`button`,role:`option`,className:`oc-agentrow`,disabled:e.state===`deleted`||ne||!te,title:e.state===`deleted`?xp():_f({name:e.displayName??e.agentId}),onClick:()=>{re(e),c(!1),M(``)},children:[(0,J.jsx)(`span`,{className:`oc-agentrow__glyph`,title:e.kind===`hermes`?`Hermes`:`OpenClaw`,children:(0,J.jsx)(f3,{kind:e.kind,size:16})}),(0,J.jsxs)(`span`,{className:`oc-agentrow__text`,children:[(0,J.jsxs)(`span`,{className:`oc-agentrow__name`,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId,g4(e,L)?(0,J.jsx)(xA,{size:12,className:`oc-agentrow__primary`,"aria-label":oh(),children:(0,J.jsx)(`title`,{children:oh()})}):null]}),t?(0,J.jsx)(`span`,{className:`oc-agentrow__meta`,children:(0,J.jsx)(`span`,{className:`oc-agentrow__inst`,children:e.instanceName})}):null]}),(0,J.jsx)(sA,{size:14,"aria-hidden":!0,className:`oc-agentrow__hover`})]},`${e.instanceName}/${e.agentId}`);if(!n&&!r)return a;let o=e.displayName??e.agentId;return(0,J.jsxs)(`div`,{className:`oc-agentrow-wrap`,children:[a,n?(0,J.jsx)(`button`,{type:`button`,className:`oc-agentrow__add`,title:vr(),"aria-label":vr(),onClick:()=>A(e),children:(0,J.jsx)(LC,{size:14,"aria-hidden":!0})}):null,r?(0,J.jsx)(`button`,{type:`button`,className:`oc-agentrow__remove`,title:ox({name:o}),"aria-label":ox({name:o}),onClick:()=>k(e),children:(0,J.jsx)(YC,{size:14,"aria-hidden":!0})}):null]},`${e.instanceName}/${e.agentId}`)},pe=+!!L+I.length,me=N?.length??1,he=Nv({agents:pe,people:me,next:ie?`${ae?.displayName??ie.agentId}${(V.has(`${ie.instanceName}\u0000${ie.agentId}`)||ee)&&ie?` (${ie.instanceName})`:``}`:`—`}),ge=(0,J.jsxs)(J.Fragment,{children:[te&&F.length>6||a?(0,J.jsxs)(`div`,{className:`oc-agentlist__search`,children:[(0,J.jsx)(vC,{size:14,"aria-hidden":!0}),(0,J.jsx)(`input`,{autoFocus:!0,value:j,onChange:e=>M(e.target.value),placeholder:eb(),"aria-label":Zg()})]}):null,ne?(0,J.jsx)(`p`,{className:`oc-agentpicker__hint`,children:t.reason===`call-active`?Rh():zv()}):null,(0,J.jsxs)(`div`,{className:`oc-agentlist`,role:`listbox`,children:[z.map(e=>fe(e)),z.length>0&&ue>0?(0,J.jsxs)(`button`,{type:`button`,className:`oc-agentlist__divider oc-agentlist__toggle`,"aria-expanded":de,onClick:()=>y(!de),children:[(0,J.jsx)(eC,{size:13,"aria-hidden":!0,className:`oc-agentlist__chev`}),(0,J.jsx)(`span`,{children:Dv()}),(0,J.jsx)(`span`,{className:`oc-agentlist__togglecount`,children:ue})]}):null,de?(0,J.jsx)(J.Fragment,{children:B.map(e=>{let t=`${e.instanceName}\u0000${e.agentId}`,n=oe.has(t);return(0,J.jsxs)(`button`,{type:`button`,className:`oc-agentrow oc-agentrow--outside`,disabled:!n,onClick:()=>A(e),title:n?vr():kh(),children:[(0,J.jsx)(`span`,{className:`oc-agentrow__glyph`,children:(0,J.jsx)(f3,{kind:e.kind,size:16})}),(0,J.jsxs)(`span`,{className:`oc-agentrow__text`,children:[(0,J.jsxs)(`span`,{className:`oc-agentrow__name`,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),V.has(t)?(0,J.jsx)(`span`,{className:`oc-agentrow__meta`,children:(0,J.jsx)(`span`,{className:`oc-agentrow__inst`,children:e.instanceName})}):null]}),n?(0,J.jsx)(LC,{size:14,"aria-hidden":!0,className:`oc-agentrow__hover`}):null]},`other/${e.instanceName}/${e.agentId}`)})}):null,de&&le.length>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`oc-agentlist__divider`,role:`presentation`,children:Pe()}),le.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`oc-agentrow`,onClick:()=>A(e),title:vr(),children:[(0,J.jsx)(`span`,{className:`oc-agentrow__glyph`,children:(0,J.jsx)(f3,{kind:e.kind,size:16})}),(0,J.jsxs)(`span`,{className:`oc-agentrow__text`,children:[(0,J.jsxs)(`span`,{className:`oc-agentrow__name`,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),V.has(`${e.instanceName}\u0000${e.agentId}`)?(0,J.jsx)(`span`,{className:`oc-agentrow__meta`,children:(0,J.jsx)(`span`,{className:`oc-agentrow__inst`,children:e.instanceName})}):null]}),(0,J.jsx)(LC,{size:14,"aria-hidden":!0,className:`oc-agentrow__hover`})]},`add/${e.instanceName}/${e.agentId}`))]}):null]})]}),_e=(t,n)=>{let r=K3(String(e),P.getState().text,String(n),k3(t));r!==null&&P.setText(r),c(!1)},ve=f.trim().toLocaleLowerCase(),ye=(N??[]).filter(e=>ve===``||e.name.toLocaleLowerCase().includes(ve)),be=(S??[]).filter(e=>e.name.toLocaleLowerCase().includes(ve)||(e.detail??``).toLocaleLowerCase().includes(ve)),xe=be.slice(0,8),Se=N4({unfolded:b,searching:ve!==``,hereCount:ye.filter(e=>!e.isSelf).length}),Ce=t=>{C({chatId:e,memberId:t.userId,role:_}).then(()=>p(``)).catch(e=>{let t=e instanceof Error?e.message:String(e),n=/participants_limit:(\d+)/.exec(t);o.error(n===null?vf():Rb({count:Number(n[1])}))})},we=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`oc-agentlist__search`,children:[(0,J.jsx)(vC,{size:14,"aria-hidden":!0}),(0,J.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),placeholder:a?pc():Ex(),"aria-label":a?pc():Ex()})]}),(0,J.jsx)(`div`,{className:`oc-agentlist__caption`,children:qn()}),(0,J.jsxs)(`div`,{className:`oc-agentlist`,role:`list`,children:[ye.map(e=>{let t=(0,J.jsxs)(`button`,{type:`button`,role:`listitem`,className:`oc-agentrow oc-agentrow--person`,disabled:e.isSelf,onClick:()=>_e(e.name,e.userId),title:e.isSelf?void 0:Eu({name:e.name}),children:[(0,J.jsx)(d3,{userId:String(e.userId),name:e.name}),(0,J.jsxs)(`span`,{className:`oc-agentrow__text`,children:[(0,J.jsxs)(`span`,{className:`oc-agentrow__name`,children:[e.name,e.isSelf?(0,J.jsx)(`span`,{className:`oc-agentrow__tag`,children:_s()}):null]}),(0,J.jsx)(`span`,{className:`oc-agentrow__meta`,children:(0,J.jsx)(Fse,{role:e.roomRole})})]}),(0,J.jsx)(sA,{size:14,"aria-hidden":!0,className:`oc-agentrow__hover`})]},String(e.userId));return p4(i?.viewerRoomRole,e)?(0,J.jsxs)(`div`,{className:`oc-agentrow-wrap`,children:[t,(0,J.jsx)(`button`,{type:`button`,className:`oc-agentrow__remove`,title:ox({name:e.name}),"aria-label":ox({name:e.name}),onClick:()=>T(e),children:(0,J.jsx)(YC,{size:14,"aria-hidden":!0})})]},String(e.userId)):t}),a?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`oc-agentlist__divider oc-agentlist__divider--invite`,role:`presentation`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-agentlist__toggle`,"aria-expanded":Se,onClick:()=>x(!Se),children:[(0,J.jsx)(eC,{size:13,"aria-hidden":!0,className:`oc-agentlist__chev`}),(0,J.jsx)(`span`,{children:ba()}),S!==void 0&&be.length>0?(0,J.jsx)(`span`,{className:`oc-agentlist__togglecount`,children:be.length}):null]}),Se?(0,J.jsxs)(`label`,{className:`oc-invite-as`,children:[(0,J.jsx)(`span`,{children:a_()}),(0,J.jsxs)(sw,{value:_,onValueChange:e=>h(e),children:[(0,J.jsx)(iw,{size:`sm`,className:`oc-invite-as__trigger`,children:(0,J.jsx)(rw,{})}),(0,J.jsx)(aw,{children:g.map(e=>(0,J.jsx)(ow,{value:e,children:v3(e)},e))})]})]}):null]}),Se?S===void 0?(0,J.jsx)(`p`,{className:`oc-agentpicker__hint`,children:Kr()}):xe.length===0?(0,J.jsx)(`p`,{className:`oc-agentpicker__hint`,children:xa()}):xe.map(e=>(0,J.jsxs)(`button`,{type:`button`,role:`listitem`,className:`oc-agentrow oc-agentrow--person`,onClick:()=>Ce(e),title:Sn({name:e.name,role:v3(_)}),children:[(0,J.jsx)(d3,{userId:String(e.userId),name:e.name}),(0,J.jsxs)(`span`,{className:`oc-agentrow__text`,children:[(0,J.jsx)(`span`,{className:`oc-agentrow__name`,children:e.name}),e.detail?(0,J.jsx)(`span`,{className:`oc-agentrow__meta`,title:e.detail,children:(0,J.jsx)(`span`,{className:`oc-agentrow__model`,children:e.detail})}):null]}),(0,J.jsx)(VC,{size:14,"aria-hidden":!0,className:`oc-agentrow__hover`})]},String(e.userId))):null,Se&&be.length>xe.length?(0,J.jsx)(`p`,{className:`oc-agentpicker__hint`,children:dp({count:be.length-xe.length})}):null]}):null]})]});return(0,J.jsxs)(`span`,{className:`oc-roompill`,children:[(0,J.jsxs)(vw,{open:s,onOpenChange:e=>{c(e),e||(M(``),y(!1),x(!1))},children:[(0,J.jsx)(_w,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`oc-roompill__main`,title:t.reason===`call-active`?Rh():he,"aria-label":he,children:[(0,J.jsx)(UC,{size:16,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-roompill__count`,children:pe+me})]})}),(0,J.jsxs)(gw,{align:`start`,className:`oc-composer__agent-pop p-0`,children:[(0,J.jsxs)(`div`,{className:`oc-roomtabs`,role:`tablist`,children:[(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":u===`agents`,className:`oc-roomtabs__tab`,onClick:()=>d(`agents`),children:[(0,J.jsx)(kS,{size:14,"aria-hidden":!0}),wd(),(0,J.jsx)(`span`,{className:`oc-roomtabs__count`,children:pe})]}),(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":u===`people`,className:`oc-roomtabs__tab`,onClick:()=>d(`people`),children:[(0,J.jsx)(UC,{size:14,"aria-hidden":!0}),yi(),(0,J.jsx)(`span`,{className:`oc-roomtabs__count`,children:me})]})]}),u===`agents`?ge:we]})]}),n?(0,J.jsxs)(hC,{children:[(0,J.jsx)(oC,{asChild:!0,children:(0,J.jsx)(`button`,{ref:l,type:`button`,className:`oc-roompill__chev`,title:Ki(),"aria-label":Ki(),"data-overflow":`room-settings`,children:(0,J.jsx)(QS,{size:13,"aria-hidden":!0})})}),(0,J.jsx)(dC,{align:`end`,className:`oc-roommenu`,returnFocus:()=>{let{more:e,field:t}=C2(l.current);return[e,t]},children:(0,J.jsxs)(pC,{onSelect:()=>n(`agents`,null),children:[(0,J.jsx)(lj,{"aria-hidden":!0}),Pm()]})})]}):null]})}function Fse({role:e}){let t=e===`owner`?Yv():e===`manager`?u_():e===`viewer`?Sm():By();return(0,J.jsxs)(`span`,{className:`oc-rolemark`,title:t,children:[(0,J.jsx)(e===`owner`?xA:e===`manager`?BC:e===`viewer`?SC:Sj,{size:13,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:t})]})}function Ise(e){let t=(0,q.useContext)(b7),n=IV(),r=Iw(),[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(``),u=(0,q.useRef)(null),d=(0,q.useRef)(null),f=(0,q.useRef)(e);f.current=e;let p=(0,q.useRef)({chatId:()=>f.current.chatId,getText:()=>n.getState().text,setText:e=>n.setText(e)}),m=(0,q.useSyncExternalStore)(Hj,Uj),h=m!==null&&m.targetChatId===e.chatId;(0,q.useEffect)(()=>()=>{u.current!==null&&d.current!==null&&(d.current.stale=!0);let e=d.current;e!==null&&e.finalizing===!0&&!e.boundToHold&&(e.stale=!0,e.h?.discard()),u.current?.discard(),u.current=null,a(!1),s(!1),l(``)},[e.chatId]);let g=(0,q.useCallback)(()=>{requestAnimationFrame(()=>{let t=e.rootRef.current?.querySelector(`.oc-composer__input`);t&&(t.scrollTop=t.scrollHeight)})},[]),_=RS(t.lang,ut()),v=(0,q.useRef)(_);v.current=_;let y=(0,q.useRef)(e.voiceInput);y.current=e.voiceInput;let b=(0,q.useCallback)(()=>{let e=hM();e!==``&&n.setText(_M(n.getState().text,e,!1))},[]),x=(0,q.useCallback)(()=>{let e=Uj();e!==null&&e.targetChatId===f.current.chatId&&b();let t=d.current,n=u.current!==null&&t!==null&&t.h===u.current;n&&(t.finalizing=!0,t.recording=!1),u.current?.stop(),u.current=null,a(!1),n?s(!0):l(``)},[]),S=(0,q.useCallback)(()=>{if(!JS()){r.error(hi());return}let e=Uj();if(e!==null&&e.targetChatId!==f.current.chatId&&e.recording){r.error(Rc());return}let t=f.current.chatId,i={h:null,boundToHold:!1,startedChatId:t,stale:!1,recording:!1};moe(d.current,p.current),d.current=i,s(!1),l(``);let o=YS({lang:_,onText:(e,r)=>{if(i.holdGen!==void 0&&i.holdGen!==Xj()||i.stale)return;let a=Uj();if(a!==null&&a.targetChatId===t){if(Zj(e,r.paragraph),f.current.chatId===t){let e=Uj();e!==null&&(n.setText(e.text),g())}return}foe(i,d.current,p.current,e,r.paragraph)&&g()},onInterim:e=>{if(i.holdGen!==void 0&&i.holdGen!==Xj()||i.stale)return;i.lastInterim=e;let n=Uj();n!==null&&n.targetChatId===t&&Qj(e),poe(i,d.current,p.current)&&l(e)},onEnd:()=>{i.finalizing=!1,i.recording=!1,i.ended=!0,i.boundToHold&&cM(i.holdGen),!(i.stale||u.current!==null&&u.current!==i.h)&&(u.current=null,a(!1),s(!1),l(``))},onError:e=>{i.boundToHold&&cM(i.holdGen),!(i.stale||u.current!==null&&u.current!==i.h)&&(u.current=null,a(!1),s(!1),l(``),e===`not-allowed`||e===`service-not-allowed`?r.error(bd()):e===`engine-gave-up`?r.error(Hi()):e!==`no-speech`&&e!==`aborted`&&r.error(kv({code:e})))}});if(o===null){r.error(hi());return}i.h=o;let c=Uj();if(c!==null&&c.targetChatId===t){i.boundToHold=!0,Yj(()=>o.stop()),i.holdGen=Xj(),a(!0);return}u.current=o,i.recording=!0,a(!0)},[_,r]),C=(0,q.useCallback)(()=>{if(n.getState().attachments.length>0||S2()){r.error(rt());return}let e=u.current,t=d.current;e===null&&e7(t)&&t7(t,p.current),Jj({targetChatId:f.current.chatId,targetLabel:f.current.chatTitle,text:n.getState().text,interim:e!==null&&t!==null&&t.h===e&&!t.stale?t.lastInterim??``:``,voiceEnabled:y.current,voiceLang:v.current,recording:e!==null,...e===null?{}:{stop:()=>e.stop()}})&&(e!==null&&d.current?.h===e&&(d.current.boundToHold=!0,d.current.holdGen=Xj()),u.current=null,a(!1),s(!1),l(``),n.setText(``))},[r]),w=(0,q.useCallback)(()=>{let e=t7(d.current,p.current);return u.current=null,a(!1),s(!1),l(``),e},[]);return{recording:i||h&&m!==null&&m.recording,ownsSend:(i||o)&&!h,interim:h&&m!==null?m.interim:c,held:h,canPin:m===null,pinned:m!==null,pinnedHere:h,pinnedLabel:m?.targetLabel??``,pinnedTargetChatId:m?.targetChatId??null,pendingSend:h?m?.pendingSend??null:null,pendingSendId:h?m?.pendingSendId??0:0,pendingRestore:h?m?.pendingRestore??null:null,start:S,stop:x,hold:C,flushForSend:w,releaseHereKeepingWords:b}}function Lse({recording:e,onStart:t,onStop:n}){let r=H(G.me.getMe,{host:hT})?.dictationShortcut??null,i=(0,q.useRef)(()=>{});(0,q.useEffect)(()=>{if(!r)return;let e=e=>{e.repeat||Aw(e,r)&&(e.preventDefault(),i.current())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]);let a=r?` (${Ow(r,Dw())})`:``;return(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__icon${e?` oc-composer__icon--rec`:``}`,"data-overflow":`mic`,title:(e?qu():Gd())+a,"aria-label":e?qu():Gd(),"aria-pressed":e,ref:e=>{i.current=()=>e?.click()},onClick:()=>e?n():t(),children:(0,J.jsx)(qS,{size:18,"aria-hidden":!0})})}function Rse({chatId:e,chatTitle:t=``,showTools:n,onToggleTools:r,unavailable:i=!1,agentGate:a,onTalkCallActiveChange:o,serverCallSessionId:s,subAgentBusy:c=!1}){let{can:l,loading:u,resolved:d}=kT(e),f=u||!d||l(`inboundAttachments`),p=T7().voiceInput,m=o4(),h=M7(),[g,_]=(0,q.useState)(!1),[v,b]=(0,q.useState)(`agents`),[x,S]=(0,q.useState)(null),C=(0,q.useCallback)(()=>S(null),[]),w=(0,q.useCallback)((e,t)=>{b(e),S(t),_(!0)},[]),T=h?.nextTarget??null,E=h?.primary??null,D=(h?.roomAgents.length??0)>0,O=D&&E?w4(h?.pool??[],E)?.displayName??E.agentId:s4(m),k=BV(e=>e.isRunning),A=u5(e),j=A!==null&&l(`followUpModes`),M=pae({turnRunning:k,hasRunningSubAgent:!j&&c}),N=M.mode===`queue`,P=(0,q.useContext)(D7),F=IV(),I=eo(),L=(0,q.useRef)(null),R=Kx(),z=Ise({chatId:e,chatTitle:t===``?O:t,voiceInput:p,rootRef:L}),[B,V]=(0,q.useState)(!1),ee=z.pendingSendId,te=Iw(),ne=(0,q.useRef)(0);(0,q.useEffect)(()=>{if(ee===0||ne.current===ee)return;ne.current=ee;let e=Uj(),t=e?.pendingSend??``,n=e?.holdId??-1;if(nM(),i){rM(n),te.error(c_());return}if(t.trim()===``){iM(n);return}N&&P!==null?P(t).then(e=>{e?Uj()?.holdId===n&&(gM(),F.setText(``)):rM(n)}):Uj()?.holdId===n&&(gM(),F.setText(t),F.send())},[ee]);let re=z.pendingRestore;(0,q.useEffect)(()=>{re!==null&&(F.setText(re),sM(),gM())},[re]),(0,q.useEffect)(()=>{if(!B)return;let e=e=>{e.key===`Escape`&&(e.stopPropagation(),V(!1))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[B]);let ie=(0,q.useContext)(MJ);(0,q.useEffect)(()=>{if(ie!==null)return ie.current={canAttach:f&&!N&&!z.pinned,attachFile:e=>z.pinned?Promise.resolve():(ce(e=>e+1),F.addAttachment(e).then(()=>{ue(``),requestAnimationFrame(()=>ue(zn()))}).finally(()=>ce(e=>Math.max(0,e-1)))),insertText:e=>{let t=F.getState();F.setText(t.text+e),ue(``),requestAnimationFrame(()=>ue(_u()))}},()=>{ie.current=null}},[ie,f,N,F,z.pinned]);let ae=(0,q.useRef)(1),oe=Iw(),[se,ce]=(0,q.useState)(0),[le,ue]=(0,q.useState)(``),de=se>0,fe=e=>{if((e.clipboardData?.files?.length??0)>0)return;let t=e.clipboardData?.getData(`text/plain`)??``;if(!t)return;let n=dae(t);if(n!==null&&f&&!N){e.preventDefault();let r=e.currentTarget,i=r.selectionStart??null,a=r.selectionEnd??null,o=F.getState().text,s=()=>{let e=F.getState();e.text===o&&i!==null&&a!==null?F.setText(o.slice(0,i)+t+o.slice(a)):F.setText(e.text+t)};ce(e=>e+1),I.query(G.chatExport.exportByReference,{reference:n}).then(e=>{let t=e;if(t===null){s();return}let n=new File([t.markdown],t.filename,{type:`text/markdown; charset=utf-8`});return LJ(n),F.addAttachment(n).then(()=>{ue(``),requestAnimationFrame(()=>ue(wm()))})}).catch(()=>{s(),oe.error(y())}).finally(()=>ce(e=>Math.max(0,e-1)));return}let r=FJ(t,ae.current);if(r.kind!==`file`||!f)return;if(e.preventDefault(),N){oe.error(Nc());return}ae.current+=1;let i=new File([t],r.filename??`texte-colle.txt`,{type:`text/plain; charset=utf-8`});LJ(i),ce(e=>e+1),F.addAttachment(i).then(()=>{ue(``),requestAnimationFrame(()=>ue(cp({lines:String(r.lines)})))}).catch(e=>{console.error(`[paste] attachment routing failed:`,e),oe.error(jte())}).finally(()=>ce(e=>Math.max(0,e-1)))},pe=(e,t)=>{if(P===null||e.trim()===``)return;let n=j?z8(A?.preference??null,A?.serverMode??null):null,r=n===null?void 0:t?Mre(n):n.mode;P(e,n===null?void 0:{...r?{mode:r}:{},immediate:r!==`queue`}).then(e=>{e&&F.setText(``)})},me=LV(e=>e.text),he=LV(e=>e.attachments.length>0),ge=(fM(me,z.interim)||he&&!N)&&!de,_e=e=>{if(i||de)return;let t=z.flushForSend();if(N){pe(t,e);return}t.trim()===``&&F.getState().attachments.length===0||F.send()},ve=e=>{if(de&&e.key===`Enter`&&!e.shiftKey){e.preventDefault(),e.stopPropagation();return}if(!(e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing)){if(z.ownsSend){e.preventDefault(),e.stopPropagation(),_e(e.metaKey||e.ctrlKey);return}!N||P===null||(e.preventDefault(),e.stopPropagation(),pe(F.getState().text,e.metaKey||e.ctrlKey))}},ye=z.ownsSend?(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__send`,"aria-label":xr(),disabled:!ge||N&&P===null,onClick:()=>_e(!1),children:(0,J.jsx)(oA,{size:18,"aria-hidden":!0})}):null,be=XC(),[xe,Se]=(0,q.useState)({settings:!1,start:!1}),[Ce,we]=(0,q.useState)(!1),Te=yae({hold:z.canPin||z.held,expand:!0,talkSettings:xe.settings,perm:Ce,tools:!B,roomSettings:h!=null,talkStart:xe.start,mic:p,recording:z.recording}),Ee=(0,q.useMemo)(()=>bae(Te),[Te.join(` `)]),De=(0,q.useRef)(null),Oe=xae(Ee,NT(()=>{let e=De.current;if(!e)return null;let t=e.getBoundingClientRect().width;return t>0?{available:t,required:PT(e,Ee.slice(0,-1).map(e=>t=>{for(let[n,r]of Object.entries(E5(e)))t.setAttribute(n,r)}),`oc-composer__bar--measure`)}:null},()=>[De.current],[Ee,be,B])),ke=new Set(Oe.moved),[Ae,je]=(0,q.useState)(!1),[Me,Ne]=(0,q.useState)(null),[Pe,Fe]=(0,q.useState)(null);(0,q.useEffect)(()=>{Oe.moved.length===0&&je(!1)},[Oe.moved.length]);let Le=(0,q.useRef)(null),Re=NT(()=>{let e=Le.current;if(!e)return null;let t=e.getBoundingClientRect().width;return t>0?{available:t,required:PT(e,[e=>e.setAttribute(`data-labels`,`on`)],`oc-composer__exphead--measure`)}:null},()=>[Le.current],[B,be]),ze=h?.perTurnRouting===!0||(h?.roomAgents?.length??0)>0,Be=(0,J.jsxs)(J.Fragment,{children:[B?(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__backdrop`,"aria-label":Jr(),onClick:()=>V(!1)}):null,(0,J.jsxs)(SW.Root,{ref:L,className:`oc-composer${i?` oc-composer--disabled`:``}${z.recording?` oc-composer--dictation`:``}${B?` oc-composer--expanded`:``}`,children:[(0,J.jsxs)(`div`,{className:`oc-composer__body`,children:[B?(0,J.jsxs)(`div`,{className:`oc-composer__exphead`,ref:Le,"data-labels":Re===0?`on`:`off`,children:[(0,J.jsx)(`span`,{className:`oc-composer__exptitle`,children:Nl()}),(0,J.jsxs)(`button`,{type:`button`,className:`oc-composer__expclose`,title:Jr(),"aria-label":Jr(),onClick:()=>V(!1),children:[(0,J.jsx)(ZA,{size:15,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-composer__expclose-label`,children:Jr()})]})]}):null,e?(0,J.jsx)(T3,{chatId:e,onOpen:()=>w(`people`,null)}):null,e?(0,J.jsx)(E3,{chatId:e,routing:h,open:g,onOpenChange:_,tab:v,onTabChange:b,intent:x,onIntentDone:C}):null,(0,J.jsx)(Ase,{chatId:e}),(0,J.jsx)(`div`,{className:`oc-attachrow`,children:(0,J.jsx)(SW.Attachments,{components:{Attachment:jse}})}),(0,J.jsx)(`span`,{className:`oc-sr-only`,role:`status`,"aria-live":`polite`,children:le}),(0,J.jsx)(Mse,{}),(0,J.jsx)(SW.Input,{className:`oc-composer__input`,placeholder:i?c_():D?Os({name:O}):Ay({name:O}),autoFocus:S5(be),unstable_focusOnRunStart:S5(be),unstable_focusOnScrollToBottom:S5(be),unstable_focusOnThreadSwitched:S5(be),rows:1,disabled:i,onKeyDownCapture:ve,onPaste:fe,autoCorrect:`off`,autoCapitalize:be?`sentences`:`off`,autoComplete:`off`,"data-gramm":`false`,"data-gramm_editor":`false`,"data-enable-grammarly":`false`}),(z.recording||z.ownsSend)&&z.interim!==``?(0,J.jsxs)(`div`,{className:`oc-composer__interim`,"aria-hidden":!0,children:[(0,J.jsx)(`span`,{className:`oc-composer__interim-dot`}),(0,J.jsx)(`span`,{className:`oc-composer__interim-text`,children:z.interim})]}):null]}),(0,J.jsxs)(`div`,{className:`oc-composer__bar`,ref:De,...E5(Oe),children:[(0,J.jsxs)(`div`,{className:`oc-composer__group`,children:[(0,J.jsx)(coe,{chatId:e,routedAgent:T?{instanceName:T.instanceName,agentId:T.agentId}:null,attachmentsSupported:f,attachDisabled:N||i}),B?null:(0,J.jsxs)(`button`,{type:`button`,className:`oc-composer__tools${n?` is-on`:``}`,onClick:r,"aria-pressed":n,title:n?fu():vl(),"data-overflow":`tools`,children:[(0,J.jsx)(HC,{size:15,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-composer__tools-label`,children:ar()})]}),(0,J.jsx)(Pse,{chatId:e,gate:a,onManage:w}),(0,J.jsx)(eoe,{chatId:e,routedAgent:T?{instanceName:T.instanceName,agentId:T.agentId}:null,multiAgent:ze,onVisibleChange:we})]}),(0,J.jsxs)(`div`,{className:`oc-composer__group`,children:[(0,J.jsx)(loe,{open:Ae,onOpenChange:je,moved:ke,hold:{held:z.held,disabled:!z.canPin||de,onHold:z.hold,onRelease:z.releaseHereKeepingWords},expand:{expanded:B,onToggle:()=>V(e=>!e)},tools:{shown:n,onToggle:r},onManageConversation:()=>w(`agents`,null),onDictate:z.start,permission:ke.has(`perm`)?(0,J.jsx)(H5,{chatId:e,routedAgent:T?{instanceName:T.instanceName,agentId:T.agentId}:null,multiAgent:ze}):null,talkSettingsSlot:Ne,talkStartSlot:Fe}),(0,J.jsx)(`span`,{className:`oc-composer__voiceslot${z.canPin||z.held?` is-shown`:``}`,"aria-hidden":!z.canPin&&!z.held,"data-overflow":`hold`,children:z.held?(0,J.jsxs)(`button`,{type:`button`,className:`oc-composer__heldchip`,title:Fs(),"aria-label":Fs(),onClick:z.releaseHereKeepingWords,children:[(0,J.jsx)(Xx,{size:12,"aria-hidden":!0}),xg(),(0,J.jsx)(YC,{size:11,"aria-hidden":!0})]}):(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__icon oc-composer__hold`,title:br(),"aria-label":br(),onClick:z.hold,disabled:!z.canPin||de,tabIndex:!z.canPin||de?-1:0,children:(0,J.jsx)(Xx,{size:16,"aria-hidden":!0})})}),(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__icon${B?` is-on`:``}`,title:B?Jr():Sa(),"aria-label":B?Jr():Sa(),"aria-pressed":B,onClick:()=>V(e=>!e),"data-overflow":`expand`,children:B?(0,J.jsx)(ZA,{size:16,"aria-hidden":!0}):(0,J.jsx)(qA,{size:16,"aria-hidden":!0})}),p?(0,J.jsx)(Lse,{recording:z.recording,onStart:z.start,onStop:z.stop}):null,(0,J.jsx)(Q2,{chatId:e,onCallActiveChange:o,serverCallSessionId:s,routedAgent:T?{instanceName:T.instanceName,agentId:T.agentId}:null,onPresenceChange:Se,more:{moved:{settings:ke.has(`talk-settings`),start:ke.has(`talk`)},settingsSlot:Me,startSlot:Pe,onDone:()=>je(!1)}},e),i?(0,J.jsxs)(J.Fragment,{children:[M.mode===`queue`?(0,J.jsx)(Y7,{}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__send`,disabled:!0,"aria-label":Yi(),children:(0,J.jsx)(oA,{size:18,"aria-hidden":!0})})]}):M.mode===`queue`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y7,{}),ye??(j?(0,J.jsx)(zie,{chatId:e,queueSend:P===null?null:(e,t)=>P(e,{...t?{mode:t}:{},immediate:t!==`queue`})}):(0,J.jsx)(Nse,{reason:M.reason}))]}):j&&c?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y7,{}),ye??(0,J.jsx)(SW.Send,{className:`oc-composer__send`,"aria-label":xr(),disabled:de,children:(0,J.jsx)(oA,{size:18,"aria-hidden":!0})})]}):ye??(0,J.jsx)(SW.Send,{className:`oc-composer__send`,"aria-label":xr(),disabled:de,children:(0,J.jsx)(oA,{size:18,"aria-hidden":!0})})]})]})]})]});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(_se,{}),z.pinned?(0,J.jsxs)(`div`,{className:`oc-composer__pinnednote`,role:`note`,children:[(0,J.jsx)(Xx,{size:14,"aria-hidden":!0}),z.pinnedHere?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:iu()}),(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__pinnedgoto`,onClick:()=>aM(),children:Ie()})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:Ox({chat:z.pinnedLabel||Dt()})}),z.pinnedTargetChatId?(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__pinnedgoto`,onClick:()=>{R({to:`/chat/$chatId`,params:{chatId:z.pinnedTargetChatId}})},children:hc()}):null]})]}):B?(0,bk.createPortal)(Be,document.body):Be]})}function zse({chatId:e}){let t=U5(e);return t.offered?(0,J.jsxs)(pC,{disabled:t.pending,"data-widgets-toggle":!0,onSelect:()=>t.set(!t.enabled),children:[(0,J.jsx)(BA,{}),t.enabled?qi():Yn()]}):null}var X7=67324752,Z7=33639248,Q7=101010256,$7=0,e9=2048,t9=class extends Error{reason;constructor(e,t){super(t===void 0?e:`${e}: ${t}`),this.reason=e,this.name=`ZipError`}},Bse=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let n=t;for(let e=0;e<8;e+=1)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function n9(e){let t=4294967295;for(let n of e)t=Bse[(t^n)&255]^t>>>8;return(t^4294967295)>>>0}function Vse(e){if(e.length>65535)throw new t9(`too_many_entries`,String(e.length));let t=new TextEncoder,n=[],r=[],i=0;for(let a of e){let e=t.encode(a.name),o=n9(a.bytes),s=new Uint8Array(30+e.length),c=new DataView(s.buffer);c.setUint32(0,X7,!0),c.setUint16(4,20,!0),c.setUint16(6,e9,!0),c.setUint16(8,$7,!0),c.setUint16(10,0,!0),c.setUint16(12,33,!0),c.setUint32(14,o,!0),c.setUint32(18,a.bytes.length,!0),c.setUint32(22,a.bytes.length,!0),c.setUint16(26,e.length,!0),c.setUint16(28,0,!0),s.set(e,30);let l=new Uint8Array(46+e.length),u=new DataView(l.buffer);u.setUint32(0,Z7,!0),u.setUint16(4,20,!0),u.setUint16(6,20,!0),u.setUint16(8,e9,!0),u.setUint16(10,$7,!0),u.setUint16(12,0,!0),u.setUint16(14,33,!0),u.setUint32(16,o,!0),u.setUint32(20,a.bytes.length,!0),u.setUint32(24,a.bytes.length,!0),u.setUint16(28,e.length,!0),u.setUint32(42,i,!0),l.set(e,46),n.push(s,a.bytes),r.push(l),i+=s.length+a.bytes.length}let a=r.reduce((e,t)=>e+t.length,0),o=new Uint8Array(22),s=new DataView(o.buffer);s.setUint32(0,Q7,!0),s.setUint16(8,e.length,!0),s.setUint16(10,e.length,!0),s.setUint32(12,a,!0),s.setUint32(16,i,!0);let c=n.reduce((e,t)=>e+t.length,0)+a+22,l=new Uint8Array(c),u=0;for(let e of[...n,...r,o])l.set(e,u),u+=e.length;return l}function Hse(e){let t=new DataView(e.buffer,e.byteOffset,e.length),n=new TextDecoder,r=-1;for(let n=e.length-22;n>=0;--n)if(t.getUint32(n,!0)===Q7){r=n;break}if(r===-1)throw new t9(`not_a_zip`);let i=t.getUint16(r+10,!0),a=t.getUint32(r+16,!0),o=[];for(let r=0;r<i;r+=1){if(a+46>e.length||t.getUint32(a,!0)!==Z7)throw new t9(`corrupt`,`central directory`);let r=t.getUint16(a+8,!0),i=t.getUint16(a+10,!0),s=t.getUint32(a+16,!0),c=t.getUint32(a+24,!0),l=t.getUint16(a+28,!0),u=t.getUint16(a+30,!0),d=t.getUint16(a+32,!0),f=t.getUint32(a+42,!0),p=n.decode(e.subarray(a+46,a+46+l));if(i!==$7)throw new t9(`unsupported_method`,p);if((r&e9)===0)throw new t9(`unsupported_encoding`,p);if(f+30>e.length||t.getUint32(f,!0)!==X7)throw new t9(`corrupt`,p);let m=t.getUint16(f+26,!0),h=t.getUint16(f+28,!0),g=f+30+m+h;if(g+c>e.length)throw new t9(`corrupt`,p);let _=e.slice(g,g+c);if(n9(_)!==s)throw new t9(`checksum_mismatch`,p);o.push({name:p,bytes:_}),a+=46+l+u+d}return o}var r9=`manifest.json`,i9=`chats/`,Use=`sections/`,a9=`blobs/`,Wse=512*1024*1024,Gse=1e4,Kse=76,qse=600*1e3;function Jse(e,t){return e.filter(e=>t-e.updatedAt>qse)}var Yse=class extends Error{bytes;constructor(e){super(`archive exceeds ${Wse} bytes`),this.bytes=e,this.name=`ArchiveTooLarge`}};async function o9(e,t,n){let r=new TextEncoder,i=await e.manifest(),a=[],o=0,s=0,c=0,l=new Set,u=(e,t)=>{if(o+=t.length+Kse+2*e.length,o>536870912)throw new Yse(o);a.push({name:e,bytes:t})},d=[];for(let a of t){let t=await e.chat(a);u(`${i9}${a}.json`,r.encode(JSON.stringify(t)));for(let t of i.sections){let i=null,o=0;do{let f=await e.section(a,t,i);f.rows.length>0&&u(`${Use}${a}/${t}/${o}.json`,r.encode(JSON.stringify(f.rows)));for(let t of f.blobs){if(t.url===null){d.push(t.key);continue}l.has(t.key)||(l.add(t.key),u(`${a9}${t.key}`,await e.blob(t.url)),s+=1,n?.({phase:`blobs`,done:s,total:null}))}i=f.cursor,o+=1,c+=1,n?.({phase:`sections`,done:c,total:null})}while(i!==null&&o<1e4);if(i!==null)throw Error(`export of ${t} did not finish within ${Gse} pages`)}}return n?.({phase:`packing`,done:a.length,total:a.length}),a.unshift({name:r9,bytes:r.encode(JSON.stringify({...i,missingBlobs:d}))}),{archive:Vse(a),manifest:i,blobCount:s,missingBlobs:d}}async function Xse(e,t,n,r){let i=new TextDecoder,a=Hse(t);r?.({phase:`reading`,done:a.length,total:a.length});let o=new Map(a.map(e=>[e.name,e.bytes])).get(r9);if(o===void 0)throw Error(`archive has no manifest`);let s=JSON.parse(i.decode(o)),c=await e.begin({formatVersion:s.formatVersion,origin:s.origin??null},n),l=0,u=!1,d=new Map,f=new Set;try{let t=a.filter(e=>e.name.startsWith(a9)).length;for(let n of a){if(!n.name.startsWith(`blobs/`))continue;let i=n.name.slice(6);if(d.has(i))throw Error(`archive names the same blob twice: ${i}`);let a=await e.upload(n.bytes,i);await e.registerBlob(c,a),d.set(i,a),r?.({phase:`uploading`,done:d.size,total:t})}let n=a.filter(e=>e.name.startsWith(i9));for(let t of n){let n=JSON.parse(i.decode(t.bytes)),r=await e.batch(c,`chats`,[n],s9([n],d));l+=r.written,c9([n],r.writtenIds,f)}for(let t of s.sections){let n=a.filter(e=>e.name.startsWith(`sections/`)&&e.name.includes(`/${t}/`)).sort((e,t)=>l9(e.name)-l9(t.name));for(let a of n){let n=JSON.parse(i.decode(a.bytes)),o=await e.batch(c,t,n,s9(n,d));l+=o.written,r?.({phase:`writing`,done:l,total:null}),c9(n,o.writtenIds,f)}}for(let[t,n]of d)f.has(t)||await e.discardUpload(c,n);let o=Math.ceil(l/100)+100;for(let t=0;t<o&&!u;t+=1)u=(await e.finish(c)).done}catch(t){try{let t=!1;for(let n=0;n<1e4&&!t;n+=1)t=(await e.abandon(c)).done;for(let t of d.values())await e.discardUpload(c,t)}catch{}throw t}return{importId:c,written:l,purged:u}}function s9(e,t){let n=new Set;for(let t of e){let e=t.archiveBlobKey;typeof e==`string`&&n.add(e);let r=t.archiveBlobKeys;if(Array.isArray(r))for(let e of r)typeof e==`string`&&n.add(e)}let r=[];for(let e of n){let n=t.get(e);n!==void 0&&r.push({key:e,storageId:n})}return r}function c9(e,t,n){let r=new Set(t);for(let t of e){if(typeof t._id!=`string`||!r.has(t._id))continue;let e=t.archiveBlobKey;typeof e==`string`&&n.add(e);let i=t.archiveBlobKeys;if(Array.isArray(i))for(let e of i)typeof e==`string`&&n.add(e)}}function l9(e){let t=/\/(\d+)\.json$/.exec(e);return t===null?0:Number(t[1])}function u9(e){return`atrium-${e.normalize(`NFKD`).replace(/[^\p{Letter}\p{Number}]+/gu,`-`).replace(/^-+|-+$/g,``).slice(0,60)||`conversation`}.zip`}function d9(e,t){let n=URL.createObjectURL(new Blob([e],{type:`application/zip`})),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),setTimeout(()=>URL.revokeObjectURL(n),6e4)}function Zse(){let e=eo(),[t,n]=(0,q.useState)({running:!1,progress:null}),r=(0,q.useRef)(!1),i=(0,q.useCallback)(()=>({manifest:()=>e.action(G.archiveExport.exportManifest,{}),chat:t=>e.query(G.archiveExport.exportChat,{chatId:t}),section:(t,n,r)=>e.query(G.archiveExport.exportChatSection,{chatId:t,section:n,cursor:r}),blob:async e=>{let t=await fetch(e);if(!t.ok)throw Error(`attachment could not be read (${t.status})`);return new Uint8Array(await t.arrayBuffer())}}),[e]),a=(0,q.useCallback)(()=>({begin:(t,n)=>e.mutation(G.archiveImport.beginImport,{manifest:t,targetProjectId:n??null}),batch:(t,n,r,i)=>e.mutation(G.archiveImport.importBatch,{importId:t,section:n,rows:r,blobs:i.map(e=>({key:e.key,storageId:e.storageId}))}),finish:t=>e.mutation(G.archiveImport.finishImport,{importId:t}),abandon:t=>e.mutation(G.archiveImport.abandonImport,{importId:t}),upload:async t=>{let n=await e.mutation(G.chats.generateUploadUrl,{}),{storageId:r}=await(await fetch(n,{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:new Blob([t])})).json();return await e.mutation(G.uploads.registerUpload,{storageId:r}),r},registerBlob:async(t,n)=>{await e.mutation(G.archiveImport.registerImportBlob,{importId:t,storageId:n})},discardUpload:async(t,n)=>{await e.mutation(G.archiveImport.discardUpload,{importId:t,storageId:n})}}),[e]),o=(0,q.useCallback)(async e=>{if(r.current)throw Error(`a transfer is already running`);r.current=!0,n({running:!0,progress:null});try{return await e(e=>n({running:!0,progress:e}))}finally{r.current=!1,n({running:!1,progress:null})}},[]),s=(0,q.useCallback)((e,t)=>o(async n=>{let{archive:r,missingBlobs:a}=await o9(i(),e,n);return d9(r,u9(t)),{missingBlobs:a}}),[o,i]),c=(0,q.useCallback)((t,n)=>o(async r=>{let a=await e.query(G.archiveExport.exportFolderTree,{projectId:t});if(!a.complete)throw Error(`folder_too_large`);let o=[];for(let t of a.folders){let n=null;do{let r=await e.query(G.archiveExport.exportFolderChats,{projectId:t._id,cursor:n});o.push(...r.chatIds),n=r.cursor}while(n!==null)}let{archive:s,missingBlobs:c}=await o9(i(),o,r);return d9(s,u9(n)),{missingBlobs:c,chatCount:o.length}}),[e,o,i]),l=(0,q.useCallback)((e,t)=>o(async n=>{if(e.size>536870912)throw Error(`archive_too_large`);return Xse(a(),new Uint8Array(await e.arrayBuffer()),t,n)}),[o,a]);return(0,q.useEffect)(()=>{let t=!1;return(async()=>{try{let n=await e.query(G.archiveImport.listOpenImports,{});for(let r of Jse(n,Date.now())){let n=!1;for(let i=0;i<1e3&&!n&&!t;i+=1)n=(await e.mutation(G.archiveImport.abandonImport,{importId:r.importId})).done}}catch{}})(),()=>{t=!0}},[e]),{state:t,exportChats:s,exportFolder:c,importArchive:l}}var f9=(0,q.createContext)(null);function Qse({children:e}){let t=Zse(),n=Iw(),r=(e,t)=>{let r=e instanceof Error?e.message:String(e);if(r.includes(`folder_too_large`)){n.error(bm());return}if(r.includes(`already running`)){n.error(E());return}if(r.includes(`archive_too_large`)){n.error(Td());return}if(r.includes(`not_a_zip`)||r.includes(`no manifest`)){n.error(Qu());return}n.error(t,e)},i={state:t.state,exportChat:(e,i)=>{t.exportChats([e],i).then(({missingBlobs:e})=>{e.length>0?n.error(qv({count:e.length})):n.success(Wh())}).catch(e=>r(e,Yd()))},exportFolder:(e,i)=>{t.exportFolder(e,i).then(({missingBlobs:e})=>{e.length>0?n.error(qv({count:e.length})):n.success(Wh())}).catch(e=>r(e,Yd()))},importArchive:(e,i)=>{t.importArchive(e,i).then(({written:e,purged:t})=>{n.success(ete({count:e}),t?void 0:Ry())}).catch(e=>r(e,zs()))}},a={...i,pickAndImport:e=>{let t=document.createElement(`input`);t.type=`file`,t.accept=`.zip,application/zip`,t.addEventListener(`change`,()=>{let n=t.files?.[0];n!==void 0&&i.importArchive(n,e)}),t.click()}};return(0,J.jsx)(f9.Provider,{value:a,children:e})}function p9(){return(0,q.useContext)(f9)}function $se(e){if(!e.running)return null;let t=e.progress;if(t===null)return Ep();switch(t.phase){case`sections`:return ob({count:t.done});case`blobs`:return gee({count:t.done});case`packing`:return Ep();case`reading`:return my({count:t.done});case`uploading`:return j_({done:t.done,total:t.total??t.done});case`writing`:return Mf({count:t.done})}}function ece(e,t){return e===null?t:`${e}-${t}`}var tce=e=>{let{transform:t}=e;return{...t,y:0}};function nce(e,t,n){let r={...e};return t.top+e.y<=n.top?r.y=n.top-t.top:t.bottom+e.y>=n.top+n.height&&(r.y=n.top+n.height-t.bottom),t.left+e.x<=n.left?r.x=n.left-t.left:t.right+e.x>=n.left+n.width&&(r.x=n.left+n.width-t.right),r}var rce=e=>{let{draggingNodeRect:t,transform:n,scrollableAncestorRects:r}=e,i=r[0];return!t||!i?n:nce(n,t,i)},ice=e=>{let{transform:t}=e;return{...t,x:0}},m9=`project:none`,ace=e=>`project:${e}`,h9=`projhead:`,g9=e=>`${h9}${e}`,_9=`oc.noproject.collapsed`,v9=`oc.shared.collapsed`,oce=[`full`,`label`,`icon`];function y9(){return(0,J.jsx)(`div`,{className:`oc-sidebar__skeleton`,"aria-hidden":`true`,children:Array.from({length:7}).map((e,t)=>(0,J.jsx)(`div`,{className:`oc-skel oc-skel--row`},t))})}var b9=(0,q.createContext)(new Map);function sce({activeChatId:e,onSelect:t,onNewChat:n,newChatShortcut:r}){let i=H(G.messages.listChats,{}),a=H(G.projects.listProjects,{}),o=H(G.me.getMe,{host:hT})?.ui?.effective?.showChatAge??!0,s=H(G.chatReads.myChatReads,{}),c=(0,q.useMemo)(()=>{let e=new Map;for(let t of s??[])e.set(t.chatId,t.lastSeenAt);return e},[s]),l=H(G.chatReads.myBusyChats,{}),u=(0,q.useMemo)(()=>new Set(l??[]),[l]),{byChat:d}=dS(l??null),f=H(G.agentRequests.pendingByChat,{}),p=(0,q.useMemo)(()=>{let e=new Map;for(let t of f??[])e.set(t.chatId,t.kinds.includes(`approval`)?`approval`:t.kinds.includes(`credential`)?`credential`:`question`);return e},[f]),m=H(G.chatBookmarks.myBookmarkedChats,{}),h=H(G.chatExport.referenceLabel,{}),g=(0,q.useMemo)(()=>new Set(m??[]),[m]),_=(0,q.useMemo)(()=>{let t=new Set;for(let n of i??[]){if(n._id===e)continue;let r=c.get(n._id);r!==void 0&&n.lastAssistantAt!==null&&n.lastAssistantAt>r&&t.add(n._id)}return t},[i,c,e]),[v,y]=(0,q.useState)(0);(0,q.useEffect)(()=>{if(!o)return;let e=window.setInterval(()=>y(e=>e+1),6e4);return()=>window.clearInterval(e)},[o]);let b=U(G.projects.createProject),x=U(G.projects.setProjectCollapsed),S=U(G.projects.setProjectSidebar),C=U(G.chats.reorderChat),w=U(G.projects.reorderProject),T=U(G.chats.moveChatToProject),E=_T(),D=hr(),O=(0,q.useRef)(null),k=(0,q.useRef)(null),A=(0,q.useRef)(null),j=oce[NT(()=>{let e=O.current;return e?{available:e.clientWidth,required:[k.current?.offsetWidth??0,A.current?.offsetWidth??0]}:null},()=>[O.current],[D,r])],[M,N]=(0,q.useState)(null),P=(0,q.useRef)(!1);(0,q.useEffect)(()=>{!P.current&&i&&N(i)},[i]);let F=M??i??[],I=F.filter(e=>e.sidebarHidden!==!0),L=F.filter(e=>e.sidebarHidden===!0),R=i===void 0&&M===null,[z,B]=(0,q.useState)(null),[V,ee]=(0,q.useState)(()=>localStorage.getItem(_9)===`1`),[te,ne]=(0,q.useState)(()=>localStorage.getItem(v9)===`1`);function re(){ne(e=>(localStorage.setItem(v9,e?`0`:`1`),!e))}function ie(){ee(e=>(localStorage.setItem(_9,e?`0`:`1`),!e))}let ae=r3();(0,q.useEffect)(()=>{if(!ae?.expand)return;let e=I.find(e=>e._id===ae.chatId);if(!e)return;let t=e.projectId??null;if(t===null){V&&(localStorage.setItem(_9,`0`),ee(!1));return}let n=(a??[]).find(e=>e._id===t);n&&n.parentId!==null||n?.collapsed&&x({projectId:t,collapsed:!1})},[ae,I,a,V,x]);let oe=fS(PS(hS,{activationConstraint:{distance:4}}),PS(IS,{activationConstraint:{delay:250,tolerance:8}}),PS(xS,{coordinateGetter:yS})),se=(0,q.useRef)(!1),ce=()=>{se.current=!0,setTimeout(()=>{se.current=!1},0)},le=(0,q.useCallback)(e=>String(e.active.id).startsWith(h9)?FS({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(h9))}):FS(e),[]),ue=I.filter(e=>e.pinned),de=I.filter(e=>!e.pinned&&e.role===`participant`),fe=I.filter(e=>!e.pinned&&e.role!==`participant`),pe=e=>fe.filter(t=>(t.projectId??null)===e),me=Kx(),he=(0,q.useMemo)(()=>uS(a??[]),[a]),ge=(0,q.useMemo)(()=>he.filter(e=>!e.sidebarHidden),[he]),_e=(0,q.useMemo)(()=>he.filter(e=>e.sidebarHidden),[he]),ve=(0,q.useMemo)(()=>{let e=a??[];return new Map(e.map(t=>[t._id,cS(e,t._id)]))},[a]),ye=(0,q.useMemo)(()=>new Map((a??[]).map(e=>[e._id,e.name])),[a]),be=e=>fe.filter(t=>t.projectId!==null&&(ve.get(t.projectId)??t.projectId)===e);function xe(e){return I.find(t=>t._id===e)}async function Se(e){B(null),ce();let{active:t,over:n}=e;if(!n)return;let r=String(t.id),i=String(n.id);if(r.startsWith(h9)){let e=r.slice(9),t=ge,n=null;if(i.startsWith(h9))n=i.slice(9);else if(i.startsWith(`project:`)&&i!==m9)n=i.slice(8);else{let e=xe(i);n=e&&!e.pinned?e.projectId??null:null}if(n===null||n===e)return;let a=t.findIndex(t=>t._id===e),o=t.findIndex(e=>e._id===n);if(a<0||o<0)return;let s=[...t],[c]=s.splice(a,1);s.splice(o,0,c);let l=s[o-1]??null,u=s[o+1]??null;await w({projectId:e,prevKey:l?l.sortKey:null,nextKey:u?u.sortKey:null});return}let a=xe(r);if(!a||a.role===`participant`)return;if(i.startsWith(h9)){let e=i.slice(9);if((a.projectId??null)===e)return;P.current=!0,N(t=>(t??I).map(t=>t._id===a._id?{...t,projectId:e}:t));try{await T({chatId:a._id,projectId:e})}finally{P.current=!1}return}if(i.startsWith(`project:`)){let e=i===m9?null:i.slice(8);if((a.projectId??null)===e)return;P.current=!0,N(t=>(t??I).map(t=>t._id===a._id?{...t,projectId:e}:t));try{await T({chatId:a._id,projectId:e})}finally{P.current=!1}return}let o=xe(i);if(!o||t.id===n.id)return;if((o.projectId??null)!==(a.projectId??null)||o.pinned!==a.pinned){if(a.pinned||o.pinned)return;P.current=!0,N(e=>(e??I).map(e=>e._id===a._id?{...e,projectId:o.projectId??null}:e));try{await T({chatId:a._id,projectId:o.projectId??null})}finally{P.current=!1}return}let s=o.pinned?ue:pe(o.projectId??null),c=s.map(e=>e._id),l=c.indexOf(a._id),u=c.indexOf(o._id);if(l<0||u<0)return;let d=[...s];d.splice(l,1),d.splice(u,0,a);let f=d[u-1]??null,p=d[u+1]??null;P.current=!0,N(e=>[...(e??I).filter(e=>!s.some(t=>t._id===e._id)),...d]);try{await C({chatId:a._id,prevKey:f?f.sortKey:null,nextKey:p?p.sortKey:null})}finally{P.current=!1}}let Ce=p9(),we=Ce?$se(Ce.state):null,[Te,Ee]=(0,q.useState)(!1),De=z?xe(z):null;return(0,J.jsx)(b9.Provider,{value:p,children:(0,J.jsx)(eS.Provider,{value:d,children:(0,J.jsxs)(`aside`,{className:`oc-sidebar`+(Te?` oc-sidebar--archivedrop`:``),onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),Ee(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||Ee(!1)},onDrop:e=>{if(!e.dataTransfer.types.includes(`Files`))return;e.preventDefault(),Ee(!1);let t=e.dataTransfer.files[0];t!==void 0&&Ce?.importArchive(t,null)},children:[Te?(0,J.jsxs)(`div`,{className:`oc-sidebar__droparchive`,"aria-hidden":!0,children:[(0,J.jsx)(KC,{className:`size-4`}),(0,J.jsx)(`span`,{children:Xp()})]}):null,we===null?null:(0,J.jsxs)(`div`,{className:`oc-sidebar__transfer`,role:`status`,"aria-live":`polite`,children:[(0,J.jsx)(`span`,{className:`oc-sidebar__transfer-spin`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-sidebar__transfer-label`,children:we})]}),(0,J.jsxs)(`div`,{className:`oc-sidebar__top`,ref:O,children:[(0,J.jsxs)(K,{className:j===`icon`?`oc-newchat flex-1 justify-center`:`oc-newchat flex-1 justify-start`,onClick:n,"data-focus-key":`sidebar:new-chat`,title:`${D} (${r})`,"aria-label":D,children:[(0,J.jsx)(LC,{}),j===`icon`?null:(0,J.jsx)(`span`,{className:`oc-newchat__label`,children:D}),j===`full`?(0,J.jsx)(`kbd`,{className:`oc-newchat__kbd`,"aria-hidden":!0,children:r}):null]}),(0,J.jsx)(`div`,{className:`oc-newchat-ghost`,"aria-hidden":!0,children:(0,J.jsxs)(`div`,{className:`oc-newchat-ghost__row`,ref:k,children:[(0,J.jsxs)(K,{className:`oc-newchat justify-start`,tabIndex:-1,children:[(0,J.jsx)(LC,{}),(0,J.jsx)(`span`,{className:`oc-newchat__label`,children:D}),(0,J.jsx)(`kbd`,{className:`oc-newchat__kbd`,children:r})]}),(0,J.jsx)(K,{variant:`outline`,size:`icon`,tabIndex:-1,children:(0,J.jsx)(tS,{})})]})}),(0,J.jsx)(`div`,{className:`oc-newchat-ghost`,"aria-hidden":!0,children:(0,J.jsxs)(`div`,{className:`oc-newchat-ghost__row`,ref:A,children:[(0,J.jsxs)(K,{className:`oc-newchat justify-start`,tabIndex:-1,children:[(0,J.jsx)(LC,{}),(0,J.jsx)(`span`,{className:`oc-newchat__label`,children:D})]}),(0,J.jsx)(K,{variant:`outline`,size:`icon`,tabIndex:-1,children:(0,J.jsx)(tS,{})})]})}),(0,J.jsx)(K,{className:`oc-newproject`,"data-focus-key":`sidebar:new-folder`,variant:`outline`,size:`icon`,"aria-label":$l(),title:$l(),onClick:async()=>{let e=await E({title:$l(),label:je(),placeholder:Cx(),confirmLabel:lc()});e&&await b({name:e})},children:(0,J.jsx)(tS,{})})]}),(0,J.jsxs)(TS,{sensors:oe,collisionDetection:le,modifiers:[ice,rce],onDragStart:e=>B(String(e.active.id)),onDragCancel:()=>{B(null),ce()},onDragEnd:Se,children:[(0,J.jsx)(`div`,{className:`oc-sidebar__scroll`,children:R?(0,J.jsx)(y9,{}):(0,J.jsxs)(J.Fragment,{children:[ue.length>0?(0,J.jsx)(x9,{label:ga(),chats:ue,children:ue.map(n=>(0,J.jsx)(S9,{chat:n,active:n._id===e,unread:_.has(n._id),busy:u.has(n._id),bookmarked:g.has(n._id),referenceLabel:h,ageTick:v,suppressClick:se,onSelect:t},n._id))}):null,(0,J.jsx)(jS,{items:ge.map(e=>g9(e._id)),strategy:OS,children:ge.map(n=>{let r=be(n._id);return(0,J.jsx)(x9,{label:n.name,dropId:ace(n._id),sortId:g9(n._id),suppressClick:se,projectId:n._id,project:n,chats:r,collapsible:!0,collapsed:n.collapsed,busy:r.some(e=>u.has(e._id)),unread:r.some(e=>_.has(e._id)),onToggle:()=>void x({projectId:n._id,collapsed:!n.collapsed}),onOpen:()=>void me({to:`/project/$projectId`,params:{projectId:n._id}}),children:n.collapsed?null:r.length===0?(0,J.jsx)(`div`,{className:`oc-sidebar__empty`,children:Hr()}):r.map(r=>(0,J.jsx)(S9,{chat:r,active:r._id===e,unread:_.has(r._id),busy:u.has(r._id),bookmarked:g.has(r._id),referenceLabel:h,domainLabel:r.projectId!==null&&r.projectId!==n._id?ye.get(r.projectId)??null:null,ageTick:v,suppressClick:se,onSelect:t},r._id))},n._id)})}),_e.length>0?(0,J.jsxs)(hC,{children:[(0,J.jsx)(oC,{asChild:!0,children:(0,J.jsxs)(`button`,{className:`oc-sidebar__hiddenfolders`,"data-focus-key":`sidebar:hidden-folders`,children:[(0,J.jsx)(xC,{className:`size-3.5`,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:bi({count:_e.length})})]})}),(0,J.jsx)(dC,{align:`start`,className:`w-56`,children:_e.map(e=>(0,J.jsxs)(pC,{onSelect:()=>void S({projectId:e._id,hidden:!1}),children:[(0,J.jsx)(aS,{}),` `,e.name]},e._id))})]}):null,de.length>0||L.length>0?(0,J.jsxs)(x9,{label:Ig(),chats:de,collapsible:!0,collapsed:te,busy:de.some(e=>u.has(e._id)),unread:de.some(e=>_.has(e._id)),onToggle:re,children:[te?null:de.map(n=>(0,J.jsx)(S9,{chat:n,active:n._id===e,unread:_.has(n._id),busy:u.has(n._id),bookmarked:g.has(n._id),referenceLabel:h,ageTick:v,suppressClick:se,onSelect:t},n._id)),!te&&L.length>0?(0,J.jsx)(cce,{chats:L}):null]}):null,(0,J.jsx)(x9,{label:vn(),dropId:m9,chats:pe(null),collapsible:!0,collapsed:V,busy:pe(null).some(e=>u.has(e._id)),unread:pe(null).some(e=>_.has(e._id)),onToggle:ie,children:V?null:pe(null).map(n=>(0,J.jsx)(S9,{chat:n,active:n._id===e,unread:_.has(n._id),busy:u.has(n._id),bookmarked:g.has(n._id),referenceLabel:h,ageTick:v,suppressClick:se,onSelect:t},n._id))})]})}),(0,J.jsxs)(ane,{children:[z?.startsWith(h9)?(()=>{let e=(a??[]).find(e=>g9(e._id)===z);return e?(0,J.jsxs)(`div`,{className:`oc-sidebar__group-head oc-chatitem--overlay`,style:{"--proj-hue":DS(e)},children:[(0,J.jsx)(QS,{className:`size-3.5 shrink-0 oc-sidebar__group-chev`}),(0,J.jsx)(`span`,{className:`oc-sidebar__group-label`,children:e.name})]}):null})():null,De?(0,J.jsxs)(`div`,{className:`oc-chatitem oc-chatitem--overlay`,children:[gS(De.color)?(0,J.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:gS(De.color)}}):(0,J.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,J.jsx)(`span`,{className:`oc-chatitem__label`,children:De.title||ps()})]}):null]})]})]})})})}function x9({label:e,dropId:t,sortId:n,suppressClick:r,projectId:i,project:a,chats:o,collapsible:s,collapsed:c,busy:l,unread:u,onToggle:d,onOpen:f,children:p}){let m=U(G.projects.setProjectSidebar),h=p9(),g=(0,q.useContext)(eS),_=o.map(e=>g.get(e._id)).find(e=>e!==void 0)??null,v=U(G.projects.deleteProject),y=U(G.projects.renameProject),b=U(G.projects.setProjectColor),x=U(G.projects.moveProject),S=gT(),C=FT(),[w,T]=(0,q.useState)(!1),[E,D]=(0,q.useState)(e),[O,k]=(0,q.useState)(!1),A=H(G.projects.projectTreeCount,i?{projectId:i}:`skip`),{setNodeRef:j,isOver:M}=Zx({id:t??`static:${e}`}),N=bS({id:n??`static-sort:${e}`,disabled:!n}),{onKeyDown:P,...F}=N.listeners??{},I=f??d,L=e=>{e.target===e.currentTarget&&s&&I&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),I())},R=a?DS(a):null;return(0,J.jsxs)(`div`,{ref:e=>{t&&j(e),n&&N.setNodeRef(e)},className:`oc-sidebar__group`+(M?` oc-sidebar__group--over`:``)+(a?` oc-sidebar__group--project`:``),style:{...R?{"--proj-hue":R}:{},...n?{transform:$x.Transform.toString(N.transform),transition:N.transition,opacity:N.isDragging?.35:1}:{}},children:[(0,J.jsxs)(`div`,{className:`oc-sidebar__group-head oc-reveal-host group/head`+(s?` oc-sidebar__group-head--btn`:``),title:c&&l&&_?oS(_):void 0,...s?{role:`button`,tabIndex:0,onClick:()=>{r?.current||I?.()},onKeyDown:L}:{},...n?F:{},children:[s?f?(0,J.jsx)(`button`,{type:`button`,className:`oc-sidebar__group-chevbtn oc-hit`,"aria-label":c?$p():ub(),"aria-expanded":!c,onClick:e=>{e.stopPropagation(),!r?.current&&d?.()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:c?(0,J.jsx)(eC,{className:`size-3.5 shrink-0`+(a?` oc-sidebar__group-chev`:``)}):(0,J.jsx)(QS,{className:`size-3.5 shrink-0`+(a?` oc-sidebar__group-chev`:``)})}):c?(0,J.jsx)(eC,{className:`size-3.5 shrink-0`+(a?` oc-sidebar__group-chev`:``)}):(0,J.jsx)(QS,{className:`size-3.5 shrink-0`+(a?` oc-sidebar__group-chev`:``)}):null,(0,J.jsx)(`span`,{className:`oc-sidebar__group-label`,children:e}),n?(0,J.jsx)(`button`,{className:`oc-drag-a11y`,"aria-label":lx(),onClick:e=>e.stopPropagation(),...N.attributes,onKeyDown:P,children:(0,J.jsx)(MA,{className:`size-3.5`})}):null,c&&l?(0,J.jsx)(`span`,{className:rS(_,ho()).className,title:rS(_,ho()).label,"aria-label":rS(_,ho()).label}):null,c&&u?(0,J.jsx)(`span`,{className:`oc-chatitem__unread`,title:xt(),"aria-label":xt()}):null,i?(0,J.jsxs)(hC,{children:[(0,J.jsx)(oC,{asChild:!0,children:(0,J.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":gg(),className:`oc-sidebar__group-menu oc-reveal oc-hit`,"data-focus-key":`sidebar:folder-menu:${i}`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:(0,J.jsx)(lC,{})})}),(0,J.jsxs)(dC,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[f?(0,J.jsxs)(pC,{onSelect:()=>f(),children:[(0,J.jsx)(aS,{}),` `,Ate()]}):null,(0,J.jsxs)(pC,{onSelect:()=>{D(e),T(!0)},children:[(0,J.jsx)(IC,{}),` `,ta()]}),(0,J.jsxs)(pC,{onSelect:()=>k(!0),children:[(0,J.jsx)(tS,{}),` `,ni()]}),a!==void 0&&a.parentId===null?(0,J.jsxs)(pC,{onSelect:()=>void m({projectId:a._id,hidden:!0}),children:[(0,J.jsx)(xC,{}),` `,sp()]}):null,h&&a?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(pC,{disabled:h.state.running,onSelect:()=>h.exportFolder(a._id,e),children:[(0,J.jsx)(bC,{}),` `,tv()]}),(0,J.jsxs)(pC,{disabled:h.state.running,onSelect:()=>h.pickAndImport(a._id),children:[(0,J.jsx)(KC,{}),` `,uee()]})]}):null,(0,J.jsx)(uC,{children:$o()}),(0,J.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void b({projectId:i,color:null}),"aria-label":$a(),children:`✕`}),SS.map(e=>(0,J.jsx)(`button`,{className:`oc-colorgrid__dot`+(a?.color===e.value?` is-selected`:``),style:{background:e.hue},"aria-label":e.value,onClick:()=>void b({projectId:i,color:e.value})},e.value))]}),(0,J.jsx)(mC,{}),(0,J.jsxs)(pC,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let t=A?.folders??0,n=A?.chats??0;await S({title:ste({name:e}),description:wne({folders:t,chats:n,days:C}),confirmWord:_e(),confirmLabel:rl(),destructive:!0})&&await v({projectId:i})})},children:[(0,J.jsx)(WC,{}),` `,_e()]})]})]}):null]}),(0,J.jsx)(`div`,{className:a&&!c?`oc-sidebar__group-body`:void 0,children:(0,J.jsx)(jS,{items:o.map(e=>e._id),strategy:OS,children:p})}),i?(0,J.jsx)(wT,{open:w,onOpenChange:T,title:ie(),canSubmit:E.trim().length>0,onSubmit:async()=>{await y({projectId:i,name:E.trim()}),T(!1)},children:(0,J.jsx)(`div`,{className:`oc-form`,children:(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:Au()}),(0,J.jsx)(Tw,{value:E,onChange:e=>D(e.target.value),autoFocus:!0})]})})}):null,i&&O?(0,J.jsx)(AS,{open:O,onOpenChange:k,title:Ai(),movingFolderId:i,currentId:a?.parentId??null,onPick:e=>void x({projectId:i,parentId:e})}):null]})}var S9=(0,q.memo)(function({chat:e,active:t,unread:n,busy:r,bookmarked:i,referenceLabel:a,domainLabel:o,suppressClick:s,onSelect:c}){let l=(0,q.useContext)(b9).get(e._id),u=(0,q.useContext)(eS).get(e._id)??null,d=p9(),{attributes:f,listeners:p,setNodeRef:m,transform:h,transition:g,isDragging:_}=bS({id:e._id}),{onKeyDown:v,...y}=p??{},b=U(G.chats.renameChat),x=Iw(),S=()=>{if(a===void 0)return;let t=ece(a,e._id);navigator.clipboard.writeText(t).then(()=>x.success(d_({reference:t})),()=>x.error(Vy()))},C=U(G.chats.deleteChat),w=U(G.chats.pinChat),T=U(G.chats.setChatColor),E=U(G.chats.moveChatToProject),D=U(G.chats.setChatSidebar),O=U(G.chatParticipants.leaveChat),k=e.role===`participant`,A=Kx(),[j,M]=(0,q.useState)(!1),N=H(G.me.getMe,{host:hT})?.ui?.effective?.showChatAge??!0,P=gT(),F=FT(),[I,L]=(0,q.useState)(!1),[R,z]=(0,q.useState)(e.title??``),B=r3()?.chatId===e._id,V=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!B)return;let t=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;V.current?.scrollIntoView({block:`nearest`,behavior:t?`auto`:`smooth`});let n=setTimeout(()=>n3(e._id),2600);return()=>clearTimeout(n)},[B,e._id]);let ee={transform:$x.Transform.toString(h),transition:g,opacity:+!_},te=gS(e.color);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{ref:e=>{m(e),V.current=e},style:ee,className:`oc-chatitem oc-reveal-host group/row`+(t?` oc-chatitem--active`:``)+(B?` oc-chatitem--flash`:``),title:r&&u?oS(u):void 0,onClick:()=>{s.current||c(e._id)},...y,onAnimationEnd:t=>{B&&t.animationName===`oc-chatitem-flash`&&n3(e._id)},children:[(0,J.jsx)(`button`,{className:`oc-drag-a11y`,"aria-label":lx(),onClick:e=>e.stopPropagation(),...f,onKeyDown:v,children:(0,J.jsx)(MA,{className:`size-3.5`})}),te?(0,J.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:te}}):(0,J.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,J.jsxs)(`button`,{className:`oc-chatitem__label`,onClick:t=>{t.stopPropagation(),!s.current&&c(e._id)},children:[(0,J.jsxs)(`span`,{className:`oc-chatitem__title`,children:[e.group?(0,J.jsx)(UC,{className:`oc-chatitem__group`,size:12,"aria-label":nl()}):null,e.title||ps()]}),e.role===`participant`&&e.ownerName?(0,J.jsx)(`span`,{className:`oc-chatitem__domain`,children:Wt({name:e.ownerName})}):o?(0,J.jsx)(`span`,{className:`oc-chatitem__domain`,children:o}):null]}),l===void 0?null:(0,J.jsx)(`span`,{className:`oc-areq-sidebadge oc-areq-sidebadge--${l}`,title:fy(),"aria-label":fy(),children:l===`approval`?(0,J.jsx)(BC,{size:11,"aria-hidden":!0}):l===`credential`?(0,J.jsx)(zA,{size:11,"aria-hidden":!0}):(0,J.jsx)(YA,{size:11,"aria-hidden":!0})}),r?(0,J.jsx)(`span`,{className:rS(u,Va()).className,title:rS(u,Va()).label,"aria-label":rS(u,Va()).label}):null,n?(0,J.jsx)(`span`,{className:`oc-chatitem__unread`,title:xt(),"aria-label":xt()}):null,e.readOnly?(0,J.jsx)(`span`,{className:`oc-chatitem__readonly`,title:Gt(),children:(0,J.jsx)(kC,{size:12,"aria-label":Gt()})}):null,i?(0,J.jsx)(`span`,{className:`oc-chatitem__bookmark group-hover/row:opacity-0 group-focus-within/row:opacity-0`,title:If(),children:(0,J.jsx)(uA,{size:12,"aria-label":If()})}):null,N?(0,J.jsx)(`span`,{className:`oc-chatitem__age group-hover/row:opacity-0 group-focus-within/row:opacity-0`,title:Xw(e.updatedAt),children:ES(e.updatedAt,Date.now())}):null,(0,J.jsxs)(hC,{children:[(0,J.jsx)(oC,{asChild:!0,children:(0,J.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":Js(),className:`oc-reveal oc-hit`,"data-focus-key":`sidebar:chat-menu:${e._id}`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:(0,J.jsx)(lC,{})})}),(0,J.jsxs)(dC,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[k?null:(0,J.jsxs)(pC,{onSelect:()=>{z(e.title??``),L(!0)},children:[(0,J.jsx)(IC,{}),` `,ta()]}),d&&!k?(0,J.jsxs)(pC,{disabled:d.state.running,onSelect:()=>d.exportChat(e._id,e.title??vn()),children:[(0,J.jsx)(bC,{}),` `,Iee()]}):null,(0,J.jsxs)(pC,{onSelect:()=>void w({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,J.jsx)(LS,{}):(0,J.jsx)(Xx,{}),e.pinned?Dr():rn()]}),k?null:(0,J.jsx)(zse,{chatId:e._id}),k?null:(0,J.jsxs)(pC,{onSelect:S,disabled:a===void 0,children:[(0,J.jsx)(HA,{}),` `,Xv()]}),k?null:(0,J.jsxs)(pC,{onSelect:()=>M(!0),children:[(0,J.jsx)(aS,{}),` `,sd()]}),e.projectId===null?null:(0,J.jsxs)(pC,{onSelect:()=>void A({to:`/project/$projectId`,params:{projectId:e.projectId},search:{c:e._id}}),children:[(0,J.jsx)(kA,{}),` `,Lee()]}),e.pinned?null:(0,J.jsxs)(pC,{onSelect:()=>void D({chatId:e._id,hidden:!0}),children:[(0,J.jsx)(mS,{}),` `,sp()]}),k?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(mC,{}),(0,J.jsxs)(pC,{variant:`destructive`,onSelect:()=>void O({chatId:e._id}),children:[(0,J.jsx)(KA,{}),` `,Dx()]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(uC,{children:$o()}),(0,J.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void T({chatId:e._id,color:null}),"aria-label":$a(),children:`✕`}),SS.map(t=>(0,J.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void T({chatId:e._id,color:t.value})},t.value))]}),(0,J.jsx)(mC,{}),(0,J.jsxs)(pC,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await P({title:ka(),description:ag({days:F}),confirmLabel:_e(),destructive:!0})&&await C({chatId:e._id})})},children:[(0,J.jsx)(WC,{}),` `,_e()]})]})]})]})]}),(0,J.jsx)(wT,{open:I,onOpenChange:L,title:kd(),canSubmit:R.trim().length>0,onSubmit:async()=>{await b({chatId:e._id,title:R.trim()}),L(!1)},children:(0,J.jsx)(`div`,{className:`oc-form`,children:(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:Au()}),(0,J.jsx)(Tw,{value:R,onChange:e=>z(e.target.value),autoFocus:!0})]})})}),j?(0,J.jsx)(AS,{open:j,onOpenChange:M,title:_v(),currentId:e.projectId,onPick:t=>void E({chatId:e._id,projectId:t})}):null]})});function cce({chats:e}){let[t,n]=(0,q.useState)(!1),r=U(G.chats.setChatSidebar);return(0,J.jsxs)(`div`,{className:`oc-hiddenshared`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-hiddenshared__toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[t?(0,J.jsx)(QS,{size:12,"aria-hidden":!0}):(0,J.jsx)(eC,{size:12,"aria-hidden":!0}),zo({count:e.length})]}),t?(0,J.jsx)(`ul`,{className:`oc-hiddenshared__list`,children:e.map(e=>(0,J.jsxs)(`li`,{className:`oc-hiddenshared__row`,children:[(0,J.jsx)(`span`,{className:`oc-hiddenshared__title`,children:e.title??vn()}),(0,J.jsx)(`button`,{type:`button`,className:`oc-hiddenshared__show`,onClick:()=>void r({chatId:e._id,hidden:!1}),children:bt()})]},e._id))}):null]})}var C9=null,w9=0,lce=400;function uce(){if(typeof window>`u`)return null;let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;if(!C9)try{C9=new e}catch{return null}return C9}function T9(e,t,n,r,i){let a=e.createOscillator(),o=e.createGain();a.type=`sine`,a.frequency.value=t;let s=e.currentTime+n;o.gain.setValueAtTime(1e-4,s),o.gain.linearRampToValueAtTime(i,s+.015),o.gain.exponentialRampToValueAtTime(1e-4,s+r),a.connect(o).connect(e.destination),a.start(s),a.stop(s+r+.02)}function E9(e){let t=Date.now();if(t-w9<lce)return;let n=uce();if(!n)return;w9=t;let r=()=>{try{e(n)}catch{}};n.state===`suspended`?n.resume().then(r,()=>{}):r()}function dce(){E9(e=>{T9(e,660,0,.16,.12),T9(e,440,.14,.2,.1)})}function fce(){E9(e=>{T9(e,880,0,.14,.08)})}function pce({activeChatId:e}){let t=H(G.messages.listChats,{}),n=U(G.chatReads.markChatSeen),r=H(G.me.getMe,{host:hT}),i=r?.ui?.effective?.replySound===!0,a=r?.userId??null,o=(0,q.useRef)(null),s=(0,q.useRef)(null);return(0,q.useEffect)(()=>{if(!t)return;s.current!==String(a)&&(s.current=String(a),o.current=null);let r=new Map;for(let e of t)e.lastAssistantAt!==null&&r.set(e._id,e.lastAssistantAt);let c=o.current;if(o.current=r,c===null)return;let l=!1;for(let[t,i]of r){let r=c.get(t);r!==void 0&&i<=r||r===void 0&&Date.now()-i>3e4||(l=!0,t===e&&document.visibilityState===`visible`?n({chatId:t}):t!==e&&t3(t))}l&&i&&fce()},[t,e,i,n,a]),(0,q.useEffect)(()=>{e&&document.visibilityState===`visible`&&n({chatId:e})},[e,n]),(0,q.useEffect)(()=>{let t=()=>{document.visibilityState===`visible`&&e&&n({chatId:e})};return document.addEventListener(`visibilitychange`,t),()=>document.removeEventListener(`visibilitychange`,t)},[e,n]),null}var D9=[`admin`,`user`,`pending`];function O9(){let e=H(G.me.authProviders)?.anonymous===!0,[t,n]=(0,q.useState)(!1),r=H(G.dev.listUsersDev,e?{}:`skip`),i=H(G.me.getImpersonation),a=U(G.dev.setMyRole),o=U(G.dev.setRole),s=U(G.admin.startImpersonation),c=U(G.admin.stopImpersonation);if(!e)return null;let l=r?.find(e=>e.isMe),u=l?.role===`admin`,d=i?.impersonating===!0,f=(r??[]).filter(e=>!e.isMe);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-devfab`,onClick:()=>n(!0),title:Wee(),children:[(0,J.jsx)(Cj,{size:13}),`DEV`]}),(0,J.jsx)(rT,{open:t,onOpenChange:n,children:(0,J.jsxs)(eT,{children:[(0,J.jsxs)(Qw,{children:[(0,J.jsx)(tT,{children:Ey()}),(0,J.jsx)(nT,{children:cm()})]}),(0,J.jsxs)(`div`,{className:`oc-devsw__me`,children:[(0,J.jsxs)(`span`,{className:`oc-devsw__melabel`,children:[x({canonical:l?.canonical??`…`}),` `,(0,J.jsx)(Rw,{variant:`outline`,children:l?.role??`…`})]}),(0,J.jsx)(`div`,{className:`oc-devsw__roles`,children:D9.map(e=>(0,J.jsx)(K,{type:`button`,size:`xs`,variant:l?.role===e?`secondary`:`ghost`,disabled:l?.role===e,onClick:()=>void a({role:e}),children:e===`admin`?Ps():e===`user`?Wd():Ku()},e))})]}),d?(0,J.jsxs)(`div`,{className:`oc-devsw__imp`,children:[yd(),` `,(0,J.jsx)(`strong`,{children:i.targetLabel}),`.`,(0,J.jsx)(K,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>void c(),children:mi()})]}):null,(0,J.jsx)(`div`,{className:`oc-devsw__list`,children:f.length===0?(0,J.jsx)(`p`,{className:`oc-devsw__empty`,children:Ov()}):f.map(e=>(0,J.jsxs)(`div`,{className:`oc-devsw__row`,children:[(0,J.jsx)(`span`,{className:`oc-devsw__label`,children:e.name||e.email||e.canonical||e.userId.slice(0,8)}),(0,J.jsx)(`select`,{className:`oc-devsw__select`,value:e.role,disabled:!e.canonical,onChange:t=>e.canonical&&void o({canonical:e.canonical,role:t.target.value}),children:D9.map(e=>(0,J.jsx)(`option`,{value:e,children:e},e))}),(0,J.jsx)(K,{type:`button`,size:`xs`,variant:`ghost`,disabled:!u||e.role===`pending`,title:u?e.role===`pending`?Un():Su():Vi(),onClick:()=>{s({profileId:e.profileId}),n(!1)},children:Ol()})]},e.profileId))})]})})]})}var k9=`atrium.authelia-login`;function mce(e){let t=new URL(e.href);if(t.origin!==e.origin)throw Error(`Invalid login return origin.`);for(let e of[`code`,`state`,`error`,`error_description`])t.searchParams.delete(e);return`${t.pathname}${t.search}${t.hash}`}function hce(e,t){let n;return{start(r,i=!1){if(n)return n;try{let t=e.getItem(k9);if(!i&&t!==null)return Promise.resolve(t===`signed-out`?`signed-out`:`failed`);e.setItem(k9,`attempted`)}catch{return Promise.resolve(`failed`)}return n=(async()=>{try{let e=await r(`authelia`,{redirectTo:t()});return e.redirect||e.signingIn?`redirecting`:`failed`}catch{return`failed`}})().finally(()=>{n=void 0}),n},signedOut(){try{e.setItem(k9,`signed-out`)}catch{}},authenticated(){try{e.removeItem(k9)}catch{}}}}var A9;function j9(){return A9??=hce({getItem:e=>window.sessionStorage.getItem(e),setItem:(e,t)=>window.sessionStorage.setItem(e,t),removeItem:e=>window.sessionStorage.removeItem(e)},()=>mce(window.location)),A9}function M9({label:e,mode:t,minimal:n=!1,compact:r=!1}){let{signOut:i}=jE();async function a(){j9().signedOut(),await i()}let o=U(G.me.setThemeMode).withOptimisticUpdate((e,{mode:t})=>{let n=e.getQuery(G.me.getMe,{host:hT});if(!n)return;let r=t===null?n.defaultThemeMode??`system`:t;e.setQuery(G.me.getMe,{host:hT},{...n,themeMode:t,resolvedThemeMode:r})}),s=t??`default`;return(0,J.jsxs)(hC,{children:[(0,J.jsx)(oC,{asChild:!0,children:r?(0,J.jsx)(K,{variant:`ghost`,size:`icon`,"aria-label":e,title:e,children:(0,J.jsx)(gA,{})}):(0,J.jsxs)(K,{variant:`ghost`,size:`sm`,className:`oc-usermenu__trigger min-w-0 shrink gap-1.5`,"aria-label":e,title:e,children:[(0,J.jsx)(gA,{className:`oc-usermenu__icon`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-usermenu__label`,children:e}),(0,J.jsx)(QS,{className:`oc-usermenu__chev opacity-60`,"aria-hidden":!0})]})}),(0,J.jsx)(dC,{side:r?`right`:`bottom`,align:`end`,className:`w-52`,children:n?(0,J.jsxs)(pC,{onClick:()=>void a(),children:[(0,J.jsx)(KA,{}),` `,wb()]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(uC,{children:Ve()}),(0,J.jsxs)(aC,{value:s,onValueChange:e=>void o({mode:e==="default"?null:e}),children:[(0,J.jsxs)(fC,{value:`light`,children:[(0,J.jsx)(yj,{}),` `,xc()]}),(0,J.jsxs)(fC,{value:`dark`,children:[(0,J.jsx)($A,{}),` `,vte()]}),(0,J.jsxs)(fC,{value:`system`,children:[(0,J.jsx)(QA,{}),` `,Xf()]}),(0,J.jsx)(fC,{value:`default`,children:Bte()})]}),(0,J.jsx)(mC,{}),(0,J.jsxs)(pC,{onClick:()=>void a(),children:[(0,J.jsx)(KA,{}),` `,wb()]})]})})]})}var N9=[`full`,`logo`,`icon`],P9=[`full`,`logo`];function gce({providers:e,children:t}){return e===void 0?(0,J.jsx)(`div`,{className:`oc-boot`,children:Vv()}):e.autheliaOnly?(0,J.jsx)(vce,{enabled:e.authelia}):t}function _ce({state:e,retry:t}){return(0,J.jsx)(`div`,{className:`oc-signin`,children:(0,J.jsxs)(`div`,{className:`oc-signin__card`,role:`status`,"aria-live":`polite`,children:[(0,J.jsx)(`p`,{className:`oc-signin__subtitle`,children:e===`redirecting`?Nd():e===`signed-out`?Pu():e===`unavailable`?hv():ad()}),e===`failed`||e===`signed-out`?(0,J.jsx)(`button`,{type:`button`,className:`oc-provider`,onClick:t,children:ws()}):null]})})}function vce({enabled:e}){let{signIn:t}=jE(),[n,r]=(0,q.useState)(e?`redirecting`:`unavailable`);return(0,q.useEffect)(()=>{let n=!0;return e?j9().start(t).then(e=>{n&&r(e)}):r(`unavailable`),()=>{n=!1}},[e,t]),(0,J.jsx)(_ce,{state:n,retry:()=>{r(`redirecting`),j9().start(t,!0).then(r)}})}var yce={altered_words:()=>Qte(),incorrect:()=>Us(),incoherence:()=>Xi(),formatting:()=>Sr(),latency:()=>$t(),api_error:()=>Yo(),other:()=>Ya()},F9=e=>yce[e]?.()??e,bce={anomaly_open:GC,anomaly_resolved:nC,feedback_reply:nS,feedback_resolved:nS,feedback_new:nS,curation:TA,operator_announcement:JA,mention:sA,agent_request:YA,chat_added:UC,group_invite:VC},xce={atrium:()=>ip(),assistants:()=>Gte(),platform:()=>Mb()},Sce={investigating:()=>df(),monitoring:()=>$m(),resolved:()=>Ch()},I9=e=>(e?xce[e]:void 0)?.()??`?`,Cce=e=>(e?Sce[e]:void 0)?.()??`?`,L9=e=>{let t=e===void 0?NaN:Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(ut()):`?`},wce={notif_feedback_reply_admin:()=>({title:ul(),body:Zn()}),notif_feedback_reply:()=>({title:ul(),body:Zn()}),notif_feedback_resolved:()=>({title:tm(),body:fb()}),notif_feedback_new:e=>({title:Fl(),body:fe({reference:e.reference??`?`,category:F9(e.category??`other`)})}),notif_mention:e=>({title:cc(),body:re({chat:e.chat??``})}),notif_chat_added:e=>({title:ha({by:e.by??`?`}),body:re({chat:e.chat??``})}),notif_group_invite_request:e=>({title:Vr(),body:_n({by:e.by??`?`,group:e.group??`?`})}),notif_group_invite_approved:e=>({title:fs(),body:mo({email:e.email??`?`,group:e.group??`?`})}),notif_group_invite_rejected:e=>({title:Ba(),body:hg({email:e.email??`?`,group:e.group??`?`})}),notif_agent_request_question:e=>({title:k_(),body:Kv({chat:e.chat??``})}),notif_agent_request_approval:e=>({title:jf(),body:Kv({chat:e.chat??``})}),notif_agent_request_credential:e=>({title:Uh(),body:Kv({chat:e.chat??``})}),notif_curation_proposed:e=>({title:gd(),body:di({name:e.name??`?`,agentId:e.agentId??`?`})}),notif_curation_failed:e=>({title:Tv(),body:Ri({name:e.name??`?`,reason:e.reason??`unknown`})}),notif_curation_relaunch_refused:e=>({title:Bn(),body:vu({name:e.name??`?`,reason:e.reason??`unknown`})}),notif_anomaly_open:(e,t)=>({title:wl({kind:e.kind??`?`}),body:t.body}),notif_anomaly_resolved:(e,t)=>({title:dr({kind:e.kind??`?`}),body:t.body}),notif_operator_maintenance_scheduled:e=>({title:Io(),body:_t({service:I9(e.service),startsAt:L9(e.starts_at),endsAt:L9(e.ends_at)})}),notif_operator_maintenance_completed:e=>({title:Vt(),body:Qc({service:I9(e.service),completedAt:L9(e.completed_at)})}),notif_operator_incident_update:e=>({title:rte(),body:Je({service:I9(e.service),status:Cce(e.status),reference:e.reference??`?`})}),notif_operator_subscription_notice:e=>({title:kc(),body:Ete({plan:e.plan??`?`,effectiveAt:L9(e.effective_at)})})};function R9(e){let t=e.messageKey?wce[e.messageKey]:void 0;return t?t(e.params??{},e):e.kind===`feedback_reply`?{title:ul(),body:Zn()}:e.kind===`feedback_resolved`?{title:tm(),body:fb()}:{title:e.title,body:e.body}}function Tce(){let e=H(G.notifications.myUnreadCount)??0,t=H(G.notifications.myNotifications),n=H(G.feedback.myFeedback),r=U(G.notifications.markRead),i=U(G.notifications.markAllRead),a=U(G.notifications.clearOne),o=U(G.notifications.clearAll),s=U(G.feedback.closeMyFeedback),c=Kx(),[l,u]=(0,q.useState)(!1),d=H(G.me.getMe,{host:hT}),f=d?.ui?.effective?.notifSound===!0,p=d?.ui?.effective?.notifSystem===!0,m=d?.userId??null,h=(0,q.useRef)(null),g=(0,q.useRef)(0),_=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!t)return;_.current!==String(m)&&(_.current=String(m),h.current=null,g.current=0);let e=t.reduce((e,t)=>Math.max(e,t.creationTime??0),0);if(h.current===null){h.current=new Set(t.map(e=>String(e._id))),g.current=e;return}let n=h.current,r=t.filter(e=>!n.has(String(e._id))&&(e.creationTime??0)>g.current);for(let e of t)n.add(String(e._id));if(g.current=Math.max(g.current,e),n.size>500){let e=new Set(t.map(e=>String(e._id)));for(let t of n)e.has(t)||n.delete(t)}if(r.length!==0&&(f&&dce(),p&&typeof Notification<`u`&&Notification.permission===`granted`&&document.visibilityState!==`visible`)){let e=r[0],{title:t,body:n}=R9(e);try{let r=new Notification(t,{body:n,tag:String(e._id)});r.onclick=()=>window.focus()}catch{}}},[t,f,p,m]);let v=e=>{if(e.unread&&r({notificationId:e._id}),!e.href)return;if(u(!1),e.href.startsWith(`/chat/`)){c({to:`/chat/$chatId`,params:{chatId:e.href.slice(6)}});return}let[t,n]=e.href.split(`?`);c({to:t,search:Object.fromEntries(new URLSearchParams(n??``))})};return(0,J.jsxs)(hC,{open:l,onOpenChange:u,children:[(0,J.jsx)(oC,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`oc-bell`,"aria-label":e>0?Lp({count:e}):Ty(),children:[(0,J.jsx)(cA,{size:18,"aria-hidden":!0}),e>0?(0,J.jsx)(`span`,{className:`oc-bell__badge`,"aria-hidden":!0,children:e>9?`9+`:e}):null]})}),(0,J.jsxs)(dC,{align:`end`,className:`oc-notif`,children:[(0,J.jsxs)(`div`,{className:`oc-notif__head`,children:[(0,J.jsx)(`span`,{children:H_()}),t&&t.length>0?(0,J.jsxs)(`span`,{className:`oc-notif__bulk`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-notif__act`,disabled:e===0,onClick:()=>void i({}),children:Wf()}),(0,J.jsx)(`button`,{type:`button`,className:`oc-notif__act`,onClick:()=>void o({}),children:$h()})]}):null]}),t===void 0?(0,J.jsx)(`div`,{className:`oc-notif__empty`,children:qb()}):t.length===0?(0,J.jsx)(`div`,{className:`oc-notif__empty`,children:ny()}):(0,J.jsx)(`div`,{className:`oc-notif__list`,children:t.map(e=>{let t=bce[e.kind]??cA,{title:n,body:i}=R9(e);return(0,J.jsxs)(`div`,{className:`oc-notif__item${e.unread?` is-unread`:``}${e.href?` is-link`:``}`,role:e.href?`button`:void 0,tabIndex:e.href?0:void 0,onClick:e.href?()=>v(e):void 0,children:[(0,J.jsxs)(`div`,{className:`oc-notif__item-head`,children:[(0,J.jsx)(t,{size:14,className:`oc-notif__kind oc-notif__kind--${e.kind}`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-notif__title`,children:n}),(0,J.jsxs)(`span`,{className:`oc-notif__row-actions`,children:[e.unread?(0,J.jsx)(`button`,{type:`button`,title:v_(),"aria-label":v_(),onClick:t=>{t.stopPropagation(),r({notificationId:e._id})},children:(0,J.jsx)(ZS,{size:13})}):null,(0,J.jsx)(`button`,{type:`button`,title:qy(),"aria-label":qy(),onClick:t=>{t.stopPropagation(),a({notificationId:e._id})},children:(0,J.jsx)(YC,{size:13})})]})]}),(0,J.jsx)(`p`,{className:`oc-notif__body`,children:i}),(0,J.jsx)(`div`,{className:`oc-notif__when`,children:new Date(e.createdAt).toLocaleString(ut())})]},e._id)})}),n&&n.length>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`oc-notif__head oc-notif__head--sub`,children:Am()}),(0,J.jsx)(`div`,{className:`oc-notif__list`,children:n.map(e=>(0,J.jsx)(Ece,{it:e,onClose:t=>s({feedbackId:e._id,reason:t}),onNavigate:()=>u(!1)},e._id))})]}):null]})]})}function Ece({it:e,onClose:t,onNavigate:n}){let r=Iw(),[i,a]=(0,q.useState)(!1),[o,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(``),[d,f]=(0,q.useState)(!1);async function p(){f(!0);try{await t(l.trim()||void 0)}catch(e){r.error(dv(),e)}finally{f(!1)}}return(0,J.jsxs)(`div`,{className:`oc-notif__item`,children:[(0,J.jsxs)(`div`,{className:`oc-notif__item-head`,children:[(0,J.jsx)(`span`,{className:`oc-notif__title`,children:F9(e.category)}),(0,J.jsx)(`span`,{className:`oc-notif__status${e.answered||e.resolvedAt?` is-answered`:``}`,children:e.resolvedAt?Ree():e.answered?s():xs()})]}),(0,J.jsx)(`div`,{className:`oc-notif__when`,children:new Date(e.at).toLocaleString(ut())}),e.thread.length>0?(0,J.jsx)(`div`,{className:`oc-notif__thread`,children:e.thread.map((e,t)=>(0,J.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,J.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?Od():e.authorRole===`agent`?rh():ku()}),(0,J.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):null,e.messageText?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-notif__report-toggle`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[i?(0,J.jsx)(QS,{size:13,"aria-hidden":!0}):(0,J.jsx)(eC,{size:13,"aria-hidden":!0}),Xr()]}),i?(0,J.jsx)(`div`,{className:`oc-notif__report-msg`,children:e.messageText}):null]}):null,(0,J.jsxs)(`div`,{className:`oc-notif__report-actions`,children:[(0,J.jsx)(Mk,{to:`/chat/$chatId`,params:{chatId:e.chatId},search:{m:e.messageId},className:`oc-notif__link`,onClick:n,children:td()}),o?null:(0,J.jsx)(`button`,{type:`button`,className:`oc-notif__link oc-notif__link--muted`,onClick:()=>c(!0),children:dv()})]}),o?(0,J.jsxs)(`div`,{className:`oc-notif__close-form`,children:[(0,J.jsx)(`textarea`,{className:`oc-notif__close-input`,rows:2,value:l,onChange:e=>u(e.target.value),placeholder:Ci()}),(0,J.jsxs)(`div`,{className:`oc-notif__close-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-notif__close-confirm`,disabled:d,onClick:()=>void p(),children:En()}),(0,J.jsx)(`button`,{type:`button`,className:`oc-notif__close-cancel`,onClick:()=>{c(!1),u(``)},children:au()})]})]}):null]})}var z9=2,Dce=180;function Oce(){let e=Kx(),t=(0,q.useRef)(null),n=(0,q.useRef)(null),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(0),d=(0,q.useMemo)(()=>Ow(Pw,Dw()),[]);(0,q.useEffect)(()=>{let e=setTimeout(()=>c(a),Dce);return()=>clearTimeout(e)},[a]);let f=s.trim(),p=H(G.search.searchConversations,f.length>=z9?{query:f}:`skip`),m=p??[],h=f.length>=z9&&p===void 0;(0,q.useEffect)(()=>{let e=e=>{Aw(e,Pw)&&(e.preventDefault(),i(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,q.useEffect)(()=>{r&&(o(``),c(``),u(0))},[r]),(0,q.useEffect)(()=>{u(0)},[p]),(0,q.useEffect)(()=>{(n.current?.querySelector(`[data-index="${l}"]`))?.scrollIntoView({block:`nearest`})},[l]);let g=(0,q.useCallback)((t,n)=>{i(!1),n&&a.trim()&&Qx(n,a.trim()),e({to:`/chat/$chatId`,params:{chatId:t},...n?{search:{m:n}}:{}})},[e,a]);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-search-trigger`,onClick:()=>i(!0),"aria-label":fee(),children:[(0,J.jsx)(vC,{className:`oc-search-trigger__icon`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-search-trigger__label`,children:ko()}),(0,J.jsx)(`kbd`,{className:`oc-search-trigger__kbd`,children:d})]}),(0,J.jsx)(rT,{open:r,onOpenChange:i,children:(0,J.jsxs)(eT,{showCloseButton:!1,className:`oc-search-palette translate-y-0 max-w-xl gap-0 overflow-hidden p-0`,onOpenAutoFocus:e=>{e.preventDefault(),t.current?.focus()},children:[(0,J.jsx)(tT,{className:`sr-only`,children:dt()}),(0,J.jsxs)(`div`,{className:`oc-search-palette__head`,children:[(0,J.jsx)(vC,{className:`oc-search-palette__head-icon`,"aria-hidden":!0}),(0,J.jsx)(`input`,{ref:t,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),u(e=>Math.min(e+1,m.length-1));else if(e.key===`ArrowUp`)e.preventDefault(),u(e=>Math.max(e-1,0));else if(e.key===`Enter`){e.preventDefault();let t=m[l];t&&g(t.chatId,t.messageId)}},placeholder:Ft(),className:`oc-search-palette__field`,autoComplete:`off`,spellCheck:!1,"aria-label":Kc()})]}),(0,J.jsx)(`div`,{className:`oc-search-palette__results`,ref:n,role:`listbox`,children:f.length<z9?(0,J.jsx)(`div`,{className:`oc-search-palette__hint`,children:Jb({count:z9})}):h?(0,J.jsx)(`div`,{className:`oc-search-palette__hint`,children:He()}):m.length===0?(0,J.jsx)(`div`,{className:`oc-search-palette__hint`,children:Sc({term:f})}):m.map((e,t)=>(0,J.jsxs)(`button`,{type:`button`,"data-index":t,role:`option`,"aria-selected":t===l,className:y_(`oc-search-result`,t===l&&`is-active`),onMouseMove:()=>u(t),onClick:()=>g(e.chatId,e.messageId),children:[(0,J.jsx)(`span`,{className:`oc-search-result__icon`,"aria-hidden":!0,children:e.matchedIn===`title`?(0,J.jsx)(NA,{size:15}):(0,J.jsx)(nS,{size:15})}),(0,J.jsxs)(`span`,{className:`oc-search-result__body`,children:[(0,J.jsx)(`span`,{className:`oc-search-result__title`,children:e.title||yte()}),e.projectPath&&e.projectPath.length>0?(0,J.jsx)(`span`,{className:`oc-search-result__path`,"aria-label":Iu(),children:e.projectPath.join(` › `)}):null,e.snippet?(0,J.jsx)(`span`,{className:`oc-search-result__snippet`,children:e.snippet}):null]}),(0,J.jsx)(`span`,{className:`oc-search-result__tag`,children:e.matchedIn===`title`?Zf():Vte()})]},e.chatId))}),(0,J.jsxs)(`div`,{className:`oc-search-palette__footer`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`kbd`,{children:`↑`}),(0,J.jsx)(`kbd`,{children:`↓`}),` `,Tb()]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`kbd`,{children:`↵`}),` `,rf()]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`kbd`,{children:Km()}),` `,gh()]})]})]})})]})}var B9=[{id:`personal`,label:()=>ua(),tabs:[`preferences`,`theme`,`files`,`scheduled`,`deletedChats`]},{id:`agents`,label:()=>Ir(),tabs:[`instances`,`agentFiles`,`chatDefaults`,`voice`,`bridge`,`injections`]},{id:`access`,label:()=>fn(),tabs:[`users`,`groups`,`access`,`roles`,`serviceAccounts`,`trash`]},{id:`observability`,label:()=>ss(),tabs:[`traces`,`kpi`,`anomalies`,`audit`,`feedbacks`,`subagentReports`,`integrations`]}],kce=new Map(B9.flatMap(e=>e.tabs.map(t=>[t,e.id])));function V9(e){let t=kce.get(e);if(!t)throw Error(`Settings tab "${e}" belongs to no group`);return t}function Ace(e,t){return e.find(e=>V9(e)===t)}B9.flatMap(e=>[...e.tabs]);function jce(){let e=H(G.bridgeHealth.getBridgeAvailability,{});if(e===void 0)return null;let t=e.gatewaysUnreachable??0,n=e.known?e.available?t>0?`warn`:`ok`:`error`:`idle`,r=e.known?e.available?t>0?Cm({count:t}):`${Xs()}${e.checkedAt?ra({time:Jw(e.checkedAt)}):``}`:kr({reason:e.reason??`?`}):dx();return(0,J.jsx)(ew,{delayDuration:150,children:(0,J.jsxs)(nw,{children:[(0,J.jsx)(ZC,{asChild:!0,children:(0,J.jsx)(`span`,{className:`oc-bridge-dot oc-bridge-dot--${n}`,role:`img`,"aria-label":r})}),(0,J.jsx)(QC,{children:r})]})})}function H9(e){let t=new Set(LT),n=new Set,r=[];for(let i of e??[])t.has(i)&&!n.has(i)&&(r.push(i),n.add(i));for(let e of LT)n.has(e)||r.push(e);return r}function Mce(e,t){let n=new Set(t),r=[...t];return e.map(e=>n.has(e)?r.shift():e)}function Nce({tab:e,active:t}){let n=Tne[e](),r=`oc-settings-tabs__tab`+(t?` is-active`:``),i=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`oc-settings-tabs__label`,children:n}),e===`bridge`?(0,J.jsx)(jce,{}):null]});return zT.includes(e)?(0,J.jsx)(Mk,{to:`/settings/$tab`,params:{tab:e},className:r,role:`tab`,"aria-selected":t,children:i}):(0,J.jsx)(Mk,{to:`/settings/${e}`,className:r,role:`tab`,"aria-selected":t,children:i})}function Pce({tab:e,active:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=bS({id:e});return(0,J.jsxs)(`div`,{ref:i,style:{transform:$x.Transform.toString(a),transition:o,opacity:s?.5:1},className:`oc-settings-tabs__item oc-reveal-host`,role:`presentation`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-settings-tabs__grip oc-reveal`,"aria-label":ql(),...n,...r,children:(0,J.jsx)(MA,{size:14,"aria-hidden":!0})}),(0,J.jsx)(Nce,{tab:e,active:t})]})}function Fce(){let e=H(G.me.getMe,{host:hT}),t=U(G.me.setSettingsTabOrder),n=IT(rA({select:e=>e.pathname})),r=n===void 0?void 0:V9(n),i=(0,q.useMemo)(()=>H9(e?.settingsTabOrder??null),[e?.settingsTabOrder]),[a,o]=(0,q.useState)(i);(0,q.useEffect)(()=>o(i),[i]);let s=(0,q.useMemo)(()=>new Set(RT(e?.permissions??[])),[e?.permissions]),c=(0,q.useMemo)(()=>r===void 0?[]:a.filter(e=>s.has(e)&&V9(e)===r),[a,s,r]),l=fS(PS(NS,{activationConstraint:{distance:5}}),PS(xS,{coordinateGetter:yS})),u=(0,q.useRef)(null);if((0,q.useLayoutEffect)(()=>{let e=u.current;if(!e)return;let t=()=>Sw(e,e.querySelector(`[role="tab"][aria-selected="true"]`));t();let n=new ResizeObserver(t);n.observe(e);for(let t of Array.from(e.children))n.observe(t);let r=t=>yw(e,t.target,`[role="tab"]`);return e.addEventListener(`focusin`,r),()=>{n.disconnect(),e.removeEventListener(`focusin`,r)}},[n,c.length]),r===void 0||c.length===0)return null;let d=B9.find(e=>e.id===r);function f(e){let{active:n,over:r}=e;if(!r||n.id===r.id)return;let i=c.indexOf(n.id),s=c.indexOf(r.id);if(i<0||s<0)return;let l=Mce(a,vS(c,i,s));o(l),t({order:l})}return(0,J.jsx)(`div`,{ref:u,className:`oc-settings-tabs`,role:`tablist`,"aria-label":d?.label(),children:(0,J.jsx)(TS,{sensors:l,collisionDetection:_S,modifiers:[tce],onDragEnd:f,children:(0,J.jsx)(jS,{items:c,strategy:wS,children:c.map(e=>(0,J.jsx)(Pce,{tab:e,active:e===n},e))})})})}function Ice(){let e=H(G.me.getMe,{host:hT}),t=Kx(),n=IT(rA({select:e=>e.pathname})),r=n===void 0?void 0:V9(n),i=(0,q.useMemo)(()=>new Set(RT(e?.permissions??[])),[e?.permissions]),a=(0,q.useMemo)(()=>H9(e?.settingsTabOrder??null).filter(e=>i.has(e)),[e?.settingsTabOrder,i]),o=B9.filter(e=>e.tabs.some(e=>i.has(e)));function s(e){let n=Ace(a,e.id);n&&t({to:VT(n)})}return(0,J.jsxs)(`nav`,{className:`oc-settings-nav`,"aria-label":Te(),children:[(0,J.jsx)(Mk,{to:`/`,className:`oc-settings-nav__back`,children:vx()}),(0,J.jsx)(`div`,{className:`oc-settings-nav__title`,children:rc()}),(0,J.jsx)(`div`,{className:`oc-settings-nav__list`,children:o.map(e=>(0,J.jsx)(`button`,{type:`button`,className:`oc-settings-nav__group`+(e.id===r?` is-active`:``),"aria-current":e.id===r?`true`:void 0,onClick:()=>s(e),children:e.label()},e.id))})]})}var Lce=`trash`,Rce=`deletedChats`;function zce(){throw jD({to:`/settings/$tab`,params:{tab:Rce},replace:!0})}var U9=`oc.theme`;function W9(e){let t=e===`dark`||e===`system`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;document.documentElement.classList.toggle(`dark`,t)}function G9(e){(0,q.useEffect)(()=>{let t=e??localStorage.getItem(U9)??`system`;if(localStorage.setItem(U9,t),W9(t),t===`system`){let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>W9(`system`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}},[e])}function Bce(e){(0,q.useEffect)(()=>{if(!e)return;document.documentElement.lang=e;let t;try{t=ut()}catch{t=void 0}t!==e&&Oo(e)},[e])}var Vce=(0,q.lazy)(()=>qw(()=>import(`./RolesTab-DWAYA0bo.js`).then(e=>({default:e.RolesTab})),__vite__mapDeps([2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))),Hce=(0,q.lazy)(()=>qw(()=>import(`./InstancesTab-ylJayyDG.js`).then(e=>({default:e.InstancesTab})),__vite__mapDeps([23,3,4,24,25,26,7,27,28,8,29,9,30,31,32,6,10,11,12,13,14,15,19,18,16,17,20,21,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57]))),Uce=(0,q.lazy)(()=>qw(()=>import(`./PromptInjectionsTab-Dj53oYJM.js`).then(e=>({default:e.PromptInjectionsTab})),__vite__mapDeps([58,3,4,24,25,26,7,27,28,8,29,9,30,31,32,6,10,13,14,51,59,60]))),Wce=(0,q.lazy)(()=>qw(()=>import(`./GroupsTab-Bza-axVm.js`).then(e=>({default:e.GroupsTab})),__vite__mapDeps([61,3,4,62,45,6,7,8,9,47,63,64,14,26,27,28,29,49,37,10,11,12,13,15,19,18,51,16,17,20,21,33,52,53,54,55,30,50,34,35,36,38,39,40,41,42,65]))),Gce=(0,q.lazy)(()=>qw(()=>import(`./IntegrationsTab-SlsD4tnS.js`).then(e=>({default:e.IntegrationsTab})),__vite__mapDeps([66,3,4,6,7,8,9,26,27,28,29,10,11,12,15]))),Kce=(0,q.lazy)(()=>qw(()=>import(`./FeedbacksTab-Xzcf0-m6.js`).then(e=>({default:e.FeedbacksTab})),__vite__mapDeps([67,3,4,10,12,50,16,17,18,11,19,14,34,27,28,35,36,29,9,37,30,6,7,8,38,39,40,41,42]))),qce=(0,q.lazy)(()=>qw(()=>import(`./SubAgentReportsTab-CkY5rTJw.js`).then(e=>({default:e.SubAgentReportsTab})),__vite__mapDeps([68,3,4,10,12,50,16,17,18,11,19,14,34,27,28,35,36,29,9,37,30,6,7,8,38,39,40,41,42]))),Jce=(0,q.lazy)(()=>qw(()=>import(`./TrashTab-DLVzwkoC.js`).then(e=>({default:e.TrashTab})),__vite__mapDeps([69,3,4,70,39,10,12,13,14,50,16,17,18,11,19,71,72,73,54,74]))),Yce=(0,q.lazy)(()=>qw(()=>import(`./DeletedChatsTab-CJeOOn67.js`).then(e=>({default:e.DeletedChatsTab})),__vite__mapDeps([75,3,4,70,10,12,16,17,18,11,19,14,72,73,54,39,50,74]))),Xce=(0,q.lazy)(()=>qw(()=>import(`./FilesTab-CAQXH5ub.js`).then(e=>({default:e.FilesTab})),__vite__mapDeps([76,3,4,36,27,29,9,37,30,77,6,7,8,54,39,26,28,17,18,10,12,13,14,15,40]))),Zce=(0,q.lazy)(()=>qw(()=>import(`./ScheduledTab-CgXOwbXe.js`).then(e=>({default:e.ScheduledTab})),__vite__mapDeps([78,3,4,62,45,79,21,80,81,54,39,26,7,27,28,8,29,9,17,18,10,30,11,12,13,14,15,19,51,42,40,52,53,55,50,41,82,35,60]))),Qce=(0,q.lazy)(()=>qw(()=>import(`./AgentFilesTab-Can04JU-.js`).then(e=>({default:e.AgentFilesTab})),__vite__mapDeps([83,3,4,48,26,7,27,28,8,29,9,17,18,10,12,13,14,15,19,51,84,42,32,56,60]))),$ce=(0,q.lazy)(()=>qw(()=>import(`./PreferencesTab-DVGrydjd.js`).then(e=>({default:e.PreferencesTab})),__vite__mapDeps([85,3,4,6,7,8,9,26,27,28,29,10,11,12,86,51,13,14,15,59,31,87,82,35,30,60]))),ele=(0,q.lazy)(()=>qw(()=>import(`./ChatDefaultsTab-BUW8zL7h.js`).then(e=>({default:e.ChatDefaultsTab})),__vite__mapDeps([88,3,4,70,21,6,7,8,9,38,48,26,27,28,29,30,10,11,12,89,54,84,56,87,60]))),tle=(0,q.lazy)(()=>qw(()=>import(`./AccessTab-BEJ_Jyn5.js`).then(e=>({default:e.AccessTab})),__vite__mapDeps([90,3,4,26,7,27,28,8,29,9,12,15]))),nle=(0,q.lazy)(()=>qw(()=>import(`./ThemeShowroom-CP-Ano4O.js`).then(e=>({default:e.ThemeShowroom})),__vite__mapDeps([91,3,4,7,36,27,29,9,37,30,77,6,8,92,14,26,28,10,11,12,15,51,59,31,93,40,55,53,50,52,54,94,38])));function rle(){let{isAuthenticated:e}=$T();return(0,q.useEffect)(()=>{e&&j9().authenticated()},[e]),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(aE,{children:(0,J.jsx)(`div`,{className:`oc-boot`,children:Vv()})}),(0,J.jsx)(iE,{children:(0,J.jsx)(ale,{})}),(0,J.jsx)(rE,{children:(0,J.jsx)(Lw,{children:(0,J.jsx)(Qse,{children:(0,J.jsx)(sle,{})})})})]})}function ile(){return(0,J.jsxs)(`svg`,{className:`oc-provider__logo`,viewBox:`0 0 48 48`,"aria-hidden":`true`,children:[(0,J.jsx)(`path`,{fill:`#EA4335`,d:`M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z`}),(0,J.jsx)(`path`,{fill:`#4285F4`,d:`M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z`}),(0,J.jsx)(`path`,{fill:`#FBBC05`,d:`M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z`}),(0,J.jsx)(`path`,{fill:`#34A853`,d:`M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z`})]})}function ale(){let{signIn:e}=jE();G9(void 0),jw(void 0);let t=H(G.charts.brandForHost,{host:hT}),n=pT(hT),r=t??n??null,i=qC(void 0);JC(r?.tokens??null,i),(0,q.useEffect)(()=>{t&&mT(hT,t)},[t]);let a=r?.brand,o=a&&!a.isDefault?e4(a,i):null,s=a?.label??`Atrium`,c=H(G.me.authProviders),[l,u]=(0,q.useState)(null);async function f(t){u(null);try{await e(t)}catch{u(Jee())}}let p=c!==void 0&&!c.google&&!c.microsoft&&!c.authelia&&!c.anonymous;return(0,J.jsx)(gce,{providers:c,children:(0,J.jsxs)(`div`,{className:`oc-signin`,children:[(0,J.jsxs)(`svg`,{className:`oc-signin__motif`,viewBox:`0 0 1200 1000`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:[(0,J.jsx)(`polyline`,{className:`oc-signin__line`,points:`0,860 470,860 522,790 574,940 626,810 678,860 1200,860`,vectorEffect:`non-scaling-stroke`}),(0,J.jsx)(`polyline`,{className:`oc-signin__pulse`,points:`0,860 470,860 522,790 574,940 626,810 678,860 1200,860`,pathLength:`100`,vectorEffect:`non-scaling-stroke`})]}),(0,J.jsxs)(`div`,{className:`oc-signin__brand`,children:[o?(0,J.jsx)(`img`,{className:`oc-signin__brandlogo`,src:o,alt:``}):null,(0,J.jsx)(`span`,{className:`oc-signin__wordmark`,children:s})]}),(0,J.jsxs)(`div`,{className:`oc-signin__card`,children:[(0,J.jsx)(`h1`,{className:`oc-signin__title`,children:jy()}),(0,J.jsx)(`p`,{className:`oc-signin__subtitle`,children:pm()}),(0,J.jsxs)(`div`,{className:`oc-signin__providers`,children:[c?.google?(0,J.jsxs)(`button`,{type:`button`,className:`oc-provider oc-provider--google`,onClick:()=>void f(`google`),children:[(0,J.jsx)(ile,{}),(0,J.jsx)(`span`,{children:d()})]}):null,c?.microsoft?(0,J.jsx)(`button`,{type:`button`,className:`oc-provider oc-provider--microsoft`,onClick:()=>void f(`microsoft-entra-id`),children:(0,J.jsx)(`span`,{children:ei()})}):null,c?.authelia?(0,J.jsx)(`button`,{type:`button`,className:`oc-provider oc-provider--authelia`,onClick:()=>void f(`authelia`),children:(0,J.jsx)(`span`,{children:ws()})}):null]}),l?(0,J.jsx)(`p`,{className:`oc-signin__error`,children:l}):null,p?(0,J.jsx)(`p`,{className:`oc-signin__error`,children:hv()}):null,c?.anonymous?(0,J.jsx)(`button`,{type:`button`,className:`oc-signin__dev`,onClick:()=>void e(`anonymous`),children:Oi()}):null]})]})})}function ole(){let{width:e,collapsed:t,isMobile:n}=rJ();return(0,J.jsx)(`div`,{className:`oc-shell`,children:(0,J.jsxs)(`div`,{className:`oc-shell__body`,children:[(0,J.jsxs)(`header`,{className:`oc-topbar`,children:[(0,J.jsxs)(`div`,{className:`oc-topbar__left`,children:[(0,J.jsx)(`div`,{className:`oc-skel`,style:{width:`1.75rem`,height:`1.75rem`}}),(0,J.jsx)(`div`,{className:`oc-skel`,style:{width:`5.5rem`,height:`1.1rem`}})]}),(0,J.jsx)(`div`,{className:`oc-topbar__search`,children:(0,J.jsx)(`div`,{className:`oc-skel`,style:{width:`100%`,height:`2.25rem`}})}),(0,J.jsx)(`div`,{className:`oc-topbar__actions`,children:(0,J.jsx)(`div`,{className:`oc-skel`,style:{width:`1.75rem`,height:`1.75rem`,borderRadius:`999px`}})})]}),(0,J.jsxs)(`div`,{className:n?`oc-workspace oc-workspace--mobile`:`oc-workspace`,children:[!t&&!n?(0,J.jsx)(`div`,{className:`oc-sidebar-col`,style:{width:e,flex:`0 0 ${e}px`},children:(0,J.jsxs)(`aside`,{className:`oc-sidebar`,children:[(0,J.jsx)(`div`,{className:`oc-skel`,style:{height:`2.25rem`,margin:`0.25rem 0.25rem 0`}}),(0,J.jsx)(y9,{})]})}):null,(0,J.jsx)(`main`,{className:`oc-main`})]})]})})}function sle(){let e=H(G.me.getMe,{host:hT}),t=U(G.me.bootstrap),n=Kx();(0,q.useEffect)(()=>{e&&!e.hasProfile&&t()},[e,t]),G9(e?.resolvedThemeMode),jw(e?.resolvedFontScale);let r=qC(e?.resolvedThemeMode);JC(e?.resolvedChartTokens,r),Bce(e?.resolvedLocale);let i=(0,q.useRef)(null);if((0,q.useEffect)(()=>{e&&(i.current!==null&&i.current!==e.userId&&n({to:`/`}),i.current=e.userId)},[e,n]),e===void 0)return(0,J.jsx)(ole,{});let a=e.name||e.email||An();return e.role===`pending`?(0,J.jsxs)(`div`,{className:`oc-shell`,children:[(0,J.jsx)(K9,{}),(0,J.jsx)(O9,{}),(0,J.jsx)(cle,{userLabel:a,themeMode:e.themeMode,resolvedThemeMode:e.resolvedThemeMode,brand:e.resolvedChartBrand}),(0,J.jsxs)(`div`,{className:`oc-pending`,children:[(0,J.jsx)(`h1`,{className:`oc-pending__title`,children:lu()}),(0,J.jsx)(`p`,{className:`oc-pending__body`,children:ml()})]})]}):(0,J.jsx)(dle,{canOpenSettings:RT(e.permissions??[]).length>0,viewerUserId:e.userId,userLabel:a,themeMode:e.themeMode,resolvedThemeMode:e.resolvedThemeMode,brand:e.resolvedChartBrand},e.userId)}function K9(){let e=H(G.me.getImpersonation),t=U(G.admin.stopImpersonation);return!e||!e.impersonating?null:(0,J.jsxs)(`div`,{className:`oc-imp`,role:`alert`,children:[(0,J.jsx)(SC,{className:`size-4 shrink-0`}),(0,J.jsxs)(`span`,{className:`oc-imp__text`,children:[tr(),` `,(0,J.jsx)(`strong`,{children:e.targetLabel}),zl(),(0,J.jsx)(`strong`,{children:e.realLabel}),ge()]}),(0,J.jsx)(K,{size:`sm`,variant:`outline`,className:`oc-imp__exit`,onClick:()=>void t(),children:nne()})]})}function q9(e){return e?.label??`Atrium`}function J9({brand:e,resolvedThemeMode:t}){let n=qC(t),r=q9(e),i=e?.isDefault??!0,a=e4(e,n),[o,s]=(0,q.useState)(!1);return(0,q.useEffect)(()=>s(!1),[a]),(0,J.jsxs)(J.Fragment,{children:[a!==null&&!o?(0,J.jsx)(`img`,{className:`oc-brand__logo`,src:a,alt:``,"aria-hidden":`true`,onError:()=>s(!0)}):i?(0,J.jsx)(i4,{className:`oc-brand__logo`}):null,(0,J.jsx)(`span`,{className:`oc-brand__label`,children:r})]})}function cle({userLabel:e,themeMode:t,resolvedThemeMode:n,brand:r}){let i=(0,q.useRef)(null),a=N9[NT(()=>{let e=i.current;if(e===null||!(e.clientWidth>0))return null;let t=PT(e,N9.slice(0,-1).map(e=>t=>t.setAttribute(`data-fit`,e)),`oc-topbar--measure`);return{available:e.clientWidth,required:t}},()=>[i.current],[])];return(0,J.jsxs)(`header`,{ref:i,className:`oc-topbar`,"data-fit":a,children:[(0,J.jsx)(`span`,{className:`oc-topbar__brand`,children:(0,J.jsx)(J9,{brand:r,resolvedThemeMode:n})}),(0,J.jsx)(`div`,{className:`oc-topbar__actions`,children:(0,J.jsx)(M9,{label:e,mode:t,minimal:!0})})]})}function lle({brand:e,resolvedThemeMode:t}){let n=(0,q.useRef)(null),r=P9[NT(()=>{let e=n.current;if(e===null||!(e.clientWidth>0))return null;let t=PT(e,P9.slice(0,-1).map(e=>t=>t.setAttribute(`data-fit`,e)),`oc-drawer__head--measure`);return{available:e.clientWidth,required:t}},()=>[n.current],[])];return(0,J.jsxs)(`div`,{ref:n,className:`oc-drawer__head`,"data-fit":r,children:[(0,J.jsx)(bT,{className:`sr-only`,children:Qo()}),(0,J.jsx)(Mk,{to:`/`,className:`oc-topbar__brand`,"aria-label":q9(e),children:(0,J.jsx)(J9,{brand:e,resolvedThemeMode:t})}),(0,J.jsx)(dne,{asChild:!0,children:(0,J.jsx)(K,{variant:`ghost`,size:`icon`,"aria-label":co(),children:(0,J.jsx)(YC,{})})})]})}function ule({userLabel:e,themeMode:t,resolvedThemeMode:n,brand:r,sidebarOpen:i,onToggleSidebar:a,toggleRef:o,rail:s}){let c=(0,q.useRef)(null),l=N9[NT(()=>{let e=c.current;if(s||e===null||!(e.clientWidth>0))return null;let t=PT(e,N9.slice(0,-1).map(e=>t=>t.setAttribute(`data-fit`,e)),`oc-topbar--measure`);return{available:e.clientWidth,required:t}},()=>[c.current],[s])];return(0,J.jsxs)(`header`,{ref:c,className:s?`oc-topbar oc-topbar--rail`:`oc-topbar`,"data-fit":s?void 0:l,children:[(0,J.jsxs)(`div`,{className:`oc-topbar__left`,children:[(0,J.jsx)(K,{ref:o,variant:`ghost`,size:`icon-sm`,"aria-label":i?ea():qs(),onClick:a,children:i?(0,J.jsx)(mS,{}):(0,J.jsx)(nj,{})}),(0,J.jsx)(Mk,{to:`/`,className:`oc-topbar__brand`,"aria-label":q9(r),children:(0,J.jsx)(J9,{brand:r,resolvedThemeMode:n})})]}),(0,J.jsx)(`div`,{className:`oc-topbar__search`,children:(0,J.jsx)(Oce,{})}),(0,J.jsxs)(`div`,{className:`oc-topbar__actions`,children:[(0,J.jsx)(Tce,{}),(0,J.jsx)(M9,{label:e,mode:t,compact:s})]})]})}function dle({canOpenSettings:e,viewerUserId:t,userLabel:n,themeMode:r,resolvedThemeMode:i,brand:a}){let{width:o,columnRef:s,collapsed:c,startResize:l,isMobile:u,drawerOpen:d,setDrawerOpen:f,toggleSidebar:p,closeDrawer:m}=rJ(),h=$q(),g=(0,q.useRef)(null),_=Zk(),v=iS({strict:!1}),y=Kx(),b=!!_({to:`/settings`,fuzzy:!0});(0,q.useEffect)(()=>{m()},[rA({select:e=>e.pathname}),m]);let x=(0,q.useCallback)(e=>{y({to:`/chat/$chatId`,params:{chatId:e}})},[y]),{startNewChat:S,picker:C}=MS(x),w=(0,q.useMemo)(()=>Ow(Mw,Dw()),[]);(0,q.useEffect)(()=>{let e=e=>{Aw(e,Mw)&&(e.preventDefault(),S())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S]);let T=b?(0,J.jsx)(Ice,{}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(sce,{activeChatId:v.chatId??null,onSelect:x,onNewChat:()=>void S(),newChatShortcut:w}),(0,J.jsx)(K,{variant:`ghost`,className:`oc-sidebar__shortcut mx-2 justify-start`,asChild:!0,children:(0,J.jsxs)(Mk,{to:`/settings/$tab`,params:{tab:`scheduled`},children:[(0,J.jsx)(fA,{"aria-hidden":!0}),Bo()]})}),(0,J.jsx)(K,{variant:`ghost`,className:`oc-sidebar__shortcut mx-2 justify-start`,asChild:!0,children:(0,J.jsxs)(Mk,{to:`/settings/$tab`,params:{tab:`files`},children:[(0,J.jsx)(VA,{"aria-hidden":!0}),Lg()]})}),e?(0,J.jsx)(K,{variant:`ghost`,className:`oc-sidebar__shortcut mx-2 mb-2 justify-start`,asChild:!0,children:(0,J.jsxs)(Mk,{to:`/settings`,children:[(0,J.jsx)(uj,{"aria-hidden":!0}),Er()]})}):null]});return(0,J.jsxs)(`div`,{className:h?`oc-shell oc-shell--short`:`oc-shell`,children:[C,(0,J.jsx)(pce,{activeChatId:v.chatId??null}),(0,J.jsx)(K9,{}),(0,J.jsx)(O9,{}),(0,J.jsxs)(`div`,{className:`oc-shell__body`,children:[(0,J.jsx)(ule,{userLabel:n,themeMode:r,resolvedThemeMode:i,brand:a,sidebarOpen:u?d:!c,onToggleSidebar:p,toggleRef:g,rail:h}),(0,J.jsxs)(`div`,{className:u?`oc-workspace oc-workspace--mobile`:`oc-workspace`,children:[u?(0,J.jsx)(ST,{open:d,onOpenChange:f,children:(0,J.jsxs)(xT,{side:`left`,className:h?`oc-drawer oc-drawer--short`:`oc-drawer`,overlayClassName:`oc-drawer-overlay`,showCloseButton:!1,"aria-describedby":void 0,returnFocus:()=>[g.current],children:[(0,J.jsx)(lle,{brand:a,resolvedThemeMode:i}),(0,J.jsx)(`div`,{className:`oc-sidebar-col oc-sidebar-col--drawer`,children:T})]})}):c?null:(0,J.jsxs)(`div`,{className:`oc-sidebar-col`,ref:e=>{s.current=e},style:{width:o,flex:`0 0 ${o}px`},children:[T,(0,J.jsx)(`div`,{className:`oc-sidebar-resizer`,onPointerDown:l,role:`separator`,"aria-orientation":`vertical`,"aria-label":nn()})]}),(0,J.jsx)(`main`,{className:`oc-main`,children:(0,J.jsx)(qk,{})}),(0,J.jsx)(B1,{viewerUserId:t,currentChatId:v.chatId??null})]})]}),(0,J.jsx)(aq,{})]})}function fle(){let e=H(G.me.getMe,{host:hT}),t=Kx(),n=rA({select:e=>e.pathname}),r=(0,q.useMemo)(()=>e?RT(e.permissions??[]):[],[e]),i=e!==void 0&&r.length===0;if((0,q.useEffect)(()=>{i&&t({to:`/`})},[i,t]),e===void 0)return(0,J.jsx)(`div`,{className:`oc-admin__hint`,style:{padding:16},children:Vv()});if(i)return null;let a=IT(n),o=a!==void 0&&!r.includes(a);return(0,J.jsxs)(`div`,{className:`oc-admin`,children:[(0,J.jsx)(Fce,{}),(0,J.jsx)(`div`,{className:`oc-admin__body`,children:o?(0,J.jsx)(ple,{}):(0,J.jsx)(qk,{})})]})}function ple(){return(0,J.jsxs)(`div`,{className:`oc-route-error`,role:`alert`,children:[(0,J.jsx)(`div`,{className:`oc-route-error__icon`,"aria-hidden":!0,children:(0,J.jsx)(GC,{size:28})}),(0,J.jsx)(`h2`,{className:`oc-route-error__title`,children:Qa()}),(0,J.jsx)(`p`,{className:`oc-route-error__body`,children:Oa()})]})}function mle(){let e=H(G.me.getMe,{host:hT}),t=Kx();return(0,q.useEffect)(()=>{if(e===void 0)return;let n=RT(e.permissions??[]),r=n.includes(`files`)?VT(`files`):n.length>0?VT(n[0]):`/`;t({to:r,replace:!0})},[e,t]),(0,J.jsx)(`div`,{className:`oc-admin__hint`,style:{padding:16},children:Vv()})}function hle(e){switch(e){case`groups`:return(0,J.jsx)(Wce,{});case`integrations`:return(0,J.jsx)(Gce,{});case`instances`:return(0,J.jsx)(Hce,{});case`injections`:return(0,J.jsx)(Uce,{});case`theme`:return(0,J.jsx)(nle,{});case`feedbacks`:return(0,J.jsx)(Kce,{});case`subagentReports`:return(0,J.jsx)(qce,{});case`files`:return(0,J.jsx)(Xce,{});case`scheduled`:return(0,J.jsx)(Zce,{});case`agentFiles`:return(0,J.jsx)(Qce,{});case`preferences`:return(0,J.jsx)($ce,{});case`chatDefaults`:return(0,J.jsx)(ele,{});case`access`:return(0,J.jsx)(tle,{});case`trash`:return(0,J.jsx)(Jce,{});case`deletedChats`:return(0,J.jsx)(Yce,{});default:return(0,J.jsx)(Vce,{})}}function gle(){let{tab:e}=iS({from:`/settings/$tab`});return(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(`div`,{className:`oc-settings__tab-loading`,"aria-busy":`true`}),children:hle(e)})}function _le(){let{chatId:e}=iS({from:`/chat/$chatId`}),{m:t}=Vx({from:`/chat/$chatId`});return(0,q.useEffect)(()=>{H1(e)},[e]),(0,J.jsx)(P7,{chatId:e,focusMessageId:t??null})}function vle(){let e=Kx(),t=U1(),n=H(G.messages.listChats,{}),r=t!==null&&n!==void 0&&n.some(e=>e._id===t);return(0,q.useEffect)(()=>{r&&t&&e({to:`/chat/$chatId`,params:{chatId:t},replace:!0})},[r,t,e]),t!==null&&(n===void 0||r)?(0,J.jsx)(`div`,{className:`oc-boot`,children:Vv()}):(0,J.jsx)(P7,{chatId:null})}var Y9=Lk({component:rle}),yle=Fk({getParentRoute:()=>Y9,path:`/`,component:vle}),ble=Fk({getParentRoute:()=>Y9,path:`chat/$chatId`,component:_le,validateSearch:e=>({m:typeof e.m==`string`?e.m:void 0})}),xle=Fk({getParentRoute:()=>Y9,path:`project/$projectId`,component:Rk(()=>qw(()=>import(`./ProjectPage-m5wYC2Rt.js`),__vite__mapDeps([95,3,4,44,96,7,47,64,11,12,15,19,14,18,10,97,27,45,36,29,9,37,30,98,79,81,39,13,16,17,20,21,42,72,99])),`ProjectPage`),validateSearch:e=>({c:typeof e.c==`string`?e.c:void 0})}),Sle=Fk({getParentRoute:()=>Y9,path:Lce,beforeLoad:zce}),X9=Fk({getParentRoute:()=>Y9,path:`settings`,component:fle}),Cle=Fk({getParentRoute:()=>X9,path:`/`,component:mle}),wle=Fk({getParentRoute:()=>X9,path:`traces`,validateSearch:oT,component:Rk(()=>qw(()=>import(`./TracesTab--6clA1rh.js`),__vite__mapDeps([100,3,4,44,7,101,98,102,14,26,27,28,8,29,9,49,37,10,12,15,50,19,18,103,51,55,53,30,11,52,54,94,38,34,35,36,6,39,40,41,42])),`TracesTab`)}),Tle=Fk({getParentRoute:()=>X9,path:`bridge`,validateSearch:iT,component:Rk(()=>qw(()=>import(`./BridgeTab-CuyyGEDU.js`),__vite__mapDeps([43,3,4,24,25,26,7,27,28,8,29,9,30,31,32,44,45,35,46,21,6,47,48,49,37,10,11,12,13,14,15,50,19,18,51,40,52,53,54,55,56,57])),`BridgeTab`)}),Ele=Fk({getParentRoute:()=>X9,path:`voice`,validateSearch:uT,component:Rk(()=>qw(()=>import(`./VoiceTab-jKwAy1TX.js`),__vite__mapDeps([104,3,4,44,105,6,7,8,9,26,27,28,29,49,37,10,12,15,51,60])),`VoiceTab`)}),Dle=Fk({getParentRoute:()=>X9,path:`audit`,validateSearch:cT,component:Rk(()=>qw(()=>import(`./AuditTab-Sl2mKF7H.js`),__vite__mapDeps([106,3,4,44,26,7,27,28,8,29,9,12,50,103,55,53,30,10,11,52,54,94,38,14,34,35,36,37,6,39,40,41,42])),`AuditTab`)}),Ole=Fk({getParentRoute:()=>X9,path:`anomalies`,validateSearch:fT,component:Rk(()=>qw(()=>import(`./AnomaliesTab-4RaS1dK-.js`),__vite__mapDeps([107,3,4,44,26,7,27,28,8,29,9,12,13,14,15,50,19,18,10,103,51,16,17,11,55,53,30,52,54,34,35,36,37,6,38,39,40,41,42,57])),`AnomaliesTab`)}),kle=Fk({getParentRoute:()=>X9,path:`kpi`,validateSearch:lT,component:Rk(()=>qw(()=>import(`./KpiTab-66ywB2qQ.js`),__vite__mapDeps([108,3,4,44,12,103,51,93,55,53,30,29,9,10,11,50])),`KpiTab`)}),Ale=Fk({getParentRoute:()=>X9,path:`serviceAccounts`,validateSearch:aT,component:Rk(()=>qw(()=>import(`./ServiceAccountsTab-DDHjiTam.js`),__vite__mapDeps([109,3,4,44,7,27,45,101,26,28,8,29,9,10,11,12,13,14,15,50,19,18,16,17,20,21,52,53,54,55,30,34,35,36,37,6,38,39,40,41,42,22])),`ServiceAccountsTab`)}),jle=Fk({getParentRoute:()=>X9,path:`users`,validateSearch:dT,component:Rk(()=>qw(()=>import(`./UsersTab-CZ7JvSwK.js`),__vite__mapDeps([110,3,4,44,36,27,29,9,37,30,6,7,8,47,64,26,28,10,12,13,14,15,19,18,51,16,17,11,33,111,52,53,54,55,50,34,35,38,39,40,41,42,65])),`UsersTab`)}),Mle=Fk({getParentRoute:()=>X9,path:`uiprefs`,beforeLoad:()=>{throw jD({to:`/settings/$tab`,params:{tab:BT.uiprefs},replace:!0})}}),Nle=Fk({getParentRoute:()=>X9,path:`$tab`,parseParams:e=>({tab:sT([...zT]).catch(`roles`).parse(e.tab)}),component:gle});function Ple({error:e,reset:t}){let n=Kx(),r=W1(e),[i]=(0,q.useState)(()=>r&&J1(Date.now()));return(0,q.useEffect)(()=>{i&&window.location.reload()},[i]),i?(0,J.jsx)(`div`,{className:`oc-route-error`,role:`status`,children:(0,J.jsx)(`p`,{className:`oc-route-error__body`,children:ig()})}):(0,J.jsxs)(`div`,{className:`oc-route-error`,role:`alert`,children:[(0,J.jsx)(`div`,{className:`oc-route-error__icon`,"aria-hidden":!0,children:(0,J.jsx)(GC,{size:28})}),(0,J.jsx)(`h2`,{className:`oc-route-error__title`,children:N()}),(0,J.jsx)(`p`,{className:`oc-route-error__body`,children:Dg()}),(0,J.jsxs)(`div`,{className:`oc-route-error__actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-route-error__cta`,onClick:()=>{r?window.location.reload():t()},children:Do()}),(0,J.jsx)(`button`,{type:`button`,className:`oc-route-error__cta oc-route-error__cta--ghost`,onClick:()=>void n({to:`/`}),children:lt()})]})]})}function Fle(){let e=Kx();return(0,J.jsxs)(`div`,{className:`oc-route-error`,role:`status`,children:[(0,J.jsx)(`div`,{className:`oc-route-error__icon`,"aria-hidden":!0,children:(0,J.jsx)(vA,{size:28})}),(0,J.jsx)(`h2`,{className:`oc-route-error__title`,children:Nt()}),(0,J.jsx)(`p`,{className:`oc-route-error__body`,children:Wc()}),(0,J.jsx)(`div`,{className:`oc-route-error__actions`,children:(0,J.jsx)(`button`,{type:`button`,className:`oc-route-error__cta`,onClick:()=>void e({to:`/`}),children:lt()})})]})}var Z9=$k({routeTree:Y9.addChildren([yle,ble,xle,Sle,X9.addChildren([Cle,wle,Ele,Tle,Dle,Ole,kle,Ale,jle,Mle,Nle])]),defaultPreload:`intent`,defaultErrorComponent:Ple,defaultNotFoundComponent:Fle}),Ile=()=>null;function Q9({children:e}){return(0,J.jsx)(`div`,{style:{display:`flex`,minHeight:`100dvh`,alignItems:`center`,justifyContent:`center`,padding:`2rem`,textAlign:`center`,font:`14px system-ui, sans-serif`,opacity:.6},children:e})}jj(),Iv();var $9=oE.createRoot(document.getElementById(`root`));$9.render((0,J.jsx)(q.StrictMode,{children:(0,J.jsx)(Q9,{children:qb()})})),Q1().then(e=>{M0(document,A0(k0(n0(),window.location.origin,[e0(),t0()])));let t=new og(e);$9.render((0,J.jsx)(q.StrictMode,{children:(0,J.jsx)(ME,{client:t,children:(0,J.jsxs)(vT,{children:[(0,J.jsx)(Pae,{children:(0,J.jsx)(nA,{router:Z9})}),(0,J.jsx)(q.Suspense,{fallback:null,children:(0,J.jsx)(Ile,{router:Z9,position:`bottom-right`})})]})})}))}).catch(e=>{console.error(`Boot failed:`,e),$9.render((0,J.jsx)(q.StrictMode,{children:(0,J.jsxs)(Q9,{children:[fr(),` `,e instanceof Error?e.message:String(e)]})}))});