local-operator-ui 0.42.8 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/out/main/index.js +407 -26
  2. package/out/renderer/assets/{_basePickBy-D4Seo5Pz.js → _basePickBy-7vSIULbq.js} +1 -1
  3. package/out/renderer/assets/{_baseUniq-CgVRhJ9V.js → _baseUniq-DmBlhBeL.js} +1 -1
  4. package/out/renderer/assets/{agent-details-page-DSmJIvXx.js → agent-details-page-BWNrXmxX.js} +1 -1
  5. package/out/renderer/assets/{agent-hub-page-CD_Db8P3.js → agent-hub-page-Cka41wII.js} +1 -1
  6. package/out/renderer/assets/{agents-page-CUktXXX5.js → agents-page-B10LHSJd.js} +3 -3
  7. package/out/renderer/assets/{arc-Ctuni3QD.js → arc-BjzgxcQZ.js} +1 -1
  8. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-CJgH5UIr.js → architectureDiagram-IEHRJDOE-BKVGSQ6O.js} +1 -1
  9. package/out/renderer/assets/{blockDiagram-JOT3LUYC-DPrJH4Ov.js → blockDiagram-JOT3LUYC-BgWUL_kv.js} +1 -1
  10. package/out/renderer/assets/{browser-page-B4X8tPFL.js → browser-page-aNCnBYZQ.js} +1 -1
  11. package/out/renderer/assets/{browser-webauthn-prompt-CKXKeFSp.js → browser-webauthn-prompt-CHrTpdBn.js} +1 -1
  12. package/out/renderer/assets/{c4Diagram-VJAJSXHY-CXM6-guv.js → c4Diagram-VJAJSXHY-Bs2CxbjU.js} +1 -1
  13. package/out/renderer/assets/channel-lXs-3cKl.js +1 -0
  14. package/out/renderer/assets/{chunk-4BMEZGHF-D1rW0otO.js → chunk-4BMEZGHF-C3ePtL7v.js} +1 -1
  15. package/out/renderer/assets/{chunk-A2AXSNBT-CpRdsZLi.js → chunk-A2AXSNBT-BURV8_Ve.js} +1 -1
  16. package/out/renderer/assets/{chunk-AEK57VVT-ZpJc0SjT.js → chunk-AEK57VVT-Drq4JjiV.js} +1 -1
  17. package/out/renderer/assets/{chunk-D6G4REZN-BnbKbjb5.js → chunk-D6G4REZN-CZAnXyui.js} +1 -1
  18. package/out/renderer/assets/{chunk-RZ5BOZE2-fE5orPok.js → chunk-RZ5BOZE2-CozFmNj8.js} +1 -1
  19. package/out/renderer/assets/{chunk-XZIHB7SX-BocbG9za.js → chunk-XZIHB7SX-C14OnVo8.js} +1 -1
  20. package/out/renderer/assets/classDiagram-GIVACNV2-ClhI-D7Z.js +1 -0
  21. package/out/renderer/assets/classDiagram-v2-COTLJTTW-ClhI-D7Z.js +1 -0
  22. package/out/renderer/assets/clone-Cmb1HZ2d.js +1 -0
  23. package/out/renderer/assets/{conversation-input-sync-BwzJoCux.js → conversation-input-sync-DxHw4wST.js} +163 -163
  24. package/out/renderer/assets/{dagre-OKDRZEBW-CzB91IzU.js → dagre-OKDRZEBW-KytYyaCt.js} +1 -1
  25. package/out/renderer/assets/{diagram-SSKATNLV-Bg5RhMEV.js → diagram-SSKATNLV-CeiU3v3N.js} +1 -1
  26. package/out/renderer/assets/{diagram-VNBRO52H-C1BWQ4vB.js → diagram-VNBRO52H-CL1MSAwf.js} +1 -1
  27. package/out/renderer/assets/{erDiagram-Q7BY3M3F-DjPk0V9l.js → erDiagram-Q7BY3M3F-DjYp6QSU.js} +1 -1
  28. package/out/renderer/assets/{flowDiagram-4HSFHLVR-DqqDHbny.js → flowDiagram-4HSFHLVR-DsZr3AEI.js} +1 -1
  29. package/out/renderer/assets/{ganttDiagram-APWFNJXF-6VnttUUq.js → ganttDiagram-APWFNJXF-C9xWgovd.js} +1 -1
  30. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-B2x6qu8n.js → gitGraphDiagram-7IBYFJ6S-N34YEldt.js} +1 -1
  31. package/out/renderer/assets/{graph-C6vbd8o2.js → graph-X21ef9S1.js} +1 -1
  32. package/out/renderer/assets/{index-C80Kbbvh.js → index-C11j6-2j.js} +1 -1
  33. package/out/renderer/assets/{index-C6H07UMx.js → index-DzhxCgE7.js} +1 -1
  34. package/out/renderer/assets/{index-DOUqLzli.js → index-KvCquFIu.js} +3 -3
  35. package/out/renderer/assets/{infoDiagram-PH2N3AL5-BNvFBjw9.js → infoDiagram-PH2N3AL5-qFk1LIco.js} +1 -1
  36. package/out/renderer/assets/{journeyDiagram-U35MCT3I-iD67_k23.js → journeyDiagram-U35MCT3I-2N_7ChXb.js} +1 -1
  37. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-BOEu-vrY.js → kanban-definition-NDS4AKOZ-DRydQT6_.js} +1 -1
  38. package/out/renderer/assets/{layout-B6vENNCe.js → layout-DsgA6KmN.js} +1 -1
  39. package/out/renderer/assets/{legacy-agents-page-B7Wl6Uer.js → legacy-agents-page-a42bd6Vb.js} +1 -1
  40. package/out/renderer/assets/{library-page-B4nuLGOL.js → library-page-C4z59b5g.js} +3 -3
  41. package/out/renderer/assets/{mermaid.core-CIDX9z6e.js → mermaid.core-rC6zEoVT.js} +5 -5
  42. package/out/renderer/assets/{mesh-page-CDYqDvSH.js → mesh-page-CY-Frpsh.js} +1 -1
  43. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-DZFrqoQW.js → mindmap-definition-ALO5MXBD-DmXwlieU.js} +1 -1
  44. package/out/renderer/assets/{mini-BXzq_AA1.js → mini-CFX07wTN.js} +1 -1
  45. package/out/renderer/assets/{org-access-CGaaYfna.js → org-access-VMhAoXqY.js} +1 -1
  46. package/out/renderer/assets/{pieDiagram-IB7DONF6-DA8UkA6f.js → pieDiagram-IB7DONF6-GxIKPV_y.js} +1 -1
  47. package/out/renderer/assets/{projects-page-Cn-KQN1u.js → projects-page-qWSJC9oD.js} +1 -1
  48. package/out/renderer/assets/{publication-validation-tcVifSwS.js → publication-validation-DLOlkolO.js} +1 -1
  49. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-DfViwx-_.js → quadrantDiagram-7GDLP6J5-DA-8Yy-L.js} +1 -1
  50. package/out/renderer/assets/{radar-MK3ICKWK-DybxyfeY.js → radar-MK3ICKWK-DsDA4o1K.js} +1 -1
  51. package/out/renderer/assets/{radient-auth-buttons-ByMhjwK9.js → radient-auth-buttons-Iuc5eVp5.js} +1 -1
  52. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-BHJJn_m3.js → requirementDiagram-KVF5MWMF-Eyhbbaq5.js} +1 -1
  53. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-DRtuiTmO.js → sankeyDiagram-QLVOVGJD-CSMpr4p1.js} +1 -1
  54. package/out/renderer/assets/{schedules-page-CWm4pp8U.js → schedules-page-Bn3e8WY7.js} +1 -1
  55. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-BS-1w7ox.js → sequenceDiagram-X6HHIX6F-BuFK5oLh.js} +1 -1
  56. package/out/renderer/assets/{settings-page-D7ZRdQEG.js → settings-page-DrhoPGFS.js} +1 -1
  57. package/out/renderer/assets/{smartart-D3PbCQe4.js → smartart-6Ai2zNd0.js} +1 -1
  58. package/out/renderer/assets/{stateDiagram-DGXRK772-Bejx0VAi.js → stateDiagram-DGXRK772-D2vUQclC.js} +1 -1
  59. package/out/renderer/assets/{stateDiagram-v2-YXO3MK2T-B-QCGmZj.js → stateDiagram-v2-YXO3MK2T-GP3LSZFY.js} +1 -1
  60. package/out/renderer/assets/{team-bridge-page-DrLX5SLK.js → team-bridge-page-BSwTmi7d.js} +2 -2
  61. package/out/renderer/assets/{timeline-definition-BDJGKUSR-C1Rfmu0P.js → timeline-definition-BDJGKUSR-DZJd-t5l.js} +1 -1
  62. package/out/renderer/assets/{use-download-agent-mutation-BS29ofCo.js → use-download-agent-mutation-DBqvJdZO.js} +1 -1
  63. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-rQhoehfj.js → xychartDiagram-VJFVF3MP-DGOwlzXU.js} +1 -1
  64. package/out/renderer/index.html +2 -2
  65. package/out/renderer/mini.html +2 -2
  66. package/package.json +2 -2
  67. package/out/renderer/assets/channel-DXQf2vmt.js +0 -1
  68. package/out/renderer/assets/classDiagram-GIVACNV2-wz5OSVRz.js +0 -1
  69. package/out/renderer/assets/classDiagram-v2-COTLJTTW-wz5OSVRz.js +0 -1
  70. package/out/renderer/assets/clone-VMNU3Wnj.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./agent-details-page-DSmJIvXx.js","./index-DZ0oVvBQ.js","./messages-DbS1PwZU.js","./index-DLDgY5fY.css","./publication-validation-tcVifSwS.js","./path-utils-CwYffJ73.js","./conversation-input-sync-BwzJoCux.js","./error-boundary-vmQ5tlCX.js","./conversation-input-sync-CAX4_ErH.css","./use-download-agent-mutation-BS29ofCo.js","./en-US-CHJkXXr4.js","./book-open-CnrMa_Lj.js","./heart-DpdW9OuA.js","./console-mirror-Biqf_qft.js","./console-mirror-DOrYoP_4.css","./agent-hub-page-CD_Db8P3.js","./page-header-CdCjG9NV.js","./org-access-CGaaYfna.js","./radient-auth-buttons-ByMhjwK9.js","./format-esAOn2VS.js","./org-surface-gate-CGfGEFG5.js","./building-2-KNn69NZT.js","./agents-page-CUktXXX5.js","./schedules-page-CWm4pp8U.js","./parseISO-BHJWTxrA.js","./projects-page-Cn-KQN1u.js","./use-session-snapshot-DoZQzNKC.js","./library-page-B4nuLGOL.js","./hash-L2ujAC5o.js","./team-bridge-page-DrLX5SLK.js","./browser-page-B4X8tPFL.js","./mesh-page-CDYqDvSH.js","./settings-page-D7ZRdQEG.js","./notebook-pen-CMhgSRMw.js","./browser-webauthn-prompt-CKXKeFSp.js"])))=>i.map(i=>d[i]);
2
- import{r as m,j as c,c as T,b as nt,h as RD,p as FK,z as DK,o as IK,A as PK,u as Wc,B as NK,C as MK,E as OK,F as ck,a as LK,R as BK}from"./index-DZ0oVvBQ.js";import{u as Qe,c as pt,e as yu,S as An,p as mo,B as le,L as xr,I as ks,T as xR,g as Us,X as Yn,ad as uk,ak as jK,D as lc,a as cc,d as rl,y as Di,x as mi,o as Up,h as fp,aj as dv,l as gt,a0 as Gp,b as P_,A as Kr,f as N_,F as i0,G as a0,H as o0,J as l0,K as c0,q as La,r as sa,s as Ba,t as dk,v as Js,w as Ot,al as hv,z as Sa,a8 as zx,am as py,a5 as Uj,Y as Gj,Z as Vj,_ as hk,k as ux,ai as HK,a1 as Qd,a2 as M_,a3 as ou,an as Bf,ao as UK,M as qx,i as Wj,ap as GK,j as $j,aq as VK,ar as AD,a4 as WK,ag as fk,C as $K,as as _g,at as wR,N as _R,$ as zK,aa as qK,ab as KK,ac as YK,a6 as XK,a7 as QK,ae as JK,af as ZK,au as eY,av as tY,aw as zj,m as FD,n as DD,ax as vd,E as nY}from"./error-boundary-vmQ5tlCX.js";import{az as sY,aA as pk,aB as rY,a7 as qj,u as Gt,aC as iY,aD as aY,aE as oY,aF as lY,aG as cY,aH as uY,aI as ID,aJ as PD,aK as dY,aL as hY,q as De,aM as fY,aN as gk,aO as O_,aP as dd,h as Nn,a as ns,c as Et,e as fv,B as Kj,A as xi,T as Yj,aQ as Ja,a0 as Vp,a4 as Xj,d as at,aR as ND,aS as gy,aT as Qj,aU as mk,aj as vk,aV as pY,D as Li,y as qo,r as pv,aW as Af,aX as Jj,aY as gY,g as Ni,aZ as my,a_ as gv,a3 as il,x as st,a$ as Zj,b0 as e6,b1 as L_,b2 as bk,b3 as mY,S as Pd,b4 as t6,b5 as vY,b6 as bY,b7 as xY,K as lu,b8 as wY,I as CR,G as mv,b9 as vy,ba as Gn,bb as xk,bc as MD,bd as wk,H as _Y,be as CY,bf as yY,bg as SY,f as n6,bh as kY,bi as EY,bj as TY,O as Yr,bk as Vl,av as B_,b as s6,bl as OD,bm as RY,bn as LD,bo as AY,bp as yR,a2 as FY,bq as DY,br as IY,bs as PY,bt as NY,bu as BD,o as SR,bv as r6,bw as MY,bx as jD,by as j_,bz as OY,bA as LY,bB as BY,bC as jY,bD as HY,bE as i6,bF as by,bG as em,bH as UY,bI as a6,bJ as GY,bK as HD,bL as UD,bM as dx,bN as hx,bO as _k,Y as kR,bP as o6,bQ as VY,X as WY,W as $Y,bR as zY,bS as GD,bT as qY,bU as nd,bV as nb,bW as KY,bX as YY,bY as XY,bZ as VD,b_ as WD,b$ as QY,c0 as JY,c1 as ZY,c2 as eX,c3 as $D,c4 as zD,c5 as qD,c6 as KD,c7 as tX,c8 as nX,c9 as sX,ca as rX,cb as iX,cc as YD,cd as aX,ce as oX,cf as lX,cg as Kx,ch as cX,ci as XD,cj as uX,ck as dX,cl as hX,cm as fX,cn as sb,co as pX,cp as gX,cq as l6,cr as mX,Z as ER,ay as QD,cs as vX,ct as bX,cu as xX,ax as wX,cv as JD,n as ZD,cw as xm,cx as _X,cy as CX,cz as yX,cA as SX,cB as rb,cC as kX,cD as ib,cE as eI,cF as EX,cG as TX,cH as ab,cI as ob,cJ as tI,cK as nI,cL as RX,cM as fx,s as Yx,t as c6,v as AX,cN as Ck,cO as FX,cP as DX,cQ as IX,cR as PX,cS as NX,cT as MX,cU as OX,cV as LX,cW as u6,cX as BX,V as vv,cY as jX,cZ as TR,a1 as HX,c_ as UX,c$ as GX,$ as VX,d0 as WX,d1 as $X,d2 as sI,d3 as xy,d4 as rI,d5 as zX,d6 as qX,d7 as KX,d8 as YX,d9 as XX,da as QX,db as iI,U as JX,dc as ZX,dd as eQ,de as tQ,df as nQ,w as sQ,dg as rQ,_ as iQ,dh as d6,di as aQ,dj as oQ,dk as lQ,dl as cQ,aw as uQ,a6 as qe,ad as aI,dm as dQ,dn as hQ,dp as wy,dq as u0,ac as fQ,dr as oI,ds as pQ,dt as yr,Q as lI,du as gQ,dv as cI,dw as mQ,dx as h6,dy as uI,dz as vQ}from"./path-utils-CwYffJ73.js";import{c7 as px,bg as Zc,c5 as oo,bo as RR,a3 as Ua,a4 as Gs,T as sn,aq as Mn,ar as Is,S as Su,av as bv,c8 as bQ,aw as xv,dB as f6,dC as xQ,dD as d0,dE as wQ,dF as _Q,dG as CQ,dH as yQ,dI as _y,dJ as Cy,bZ as $c,bK as H_,cB as ku,cm as gx,cl as SQ,ck as dr,cn as _n,dK as p6,dL as kQ,dM as yk,ax as _h,dN as AR,ct as U_,cS as EQ,dO as dI,dP as TQ,dQ as RQ,dR as Sk,dS as AQ,dT as FQ,dU as DQ,dV as IQ,dW as Xx,Y as Qx,ah as jf,dX as hI,dY as fI,dZ as PQ,d_ as NQ,d$ as MQ,e0 as g6,e1 as OQ,e2 as LQ,e3 as m6,e4 as G_,e5 as V_,e6 as BQ,e7 as jQ,e8 as HQ,e9 as pI,ea as UQ,eb as GQ,ec as VQ,ed as WQ,ee as $Q,ef as zQ,eg as qQ,eh as KQ,bW as v6,ei as YQ,ej as b6,ek as XQ,el as gI,em as QQ,en as JQ,bT as qr,eo as h0,ep as x6,eq as ZQ,er as eJ,es as mI,et as tJ,eu as nJ,ev as sJ,ew as rJ,ex as iJ,b1 as w6,ey as wm,ez as _6,eA as aJ,eB as oJ,eC as lJ,eD as cJ,eE as uJ,eF as dJ,eG as hJ,be as cu,eH as uu,eI as fJ,a0 as FR,eJ as vI,eK as pJ,eL as gJ,eM as mJ,eN as vJ,eO as bJ,eP as xJ,eQ as xf,cK as wJ,eR as _J,eS as CJ,cN as yJ,eT as SJ,eU as kJ,eV as C6,bL as yy,eW as DR,az as y6,eX as W_,eY as EJ,b4 as kk,at as IR,eZ as S6,aA as Wl,e_ as k6,bc as Jd,bN as $_,e$ as TJ,f0 as RJ,bk as du,bP as z_,f1 as bI,f2 as AJ,f3 as FJ,f4 as DJ,f5 as IJ,f6 as PJ,f7 as NJ,f8 as MJ,f9 as OJ,fa as LJ,fb as xI,fc as BJ,fd as jJ,fe as PR,ff as wI,cP as HJ,fg as UJ,fh as E6,fi as GJ,fj as VJ,fk as T6,fl as Ek,fm as WJ,fn as Hf,fo as Wp,fp as $J,fq as _I,fr as zJ,bQ as q_,fs as qJ,ft as R6,fu as A6,fv as KJ,fw as F6,fx as Jx,fy as YJ,fz as XJ,fA as QJ,fB as JJ,fC as ZJ,fD as eZ,fE as tZ,ad as _s,fF as nZ,ac as zc,fG as D6,fH as sZ,fI as rZ,fJ as NR,fK as iZ,bV as I6,cc as K_,cf as Y_,fL as X_,fM as Ga,fN as aZ,fO as $n,fP as pn,fQ as wv,fR as f0,fS as Q_,fT as MR,fU as J_,fV as oZ,fW as lZ,fX as cZ,fY as Rn,fZ as p0,f_ as P6,f$ as ka,g0 as Zd,g1 as uZ,g2 as N6,g3 as M6,g4 as OR,g5 as Zx,g6 as O6,K as LR,g7 as Tk,g8 as BR,g9 as Sy,ga as dZ,gb as hZ,gc as fZ,gd as Ff,ge as Rk,gf as L6,gg as pZ,gh as B6,gi as gZ,gj as mZ,gk as vZ,gl as bZ,gm as xZ,gn as wZ,go as _Z,gp as CZ,gq as yZ,gr as SZ,gs as ew,gt as kZ,gu as EZ,gv as TZ,gw as RZ,gx as AZ,gy as FZ,gz as jR,gA as DZ,gB as j6,v as ht,gC as IZ,gD as Z_,gE as eh,bn as H6,bq as PZ,gF as CI,aZ as U6,gG as NZ,gH as MZ,gI as OZ,gJ as LZ,gK as BZ,gL as jZ,gM as HZ,gN as UZ,af as Er,gO as GZ,gP as VZ,gQ as WZ,gR as $Z,gS as zZ,gT as qZ,gU as KZ,gV as YZ,gW as XZ,gX as G6,gY as QZ,gZ as JZ,g_ as g0,g$ as V6,h0 as tw,h1 as pp,h2 as eC,h3 as HR,h4 as ZZ,h5 as eee,h6 as tee,h7 as W6,h8 as nee,h9 as yI,ha as see,hb as UR,hc as ree,hd as GR,he as _v,hf as Cv,hg as iee,hh as $6,hi as m0,hj as aee,hk as oee,hl as lee,hm as cee,hn as uee,ho as dee,hp as SI,hq as z6,bH as q6,hr as hee,hs as fee,ht as pee,hu as gee,bv as mee,hv as kI,hw as vee,hx as bee,hy as K6,hz as xee,hA as Hl,hB as EI,hC as _m,hD as Cg,hE as wee,hF as TI,hG as RI,hH as _ee,hI as Y6,bb as Cm,hJ as Cee,hK as yee,hL as tC,ci as See,as as $p,hM as kee,hN as Ak,hO as Eee,hP as Tee,hQ as VR,bw as Ree,hR as Aee,hS as eu,hT as WR,hU as $R,hV as Fee,b7 as Dee,b8 as nC,hW as Iee,b6 as gp,cj as ky,hX as Pee,hY as Nee,hZ as Mee,h_ as Oee,h$ as Lee,i0 as Bee,i1 as jee,i2 as Al,i3 as AI,i4 as Hee,bl as Uee,i5 as Gee,i6 as Vee,i7 as Wee,i8 as $ee,i9 as zee,ia as qee,ib as Fk,bx as Kee,by as FI,c3 as wf,ic as Yee,bA as Xee,bU as Qee,id as Jee,ie as X6,bI as Zee,ig as ete,c0 as tte,ih as nte,ii as ste,ij as rte,ik as ite,cA as ate,bJ as ote,il as lte,im as cte,io as lb,ip as Q6,cx as ute,iq as Nd,d9 as J6,da as zR,ir as dte,is as hte,it as fte,iu as Z6,bF as pte,iv as gte,ai as e5,d8 as mte,iw as vte,bj as t5,ix as bte,iy as xte,iz as wte,iA as _te,iB as Cte,iC as yte,a_ as Ey,a$ as Ty,b0 as Ry,ag as Ste,iD as kte,iE as Ete,iF as Tte,c2 as Zh,iG as ef,iH as Rte,iI as Ate,iJ as n5,iK as Fte,iL as s5,iM as Dk,iN as Ik,iO as Ay,iP as Dte,iQ as Ite,iR as _f,iS as Pte,_ as DI,iT as II,iU as r5,iV as Pk,iW as i5,iX as a5,iY as Nte,iZ as Mte,i_ as Ote,i$ as Lte,j0 as Bte,j1 as jte,j2 as Hte,j3 as Ute,j4 as Gte,j5 as Vte,j6 as Wte,j7 as $te,j8 as zte,j9 as qte,ja as Kte,jb as Yte,jc as Xte,jd as Qte,je as Jte,jf as PI,jg as Zte,jh as ene,ji as tne,jj as nne,jk as sne,jl as rne,jm as ine,jn as ane,jo as one,a7 as lne,a8 as cne,a9 as une,aa as dne,ab as hne,jp as fne,jq as pne,jr as gne,js as NI,cO as o5,jt as qR,ju as mne,ay as l5,jv as c5,jw as vne,jx as bne,jy as xne,jz as Hr,jA as wne,jB as Nc,jC as u5,jD as d5,jE as h5,jF as KR,jG as Ki,jH as _ne,jI as Cne,jJ as yne,jK as Sne,jL as kne,jM as Ene,jN as Tne,jO as Rne,jP as Ane,jQ as Fne,jR as f5,jS as Dne,jT as Ine,jU as Pne,jV as Nne,jW as Mne,jX as Nk,jY as One,jZ as Lne,j_ as MI,j$ as p5,k0 as Bne,k1 as jne,k2 as Hne,k3 as OI,k4 as Une,k5 as Gne,k6 as Vne,k7 as Wne,k8 as $ne,k9 as zne,ka as qne,kb as Kne,kc as g5,kd as Yne,ke as Xne,cz as nw,kf as Qne,kg as LI,kh as Jne,ki as Zne,bf as wi,ap as YR,kj as m5,kk as v5,kl as v0,km as ese,kn as BI,ko as tse,cF as nse,cU as sse,kp as rse,kq as ise,kr as ase,cT as jI,ks as ose,a1 as lse,bd as Va,kt as cse,ku as use,kv as dse,kw as hse,kx as tf,ky as fse,kz as pse,kA as sw,kB as gse,kC as mse,kD as Fy,kE as Dy,kF as HI,kG as Iy,kH as UI,kI as b5,ao as vse,kJ as x5,kK as bse,al as xse,am as wse,aj as _se,ak as Cse,kL as yse,an as Sse}from"./conversation-input-sync-BwzJoCux.js";import{t as p,c as GI,L as Yo,b as kse}from"./messages-DbS1PwZU.js";import{u as w5,b as Ese,c as Tse,r as _5,d as C5,e as b0,f as Rse,g as Ase,o as zp,s as XR,n as Mk,h as Fse,i as Dse,p as Ise,j as Pse,k as Nse,l as Mse,q as Ose,v as Lse,w as VI,x as WI,y as Bse,z as jse,A as Hse,C as Use,B as Gse,D as Vse,E as Wse,F as $se,G as zse,H as qse}from"./console-mirror-Biqf_qft.js";function $I(e,t){return e.filter(n=>!t.includes(n))}function Kse(e,t,n){const s=e.slice(0);return s[t]=n,s}var Yse=class extends sY{#s;#e;#r;#i;#t;#n;#a;#o;#l=[];constructor(e,t,n){super(),this.#s=e,this.#i=n,this.#r=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(t=>{this.#h(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,t){this.#r=e,this.#i=t,pk.batch(()=>{const n=this.#t,s=this.#d(this.#r);this.#l=s,s.forEach(o=>o.observer.setOptions(o.defaultedQueryOptions));const r=s.map(o=>o.observer),i=r.map(o=>o.getCurrentResult()),a=r.some((o,l)=>o!==n[l]);n.length===r.length&&!a||(this.#t=r,this.#e=i,this.hasListeners()&&($I(n,r).forEach(o=>{o.destroy()}),$I(r,n).forEach(o=>{o.subscribe(l=>{this.#h(o,l)})}),this.#f()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const n=this.#d(e),s=n.map(r=>r.observer.getOptimisticResult(r.defaultedQueryOptions));return[s,r=>this.#u(r??s,t),()=>this.#c(s,n)]}#c(e,t){return t.map((n,s)=>{const r=e[s];return n.defaultedQueryOptions.notifyOnChangeProps?r:n.observer.trackResult(r,i=>{t.forEach(a=>{a.observer.trackProp(i)})})})}#u(e,t){return t?((!this.#n||this.#e!==this.#o||t!==this.#a)&&(this.#a=t,this.#o=this.#e,this.#n=rY(this.#n,t(e))),this.#n):e}#d(e){const t=new Map(this.#t.map(s=>[s.options.queryHash,s])),n=[];return e.forEach(s=>{const r=this.#s.defaultQueryOptions(s),i=t.get(r.queryHash);i?n.push({defaultedQueryOptions:r,observer:i}):n.push({defaultedQueryOptions:r,observer:new qj(this.#s,r)})}),n}#h(e,t){const n=this.#t.indexOf(e);n!==-1&&(this.#e=Kse(this.#e,n,t),this.#f())}#f(){if(this.hasListeners()){const e=this.#n,t=this.#c(this.#e,this.#l),n=this.#u(t,this.#i?.combine);e!==n&&pk.batch(()=>{this.listeners.forEach(s=>{s(this.#e)})})}}};function y5({queries:e,...t},n){const s=Gt(n),r=iY(),i=aY(),a=m.useMemo(()=>e.map(b=>{const x=s.defaultQueryOptions(b);return x._optimisticResults=r?"isRestoring":"optimistic",x}),[e,s,r]);a.forEach(b=>{oY(b),lY(b,i)}),cY(i);const[o]=m.useState(()=>new Yse(s,a,t)),[l,u,d]=o.getOptimisticResult(a,t.combine),h=!r&&t.subscribed!==!1;m.useSyncExternalStore(m.useCallback(b=>h?o.subscribe(pk.batchCalls(b)):uY,[o,h]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),m.useEffect(()=>{o.setQueries(a,t)},[a,t,o]);const g=l.some((b,x)=>ID(a[x],b))?l.flatMap((b,x)=>{const w=a[x];if(w){const _=new qj(s,w);if(ID(w,b))return PD(w,_,i);dY(b,r)&&PD(w,_,i)}return[]}):[];if(g.length>0)throw Promise.all(g);const v=l.find((b,x)=>{const w=a[x];return w&&hY({result:b,errorResetBoundary:i,throwOnError:w.throwOnError,query:s.getQueryCache().get(w.queryHash),suspense:w.suspense})});if(v?.error)throw v.error;return u(d())}const Ok=8e3,S5=1e4;function Xse(e){return e?`“${e}”`:"Conversation"}const Qse="archived.";function Jse(e){return De.getState().archiveFacts[e]}function Zse(e){const t=De.getState(),n=t.archiveFacts[e];return n?n.archived:t.sessions.find(s=>s.session_id===e)?.archived}function ere(){const e=De(t=>t.archiveUndo);m.useEffect(()=>{if(e===null)return;let t=!1;const n=()=>{t||(t=!0,r())},s=()=>{n();const i=De.getState().archiveUndo;i!==null&&i.sessionId===e.sessionId&&i.at===e.at&&De.getState().setArchiveUndo(null)},r=De.subscribe(()=>{const i=Jse(e.sessionId);i!==void 0&&!i.answered||fY(e.archived,Zse(e.sessionId))||s()});return n},[e])}function tre(e){return e===1?"Draft":`${e} drafts`}const nre="discarded.",sre=e=>{const t=gk(e),n=t.length,s=t.filter(o=>!o.active).length,r=n===1?"chat":"chats",i=e.filter(o=>O_(o)!==null&&gk([o]).length===0).length,a=[`Mark ${n} unread ${r} as read${s>0?`, including ${s} in Previous chats`:""}.`];return i>0&&a.push(`${i} unread ${i===1?"mark":"marks"} with no completion token cannot be cleared.`),{count:n,label:`Mark all ${n} read`,scope:a.join(" "),nameSuffix:s>0?`, including ${s} in Previous chats`:""}},k5=e=>e===1?"1 lives on another device and clears when that device updates.":`${e} live on other devices and clear when those devices update.`,rre=e=>{if(e.attempted===0)return{tone:"success",message:"Nothing to clear."};const t=e.unknown-e.deferred,n=[e.superseded>0?`${e.superseded} ${e.superseded===1?"has a newer result and stays":"have newer results and stay"} unread.`:null,t>0?`${t} could not be cleared and ${t===1?"stays":"stay"} unread.`:null,e.deferred>0?k5(e.deferred):null].filter(s=>s!==null);return e.cleared===0?{tone:"warning",message:["Nothing was cleared.",...n].join(" ")}:{tone:"success",message:[`Marked ${e.cleared} ${e.cleared===1?"chat":"chats"} as read.`,...n].join(" ")}},Py="archive",zI="drafts-undo",qI="bulk-read-deferral",ire=8e3;function are(){Qe();const e=De(f=>f.archiveFailure),t=De(f=>f.archiveUndo),n=De(f=>f.draftsUndo),s=De(f=>f.bulkReadDeferral),r=De(f=>f.clearArchiveFailure),i=De(f=>f.setArchiveUndo),a=De(f=>f.setSessionArchived),o=De(f=>f.restoreDraftsUndo);ere();const l=dd(e?.title),u=m.useRef(null);m.useEffect(()=>{if(e===null&&t===null){if(u.current===null)return;u.current=null,px(Py);return}const f=e&&t?t.at>e.at?"offer":"failure":e?"failure":"offer",g=f==="offer"?t?.at??0:e?.at??0,v=u.current;u.current={kind:f,at:g},v!==null&&v.kind!==f&&g>v.at&&(f==="failure"?i(null):r());const b=(x,w)=>()=>{const _=De.getState();x==="offer"?_.archiveUndo?.at===w&&_.setArchiveUndo(null):_.archiveFailure?.at===w&&_.clearArchiveFailure();const C=u.current;C!==null&&C.kind===x&&C.at===w&&(u.current=null)};if(f==="failure"&&e){Zc(`Could not ${e.archived?"archive":"unarchive"} “${l}”.${e.detail?` ${e.detail}`:""}`,{id:Py,duration:S5,onAutoClose:b("failure",e.at),onDismiss:b("failure",e.at),action:{label:"Retry",onClick:x=>{x.preventDefault(),a(e.sessionId,e.archived,e.title)}}});return}t&&oo(c.jsxs("span",{className:T("flex min-w-0 items-baseline gap-1"),children:[c.jsx("span",{className:T("min-w-0 truncate"),children:Xse(t.title)}),c.jsx("span",{className:T("shrink-0"),children:Qse})]}),{id:Py,duration:Ok,classNames:{content:"min-w-0"},onAutoClose:b("offer",t.at),onDismiss:b("offer",t.at),action:{label:"Undo",onClick:x=>{x.preventDefault(),a(t.sessionId,!t.archived,t.title)}}})},[l,e,t,i,r,a]);const d=m.useRef(!1);m.useEffect(()=>{if(n===null){if(!d.current)return;d.current=!1,px(zI);return}d.current=!0;const f=()=>{const g=De.getState();g.draftsUndo?.at===n.at&&(g.setDraftsUndo(null),d.current=!1)};oo(c.jsxs("span",{className:T("flex min-w-0 items-baseline gap-1"),children:[c.jsx("span",{className:T("min-w-0 truncate"),children:tre(n.keys.length)}),c.jsx("span",{className:T("shrink-0"),children:nre})]}),{id:zI,duration:Ok,classNames:{content:"min-w-0"},onAutoClose:f,onDismiss:f,action:{label:"Undo",onClick:g=>{g.preventDefault(),o();const v=De.getState(),b=v.stagedByDiscard;v.setStagedByDiscard(null),n.keys.length===1&&b!==null&&De.getState().activeDraftKey===b&&De.getState().openDraft(n.keys[0])}}})},[n,o]);const h=m.useRef(!1);return m.useEffect(()=>{if(s===null){if(!h.current)return;h.current=!1,px(qI);return}h.current=!0;const f=()=>{const g=De.getState();g.bulkReadDeferral?.at===s.at&&(g.clearBulkReadDeferral(),h.current=!1)};oo(k5(s.count),{id:qI,duration:ire,onAutoClose:f,onDismiss:f})},[s]),null}var so,Ue=typeof window<"u"?window:void 0,Ti=typeof globalThis<"u"?globalThis:Ue,E5=Array.prototype,KI=E5.forEach,YI=E5.indexOf,Zi=Ti?.navigator,It=Ti?.document,ki=Ti?.location,Lk=Ti?.fetch,Bk=Ti!=null&&Ti.XMLHttpRequest&&"withCredentials"in new Ti.XMLHttpRequest?Ti.XMLHttpRequest:void 0,XI=Ti?.AbortController,Ys=Zi?.userAgent,Zt=Ue??{},Ml={DEBUG:!1,LIB_VERSION:"1.235.6"},Ny="$copy_autocapture",ore=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];(function(e){e.GZipJS="gzip-js",e.Base64="base64"})(so||(so={}));var lre=["fatal","error","warning","log","info","debug"];function fn(e,t){return e.indexOf(t)!==-1}var sC=function(e){return e.trim()},QR=function(e){return e.replace(/^\$/,"")},cre=Array.isArray,T5=Object.prototype,R5=T5.hasOwnProperty,rC=T5.toString,As=cre||function(e){return rC.call(e)==="[object Array]"},lo=e=>typeof e=="function",Fs=e=>e===Object(e)&&!As(e),Df=e=>{if(Fs(e)){for(var t in e)if(R5.call(e,t))return!1;return!0}return!1},At=e=>e===void 0,Qs=e=>rC.call(e)=="[object String]",jk=e=>Qs(e)&&e.trim().length===0,Eu=e=>e===null,Wn=e=>At(e)||Eu(e),gi=e=>rC.call(e)=="[object Number]",Ll=e=>rC.call(e)==="[object Boolean]",ure=e=>e instanceof FormData,dre=e=>fn(ore,e),A5=e=>{var t={_log:function(n){if(Ue&&(Ml.DEBUG||Zt.POSTHOG_DEBUG)&&!At(Ue.console)&&Ue.console){for(var s=("__rrweb_original__"in Ue.console[n])?Ue.console[n].__rrweb_original__:Ue.console[n],r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];s(e,...i)}},info:function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];t._log("log",...s)},warn:function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];t._log("warn",...s)},error:function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];t._log("error",...s)},critical:function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];console.error(e,...s)},uninitializedWarning:n=>{t.error("You must initialize PostHog before calling ".concat(n))},createLogger:n=>A5("".concat(e," ").concat(n))};return t},Lt=A5("[PostHog.js]"),Zr=Lt.createLogger,hre=Zr("[ExternalScriptsLoader]"),QI=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return hre.warn("".concat(t," was requested but loading of external scripts is disabled.")),n("Loading of external scripts is disabled");var s=It?.querySelectorAll("script");if(s){for(var r=0;r<s.length;r++)if(s[r].src===t)return n()}var i=()=>{if(!It)return n("document not found");var a=It.createElement("script");if(a.type="text/javascript",a.crossOrigin="anonymous",a.src=t,a.onload=u=>n(void 0,u),a.onerror=u=>n(u),e.config.prepare_external_dependency_script&&(a=e.config.prepare_external_dependency_script(a)),!a)return n("prepare_external_dependency_script returned null");var o,l=It.querySelectorAll("body > script");l.length>0?(o=l[0].parentNode)===null||o===void 0||o.insertBefore(a,l[0]):It.body.appendChild(a)};It!=null&&It.body?i():It?.addEventListener("DOMContentLoaded",i)};function JI(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,s)}return n}function ze(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?JI(Object(n),!0).forEach(function(s){bt(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):JI(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function bt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function F5(e,t){if(e==null)return{};var n,s,r=function(a,o){if(a==null)return{};var l,u,d={},h=Object.keys(a);for(u=0;u<h.length;u++)l=h[u],o.indexOf(l)>=0||(d[l]=a[l]);return d}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)n=i[s],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}Zt.__PosthogExtensions__=Zt.__PosthogExtensions__||{},Zt.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{var s="/static/".concat(t,".js")+"?v=".concat(e.version);if(t==="remote-config"&&(s="/array/".concat(e.config.token,"/config.js")),t==="toolbar"){var r=3e5,i=Math.floor(Date.now()/r)*r;s="".concat(s,"&t=").concat(i)}var a=e.requestRouter.endpointFor("assets",s);QI(e,a,n)},Zt.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{var s=e.requestRouter.endpointFor("api",t);QI(e,s,n)};var rw={};function tu(e,t,n){if(As(e)){if(KI&&e.forEach===KI)e.forEach(t,n);else if("length"in e&&e.length===+e.length){for(var s=0,r=e.length;s<r;s++)if(s in e&&t.call(n,e[s],s)===rw)return}}}function es(e,t,n){if(!Wn(e)){if(As(e))return tu(e,t,n);if(ure(e)){for(var s of e.entries())if(t.call(n,s[1],s[0])===rw)return}else for(var r in e)if(R5.call(e,r)&&t.call(n,e[r],r)===rw)return}}var Os=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];return tu(n,function(r){for(var i in r)r[i]!==void 0&&(e[i]=r[i])}),e},mx=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];return tu(n,function(r){tu(r,function(i){e.push(i)})}),e};function vx(e){for(var t=Object.keys(e),n=t.length,s=new Array(n);n--;)s[n]=[t[n],e[t[n]]];return s}var ZI=function(e){try{return e()}catch{return}},fre=function(e){return function(){try{for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return e.apply(this,n)}catch(r){Lt.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Lt.critical(r)}}},x0=function(e){var t={};return es(e,function(n,s){Qs(n)&&n.length>0&&(t[s]=n)}),t};function pre(e,t){return n=e,s=i=>Qs(i)&&!Eu(t)?i.slice(0,t):i,r=new Set,function i(a,o){return a!==Object(a)?s?s(a,o):a:r.has(a)?void 0:(r.add(a),As(a)?(l=[],tu(a,u=>{l.push(i(u))})):(l={},es(a,(u,d)=>{r.has(u)||(l[d]=i(u,d))})),l);var l}(n);var n,s,r}var gre=["herokuapp.com","vercel.app","netlify.app"];function mre(e){var t=e?.hostname;if(!Qs(t))return!1;var n=t.split(".").slice(-2).join(".");for(var s of gre)if(n===s)return!1;return!0}function D5(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return e[n]}function Bs(e,t,n,s){var{capture:r=!1,passive:i=!0}=s??{};e?.addEventListener(t,n,{capture:r,passive:i})}var I5="$people_distinct_id",tm="__alias",nm="__timers",eP="$autocapture_disabled_server_side",Hk="$heatmaps_enabled_server_side",tP="$exception_capture_enabled_server_side",nP="$web_vitals_enabled_server_side",P5="$dead_clicks_enabled_server_side",sP="$web_vitals_allowed_metrics",Uk="$session_recording_enabled_server_side",rP="$console_log_recording_enabled_server_side",iP="$session_recording_network_payload_capture",aP="$session_recording_masking",oP="$session_recording_canvas_recording",lP="$replay_sample_rate",cP="$replay_minimum_duration",uP="$replay_script_config",iw="$sesid",sm="$session_is_sampled",My="$session_recording_url_trigger_activated_session",Oy="$session_recording_event_trigger_activated_session",If="$enabled_feature_flags",bx="$early_access_features",Gk="$feature_flag_details",rm="$stored_person_properties",hd="$stored_group_properties",Vk="$surveys",cb="$surveys_activated",aw="$flag_call_reported",Il="$user_state",Wk="$client_session_props",$k="$capture_rate_limit",zk="$initial_campaign_params",qk="$initial_referrer_info",Kk="$initial_person_info",ow="$epp",N5="__POSTHOG_TOOLBAR__",dP="$posthog_cookieless",vre=[I5,tm,"__cmpns",nm,Uk,Hk,iw,If,Il,bx,Gk,hd,rm,Vk,aw,Wk,$k,zk,qk,ow];function hP(e){var t;return e instanceof Element&&(e.id===N5||!((t=e.closest)===null||t===void 0||!t.call(e,".toolbar-global-fade-container")))}function iC(e){return!!e&&e.nodeType===1}function nu(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function M5(e){return!!e&&e.nodeType===3}function O5(e){return!!e&&e.nodeType===11}function JR(e){return e?sC(e).split(/\s+/):[]}function fP(e){var t=Ue?.location.href;return!!(t&&e&&e.some(n=>t.match(n)))}function lw(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return JR(t)}function L5(e){return Wn(e)?null:sC(e).split(/(\s+)/).filter(t=>mp(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function aC(e){var t="";return Xk(e)&&!H5(e)&&e.childNodes&&e.childNodes.length&&es(e.childNodes,function(n){var s;M5(n)&&n.textContent&&(t+=(s=L5(n.textContent))!==null&&s!==void 0?s:"")}),sC(t)}function B5(e){return At(e.target)?e.srcElement||null:(t=e.target)!==null&&t!==void 0&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var Yk=["a","button","form","input","select","textarea","label"];function j5(e){var t=e.parentNode;return!(!t||!iC(t))&&t}function bre(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;if(!Ue||!e||nu(e,"html")||!iC(e)||n!=null&&n.url_allowlist&&!fP(n.url_allowlist)||n!=null&&n.url_ignorelist&&fP(n.url_ignorelist))return!1;if(n!=null&&n.dom_event_allowlist){var i=n.dom_event_allowlist;if(i&&!i.some(g=>t.type===g))return!1}for(var a=!1,o=[e],l=!0,u=e;u.parentNode&&!nu(u,"body");)if(O5(u.parentNode))o.push(u.parentNode.host),u=u.parentNode.host;else{if(!(l=j5(u)))break;if(s||Yk.indexOf(l.tagName.toLowerCase())>-1)a=!0;else{var d=Ue.getComputedStyle(l);d&&d.getPropertyValue("cursor")==="pointer"&&(a=!0)}o.push(l),u=l}if(!function(g,v){var b=v?.element_allowlist;if(At(b))return!0;var x=function(C){if(b.some(S=>C.tagName.toLowerCase()===S))return{v:!0}};for(var w of g){var _=x(w);if(typeof _=="object")return _.v}return!1}(o,n)||!function(g,v){var b=v?.css_selector_allowlist;if(At(b))return!0;var x=function(C){if(b.some(S=>C.matches(S)))return{v:!0}};for(var w of g){var _=x(w);if(typeof _=="object")return _.v}return!1}(o,n))return!1;var h=Ue.getComputedStyle(e);if(h&&h.getPropertyValue("cursor")==="pointer"&&t.type==="click")return!0;var f=e.tagName.toLowerCase();switch(f){case"html":return!1;case"form":return(r||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(r||["change","click"]).indexOf(t.type)>=0;default:return a?(r||["click"]).indexOf(t.type)>=0:(r||["click"]).indexOf(t.type)>=0&&(Yk.indexOf(f)>-1||e.getAttribute("contenteditable")==="true")}}function Xk(e){for(var t=e;t.parentNode&&!nu(t,"body");t=t.parentNode){var n=lw(t);if(fn(n,"ph-sensitive")||fn(n,"ph-no-capture"))return!1}if(fn(lw(e),"ph-include"))return!0;var s=e.type||"";if(Qs(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=e.name||e.id||"";return!(Qs(r)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,"")))}function H5(e){return!!(nu(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||nu(e,"select")||nu(e,"textarea")||e.getAttribute("contenteditable")==="true")}var U5="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",xre=new RegExp("^(?:".concat(U5,")$")),wre=new RegExp(U5),G5="\\d{3}-?\\d{2}-?\\d{4}",_re=new RegExp("^(".concat(G5,")$")),Cre=new RegExp("(".concat(G5,")"));function mp(e){var t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return!(Wn(e)||Qs(e)&&(e=sC(e),(t?xre:wre).test((e||"").replace(/[- ]/g,""))||(t?_re:Cre).test(e)))}function V5(e){var t=aC(e);return mp(t="".concat(t," ").concat(W5(e)).trim())?t:""}function W5(e){var t="";return e&&e.childNodes&&e.childNodes.length&&es(e.childNodes,function(n){var s;if(n&&((s=n.tagName)===null||s===void 0?void 0:s.toLowerCase())==="span")try{var r=aC(n);t="".concat(t," ").concat(r).trim(),n.childNodes&&n.childNodes.length&&(t="".concat(t," ").concat(W5(n)).trim())}catch(i){Lt.error("[AutoCapture]",i)}}),t}function yre(e){return function(t){var n=t.map(s=>{var r,i,a="";if(s.tag_name&&(a+=s.tag_name),s.attr_class)for(var o of(s.attr_class.sort(),s.attr_class))a+=".".concat(o.replace(/"/g,""));var l=ze(ze(ze(ze({},s.text?{text:s.text}:{}),{},{"nth-child":(r=s.nth_child)!==null&&r!==void 0?r:0,"nth-of-type":(i=s.nth_of_type)!==null&&i!==void 0?i:0},s.href?{href:s.href}:{}),s.attr_id?{attr_id:s.attr_id}:{}),s.attributes),u={};return vx(l).sort((d,h)=>{var[f]=d,[g]=h;return f.localeCompare(g)}).forEach(d=>{var[h,f]=d;return u[pP(h.toString())]=pP(f.toString())}),a+=":",a+=vx(l).map(d=>{var[h,f]=d;return"".concat(h,'="').concat(f,'"')}).join("")});return n.join(";")}(function(t){return t.map(n=>{var s,r,i={text:(s=n.$el_text)===null||s===void 0?void 0:s.slice(0,400),tag_name:n.tag_name,href:(r=n.attr__href)===null||r===void 0?void 0:r.slice(0,2048),attr_class:Sre(n),attr_id:n.attr__id,nth_child:n.nth_child,nth_of_type:n.nth_of_type,attributes:{}};return vx(n).filter(a=>{var[o]=a;return o.indexOf("attr__")===0}).forEach(a=>{var[o,l]=a;return i.attributes[o]=l}),i})}(e))}function pP(e){return e.replace(/"|\\"/g,'\\"')}function Sre(e){var t=e.attr__class;return t?As(t)?t:JR(t):void 0}class $5{constructor(){this.clicks=[]}isRageClick(t,n,s){var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(n-r.y)<30&&s-r.timestamp<1e3){if(this.clicks.push({x:t,y:n,timestamp:s}),this.clicks.length===3)return!0}else this.clicks=[{x:t,y:n,timestamp:s}];return!1}}var kre=["localhost","127.0.0.1"],Uf=e=>{var t=It?.createElement("a");return At(t)?null:(t.href=e,t)},Ere=function(e){var t,n,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"&",r=[];return es(e,function(i,a){At(i)||At(a)||a==="undefined"||(t=encodeURIComponent((o=>o instanceof File)(i)?i.name:i.toString()),n=encodeURIComponent(a),r[r.length]=n+"="+t)}),r.join(s)},cw=function(e,t){for(var n,s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;r<s.length;r++){var i=s[r].split("=");if(i[0]===t){n=i;break}}if(!As(n)||n.length<2)return"";var a=n[1];try{a=decodeURIComponent(a)}catch{Lt.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},Ly=function(e,t,n){if(!e||!t||!t.length)return e;for(var s=e.split("#"),r=s[0]||"",i=s[1],a=r.split("?"),o=a[1],l=a[0],u=(o||"").split("&"),d=[],h=0;h<u.length;h++){var f=u[h].split("=");As(f)&&(t.includes(f[0])?d.push(f[0]+"="+n):d.push(u[h]))}var g=l;return o!=null&&(g+="?"+d.join("&")),i!=null&&(g+="#"+i),g},uw=function(e,t){var n=e.match(new RegExp(t+"=([^&]*)"));return n?n[1]:null},gP=Zr("[AutoCapture]");function By(e,t){return t.length>e?t.slice(0,e)+"...":t}function Tre(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!iC(t));return t}function Rre(e,t,n,s){var r=e.tagName.toLowerCase(),i={tag_name:r};Yk.indexOf(r)>-1&&!n&&(r.toLowerCase()==="a"||r.toLowerCase()==="button"?i.$el_text=By(1024,V5(e)):i.$el_text=By(1024,aC(e)));var a=lw(e);a.length>0&&(i.classes=a.filter(function(d){return d!==""})),es(e.attributes,function(d){var h;if((!H5(e)||["name","id","class","aria-label"].indexOf(d.name)!==-1)&&(s==null||!s.includes(d.name))&&!t&&mp(d.value)&&(h=d.name,!Qs(h)||h.substring(0,10)!=="_ngcontent"&&h.substring(0,7)!=="_nghost")){var f=d.value;d.name==="class"&&(f=JR(f).join(" ")),i["attr__"+d.name]=By(1024,f)}});for(var o=1,l=1,u=e;u=Tre(u);)o++,u.tagName===e.tagName&&l++;return i.nth_child=o,i.nth_of_type=l,i}function Are(e,t){for(var n,s,{e:r,maskAllElementAttributes:i,maskAllText:a,elementAttributeIgnoreList:o,elementsChainAsString:l}=t,u=[e],d=e;d.parentNode&&!nu(d,"body");)O5(d.parentNode)?(u.push(d.parentNode.host),d=d.parentNode.host):(u.push(d.parentNode),d=d.parentNode);var h,f=[],g={},v=!1,b=!1;if(es(u,S=>{var y=Xk(S);S.tagName.toLowerCase()==="a"&&(v=S.getAttribute("href"),v=y&&v&&mp(v)&&v),fn(lw(S),"ph-no-capture")&&(b=!0),f.push(Rre(S,i,a,o));var R=function(E){if(!Xk(E))return{};var F={};return es(E.attributes,function(A){if(A.name&&A.name.indexOf("data-ph-capture-attribute")===0){var I=A.name.replace("data-ph-capture-attribute-",""),P=A.value;I&&P&&mp(P)&&(F[I]=P)}}),F}(S);Os(g,R)}),b)return{props:{},explicitNoCapture:b};if(a||(e.tagName.toLowerCase()==="a"||e.tagName.toLowerCase()==="button"?f[0].$el_text=V5(e):f[0].$el_text=aC(e)),v){var x,w;f[0].attr__href=v;var _=(x=Uf(v))===null||x===void 0?void 0:x.host,C=Ue==null||(w=Ue.location)===null||w===void 0?void 0:w.host;_&&C&&_!==C&&(h=v)}return{props:Os({$event_type:r.type,$ce_version:1},l?{}:{$elements:f},{$elements_chain:yre(f)},(n=f[0])!==null&&n!==void 0&&n.$el_text?{$el_text:(s=f[0])===null||s===void 0?void 0:s.$el_text}:{},h&&r.type==="click"?{$external_click_url:h}:{},g)}}let Fre=class{constructor(t){bt(this,"_initialized",!1),bt(this,"_isDisabledServerSide",null),bt(this,"rageclicks",new $5),bt(this,"_elementsChainAsString",!1),this.instance=t,this._elementSelectors=null}get config(){var t,n,s=Fs(this.instance.config.autocapture)?this.instance.config.autocapture:{};return s.url_allowlist=(t=s.url_allowlist)===null||t===void 0?void 0:t.map(r=>new RegExp(r)),s.url_ignorelist=(n=s.url_ignorelist)===null||n===void 0?void 0:n.map(r=>new RegExp(r)),s}_addDomEventHandlers(){if(this.isBrowserSupported()){if(Ue&&It){var t=s=>{s=s||Ue?.event;try{this._captureEvent(s)}catch(r){gP.error("Failed to capture event",r)}};if(Bs(It,"submit",t,{capture:!0}),Bs(It,"change",t,{capture:!0}),Bs(It,"click",t,{capture:!0}),this.config.capture_copied_text){var n=s=>{s=s||Ue?.event,this._captureEvent(s,Ny)};Bs(It,"copy",n,{capture:!0}),Bs(It,"cut",n,{capture:!0})}}}else gP.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this._elementsChainAsString=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[eP]:!!t.autocapture_opt_out}),this._isDisabledServerSide=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this._elementSelectors=t}getElementSelectors(t){var n,s=[];return(n=this._elementSelectors)===null||n===void 0||n.forEach(r=>{var i=It?.querySelectorAll(r);i?.forEach(a=>{t===a&&s.push(r)})}),s}get isEnabled(){var t,n,s=(t=this.instance.persistence)===null||t===void 0?void 0:t.props[eP],r=this._isDisabledServerSide;if(Eu(r)&&!Ll(s)&&!this.instance.config.advanced_disable_decide)return!1;var i=(n=this._isDisabledServerSide)!==null&&n!==void 0?n:!!s;return!!this.instance.config.autocapture&&!i}_captureEvent(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"$autocapture";if(this.isEnabled){var s,r=B5(t);M5(r)&&(r=r.parentNode||null),n==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&this.instance.config.rageclick&&(s=this.rageclicks)!==null&&s!==void 0&&s.isRageClick(t.clientX,t.clientY,new Date().getTime())&&this._captureEvent(t,"$rageclick");var i=n===Ny;if(r&&bre(r,t,this.config,i,i?["copy","cut"]:void 0)){var{props:a,explicitNoCapture:o}=Are(r,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(o)return!1;var l=this.getElementSelectors(r);if(l&&l.length>0&&(a.$element_selectors=l),n===Ny){var u,d=L5(Ue==null||(u=Ue.getSelection())===null||u===void 0?void 0:u.toString()),h=t.type||"clipboard";if(!d)return!1;a.$selected_content=d,a.$copy_type=h}return this.instance.capture(n,a),!0}}}isBrowserSupported(){return lo(It?.querySelectorAll)}};Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return gi(e)&&isFinite(e)&&Math.floor(e)===e});var mP="0123456789abcdef";let Dre=class Qk{constructor(t){if(this.bytes=t,t.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,n,s,r){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(s)||!Number.isInteger(r)||t<0||n<0||s<0||r<0||t>0xffffffffffff||n>4095||s>1073741823||r>4294967295)throw new RangeError("invalid field value");var i=new Uint8Array(16);return i[0]=t/Math.pow(2,40),i[1]=t/Math.pow(2,32),i[2]=t/Math.pow(2,24),i[3]=t/Math.pow(2,16),i[4]=t/Math.pow(2,8),i[5]=t,i[6]=112|n>>>8,i[7]=n,i[8]=128|s>>>24,i[9]=s>>>16,i[10]=s>>>8,i[11]=s,i[12]=r>>>24,i[13]=r>>>16,i[14]=r>>>8,i[15]=r,new Qk(i)}toString(){for(var t="",n=0;n<this.bytes.length;n++)t=t+mP.charAt(this.bytes[n]>>>4)+mP.charAt(15&this.bytes[n]),n!==3&&n!==5&&n!==7&&n!==9||(t+="-");if(t.length!==36)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new Qk(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(var n=0;n<16;n++){var s=this.bytes[n]-t.bytes[n];if(s!==0)return Math.sign(s)}return 0}},Ire=class{constructor(){bt(this,"timestamp",0),bt(this,"counter",0),bt(this,"random",new Pre)}generate(){var t=this.generateOrAbort();if(At(t)){this.timestamp=0;var n=this.generateOrAbort();if(At(n))throw new Error("Could not generate UUID after timestamp reset");return n}return t}generateOrAbort(){var t=Date.now();if(t>this.timestamp)this.timestamp=t,this.resetCounter();else{if(!(t+1e4>this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return Dre.fromFieldsV7(this.timestamp,Math.trunc(this.counter/Math.pow(2,30)),this.counter&Math.pow(2,30)-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}};var vP,z5=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};Ue&&!At(Ue.crypto)&&crypto.getRandomValues&&(z5=e=>crypto.getRandomValues(e));let Pre=class{constructor(){bt(this,"buffer",new Uint32Array(8)),bt(this,"cursor",1/0)}nextUint32(){return this.cursor>=this.buffer.length&&(z5(this.buffer),this.cursor=0),this.buffer[this.cursor++]}};var qc=()=>Nre().toString(),Nre=()=>(vP||(vP=new Ire)).generate(),Mre="Thu, 01 Jan 1970 00:00:00 GMT",yg="",Ore=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function Lre(e,t){if(t){var n=function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:It;if(yg)return yg;if(!i||["localhost","127.0.0.1"].includes(r))return"";for(var a=r.split("."),o=Math.min(a.length,8),l="dmn_chk_"+qc(),u=new RegExp("(^|;)\\s*"+l+"=1");!yg&&o--;){var d=a.slice(o).join("."),h=l+"=1;domain=."+d;i.cookie=h,u.test(i.cookie)&&(i.cookie=h+";expires="+Mre,yg=d)}return yg}(e);if(!n){var s=(r=>{var i=r.match(Ore);return i?i[0]:""})(e);s!==n&&Lt.info("Warning: cookie subdomain discovery mismatch",s,n),n=s}return n?"; domain=."+n:""}return""}var jc,$l={is_supported:()=>!!It,error:function(e){Lt.error("cookieStore error: "+e)},get:function(e){if(It){try{for(var t=e+"=",n=It.cookie.split(";").filter(i=>i.length),s=0;s<n.length;s++){for(var r=n[s];r.charAt(0)==" ";)r=r.substring(1,r.length);if(r.indexOf(t)===0)return decodeURIComponent(r.substring(t.length,r.length))}}catch{}return null}},parse:function(e){var t;try{t=JSON.parse($l.get(e))||{}}catch{}return t},set:function(e,t,n,s,r){if(It)try{var i="",a="",o=Lre(It.location.hostname,s);if(n){var l=new Date;l.setTime(l.getTime()+24*n*60*60*1e3),i="; expires="+l.toUTCString()}r&&(a="; secure");var u=e+"="+encodeURIComponent(JSON.stringify(t))+i+"; SameSite=Lax; path=/"+o+a;return u.length>3686.4&&Lt.warn("cookieStore warning: large cookie, len="+u.length),It.cookie=u,u}catch{return}},remove:function(e,t){try{$l.set(e,"",-1,t)}catch{return}}},jy=null,Zs={is_supported:function(){if(!Eu(jy))return jy;var e=!0;if(At(Ue))e=!1;else try{var t="__mplssupport__";Zs.set(t,"xyz"),Zs.get(t)!=='"xyz"'&&(e=!1),Zs.remove(t)}catch{e=!1}return e||Lt.error("localStorage unsupported; falling back to cookie store"),jy=e,e},error:function(e){Lt.error("localStorage error: "+e)},get:function(e){try{return Ue?.localStorage.getItem(e)}catch(t){Zs.error(t)}return null},parse:function(e){try{return JSON.parse(Zs.get(e))||{}}catch{}return null},set:function(e,t){try{Ue?.localStorage.setItem(e,JSON.stringify(t))}catch(n){Zs.error(n)}},remove:function(e){try{Ue?.localStorage.removeItem(e)}catch(t){Zs.error(t)}}},Bre=["distinct_id",iw,sm,ow,Kk],ub=ze(ze({},Zs),{},{parse:function(e){try{var t={};try{t=$l.parse(e)||{}}catch{}var n=Os(t,JSON.parse(Zs.get(e)||"{}"));return Zs.set(e,n),n}catch{}return null},set:function(e,t,n,s,r,i){try{Zs.set(e,t,void 0,void 0,i);var a={};Bre.forEach(o=>{t[o]&&(a[o]=t[o])}),Object.keys(a).length&&$l.set(e,a,n,s,r,i)}catch(o){Zs.error(o)}},remove:function(e,t){try{Ue?.localStorage.removeItem(e),$l.remove(e,t)}catch(n){Zs.error(n)}}}),db={},jre={is_supported:function(){return!0},error:function(e){Lt.error("memoryStorage error: "+e)},get:function(e){return db[e]||null},parse:function(e){return db[e]||null},set:function(e,t){db[e]=t},remove:function(e){delete db[e]}},sd=null,Tr={is_supported:function(){if(!Eu(sd))return sd;if(sd=!0,At(Ue))sd=!1;else try{var e="__support__";Tr.set(e,"xyz"),Tr.get(e)!=='"xyz"'&&(sd=!1),Tr.remove(e)}catch{sd=!1}return sd},error:function(e){Lt.error("sessionStorage error: ",e)},get:function(e){try{return Ue?.sessionStorage.getItem(e)}catch(t){Tr.error(t)}return null},parse:function(e){try{return JSON.parse(Tr.get(e))||null}catch{}return null},set:function(e,t){try{Ue?.sessionStorage.setItem(e,JSON.stringify(t))}catch(n){Tr.error(n)}},remove:function(e){try{Ue?.sessionStorage.removeItem(e)}catch(t){Tr.error(t)}}};(function(e){e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED"})(jc||(jc={}));let Hre=class{constructor(t){this.instance=t}get config(){return this.instance.config}get consent(){return this.getDnt()?jc.DENIED:this.storedConsent}isOptedOut(){return this.consent===jc.DENIED||this.consent===jc.PENDING&&this.config.opt_out_capturing_by_default}isOptedIn(){return!this.isOptedOut()}optInOut(t){this.storage.set(this.storageKey,t?1:0,this.config.cookie_expiration,this.config.cross_subdomain_cookie,this.config.secure_cookie)}reset(){this.storage.remove(this.storageKey,this.config.cross_subdomain_cookie)}get storageKey(){var{token:t,opt_out_capturing_cookie_prefix:n}=this.instance.config;return(n||"__ph_opt_in_out_")+t}get storedConsent(){var t=this.storage.get(this.storageKey);return t==="1"?jc.GRANTED:t==="0"?jc.DENIED:jc.PENDING}get storage(){if(!this._storage){var t=this.config.opt_out_capturing_persistence_type;this._storage=t==="localStorage"?Zs:$l;var n=t==="localStorage"?$l:Zs;n.get(this.storageKey)&&(this._storage.get(this.storageKey)||this.optInOut(n.get(this.storageKey)==="1"),n.remove(this.storageKey,this.config.cross_subdomain_cookie))}return this._storage}getDnt(){return!!this.config.respect_dnt&&!!D5([Zi?.doNotTrack,Zi?.msDoNotTrack,Zt.doNotTrack],t=>fn([!0,1,"1","yes"],t))}};var hb=Zr("[Dead Clicks]"),Ure=()=>!0,Gre=e=>{var t,n=!((t=e.instance.persistence)===null||t===void 0||!t.get_property(P5)),s=e.instance.config.capture_dead_clicks;return Ll(s)?s:n};let q5=class{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(t,n,s){this.instance=t,this.isEnabled=n,this.onCapture=s,this.startIfEnabled()}onRemoteConfig(t){this.instance.persistence&&this.instance.persistence.register({[P5]:t?.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.loadScript(()=>{this.start()})}loadScript(t){var n,s,r;(n=Zt.__PosthogExtensions__)!==null&&n!==void 0&&n.initDeadClicksAutocapture&&t(),(s=Zt.__PosthogExtensions__)===null||s===void 0||(r=s.loadExternalDependency)===null||r===void 0||r.call(s,this.instance,"dead-clicks-autocapture",i=>{i?hb.error("failed to load script",i):t()})}start(){var t;if(It){if(!this._lazyLoadedDeadClicksAutocapture&&(t=Zt.__PosthogExtensions__)!==null&&t!==void 0&&t.initDeadClicksAutocapture){var n=Fs(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};n.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=Zt.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this._lazyLoadedDeadClicksAutocapture.start(It),hb.info("starting...")}}else hb.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,hb.info("stopping..."))}};var Hy=Zr("[ExceptionAutocapture]");let Vre=class{constructor(t){var n;bt(this,"startCapturing",()=>{var s;if(Ue&&this.isEnabled&&(s=Zt.__PosthogExtensions__)!==null&&s!==void 0&&s.errorWrappingFunctions){var r=Zt.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Zt.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=Zt.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.unwrapOnError&&this.config.capture_unhandled_errors&&(this.unwrapOnError=r(this.captureException.bind(this))),!this.unwrapUnhandledRejection&&this.config.capture_unhandled_rejections&&(this.unwrapUnhandledRejection=i(this.captureException.bind(this))),!this.unwrapConsoleError&&this.config.capture_console_errors&&(this.unwrapConsoleError=a(this.captureException.bind(this)))}catch(o){Hy.error("failed to start",o),this.stopCapturing()}}}),this.instance=t,this.remoteEnabled=!((n=this.instance.persistence)===null||n===void 0||!n.props[tP]),this.config=this.requiredConfig(),this.startIfEnabled()}requiredConfig(){var t=this.instance.config.capture_exceptions,n={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Fs(t)?n=ze(ze({},n),t):(At(t)?this.remoteEnabled:t)&&(n=ze(ze({},n),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),n}get isEnabled(){return this.config.capture_console_errors||this.config.capture_unhandled_errors||this.config.capture_unhandled_rejections}startIfEnabled(){this.isEnabled&&(Hy.info("enabled"),this.loadScript(this.startCapturing))}loadScript(t){var n,s,r;(n=Zt.__PosthogExtensions__)!==null&&n!==void 0&&n.errorWrappingFunctions&&t(),(s=Zt.__PosthogExtensions__)===null||s===void 0||(r=s.loadExternalDependency)===null||r===void 0||r.call(s,this.instance,"exception-autocapture",i=>{if(i)return Hy.error("failed to load script",i);t()})}stopCapturing(){var t,n,s;(t=this.unwrapOnError)===null||t===void 0||t.call(this),this.unwrapOnError=void 0,(n=this.unwrapUnhandledRejection)===null||n===void 0||n.call(this),this.unwrapUnhandledRejection=void 0,(s=this.unwrapConsoleError)===null||s===void 0||s.call(this),this.unwrapConsoleError=void 0}onRemoteConfig(t){var n=t.autocaptureExceptions;this.remoteEnabled=!!n||!1,this.config=this.requiredConfig(),this.instance.persistence&&this.instance.persistence.register({[tP]:this.remoteEnabled}),this.startIfEnabled()}captureException(t){var n=this.instance.requestRouter.endpointFor("ui");t.$exception_personURL="".concat(n,"/project/").concat(this.instance.config.token,"/person/").concat(this.instance.get_distinct_id()),this.instance.exceptions.sendExceptionEvent(t)}};function K5(e){return!At(Event)&&Y5(e,Event)}function Y5(e,t){try{return e instanceof t}catch{return!1}}function xx(e,t){return Object.prototype.toString.call(e)==="[object ".concat(t,"]")}function Uy(e){return xx(e,"DOMError")}var bP=/\(error: (.*)\)/,xP=50,Pf="?";function Gy(e,t,n,s){var r={platform:"web:javascript",filename:e,function:t==="<anonymous>"?Pf:t,in_app:!0};return At(n)||(r.lineno=n),At(s)||(r.colno=s),r}var Wre=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,$re=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,zre=/\((\S*)(?::(\d+))(?::(\d+))\)/,qre=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Kre=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Yre=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var s=t.sort((r,i)=>r[0]-i[0]).map(r=>r[1]);return function(r){for(var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=[],o=r.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./agent-details-page-BWNrXmxX.js","./index-DZ0oVvBQ.js","./messages-DbS1PwZU.js","./index-DLDgY5fY.css","./publication-validation-DLOlkolO.js","./path-utils-CwYffJ73.js","./conversation-input-sync-DxHw4wST.js","./error-boundary-vmQ5tlCX.js","./conversation-input-sync-CAX4_ErH.css","./use-download-agent-mutation-DBqvJdZO.js","./en-US-CHJkXXr4.js","./book-open-CnrMa_Lj.js","./heart-DpdW9OuA.js","./console-mirror-Biqf_qft.js","./console-mirror-DOrYoP_4.css","./agent-hub-page-Cka41wII.js","./page-header-CdCjG9NV.js","./org-access-VMhAoXqY.js","./radient-auth-buttons-Iuc5eVp5.js","./format-esAOn2VS.js","./org-surface-gate-CGfGEFG5.js","./building-2-KNn69NZT.js","./agents-page-B10LHSJd.js","./schedules-page-Bn3e8WY7.js","./parseISO-BHJWTxrA.js","./projects-page-qWSJC9oD.js","./use-session-snapshot-DoZQzNKC.js","./library-page-C4z59b5g.js","./hash-L2ujAC5o.js","./team-bridge-page-BSwTmi7d.js","./browser-page-aNCnBYZQ.js","./mesh-page-CY-Frpsh.js","./settings-page-DrhoPGFS.js","./notebook-pen-CMhgSRMw.js","./browser-webauthn-prompt-CHrTpdBn.js"])))=>i.map(i=>d[i]);
2
+ import{r as m,j as c,c as T,b as nt,h as RD,p as FK,z as DK,o as IK,A as PK,u as Wc,B as NK,C as MK,E as OK,F as ck,a as LK,R as BK}from"./index-DZ0oVvBQ.js";import{u as Qe,c as pt,e as yu,S as An,p as mo,B as le,L as xr,I as ks,T as xR,g as Us,X as Yn,ad as uk,ak as jK,D as lc,a as cc,d as rl,y as Di,x as mi,o as Up,h as fp,aj as dv,l as gt,a0 as Gp,b as P_,A as Kr,f as N_,F as i0,G as a0,H as o0,J as l0,K as c0,q as La,r as sa,s as Ba,t as dk,v as Js,w as Ot,al as hv,z as Sa,a8 as zx,am as py,a5 as Uj,Y as Gj,Z as Vj,_ as hk,k as ux,ai as HK,a1 as Qd,a2 as M_,a3 as ou,an as Bf,ao as UK,M as qx,i as Wj,ap as GK,j as $j,aq as VK,ar as AD,a4 as WK,ag as fk,C as $K,as as _g,at as wR,N as _R,$ as zK,aa as qK,ab as KK,ac as YK,a6 as XK,a7 as QK,ae as JK,af as ZK,au as eY,av as tY,aw as zj,m as FD,n as DD,ax as vd,E as nY}from"./error-boundary-vmQ5tlCX.js";import{az as sY,aA as pk,aB as rY,a7 as qj,u as Gt,aC as iY,aD as aY,aE as oY,aF as lY,aG as cY,aH as uY,aI as ID,aJ as PD,aK as dY,aL as hY,q as De,aM as fY,aN as gk,aO as O_,aP as dd,h as Nn,a as ns,c as Et,e as fv,B as Kj,A as xi,T as Yj,aQ as Ja,a0 as Vp,a4 as Xj,d as at,aR as ND,aS as gy,aT as Qj,aU as mk,aj as vk,aV as pY,D as Li,y as qo,r as pv,aW as Af,aX as Jj,aY as gY,g as Ni,aZ as my,a_ as gv,a3 as il,x as st,a$ as Zj,b0 as e6,b1 as L_,b2 as bk,b3 as mY,S as Pd,b4 as t6,b5 as vY,b6 as bY,b7 as xY,K as lu,b8 as wY,I as CR,G as mv,b9 as vy,ba as Gn,bb as xk,bc as MD,bd as wk,H as _Y,be as CY,bf as yY,bg as SY,f as n6,bh as kY,bi as EY,bj as TY,O as Yr,bk as Vl,av as B_,b as s6,bl as OD,bm as RY,bn as LD,bo as AY,bp as yR,a2 as FY,bq as DY,br as IY,bs as PY,bt as NY,bu as BD,o as SR,bv as r6,bw as MY,bx as jD,by as j_,bz as OY,bA as LY,bB as BY,bC as jY,bD as HY,bE as i6,bF as by,bG as em,bH as UY,bI as a6,bJ as GY,bK as HD,bL as UD,bM as dx,bN as hx,bO as _k,Y as kR,bP as o6,bQ as VY,X as WY,W as $Y,bR as zY,bS as GD,bT as qY,bU as nd,bV as nb,bW as KY,bX as YY,bY as XY,bZ as VD,b_ as WD,b$ as QY,c0 as JY,c1 as ZY,c2 as eX,c3 as $D,c4 as zD,c5 as qD,c6 as KD,c7 as tX,c8 as nX,c9 as sX,ca as rX,cb as iX,cc as YD,cd as aX,ce as oX,cf as lX,cg as Kx,ch as cX,ci as XD,cj as uX,ck as dX,cl as hX,cm as fX,cn as sb,co as pX,cp as gX,cq as l6,cr as mX,Z as ER,ay as QD,cs as vX,ct as bX,cu as xX,ax as wX,cv as JD,n as ZD,cw as xm,cx as _X,cy as CX,cz as yX,cA as SX,cB as rb,cC as kX,cD as ib,cE as eI,cF as EX,cG as TX,cH as ab,cI as ob,cJ as tI,cK as nI,cL as RX,cM as fx,s as Yx,t as c6,v as AX,cN as Ck,cO as FX,cP as DX,cQ as IX,cR as PX,cS as NX,cT as MX,cU as OX,cV as LX,cW as u6,cX as BX,V as vv,cY as jX,cZ as TR,a1 as HX,c_ as UX,c$ as GX,$ as VX,d0 as WX,d1 as $X,d2 as sI,d3 as xy,d4 as rI,d5 as zX,d6 as qX,d7 as KX,d8 as YX,d9 as XX,da as QX,db as iI,U as JX,dc as ZX,dd as eQ,de as tQ,df as nQ,w as sQ,dg as rQ,_ as iQ,dh as d6,di as aQ,dj as oQ,dk as lQ,dl as cQ,aw as uQ,a6 as qe,ad as aI,dm as dQ,dn as hQ,dp as wy,dq as u0,ac as fQ,dr as oI,ds as pQ,dt as yr,Q as lI,du as gQ,dv as cI,dw as mQ,dx as h6,dy as uI,dz as vQ}from"./path-utils-CwYffJ73.js";import{c7 as px,bg as Zc,c5 as oo,bo as RR,a3 as Ua,a4 as Gs,T as sn,aq as Mn,ar as Is,S as Su,av as bv,c8 as bQ,aw as xv,dB as f6,dC as xQ,dD as d0,dE as wQ,dF as _Q,dG as CQ,dH as yQ,dI as _y,dJ as Cy,bZ as $c,bK as H_,cB as ku,cm as gx,cl as SQ,ck as dr,cn as _n,dK as p6,dL as kQ,dM as yk,ax as _h,dN as AR,ct as U_,cS as EQ,dO as dI,dP as TQ,dQ as RQ,dR as Sk,dS as AQ,dT as FQ,dU as DQ,dV as IQ,dW as Xx,Y as Qx,ah as jf,dX as hI,dY as fI,dZ as PQ,d_ as NQ,d$ as MQ,e0 as g6,e1 as OQ,e2 as LQ,e3 as m6,e4 as G_,e5 as V_,e6 as BQ,e7 as jQ,e8 as HQ,e9 as pI,ea as UQ,eb as GQ,ec as VQ,ed as WQ,ee as $Q,ef as zQ,eg as qQ,eh as KQ,bW as v6,ei as YQ,ej as b6,ek as XQ,el as gI,em as QQ,en as JQ,bT as qr,eo as h0,ep as x6,eq as ZQ,er as eJ,es as mI,et as tJ,eu as nJ,ev as sJ,ew as rJ,ex as iJ,b1 as w6,ey as wm,ez as _6,eA as aJ,eB as oJ,eC as lJ,eD as cJ,eE as uJ,eF as dJ,eG as hJ,be as cu,eH as uu,eI as fJ,a0 as FR,eJ as vI,eK as pJ,eL as gJ,eM as mJ,eN as vJ,eO as bJ,eP as xJ,eQ as xf,cK as wJ,eR as _J,eS as CJ,cN as yJ,eT as SJ,eU as kJ,eV as C6,bL as yy,eW as DR,az as y6,eX as W_,eY as EJ,b4 as kk,at as IR,eZ as S6,aA as Wl,e_ as k6,bc as Jd,bN as $_,e$ as TJ,f0 as RJ,bk as du,bP as z_,f1 as bI,f2 as AJ,f3 as FJ,f4 as DJ,f5 as IJ,f6 as PJ,f7 as NJ,f8 as MJ,f9 as OJ,fa as LJ,fb as xI,fc as BJ,fd as jJ,fe as PR,ff as wI,cP as HJ,fg as UJ,fh as E6,fi as GJ,fj as VJ,fk as T6,fl as Ek,fm as WJ,fn as Hf,fo as Wp,fp as $J,fq as _I,fr as zJ,bQ as q_,fs as qJ,ft as R6,fu as A6,fv as KJ,fw as F6,fx as Jx,fy as YJ,fz as XJ,fA as QJ,fB as JJ,fC as ZJ,fD as eZ,fE as tZ,ad as _s,fF as nZ,ac as zc,fG as D6,fH as sZ,fI as rZ,fJ as NR,fK as iZ,bV as I6,cc as K_,cf as Y_,fL as X_,fM as Ga,fN as aZ,fO as $n,fP as pn,fQ as wv,fR as f0,fS as Q_,fT as MR,fU as J_,fV as oZ,fW as lZ,fX as cZ,fY as Rn,fZ as p0,f_ as P6,f$ as ka,g0 as Zd,g1 as uZ,g2 as N6,g3 as M6,g4 as OR,g5 as Zx,g6 as O6,K as LR,g7 as Tk,g8 as BR,g9 as Sy,ga as dZ,gb as hZ,gc as fZ,gd as Ff,ge as Rk,gf as L6,gg as pZ,gh as B6,gi as gZ,gj as mZ,gk as vZ,gl as bZ,gm as xZ,gn as wZ,go as _Z,gp as CZ,gq as yZ,gr as SZ,gs as ew,gt as kZ,gu as EZ,gv as TZ,gw as RZ,gx as AZ,gy as FZ,gz as jR,gA as DZ,gB as j6,v as ht,gC as IZ,gD as Z_,gE as eh,bn as H6,bq as PZ,gF as CI,aZ as U6,gG as NZ,gH as MZ,gI as OZ,gJ as LZ,gK as BZ,gL as jZ,gM as HZ,gN as UZ,af as Er,gO as GZ,gP as VZ,gQ as WZ,gR as $Z,gS as zZ,gT as qZ,gU as KZ,gV as YZ,gW as XZ,gX as G6,gY as QZ,gZ as JZ,g_ as g0,g$ as V6,h0 as tw,h1 as pp,h2 as eC,h3 as HR,h4 as ZZ,h5 as eee,h6 as tee,h7 as W6,h8 as nee,h9 as yI,ha as see,hb as UR,hc as ree,hd as GR,he as _v,hf as Cv,hg as iee,hh as $6,hi as m0,hj as aee,hk as oee,hl as lee,hm as cee,hn as uee,ho as dee,hp as SI,hq as z6,bH as q6,hr as hee,hs as fee,ht as pee,hu as gee,bv as mee,hv as kI,hw as vee,hx as bee,hy as K6,hz as xee,hA as Hl,hB as EI,hC as _m,hD as Cg,hE as wee,hF as TI,hG as RI,hH as _ee,hI as Y6,bb as Cm,hJ as Cee,hK as yee,hL as tC,ci as See,as as $p,hM as kee,hN as Ak,hO as Eee,hP as Tee,hQ as VR,bw as Ree,hR as Aee,hS as eu,hT as WR,hU as $R,hV as Fee,b7 as Dee,b8 as nC,hW as Iee,b6 as gp,cj as ky,hX as Pee,hY as Nee,hZ as Mee,h_ as Oee,h$ as Lee,i0 as Bee,i1 as jee,i2 as Al,i3 as AI,i4 as Hee,bl as Uee,i5 as Gee,i6 as Vee,i7 as Wee,i8 as $ee,i9 as zee,ia as qee,ib as Fk,bx as Kee,by as FI,c3 as wf,ic as Yee,bA as Xee,bU as Qee,id as Jee,ie as X6,bI as Zee,ig as ete,c0 as tte,ih as nte,ii as ste,ij as rte,ik as ite,cA as ate,bJ as ote,il as lte,im as cte,io as lb,ip as Q6,cx as ute,iq as Nd,d9 as J6,da as zR,ir as dte,is as hte,it as fte,iu as Z6,bF as pte,iv as gte,ai as e5,d8 as mte,iw as vte,bj as t5,ix as bte,iy as xte,iz as wte,iA as _te,iB as Cte,iC as yte,a_ as Ey,a$ as Ty,b0 as Ry,ag as Ste,iD as kte,iE as Ete,iF as Tte,c2 as Zh,iG as ef,iH as Rte,iI as Ate,iJ as n5,iK as Fte,iL as s5,iM as Dk,iN as Ik,iO as Ay,iP as Dte,iQ as Ite,iR as _f,iS as Pte,_ as DI,iT as II,iU as r5,iV as Pk,iW as i5,iX as a5,iY as Nte,iZ as Mte,i_ as Ote,i$ as Lte,j0 as Bte,j1 as jte,j2 as Hte,j3 as Ute,j4 as Gte,j5 as Vte,j6 as Wte,j7 as $te,j8 as zte,j9 as qte,ja as Kte,jb as Yte,jc as Xte,jd as Qte,je as Jte,jf as PI,jg as Zte,jh as ene,ji as tne,jj as nne,jk as sne,jl as rne,jm as ine,jn as ane,jo as one,a7 as lne,a8 as cne,a9 as une,aa as dne,ab as hne,jp as fne,jq as pne,jr as gne,js as NI,cO as o5,jt as qR,ju as mne,ay as l5,jv as c5,jw as vne,jx as bne,jy as xne,jz as Hr,jA as wne,jB as Nc,jC as u5,jD as d5,jE as h5,jF as KR,jG as Ki,jH as _ne,jI as Cne,jJ as yne,jK as Sne,jL as kne,jM as Ene,jN as Tne,jO as Rne,jP as Ane,jQ as Fne,jR as f5,jS as Dne,jT as Ine,jU as Pne,jV as Nne,jW as Mne,jX as Nk,jY as One,jZ as Lne,j_ as MI,j$ as p5,k0 as Bne,k1 as jne,k2 as Hne,k3 as OI,k4 as Une,k5 as Gne,k6 as Vne,k7 as Wne,k8 as $ne,k9 as zne,ka as qne,kb as Kne,kc as g5,kd as Yne,ke as Xne,cz as nw,kf as Qne,kg as LI,kh as Jne,ki as Zne,bf as wi,ap as YR,kj as m5,kk as v5,kl as v0,km as ese,kn as BI,ko as tse,cF as nse,cU as sse,kp as rse,kq as ise,kr as ase,cT as jI,ks as ose,a1 as lse,bd as Va,kt as cse,ku as use,kv as dse,kw as hse,kx as tf,ky as fse,kz as pse,kA as sw,kB as gse,kC as mse,kD as Fy,kE as Dy,kF as HI,kG as Iy,kH as UI,kI as b5,ao as vse,kJ as x5,kK as bse,al as xse,am as wse,aj as _se,ak as Cse,kL as yse,an as Sse}from"./conversation-input-sync-DxHw4wST.js";import{t as p,c as GI,L as Yo,b as kse}from"./messages-DbS1PwZU.js";import{u as w5,b as Ese,c as Tse,r as _5,d as C5,e as b0,f as Rse,g as Ase,o as zp,s as XR,n as Mk,h as Fse,i as Dse,p as Ise,j as Pse,k as Nse,l as Mse,q as Ose,v as Lse,w as VI,x as WI,y as Bse,z as jse,A as Hse,C as Use,B as Gse,D as Vse,E as Wse,F as $se,G as zse,H as qse}from"./console-mirror-Biqf_qft.js";function $I(e,t){return e.filter(n=>!t.includes(n))}function Kse(e,t,n){const s=e.slice(0);return s[t]=n,s}var Yse=class extends sY{#s;#e;#r;#i;#t;#n;#a;#o;#l=[];constructor(e,t,n){super(),this.#s=e,this.#i=n,this.#r=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(t=>{this.#h(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,t){this.#r=e,this.#i=t,pk.batch(()=>{const n=this.#t,s=this.#d(this.#r);this.#l=s,s.forEach(o=>o.observer.setOptions(o.defaultedQueryOptions));const r=s.map(o=>o.observer),i=r.map(o=>o.getCurrentResult()),a=r.some((o,l)=>o!==n[l]);n.length===r.length&&!a||(this.#t=r,this.#e=i,this.hasListeners()&&($I(n,r).forEach(o=>{o.destroy()}),$I(r,n).forEach(o=>{o.subscribe(l=>{this.#h(o,l)})}),this.#f()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const n=this.#d(e),s=n.map(r=>r.observer.getOptimisticResult(r.defaultedQueryOptions));return[s,r=>this.#u(r??s,t),()=>this.#c(s,n)]}#c(e,t){return t.map((n,s)=>{const r=e[s];return n.defaultedQueryOptions.notifyOnChangeProps?r:n.observer.trackResult(r,i=>{t.forEach(a=>{a.observer.trackProp(i)})})})}#u(e,t){return t?((!this.#n||this.#e!==this.#o||t!==this.#a)&&(this.#a=t,this.#o=this.#e,this.#n=rY(this.#n,t(e))),this.#n):e}#d(e){const t=new Map(this.#t.map(s=>[s.options.queryHash,s])),n=[];return e.forEach(s=>{const r=this.#s.defaultQueryOptions(s),i=t.get(r.queryHash);i?n.push({defaultedQueryOptions:r,observer:i}):n.push({defaultedQueryOptions:r,observer:new qj(this.#s,r)})}),n}#h(e,t){const n=this.#t.indexOf(e);n!==-1&&(this.#e=Kse(this.#e,n,t),this.#f())}#f(){if(this.hasListeners()){const e=this.#n,t=this.#c(this.#e,this.#l),n=this.#u(t,this.#i?.combine);e!==n&&pk.batch(()=>{this.listeners.forEach(s=>{s(this.#e)})})}}};function y5({queries:e,...t},n){const s=Gt(n),r=iY(),i=aY(),a=m.useMemo(()=>e.map(b=>{const x=s.defaultQueryOptions(b);return x._optimisticResults=r?"isRestoring":"optimistic",x}),[e,s,r]);a.forEach(b=>{oY(b),lY(b,i)}),cY(i);const[o]=m.useState(()=>new Yse(s,a,t)),[l,u,d]=o.getOptimisticResult(a,t.combine),h=!r&&t.subscribed!==!1;m.useSyncExternalStore(m.useCallback(b=>h?o.subscribe(pk.batchCalls(b)):uY,[o,h]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),m.useEffect(()=>{o.setQueries(a,t)},[a,t,o]);const g=l.some((b,x)=>ID(a[x],b))?l.flatMap((b,x)=>{const w=a[x];if(w){const _=new qj(s,w);if(ID(w,b))return PD(w,_,i);dY(b,r)&&PD(w,_,i)}return[]}):[];if(g.length>0)throw Promise.all(g);const v=l.find((b,x)=>{const w=a[x];return w&&hY({result:b,errorResetBoundary:i,throwOnError:w.throwOnError,query:s.getQueryCache().get(w.queryHash),suspense:w.suspense})});if(v?.error)throw v.error;return u(d())}const Ok=8e3,S5=1e4;function Xse(e){return e?`“${e}”`:"Conversation"}const Qse="archived.";function Jse(e){return De.getState().archiveFacts[e]}function Zse(e){const t=De.getState(),n=t.archiveFacts[e];return n?n.archived:t.sessions.find(s=>s.session_id===e)?.archived}function ere(){const e=De(t=>t.archiveUndo);m.useEffect(()=>{if(e===null)return;let t=!1;const n=()=>{t||(t=!0,r())},s=()=>{n();const i=De.getState().archiveUndo;i!==null&&i.sessionId===e.sessionId&&i.at===e.at&&De.getState().setArchiveUndo(null)},r=De.subscribe(()=>{const i=Jse(e.sessionId);i!==void 0&&!i.answered||fY(e.archived,Zse(e.sessionId))||s()});return n},[e])}function tre(e){return e===1?"Draft":`${e} drafts`}const nre="discarded.",sre=e=>{const t=gk(e),n=t.length,s=t.filter(o=>!o.active).length,r=n===1?"chat":"chats",i=e.filter(o=>O_(o)!==null&&gk([o]).length===0).length,a=[`Mark ${n} unread ${r} as read${s>0?`, including ${s} in Previous chats`:""}.`];return i>0&&a.push(`${i} unread ${i===1?"mark":"marks"} with no completion token cannot be cleared.`),{count:n,label:`Mark all ${n} read`,scope:a.join(" "),nameSuffix:s>0?`, including ${s} in Previous chats`:""}},k5=e=>e===1?"1 lives on another device and clears when that device updates.":`${e} live on other devices and clear when those devices update.`,rre=e=>{if(e.attempted===0)return{tone:"success",message:"Nothing to clear."};const t=e.unknown-e.deferred,n=[e.superseded>0?`${e.superseded} ${e.superseded===1?"has a newer result and stays":"have newer results and stay"} unread.`:null,t>0?`${t} could not be cleared and ${t===1?"stays":"stay"} unread.`:null,e.deferred>0?k5(e.deferred):null].filter(s=>s!==null);return e.cleared===0?{tone:"warning",message:["Nothing was cleared.",...n].join(" ")}:{tone:"success",message:[`Marked ${e.cleared} ${e.cleared===1?"chat":"chats"} as read.`,...n].join(" ")}},Py="archive",zI="drafts-undo",qI="bulk-read-deferral",ire=8e3;function are(){Qe();const e=De(f=>f.archiveFailure),t=De(f=>f.archiveUndo),n=De(f=>f.draftsUndo),s=De(f=>f.bulkReadDeferral),r=De(f=>f.clearArchiveFailure),i=De(f=>f.setArchiveUndo),a=De(f=>f.setSessionArchived),o=De(f=>f.restoreDraftsUndo);ere();const l=dd(e?.title),u=m.useRef(null);m.useEffect(()=>{if(e===null&&t===null){if(u.current===null)return;u.current=null,px(Py);return}const f=e&&t?t.at>e.at?"offer":"failure":e?"failure":"offer",g=f==="offer"?t?.at??0:e?.at??0,v=u.current;u.current={kind:f,at:g},v!==null&&v.kind!==f&&g>v.at&&(f==="failure"?i(null):r());const b=(x,w)=>()=>{const _=De.getState();x==="offer"?_.archiveUndo?.at===w&&_.setArchiveUndo(null):_.archiveFailure?.at===w&&_.clearArchiveFailure();const C=u.current;C!==null&&C.kind===x&&C.at===w&&(u.current=null)};if(f==="failure"&&e){Zc(`Could not ${e.archived?"archive":"unarchive"} “${l}”.${e.detail?` ${e.detail}`:""}`,{id:Py,duration:S5,onAutoClose:b("failure",e.at),onDismiss:b("failure",e.at),action:{label:"Retry",onClick:x=>{x.preventDefault(),a(e.sessionId,e.archived,e.title)}}});return}t&&oo(c.jsxs("span",{className:T("flex min-w-0 items-baseline gap-1"),children:[c.jsx("span",{className:T("min-w-0 truncate"),children:Xse(t.title)}),c.jsx("span",{className:T("shrink-0"),children:Qse})]}),{id:Py,duration:Ok,classNames:{content:"min-w-0"},onAutoClose:b("offer",t.at),onDismiss:b("offer",t.at),action:{label:"Undo",onClick:x=>{x.preventDefault(),a(t.sessionId,!t.archived,t.title)}}})},[l,e,t,i,r,a]);const d=m.useRef(!1);m.useEffect(()=>{if(n===null){if(!d.current)return;d.current=!1,px(zI);return}d.current=!0;const f=()=>{const g=De.getState();g.draftsUndo?.at===n.at&&(g.setDraftsUndo(null),d.current=!1)};oo(c.jsxs("span",{className:T("flex min-w-0 items-baseline gap-1"),children:[c.jsx("span",{className:T("min-w-0 truncate"),children:tre(n.keys.length)}),c.jsx("span",{className:T("shrink-0"),children:nre})]}),{id:zI,duration:Ok,classNames:{content:"min-w-0"},onAutoClose:f,onDismiss:f,action:{label:"Undo",onClick:g=>{g.preventDefault(),o();const v=De.getState(),b=v.stagedByDiscard;v.setStagedByDiscard(null),n.keys.length===1&&b!==null&&De.getState().activeDraftKey===b&&De.getState().openDraft(n.keys[0])}}})},[n,o]);const h=m.useRef(!1);return m.useEffect(()=>{if(s===null){if(!h.current)return;h.current=!1,px(qI);return}h.current=!0;const f=()=>{const g=De.getState();g.bulkReadDeferral?.at===s.at&&(g.clearBulkReadDeferral(),h.current=!1)};oo(k5(s.count),{id:qI,duration:ire,onAutoClose:f,onDismiss:f})},[s]),null}var so,Ue=typeof window<"u"?window:void 0,Ti=typeof globalThis<"u"?globalThis:Ue,E5=Array.prototype,KI=E5.forEach,YI=E5.indexOf,Zi=Ti?.navigator,It=Ti?.document,ki=Ti?.location,Lk=Ti?.fetch,Bk=Ti!=null&&Ti.XMLHttpRequest&&"withCredentials"in new Ti.XMLHttpRequest?Ti.XMLHttpRequest:void 0,XI=Ti?.AbortController,Ys=Zi?.userAgent,Zt=Ue??{},Ml={DEBUG:!1,LIB_VERSION:"1.235.6"},Ny="$copy_autocapture",ore=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];(function(e){e.GZipJS="gzip-js",e.Base64="base64"})(so||(so={}));var lre=["fatal","error","warning","log","info","debug"];function fn(e,t){return e.indexOf(t)!==-1}var sC=function(e){return e.trim()},QR=function(e){return e.replace(/^\$/,"")},cre=Array.isArray,T5=Object.prototype,R5=T5.hasOwnProperty,rC=T5.toString,As=cre||function(e){return rC.call(e)==="[object Array]"},lo=e=>typeof e=="function",Fs=e=>e===Object(e)&&!As(e),Df=e=>{if(Fs(e)){for(var t in e)if(R5.call(e,t))return!1;return!0}return!1},At=e=>e===void 0,Qs=e=>rC.call(e)=="[object String]",jk=e=>Qs(e)&&e.trim().length===0,Eu=e=>e===null,Wn=e=>At(e)||Eu(e),gi=e=>rC.call(e)=="[object Number]",Ll=e=>rC.call(e)==="[object Boolean]",ure=e=>e instanceof FormData,dre=e=>fn(ore,e),A5=e=>{var t={_log:function(n){if(Ue&&(Ml.DEBUG||Zt.POSTHOG_DEBUG)&&!At(Ue.console)&&Ue.console){for(var s=("__rrweb_original__"in Ue.console[n])?Ue.console[n].__rrweb_original__:Ue.console[n],r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];s(e,...i)}},info:function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];t._log("log",...s)},warn:function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];t._log("warn",...s)},error:function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];t._log("error",...s)},critical:function(){for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];console.error(e,...s)},uninitializedWarning:n=>{t.error("You must initialize PostHog before calling ".concat(n))},createLogger:n=>A5("".concat(e," ").concat(n))};return t},Lt=A5("[PostHog.js]"),Zr=Lt.createLogger,hre=Zr("[ExternalScriptsLoader]"),QI=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return hre.warn("".concat(t," was requested but loading of external scripts is disabled.")),n("Loading of external scripts is disabled");var s=It?.querySelectorAll("script");if(s){for(var r=0;r<s.length;r++)if(s[r].src===t)return n()}var i=()=>{if(!It)return n("document not found");var a=It.createElement("script");if(a.type="text/javascript",a.crossOrigin="anonymous",a.src=t,a.onload=u=>n(void 0,u),a.onerror=u=>n(u),e.config.prepare_external_dependency_script&&(a=e.config.prepare_external_dependency_script(a)),!a)return n("prepare_external_dependency_script returned null");var o,l=It.querySelectorAll("body > script");l.length>0?(o=l[0].parentNode)===null||o===void 0||o.insertBefore(a,l[0]):It.body.appendChild(a)};It!=null&&It.body?i():It?.addEventListener("DOMContentLoaded",i)};function JI(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,s)}return n}function ze(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?JI(Object(n),!0).forEach(function(s){bt(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):JI(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function bt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function F5(e,t){if(e==null)return{};var n,s,r=function(a,o){if(a==null)return{};var l,u,d={},h=Object.keys(a);for(u=0;u<h.length;u++)l=h[u],o.indexOf(l)>=0||(d[l]=a[l]);return d}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)n=i[s],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}Zt.__PosthogExtensions__=Zt.__PosthogExtensions__||{},Zt.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{var s="/static/".concat(t,".js")+"?v=".concat(e.version);if(t==="remote-config"&&(s="/array/".concat(e.config.token,"/config.js")),t==="toolbar"){var r=3e5,i=Math.floor(Date.now()/r)*r;s="".concat(s,"&t=").concat(i)}var a=e.requestRouter.endpointFor("assets",s);QI(e,a,n)},Zt.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{var s=e.requestRouter.endpointFor("api",t);QI(e,s,n)};var rw={};function tu(e,t,n){if(As(e)){if(KI&&e.forEach===KI)e.forEach(t,n);else if("length"in e&&e.length===+e.length){for(var s=0,r=e.length;s<r;s++)if(s in e&&t.call(n,e[s],s)===rw)return}}}function es(e,t,n){if(!Wn(e)){if(As(e))return tu(e,t,n);if(ure(e)){for(var s of e.entries())if(t.call(n,s[1],s[0])===rw)return}else for(var r in e)if(R5.call(e,r)&&t.call(n,e[r],r)===rw)return}}var Os=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];return tu(n,function(r){for(var i in r)r[i]!==void 0&&(e[i]=r[i])}),e},mx=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];return tu(n,function(r){tu(r,function(i){e.push(i)})}),e};function vx(e){for(var t=Object.keys(e),n=t.length,s=new Array(n);n--;)s[n]=[t[n],e[t[n]]];return s}var ZI=function(e){try{return e()}catch{return}},fre=function(e){return function(){try{for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return e.apply(this,n)}catch(r){Lt.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Lt.critical(r)}}},x0=function(e){var t={};return es(e,function(n,s){Qs(n)&&n.length>0&&(t[s]=n)}),t};function pre(e,t){return n=e,s=i=>Qs(i)&&!Eu(t)?i.slice(0,t):i,r=new Set,function i(a,o){return a!==Object(a)?s?s(a,o):a:r.has(a)?void 0:(r.add(a),As(a)?(l=[],tu(a,u=>{l.push(i(u))})):(l={},es(a,(u,d)=>{r.has(u)||(l[d]=i(u,d))})),l);var l}(n);var n,s,r}var gre=["herokuapp.com","vercel.app","netlify.app"];function mre(e){var t=e?.hostname;if(!Qs(t))return!1;var n=t.split(".").slice(-2).join(".");for(var s of gre)if(n===s)return!1;return!0}function D5(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return e[n]}function Bs(e,t,n,s){var{capture:r=!1,passive:i=!0}=s??{};e?.addEventListener(t,n,{capture:r,passive:i})}var I5="$people_distinct_id",tm="__alias",nm="__timers",eP="$autocapture_disabled_server_side",Hk="$heatmaps_enabled_server_side",tP="$exception_capture_enabled_server_side",nP="$web_vitals_enabled_server_side",P5="$dead_clicks_enabled_server_side",sP="$web_vitals_allowed_metrics",Uk="$session_recording_enabled_server_side",rP="$console_log_recording_enabled_server_side",iP="$session_recording_network_payload_capture",aP="$session_recording_masking",oP="$session_recording_canvas_recording",lP="$replay_sample_rate",cP="$replay_minimum_duration",uP="$replay_script_config",iw="$sesid",sm="$session_is_sampled",My="$session_recording_url_trigger_activated_session",Oy="$session_recording_event_trigger_activated_session",If="$enabled_feature_flags",bx="$early_access_features",Gk="$feature_flag_details",rm="$stored_person_properties",hd="$stored_group_properties",Vk="$surveys",cb="$surveys_activated",aw="$flag_call_reported",Il="$user_state",Wk="$client_session_props",$k="$capture_rate_limit",zk="$initial_campaign_params",qk="$initial_referrer_info",Kk="$initial_person_info",ow="$epp",N5="__POSTHOG_TOOLBAR__",dP="$posthog_cookieless",vre=[I5,tm,"__cmpns",nm,Uk,Hk,iw,If,Il,bx,Gk,hd,rm,Vk,aw,Wk,$k,zk,qk,ow];function hP(e){var t;return e instanceof Element&&(e.id===N5||!((t=e.closest)===null||t===void 0||!t.call(e,".toolbar-global-fade-container")))}function iC(e){return!!e&&e.nodeType===1}function nu(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function M5(e){return!!e&&e.nodeType===3}function O5(e){return!!e&&e.nodeType===11}function JR(e){return e?sC(e).split(/\s+/):[]}function fP(e){var t=Ue?.location.href;return!!(t&&e&&e.some(n=>t.match(n)))}function lw(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return JR(t)}function L5(e){return Wn(e)?null:sC(e).split(/(\s+)/).filter(t=>mp(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function aC(e){var t="";return Xk(e)&&!H5(e)&&e.childNodes&&e.childNodes.length&&es(e.childNodes,function(n){var s;M5(n)&&n.textContent&&(t+=(s=L5(n.textContent))!==null&&s!==void 0?s:"")}),sC(t)}function B5(e){return At(e.target)?e.srcElement||null:(t=e.target)!==null&&t!==void 0&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var Yk=["a","button","form","input","select","textarea","label"];function j5(e){var t=e.parentNode;return!(!t||!iC(t))&&t}function bre(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;if(!Ue||!e||nu(e,"html")||!iC(e)||n!=null&&n.url_allowlist&&!fP(n.url_allowlist)||n!=null&&n.url_ignorelist&&fP(n.url_ignorelist))return!1;if(n!=null&&n.dom_event_allowlist){var i=n.dom_event_allowlist;if(i&&!i.some(g=>t.type===g))return!1}for(var a=!1,o=[e],l=!0,u=e;u.parentNode&&!nu(u,"body");)if(O5(u.parentNode))o.push(u.parentNode.host),u=u.parentNode.host;else{if(!(l=j5(u)))break;if(s||Yk.indexOf(l.tagName.toLowerCase())>-1)a=!0;else{var d=Ue.getComputedStyle(l);d&&d.getPropertyValue("cursor")==="pointer"&&(a=!0)}o.push(l),u=l}if(!function(g,v){var b=v?.element_allowlist;if(At(b))return!0;var x=function(C){if(b.some(S=>C.tagName.toLowerCase()===S))return{v:!0}};for(var w of g){var _=x(w);if(typeof _=="object")return _.v}return!1}(o,n)||!function(g,v){var b=v?.css_selector_allowlist;if(At(b))return!0;var x=function(C){if(b.some(S=>C.matches(S)))return{v:!0}};for(var w of g){var _=x(w);if(typeof _=="object")return _.v}return!1}(o,n))return!1;var h=Ue.getComputedStyle(e);if(h&&h.getPropertyValue("cursor")==="pointer"&&t.type==="click")return!0;var f=e.tagName.toLowerCase();switch(f){case"html":return!1;case"form":return(r||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(r||["change","click"]).indexOf(t.type)>=0;default:return a?(r||["click"]).indexOf(t.type)>=0:(r||["click"]).indexOf(t.type)>=0&&(Yk.indexOf(f)>-1||e.getAttribute("contenteditable")==="true")}}function Xk(e){for(var t=e;t.parentNode&&!nu(t,"body");t=t.parentNode){var n=lw(t);if(fn(n,"ph-sensitive")||fn(n,"ph-no-capture"))return!1}if(fn(lw(e),"ph-include"))return!0;var s=e.type||"";if(Qs(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=e.name||e.id||"";return!(Qs(r)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,"")))}function H5(e){return!!(nu(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||nu(e,"select")||nu(e,"textarea")||e.getAttribute("contenteditable")==="true")}var U5="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",xre=new RegExp("^(?:".concat(U5,")$")),wre=new RegExp(U5),G5="\\d{3}-?\\d{2}-?\\d{4}",_re=new RegExp("^(".concat(G5,")$")),Cre=new RegExp("(".concat(G5,")"));function mp(e){var t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return!(Wn(e)||Qs(e)&&(e=sC(e),(t?xre:wre).test((e||"").replace(/[- ]/g,""))||(t?_re:Cre).test(e)))}function V5(e){var t=aC(e);return mp(t="".concat(t," ").concat(W5(e)).trim())?t:""}function W5(e){var t="";return e&&e.childNodes&&e.childNodes.length&&es(e.childNodes,function(n){var s;if(n&&((s=n.tagName)===null||s===void 0?void 0:s.toLowerCase())==="span")try{var r=aC(n);t="".concat(t," ").concat(r).trim(),n.childNodes&&n.childNodes.length&&(t="".concat(t," ").concat(W5(n)).trim())}catch(i){Lt.error("[AutoCapture]",i)}}),t}function yre(e){return function(t){var n=t.map(s=>{var r,i,a="";if(s.tag_name&&(a+=s.tag_name),s.attr_class)for(var o of(s.attr_class.sort(),s.attr_class))a+=".".concat(o.replace(/"/g,""));var l=ze(ze(ze(ze({},s.text?{text:s.text}:{}),{},{"nth-child":(r=s.nth_child)!==null&&r!==void 0?r:0,"nth-of-type":(i=s.nth_of_type)!==null&&i!==void 0?i:0},s.href?{href:s.href}:{}),s.attr_id?{attr_id:s.attr_id}:{}),s.attributes),u={};return vx(l).sort((d,h)=>{var[f]=d,[g]=h;return f.localeCompare(g)}).forEach(d=>{var[h,f]=d;return u[pP(h.toString())]=pP(f.toString())}),a+=":",a+=vx(l).map(d=>{var[h,f]=d;return"".concat(h,'="').concat(f,'"')}).join("")});return n.join(";")}(function(t){return t.map(n=>{var s,r,i={text:(s=n.$el_text)===null||s===void 0?void 0:s.slice(0,400),tag_name:n.tag_name,href:(r=n.attr__href)===null||r===void 0?void 0:r.slice(0,2048),attr_class:Sre(n),attr_id:n.attr__id,nth_child:n.nth_child,nth_of_type:n.nth_of_type,attributes:{}};return vx(n).filter(a=>{var[o]=a;return o.indexOf("attr__")===0}).forEach(a=>{var[o,l]=a;return i.attributes[o]=l}),i})}(e))}function pP(e){return e.replace(/"|\\"/g,'\\"')}function Sre(e){var t=e.attr__class;return t?As(t)?t:JR(t):void 0}class $5{constructor(){this.clicks=[]}isRageClick(t,n,s){var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(n-r.y)<30&&s-r.timestamp<1e3){if(this.clicks.push({x:t,y:n,timestamp:s}),this.clicks.length===3)return!0}else this.clicks=[{x:t,y:n,timestamp:s}];return!1}}var kre=["localhost","127.0.0.1"],Uf=e=>{var t=It?.createElement("a");return At(t)?null:(t.href=e,t)},Ere=function(e){var t,n,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"&",r=[];return es(e,function(i,a){At(i)||At(a)||a==="undefined"||(t=encodeURIComponent((o=>o instanceof File)(i)?i.name:i.toString()),n=encodeURIComponent(a),r[r.length]=n+"="+t)}),r.join(s)},cw=function(e,t){for(var n,s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;r<s.length;r++){var i=s[r].split("=");if(i[0]===t){n=i;break}}if(!As(n)||n.length<2)return"";var a=n[1];try{a=decodeURIComponent(a)}catch{Lt.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},Ly=function(e,t,n){if(!e||!t||!t.length)return e;for(var s=e.split("#"),r=s[0]||"",i=s[1],a=r.split("?"),o=a[1],l=a[0],u=(o||"").split("&"),d=[],h=0;h<u.length;h++){var f=u[h].split("=");As(f)&&(t.includes(f[0])?d.push(f[0]+"="+n):d.push(u[h]))}var g=l;return o!=null&&(g+="?"+d.join("&")),i!=null&&(g+="#"+i),g},uw=function(e,t){var n=e.match(new RegExp(t+"=([^&]*)"));return n?n[1]:null},gP=Zr("[AutoCapture]");function By(e,t){return t.length>e?t.slice(0,e)+"...":t}function Tre(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!iC(t));return t}function Rre(e,t,n,s){var r=e.tagName.toLowerCase(),i={tag_name:r};Yk.indexOf(r)>-1&&!n&&(r.toLowerCase()==="a"||r.toLowerCase()==="button"?i.$el_text=By(1024,V5(e)):i.$el_text=By(1024,aC(e)));var a=lw(e);a.length>0&&(i.classes=a.filter(function(d){return d!==""})),es(e.attributes,function(d){var h;if((!H5(e)||["name","id","class","aria-label"].indexOf(d.name)!==-1)&&(s==null||!s.includes(d.name))&&!t&&mp(d.value)&&(h=d.name,!Qs(h)||h.substring(0,10)!=="_ngcontent"&&h.substring(0,7)!=="_nghost")){var f=d.value;d.name==="class"&&(f=JR(f).join(" ")),i["attr__"+d.name]=By(1024,f)}});for(var o=1,l=1,u=e;u=Tre(u);)o++,u.tagName===e.tagName&&l++;return i.nth_child=o,i.nth_of_type=l,i}function Are(e,t){for(var n,s,{e:r,maskAllElementAttributes:i,maskAllText:a,elementAttributeIgnoreList:o,elementsChainAsString:l}=t,u=[e],d=e;d.parentNode&&!nu(d,"body");)O5(d.parentNode)?(u.push(d.parentNode.host),d=d.parentNode.host):(u.push(d.parentNode),d=d.parentNode);var h,f=[],g={},v=!1,b=!1;if(es(u,S=>{var y=Xk(S);S.tagName.toLowerCase()==="a"&&(v=S.getAttribute("href"),v=y&&v&&mp(v)&&v),fn(lw(S),"ph-no-capture")&&(b=!0),f.push(Rre(S,i,a,o));var R=function(E){if(!Xk(E))return{};var F={};return es(E.attributes,function(A){if(A.name&&A.name.indexOf("data-ph-capture-attribute")===0){var I=A.name.replace("data-ph-capture-attribute-",""),P=A.value;I&&P&&mp(P)&&(F[I]=P)}}),F}(S);Os(g,R)}),b)return{props:{},explicitNoCapture:b};if(a||(e.tagName.toLowerCase()==="a"||e.tagName.toLowerCase()==="button"?f[0].$el_text=V5(e):f[0].$el_text=aC(e)),v){var x,w;f[0].attr__href=v;var _=(x=Uf(v))===null||x===void 0?void 0:x.host,C=Ue==null||(w=Ue.location)===null||w===void 0?void 0:w.host;_&&C&&_!==C&&(h=v)}return{props:Os({$event_type:r.type,$ce_version:1},l?{}:{$elements:f},{$elements_chain:yre(f)},(n=f[0])!==null&&n!==void 0&&n.$el_text?{$el_text:(s=f[0])===null||s===void 0?void 0:s.$el_text}:{},h&&r.type==="click"?{$external_click_url:h}:{},g)}}let Fre=class{constructor(t){bt(this,"_initialized",!1),bt(this,"_isDisabledServerSide",null),bt(this,"rageclicks",new $5),bt(this,"_elementsChainAsString",!1),this.instance=t,this._elementSelectors=null}get config(){var t,n,s=Fs(this.instance.config.autocapture)?this.instance.config.autocapture:{};return s.url_allowlist=(t=s.url_allowlist)===null||t===void 0?void 0:t.map(r=>new RegExp(r)),s.url_ignorelist=(n=s.url_ignorelist)===null||n===void 0?void 0:n.map(r=>new RegExp(r)),s}_addDomEventHandlers(){if(this.isBrowserSupported()){if(Ue&&It){var t=s=>{s=s||Ue?.event;try{this._captureEvent(s)}catch(r){gP.error("Failed to capture event",r)}};if(Bs(It,"submit",t,{capture:!0}),Bs(It,"change",t,{capture:!0}),Bs(It,"click",t,{capture:!0}),this.config.capture_copied_text){var n=s=>{s=s||Ue?.event,this._captureEvent(s,Ny)};Bs(It,"copy",n,{capture:!0}),Bs(It,"cut",n,{capture:!0})}}}else gP.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this._elementsChainAsString=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[eP]:!!t.autocapture_opt_out}),this._isDisabledServerSide=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this._elementSelectors=t}getElementSelectors(t){var n,s=[];return(n=this._elementSelectors)===null||n===void 0||n.forEach(r=>{var i=It?.querySelectorAll(r);i?.forEach(a=>{t===a&&s.push(r)})}),s}get isEnabled(){var t,n,s=(t=this.instance.persistence)===null||t===void 0?void 0:t.props[eP],r=this._isDisabledServerSide;if(Eu(r)&&!Ll(s)&&!this.instance.config.advanced_disable_decide)return!1;var i=(n=this._isDisabledServerSide)!==null&&n!==void 0?n:!!s;return!!this.instance.config.autocapture&&!i}_captureEvent(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"$autocapture";if(this.isEnabled){var s,r=B5(t);M5(r)&&(r=r.parentNode||null),n==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&this.instance.config.rageclick&&(s=this.rageclicks)!==null&&s!==void 0&&s.isRageClick(t.clientX,t.clientY,new Date().getTime())&&this._captureEvent(t,"$rageclick");var i=n===Ny;if(r&&bre(r,t,this.config,i,i?["copy","cut"]:void 0)){var{props:a,explicitNoCapture:o}=Are(r,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(o)return!1;var l=this.getElementSelectors(r);if(l&&l.length>0&&(a.$element_selectors=l),n===Ny){var u,d=L5(Ue==null||(u=Ue.getSelection())===null||u===void 0?void 0:u.toString()),h=t.type||"clipboard";if(!d)return!1;a.$selected_content=d,a.$copy_type=h}return this.instance.capture(n,a),!0}}}isBrowserSupported(){return lo(It?.querySelectorAll)}};Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return gi(e)&&isFinite(e)&&Math.floor(e)===e});var mP="0123456789abcdef";let Dre=class Qk{constructor(t){if(this.bytes=t,t.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,n,s,r){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(s)||!Number.isInteger(r)||t<0||n<0||s<0||r<0||t>0xffffffffffff||n>4095||s>1073741823||r>4294967295)throw new RangeError("invalid field value");var i=new Uint8Array(16);return i[0]=t/Math.pow(2,40),i[1]=t/Math.pow(2,32),i[2]=t/Math.pow(2,24),i[3]=t/Math.pow(2,16),i[4]=t/Math.pow(2,8),i[5]=t,i[6]=112|n>>>8,i[7]=n,i[8]=128|s>>>24,i[9]=s>>>16,i[10]=s>>>8,i[11]=s,i[12]=r>>>24,i[13]=r>>>16,i[14]=r>>>8,i[15]=r,new Qk(i)}toString(){for(var t="",n=0;n<this.bytes.length;n++)t=t+mP.charAt(this.bytes[n]>>>4)+mP.charAt(15&this.bytes[n]),n!==3&&n!==5&&n!==7&&n!==9||(t+="-");if(t.length!==36)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new Qk(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(var n=0;n<16;n++){var s=this.bytes[n]-t.bytes[n];if(s!==0)return Math.sign(s)}return 0}},Ire=class{constructor(){bt(this,"timestamp",0),bt(this,"counter",0),bt(this,"random",new Pre)}generate(){var t=this.generateOrAbort();if(At(t)){this.timestamp=0;var n=this.generateOrAbort();if(At(n))throw new Error("Could not generate UUID after timestamp reset");return n}return t}generateOrAbort(){var t=Date.now();if(t>this.timestamp)this.timestamp=t,this.resetCounter();else{if(!(t+1e4>this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return Dre.fromFieldsV7(this.timestamp,Math.trunc(this.counter/Math.pow(2,30)),this.counter&Math.pow(2,30)-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}};var vP,z5=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};Ue&&!At(Ue.crypto)&&crypto.getRandomValues&&(z5=e=>crypto.getRandomValues(e));let Pre=class{constructor(){bt(this,"buffer",new Uint32Array(8)),bt(this,"cursor",1/0)}nextUint32(){return this.cursor>=this.buffer.length&&(z5(this.buffer),this.cursor=0),this.buffer[this.cursor++]}};var qc=()=>Nre().toString(),Nre=()=>(vP||(vP=new Ire)).generate(),Mre="Thu, 01 Jan 1970 00:00:00 GMT",yg="",Ore=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function Lre(e,t){if(t){var n=function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:It;if(yg)return yg;if(!i||["localhost","127.0.0.1"].includes(r))return"";for(var a=r.split("."),o=Math.min(a.length,8),l="dmn_chk_"+qc(),u=new RegExp("(^|;)\\s*"+l+"=1");!yg&&o--;){var d=a.slice(o).join("."),h=l+"=1;domain=."+d;i.cookie=h,u.test(i.cookie)&&(i.cookie=h+";expires="+Mre,yg=d)}return yg}(e);if(!n){var s=(r=>{var i=r.match(Ore);return i?i[0]:""})(e);s!==n&&Lt.info("Warning: cookie subdomain discovery mismatch",s,n),n=s}return n?"; domain=."+n:""}return""}var jc,$l={is_supported:()=>!!It,error:function(e){Lt.error("cookieStore error: "+e)},get:function(e){if(It){try{for(var t=e+"=",n=It.cookie.split(";").filter(i=>i.length),s=0;s<n.length;s++){for(var r=n[s];r.charAt(0)==" ";)r=r.substring(1,r.length);if(r.indexOf(t)===0)return decodeURIComponent(r.substring(t.length,r.length))}}catch{}return null}},parse:function(e){var t;try{t=JSON.parse($l.get(e))||{}}catch{}return t},set:function(e,t,n,s,r){if(It)try{var i="",a="",o=Lre(It.location.hostname,s);if(n){var l=new Date;l.setTime(l.getTime()+24*n*60*60*1e3),i="; expires="+l.toUTCString()}r&&(a="; secure");var u=e+"="+encodeURIComponent(JSON.stringify(t))+i+"; SameSite=Lax; path=/"+o+a;return u.length>3686.4&&Lt.warn("cookieStore warning: large cookie, len="+u.length),It.cookie=u,u}catch{return}},remove:function(e,t){try{$l.set(e,"",-1,t)}catch{return}}},jy=null,Zs={is_supported:function(){if(!Eu(jy))return jy;var e=!0;if(At(Ue))e=!1;else try{var t="__mplssupport__";Zs.set(t,"xyz"),Zs.get(t)!=='"xyz"'&&(e=!1),Zs.remove(t)}catch{e=!1}return e||Lt.error("localStorage unsupported; falling back to cookie store"),jy=e,e},error:function(e){Lt.error("localStorage error: "+e)},get:function(e){try{return Ue?.localStorage.getItem(e)}catch(t){Zs.error(t)}return null},parse:function(e){try{return JSON.parse(Zs.get(e))||{}}catch{}return null},set:function(e,t){try{Ue?.localStorage.setItem(e,JSON.stringify(t))}catch(n){Zs.error(n)}},remove:function(e){try{Ue?.localStorage.removeItem(e)}catch(t){Zs.error(t)}}},Bre=["distinct_id",iw,sm,ow,Kk],ub=ze(ze({},Zs),{},{parse:function(e){try{var t={};try{t=$l.parse(e)||{}}catch{}var n=Os(t,JSON.parse(Zs.get(e)||"{}"));return Zs.set(e,n),n}catch{}return null},set:function(e,t,n,s,r,i){try{Zs.set(e,t,void 0,void 0,i);var a={};Bre.forEach(o=>{t[o]&&(a[o]=t[o])}),Object.keys(a).length&&$l.set(e,a,n,s,r,i)}catch(o){Zs.error(o)}},remove:function(e,t){try{Ue?.localStorage.removeItem(e),$l.remove(e,t)}catch(n){Zs.error(n)}}}),db={},jre={is_supported:function(){return!0},error:function(e){Lt.error("memoryStorage error: "+e)},get:function(e){return db[e]||null},parse:function(e){return db[e]||null},set:function(e,t){db[e]=t},remove:function(e){delete db[e]}},sd=null,Tr={is_supported:function(){if(!Eu(sd))return sd;if(sd=!0,At(Ue))sd=!1;else try{var e="__support__";Tr.set(e,"xyz"),Tr.get(e)!=='"xyz"'&&(sd=!1),Tr.remove(e)}catch{sd=!1}return sd},error:function(e){Lt.error("sessionStorage error: ",e)},get:function(e){try{return Ue?.sessionStorage.getItem(e)}catch(t){Tr.error(t)}return null},parse:function(e){try{return JSON.parse(Tr.get(e))||null}catch{}return null},set:function(e,t){try{Ue?.sessionStorage.setItem(e,JSON.stringify(t))}catch(n){Tr.error(n)}},remove:function(e){try{Ue?.sessionStorage.removeItem(e)}catch(t){Tr.error(t)}}};(function(e){e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED"})(jc||(jc={}));let Hre=class{constructor(t){this.instance=t}get config(){return this.instance.config}get consent(){return this.getDnt()?jc.DENIED:this.storedConsent}isOptedOut(){return this.consent===jc.DENIED||this.consent===jc.PENDING&&this.config.opt_out_capturing_by_default}isOptedIn(){return!this.isOptedOut()}optInOut(t){this.storage.set(this.storageKey,t?1:0,this.config.cookie_expiration,this.config.cross_subdomain_cookie,this.config.secure_cookie)}reset(){this.storage.remove(this.storageKey,this.config.cross_subdomain_cookie)}get storageKey(){var{token:t,opt_out_capturing_cookie_prefix:n}=this.instance.config;return(n||"__ph_opt_in_out_")+t}get storedConsent(){var t=this.storage.get(this.storageKey);return t==="1"?jc.GRANTED:t==="0"?jc.DENIED:jc.PENDING}get storage(){if(!this._storage){var t=this.config.opt_out_capturing_persistence_type;this._storage=t==="localStorage"?Zs:$l;var n=t==="localStorage"?$l:Zs;n.get(this.storageKey)&&(this._storage.get(this.storageKey)||this.optInOut(n.get(this.storageKey)==="1"),n.remove(this.storageKey,this.config.cross_subdomain_cookie))}return this._storage}getDnt(){return!!this.config.respect_dnt&&!!D5([Zi?.doNotTrack,Zi?.msDoNotTrack,Zt.doNotTrack],t=>fn([!0,1,"1","yes"],t))}};var hb=Zr("[Dead Clicks]"),Ure=()=>!0,Gre=e=>{var t,n=!((t=e.instance.persistence)===null||t===void 0||!t.get_property(P5)),s=e.instance.config.capture_dead_clicks;return Ll(s)?s:n};let q5=class{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(t,n,s){this.instance=t,this.isEnabled=n,this.onCapture=s,this.startIfEnabled()}onRemoteConfig(t){this.instance.persistence&&this.instance.persistence.register({[P5]:t?.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.loadScript(()=>{this.start()})}loadScript(t){var n,s,r;(n=Zt.__PosthogExtensions__)!==null&&n!==void 0&&n.initDeadClicksAutocapture&&t(),(s=Zt.__PosthogExtensions__)===null||s===void 0||(r=s.loadExternalDependency)===null||r===void 0||r.call(s,this.instance,"dead-clicks-autocapture",i=>{i?hb.error("failed to load script",i):t()})}start(){var t;if(It){if(!this._lazyLoadedDeadClicksAutocapture&&(t=Zt.__PosthogExtensions__)!==null&&t!==void 0&&t.initDeadClicksAutocapture){var n=Fs(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};n.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=Zt.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this._lazyLoadedDeadClicksAutocapture.start(It),hb.info("starting...")}}else hb.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,hb.info("stopping..."))}};var Hy=Zr("[ExceptionAutocapture]");let Vre=class{constructor(t){var n;bt(this,"startCapturing",()=>{var s;if(Ue&&this.isEnabled&&(s=Zt.__PosthogExtensions__)!==null&&s!==void 0&&s.errorWrappingFunctions){var r=Zt.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Zt.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=Zt.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.unwrapOnError&&this.config.capture_unhandled_errors&&(this.unwrapOnError=r(this.captureException.bind(this))),!this.unwrapUnhandledRejection&&this.config.capture_unhandled_rejections&&(this.unwrapUnhandledRejection=i(this.captureException.bind(this))),!this.unwrapConsoleError&&this.config.capture_console_errors&&(this.unwrapConsoleError=a(this.captureException.bind(this)))}catch(o){Hy.error("failed to start",o),this.stopCapturing()}}}),this.instance=t,this.remoteEnabled=!((n=this.instance.persistence)===null||n===void 0||!n.props[tP]),this.config=this.requiredConfig(),this.startIfEnabled()}requiredConfig(){var t=this.instance.config.capture_exceptions,n={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Fs(t)?n=ze(ze({},n),t):(At(t)?this.remoteEnabled:t)&&(n=ze(ze({},n),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),n}get isEnabled(){return this.config.capture_console_errors||this.config.capture_unhandled_errors||this.config.capture_unhandled_rejections}startIfEnabled(){this.isEnabled&&(Hy.info("enabled"),this.loadScript(this.startCapturing))}loadScript(t){var n,s,r;(n=Zt.__PosthogExtensions__)!==null&&n!==void 0&&n.errorWrappingFunctions&&t(),(s=Zt.__PosthogExtensions__)===null||s===void 0||(r=s.loadExternalDependency)===null||r===void 0||r.call(s,this.instance,"exception-autocapture",i=>{if(i)return Hy.error("failed to load script",i);t()})}stopCapturing(){var t,n,s;(t=this.unwrapOnError)===null||t===void 0||t.call(this),this.unwrapOnError=void 0,(n=this.unwrapUnhandledRejection)===null||n===void 0||n.call(this),this.unwrapUnhandledRejection=void 0,(s=this.unwrapConsoleError)===null||s===void 0||s.call(this),this.unwrapConsoleError=void 0}onRemoteConfig(t){var n=t.autocaptureExceptions;this.remoteEnabled=!!n||!1,this.config=this.requiredConfig(),this.instance.persistence&&this.instance.persistence.register({[tP]:this.remoteEnabled}),this.startIfEnabled()}captureException(t){var n=this.instance.requestRouter.endpointFor("ui");t.$exception_personURL="".concat(n,"/project/").concat(this.instance.config.token,"/person/").concat(this.instance.get_distinct_id()),this.instance.exceptions.sendExceptionEvent(t)}};function K5(e){return!At(Event)&&Y5(e,Event)}function Y5(e,t){try{return e instanceof t}catch{return!1}}function xx(e,t){return Object.prototype.toString.call(e)==="[object ".concat(t,"]")}function Uy(e){return xx(e,"DOMError")}var bP=/\(error: (.*)\)/,xP=50,Pf="?";function Gy(e,t,n,s){var r={platform:"web:javascript",filename:e,function:t==="<anonymous>"?Pf:t,in_app:!0};return At(n)||(r.lineno=n),At(s)||(r.colno=s),r}var Wre=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,$re=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,zre=/\((\S*)(?::(\d+))(?::(\d+))\)/,qre=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Kre=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Yre=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var s=t.sort((r,i)=>r[0]-i[0]).map(r=>r[1]);return function(r){for(var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=[],o=r.split(`
3
3
  `),l=i;l<o.length;l++){var u=o[l];if(!(u.length>1024)){var d=bP.test(u)?u.replace(bP,"$1"):u;if(!d.match(/\S*Error: /)){for(var h of s){var f=h(d);if(f){a.push(f);break}}if(a.length>=xP)break}}}return function(g){if(!g.length)return[];var v=Array.from(g);return v.reverse(),v.slice(0,xP).map(b=>ze(ze({},b),{},{filename:b.filename||Xre(v).filename,function:b.function||Pf}))}(a)}}([30,e=>{var t=Wre.exec(e);if(t){var[,n,s,r]=t;return Gy(n,Pf,+s,+r)}var i=$re.exec(e);if(i){if(i[2]&&i[2].indexOf("eval")===0){var a=zre.exec(i[2]);a&&(i[2]=a[1],i[3]=a[2],i[4]=a[3])}var[o,l]=_P(i[1]||Pf,i[2]);return Gy(l,o,i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}}],[50,e=>{var t=qre.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var n=Kre.exec(t[3]);n&&(t[1]=t[1]||"eval",t[3]=n[1],t[4]=n[2],t[5]="")}var s=t[3],r=t[1]||Pf;return[r,s]=_P(r,s),Gy(s,r,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}}]);function Xre(e){return e[e.length-1]||{}}var fb,wP,Vy,_P=(e,t)=>{var n=e.indexOf("safari-extension")!==-1,s=e.indexOf("safari-web-extension")!==-1;return n||s?[e.indexOf("@")!==-1?e.split("@")[0]:Pf,n?"safari-extension:".concat(t):"safari-web-extension:".concat(t)]:[e,t]},Qre=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;function ZR(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=e.stacktrace||e.stack||"",s=function(a){return a&&Jre.test(a.message)?1:0}(e);try{var r=Yre,i=function(a,o){var l=function(u){var d=globalThis._posthogChunkIds;if(!d)return{};var h=Object.keys(d);return Vy&&h.length===wP||(wP=h.length,Vy=h.reduce((f,g)=>{fb||(fb={});var v=fb[g];if(v)f[v[0]]=v[1];else for(var b=u(g),x=b.length-1;x>=0;x--){var w=b[x],_=w?.filename,C=d[g];if(_&&C){f[_]=C,fb[g]=[_,C];break}}return f},{})),Vy}(o);return a.forEach(u=>{u.filename&&(u.chunk_id=l[u.filename])}),a}(r(n,s),r);return i.slice(0,i.length-t)}catch{}return[]}var Jre=/Minified React error #\d+;/i;function Wy(e,t){var n,s,r=ZR(e),i=(n=t?.handled)===null||n===void 0||n,a=(s=t?.synthetic)!==null&&s!==void 0&&s;return{$exception_list:[{type:t!=null&&t.overrideExceptionType?t.overrideExceptionType:e.name,value:function(o){var l=o.message;return l.error&&typeof l.error.message=="string"?String(l.error.message):String(l)}(e),stacktrace:{frames:r,type:"raw"},mechanism:{handled:i,synthetic:a}}],$exception_level:"error"}}function $y(e,t){var n,s,r,i=(n=t?.handled)===null||n===void 0||n,a=(s=t?.synthetic)===null||s===void 0||s,o={type:t!=null&&t.overrideExceptionType?t.overrideExceptionType:(r=t?.defaultExceptionType)!==null&&r!==void 0?r:"Error",value:e||t?.defaultExceptionMessage,mechanism:{handled:i,synthetic:a}};if(t!=null&&t.syntheticException){var l=ZR(t.syntheticException,1);l.length&&(o.stacktrace={frames:l,type:"raw"})}return{$exception_list:[o],$exception_level:"error"}}function Zre(e){return Qs(e)&&!jk(e)&&lre.indexOf(e)>=0}function eie(e,t){var n,s,r=(n=t?.handled)===null||n===void 0||n,i=(s=t?.synthetic)===null||s===void 0||s,a=t!=null&&t.overrideExceptionType?t.overrideExceptionType:K5(e)?e.constructor.name:"Error",o="Non-Error 'exception' captured with keys: ".concat(function(d){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:40,f=Object.keys(d);if(f.sort(),!f.length)return"[object has no keys]";for(var g=f.length;g>0;g--){var v=f.slice(0,g).join(", ");if(!(v.length>h))return g===f.length||v.length<=h?v:"".concat(v.slice(0,h),"...")}return""}(e)),l={type:a,value:o,mechanism:{handled:r,synthetic:i}};if(t!=null&&t.syntheticException){var u=ZR(t?.syntheticException,1);u.length&&(l.stacktrace={frames:u,type:"raw"})}return{$exception_list:[l],$exception_level:Zre(e.level)?e.level:"error"}}function tie(e,t){var{error:n,event:s}=e,r={$exception_list:[]},i=n||s;if(Uy(i)||function(g){return xx(g,"DOMException")}(i)){var a=i;if(function(g){return"stack"in g}(i))r=Wy(i,t);else{var o=a.name||(Uy(a)?"DOMError":"DOMException"),l=a.message?"".concat(o,": ").concat(a.message):o,u=Uy(a)?"DOMError":"DOMException";r=$y(l,ze(ze({},t),{},{overrideExceptionType:u,defaultExceptionMessage:l}))}return"code"in a&&(r.$exception_DOMException_code="".concat(a.code)),r}if(function(g){return xx(g,"ErrorEvent")}(i)&&i.error)return Wy(i.error,t);if(function(g){switch(Object.prototype.toString.call(g)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":return!0;default:return Y5(g,Error)}}(i))return Wy(i,t);if(function(g){return xx(g,"Object")}(i)||K5(i))return eie(i,t);if(At(n)&&Qs(s)){var d="Error",h=s,f=s.match(Qre);return f&&(d=f[1],h=f[2]),$y(h,ze(ze({},t),{},{overrideExceptionType:d,defaultExceptionMessage:h}))}return $y(i,t)}function dw(e){var t,n;return((t=JSON.stringify(e,(n=[],function(s,r){if(Fs(r)){for(;n.length>0&&n[n.length-1]!==this;)n.pop();return n.includes(r)?"[Circular]":(n.push(r),r)}return r})))===null||t===void 0?void 0:t.length)||0}function Jk(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:66060288e-1;if(e.size>=t&&e.data.length>1){var n=Math.floor(e.data.length/2),s=e.data.slice(0,n),r=e.data.slice(n);return[Jk({size:dw(s),data:s,sessionId:e.sessionId,windowId:e.windowId}),Jk({size:dw(r),data:r,sessionId:e.sessionId,windowId:e.windowId})].flatMap(i=>i)}return[e]}var Pl=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(Pl||{}),eo=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(eo||{}),Zk="[SessionRecording]",eE="redacted",pb={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:e=>e,recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:1e6,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io",".clarity.ms","analytics.google.com"]},nie=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],sie=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],rie=["/s/","/e/","/i/"];function CP(e,t,n,s){if(Wn(e))return e;var r=t?.["content-length"]||function(i){return new Blob([i]).size}(e);return Qs(r)&&(r=parseInt(r)),r>n?Zk+" ".concat(s," body too large to record (").concat(r," bytes)"):e}function yP(e,t){if(Wn(e))return e;var n=e;return mp(n,!1)||(n=Zk+" "+t+" body "+eE),es(sie,s=>{var r,i;(r=n)!==null&&r!==void 0&&r.length&&((i=n)===null||i===void 0?void 0:i.indexOf(s))!==-1&&(n=Zk+" "+t+" body "+eE+" as might contain: "+s)}),n}var iie=(e,t)=>{var n,s,r,i={payloadSizeLimitBytes:pb.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...pb.performanceEntryTypeToObserve],payloadHostDenyList:[...t.payloadHostDenyList||[],...pb.payloadHostDenyList]},a=e.session_recording.recordHeaders!==!1&&t.recordHeaders,o=e.session_recording.recordBody!==!1&&t.recordBody,l=e.capture_performance!==!1&&t.recordPerformance,u=(n=i,r=Math.min(1e6,(s=n.payloadSizeLimitBytes)!==null&&s!==void 0?s:1e6),f=>(f!=null&&f.requestBody&&(f.requestBody=CP(f.requestBody,f.requestHeaders,r,"Request")),f!=null&&f.responseBody&&(f.responseBody=CP(f.responseBody,f.responseHeaders,r,"Response")),f)),d=f=>{return u(((b,x)=>{var w,_=Uf(b.name),C=x.indexOf("http")===0?(w=Uf(x))===null||w===void 0?void 0:w.pathname:x;C==="/"&&(C="");var S=_?.pathname.replace(C||"","");if(!(_&&S&&rie.some(y=>S.indexOf(y)===0)))return b})((v=(g=f).requestHeaders,Wn(v)||es(Object.keys(v??{}),b=>{nie.includes(b.toLowerCase())&&(v[b]=eE)}),g),e.api_host));var g,v},h=lo(e.session_recording.maskNetworkRequestFn);return h&&lo(e.session_recording.maskCapturedNetworkRequestFn)&&Lt.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),h&&(e.session_recording.maskCapturedNetworkRequestFn=f=>{var g=e.session_recording.maskNetworkRequestFn({url:f.name});return ze(ze({},f),{},{name:g?.url})}),i.maskRequestFn=lo(e.session_recording.maskCapturedNetworkRequestFn)?f=>{var g,v,b,x=d(f);return x&&(g=(v=(b=e.session_recording).maskCapturedNetworkRequestFn)===null||v===void 0?void 0:v.call(b,x))!==null&&g!==void 0?g:void 0}:f=>function(g){if(!At(g))return g.requestBody=yP(g.requestBody,"Request"),g.responseBody=yP(g.responseBody,"Response"),g}(d(f)),ze(ze(ze({},pb),i),{},{recordHeaders:a,recordBody:o,recordPerformance:l,recordInitialRequests:l})};function Ea(e,t,n,s,r){return t>n&&(Lt.warn("min cannot be greater than max."),t=n),gi(e)?e>n?(s&&Lt.warn(s+" cannot be greater than max: "+n+". Using max value instead."),n):e<t?(s&&Lt.warn(s+" cannot be less than min: "+t+". Using min value instead."),t):e:(s&&Lt.warn(s+" must be a number. using max or fallback. max: "+n+", fallback: "+r),Ea(r||n,t,n,s))}let aie=class{constructor(t){var n,s,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};bt(this,"bucketSize",100),bt(this,"refillRate",10),bt(this,"mutationBuckets",{}),bt(this,"loggedTracker",{}),bt(this,"refillBuckets",()=>{Object.keys(this.mutationBuckets).forEach(i=>{this.mutationBuckets[i]=this.mutationBuckets[i]+this.refillRate,this.mutationBuckets[i]>=this.bucketSize&&delete this.mutationBuckets[i]})}),bt(this,"getNodeOrRelevantParent",i=>{var a=this.rrweb.mirror.getNode(i);if(a?.nodeName!=="svg"&&a instanceof Element){var o=a.closest("svg");if(o)return[this.rrweb.mirror.getId(o),o]}return[i,a]}),bt(this,"numberOfChanges",i=>{var a,o,l,u,d,h,f,g;return((a=(o=i.removes)===null||o===void 0?void 0:o.length)!==null&&a!==void 0?a:0)+((l=(u=i.attributes)===null||u===void 0?void 0:u.length)!==null&&l!==void 0?l:0)+((d=(h=i.texts)===null||h===void 0?void 0:h.length)!==null&&d!==void 0?d:0)+((f=(g=i.adds)===null||g===void 0?void 0:g.length)!==null&&f!==void 0?f:0)}),bt(this,"throttleMutations",i=>{if(i.type!==3||i.data.source!==0)return i;var a=i.data,o=this.numberOfChanges(a);a.attributes&&(a.attributes=a.attributes.filter(u=>{var d,h,f,[g,v]=this.getNodeOrRelevantParent(u.id);return this.mutationBuckets[g]===0?!1:(this.mutationBuckets[g]=(d=this.mutationBuckets[g])!==null&&d!==void 0?d:this.bucketSize,this.mutationBuckets[g]=Math.max(this.mutationBuckets[g]-1,0),this.mutationBuckets[g]===0&&(this.loggedTracker[g]||(this.loggedTracker[g]=!0,(h=(f=this.options).onBlockedNode)===null||h===void 0||h.call(f,g,v))),u)}));var l=this.numberOfChanges(a);return l!==0||o===l?i:void 0}),this.rrweb=t,this.options=r,this.refillRate=Ea((n=this.options.refillRate)!==null&&n!==void 0?n:this.refillRate,0,100,"mutation throttling refill rate"),this.bucketSize=Ea((s=this.options.bucketSize)!==null&&s!==void 0?s:this.bucketSize,0,100,"mutation throttling bucket size"),setInterval(()=>{this.refillBuckets()},1e3)}};var Da=Uint8Array,Ri=Uint16Array,vp=Uint32Array,eA=new Da([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),tA=new Da([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),SP=new Da([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),X5=function(e,t){for(var n=new Ri(31),s=0;s<31;++s)n[s]=t+=1<<e[s-1];var r=new vp(n[30]);for(s=1;s<30;++s)for(var i=n[s];i<n[s+1];++i)r[i]=i-n[s]<<5|s;return[n,r]},Q5=X5(eA,2),oie=Q5[0],tE=Q5[1];oie[28]=258,tE[258]=28;for(var kP=X5(tA,0)[1],J5=new Ri(32768),as=0;as<32768;++as){var rd=(43690&as)>>>1|(21845&as)<<1;rd=(61680&(rd=(52428&rd)>>>2|(13107&rd)<<2))>>>4|(3855&rd)<<4,J5[as]=((65280&rd)>>>8|(255&rd)<<8)>>>1}var ym=function(e,t,n){for(var s=e.length,r=0,i=new Ri(t);r<s;++r)++i[e[r]-1];var a,o=new Ri(t);for(r=0;r<t;++r)o[r]=o[r-1]+i[r-1]<<1;for(a=new Ri(s),r=0;r<s;++r)a[r]=J5[o[e[r]-1]++]>>>15-e[r];return a},th=new Da(288);for(as=0;as<144;++as)th[as]=8;for(as=144;as<256;++as)th[as]=9;for(as=256;as<280;++as)th[as]=7;for(as=280;as<288;++as)th[as]=8;var hw=new Da(32);for(as=0;as<32;++as)hw[as]=5;var lie=ym(th,9),cie=ym(hw,5),Z5=function(e){return(e/8>>0)+(7&e&&1)},e8=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var s=new(e instanceof Ri?Ri:e instanceof vp?vp:Da)(n-t);return s.set(e.subarray(t,n)),s},Fl=function(e,t,n){n<<=7&t;var s=t/8>>0;e[s]|=n,e[s+1]|=n>>>8},Sg=function(e,t,n){n<<=7&t;var s=t/8>>0;e[s]|=n,e[s+1]|=n>>>8,e[s+2]|=n>>>16},zy=function(e,t){for(var n=[],s=0;s<e.length;++s)e[s]&&n.push({s,f:e[s]});var r=n.length,i=n.slice();if(!r)return[new Da(0),0];if(r==1){var a=new Da(n[0].s+1);return a[n[0].s]=1,[a,1]}n.sort(function(y,R){return y.f-R.f}),n.push({s:-1,f:25001});var o=n[0],l=n[1],u=0,d=1,h=2;for(n[0]={s:-1,f:o.f+l.f,l:o,r:l};d!=r-1;)o=n[n[u].f<n[h].f?u++:h++],l=n[u!=d&&n[u].f<n[h].f?u++:h++],n[d++]={s:-1,f:o.f+l.f,l:o,r:l};var f=i[0].s;for(s=1;s<r;++s)i[s].s>f&&(f=i[s].s);var g=new Ri(f+1),v=nE(n[d-1],g,0);if(v>t){s=0;var b=0,x=v-t,w=1<<x;for(i.sort(function(y,R){return g[R.s]-g[y.s]||y.f-R.f});s<r;++s){var _=i[s].s;if(!(g[_]>t))break;b+=w-(1<<v-g[_]),g[_]=t}for(b>>>=x;b>0;){var C=i[s].s;g[C]<t?b-=1<<t-g[C]++-1:++s}for(;s>=0&&b;--s){var S=i[s].s;g[S]==t&&(--g[S],++b)}v=t}return[new Da(g),v]},nE=function(e,t,n){return e.s==-1?Math.max(nE(e.l,t,n+1),nE(e.r,t,n+1)):t[e.s]=n},EP=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Ri(++t),s=0,r=e[0],i=1,a=function(l){n[s++]=l},o=1;o<=t;++o)if(e[o]==r&&o!=t)++i;else{if(!r&&i>2){for(;i>138;i-=138)a(32754);i>2&&(a(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(a(r),--i;i>6;i-=6)a(8304);i>2&&(a(i-3<<5|8208),i=0)}for(;i--;)a(r);i=1,r=e[o]}return[n.subarray(0,s),t]},kg=function(e,t){for(var n=0,s=0;s<t.length;++s)n+=e[s]*t[s];return n},sE=function(e,t,n){var s=n.length,r=Z5(t+2);e[r]=255&s,e[r+1]=s>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var i=0;i<s;++i)e[r+i+4]=n[i];return 8*(r+4+s)},TP=function(e,t,n,s,r,i,a,o,l,u,d){Fl(t,d++,n),++r[256];for(var h=zy(r,15),f=h[0],g=h[1],v=zy(i,15),b=v[0],x=v[1],w=EP(f),_=w[0],C=w[1],S=EP(b),y=S[0],R=S[1],E=new Ri(19),F=0;F<_.length;++F)E[31&_[F]]++;for(F=0;F<y.length;++F)E[31&y[F]]++;for(var A=zy(E,7),I=A[0],P=A[1],N=19;N>4&&!I[SP[N-1]];--N);var L,V,B,ne,J=u+5<<3,Q=kg(r,th)+kg(i,hw)+a,G=kg(r,f)+kg(i,b)+a+14+3*N+kg(E,I)+(2*E[16]+3*E[17]+7*E[18]);if(J<=Q&&J<=G)return sE(t,d,e.subarray(l,l+u));if(Fl(t,d,1+(G<Q)),d+=2,G<Q){L=ym(f,g),V=f,B=ym(b,x),ne=b;var oe=ym(I,P);for(Fl(t,d,C-257),Fl(t,d+5,R-1),Fl(t,d+10,N-4),d+=14,F=0;F<N;++F)Fl(t,d+3*F,I[SP[F]]);d+=3*N;for(var ce=[_,y],M=0;M<2;++M){var W=ce[M];for(F=0;F<W.length;++F){var j=31&W[F];Fl(t,d,oe[j]),d+=I[j],j>15&&(Fl(t,d,W[F]>>>5&127),d+=W[F]>>>12)}}}else L=lie,V=th,B=cie,ne=hw;for(F=0;F<o;++F)if(s[F]>255){j=s[F]>>>18&31,Sg(t,d,L[j+257]),d+=V[j+257],j>7&&(Fl(t,d,s[F]>>>23&31),d+=eA[j]);var q=31&s[F];Sg(t,d,B[q]),d+=ne[q],q>3&&(Sg(t,d,s[F]>>>5&8191),d+=tA[q])}else Sg(t,d,L[s[F]]),d+=V[s[F]];return Sg(t,d,L[256]),d+V[256]},uie=new vp([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),die=function(){for(var e=new vp(256),t=0;t<256;++t){for(var n=t,s=9;--s;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),hie=function(){var e=4294967295;return{p:function(t){for(var n=e,s=0;s<t.length;++s)n=die[255&n^t[s]]^n>>>8;e=n},d:function(){return 4294967295^e}}},fie=function(e,t,n,s,r){return function(i,a,o,l,u,d){var h=i.length,f=new Da(l+h+5*(1+Math.floor(h/7e3))+u),g=f.subarray(l,f.length-u),v=0;if(!a||h<8)for(var b=0;b<=h;b+=65535){var x=b+65535;x<h?v=sE(g,v,i.subarray(b,x)):(g[b]=d,v=sE(g,v,i.subarray(b,h)))}else{for(var w=uie[a-1],_=w>>>13,C=8191&w,S=(1<<o)-1,y=new Ri(32768),R=new Ri(S+1),E=Math.ceil(o/3),F=2*E,A=function(ue){return(i[ue]^i[ue+1]<<E^i[ue+2]<<F)&S},I=new vp(25e3),P=new Ri(288),N=new Ri(32),L=0,V=0,B=(b=0,0),ne=0,J=0;b<h;++b){var Q=A(b),G=32767&b,oe=R[Q];if(y[G]=oe,R[Q]=G,ne<=b){var ce=h-b;if((L>7e3||B>24576)&&ce>423){v=TP(i,g,0,I,P,N,V,B,J,b-J,v),B=L=V=0,J=b;for(var M=0;M<286;++M)P[M]=0;for(M=0;M<30;++M)N[M]=0}var W=2,j=0,q=C,U=G-oe&32767;if(ce>2&&Q==A(b-U))for(var fe=Math.min(_,ce)-1,ye=Math.min(32767,b),Ae=Math.min(258,ce);U<=ye&&--q&&G!=oe;){if(i[b+W]==i[b+W-U]){for(var z=0;z<Ae&&i[b+z]==i[b+z-U];++z);if(z>W){if(W=z,j=U,z>fe)break;var Te=Math.min(U,z-2),H=0;for(M=0;M<Te;++M){var ve=b-U+M+32768&32767,Fe=ve-y[ve]+32768&32767;Fe>H&&(H=Fe,oe=ve)}}}U+=(G=oe)-(oe=y[G])+32768&32767}if(j){I[B++]=268435456|tE[W]<<18|kP[j];var ie=31&tE[W],re=31&kP[j];V+=eA[ie]+tA[re],++P[257+ie],++N[re],ne=b+W,++L}else I[B++]=i[b],++P[i[b]]}}v=TP(i,g,d,I,P,N,V,B,J,b-J,v)}return e8(f,0,l+Z5(v)+u)}(e,t.level==null?6:t.level,t.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,s,!0)},rE=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},pie=function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&rE(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var s=0;s<=n.length;++s)e[s+10]=n.charCodeAt(s)}},gie=function(e){return 10+(e.filename&&e.filename.length+1||0)};function t8(e,t){t===void 0&&(t={});var n=hie(),s=e.length;n.p(e);var r=fie(e,t,gie(t),8),i=r.length;return pie(r,t),rE(r,i-8,n.d()),rE(r,i-4,s),r}function n8(e,t){var n=e.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(e);for(var s=new Da(e.length+(e.length>>>1)),r=0,i=function(u){s[r++]=u},a=0;a<n;++a){if(r+5>s.length){var o=new Da(r+8+(n-a<<1));o.set(s),s=o}var l=e.charCodeAt(a);l<128||t?i(l):l<2048?(i(192|l>>>6),i(128|63&l)):l>55295&&l<57344?(i(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++a))>>>18),i(128|l>>>12&63),i(128|l>>>6&63),i(128|63&l)):(i(224|l>>>12),i(128|l>>>6&63),i(128|63&l))}return e8(s,0,r)}function mie(e,t){return function(n){for(var s=0,r=0;r<n.length;r++)s=(s<<5)-s+n.charCodeAt(r),s|=0;return Math.abs(s)}(e)%100<Ea(100*t,0,100)}var im="[SessionRecording]",Lr=Zr(im);function gb(){var e,t;return Zt==null||(e=Zt.__PosthogExtensions__)===null||e===void 0||(t=e.rrweb)===null||t===void 0?void 0:t.record}var vie=3e5,bie=[eo.MouseMove,eo.MouseInteraction,eo.Scroll,eo.ViewportResize,eo.Input,eo.TouchMove,eo.MediaInteraction,eo.Drag],RP=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1});function id(e){return function(t,n){for(var s="",r=0;r<t.length;){var i=t[r++];s+=String.fromCharCode(i)}return s}(t8(n8(JSON.stringify(e))))}function AP(e){return e.type===Pl.Custom&&e.data.tag==="sessionIdle"}function FP(e,t){return t.some(n=>n.matching==="regex"&&new RegExp(n.url).test(e))}let xie=class{get sessionIdleThresholdMilliseconds(){return this.instance.config.session_recording.session_idle_threshold_ms||3e5}get started(){return this._captureStarted}get sessionManager(){if(!this.instance.sessionManager)throw new Error(im+" must be started with a valid sessionManager.");return this.instance.sessionManager}get fullSnapshotIntervalMillis(){var t,n;return this.triggerStatus==="trigger_pending"?6e4:(t=(n=this.instance.config.session_recording)===null||n===void 0?void 0:n.full_snapshot_interval_millis)!==null&&t!==void 0?t:vie}get isSampled(){var t=this.instance.get_property(sm);return Ll(t)?t:null}get sessionDuration(){var t,n,s=(t=this.buffer)===null||t===void 0?void 0:t.data[((n=this.buffer)===null||n===void 0?void 0:n.data.length)-1],{sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0);return s?s.timestamp-r:null}get isRecordingEnabled(){var t=!!this.instance.get_property(Uk),n=!this.instance.config.disable_session_recording;return Ue&&t&&n}get isConsoleLogCaptureEnabled(){var t=!!this.instance.get_property(rP),n=this.instance.config.enable_recording_console_log;return n??t}get canvasRecording(){var t,n,s,r,i,a,o=this.instance.config.session_recording.captureCanvas,l=this.instance.get_property(oP),u=(t=(n=o?.recordCanvas)!==null&&n!==void 0?n:l?.enabled)!==null&&t!==void 0&&t,d=(s=(r=o?.canvasFps)!==null&&r!==void 0?r:l?.fps)!==null&&s!==void 0?s:4,h=(i=(a=o?.canvasQuality)!==null&&a!==void 0?a:l?.quality)!==null&&i!==void 0?i:.4;if(typeof h=="string"){var f=parseFloat(h);h=isNaN(f)?.4:f}return{enabled:u,fps:Ea(d,0,12,"canvas recording fps",4),quality:Ea(h,0,1,"canvas recording quality",.4)}}get networkPayloadCapture(){var t,n,s=this.instance.get_property(iP),r={recordHeaders:(t=this.instance.config.session_recording)===null||t===void 0?void 0:t.recordHeaders,recordBody:(n=this.instance.config.session_recording)===null||n===void 0?void 0:n.recordBody},i=r?.recordHeaders||s?.recordHeaders,a=r?.recordBody||s?.recordBody,o=Fs(this.instance.config.capture_performance)?this.instance.config.capture_performance.network_timing:this.instance.config.capture_performance,l=!!(Ll(o)?o:s?.capturePerformance);return i||a||l?{recordHeaders:i,recordBody:a,recordPerformance:l}:void 0}get masking(){var t,n,s,r,i,a,o=this.instance.get_property(aP),l={maskAllInputs:(t=this.instance.config.session_recording)===null||t===void 0?void 0:t.maskAllInputs,maskTextSelector:(n=this.instance.config.session_recording)===null||n===void 0?void 0:n.maskTextSelector,blockSelector:(s=this.instance.config.session_recording)===null||s===void 0?void 0:s.blockSelector},u=(r=l?.maskAllInputs)!==null&&r!==void 0?r:o?.maskAllInputs,d=(i=l?.maskTextSelector)!==null&&i!==void 0?i:o?.maskTextSelector,h=(a=l?.blockSelector)!==null&&a!==void 0?a:o?.blockSelector;return At(u)&&At(d)&&At(h)?void 0:{maskAllInputs:u==null||u,maskTextSelector:d,blockSelector:h}}get sampleRate(){var t=this.instance.get_property(lP);return gi(t)?t:null}get minimumDuration(){var t=this.instance.get_property(cP);return gi(t)?t:null}get status(){return this.receivedDecide?this.isRecordingEnabled?this.isSampled===!1?"disabled":this._urlBlocked?"paused":Wn(this._linkedFlag)||this._linkedFlagSeen?this.triggerStatus==="trigger_pending"?"buffering":Ll(this.isSampled)?this.isSampled?"sampled":"disabled":"active":"buffering":"disabled":"buffering"}get urlTriggerStatus(){var t;return this._urlTriggers.length===0?"trigger_disabled":((t=this.instance)===null||t===void 0?void 0:t.get_property(My))===this.sessionId?"trigger_activated":"trigger_pending"}get eventTriggerStatus(){var t;return this._eventTriggers.length===0?"trigger_disabled":((t=this.instance)===null||t===void 0?void 0:t.get_property(Oy))===this.sessionId?"trigger_activated":"trigger_pending"}get triggerStatus(){var t=this.eventTriggerStatus==="trigger_activated"||this.urlTriggerStatus==="trigger_activated",n=this.eventTriggerStatus==="trigger_pending"||this.urlTriggerStatus==="trigger_pending";return t?"trigger_activated":n?"trigger_pending":"trigger_disabled"}constructor(t){if(bt(this,"queuedRRWebEvents",[]),bt(this,"isIdle","unknown"),bt(this,"_linkedFlagSeen",!1),bt(this,"_lastActivityTimestamp",Date.now()),bt(this,"_linkedFlag",null),bt(this,"_removePageViewCaptureHook",void 0),bt(this,"_onSessionIdListener",void 0),bt(this,"_persistDecideOnSessionListener",void 0),bt(this,"_samplingSessionListener",void 0),bt(this,"_urlTriggers",[]),bt(this,"_urlBlocklist",[]),bt(this,"_urlBlocked",!1),bt(this,"_eventTriggers",[]),bt(this,"_removeEventTriggerCaptureHook",void 0),bt(this,"_forceAllowLocalhostNetworkCapture",!1),bt(this,"_onBeforeUnload",()=>{this._flushBuffer()}),bt(this,"_onOffline",()=>{this._tryAddCustomEvent("browser offline",{})}),bt(this,"_onOnline",()=>{this._tryAddCustomEvent("browser online",{})}),bt(this,"_onVisibilityChange",()=>{if(It!=null&&It.visibilityState){var r="window "+It.visibilityState;this._tryAddCustomEvent(r,{})}}),this.instance=t,this._captureStarted=!1,this._endpoint="/s/",this.stopRrweb=void 0,this.receivedDecide=!1,!this.instance.sessionManager)throw Lr.error("started without valid sessionManager"),new Error(im+" started without valid sessionManager. This is a bug.");if(this.instance.config.__preview_experimental_cookieless_mode)throw new Error(im+" cannot be used with __preview_experimental_cookieless_mode.");var{sessionId:n,windowId:s}=this.sessionManager.checkAndGetSessionAndWindowId();this.sessionId=n,this.windowId=s,this.buffer=this.clearBuffer(),this.sessionIdleThresholdMilliseconds>=this.sessionManager.sessionTimeoutMs&&Lr.warn("session_idle_threshold_ms (".concat(this.sessionIdleThresholdMilliseconds,") is greater than the session timeout (").concat(this.sessionManager.sessionTimeoutMs,"). Session will never be detected as idle"))}startIfEnabledOrStop(t){this.isRecordingEnabled?(this._startCapture(t),Bs(Ue,"beforeunload",this._onBeforeUnload),Bs(Ue,"offline",this._onOffline),Bs(Ue,"online",this._onOnline),Bs(Ue,"visibilitychange",this._onVisibilityChange),this._setupSampling(),this._addEventTriggerListener(),Wn(this._removePageViewCaptureHook)&&(this._removePageViewCaptureHook=this.instance.on("eventCaptured",n=>{try{if(n.event==="$pageview"){var s=n!=null&&n.properties.$current_url?this._maskUrl(n?.properties.$current_url):"";if(!s)return;this._tryAddCustomEvent("$pageview",{href:s})}}catch(r){Lr.error("Could not add $pageview to rrweb session",r)}})),this._onSessionIdListener||(this._onSessionIdListener=this.sessionManager.onSessionId((n,s,r)=>{var i,a,o,l;r&&(this._tryAddCustomEvent("$session_id_change",{sessionId:n,windowId:s,changeReason:r}),(i=this.instance)===null||i===void 0||(a=i.persistence)===null||a===void 0||a.unregister(Oy),(o=this.instance)===null||o===void 0||(l=o.persistence)===null||l===void 0||l.unregister(My))}))):this.stopRecording()}stopRecording(){var t,n,s,r;this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1,Ue?.removeEventListener("beforeunload",this._onBeforeUnload),Ue?.removeEventListener("offline",this._onOffline),Ue?.removeEventListener("online",this._onOnline),Ue?.removeEventListener("visibilitychange",this._onVisibilityChange),this.clearBuffer(),clearInterval(this._fullSnapshotTimer),(t=this._removePageViewCaptureHook)===null||t===void 0||t.call(this),this._removePageViewCaptureHook=void 0,(n=this._removeEventTriggerCaptureHook)===null||n===void 0||n.call(this),this._removeEventTriggerCaptureHook=void 0,(s=this._onSessionIdListener)===null||s===void 0||s.call(this),this._onSessionIdListener=void 0,(r=this._samplingSessionListener)===null||r===void 0||r.call(this),this._samplingSessionListener=void 0,Lr.info("stopped"))}_resetSampling(){var t;(t=this.instance.persistence)===null||t===void 0||t.unregister(sm)}makeSamplingDecision(t){var n,s=this.sessionId!==t,r=this.sampleRate;if(gi(r)){var i=this.isSampled,a=s||!Ll(i),o=a?mie(t,r):i;a&&(o?this._reportStarted("sampled"):Lr.warn("Sample rate (".concat(r,") has determined that this sessionId (").concat(t,") will not be sent to the server.")),this._tryAddCustomEvent("samplingDecisionMade",{sampleRate:r,isSampled:o})),(n=this.instance.persistence)===null||n===void 0||n.register({[sm]:o})}else this._resetSampling()}onRemoteConfig(t){var n,s,r,i,a,o;if(this._tryAddCustomEvent("$remote_config_received",t),this._persistRemoteConfig(t),this._linkedFlag=((n=t.sessionRecording)===null||n===void 0?void 0:n.linkedFlag)||null,(s=t.sessionRecording)!==null&&s!==void 0&&s.endpoint&&(this._endpoint=(o=t.sessionRecording)===null||o===void 0?void 0:o.endpoint),this._setupSampling(),!Wn(this._linkedFlag)&&!this._linkedFlagSeen){var l=Qs(this._linkedFlag)?this._linkedFlag:this._linkedFlag.flag,u=Qs(this._linkedFlag)?null:this._linkedFlag.variant;this.instance.onFeatureFlags((d,h)=>{var f=Fs(h)&&l in h,g=u?h[l]===u:f;g&&this._reportStarted("linked_flag_matched",{linkedFlag:l,linkedVariant:u}),this._linkedFlagSeen=g})}(r=t.sessionRecording)!==null&&r!==void 0&&r.urlTriggers&&(this._urlTriggers=t.sessionRecording.urlTriggers),(i=t.sessionRecording)!==null&&i!==void 0&&i.urlBlocklist&&(this._urlBlocklist=t.sessionRecording.urlBlocklist),(a=t.sessionRecording)!==null&&a!==void 0&&a.eventTriggers&&(this._eventTriggers=t.sessionRecording.eventTriggers),this.receivedDecide=!0,this.startIfEnabledOrStop()}_setupSampling(){gi(this.sampleRate)&&Wn(this._samplingSessionListener)&&(this._samplingSessionListener=this.sessionManager.onSessionId(t=>{this.makeSamplingDecision(t)}))}_persistRemoteConfig(t){if(this.instance.persistence){var n,s=this.instance.persistence,r=()=>{var i,a,o,l,u,d,h,f,g,v=(i=t.sessionRecording)===null||i===void 0?void 0:i.sampleRate,b=Wn(v)?null:parseFloat(v);Wn(b)&&this._resetSampling();var x=(a=t.sessionRecording)===null||a===void 0?void 0:a.minimumDurationMilliseconds;s.register({[Uk]:!!t.sessionRecording,[rP]:(o=t.sessionRecording)===null||o===void 0?void 0:o.consoleLogRecordingEnabled,[iP]:ze({capturePerformance:t.capturePerformance},(l=t.sessionRecording)===null||l===void 0?void 0:l.networkPayloadCapture),[aP]:(u=t.sessionRecording)===null||u===void 0?void 0:u.masking,[oP]:{enabled:(d=t.sessionRecording)===null||d===void 0?void 0:d.recordCanvas,fps:(h=t.sessionRecording)===null||h===void 0?void 0:h.canvasFps,quality:(f=t.sessionRecording)===null||f===void 0?void 0:f.canvasQuality},[lP]:b,[cP]:At(x)?null:x,[uP]:(g=t.sessionRecording)===null||g===void 0?void 0:g.scriptConfig})};r(),(n=this._persistDecideOnSessionListener)===null||n===void 0||n.call(this),this._persistDecideOnSessionListener=this.sessionManager.onSessionId(r)}}log(t){var n,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"log";(n=this.instance.sessionRecording)===null||n===void 0||n.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:s,trace:[],payload:[JSON.stringify(t)]}},timestamp:Date.now()})}_startCapture(t){if(!At(Object.assign)&&!At(Array.from)&&!(this._captureStarted||this.instance.config.disable_session_recording||this.instance.consent.isOptedOut())){var n,s;this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId(),gb()?this._onScriptLoaded():(n=Zt.__PosthogExtensions__)===null||n===void 0||(s=n.loadExternalDependency)===null||s===void 0||s.call(n,this.instance,this.scriptName,r=>{if(r)return Lr.error("could not load recorder",r);this._onScriptLoaded()}),Lr.info("starting"),this.status==="active"&&this._reportStarted(t||"recording_initialized")}}get scriptName(){var t,n,s;return((t=this.instance)===null||t===void 0||(n=t.persistence)===null||n===void 0||(s=n.get_property(uP))===null||s===void 0?void 0:s.script)||"recorder"}isInteractiveEvent(t){var n;return t.type===3&&bie.indexOf((n=t.data)===null||n===void 0?void 0:n.source)!==-1}_updateWindowAndSessionIds(t){var n=this.isInteractiveEvent(t);n||this.isIdle||t.timestamp-this._lastActivityTimestamp>this.sessionIdleThresholdMilliseconds&&(this.isIdle=!0,clearInterval(this._fullSnapshotTimer),this._tryAddCustomEvent("sessionIdle",{eventTimestamp:t.timestamp,lastActivityTimestamp:this._lastActivityTimestamp,threshold:this.sessionIdleThresholdMilliseconds,bufferLength:this.buffer.data.length,bufferSize:this.buffer.size}),this._flushBuffer());var s=!1;if(n&&(this._lastActivityTimestamp=t.timestamp,this.isIdle)){var r=this.isIdle==="unknown";this.isIdle=!1,r||(this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:t.type}),s=!0)}if(!this.isIdle){var{windowId:i,sessionId:a}=this.sessionManager.checkAndGetSessionAndWindowId(!n,t.timestamp),o=this.sessionId!==a,l=this.windowId!==i;this.windowId=i,this.sessionId=a,o||l?(this.stopRecording(),this.startIfEnabledOrStop("session_id_changed")):s&&this._scheduleFullSnapshot()}}_tryRRWebMethod(t){try{return t.rrwebMethod(),!0}catch(n){return this.queuedRRWebEvents.length<10?this.queuedRRWebEvents.push({enqueuedAt:t.enqueuedAt||Date.now(),attempt:t.attempt++,rrwebMethod:t.rrwebMethod}):Lr.warn("could not emit queued rrweb event.",n,t),!1}}_tryAddCustomEvent(t,n){return this._tryRRWebMethod(RP(()=>gb().addCustomEvent(t,n)))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(RP(()=>gb().takeFullSnapshot()))}_onScriptLoaded(){var t,n,s,r,i={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1},a=this.instance.config.session_recording;for(var[o,l]of Object.entries(a||{}))o in i&&(o==="maskInputOptions"?i.maskInputOptions=ze({password:!0},l):i[o]=l);this.canvasRecording&&this.canvasRecording.enabled&&(i.recordCanvas=!0,i.sampling={canvas:this.canvasRecording.fps},i.dataURLOptions={type:"image/webp",quality:this.canvasRecording.quality}),this.masking&&(i.maskAllInputs=(n=this.masking.maskAllInputs)===null||n===void 0||n,i.maskTextSelector=(s=this.masking.maskTextSelector)!==null&&s!==void 0?s:void 0,i.blockSelector=(r=this.masking.blockSelector)!==null&&r!==void 0?r:void 0);var u=gb();if(u){this.mutationRateLimiter=(t=this.mutationRateLimiter)!==null&&t!==void 0?t:new aie(u,{refillRate:this.instance.config.session_recording.__mutationRateLimiterRefillRate,bucketSize:this.instance.config.session_recording.__mutationRateLimiterBucketSize,onBlockedNode:(h,f)=>{var g="Too many mutations on node '".concat(h,"'. Rate limiting. This could be due to SVG animations or something similar");Lr.info(g,{node:f}),this.log(im+" "+g,"warn")}});var d=this._gatherRRWebPlugins();this.stopRrweb=u(ze({emit:h=>{this.onRRwebEmit(h)},plugins:d},i)),this._lastActivityTimestamp=Date.now(),this.isIdle=Ll(this.isIdle)?this.isIdle:"unknown",this._tryAddCustomEvent("$session_options",{sessionRecordingOptions:i,activePlugins:d.map(h=>h?.name)}),this._tryAddCustomEvent("$posthog_config",{config:this.instance.config})}else Lr.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),this.isIdle!==!0){var t=this.fullSnapshotIntervalMillis;t&&(this._fullSnapshotTimer=setInterval(()=>{this._tryTakeFullSnapshot()},t))}}_gatherRRWebPlugins(){var t,n,s,r,i=[],a=(t=Zt.__PosthogExtensions__)===null||t===void 0||(n=t.rrwebPlugins)===null||n===void 0?void 0:n.getRecordConsolePlugin;a&&this.isConsoleLogCaptureEnabled&&i.push(a());var o=(s=Zt.__PosthogExtensions__)===null||s===void 0||(r=s.rrwebPlugins)===null||r===void 0?void 0:r.getRecordNetworkPlugin;return this.networkPayloadCapture&&lo(o)&&(!kre.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?i.push(o(iie(this.instance.config,this.networkPayloadCapture))):Lr.info("NetworkCapture not started because we are on localhost.")),i}onRRwebEmit(t){var n;if(this._processQueuedEvents(),t&&Fs(t)){if(t.type===Pl.Meta){var s=this._maskUrl(t.data.href);if(this._lastHref=s,!s)return;t.data.href=s}else this._pageViewFallBack();if(this._checkUrlTriggerConditions(),!this._urlBlocked||function(h){return h.type===Pl.Custom&&h.data.tag==="recording paused"}(t)){t.type===Pl.FullSnapshot&&this._scheduleFullSnapshot(),t.type===Pl.FullSnapshot&&this.triggerStatus==="trigger_pending"&&this.clearBuffer();var r=this.mutationRateLimiter?this.mutationRateLimiter.throttleMutations(t):t;if(r){var i=function(h){var f=h;if(f&&Fs(f)&&f.type===6&&Fs(f.data)&&f.data.plugin==="rrweb/console@1"){f.data.payload.payload.length>10&&(f.data.payload.payload=f.data.payload.payload.slice(0,10),f.data.payload.payload.push("...[truncated]"));for(var g=[],v=0;v<f.data.payload.payload.length;v++)f.data.payload.payload[v]&&f.data.payload.payload[v].length>2e3?g.push(f.data.payload.payload[v].slice(0,2e3)+"...[truncated]"):g.push(f.data.payload.payload[v]);return f.data.payload.payload=g,h}return h}(r);if(this._updateWindowAndSessionIds(i),this.isIdle!==!0||AP(i)){if(AP(i)){var a=i.data.payload;if(a){var o=a.lastActivityTimestamp,l=a.threshold;i.timestamp=o+l}}var u=(n=this.instance.config.session_recording.compress_events)===null||n===void 0||n?function(h){if(dw(h)<1024)return h;try{if(h.type===Pl.FullSnapshot)return ze(ze({},h),{},{data:id(h.data),cv:"2024-10"});if(h.type===Pl.IncrementalSnapshot&&h.data.source===eo.Mutation)return ze(ze({},h),{},{cv:"2024-10",data:ze(ze({},h.data),{},{texts:id(h.data.texts),attributes:id(h.data.attributes),removes:id(h.data.removes),adds:id(h.data.adds)})});if(h.type===Pl.IncrementalSnapshot&&h.data.source===eo.StyleSheetRule)return ze(ze({},h),{},{cv:"2024-10",data:ze(ze({},h.data),{},{adds:h.data.adds?id(h.data.adds):void 0,removes:h.data.removes?id(h.data.removes):void 0})})}catch(f){Lr.error("could not compress event - will use uncompressed event",f)}return h}(i):i,d={$snapshot_bytes:dw(u),$snapshot_data:u,$session_id:this.sessionId,$window_id:this.windowId};this.status!=="disabled"?this._captureSnapshotBuffered(d):this.clearBuffer()}}}}}_pageViewFallBack(){if(!this.instance.config.capture_pageview&&Ue){var t=this._maskUrl(Ue.location.href);this._lastHref!==t&&(this._tryAddCustomEvent("$url_changed",{href:t}),this._lastHref=t)}}_processQueuedEvents(){if(this.queuedRRWebEvents.length){var t=[...this.queuedRRWebEvents];this.queuedRRWebEvents=[],t.forEach(n=>{Date.now()-n.enqueuedAt<=2e3&&this._tryRRWebMethod(n)})}}_maskUrl(t){var n=this.instance.config.session_recording;if(n.maskNetworkRequestFn){var s,r={url:t};return(s=r=n.maskNetworkRequestFn(r))===null||s===void 0?void 0:s.url}return t}clearBuffer(){return this.buffer={size:0,data:[],sessionId:this.sessionId,windowId:this.windowId},this.buffer}_flushBuffer(){this.flushBufferTimer&&(clearTimeout(this.flushBufferTimer),this.flushBufferTimer=void 0);var t=this.minimumDuration,n=this.sessionDuration,s=gi(n)&&n>=0,r=gi(t)&&s&&n<t;return this.status==="buffering"||this.status==="paused"||this.status==="disabled"||r?(this.flushBufferTimer=setTimeout(()=>{this._flushBuffer()},2e3),this.buffer):(this.buffer.data.length>0&&Jk(this.buffer).forEach(i=>{this._captureSnapshot({$snapshot_bytes:i.size,$snapshot_data:i.data,$session_id:i.sessionId,$window_id:i.windowId,$lib:"web",$lib_version:Ml.LIB_VERSION})}),this.clearBuffer())}_captureSnapshotBuffered(t){var n,s=2+(((n=this.buffer)===null||n===void 0?void 0:n.data.length)||0);!this.isIdle&&(this.buffer.size+t.$snapshot_bytes+s>943718.4||this.buffer.sessionId!==this.sessionId)&&(this.buffer=this._flushBuffer()),this.buffer.size+=t.$snapshot_bytes,this.buffer.data.push(t.$snapshot_data),this.flushBufferTimer||this.isIdle||(this.flushBufferTimer=setTimeout(()=>{this._flushBuffer()},2e3))}_captureSnapshot(t){this.instance.capture("$snapshot",t,{_url:this.instance.requestRouter.endpointFor("api",this._endpoint),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}_checkUrlTriggerConditions(){if(Ue!==void 0&&Ue.location.href){var t=Ue.location.href,n=this._urlBlocked,s=FP(t,this._urlBlocklist);s&&!n?this._pauseRecording():!s&&n&&this._resumeRecording(),FP(t,this._urlTriggers)&&this._activateTrigger("url")}}_activateTrigger(t){var n,s;this.triggerStatus==="trigger_pending"&&((n=this.instance)===null||n===void 0||(s=n.persistence)===null||s===void 0||s.register({[t==="url"?My:Oy]:this.sessionId}),this._flushBuffer(),this._reportStarted(t+"_trigger_matched"))}_pauseRecording(){this._urlBlocked||(this._urlBlocked=!0,clearInterval(this._fullSnapshotTimer),Lr.info("recording paused due to URL blocker"),this._tryAddCustomEvent("recording paused",{reason:"url blocker"}))}_resumeRecording(){this._urlBlocked&&(this._urlBlocked=!1,this._tryTakeFullSnapshot(),this._scheduleFullSnapshot(),this._tryAddCustomEvent("recording resumed",{reason:"left blocked url"}),Lr.info("recording resumed"))}_addEventTriggerListener(){this._eventTriggers.length!==0&&Wn(this._removeEventTriggerCaptureHook)&&(this._removeEventTriggerCaptureHook=this.instance.on("eventCaptured",t=>{try{this._eventTriggers.includes(t.event)&&this._activateTrigger("event")}catch(n){Lr.error("Could not activate event trigger",n)}}))}overrideLinkedFlag(){this._linkedFlagSeen=!0,this._tryTakeFullSnapshot(),this._reportStarted("linked_flag_overridden")}overrideSampling(){var t;(t=this.instance.persistence)===null||t===void 0||t.register({[sm]:!0}),this._tryTakeFullSnapshot(),this._reportStarted("sampling_overridden")}overrideTrigger(t){this._activateTrigger(t)}_reportStarted(t,n){this.instance.register_for_session({$session_recording_start_reason:t}),Lr.info(t.replace("_"," "),n),fn(["recording_initialized","session_id_changed"],t)||this._tryAddCustomEvent(t,n)}get sdkDebugProperties(){var{sessionStartTimestamp:t}=this.sessionManager.checkAndGetSessionAndWindowId(!0);return{$recording_status:this.status,$sdk_debug_replay_internal_buffer_length:this.buffer.data.length,$sdk_debug_replay_internal_buffer_size:this.buffer.size,$sdk_debug_current_session_duration:this.sessionDuration,$sdk_debug_session_start:t}}};var qy=Zr("[SegmentIntegration]");function wie(e,t){var n=e.config.segment;if(!n)return t();(function(s,r){var i=s.config.segment;if(!i)return r();var a=l=>{var u=()=>l.anonymousId()||qc();s.config.get_device_id=u,l.id()&&(s.register({distinct_id:l.id(),$device_id:u()}),s.persistence.set_property(Il,"identified")),r()},o=i.user();"then"in o&&lo(o.then)?o.then(l=>a(l)):a(o)})(e,()=>{n.register((s=>{Promise&&Promise.resolve||qy.warn("This browser does not have Promise support, and can not use the segment integration");var r=(i,a)=>{var o;if(!a)return i;i.event.userId||i.event.anonymousId===s.get_distinct_id()||(qy.info("No userId set, resetting PostHog"),s.reset()),i.event.userId&&i.event.userId!==s.get_distinct_id()&&(qy.info("UserId set, identifying with PostHog"),s.identify(i.event.userId));var l=s._calculate_event_properties(a,(o=i.event.properties)!==null&&o!==void 0?o:{},new Date);return i.event.properties=Object.assign({},l,i.event.properties),i};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:i=>r(i,i.event.event),page:i=>r(i,"$pageview"),identify:i=>r(i,"$identify"),screen:i=>r(i,"$screen")}})(e)).then(()=>{t()})})}var s8="posthog-js";function r8(e){var{organization:t,projectId:n,prefix:s,severityAllowList:r=["error"]}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return i=>{var a,o,l,u,d;if(!(r==="*"||r.includes(i.level))||!e.__loaded)return i;i.tags||(i.tags={});var h=e.requestRouter.endpointFor("ui","/project/".concat(e.config.token,"/person/").concat(e.get_distinct_id()));i.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(i.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var f=((a=i.exception)===null||a===void 0?void 0:a.values)||[],g=f.map(b=>ze(ze({},b),{},{stacktrace:b.stacktrace?ze(ze({},b.stacktrace),{},{type:"raw",frames:(b.stacktrace.frames||[]).map(x=>ze(ze({},x),{},{platform:"web:javascript"}))}):void 0})),v={$exception_message:((o=f[0])===null||o===void 0?void 0:o.value)||i.message,$exception_type:(l=f[0])===null||l===void 0?void 0:l.type,$exception_personURL:h,$exception_level:i.level,$exception_list:g,$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:((u=f[0])===null||u===void 0?void 0:u.value)||i.message,$sentry_exception_type:(d=f[0])===null||d===void 0?void 0:d.type,$sentry_tags:i.tags};return t&&n&&(v.$sentry_url=(s||"https://sentry.io/organizations/")+t+"/issues/?project="+n+"&query="+i.event_id),e.exceptions.sendExceptionEvent(v),i}}let _ie=class{constructor(t,n,s,r,i){this.name=s8,this.setupOnce=function(a){a(r8(t,{organization:n,projectId:s,prefix:r,severityAllowList:i}))}}};var Nl,Cie=Ue!=null&&Ue.location?uw(Ue.location.hash,"__posthog")||uw(location.hash,"state"):null,DP="_postHogToolbarParams",IP=Zr("[Toolbar]");(function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED"})(Nl||(Nl={}));class yie{constructor(t){this.instance=t}setToolbarState(t){Zt.ph_toolbar_state=t}getToolbarState(){var t;return(t=Zt.ph_toolbar_state)!==null&&t!==void 0?t:Nl.UNINITIALIZED}maybeLoadToolbar(){var t,n,s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;if(!Ue||!It)return!1;s=(t=s)!==null&&t!==void 0?t:Ue.location,i=(n=i)!==null&&n!==void 0?n:Ue.history;try{if(!r){try{Ue.localStorage.setItem("test","test"),Ue.localStorage.removeItem("test")}catch{return!1}r=Ue?.localStorage}var a,o=Cie||uw(s.hash,"__posthog")||uw(s.hash,"state"),l=o?ZI(()=>JSON.parse(atob(decodeURIComponent(o))))||ZI(()=>JSON.parse(decodeURIComponent(o))):null;return l&&l.action==="ph_authorize"?((a=l).source="url",a&&Object.keys(a).length>0&&(l.desiredHash?s.hash=l.desiredHash:i?i.replaceState(i.state,"",s.pathname+s.search):s.hash="")):((a=JSON.parse(r.getItem(DP)||"{}")).source="localstorage",delete a.userIntent),!(!a.token||this.instance.config.token!==a.token)&&(this.loadToolbar(a),!0)}catch{return!1}}_callLoadToolbar(t){var n=Zt.ph_load_toolbar||Zt.ph_load_editor;!Wn(n)&&lo(n)?n(t,this.instance):IP.warn("No toolbar load function found")}loadToolbar(t){var n=!(It==null||!It.getElementById(N5));if(!Ue||n)return!1;var s=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,r=ze(ze({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(Ue.localStorage.setItem(DP,JSON.stringify(ze(ze({},r),{},{source:void 0}))),this.getToolbarState()===Nl.LOADED)this._callLoadToolbar(r);else if(this.getToolbarState()===Nl.UNINITIALIZED){var i,a;this.setToolbarState(Nl.LOADING),(i=Zt.__PosthogExtensions__)===null||i===void 0||(a=i.loadExternalDependency)===null||a===void 0||a.call(i,this.instance,"toolbar",o=>{if(o)return IP.error("[Toolbar] Failed to load",o),void this.setToolbarState(Nl.UNINITIALIZED);this.setToolbarState(Nl.LOADED),this._callLoadToolbar(r)}),Bs(Ue,"turbolinks:load",()=>{this.setToolbarState(Nl.UNINITIALIZED),this.loadToolbar(r)})}return!0}_loadEditor(t){return this.loadToolbar(t)}maybeLoadEditor(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;return this.maybeLoadToolbar(t,n,s)}}var Sie=Zr("[TracingHeaders]");class kie{constructor(t){bt(this,"_restoreXHRPatch",void 0),bt(this,"_restoreFetchPatch",void 0),bt(this,"_startCapturing",()=>{var n,s,r,i;At(this._restoreXHRPatch)&&((n=Zt.__PosthogExtensions__)===null||n===void 0||(s=n.tracingHeadersPatchFns)===null||s===void 0||s._patchXHR(this.instance.sessionManager)),At(this._restoreFetchPatch)&&((r=Zt.__PosthogExtensions__)===null||r===void 0||(i=r.tracingHeadersPatchFns)===null||i===void 0||i._patchFetch(this.instance.sessionManager))}),this.instance=t}_loadScript(t){var n,s,r;(n=Zt.__PosthogExtensions__)!==null&&n!==void 0&&n.tracingHeadersPatchFns&&t(),(s=Zt.__PosthogExtensions__)===null||s===void 0||(r=s.loadExternalDependency)===null||r===void 0||r.call(s,this.instance,"tracing-headers",i=>{if(i)return Sie.error("failed to load script",i);t()})}startIfEnabledOrStop(){var t,n;this.instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):((t=this._restoreXHRPatch)===null||t===void 0||t.call(this),(n=this._restoreFetchPatch)===null||n===void 0||n.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}}var Tc=Zr("[Web Vitals]"),PP=9e5;class Eie{constructor(t){var n;bt(this,"_enabledServerSide",!1),bt(this,"_initialized",!1),bt(this,"buffer",{url:void 0,metrics:[],firstMetricTimestamp:void 0}),bt(this,"_flushToCapture",()=>{clearTimeout(this._delayedFlushTimer),this.buffer.metrics.length!==0&&(this.instance.capture("$web_vitals",this.buffer.metrics.reduce((s,r)=>ze(ze({},s),{},{["$web_vitals_".concat(r.name,"_event")]:ze({},r),["$web_vitals_".concat(r.name,"_value")]:r.value}),{})),this.buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})}),bt(this,"_addToBuffer",s=>{var r,i=(r=this.instance.sessionManager)===null||r===void 0?void 0:r.checkAndGetSessionAndWindowId(!0);if(At(i))Tc.error("Could not read session ID. Dropping metrics!");else{this.buffer=this.buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var a=this._currentURL();At(a)||(Wn(s?.name)||Wn(s?.value)?Tc.error("Invalid metric received",s):this._maxAllowedValue&&s.value>=this._maxAllowedValue?Tc.error("Ignoring metric with value >= "+this._maxAllowedValue,s):(this.buffer.url!==a&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),At(this.buffer.url)&&(this.buffer.url=a),this.buffer.firstMetricTimestamp=At(this.buffer.firstMetricTimestamp)?Date.now():this.buffer.firstMetricTimestamp,s.attribution&&s.attribution.interactionTargetElement&&(s.attribution.interactionTargetElement=void 0),this.buffer.metrics.push(ze(ze({},s),{},{$current_url:a,$session_id:i.sessionId,$window_id:i.windowId,timestamp:Date.now()})),this.buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()))}}),bt(this,"_startCapturing",()=>{var s,r,i,a,o=Zt.__PosthogExtensions__;At(o)||At(o.postHogWebVitalsCallbacks)||({onLCP:s,onCLS:r,onFCP:i,onINP:a}=o.postHogWebVitalsCallbacks),s&&r&&i&&a?(this.allowedMetrics.indexOf("LCP")>-1&&s(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&r(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&a(this._addToBuffer.bind(this)),this._initialized=!0):Tc.error("web vitals callbacks not loaded - not starting")}),this.instance=t,this._enabledServerSide=!((n=this.instance.persistence)===null||n===void 0||!n.props[nP]),this.startIfEnabled()}get allowedMetrics(){var t,n,s=Fs(this.instance.config.capture_performance)?(t=this.instance.config.capture_performance)===null||t===void 0?void 0:t.web_vitals_allowed_metrics:void 0;return At(s)?((n=this.instance.persistence)===null||n===void 0?void 0:n.props[sP])||["CLS","FCP","INP","LCP"]:s}get flushToCaptureTimeoutMs(){return(Fs(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var t=Fs(this.instance.config.capture_performance)&&gi(this.instance.config.capture_performance.__web_vitals_max_value)?this.instance.config.capture_performance.__web_vitals_max_value:PP;return 0<t&&t<=6e4?PP:t}get isEnabled(){var t=ki?.protocol;if(t!=="http:"&&t!=="https:")return Tc.info("Web Vitals are disabled on non-http/https protocols"),!1;var n=Fs(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals:Ll(this.instance.config.capture_performance)?this.instance.config.capture_performance:void 0;return Ll(n)?n:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(Tc.info("enabled, starting..."),this.loadScript(this._startCapturing))}onRemoteConfig(t){var n=Fs(t.capturePerformance)&&!!t.capturePerformance.web_vitals,s=Fs(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this.instance.persistence&&(this.instance.persistence.register({[nP]:n}),this.instance.persistence.register({[sP]:s})),this._enabledServerSide=n,this.startIfEnabled()}loadScript(t){var n,s,r;(n=Zt.__PosthogExtensions__)!==null&&n!==void 0&&n.postHogWebVitalsCallbacks&&t(),(s=Zt.__PosthogExtensions__)===null||s===void 0||(r=s.loadExternalDependency)===null||r===void 0||r.call(s,this.instance,"web-vitals",i=>{i?Tc.error("failed to load script",i):t()})}_currentURL(){var t=Ue?Ue.location.href:void 0;return t||Tc.error("Could not determine current URL"),t}}var Tie=Zr("[Heatmaps]");function NP(e){return Fs(e)&&"clientX"in e&&"clientY"in e&&gi(e.clientX)&&gi(e.clientY)}class Rie{constructor(t){var n;bt(this,"rageclicks",new $5),bt(this,"_enabledServerSide",!1),bt(this,"_initialized",!1),bt(this,"_flushInterval",null),this.instance=t,this._enabledServerSide=!((n=this.instance.persistence)===null||n===void 0||!n.props[Hk])}get flushIntervalMilliseconds(){var t=5e3;return Fs(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(t=this.instance.config.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return At(this.instance.config.capture_heatmaps)?At(this.instance.config.enable_heatmaps)?this._enabledServerSide:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;Tie.info("starting..."),this._setupListeners(),this._flushInterval=setInterval(this.flush.bind(this),this.flushIntervalMilliseconds)}else{var t,n;clearInterval((t=this._flushInterval)!==null&&t!==void 0?t:void 0),(n=this.deadClicksCapture)===null||n===void 0||n.stop(),this.getAndClearBuffer()}}onRemoteConfig(t){var n=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Hk]:n}),this._enabledServerSide=n,this.startIfEnabled()}getAndClearBuffer(){var t=this.buffer;return this.buffer=void 0,t}_onDeadClick(t){this._onClick(t.originalEvent,"deadclick")}_setupListeners(){Ue&&It&&(Bs(Ue,"beforeunload",this.flush.bind(this)),Bs(It,"click",t=>this._onClick(t||Ue?.event),{capture:!0}),Bs(It,"mousemove",t=>this._onMouseMove(t||Ue?.event),{capture:!0}),this.deadClicksCapture=new q5(this.instance,Ure,this._onDeadClick.bind(this)),this.deadClicksCapture.startIfEnabled(),this._initialized=!0)}_getProperties(t,n){var s=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),i=this.instance.scrollManager.scrollElement(),a=function(o,l,u){for(var d=o;d&&iC(d)&&!nu(d,"body");){if(d===u)return!1;if(fn(l,Ue?.getComputedStyle(d).position))return!0;d=j5(d)}return!1}(B5(t),["fixed","sticky"],i);return{x:t.clientX+(a?0:r),y:t.clientY+(a?0:s),target_fixed:a,type:n}}_onClick(t){var n,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"click";if(!hP(t.target)&&NP(t)){var r=this._getProperties(t,s);(n=this.rageclicks)!==null&&n!==void 0&&n.isRageClick(t.clientX,t.clientY,new Date().getTime())&&this._capture(ze(ze({},r),{},{type:"rageclick"})),this._capture(r)}}_onMouseMove(t){!hP(t.target)&&NP(t)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(()=>{this._capture(this._getProperties(t,"mousemove"))},500))}_capture(t){if(Ue){var n=Ue.location.href;this.buffer=this.buffer||{},this.buffer[n]||(this.buffer[n]=[]),this.buffer[n].push(t)}}flush(){this.buffer&&!Df(this.buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class Aie{constructor(t){this._instance=t}doPageView(t,n){var s,r=this._previousPageViewProperties(t,n);return this._currentPageview={pathname:(s=Ue?.location.pathname)!==null&&s!==void 0?s:"",pageViewId:n,timestamp:t},this._instance.scrollManager.resetContext(),r}doPageLeave(t){var n;return this._previousPageViewProperties(t,(n=this._currentPageview)===null||n===void 0?void 0:n.pageViewId)}doEvent(){var t;return{$pageview_id:(t=this._currentPageview)===null||t===void 0?void 0:t.pageViewId}}_previousPageViewProperties(t,n){var s=this._currentPageview;if(!s)return{$pageview_id:n};var r={$pageview_id:n,$prev_pageview_id:s.pageViewId},i=this._instance.scrollManager.getContext();if(i&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:a,lastScrollY:o,maxScrollY:l,maxContentHeight:u,lastContentY:d,maxContentY:h}=i;if(!(At(a)||At(o)||At(l)||At(u)||At(d)||At(h))){a=Math.ceil(a),o=Math.ceil(o),l=Math.ceil(l),u=Math.ceil(u),d=Math.ceil(d),h=Math.ceil(h);var f=a<=1?1:Ea(o/a,0,1),g=a<=1?1:Ea(l/a,0,1),v=u<=1?1:Ea(d/u,0,1),b=u<=1?1:Ea(h/u,0,1);r=Os(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:f,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:g,$prev_pageview_last_content:d,$prev_pageview_last_content_percentage:v,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:b})}}return s.pathname&&(r.$prev_pageview_pathname=s.pathname),s.timestamp&&(r.$prev_pageview_duration=(t.getTime()-s.timestamp.getTime())/1e3),r}}let Fie=class{constructor(t){this.instance=t}sendExceptionEvent(t){this.instance.capture("$exception",t,{_noTruncate:!0,_batchKey:"exceptionEvent"})}};var Ia="Mobile",fw="iOS",Xo="Android",w0="Tablet",i8=Xo+" "+w0,a8="iPad",o8="Apple",l8=o8+" Watch",_0="Safari",bp="BlackBerry",c8="Samsung",u8=c8+"Browser",d8=c8+" Internet",nh="Chrome",Die=nh+" OS",h8=nh+" "+fw,nA="Internet Explorer",f8=nA+" "+Ia,sA="Opera",Iie=sA+" Mini",rA="Edge",p8="Microsoft "+rA,Gf="Firefox",g8=Gf+" "+fw,C0="Nintendo",y0="PlayStation",Vf="Xbox",m8=Xo+" "+Ia,v8=Ia+" "+_0,am="Windows",iE=am+" Phone",MP="Nokia",aE="Ouya",b8="Generic",Pie=b8+" "+Ia.toLowerCase(),x8=b8+" "+w0.toLowerCase(),oE="Konqueror",di="(\\d+(\\.\\d+)?)",Ky=new RegExp("Version/"+di),Nie=new RegExp(Vf,"i"),Mie=new RegExp(y0+" \\w+","i"),Oie=new RegExp(C0+" \\w+","i"),iA=new RegExp(bp+"|PlayBook|BB10","i"),Lie={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},lE,Bie=(e,t)=>t&&fn(t,o8)||function(n){return fn(n,_0)&&!fn(n,nh)&&!fn(n,Xo)}(e),OP=function(e,t){return t=t||"",fn(e," OPR/")&&fn(e,"Mini")?Iie:fn(e," OPR/")?sA:iA.test(e)?bp:fn(e,"IE"+Ia)||fn(e,"WPDesktop")?f8:fn(e,u8)?d8:fn(e,rA)||fn(e,"Edg/")?p8:fn(e,"FBIOS")?"Facebook "+Ia:fn(e,"UCWEB")||fn(e,"UCBrowser")?"UC Browser":fn(e,"CriOS")?h8:fn(e,"CrMo")||fn(e,nh)?nh:fn(e,Xo)&&fn(e,_0)?m8:fn(e,"FxiOS")?g8:fn(e.toLowerCase(),oE.toLowerCase())?oE:Bie(e,t)?fn(e,Ia)?v8:_0:fn(e,Gf)?Gf:fn(e,"MSIE")||fn(e,"Trident/")?nA:fn(e,"Gecko")?Gf:""},jie={[f8]:[new RegExp("rv:"+di)],[p8]:[new RegExp(rA+"?\\/"+di)],[nh]:[new RegExp("("+nh+"|CrMo)\\/"+di)],[h8]:[new RegExp("CriOS\\/"+di)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+di)],[_0]:[Ky],[v8]:[Ky],[sA]:[new RegExp("(Opera|OPR)\\/"+di)],[Gf]:[new RegExp(Gf+"\\/"+di)],[g8]:[new RegExp("FxiOS\\/"+di)],[oE]:[new RegExp("Konqueror[:/]?"+di,"i")],[bp]:[new RegExp(bp+" "+di),Ky],[m8]:[new RegExp("android\\s"+di,"i")],[d8]:[new RegExp(u8+"\\/"+di)],[nA]:[new RegExp("(rv:|MSIE )"+di)],Mozilla:[new RegExp("rv:"+di)]},LP=[[new RegExp(Vf+"; "+Vf+" (.*?)[);]","i"),e=>[Vf,e&&e[1]||""]],[new RegExp(C0,"i"),[C0,""]],[new RegExp(y0,"i"),[y0,""]],[iA,[bp,""]],[new RegExp(am,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[iE,""];if(new RegExp(Ia).test(t)&&!/IEMobile\b/.test(t))return[am+" "+Ia,""];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var s=n[1],r=Lie[s]||"";return/arm/i.test(t)&&(r="RT"),[am,r]}return[am,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[fw,t.join(".")]}return[fw,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=At(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+Xo+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Xo+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[Xo,t.join(".")]}return[Xo,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var n=[e[1],e[2],e[3]||"0"];t[1]=n.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Die,""]],[/Linux|debian/i,["Linux",""]]],BP=function(e){return Oie.test(e)?C0:Mie.test(e)?y0:Nie.test(e)?Vf:new RegExp(aE,"i").test(e)?aE:new RegExp("("+iE+"|WPDesktop)","i").test(e)?iE:/iPad/.test(e)?a8:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?l8:iA.test(e)?bp:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(MP,"i").test(e)?MP:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(Ia).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?Xo:i8:Xo:new RegExp("(pda|"+Ia+")","i").test(e)?Pie:new RegExp(w0,"i").test(e)&&!new RegExp(w0+" pc","i").test(e)?x8:""},mb="https?://(.*)",wx=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","irclid","_kx"],Hie=mx(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],wx),Yy="<masked>",ms={campaignParams:function(){var{customTrackedParams:e,maskPersonalDataProperties:t,customPersonalDataProperties:n}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!It)return{};var s=t?mx([],wx,n||[]):[];return this._campaignParamsFromUrl(Ly(It.URL,s,Yy),e)},_campaignParamsFromUrl:function(e,t){var n=Hie.concat(t||[]),s={};return es(n,function(r){var i=cw(e,r);s[r]=i||null}),s},_searchEngine:function(e){return e?e.search(mb+"google.([^/?]*)")===0?"google":e.search(mb+"bing.com")===0?"bing":e.search(mb+"yahoo.com")===0?"yahoo":e.search(mb+"duckduckgo.com")===0?"duckduckgo":null:null},_searchInfoFromReferrer:function(e){var t=ms._searchEngine(e),n=t!="yahoo"?"q":"p",s={};if(!Eu(t)){s.$search_engine=t;var r=It?cw(It.referrer,n):"";r.length&&(s.ph_keyword=r)}return s},searchInfo:function(){var e=It?.referrer;return e?this._searchInfoFromReferrer(e):{}},browser:OP,browserVersion:function(e,t){var n=OP(e,t),s=jie[n];if(At(s))return null;for(var r=0;r<s.length;r++){var i=s[r],a=e.match(i);if(a)return parseFloat(a[a.length-2])}return null},browserLanguage:function(){return navigator.language||navigator.userLanguage},browserLanguagePrefix:function(){var e=this.browserLanguage();return typeof e=="string"?e.split("-")[0]:void 0},os:function(e){for(var t=0;t<LP.length;t++){var[n,s]=LP[t],r=n.exec(e),i=r&&(lo(s)?s(r,e):s);if(i)return i}return["",""]},device:BP,deviceType:function(e){var t=BP(e);return t===a8||t===i8||t==="Kobo"||t==="Kindle Fire"||t===x8?w0:t===C0||t===Vf||t===y0||t===aE?"Console":t===l8?"Wearable":t?Ia:"Desktop"},referrer:function(){return It?.referrer||"$direct"},referringDomain:function(){var e;return It!=null&&It.referrer&&((e=Uf(It.referrer))===null||e===void 0?void 0:e.host)||"$direct"},referrerInfo:function(){return{$referrer:this.referrer(),$referring_domain:this.referringDomain()}},personInfo:function(){var{maskPersonalDataProperties:e,customPersonalDataProperties:t}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=e?mx([],wx,t||[]):[],s=ki?.href.substring(0,1e3);return{r:this.referrer().substring(0,1e3),u:s?Ly(s,n,Yy):void 0}},personPropsFromInfo:function(e){var t,{r:n,u:s}=e,r={$referrer:n,$referring_domain:n==null?void 0:n=="$direct"?"$direct":(t=Uf(n))===null||t===void 0?void 0:t.host};if(s){r.$current_url=s;var i=Uf(s);r.$host=i?.host,r.$pathname=i?.pathname;var a=this._campaignParamsFromUrl(s);Os(r,a)}if(n){var o=this._searchInfoFromReferrer(n);Os(r,o)}return r},initialPersonPropsFromInfo:function(e){var t=this.personPropsFromInfo(e),n={};return es(t,function(s,r){n["$initial_".concat(QR(r))]=s}),n},timezone:function(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}},timezoneOffset:function(){try{return new Date().getTimezoneOffset()}catch{return}},properties:function(){var{maskPersonalDataProperties:e,customPersonalDataProperties:t}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!Ys)return{};var n=e?mx([],wx,t||[]):[],[s,r]=ms.os(Ys);return Os(x0({$os:s,$os_version:r,$browser:ms.browser(Ys,navigator.vendor),$device:ms.device(Ys),$device_type:ms.deviceType(Ys),$timezone:ms.timezone(),$timezone_offset:ms.timezoneOffset()}),{$current_url:Ly(ki?.href,n,Yy),$host:ki?.host,$pathname:ki?.pathname,$raw_user_agent:Ys.length>1e3?Ys.substring(0,997)+"...":Ys,$browser_version:ms.browserVersion(Ys,navigator.vendor),$browser_language:ms.browserLanguage(),$browser_language_prefix:ms.browserLanguagePrefix(),$screen_height:Ue?.screen.height,$screen_width:Ue?.screen.width,$viewport_height:Ue?.innerHeight,$viewport_width:Ue?.innerWidth,$lib:"web",$lib_version:Ml.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})},people_properties:function(){if(!Ys)return{};var[e,t]=ms.os(Ys);return Os(x0({$os:e,$os_version:t,$browser:ms.browser(Ys,navigator.vendor)}),{$browser_version:ms.browserVersion(Ys,navigator.vendor)})}},jo=Zr("[FeatureFlags]"),Xy="$active_feature_flags",nf="$override_feature_flags",jP="$feature_flag_payloads",Eg="$override_feature_flag_payloads",HP="$feature_flag_request_id",UP=e=>{var t={};for(var[n,s]of vx(e||{}))s&&(t[n]=s);return t},Uie=e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map(n=>{var s;return[n,(s=t[n].variant)!==null&&s!==void 0?s:t[n].enabled]})),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter(n=>t[n].enabled).filter(n=>{var s;return(s=t[n].metadata)===null||s===void 0?void 0:s.payload}).map(n=>{var s;return[n,(s=t[n].metadata)===null||s===void 0?void 0:s.payload]}))):jo.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e};(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(lE||(lE={}));class Gie{constructor(t){bt(this,"_override_warning",!1),bt(this,"_hasLoadedFlags",!1),bt(this,"_requestInFlight",!1),bt(this,"_reloadingDisabled",!1),bt(this,"_additionalReloadRequested",!1),bt(this,"_decideCalled",!1),bt(this,"_flagsLoadedFromRemote",!1),this.instance=t,this.featureFlagEventHandlers=[]}decide(){if(this.instance.config.__preview_remote_config)this._decideCalled=!0;else{var t=!this._reloadDebouncer&&(this.instance.config.advanced_disable_feature_flags||this.instance.config.advanced_disable_feature_flags_on_first_load);this._callDecideEndpoint({disableFlags:t})}}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.instance.get_property(Gk),n=this.instance.get_property(nf),s=this.instance.get_property(Eg);if(!s&&!n)return t||{};var r=Os({},t||{}),i=[...new Set([...Object.keys(s||{}),...Object.keys(n||{})])];for(var a of i){var o,l,u=r[a],d=n?.[a],h=At(d)?(o=u?.enabled)!==null&&o!==void 0&&o:!!d,f=At(d)?u.variant:typeof d=="string"?d:void 0,g=s?.[a],v=ze(ze({},u),{},{enabled:h,variant:h?f??u?.variant:void 0});h!==u?.enabled&&(v.original_enabled=u?.enabled),f!==u?.variant&&(v.original_variant=u?.variant),g&&(v.metadata=ze(ze({},u?.metadata),{},{payload:g,original_payload:u==null||(l=u.metadata)===null||l===void 0?void 0:l.payload})),r[a]=v}return this._override_warning||(jo.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:s,finalDetails:r}),this._override_warning=!0),r}getFlagVariants(){var t=this.instance.get_property(If),n=this.instance.get_property(nf);if(!n)return t||{};for(var s=Os({},t),r=Object.keys(n),i=0;i<r.length;i++)s[r[i]]=n[r[i]];return this._override_warning||(jo.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:n,finalFlags:s}),this._override_warning=!0),s}getFlagPayloads(){var t=this.instance.get_property(jP),n=this.instance.get_property(Eg);if(!n)return t||{};for(var s=Os({},t||{}),r=Object.keys(n),i=0;i<r.length;i++)s[r[i]]=n[r[i]];return this._override_warning||(jo.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:n,finalPayloads:s}),this._override_warning=!0),s}reloadFeatureFlags(){this._reloadingDisabled||this.instance.config.advanced_disable_feature_flags||this._reloadDebouncer||(this._reloadDebouncer=setTimeout(()=>{this._callDecideEndpoint()},5))}clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this._reloadingDisabled=t}_callDecideEndpoint(t){var n;if(this.clearDebouncer(),!this.instance.config.advanced_disable_decide)if(this._requestInFlight)this._additionalReloadRequested=!0;else{var s={token:this.instance.config.token,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:ze(ze({},((n=this.instance.persistence)===null||n===void 0?void 0:n.get_initial_props())||{}),this.instance.get_property(rm)||{}),group_properties:this.instance.get_property(hd)};(t!=null&&t.disableFlags||this.instance.config.advanced_disable_feature_flags)&&(s.disable_flags=!0);var r=this.instance.config.__preview_flags_v2&&this.instance.config.__preview_remote_config;r&&(s.timezone=ms.timezone()),this._requestInFlight=!0,this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api",r?"/flags/?v=2":"/decide/?v=4"),data:s,compression:this.instance.config.disable_compression?void 0:so.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:i=>{var a,o,l,u=!0;i.statusCode===200&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),u=!1),this._requestInFlight=!1,this._decideCalled||(this._decideCalled=!0,this.instance._onRemoteConfig((l=i.json)!==null&&l!==void 0?l:{})),s.disable_flags&&!this._additionalReloadRequested||(this._flagsLoadedFromRemote=!u,i.json&&(a=i.json.quotaLimited)!==null&&a!==void 0&&a.includes(lE.FeatureFlags)?jo.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):(this.receivedFeatureFlags((o=i.json)!==null&&o!==void 0?o:{},u),this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callDecideEndpoint())))}})}}getFeatureFlag(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var s=this.getFlagVariants()[t],r="".concat(s),i=this.instance.get_property(HP)||void 0,a=this.instance.get_property(aw)||{};if((n.send_event||!("send_event"in n))&&(!(t in a)||!a[t].includes(r))){var o,l,u,d,h,f,g,v,b,x,w;As(a[t])?a[t].push(r):a[t]=[r],(o=this.instance.persistence)===null||o===void 0||o.register({[aw]:a});var _=this.getFeatureFlagDetails(t),C={$feature_flag:t,$feature_flag_response:s,$feature_flag_payload:this.getFeatureFlagPayload(t)||null,$feature_flag_request_id:i,$feature_flag_bootstrapped_response:((l=this.instance.config.bootstrap)===null||l===void 0||(u=l.featureFlags)===null||u===void 0?void 0:u[t])||null,$feature_flag_bootstrapped_payload:((d=this.instance.config.bootstrap)===null||d===void 0||(h=d.featureFlagPayloads)===null||h===void 0?void 0:h[t])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};At(_==null||(f=_.metadata)===null||f===void 0?void 0:f.version)||(C.$feature_flag_version=_.metadata.version);var S,y=(g=_==null||(v=_.reason)===null||v===void 0?void 0:v.description)!==null&&g!==void 0?g:_==null||(b=_.reason)===null||b===void 0?void 0:b.code;y&&(C.$feature_flag_reason=y),_!=null&&(x=_.metadata)!==null&&x!==void 0&&x.id&&(C.$feature_flag_id=_.metadata.id),At(_?.original_variant)&&At(_?.original_enabled)||(C.$feature_flag_original_response=At(_.original_variant)?_.original_enabled:_.original_variant),_!=null&&(w=_.metadata)!==null&&w!==void 0&&w.original_payload&&(C.$feature_flag_original_payload=_==null||(S=_.metadata)===null||S===void 0?void 0:S.original_payload),this.instance.capture("$feature_flag_called",C)}return s}jo.warn('getFeatureFlag for key "'+t+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){return this.getFlagPayloads()[t]}getRemoteConfigPayload(t,n){var s=this.instance.config.token;this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=4"),data:{distinct_id:this.instance.get_distinct_id(),token:s},compression:this.instance.config.disable_compression?void 0:so.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:r=>{var i,a=(i=r.json)===null||i===void 0?void 0:i.featureFlagPayloads;n(a?.[t]||void 0)}})}isFeatureEnabled(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(t,n);jo.warn('isFeatureEnabled for key "'+t+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(n=>n!==t)}receivedFeatureFlags(t,n){if(this.instance.persistence){this._hasLoadedFlags=!0;var s=this.getFlagVariants(),r=this.getFlagPayloads(),i=this.getFlagsWithDetails();(function(a,o){var l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},u=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},d=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{},h=Uie(a),f=h.flags,g=h.featureFlags,v=h.featureFlagPayloads;if(g){var b=a.requestId;if(As(g)){jo.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var x={};if(g)for(var w=0;w<g.length;w++)x[g[w]]=!0;o&&o.register({[Xy]:g,[If]:x})}else{var _=g,C=v,S=f;a.errorsWhileComputingFlags&&(_=ze(ze({},l),_),C=ze(ze({},u),C),S=ze(ze({},d),S)),o&&o.register(ze({[Xy]:Object.keys(UP(_)),[If]:_||{},[jP]:C||{},[Gk]:S||{}},b?{[HP]:b}:{}))}}})(t,this.instance.persistence,s,r,i),this._fireFeatureFlagsCallbacks(n)}}override(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];jo.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:n})}overrideFeatureFlags(t){if(!this.instance.__loaded||!this.instance.persistence)return jo.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(t===!1)return this.instance.persistence.unregister(nf),this.instance.persistence.unregister(Eg),void this._fireFeatureFlagsCallbacks();if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var n,s=t;if(this._override_warning=!!((n=s.suppressWarning)!==null&&n!==void 0&&n),"flags"in s){if(s.flags===!1)this.instance.persistence.unregister(nf);else if(s.flags)if(As(s.flags)){for(var r={},i=0;i<s.flags.length;i++)r[s.flags[i]]=!0;this.instance.persistence.register({[nf]:r})}else this.instance.persistence.register({[nf]:s.flags})}return"payloads"in s&&(s.payloads===!1?this.instance.persistence.unregister(Eg):s.payloads&&this.instance.persistence.register({[Eg]:s.payloads})),void this._fireFeatureFlagsCallbacks()}this._fireFeatureFlagsCallbacks()}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this._hasLoadedFlags){var{flags:n,flagVariants:s}=this._prepareFeatureFlagsForCallbacks();t(n,s)}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,n){var s,r=(this.instance.get_property(bx)||[]).find(l=>l.flagKey===t),i={["$feature_enrollment/".concat(t)]:n},a={$feature_flag:t,$feature_enrollment:n,$set:i};r&&(a.$early_access_feature_name=r.name),this.instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(i,!1);var o=ze(ze({},this.getFlagVariants()),{},{[t]:n});(s=this.instance.persistence)===null||s===void 0||s.register({[Xy]:Object.keys(UP(o)),[If]:o}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1],s=arguments.length>2?arguments[2]:void 0,r=this.instance.get_property(bx),i=s?"&".concat(s.map(a=>"stage=".concat(a)).join("&")):"";if(r&&!n)return t(r);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/early_access_features/?token=".concat(this.instance.config.token).concat(i)),method:"GET",callback:a=>{var o;if(a.json){var l=a.json.earlyAccessFeatures;return(o=this.instance.persistence)===null||o===void 0||o.register({[bx]:l}),t(l)}}})}_prepareFeatureFlagsForCallbacks(){var t=this.getFlags(),n=this.getFlagVariants();return{flags:t.filter(s=>n[s]),flagVariants:Object.keys(n).filter(s=>n[s]).reduce((s,r)=>(s[r]=n[r],s),{})}}_fireFeatureFlagsCallbacks(t){var{flags:n,flagVariants:s}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach(r=>r(n,s,{errorsLoading:t}))}setPersonPropertiesForFlags(t){var n=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],s=this.instance.get_property(rm)||{};this.instance.register({[rm]:ze(ze({},s),t)}),n&&this.instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this.instance.unregister(rm)}setGroupPropertiesForFlags(t){var n=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],s=this.instance.get_property(hd)||{};Object.keys(s).length!==0&&Object.keys(s).forEach(r=>{s[r]=ze(ze({},s[r]),t[r]),delete t[r]}),this.instance.register({[hd]:ze(ze({},s),t)}),n&&this.instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var n=this.instance.get_property(hd)||{};this.instance.register({[hd]:ze(ze({},n),{},{[t]:{}})})}else this.instance.unregister(hd)}}var Vie=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class Qy{constructor(t){this.config=t,this.props={},this.campaign_params_saved=!1,this.name=(n=>{var s="";return n.token&&(s=n.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),n.persistence_name?"ph_"+n.persistence_name:"ph_"+s+"_posthog"})(t),this.storage=this.buildStorage(t),this.load(),t.debug&&Lt.info("Persistence loaded",t.persistence,ze({},this.props)),this.update_config(t,t),this.save()}buildStorage(t){Vie.indexOf(t.persistence.toLowerCase())===-1&&(Lt.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");var n=t.persistence.toLowerCase();return n==="localstorage"&&Zs.is_supported()?Zs:n==="localstorage+cookie"&&ub.is_supported()?ub:n==="sessionstorage"&&Tr.is_supported()?Tr:n==="memory"?jre:n==="cookie"?$l:ub.is_supported()?ub:$l}properties(){var t={};return es(this.props,function(n,s){if(s===If&&Fs(n))for(var r=Object.keys(n),i=0;i<r.length;i++)t["$feature/".concat(r[i])]=n[r[i]];else o=s,l=!1,(Eu(a=vre)?l:YI&&a.indexOf===YI?a.indexOf(o)!=-1:(es(a,function(u){if(l||(l=u===o))return rw}),l))||(t[s]=n);var a,o,l}),t}load(){if(!this.disabled){var t=this.storage.parse(this.name);t&&(this.props=Os({},t))}}save(){this.disabled||this.storage.set(this.name,this.props,this.expire_days,this.cross_subdomain,this.secure,this.config.debug)}remove(){this.storage.remove(this.name,!1),this.storage.remove(this.name,!0)}clear(){this.remove(),this.props={}}register_once(t,n,s){if(Fs(t)){At(n)&&(n="None"),this.expire_days=At(s)?this.default_expiry:s;var r=!1;if(es(t,(i,a)=>{this.props.hasOwnProperty(a)&&this.props[a]!==n||(this.props[a]=i,r=!0)}),r)return this.save(),!0}return!1}register(t,n){if(Fs(t)){this.expire_days=At(n)?this.default_expiry:n;var s=!1;if(es(t,(r,i)=>{t.hasOwnProperty(i)&&this.props[i]!==r&&(this.props[i]=r,s=!0)}),s)return this.save(),!0}return!1}unregister(t){t in this.props&&(delete this.props[t],this.save())}update_campaign_params(){if(!this.campaign_params_saved){var t=ms.campaignParams({customTrackedParams:this.config.custom_campaign_params,maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties});Df(x0(t))||this.register(t),this.campaign_params_saved=!0}}update_search_keyword(){this.register(ms.searchInfo())}update_referrer_info(){this.register_once(ms.referrerInfo(),void 0)}set_initial_person_info(){this.props[zk]||this.props[qk]||this.register_once({[Kk]:ms.personInfo({maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties})},void 0)}get_referrer_info(){return x0({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}get_initial_props(){var t={};es([qk,zk],r=>{var i=this.props[r];i&&es(i,function(a,o){t["$initial_"+QR(o)]=a})});var n=this.props[Kk];if(n){var s=ms.initialPersonPropsFromInfo(n);Os(t,s)}return t}safe_merge(t){return es(this.props,function(n,s){s in t||(t[s]=n)}),t}update_config(t,n){if(this.default_expiry=this.expire_days=t.cookie_expiration,this.set_disabled(t.disable_persistence),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),t.persistence!==n.persistence){var s=this.buildStorage(t),r=this.props;this.clear(),this.storage=s,this.props=r,this.save()}}set_disabled(t){this.disabled=t,this.disabled?this.remove():this.save()}set_cross_subdomain(t){t!==this.cross_subdomain&&(this.cross_subdomain=t,this.remove(),this.save())}get_cross_subdomain(){return!!this.cross_subdomain}set_secure(t){t!==this.secure&&(this.secure=t,this.remove(),this.save())}set_event_timer(t,n){var s=this.props[nm]||{};s[t]=n,this.props[nm]=s,this.save()}remove_event_timer(t){var n=(this.props[nm]||{})[t];return At(n)||(delete this.props[nm][t],this.save()),n}get_property(t){return this.props[t]}set_property(t,n){this.props[t]=n,this.save()}}var w8,Ds,_8,bd,GP,C8,cE,y8,VP,uE,WP,$P,zP,qP,dE={},S8=[],Wie=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,aA=Array.isArray;function Kc(e,t){for(var n in t)e[n]=t[n];return e}function k8(e){var t=e.parentNode;t&&t.removeChild(e)}function Jy(e,t,n,s,r){var i={type:e,props:t,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:r??++_8,__i:-1,__u:0};return r==null&&Ds.vnode!=null&&Ds.vnode(i),i}function oA(e){return e.children}function _x(e,t){this.props=e,this.context=t}function xp(e,t){if(t==null)return e.__?xp(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?xp(e):null}function E8(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return E8(e)}}function hE(e){(!e.__d&&(e.__d=!0)&&bd.push(e)&&!pw.__r++||GP!==Ds.debounceRendering)&&((GP=Ds.debounceRendering)||C8)(pw)}function pw(){var e,t,n,s,r,i,a,o,l;for(bd.sort(cE);e=bd.shift();)e.__d&&(t=bd.length,s=void 0,i=(r=(n=e).__v).__e,o=[],l=[],(a=n.__P)&&((s=Kc({},r)).__v=r.__v+1,Ds.vnode&&Ds.vnode(s),A8(a,s,r,n.__n,a.ownerSVGElement!==void 0,32&r.__u?[i]:null,o,i??xp(r),!!(32&r.__u),l),s.__.__k[s.__i]=s,qie(o,s,l),s.__e!=i&&E8(s)),bd.length>t&&bd.sort(cE));pw.__r=0}function T8(e,t,n,s,r,i,a,o,l,u,d){var h,f,g,v,b,x=s&&s.__k||S8,w=t.length;for(n.__d=l,$ie(n,t,x),l=n.__d,h=0;h<w;h++)(g=n.__k[h])!=null&&typeof g!="boolean"&&typeof g!="function"&&(f=g.__i===-1?dE:x[g.__i]||dE,g.__i=h,A8(e,g,f,r,i,a,o,l,u,d),v=g.__e,g.ref&&f.ref!=g.ref&&(f.ref&&lA(f.ref,null,g),d.push(g.ref,g.__c||v,g)),b==null&&v!=null&&(b=v),65536&g.__u||f.__k===g.__k?l=R8(g,l,e):typeof g.type=="function"&&g.__d!==void 0?l=g.__d:v&&(l=v.nextSibling),g.__d=void 0,g.__u&=-196609);n.__d=l,n.__e=b}function $ie(e,t,n){var s,r,i,a,o,l=t.length,u=n.length,d=u,h=0;for(e.__k=[],s=0;s<l;s++)(r=e.__k[s]=(r=t[s])==null||typeof r=="boolean"||typeof r=="function"?null:typeof r=="string"||typeof r=="number"||typeof r=="bigint"||r.constructor==String?Jy(null,r,null,null,r):aA(r)?Jy(oA,{children:r},null,null,null):r.constructor===void 0&&r.__b>0?Jy(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):r)!=null?(r.__=e,r.__b=e.__b+1,o=zie(r,n,a=s+h,d),r.__i=o,i=null,o!==-1&&(d--,(i=n[o])&&(i.__u|=131072)),i==null||i.__v===null?(o==-1&&h--,typeof r.type!="function"&&(r.__u|=65536)):o!==a&&(o===a+1?h++:o>a?d>l-a?h+=o-a:h--:h=o<a&&o==a-1?o-a:0,o!==s+h&&(r.__u|=65536))):(i=n[s])&&i.key==null&&i.__e&&(i.__e==e.__d&&(e.__d=xp(i)),fE(i,i,!1),n[s]=null,d--);if(d)for(s=0;s<u;s++)(i=n[s])!=null&&(131072&i.__u)==0&&(i.__e==e.__d&&(e.__d=xp(i)),fE(i,i))}function R8(e,t,n){var s,r;if(typeof e.type=="function"){for(s=e.__k,r=0;s&&r<s.length;r++)s[r]&&(s[r].__=e,t=R8(s[r],t,n));return t}return e.__e!=t&&(n.insertBefore(e.__e,t||null),t=e.__e),t&&t.nextSibling}function zie(e,t,n,s){var r=e.key,i=e.type,a=n-1,o=n+1,l=t[n];if(l===null||l&&r==l.key&&i===l.type)return n;if(s>(l!=null&&(131072&l.__u)==0?1:0))for(;a>=0||o<t.length;){if(a>=0){if((l=t[a])&&(131072&l.__u)==0&&r==l.key&&i===l.type)return a;a--}if(o<t.length){if((l=t[o])&&(131072&l.__u)==0&&r==l.key&&i===l.type)return o;o++}}return-1}function KP(e,t,n){t[0]==="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||Wie.test(t)?n:n+"px"}function vb(e,t,n,s,r){var i;e:if(t==="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof s=="string"&&(e.style.cssText=s=""),s)for(t in s)n&&t in n||KP(e.style,t,"");if(n)for(t in n)s&&n[t]===s[t]||KP(e.style,t,n[t])}else if(t[0]==="o"&&t[1]==="n")i=t!==(t=t.replace(/(PointerCapture)$|Capture$/,"$1")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+i]=n,n?s?n.u=s.u:(n.u=Date.now(),e.addEventListener(t,i?XP:YP,i)):e.removeEventListener(t,i?XP:YP,i);else{if(r)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!=="width"&&t!=="height"&&t!=="href"&&t!=="list"&&t!=="form"&&t!=="tabIndex"&&t!=="download"&&t!=="rowSpan"&&t!=="colSpan"&&t!=="role"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!=="-"?e.removeAttribute(t):e.setAttribute(t,n))}}function YP(e){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(Ds.event?Ds.event(e):e)}function XP(e){return this.l[e.type+!0](Ds.event?Ds.event(e):e)}function A8(e,t,n,s,r,i,a,o,l,u){var d,h,f,g,v,b,x,w,_,C,S,y,R,E,F,A=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),i=[o=t.__e=n.__e]),(d=Ds.__b)&&d(t);e:if(typeof A=="function")try{if(w=t.props,_=(d=A.contextType)&&s[d.__c],C=d?_?_.props.value:d.__:s,n.__c?x=(h=t.__c=n.__c).__=h.__E:("prototype"in A&&A.prototype.render?t.__c=h=new A(w,C):(t.__c=h=new _x(w,C),h.constructor=A,h.render=Yie),_&&_.sub(h),h.props=w,h.state||(h.state={}),h.context=C,h.__n=s,f=h.__d=!0,h.__h=[],h._sb=[]),h.__s==null&&(h.__s=h.state),A.getDerivedStateFromProps!=null&&(h.__s==h.state&&(h.__s=Kc({},h.__s)),Kc(h.__s,A.getDerivedStateFromProps(w,h.__s))),g=h.props,v=h.state,h.__v=t,f)A.getDerivedStateFromProps==null&&h.componentWillMount!=null&&h.componentWillMount(),h.componentDidMount!=null&&h.__h.push(h.componentDidMount);else{if(A.getDerivedStateFromProps==null&&w!==g&&h.componentWillReceiveProps!=null&&h.componentWillReceiveProps(w,C),!h.__e&&(h.shouldComponentUpdate!=null&&h.shouldComponentUpdate(w,h.__s,C)===!1||t.__v===n.__v)){for(t.__v!==n.__v&&(h.props=w,h.state=h.__s,h.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.forEach(function(I){I&&(I.__=t)}),S=0;S<h._sb.length;S++)h.__h.push(h._sb[S]);h._sb=[],h.__h.length&&a.push(h);break e}h.componentWillUpdate!=null&&h.componentWillUpdate(w,h.__s,C),h.componentDidUpdate!=null&&h.__h.push(function(){h.componentDidUpdate(g,v,b)})}if(h.context=C,h.props=w,h.__P=e,h.__e=!1,y=Ds.__r,R=0,"prototype"in A&&A.prototype.render){for(h.state=h.__s,h.__d=!1,y&&y(t),d=h.render(h.props,h.state,h.context),E=0;E<h._sb.length;E++)h.__h.push(h._sb[E]);h._sb=[]}else do h.__d=!1,y&&y(t),d=h.render(h.props,h.state,h.context),h.state=h.__s;while(h.__d&&++R<25);h.state=h.__s,h.getChildContext!=null&&(s=Kc(Kc({},s),h.getChildContext())),f||h.getSnapshotBeforeUpdate==null||(b=h.getSnapshotBeforeUpdate(g,v)),T8(e,aA(F=d!=null&&d.type===oA&&d.key==null?d.props.children:d)?F:[F],t,n,s,r,i,a,o,l,u),h.base=t.__e,t.__u&=-161,h.__h.length&&a.push(h),x&&(h.__E=h.__=null)}catch(I){t.__v=null,l||i!=null?(t.__e=o,t.__u|=l?160:32,i[i.indexOf(o)]=null):(t.__e=n.__e,t.__k=n.__k),Ds.__e(I,t,n)}else i==null&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=Kie(n.__e,t,n,s,r,i,a,l,u);(d=Ds.diffed)&&d(t)}function qie(e,t,n){t.__d=void 0;for(var s=0;s<n.length;s++)lA(n[s],n[++s],n[++s]);Ds.__c&&Ds.__c(t,e),e.some(function(r){try{e=r.__h,r.__h=[],e.some(function(i){i.call(r)})}catch(i){Ds.__e(i,r.__v)}})}function Kie(e,t,n,s,r,i,a,o,l){var u,d,h,f,g,v,b,x=n.props,w=t.props,_=t.type;if(_==="svg"&&(r=!0),i!=null){for(u=0;u<i.length;u++)if((g=i[u])&&"setAttribute"in g==!!_&&(_?g.localName===_:g.nodeType===3)){e=g,i[u]=null;break}}if(e==null){if(_===null)return document.createTextNode(w);e=r?document.createElementNS("http://www.w3.org/2000/svg",_):document.createElement(_,w.is&&w),i=null,o=!1}if(_===null)x===w||o&&e.data===w||(e.data=w);else{if(i=i&&w8.call(e.childNodes),x=n.props||dE,!o&&i!=null)for(x={},u=0;u<e.attributes.length;u++)x[(g=e.attributes[u]).name]=g.value;for(u in x)g=x[u],u=="children"||(u=="dangerouslySetInnerHTML"?h=g:u==="key"||u in w||vb(e,u,null,g,r));for(u in w)g=w[u],u=="children"?f=g:u=="dangerouslySetInnerHTML"?d=g:u=="value"?v=g:u=="checked"?b=g:u==="key"||o&&typeof g!="function"||x[u]===g||vb(e,u,g,x[u],r);if(d)o||h&&(d.__html===h.__html||d.__html===e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(h&&(e.innerHTML=""),T8(e,aA(f)?f:[f],t,n,s,r&&_!=="foreignObject",i,a,i?i[0]:n.__k&&xp(n,0),o,l),i!=null)for(u=i.length;u--;)i[u]!=null&&k8(i[u]);o||(u="value",v!==void 0&&(v!==e[u]||_==="progress"&&!v||_==="option"&&v!==x[u])&&vb(e,u,v,x[u],!1),u="checked",b!==void 0&&b!==e[u]&&vb(e,u,b,x[u],!1))}return e}function lA(e,t,n){try{typeof e=="function"?e(t):e.current=t}catch(s){Ds.__e(s,n)}}function fE(e,t,n){var s,r;if(Ds.unmount&&Ds.unmount(e),(s=e.ref)&&(s.current&&s.current!==e.__e||lA(s,null,t)),(s=e.__c)!=null){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(i){Ds.__e(i,t)}s.base=s.__P=null,e.__c=void 0}if(s=e.__k)for(r=0;r<s.length;r++)s[r]&&fE(s[r],t,n||typeof e.type!="function");n||e.__e==null||k8(e.__e),e.__=e.__e=e.__d=void 0}function Yie(e,t,n){return this.constructor(e,n)}w8=S8.slice,Ds={__e:function(e,t,n,s){for(var r,i,a;t=t.__;)if((r=t.__c)&&!r.__)try{if((i=r.constructor)&&i.getDerivedStateFromError!=null&&(r.setState(i.getDerivedStateFromError(e)),a=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(e,s||{}),a=r.__d),a)return r.__E=r}catch(o){e=o}throw e}},_8=0,_x.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=Kc({},this.state),typeof e=="function"&&(e=e(Kc({},n),this.props)),e&&Kc(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),hE(this))},_x.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),hE(this))},_x.prototype.render=oA,bd=[],C8=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,cE=function(e,t){return e.__v.__b-t.__v.__b},pw.__r=0,y8=0,function(e){e.Button="button",e.Tab="tab",e.Selector="selector"}(VP||(VP={})),function(e){e.Left="left",e.Center="center",e.Right="right",e.NextToTrigger="next_to_trigger"}(uE||(uE={})),function(e){e.Popover="popover",e.API="api",e.Widget="widget"}(WP||(WP={})),function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"}($P||($P={})),function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"}(zP||(zP={})),function(e){e.Once="once",e.Recurring="recurring",e.Always="always"}(qP||(qP={}));var wp=function(e,t){if(!function(n){try{new RegExp(n)}catch{return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}},Sr=Zr("[Surveys]"),QP={icontains:(e,t)=>e.some(n=>t.toLowerCase().includes(n.toLowerCase())),not_icontains:(e,t)=>e.every(n=>!t.toLowerCase().includes(n.toLowerCase())),regex:(e,t)=>e.some(n=>wp(t,n)),not_regex:(e,t)=>e.every(n=>!wp(t,n)),exact:(e,t)=>e.some(n=>t===n),is_not:(e,t)=>e.every(n=>t!==n)};function JP(e){return e??"icontains"}uE.Right;(function(e,t){var n={__c:t="__cC"+y8++,__:e,Consumer:function(s,r){return s.children(r)},Provider:function(s){var r,i;return this.getChildContext||(r=[],(i={})[t]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(a){this.props.value!==a.value&&r.some(function(o){o.__e=!0,hE(o)})},this.sub=function(a){r.push(a);var o=a.componentWillUnmount;a.componentWillUnmount=function(){r.splice(r.indexOf(a),1),o&&o.call(a)}}),s.children}};n.Provider.__=n.Consumer.contextType=n})({isPreviewMode:!1,previewPageIndex:0,onPopupSurveyDismissed:()=>{},isPopup:!0,onPreviewSubmit:()=>{}});let F8=class{constructor(){bt(this,"events",{}),this.events={}}on(t,n){return this.events[t]||(this.events[t]=[]),this.events[t].push(n),()=>{this.events[t]=this.events[t].filter(s=>s!==n)}}emit(t,n){for(var s of this.events[t]||[])s(n);for(var r of this.events["*"]||[])r(t,n)}},Xie=class Cf{constructor(t){bt(this,"_debugEventEmitter",new F8),bt(this,"checkStep",(n,s)=>this.checkStepEvent(n,s)&&this.checkStepUrl(n,s)&&this.checkStepElement(n,s)),bt(this,"checkStepEvent",(n,s)=>s==null||!s.event||n?.event===s?.event),this.instance=t,this.actionEvents=new Set,this.actionRegistry=new Set}init(){var t;if(!At((t=this.instance)===null||t===void 0?void 0:t._addCaptureHook)){var n;(n=this.instance)===null||n===void 0||n._addCaptureHook((s,r)=>{this.on(s,r)})}}register(t){var n,s;if(!At((n=this.instance)===null||n===void 0?void 0:n._addCaptureHook)&&(t.forEach(a=>{var o,l;(o=this.actionRegistry)===null||o===void 0||o.add(a),(l=a.steps)===null||l===void 0||l.forEach(u=>{var d;(d=this.actionEvents)===null||d===void 0||d.add(u?.event||"")})}),(s=this.instance)!==null&&s!==void 0&&s.autocapture)){var r,i=new Set;t.forEach(a=>{var o;(o=a.steps)===null||o===void 0||o.forEach(l=>{l!=null&&l.selector&&i.add(l?.selector)})}),(r=this.instance)===null||r===void 0||r.autocapture.setElementSelectors(i)}}on(t,n){var s;n!=null&&t.length!=0&&(this.actionEvents.has(t)||this.actionEvents.has(n?.event))&&this.actionRegistry&&((s=this.actionRegistry)===null||s===void 0?void 0:s.size)>0&&this.actionRegistry.forEach(r=>{this.checkAction(n,r)&&this._debugEventEmitter.emit("actionCaptured",r.name)})}_addActionHook(t){this.onAction("actionCaptured",n=>t(n))}checkAction(t,n){if(n?.steps==null)return!1;for(var s of n.steps)if(this.checkStep(t,s))return!0;return!1}onAction(t,n){return this._debugEventEmitter.on(t,n)}checkStepUrl(t,n){if(n!=null&&n.url){var s,r=t==null||(s=t.properties)===null||s===void 0?void 0:s.$current_url;if(!r||typeof r!="string"||!Cf.matchString(r,n?.url,n?.url_matching||"contains"))return!1}return!0}static matchString(t,n,s){switch(s){case"regex":return!!Ue&&wp(t,n);case"exact":return n===t;case"contains":var r=Cf.escapeStringRegexp(n).replace(/_/g,".").replace(/%/g,".*");return wp(t,r);default:return!1}}static escapeStringRegexp(t){return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}checkStepElement(t,n){if((n!=null&&n.href||n!=null&&n.tag_name||n!=null&&n.text)&&!this.getElementsList(t).some(i=>!(n!=null&&n.href&&!Cf.matchString(i.href||"",n?.href,n?.href_matching||"exact"))&&(n==null||!n.tag_name||i.tag_name===n?.tag_name)&&!(n!=null&&n.text&&!Cf.matchString(i.text||"",n?.text,n?.text_matching||"exact")&&!Cf.matchString(i.$el_text||"",n?.text,n?.text_matching||"exact"))))return!1;if(n!=null&&n.selector){var s,r=t==null||(s=t.properties)===null||s===void 0?void 0:s.$element_selectors;if(!r||!r.includes(n?.selector))return!1}return!0}getElementsList(t){return t?.properties.$elements==null?[]:t?.properties.$elements}},pE=class D8{constructor(t){this.instance=t,this.eventToSurveys=new Map,this.actionToSurveys=new Map}register(t){var n;At((n=this.instance)===null||n===void 0?void 0:n._addCaptureHook)||(this.setupEventBasedSurveys(t),this.setupActionBasedSurveys(t))}setupActionBasedSurveys(t){var n=t.filter(s=>{var r,i,a,o;return((r=s.conditions)===null||r===void 0?void 0:r.actions)&&((i=s.conditions)===null||i===void 0||(a=i.actions)===null||a===void 0||(o=a.values)===null||o===void 0?void 0:o.length)>0});n.length!==0&&(this.actionMatcher==null&&(this.actionMatcher=new Xie(this.instance),this.actionMatcher.init(),this.actionMatcher._addActionHook(s=>{this.onAction(s)})),n.forEach(s=>{var r,i,a,o,l,u,d,h,f,g;s.conditions&&(r=s.conditions)!==null&&r!==void 0&&r.actions&&(i=s.conditions)!==null&&i!==void 0&&(a=i.actions)!==null&&a!==void 0&&a.values&&((o=s.conditions)===null||o===void 0||(l=o.actions)===null||l===void 0||(u=l.values)===null||u===void 0?void 0:u.length)>0&&((d=this.actionMatcher)===null||d===void 0||d.register(s.conditions.actions.values),(h=s.conditions)===null||h===void 0||(f=h.actions)===null||f===void 0||(g=f.values)===null||g===void 0||g.forEach(v=>{if(v&&v.name){var b=this.actionToSurveys.get(v.name);b&&b.push(s.id),this.actionToSurveys.set(v.name,b||[s.id])}}))}))}setupEventBasedSurveys(t){var n;t.filter(s=>{var r,i,a,o;return((r=s.conditions)===null||r===void 0?void 0:r.events)&&((i=s.conditions)===null||i===void 0||(a=i.events)===null||a===void 0||(o=a.values)===null||o===void 0?void 0:o.length)>0}).length!==0&&((n=this.instance)===null||n===void 0||n._addCaptureHook((s,r)=>{this.onEvent(s,r)}),t.forEach(s=>{var r,i,a;(r=s.conditions)===null||r===void 0||(i=r.events)===null||i===void 0||(a=i.values)===null||a===void 0||a.forEach(o=>{if(o&&o.name){var l=this.eventToSurveys.get(o.name);l&&l.push(s.id),this.eventToSurveys.set(o.name,l||[s.id])}})}))}onEvent(t,n){var s,r,i=((s=this.instance)===null||s===void 0||(r=s.persistence)===null||r===void 0?void 0:r.props[cb])||[];if(D8.SURVEY_SHOWN_EVENT_NAME==t&&n&&i.length>0){var a,o=n==null||(a=n.properties)===null||a===void 0?void 0:a.$survey_id;if(o){var l=i.indexOf(o);l>=0&&(i.splice(l,1),this._updateActivatedSurveys(i))}}else this.eventToSurveys.has(t)&&this._updateActivatedSurveys(i.concat(this.eventToSurveys.get(t)||[]))}onAction(t){var n,s,r=((n=this.instance)===null||n===void 0||(s=n.persistence)===null||s===void 0?void 0:s.props[cb])||[];this.actionToSurveys.has(t)&&this._updateActivatedSurveys(r.concat(this.actionToSurveys.get(t)||[]))}_updateActivatedSurveys(t){var n,s;(n=this.instance)===null||n===void 0||(s=n.persistence)===null||s===void 0||s.register({[cb]:[...new Set(t)]})}getSurveys(){var t,n,s=(t=this.instance)===null||t===void 0||(n=t.persistence)===null||n===void 0?void 0:n.props[cb];return s||[]}getEventToSurveys(){return this.eventToSurveys}_getActionMatcher(){return this.actionMatcher}};bt(pE,"SURVEY_SHOWN_EVENT_NAME","survey shown");let Qie=class{constructor(t){bt(this,"_isFetchingSurveys",!1),bt(this,"_isInitializingSurveys",!1),bt(this,"_surveyCallbacks",[]),this.instance=t,this._surveyEventReceiver=null}onRemoteConfig(t){var n=t.surveys;if(Wn(n))return Sr.warn("Decide not loaded yet. Not loading surveys.");var s=As(n);this._hasSurveys=s?n.length>0:n,Sr.info("decide response received, hasSurveys: ".concat(this._hasSurveys)),this._hasSurveys&&this.loadIfEnabled()}reset(){localStorage.removeItem("lastSeenSurveyDate");var t=(()=>{for(var n=[],s=0;s<localStorage.length;s++){var r=localStorage.key(s);r!=null&&r.startsWith("seenSurvey_")&&n.push(r)}return n})();t.forEach(n=>localStorage.removeItem(n))}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)Sr.info("Already initializing surveys, skipping...");else if(this.instance.config.disable_surveys)Sr.info("Disabled. Not loading surveys.");else{var t=Zt?.__PosthogExtensions__;if(t)if(this._hasSurveys){this._isInitializingSurveys=!0;try{var n=t.generateSurveys;if(n)this._surveyManager=n(this.instance),this._isInitializingSurveys=!1,this._surveyEventReceiver=new pE(this.instance),Sr.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0});else{var s=t.loadExternalDependency;if(s)s(this.instance,"surveys",i=>{if(i||!t.generateSurveys)return Sr.error("Could not load surveys script",i),void(this._isInitializingSurveys=!1);this._surveyManager=t.generateSurveys(this.instance),this._isInitializingSurveys=!1,this._surveyEventReceiver=new pE(this.instance),Sr.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})});else{var r="PostHog loadExternalDependency extension not found. Cannot load remote config.";Sr.error(r),this._isInitializingSurveys=!1,this._notifySurveyCallbacks({isLoaded:!1,error:r})}}}catch(i){throw Sr.error("Error initializing surveys",i),this._isInitializingSurveys=!1,this._notifySurveyCallbacks({isLoaded:!1,error:"Error initializing surveys"}),i}}else Sr.info("No surveys to load.");else Sr.error("PostHog Extensions not found.")}}onSurveysLoaded(t){return this._surveyCallbacks.push(t),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter(n=>n!==t)}}getSurveys(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(this.instance.config.disable_surveys)return Sr.info("Disabled. Not loading surveys."),t([]);var s=this.instance.get_property(Vk);if(s&&!n)return t(s,{isLoaded:!0});if(this._isFetchingSurveys)return t([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this._isFetchingSurveys=!0,this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/surveys/?token=".concat(this.instance.config.token)),method:"GET",timeout:this.instance.config.surveys_request_timeout_ms,callback:r=>{var i;this._isFetchingSurveys=!1;var a=r.statusCode;if(a!==200||!r.json){var o="Surveys API could not be loaded, status: ".concat(a);return Sr.error(o),t([],{isLoaded:!1,error:o})}var l,u=r.json.surveys||[],d=u.filter(h=>{var f,g,v,b,x,w,_,C,S,y,R,E;return((f=h.conditions)===null||f===void 0?void 0:f.events)&&((g=h.conditions)===null||g===void 0||(v=g.events)===null||v===void 0?void 0:v.values)&&((b=h.conditions)===null||b===void 0||(x=b.events)===null||x===void 0||(w=x.values)===null||w===void 0?void 0:w.length)>0||((_=h.conditions)===null||_===void 0?void 0:_.actions)&&((C=h.conditions)===null||C===void 0||(S=C.actions)===null||S===void 0?void 0:S.values)&&((y=h.conditions)===null||y===void 0||(R=y.actions)===null||R===void 0||(E=R.values)===null||E===void 0?void 0:E.length)>0});return d.length>0&&((l=this._surveyEventReceiver)===null||l===void 0||l.register(d)),(i=this.instance.persistence)===null||i===void 0||i.register({[Vk]:u}),t(u,{isLoaded:!0})}})}catch(r){throw this._isFetchingSurveys=!1,r}}_notifySurveyCallbacks(t){for(var n of this._surveyCallbacks)try{t.isLoaded?this.getSurveys(n):n([],t)}catch(s){Sr.error("Error in survey callback",s)}}isSurveyFeatureFlagEnabled(t){return!t||this.instance.featureFlags.isFeatureEnabled(t)}getActiveMatchingSurveys(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.getSurveys(s=>{var r,i=s.filter(l=>!(!l.start_date||l.end_date)).filter(l=>{var u;if(!l.conditions)return!0;var d=function(g){var v,b,x;if((v=g.conditions)===null||v===void 0||!v.url)return!0;var w=Ue==null||(b=Ue.location)===null||b===void 0?void 0:b.href;if(!w)return!1;var _=[g.conditions.url];return QP[JP((x=g.conditions)===null||x===void 0?void 0:x.urlMatchType)](_,w)}(l),h=(u=l.conditions)===null||u===void 0||!u.selector||It?.querySelector(l.conditions.selector),f=function(g){var v,b,x;if((v=g.conditions)===null||v===void 0||!v.deviceTypes||((b=g.conditions)===null||b===void 0?void 0:b.deviceTypes.length)===0)return!0;if(!Ys)return!1;var w=ms.deviceType(Ys);return QP[JP((x=g.conditions)===null||x===void 0?void 0:x.deviceTypesMatchType)](g.conditions.deviceTypes,w)}(l);return d&&h&&f}),a=(r=this._surveyEventReceiver)===null||r===void 0?void 0:r.getSurveys(),o=i.filter(l=>{var u,d,h,f,g,v,b,x,w;if(!(l.linked_flag_key||l.targeting_flag_key||l.internal_targeting_flag_key||(u=l.feature_flag_keys)!==null&&u!==void 0&&u.length))return!0;var _=this.isSurveyFeatureFlagEnabled(l.linked_flag_key),C=this.isSurveyFeatureFlagEnabled(l.targeting_flag_key),S=((d=(h=l.conditions)===null||h===void 0||(f=h.events)===null||f===void 0||(g=f.values)===null||g===void 0?void 0:g.length)!==null&&d!==void 0?d:0)>0,y=((v=(b=l.conditions)===null||b===void 0||(x=b.actions)===null||x===void 0||(w=x.values)===null||w===void 0?void 0:w.length)!==null&&v!==void 0?v:0)>0,R=!S&&!y||a?.includes(l.id),E=this._canActivateRepeatedly(l)||this.isSurveyFeatureFlagEnabled(l.internal_targeting_flag_key),F=this.checkFlags(l);return _&&C&&E&&R&&F});return t(o)},n)}checkFlags(t){var n;return(n=t.feature_flag_keys)===null||n===void 0||!n.length||t.feature_flag_keys.every(s=>{var{key:r,value:i}=s;return!r||!i||this.instance.featureFlags.isFeatureEnabled(i)})}_canActivateRepeatedly(t){var n;return Wn((n=Zt.__PosthogExtensions__)===null||n===void 0?void 0:n.canActivateRepeatedly)?(Sr.warn("init was not called"),!1):Zt.__PosthogExtensions__.canActivateRepeatedly(t)}canRenderSurvey(t){if(Wn(this._surveyManager))return Sr.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var n=null;return this.getSurveys(s=>{var r=s.filter(i=>i.id===t)[0];n=r?ze({},this._surveyManager.canRenderSurvey(r)):{visible:!1,disabledReason:"Survey not found"}}),n}renderSurvey(t,n){Wn(this._surveyManager)?Sr.warn("init was not called"):this.getSurveys(s=>{var r=s.filter(i=>i.id===t)[0];this._surveyManager.renderSurvey(r,It?.querySelector(n))})}};var ZP=Zr("[RateLimiter]");let Jie=class{constructor(t){var n,s;bt(this,"serverLimits",{}),bt(this,"lastEventRateLimited",!1),bt(this,"checkForLimiting",r=>{var i=r.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach(a=>{ZP.info("".concat(a||"events"," is quota limited.")),this.serverLimits[a]=new Date().getTime()+6e4})}catch(a){return void ZP.warn('could not rate limit - continuing. Error: "'.concat(a?.message,'"'),{text:i})}}),this.instance=t,this.captureEventsPerSecond=((n=t.config.rate_limiting)===null||n===void 0?void 0:n.events_per_second)||10,this.captureEventsBurstLimit=Math.max(((s=t.config.rate_limiting)===null||s===void 0?void 0:s.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(){var t,n,s,r=arguments.length>0&&arguments[0]!==void 0&&arguments[0],i=new Date().getTime(),a=(t=(n=this.instance.persistence)===null||n===void 0?void 0:n.get_property($k))!==null&&t!==void 0?t:{tokens:this.captureEventsBurstLimit,last:i};a.tokens+=(i-a.last)/1e3*this.captureEventsPerSecond,a.last=i,a.tokens>this.captureEventsBurstLimit&&(a.tokens=this.captureEventsBurstLimit);var o=a.tokens<1;return o||r||(a.tokens=Math.max(0,a.tokens-1)),!o||this.lastEventRateLimited||r||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to ".concat(this.captureEventsPerSecond," events per second and ").concat(this.captureEventsBurstLimit," events burst limit.")},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=o,(s=this.instance.persistence)===null||s===void 0||s.set_property($k,a),{isRateLimited:o,remainingTokens:a.tokens}}isServerRateLimited(t){var n=this.serverLimits[t||"events"]||!1;return n!==!1&&new Date().getTime()<n}};var ad=Zr("[RemoteConfig]");let Zie=class{constructor(t){this.instance=t}get remoteConfig(){var t,n;return(t=Zt._POSTHOG_REMOTE_CONFIG)===null||t===void 0||(n=t[this.instance.config.token])===null||n===void 0?void 0:n.config}_loadRemoteConfigJs(t){var n,s,r;(n=Zt.__PosthogExtensions__)!==null&&n!==void 0&&n.loadExternalDependency?(s=Zt.__PosthogExtensions__)===null||s===void 0||(r=s.loadExternalDependency)===null||r===void 0||r.call(s,this.instance,"remote-config",()=>t(this.remoteConfig)):(ad.error("PostHog Extensions not found. Cannot load remote config."),t())}_loadRemoteConfigJSON(t){this.instance._send_request({method:"GET",url:this.instance.requestRouter.endpointFor("assets","/array/".concat(this.instance.config.token,"/config")),callback:n=>{t(n.json)}})}load(){try{if(this.remoteConfig)return ad.info("Using preloaded remote config",this.remoteConfig),void this.onRemoteConfig(this.remoteConfig);if(this.instance.config.advanced_disable_decide)return void ad.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(t=>{if(!t)return ad.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON(n=>{this.onRemoteConfig(n)});this.onRemoteConfig(t)})}catch(t){ad.error("Error loading remote config",t)}}onRemoteConfig(t){t?this.instance.config.__preview_remote_config?(this.instance._onRemoteConfig(t),t.hasFeatureFlags!==!1&&this.instance.featureFlags.ensureFlagsLoaded()):ad.info("__preview_remote_config is disabled. Logging config instead",t):ad.error("Failed to fetch remote config from PostHog.")}};var eae=function(e){var t,n,s,r,i="";for(t=n=0,s=(e=(e+"").replace(/\r\n/g,`
4
4
  `).replace(/\r/g,`
5
5
  `)).length,r=0;r<s;r++){var a=e.charCodeAt(r),o=null;a<128?n++:o=a>127&&a<2048?String.fromCharCode(a>>6|192,63&a|128):String.fromCharCode(a>>12|224,a>>6&63|128,63&a|128),Eu(o)||(n>t&&(i+=e.substring(t,n)),i+=o,t=n=r+1)}return n>t&&(i+=e.substring(t,e.length)),i},tae=!!Bk||!!Lk,eN="text/plain",gw=(e,t)=>{var[n,s]=e.split("?"),r=ze({},t);s?.split("&").forEach(a=>{var[o]=a.split("=");delete r[o]});var i=Ere(r);return i=i?(s?s+"&":"")+i:s,"".concat(n,"?").concat(i)},om=(e,t)=>JSON.stringify(e,(n,s)=>typeof s=="bigint"?s.toString():s,t),Zy=e=>{var{data:t,compression:n}=e;if(t){if(n===so.GZipJS){var s=t8(n8(om(t)),{mtime:0}),r=new Blob([s],{type:eN});return{contentType:eN,body:r,estimatedSize:r.size}}if(n===so.Base64){var i=function(l){var u,d,h,f,g,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",b=0,x=0,w="",_=[];if(!l)return l;l=eae(l);do u=(g=l.charCodeAt(b++)<<16|l.charCodeAt(b++)<<8|l.charCodeAt(b++))>>18&63,d=g>>12&63,h=g>>6&63,f=63&g,_[x++]=v.charAt(u)+v.charAt(d)+v.charAt(h)+v.charAt(f);while(b<l.length);switch(w=_.join(""),l.length%3){case 1:w=w.slice(0,-2)+"==";break;case 2:w=w.slice(0,-1)+"="}return w}(om(t)),a=(l=>"data="+encodeURIComponent(typeof l=="string"?l:om(l)))(i);return{contentType:"application/x-www-form-urlencoded",body:a,estimatedSize:new Blob([a]).size}}var o=om(t);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},Sm=[];Lk&&Sm.push({transport:"fetch",method:e=>{var t,n,{contentType:s,body:r,estimatedSize:i}=(t=Zy(e))!==null&&t!==void 0?t:{},a=new Headers;es(e.headers,function(d,h){a.append(h,d)}),s&&a.append("Content-Type",s);var o=e.url,l=null;if(XI){var u=new XI;l={signal:u.signal,timeout:setTimeout(()=>u.abort(),e.timeout)}}Lk(o,ze({method:e?.method||"GET",headers:a,keepalive:e.method==="POST"&&(i||0)<52428.8,body:r,signal:(n=l)===null||n===void 0?void 0:n.signal},e.fetchOptions)).then(d=>d.text().then(h=>{var f,g={statusCode:d.status,text:h};if(d.status===200)try{g.json=JSON.parse(h)}catch(v){Lt.error(v)}(f=e.callback)===null||f===void 0||f.call(e,g)})).catch(d=>{var h;Lt.error(d),(h=e.callback)===null||h===void 0||h.call(e,{statusCode:0,text:d})}).finally(()=>l?clearTimeout(l.timeout):null)}}),Bk&&Sm.push({transport:"XHR",method:e=>{var t,n=new Bk;n.open(e.method||"GET",e.url,!0);var{contentType:s,body:r}=(t=Zy(e))!==null&&t!==void 0?t:{};es(e.headers,function(i,a){n.setRequestHeader(a,i)}),s&&n.setRequestHeader("Content-Type",s),e.timeout&&(n.timeout=e.timeout),n.withCredentials=!0,n.onreadystatechange=()=>{if(n.readyState===4){var i,a={statusCode:n.status,text:n.responseText};if(n.status===200)try{a.json=JSON.parse(n.responseText)}catch{}(i=e.callback)===null||i===void 0||i.call(e,a)}},n.send(r)}}),Zi!=null&&Zi.sendBeacon&&Sm.push({transport:"sendBeacon",method:e=>{var t=gw(e.url,{beacon:"1"});try{var n,{contentType:s,body:r}=(n=Zy(e))!==null&&n!==void 0?n:{},i=typeof r=="string"?new Blob([r],{type:s}):r;Zi.sendBeacon(t,i)}catch{}}});var gE=3e3;let nae=class{constructor(t,n){bt(this,"isPaused",!0),bt(this,"queue",[]),this.flushTimeoutMs=Ea(n?.flush_interval_ms||gE,250,5e3,"flush interval",gE),this.sendRequest=t}enqueue(t){this.queue.push(t),this.flushTimeout||this.setFlushTimeout()}unload(){this.clearFlushTimeout();var t=this.queue.length>0?this.formatQueue():{},n=Object.values(t),s=[...n.filter(r=>r.url.indexOf("/e")===0),...n.filter(r=>r.url.indexOf("/e")!==0)];s.map(r=>{this.sendRequest(ze(ze({},r),{},{transport:"sendBeacon"}))})}enable(){this.isPaused=!1,this.setFlushTimeout()}setFlushTimeout(){var t=this;this.isPaused||(this.flushTimeout=setTimeout(()=>{if(this.clearFlushTimeout(),this.queue.length>0){var n=this.formatQueue(),s=function(i){var a=n[i],o=new Date().getTime();a.data&&As(a.data)&&es(a.data,l=>{l.offset=Math.abs(l.timestamp-o),delete l.timestamp}),t.sendRequest(a)};for(var r in n)s(r)}},this.flushTimeoutMs))}clearFlushTimeout(){clearTimeout(this.flushTimeout),this.flushTimeout=void 0}formatQueue(){var t={};return es(this.queue,n=>{var s,r=n,i=(r?r.batchKey:null)||r.url;At(t[i])&&(t[i]=ze(ze({},r),{},{data:[]})),(s=t[i].data)===null||s===void 0||s.push(r.data)}),this.queue=[],t}};var sae=["retriesPerformedSoFar"];let rae=class{constructor(t){bt(this,"isPolling",!1),bt(this,"pollIntervalMs",3e3),bt(this,"queue",[]),this.instance=t,this.queue=[],this.areWeOnline=!0,!At(Ue)&&"onLine"in Ue.navigator&&(this.areWeOnline=Ue.navigator.onLine,Bs(Ue,"online",()=>{this.areWeOnline=!0,this.flush()}),Bs(Ue,"offline",()=>{this.areWeOnline=!1}))}retriableRequest(t){var{retriesPerformedSoFar:n}=t,s=F5(t,sae);gi(n)&&n>0&&(s.url=gw(s.url,{retry_count:n})),this.instance._send_request(ze(ze({},s),{},{callback:r=>{var i;r.statusCode!==200&&(r.statusCode<400||r.statusCode>=500)&&(n??0)<10?this.enqueue(ze({retriesPerformedSoFar:n},s)):(i=s.callback)===null||i===void 0||i.call(s,r)}}))}enqueue(t){var n=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=n+1;var s=function(a){var o=3e3*Math.pow(2,a),l=o/2,u=Math.min(18e5,o),d=(Math.random()-.5)*(u-l);return Math.ceil(u+d)}(n),r=Date.now()+s;this.queue.push({retryAt:r,requestOptions:t});var i="Enqueued failed request for retry in ".concat(s);navigator.onLine||(i+=" (Browser is offline)"),Lt.warn(i),this.isPolling||(this.isPolling=!0,this.poll())}poll(){this.poller&&clearTimeout(this.poller),this.poller=setTimeout(()=>{this.areWeOnline&&this.queue.length>0&&this.flush(),this.poll()},this.pollIntervalMs)}flush(){var t=Date.now(),n=[],s=this.queue.filter(i=>i.retryAt<t||(n.push(i),!1));if(this.queue=n,s.length>0)for(var{requestOptions:r}of s)this.retriableRequest(r)}unload(){for(var{requestOptions:t}of(this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.queue))try{this.instance._send_request(ze(ze({},t),{},{transport:"sendBeacon"}))}catch(n){Lt.error(n)}this.queue=[]}},iae=class{constructor(t){bt(this,"_updateScrollData",()=>{var n,s,r,i;this.context||(this.context={});var a=this.scrollElement(),o=this.scrollY(),l=a?Math.max(0,a.scrollHeight-a.clientHeight):0,u=o+(a?.clientHeight||0),d=a?.scrollHeight||0;this.context.lastScrollY=Math.ceil(o),this.context.maxScrollY=Math.max(o,(n=this.context.maxScrollY)!==null&&n!==void 0?n:0),this.context.maxScrollHeight=Math.max(l,(s=this.context.maxScrollHeight)!==null&&s!==void 0?s:0),this.context.lastContentY=u,this.context.maxContentY=Math.max(u,(r=this.context.maxContentY)!==null&&r!==void 0?r:0),this.context.maxContentHeight=Math.max(d,(i=this.context.maxContentHeight)!==null&&i!==void 0?i:0)}),this.instance=t}getContext(){return this.context}resetContext(){var t=this.context;return setTimeout(this._updateScrollData,0),t}startMeasuringScrollPosition(){Bs(Ue,"scroll",this._updateScrollData,{capture:!0}),Bs(Ue,"scrollend",this._updateScrollData,{capture:!0}),Bs(Ue,"resize",this._updateScrollData)}scrollElement(){if(!this.instance.config.scroll_root_selector)return Ue?.document.documentElement;var t=As(this.instance.config.scroll_root_selector)?this.instance.config.scroll_root_selector:[this.instance.config.scroll_root_selector];for(var n of t){var s=Ue?.document.querySelector(n);if(s)return s}}scrollY(){if(this.instance.config.scroll_root_selector){var t=this.scrollElement();return t&&t.scrollTop||0}return Ue&&(Ue.scrollY||Ue.pageYOffset||Ue.document.documentElement.scrollTop)||0}scrollX(){if(this.instance.config.scroll_root_selector){var t=this.scrollElement();return t&&t.scrollLeft||0}return Ue&&(Ue.scrollX||Ue.pageXOffset||Ue.document.documentElement.scrollLeft)||0}};var aae=e=>ms.personInfo({maskPersonalDataProperties:e?.config.mask_personal_data_properties,customPersonalDataProperties:e?.config.custom_personal_data_properties});let oae=class{constructor(t,n,s,r){bt(this,"_onSessionIdCallback",i=>{var a=this._getStored();if(!a||a.sessionId!==i){var o={sessionId:i,props:this._sessionSourceParamGenerator(this.instance)};this._persistence.register({[Wk]:o})}}),this.instance=t,this._sessionIdManager=n,this._persistence=s,this._sessionSourceParamGenerator=r||aae,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[Wk]}getSetOnceProps(){var t,n=(t=this._getStored())===null||t===void 0?void 0:t.props;return n?"r"in n?ms.personPropsFromInfo(n):{$referring_domain:n.referringDomain,$pathname:n.initialPathName,utm_source:n.utm_source,utm_campaign:n.utm_campaign,utm_medium:n.utm_medium,utm_content:n.utm_content,utm_term:n.utm_term}:{}}getSessionProps(){var t={};return es(x0(this.getSetOnceProps()),(n,s)=>{s==="$current_url"&&(s="url"),t["$session_entry_".concat(QR(s))]=n}),t}};var tN=Zr("[SessionId]");let lae=class{constructor(t,n,s){var r;if(bt(this,"_sessionIdChangedHandlers",[]),!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.__preview_experimental_cookieless_mode)throw new Error("SessionIdManager cannot be used with __preview_experimental_cookieless_mode");this.config=t.config,this.persistence=t.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=n||qc,this._windowIdGenerator=s||qc;var i=this.config.persistence_name||this.config.token,a=this.config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Ea(a,60,36e3,"session_idle_timeout_seconds",1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.resetIdleTimer(),this._window_id_storage_key="ph_"+i+"_window_id",this._primary_window_exists_storage_key="ph_"+i+"_primary_window_exists",this._canUseSessionStorage()){var o=Tr.parse(this._window_id_storage_key),l=Tr.parse(this._primary_window_exists_storage_key);o&&!l?this._windowId=o:Tr.remove(this._window_id_storage_key),Tr.set(this._primary_window_exists_storage_key,!0)}if((r=this.config.bootstrap)!==null&&r!==void 0&&r.sessionID)try{var u=(d=>{var h=d.replace(/-/g,"");if(h.length!==32)throw new Error("Not a valid UUID");if(h[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(h.substring(0,12),16)})(this.config.bootstrap.sessionID);this._setSessionId(this.config.bootstrap.sessionID,new Date().getTime(),u)}catch(d){tN.error("Invalid sessionID in bootstrap",d)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return At(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(t),this._sessionId&&t(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter(n=>n!==t)}}_canUseSessionStorage(){return this.config.persistence!=="memory"&&!this.persistence.disabled&&Tr.is_supported()}_setWindowId(t){t!==this._windowId&&(this._windowId=t,this._canUseSessionStorage()&&Tr.set(this._window_id_storage_key,t))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Tr.parse(this._window_id_storage_key):null}_setSessionId(t,n,s){t===this._sessionId&&n===this._sessionActivityTimestamp&&s===this._sessionStartTimestamp||(this._sessionStartTimestamp=s,this._sessionActivityTimestamp=n,this._sessionId=t,this.persistence.register({[iw]:[n,t,s]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var t=this.persistence.props[iw];return As(t)&&t.length===2&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){Bs(Ue,"beforeunload",()=>{this._canUseSessionStorage()&&Tr.remove(this._primary_window_exists_storage_key)},{capture:!1})}checkAndGetSessionAndWindowId(){var t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(this.config.__preview_experimental_cookieless_mode)throw new Error("checkAndGetSessionAndWindowId should not be called in __preview_experimental_cookieless_mode");var s=n||new Date().getTime(),[r,i,a]=this._getSessionId(),o=this._getWindowId(),l=gi(a)&&a>0&&Math.abs(s-a)>864e5,u=!1,d=!i,h=!t&&Math.abs(s-r)>this.sessionTimeoutMs;d||h||l?(i=this._sessionIdGenerator(),o=this._windowIdGenerator(),tN.info("new session ID generated",{sessionId:i,windowId:o,changeReason:{noSessionId:d,activityTimeout:h,sessionPastMaximumLength:l}}),a=s,u=!0):o||(o=this._windowIdGenerator(),u=!0);var f=r===0||!t||l?s:r,g=a===0?new Date().getTime():a;return this._setWindowId(o),this._setSessionId(i,f,g),t||this.resetIdleTimer(),u&&this._sessionIdChangedHandlers.forEach(v=>v(i,o,u?{noSessionId:d,activityTimeout:h,sessionPastMaximumLength:l}:void 0)),{sessionId:i,windowId:o,sessionStartTimestamp:g,changeReason:u?{noSessionId:d,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:r}}resetIdleTimer(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout(()=>{this.resetSessionId()},1.1*this.sessionTimeoutMs)}};var cae=["$set_once","$set"],Rc=Zr("[SiteApps]");let uae=class{constructor(t){this.instance=t,this.bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this.instance.config.opt_in_site_apps}eventCollector(t,n){if(n){var s=this.globalsForEvent(n);this.bufferedInvocations.push(s),this.bufferedInvocations.length>1e3&&(this.bufferedInvocations=this.bufferedInvocations.slice(10))}}get siteAppLoaders(){var t,n;return(t=Zt._POSTHOG_REMOTE_CONFIG)===null||t===void 0||(n=t[this.instance.config.token])===null||n===void 0?void 0:n.siteApps}init(){if(this.isEnabled){var t=this.instance._addCaptureHook(this.eventCollector.bind(this));this.stopBuffering=()=>{t(),this.bufferedInvocations=[],this.stopBuffering=void 0}}}globalsForEvent(t){var n,s,r,i,a,o,l;if(!t)throw new Error("Event payload is required");var u={},d=this.instance.get_property("$groups")||[],h=this.instance.get_property("$stored_group_properties")||{};for(var[f,g]of Object.entries(h))u[f]={id:d[f],type:f,properties:g};var{$set_once:v,$set:b}=t;return{event:ze(ze({},F5(t,cae)),{},{properties:ze(ze(ze({},t.properties),b?{$set:ze(ze({},(n=(s=t.properties)===null||s===void 0?void 0:s.$set)!==null&&n!==void 0?n:{}),b)}:{}),v?{$set_once:ze(ze({},(r=(i=t.properties)===null||i===void 0?void 0:i.$set_once)!==null&&r!==void 0?r:{}),v)}:{}),elements_chain:(a=(o=t.properties)===null||o===void 0?void 0:o.$elements_chain)!==null&&a!==void 0?a:"",distinct_id:(l=t.properties)===null||l===void 0?void 0:l.distinct_id}),person:{properties:this.instance.get_property("$stored_person_properties")},groups:u}}setupSiteApp(t){var n=this.apps[t.id],s=()=>{var o;!n.errored&&this.bufferedInvocations.length&&(Rc.info("Processing ".concat(this.bufferedInvocations.length," events for site app with id ").concat(t.id)),this.bufferedInvocations.forEach(l=>{var u;return(u=n.processEvent)===null||u===void 0?void 0:u.call(n,l)}),n.processedBuffer=!0),Object.values(this.apps).every(l=>l.processedBuffer||l.errored)&&((o=this.stopBuffering)===null||o===void 0||o.call(this))},r=!1,i=o=>{n.errored=!o,n.loaded=!0,Rc.info("Site app with id ".concat(t.id," ").concat(o?"loaded":"errored")),r&&s()};try{var{processEvent:a}=t.init({posthog:this.instance,callback:o=>{i(o)}});a&&(n.processEvent=a),r=!0}catch(o){Rc.error("Error while initializing PostHog app with config id ".concat(t.id),o),i(!1)}if(r&&n.loaded)try{s()}catch(o){Rc.error("Error while processing buffered events PostHog app with config id ".concat(t.id),o),n.errored=!0}}setupSiteApps(){var t=this.siteAppLoaders||[];for(var n of t)this.apps[n.id]={id:n.id,loaded:!1,errored:!1,processedBuffer:!1};for(var s of t)this.setupSiteApp(s)}onCapturedEvent(t){if(Object.keys(this.apps).length!==0){var n=this.globalsForEvent(t);for(var s of Object.values(this.apps))try{var r;(r=s.processEvent)===null||r===void 0||r.call(s,n)}catch(i){Rc.error("Error while processing event ".concat(t.event," for site app ").concat(s.id),i)}}}onRemoteConfig(t){var n,s,r,i=this;if((n=this.siteAppLoaders)!==null&&n!==void 0&&n.length)return this.isEnabled?(this.setupSiteApps(),void this.instance.on("eventCaptured",u=>this.onCapturedEvent(u))):void Rc.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((s=this.stopBuffering)===null||s===void 0||s.call(this),(r=t.siteApps)!==null&&r!==void 0&&r.length)if(this.isEnabled){var a=function(u,d){var h,f;Zt["__$$ph_site_app_".concat(u)]=i.instance,(h=Zt.__PosthogExtensions__)===null||h===void 0||(f=h.loadSiteApp)===null||f===void 0||f.call(h,i.instance,d,g=>{if(g)return Rc.error("Error while initializing PostHog app with config id ".concat(u),g)})};for(var{id:o,url:l}of t.siteApps)a(o,l)}else Rc.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}};var Td,dae=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google","bytespider"],nN=function(e,t){if(!e)return!1;var n=e.toLowerCase();return dae.concat(t||[]).some(s=>{var r=s.toLowerCase();return n.indexOf(r)!==-1})},I8=function(e,t){if(!e)return!1;var n=e.userAgent;if(n&&nN(n,t))return!0;try{var s=e?.userAgentData;if(s!=null&&s.brands&&s.brands.some(r=>nN(r?.brand,t)))return!0}catch{}return!!e.webdriver};function sN(e,t,n){return om({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}(function(e){e.US="us",e.EU="eu",e.CUSTOM="custom"})(Td||(Td={}));var rN="i.posthog.com";let hae=class{constructor(t){bt(this,"_regionCache",{}),this.instance=t}get apiHost(){var t=this.instance.config.api_host.trim().replace(/\/$/,"");return t==="https://app.posthog.com"?"https://us.i.posthog.com":t}get uiHost(){var t,n=(t=this.instance.config.ui_host)===null||t===void 0?void 0:t.replace(/\/$/,"");return n||(n=this.apiHost.replace(".".concat(rN),".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this._regionCache[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=Td.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=Td.EU:this._regionCache[this.apiHost]=Td.CUSTOM),this._regionCache[this.apiHost]}endpointFor(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";if(n&&(n=n[0]==="/"?n:"/".concat(n)),t==="ui")return this.uiHost+n;if(this.region===Td.CUSTOM)return this.apiHost+n;var s=rN+n;switch(t){case"assets":return"https://".concat(this.region,"-assets.").concat(s);case"api":return"https://".concat(this.region,".").concat(s)}}};var fae={icontains:(e,t)=>!!Ue&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!Ue&&t.href.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>!!Ue&&wp(t.href,e),not_regex:(e,t)=>!!Ue&&!wp(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};let pae=class hi{constructor(t){var n=this;bt(this,"getWebExperimentsAndEvaluateDisplayLogic",function(){var s=arguments.length>0&&arguments[0]!==void 0&&arguments[0];n.getWebExperiments(r=>{hi.logInfo("retrieved web experiments from the server"),n._flagToExperiments=new Map,r.forEach(i=>{if(i.feature_flag_key){var a;n._flagToExperiments&&(hi.logInfo("setting flag key ",i.feature_flag_key," to web experiment ",i),(a=n._flagToExperiments)===null||a===void 0||a.set(i.feature_flag_key,i));var o=n.instance.getFeatureFlag(i.feature_flag_key);Qs(o)&&i.variants[o]&&n.applyTransforms(i.name,o,i.variants[o].transforms)}else if(i.variants)for(var l in i.variants){var u=i.variants[l];hi.matchesTestVariant(u)&&n.applyTransforms(i.name,l,u.transforms)}})},s)}),this.instance=t,this.instance.onFeatureFlags(s=>{this.onFeatureFlags(s)})}onFeatureFlags(t){if(this._is_bot())hi.logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this.instance.config.disable_web_experiments){if(Wn(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();hi.logInfo("applying feature flags",t),t.forEach(n=>{var s;if(this._flagToExperiments&&(s=this._flagToExperiments)!==null&&s!==void 0&&s.has(n)){var r,i=this.instance.getFeatureFlag(n),a=(r=this._flagToExperiments)===null||r===void 0?void 0:r.get(n);i&&a!=null&&a.variants[i]&&this.applyTransforms(a.name,i,a.variants[i].transforms)}})}}previewWebExperiment(){var t=hi.getWindowLocation();if(t!=null&&t.search){var n=cw(t?.search,"__experiment_id"),s=cw(t?.search,"__experiment_variant");n&&s&&(hi.logInfo("previewing web experiments ".concat(n," && ").concat(s)),this.getWebExperiments(r=>{this.showPreviewWebExperiment(parseInt(n),s,r)},!1,!0))}}loadIfEnabled(){this.instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,n,s){if(this.instance.config.disable_web_experiments&&!s)return t([]);var r=this.instance.get_property("$web_experiments");if(r&&!n)return t(r);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/web_experiments/?token=".concat(this.instance.config.token)),method:"GET",callback:i=>{if(i.statusCode!==200||!i.json)return t([]);var a=i.json.experiments||[];return t(a)}})}showPreviewWebExperiment(t,n,s){var r=s.filter(i=>i.id===t);r&&r.length>0&&(hi.logInfo("Previewing web experiment [".concat(r[0].name,"] with variant [").concat(n,"]")),this.applyTransforms(r[0].name,n,r[0].variants[n].transforms))}static matchesTestVariant(t){return!Wn(t.conditions)&&hi.matchUrlConditions(t)&&hi.matchUTMConditions(t)}static matchUrlConditions(t){var n;if(Wn(t.conditions)||Wn((n=t.conditions)===null||n===void 0?void 0:n.url))return!0;var s,r,i,a=hi.getWindowLocation();return!!a&&((s=t.conditions)===null||s===void 0||!s.url||fae[(r=(i=t.conditions)===null||i===void 0?void 0:i.urlMatchType)!==null&&r!==void 0?r:"icontains"](t.conditions.url,a))}static getWindowLocation(){return Ue?.location}static matchUTMConditions(t){var n;if(Wn(t.conditions)||Wn((n=t.conditions)===null||n===void 0?void 0:n.utm))return!0;var s=ms.campaignParams();if(s.utm_source){var r,i,a,o,l,u,d,h,f,g,v,b,x,w,_,C,S=(r=t.conditions)===null||r===void 0||(i=r.utm)===null||i===void 0||!i.utm_campaign||((a=t.conditions)===null||a===void 0||(o=a.utm)===null||o===void 0?void 0:o.utm_campaign)==s.utm_campaign,y=(l=t.conditions)===null||l===void 0||(u=l.utm)===null||u===void 0||!u.utm_source||((d=t.conditions)===null||d===void 0||(h=d.utm)===null||h===void 0?void 0:h.utm_source)==s.utm_source,R=(f=t.conditions)===null||f===void 0||(g=f.utm)===null||g===void 0||!g.utm_medium||((v=t.conditions)===null||v===void 0||(b=v.utm)===null||b===void 0?void 0:b.utm_medium)==s.utm_medium,E=(x=t.conditions)===null||x===void 0||(w=x.utm)===null||w===void 0||!w.utm_term||((_=t.conditions)===null||_===void 0||(C=_.utm)===null||C===void 0?void 0:C.utm_term)==s.utm_term;return S&&R&&E&&y}return!1}static logInfo(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),r=1;r<n;r++)s[r-1]=arguments[r];Lt.info("[WebExperiments] ".concat(t),s)}applyTransforms(t,n,s){this._is_bot()?hi.logInfo("Refusing to render web experiment since the viewer is a likely bot"):n!=="control"?s.forEach(r=>{if(r.selector){var i;hi.logInfo("applying transform of variant ".concat(n," for experiment ").concat(t," "),r);var a=(i=document)===null||i===void 0?void 0:i.querySelectorAll(r.selector);a?.forEach(o=>{var l=o;r.html&&(l.innerHTML=r.html),r.css&&l.setAttribute("style",r.css)})}}):hi.logInfo("Control variants leave the page unmodified.")}_is_bot(){return Zi&&this.instance?I8(Zi,this.instance.config.custom_blocked_useragents):void 0}};var km={},mE=()=>{},yf="posthog",P8=!tae&&Ys?.indexOf("MSIE")===-1&&Ys?.indexOf("Mozilla")===-1,iN=()=>{var e;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:mre(It?.location),persistence:"localStorage+cookie",persistence_name:"",loaded:mE,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:"if_capture_pageview",debug:ki&&Qs(ki?.search)&&ki.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(Ue==null||(e=Ue.location)===null||e===void 0?void 0:e.protocol)==="https:",ip:!0,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:t=>{var n="Bad HTTP status: "+t.statusCode+" "+t.text;Lt.error(n)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:gE},_onCapture:mE}},aN=e=>{var t={};At(e.process_person)||(t.person_profiles=e.process_person),At(e.xhr_headers)||(t.request_headers=e.xhr_headers),At(e.cookie_name)||(t.persistence_name=e.cookie_name),At(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),At(e.store_google)||(t.save_campaign_params=e.store_google),At(e.verbose)||(t.debug=e.verbose);var n=Os({},t,e);return As(e.property_blacklist)&&(At(e.property_denylist)?n.property_denylist=e.property_blacklist:As(e.property_denylist)?n.property_denylist=[...e.property_blacklist,...e.property_denylist]:Lt.error("Invalid value for property_denylist config: "+e.property_denylist)),n};class gae{constructor(){bt(this,"__forceAllowLocalhost",!1)}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(t){Lt.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}}class oC{get decideEndpointWasHit(){var t,n;return(t=(n=this.featureFlags)===null||n===void 0?void 0:n.hasLoadedFlags)!==null&&t!==void 0&&t}constructor(){bt(this,"webPerformance",new gae),bt(this,"_personProcessingSetOncePropertiesSent",!1),bt(this,"version",Ml.LIB_VERSION),bt(this,"_internalEventEmitter",new F8),this.config=iN(),this.SentryIntegration=_ie,this.sentryIntegration=t=>function(n,s){var r=r8(n,s);return{name:s8,processEvent:i=>r(i)}}(this,t),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._initialPersonProfilesConfig=null,this._cachedPersonProperties=null,this.featureFlags=new Gie(this),this.toolbar=new yie(this),this.scrollManager=new iae(this),this.pageViewManager=new Aie(this),this.surveys=new Qie(this),this.experiments=new pae(this),this.exceptions=new Fie(this),this.rateLimiter=new Jie(this),this.requestRouter=new hae(this),this.consent=new Hre(this),this.people={set:(t,n,s)=>{var r=Qs(t)?{[t]:n}:t;this.setPersonProperties(r),s?.({})},set_once:(t,n,s)=>{var r=Qs(t)?{[t]:n}:t;this.setPersonProperties(void 0,r),s?.({})}},this.on("eventCaptured",t=>Lt.info('send "'.concat(t?.event,'"'),t))}init(t,n,s){if(s&&s!==yf){var r,i=(r=km[s])!==null&&r!==void 0?r:new oC;return i._init(t,n,s),km[s]=i,km[yf][s]=i,i}return this._init(t,n,s)}_init(t){var n,s,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;if(At(t)||jk(t))return Lt.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return Lt.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this._triggered_notifs=[],r.person_profiles&&(this._initialPersonProfilesConfig=r.person_profiles),this.set_config(Os({},iN(),aN(r),{name:i,token:t})),this.config.on_xhr_error&&Lt.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=r.disable_compression?void 0:so.GZipJS,this.persistence=new Qy(this.config),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Qy(ze(ze({},this.config),{},{persistence:"sessionStorage"}));var a=ze({},this.persistence.props),o=ze({},this.sessionPersistence.props);if(this._requestQueue=new nae(w=>this._send_retriable_request(w),this.config.request_queue_config),this._retryQueue=new rae(this),this.__request_queue=[],this.config.__preview_experimental_cookieless_mode||(this.sessionManager=new lae(this),this.sessionPropsManager=new oae(this,this.sessionManager,this.persistence)),new kie(this).startIfEnabledOrStop(),this.siteApps=new uae(this),(n=this.siteApps)===null||n===void 0||n.init(),this.config.__preview_experimental_cookieless_mode||(this.sessionRecording=new xie(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new Fre(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new Rie(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new Eie(this),this.exceptionObserver=new Vre(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new q5(this,Gre),this.deadClicksAutocapture.startIfEnabled(),Ml.DEBUG=Ml.DEBUG||this.config.debug,Ml.DEBUG&&Lt.info("Starting in debug mode",{this:this,config:r,thisC:ze({},this.config),p:a,s:o}),this._sync_opt_out_with_persistence(),((s=r.bootstrap)===null||s===void 0?void 0:s.distinctID)!==void 0){var l,u,d=this.config.get_device_id(qc()),h=(l=r.bootstrap)!==null&&l!==void 0&&l.isIdentifiedID?d:r.bootstrap.distinctID;this.persistence.set_property(Il,(u=r.bootstrap)!==null&&u!==void 0&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:r.bootstrap.distinctID,$device_id:h})}if(this._hasBootstrappedFeatureFlags()){var f,g,v=Object.keys(((f=r.bootstrap)===null||f===void 0?void 0:f.featureFlags)||{}).filter(w=>{var _,C;return!((_=r.bootstrap)===null||_===void 0||(C=_.featureFlags)===null||C===void 0||!C[w])}).reduce((w,_)=>{var C,S;return w[_]=((C=r.bootstrap)===null||C===void 0||(S=C.featureFlags)===null||S===void 0?void 0:S[_])||!1,w},{}),b=Object.keys(((g=r.bootstrap)===null||g===void 0?void 0:g.featureFlagPayloads)||{}).filter(w=>v[w]).reduce((w,_)=>{var C,S,y,R;return(C=r.bootstrap)!==null&&C!==void 0&&(S=C.featureFlagPayloads)!==null&&S!==void 0&&S[_]&&(w[_]=(y=r.bootstrap)===null||y===void 0||(R=y.featureFlagPayloads)===null||R===void 0?void 0:R[_]),w},{});this.featureFlags.receivedFeatureFlags({featureFlags:v,featureFlagPayloads:b})}if(this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:dP,$device_id:null},"");else if(!this.get_distinct_id()){var x=this.config.get_device_id(qc());this.register_once({distinct_id:x,$device_id:x},""),this.persistence.set_property(Il,"anonymous")}return Bs(Ue,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),r.segment?wie(this,()=>this._loaded()):this._loaded(),lo(this.config._onCapture)&&this.config._onCapture!==mE&&(Lt.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",w=>this.config._onCapture(w.event,w))),this}_onRemoteConfig(t){var n,s,r,i,a,o,l,u;if(!It||!It.body)return Lt.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this._onRemoteConfig(t)},500);this.compression=void 0,t.supportedCompression&&!this.config.disable_compression&&(this.compression=fn(t.supportedCompression,so.GZipJS)?so.GZipJS:fn(t.supportedCompression,so.Base64)?so.Base64:void 0),(n=t.analytics)!==null&&n!==void 0&&n.endpoint&&(this.analyticsDefaultEndpoint=t.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:"identified_only"}),(s=this.siteApps)===null||s===void 0||s.onRemoteConfig(t),(r=this.sessionRecording)===null||r===void 0||r.onRemoteConfig(t),(i=this.autocapture)===null||i===void 0||i.onRemoteConfig(t),(a=this.heatmaps)===null||a===void 0||a.onRemoteConfig(t),this.surveys.onRemoteConfig(t),(o=this.webVitalsAutocapture)===null||o===void 0||o.onRemoteConfig(t),(l=this.exceptionObserver)===null||l===void 0||l.onRemoteConfig(t),(u=this.deadClicksAutocapture)===null||u===void 0||u.onRemoteConfig(t)}_loaded(){try{this.config.loaded(this)}catch(t){Lt.critical("`loaded` function failed",t)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout(()=>{this.consent.isOptedIn()&&this._captureInitialPageview()},1),new Zie(this).load(),this.featureFlags.decide()}_start_queue_if_opted_in(){var t;this.has_opted_out_capturing()||this.config.request_batching&&((t=this._requestQueue)===null||t===void 0||t.enable())}_dom_loaded(){this.has_opted_out_capturing()||tu(this.__request_queue,t=>this._send_retriable_request(t)),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var t,n;this.config.request_batching?(this._shouldCapturePageleave()&&this.capture("$pageleave"),(t=this._requestQueue)===null||t===void 0||t.unload(),(n=this._retryQueue)===null||n===void 0||n.unload()):this._shouldCapturePageleave()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(t){this.__loaded&&(P8?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)||(t.transport=t.transport||this.config.api_transport,t.url=gw(t.url,{ip:this.config.ip?1:0}),t.headers=ze({},this.config.request_headers),t.compression=t.compression==="best-available"?this.compression:t.compression,t.fetchOptions=t.fetchOptions||this.config.fetch_options,(n=>{var s,r,i,a=ze({},n);a.timeout=a.timeout||6e4,a.url=gw(a.url,{_:new Date().getTime().toString(),ver:Ml.LIB_VERSION,compression:a.compression});var o=(s=a.transport)!==null&&s!==void 0?s:"fetch",l=(r=(i=D5(Sm,u=>u.transport===o))===null||i===void 0?void 0:i.method)!==null&&r!==void 0?r:Sm[0].method;if(!l)throw new Error("No available transport method");l(a)})(ze(ze({},t),{},{callback:n=>{var s,r,i;this.rateLimiter.checkForLimiting(n),n.statusCode>=400&&((r=(i=this.config).on_request_error)===null||r===void 0||r.call(i,n)),(s=t.callback)===null||s===void 0||s.call(t,n)}}))))}_send_retriable_request(t){this._retryQueue?this._retryQueue.retriableRequest(t):this._send_request(t)}_execute_array(t){var n,s=[],r=[],i=[];tu(t,o=>{o&&(n=o[0],As(n)?i.push(o):lo(o)?o.call(this):As(o)&&n==="alias"?s.push(o):As(o)&&n.indexOf("capture")!==-1&&lo(this[n])?i.push(o):r.push(o))});var a=function(o,l){tu(o,function(u){if(As(u[0])){var d=l;es(u,function(h){d=d[h[0]].apply(d,h.slice(1))})}else this[u[0]].apply(this,u.slice(1))},l)};a(s,this),a(r,this),a(i,this)}_hasBootstrappedFeatureFlags(){var t,n;return((t=this.config.bootstrap)===null||t===void 0?void 0:t.featureFlags)&&Object.keys((n=this.config.bootstrap)===null||n===void 0?void 0:n.featureFlags).length>0||!1}push(t){this._execute_array([t])}capture(t,n,s){var r;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(!this.consent.isOptedOut())if(!At(t)&&Qs(t)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var i=s!=null&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(i==null||!i.isRateLimited){n!=null&&n.$current_url&&!Qs(n?.$current_url)&&(Lt.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var a=new Date,o=s?.timestamp||a,l=qc(),u={uuid:l,event:t,properties:this._calculate_event_properties(t,n||{},o,l)};i&&(u.properties.$lib_rate_limit_remaining_tokens=i.remainingTokens),s?.$set&&(u.$set=s?.$set);var d=this._calculate_set_once_properties(s?.$set_once);d&&(u.$set_once=d),(u=pre(u,s!=null&&s._noTruncate?null:this.config.properties_string_max_length)).timestamp=o,At(s?.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a);var h=ze(ze({},u.properties.$set),u.$set);if(Df(h)||this.setPersonPropertiesForFlags(h),!Wn(this.config.before_send)){var f=this._runBeforeSend(u);if(!f)return;u=f}this._internalEventEmitter.emit("eventCaptured",u);var g={method:"POST",url:(r=s?._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:s?._batchKey};return!this.config.request_batching||s&&(s==null||!s._batchKey)||s!=null&&s.send_instantly?this._send_retriable_request(g):this._requestQueue.enqueue(g),u}Lt.critical("This capture call is ignored due to client rate limiting.")}}else Lt.error("No event name provided to posthog.capture")}else Lt.uninitializedWarning("posthog.capture")}_addCaptureHook(t){return this.on("eventCaptured",n=>t(n.event,n))}_calculate_event_properties(t,n,s,r){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return n;var i=this.persistence.remove_event_timer(t),a=ze({},n);if(a.token=this.config.token,this.config.__preview_experimental_cookieless_mode&&(a.$cookieless_mode=!0),t==="$snapshot"){var o=ze(ze({},this.persistence.properties()),this.sessionPersistence.properties());return a.distinct_id=o.distinct_id,(!Qs(a.distinct_id)&&!gi(a.distinct_id)||jk(a.distinct_id))&&Lt.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var l,u=ms.properties({maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties});if(this.sessionManager){var{sessionId:d,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId();a.$session_id=d,a.$window_id=h}this.sessionPropsManager&&Os(a,this.sessionPropsManager.getSessionProps());try{var f,g;this.sessionRecording&&Os(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(f=this._retryQueue)===null||f===void 0||(g=f.queue)===null||g===void 0?void 0:g.length}catch(w){a.$sdk_debug_error_capturing_properties=String(w)}if(this.requestRouter.region===Td.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),l=t==="$pageview"?this.pageViewManager.doPageView(s,r):t==="$pageleave"?this.pageViewManager.doPageLeave(s):this.pageViewManager.doEvent(),a=Os(a,l),t==="$pageview"&&It&&(a.title=It.title),!At(i)){var v=s.getTime()-i;a.$duration=parseFloat((v/1e3).toFixed(3))}Ys&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=Os({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),As(this.config.property_denylist)?es(this.config.property_denylist,function(w){delete a[w]}):Lt.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var b=this.config.sanitize_properties;b&&(Lt.error("sanitize_properties is deprecated. Use before_send instead"),a=b(a,t));var x=this._hasPersonProcessing();return a.$process_person_profile=x,x&&this._requirePersonProcessing("_calculate_event_properties"),a}_calculate_set_once_properties(t){var n;if(!this.persistence||!this._hasPersonProcessing()||this._personProcessingSetOncePropertiesSent)return t;var s=this.persistence.get_initial_props(),r=(n=this.sessionPropsManager)===null||n===void 0?void 0:n.getSetOnceProps(),i=Os({},s,r||{},t||{}),a=this.config.sanitize_properties;return a&&(Lt.error("sanitize_properties is deprecated. Use before_send instead"),i=a(i,"$set_once")),this._personProcessingSetOncePropertiesSent=!0,Df(i)?void 0:i}register(t,n){var s;(s=this.persistence)===null||s===void 0||s.register(t,n)}register_once(t,n,s){var r;(r=this.persistence)===null||r===void 0||r.register_once(t,n,s)}register_for_session(t){var n;(n=this.sessionPersistence)===null||n===void 0||n.register(t)}unregister(t){var n;(n=this.persistence)===null||n===void 0||n.unregister(t)}unregister_for_session(t){var n;(n=this.sessionPersistence)===null||n===void 0||n.unregister(t)}_register_single(t,n){this.register({[t]:n})}getFeatureFlag(t,n){return this.featureFlags.getFeatureFlag(t,n)}getFeatureFlagPayload(t){var n=this.featureFlags.getFeatureFlagPayload(t);try{return JSON.parse(n)}catch{return n}}isFeatureEnabled(t,n){return this.featureFlags.isFeatureEnabled(t,n)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(t,n){this.featureFlags.updateEarlyAccessFeatureEnrollment(t,n)}getEarlyAccessFeatures(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1],s=arguments.length>2?arguments[2]:void 0;return this.featureFlags.getEarlyAccessFeatures(t,n,s)}on(t,n){return this._internalEventEmitter.on(t,n)}onFeatureFlags(t){return this.featureFlags.onFeatureFlags(t)}onSurveysLoaded(t){return this.surveys.onSurveysLoaded(t)}onSessionId(t){var n,s;return(n=(s=this.sessionManager)===null||s===void 0?void 0:s.onSessionId(t))!==null&&n!==void 0?n:()=>{}}getSurveys(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getSurveys(t,n)}getActiveMatchingSurveys(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getActiveMatchingSurveys(t,n)}renderSurvey(t,n){this.surveys.renderSurvey(t,n)}canRenderSurvey(t){return this.surveys.canRenderSurvey(t)}identify(t,n,s){if(!this.__loaded||!this.persistence)return Lt.uninitializedWarning("posthog.identify");if(gi(t)&&(t=t.toString(),Lt.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),t){if(["distinct_id","distinctid"].includes(t.toLowerCase()))Lt.critical('The string "'.concat(t,'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'));else if(this._requirePersonProcessing("posthog.identify")){var r=this.get_distinct_id();if(this.register({$user_id:t}),!this.get_property("$device_id")){var i=r;this.register_once({$had_persisted_distinct_id:!0,$device_id:i},"")}t!==r&&t!==this.get_property(tm)&&(this.unregister(tm),this.register({distinct_id:t}));var a=(this.persistence.get_property(Il)||"anonymous")==="anonymous";t!==r&&a?(this.persistence.set_property(Il,"identified"),this.setPersonPropertiesForFlags(ze(ze({},s||{}),n||{}),!1),this.capture("$identify",{distinct_id:t,$anon_distinct_id:r},{$set:n||{},$set_once:s||{}}),this._cachedPersonProperties=sN(t,n,s),this.featureFlags.setAnonymousDistinctId(r)):(n||s)&&this.setPersonProperties(n,s),t!==r&&(this.reloadFeatureFlags(),this.unregister(aw))}}else Lt.error("Unique user id has not been set in posthog.identify")}setPersonProperties(t,n){if((t||n)&&this._requirePersonProcessing("posthog.setPersonProperties")){var s=sN(this.get_distinct_id(),t,n);this._cachedPersonProperties!==s?(this.setPersonPropertiesForFlags(ze(ze({},n||{}),t||{})),this.capture("$set",{$set:t||{},$set_once:n||{}}),this._cachedPersonProperties=s):Lt.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(t,n,s){if(t&&n){if(this._requirePersonProcessing("posthog.group")){var r=this.getGroups();r[t]!==n&&this.resetGroupPropertiesForFlags(t),this.register({$groups:ze(ze({},r),{},{[t]:n})}),s&&(this.capture("$groupidentify",{$group_type:t,$group_key:n,$group_set:s}),this.setGroupPropertiesForFlags({[t]:s})),r[t]===n||s||this.reloadFeatureFlags()}}else Lt.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t){var n=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this.featureFlags.setPersonPropertiesForFlags(t,n)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(t){var n=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(t,n)}resetGroupPropertiesForFlags(t){this.featureFlags.resetGroupPropertiesForFlags(t)}reset(t){var n,s,r,i;if(Lt.info("reset"),!this.__loaded)return Lt.uninitializedWarning("posthog.reset");var a=this.get_property("$device_id");if(this.consent.reset(),(n=this.persistence)===null||n===void 0||n.clear(),(s=this.sessionPersistence)===null||s===void 0||s.clear(),this.surveys.reset(),(r=this.persistence)===null||r===void 0||r.set_property(Il,"anonymous"),(i=this.sessionManager)===null||i===void 0||i.resetSessionId(),this._cachedPersonProperties=null,this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:dP,$device_id:null},"");else{var o=this.config.get_device_id(qc());this.register_once({distinct_id:o,$device_id:t?o:a},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,n;return(t=(n=this.sessionManager)===null||n===void 0?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&t!==void 0?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";var{sessionId:n,sessionStartTimestamp:s}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/".concat(this.config.token,"/replay/").concat(n));if(t!=null&&t.withTimestamp&&s){var i,a=(i=t.timestampLookBack)!==null&&i!==void 0?i:10;if(!s)return r;var o=Math.max(Math.floor((new Date().getTime()-s)/1e3)-a,0);r+="?t=".concat(o)}return r}alias(t,n){return t===this.get_property(I5)?(Lt.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(At(n)&&(n=this.get_distinct_id()),t!==n?(this._register_single(tm,t),this.capture("$create_alias",{alias:t,distinct_id:n})):(Lt.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){var n,s,r,i,a=ze({},this.config);Fs(t)&&(Os(this.config,aN(t)),(n=this.persistence)===null||n===void 0||n.update_config(this.config,a),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Qy(ze(ze({},this.config),{},{persistence:"sessionStorage"})),Zs.is_supported()&&Zs.get("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&(Ml.DEBUG=!0,Lt.info("set_config",JSON.stringify({config:t,oldConfig:a,newConfig:ze({},this.config)},null,2))),(s=this.sessionRecording)===null||s===void 0||s.startIfEnabledOrStop(),(r=this.autocapture)===null||r===void 0||r.startIfEnabled(),(i=this.heatmaps)===null||i===void 0||i.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence())}startSessionRecording(t){var n=t===!0,s={sampling:n||!(t==null||!t.sampling),linked_flag:n||!(t==null||!t.linked_flag),url_trigger:n||!(t==null||!t.url_trigger),event_trigger:n||!(t==null||!t.event_trigger)};if(Object.values(s).some(Boolean)){var r,i,a,o,l;(r=this.sessionManager)===null||r===void 0||r.checkAndGetSessionAndWindowId(),s.sampling&&((i=this.sessionRecording)===null||i===void 0||i.overrideSampling()),s.linked_flag&&((a=this.sessionRecording)===null||a===void 0||a.overrideLinkedFlag()),s.url_trigger&&((o=this.sessionRecording)===null||o===void 0||o.overrideTrigger("url")),s.event_trigger&&((l=this.sessionRecording)===null||l===void 0||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var t;return!((t=this.sessionRecording)===null||t===void 0||!t.started)}captureException(t,n){var s=new Error("PostHog syntheticException");this.exceptions.sendExceptionEvent(ze(ze({},tie((r=>r instanceof Error)(t)?{error:t,event:t.message}:{event:t},{syntheticException:s})),n))}loadToolbar(t){return this.toolbar.loadToolbar(t)}get_property(t){var n;return(n=this.persistence)===null||n===void 0?void 0:n.props[t]}getSessionProperty(t){var n;return(n=this.sessionPersistence)===null||n===void 0?void 0:n.props[t]}toString(){var t,n=(t=this.config.name)!==null&&t!==void 0?t:yf;return n!==yf&&(n=yf+"."+n),n}_isIdentified(){var t,n;return((t=this.persistence)===null||t===void 0?void 0:t.get_property(Il))==="identified"||((n=this.sessionPersistence)===null||n===void 0?void 0:n.get_property(Il))==="identified"}_hasPersonProcessing(){var t,n,s,r;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Df(this.getGroups())&&((t=this.persistence)===null||t===void 0||(n=t.props)===null||n===void 0||!n[tm])&&((s=this.persistence)===null||s===void 0||(r=s.props)===null||r===void 0||!r[ow]))}_shouldCapturePageleave(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&this.config.capture_pageview}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}_requirePersonProcessing(t){return this.config.person_profiles==="never"?(Lt.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(ow,!0),!0)}_sync_opt_out_with_persistence(){var t,n,s,r,i=this.consent.isOptedOut(),a=this.config.opt_out_persistence_by_default,o=this.config.disable_persistence||i&&!!a;((t=this.persistence)===null||t===void 0?void 0:t.disabled)!==o&&((s=this.persistence)===null||s===void 0||s.set_disabled(o)),((n=this.sessionPersistence)===null||n===void 0?void 0:n.disabled)!==o&&((r=this.sessionPersistence)===null||r===void 0||r.set_disabled(o))}opt_in_capturing(t){var n;this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),(At(t?.captureEventName)||t!=null&&t.captureEventName)&&this.capture((n=t?.captureEventName)!==null&&n!==void 0?n:"$opt_in",t?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}opt_out_capturing(){this.consent.optInOut(!1),this._sync_opt_out_with_persistence()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return Zi?I8(Zi,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){It&&!this._initialPageviewCaptured&&(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:It.title},{send_instantly:!0}))}debug(t){t===!1?(Ue?.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(Ue?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))}_runBeforeSend(t){if(Wn(this.config.before_send))return t;var n=As(this.config.before_send)?this.config.before_send:[this.config.before_send],s=t;for(var r of n){if(s=r(s),Wn(s)){var i="Event '".concat(t.event,"' was rejected in beforeSend function");return dre(t.event)?Lt.warn("".concat(i,". This can cause unexpected behavior.")):Lt.info(i),null}s.properties&&!Df(s.properties)||Lt.warn("Event '".concat(t.event,"' has no properties after beforeSend function, this is likely an error."))}return s}getPageViewId(){var t;return(t=this.pageViewManager._currentPageview)===null||t===void 0?void 0:t.pageViewId}captureTraceFeedback(t,n){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:n})}captureTraceMetric(t,n,s){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:n,$ai_metric_value:String(s)})}}(function(e,t){for(var n=0;n<t.length;n++)e.prototype[t[n]]=fre(e.prototype[t[n]])})(oC,["identify"]);var oN,xd=(oN=km[yf]=new oC,function(){function e(){e.done||(e.done=!0,P8=!1,es(km,function(t){t._dom_loaded()}))}It!=null&&It.addEventListener?It.readyState==="complete"?e():Bs(It,"DOMContentLoaded",e,{capture:!1}):Ue&&Lt.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),oN),cA=m.createContext({client:xd});function N8(e,t,n){if(n===void 0&&(n=new WeakMap),e===t)return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(n.has(e)&&n.get(e)===t)return!0;n.set(e,t);var s=Object.keys(e),r=Object.keys(t);if(s.length!==r.length)return!1;for(var i=0,a=s;i<a.length;i++){var o=a[i];if(!r.includes(o)||!N8(e[o],t[o],n))return!1}return!0}function mae(e){var t=e.children,n=e.client,s=e.apiKey,r=e.options,i=m.useRef(null),a=m.useMemo(function(){return n?(s&&console.warn("[PostHog.js] You have provided both `client` and `apiKey` to `PostHogProvider`. `apiKey` will be ignored in favour of `client`."),r&&console.warn("[PostHog.js] You have provided both `client` and `options` to `PostHogProvider`. `options` will be ignored in favour of `client`."),n):(s||console.warn("[PostHog.js] No `apiKey` or `client` were provided to `PostHogProvider`. Using default global `window.posthog` instance. You must initialize it manually. This is not recommended behavior."),xd)},[n,s,JSON.stringify(r)]);return m.useEffect(function(){if(!n){var o=i.current;o?(s!==o.apiKey&&console.warn("[PostHog.js] You have provided a different `apiKey` to `PostHogProvider` than the one that was already initialized. This is not supported by our provider and we'll keep using the previous key. If you need to toggle between API Keys you need to control the `client` yourself and pass it in as a prop rather than an `apiKey` prop."),r&&!N8(r,o.options)&&xd.set_config(r),i.current={apiKey:s,options:r??{}}):(xd.__loaded&&console.warn("[PostHog.js] `posthog` was already loaded elsewhere. This may cause issues."),xd.init(s,r),i.current={apiKey:s,options:r??{}})}},[n,s,JSON.stringify(r)]),nt.createElement(cA.Provider,{value:{client:a}},t)}var vae=function(){var e=m.useContext(cA).client;return e};function e1(e){var t=vae(),n=m.useState(function(){return t.isFeatureEnabled(e)}),s=n[0],r=n[1];return m.useEffect(function(){return t.onFeatureFlags(function(){r(t.isFeatureEnabled(e))})},[t,e]),s}var vE=function(e,t){return vE=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,s){n.__proto__=s}||function(n,s){for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(n[r]=s[r])},vE(e,t)};function bae(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");vE(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var t1=function(e){return typeof e=="function"},xae={componentStack:null,error:null},wae={INVALID_FALLBACK:"[PostHog.js][PostHogErrorBoundary] Invalid fallback prop, provide a valid React element or a function that returns a valid React element."};(function(e){bae(t,e);function t(n){var s=e.call(this,n)||this;return s.state=xae,s}return t.prototype.componentDidCatch=function(n,s){var r=s.componentStack,i=this.props.additionalProperties;this.setState({error:n,componentStack:r});var a;t1(i)?a=i(n):typeof i=="object"&&(a=i);var o=this.context.client;o.captureException(n,a)},t.prototype.render=function(){var n=this.props,s=n.children,r=n.fallback,i=this.state;if(i.componentStack==null)return t1(s)?s():s;var a=t1(r)?nt.createElement(r,{error:i.error,componentStack:i.componentStack}):r;return nt.isValidElement(a)?a:(console.warn(wae.INVALID_FALLBACK),nt.createElement(nt.Fragment,null))},t.contextType=cA,t})(nt.Component);/**
@@ -702,7 +702,7 @@ ${fz(r)}`)}const pz=vee;function F4(e){return e.artifact&&bee(e.path)?e.artifact
702
702
  * LICENSE file in the root directory of this source tree.
703
703
  */var qB;function AZe(){if(qB)return Yg;qB=1;var e=nt,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,r=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function a(o,l,u){var d,h={},f=null,g=null;u!==void 0&&(f=""+u),l.key!==void 0&&(f=""+l.key),l.ref!==void 0&&(g=l.ref);for(d in l)s.call(l,d)&&!i.hasOwnProperty(d)&&(h[d]=l[d]);if(o&&o.defaultProps)for(d in l=o.defaultProps,l)h[d]===void 0&&(h[d]=l[d]);return{$$typeof:t,type:o,key:f,ref:g,props:h,_owner:r.current}}return Yg.Fragment=n,Yg.jsx=a,Yg.jsxs=a,Yg}var KB;function FZe(){return KB||(KB=1,zB.exports=AZe()),zB.exports}var DZe=FZe();/*! shepherd.js 14.5.0 */function IZe(e){return e instanceof Element}function Mp(e){return e instanceof HTMLElement}function xu(e){return typeof e=="function"}function ov(e){return typeof e=="string"}function $r(e){return e===void 0}class OF{on(t,n,s,r=!1){var i;return $r(this.bindings)&&(this.bindings={}),$r(this.bindings[t])&&(this.bindings[t]=[]),(i=this.bindings[t])==null||i.push({handler:n,ctx:s,once:r}),this}once(t,n,s){return this.on(t,n,s,!0)}off(t,n){if($r(this.bindings)||$r(this.bindings[t]))return this;if($r(n))delete this.bindings[t];else{var s;(s=this.bindings[t])==null||s.forEach((r,i)=>{if(r.handler===n){var a;(a=this.bindings[t])==null||a.splice(i,1)}})}return this}trigger(t,...n){if(!$r(this.bindings)&&this.bindings[t]){var s;(s=this.bindings[t])==null||s.forEach((r,i)=>{const{ctx:a,handler:o,once:l}=r,u=a||this;if(o.apply(u,n),l){var d;(d=this.bindings[t])==null||d.splice(i,1)}})}return this}}function Pi(){return Pi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)({}).hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},Pi.apply(null,arguments)}function LF(e,t){if(e==null)return{};var n={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(t.includes(s))continue;n[s]=e[s]}return n}const Pu={defaultMerge:Symbol("deepmerge-ts: default merge"),skip:Symbol("deepmerge-ts: skip")};Pu.defaultMerge;function PZe(e,t){return t}function NZe(e,t){return e.filter(n=>n!==void 0)}var YB;(function(e){e[e.NOT=0]="NOT",e[e.RECORD=1]="RECORD",e[e.ARRAY=2]="ARRAY",e[e.SET=3]="SET",e[e.MAP=4]="MAP",e[e.OTHER=5]="OTHER"})(YB||(YB={}));function XB(e){return typeof e!="object"||e===null?0:Array.isArray(e)?2:LZe(e)?1:e instanceof Set?3:e instanceof Map?4:5}function MZe(e){const t=new Set;for(const n of e)for(const s of[...Object.keys(n),...Object.getOwnPropertySymbols(n)])t.add(s);return t}function OZe(e,t){return typeof e=="object"&&Object.prototype.propertyIsEnumerable.call(e,t)}function hq(e){return{*[Symbol.iterator](){for(const t of e)for(const n of t)yield n}}}const QB=new Set(["[object Object]","[object Module]"]);function LZe(e){if(!QB.has(Object.prototype.toString.call(e)))return!1;const{constructor:t}=e;if(t===void 0)return!0;const n=t.prototype;return!(n===null||typeof n!="object"||!QB.has(Object.prototype.toString.call(n))||!n.hasOwnProperty("isPrototypeOf"))}function BZe(e,t,n){const s={};for(const r of MZe(e)){const i=[];for(const l of e)OZe(l,r)&&i.push(l[r]);if(i.length===0)continue;const a=t.metaDataUpdater(n,{key:r,parents:e}),o=fq(i,t,a);o!==Pu.skip&&(r==="__proto__"?Object.defineProperty(s,r,{value:o,configurable:!0,enumerable:!0,writable:!0}):s[r]=o)}return s}function jZe(e){return e.flat()}function HZe(e){return new Set(hq(e))}function UZe(e){return new Map(hq(e))}function GZe(e){return e.at(-1)}const ox={mergeRecords:BZe,mergeArrays:jZe,mergeSets:HZe,mergeMaps:UZe,mergeOthers:GZe};function BF(...e){return VZe({})(...e)}function VZe(e,t){const n=WZe(e,s);function s(...r){return fq(r,n,t)}return s}function WZe(e,t){var n,s,r;return{defaultMergeFunctions:ox,mergeFunctions:Pi({},ox,Object.fromEntries(Object.entries(e).filter(([i,a])=>Object.hasOwn(ox,i)).map(([i,a])=>a===!1?[i,ox.mergeOthers]:[i,a]))),metaDataUpdater:(n=e.metaDataUpdater)!=null?n:PZe,deepmerge:t,useImplicitDefaultMerging:(s=e.enableImplicitDefaultMerging)!=null?s:!1,filterValues:e.filterValues===!1?void 0:(r=e.filterValues)!=null?r:NZe,actions:Pu}}function fq(e,t,n){var s;const r=(s=t.filterValues==null?void 0:t.filterValues(e,n))!=null?s:e;if(r.length===0)return;if(r.length===1)return nk(r,t,n);const i=XB(r[0]);if(i!==0&&i!==5){for(let a=1;a<r.length;a++)if(XB(r[a])!==i)return nk(r,t,n)}switch(i){case 1:return $Ze(r,t,n);case 2:return zZe(r,t,n);case 3:return qZe(r,t,n);case 4:return KZe(r,t,n);default:return nk(r,t,n)}}function $Ze(e,t,n){const s=t.mergeFunctions.mergeRecords(e,t,n);return s===Pu.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeRecords!==t.defaultMergeFunctions.mergeRecords?t.defaultMergeFunctions.mergeRecords(e,t,n):s}function zZe(e,t,n){const s=t.mergeFunctions.mergeArrays(e,t,n);return s===Pu.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeArrays!==t.defaultMergeFunctions.mergeArrays?t.defaultMergeFunctions.mergeArrays(e):s}function qZe(e,t,n){const s=t.mergeFunctions.mergeSets(e,t,n);return s===Pu.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeSets!==t.defaultMergeFunctions.mergeSets?t.defaultMergeFunctions.mergeSets(e):s}function KZe(e,t,n){const s=t.mergeFunctions.mergeMaps(e,t,n);return s===Pu.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeMaps!==t.defaultMergeFunctions.mergeMaps?t.defaultMergeFunctions.mergeMaps(e):s}function nk(e,t,n){const s=t.mergeFunctions.mergeOthers(e,t,n);return s===Pu.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeOthers!==t.defaultMergeFunctions.mergeOthers?t.defaultMergeFunctions.mergeOthers(e):s}function jF(e){const t=Object.getOwnPropertyNames(e.constructor.prototype);for(let n=0;n<t.length;n++){const s=t[n],r=e[s];s!=="constructor"&&typeof r=="function"&&(e[s]=r.bind(e))}return e}function YZe(e,t){return n=>{if(e.isOpen()){const s=e.el&&n.currentTarget===e.el;(!$r(t)&&n.currentTarget.matches(t)||s)&&e.tour.next()}}}function XZe(e){const{event:t,selector:n}=e.options.advanceOn||{};if(t){const s=YZe(e,n);let r=null;if(!$r(n)&&(r=document.querySelector(n),!r))return console.error(`No element was found for the selector supplied to advanceOn: ${n}`);r?(r.addEventListener(t,s),e.on("destroy",()=>r.removeEventListener(t,s))):(document.body.addEventListener(t,s,!0),e.on("destroy",()=>document.body.removeEventListener(t,s,!0)))}else return console.error("advanceOn was defined, but no event name was passed.")}class QZe{constructor(t){}}class JZe{constructor(t,n){}}function pq(e){return!ov(e)||e===""?"":e.charAt(e.length-1)!=="-"?`${e}-`:e}function ZZe(e){const t=e.options.attachTo||{},n=Object.assign({},t);if(xu(n.element)&&(n.element=n.element.call(e)),ov(n.element)){try{n.element=document.querySelector(n.element)}catch{}n.element||console.error(`The element for this Shepherd step was not found ${t.element}`)}return n}function eet(e){return e.options.extraHighlights?e.options.extraHighlights.flatMap(t=>Array.from(document.querySelectorAll(t))):[]}function gq(e){return e==null?!0:!e.element||!e.on}function mq(){let e=Date.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=(e+Math.random()*16)%16|0;return e=Math.floor(e/16),(t=="x"?n:n&3|8).toString(16)})}const tet=["top","right","bottom","left"],JB=["start","end"],ZB=tet.reduce((e,t)=>e.concat(t,t+"-"+JB[0],t+"-"+JB[1]),[]),Op=Math.min,Kd=Math.max,E_=Math.round,lx=Math.floor,sl=e=>({x:e,y:e}),net={left:"right",right:"left",bottom:"top",top:"bottom"},set={start:"end",end:"start"};function iR(e,t,n){return Kd(e,Op(t,n))}function xh(e,t){return typeof e=="function"?e(t):e}function oc(e){return e.split("-")[0]}function tc(e){return e.split("-")[1]}function HF(e){return e==="x"?"y":"x"}function UF(e){return e==="y"?"height":"width"}function Lp(e){return["top","bottom"].includes(oc(e))?"y":"x"}function GF(e){return HF(Lp(e))}function vq(e,t,n){n===void 0&&(n=!1);const s=tc(e),r=GF(e),i=UF(r);let a=r==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=R_(a)),[a,R_(a)]}function ret(e){const t=R_(e);return[T_(e),t,T_(t)]}function T_(e){return e.replace(/start|end/g,t=>set[t])}function iet(e,t,n){const s=["left","right"],r=["right","left"],i=["top","bottom"],a=["bottom","top"];switch(e){case"top":case"bottom":return n?t?r:s:t?s:r;case"left":case"right":return t?i:a;default:return[]}}function aet(e,t,n,s){const r=tc(e);let i=iet(oc(e),n==="start",s);return r&&(i=i.map(a=>a+"-"+r),t&&(i=i.concat(i.map(T_)))),i}function R_(e){return e.replace(/left|right|bottom|top/g,t=>net[t])}function oet(e){return Pi({top:0,right:0,bottom:0,left:0},e)}function bq(e){return typeof e!="number"?oet(e):{top:e,right:e,bottom:e,left:e}}function A_(e){const{x:t,y:n,width:s,height:r}=e;return{width:s,height:r,top:n,left:t,right:t+s,bottom:n+r,x:t,y:n}}const cet=["crossAxis","alignment","allowedPlacements","autoAlignment"],uet=["mainAxis","crossAxis","fallbackPlacements","fallbackStrategy","fallbackAxisSideDirection","flipAlignment"],det=["mainAxis","crossAxis","limiter"];function ej(e,t,n){let{reference:s,floating:r}=e;const i=Lp(t),a=GF(t),o=UF(a),l=oc(t),u=i==="y",d=s.x+s.width/2-r.width/2,h=s.y+s.height/2-r.height/2,f=s[o]/2-r[o]/2;let g;switch(l){case"top":g={x:d,y:s.y-r.height};break;case"bottom":g={x:d,y:s.y+s.height};break;case"right":g={x:s.x+s.width,y:h};break;case"left":g={x:s.x-r.width,y:h};break;default:g={x:s.x,y:s.y}}switch(tc(t)){case"start":g[a]-=f*(n&&u?-1:1);break;case"end":g[a]+=f*(n&&u?-1:1);break}return g}const het=async(e,t,n)=>{const{placement:s="bottom",strategy:r="absolute",middleware:i=[],platform:a}=n,o=i.filter(Boolean),l=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:r}),{x:d,y:h}=ej(u,s,l),f=s,g={},v=0;for(let b=0;b<o.length;b++){const{name:x,fn:w}=o[b],{x:_,y:C,data:S,reset:y}=await w({x:d,y:h,initialPlacement:s,placement:f,strategy:r,middlewareData:g,rects:u,platform:a,elements:{reference:e,floating:t}});d=_??d,h=C??h,g=Pi({},g,{[x]:Pi({},g[x],S)}),y&&v<=50&&(v++,typeof y=="object"&&(y.placement&&(f=y.placement),y.rects&&(u=y.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:r}):y.rects),{x:d,y:h}=ej(u,f,l)),b=-1)}return{x:d,y:h,placement:f,strategy:r,middlewareData:g}};async function VF(e,t){var n;t===void 0&&(t={});const{x:s,y:r,platform:i,rects:a,elements:o,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:f=!1,padding:g=0}=xh(t,e),v=bq(g),b=o[f?h==="floating"?"reference":"floating":h],x=A_(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(b)))==null||n?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:u,rootBoundary:d,strategy:l})),w=h==="floating"?{x:s,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),C=await(i.isElement==null?void 0:i.isElement(_))?await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1}:{x:1,y:1},S=A_(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:w,offsetParent:_,strategy:l}):w);return{top:(x.top-S.top+v.top)/C.y,bottom:(S.bottom-x.bottom+v.bottom)/C.y,left:(x.left-S.left+v.left)/C.x,right:(S.right-x.right+v.right)/C.x}}const fet=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:r,rects:i,platform:a,elements:o,middlewareData:l}=t,{element:u,padding:d=0}=xh(e,t)||{};if(u==null)return{};const h=bq(d),f={x:n,y:s},g=GF(r),v=UF(g),b=await a.getDimensions(u),x=g==="y",w=x?"top":"left",_=x?"bottom":"right",C=x?"clientHeight":"clientWidth",S=i.reference[v]+i.reference[g]-f[g]-i.floating[v],y=f[g]-i.reference[g],R=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let E=R?R[C]:0;(!E||!await(a.isElement==null?void 0:a.isElement(R)))&&(E=o.floating[C]||i.floating[v]);const F=S/2-y/2,A=E/2-b[v]/2-1,I=Op(h[w],A),P=Op(h[_],A),N=I,L=E-b[v]-P,V=E/2-b[v]/2+F,B=iR(N,V,L),ne=!l.arrow&&tc(r)!=null&&V!==B&&i.reference[v]/2-(V<N?I:P)-b[v]/2<0,J=ne?V<N?V-N:V-L:0;return{[g]:f[g]+J,data:Pi({[g]:B,centerOffset:V-B-J},ne&&{alignmentOffset:J}),reset:ne}}});function pet(e,t,n){return(e?[...n.filter(s=>tc(s)===e),...n.filter(s=>tc(s)!==e)]:n.filter(s=>oc(s)===s)).filter(s=>e?tc(s)===e||(t?T_(s)!==s:!1):!0)}const get=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,s,r;const{rects:i,middlewareData:a,placement:o,platform:l,elements:u}=t,d=xh(e,t),{crossAxis:h=!1,alignment:f,allowedPlacements:g=ZB,autoAlignment:v=!0}=d,b=LF(d,cet),x=f!==void 0||g===ZB?pet(f||null,v,g):g,w=await VF(t,b),_=((n=a.autoPlacement)==null?void 0:n.index)||0,C=x[_];if(C==null)return{};const S=vq(C,i,await(l.isRTL==null?void 0:l.isRTL(u.floating)));if(o!==C)return{reset:{placement:x[0]}};const y=[w[oc(C)],w[S[0]],w[S[1]]],R=[...((s=a.autoPlacement)==null?void 0:s.overflows)||[],{placement:C,overflows:y}],E=x[_+1];if(E)return{data:{index:_+1,overflows:R},reset:{placement:E}};const F=R.map(I=>{const P=tc(I.placement);return[I.placement,P&&h?I.overflows.slice(0,2).reduce((N,L)=>N+L,0):I.overflows[0],I.overflows]}).sort((I,P)=>I[1]-P[1]),A=((r=F.filter(I=>I[2].slice(0,tc(I[0])?2:3).every(P=>P<=0))[0])==null?void 0:r[0])||F[0][0];return A!==o?{data:{index:_+1,overflows:R},reset:{placement:A}}:{}}}},met=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:l,elements:u}=t,d=xh(e,t),{mainAxis:h=!0,crossAxis:f=!0,fallbackPlacements:g,fallbackStrategy:v="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:x=!0}=d,w=LF(d,uet);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const _=oc(r),C=Lp(o),S=oc(o)===o,y=await(l.isRTL==null?void 0:l.isRTL(u.floating)),R=g||(S||!x?[R_(o)]:ret(o)),E=b!=="none";!g&&E&&R.push(...aet(o,x,b,y));const F=[o,...R],A=await VF(t,w),I=[];let P=((s=i.flip)==null?void 0:s.overflows)||[];if(h&&I.push(A[_]),f){const B=vq(r,a,y);I.push(A[B[0]],A[B[1]])}if(P=[...P,{placement:r,overflows:I}],!I.every(B=>B<=0)){var N,L;const B=(((N=i.flip)==null?void 0:N.index)||0)+1,ne=F[B];if(ne)return{data:{index:B,overflows:P},reset:{placement:ne}};let J=(L=P.filter(Q=>Q.overflows[0]<=0).sort((Q,G)=>Q.overflows[1]-G.overflows[1])[0])==null?void 0:L.placement;if(!J)switch(v){case"bestFit":{var V;const Q=(V=P.filter(G=>{if(E){const oe=Lp(G.placement);return oe===C||oe==="y"}return!0}).map(G=>[G.placement,G.overflows.filter(oe=>oe>0).reduce((oe,ce)=>oe+ce,0)]).sort((G,oe)=>G[1]-oe[1])[0])==null?void 0:V[0];Q&&(J=Q);break}case"initialPlacement":J=o;break}if(r!==J)return{reset:{placement:J}}}return{}}}},vet=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:r}=t,i=xh(e,t),{mainAxis:a=!0,crossAxis:o=!1,limiter:l={fn:w=>{let{x:_,y:C}=w;return{x:_,y:C}}}}=i,u=LF(i,det),d={x:n,y:s},h=await VF(t,u),f=Lp(oc(r)),g=HF(f);let v=d[g],b=d[f];if(a){const w=g==="y"?"top":"left",_=g==="y"?"bottom":"right",C=v+h[w],S=v-h[_];v=iR(C,v,S)}if(o){const w=f==="y"?"top":"left",_=f==="y"?"bottom":"right",C=b+h[w],S=b-h[_];b=iR(C,b,S)}const x=l.fn(Pi({},t,{[g]:v,[f]:b}));return Pi({},x,{data:{x:x.x-n,y:x.y-s}})}}},bet=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:r,rects:i,middlewareData:a}=t,{offset:o=0,mainAxis:l=!0,crossAxis:u=!0}=xh(e,t),d={x:n,y:s},h=Lp(r),f=HF(h);let g=d[f],v=d[h];const b=xh(o,t),x=typeof b=="number"?{mainAxis:b,crossAxis:0}:Pi({mainAxis:0,crossAxis:0},b);if(l){const C=f==="y"?"height":"width",S=i.reference[f]-i.floating[C]+x.mainAxis,y=i.reference[f]+i.reference[C]-x.mainAxis;g<S?g=S:g>y&&(g=y)}if(u){var w,_;const C=f==="y"?"width":"height",S=["top","left"].includes(oc(r)),y=i.reference[h]-i.floating[C]+(S&&((w=a.offset)==null?void 0:w[h])||0)+(S?0:x.crossAxis),R=i.reference[h]+i.reference[C]+(S?0:((_=a.offset)==null?void 0:_[h])||0)-(S?x.crossAxis:0);v<y?v=y:v>R&&(v=R)}return{[f]:g,[h]:v}}}};function XC(){return typeof window<"u"}function og(e){return xq(e)?(e.nodeName||"").toLowerCase():"#document"}function na(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function gl(e){var t;return(t=(xq(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function xq(e){return XC()?e instanceof Node||e instanceof na(e).Node:!1}function po(e){return XC()?e instanceof Element||e instanceof na(e).Element:!1}function cl(e){return XC()?e instanceof HTMLElement||e instanceof na(e).HTMLElement:!1}function tj(e){return!XC()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof na(e).ShadowRoot}function $v(e){const{overflow:t,overflowX:n,overflowY:s,display:r}=go(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!["inline","contents"].includes(r)}function xet(e){return["table","td","th"].includes(og(e))}function QC(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function WF(e){const t=$F(),n=po(e)?go(e):e;return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(s=>(n.willChange||"").includes(s))||["paint","layout","strict","content"].some(s=>(n.contain||"").includes(s))}function wet(e){let t=wu(e);for(;cl(t)&&!Bp(t);){if(WF(t))return t;if(QC(t))return null;t=wu(t)}return null}function $F(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Bp(e){return["html","body","#document"].includes(og(e))}function go(e){return na(e).getComputedStyle(e)}function JC(e){return po(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function wu(e){if(og(e)==="html")return e;const t=e.assignedSlot||e.parentNode||tj(e)&&e.host||gl(e);return tj(t)?t.host:t}function wq(e){const t=wu(e);return Bp(t)?e.ownerDocument?e.ownerDocument.body:e.body:cl(t)&&$v(t)?t:wq(t)}function lv(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=wq(e),i=r===((s=e.ownerDocument)==null?void 0:s.body),a=na(r);if(i){const o=aR(a);return t.concat(a,a.visualViewport||[],$v(r)?r:[],o&&n?lv(o):[])}return t.concat(r,lv(r,[],n))}function aR(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function _q(e){const t=go(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const r=cl(e),i=r?e.offsetWidth:n,a=r?e.offsetHeight:s,o=E_(n)!==i||E_(s)!==a;return o&&(n=i,s=a),{width:n,height:s,$:o}}function zF(e){return po(e)?e:e.contextElement}function dp(e){const t=zF(e);if(!cl(t))return sl(1);const n=t.getBoundingClientRect(),{width:s,height:r,$:i}=_q(t);let a=(i?E_(n.width):n.width)/s,o=(i?E_(n.height):n.height)/r;return(!a||!Number.isFinite(a))&&(a=1),(!o||!Number.isFinite(o))&&(o=1),{x:a,y:o}}const _et=sl(0);function Cq(e){const t=na(e);return!$F()||!t.visualViewport?_et:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Cet(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==na(e)?!1:t}function wh(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),i=zF(e);let a=sl(1);t&&(s?po(s)&&(a=dp(s)):a=dp(e));const o=Cet(i,n,s)?Cq(i):sl(0);let l=(r.left+o.x)/a.x,u=(r.top+o.y)/a.y,d=r.width/a.x,h=r.height/a.y;if(i){const f=na(i),g=s&&po(s)?na(s):s;let v=f,b=aR(v);for(;b&&s&&g!==v;){const x=dp(b),w=b.getBoundingClientRect(),_=go(b),C=w.left+(b.clientLeft+parseFloat(_.paddingLeft))*x.x,S=w.top+(b.clientTop+parseFloat(_.paddingTop))*x.y;l*=x.x,u*=x.y,d*=x.x,h*=x.y,l+=C,u+=S,v=na(b),b=aR(v)}}return A_({width:d,height:h,x:l,y:u})}function qF(e,t){const n=JC(e).scrollLeft;return t?t.left+n:wh(gl(e)).left+n}function yq(e,t,n){n===void 0&&(n=!1);const s=e.getBoundingClientRect(),r=s.left+t.scrollLeft-(n?0:qF(e,s)),i=s.top+t.scrollTop;return{x:r,y:i}}function yet(e){let{elements:t,rect:n,offsetParent:s,strategy:r}=e;const i=r==="fixed",a=gl(s),o=t?QC(t.floating):!1;if(s===a||o&&i)return n;let l={scrollLeft:0,scrollTop:0},u=sl(1);const d=sl(0),h=cl(s);if((h||!h&&!i)&&((og(s)!=="body"||$v(a))&&(l=JC(s)),cl(s))){const g=wh(s);u=dp(s),d.x=g.x+s.clientLeft,d.y=g.y+s.clientTop}const f=a&&!h&&!i?yq(a,l,!0):sl(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+f.x,y:n.y*u.y-l.scrollTop*u.y+d.y+f.y}}function ket(e){return Array.from(e.getClientRects())}function Eet(e){const t=gl(e),n=JC(e),s=e.ownerDocument.body,r=Kd(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),i=Kd(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let a=-n.scrollLeft+qF(e);const o=-n.scrollTop;return go(s).direction==="rtl"&&(a+=Kd(t.clientWidth,s.clientWidth)-r),{width:r,height:i,x:a,y:o}}function Tet(e,t){const n=na(e),s=gl(e),r=n.visualViewport;let i=s.clientWidth,a=s.clientHeight,o=0,l=0;if(r){i=r.width,a=r.height;const u=$F();(!u||u&&t==="fixed")&&(o=r.offsetLeft,l=r.offsetTop)}return{width:i,height:a,x:o,y:l}}function Ret(e,t){const n=wh(e,!0,t==="fixed"),s=n.top+e.clientTop,r=n.left+e.clientLeft,i=cl(e)?dp(e):sl(1),a=e.clientWidth*i.x,o=e.clientHeight*i.y,l=r*i.x,u=s*i.y;return{width:a,height:o,x:l,y:u}}function nj(e,t,n){let s;if(t==="viewport")s=Tet(e,n);else if(t==="document")s=Eet(gl(e));else if(po(t))s=Ret(t,n);else{const r=Cq(e);s={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return A_(s)}function Sq(e,t){const n=wu(e);return n===t||!po(n)||Bp(n)?!1:go(n).position==="fixed"||Sq(n,t)}function Aet(e,t){const n=t.get(e);if(n)return n;let s=lv(e,[],!1).filter(o=>po(o)&&og(o)!=="body"),r=null;const i=go(e).position==="fixed";let a=i?wu(e):e;for(;po(a)&&!Bp(a);){const o=go(a),l=WF(a);!l&&o.position==="fixed"&&(r=null),(i?!l&&!r:!l&&o.position==="static"&&r&&["absolute","fixed"].includes(r.position)||$v(a)&&!l&&Sq(e,a))?s=s.filter(u=>u!==a):r=o,a=wu(a)}return t.set(e,s),s}function Fet(e){let{element:t,boundary:n,rootBoundary:s,strategy:r}=e;const i=[...n==="clippingAncestors"?QC(t)?[]:Aet(t,this._c):[].concat(n),s],a=i[0],o=i.reduce((l,u)=>{const d=nj(t,u,r);return l.top=Kd(d.top,l.top),l.right=Op(d.right,l.right),l.bottom=Op(d.bottom,l.bottom),l.left=Kd(d.left,l.left),l},nj(t,a,r));return{width:o.right-o.left,height:o.bottom-o.top,x:o.left,y:o.top}}function Det(e){const{width:t,height:n}=_q(e);return{width:t,height:n}}function Iet(e,t,n){const s=cl(t),r=gl(t),i=n==="fixed",a=wh(e,!0,i,t);let o={scrollLeft:0,scrollTop:0};const l=sl(0);if(s||!s&&!i)if((og(t)!=="body"||$v(r))&&(o=JC(t)),s){const f=wh(t,!0,i,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else r&&(l.x=qF(r));const u=r&&!s&&!i?yq(r,o):sl(0),d=a.left+o.scrollLeft-l.x-u.x,h=a.top+o.scrollTop-l.y-u.y;return{x:d,y:h,width:a.width,height:a.height}}function sk(e){return go(e).position==="static"}function sj(e,t){if(!cl(e)||go(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return gl(e)===n&&(n=n.ownerDocument.body),n}function kq(e,t){const n=na(e);if(QC(e))return n;if(!cl(e)){let r=wu(e);for(;r&&!Bp(r);){if(po(r)&&!sk(r))return r;r=wu(r)}return n}let s=sj(e,t);for(;s&&xet(s)&&sk(s);)s=sj(s,t);return s&&Bp(s)&&sk(s)&&!WF(s)?n:s||wet(e)||n}const Pet=async function(e){const t=this.getOffsetParent||kq,n=this.getDimensions,s=await n(e.floating);return{reference:Iet(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function Net(e){return go(e).direction==="rtl"}const Met={convertOffsetParentRelativeRectToViewportRelativeRect:yet,getDocumentElement:gl,getClippingRect:Fet,getOffsetParent:kq,getElementRects:Pet,getClientRects:ket,getDimensions:Det,getScale:dp,isElement:po,isRTL:Net};function Oet(e,t){let n=null,s;const r=gl(e);function i(){var o;clearTimeout(s),(o=n)==null||o.disconnect(),n=null}function a(o,l){o===void 0&&(o=!1),l===void 0&&(l=1),i();const{left:u,top:d,width:h,height:f}=e.getBoundingClientRect();if(o||t(),!h||!f)return;const g=lx(d),v=lx(r.clientWidth-(u+h)),b=lx(r.clientHeight-(d+f)),x=lx(u),w={rootMargin:-g+"px "+-v+"px "+-b+"px "+-x+"px",threshold:Kd(0,Op(1,l))||1};let _=!0;function C(S){const y=S[0].intersectionRatio;if(y!==l){if(!_)return a();y?a(!1,y):s=setTimeout(()=>{a(!1,1e-7)},1e3)}_=!1}try{n=new IntersectionObserver(C,Pi({},w,{root:r.ownerDocument}))}catch{n=new IntersectionObserver(C,w)}n.observe(e)}return a(!0),i}function Let(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:r=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:o=typeof IntersectionObserver=="function",animationFrame:l=!1}=s,u=zF(e),d=r||i?[...u?lv(u):[],...lv(t)]:[];d.forEach(w=>{r&&w.addEventListener("scroll",n,{passive:!0}),i&&w.addEventListener("resize",n)});const h=u&&o?Oet(u,n):null;let f=-1,g=null;a&&(g=new ResizeObserver(w=>{let[_]=w;_&&_.target===u&&g&&(g.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var C;(C=g)==null||C.observe(t)})),n()}),u&&!l&&g.observe(u),g.observe(t));let v,b=l?wh(e):null;l&&x();function x(){const w=wh(e);b&&(w.x!==b.x||w.y!==b.y||w.width!==b.width||w.height!==b.height)&&n(),b=w,v=requestAnimationFrame(x)}return n(),()=>{var w;d.forEach(_=>{r&&_.removeEventListener("scroll",n),i&&_.removeEventListener("resize",n)}),h?.(),(w=g)==null||w.disconnect(),g=null,l&&cancelAnimationFrame(v)}}const Bet=get,jet=vet,Het=met,Uet=fet,Get=bet,Vet=(e,t,n)=>{const s=new Map,r=Pi({platform:Met},n),i=Pi({},r.platform,{_c:s});return het(e,t,Pi({},r,{platform:i}))};function Wet(e){e.cleanup&&e.cleanup();const t=e._getResolvedAttachToOptions();let n=t.element;const s=Xet(t,e),r=gq(t);return r&&(n=document.body,e.shepherdElementComponent.getElement().classList.add("shepherd-centered")),e.cleanup=Let(n,e.el,()=>{if(!e.el){e.cleanup==null||e.cleanup();return}qet(n,e,s,r)}),e.target=t.element,s}function $et(e,t){return{floatingUIOptions:BF(e.floatingUIOptions||{},t.floatingUIOptions||{})}}function zet(e){e.cleanup&&e.cleanup(),e.cleanup=null}function qet(e,t,n,s){return Vet(e,t.el,n).then(Ket(t,s)).then(r=>new Promise(i=>{setTimeout(()=>i(r),300)})).then(r=>{r!=null&&r.el&&r.el.focus({preventScroll:!0})})}function Ket(e,t){return({x:n,y:s,placement:r,middlewareData:i})=>(e.el&&(t?Object.assign(e.el.style,{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)"}):Object.assign(e.el.style,{position:"absolute",left:`${n}px`,top:`${s}px`}),e.el.dataset.popperPlacement=r,Yet(e.el,i)),e)}function Yet(e,t){const n=e.querySelector(".shepherd-arrow");if(Mp(n)&&t.arrow){const{x:s,y:r}=t.arrow;Object.assign(n.style,{left:s!=null?`${s}px`:"",top:r!=null?`${r}px`:""})}}function Xet(e,t){var n,s,r;const i={strategy:"absolute"};i.middleware=[];const a=Qet(t),o=gq(e),l=(n=e.on)==null?void 0:n.includes("auto"),u=(e==null||(s=e.on)==null?void 0:s.includes("-start"))||(e==null||(r=e.on)==null?void 0:r.includes("-end"));if(!o){if(l){var d;i.middleware.push(Bet({crossAxis:!0,alignment:u?e==null||(d=e.on)==null?void 0:d.split("-").pop():null}))}else i.middleware.push(Het());if(i.middleware.push(jet({limiter:Get(),crossAxis:!0})),a){const h=typeof t.options.arrow=="object"?t.options.arrow:{padding:4};i.middleware.push(Uet({element:a,padding:u?h.padding:0}))}l||(i.placement=e.on)}return BF(i,t.options.floatingUIOptions||{})}function Qet(e){return e.options.arrow&&e.el?e.el.querySelector(".shepherd-arrow"):!1}function aa(){}function Jet(e,t){for(const n in t)e[n]=t[n];return e}function Eq(e){return e()}function rj(){return Object.create(null)}function zv(e){e.forEach(Eq)}function KF(e){return typeof e=="function"}function mc(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function Zet(e){return Object.keys(e).length===0}function jp(e,t){e.appendChild(t)}function _o(e,t,n){e.insertBefore(t,n||null)}function za(e){e.parentNode&&e.parentNode.removeChild(e)}function ett(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function ul(e){return document.createElement(e)}function ij(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function Tq(e){return document.createTextNode(e)}function F_(){return Tq(" ")}function ttt(){return Tq("")}function ZC(e,t,n,s){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n,s)}function ts(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}const ntt=["width","height"];function aj(e,t){const n=Object.getOwnPropertyDescriptors(e.__proto__);for(const s in t)t[s]==null?e.removeAttribute(s):s==="style"?e.style.cssText=t[s]:s==="__value"?e.value=e[s]=t[s]:n[s]&&n[s].set&&ntt.indexOf(s)===-1?e[s]=t[s]:ts(e,s,t[s])}function stt(e){return Array.from(e.childNodes)}function ff(e,t,n){e.classList.toggle(t,!!n)}let cv;function n0(e){cv=e}function Rq(){if(!cv)throw new Error("Function called outside component initialization");return cv}function rtt(e){Rq().$$.on_mount.push(e)}function YF(e){Rq().$$.after_update.push(e)}const Rf=[],Hp=[];let hp=[];const oj=[],itt=Promise.resolve();let oR=!1;function att(){oR||(oR=!0,itt.then(Aq))}function lR(e){hp.push(e)}const rk=new Set;let pf=0;function Aq(){if(pf!==0)return;const e=cv;do{try{for(;pf<Rf.length;){const t=Rf[pf];pf++,n0(t),ott(t.$$)}}catch(t){throw Rf.length=0,pf=0,t}for(n0(null),Rf.length=0,pf=0;Hp.length;)Hp.pop()();for(let t=0;t<hp.length;t+=1){const n=hp[t];rk.has(n)||(rk.add(n),n())}hp.length=0}while(Rf.length);for(;oj.length;)oj.pop()();oR=!1,rk.clear(),n0(e)}function ott(e){if(e.fragment!==null){e.update(),zv(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(lR)}}function ltt(e){const t=[],n=[];hp.forEach(s=>e.indexOf(s)===-1?t.push(s):n.push(s)),n.forEach(s=>s()),hp=t}const Ux=new Set;let Dd;function Yd(){Dd={r:0,c:[],p:Dd}}function Xd(){Dd.r||zv(Dd.c),Dd=Dd.p}function Vn(e,t){e&&e.i&&(Ux.delete(e),e.i(t))}function Ls(e,t,n,s){if(e&&e.o){if(Ux.has(e))return;Ux.add(e),Dd.c.push(()=>{Ux.delete(e),s&&(n&&e.d(1),s())}),e.o(t)}else s&&s()}function lj(e){return e?.length!==void 0?e:Array.from(e)}function ctt(e,t){const n={},s={},r={$$scope:1};let i=e.length;for(;i--;){const a=e[i],o=t[i];if(o){for(const l in a)l in o||(s[l]=1);for(const l in o)r[l]||(n[l]=o[l],r[l]=1);e[i]=o}else for(const l in a)r[l]=1}for(const a in s)a in n||(n[a]=void 0);return n}function Oh(e){e&&e.c()}function Nu(e,t,n){const{fragment:s,after_update:r}=e.$$;s&&s.m(t,n),lR(()=>{const i=e.$$.on_mount.map(Eq).filter(KF);e.$$.on_destroy?e.$$.on_destroy.push(...i):zv(i),e.$$.on_mount=[]}),r.forEach(lR)}function Mu(e,t){const n=e.$$;n.fragment!==null&&(ltt(n.after_update),zv(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function utt(e,t){e.$$.dirty[0]===-1&&(Rf.push(e),att(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function vc(e,t,n,s,r,i,a=null,o=[-1]){const l=cv;n0(e);const u=e.$$={fragment:null,ctx:[],props:i,update:aa,not_equal:r,bound:rj(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:rj(),dirty:o,skip_bound:!1,root:t.target||l.$$.root};a&&a(u.root);let d=!1;if(u.ctx=n?n(e,t.props||{},(h,f,...g)=>{const v=g.length?g[0]:f;return u.ctx&&r(u.ctx[h],u.ctx[h]=v)&&(!u.skip_bound&&u.bound[h]&&u.bound[h](v),d&&utt(e,h)),f}):[],u.update(),d=!0,zv(u.before_update),u.fragment=s?s(u.ctx):!1,t.target){if(t.hydrate){const h=stt(t.target);u.fragment&&u.fragment.l(h),h.forEach(za)}else u.fragment&&u.fragment.c();t.intro&&Vn(e.$$.fragment),Nu(e,t.target,t.anchor),Aq()}n0(l)}class bc{constructor(){this.$$=void 0,this.$$set=void 0}$destroy(){Mu(this,1),this.$destroy=aa}$on(t,n){if(!KF(n))return aa;const s=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return s.push(n),()=>{const r=s.indexOf(n);r!==-1&&s.splice(r,1)}}$set(t){this.$$set&&!Zet(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const dtt="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(dtt);function htt(e){let t,n,s,r,i;return{c(){t=ul("button"),ts(t,"aria-label",n=e[3]?e[3]:null),ts(t,"class",s=`${e[1]||""} shepherd-button ${e[4]?"shepherd-button-secondary":""}`),t.disabled=e[2],ts(t,"tabindex","0"),ts(t,"type","button")},m(a,o){_o(a,t,o),t.innerHTML=e[5],r||(i=ZC(t,"click",function(){KF(e[0])&&e[0].apply(this,arguments)}),r=!0)},p(a,[o]){e=a,o&32&&(t.innerHTML=e[5]),o&8&&n!==(n=e[3]?e[3]:null)&&ts(t,"aria-label",n),o&18&&s!==(s=`${e[1]||""} shepherd-button ${e[4]?"shepherd-button-secondary":""}`)&&ts(t,"class",s),o&4&&(t.disabled=e[2])},i:aa,o:aa,d(a){a&&za(t),r=!1,i()}}}function ftt(e,t,n){let{config:s,step:r}=t,i,a,o,l,u,d;function h(f){return xu(f)?f=f.call(r):f}return e.$$set=f=>{"config"in f&&n(6,s=f.config),"step"in f&&n(7,r=f.step)},e.$$.update=()=>{e.$$.dirty&192&&(n(0,i=s.action?s.action.bind(r.tour):null),n(1,a=s.classes),n(2,o=s.disabled?h(s.disabled):!1),n(3,l=s.label?h(s.label):null),n(4,u=s.secondary),n(5,d=s.text?h(s.text):null))},[i,a,o,l,u,d,s,r]}class ptt extends bc{constructor(t){super(),vc(this,t,ftt,htt,mc,{config:6,step:7})}}function cj(e,t,n){const s=e.slice();return s[2]=t[n],s}function uj(e){let t,n,s=lj(e[1]),r=[];for(let a=0;a<s.length;a+=1)r[a]=dj(cj(e,s,a));const i=a=>Ls(r[a],1,1,()=>{r[a]=null});return{c(){for(let a=0;a<r.length;a+=1)r[a].c();t=ttt()},m(a,o){for(let l=0;l<r.length;l+=1)r[l]&&r[l].m(a,o);_o(a,t,o),n=!0},p(a,o){if(o&3){s=lj(a[1]);let l;for(l=0;l<s.length;l+=1){const u=cj(a,s,l);r[l]?(r[l].p(u,o),Vn(r[l],1)):(r[l]=dj(u),r[l].c(),Vn(r[l],1),r[l].m(t.parentNode,t))}for(Yd(),l=s.length;l<r.length;l+=1)i(l);Xd()}},i(a){if(!n){for(let o=0;o<s.length;o+=1)Vn(r[o]);n=!0}},o(a){r=r.filter(Boolean);for(let o=0;o<r.length;o+=1)Ls(r[o]);n=!1},d(a){a&&za(t),ett(r,a)}}}function dj(e){let t,n;return t=new ptt({props:{config:e[2],step:e[0]}}),{c(){Oh(t.$$.fragment)},m(s,r){Nu(t,s,r),n=!0},p(s,r){const i={};r&2&&(i.config=s[2]),r&1&&(i.step=s[0]),t.$set(i)},i(s){n||(Vn(t.$$.fragment,s),n=!0)},o(s){Ls(t.$$.fragment,s),n=!1},d(s){Mu(t,s)}}}function gtt(e){let t,n,s=e[1]&&uj(e);return{c(){t=ul("footer"),s&&s.c(),ts(t,"class","shepherd-footer")},m(r,i){_o(r,t,i),s&&s.m(t,null),n=!0},p(r,[i]){r[1]?s?(s.p(r,i),i&2&&Vn(s,1)):(s=uj(r),s.c(),Vn(s,1),s.m(t,null)):s&&(Yd(),Ls(s,1,1,()=>{s=null}),Xd())},i(r){n||(Vn(s),n=!0)},o(r){Ls(s),n=!1},d(r){r&&za(t),s&&s.d()}}}function mtt(e,t,n){let s,{step:r}=t;return e.$$set=i=>{"step"in i&&n(0,r=i.step)},e.$$.update=()=>{e.$$.dirty&1&&n(1,s=r.options.buttons)},[r,s]}class vtt extends bc{constructor(t){super(),vc(this,t,mtt,gtt,mc,{step:0})}}function btt(e){let t,n,s,r,i;return{c(){t=ul("button"),n=ul("span"),n.textContent="×",ts(n,"aria-hidden","true"),ts(t,"aria-label",s=e[0].label?e[0].label:"Close Tour"),ts(t,"class","shepherd-cancel-icon"),ts(t,"type","button")},m(a,o){_o(a,t,o),jp(t,n),r||(i=ZC(t,"click",e[1]),r=!0)},p(a,[o]){o&1&&s!==(s=a[0].label?a[0].label:"Close Tour")&&ts(t,"aria-label",s)},i:aa,o:aa,d(a){a&&za(t),r=!1,i()}}}function xtt(e,t,n){let{cancelIcon:s,step:r}=t;const i=a=>{a.preventDefault(),r.cancel()};return e.$$set=a=>{"cancelIcon"in a&&n(0,s=a.cancelIcon),"step"in a&&n(2,r=a.step)},[s,i,r]}class wtt extends bc{constructor(t){super(),vc(this,t,xtt,btt,mc,{cancelIcon:0,step:2})}}function _tt(e){let t;return{c(){t=ul("h3"),ts(t,"id",e[1]),ts(t,"class","shepherd-title")},m(n,s){_o(n,t,s),e[3](t)},p(n,[s]){s&2&&ts(t,"id",n[1])},i:aa,o:aa,d(n){n&&za(t),e[3](null)}}}function Ctt(e,t,n){let{labelId:s,element:r,title:i}=t;YF(()=>{xu(i)&&n(2,i=i()),n(0,r.innerHTML=i,r)});function a(o){Hp[o?"unshift":"push"](()=>{r=o,n(0,r)})}return e.$$set=o=>{"labelId"in o&&n(1,s=o.labelId),"element"in o&&n(0,r=o.element),"title"in o&&n(2,i=o.title)},[r,s,i,a]}class ytt extends bc{constructor(t){super(),vc(this,t,Ctt,_tt,mc,{labelId:1,element:0,title:2})}}function hj(e){let t,n;return t=new ytt({props:{labelId:e[0],title:e[2]}}),{c(){Oh(t.$$.fragment)},m(s,r){Nu(t,s,r),n=!0},p(s,r){const i={};r&1&&(i.labelId=s[0]),r&4&&(i.title=s[2]),t.$set(i)},i(s){n||(Vn(t.$$.fragment,s),n=!0)},o(s){Ls(t.$$.fragment,s),n=!1},d(s){Mu(t,s)}}}function fj(e){let t,n;return t=new wtt({props:{cancelIcon:e[3],step:e[1]}}),{c(){Oh(t.$$.fragment)},m(s,r){Nu(t,s,r),n=!0},p(s,r){const i={};r&8&&(i.cancelIcon=s[3]),r&2&&(i.step=s[1]),t.$set(i)},i(s){n||(Vn(t.$$.fragment,s),n=!0)},o(s){Ls(t.$$.fragment,s),n=!1},d(s){Mu(t,s)}}}function Stt(e){let t,n,s,r=e[2]&&hj(e),i=e[3]&&e[3].enabled&&fj(e);return{c(){t=ul("header"),r&&r.c(),n=F_(),i&&i.c(),ts(t,"class","shepherd-header")},m(a,o){_o(a,t,o),r&&r.m(t,null),jp(t,n),i&&i.m(t,null),s=!0},p(a,[o]){a[2]?r?(r.p(a,o),o&4&&Vn(r,1)):(r=hj(a),r.c(),Vn(r,1),r.m(t,n)):r&&(Yd(),Ls(r,1,1,()=>{r=null}),Xd()),a[3]&&a[3].enabled?i?(i.p(a,o),o&8&&Vn(i,1)):(i=fj(a),i.c(),Vn(i,1),i.m(t,null)):i&&(Yd(),Ls(i,1,1,()=>{i=null}),Xd())},i(a){s||(Vn(r),Vn(i),s=!0)},o(a){Ls(r),Ls(i),s=!1},d(a){a&&za(t),r&&r.d(),i&&i.d()}}}function ktt(e,t,n){let{labelId:s,step:r}=t,i,a;return e.$$set=o=>{"labelId"in o&&n(0,s=o.labelId),"step"in o&&n(1,r=o.step)},e.$$.update=()=>{e.$$.dirty&2&&(n(2,i=r.options.title),n(3,a=r.options.cancelIcon))},[s,r,i,a]}class Ett extends bc{constructor(t){super(),vc(this,t,ktt,Stt,mc,{labelId:0,step:1})}}function Ttt(e){let t;return{c(){t=ul("div"),ts(t,"class","shepherd-text"),ts(t,"id",e[1])},m(n,s){_o(n,t,s),e[3](t)},p(n,[s]){s&2&&ts(t,"id",n[1])},i:aa,o:aa,d(n){n&&za(t),e[3](null)}}}function Rtt(e,t,n){let{descriptionId:s,element:r,step:i}=t;YF(()=>{let{text:o}=i.options;xu(o)&&(o=o.call(i)),Mp(o)?r.appendChild(o):n(0,r.innerHTML=o,r)});function a(o){Hp[o?"unshift":"push"](()=>{r=o,n(0,r)})}return e.$$set=o=>{"descriptionId"in o&&n(1,s=o.descriptionId),"element"in o&&n(0,r=o.element),"step"in o&&n(2,i=o.step)},[r,s,i,a]}class Att extends bc{constructor(t){super(),vc(this,t,Rtt,Ttt,mc,{descriptionId:1,element:0,step:2})}}function pj(e){let t,n;return t=new Ett({props:{labelId:e[1],step:e[2]}}),{c(){Oh(t.$$.fragment)},m(s,r){Nu(t,s,r),n=!0},p(s,r){const i={};r&2&&(i.labelId=s[1]),r&4&&(i.step=s[2]),t.$set(i)},i(s){n||(Vn(t.$$.fragment,s),n=!0)},o(s){Ls(t.$$.fragment,s),n=!1},d(s){Mu(t,s)}}}function gj(e){let t,n;return t=new Att({props:{descriptionId:e[0],step:e[2]}}),{c(){Oh(t.$$.fragment)},m(s,r){Nu(t,s,r),n=!0},p(s,r){const i={};r&1&&(i.descriptionId=s[0]),r&4&&(i.step=s[2]),t.$set(i)},i(s){n||(Vn(t.$$.fragment,s),n=!0)},o(s){Ls(t.$$.fragment,s),n=!1},d(s){Mu(t,s)}}}function mj(e){let t,n;return t=new vtt({props:{step:e[2]}}),{c(){Oh(t.$$.fragment)},m(s,r){Nu(t,s,r),n=!0},p(s,r){const i={};r&4&&(i.step=s[2]),t.$set(i)},i(s){n||(Vn(t.$$.fragment,s),n=!0)},o(s){Ls(t.$$.fragment,s),n=!1},d(s){Mu(t,s)}}}function Ftt(e){let t,n=!$r(e[2].options.title)||e[2].options.cancelIcon&&e[2].options.cancelIcon.enabled,s,r=!$r(e[2].options.text),i,a=Array.isArray(e[2].options.buttons)&&e[2].options.buttons.length,o,l=n&&pj(e),u=r&&gj(e),d=a&&mj(e);return{c(){t=ul("div"),l&&l.c(),s=F_(),u&&u.c(),i=F_(),d&&d.c(),ts(t,"class","shepherd-content")},m(h,f){_o(h,t,f),l&&l.m(t,null),jp(t,s),u&&u.m(t,null),jp(t,i),d&&d.m(t,null),o=!0},p(h,[f]){f&4&&(n=!$r(h[2].options.title)||h[2].options.cancelIcon&&h[2].options.cancelIcon.enabled),n?l?(l.p(h,f),f&4&&Vn(l,1)):(l=pj(h),l.c(),Vn(l,1),l.m(t,s)):l&&(Yd(),Ls(l,1,1,()=>{l=null}),Xd()),f&4&&(r=!$r(h[2].options.text)),r?u?(u.p(h,f),f&4&&Vn(u,1)):(u=gj(h),u.c(),Vn(u,1),u.m(t,i)):u&&(Yd(),Ls(u,1,1,()=>{u=null}),Xd()),f&4&&(a=Array.isArray(h[2].options.buttons)&&h[2].options.buttons.length),a?d?(d.p(h,f),f&4&&Vn(d,1)):(d=mj(h),d.c(),Vn(d,1),d.m(t,null)):d&&(Yd(),Ls(d,1,1,()=>{d=null}),Xd())},i(h){o||(Vn(l),Vn(u),Vn(d),o=!0)},o(h){Ls(l),Ls(u),Ls(d),o=!1},d(h){h&&za(t),l&&l.d(),u&&u.d(),d&&d.d()}}}function Dtt(e,t,n){let{descriptionId:s,labelId:r,step:i}=t;return e.$$set=a=>{"descriptionId"in a&&n(0,s=a.descriptionId),"labelId"in a&&n(1,r=a.labelId),"step"in a&&n(2,i=a.step)},[s,r,i]}class Itt extends bc{constructor(t){super(),vc(this,t,Dtt,Ftt,mc,{descriptionId:0,labelId:1,step:2})}}function vj(e){let t;return{c(){t=ul("div"),ts(t,"class","shepherd-arrow"),ts(t,"data-popper-arrow","")},m(n,s){_o(n,t,s)},d(n){n&&za(t)}}}function Ptt(e){let t,n,s,r,i,a,o,l,u=e[4].options.arrow&&e[4].options.attachTo&&e[4].options.attachTo.element&&e[4].options.attachTo.on&&vj();s=new Itt({props:{descriptionId:e[2],labelId:e[3],step:e[4]}});let d=[{"aria-describedby":r=$r(e[4].options.text)?null:e[2]},{"aria-labelledby":i=e[4].options.title?e[3]:null},e[1],{open:"true"}],h={};for(let f=0;f<d.length;f+=1)h=Jet(h,d[f]);return{c(){t=ul("dialog"),u&&u.c(),n=F_(),Oh(s.$$.fragment),aj(t,h),ff(t,"shepherd-has-cancel-icon",e[5]),ff(t,"shepherd-has-title",e[6]),ff(t,"shepherd-element",!0)},m(f,g){_o(f,t,g),u&&u.m(t,null),jp(t,n),Nu(s,t,null),e[13](t),a=!0,o||(l=ZC(t,"keydown",e[7]),o=!0)},p(f,[g]){f[4].options.arrow&&f[4].options.attachTo&&f[4].options.attachTo.element&&f[4].options.attachTo.on?u||(u=vj(),u.c(),u.m(t,n)):u&&(u.d(1),u=null);const v={};g&4&&(v.descriptionId=f[2]),g&8&&(v.labelId=f[3]),g&16&&(v.step=f[4]),s.$set(v),aj(t,h=ctt(d,[(!a||g&20&&r!==(r=$r(f[4].options.text)?null:f[2]))&&{"aria-describedby":r},(!a||g&24&&i!==(i=f[4].options.title?f[3]:null))&&{"aria-labelledby":i},g&2&&f[1],{open:"true"}])),ff(t,"shepherd-has-cancel-icon",f[5]),ff(t,"shepherd-has-title",f[6]),ff(t,"shepherd-element",!0)},i(f){a||(Vn(s.$$.fragment,f),a=!0)},o(f){Ls(s.$$.fragment,f),a=!1},d(f){f&&za(t),u&&u.d(),Mu(s),e[13](null),o=!1,l()}}}const Ntt=9,Mtt=27,Ott=37,Ltt=39;function bj(e){return e.split(" ").filter(t=>!!t.length)}function Btt(e,t,n){let{classPrefix:s,element:r,descriptionId:i,firstFocusableElement:a,focusableElements:o,labelId:l,lastFocusableElement:u,step:d,dataStepId:h}=t,f,g,v;const b=()=>r;rtt(()=>{n(1,h={[`data-${s}shepherd-step-id`]:d.id}),n(9,o=r.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]')),n(8,a=o[0]),n(10,u=o[o.length-1])}),YF(()=>{v!==d.options.classes&&x()});function x(){w(v),v=d.options.classes,_(v)}function w(y){if(ov(y)){const R=bj(y);R.length&&r.classList.remove(...R)}}function _(y){if(ov(y)){const R=bj(y);R.length&&r.classList.add(...R)}}const C=y=>{const{tour:R}=d;switch(y.keyCode){case Ntt:if(o.length===0){y.preventDefault();break}y.shiftKey?(document.activeElement===a||document.activeElement.classList.contains("shepherd-element"))&&(y.preventDefault(),u.focus()):document.activeElement===u&&(y.preventDefault(),a.focus());break;case Mtt:R.options.exitOnEsc&&(y.preventDefault(),y.stopPropagation(),d.cancel());break;case Ott:R.options.keyboardNavigation&&(y.preventDefault(),y.stopPropagation(),R.back());break;case Ltt:R.options.keyboardNavigation&&(y.preventDefault(),y.stopPropagation(),R.next());break}};function S(y){Hp[y?"unshift":"push"](()=>{r=y,n(0,r)})}return e.$$set=y=>{"classPrefix"in y&&n(11,s=y.classPrefix),"element"in y&&n(0,r=y.element),"descriptionId"in y&&n(2,i=y.descriptionId),"firstFocusableElement"in y&&n(8,a=y.firstFocusableElement),"focusableElements"in y&&n(9,o=y.focusableElements),"labelId"in y&&n(3,l=y.labelId),"lastFocusableElement"in y&&n(10,u=y.lastFocusableElement),"step"in y&&n(4,d=y.step),"dataStepId"in y&&n(1,h=y.dataStepId)},e.$$.update=()=>{e.$$.dirty&16&&(n(5,f=d.options&&d.options.cancelIcon&&d.options.cancelIcon.enabled),n(6,g=d.options&&d.options.title))},[r,h,i,l,d,f,g,C,a,o,u,s,b,S]}class jtt extends bc{constructor(t){super(),vc(this,t,Btt,Ptt,mc,{classPrefix:11,element:0,descriptionId:2,firstFocusableElement:8,focusableElements:9,labelId:3,lastFocusableElement:10,step:4,dataStepId:1,getElement:12})}get getElement(){return this.$$.ctx[12]}}class cR extends OF{constructor(t,n={}){return super(),this._resolvedAttachTo=void 0,this._resolvedExtraHighlightElements=void 0,this.classPrefix=void 0,this.el=void 0,this.target=void 0,this.tour=void 0,this.tour=t,this.classPrefix=this.tour.options?pq(this.tour.options.classPrefix):"",this.styles=t.styles,this._resolvedAttachTo=null,jF(this),this._setOptions(n),this}cancel(){this.tour.cancel(),this.trigger("cancel")}complete(){this.tour.complete(),this.trigger("complete")}destroy(){zet(this),Mp(this.el)&&(this.el.remove(),this.el=null),this._updateStepTargetOnHide(),this.trigger("destroy")}getTour(){return this.tour}hide(){var t;(t=this.tour.modal)==null||t.hide(),this.trigger("before-hide"),this.el&&(this.el.hidden=!0),this._updateStepTargetOnHide(),this.trigger("hide")}_resolveExtraHiglightElements(){return this._resolvedExtraHighlightElements=eet(this),this._resolvedExtraHighlightElements}_resolveAttachToOptions(){return this._resolvedAttachTo=ZZe(this),this._resolvedAttachTo}_getResolvedAttachToOptions(){return this._resolvedAttachTo===null?this._resolveAttachToOptions():this._resolvedAttachTo}isOpen(){return!!(this.el&&!this.el.hidden)}show(){return xu(this.options.beforeShowPromise)?Promise.resolve(this.options.beforeShowPromise()).then(()=>this._show()):Promise.resolve(this._show())}updateStepOptions(t){Object.assign(this.options,t),this.shepherdElementComponent&&this.shepherdElementComponent.$set({step:this})}getElement(){return this.el}getTarget(){return this.target}_createTooltipContent(){const t=`${this.id}-description`,n=`${this.id}-label`;return this.shepherdElementComponent=new jtt({target:this.tour.options.stepsContainer||document.body,props:{classPrefix:this.classPrefix,descriptionId:t,labelId:n,step:this,styles:this.styles}}),this.shepherdElementComponent.getElement()}_scrollTo(t){const{element:n}=this._getResolvedAttachToOptions();xu(this.options.scrollToHandler)?this.options.scrollToHandler(n):IZe(n)&&typeof n.scrollIntoView=="function"&&n.scrollIntoView(t)}_getClassOptions(t){const n=this.tour&&this.tour.options&&this.tour.options.defaultStepOptions,s=t.classes?t.classes:"",r=n&&n.classes?n.classes:"",i=[...s.split(" "),...r.split(" ")],a=new Set(i);return Array.from(a).join(" ").trim()}_setOptions(t={}){let n=this.tour&&this.tour.options&&this.tour.options.defaultStepOptions;n=BF({},n||{}),this.options=Object.assign({arrow:!0},n,t,$et(n,t));const{when:s}=this.options;this.options.classes=this._getClassOptions(t),this.destroy(),this.id=this.options.id||`step-${mq()}`,s&&Object.keys(s).forEach(r=>{this.on(r,s[r],this)})}_setupElements(){$r(this.el)||this.destroy(),this.el=this._createTooltipContent(),this.options.advanceOn&&XZe(this),Wet(this)}_show(){var t;this.trigger("before-show"),this._resolveAttachToOptions(),this._resolveExtraHiglightElements(),this._setupElements(),this.tour.modal||this.tour.setupModal(),(t=this.tour.modal)==null||t.setupForStep(this),this._styleTargetElementForStep(this),this.el&&(this.el.hidden=!1),this.options.scrollTo&&setTimeout(()=>{this._scrollTo(this.options.scrollTo)}),this.el&&(this.el.hidden=!1);const n=this.shepherdElementComponent.getElement(),s=this.target||document.body,r=this._resolvedExtraHighlightElements;s.classList.add(`${this.classPrefix}shepherd-enabled`),s.classList.add(`${this.classPrefix}shepherd-target`),n.classList.add("shepherd-enabled"),r?.forEach(i=>{i.classList.add(`${this.classPrefix}shepherd-enabled`),i.classList.add(`${this.classPrefix}shepherd-target`)}),this.trigger("show")}_styleTargetElementForStep(t){const n=t.target,s=t._resolvedExtraHighlightElements;if(!n)return;const r=t.options.highlightClass;r&&(n.classList.add(r),s?.forEach(i=>i.classList.add(r))),n.classList.remove("shepherd-target-click-disabled"),s?.forEach(i=>i.classList.remove("shepherd-target-click-disabled")),t.options.canClickTarget===!1&&(n.classList.add("shepherd-target-click-disabled"),s?.forEach(i=>i.classList.add("shepherd-target-click-disabled")))}_updateStepTargetOnHide(){const t=this.target||document.body,n=this._resolvedExtraHighlightElements,s=this.options.highlightClass;s&&(t.classList.remove(s),n?.forEach(r=>r.classList.remove(s))),t.classList.remove("shepherd-target-click-disabled",`${this.classPrefix}shepherd-enabled`,`${this.classPrefix}shepherd-target`),n?.forEach(r=>{r.classList.remove("shepherd-target-click-disabled",`${this.classPrefix}shepherd-enabled`,`${this.classPrefix}shepherd-target`)})}}function Htt(e){if(e){const{steps:t}=e;t.forEach(n=>{n.options&&n.options.canClickTarget===!1&&n.options.attachTo&&(Mp(n.target)&&n.target.classList.remove("shepherd-target-click-disabled"),n._resolvedExtraHighlightElements&&n._resolvedExtraHighlightElements.forEach(s=>{Mp(s)&&s.classList.remove("shepherd-target-click-disabled")}))})}}function Utt(e){let t="";const{innerWidth:n,innerHeight:s}=window;return e.forEach(r=>{const{width:i,height:a,x:o=0,y:l=0,r:u=0}=r,{topLeft:d=0,topRight:h=0,bottomRight:f=0,bottomLeft:g=0}=typeof u=="number"?{topLeft:u,topRight:u,bottomRight:u,bottomLeft:u}:u;t+=`M${o+d},${l} a${d},${d},0,0,0-${d},${d} V${a+l-g} a${g},${g},0,0,0,${g},${g} H${i+o-f} a${f},${f},0,0,0,${f}-${f} V${l+h} a${h},${h},0,0,0-${h}-${h} Z`}),`M${n},${s} H0 V0 H${n} V${s} Z ${t}`.replace(/\s/g,"")}function Gtt(e){let t,n,s,r,i;return{c(){t=ij("svg"),n=ij("path"),ts(n,"d",e[2]),ts(t,"class",s=`${e[1]?"shepherd-modal-is-visible":""} shepherd-modal-overlay-container`)},m(a,o){_o(a,t,o),jp(t,n),e[11](t),r||(i=ZC(t,"touchmove",e[3]),r=!0)},p(a,[o]){o&4&&ts(n,"d",a[2]),o&2&&s!==(s=`${a[1]?"shepherd-modal-is-visible":""} shepherd-modal-overlay-container`)&&ts(t,"class",s)},i:aa,o:aa,d(a){a&&za(t),e[11](null),r=!1,i()}}}function Fq(e){if(!e)return null;const t=e instanceof HTMLElement&&window.getComputedStyle(e).overflowY;return t!=="hidden"&&t!=="visible"&&e.scrollHeight>=e.clientHeight?e:Fq(e.parentElement)}function Vtt(e){let t={top:0,left:0};if(!e)return t;let n=e.ownerDocument.defaultView;for(;n!==window.top;){var s;const a=(s=n)==null?void 0:s.frameElement;if(a){var r,i;const o=a.getBoundingClientRect();t.top+=o.top+((r=o.scrollTop)!=null?r:0),t.left+=o.left+((i=o.scrollLeft)!=null?i:0)}n=n.parent}return t}function Wtt(e,t){const n=e.getBoundingClientRect();let s=n.y||n.top,r=n.bottom||s+n.height;if(t){const a=t.getBoundingClientRect(),o=a.y||a.top,l=a.bottom||o+a.height;s=Math.max(s,o),r=Math.min(r,l)}const i=Math.max(r-s,0);return{y:s,height:i}}function $tt(e,t,n){let{element:s,openingProperties:r}=t,i=!1,a,o;u();const l=()=>s;function u(){n(4,r=[{width:0,height:0,x:0,y:0,r:0}])}function d(){n(1,i=!1),w()}function h(S=0,y=0,R=0,E=0,F,A,I){if(A){const P=[A,...I||[]];n(4,r=[]);for(const N of P){if(!N||P.indexOf(N)!==P.lastIndexOf(N))continue;const{y:L,height:V}=Wtt(N,F),{x:B,width:ne,left:J}=N.getBoundingClientRect();P.some(Q=>{if(Q===N)return!1;const G=Q.getBoundingClientRect();return B>=G.left&&B+ne<=G.right&&L>=G.top&&L+V<=G.bottom})||r.push({width:ne+S*2,height:V+S*2,x:(B||J)+R-S,y:L+E-S,r:y})}}else u()}function f(S){w(),S.tour.options.useModalOverlay?(_(S),g()):d()}function g(){n(1,i=!0)}const v=S=>{S.preventDefault()},b=S=>{S.stopPropagation()};function x(){window.addEventListener("touchmove",v,{passive:!1})}function w(){a&&(cancelAnimationFrame(a),a=void 0),window.removeEventListener("touchmove",v,{passive:!1})}function _(S){const{modalOverlayOpeningPadding:y,modalOverlayOpeningRadius:R,modalOverlayOpeningXOffset:E=0,modalOverlayOpeningYOffset:F=0}=S.options,A=Vtt(S.target),I=Fq(S.target),P=()=>{a=void 0,h(y,R,E+A.left,F+A.top,I,S.target,S._resolvedExtraHighlightElements),a=requestAnimationFrame(P)};P(),x()}function C(S){Hp[S?"unshift":"push"](()=>{s=S,n(0,s)})}return e.$$set=S=>{"element"in S&&n(0,s=S.element),"openingProperties"in S&&n(4,r=S.openingProperties)},e.$$.update=()=>{e.$$.dirty&16&&n(2,o=Utt(r))},[s,i,o,b,r,l,u,d,h,f,g,C]}class ztt extends bc{constructor(t){super(),vc(this,t,$tt,Gtt,mc,{element:0,openingProperties:4,getElement:5,closeModalOpening:6,hide:7,positionModal:8,setupForStep:9,show:10})}get getElement(){return this.$$.ctx[5]}get closeModalOpening(){return this.$$.ctx[6]}get hide(){return this.$$.ctx[7]}get positionModal(){return this.$$.ctx[8]}get setupForStep(){return this.$$.ctx[9]}get show(){return this.$$.ctx[10]}}class qtt extends OF{constructor(){super(),this.activeTour=void 0,jF(this)}}class Ktt extends OF{constructor(t={}){super(),this.trackedEvents=["active","cancel","complete","show"],this.classPrefix=void 0,this.currentStep=void 0,this.focusedElBeforeOpen=void 0,this.id=void 0,this.modal=void 0,this.options=void 0,this.steps=void 0,jF(this);const n={exitOnEsc:!0,keyboardNavigation:!0};return this.options=Object.assign({},n,t),this.classPrefix=pq(this.options.classPrefix),this.steps=[],this.addSteps(this.options.steps),["active","cancel","complete","inactive","show","start"].map(s=>{(r=>{this.on(r,i=>{i=i||{},i.tour=this,Id.trigger(r,i)})})(s)}),this._setTourID(t.id),this}addStep(t,n){let s=t;return s instanceof cR?s.tour=this:s=new cR(this,s),$r(n)?this.steps.push(s):this.steps.splice(n,0,s),s}addSteps(t){return Array.isArray(t)&&t.forEach(n=>{this.addStep(n)}),this}back(){const t=this.steps.indexOf(this.currentStep);this.show(t-1,!1)}async cancel(){if(this.options.confirmCancel){const t=this.options.confirmCancelMessage||"Are you sure you want to stop the tour?";let n;xu(this.options.confirmCancel)?n=await this.options.confirmCancel():n=window.confirm(t),n&&this._done("cancel")}else this._done("cancel")}complete(){this._done("complete")}getById(t){return this.steps.find(n=>n.id===t)}getCurrentStep(){return this.currentStep}hide(){const t=this.getCurrentStep();if(t)return t.hide()}isActive(){return Id.activeTour===this}next(){const t=this.steps.indexOf(this.currentStep);t===this.steps.length-1?this.complete():this.show(t+1,!0)}removeStep(t){const n=this.getCurrentStep();this.steps.some((s,r)=>{if(s.id===t)return s.isOpen()&&s.hide(),s.destroy(),this.steps.splice(r,1),!0}),n&&n.id===t&&(this.currentStep=void 0,this.steps.length?this.show(0):this.cancel())}show(t=0,n=!0){const s=ov(t)?this.getById(t):this.steps[t];s&&(this._updateStateBeforeShow(),xu(s.options.showOn)&&!s.options.showOn()?this._skipStep(s,n):(this.currentStep=s,this.trigger("show",{step:s,previous:this.currentStep}),s.show()))}async start(){this.trigger("start"),this.focusedElBeforeOpen=document.activeElement,this.currentStep=null,this.setupModal(),this._setupActiveTour(),this.next()}_done(t){const n=this.steps.indexOf(this.currentStep);if(Array.isArray(this.steps)&&this.steps.forEach(s=>s.destroy()),Htt(this),this.trigger(t,{index:n}),Id.activeTour=null,this.trigger("inactive",{tour:this}),this.modal&&this.modal.hide(),(t==="cancel"||t==="complete")&&this.modal){const s=document.querySelector(".shepherd-modal-overlay-container");s&&(s.remove(),this.modal=null)}Mp(this.focusedElBeforeOpen)&&this.focusedElBeforeOpen.focus()}_setupActiveTour(){this.trigger("active",{tour:this}),Id.activeTour=this}setupModal(){this.modal=new ztt({target:this.options.modalContainer||document.body,props:{styles:this.styles}})}_skipStep(t,n){const s=this.steps.indexOf(t);if(s===this.steps.length-1)this.complete();else{const r=n?s+1:s-1;this.show(r,n)}}_updateStateBeforeShow(){this.currentStep&&this.currentStep.hide(),this.isActive()||this._setupActiveTour()}_setTourID(t){const n=this.options.tourName||"tour",s=t||mq();this.id=`${n}--${s}`}}const Id=new qtt,Dq=typeof window>"u";Id.Step=Dq?QZe:cR;Id.Tour=Dq?JZe:Ktt;const ey=m.createContext(void 0);ey.Consumer;const Ytt=({children:e})=>DZe.jsx(ey.Provider,{value:{Shepherd:Id},children:e}),Xtt=""+new URL("agentic-sequence-CExfswgi.png",import.meta.url).href,Qtt=""+new URL("canvas-code-inline-edit-DLji9b0m.png",import.meta.url).href,Jtt=""+new URL("canvas-overview-CruGEIRC.png",import.meta.url).href,Ztt=""+new URL("canvas-variables-view-DrA20zqs.png",import.meta.url).href,ent=""+new URL("chat-attachments-_3cRrONU.png",import.meta.url).href,tnt=""+new URL("chat-full-view-e-eJPzrw.png",import.meta.url).href,nnt=""+new URL("chat-input-CU-CA7Se.png",import.meta.url).href,snt=""+new URL("inline-edit-canvas-O9conTkE.png",import.meta.url).href,rnt=e=>{const t=Array.from(document.querySelectorAll(`[data-tour-tag="${e}"]`));return t.find(n=>n.offsetParent!==null)??t[0]??null},xj=e=>{document.querySelector(`[data-tour-action="${e}"]`)?.click()},wj=[{id:"welcome",title:"Welcome to Local Operator",text:`Local Operator is an AI agents platform that allows you to create a team of proactive AI agents that support you and help to reduce your daily workload.<br/><img src="${tnt}" alt="Chat full view" style="width: 100%; height: 350px; object-fit: contain; border-radius: 8px;"/><br />These agents are different from simple chatbots because they can actually do things for you on your computer like create files, run code and analytics, edit images, videos, and PDFs, organize your system, and much more.<br/><br/>In this walkthrough we'll cover:<ul><li>Creating agents</li><li>Making agents do things</li><li>The canvas workspace</li><li>Customizing agents</li><li>Agent Hub for sharing and collaborating</li><li>Schedules for proactive agents</li><li>Settings for customization</li></ul>Let's explore how it works.`,buttons:[{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"agent-list",attachTo:{element:'[data-tour-tag="agent-list-panel"]',on:"right"},title:"Your agents",text:"On the left, you'll see a list of your available AI agents. You can select an agent to start a conversation or manage its settings. Think of this as your messenger contacts list, but for AI agents. There are no limits to how many agents you can have, so create as many as you need to handle all your daily tasks.<br/><br/>Use the create agents button at the top of the toolbar to create a new agent at any time. You can also import agents from the Agent Hub, which we will cover later in this tour.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"select-agent",attachTo:{element:'[data-tour-tag="agent-list-item-button-0"]',on:"right"},title:"Select an agent",text:"Click on an agent to open the chat window to pull up your conversation with it. This will show the messages that you have sent them and the responses and actions that they have taken.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="agent-list-item-button-0"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"chat-input",attachTo:{element:'[data-tour-tag="chat-input-textarea"]',on:"top"},title:"Ask your agent anything",text:`Type your request here. Agents can answer questions, perform tasks, search the web, and much more. When you create a new agent, you'll see suggested prompts for ideas.<br /><br />Some powerful requests that you can try:<br /><br /><ul><li>"Create a spreadsheet in my Documents folder with all the major cities in Canada."</li><li>"Search the web for the latest news on AI and make a thorough report."</li><li>Select an attachment and then "translate this document to French."</li></ul><br /><img src="${nnt}" alt="Chat input" style="width: 100%; height: 200px; object-fit: contain; border-radius: 8px;"/><br />You can also attach files to your message by clicking the paperclip button, which we will cover in the next step.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"attachments",attachTo:{element:'button[data-tour-tag="chat-input-attach-file-button"]',on:"top"},title:"Attach files to your message",text:`You can attach any files, images, or documents to your message by clicking this paperclip button, there are no limitations on the file types. Your agent can process, analyze, or translate these attachments as part of your request.<br /><br />Try attaching a PDF, image, or text file and then ask your agent to summarize, translate, or extract information from it.<br /><img src="${ent}" alt="Chat attachments" style="width: 100%; height: 200px; object-fit: contain; border-radius: 8px;"/><br />Images like PNGs, JPGs, and PDFs are natively streamed into the model context window, so they can understand them directly without needing to run any code. Other files like Excel, Word, and CSV files are included as file paths on your device to direct the model's attention to work with them using code. You can attach massive files like million line CSVs and have the agent work with them using code.<br /><br />You can also paste images into the chat input, and attach multiple files at once to achieve more complex tasks. Try taking a screenshot of a website and then asking your agent to try to code it.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"agent-capabilities",attachTo:{element:'[data-tour-tag="chat-header"]',on:"top"},title:"More than just chat",text:`Local Operator agents are different from simple chatbots. They can perform actions on your computer, like creating files, running code, or browsing the web, based on your instructions. You'll see them use "tools" like reading, writing, and executing code to get things done. Agents have memory of the conversation, previous steps, learnings, and even store the execution variables of previous steps in code to be able to use them later in the conversation.<br /><img src="${Xtt}" alt="Agentic sequence" style="width: 100%; height: 350px; object-fit: contain; border-radius: 8px;"/><br />Local Operator agents are extremely flexible, so they can bounce back and forth with you for simple chatting, and know when they need to embark on a work journey to get things done in multiple steps with tool use.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const{openCommandPalette:e}=st.getState();e(),setTimeout(()=>{this.next()},500)}}]},{id:"pre-command-palette-open-canvas",title:"Command palette",attachTo:{element:'[data-tour-tag="command-palette-dialog"]',on:"right"},text:`Let's quickly look at another powerful feature: the Command Palette. You can open it anywhere in the app by pressing <code>${zo("everything",!0)}</code> on Mac and <code>${zo("everything",!1)}</code> on Windows or Linux. This is a helpful window that you can open from anywhere in the app to be able to access your chats, agents, settings, pages and actions, and much more, using your keyboard. It can often be faster to access sections in the app this way instead of clicking through menus. Type a word to search everything at once, or start with a prefix to narrow it: <code>#</code> for chats, <code>@</code> for agents and teams, <code>,</code> for settings, and <code>&gt;</code> for commands and pages.<br /><br />In a hurry for a conversation? Press <code>${zo("chats",!0)}</code> on Mac and <code>${zo("chats",!1)}</code> on Windows or Linux and the palette opens already searching your chats, so you can jump straight to one — and <code>${zo("commands",!0)}</code> on Mac and <code>${zo("commands",!1)}</code> on Windows or Linux opens it on the app's own commands and pages when that is what you are after. You can also just click Search in the sidebar to open it.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const{closeCommandPalette:e}=st.getState();e(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const{closeCommandPalette:e}=st.getState();e(),setTimeout(()=>{this.next()},500)}}]},{id:"canvas-open-button",attachTo:{element:'button[data-tour-tag="open-canvas-button"]',on:"left"},title:"Open the canvas",text:"Click here to open the Canvas, a workspace for files and dynamic visualizations where you can organize, plan, and interact with your agents in a more flexible way.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const{openCommandPalette:e}=st.getState();e(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="open-canvas-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"canvas-feature",attachTo:{element:'[data-tour-tag="canvas-container"]',on:"left"},title:"The canvas: your visual workspace",text:`This is the Canvas, your workspace for files and dynamic visualizations where you can organize, plan, and interact with your agents in a more flexible way. Any files that your agents create on your device can be opened here by clicking on the file icons that you see as they work.<br/><br/>Agents can make dynamic visualizations like games, charts, maps, and more in HTML files. Any HTML files you open will be rendered dynamically in an iframe. Any markdown files that you open will be rendered in full markdown viewer with support for code blocks, tables, mermaid diagrams, and more.<br/><img src="${Jtt}" alt="Canvas overview" style="width: 100%; height: 300px; object-fit: contain; border-radius: 8px;"/>`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="close-canvas-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="canvas-documents-view-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"canvas-documents-view",attachTo:{element:'button[data-tour-tag="canvas-documents-view-button"]',on:"top"},title:"Documents view",text:`The Documents view shows all your open notes, blog articles, code, and visualizations as tabs. You can switch between documents to edit them and see dynamic visualizations in HTML created by your agents. Use this view to work with your notes, reports, and agent-generated content.<br /><br />This is where you can get more precise around your agents' work.<br/><img src="${snt}" alt="Inline edit canvas" style="width: 100%; height: 200px; object-fit: contain; border-radius: 8px;"/><br />In your documents, highlight any text that you want your agent to improve and press Cmd/Ctrl+K to bring up the inline AI editor.
704
704
  <br /><img src="${Qtt}" alt="Canvas code inline edit" style="width: 100%; height: 200px; object-fit: cover; object-position: top; border-radius: 8px;"/><br />You can be as precise as you want and the agent will edit the document for you in place, using its memories and context so you don't have to re-explain things.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="canvas-files-view-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"canvas-files-view",attachTo:{element:'button[data-tour-tag="canvas-files-view-button"]',on:"top"},title:"Files view",text:"The Files view lets you browse and open files that your agents have created or that are relevant to your current conversation. Use this to quickly access, preview, and open files in the Canvas workspace.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('button[data-tour-tag="canvas-documents-view-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="canvas-variables-view-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"canvas-variables-view",attachTo:{element:'button[data-tour-tag="canvas-variables-view-button"]',on:"top"},title:"Variables view",text:`The Variables view displays the "code memory" that agents have stored during their work. These are technical variables that include results, intermediate values, and other data that agents use to perform tasks. You can inspect and manage these variables here.<br /><br />This section will be most helpful for more technical users who want to understand how agents are working and what they are doing.<br/><img src="${Ztt}" alt="Canvas variables" style="width: 100%; height: 350px; object-fit: contain; border-radius: 8px;"/>`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('button[data-tour-tag="canvas-files-view-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="close-canvas-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"agent-options",attachTo:{element:'button[data-tour-tag="agent-options-button"]',on:"right"},title:"Agent options",text:"Click here to see options for the currently selected agent, like viewing its settings, exporting it, or deleting it.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('button[data-tour-tag="open-canvas-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="agent-options-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"click-view-settings-from-chat",attachTo:{element:'[role="menuitem"][data-tour-tag="view-agent-settings-menu-item"]',on:"right"},title:"View configuration",text:'Click "View agent settings" to see and change how this agent works and change things like its name, description, hosting provider, and AI model.',buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[role="menuitem"][data-tour-tag="view-agent-settings-menu-item"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"view-agent-settings",attachTo:{element:'div[data-tour-tag="agent-settings-details-paper"]',on:"left"},title:"Agent configuration",text:"This is where you can customize and configure your agent. You can change its name, description, the AI model it uses, its temperature for creativity, and other chat settings.<br /><br />The agents will already have default settings that work well for most use cases, but if you want to roll up your sleeves and customize, you can do so here.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-chat"]');e&&e.click(),setTimeout(()=>{const t=document.querySelector('button[data-tour-tag="agent-options-button"]');t&&t.click()},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"select-provider",attachTo:{element:'[data-tour-tag="agent-settings-hosting-select"]',on:"left"},title:"Select hosting provider",text:`Choose an AI provider for your agent. If you don't pick one here, then the default provider from the settings page will be used. Providers offer different AI models and pricing. Radient is recommended for Local Operator as its "Automatic" mode is optimized for the lowest cost and best performance.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"select-model",attachTo:{element:'[data-tour-tag="agent-settings-model-select"]',on:"left"},title:"Select AI model",text:"After selecting a provider, choose an AI model. Models marked as 'Recommended' are known to work well with Local Operator. Other models might have inconsistent performance. If a model you expect to be recommended isn't listed, please let us know if it works well for you in Local Operator via GitHub Issues or email.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"modify-security-prompt",attachTo:{element:'[data-tour-tag="agent-settings-security"]',on:"left"},title:"Customize security behaviors",text:"This prompt provides separate instructions to the security agent that reviews this agent's work. You can explicitly allow certain actions that would normally be blocked. If you encounter frequent security interventions, consider adding a note here for the security agent.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"modify-agent-prompt",attachTo:{element:'[data-tour-tag="agent-settings-system-prompt"]',on:"left"},title:"Customize the agent's behavior",text:"This prompt allows you to customize the baseline behavior of the agent. While most customization can happen by talking to the agent (it records learnings in its notebook), you can provide specific workflow instructions here that will be followed separately.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"create-new-agent",attachTo:{element:'button[data-tour-tag="create-new-agent-button"]',on:"bottom"},title:"Create a new agent",text:'Click the "+" button to create a brand new agent from scratch. You can then customize its behavior and capabilities.',buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="agent-list-item-button-0"]');e&&e.click(),setTimeout(()=>{const t=document.querySelector('button[data-tour-tag="agent-options-button"]');t&&t.click()},500),setTimeout(()=>{const t=document.querySelector('[role="menuitem"][data-tour-tag="view-agent-settings-menu-item"]');t&&t.click()},1e3),setTimeout(()=>{this.back()},1500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="create-new-agent-button"]');e&&e.click(),setTimeout(()=>{this.next()},1e3)}}]},{id:"agent-naming-guidelines",attachTo:{element:'[data-tour-tag="create-agent-dialog"]',on:"right"},title:"Naming and describing your agent",text:`Give your agent a clear, descriptive name that reflects its purpose (e.g., "File Organizer" or "Web Researcher").
705
- A good description helps you and others understand what the agent does and any special instructions. The descriptions are also used by other agents to help them understand how to tag each other in for certain tasks.<br /><br />If you want this agent to be part of the agent-to-agent communication network, it will need to have a description that captures its purpose and capabilities. Be concise and specific.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="create-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="create-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"navigate-agent-hub",attachTo:{element:'[data-tour-tag="nav-item-agent-hub"]',on:"right"},title:"Discover more agents",text:`Let's visit the Agent Hub to find community-created agents. Click on the "Agent Hub" icon in the navigation bar.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agents"]');e&&e.click(),setTimeout(()=>{const t=document.querySelector('[data-tour-tag="create-new-agent-button"]');t&&t.click()},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agent-hub"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"agent-hub-view",attachTo:{element:'[data-tour-tag="agent-hub-sidebar-container"]',on:"right"},title:"The Agent Hub",text:"Here you can browse agents by category or search for specific ones. These agents are shared by the community and can perform various specialized tasks.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"download-agent",attachTo:{element:'button[data-tour-tag="agent-hub-download-button"]',on:"bottom"},title:"Download an agent",text:'Find an agent that interests you and click the "Get" button to add it to your local agent list.',buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agents"]');e&&e.click(),setTimeout(()=>{this.next()},1e3)}}]},{id:"upload-agent-hub",attachTo:{element:()=>rnt("upload-to-hub-header-button"),on:"bottom"},title:"Share your agents",text:"If you create a useful agent, you can also share it with the community by uploading it to the Agent Hub from the agent options menu.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agent-hub"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){xj("open-upload-dialog"),setTimeout(()=>{this.next()},500)}}]},{id:"upload-agent-hub-dialog",attachTo:{element:'[data-tour-tag="upload-agent-dialog"]',on:"right"},title:"Upload agent to hub",text:"This dialog publishes your agent's instruction set to the community. You need a Radient account to publish, which is free to create and costs nothing per agent. You can review the details before confirming. What is published is what describes the agent - its name, description, instructions and tool surface; no conversation, execution history, memory, plan or machine-specific configuration leaves your computer. Make sure your agent meets the required criteria before submitting.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('button[data-tour-tag="upload-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="upload-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"navigate-schedules",attachTo:{element:'[data-tour-tag="nav-item-schedules"]',on:"right"},title:"Automate tasks with schedules",text:"Local Operator can run tasks for you on a regular basis. Let's check out the Schedules section.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agents"]');e&&e.click(),setTimeout(()=>{xj("open-upload-dialog")},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-schedules"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"schedules-overview",title:"Proactive agents with schedules",text:"A powerful feature of Local Operator is the ability to ask agents to perform tasks on their own on a recurring basis. This turns them from reactive agent bots to proactive agents that work on their own in the background to support you without you needing to continually ask them to do things.<br /><br />You can simply ask any agent to do something at some point in the future, or to handle some daily task at a certain time, and it will create a prompt for itself that will be executed at the specified times.<br /><br />Here, you can view, create, and manage all your scheduled tasks in one place to streamline your workflow and ensure important actions happen automatically.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"create-schedule",attachTo:{element:'button[data-tour-tag="create-schedule-button"]',on:"bottom"},title:"Set up a recurring task",text:'Click "Create schedule" to ask an agent to perform a task for you regularly, like sending a daily report or checking for news updates.<br /><br />You can also create one-off tasks that only run once at some point in the future.',buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="create-schedule-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"create-schedule-dialog",attachTo:{element:'[data-tour-tag="create-schedule-dialog"]',on:"right"},title:"Configure your schedule",text:"While it is often much easier to simply ask the agent to do a task on a recurring basis for you, you can also manually set up a schedule for a task here or update existing tasks.<br /><br />The prompt is the message that will be sent to the agent at the predefined schedule. You can update the time of day in your local timezone, the frequency of the task, and even specify a specific date or time that the task should stop running at.<br /><br />You can also schedule one-off tasks that only run once at some point in the future.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="create-schedule-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="create-schedule-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"navigate-settings",attachTo:{element:'[data-tour-tag="nav-item-settings"]',on:"right"},title:"Personalize your experience",text:"Now, let's explore the Settings menu to customize Local Operator to your liking.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-schedules"]');e&&e.click(),setTimeout(()=>{const t=document.querySelector('button[data-tour-tag="create-schedule-button"]');t&&t.click()},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-settings"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"general-settings",attachTo:{element:'div[data-tour-tag="settings-general-section"]',on:"right"},title:"General settings",text:"Here you can update your user profile and configure model settings (like default hosting provider and model).",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"appearance-settings",attachTo:{element:'[data-tour-tag="settings-appearance-section"]',on:"right"},title:"Customize appearance",text:"Choose from various themes to change the look and feel of Local Operator. Find one that suits your style.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"radient-account-settings",attachTo:{element:'[data-tour-tag="settings-radient-account-section"]',on:"right"},title:"Radient account",text:"Connect your Radient account to access your Radient Pass details, credits, and unlock unified access to models and tools. Radient is the best way to use Local Operator since it powers the AI models, web search, image generation, and much more with a single integration. You get free credits when you sign up to try it out and bonus credits when you top up.<br /><br />When you sign in for the first time, it will automatically create a Radient Pass for you and save it securely to your computer. This will power your Local Operator agents with Radient Automatic, which mixes and matches AI models to get you the best balance of speed, accuracy, and cost in every step of your agents' workflows.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"integrations-settings",attachTo:{element:'[data-tour-tag="settings-integrations-section"]',on:"right"},title:"Connect your services",text:"Enhance your agents' capabilities by connecting your Google services like Gmail, Calendar, and Drive. This allows agents to access and manage your information with your permission.<br /><br />You need to be logged in to a Radient account to use this feature, however it is free to use and doesn't cost any additional Radient credits per action.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"application-updates-settings",attachTo:{element:'[data-tour-tag="settings-app-updates-section"]',on:"right"},title:"Stay up to date",text:"Check for updates to Local Operator here to ensure you have the latest features and improvements. You can see your current version information below.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"tour-complete",title:"Tour complete",text:"You've now seen the main features of Local Operator. Feel free to explore further and discover all the ways your AI agents can assist you. Happy automating.",buttons:[{text:"Finish",classes:"shepherd-button-primary",action:function(){this.complete()}}]}],int=()=>{const e=xi(),{completeTourOnboarding:t}=d0(),n=m.useContext(ey),s={cancelIcon:{enabled:!0},scrollTo:{behavior:"smooth",block:"center"}},r=!0;return{startTour:a=>{if(n?.tour?.isActive()&&!a?.forceModalCompleted){console.log("Onboarding tour is already active (from context.tour). Not starting another.");return}const o=d0.getState();if(!a?.forceModalCompleted&&!o.isModalComplete){console.log("Onboarding modal not completed (checked via store). Tour will not start.");return}if(o.isTourComplete&&!a?.forceModalCompleted){console.log("Onboarding tour already completed in store and not forced. Not starting again.");return}let l=n?.tour;const u=n?.Shepherd;if(!l&&u&&(l=u.activeTour,!l&&u.Tour&&(console.log("No active Shepherd tour found from context or global. Creating a new one."),l=new u.Tour({useModalOverlay:r,defaultStepOptions:s}))),!l){console.warn("Failed to get or create a Shepherd tour instance.",n);return}if(l.isActive()){console.log("Tour is already active. Not starting again.");return}if(l.options.defaultStepOptions={...l.options.defaultStepOptions||{},...s},l.options.useModalOverlay=r,a?.firstAgentId&&(l.options.firstAgentId=a.firstAgentId),l.off("complete",t),l.on("complete",t),l.off("cancel",t),l.on("cancel",t),a?.forceModalCompleted||!l.isActive()){const d=[...l.steps];for(const h of d)h.id&&l.removeStep(h.id);l.addSteps(wj)}else l.steps.length===0&&l.addSteps(wj);typeof l.start=="function"?(e("/"),l.start()):console.warn("Shepherd tour instance does not have a start method.",l)}}},ant=()=>{const{isModalComplete:e,isTourComplete:t}=d0(),{startTour:n}=int(),s=nt.useContext(ey),{data:r}=_E(1,1);return m.useEffect(()=>{if(e&&!t&&s){const i=setTimeout(()=>{const a=r?.agents?.[0]?.id;n({firstAgentId:a})},500);return()=>clearTimeout(i)}},[e,t,s,n,r]),null},ont=({children:e})=>c.jsxs(Ytt,{children:[e,c.jsx(ant,{})]}),lnt=()=>{Qe();const{open:e,focusGroup:t,providerId:n,closeConnect:s}=c5(),r=m.useRef(null);m.useEffect(()=>{e&&(r.current=document.activeElement instanceof HTMLElement?document.activeElement:null)},[e]);const i=xi();return c.jsx(lc,{open:e,onOpenChange:a=>{a||s()},children:c.jsxs(cc,{className:"max-h-[calc(100vh-4rem)] max-w-[min(40rem,calc(100vw-4rem))] gap-4 overflow-y-auto","data-connect-provider-dialog":"",onCloseAutoFocus:a=>{const o=r.current;r.current=null,o?.isConnected&&(a.preventDefault(),o.focus())},children:[c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx(rl,{className:"text-title",children:p("ui.providers.connect_provider_dialog.connect_a_model_provider")}),c.jsx(yu,{className:"text-body-sm text-ink-muted",children:p("ui.providers.connect_provider_dialog.your_agents_need_a_model_to_think")})]}),e?c.jsx(uq,{context:"dialog",featuredOnly:!0,focusGroup:t,initialProviderId:n,onDone:s,onChangeModel:()=>{s(),i("/settings")}}):null]})})};function cnt(){const{visible:e,rows:t,cursor:n,commitAt:s,hoverAt:r}=Vse();Wc(e,"session-switcher");const i=n!==null&&e?t[n]??null:null,a=e&&t.length>=2;return c.jsxs(c.Fragment,{children:[c.jsx("output",{"aria-live":"polite",className:"sr-only","data-session-switcher-announcement":"",children:i!==null&&n!==null?c.jsxs(c.Fragment,{children:[Iq(i),", ",n+1," / ",t.length]}):null}),a?dv.createPortal(c.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 flex items-start justify-center pt-[18vh]",children:c.jsx("div",{role:"dialog","aria-modal":"false","aria-label":p("ui.command_palette.palette_search.recents"),className:"pointer-events-auto w-160 max-w-[90vw] rounded-lg border border-hairline bg-elevated p-2 shadow-overlay",children:t.map((o,l)=>c.jsx(hnt,{row:o,active:l===n,onCommit:()=>s(l),onHover:()=>r(l)},o.sessionId))})}),document.body):null]})}function Iq(e){return e.title??p("ui.command_palette.palette_search.untitled_chat")}const unt=1e3;function dnt(){let e=0;function t(){window.clearTimeout(e),window.removeEventListener("contextmenu",n,!0),window.removeEventListener("pointerup",t,!0)}function n(s){s.preventDefault(),s.stopPropagation(),t()}e=window.setTimeout(t,unt),window.addEventListener("contextmenu",n,!0),window.addEventListener("pointerup",t,!0)}function hnt({row:e,active:t,onCommit:n,onHover:s}){return c.jsxs("button",{type:"button",tabIndex:-1,"aria-current":t?"true":void 0,"data-session-id":e.sessionId,onPointerDown:r=>{r.button===0&&(r.preventDefault(),dnt(),n())},onMouseDown:r=>r.preventDefault(),onContextMenu:r=>r.preventDefault(),onMouseMove:s,className:T("flex h-9 w-full items-center gap-3 rounded-sm px-2 text-left",t?"bg-sunken outline-solid outline-1 -outline-offset-1 outline-control":"bg-transparent"),children:[e.row===null?c.jsx("span",{"aria-hidden":"true",className:"size-4 shrink-0"}):c.jsx($z,{row:e.row}),c.jsx("span",{className:T("min-w-0 flex-1 truncate text-body-sm",e.title===null?"text-ink-muted":"text-ink"),children:Iq(e)})]})}const fnt=({title:e,description:t,icon:n,children:s,titleComponent:r,sectionRef:i,dataTourTag:a,className:o,id:l})=>c.jsxs("div",{ref:i,id:l,tabIndex:l?-1:void 0,"data-tour-tag":a,className:T("w-full",o),children:[r??c.jsxs("h2",{className:"flex items-center gap-2 text-heading text-ink",children:[n&&c.jsx(n,{size:16,className:"shrink-0 text-ink-dim"}),e]}),t&&c.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:t}),c.jsx("div",{className:"mt-4",children:s})]}),qat=({label:e,value:t,className:n,valueClassName:s})=>c.jsxs("div",{className:T("min-w-0",n),children:[c.jsx("div",{className:"flex items-center gap-1.5 text-meta text-ink-dim",children:e}),c.jsx("div",{className:T("mt-0.5 break-words text-body-sm",s??"text-ink"),children:t})]}),Kat=({children:e,className:t})=>c.jsx("div",{className:T("grid grid-cols-[repeat(auto-fit,minmax(160px,1fr))] gap-x-6 gap-y-4",t),children:e});async function Pq(e){await at({op:"settings.edit",key:Yo,value:e.value}),Qne(e.queryClient)}async function pnt(e){await Pq(e),e.queryClient.setQueryData(nw.all,t=>t&&{...t,settings:t.settings.map(n=>n.key===Yo?{...n,value:e.value,is_default:e.value===n.default}:n)});try{return await e.queryClient.fetchQuery({queryKey:nw.all,queryFn:()=>at({op:"settings.list"}),staleTime:0,retry:!1}),"confirmed"}catch{return"readback-unknown"}}const Yat=({focus:e=!1})=>{Qe();const t=Gt(),n=ns(),s=Et(n.data,"settings"),r=Nn({queryKey:nw.all,queryFn:()=>at({op:"settings.list"}),enabled:s,retry:!1,refetchOnReconnect:!0}),i=r.data?.settings.find(F=>F.key===Yo),[a,o]=m.useState(!1),[l,u]=m.useState(null),[d,h]=m.useState(!1),[f,g]=m.useState(!1),v=m.useRef(!1),b=m.useRef(null),x=m.useRef(!1);m.useEffect(()=>{if(!e){x.current=!1;return}!i||x.current||(b.current?.querySelector("[role=combobox]")?.focus(),x.current=!0)},[e,i]),m.useEffect(()=>{r.isSuccess&&!r.isFetching&&h(!1)},[r.isFetching,r.isSuccess]);const w=async F=>{if(!(!i||v.current||d||!i.choices.some(A=>A.value===F))){v.current=!0,o(!0),u(null),g(!1);try{const A=await pnt({value:F,queryClient:t});h(A==="readback-unknown"),g(A==="confirmed")}catch(A){u({value:F,message:A instanceof Error?A.message:""})}finally{v.current=!1,o(!1)}}},_=async()=>{const[F,A]=await Promise.all([r.refetch(),n.refetch()]);!F.isError&&!A.isError&&h(!1)},C=!r.data&&r.error||!n.data&&n.error,S=n.data&&(!s||r.data&&!i),y=!C&&!S&&!i,R=n.data?.features?.i18n?n.data.language:void 0,E=typeof R=="string"&&R!==""?R:void 0;return c.jsx(fnt,{title:p("ui.settings.language.dialog.title"),icon:H8,description:p("ui.settings.language.general.description"),children:c.jsxs("div",{ref:b,"data-setting-key":Yo,className:"flex flex-col gap-3","aria-busy":a,children:[y&&c.jsx("output",{className:"text-meta text-ink-dim",children:p("ui.settings.language.dialog.loading")}),S&&c.jsx("p",{className:"text-meta text-ink-dim",children:p("ui.settings.language.dialog.unavailable")}),i&&c.jsx(g5,{setting:{...qR(i),label:p("ui.settings.language.dialog.title")},value:String(i.value),onValueChange:F=>{w(F)},disabled:a||d,suppressEffectiveNote:!0}),c.jsx("output",{id:Yne(Yo),"aria-live":"polite",className:"text-meta text-ink-dim",children:a?p("ui.settings.language.general.pending"):f?p("ui.settings.language.general.saved"):E?p(d||n.error?"ui.settings.language.general.last_known":"ui.settings.language.general.effective",{locale:Xne(E)?.name??E}):p("ui.settings.language.general.no_resolution")}),(C||l||d)&&c.jsx(Kr,{variant:"danger",children:c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsx("p",{role:"alert",children:l?p("ui.settings.language.general.write_error",{message:l.message}):d?p("ui.settings.language.general.readback_error"):p("ui.settings.language.dialog.unavailable")}),c.jsx(le,{variant:"outline",size:"sm",disabled:a||r.isFetching||n.isFetching,onClick:()=>{l?w(l.value):_()},children:p("ui.settings.language.dialog.retry")})]})})]})})},gnt=()=>{Qe();const e=sR(ne=>ne.open),t=sR(ne=>ne.closeLanguage),n=Gt(),s=ns(),r=Et(s.data,"settings"),i=Nn({queryKey:nw.all,queryFn:()=>at({op:"settings.list"}),enabled:e&&r,staleTime:1e4}),a=m.useRef(null),o=t5(),l=(i.data?.settings??[]).find(ne=>ne.key===Yo),u=l?qR(l):void 0,[d,h]=m.useState(null),[f,g]=m.useState(!1),[v,b]=m.useState(!1),[x,w]=m.useState(null),_=m.useRef(null);m.useEffect(()=>{e&&h(null)},[e]),m.useEffect(()=>{if(!e||!u)return;const ne=String(u.value??"");(d===null||d===_.current)&&h(ne),_.current=ne},[e,u,d]),m.useEffect(()=>{e&&(b(!1),w(null))},[e]);const C=d??String(u?.value??""),S=!!u&&C!==String(u?.value??""),y=!u||!S||f,R=async()=>{if(!(!u||!S)){g(!0),w(null);try{await Pq({value:C,queryClient:n}),b(!0),h(null),await i.refetch()}catch(ne){w(ne instanceof Error?ne.message:p("ui.settings.configuration.language_dialog.the_language_could_not_be_saved"))}finally{g(!1)}}},E=!!s.data,F=E&&!r,A=s.error&&!s.data?s.error:null,I=A??i.error,P=!E&&!I,{sentence:N,remedy:L}=uQ(o??null,p("ui.settings.configuration.language_dialog.your_settings_could_not_be_loaded"),I),V=s.isFetching||i.isFetching,B=u?"combo":I?"retry":"none";return m.useEffect(()=>{!e||B==="none"||requestAnimationFrame(()=>{a.current?.querySelector(B==="combo"?'[role="combobox"]':"[data-language-retry]")?.focus()})},[e,B]),c.jsx(lc,{open:e,onOpenChange:ne=>!ne&&t(),children:c.jsxs(cc,{ref:a,onOpenAutoFocus:ne=>ne.preventDefault(),className:"max-w-[min(28rem,calc(100vw-4rem))] gap-4",children:[c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx(rl,{className:"text-title",children:p("ui.settings.language.dialog.title")}),c.jsx(yu,{className:"text-body-sm text-ink-muted",children:p("ui.settings.language.dialog.description")})]}),P?c.jsxs("div",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[c.jsx(An,{}),p("ui.settings.language.dialog.loading")]}):F?c.jsx(Kr,{variant:"warning",children:c.jsx("span",{children:p("ui.settings.language.dialog.unavailable")})}):I?c.jsx(Kr,{variant:"warning",children:c.jsxs("div",{className:"flex items-center justify-between gap-3",children:[c.jsx("span",{children:N}),L&&c.jsx(le,{variant:"secondary",size:"sm",className:"shrink-0","data-language-retry":"",onClick:()=>{A?s.refetch():i.refetch()},disabled:V,children:V?p("ui.settings.language.dialog.retrying"):p("ui.settings.language.dialog.retry")})]})}):i.isPending?c.jsxs("div",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[c.jsx(An,{}),p("ui.settings.language.dialog.loading")]}):u?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("span",{id:LI(Yo),className:"text-meta text-ink-dim",children:u.help}),c.jsx(g5,{setting:u,value:C,disabled:f,helpId:LI(Yo),effectiveNoteId:Jne(Yo,Zne),onValueChange:ne=>{b(!1),h(ne)}})]}),x&&c.jsx("p",{className:"text-meta text-danger",children:x}),c.jsx("div",{className:"flex min-h-8 items-center justify-end",children:v&&!S?c.jsxs("output",{"data-language-save":"",className:"inline-flex items-center gap-1.5 text-body-sm text-ink",children:[c.jsx(Us,{"aria-hidden":"true",className:"size-3.5"}),p("ui.settings.language.dialog.saved")]}):c.jsx(le,{onClick:R,disabled:y,"data-language-save":"",children:f?`${p("ui.settings.language.dialog.save")}...`:p("ui.settings.language.dialog.save")})})]}):c.jsx(Kr,{variant:"warning",children:c.jsx("span",{children:p("ui.settings.language.dialog.unavailable")})})]})})};function Ou(){return crypto.randomUUID()}async function Xat(e=1,t=20,n){const s={page:e,per_page:t};if(n)for(const[r,i]of Object.entries(n))i&&(s[r]=i);return wi({operation:"agents.list",query:s})}async function Qat(e){return wi({operation:"agents.get",agentId:e})}async function Jat(e){return wi({operation:"agents.delete",agentId:e,requestId:Ou(),confirmed:!0})}async function Zat(e){return wi({operation:"agents.like",agentId:e,requestId:Ou()})}async function eot(e){return wi({operation:"agents.unlike",agentId:e,requestId:Ou(),confirmed:!0})}async function tot(e){return wi({operation:"agents.favourite",agentId:e,requestId:Ou()})}async function not(e){return wi({operation:"agents.unfavourite",agentId:e,requestId:Ou(),confirmed:!0})}async function sot(e,t){return wi({operation:"comments.create",agentId:e,payload:t,requestId:Ou()})}async function rot(e,t=1,n=20){return wi({operation:"comments.list",agentId:e,query:{page:t,per_page:n}})}async function iot(e,t,n){return wi({operation:"comments.update",agentId:e,commentId:t,payload:n,requestId:Ou()})}async function aot(e,t){return wi({operation:"comments.delete",agentId:e,commentId:t,requestId:Ou(),confirmed:!0})}async function oot(e){return wi({operation:"agents.statuses",query:{agent_ids:e.join(",")}})}async function mnt(){return wi({operation:"memberships.list"})}async function lot(e,t=1,n=20,s){const r={page:t,per_page:n};if(s)for(const[i,a]of Object.entries(s))a&&(r[i]=a);return wi({operation:"org_agents.list",tenantId:e,query:r})}async function cot(e){return wi({operation:"org_teams.list",tenantId:e})}class cx extends Error{status;reason;constructor(t,n,s){super(t),this.name="PublicHubError",this.status=n,this.reason=s}}const vnt=/\/+$/,bnt=(e,t,n)=>{const s=e.replace(vnt,"");return n?`${s}/v1/${t}/${encodeURIComponent(n)}`:`${s}/v1/${t}`},Nq=(e,t)=>bnt(e,"teams",t),Mq=async e=>{let t;try{t=await fetch(e,{method:"GET",headers:{Accept:"application/json"},redirect:"error"})}catch(s){throw console.error("The public hub could not be reached:",s),new cx(p("ui.common.errors.public_hub_unreachable"),null,s)}if(!t.ok)throw new cx(p("ui.common.errors.public_hub_status",{status:t.status}),t.status);let n;try{n=await t.json()}catch{throw new cx(p("ui.common.errors.public_hub_json"),t.status)}if(!n||typeof n!="object"||!("result"in n))throw new cx(p("ui.common.errors.public_hub_body"),t.status);return n};async function uot(e,t=1,n=12){const s=`${Nq(e)}?page=${t}&per_page=${n}`;return Mq(s)}async function dot(e,t){return Mq(Nq(e,t))}const xnt={all:["memberships"],account:e=>["memberships","account",e??"unresolved-owner"]},wnt=({enabled:e=!0}={})=>{const{isAuthenticated:t}=YR(),n=Gt(),{accountId:s}=m5(),r=Nn({queryKey:xnt.account(s),queryFn:async()=>(await v5(n,s,()=>mnt())).result??{memberships:[]},enabled:e&&t&&!!s,staleTime:5*60*1e3,gcTime:10*60*1e3,refetchOnWindowFocus:!1,retry:pv});return{...r,memberships:r.data?.memberships??[]}},br=qe.string().min(1).max(128),_nt=qe.object({account_id:br,kind:qe.enum(["human","agent"]),display_label:qe.string().min(1).max(64),role:qe.enum(["owner","member"]),state:qe.enum(["invited","active","left","removed"]),joined_seq:qe.number().int().nonnegative().optional()}).passthrough(),Oq=qe.enum(["all","mention","mute"]),Gx=qe.object({id:br,tenant_id:br,kind:qe.enum(["dm","group","channel"]),name:qe.string().optional(),topic:qe.string().optional(),visibility:qe.enum(["private","tenant"]),agent_capable:qe.boolean(),status:qe.enum(["open","archived"]),created_by:br,last_message_at:qe.string(),latest_seq:qe.number().int().nonnegative(),members:qe.array(_nt),last_read_seq:qe.number().int().nonnegative(),unread_count:qe.number().int().nonnegative(),muted:qe.boolean(),discoverable:qe.boolean().optional(),member:qe.boolean().optional(),member_count:qe.number().int().nonnegative().optional(),notify:Oq.optional(),last_sender_label:qe.string().min(1).max(64).optional(),last_thread_root_id:br.optional(),builtin:qe.string().min(1).max(32).optional()}).passthrough(),Cnt=qe.object({conversations:qe.array(Gx),has_more:qe.boolean().optional(),next_before:qe.string().optional()}).passthrough(),Lq=qe.object({emoji:qe.string().min(1),count:qe.number().int().positive(),reacted_by_me:qe.boolean(),sample_labels:qe.array(qe.string()).max(3)}).passthrough(),ynt=qe.object({message_id:br,reactions:qe.array(Lq).max(50)}).passthrough(),Snt=Lq.extend({sample_labels:qe.array(qe.string()).transform(e=>e.slice(0,3))}),knt=qe.array(Snt).transform(e=>e.slice(0,50)),Bq=qe.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/),XF=qe.object({id:Bq,mime:qe.string().max(64),size:qe.number().int().nonnegative(),width:qe.number().int().nonnegative(),height:qe.number().int().nonnegative(),sha256:qe.string().max(128).optional(),state:qe.string().max(32).optional(),expires_at:qe.string().optional()}).passthrough(),Ent=qe.object({attachment:XF}).passthrough(),hot=qe.object({enabled:qe.boolean(),max_count:qe.number().int().positive().max(16),max_bytes:qe.number().int().positive(),max_pixels:qe.number().int().positive().optional(),mime_types:qe.array(qe.string())}).passthrough(),uR=qe.object({id:br,conversation_id:br,seq:qe.number().int().nonnegative(),sender:qe.object({account_id:br,kind:qe.enum(["human","agent"]),display_label:qe.string().min(1).max(64)}).passthrough(),body:qe.string().nullable(),body_hash:qe.string().optional(),origin:qe.enum(["human","agent","system"]),agent_label:qe.string().optional(),created_at:qe.string(),reactions:knt.optional(),thread_root_id:br.optional(),reply_count:qe.number().int().nonnegative().optional(),last_reply_at:qe.string().optional(),reply_participants:qe.array(qe.string()).optional(),attachments:qe.array(XF).max(16).optional()}).passthrough(),Tnt=qe.object({root:uR,replies:qe.array(uR),next_after_seq:qe.number().int().nonnegative().optional(),has_more:qe.boolean().optional()}).passthrough(),Rnt=qe.object({messages:qe.array(uR),next_before_seq:qe.number().int().nonnegative().optional(),has_more:qe.boolean().optional()}).passthrough(),Ant=qe.object({tenant_id:br,tenant_name:qe.string(),unread:qe.number().int().nonnegative(),eligible:qe.boolean()}).passthrough(),Fnt=qe.object({total:qe.number().int().nonnegative(),conversations:qe.array(qe.object({conversation_id:br,unread_count:qe.number().int().nonnegative(),last_read_seq:qe.number().int().nonnegative(),latest_seq:qe.number().int().nonnegative(),muted:qe.boolean()}).passthrough()).optional(),organizations:qe.array(Ant).optional()}).passthrough(),jq=qe.enum(["active","paused","disabled","none"]),Hq=qe.object({endpoint_id:br,name:qe.string().max(128),state:qe.string().min(1).max(32)}).passthrough(),Dnt=qe.object({account_id:br,display_label:qe.string(),role:qe.string().min(1).max(32),bridge_enabled:qe.boolean(),bridge_state:jq,agent:Hq.optional().catch(void 0)}).passthrough();function Int(e){if(e===null||typeof e!="object")return null;const t=e,n=t.account_id;if(typeof n!="string"||n.length===0)return null;const s=typeof t.display_label=="string"?t.display_label:"",r=typeof t.role=="string"&&t.role.length>0?t.role:"member",i=t.bridge_enabled===!0,a=jq.safeParse(t.bridge_state),o=Hq.safeParse(t.agent);return{account_id:n,display_label:s,role:r,bridge_enabled:i,bridge_state:a.success?a.data:"none",...o.success?{agent:o.data}:{}}}const Pnt=qe.object({members:qe.array(qe.unknown())}).passthrough().transform(e=>{const t=[];let n=0;for(const s of e.members){const r=Dnt.safeParse(s);if(r.success){t.push(r.data);continue}const i=Int(s);i?t.push(i):n+=1}return{...e,members:t,unavailable_count:n}}),Nnt=qe.object({account_id:qe.string().min(1).nullable().optional()}).passthrough(),_j=qe.object({conversation_id:br,last_read_seq:qe.number().int().nonnegative(),unread_count:qe.number().int().nonnegative(),muted:qe.boolean(),notify:Oq.optional()}).passthrough(),dR=qe.object({id:br,tenant_id:br,conversation_id:br,body:qe.string(),send_at:qe.string().datetime({offset:!0}),status:qe.enum(["scheduled","sending"]),created_at:qe.string().datetime({offset:!0}),attachments:qe.array(XF).max(16).optional(),attachment_ids:qe.array(Bq).max(16).optional()}).transform(({attachment_ids:e,...t})=>t.attachments!==void 0||!e?.length?t:{...t,attachments:e.map(n=>({id:n,mime:"",size:0,width:0,height:0,state:"reserved"}))}),Mnt=qe.object({scheduled:qe.array(dR)});class Cj extends Error{status;code;constructor(t,n){super("team bridge attachment request failed"),this.name="TeamBridgeAttachmentError",this.status=t,this.code=n}}async function ud(e,t){if(!e||!t)throw new Error("Team Bridge write owner and tenant required");if(((await at({op:"capabilities"})).features?.team_bridge_conversation_owner_guard??0)<1)throw new Error("Team Bridge runtime owner guard unavailable");return{expected_account_id:e,tenant_id:t}}const Jr={async scheduledList(e){return Mnt.parse(await at({op:"team_bridge.scheduled.list",tenant_id:e}))},async scheduledCreate(e){return dR.parse(await at({op:"team_bridge.scheduled.create",...e}))},async scheduledUpdate(e,t,n){return dR.parse(await at({op:"team_bridge.scheduled.update",tenant_id:e,scheduled_id:t,...n}))},async scheduledCancel(e,t){return at({op:"team_bridge.scheduled.cancel",tenant_id:e,scheduled_id:t})},async react(e,t,n,s,r){const i=await at({op:"team_bridge.reactions.toggle",conversation_id:e,message_id:t,emoji:n,active:s,...r?{tenant_id:r}:{}});return ynt.parse(i)},async listConversations(e){const t=await at({op:"team_bridge.conversations.list",...e==="account"?{scope:"account"}:{tenant_id:e.tenantId}});return Cnt.parse(t)},async getConversation(e,t){const n=await at({op:"team_bridge.conversations.get",conversation_id:e,...t?{tenant_id:t}:{}});return Gx.parse(n)},async startConversation(e){const t=await at({op:"team_bridge.conversations.create",...await ud(e.expectedAccountId,e.tenantId),kind:e.kind,...e.tenantId?{tenant_id:e.tenantId}:{},...e.name?{name:e.name}:{},...e.topic?{topic:e.topic}:{},...e.visibility?{visibility:e.visibility}:{},...e.agentCapable===void 0?{}:{agent_capable:e.agentCapable},members:e.members});return Gx.parse(t)},async listMessages(e,t={}){const n=await at({op:"team_bridge.messages.list",conversation_id:e,...t.tenantId?{tenant_id:t.tenantId}:{},...t.limit===void 0?{}:{limit:t.limit},...t.beforeSeq===void 0?{}:{before_seq:t.beforeSeq}});return Rnt.parse(n)},async listReplies(e,t,n={}){const s=await at({op:"team_bridge.messages.replies",conversation_id:e,message_id:t,...n.tenantId?{tenant_id:n.tenantId}:{},...n.limit===void 0?{}:{limit:n.limit},...n.afterSeq===void 0?{}:{after_seq:n.afterSeq}});return Tnt.parse(s)},async send(e,t){return at({op:"team_bridge.messages.send",...t.threadRootId?{}:await ud(t.expectedAccountId,t.tenantId),conversation_id:e,client_ref:t.clientRef,body:t.body,...t.tenantId?{tenant_id:t.tenantId}:{},...t.threadRootId?{thread_root_id:t.threadRootId}:{},...t.attachmentIds?.length?{attachment_ids:[...t.attachmentIds]}:{}})},async uploadAttachment(e,t,n,s){const r=await aI({op:"team_bridge.attachment.upload",tenantId:e,conversationId:t,expectedAccountId:s},n);if(r.kind!=="json")throw new Cj(r.kind==="error"?r.status:null,r.kind==="error"?r.code:void 0);const i=r.body;return Ent.parse(i&&typeof i=="object"&&"result"in i?i.result:i).attachment},async deleteAttachment(e,t,n,s){return at({op:"team_bridge.attachments.delete",tenant_id:e,expected_account_id:s,conversation_id:t,attachment_id:n})},async attachmentBytes(e){const t=await aI({op:"team_bridge.attachment",...e},null);if(t.kind!=="bytes")throw new Cj(t.kind==="error"?t.status:null,t.kind==="error"?t.code:void 0);return{data:t.data,mimeType:t.mimeType}},async markRead(e,t){const n=await at({op:"team_bridge.read",...await ud(t.expectedAccountId,t.tenantId),conversation_id:e,...t.tenantId?{tenant_id:t.tenantId}:{},...t.seq===void 0?{}:{seq:t.seq},...t.muted===void 0?{}:{muted:t.muted}});return _j.parse(n)},async identity(){const e=await at({op:"agent_messages.status",boundary:"surface_open"}),t=Nnt.parse(e);return FE(AE(),t),t.account_id??null},async unread(e){const t=await at({op:"team_bridge.unread",...e==="account"?{scope:"account"}:{tenant_id:e.tenantId}});return Fnt.parse(t)},async directory(e){const t=await at({op:"team_bridge.directory",tenant_id:e});return Pnt.parse(t)},async status(e){const t=await at({op:"team_bridge.status",...e?{boundary:e}:{}}),n=Qj.parse(t);return FE(AE(),n),n},async setArchived(e,t,n,s){return at({op:"team_bridge.conversations.lifecycle",conversation_id:e,action:t?"archive":"unarchive",...await ud(s,n)})},async leave(e,t,n){return at({op:"team_bridge.conversations.lifecycle",conversation_id:e,action:"leave",...await ud(n,t)})},async join(e,t,n){const s=await at({op:"team_bridge.conversations.join",...await ud(n,t),conversation_id:e,...t?{tenant_id:t}:{}});return Gx.parse(s)},async setNotify(e,t,n,s){const r=await at({op:"team_bridge.conversations.notify",...await ud(s,n),conversation_id:e,...n?{tenant_id:n}:{},notify:t});return _j.parse(r)}},Ont=320,Lnt=360,Bnt=320;function jnt(e){const t=e.codePointAt(0)??0;return e==="<"||e===">"||t<32||t>=127&&t<=159||t===1564||t===8206||t===8207||t>=8234&&t<=8238||t>=8294&&t<=8297||t===8232||t===8233}const Hnt=/\s+/g,Unt=new Intl.Segmenter(void 0,{granularity:"grapheme"});function Uq(e,t,n="points"){let s=0,r="";for(const{segment:i}of Unt.segment(e)){const a=n==="points"?Array.from(i).length:i.length;if(s+a>t)return`${r.trimEnd()}…`;r+=i,s+=a}return r}function Vx(e,t){let n="";for(const r of e)r==="<"?n+="‹":r===">"?n+="›":n+=jnt(r)?" ":r;const s=n.replace(Hnt," ").trim();return s.length<=t?s:Uq(s,Math.max(0,t-1),"units")}const fot=!1,pot=!1;function Gnt(e){return`/team-bridge?${new URLSearchParams({tenant:e.tenantId,conversation:e.conversationId}).toString()}`}const Vnt=140,Wnt=/^\s*(```|~~~).*$/gm,$nt=/^\s{0,3}#{1,6}\s+/gm,znt=/^\s{0,3}(>\s?)+/gm,qnt=/^\s*([-*+]|\d{1,9}[.)])\s+/gm,Knt=/^\[[ xX]\]\s+/gm,Ynt=/^\s{0,3}([-*_])(\s*\1){2,}\s*$/gm,Xnt=/!\[([^\]]*)\]\([^)]*\)/g,Qnt=/\[([^\]]+)\]\([^)]*\)/g,Jnt=/<((?:https?|mailto):[^>\s]+)>/gi,Znt=/<\/?[A-Za-z][^>]*>/g,est=/`+([^`]*)`+/g,tst=/(\*\*|__)(?=\S)([\s\S]*?\S)\1/g,nst=/~~(?=\S)([\s\S]*?\S)~~/g,sst=/(^|[^\w*])\*(?=\S)([^*]*?\S)\*(?!\w)/g,rst=/(^|[^\w])_(?=\S)([^_]*?\S)_(?!\w)/g;function ist(e,t=Vnt){if(typeof e!="string"||e.trim().length===0)return null;const n=e.replace(Wnt," ").replace(Ynt," ").replace($nt,"").replace(znt,"").replace(qnt,"").replace(Knt,"").replace(Xnt,"$1").replace(Qnt,"$1").replace(Jnt,"$1").replace(Znt,"").replace(est,"$1").replace(tst,"$2").replace(nst,"$1").replace(sst,"$1$2").replace(rst,"$1$2"),s=Vx(n,Number.MAX_SAFE_INTEGER);return s.length===0?null:Uq(s,t)}function ast(e,t){const n=e.senderLabel?.trim()||e.conversationName?.trim()||t.untitled,s=e.place.kind==="dm"?t.directMessage:e.place.kind==="channel"?e.place.name?.trim()?t.channel(e.place.name.trim()):e.conversationName?.trim()??t.untitled:e.place.name?.trim()||e.conversationName?.trim()||t.group,r=e.organizationName?t.subtitle(s,e.organizationName):s,i=Math.max(1,Math.floor(e.unreadCount)),a=i>1?e.preview?t.countPreview(i,e.preview):t.count(i):e.preview??t.fallback;return{title:Vx(n,Ont)||t.untitled,subtitle:Vx(r,Bnt)||t.untitled,body:Vx(a,Lnt)||t.fallback}}const _u="all";function got(e){return e}function mot(e){return e===_u?_u:e}function ost(e,t){const n=e.name?.trim();if(n)return n;const s=e.members.filter(i=>i.state!=="removed"&&!(i.kind==="human"&&i.account_id===t));if(e.kind==="dm"){const i=s.find(a=>a.state==="active")??s[0];return i?D_(i.display_label):null}const r=s.filter(i=>i.state==="active").map(i=>D_(i.display_label)).filter(i=>i!==null);return r.length===0?null:r.length<=3?r.join(", "):`${r.slice(0,2).join(", ")} +${r.length-2}`}function vot(e){return e.discoverable===!0&&e.member===!1}function Gq(e){return e.notify??(e.muted?"mute":"all")}function bot(e){return Gq(e)==="mute"}function xot(e){return e==="mute"?"all":"mute"}const wot=[{value:"all",labelKey:"ui.teamBridge.notify.all"},{value:"mention",labelKey:"ui.teamBridge.notify.mention"},{value:"mute",labelKey:"ui.teamBridge.notify.mute"}];function _ot(e){return e==="mention"||e==="mute"?e:"all"}function lst(e,t,n,s){return{...e,conversations:e.conversations.map(r=>r.id===t&&(!s||r.tenant_id===s)?{...r,notify:n,muted:n==="mute"}:r)}}function Cot(e,t){return e.isError&&e.variables?.conversationId===t}function yot(e){return e.members.length>0?e.members.filter(t=>t.state==="active").length:e.member_count??0}function cst(e){const t=(e.conversations??[]).filter(r=>!r.muted).reduce((r,i)=>r+i.unread_count,0),n=(e.organizations??[]).reduce((r,i)=>r+i.unread,0),s=Math.max(t,n);return Number.isFinite(e.total)&&e.total>0?Math.max(0,e.total):s}function ust(e){return[...e].sort((t,n)=>t.seq-n.seq)}function dst(e,t=[],n){const s=new Map(t.map(l=>[l.tenant_id,l.unread])),r=e.filter(l=>l.status==="active");if(!n)return r.map(l=>({tenantId:l.tenant_id,name:l.tenant_name,role:l.role,unread:s.get(l.tenant_id)??0}));const i=new Map(r.map(l=>[l.tenant_id,l])),a=new Set,o=[];for(const l of n){if(a.has(l.tenant_id))continue;a.add(l.tenant_id);const u=i.get(l.tenant_id);o.push({tenantId:l.tenant_id,name:l.tenant_name?.trim()||u?.tenant_name?.trim()||l.tenant_id,role:u?.role??"",unread:s.get(l.tenant_id)??0})}return o}function Sot(e,t,n){return n||e.length!==1?t:e[0].tenantId}function kot(e,t){return e.find(n=>n.tenantId===t)??null}function QF(e){const t=n=>{const s=Date.parse(n);return Number.isNaN(s)?Number.NEGATIVE_INFINITY:s};return[...e].sort((n,s)=>{const r=t(s.last_message_at)-t(n.last_message_at);return r!==0?r:n.id.localeCompare(s.id)})}function Eot(e){return e?.status?.tenants??null}function Tot(e,t){return e!==null?{pending:!1,failed:!1}:{pending:t.isLoading,failed:t.isError}}function Vq(e,t){return t.find(n=>n.tenantId===e.tenant_id)?.name??null}function Rot(e,t,n){return t!==_u?[...e]:QF(e).filter(s=>Vq(s,n)!==null)}function Aot(e){return e?e.state==="signed_out"?"signed_out":e.state==="update_required"||e.update_required?"update_required":e.state==="unavailable"?"unavailable":e.surface_state==="A"?"plan_required":null:null}function hR(e){return e.display_label.trim()||e.account_id}function Fot(e){const t=e,n=typeof t?.status=="number"?t.status:null,s=typeof t?.code=="string"?t.code:null;return n===401?"sign_in":n===403&&s==="bridge_not_available"?"plan":n===403?"refused":n===422||s==="invalid_request"?"invalid":n===400||n===404||t?.name==="ZodError"?"outdated":n===null?"unreachable":"server"}function hst(e,t){return t&&e.account_id===t?"self":e.bridge_enabled&&(e.bridge_state==="active"||e.bridge_state==="paused")?e.bridge_state==="paused"?"paused":"openable":"unavailable"}function fR(e,t,n){const s=e.filter(r=>r.kind!=="dm"||r.status==="archived"||!r.members.some(a=>a.kind==="human"&&a.account_id===t&&a.state!=="removed")?!1:n?r.members.some(a=>a.kind==="human"&&a.account_id===n&&a.state!=="removed"):!0);return s.length===0?null:QF(s)[0]??null}function Dot(e){return e.trim().charAt(0).toUpperCase()||"?"}function fst(e,t){const n=[];for(const s of e){if(t&&s.account_id===t)continue;const r=s.agent;!r||r.state==="disabled"||n.push({person:s,endpointId:r.endpoint_id,agentName:r.name.trim(),paused:r.state==="paused"})}return n}function pR(e,t,n){const s=e.filter(r=>r.kind==="dm"&&r.status!=="archived"&&r.members.some(i=>i.kind==="agent"&&i.account_id===t&&i.state!=="removed")&&(!n||r.members.some(i=>i.kind==="human"&&i.account_id===n&&i.state!=="removed")));return s.length===0?null:QF(s)[0]??null}const ik=["humans","agents"];function Iot(e){const t=[],n=[],s=[],r=[];for(const i of e)i.kind==="channel"?i.builtin&&ik.includes(i.builtin)?t.push(i):n.push(i):i.kind==="group"?s.push(i):r.push(i);return t.sort((i,a)=>ik.indexOf(i.builtin)-ik.indexOf(a.builtin)),{channels:[...t,...n],groups:s,directs:r}}function Pot(e,t,n,s){const r=new Set;for(const i of t){if(s!==void 0&&i.account_id===s)continue;const a=fR(e,i.account_id,s);a&&r.add(a.id)}for(const i of n){const a=pR(e,i.person.account_id,s);a&&r.add(a.id)}return e.filter(i=>!r.has(i.id))}function Not(e){return`${e.kind}:${e.accountId}`}function Mot(e,t,n){if(e===null)return null;switch(e.type){case"conversation":return t.find(s=>s.id===e.id)??null;case"person":return fR(t,e.accountId,n);case"chief":return pR(t,e.accountId,n);case"compose":{if(e.recipients.length!==1)return null;const[s]=e.recipients;return s.kind==="agent"?pR(t,s.accountId,n):fR(t,s.accountId,n)}}}function pst(e){return e.kind==="agent"?{account_id:e.accountId,kind:"agent",endpoint_id:e.endpointId,display_label:e.label.slice(0,64)}:{account_id:e.accountId,kind:"human",display_label:e.label.slice(0,64)}}function Oot(e,t,n){const s=e.filter(i=>{const a=hst(i,t);return a==="openable"||a==="paused"}).map(i=>({kind:"human",accountId:i.account_id,label:hR(i)})),r=fst(e,t).map(i=>({kind:"agent",accountId:i.person.account_id,endpointId:i.endpointId,label:n(i.agentName,hR(i.person))}));return[...s,...r]}function Lot(e){if(e.length===0)return null;const t=e.map(pst);return{kind:e.length===1?"dm":"group",visibility:"private",agentCapable:e.some(n=>n.kind==="agent"),members:t}}const gst="Member";function D_(e){const t=e.trim();return t===""||t===gst?null:t}function mst(e,t,n,s){const r=t.find(l=>l.account_id===e.account_id),i=r?hR(r):null,a=D_(e.display_label);if(e.kind==="human"){const l=s&&s.accountId===e.account_id&&s.name.trim()||null;return i??l??a}const o=r?.agent?.name.trim()||a;return o?i?n(o,i):o:null}const vst=5*6e4;function ak(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function Bot(e,t){const n=ak(t),s=ak(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1)),r=[];let i=null,a=null;for(const o of ust(e)){const l=new Date(o.created_at),u=!Number.isNaN(l.getTime()),d=u?ak(l):null;d!==null&&d!==a&&r.push({type:"day",key:d,date:l,relative:d===n?"today":d===s?"yesterday":null});const h=i!==null&&u&&d===a&&i.sender.account_id===o.sender.account_id&&i.sender.kind===o.sender.kind&&l.getTime()-Date.parse(i.created_at)<vst;r.push({type:"message",message:o,continuation:h}),i=o,d!==null&&(a=d)}return r}async function jot(e){let t=e.remembered.get(e.draftKey);if(t===void 0){const n=await e.create(e.input);if(!n.id)throw new Error("create returned no conversation id");t={id:n.id,tenantId:n.tenant_id??e.tenantId},e.remembered.set(e.draftKey,t)}return await e.post(t.id,{clientRef:e.clientRef,body:e.body,tenantId:t.tenantId}),e.remembered.delete(e.draftKey),t}const Xg=3e4,bst=10;function xst(e,t=bst){return[...e?.organizations??[]].filter(n=>n.eligible&&n.unread>0).sort((n,s)=>s.unread-n.unread||n.tenant_id.localeCompare(s.tenant_id)).slice(0,t)}function wst(e,t){return e.member===!0?!0:e.member===!1||!t?!1:e.members.some(n=>n.kind==="human"&&n.account_id===t&&n.state==="active")}function _st(e,t){return wst(e,t)&&Gq(e)==="all"&&e.builtin!=="agents"}function Cst(e,t,n){return{conversationName:ost(e,t),organizationName:Vq(e,n),senderLabel:D_(e.last_sender_label??"")}}function yst(e){const t=new Map(e.cursors),n=e.rows;if(!e.seeded){for(const a of n)t.set(a.conversation_id,a.latest_seq);return{candidates:[],cursors:t,seeded:!0}}const r=new Map(e.conversations.map(a=>[a.id,a])),i=[];for(const a of n){const o=t.get(a.conversation_id);if(a.unread_count===0||a.latest_seq<=a.last_read_seq||o!==void 0&&a.latest_seq<=o){(o===void 0||a.latest_seq>o)&&t.set(a.conversation_id,a.latest_seq);continue}const l=r.get(a.conversation_id);l!==void 0&&l.latest_seq===a.latest_seq&&(t.set(a.conversation_id,a.latest_seq),_st(l,e.selfAccountId)&&i.push({conversationId:l.id,...l.last_thread_root_id?{threadId:l.last_thread_root_id}:{},tenantId:a.tenant_id,seq:a.latest_seq,...Cst(l,e.selfAccountId,e.organizations),kind:l.kind,name:l.name?.trim()||null,unreadCount:a.unread_count}))}return{candidates:i,cursors:t,seeded:!0}}const Lo=["team-bridge"],Qg=e=>e?["account",e]:[],is={all:Lo,conversations:(e,t)=>[...Lo,"conversations",e,...Qg(t)],conversationsPrefix:[...Lo,"conversations"],messages:(e,t,n)=>[...Lo,"messages",t??"unknown-tenant",e,...Qg(n)],unread:(e,t)=>[...Lo,"unread",e,...Qg(t)],unreadPrefix:[...Lo,"unread"],directory:(e,t)=>[...Lo,"directory",e,...Qg(t)],replies:(e,t,n,s)=>[...Lo,"replies",e,t,n,...Qg(s)],status:[...Lo,"status"],statusFor:e=>[...Lo,"status","account",e??"unresolved-owner"]};function JF(){return U_(),m5()}function Wq(e,t){const n=v0(e),s=e.getQueryData(is.statusFor(t));return!!(t&&n.accountId===t&&s?.account_id===t&&s.state==="ready"&&s.local.enabled&&!s.read_only)}function yj(e,t){const n=e.getQueryData(is.statusFor(t));if(!t||v0(e).accountId!==t||n?.account_id!==t)throw new Error("Team Bridge read owner changed")}const $q=v5;async function Cu(e,t,n){yj(e,t);const s=e.getQueryData(is.statusFor(t)),r=await $q(e,t,n);if(yj(e,t),e.getQueryData(is.statusFor(t))!==s)throw new Error("Team Bridge read authority changed");return r}function qv(e){const t=Gt(),n=v0(t),s=m.useRef({accountId:e??n.accountId,epoch:n.epoch}).current,r=m.useRef(!0);m.useLayoutEffect(()=>(r.current=!0,()=>{r.current=!1}),[]);const i=()=>{const l=v0(t);return r.current&&!!s.accountId&&l.accountId===s.accountId&&l.epoch===s.epoch},a=()=>i()&&Wq(t,s.accountId),o=()=>{if(!a())throw new Error("Team Bridge write authority changed")};return{accountId:s.accountId,isCurrent:a,isReadCurrent:i,assertCurrent:o}}function Sst(e,t){if(e.root.id!==t.rootId||e.root.conversation_id!==t.conversationId||e.root.thread_root_id||e.replies.some(n=>n.conversation_id!==t.conversationId||n.thread_root_id!==t.rootId))throw new Error("Thread response identity mismatch");return e}let Wx=null;function kst(){return Wx}function Hot(e){m.useEffect(()=>{const t=e??null;return Wx=t,()=>{Wx===t&&(Wx=null)}},[e])}function ty(e,t){const n=s=>({onSuccess:(r,i,a)=>s?.onSuccess?.(r,i.input,a),onError:(r,i,a)=>s?.onError?.(r,i.input,a),onSettled:(r,i,a,o)=>s?.onSettled?.(r,i,a.input,o)});return{...e,variables:e.variables?.input,mutate:(s,r)=>e.mutate({input:s,target:t()},n(r)),mutateAsync:(s,r)=>e.mutateAsync({input:s,target:t()},n(r))}}function zq(e){return e===_u?"account":{tenantId:e}}const Est=18e4,Sj=6e4;function Tst(){return typeof document>"u"?Sj:document.visibilityState==="visible"?Est:Sj}function Uot(e,t=!0,n){const s=Gt();return Nn({queryKey:is.conversations(e,n??"unresolved-owner"),queryFn:()=>Cu(s,n,()=>Jr.listConversations(zq(e))),enabled:t&&!!n,staleTime:15e3,refetchOnWindowFocus:!0})}function Got(e,t,n=!0,s){const r=Gt();return Nn({queryKey:is.messages(e??"none",t,s??"unresolved-owner"),queryFn:()=>Cu(r,s,()=>Jr.listMessages(e,{tenantId:t})),enabled:n&&!!s&&!!e,staleTime:5e3,refetchInterval:8e3,refetchOnWindowFocus:!0})}function Rst(e,t){return $q(e,t,async()=>{const n=await Jr.status("surface_open");if(n.state==="ready"&&n.account_id!==t)throw new Error("Team Bridge status owner changed");return n})}function Vot(e,t=!0,n){const s=Gt();return Nn({queryKey:is.directory(e??"none",n??"unresolved-owner"),queryFn:()=>Cu(s,n,()=>Jr.directory(e)),enabled:t&&!!n&&!!e,staleTime:3e4,refetchOnWindowFocus:!0,retry:1})}function Wot(e,t=!0,n){const s=Gt();return y5({queries:e.map(r=>({queryKey:is.directory(r,n??"unresolved-owner"),queryFn:()=>Cu(s,n,()=>Jr.directory(r)),enabled:t&&!!n,staleTime:3e4,refetchOnWindowFocus:!0,retry:1})),combine:r=>{const i={};return r.forEach((a,o)=>{a.data&&(i[e[o]]=a.data.members)}),i}})}function qq(e=!0){const t=Gt(),{accountId:n}=JF();return Nn({queryKey:is.statusFor(n),queryFn:()=>Rst(t,n),enabled:e&&!!n,staleTime:6e4,refetchOnWindowFocus:!0,retry:1})}function Kq(e,t=_u,n={}){const s=Gt();return Nn({queryKey:is.unread(t,n.accountId??"unresolved-owner"),queryFn:()=>Cu(s,n.accountId,()=>Jr.unread(zq(t))),enabled:e&&!!n.accountId,staleTime:3e4,refetchInterval:n.refetchInterval??Tst(),refetchIntervalInBackground:n.refetchIntervalInBackground,refetchOnWindowFocus:!0,retry:1})}async function Yq(e,t,n,s=()=>!0){s()&&(await e.invalidateQueries({queryKey:is.messages(t,n)}),s()&&(await e.invalidateQueries({queryKey:is.conversationsPrefix}),s()&&await e.invalidateQueries({queryKey:is.unreadPrefix})))}function $ot(e,t){const n=Gt(),s=qv(),r=Mn({mutationFn:({input:i,target:a})=>(a.assertCurrent(),Jr.send(a.conversationId,{...i,tenantId:a.tenantId,expectedAccountId:a.accountId})),onSuccess:(i,{target:a})=>Yq(n,a.conversationId,a.tenantId,a.isCurrent)});return ty(r,()=>({...s,conversationId:e,tenantId:t}))}function zot(e,t){const n=Gt(),s=qv(),r=Mn({mutationFn:({target:i})=>(i.assertCurrent(),Jr.join(i.conversationId,i.tenantId,i.accountId)),onSuccess:(i,{target:a})=>Yq(n,a.conversationId,a.tenantId,a.isCurrent)});return ty(r,()=>({...s,conversationId:e,tenantId:t}))}function Ast(e,t){const n=v0(e).accountId,s=()=>Wq(e,n)&&(t?.()??!0),r=()=>{if(!s())throw new Error("Team Bridge write authority changed")},i={queryKey:is.conversationsPrefix,predicate:a=>a.queryKey.at(-1)===n&&a.queryKey.at(-2)==="account"};return{mutationFn:({conversationId:a,notify:o,tenantId:l})=>(r(),Jr.setNotify(a,o,l,n)),onMutate:async({conversationId:a,notify:o,tenantId:l})=>{r(),await e.cancelQueries(i),r();const u=e.getQueriesData(i);return e.setQueriesData(i,d=>d===void 0?d:lst(d,a,o,l)),{snapshots:u}},onError:(a,o,l)=>{if(s())for(const[u,d]of l?.snapshots??[])e.setQueryData(u,d)},onSettled:async()=>{s()&&(await e.invalidateQueries(i),s()&&await e.invalidateQueries({queryKey:is.unreadPrefix}))}}}function qot(){const e=Gt(),t=qv();return Mn(Ast(e,t.isCurrent))}function Kot(e,t){const n=Gt(),s=qv(),r=Mn({mutationFn:({input:i,target:a})=>(a.assertCurrent(),Jr.markRead(a.conversationId,{...i,tenantId:a.tenantId,expectedAccountId:a.accountId})),onSuccess:async(i,{target:a})=>{a.isCurrent()&&(await n.invalidateQueries({queryKey:is.conversationsPrefix}),a.isCurrent()&&await n.invalidateQueries({queryKey:is.unreadPrefix}))}});return ty(r,()=>({...s,conversationId:e,tenantId:t}))}function Yot(e,t=()=>!0){const n=Gt(),s=qv(),r=Mn({mutationFn:({input:i,target:a})=>{if(a.assertCurrent(),!a.isCurrent())throw new Error("Team Bridge write authority changed");return Jr.startConversation({...i,tenantId:a.tenantId,expectedAccountId:a.accountId})},onSuccess:async(i,{target:a})=>{a.isCurrent()&&await n.invalidateQueries({queryKey:is.conversationsPrefix})}});return ty(r,()=>({...s,conversationId:"",tenantId:e,isCurrent:()=>s.isCurrent()&&t()}))}const Fst="display.notifications";function Dst(){return{untitled:p("ui.teamBridge.list.untitled"),directMessage:p("ui.teamBridge.kind.dm"),group:p("ui.teamBridge.kind.group"),channel:e=>p("ui.teamBridge.notify.channel",{channel:e}),subtitle:(e,t)=>p("ui.teamBridge.notify.subtitle",{place:e,organization:t}),count:e=>p("ui.teamBridge.notify.count",{count:e}),countPreview:(e,t)=>p("ui.teamBridge.notify.count_preview",{count:e,preview:t}),fallback:p("ui.teamBridge.notify.body_fallback")}}function Ist(e){return e.kind==="dm"?{kind:"dm"}:{kind:e.kind,name:e.name}}async function Pst(e,t,n){try{return(await e.fetchQuery({queryKey:is.directory(t,n),queryFn:()=>Cu(e,n,()=>Jr.directory(t)),staleTime:3e4,retry:!1})).members}catch{return[]}}async function Nst(e,t,n,s){if(!s())return;let r=t.senderLabel,i=null;const a=void 0;try{const u=a?Sst(await Jr.listReplies(t.conversationId,a,{tenantId:t.tenantId,afterSeq:t.seq,limit:1}),{tenantId:t.tenantId,conversationId:t.conversationId,rootId:a}).replies.find(d=>d.seq===t.seq):(await Jr.listMessages(t.conversationId,{tenantId:t.tenantId,limit:1})).messages[0];if(u&&u.seq>=t.seq){if(u.sender.kind==="human"&&u.sender.account_id===n||!s())return;const d=await Pst(e,t.tenantId,n);r=mst(u.sender,d,(h,f)=>p("ui.teamBridge.chief.label",{agent:h,person:f})),i=ist(u.body)}}catch{}const o=window.api?.desktop?.teamBridge;if(!o)return;const l=ast({senderLabel:r,conversationName:t.conversationName,place:Ist(t),organizationName:t.organizationName,preview:i,unreadCount:t.unreadCount},Dst());s()&&await o.notify({conversationId:t.conversationId,tenantId:t.tenantId,seq:t.seq,title:l.title,subtitle:l.subtitle,body:l.body,viewing:kst()===t.conversationId}).catch(()=>{})}function Mst(e){const t=!!window.api?.desktop?.teamBridge,n=JF(),s=qq(e&&t),r=n.accountId,a=e&&t&&!!r&&s.data?.account_id===r&&s.data?.state==="ready"&&s.data.local.enabled&&!s.data.read_only,o=Gt(),l=wnt({enabled:a}),u=ns(),d=Et(u.data,"settings"),h=Nn({...C6(),enabled:a&&d}),f=d&&ese(h.data?.settings,Fst)===!1,g=m.useRef(f);g.current=f;const v=m.useRef(r);v.current=r;const b=m.useRef(a);b.current=a,m.useEffect(()=>(b.current=a,()=>{b.current=!1}),[a]);const x=l.data,w=Kq(a,_u,{accountId:r,refetchInterval:Xg,refetchIntervalInBackground:!0}),_=m.useMemo(()=>xst(w.data),[w.data]),C=y5({queries:_.map(L=>{const V=L.tenant_id;return{queryKey:is.unread(V,r??"unresolved-owner"),queryFn:()=>Cu(o,r,()=>Jr.unread({tenantId:V})),enabled:a,staleTime:Xg,refetchInterval:Xg,refetchIntervalInBackground:!0,refetchOnWindowFocus:!0,retry:1}})}),S=C.map(L=>`${L.status}:${L.dataUpdatedAt}`).join("|"),y=m.useRef(C);y.current=C;const R=m.useRef(_);R.current=_;const E=Nn({queryKey:is.conversations(_u,r??"unresolved-owner"),queryFn:()=>Cu(o,r,()=>Jr.listConversations("account")),enabled:a,staleTime:Xg,refetchInterval:Xg,refetchIntervalInBackground:!0,refetchOnWindowFocus:!0,retry:1}),F=m.useRef(new Map),A=m.useRef(new Set),I=m.useRef(void 0),P=m.useRef(null),N=[S,w.dataUpdatedAt,E.dataUpdatedAt,(x?.memberships??[]).map(L=>`${L.tenant_id}:${L.tenant_name}`).join(","),r??""].join("#");m.useEffect(()=>{const L=I.current;I.current=r,L!==r&&L!==void 0&&(F.current=new Map,A.current=new Set,P.current=null,o.invalidateQueries({queryKey:is.unreadPrefix}),o.invalidateQueries({queryKey:is.conversationsPrefix}))},[r,o]),m.useEffect(()=>{if(P.current===N||(P.current=N,!w.data))return;for(const J of w.data.organizations??[])J.unread===0&&!A.current.has(J.tenant_id)&&A.current.add(J.tenant_id);if(!E.data)return;const L=y.current,V=R.current,B=dst(x?.memberships??[],w.data.organizations,w.data.organizations??null);let ne=F.current;for(let J=0;J<V.length;J+=1){const Q=V[J],G=L[J]?.data;if(!G)continue;const oe=(G.conversations??[]).map(q=>({conversation_id:q.conversation_id,tenant_id:Q.tenant_id,unread_count:q.unread_count,last_read_seq:q.last_read_seq,latest_seq:q.latest_seq})),ce=yst({conversations:E.data.conversations,rows:oe,organizations:B,selfAccountId:r,cursors:ne,seeded:A.current.has(Q.tenant_id)});if(ne=ce.cursors,ce.seeded&&A.current.add(Q.tenant_id),g.current||!r)continue;const M=r,W=BI(o),j=o.getQueryData(is.statusFor(M));for(const q of ce.candidates)Nst(o,q,M,()=>v.current===M&&BI(o)===W&&o.getQueryData(is.statusFor(M))===j&&b.current&&!g.current)}F.current=ne},[N,w.data,E.data,x,r,o])}function Ost(){const{data:e}=ns();m.useEffect(()=>{e&&kse(e)},[e]);const t=WR(),n=Gt(),s=m.useRef(null);m.useEffect(()=>{const r=t.configChange;if(!r)return;const i=`${r.epoch}:${r.seq}`;s.current!==i&&r.changedKeys.includes(Yo)&&(s.current=i,n.invalidateQueries({queryKey:il.capabilities}),n.invalidateQueries({queryKey:il.settings}),!tse()&&oo(p("ui.settings.language.external_notice",{language:r.language}),{id:"i18n-language-external"}))},[t.configChange,n])}function Lst(e,t){if(e.defaultPrevented||e.repeat||e.isComposing||!(e.metaKey||e.ctrlKey))return null;const n=nse(e);if(n===null)return null;const s=dQ(t.bindings).get(n);return s===void 0||ER(e.target)||!_pe(Xq(s),t.route)?null:s}const Xq=e=>e.slice(6);function Bst(e){const t=De.getState(),n=t.activeDraftKey?t.drafts[t.activeDraftKey]:void 0,s=vv(t.activeDraftKey,n?.sessionId,t.activeSessionId)??null;_d(Xq(e),{sessionId:s,askScope:s===null?"fleet":"session",via:"chord"})}function jst(){m.useEffect(()=>{const e=t=>{const n=st.getState(),s=Lst(t,{bindings:n.shortcutBindings,route:n.rightSlotRoute});s!==null&&(t.preventDefault(),Bst(s))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[])}const Hst=""+new URL("radient-icon-1024x1024-D_JJedvo.png",import.meta.url).href,Qq=Vp()(Xj(e=>({hasBeenNotified:!1,setHasBeenNotified:t=>{e({hasBeenNotified:t})}}),{name:"low-credits-storage"})),Ust=({open:e,onClose:t,onGoToConsole:n})=>{Qe();const{setHasBeenNotified:s}=Qq(),{prices:r,isLoading:i,error:a}=sse(),o=d=>typeof d!="number"?"$...":p("ui.common.account.low_credits_dialog.detail",{detail:String(d.toFixed(2))}),l=()=>{s(!0),t()},u=()=>{s(!0),n()};return c.jsx(Su,{open:e,onClose:l,title:c.jsxs(c.Fragment,{children:[c.jsx("img",{src:Hst,alt:p("ui.common.account.low_credits_dialog.radient_icon"),className:"size-7"}),p("ui.common.account.low_credits_dialog.running_low_on_radient_credits")]}),maxWidth:"sm",fullWidth:!1,actions:c.jsxs(c.Fragment,{children:[c.jsx(bv,{onClick:l,children:p("ui.common.account.low_credits_dialog.maybe_later")}),c.jsx(xv,{onClick:u,startIcon:c.jsx($c,{size:18}),className:"min-w-55",children:p("ui.common.account.low_credits_dialog.get_more_credits")})]}),children:c.jsxs("div",{className:"flex flex-col items-center gap-4 py-2 text-center",children:[c.jsxs("p",{className:"text-body-sm text-ink-muted",children:[p("ui.common.account.low_credits_dialog.unlock_the_full_power_of_local_operator_with")," ",c.jsx("span",{className:"font-bold text-accent",children:p("ui.common.account.low_credits_dialog.radient_pass")}),"."]}),c.jsx("p",{className:"text-body-sm text-ink-muted",children:p("ui.common.account.low_credits_dialog.radient_automatic_is_often_cheaper_than_bringing_your_own_key_its")}),c.jsx("p",{className:"text-body-sm text-ink-muted",children:p("ui.common.account.low_credits_dialog.it_s_pay_as_you_go_with_no_commitments_load_up_what_you_need_star")}),c.jsxs("p",{className:"text-body-sm text-ink-muted",children:[p("ui.common.account.low_credits_dialog.plus_get")," ",c.jsx("span",{className:"font-medium text-ink",children:i?c.jsx(An,{size:"sm",className:"me-0.5 align-middle"}):o(r?.default_registration_credits)})," ",p("ui.common.account.low_credits_dialog.in_bonus_credits_with_your_first_purchase"),a&&c.jsx("span",{className:"mt-1 block text-meta text-danger",children:p("ui.common.account.low_credits_dialog.could_not_load_bonus_credit_information")})]}),c.jsx("p",{className:"text-meta text-ink-dim",children:p("ui.common.account.low_credits_dialog.you_can_also_reach_the_radient_console_from_settings_at_any_time")})]})})},Gst=(e,t)=>t?gk(e.filter(n=>n.session_id===t)).length:0;function Vst(e){return De(t=>Gst(t.sessions,e))}const Wst=(e,t)=>t?e.some(n=>n.session_id===t&&n.status?.code==="busy"):!1;function $st(e){return De(t=>Wst(t.sessions,e))}const zst=[];function qst(){const{state:e}=fC(),t=e?.pendingConsent??zst,n=FH(s=>WN(t,s));return m.useEffect(()=>{t.length>0&&SA()},[t]),WN(t,n)}const Jq={approvals:["desktop","mesh","approvals"]},Kst=15e3,Yst=new Set(["requested","approved","connecting","failed"]);function Xst(e){return Yst.has(e)}function Qst(e){return e==="requested"}function Jst(e){return e.filter(t=>Qst(t.state)).length}function Xot(e){return e.state==="requested"&&e.canApproveHere!==!1&&(e.kind==="device"||e.kind==="machine")}function Qot(e){return Xst(e)}function Jot(e){switch(e){case"requested":return p("ui.mesh.mesh_approvals.waiting_for_you");case"approved":return p("ui.mesh.mesh_approvals.approved");case"connecting":return p("ui.mesh.mesh_approvals.connecting");case"connected":return p("ui.mesh.mesh_approvals.connected");case"denied":return p("ui.mesh.mesh_approvals.denied");case"expired":return p("ui.mesh.mesh_approvals.expired");case"failed":return p("ui.mesh.mesh_approvals.failed");default:return e}}function Vc(e){return typeof e=="object"&&e!==null}function Zst(e){const t=Vc(e)?e:{};return{deviceId:Gn(t.device_id),name:Gn(t.name),host:Gn(t.host),user:Gn(t.user),transport:Gn(t.transport),hostKeyFp:Gn(t.host_key_fp)}}function ert(e){const t=Vc(e)?e:{};return{connect:wy(t.connect,!1),install:wy(t.install,!1),anchor:Vc(t.anchor),networkId:Gn(t.network_id),role:Gn(t.role),unattended:wy(t.unattended,!1),grants:wk(t.grant)}}function trt(e){const t=Array.isArray(e)?e:e?.approvals??[];if(!Array.isArray(t))return[];const n=[];for(const s of t){if(!Vc(s))continue;const r=Gn(s.approval_id),i=Gn(s.state);if(!r||!i)continue;const a=Vc(s.what)&&Object.prototype.hasOwnProperty.call(s.what,"credential_inheritance"),o=Object.prototype.hasOwnProperty.call(s,"kind")?Gn(s.kind):void 0,l=a||o==="credential_inheritance"?"credential":o!==void 0&&!["device_onboard","local_authority"].includes(o)?"unknown":!Vc(s.device)&&Vc(s.machine)?"machine":"device",u=Vc(s.requested_by)?s.requested_by:{};n.push({approvalId:r,state:i,kind:l,summary:Gn(s.summary)||void 0,details:Array.isArray(s.details)&&s.details.every(d=>typeof d=="string")?s.details.slice():void 0,canApproveHere:Object.prototype.hasOwnProperty.call(s,"can_approve_here")?s.can_approve_here===!0:void 0,approveRemedy:Gn(s.approve_remedy)||void 0,where:Zst(l==="machine"?s.machine:s.device),what:ert(s.what),requestedBy:{surface:Gn(u.surface),sessionId:Gn(u.session_id),deviceId:Gn(u.device_id)},expiresAt:hQ(s.expires_at)})}return n}function nrt(e){return e.kind==="machine"?p("ui.mesh.mesh_approvals.this_machine"):xk({device_id:e.where.deviceId,name:e.where.name})}function Zot(e,t){if(e.kind==="credential"||e.kind==="unknown"||e.canApproveHere===!1){if(e.summary)return e.summary;if(e.kind==="credential"||e.kind==="unknown")return kj(e)}const n=kj(e),s=rrt(e,t).map(r=>r.clause);return s.length?p("ui.mesh.mesh_approvals.approval_title_with_clauses",{head:n,clauses:srt(s)}):p("ui.mesh.mesh_approvals.approval_title",{head:n})}function kj(e){return e.kind==="credential"?e.summary||p("ui.mesh.approval.credential_title"):e.kind==="unknown"?e.summary||p("ui.mesh.approval.unknown_title"):e.canApproveHere===!1&&e.summary?e.summary:e.kind==="machine"?p("ui.mesh.mesh_approvals.set_up_operator_authority_on_this_machine"):p("ui.mesh.mesh_approvals.onboard_subject",{subject:nrt(e)})}function srt(e){return e.length===1?e[0]:p("ui.mesh.mesh_approvals.join_clauses",{clauses:e.slice(0,-1).join(", "),last:e[e.length-1]})}function elt(e){if(e.kind==="credential"||e.kind==="unknown")return null;const{user:t,host:n,transport:s,name:r}=e.where,i=[n?t?`${t}@${n}`:n:"",s?p("ui.mesh.mesh_approvals.via_transport",{transport:s}):"",r&&r!==n?`(${r})`:""].filter(Boolean);return i.length?i.join(" "):null}function tlt(e){return e.kind==="credential"||e.kind==="unknown"?null:e.where.hostKeyFp||null}function nlt(e){const{surface:t,sessionId:n}=e.requestedBy,s=[t||"",n?p("ui.mesh.mesh_approvals.session_suffix",{suffix:n.slice(-6)}):""].filter(Boolean);return s.length?p("ui.mesh.mesh_approvals.asked_by",{requester:s.join(" · ")}):null}function rrt(e,t){if(e.kind==="credential"||e.kind==="unknown")return[];const{connect:n,install:s,anchor:r,networkId:i,role:a,unattended:o,grants:l}=e.what,u=[];if(n&&u.push({term:"connect",clause:e.where.transport?p("ui.mesh.mesh_approvals.connect_over",{transport:e.where.transport}):p("ui.mesh.mesh_approvals.connect_to_it"),consequence:e.where.transport?p("ui.mesh.mesh_approvals.may_connect_over",{transport:e.where.transport}):p("ui.mesh.mesh_approvals.this_machine_may_connect_to_it")}),s&&u.push({term:"install",clause:e.kind==="machine"?p("ui.mesh.mesh_approvals.install_local_operator"):p("ui.mesh.mesh_approvals.install_local_operator_there"),consequence:e.kind==="machine"?p("ui.mesh.mesh_approvals.local_operator_is_installed_on_this_machine"):p("ui.mesh.mesh_approvals.local_operator_is_installed_on_it")}),r&&u.push({term:p("ui.mesh.mesh_approvals.install_operator_anchor"),clause:p("ui.mesh.mesh_approvals.check_approvals_signed_on_your_machines"),consequence:p("ui.mesh.mesh_approvals.that_device_can_check_approvals_signed_on")}),i){const d=t?.get(i),h=p("ui.mesh.mesh_approvals.join_network",{network:d||i,role:a||"?"});u.push({term:h,clause:h,consequence:p("ui.mesh.mesh_approvals.joins_network",{network:d||i,role:a||"?"})})}o&&u.push({term:p("ui.mesh.mesh_approvals.trust_unattended_sessions"),clause:p("ui.mesh.mesh_approvals.run_sessions_there_without_an_approval_prompt"),consequence:p("ui.mesh.mesh_approvals.sessions_you_start_on_that_device_run")});for(const d of irt(l,o)){const h=art()[d];u.push({term:h?.term??p("ui.mesh.mesh_approvals.grant_capability",{grant:d}),clause:ort()[d]??p("ui.mesh.mesh_approvals.use_capability",{grant:d}),consequence:h?.gloss??p("ui.mesh.mesh_approvals.may_use_capability",{grant:d})})}return u}function irt(e,t){const n=new Set;for(const s of e){const r=String(s??"").trim();r&&(t&&r==="unattended"||n.add(r))}return[...n]}const art=()=>({unattended:{term:p("ui.mesh.mesh_approvals.trust_unattended_sessions"),gloss:p("ui.mesh.mesh_approvals.sessions_you_start_on_that_device_run")},broker_credential:{term:p("ui.mesh.mesh_approvals.borrow_logins_there"),gloss:p("ui.mesh.mesh_approvals.your_sessions_may_use_the_logins_stored")}}),ort=()=>({list:p("ui.mesh.mesh_approvals.see_its_sessions"),view:p("ui.mesh.mesh_approvals.watch_a_session_there"),prompt:p("ui.mesh.mesh_approvals.send_prompts_to_a_session_there"),steer:p("ui.mesh.mesh_approvals.steer_a_running_turn_there"),stop:p("ui.mesh.mesh_approvals.stop_a_session_there"),slash:p("ui.mesh.mesh_approvals.run_slash_commands_there"),delete:p("ui.mesh.mesh_approvals.archive_or_delete_a_session_there"),move:p("ui.mesh.mesh_approvals.move_sessions_to_or_from_there"),broker_credential:p("ui.mesh.mesh_approvals.borrow_the_logins_stored_there"),approve:p("ui.mesh.mesh_approvals.answer_approval_prompts_there"),unattended:p("ui.mesh.mesh_approvals.run_sessions_there_without_an_approval_prompt")});function slt(e,t){if(e===null||e<=0)return null;const n=e-t;if(n<=0)return null;if(n<60)return p("ui.mesh.mesh_approvals.expires_in_under_a_minute");const s=Math.ceil(n/60);if(s<90)return p("ui.mesh.mesh_approvals.expires_minutes",{count:s});const r=Math.ceil(s/60);return p("ui.mesh.mesh_approvals.expires_hours",{count:r})}function lrt(e,{poll:t=!0}={}){return Nn({queryKey:Jq.approvals,enabled:e,queryFn:async()=>trt(await at({op:"approvals.list"})),retry:!1,staleTime:t?1e4:Number.POSITIVE_INFINITY,refetchInterval:e&&t?Kst:!1,refetchOnWindowFocus:t})}function rlt(){const e=Gt();return Mn({mutationFn:async t=>{const n=t.decision==="approve"?{op:"approvals.approve",approvalId:t.approvalId}:{op:"approvals.deny",approvalId:t.approvalId};await at(n)},onSettled:()=>{e.invalidateQueries({queryKey:Jq.approvals}),e.invalidateQueries({queryKey:nc.networks}),e.invalidateQueries({queryKey:nc.peers})}})}function ilt(e){const t=e?.message;return typeof t=="string"&&t.trim()?t.trim():p("ui.mesh.mesh_approvals.the_approvals_could_not_be_read")}function alt(e){const t=e;return{code:Gn(t?.code)||"approval_refused",sentence:Gn(t?.message)||p("ui.mesh.mesh_approvals.decision_could_not_be_answered")}}const crt="/team-bridge",urt="nav-team-bridge",drt="nav-team-bridge-badge";function hrt(e){const{accountId:t}=JF(),n=qq(e),s=e&&!!t&&n.data?.account_id===t,r=Kq(s,_u,{accountId:t});if(!e)return null;const i=s&&r.data?cst(r.data):0;return{icon:k0,label:p("ui.teamBridge.nav.label"),path:crt,tourTag:urt,attention:i,attentionTag:drt,attentionName:a=>p("ui.teamBridge.nav.unread",{count:a})}}const gR={aida:"visible",library:"visible",projects:"visible",agents:"visible",schedules:"visible",browser:"visible","team-bridge":"more","agent-hub":"more",mesh:"more"},I_={visible:u0.filter(e=>gR[e]==="visible"),more:u0.filter(e=>gR[e]==="more")},Ej=new Map(u0.map((e,t)=>[e,t])),frt=new Set(u0);function prt(e){return typeof e=="string"&&frt.has(e)}function ok(e,t){if(e===t)return!0;if(e.visible.length!==t.visible.length||e.more.length!==t.more.length)return!1;for(let n=0;n<e.visible.length;n+=1)if(e.visible[n]!==t.visible[n])return!1;for(let n=0;n<e.more.length;n+=1)if(e.more[n]!==t.more[n])return!1;return!0}function Za(e,t){return e.visible.includes(t)?"visible":"more"}function $x(e,t,n){return e[t].filter(s=>n.has(s))}function grt(e,t,n,s){if(!s.has(t))return null;const r=Za(e,t),i=$x(e,r,s),a=i.indexOf(t);if(a<0)return null;const o=a+n;if(o<0||o>=i.length)return null;const l=i[o],u=e[r],d=u.indexOf(t),h=u.indexOf(l);if(d<0||h<0)return null;const f=u.slice();f[d]=l,f[h]=t;const g={visible:e.visible.slice(),more:e.more.slice()};return g[r]=f,g}function Tj(e,t,n){const s={visible:e.visible.filter(r=>r!==t),more:e.more.filter(r=>r!==t)};return{...s,[n]:[...s[n],t]}}function mrt(e,t,n,s,r){if(s===t)return{visible:e.visible.slice(),more:e.more.slice()};if(s!==null&&(!r.has(s)||!e[n].includes(s)))return null;const i={visible:e.visible.filter(l=>l!==t),more:e.more.filter(l=>l!==t)},a=i[n].slice(),o=s===null?a.length:a.indexOf(s);return o<0?null:(a.splice(o,0,t),{...i,[n]:a})}function Rj(e,t){for(const n of u0){if(gR[n]!==t||e.visible.includes(n)||e.more.includes(n))continue;const s=Ej.get(n)??0,r=e[t];let i=-1,a=-1,o=-1,l=Number.POSITIVE_INFINITY;for(let d=0;d<r.length;d+=1){const h=Ej.get(r[d])??0;h<s&&h>a&&(a=h,i=d),h>s&&h<l&&(l=h,o=d)}const u=i>=0?i+1:o>=0?o:r.length;r.splice(u,0,n)}}function mR(e){const t={visible:[],more:[]},n=new Set;if(e&&typeof e=="object"){const s=e;for(const r of["visible","more"]){const i=s[r];if(Array.isArray(i))for(const a of i)prt(a)&&(n.has(a)||(n.add(a),t[r].push(a)))}}return Rj(t,"visible"),Rj(t,"more"),t}const gf={layout:["desktop","sidebar_layout"]};async function vrt(){const e=await at({op:"sidebar_layout.get"});return mR(e.layout)}function brt(e){const t=Gt(),n=Nn({queryKey:gf.layout,enabled:e,queryFn:vrt,staleTime:Number.POSITIVE_INFINITY,retry:pv}),s=m.useRef(0),r=Mn({scope:{id:"sidebar-layout"},mutationFn:async u=>{const d=await at({op:"sidebar_layout.set",layout:u});return mR(d.layout)},retry:fQ,onMutate:async u=>{const d=++s.current;await t.cancelQueries({queryKey:gf.layout});const h=t.getQueryData(gf.layout);return t.setQueryData(gf.layout,u),{previous:h,seq:d}},onError:(u,d,h)=>{h?.seq===s.current&&h.previous&&t.setQueryData(gf.layout,h.previous),sn(p("ui.shell.sidebar_navigation.save_failed"))},onSettled:(u,d,h,f)=>{f?.seq===s.current&&t.invalidateQueries({queryKey:gf.layout})}}),i=e&&n.data!==void 0;return{layout:i?n.data:I_,canCustomise:i,save:u=>{i&&r.mutate(u)},reset:()=>{i&&r.mutate(mR(I_))}}}const Aj=e=>{const t=ase(e.type),n=typeof e.percent=="number"?`, ${Math.round(e.percent)}%`:"";return p("ui.common.updates.update_foot_icon.in_progress",{subject:t,percent:n})},Zq=e=>ise({type:e.type,version:e.offer.version}),xrt=e=>{const t=e.map(s=>Zq(s)),n=t.slice(1).reduce((s,r)=>p("ui.common.updates.update_foot_icon.subject_join",{left:s,right:`${r.charAt(0).toLowerCase()}${r.slice(1)}`}),t[0]);return p("ui.common.updates.update_foot_icon.available_show_the_update_notice",{joined:n})},wrt=({surfaces:e,inflight:t,onShow:n,onDismiss:s})=>{if(Qe(),t===null&&e.length===0)return null;if(t!==null)return c.jsx(gt,{side:"top",collisionPadding:8,content:Aj(t),children:c.jsx("output",{"data-update-foot-icon":"","data-update-foot-icon-state":"inflight","aria-label":Aj(t),className:"flex size-8 shrink-0 items-center justify-center text-accent",children:c.jsx(qr,{className:"size-4 shrink-0 motion-safe:animate-spin","aria-hidden":"true"})})});const r=e.find(i=>(i.offer.summary??"").trim()!=="");return c.jsx(gt,{side:"top",collisionPadding:8,content:c.jsxs("div",{className:"flex max-w-64 flex-col gap-0.5",children:[e.map(i=>c.jsxs("span",{className:"truncate text-ink",children:[Zq(i)," ",p("ui.common.updates.update_foot_icon.available")]},i.type)),r?c.jsx("span",{className:"truncate text-ink-muted",children:(r.offer.summary??"").trim()}):null,c.jsx("span",{className:"whitespace-nowrap text-ink-muted",children:p("ui.common.updates.update_foot_icon.show_the_update_notice")})]}),children:c.jsx("button",{type:"button","data-update-foot-icon":"","data-update-foot-icon-state":"available","aria-label":xrt(e),onClick:n,onKeyDown:i=>{i.key!=="Escape"||!s||(i.stopPropagation(),s())},className:T("flex size-8 shrink-0 items-center justify-center rounded-sm text-accent","transition-colors duration-fast ease-out-quart","hover:bg-row-hover hover:text-ink"),children:c.jsx(VR,{className:"size-4 shrink-0","aria-hidden":"true"})})})},Fj=()=>{const e=dr(g=>g.followed),t=dr(g=>g.running),n=dr(g=>g.offers),s=dr(g=>g.detailOpen),r=dr(g=>g.inflight),i=dr(g=>g.downloadPercent),a=dr(g=>g.openNotice),o=dr(g=>g.noticeOpen),l=dr(g=>g.dismissNotice),u=m.useMemo(()=>{const g={followed:e,running:t,offers:n,detailOpen:s};return p6.filter(v=>rse(g,v)).map(v=>{const b=n[v];return b?{type:v,offer:b}:null}).filter(v=>v!==null)},[e,t,n,s]),d=m.useMemo(()=>r[_n.BACKEND]?{type:_n.BACKEND,percent:null}:r[_n.UI]?{type:_n.UI,percent:i[_n.UI]}:null,[r,i]),h=m.useCallback(()=>a(),[a]),f=m.useCallback(()=>l(),[l]);return c.jsx(wrt,{surfaces:u,inflight:d,onShow:h,onDismiss:o?f:void 0})},Dj=({expanded:e})=>(Qe(),c.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[c.jsx(S6,{className:"size-6",label:e?void 0:p("ui.shell.collapsible_app_logo.local_operator")}),e&&c.jsx("span",{className:"truncate font-semibold text-body text-ink",children:p("ui.shell.collapsible_app_logo.local_operator")})]})),vR=nt.memo(({expanded:e,useAuth:t=!1})=>{const n=AR(),s=xi(),{user:r,isAuthenticated:i,accountRead:a,signOut:o}=YR(),l=a==="checking"?p("ui.shell.user_profile_sidebar.checking_account"):jI(a)?p("ui.shell.user_profile_sidebar.account_unavailable"):null,u=r?.name??l??p("ui.shell.user_profile_sidebar.user"),d=jI(a),h=r?.email??"",f=d?p("ui.shell.user_profile_sidebar.reconnect_radient"):h,g=d?"/settings?section=providers&provider=radient":"/settings",v=d?p("ui.shell.user_profile_sidebar.reconnect_radient"):p("ui.shell.user_profile_sidebar.account_settings"),b=m.useCallback(async()=>{i&&(await o(),window.location.reload())},[i,o]),x=m.useMemo(()=>{const C=r?.name;return C?C.split(" ").map(S=>S.charAt(0)).join("").toUpperCase().substring(0,2):null},[r?.name]),w=c.jsxs("button",{type:"button",onClick:t?void 0:()=>s(g),"aria-label":e?void 0:v,className:T("flex w-full min-w-0 items-center gap-2 rounded-sm transition-colors duration-fast ease-out-quart hover:bg-row-hover",e?"px-2 py-1.5":"justify-center py-1.5"),children:[c.jsx(Wj,{className:"size-7 shrink-0",children:c.jsx($j,{className:"border border-control bg-elevated text-ink",children:x??c.jsx(Yle,{size:14,"aria-hidden":"true"})})}),e&&u&&c.jsxs("span",{className:"min-w-0 text-start",children:[c.jsx("span",{className:"block truncate text-body-sm text-ink",children:u}),f&&c.jsx("span",{className:T("block truncate text-meta",d?"text-accent":"text-ink-dim"),children:f})]})]}),_=e?w:c.jsx(vd,{content:v,side:n==="rtl"?"left":"right",children:w});return t?c.jsxs(La,{children:[e?c.jsx(sa,{asChild:!0,children:w}):c.jsx(vd,{content:v,side:n==="rtl"?"left":"right",children:c.jsx(sa,{asChild:!0,children:w})}),c.jsxs(Ba,{align:"end",side:"top",className:"min-w-50",children:[d?c.jsxs(Ot,{onSelect:()=>s(g),children:[c.jsx(Uj,{size:16,"aria-hidden":"true"}),p("ui.shell.user_profile_sidebar.reconnect_radient")]}):null,c.jsxs(Ot,{onSelect:()=>s("/settings"),children:[c.jsx(Yc,{size:16,"aria-hidden":"true"}),p("ui.shell.user_profile_sidebar.settings")]}),c.jsxs(Ot,{children:[c.jsx(xle,{size:16,"aria-hidden":"true"}),p("ui.shell.user_profile_sidebar.privacy_and_security")]}),c.jsx(Js,{}),c.jsxs(Ot,{onSelect:b,className:"text-danger focus:bg-danger-wash focus:text-danger",children:[c.jsx(Uoe,{size:16,"aria-hidden":"true"}),p("ui.shell.user_profile_sidebar.sign_out")]})]})]}):_});vR.displayName="UserProfileSidebar";const _rt=()=>{const e=WR(),t=ns(),n=De(u=>u.setCataloguePageable),s=De(u=>u.setCatalogueActivityHead),r=De(u=>u.fetchSessions),i=Et(t.data,"session_catalogue_page"),a=Et(t.data,"session_catalogue_sort");m.useEffect(()=>{n(i)},[i,n]),m.useEffect(()=>{s(a)},[a,s]);const o=Yr(t.data,"session_catalogue",2)==="enabled",l=m.useCallback(()=>r(i?o6:B_,i),[r,i]);return m.useEffect(()=>{o&&l()},[o,l,e.catalogueRevision]),null},Ij="flex h-[30px] w-full items-center gap-2 rounded-md px-2 text-body-sm transition-colors duration-fast ease-out-quart",Crt=()=>{Qe();const e=AR()==="rtl",t=xi(),n=Oue(),{expanded:s,onCollapse:r}=ose(),i=st(ae=>ae.openCommandPalette),a=ns(),o=hrt(Et(a.data,"team_bridge_conversations")),l=De(ae=>ae.activeSessionId),u=qst(),d=Yr(a.data,"peers")==="enabled",h=PA(d),f=Yr(a.data,"approvals")==="enabled",g=lrt(h==="member"&&f,{poll:!0}),v=Jst(g.data??[]),b=Et(a.data,"projects",1),x=Et(a.data,"library",1),w=st(ae=>ae.sidebarOverflowExpanded),_=st(ae=>ae.setSidebarOverflowExpanded),C=Et(a.data,"aida",1),S=Sv(C),y=C&&S.data?.enabled===!0,R=S.data?.name??"Aida",E=ehe(),F=Vst(S.data?.session_id),A=$st(S.data?.session_id),I=()=>{E(t,S.data).catch(ae=>sn(_f(ae)))},P=new Map;y&&P.set("aida",{icon:zae,label:R,path:"/chat",isActive:n==="chat"&&!!S.data?.session_id&&l===S.data?.session_id,tourTag:"nav-item-aida",onSelect:I,attention:F,attentionTag:"nav-aida-badge",attentionName:ae=>p("ui.shell.sidebar_navigation.aida_missed",{name:R,count:ae}),working:A,workingName:p("ui.shell.sidebar_navigation.aida_working",{name:R})}),x&&P.set("library",{icon:Aoe,label:p("ui.library.page.title"),path:"/library",isActive:n==="library",tourTag:"nav-item-library"}),b&&P.set("projects",{icon:B8,label:p("ui.shell.sidebar_navigation.projects"),path:"/projects",isActive:n==="projects",tourTag:"nav-item-projects"}),P.set("agents",{icon:hu,label:p("ui.shell.sidebar_navigation.agents"),path:"/agents",isActive:n==="agents",tourTag:"nav-item-agents"}),P.set("schedules",{icon:O8,label:p("ui.shell.sidebar_navigation.schedules"),path:"/schedules",isActive:n==="schedules",tourTag:"nav-item-schedules"}),P.set("browser",{icon:du,label:p("ui.shell.sidebar_navigation.browser"),path:"/browser",isActive:n==="browser",tourTag:"nav-item-browser",attention:u,attentionTag:"nav-browser-badge",attentionName:ae=>p("ui.shell.sidebar_navigation.browser_waiting",{count:ae,countText:String(ae)})}),o&&P.set("team-bridge",{...o,isActive:n==="team-bridge"}),P.set("agent-hub",{icon:$8,label:p("ui.shell.sidebar_navigation.agent_hub"),path:"/agent-hub",isActive:n==="agent-hub",tourTag:"nav-item-agent-hub"}),h==="member"&&P.set("mesh",{icon:l5,label:p("ui.shell.sidebar_navigation.mesh"),path:"/mesh",isActive:n==="mesh",tourTag:"nav-item-mesh",attention:v,attentionTag:"nav-mesh-badge",attentionName:ae=>p("ui.shell.sidebar_navigation.mesh_waiting",{count:ae,countText:String(ae)})});const N=new Set(P.keys()),L=Et(a.data,"sidebar_layout",1),{layout:V,canCustomise:B,save:ne,reset:J}=brt(L),Q=B?V:I_,G=$x(Q,"visible",N),oe=$x(Q,"more",N),[ce,M]=m.useState(!1),W=w||ce||oe.some(ae=>P.get(ae)?.isActive),[j,q]=m.useState(""),[U,fe]=m.useState(null),ye=m.useRef(new Map),Ae=ae=>{requestAnimationFrame(()=>ye.current.get(ae)?.focus())},[z,Te]=m.useState(null),[H,ve]=m.useState(null),Fe=m.useRef(null),ie=m.useRef(null),re=m.useRef(null),ue=m.useRef(0),ke=m.useRef(0),Oe=m.useRef(null),he=m.useRef(null),Ee=m.useRef(!1),Ze=ae=>{const te=Fe.current;return te===null?[]:Array.from(te.querySelectorAll("[data-sidebar-row]")).filter(me=>me.dataset.sidebarRow!==ae).map(me=>{const xe=me.getBoundingClientRect();return{id:me.dataset.sidebarRow??"",top:xe.top,bottom:xe.bottom}})},Tt=(ae,te)=>{const me=Fe.current;if(me===null)return null;const xe=me.getBoundingClientRect(),Le=Ze(te),Ke=Re=>Le.filter(Ye=>Za(Q,Ye.id)===Re);let ct=null;if(ae.kind==="more"){const Re=Ke("more").at(-1);if(Re)ct=Re.bottom;else{const Ye=me.querySelector("[data-sidebar-more]");ct=Ye?Ye.getBoundingClientRect().bottom:xe.top+2}}else if(ae.kind==="band"){const Re=Za(Q,te),kt=Ke(Re==="more"?"visible":"more").at(-1);if(kt)ct=kt.bottom;else if(Re==="more"){const Vt=me.querySelector("[data-sidebar-more]");ct=Vt?Vt.getBoundingClientRect().top:xe.top+2}}else{const Re=Le[ae.slot];Re?ct=Re.top:ct=Le.at(-1)?.bottom??xe.top+2}return ct===null?null:Math.round(ct-xe.top+me.scrollTop)},St=()=>{he.current!==null&&(window.clearTimeout(he.current),he.current=null)},Ve=(ae,te)=>{const me=ie.current;if(me===null||!me.armed)return;const xe=document.elementFromPoint(ae,te),Le=!!xe?.closest("[data-sidebar-more]"),Ke=!!xe?.closest("[data-sidebar-drop-band]");let ct;if(Le)ct={kind:"more"},Za(Q,me.id)==="visible"&&!W&&he.current===null&&(he.current=window.setTimeout(()=>{he.current=null,M(!0),requestAnimationFrame(()=>$e.current(ue.current,ke.current))},400));else if(St(),Ke)ct={kind:"band"};else{const Re=Ze(me.id),Ye=yz(Re,me.id,te),kt=Re[Ye];let Vt="visible";if(kt)Vt=Za(Q,kt.id);else{const hn=Re.at(-1);Vt=hn?Za(Q,hn.id):"visible"}ct={kind:"slot",slot:Ye,beforeId:kt?.id??null,region:Vt}}re.current=ct,ve(Tt(ct,me.id))},$e=m.useRef(Ve);$e.current=Ve;const ft=()=>{Oe.current!==null&&(cancelAnimationFrame(Oe.current),Oe.current=null)},pe=()=>{Oe.current=null;const ae=ie.current,te=Fe.current;if(ae===null||!ae.armed||te===null)return;const me=te.getBoundingClientRect(),xe=ke.current,Le=te.scrollHeight-te.clientHeight;let Ke=0;xe-me.top<24&&te.scrollTop>0?Ke=-1:me.bottom-xe<24&&te.scrollTop<Le&&(Ke=1),Ke!==0&&(te.scrollTop+=Ke*8,$e.current(ue.current,xe)),Oe.current=requestAnimationFrame(pe)},et=(ae,te)=>{if(B&&te.button===0&&!(te.altKey||te.ctrlKey||te.metaKey||te.shiftKey)){try{te.currentTarget.setPointerCapture(te.pointerId)}catch{}ie.current={pointerId:te.pointerId,id:ae,armed:!1,startX:te.clientX,startY:te.clientY},ue.current=te.clientX,ke.current=te.clientY}},tt=ae=>{const te=ie.current;if(!(te===null||te.pointerId!==ae.pointerId)){if(ue.current=ae.clientX,ke.current=ae.clientY,!te.armed){if(Math.hypot(ae.clientX-te.startX,ae.clientY-te.startY)<5)return;te.armed=!0,Ee.current=!0,Te(te.id);const me=P.get(te.id);me&&q(p("ui.shell.sidebar_navigation.drag_armed",{name:me.label})),Oe.current===null&&(Oe.current=requestAnimationFrame(pe))}Ve(ae.clientX,ae.clientY)}},Ft=(ae,te)=>{if(te.kind==="slot")return mrt(Q,ae,te.region,te.beforeId,N);const me=Za(Q,ae),xe=te.kind==="more"?"more":me==="more"?"visible":"more";return Tj(Q,ae,xe)},$t=(ae,te)=>{const me=P.get(ae);if(me===void 0)return;const xe=Ft(ae,te);if(xe===null||ok(xe,Q))return;const Le=Za(xe,ae);if(Le==="more"&&_(!0),ne(xe),te.kind==="slot"){Dt(xe,ae);return}q(Le==="more"?p("ui.shell.sidebar_navigation.move_to_more_note",{name:me.label}):p("ui.shell.sidebar_navigation.show_in_sidebar_note",{name:me.label}))},Dt=(ae,te)=>{const me=P.get(te),xe=Za(ae,te),Le=$x(ae,xe,N);q(p("ui.shell.sidebar_navigation.move_note",{name:me?.label??"",position:String(Le.indexOf(te)+1),total:String(Le.length)}))},Nt=(ae,te=!1)=>{const me=ie.current;if(me===null)return;ie.current=null,ft(),St();const xe=re.current;if(re.current=null,Te(null),ve(null),M(!1),!!me.armed){if(!ae){if(te){Ee.current=!1,q("");return}const Le=()=>{Ee.current=!1},Ke=()=>{window.setTimeout(Le,0)},ct=()=>{window.removeEventListener("pointerup",Re,!0),window.removeEventListener("pointercancel",Ye,!0),window.removeEventListener("blur",Ye,!0)},Re=()=>{ct(),Ke()},Ye=()=>{ct(),Le()};window.addEventListener("pointerup",Re,!0),window.addEventListener("pointercancel",Ye,!0),window.addEventListener("blur",Ye,!0),q("");return}window.setTimeout(()=>{Ee.current=!1},0),xe!==null&&$t(me.id,xe)}},tn=m.useRef(Nt);tn.current=Nt,m.useEffect(()=>{if(z===null)return;const ae=xe=>{xe.key==="Escape"&&(tn.current(!1),xe.preventDefault())},te=xe=>{ie.current?.pointerId===xe.pointerId&&tn.current(!0)},me=()=>tn.current(!1,!0);return window.addEventListener("keydown",ae),window.addEventListener("pointerup",te),window.addEventListener("pointercancel",me),window.addEventListener("blur",me),()=>{window.removeEventListener("keydown",ae),window.removeEventListener("pointerup",te),window.removeEventListener("pointercancel",me),window.removeEventListener("blur",me)}},[z]),m.useEffect(()=>()=>{Oe.current!==null&&cancelAnimationFrame(Oe.current),he.current!==null&&window.clearTimeout(he.current)},[]);const Bt=(ae,te)=>{if(!B)return;const me=P.get(ae);if(me===void 0)return;if(te.kind==="reset"){J(),q(p("ui.shell.sidebar_navigation.reset_note")),Ae(ae);return}if(te.kind==="move"){const Le=grt(Q,ae,te.delta,N);if(Le===null)return;ne(Le),Dt(Le,ae),Ae(ae);return}const xe=Tj(Q,ae,te.region);ok(xe,Q)||(te.region==="more"&&_(!0),ne(xe),q(te.region==="more"?p("ui.shell.sidebar_navigation.move_to_more_note",{name:me.label}):p("ui.shell.sidebar_navigation.show_in_sidebar_note",{name:me.label})),Ae(ae))},rn=c.jsx(lXe,{selectedConversation:l??void 0,onSelectConversation:ae=>void zp(t,ae),onStageDraft:(ae,te)=>{De.getState().stageDraft(ae,te),t("/chat")}}),Fn=ae=>{const te=ae.attention??0,me=te>0&&ae.attentionName?ae.attentionName(te):ae.label;return ae.working&&ae.workingName?ae.workingName:me},rt=ae=>{const te=P.get(ae);if(te===void 0)return null;const me=Za(Q,ae),xe=me==="more"?oe:G,Le=xe.indexOf(ae),Ke=Le<=0,ct=Le===-1||Le>=xe.length-1,Re=te.attention??0,Ye=Fn(te),kt=z===ae,Vt=e?"left":"right",hn=te.isActive?no:"text-ink-muted hover:bg-row-hover hover:text-ink",ln=c.jsx(te.icon,{size:16,"aria-hidden":"true",className:T("shrink-0",te.isActive&&"text-accent")}),Qn=c.jsxs("button",{type:"button",ref:Jt=>{Jt?ye.current.set(ae,Jt):ye.current.delete(ae)},onClick:()=>{if(Ee.current){Ee.current=!1;return}te.onSelect?te.onSelect():t(te.path)},onPointerDown:B?Jt=>et(ae,Jt):void 0,onPointerMove:B?tt:void 0,onPointerUp:B?Jt=>{ie.current?.pointerId===Jt.pointerId&&Nt(!0)}:void 0,onPointerCancel:B?()=>Nt(!1,!0):void 0,onKeyDown:B?Jt=>{if(Jt.key==="ContextMenu"||Jt.shiftKey&&Jt.key==="F10"){Jt.preventDefault(),fe(ae);return}Jt.altKey&&(Jt.key!=="ArrowUp"&&Jt.key!=="ArrowDown"||(Jt.preventDefault(),Bt(ae,{kind:"move",delta:Jt.key==="ArrowUp"?-1:1})))}:void 0,"data-tour-tag":te.tourTag,"aria-current":te.isActive?"page":void 0,"aria-haspopup":B?"menu":void 0,"aria-label":s&&Ye===te.label?void 0:Ye,className:T("flex h-full min-w-0 flex-1 items-center gap-2 rounded-md",s?"px-2":"justify-center px-0"),children:[s?ln:c.jsxs("span",{className:"relative flex size-7 shrink-0 items-center justify-center",children:[ln,Re>0&&c.jsx("span",{className:"pointer-events-none absolute -top-0.5 -end-0.5 flex",children:c.jsx(Sa,{variant:"attentionQuiet",shape:"pill",size:"count",className:"h-3.5 min-w-3.5 px-0.75 leading-none","data-tour-tag":te.attentionTag,children:Re})})]}),!s&&te.working&&c.jsx("span",{className:"inline-flex",children:c.jsx(qr,{size:16,"aria-hidden":"true",className:"text-accent motion-safe:animate-spin"})}),s&&c.jsx("span",{className:"truncate",children:te.label})]}),Es=B?c.jsxs(La,{open:U===ae,onOpenChange:Jt=>fe(Jt?ae:null),children:[c.jsx(sa,{asChild:!0,children:s?c.jsx("button",{type:"button","data-sidebar-row-menu":"","aria-label":p("ui.shell.sidebar_navigation.row_actions",{name:te.label}),className:T("me-0.5 flex size-6 shrink-0 items-center justify-center rounded-sm","text-ink-muted opacity-0 transition-opacity duration-fast ease-out-quart","hover:bg-row-hover hover:text-ink","group-hover/row:opacity-100 group-focus-within/row:opacity-100","focus-visible:opacity-100 data-[state=open]:opacity-100",z!==null&&"pointer-events-none opacity-0!"),children:c.jsx(Wl,{size:16,"aria-hidden":"true"})}):c.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-1 end-0 w-0"})}),c.jsxs(Ba,{align:"start",side:Vt,sideOffset:s?6:16,className:"min-w-44",onCloseAutoFocus:Jt=>{Jt.preventDefault(),Ae(ae)},children:[c.jsx(Ot,{disabled:Ke,onSelect:()=>Bt(ae,{kind:"move",delta:-1}),children:p("ui.shell.sidebar_navigation.move_up")}),c.jsx(Ot,{disabled:ct,onSelect:()=>Bt(ae,{kind:"move",delta:1}),children:p("ui.shell.sidebar_navigation.move_down")}),c.jsx(Js,{}),me==="more"?c.jsx(Ot,{onSelect:()=>Bt(ae,{kind:"region",region:"visible"}),children:p("ui.shell.sidebar_navigation.show_in_sidebar")}):c.jsx(Ot,{onSelect:()=>Bt(ae,{kind:"region",region:"more"}),children:p("ui.shell.sidebar_navigation.move_to_more")}),!ok(Q,I_)&&c.jsxs(c.Fragment,{children:[c.jsx(Js,{}),c.jsx(Ot,{onSelect:()=>Bt(ae,{kind:"reset"}),children:p("ui.shell.sidebar_navigation.reset_layout")})]})]})]}):null;return c.jsxs("li",{"data-sidebar-row":ae,"data-sidebar-region":me,onContextMenu:B?Jt=>{Jt.preventDefault(),fe(ae)}:void 0,className:T("group/row relative flex h-[30px] w-full items-center rounded-md","transition-colors duration-fast ease-out-quart",hn,kt&&zz,kt&&qz),children:[s?Qn:c.jsx(vd,{content:Fn(te),side:Vt,suppressed:z!==null,children:Qn}),Es,s&&(Re>0||te.working)&&c.jsxs("span",{"aria-hidden":"true",className:"pointer-events-none inline-flex shrink-0 items-center gap-1 pe-2",children:[Re>0&&c.jsx(Sa,{variant:"attentionQuiet",shape:"pill",size:"count","data-tour-tag":te.attentionTag,children:Re}),te.working&&c.jsx(qr,{size:16,"aria-hidden":"true",className:"text-accent motion-safe:animate-spin"})]})]},te.tourTag)},on=H===null?null:c.jsx("span",{"aria-hidden":"true","data-sidebar-drop-indicator":"",className:"pointer-events-none absolute inset-x-1 z-10 h-0.5 -translate-y-px rounded-full bg-accent",style:{top:H}}),Ws=(z===null?null:Za(Q,z))==="more"?p("ui.shell.sidebar_navigation.show_in_sidebar"):p("ui.shell.sidebar_navigation.move_to_more"),xn=z===null?null:s?c.jsx("div",{"data-sidebar-drop-band":"",className:"absolute inset-x-0 top-full z-20 mt-1 flex h-7 items-center justify-center rounded-md border border-dashed border-control bg-surface text-meta text-ink-dim",children:Ws}):c.jsx(vd,{content:Ws,side:e?"left":"right",children:c.jsx("div",{"data-sidebar-drop-band":"",className:"absolute inset-x-0 top-full z-20 mx-auto mt-1 flex h-6 w-8 items-center justify-center rounded-sm border border-dashed border-control bg-surface",children:c.jsx("span",{"aria-hidden":"true",className:"h-0.5 w-4 rounded-full bg-ink-dim"})})}),Kn=c.jsx("span",{className:"sr-only","aria-live":"polite","aria-atomic":"true",children:j}),bs=s?p("ui.shell.sidebar_navigation.collapse_sidebar"):p("ui.shell.sidebar_navigation.expand_sidebar"),mn=s?e?Di:cu:e?cu:Di,Qt=navigator.platform.toUpperCase().indexOf("MAC")>=0,kn=Et(a.data,"session_catalogue",2),Ht=De(ae=>ae.activeDraftKey),jn=De(ae=>ae.drafts),vn=!!Ht&&!(Ht?jn[Ht]:void 0)?.target,Je=()=>{De.getState().stageDraft(void 0,!0),t("/chat")},_e=p("ui.shell.sidebar_navigation.new_chat_shortcut",{shortcut:NB(Qt).replace("+","")}),ge=p("ui.shell.sidebar_navigation.search_accessible",{everything:zo("everything",Qt),chats:zo("chats",Qt)}),Se=p("ui.shell.sidebar_navigation.search_tooltip",{everything:zo("everything",Qt),chats:zo("chats",Qt)}),O=(ae,te,me,xe)=>{const Le=ae;return c.jsxs("button",{type:"button",...xe.attrs,onClick:xe.onClick,disabled:xe.disabled,"aria-label":xe.ariaLabel,"aria-current":xe.current?"page":void 0,className:T(Ij,xe.current?no:"text-ink-muted hover:bg-row-hover hover:text-ink","disabled:text-ink-disabled disabled:hover:bg-transparent"),children:[c.jsx(Le,{size:16,"aria-hidden":"true",className:"shrink-0"}),c.jsx("span",{className:"truncate",children:te}),c.jsx("span",{"aria-hidden":"true",className:"ms-auto",children:c.jsx(Er,{shortcut:me,joined:!0})})]})},X=O(wE,p("ui.shell.sidebar_navigation.new_chat"),NB(Qt),{onClick:Je,ariaLabel:_e,current:vn,disabled:!kn,attrs:{"data-tour-tag":"nav-item-chat","data-new-chat-row":""}}),K=O(Jd,p("ui.shell.sidebar_navigation.search"),fJe("everything",Qt),{onClick:i,ariaLabel:ge,attrs:{"data-command-palette-trigger":"",title:Se}}),Y=(ae,te,me)=>{const xe=ae;return c.jsx(vd,{content:te,side:e?"left":"right",children:c.jsx("button",{type:"button",...me.attrs,onClick:me.onClick,disabled:me.disabled,"aria-label":te,className:T("flex size-8 items-center justify-center rounded-sm text-ink-muted","transition-colors duration-fast ease-out-quart","hover:bg-row-hover hover:text-ink","disabled:text-ink-disabled disabled:hover:bg-transparent"),children:c.jsxs("span",{className:"relative flex size-7 items-center justify-center",children:[c.jsx(xe,{size:16,"aria-hidden":"true"}),(me.attention??0)>0&&c.jsx("span",{className:"pointer-events-none absolute -top-0.5 -end-0.5 flex",children:c.jsx(Sa,{variant:"attentionQuiet",shape:"pill",size:"count",className:"h-3.5 min-w-3.5 px-0.75 leading-none","data-tour-tag":me.attentionTag,children:me.attention})}),me.working&&c.jsx("span",{className:"pointer-events-none absolute -bottom-0.5 -end-0.5 flex",children:c.jsx(qr,{size:12,"aria-hidden":"true",className:"text-accent motion-safe:animate-spin"})})]})})})},ee=c.jsx("div",{className:T("pointer-events-none opacity-0 transition-opacity duration-fast ease-out-quart","group-hover/sidebar:pointer-events-auto group-hover/sidebar:opacity-100","group-focus-within/sidebar:pointer-events-auto group-focus-within/sidebar:opacity-100"),children:c.jsx(vd,{content:bs,side:e?"left":"right",children:c.jsx(le,{variant:"ghost",size:"icon-sm",onClick:r,"aria-label":bs,"aria-expanded":s,"aria-keyshortcuts":oI(Qt),children:c.jsx(mn,{"aria-hidden":"true"})})})}),Z=()=>{if(oe.length===0)return null;const ae=oe.map(Le=>P.get(Le)).filter(Le=>Le!==void 0),te=ae.reduce((Le,Ke)=>Le+(Ke.attention??0),0),me=ae.some(Le=>Le.working===!0),xe=te>0?p("ui.shell.sidebar_navigation.more_waiting",{count:te,countText:String(te)}):me?p("ui.shell.sidebar_navigation.more_working"):p("ui.library.page.more_destinations");return c.jsxs("li",{className:T("flex flex-col",s?"gap-0.5":"items-center gap-1"),children:[s?c.jsxs("button",{type:"button","data-tour-tag":"nav-item-more","data-sidebar-more":"","aria-expanded":W,"aria-controls":"sidebar-more-destinations","aria-label":xe,onClick:()=>_(!W),className:T(Ij,"text-ink-muted hover:bg-row-hover hover:text-ink"),children:[c.jsx(Wl,{size:16,"aria-hidden":"true",className:"shrink-0"}),c.jsx("span",{className:"min-w-0 flex-1 truncate text-start",children:p("ui.library.page.more")}),(te>0||me)&&c.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1",children:[te>0&&c.jsx(Sa,{variant:"attentionQuiet",shape:"pill",size:"count","data-tour-tag":"nav-more-badge",children:te}),me&&c.jsx(qr,{size:16,"aria-hidden":"true",className:"text-accent motion-safe:animate-spin"})]}),c.jsx(mi,{size:14,"aria-hidden":"true",className:T("shrink-0 transition-transform duration-fast",W&&"rotate-180")})]}):Y(Wl,xe,{onClick:()=>_(!W),attention:te,attentionTag:"nav-more-badge",working:me,attrs:{"aria-expanded":W,"aria-controls":"sidebar-more-destinations","data-tour-tag":"nav-item-more","data-sidebar-more":""}}),W&&c.jsx("ul",{id:"sidebar-more-destinations",className:T("flex flex-col gap-0.5",!s&&"items-center gap-1"),children:oe.map(rt)})]},"nav-overflow")},Ce=c.jsx(vd,{content:p("ui.shell.sidebar_navigation.settings"),side:"top",children:c.jsx("button",{type:"button","data-tour-tag":"nav-item-settings",onClick:()=>t("/settings"),"aria-current":n==="settings"?"page":void 0,"aria-label":p("ui.shell.sidebar_navigation.settings"),className:T("flex size-8 shrink-0 items-center justify-center rounded-sm text-ink-muted","transition-colors duration-fast ease-out-quart","hover:bg-row-hover hover:text-ink",n==="settings"&&"text-ink"),children:c.jsx(Yc,{size:16,"aria-hidden":"true"})})});return s?c.jsxs("div",{"data-sidebar-shell":"","data-glass-region":"sidebar",className:"panel-top-pad group/sidebar flex h-full min-h-0 flex-col overflow-hidden bg-surface",children:[c.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 pe-2 ps-4",children:[c.jsx(Dj,{expanded:!0}),c.jsx("span",{className:"ms-auto",children:ee})]}),c.jsxs("div",{className:"flex shrink-0 flex-col gap-2 px-2 pb-2",children:[c.jsxs("div",{className:"flex flex-col gap-0.5",children:[X,K]}),c.jsxs("div",{className:"relative",children:[c.jsxs("div",{ref:Fe,"data-sidebar-destinations-area":"","data-sidebar-dragging":z!==null?"":void 0,className:"relative min-h-0 max-h-[50dvh] overflow-y-auto select-none",children:[c.jsxs("ul",{"data-sidebar-destinations":"",className:"flex flex-col gap-0.5",children:[G.map(rt),Z()]}),on]}),xn]}),Kn]}),c.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:rn}),c.jsxs("div",{className:"flex min-h-10 shrink-0 items-center justify-between gap-1 px-2 pb-2",children:[c.jsx(vR,{expanded:!0}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(Fj,{}),Ce]})]})]}):c.jsxs("div",{"data-sidebar-strip":"","data-glass-region":"sidebar",className:"panel-top-pad group/sidebar flex h-full min-h-0 flex-col items-center bg-surface",children:[c.jsx(_rt,{}),c.jsx("div",{className:"flex h-10 shrink-0 items-center justify-center",children:c.jsx(Dj,{expanded:!1})}),c.jsxs("ul",{className:"flex flex-col items-center gap-1",children:[c.jsx("li",{children:Y(Di,bs,{onClick:r,attrs:{"aria-expanded":!1,"aria-keyshortcuts":oI(Qt)}})}),c.jsx("li",{children:Y(wE,_e,{onClick:Je,disabled:!kn,attrs:{"data-tour-tag":"nav-item-chat"}})}),c.jsx("li",{children:Y(Jd,ge,{onClick:i,attrs:{"data-command-palette-trigger":""}})})]}),c.jsxs("div",{ref:Fe,"data-sidebar-destinations-area":"","data-sidebar-dragging":z!==null?"":void 0,className:"relative mt-4 flex flex-col items-center gap-1 select-none",children:[c.jsxs("ul",{"data-sidebar-destinations":"",className:"flex flex-col items-center gap-1",children:[G.map(rt),Z()]}),on,xn]}),Kn,c.jsxs("div",{className:"mt-auto flex flex-col items-center gap-1 pb-2",children:[c.jsx(Fj,{}),Ce,c.jsx(vR,{expanded:!1})]})]})},yrt=1,Srt=()=>{const{isAuthenticated:e,user:t}=YR(),{hasBeenNotified:n,setHasBeenNotified:s}=Qq(),[r,i]=m.useState(!1),[a,o]=m.useState(null),l=m.useCallback(async()=>{if(!(!e||!t?.radientUser?.account?.tenant_id))try{const f=await lse({operation:"credits",tenantId:t.radientUser.account.tenant_id});if(!f||typeof f.balance!="number")throw new Error(p("ui.common.errors.credit_balance_invalid"));o(f.balance)}catch(f){console.error("Failed to fetch Radient credits:",f),o(null)}},[e,t?.radientUser?.account?.tenant_id]);return m.useEffect(()=>{e&&l()},[e,l]),m.useEffect(()=>{e&&a!==null?a<yrt?n||i(!0):(i(!1),n&&s(!1)):i(!1)},[e,n,a,s]),{isLowCreditsDialogOpen:r,openRadientConsole:()=>{window.api?.openExternal?window.api.openExternal("https://console.radienthq.com"):window.open("https://console.radienthq.com","_blank"),s(!0),i(!1)},closeLowCreditsDialog:()=>{i(!1)},onLowCreditsDialogClose:()=>{s(!0),i(!1)},currentCredits:a}};function krt(){const e=xi();m.useEffect(()=>{const t=r=>{e(r==="back"?-1:1)},n=r=>{const i=Wse(r);i&&(r.preventDefault(),t(i))},s=r=>{const i=$se(r);i&&(r.preventDefault(),t(i))};return window.addEventListener("keydown",n),window.addEventListener("mouseup",s),()=>{window.removeEventListener("keydown",n),window.removeEventListener("mouseup",s)}},[e])}function Ert(){const e=navigator.windowControlsOverlay;if(!e?.getTitlebarAreaRect)return null;try{const t=e.getTitlebarAreaRect();return t.width<=0&&t.height<=0?null:{x:t.x,y:t.y,width:t.width,height:t.height}}catch{return null}}function Trt(e,t,n){const s=document.documentElement;if(t==="mac"){s.dataset.chromeLeading="true",s.dataset.chromeTrailing="false";return}if(e===null){s.dataset.chromeLeading="false",s.dataset.chromeTrailing="false";return}s.dataset.chromeLeading=e.x<=1?"true":"false",s.dataset.chromeTrailing=Math.abs(e.x+e.width-n)<=1?"true":"false"}function Rrt(e){const t=window.api?.windowChrome;if(!t)return;const n=getComputedStyle(document.documentElement),s=n.getPropertyValue("--lo-canvas").trim(),r=n.getPropertyValue("--lo-ink-muted").trim(),i=n.getPropertyValue("--lo-ink-dim").trim();!s||!r||!i||t.report({themeId:e,colors:{ground:s,symbol:r,symbolInactive:i}})}function Art(){m.useLayoutEffect(()=>{if(!window.api?.windowChrome)return;const t=document.documentElement.dataset.chromePlatform??"linux",n=()=>Trt(Ert(),t,window.innerWidth);n();const s=navigator.windowControlsOverlay;return s?.addEventListener?.("geometrychange",n),window.addEventListener("resize",n),()=>{s?.removeEventListener?.("geometrychange",n),window.removeEventListener("resize",n)}},[]),m.useEffect(()=>{const e=window.api?.windowChrome;if(e)return e.onState(t=>{document.documentElement.dataset.chromeFullscreen=t.fullScreen?"true":"false"})},[])}const Frt=m.lazy(()=>Va(()=>import("./agent-details-page-DSmJIvXx.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]),import.meta.url).then(e=>({default:e.AgentDetailsPage}))),Drt=m.lazy(()=>Va(()=>import("./agent-hub-page-CD_Db8P3.js"),__vite__mapDeps([15,1,2,3,5,16,7,6,8,4,9,10,11,12,17,18,19,20,21,13,14]),import.meta.url).then(e=>({default:e.AgentHubPage}))),Pj=m.lazy(()=>Va(()=>import("./agents-page-CUktXXX5.js"),__vite__mapDeps([22,6,1,2,3,5,7,8,17,13,14]),import.meta.url).then(e=>({default:e.AgentsPage}))),Irt=m.lazy(()=>Va(()=>import("./schedules-page-CWm4pp8U.js"),__vite__mapDeps([23,1,2,3,5,16,7,6,8,19,10,24,13,14]),import.meta.url).then(e=>({default:e.SchedulesPage}))),Nj=m.lazy(()=>Va(()=>import("./projects-page-Cn-KQN1u.js"),__vite__mapDeps([25,1,2,3,6,5,7,8,16,13,14,26]),import.meta.url).then(e=>({default:e.ProjectsPage}))),Mj=m.lazy(()=>Va(()=>import("./library-page-B4nuLGOL.js").then(e=>e.l),__vite__mapDeps([27,1,2,3,13,5,14,16,6,7,8,12,28,26]),import.meta.url).then(e=>({default:e.LibraryPage}))),Prt=m.lazy(()=>Va(()=>import("./team-bridge-page-DrLX5SLK.js"),__vite__mapDeps([29,1,2,3,5,7,6,8,21,28,13,14]),import.meta.url).then(e=>({default:e.TeamBridgePage}))),Nrt=m.lazy(()=>Va(()=>import("./browser-page-B4X8tPFL.js"),__vite__mapDeps([30,1,2,3,7,5,6,8,13,14]),import.meta.url).then(e=>({default:e.BrowserPage}))),Mrt=m.lazy(()=>Va(()=>import("./mesh-page-CDYqDvSH.js"),__vite__mapDeps([31,1,2,3,5,16,7,6,8,13,14]),import.meta.url).then(e=>({default:e.MeshPage}))),Ort=m.lazy(()=>Va(()=>import("./settings-page-D7ZRdQEG.js"),__vite__mapDeps([32,1,2,3,13,5,14,6,7,8,16,18,33,11,24,10,19]),import.meta.url).then(e=>({default:e.SettingsPage}))),Lrt=m.lazy(()=>Va(()=>import("./browser-webauthn-prompt-CKXKeFSp.js"),__vite__mapDeps([34,1,2,3,5,7,6,8,13,14]),import.meta.url).then(e=>({default:e.BrowserWebauthnPrompt}))),Brt=()=>{Qe(),Art(),Ost(),cse();const{pathname:e}=kR(),t=e.startsWith("/chat")||e.startsWith("/browser"),{isOnboardingActive:n}=Nue(),{isLowCreditsDialogOpen:s,openRadientConsole:r,onLowCreditsDialogClose:i}=Srt(),{isCommandPaletteOpen:a,isCreateAgentDialogOpen:o,isSidebarCollapsed:l,closeCreateAgentDialog:u}=st();Wc(a,"command-palette"),Wc(o,"dialog","create-agent"),Wc(n,"onboarding"),Wc(s,"dialog","low-credits");const d=xi(),h=ns(),f=Et(h.data,"session_catalogue",2),g=Et(h.data,"session_archive");m.useEffect(()=>{De.getState().requestArchiveConfirm(null)},[e]);const v=Yr(h.data,"peers"),b=Yr(h.data,"library"),x=Yr(h.data,"team_bridge_conversations");Mst(Et(h.data,"team_bridge_conversations"));const w=I=>{De.getState().stageDraft({kind:"agent",name:I.name}),d("/chat"),u()};PJe(),jst(),zse(),krt(),kve();const _=De(I=>I.setActiveSession),C=De(I=>{const P=I.activeDraftKey?I.drafts[I.activeDraftKey]:void 0;return vv(I.activeDraftKey,P?.sessionId,I.activeSessionId)}),S=Tde({displayedSessionId:C,archiveEnabled:g}),y=st(I=>I.setConsolePaneOpen),R=st(I=>I.setBrowserPaneOpen),E=st(I=>I.setConsoleActiveSurface);m.useEffect(()=>{const I=window.api?.desktop?.onOpenConversation?.((P,N)=>{P!==null&&performance.mark("lop:open:requested"),_(P),N!==void 0&&P!==null&&(E(N),y(!0)),d("/chat")});return()=>I?.()},[d,_,y,E]);const[F,A]=m.useState(null);return m.useEffect(()=>{const I=window.api?.desktop?.teamBridge,P=()=>{I?.pendingOpen?.().then(L=>{L&&A(L)}).catch(()=>{})},N=I?.onOpen?.(P);return P(),()=>N?.()},[]),m.useEffect(()=>{!F||x!=="enabled"||(d(Gnt(F)),A(null))},[F,x,d]),m.useEffect(()=>{const I=window.api?.console?.onReveal?.(P=>{if(P.mode!=="none"&&!(P.mode==="session"&&P.session_id!==C)){if(P.mode==="open"){if(!use({targetSessionId:P.session_id,displayedSessionId:C,activeElement:document.activeElement,commandPaletteOpen:a}))return;_(P.session_id)}E(P.surface),y(!0)}});return()=>I?.()},[C,a,_,y,E]),zde(),aJe(),m.useEffect(()=>{const I=window.api?.browser?.onConsentAttention?.(P=>{const N=Dde(P.requesterSessionId,De.getState().sessions);if(Rde(P.entryId),N.kind==="browser"){d("/browser");return}_(N.sessionId),R(!0),d("/chat")});return()=>I?.()},[d,_,R]),m.useEffect(()=>{const I=P=>{n||f&&lJe(P)&&(P.preventDefault(),De.getState().stageDraft(void 0,!0),d("/chat"))};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[f,n,d]),c.jsx(ont,{children:c.jsx("div",{className:"relative flex h-screen flex-col overflow-hidden","data-titlebar-sidebar-collapsed":l?"true":"false",children:c.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[a&&c.jsx(AJe,{}),c.jsx(cnt,{}),c.jsx(cJe,{}),c.jsx(dse,{}),c.jsx(NJe,{enabled:v==="enabled"}),c.jsx(RZe,{open:n}),c.jsx(lnt,{}),c.jsx(gnt,{}),g&&c.jsx(Xde,{}),c.jsx(lde,{}),c.jsx(m.Suspense,{fallback:null,children:c.jsx(Lrt,{})}),c.jsx(_de,{blocked:n||s||a||o||S,sessionId:e.startsWith("/chat")?C??null:null}),c.jsx(Ust,{open:s,onClose:i,onGoToConsole:r}),c.jsx(jue,{open:o,onClose:u,onAgentCreated:w}),c.jsx(hse,{sidebar:c.jsx(Crt,{}),content:c.jsxs("main",{"data-glass-region":"canvas-backing",className:"panel-top-pad flex grow flex-col overflow-hidden",children:[t?null:c.jsx("div",{"data-chrome-route-band":""}),c.jsx(m.Suspense,{fallback:c.jsx("div",{className:"flex grow items-center justify-center",children:c.jsx(An,{size:"lg",label:p("ui.common.loading.page")})}),children:c.jsxs(pQ,{children:[c.jsx(yr,{path:"/",element:c.jsx(lI,{to:"/chat",replace:!0})}),c.jsx(yr,{path:"/chat",element:c.jsx(IB,{})}),c.jsx(yr,{path:"/chat/:agentId",element:c.jsx(IB,{})}),c.jsx(yr,{path:"/agents",element:c.jsx(Pj,{})}),c.jsx(yr,{path:"/agents/:agentId",element:c.jsx(Pj,{})}),c.jsx(yr,{path:"/settings",element:c.jsx(Ort,{})}),c.jsx(yr,{path:"/agent-hub",element:c.jsx(Drt,{})}),c.jsx(yr,{path:"/agent-hub/:agentId",element:c.jsx(Frt,{})}),c.jsx(yr,{path:"/schedules",element:c.jsx(Irt,{})}),c.jsx(yr,{path:"/projects",element:c.jsx(Nj,{})}),c.jsx(yr,{path:"/projects/:projectId",element:c.jsx(Nj,{})}),c.jsx(yr,{path:"/browser",element:c.jsx(Nrt,{})}),b==="enabled"&&c.jsxs(c.Fragment,{children:[c.jsx(yr,{path:"/library",element:c.jsx(Mj,{})}),c.jsx(yr,{path:"/library/assets/:assetId",element:c.jsx(Mj,{})})]}),x==="enabled"&&c.jsx(yr,{path:"/team-bridge",element:c.jsx(Prt,{})}),v==="enabled"&&c.jsx(yr,{path:"/mesh",element:c.jsx(Mrt,{})}),c.jsx(yr,{path:"*",element:c.jsx(lI,{to:"/chat",replace:!0})})]})})]})})]})})})};let Bo=null,mf=null,Jg=null,vf=null,lk=null;const jrt={soundsArm:async()=>{if(tf.getState().element)throw new Error("sounds safety: element already exists");if(Bo)throw new Error("sounds safety: graph already armed");return Bo=new AudioContext,await Bo.resume(),pse(e=>{if(!Bo)throw new Error("sounds safety: no context");const t=Bo.createMediaElementSource(e);Jg=Bo.createGain(),Jg.gain.value=0,mf=Bo.createAnalyser(),vf=Bo.createAnalyser(),t.connect(vf),vf.connect(Jg),Jg.connect(mf),mf.connect(Bo.destination)}),{armed:!0,contextState:Bo.state}},soundsFacts:()=>{const e=tf.getState(),t=new Float32Array(mf?.fftSize??32);mf?.getFloatTimeDomainData(t);const n=new Float32Array(vf?.fftSize??32);return vf?.getFloatTimeDomainData(n),{ownerId:e.ownerId,status:e.status,time:e.element?.currentTime??0,duration:e.element?.duration??0,paused:e.element?.paused??!0,gain:Jg?.gain.value??null,inputRms:vf?Math.sqrt(n.reduce((s,r)=>s+r*r,0)/n.length):null,players:Array.from(document.querySelectorAll("[data-sound-player]")).map(s=>({status:s.getAttribute("data-sound-status"),clock:s.querySelector("[data-sound-time]")?.textContent,clip:s.querySelectorAll("canvas")[1]?.style.clipPath,numeric:getComputedStyle(s.querySelector("[data-sound-time]")??s).fontVariantNumeric})),rms:mf?Math.sqrt(t.reduce((s,r)=>s+r*r,0)/t.length):null,src:e.element?.src??null,nativeElements:document.querySelectorAll("audio").length,canvas:Object.values(_s.getState().conversations).map(s=>({selectedTab:s.selectedTabId,files:s.files?.map(r=>({id:r.id,path:r.path,artifact:r.artifact??null}))}))}},soundsScrub:e=>{const t=e,n=document.querySelector(t.selector);if(!n)throw new Error("sounds: no slider");const s=n.getBoundingClientRect(),r=(u,d)=>n.dispatchEvent(new PointerEvent(u,{pointerId:17,pointerType:"mouse",clientX:d,clientY:s.y+s.height/2,bubbles:!0})),i=n.setPointerCapture,a=n.releasePointerCapture;n.setPointerCapture=()=>{},n.releasePointerCapture=()=>{},r("pointerdown",s.left+1),r("pointermove",s.left+s.width*t.fraction);const o=()=>n.closest("[data-sound-player]")?.getAttribute("data-sound-status"),l=performance.now()+1500;return new Promise(u=>{const d=()=>{const h=o();if(h!=="scrubbing"&&performance.now()<l){requestAnimationFrame(d);return}lk=()=>{r("pointerup",s.left+s.width*t.fraction),n.setPointerCapture=i,n.releasePointerCapture=a},u({during:h,seconds:tf.getState().element?.currentTime})};requestAnimationFrame(d)})},soundsScrubFinish:()=>(lk?.(),lk=null,{committed:!0}),soundsEnd:()=>{const e=tf.getState();if(!e.ownerId||!e.element)throw new Error("sounds: no active playback");return e.seek(e.ownerId,e.element.duration-.12),{requested:!0}},soundsSpeech:async()=>{const e=tf.getState();if(!e.element?.src)throw new Error("sounds: fixture not resolved");const{fetchAttachmentBlob:t}=await Va(async()=>{const{fetchAttachmentBlob:r}=await import("./conversation-input-sync-BwzJoCux.js").then(i=>i.kN);return{fetchAttachmentBlob:r}},__vite__mapDeps([6,1,2,3,5,7,8]),import.meta.url),n=De.getState().activeSessionId,s=e.ownerId?.startsWith("sound:")?e.ownerId.slice(6):null;if(!n||!s)throw new Error("sounds: missing attachment identity");return await fse.getState().speak("sounds-driver",()=>t({sessionId:n,childId:null},s)),{ownerId:tf.getState().ownerId}}};function Ed(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}const Hrt=3,Urt=3e3;function Grt(e){return e instanceof CSSTransition&&e.playState==="running"}function Vrt(e){const t=e.effect,n=t instanceof KeyframeEffect?t.target:null,s=e.transitionProperty,i=/^[a-z-]+$/.test(s)&&n instanceof Element?getComputedStyle(n).getPropertyValue(s).trim()||"(empty)":"(unreadable)";return`${s||"(unnamed property)"} on ${uv(n)??"an element no longer in the document"} = ${i}`}async function Wrt(e=Urt){const t=performance.now();let n=0;for(;;){await Ed();const s=Math.round(performance.now()-t),r=document.getAnimations().filter(Grt);if(n=r.length===0?n+1:0,n>=Hrt)return{waitedMs:s,timedOut:!1,pending:[]};if(s>e)return{waitedMs:s,timedOut:!0,pending:r.map(Vrt)}}}const $rt=/^#/;function s0(){const e=window.location.hash.replace($rt,"");return e===""?"/":e}function uv(e){if(!e)return null;const t=e.getAttribute("aria-label")??e.textContent??"";return`${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""} "${t.trim().slice(0,60)}"`}function zrt(e){const t=e.getBoundingClientRect(),n=t.left+t.width/2,s=t.top+t.height/2,r=document.elementFromPoint(n,s),i=r!==null&&(r===e||e.contains(r)),a=document.elementsFromPoint(n,s).slice(0,4).map(l=>uv(l)),o={bubbles:!0,cancelable:!0,composed:!0,button:0,buttons:1,clientX:n,clientY:s,view:window};return e.dispatchEvent(new PointerEvent("pointerdown",{...o,pointerId:1,isPrimary:!0})),e.dispatchEvent(new MouseEvent("mousedown",o)),e.dispatchEvent(new PointerEvent("pointerup",{...o,buttons:0,pointerId:1,isPrimary:!0})),e.dispatchEvent(new MouseEvent("mouseup",{...o,buttons:0})),e.dispatchEvent(new MouseEvent("click",{...o,buttons:0})),{hitTest:i,hit:uv(r),stack:a,disabled:e instanceof HTMLButtonElement?e.disabled:null,rect:{x:t.x,y:t.y,width:t.width,height:t.height}}}function Zg(e,t){if(typeof e!="string"||e==="")throw new Error(`${t} must be a non-empty string`);return e}async function qrt(e,t=1e4){const n=Date.now();for(;s0()!==e;){if(Date.now()-n>t)throw new Error(`route did not become ${e} (it is ${s0()})`);await new Promise(s=>setTimeout(s,50))}return await Ed(),s0()}const bR=["dev-driver","query-fetch-probe"];let r0=null;function Krt(){if(r0)return r0;const e=[],t=cI.prototype.fetch;return cI.prototype.fetch=function(...s){return e.push({at:Date.now(),key:JSON.stringify(this.queryKey),stack:(new Error().stack??"").split(`
705
+ A good description helps you and others understand what the agent does and any special instructions. The descriptions are also used by other agents to help them understand how to tag each other in for certain tasks.<br /><br />If you want this agent to be part of the agent-to-agent communication network, it will need to have a description that captures its purpose and capabilities. Be concise and specific.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="create-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="create-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"navigate-agent-hub",attachTo:{element:'[data-tour-tag="nav-item-agent-hub"]',on:"right"},title:"Discover more agents",text:`Let's visit the Agent Hub to find community-created agents. Click on the "Agent Hub" icon in the navigation bar.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agents"]');e&&e.click(),setTimeout(()=>{const t=document.querySelector('[data-tour-tag="create-new-agent-button"]');t&&t.click()},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agent-hub"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"agent-hub-view",attachTo:{element:'[data-tour-tag="agent-hub-sidebar-container"]',on:"right"},title:"The Agent Hub",text:"Here you can browse agents by category or search for specific ones. These agents are shared by the community and can perform various specialized tasks.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"download-agent",attachTo:{element:'button[data-tour-tag="agent-hub-download-button"]',on:"bottom"},title:"Download an agent",text:'Find an agent that interests you and click the "Get" button to add it to your local agent list.',buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agents"]');e&&e.click(),setTimeout(()=>{this.next()},1e3)}}]},{id:"upload-agent-hub",attachTo:{element:()=>rnt("upload-to-hub-header-button"),on:"bottom"},title:"Share your agents",text:"If you create a useful agent, you can also share it with the community by uploading it to the Agent Hub from the agent options menu.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agent-hub"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){xj("open-upload-dialog"),setTimeout(()=>{this.next()},500)}}]},{id:"upload-agent-hub-dialog",attachTo:{element:'[data-tour-tag="upload-agent-dialog"]',on:"right"},title:"Upload agent to hub",text:"This dialog publishes your agent's instruction set to the community. You need a Radient account to publish, which is free to create and costs nothing per agent. You can review the details before confirming. What is published is what describes the agent - its name, description, instructions and tool surface; no conversation, execution history, memory, plan or machine-specific configuration leaves your computer. Make sure your agent meets the required criteria before submitting.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('button[data-tour-tag="upload-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="upload-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"navigate-schedules",attachTo:{element:'[data-tour-tag="nav-item-schedules"]',on:"right"},title:"Automate tasks with schedules",text:"Local Operator can run tasks for you on a regular basis. Let's check out the Schedules section.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agents"]');e&&e.click(),setTimeout(()=>{xj("open-upload-dialog")},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-schedules"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"schedules-overview",title:"Proactive agents with schedules",text:"A powerful feature of Local Operator is the ability to ask agents to perform tasks on their own on a recurring basis. This turns them from reactive agent bots to proactive agents that work on their own in the background to support you without you needing to continually ask them to do things.<br /><br />You can simply ask any agent to do something at some point in the future, or to handle some daily task at a certain time, and it will create a prompt for itself that will be executed at the specified times.<br /><br />Here, you can view, create, and manage all your scheduled tasks in one place to streamline your workflow and ensure important actions happen automatically.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"create-schedule",attachTo:{element:'button[data-tour-tag="create-schedule-button"]',on:"bottom"},title:"Set up a recurring task",text:'Click "Create schedule" to ask an agent to perform a task for you regularly, like sending a daily report or checking for news updates.<br /><br />You can also create one-off tasks that only run once at some point in the future.',buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="create-schedule-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"create-schedule-dialog",attachTo:{element:'[data-tour-tag="create-schedule-dialog"]',on:"right"},title:"Configure your schedule",text:"While it is often much easier to simply ask the agent to do a task on a recurring basis for you, you can also manually set up a schedule for a task here or update existing tasks.<br /><br />The prompt is the message that will be sent to the agent at the predefined schedule. You can update the time of day in your local timezone, the frequency of the task, and even specify a specific date or time that the task should stop running at.<br /><br />You can also schedule one-off tasks that only run once at some point in the future.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="create-schedule-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="create-schedule-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"navigate-settings",attachTo:{element:'[data-tour-tag="nav-item-settings"]',on:"right"},title:"Personalize your experience",text:"Now, let's explore the Settings menu to customize Local Operator to your liking.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-schedules"]');e&&e.click(),setTimeout(()=>{const t=document.querySelector('button[data-tour-tag="create-schedule-button"]');t&&t.click()},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-settings"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"general-settings",attachTo:{element:'div[data-tour-tag="settings-general-section"]',on:"right"},title:"General settings",text:"Here you can update your user profile and configure model settings (like default hosting provider and model).",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"appearance-settings",attachTo:{element:'[data-tour-tag="settings-appearance-section"]',on:"right"},title:"Customize appearance",text:"Choose from various themes to change the look and feel of Local Operator. Find one that suits your style.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"radient-account-settings",attachTo:{element:'[data-tour-tag="settings-radient-account-section"]',on:"right"},title:"Radient account",text:"Connect your Radient account to access your Radient Pass details, credits, and unlock unified access to models and tools. Radient is the best way to use Local Operator since it powers the AI models, web search, image generation, and much more with a single integration. You get free credits when you sign up to try it out and bonus credits when you top up.<br /><br />When you sign in for the first time, it will automatically create a Radient Pass for you and save it securely to your computer. This will power your Local Operator agents with Radient Automatic, which mixes and matches AI models to get you the best balance of speed, accuracy, and cost in every step of your agents' workflows.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"integrations-settings",attachTo:{element:'[data-tour-tag="settings-integrations-section"]',on:"right"},title:"Connect your services",text:"Enhance your agents' capabilities by connecting your Google services like Gmail, Calendar, and Drive. This allows agents to access and manage your information with your permission.<br /><br />You need to be logged in to a Radient account to use this feature, however it is free to use and doesn't cost any additional Radient credits per action.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"application-updates-settings",attachTo:{element:'[data-tour-tag="settings-app-updates-section"]',on:"right"},title:"Stay up to date",text:"Check for updates to Local Operator here to ensure you have the latest features and improvements. You can see your current version information below.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"tour-complete",title:"Tour complete",text:"You've now seen the main features of Local Operator. Feel free to explore further and discover all the ways your AI agents can assist you. Happy automating.",buttons:[{text:"Finish",classes:"shepherd-button-primary",action:function(){this.complete()}}]}],int=()=>{const e=xi(),{completeTourOnboarding:t}=d0(),n=m.useContext(ey),s={cancelIcon:{enabled:!0},scrollTo:{behavior:"smooth",block:"center"}},r=!0;return{startTour:a=>{if(n?.tour?.isActive()&&!a?.forceModalCompleted){console.log("Onboarding tour is already active (from context.tour). Not starting another.");return}const o=d0.getState();if(!a?.forceModalCompleted&&!o.isModalComplete){console.log("Onboarding modal not completed (checked via store). Tour will not start.");return}if(o.isTourComplete&&!a?.forceModalCompleted){console.log("Onboarding tour already completed in store and not forced. Not starting again.");return}let l=n?.tour;const u=n?.Shepherd;if(!l&&u&&(l=u.activeTour,!l&&u.Tour&&(console.log("No active Shepherd tour found from context or global. Creating a new one."),l=new u.Tour({useModalOverlay:r,defaultStepOptions:s}))),!l){console.warn("Failed to get or create a Shepherd tour instance.",n);return}if(l.isActive()){console.log("Tour is already active. Not starting again.");return}if(l.options.defaultStepOptions={...l.options.defaultStepOptions||{},...s},l.options.useModalOverlay=r,a?.firstAgentId&&(l.options.firstAgentId=a.firstAgentId),l.off("complete",t),l.on("complete",t),l.off("cancel",t),l.on("cancel",t),a?.forceModalCompleted||!l.isActive()){const d=[...l.steps];for(const h of d)h.id&&l.removeStep(h.id);l.addSteps(wj)}else l.steps.length===0&&l.addSteps(wj);typeof l.start=="function"?(e("/"),l.start()):console.warn("Shepherd tour instance does not have a start method.",l)}}},ant=()=>{const{isModalComplete:e,isTourComplete:t}=d0(),{startTour:n}=int(),s=nt.useContext(ey),{data:r}=_E(1,1);return m.useEffect(()=>{if(e&&!t&&s){const i=setTimeout(()=>{const a=r?.agents?.[0]?.id;n({firstAgentId:a})},500);return()=>clearTimeout(i)}},[e,t,s,n,r]),null},ont=({children:e})=>c.jsxs(Ytt,{children:[e,c.jsx(ant,{})]}),lnt=()=>{Qe();const{open:e,focusGroup:t,providerId:n,closeConnect:s}=c5(),r=m.useRef(null);m.useEffect(()=>{e&&(r.current=document.activeElement instanceof HTMLElement?document.activeElement:null)},[e]);const i=xi();return c.jsx(lc,{open:e,onOpenChange:a=>{a||s()},children:c.jsxs(cc,{className:"max-h-[calc(100vh-4rem)] max-w-[min(40rem,calc(100vw-4rem))] gap-4 overflow-y-auto","data-connect-provider-dialog":"",onCloseAutoFocus:a=>{const o=r.current;r.current=null,o?.isConnected&&(a.preventDefault(),o.focus())},children:[c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx(rl,{className:"text-title",children:p("ui.providers.connect_provider_dialog.connect_a_model_provider")}),c.jsx(yu,{className:"text-body-sm text-ink-muted",children:p("ui.providers.connect_provider_dialog.your_agents_need_a_model_to_think")})]}),e?c.jsx(uq,{context:"dialog",featuredOnly:!0,focusGroup:t,initialProviderId:n,onDone:s,onChangeModel:()=>{s(),i("/settings")}}):null]})})};function cnt(){const{visible:e,rows:t,cursor:n,commitAt:s,hoverAt:r}=Vse();Wc(e,"session-switcher");const i=n!==null&&e?t[n]??null:null,a=e&&t.length>=2;return c.jsxs(c.Fragment,{children:[c.jsx("output",{"aria-live":"polite",className:"sr-only","data-session-switcher-announcement":"",children:i!==null&&n!==null?c.jsxs(c.Fragment,{children:[Iq(i),", ",n+1," / ",t.length]}):null}),a?dv.createPortal(c.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 flex items-start justify-center pt-[18vh]",children:c.jsx("div",{role:"dialog","aria-modal":"false","aria-label":p("ui.command_palette.palette_search.recents"),className:"pointer-events-auto w-160 max-w-[90vw] rounded-lg border border-hairline bg-elevated p-2 shadow-overlay",children:t.map((o,l)=>c.jsx(hnt,{row:o,active:l===n,onCommit:()=>s(l),onHover:()=>r(l)},o.sessionId))})}),document.body):null]})}function Iq(e){return e.title??p("ui.command_palette.palette_search.untitled_chat")}const unt=1e3;function dnt(){let e=0;function t(){window.clearTimeout(e),window.removeEventListener("contextmenu",n,!0),window.removeEventListener("pointerup",t,!0)}function n(s){s.preventDefault(),s.stopPropagation(),t()}e=window.setTimeout(t,unt),window.addEventListener("contextmenu",n,!0),window.addEventListener("pointerup",t,!0)}function hnt({row:e,active:t,onCommit:n,onHover:s}){return c.jsxs("button",{type:"button",tabIndex:-1,"aria-current":t?"true":void 0,"data-session-id":e.sessionId,onPointerDown:r=>{r.button===0&&(r.preventDefault(),dnt(),n())},onMouseDown:r=>r.preventDefault(),onContextMenu:r=>r.preventDefault(),onMouseMove:s,className:T("flex h-9 w-full items-center gap-3 rounded-sm px-2 text-left",t?"bg-sunken outline-solid outline-1 -outline-offset-1 outline-control":"bg-transparent"),children:[e.row===null?c.jsx("span",{"aria-hidden":"true",className:"size-4 shrink-0"}):c.jsx($z,{row:e.row}),c.jsx("span",{className:T("min-w-0 flex-1 truncate text-body-sm",e.title===null?"text-ink-muted":"text-ink"),children:Iq(e)})]})}const fnt=({title:e,description:t,icon:n,children:s,titleComponent:r,sectionRef:i,dataTourTag:a,className:o,id:l})=>c.jsxs("div",{ref:i,id:l,tabIndex:l?-1:void 0,"data-tour-tag":a,className:T("w-full",o),children:[r??c.jsxs("h2",{className:"flex items-center gap-2 text-heading text-ink",children:[n&&c.jsx(n,{size:16,className:"shrink-0 text-ink-dim"}),e]}),t&&c.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:t}),c.jsx("div",{className:"mt-4",children:s})]}),qat=({label:e,value:t,className:n,valueClassName:s})=>c.jsxs("div",{className:T("min-w-0",n),children:[c.jsx("div",{className:"flex items-center gap-1.5 text-meta text-ink-dim",children:e}),c.jsx("div",{className:T("mt-0.5 break-words text-body-sm",s??"text-ink"),children:t})]}),Kat=({children:e,className:t})=>c.jsx("div",{className:T("grid grid-cols-[repeat(auto-fit,minmax(160px,1fr))] gap-x-6 gap-y-4",t),children:e});async function Pq(e){await at({op:"settings.edit",key:Yo,value:e.value}),Qne(e.queryClient)}async function pnt(e){await Pq(e),e.queryClient.setQueryData(nw.all,t=>t&&{...t,settings:t.settings.map(n=>n.key===Yo?{...n,value:e.value,is_default:e.value===n.default}:n)});try{return await e.queryClient.fetchQuery({queryKey:nw.all,queryFn:()=>at({op:"settings.list"}),staleTime:0,retry:!1}),"confirmed"}catch{return"readback-unknown"}}const Yat=({focus:e=!1})=>{Qe();const t=Gt(),n=ns(),s=Et(n.data,"settings"),r=Nn({queryKey:nw.all,queryFn:()=>at({op:"settings.list"}),enabled:s,retry:!1,refetchOnReconnect:!0}),i=r.data?.settings.find(F=>F.key===Yo),[a,o]=m.useState(!1),[l,u]=m.useState(null),[d,h]=m.useState(!1),[f,g]=m.useState(!1),v=m.useRef(!1),b=m.useRef(null),x=m.useRef(!1);m.useEffect(()=>{if(!e){x.current=!1;return}!i||x.current||(b.current?.querySelector("[role=combobox]")?.focus(),x.current=!0)},[e,i]),m.useEffect(()=>{r.isSuccess&&!r.isFetching&&h(!1)},[r.isFetching,r.isSuccess]);const w=async F=>{if(!(!i||v.current||d||!i.choices.some(A=>A.value===F))){v.current=!0,o(!0),u(null),g(!1);try{const A=await pnt({value:F,queryClient:t});h(A==="readback-unknown"),g(A==="confirmed")}catch(A){u({value:F,message:A instanceof Error?A.message:""})}finally{v.current=!1,o(!1)}}},_=async()=>{const[F,A]=await Promise.all([r.refetch(),n.refetch()]);!F.isError&&!A.isError&&h(!1)},C=!r.data&&r.error||!n.data&&n.error,S=n.data&&(!s||r.data&&!i),y=!C&&!S&&!i,R=n.data?.features?.i18n?n.data.language:void 0,E=typeof R=="string"&&R!==""?R:void 0;return c.jsx(fnt,{title:p("ui.settings.language.dialog.title"),icon:H8,description:p("ui.settings.language.general.description"),children:c.jsxs("div",{ref:b,"data-setting-key":Yo,className:"flex flex-col gap-3","aria-busy":a,children:[y&&c.jsx("output",{className:"text-meta text-ink-dim",children:p("ui.settings.language.dialog.loading")}),S&&c.jsx("p",{className:"text-meta text-ink-dim",children:p("ui.settings.language.dialog.unavailable")}),i&&c.jsx(g5,{setting:{...qR(i),label:p("ui.settings.language.dialog.title")},value:String(i.value),onValueChange:F=>{w(F)},disabled:a||d,suppressEffectiveNote:!0}),c.jsx("output",{id:Yne(Yo),"aria-live":"polite",className:"text-meta text-ink-dim",children:a?p("ui.settings.language.general.pending"):f?p("ui.settings.language.general.saved"):E?p(d||n.error?"ui.settings.language.general.last_known":"ui.settings.language.general.effective",{locale:Xne(E)?.name??E}):p("ui.settings.language.general.no_resolution")}),(C||l||d)&&c.jsx(Kr,{variant:"danger",children:c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsx("p",{role:"alert",children:l?p("ui.settings.language.general.write_error",{message:l.message}):d?p("ui.settings.language.general.readback_error"):p("ui.settings.language.dialog.unavailable")}),c.jsx(le,{variant:"outline",size:"sm",disabled:a||r.isFetching||n.isFetching,onClick:()=>{l?w(l.value):_()},children:p("ui.settings.language.dialog.retry")})]})})]})})},gnt=()=>{Qe();const e=sR(ne=>ne.open),t=sR(ne=>ne.closeLanguage),n=Gt(),s=ns(),r=Et(s.data,"settings"),i=Nn({queryKey:nw.all,queryFn:()=>at({op:"settings.list"}),enabled:e&&r,staleTime:1e4}),a=m.useRef(null),o=t5(),l=(i.data?.settings??[]).find(ne=>ne.key===Yo),u=l?qR(l):void 0,[d,h]=m.useState(null),[f,g]=m.useState(!1),[v,b]=m.useState(!1),[x,w]=m.useState(null),_=m.useRef(null);m.useEffect(()=>{e&&h(null)},[e]),m.useEffect(()=>{if(!e||!u)return;const ne=String(u.value??"");(d===null||d===_.current)&&h(ne),_.current=ne},[e,u,d]),m.useEffect(()=>{e&&(b(!1),w(null))},[e]);const C=d??String(u?.value??""),S=!!u&&C!==String(u?.value??""),y=!u||!S||f,R=async()=>{if(!(!u||!S)){g(!0),w(null);try{await Pq({value:C,queryClient:n}),b(!0),h(null),await i.refetch()}catch(ne){w(ne instanceof Error?ne.message:p("ui.settings.configuration.language_dialog.the_language_could_not_be_saved"))}finally{g(!1)}}},E=!!s.data,F=E&&!r,A=s.error&&!s.data?s.error:null,I=A??i.error,P=!E&&!I,{sentence:N,remedy:L}=uQ(o??null,p("ui.settings.configuration.language_dialog.your_settings_could_not_be_loaded"),I),V=s.isFetching||i.isFetching,B=u?"combo":I?"retry":"none";return m.useEffect(()=>{!e||B==="none"||requestAnimationFrame(()=>{a.current?.querySelector(B==="combo"?'[role="combobox"]':"[data-language-retry]")?.focus()})},[e,B]),c.jsx(lc,{open:e,onOpenChange:ne=>!ne&&t(),children:c.jsxs(cc,{ref:a,onOpenAutoFocus:ne=>ne.preventDefault(),className:"max-w-[min(28rem,calc(100vw-4rem))] gap-4",children:[c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx(rl,{className:"text-title",children:p("ui.settings.language.dialog.title")}),c.jsx(yu,{className:"text-body-sm text-ink-muted",children:p("ui.settings.language.dialog.description")})]}),P?c.jsxs("div",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[c.jsx(An,{}),p("ui.settings.language.dialog.loading")]}):F?c.jsx(Kr,{variant:"warning",children:c.jsx("span",{children:p("ui.settings.language.dialog.unavailable")})}):I?c.jsx(Kr,{variant:"warning",children:c.jsxs("div",{className:"flex items-center justify-between gap-3",children:[c.jsx("span",{children:N}),L&&c.jsx(le,{variant:"secondary",size:"sm",className:"shrink-0","data-language-retry":"",onClick:()=>{A?s.refetch():i.refetch()},disabled:V,children:V?p("ui.settings.language.dialog.retrying"):p("ui.settings.language.dialog.retry")})]})}):i.isPending?c.jsxs("div",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[c.jsx(An,{}),p("ui.settings.language.dialog.loading")]}):u?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("span",{id:LI(Yo),className:"text-meta text-ink-dim",children:u.help}),c.jsx(g5,{setting:u,value:C,disabled:f,helpId:LI(Yo),effectiveNoteId:Jne(Yo,Zne),onValueChange:ne=>{b(!1),h(ne)}})]}),x&&c.jsx("p",{className:"text-meta text-danger",children:x}),c.jsx("div",{className:"flex min-h-8 items-center justify-end",children:v&&!S?c.jsxs("output",{"data-language-save":"",className:"inline-flex items-center gap-1.5 text-body-sm text-ink",children:[c.jsx(Us,{"aria-hidden":"true",className:"size-3.5"}),p("ui.settings.language.dialog.saved")]}):c.jsx(le,{onClick:R,disabled:y,"data-language-save":"",children:f?`${p("ui.settings.language.dialog.save")}...`:p("ui.settings.language.dialog.save")})})]}):c.jsx(Kr,{variant:"warning",children:c.jsx("span",{children:p("ui.settings.language.dialog.unavailable")})})]})})};function Ou(){return crypto.randomUUID()}async function Xat(e=1,t=20,n){const s={page:e,per_page:t};if(n)for(const[r,i]of Object.entries(n))i&&(s[r]=i);return wi({operation:"agents.list",query:s})}async function Qat(e){return wi({operation:"agents.get",agentId:e})}async function Jat(e){return wi({operation:"agents.delete",agentId:e,requestId:Ou(),confirmed:!0})}async function Zat(e){return wi({operation:"agents.like",agentId:e,requestId:Ou()})}async function eot(e){return wi({operation:"agents.unlike",agentId:e,requestId:Ou(),confirmed:!0})}async function tot(e){return wi({operation:"agents.favourite",agentId:e,requestId:Ou()})}async function not(e){return wi({operation:"agents.unfavourite",agentId:e,requestId:Ou(),confirmed:!0})}async function sot(e,t){return wi({operation:"comments.create",agentId:e,payload:t,requestId:Ou()})}async function rot(e,t=1,n=20){return wi({operation:"comments.list",agentId:e,query:{page:t,per_page:n}})}async function iot(e,t,n){return wi({operation:"comments.update",agentId:e,commentId:t,payload:n,requestId:Ou()})}async function aot(e,t){return wi({operation:"comments.delete",agentId:e,commentId:t,requestId:Ou(),confirmed:!0})}async function oot(e){return wi({operation:"agents.statuses",query:{agent_ids:e.join(",")}})}async function mnt(){return wi({operation:"memberships.list"})}async function lot(e,t=1,n=20,s){const r={page:t,per_page:n};if(s)for(const[i,a]of Object.entries(s))a&&(r[i]=a);return wi({operation:"org_agents.list",tenantId:e,query:r})}async function cot(e){return wi({operation:"org_teams.list",tenantId:e})}class cx extends Error{status;reason;constructor(t,n,s){super(t),this.name="PublicHubError",this.status=n,this.reason=s}}const vnt=/\/+$/,bnt=(e,t,n)=>{const s=e.replace(vnt,"");return n?`${s}/v1/${t}/${encodeURIComponent(n)}`:`${s}/v1/${t}`},Nq=(e,t)=>bnt(e,"teams",t),Mq=async e=>{let t;try{t=await fetch(e,{method:"GET",headers:{Accept:"application/json"},redirect:"error"})}catch(s){throw console.error("The public hub could not be reached:",s),new cx(p("ui.common.errors.public_hub_unreachable"),null,s)}if(!t.ok)throw new cx(p("ui.common.errors.public_hub_status",{status:t.status}),t.status);let n;try{n=await t.json()}catch{throw new cx(p("ui.common.errors.public_hub_json"),t.status)}if(!n||typeof n!="object"||!("result"in n))throw new cx(p("ui.common.errors.public_hub_body"),t.status);return n};async function uot(e,t=1,n=12){const s=`${Nq(e)}?page=${t}&per_page=${n}`;return Mq(s)}async function dot(e,t){return Mq(Nq(e,t))}const xnt={all:["memberships"],account:e=>["memberships","account",e??"unresolved-owner"]},wnt=({enabled:e=!0}={})=>{const{isAuthenticated:t}=YR(),n=Gt(),{accountId:s}=m5(),r=Nn({queryKey:xnt.account(s),queryFn:async()=>(await v5(n,s,()=>mnt())).result??{memberships:[]},enabled:e&&t&&!!s,staleTime:5*60*1e3,gcTime:10*60*1e3,refetchOnWindowFocus:!1,retry:pv});return{...r,memberships:r.data?.memberships??[]}},br=qe.string().min(1).max(128),_nt=qe.object({account_id:br,kind:qe.enum(["human","agent"]),display_label:qe.string().min(1).max(64),role:qe.enum(["owner","member"]),state:qe.enum(["invited","active","left","removed"]),joined_seq:qe.number().int().nonnegative().optional()}).passthrough(),Oq=qe.enum(["all","mention","mute"]),Gx=qe.object({id:br,tenant_id:br,kind:qe.enum(["dm","group","channel"]),name:qe.string().optional(),topic:qe.string().optional(),visibility:qe.enum(["private","tenant"]),agent_capable:qe.boolean(),status:qe.enum(["open","archived"]),created_by:br,last_message_at:qe.string(),latest_seq:qe.number().int().nonnegative(),members:qe.array(_nt),last_read_seq:qe.number().int().nonnegative(),unread_count:qe.number().int().nonnegative(),muted:qe.boolean(),discoverable:qe.boolean().optional(),member:qe.boolean().optional(),member_count:qe.number().int().nonnegative().optional(),notify:Oq.optional(),last_sender_label:qe.string().min(1).max(64).optional(),last_thread_root_id:br.optional(),builtin:qe.string().min(1).max(32).optional()}).passthrough(),Cnt=qe.object({conversations:qe.array(Gx),has_more:qe.boolean().optional(),next_before:qe.string().optional()}).passthrough(),Lq=qe.object({emoji:qe.string().min(1),count:qe.number().int().positive(),reacted_by_me:qe.boolean(),sample_labels:qe.array(qe.string()).max(3)}).passthrough(),ynt=qe.object({message_id:br,reactions:qe.array(Lq).max(50)}).passthrough(),Snt=Lq.extend({sample_labels:qe.array(qe.string()).transform(e=>e.slice(0,3))}),knt=qe.array(Snt).transform(e=>e.slice(0,50)),Bq=qe.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/),XF=qe.object({id:Bq,mime:qe.string().max(64),size:qe.number().int().nonnegative(),width:qe.number().int().nonnegative(),height:qe.number().int().nonnegative(),sha256:qe.string().max(128).optional(),state:qe.string().max(32).optional(),expires_at:qe.string().optional()}).passthrough(),Ent=qe.object({attachment:XF}).passthrough(),hot=qe.object({enabled:qe.boolean(),max_count:qe.number().int().positive().max(16),max_bytes:qe.number().int().positive(),max_pixels:qe.number().int().positive().optional(),mime_types:qe.array(qe.string())}).passthrough(),uR=qe.object({id:br,conversation_id:br,seq:qe.number().int().nonnegative(),sender:qe.object({account_id:br,kind:qe.enum(["human","agent"]),display_label:qe.string().min(1).max(64)}).passthrough(),body:qe.string().nullable(),body_hash:qe.string().optional(),origin:qe.enum(["human","agent","system"]),agent_label:qe.string().optional(),created_at:qe.string(),reactions:knt.optional(),thread_root_id:br.optional(),reply_count:qe.number().int().nonnegative().optional(),last_reply_at:qe.string().optional(),reply_participants:qe.array(qe.string()).optional(),attachments:qe.array(XF).max(16).optional()}).passthrough(),Tnt=qe.object({root:uR,replies:qe.array(uR),next_after_seq:qe.number().int().nonnegative().optional(),has_more:qe.boolean().optional()}).passthrough(),Rnt=qe.object({messages:qe.array(uR),next_before_seq:qe.number().int().nonnegative().optional(),has_more:qe.boolean().optional()}).passthrough(),Ant=qe.object({tenant_id:br,tenant_name:qe.string(),unread:qe.number().int().nonnegative(),eligible:qe.boolean()}).passthrough(),Fnt=qe.object({total:qe.number().int().nonnegative(),conversations:qe.array(qe.object({conversation_id:br,unread_count:qe.number().int().nonnegative(),last_read_seq:qe.number().int().nonnegative(),latest_seq:qe.number().int().nonnegative(),muted:qe.boolean()}).passthrough()).optional(),organizations:qe.array(Ant).optional()}).passthrough(),jq=qe.enum(["active","paused","disabled","none"]),Hq=qe.object({endpoint_id:br,name:qe.string().max(128),state:qe.string().min(1).max(32)}).passthrough(),Dnt=qe.object({account_id:br,display_label:qe.string(),role:qe.string().min(1).max(32),bridge_enabled:qe.boolean(),bridge_state:jq,agent:Hq.optional().catch(void 0)}).passthrough();function Int(e){if(e===null||typeof e!="object")return null;const t=e,n=t.account_id;if(typeof n!="string"||n.length===0)return null;const s=typeof t.display_label=="string"?t.display_label:"",r=typeof t.role=="string"&&t.role.length>0?t.role:"member",i=t.bridge_enabled===!0,a=jq.safeParse(t.bridge_state),o=Hq.safeParse(t.agent);return{account_id:n,display_label:s,role:r,bridge_enabled:i,bridge_state:a.success?a.data:"none",...o.success?{agent:o.data}:{}}}const Pnt=qe.object({members:qe.array(qe.unknown())}).passthrough().transform(e=>{const t=[];let n=0;for(const s of e.members){const r=Dnt.safeParse(s);if(r.success){t.push(r.data);continue}const i=Int(s);i?t.push(i):n+=1}return{...e,members:t,unavailable_count:n}}),Nnt=qe.object({account_id:qe.string().min(1).nullable().optional()}).passthrough(),_j=qe.object({conversation_id:br,last_read_seq:qe.number().int().nonnegative(),unread_count:qe.number().int().nonnegative(),muted:qe.boolean(),notify:Oq.optional()}).passthrough(),dR=qe.object({id:br,tenant_id:br,conversation_id:br,body:qe.string(),send_at:qe.string().datetime({offset:!0}),status:qe.enum(["scheduled","sending"]),created_at:qe.string().datetime({offset:!0}),attachments:qe.array(XF).max(16).optional(),attachment_ids:qe.array(Bq).max(16).optional()}).transform(({attachment_ids:e,...t})=>t.attachments!==void 0||!e?.length?t:{...t,attachments:e.map(n=>({id:n,mime:"",size:0,width:0,height:0,state:"reserved"}))}),Mnt=qe.object({scheduled:qe.array(dR)});class Cj extends Error{status;code;constructor(t,n){super("team bridge attachment request failed"),this.name="TeamBridgeAttachmentError",this.status=t,this.code=n}}async function ud(e,t){if(!e||!t)throw new Error("Team Bridge write owner and tenant required");if(((await at({op:"capabilities"})).features?.team_bridge_conversation_owner_guard??0)<1)throw new Error("Team Bridge runtime owner guard unavailable");return{expected_account_id:e,tenant_id:t}}const Jr={async scheduledList(e){return Mnt.parse(await at({op:"team_bridge.scheduled.list",tenant_id:e}))},async scheduledCreate(e){return dR.parse(await at({op:"team_bridge.scheduled.create",...e}))},async scheduledUpdate(e,t,n){return dR.parse(await at({op:"team_bridge.scheduled.update",tenant_id:e,scheduled_id:t,...n}))},async scheduledCancel(e,t){return at({op:"team_bridge.scheduled.cancel",tenant_id:e,scheduled_id:t})},async react(e,t,n,s,r){const i=await at({op:"team_bridge.reactions.toggle",conversation_id:e,message_id:t,emoji:n,active:s,...r?{tenant_id:r}:{}});return ynt.parse(i)},async listConversations(e){const t=await at({op:"team_bridge.conversations.list",...e==="account"?{scope:"account"}:{tenant_id:e.tenantId}});return Cnt.parse(t)},async getConversation(e,t){const n=await at({op:"team_bridge.conversations.get",conversation_id:e,...t?{tenant_id:t}:{}});return Gx.parse(n)},async startConversation(e){const t=await at({op:"team_bridge.conversations.create",...await ud(e.expectedAccountId,e.tenantId),kind:e.kind,...e.tenantId?{tenant_id:e.tenantId}:{},...e.name?{name:e.name}:{},...e.topic?{topic:e.topic}:{},...e.visibility?{visibility:e.visibility}:{},...e.agentCapable===void 0?{}:{agent_capable:e.agentCapable},members:e.members});return Gx.parse(t)},async listMessages(e,t={}){const n=await at({op:"team_bridge.messages.list",conversation_id:e,...t.tenantId?{tenant_id:t.tenantId}:{},...t.limit===void 0?{}:{limit:t.limit},...t.beforeSeq===void 0?{}:{before_seq:t.beforeSeq}});return Rnt.parse(n)},async listReplies(e,t,n={}){const s=await at({op:"team_bridge.messages.replies",conversation_id:e,message_id:t,...n.tenantId?{tenant_id:n.tenantId}:{},...n.limit===void 0?{}:{limit:n.limit},...n.afterSeq===void 0?{}:{after_seq:n.afterSeq}});return Tnt.parse(s)},async send(e,t){return at({op:"team_bridge.messages.send",...t.threadRootId?{}:await ud(t.expectedAccountId,t.tenantId),conversation_id:e,client_ref:t.clientRef,body:t.body,...t.tenantId?{tenant_id:t.tenantId}:{},...t.threadRootId?{thread_root_id:t.threadRootId}:{},...t.attachmentIds?.length?{attachment_ids:[...t.attachmentIds]}:{}})},async uploadAttachment(e,t,n,s){const r=await aI({op:"team_bridge.attachment.upload",tenantId:e,conversationId:t,expectedAccountId:s},n);if(r.kind!=="json")throw new Cj(r.kind==="error"?r.status:null,r.kind==="error"?r.code:void 0);const i=r.body;return Ent.parse(i&&typeof i=="object"&&"result"in i?i.result:i).attachment},async deleteAttachment(e,t,n,s){return at({op:"team_bridge.attachments.delete",tenant_id:e,expected_account_id:s,conversation_id:t,attachment_id:n})},async attachmentBytes(e){const t=await aI({op:"team_bridge.attachment",...e},null);if(t.kind!=="bytes")throw new Cj(t.kind==="error"?t.status:null,t.kind==="error"?t.code:void 0);return{data:t.data,mimeType:t.mimeType}},async markRead(e,t){const n=await at({op:"team_bridge.read",...await ud(t.expectedAccountId,t.tenantId),conversation_id:e,...t.tenantId?{tenant_id:t.tenantId}:{},...t.seq===void 0?{}:{seq:t.seq},...t.muted===void 0?{}:{muted:t.muted}});return _j.parse(n)},async identity(){const e=await at({op:"agent_messages.status",boundary:"surface_open"}),t=Nnt.parse(e);return FE(AE(),t),t.account_id??null},async unread(e){const t=await at({op:"team_bridge.unread",...e==="account"?{scope:"account"}:{tenant_id:e.tenantId}});return Fnt.parse(t)},async directory(e){const t=await at({op:"team_bridge.directory",tenant_id:e});return Pnt.parse(t)},async status(e){const t=await at({op:"team_bridge.status",...e?{boundary:e}:{}}),n=Qj.parse(t);return FE(AE(),n),n},async setArchived(e,t,n,s){return at({op:"team_bridge.conversations.lifecycle",conversation_id:e,action:t?"archive":"unarchive",...await ud(s,n)})},async leave(e,t,n){return at({op:"team_bridge.conversations.lifecycle",conversation_id:e,action:"leave",...await ud(n,t)})},async join(e,t,n){const s=await at({op:"team_bridge.conversations.join",...await ud(n,t),conversation_id:e,...t?{tenant_id:t}:{}});return Gx.parse(s)},async setNotify(e,t,n,s){const r=await at({op:"team_bridge.conversations.notify",...await ud(s,n),conversation_id:e,...n?{tenant_id:n}:{},notify:t});return _j.parse(r)}},Ont=320,Lnt=360,Bnt=320;function jnt(e){const t=e.codePointAt(0)??0;return e==="<"||e===">"||t<32||t>=127&&t<=159||t===1564||t===8206||t===8207||t>=8234&&t<=8238||t>=8294&&t<=8297||t===8232||t===8233}const Hnt=/\s+/g,Unt=new Intl.Segmenter(void 0,{granularity:"grapheme"});function Uq(e,t,n="points"){let s=0,r="";for(const{segment:i}of Unt.segment(e)){const a=n==="points"?Array.from(i).length:i.length;if(s+a>t)return`${r.trimEnd()}…`;r+=i,s+=a}return r}function Vx(e,t){let n="";for(const r of e)r==="<"?n+="‹":r===">"?n+="›":n+=jnt(r)?" ":r;const s=n.replace(Hnt," ").trim();return s.length<=t?s:Uq(s,Math.max(0,t-1),"units")}const fot=!1,pot=!1;function Gnt(e){return`/team-bridge?${new URLSearchParams({tenant:e.tenantId,conversation:e.conversationId}).toString()}`}const Vnt=140,Wnt=/^\s*(```|~~~).*$/gm,$nt=/^\s{0,3}#{1,6}\s+/gm,znt=/^\s{0,3}(>\s?)+/gm,qnt=/^\s*([-*+]|\d{1,9}[.)])\s+/gm,Knt=/^\[[ xX]\]\s+/gm,Ynt=/^\s{0,3}([-*_])(\s*\1){2,}\s*$/gm,Xnt=/!\[([^\]]*)\]\([^)]*\)/g,Qnt=/\[([^\]]+)\]\([^)]*\)/g,Jnt=/<((?:https?|mailto):[^>\s]+)>/gi,Znt=/<\/?[A-Za-z][^>]*>/g,est=/`+([^`]*)`+/g,tst=/(\*\*|__)(?=\S)([\s\S]*?\S)\1/g,nst=/~~(?=\S)([\s\S]*?\S)~~/g,sst=/(^|[^\w*])\*(?=\S)([^*]*?\S)\*(?!\w)/g,rst=/(^|[^\w])_(?=\S)([^_]*?\S)_(?!\w)/g;function ist(e,t=Vnt){if(typeof e!="string"||e.trim().length===0)return null;const n=e.replace(Wnt," ").replace(Ynt," ").replace($nt,"").replace(znt,"").replace(qnt,"").replace(Knt,"").replace(Xnt,"$1").replace(Qnt,"$1").replace(Jnt,"$1").replace(Znt,"").replace(est,"$1").replace(tst,"$2").replace(nst,"$1").replace(sst,"$1$2").replace(rst,"$1$2"),s=Vx(n,Number.MAX_SAFE_INTEGER);return s.length===0?null:Uq(s,t)}function ast(e,t){const n=e.senderLabel?.trim()||e.conversationName?.trim()||t.untitled,s=e.place.kind==="dm"?t.directMessage:e.place.kind==="channel"?e.place.name?.trim()?t.channel(e.place.name.trim()):e.conversationName?.trim()??t.untitled:e.place.name?.trim()||e.conversationName?.trim()||t.group,r=e.organizationName?t.subtitle(s,e.organizationName):s,i=Math.max(1,Math.floor(e.unreadCount)),a=i>1?e.preview?t.countPreview(i,e.preview):t.count(i):e.preview??t.fallback;return{title:Vx(n,Ont)||t.untitled,subtitle:Vx(r,Bnt)||t.untitled,body:Vx(a,Lnt)||t.fallback}}const _u="all";function got(e){return e}function mot(e){return e===_u?_u:e}function ost(e,t){const n=e.name?.trim();if(n)return n;const s=e.members.filter(i=>i.state!=="removed"&&!(i.kind==="human"&&i.account_id===t));if(e.kind==="dm"){const i=s.find(a=>a.state==="active")??s[0];return i?D_(i.display_label):null}const r=s.filter(i=>i.state==="active").map(i=>D_(i.display_label)).filter(i=>i!==null);return r.length===0?null:r.length<=3?r.join(", "):`${r.slice(0,2).join(", ")} +${r.length-2}`}function vot(e){return e.discoverable===!0&&e.member===!1}function Gq(e){return e.notify??(e.muted?"mute":"all")}function bot(e){return Gq(e)==="mute"}function xot(e){return e==="mute"?"all":"mute"}const wot=[{value:"all",labelKey:"ui.teamBridge.notify.all"},{value:"mention",labelKey:"ui.teamBridge.notify.mention"},{value:"mute",labelKey:"ui.teamBridge.notify.mute"}];function _ot(e){return e==="mention"||e==="mute"?e:"all"}function lst(e,t,n,s){return{...e,conversations:e.conversations.map(r=>r.id===t&&(!s||r.tenant_id===s)?{...r,notify:n,muted:n==="mute"}:r)}}function Cot(e,t){return e.isError&&e.variables?.conversationId===t}function yot(e){return e.members.length>0?e.members.filter(t=>t.state==="active").length:e.member_count??0}function cst(e){const t=(e.conversations??[]).filter(r=>!r.muted).reduce((r,i)=>r+i.unread_count,0),n=(e.organizations??[]).reduce((r,i)=>r+i.unread,0),s=Math.max(t,n);return Number.isFinite(e.total)&&e.total>0?Math.max(0,e.total):s}function ust(e){return[...e].sort((t,n)=>t.seq-n.seq)}function dst(e,t=[],n){const s=new Map(t.map(l=>[l.tenant_id,l.unread])),r=e.filter(l=>l.status==="active");if(!n)return r.map(l=>({tenantId:l.tenant_id,name:l.tenant_name,role:l.role,unread:s.get(l.tenant_id)??0}));const i=new Map(r.map(l=>[l.tenant_id,l])),a=new Set,o=[];for(const l of n){if(a.has(l.tenant_id))continue;a.add(l.tenant_id);const u=i.get(l.tenant_id);o.push({tenantId:l.tenant_id,name:l.tenant_name?.trim()||u?.tenant_name?.trim()||l.tenant_id,role:u?.role??"",unread:s.get(l.tenant_id)??0})}return o}function Sot(e,t,n){return n||e.length!==1?t:e[0].tenantId}function kot(e,t){return e.find(n=>n.tenantId===t)??null}function QF(e){const t=n=>{const s=Date.parse(n);return Number.isNaN(s)?Number.NEGATIVE_INFINITY:s};return[...e].sort((n,s)=>{const r=t(s.last_message_at)-t(n.last_message_at);return r!==0?r:n.id.localeCompare(s.id)})}function Eot(e){return e?.status?.tenants??null}function Tot(e,t){return e!==null?{pending:!1,failed:!1}:{pending:t.isLoading,failed:t.isError}}function Vq(e,t){return t.find(n=>n.tenantId===e.tenant_id)?.name??null}function Rot(e,t,n){return t!==_u?[...e]:QF(e).filter(s=>Vq(s,n)!==null)}function Aot(e){return e?e.state==="signed_out"?"signed_out":e.state==="update_required"||e.update_required?"update_required":e.state==="unavailable"?"unavailable":e.surface_state==="A"?"plan_required":null:null}function hR(e){return e.display_label.trim()||e.account_id}function Fot(e){const t=e,n=typeof t?.status=="number"?t.status:null,s=typeof t?.code=="string"?t.code:null;return n===401?"sign_in":n===403&&s==="bridge_not_available"?"plan":n===403?"refused":n===422||s==="invalid_request"?"invalid":n===400||n===404||t?.name==="ZodError"?"outdated":n===null?"unreachable":"server"}function hst(e,t){return t&&e.account_id===t?"self":e.bridge_enabled&&(e.bridge_state==="active"||e.bridge_state==="paused")?e.bridge_state==="paused"?"paused":"openable":"unavailable"}function fR(e,t,n){const s=e.filter(r=>r.kind!=="dm"||r.status==="archived"||!r.members.some(a=>a.kind==="human"&&a.account_id===t&&a.state!=="removed")?!1:n?r.members.some(a=>a.kind==="human"&&a.account_id===n&&a.state!=="removed"):!0);return s.length===0?null:QF(s)[0]??null}function Dot(e){return e.trim().charAt(0).toUpperCase()||"?"}function fst(e,t){const n=[];for(const s of e){if(t&&s.account_id===t)continue;const r=s.agent;!r||r.state==="disabled"||n.push({person:s,endpointId:r.endpoint_id,agentName:r.name.trim(),paused:r.state==="paused"})}return n}function pR(e,t,n){const s=e.filter(r=>r.kind==="dm"&&r.status!=="archived"&&r.members.some(i=>i.kind==="agent"&&i.account_id===t&&i.state!=="removed")&&(!n||r.members.some(i=>i.kind==="human"&&i.account_id===n&&i.state!=="removed")));return s.length===0?null:QF(s)[0]??null}const ik=["humans","agents"];function Iot(e){const t=[],n=[],s=[],r=[];for(const i of e)i.kind==="channel"?i.builtin&&ik.includes(i.builtin)?t.push(i):n.push(i):i.kind==="group"?s.push(i):r.push(i);return t.sort((i,a)=>ik.indexOf(i.builtin)-ik.indexOf(a.builtin)),{channels:[...t,...n],groups:s,directs:r}}function Pot(e,t,n,s){const r=new Set;for(const i of t){if(s!==void 0&&i.account_id===s)continue;const a=fR(e,i.account_id,s);a&&r.add(a.id)}for(const i of n){const a=pR(e,i.person.account_id,s);a&&r.add(a.id)}return e.filter(i=>!r.has(i.id))}function Not(e){return`${e.kind}:${e.accountId}`}function Mot(e,t,n){if(e===null)return null;switch(e.type){case"conversation":return t.find(s=>s.id===e.id)??null;case"person":return fR(t,e.accountId,n);case"chief":return pR(t,e.accountId,n);case"compose":{if(e.recipients.length!==1)return null;const[s]=e.recipients;return s.kind==="agent"?pR(t,s.accountId,n):fR(t,s.accountId,n)}}}function pst(e){return e.kind==="agent"?{account_id:e.accountId,kind:"agent",endpoint_id:e.endpointId,display_label:e.label.slice(0,64)}:{account_id:e.accountId,kind:"human",display_label:e.label.slice(0,64)}}function Oot(e,t,n){const s=e.filter(i=>{const a=hst(i,t);return a==="openable"||a==="paused"}).map(i=>({kind:"human",accountId:i.account_id,label:hR(i)})),r=fst(e,t).map(i=>({kind:"agent",accountId:i.person.account_id,endpointId:i.endpointId,label:n(i.agentName,hR(i.person))}));return[...s,...r]}function Lot(e){if(e.length===0)return null;const t=e.map(pst);return{kind:e.length===1?"dm":"group",visibility:"private",agentCapable:e.some(n=>n.kind==="agent"),members:t}}const gst="Member";function D_(e){const t=e.trim();return t===""||t===gst?null:t}function mst(e,t,n,s){const r=t.find(l=>l.account_id===e.account_id),i=r?hR(r):null,a=D_(e.display_label);if(e.kind==="human"){const l=s&&s.accountId===e.account_id&&s.name.trim()||null;return i??l??a}const o=r?.agent?.name.trim()||a;return o?i?n(o,i):o:null}const vst=5*6e4;function ak(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function Bot(e,t){const n=ak(t),s=ak(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1)),r=[];let i=null,a=null;for(const o of ust(e)){const l=new Date(o.created_at),u=!Number.isNaN(l.getTime()),d=u?ak(l):null;d!==null&&d!==a&&r.push({type:"day",key:d,date:l,relative:d===n?"today":d===s?"yesterday":null});const h=i!==null&&u&&d===a&&i.sender.account_id===o.sender.account_id&&i.sender.kind===o.sender.kind&&l.getTime()-Date.parse(i.created_at)<vst;r.push({type:"message",message:o,continuation:h}),i=o,d!==null&&(a=d)}return r}async function jot(e){let t=e.remembered.get(e.draftKey);if(t===void 0){const n=await e.create(e.input);if(!n.id)throw new Error("create returned no conversation id");t={id:n.id,tenantId:n.tenant_id??e.tenantId},e.remembered.set(e.draftKey,t)}return await e.post(t.id,{clientRef:e.clientRef,body:e.body,tenantId:t.tenantId}),e.remembered.delete(e.draftKey),t}const Xg=3e4,bst=10;function xst(e,t=bst){return[...e?.organizations??[]].filter(n=>n.eligible&&n.unread>0).sort((n,s)=>s.unread-n.unread||n.tenant_id.localeCompare(s.tenant_id)).slice(0,t)}function wst(e,t){return e.member===!0?!0:e.member===!1||!t?!1:e.members.some(n=>n.kind==="human"&&n.account_id===t&&n.state==="active")}function _st(e,t){return wst(e,t)&&Gq(e)==="all"&&e.builtin!=="agents"}function Cst(e,t,n){return{conversationName:ost(e,t),organizationName:Vq(e,n),senderLabel:D_(e.last_sender_label??"")}}function yst(e){const t=new Map(e.cursors),n=e.rows;if(!e.seeded){for(const a of n)t.set(a.conversation_id,a.latest_seq);return{candidates:[],cursors:t,seeded:!0}}const r=new Map(e.conversations.map(a=>[a.id,a])),i=[];for(const a of n){const o=t.get(a.conversation_id);if(a.unread_count===0||a.latest_seq<=a.last_read_seq||o!==void 0&&a.latest_seq<=o){(o===void 0||a.latest_seq>o)&&t.set(a.conversation_id,a.latest_seq);continue}const l=r.get(a.conversation_id);l!==void 0&&l.latest_seq===a.latest_seq&&(t.set(a.conversation_id,a.latest_seq),_st(l,e.selfAccountId)&&i.push({conversationId:l.id,...l.last_thread_root_id?{threadId:l.last_thread_root_id}:{},tenantId:a.tenant_id,seq:a.latest_seq,...Cst(l,e.selfAccountId,e.organizations),kind:l.kind,name:l.name?.trim()||null,unreadCount:a.unread_count}))}return{candidates:i,cursors:t,seeded:!0}}const Lo=["team-bridge"],Qg=e=>e?["account",e]:[],is={all:Lo,conversations:(e,t)=>[...Lo,"conversations",e,...Qg(t)],conversationsPrefix:[...Lo,"conversations"],messages:(e,t,n)=>[...Lo,"messages",t??"unknown-tenant",e,...Qg(n)],unread:(e,t)=>[...Lo,"unread",e,...Qg(t)],unreadPrefix:[...Lo,"unread"],directory:(e,t)=>[...Lo,"directory",e,...Qg(t)],replies:(e,t,n,s)=>[...Lo,"replies",e,t,n,...Qg(s)],status:[...Lo,"status"],statusFor:e=>[...Lo,"status","account",e??"unresolved-owner"]};function JF(){return U_(),m5()}function Wq(e,t){const n=v0(e),s=e.getQueryData(is.statusFor(t));return!!(t&&n.accountId===t&&s?.account_id===t&&s.state==="ready"&&s.local.enabled&&!s.read_only)}function yj(e,t){const n=e.getQueryData(is.statusFor(t));if(!t||v0(e).accountId!==t||n?.account_id!==t)throw new Error("Team Bridge read owner changed")}const $q=v5;async function Cu(e,t,n){yj(e,t);const s=e.getQueryData(is.statusFor(t)),r=await $q(e,t,n);if(yj(e,t),e.getQueryData(is.statusFor(t))!==s)throw new Error("Team Bridge read authority changed");return r}function qv(e){const t=Gt(),n=v0(t),s=m.useRef({accountId:e??n.accountId,epoch:n.epoch}).current,r=m.useRef(!0);m.useLayoutEffect(()=>(r.current=!0,()=>{r.current=!1}),[]);const i=()=>{const l=v0(t);return r.current&&!!s.accountId&&l.accountId===s.accountId&&l.epoch===s.epoch},a=()=>i()&&Wq(t,s.accountId),o=()=>{if(!a())throw new Error("Team Bridge write authority changed")};return{accountId:s.accountId,isCurrent:a,isReadCurrent:i,assertCurrent:o}}function Sst(e,t){if(e.root.id!==t.rootId||e.root.conversation_id!==t.conversationId||e.root.thread_root_id||e.replies.some(n=>n.conversation_id!==t.conversationId||n.thread_root_id!==t.rootId))throw new Error("Thread response identity mismatch");return e}let Wx=null;function kst(){return Wx}function Hot(e){m.useEffect(()=>{const t=e??null;return Wx=t,()=>{Wx===t&&(Wx=null)}},[e])}function ty(e,t){const n=s=>({onSuccess:(r,i,a)=>s?.onSuccess?.(r,i.input,a),onError:(r,i,a)=>s?.onError?.(r,i.input,a),onSettled:(r,i,a,o)=>s?.onSettled?.(r,i,a.input,o)});return{...e,variables:e.variables?.input,mutate:(s,r)=>e.mutate({input:s,target:t()},n(r)),mutateAsync:(s,r)=>e.mutateAsync({input:s,target:t()},n(r))}}function zq(e){return e===_u?"account":{tenantId:e}}const Est=18e4,Sj=6e4;function Tst(){return typeof document>"u"?Sj:document.visibilityState==="visible"?Est:Sj}function Uot(e,t=!0,n){const s=Gt();return Nn({queryKey:is.conversations(e,n??"unresolved-owner"),queryFn:()=>Cu(s,n,()=>Jr.listConversations(zq(e))),enabled:t&&!!n,staleTime:15e3,refetchOnWindowFocus:!0})}function Got(e,t,n=!0,s){const r=Gt();return Nn({queryKey:is.messages(e??"none",t,s??"unresolved-owner"),queryFn:()=>Cu(r,s,()=>Jr.listMessages(e,{tenantId:t})),enabled:n&&!!s&&!!e,staleTime:5e3,refetchInterval:8e3,refetchOnWindowFocus:!0})}function Rst(e,t){return $q(e,t,async()=>{const n=await Jr.status("surface_open");if(n.state==="ready"&&n.account_id!==t)throw new Error("Team Bridge status owner changed");return n})}function Vot(e,t=!0,n){const s=Gt();return Nn({queryKey:is.directory(e??"none",n??"unresolved-owner"),queryFn:()=>Cu(s,n,()=>Jr.directory(e)),enabled:t&&!!n&&!!e,staleTime:3e4,refetchOnWindowFocus:!0,retry:1})}function Wot(e,t=!0,n){const s=Gt();return y5({queries:e.map(r=>({queryKey:is.directory(r,n??"unresolved-owner"),queryFn:()=>Cu(s,n,()=>Jr.directory(r)),enabled:t&&!!n,staleTime:3e4,refetchOnWindowFocus:!0,retry:1})),combine:r=>{const i={};return r.forEach((a,o)=>{a.data&&(i[e[o]]=a.data.members)}),i}})}function qq(e=!0){const t=Gt(),{accountId:n}=JF();return Nn({queryKey:is.statusFor(n),queryFn:()=>Rst(t,n),enabled:e&&!!n,staleTime:6e4,refetchOnWindowFocus:!0,retry:1})}function Kq(e,t=_u,n={}){const s=Gt();return Nn({queryKey:is.unread(t,n.accountId??"unresolved-owner"),queryFn:()=>Cu(s,n.accountId,()=>Jr.unread(zq(t))),enabled:e&&!!n.accountId,staleTime:3e4,refetchInterval:n.refetchInterval??Tst(),refetchIntervalInBackground:n.refetchIntervalInBackground,refetchOnWindowFocus:!0,retry:1})}async function Yq(e,t,n,s=()=>!0){s()&&(await e.invalidateQueries({queryKey:is.messages(t,n)}),s()&&(await e.invalidateQueries({queryKey:is.conversationsPrefix}),s()&&await e.invalidateQueries({queryKey:is.unreadPrefix})))}function $ot(e,t){const n=Gt(),s=qv(),r=Mn({mutationFn:({input:i,target:a})=>(a.assertCurrent(),Jr.send(a.conversationId,{...i,tenantId:a.tenantId,expectedAccountId:a.accountId})),onSuccess:(i,{target:a})=>Yq(n,a.conversationId,a.tenantId,a.isCurrent)});return ty(r,()=>({...s,conversationId:e,tenantId:t}))}function zot(e,t){const n=Gt(),s=qv(),r=Mn({mutationFn:({target:i})=>(i.assertCurrent(),Jr.join(i.conversationId,i.tenantId,i.accountId)),onSuccess:(i,{target:a})=>Yq(n,a.conversationId,a.tenantId,a.isCurrent)});return ty(r,()=>({...s,conversationId:e,tenantId:t}))}function Ast(e,t){const n=v0(e).accountId,s=()=>Wq(e,n)&&(t?.()??!0),r=()=>{if(!s())throw new Error("Team Bridge write authority changed")},i={queryKey:is.conversationsPrefix,predicate:a=>a.queryKey.at(-1)===n&&a.queryKey.at(-2)==="account"};return{mutationFn:({conversationId:a,notify:o,tenantId:l})=>(r(),Jr.setNotify(a,o,l,n)),onMutate:async({conversationId:a,notify:o,tenantId:l})=>{r(),await e.cancelQueries(i),r();const u=e.getQueriesData(i);return e.setQueriesData(i,d=>d===void 0?d:lst(d,a,o,l)),{snapshots:u}},onError:(a,o,l)=>{if(s())for(const[u,d]of l?.snapshots??[])e.setQueryData(u,d)},onSettled:async()=>{s()&&(await e.invalidateQueries(i),s()&&await e.invalidateQueries({queryKey:is.unreadPrefix}))}}}function qot(){const e=Gt(),t=qv();return Mn(Ast(e,t.isCurrent))}function Kot(e,t){const n=Gt(),s=qv(),r=Mn({mutationFn:({input:i,target:a})=>(a.assertCurrent(),Jr.markRead(a.conversationId,{...i,tenantId:a.tenantId,expectedAccountId:a.accountId})),onSuccess:async(i,{target:a})=>{a.isCurrent()&&(await n.invalidateQueries({queryKey:is.conversationsPrefix}),a.isCurrent()&&await n.invalidateQueries({queryKey:is.unreadPrefix}))}});return ty(r,()=>({...s,conversationId:e,tenantId:t}))}function Yot(e,t=()=>!0){const n=Gt(),s=qv(),r=Mn({mutationFn:({input:i,target:a})=>{if(a.assertCurrent(),!a.isCurrent())throw new Error("Team Bridge write authority changed");return Jr.startConversation({...i,tenantId:a.tenantId,expectedAccountId:a.accountId})},onSuccess:async(i,{target:a})=>{a.isCurrent()&&await n.invalidateQueries({queryKey:is.conversationsPrefix})}});return ty(r,()=>({...s,conversationId:"",tenantId:e,isCurrent:()=>s.isCurrent()&&t()}))}const Fst="display.notifications";function Dst(){return{untitled:p("ui.teamBridge.list.untitled"),directMessage:p("ui.teamBridge.kind.dm"),group:p("ui.teamBridge.kind.group"),channel:e=>p("ui.teamBridge.notify.channel",{channel:e}),subtitle:(e,t)=>p("ui.teamBridge.notify.subtitle",{place:e,organization:t}),count:e=>p("ui.teamBridge.notify.count",{count:e}),countPreview:(e,t)=>p("ui.teamBridge.notify.count_preview",{count:e,preview:t}),fallback:p("ui.teamBridge.notify.body_fallback")}}function Ist(e){return e.kind==="dm"?{kind:"dm"}:{kind:e.kind,name:e.name}}async function Pst(e,t,n){try{return(await e.fetchQuery({queryKey:is.directory(t,n),queryFn:()=>Cu(e,n,()=>Jr.directory(t)),staleTime:3e4,retry:!1})).members}catch{return[]}}async function Nst(e,t,n,s){if(!s())return;let r=t.senderLabel,i=null;const a=void 0;try{const u=a?Sst(await Jr.listReplies(t.conversationId,a,{tenantId:t.tenantId,afterSeq:t.seq,limit:1}),{tenantId:t.tenantId,conversationId:t.conversationId,rootId:a}).replies.find(d=>d.seq===t.seq):(await Jr.listMessages(t.conversationId,{tenantId:t.tenantId,limit:1})).messages[0];if(u&&u.seq>=t.seq){if(u.sender.kind==="human"&&u.sender.account_id===n||!s())return;const d=await Pst(e,t.tenantId,n);r=mst(u.sender,d,(h,f)=>p("ui.teamBridge.chief.label",{agent:h,person:f})),i=ist(u.body)}}catch{}const o=window.api?.desktop?.teamBridge;if(!o)return;const l=ast({senderLabel:r,conversationName:t.conversationName,place:Ist(t),organizationName:t.organizationName,preview:i,unreadCount:t.unreadCount},Dst());s()&&await o.notify({conversationId:t.conversationId,tenantId:t.tenantId,seq:t.seq,title:l.title,subtitle:l.subtitle,body:l.body,viewing:kst()===t.conversationId}).catch(()=>{})}function Mst(e){const t=!!window.api?.desktop?.teamBridge,n=JF(),s=qq(e&&t),r=n.accountId,a=e&&t&&!!r&&s.data?.account_id===r&&s.data?.state==="ready"&&s.data.local.enabled&&!s.data.read_only,o=Gt(),l=wnt({enabled:a}),u=ns(),d=Et(u.data,"settings"),h=Nn({...C6(),enabled:a&&d}),f=d&&ese(h.data?.settings,Fst)===!1,g=m.useRef(f);g.current=f;const v=m.useRef(r);v.current=r;const b=m.useRef(a);b.current=a,m.useEffect(()=>(b.current=a,()=>{b.current=!1}),[a]);const x=l.data,w=Kq(a,_u,{accountId:r,refetchInterval:Xg,refetchIntervalInBackground:!0}),_=m.useMemo(()=>xst(w.data),[w.data]),C=y5({queries:_.map(L=>{const V=L.tenant_id;return{queryKey:is.unread(V,r??"unresolved-owner"),queryFn:()=>Cu(o,r,()=>Jr.unread({tenantId:V})),enabled:a,staleTime:Xg,refetchInterval:Xg,refetchIntervalInBackground:!0,refetchOnWindowFocus:!0,retry:1}})}),S=C.map(L=>`${L.status}:${L.dataUpdatedAt}`).join("|"),y=m.useRef(C);y.current=C;const R=m.useRef(_);R.current=_;const E=Nn({queryKey:is.conversations(_u,r??"unresolved-owner"),queryFn:()=>Cu(o,r,()=>Jr.listConversations("account")),enabled:a,staleTime:Xg,refetchInterval:Xg,refetchIntervalInBackground:!0,refetchOnWindowFocus:!0,retry:1}),F=m.useRef(new Map),A=m.useRef(new Set),I=m.useRef(void 0),P=m.useRef(null),N=[S,w.dataUpdatedAt,E.dataUpdatedAt,(x?.memberships??[]).map(L=>`${L.tenant_id}:${L.tenant_name}`).join(","),r??""].join("#");m.useEffect(()=>{const L=I.current;I.current=r,L!==r&&L!==void 0&&(F.current=new Map,A.current=new Set,P.current=null,o.invalidateQueries({queryKey:is.unreadPrefix}),o.invalidateQueries({queryKey:is.conversationsPrefix}))},[r,o]),m.useEffect(()=>{if(P.current===N||(P.current=N,!w.data))return;for(const J of w.data.organizations??[])J.unread===0&&!A.current.has(J.tenant_id)&&A.current.add(J.tenant_id);if(!E.data)return;const L=y.current,V=R.current,B=dst(x?.memberships??[],w.data.organizations,w.data.organizations??null);let ne=F.current;for(let J=0;J<V.length;J+=1){const Q=V[J],G=L[J]?.data;if(!G)continue;const oe=(G.conversations??[]).map(q=>({conversation_id:q.conversation_id,tenant_id:Q.tenant_id,unread_count:q.unread_count,last_read_seq:q.last_read_seq,latest_seq:q.latest_seq})),ce=yst({conversations:E.data.conversations,rows:oe,organizations:B,selfAccountId:r,cursors:ne,seeded:A.current.has(Q.tenant_id)});if(ne=ce.cursors,ce.seeded&&A.current.add(Q.tenant_id),g.current||!r)continue;const M=r,W=BI(o),j=o.getQueryData(is.statusFor(M));for(const q of ce.candidates)Nst(o,q,M,()=>v.current===M&&BI(o)===W&&o.getQueryData(is.statusFor(M))===j&&b.current&&!g.current)}F.current=ne},[N,w.data,E.data,x,r,o])}function Ost(){const{data:e}=ns();m.useEffect(()=>{e&&kse(e)},[e]);const t=WR(),n=Gt(),s=m.useRef(null);m.useEffect(()=>{const r=t.configChange;if(!r)return;const i=`${r.epoch}:${r.seq}`;s.current!==i&&r.changedKeys.includes(Yo)&&(s.current=i,n.invalidateQueries({queryKey:il.capabilities}),n.invalidateQueries({queryKey:il.settings}),!tse()&&oo(p("ui.settings.language.external_notice",{language:r.language}),{id:"i18n-language-external"}))},[t.configChange,n])}function Lst(e,t){if(e.defaultPrevented||e.repeat||e.isComposing||!(e.metaKey||e.ctrlKey))return null;const n=nse(e);if(n===null)return null;const s=dQ(t.bindings).get(n);return s===void 0||ER(e.target)||!_pe(Xq(s),t.route)?null:s}const Xq=e=>e.slice(6);function Bst(e){const t=De.getState(),n=t.activeDraftKey?t.drafts[t.activeDraftKey]:void 0,s=vv(t.activeDraftKey,n?.sessionId,t.activeSessionId)??null;_d(Xq(e),{sessionId:s,askScope:s===null?"fleet":"session",via:"chord"})}function jst(){m.useEffect(()=>{const e=t=>{const n=st.getState(),s=Lst(t,{bindings:n.shortcutBindings,route:n.rightSlotRoute});s!==null&&(t.preventDefault(),Bst(s))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[])}const Hst=""+new URL("radient-icon-1024x1024-D_JJedvo.png",import.meta.url).href,Qq=Vp()(Xj(e=>({hasBeenNotified:!1,setHasBeenNotified:t=>{e({hasBeenNotified:t})}}),{name:"low-credits-storage"})),Ust=({open:e,onClose:t,onGoToConsole:n})=>{Qe();const{setHasBeenNotified:s}=Qq(),{prices:r,isLoading:i,error:a}=sse(),o=d=>typeof d!="number"?"$...":p("ui.common.account.low_credits_dialog.detail",{detail:String(d.toFixed(2))}),l=()=>{s(!0),t()},u=()=>{s(!0),n()};return c.jsx(Su,{open:e,onClose:l,title:c.jsxs(c.Fragment,{children:[c.jsx("img",{src:Hst,alt:p("ui.common.account.low_credits_dialog.radient_icon"),className:"size-7"}),p("ui.common.account.low_credits_dialog.running_low_on_radient_credits")]}),maxWidth:"sm",fullWidth:!1,actions:c.jsxs(c.Fragment,{children:[c.jsx(bv,{onClick:l,children:p("ui.common.account.low_credits_dialog.maybe_later")}),c.jsx(xv,{onClick:u,startIcon:c.jsx($c,{size:18}),className:"min-w-55",children:p("ui.common.account.low_credits_dialog.get_more_credits")})]}),children:c.jsxs("div",{className:"flex flex-col items-center gap-4 py-2 text-center",children:[c.jsxs("p",{className:"text-body-sm text-ink-muted",children:[p("ui.common.account.low_credits_dialog.unlock_the_full_power_of_local_operator_with")," ",c.jsx("span",{className:"font-bold text-accent",children:p("ui.common.account.low_credits_dialog.radient_pass")}),"."]}),c.jsx("p",{className:"text-body-sm text-ink-muted",children:p("ui.common.account.low_credits_dialog.radient_automatic_is_often_cheaper_than_bringing_your_own_key_its")}),c.jsx("p",{className:"text-body-sm text-ink-muted",children:p("ui.common.account.low_credits_dialog.it_s_pay_as_you_go_with_no_commitments_load_up_what_you_need_star")}),c.jsxs("p",{className:"text-body-sm text-ink-muted",children:[p("ui.common.account.low_credits_dialog.plus_get")," ",c.jsx("span",{className:"font-medium text-ink",children:i?c.jsx(An,{size:"sm",className:"me-0.5 align-middle"}):o(r?.default_registration_credits)})," ",p("ui.common.account.low_credits_dialog.in_bonus_credits_with_your_first_purchase"),a&&c.jsx("span",{className:"mt-1 block text-meta text-danger",children:p("ui.common.account.low_credits_dialog.could_not_load_bonus_credit_information")})]}),c.jsx("p",{className:"text-meta text-ink-dim",children:p("ui.common.account.low_credits_dialog.you_can_also_reach_the_radient_console_from_settings_at_any_time")})]})})},Gst=(e,t)=>t?gk(e.filter(n=>n.session_id===t)).length:0;function Vst(e){return De(t=>Gst(t.sessions,e))}const Wst=(e,t)=>t?e.some(n=>n.session_id===t&&n.status?.code==="busy"):!1;function $st(e){return De(t=>Wst(t.sessions,e))}const zst=[];function qst(){const{state:e}=fC(),t=e?.pendingConsent??zst,n=FH(s=>WN(t,s));return m.useEffect(()=>{t.length>0&&SA()},[t]),WN(t,n)}const Jq={approvals:["desktop","mesh","approvals"]},Kst=15e3,Yst=new Set(["requested","approved","connecting","failed"]);function Xst(e){return Yst.has(e)}function Qst(e){return e==="requested"}function Jst(e){return e.filter(t=>Qst(t.state)).length}function Xot(e){return e.state==="requested"&&e.canApproveHere!==!1&&(e.kind==="device"||e.kind==="machine")}function Qot(e){return Xst(e)}function Jot(e){switch(e){case"requested":return p("ui.mesh.mesh_approvals.waiting_for_you");case"approved":return p("ui.mesh.mesh_approvals.approved");case"connecting":return p("ui.mesh.mesh_approvals.connecting");case"connected":return p("ui.mesh.mesh_approvals.connected");case"denied":return p("ui.mesh.mesh_approvals.denied");case"expired":return p("ui.mesh.mesh_approvals.expired");case"failed":return p("ui.mesh.mesh_approvals.failed");default:return e}}function Vc(e){return typeof e=="object"&&e!==null}function Zst(e){const t=Vc(e)?e:{};return{deviceId:Gn(t.device_id),name:Gn(t.name),host:Gn(t.host),user:Gn(t.user),transport:Gn(t.transport),hostKeyFp:Gn(t.host_key_fp)}}function ert(e){const t=Vc(e)?e:{};return{connect:wy(t.connect,!1),install:wy(t.install,!1),anchor:Vc(t.anchor),networkId:Gn(t.network_id),role:Gn(t.role),unattended:wy(t.unattended,!1),grants:wk(t.grant)}}function trt(e){const t=Array.isArray(e)?e:e?.approvals??[];if(!Array.isArray(t))return[];const n=[];for(const s of t){if(!Vc(s))continue;const r=Gn(s.approval_id),i=Gn(s.state);if(!r||!i)continue;const a=Vc(s.what)&&Object.prototype.hasOwnProperty.call(s.what,"credential_inheritance"),o=Object.prototype.hasOwnProperty.call(s,"kind")?Gn(s.kind):void 0,l=a||o==="credential_inheritance"?"credential":o!==void 0&&!["device_onboard","local_authority"].includes(o)?"unknown":!Vc(s.device)&&Vc(s.machine)?"machine":"device",u=Vc(s.requested_by)?s.requested_by:{};n.push({approvalId:r,state:i,kind:l,summary:Gn(s.summary)||void 0,details:Array.isArray(s.details)&&s.details.every(d=>typeof d=="string")?s.details.slice():void 0,canApproveHere:Object.prototype.hasOwnProperty.call(s,"can_approve_here")?s.can_approve_here===!0:void 0,approveRemedy:Gn(s.approve_remedy)||void 0,where:Zst(l==="machine"?s.machine:s.device),what:ert(s.what),requestedBy:{surface:Gn(u.surface),sessionId:Gn(u.session_id),deviceId:Gn(u.device_id)},expiresAt:hQ(s.expires_at)})}return n}function nrt(e){return e.kind==="machine"?p("ui.mesh.mesh_approvals.this_machine"):xk({device_id:e.where.deviceId,name:e.where.name})}function Zot(e,t){if(e.kind==="credential"||e.kind==="unknown"||e.canApproveHere===!1){if(e.summary)return e.summary;if(e.kind==="credential"||e.kind==="unknown")return kj(e)}const n=kj(e),s=rrt(e,t).map(r=>r.clause);return s.length?p("ui.mesh.mesh_approvals.approval_title_with_clauses",{head:n,clauses:srt(s)}):p("ui.mesh.mesh_approvals.approval_title",{head:n})}function kj(e){return e.kind==="credential"?e.summary||p("ui.mesh.approval.credential_title"):e.kind==="unknown"?e.summary||p("ui.mesh.approval.unknown_title"):e.canApproveHere===!1&&e.summary?e.summary:e.kind==="machine"?p("ui.mesh.mesh_approvals.set_up_operator_authority_on_this_machine"):p("ui.mesh.mesh_approvals.onboard_subject",{subject:nrt(e)})}function srt(e){return e.length===1?e[0]:p("ui.mesh.mesh_approvals.join_clauses",{clauses:e.slice(0,-1).join(", "),last:e[e.length-1]})}function elt(e){if(e.kind==="credential"||e.kind==="unknown")return null;const{user:t,host:n,transport:s,name:r}=e.where,i=[n?t?`${t}@${n}`:n:"",s?p("ui.mesh.mesh_approvals.via_transport",{transport:s}):"",r&&r!==n?`(${r})`:""].filter(Boolean);return i.length?i.join(" "):null}function tlt(e){return e.kind==="credential"||e.kind==="unknown"?null:e.where.hostKeyFp||null}function nlt(e){const{surface:t,sessionId:n}=e.requestedBy,s=[t||"",n?p("ui.mesh.mesh_approvals.session_suffix",{suffix:n.slice(-6)}):""].filter(Boolean);return s.length?p("ui.mesh.mesh_approvals.asked_by",{requester:s.join(" · ")}):null}function rrt(e,t){if(e.kind==="credential"||e.kind==="unknown")return[];const{connect:n,install:s,anchor:r,networkId:i,role:a,unattended:o,grants:l}=e.what,u=[];if(n&&u.push({term:"connect",clause:e.where.transport?p("ui.mesh.mesh_approvals.connect_over",{transport:e.where.transport}):p("ui.mesh.mesh_approvals.connect_to_it"),consequence:e.where.transport?p("ui.mesh.mesh_approvals.may_connect_over",{transport:e.where.transport}):p("ui.mesh.mesh_approvals.this_machine_may_connect_to_it")}),s&&u.push({term:"install",clause:e.kind==="machine"?p("ui.mesh.mesh_approvals.install_local_operator"):p("ui.mesh.mesh_approvals.install_local_operator_there"),consequence:e.kind==="machine"?p("ui.mesh.mesh_approvals.local_operator_is_installed_on_this_machine"):p("ui.mesh.mesh_approvals.local_operator_is_installed_on_it")}),r&&u.push({term:p("ui.mesh.mesh_approvals.install_operator_anchor"),clause:p("ui.mesh.mesh_approvals.check_approvals_signed_on_your_machines"),consequence:p("ui.mesh.mesh_approvals.that_device_can_check_approvals_signed_on")}),i){const d=t?.get(i),h=p("ui.mesh.mesh_approvals.join_network",{network:d||i,role:a||"?"});u.push({term:h,clause:h,consequence:p("ui.mesh.mesh_approvals.joins_network",{network:d||i,role:a||"?"})})}o&&u.push({term:p("ui.mesh.mesh_approvals.trust_unattended_sessions"),clause:p("ui.mesh.mesh_approvals.run_sessions_there_without_an_approval_prompt"),consequence:p("ui.mesh.mesh_approvals.sessions_you_start_on_that_device_run")});for(const d of irt(l,o)){const h=art()[d];u.push({term:h?.term??p("ui.mesh.mesh_approvals.grant_capability",{grant:d}),clause:ort()[d]??p("ui.mesh.mesh_approvals.use_capability",{grant:d}),consequence:h?.gloss??p("ui.mesh.mesh_approvals.may_use_capability",{grant:d})})}return u}function irt(e,t){const n=new Set;for(const s of e){const r=String(s??"").trim();r&&(t&&r==="unattended"||n.add(r))}return[...n]}const art=()=>({unattended:{term:p("ui.mesh.mesh_approvals.trust_unattended_sessions"),gloss:p("ui.mesh.mesh_approvals.sessions_you_start_on_that_device_run")},broker_credential:{term:p("ui.mesh.mesh_approvals.borrow_logins_there"),gloss:p("ui.mesh.mesh_approvals.your_sessions_may_use_the_logins_stored")}}),ort=()=>({list:p("ui.mesh.mesh_approvals.see_its_sessions"),view:p("ui.mesh.mesh_approvals.watch_a_session_there"),prompt:p("ui.mesh.mesh_approvals.send_prompts_to_a_session_there"),steer:p("ui.mesh.mesh_approvals.steer_a_running_turn_there"),stop:p("ui.mesh.mesh_approvals.stop_a_session_there"),slash:p("ui.mesh.mesh_approvals.run_slash_commands_there"),delete:p("ui.mesh.mesh_approvals.archive_or_delete_a_session_there"),move:p("ui.mesh.mesh_approvals.move_sessions_to_or_from_there"),broker_credential:p("ui.mesh.mesh_approvals.borrow_the_logins_stored_there"),approve:p("ui.mesh.mesh_approvals.answer_approval_prompts_there"),unattended:p("ui.mesh.mesh_approvals.run_sessions_there_without_an_approval_prompt")});function slt(e,t){if(e===null||e<=0)return null;const n=e-t;if(n<=0)return null;if(n<60)return p("ui.mesh.mesh_approvals.expires_in_under_a_minute");const s=Math.ceil(n/60);if(s<90)return p("ui.mesh.mesh_approvals.expires_minutes",{count:s});const r=Math.ceil(s/60);return p("ui.mesh.mesh_approvals.expires_hours",{count:r})}function lrt(e,{poll:t=!0}={}){return Nn({queryKey:Jq.approvals,enabled:e,queryFn:async()=>trt(await at({op:"approvals.list"})),retry:!1,staleTime:t?1e4:Number.POSITIVE_INFINITY,refetchInterval:e&&t?Kst:!1,refetchOnWindowFocus:t})}function rlt(){const e=Gt();return Mn({mutationFn:async t=>{const n=t.decision==="approve"?{op:"approvals.approve",approvalId:t.approvalId}:{op:"approvals.deny",approvalId:t.approvalId};await at(n)},onSettled:()=>{e.invalidateQueries({queryKey:Jq.approvals}),e.invalidateQueries({queryKey:nc.networks}),e.invalidateQueries({queryKey:nc.peers})}})}function ilt(e){const t=e?.message;return typeof t=="string"&&t.trim()?t.trim():p("ui.mesh.mesh_approvals.the_approvals_could_not_be_read")}function alt(e){const t=e;return{code:Gn(t?.code)||"approval_refused",sentence:Gn(t?.message)||p("ui.mesh.mesh_approvals.decision_could_not_be_answered")}}const crt="/team-bridge",urt="nav-team-bridge",drt="nav-team-bridge-badge";function hrt(e){const{accountId:t}=JF(),n=qq(e),s=e&&!!t&&n.data?.account_id===t,r=Kq(s,_u,{accountId:t});if(!e)return null;const i=s&&r.data?cst(r.data):0;return{icon:k0,label:p("ui.teamBridge.nav.label"),path:crt,tourTag:urt,attention:i,attentionTag:drt,attentionName:a=>p("ui.teamBridge.nav.unread",{count:a})}}const gR={aida:"visible",library:"visible",projects:"visible",agents:"visible",schedules:"visible",browser:"visible","team-bridge":"more","agent-hub":"more",mesh:"more"},I_={visible:u0.filter(e=>gR[e]==="visible"),more:u0.filter(e=>gR[e]==="more")},Ej=new Map(u0.map((e,t)=>[e,t])),frt=new Set(u0);function prt(e){return typeof e=="string"&&frt.has(e)}function ok(e,t){if(e===t)return!0;if(e.visible.length!==t.visible.length||e.more.length!==t.more.length)return!1;for(let n=0;n<e.visible.length;n+=1)if(e.visible[n]!==t.visible[n])return!1;for(let n=0;n<e.more.length;n+=1)if(e.more[n]!==t.more[n])return!1;return!0}function Za(e,t){return e.visible.includes(t)?"visible":"more"}function $x(e,t,n){return e[t].filter(s=>n.has(s))}function grt(e,t,n,s){if(!s.has(t))return null;const r=Za(e,t),i=$x(e,r,s),a=i.indexOf(t);if(a<0)return null;const o=a+n;if(o<0||o>=i.length)return null;const l=i[o],u=e[r],d=u.indexOf(t),h=u.indexOf(l);if(d<0||h<0)return null;const f=u.slice();f[d]=l,f[h]=t;const g={visible:e.visible.slice(),more:e.more.slice()};return g[r]=f,g}function Tj(e,t,n){const s={visible:e.visible.filter(r=>r!==t),more:e.more.filter(r=>r!==t)};return{...s,[n]:[...s[n],t]}}function mrt(e,t,n,s,r){if(s===t)return{visible:e.visible.slice(),more:e.more.slice()};if(s!==null&&(!r.has(s)||!e[n].includes(s)))return null;const i={visible:e.visible.filter(l=>l!==t),more:e.more.filter(l=>l!==t)},a=i[n].slice(),o=s===null?a.length:a.indexOf(s);return o<0?null:(a.splice(o,0,t),{...i,[n]:a})}function Rj(e,t){for(const n of u0){if(gR[n]!==t||e.visible.includes(n)||e.more.includes(n))continue;const s=Ej.get(n)??0,r=e[t];let i=-1,a=-1,o=-1,l=Number.POSITIVE_INFINITY;for(let d=0;d<r.length;d+=1){const h=Ej.get(r[d])??0;h<s&&h>a&&(a=h,i=d),h>s&&h<l&&(l=h,o=d)}const u=i>=0?i+1:o>=0?o:r.length;r.splice(u,0,n)}}function mR(e){const t={visible:[],more:[]},n=new Set;if(e&&typeof e=="object"){const s=e;for(const r of["visible","more"]){const i=s[r];if(Array.isArray(i))for(const a of i)prt(a)&&(n.has(a)||(n.add(a),t[r].push(a)))}}return Rj(t,"visible"),Rj(t,"more"),t}const gf={layout:["desktop","sidebar_layout"]};async function vrt(){const e=await at({op:"sidebar_layout.get"});return mR(e.layout)}function brt(e){const t=Gt(),n=Nn({queryKey:gf.layout,enabled:e,queryFn:vrt,staleTime:Number.POSITIVE_INFINITY,retry:pv}),s=m.useRef(0),r=Mn({scope:{id:"sidebar-layout"},mutationFn:async u=>{const d=await at({op:"sidebar_layout.set",layout:u});return mR(d.layout)},retry:fQ,onMutate:async u=>{const d=++s.current;await t.cancelQueries({queryKey:gf.layout});const h=t.getQueryData(gf.layout);return t.setQueryData(gf.layout,u),{previous:h,seq:d}},onError:(u,d,h)=>{h?.seq===s.current&&h.previous&&t.setQueryData(gf.layout,h.previous),sn(p("ui.shell.sidebar_navigation.save_failed"))},onSettled:(u,d,h,f)=>{f?.seq===s.current&&t.invalidateQueries({queryKey:gf.layout})}}),i=e&&n.data!==void 0;return{layout:i?n.data:I_,canCustomise:i,save:u=>{i&&r.mutate(u)},reset:()=>{i&&r.mutate(mR(I_))}}}const Aj=e=>{const t=ase(e.type),n=typeof e.percent=="number"?`, ${Math.round(e.percent)}%`:"";return p("ui.common.updates.update_foot_icon.in_progress",{subject:t,percent:n})},Zq=e=>ise({type:e.type,version:e.offer.version}),xrt=e=>{const t=e.map(s=>Zq(s)),n=t.slice(1).reduce((s,r)=>p("ui.common.updates.update_foot_icon.subject_join",{left:s,right:`${r.charAt(0).toLowerCase()}${r.slice(1)}`}),t[0]);return p("ui.common.updates.update_foot_icon.available_show_the_update_notice",{joined:n})},wrt=({surfaces:e,inflight:t,onShow:n,onDismiss:s})=>{if(Qe(),t===null&&e.length===0)return null;if(t!==null)return c.jsx(gt,{side:"top",collisionPadding:8,content:Aj(t),children:c.jsx("output",{"data-update-foot-icon":"","data-update-foot-icon-state":"inflight","aria-label":Aj(t),className:"flex size-8 shrink-0 items-center justify-center text-accent",children:c.jsx(qr,{className:"size-4 shrink-0 motion-safe:animate-spin","aria-hidden":"true"})})});const r=e.find(i=>(i.offer.summary??"").trim()!=="");return c.jsx(gt,{side:"top",collisionPadding:8,content:c.jsxs("div",{className:"flex max-w-64 flex-col gap-0.5",children:[e.map(i=>c.jsxs("span",{className:"truncate text-ink",children:[Zq(i)," ",p("ui.common.updates.update_foot_icon.available")]},i.type)),r?c.jsx("span",{className:"truncate text-ink-muted",children:(r.offer.summary??"").trim()}):null,c.jsx("span",{className:"whitespace-nowrap text-ink-muted",children:p("ui.common.updates.update_foot_icon.show_the_update_notice")})]}),children:c.jsx("button",{type:"button","data-update-foot-icon":"","data-update-foot-icon-state":"available","aria-label":xrt(e),onClick:n,onKeyDown:i=>{i.key!=="Escape"||!s||(i.stopPropagation(),s())},className:T("flex size-8 shrink-0 items-center justify-center rounded-sm text-accent","transition-colors duration-fast ease-out-quart","hover:bg-row-hover hover:text-ink"),children:c.jsx(VR,{className:"size-4 shrink-0","aria-hidden":"true"})})})},Fj=()=>{const e=dr(g=>g.followed),t=dr(g=>g.running),n=dr(g=>g.offers),s=dr(g=>g.detailOpen),r=dr(g=>g.inflight),i=dr(g=>g.downloadPercent),a=dr(g=>g.openNotice),o=dr(g=>g.noticeOpen),l=dr(g=>g.dismissNotice),u=m.useMemo(()=>{const g={followed:e,running:t,offers:n,detailOpen:s};return p6.filter(v=>rse(g,v)).map(v=>{const b=n[v];return b?{type:v,offer:b}:null}).filter(v=>v!==null)},[e,t,n,s]),d=m.useMemo(()=>r[_n.BACKEND]?{type:_n.BACKEND,percent:null}:r[_n.UI]?{type:_n.UI,percent:i[_n.UI]}:null,[r,i]),h=m.useCallback(()=>a(),[a]),f=m.useCallback(()=>l(),[l]);return c.jsx(wrt,{surfaces:u,inflight:d,onShow:h,onDismiss:o?f:void 0})},Dj=({expanded:e})=>(Qe(),c.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[c.jsx(S6,{className:"size-6",label:e?void 0:p("ui.shell.collapsible_app_logo.local_operator")}),e&&c.jsx("span",{className:"truncate font-semibold text-body text-ink",children:p("ui.shell.collapsible_app_logo.local_operator")})]})),vR=nt.memo(({expanded:e,useAuth:t=!1})=>{const n=AR(),s=xi(),{user:r,isAuthenticated:i,accountRead:a,signOut:o}=YR(),l=a==="checking"?p("ui.shell.user_profile_sidebar.checking_account"):jI(a)?p("ui.shell.user_profile_sidebar.account_unavailable"):null,u=r?.name??l??p("ui.shell.user_profile_sidebar.user"),d=jI(a),h=r?.email??"",f=d?p("ui.shell.user_profile_sidebar.reconnect_radient"):h,g=d?"/settings?section=providers&provider=radient":"/settings",v=d?p("ui.shell.user_profile_sidebar.reconnect_radient"):p("ui.shell.user_profile_sidebar.account_settings"),b=m.useCallback(async()=>{i&&(await o(),window.location.reload())},[i,o]),x=m.useMemo(()=>{const C=r?.name;return C?C.split(" ").map(S=>S.charAt(0)).join("").toUpperCase().substring(0,2):null},[r?.name]),w=c.jsxs("button",{type:"button",onClick:t?void 0:()=>s(g),"aria-label":e?void 0:v,className:T("flex w-full min-w-0 items-center gap-2 rounded-sm transition-colors duration-fast ease-out-quart hover:bg-row-hover",e?"px-2 py-1.5":"justify-center py-1.5"),children:[c.jsx(Wj,{className:"size-7 shrink-0",children:c.jsx($j,{className:"border border-control bg-elevated text-ink",children:x??c.jsx(Yle,{size:14,"aria-hidden":"true"})})}),e&&u&&c.jsxs("span",{className:"min-w-0 text-start",children:[c.jsx("span",{className:"block truncate text-body-sm text-ink",children:u}),f&&c.jsx("span",{className:T("block truncate text-meta",d?"text-accent":"text-ink-dim"),children:f})]})]}),_=e?w:c.jsx(vd,{content:v,side:n==="rtl"?"left":"right",children:w});return t?c.jsxs(La,{children:[e?c.jsx(sa,{asChild:!0,children:w}):c.jsx(vd,{content:v,side:n==="rtl"?"left":"right",children:c.jsx(sa,{asChild:!0,children:w})}),c.jsxs(Ba,{align:"end",side:"top",className:"min-w-50",children:[d?c.jsxs(Ot,{onSelect:()=>s(g),children:[c.jsx(Uj,{size:16,"aria-hidden":"true"}),p("ui.shell.user_profile_sidebar.reconnect_radient")]}):null,c.jsxs(Ot,{onSelect:()=>s("/settings"),children:[c.jsx(Yc,{size:16,"aria-hidden":"true"}),p("ui.shell.user_profile_sidebar.settings")]}),c.jsxs(Ot,{children:[c.jsx(xle,{size:16,"aria-hidden":"true"}),p("ui.shell.user_profile_sidebar.privacy_and_security")]}),c.jsx(Js,{}),c.jsxs(Ot,{onSelect:b,className:"text-danger focus:bg-danger-wash focus:text-danger",children:[c.jsx(Uoe,{size:16,"aria-hidden":"true"}),p("ui.shell.user_profile_sidebar.sign_out")]})]})]}):_});vR.displayName="UserProfileSidebar";const _rt=()=>{const e=WR(),t=ns(),n=De(u=>u.setCataloguePageable),s=De(u=>u.setCatalogueActivityHead),r=De(u=>u.fetchSessions),i=Et(t.data,"session_catalogue_page"),a=Et(t.data,"session_catalogue_sort");m.useEffect(()=>{n(i)},[i,n]),m.useEffect(()=>{s(a)},[a,s]);const o=Yr(t.data,"session_catalogue",2)==="enabled",l=m.useCallback(()=>r(i?o6:B_,i),[r,i]);return m.useEffect(()=>{o&&l()},[o,l,e.catalogueRevision]),null},Ij="flex h-[30px] w-full items-center gap-2 rounded-md px-2 text-body-sm transition-colors duration-fast ease-out-quart",Crt=()=>{Qe();const e=AR()==="rtl",t=xi(),n=Oue(),{expanded:s,onCollapse:r}=ose(),i=st(ae=>ae.openCommandPalette),a=ns(),o=hrt(Et(a.data,"team_bridge_conversations")),l=De(ae=>ae.activeSessionId),u=qst(),d=Yr(a.data,"peers")==="enabled",h=PA(d),f=Yr(a.data,"approvals")==="enabled",g=lrt(h==="member"&&f,{poll:!0}),v=Jst(g.data??[]),b=Et(a.data,"projects",1),x=Et(a.data,"library",1),w=st(ae=>ae.sidebarOverflowExpanded),_=st(ae=>ae.setSidebarOverflowExpanded),C=Et(a.data,"aida",1),S=Sv(C),y=C&&S.data?.enabled===!0,R=S.data?.name??"Aida",E=ehe(),F=Vst(S.data?.session_id),A=$st(S.data?.session_id),I=()=>{E(t,S.data).catch(ae=>sn(_f(ae)))},P=new Map;y&&P.set("aida",{icon:zae,label:R,path:"/chat",isActive:n==="chat"&&!!S.data?.session_id&&l===S.data?.session_id,tourTag:"nav-item-aida",onSelect:I,attention:F,attentionTag:"nav-aida-badge",attentionName:ae=>p("ui.shell.sidebar_navigation.aida_missed",{name:R,count:ae}),working:A,workingName:p("ui.shell.sidebar_navigation.aida_working",{name:R})}),x&&P.set("library",{icon:Aoe,label:p("ui.library.page.title"),path:"/library",isActive:n==="library",tourTag:"nav-item-library"}),b&&P.set("projects",{icon:B8,label:p("ui.shell.sidebar_navigation.projects"),path:"/projects",isActive:n==="projects",tourTag:"nav-item-projects"}),P.set("agents",{icon:hu,label:p("ui.shell.sidebar_navigation.agents"),path:"/agents",isActive:n==="agents",tourTag:"nav-item-agents"}),P.set("schedules",{icon:O8,label:p("ui.shell.sidebar_navigation.schedules"),path:"/schedules",isActive:n==="schedules",tourTag:"nav-item-schedules"}),P.set("browser",{icon:du,label:p("ui.shell.sidebar_navigation.browser"),path:"/browser",isActive:n==="browser",tourTag:"nav-item-browser",attention:u,attentionTag:"nav-browser-badge",attentionName:ae=>p("ui.shell.sidebar_navigation.browser_waiting",{count:ae,countText:String(ae)})}),o&&P.set("team-bridge",{...o,isActive:n==="team-bridge"}),P.set("agent-hub",{icon:$8,label:p("ui.shell.sidebar_navigation.agent_hub"),path:"/agent-hub",isActive:n==="agent-hub",tourTag:"nav-item-agent-hub"}),h==="member"&&P.set("mesh",{icon:l5,label:p("ui.shell.sidebar_navigation.mesh"),path:"/mesh",isActive:n==="mesh",tourTag:"nav-item-mesh",attention:v,attentionTag:"nav-mesh-badge",attentionName:ae=>p("ui.shell.sidebar_navigation.mesh_waiting",{count:ae,countText:String(ae)})});const N=new Set(P.keys()),L=Et(a.data,"sidebar_layout",1),{layout:V,canCustomise:B,save:ne,reset:J}=brt(L),Q=B?V:I_,G=$x(Q,"visible",N),oe=$x(Q,"more",N),[ce,M]=m.useState(!1),W=w||ce||oe.some(ae=>P.get(ae)?.isActive),[j,q]=m.useState(""),[U,fe]=m.useState(null),ye=m.useRef(new Map),Ae=ae=>{requestAnimationFrame(()=>ye.current.get(ae)?.focus())},[z,Te]=m.useState(null),[H,ve]=m.useState(null),Fe=m.useRef(null),ie=m.useRef(null),re=m.useRef(null),ue=m.useRef(0),ke=m.useRef(0),Oe=m.useRef(null),he=m.useRef(null),Ee=m.useRef(!1),Ze=ae=>{const te=Fe.current;return te===null?[]:Array.from(te.querySelectorAll("[data-sidebar-row]")).filter(me=>me.dataset.sidebarRow!==ae).map(me=>{const xe=me.getBoundingClientRect();return{id:me.dataset.sidebarRow??"",top:xe.top,bottom:xe.bottom}})},Tt=(ae,te)=>{const me=Fe.current;if(me===null)return null;const xe=me.getBoundingClientRect(),Le=Ze(te),Ke=Re=>Le.filter(Ye=>Za(Q,Ye.id)===Re);let ct=null;if(ae.kind==="more"){const Re=Ke("more").at(-1);if(Re)ct=Re.bottom;else{const Ye=me.querySelector("[data-sidebar-more]");ct=Ye?Ye.getBoundingClientRect().bottom:xe.top+2}}else if(ae.kind==="band"){const Re=Za(Q,te),kt=Ke(Re==="more"?"visible":"more").at(-1);if(kt)ct=kt.bottom;else if(Re==="more"){const Vt=me.querySelector("[data-sidebar-more]");ct=Vt?Vt.getBoundingClientRect().top:xe.top+2}}else{const Re=Le[ae.slot];Re?ct=Re.top:ct=Le.at(-1)?.bottom??xe.top+2}return ct===null?null:Math.round(ct-xe.top+me.scrollTop)},St=()=>{he.current!==null&&(window.clearTimeout(he.current),he.current=null)},Ve=(ae,te)=>{const me=ie.current;if(me===null||!me.armed)return;const xe=document.elementFromPoint(ae,te),Le=!!xe?.closest("[data-sidebar-more]"),Ke=!!xe?.closest("[data-sidebar-drop-band]");let ct;if(Le)ct={kind:"more"},Za(Q,me.id)==="visible"&&!W&&he.current===null&&(he.current=window.setTimeout(()=>{he.current=null,M(!0),requestAnimationFrame(()=>$e.current(ue.current,ke.current))},400));else if(St(),Ke)ct={kind:"band"};else{const Re=Ze(me.id),Ye=yz(Re,me.id,te),kt=Re[Ye];let Vt="visible";if(kt)Vt=Za(Q,kt.id);else{const hn=Re.at(-1);Vt=hn?Za(Q,hn.id):"visible"}ct={kind:"slot",slot:Ye,beforeId:kt?.id??null,region:Vt}}re.current=ct,ve(Tt(ct,me.id))},$e=m.useRef(Ve);$e.current=Ve;const ft=()=>{Oe.current!==null&&(cancelAnimationFrame(Oe.current),Oe.current=null)},pe=()=>{Oe.current=null;const ae=ie.current,te=Fe.current;if(ae===null||!ae.armed||te===null)return;const me=te.getBoundingClientRect(),xe=ke.current,Le=te.scrollHeight-te.clientHeight;let Ke=0;xe-me.top<24&&te.scrollTop>0?Ke=-1:me.bottom-xe<24&&te.scrollTop<Le&&(Ke=1),Ke!==0&&(te.scrollTop+=Ke*8,$e.current(ue.current,xe)),Oe.current=requestAnimationFrame(pe)},et=(ae,te)=>{if(B&&te.button===0&&!(te.altKey||te.ctrlKey||te.metaKey||te.shiftKey)){try{te.currentTarget.setPointerCapture(te.pointerId)}catch{}ie.current={pointerId:te.pointerId,id:ae,armed:!1,startX:te.clientX,startY:te.clientY},ue.current=te.clientX,ke.current=te.clientY}},tt=ae=>{const te=ie.current;if(!(te===null||te.pointerId!==ae.pointerId)){if(ue.current=ae.clientX,ke.current=ae.clientY,!te.armed){if(Math.hypot(ae.clientX-te.startX,ae.clientY-te.startY)<5)return;te.armed=!0,Ee.current=!0,Te(te.id);const me=P.get(te.id);me&&q(p("ui.shell.sidebar_navigation.drag_armed",{name:me.label})),Oe.current===null&&(Oe.current=requestAnimationFrame(pe))}Ve(ae.clientX,ae.clientY)}},Ft=(ae,te)=>{if(te.kind==="slot")return mrt(Q,ae,te.region,te.beforeId,N);const me=Za(Q,ae),xe=te.kind==="more"?"more":me==="more"?"visible":"more";return Tj(Q,ae,xe)},$t=(ae,te)=>{const me=P.get(ae);if(me===void 0)return;const xe=Ft(ae,te);if(xe===null||ok(xe,Q))return;const Le=Za(xe,ae);if(Le==="more"&&_(!0),ne(xe),te.kind==="slot"){Dt(xe,ae);return}q(Le==="more"?p("ui.shell.sidebar_navigation.move_to_more_note",{name:me.label}):p("ui.shell.sidebar_navigation.show_in_sidebar_note",{name:me.label}))},Dt=(ae,te)=>{const me=P.get(te),xe=Za(ae,te),Le=$x(ae,xe,N);q(p("ui.shell.sidebar_navigation.move_note",{name:me?.label??"",position:String(Le.indexOf(te)+1),total:String(Le.length)}))},Nt=(ae,te=!1)=>{const me=ie.current;if(me===null)return;ie.current=null,ft(),St();const xe=re.current;if(re.current=null,Te(null),ve(null),M(!1),!!me.armed){if(!ae){if(te){Ee.current=!1,q("");return}const Le=()=>{Ee.current=!1},Ke=()=>{window.setTimeout(Le,0)},ct=()=>{window.removeEventListener("pointerup",Re,!0),window.removeEventListener("pointercancel",Ye,!0),window.removeEventListener("blur",Ye,!0)},Re=()=>{ct(),Ke()},Ye=()=>{ct(),Le()};window.addEventListener("pointerup",Re,!0),window.addEventListener("pointercancel",Ye,!0),window.addEventListener("blur",Ye,!0),q("");return}window.setTimeout(()=>{Ee.current=!1},0),xe!==null&&$t(me.id,xe)}},tn=m.useRef(Nt);tn.current=Nt,m.useEffect(()=>{if(z===null)return;const ae=xe=>{xe.key==="Escape"&&(tn.current(!1),xe.preventDefault())},te=xe=>{ie.current?.pointerId===xe.pointerId&&tn.current(!0)},me=()=>tn.current(!1,!0);return window.addEventListener("keydown",ae),window.addEventListener("pointerup",te),window.addEventListener("pointercancel",me),window.addEventListener("blur",me),()=>{window.removeEventListener("keydown",ae),window.removeEventListener("pointerup",te),window.removeEventListener("pointercancel",me),window.removeEventListener("blur",me)}},[z]),m.useEffect(()=>()=>{Oe.current!==null&&cancelAnimationFrame(Oe.current),he.current!==null&&window.clearTimeout(he.current)},[]);const Bt=(ae,te)=>{if(!B)return;const me=P.get(ae);if(me===void 0)return;if(te.kind==="reset"){J(),q(p("ui.shell.sidebar_navigation.reset_note")),Ae(ae);return}if(te.kind==="move"){const Le=grt(Q,ae,te.delta,N);if(Le===null)return;ne(Le),Dt(Le,ae),Ae(ae);return}const xe=Tj(Q,ae,te.region);ok(xe,Q)||(te.region==="more"&&_(!0),ne(xe),q(te.region==="more"?p("ui.shell.sidebar_navigation.move_to_more_note",{name:me.label}):p("ui.shell.sidebar_navigation.show_in_sidebar_note",{name:me.label})),Ae(ae))},rn=c.jsx(lXe,{selectedConversation:l??void 0,onSelectConversation:ae=>void zp(t,ae),onStageDraft:(ae,te)=>{De.getState().stageDraft(ae,te),t("/chat")}}),Fn=ae=>{const te=ae.attention??0,me=te>0&&ae.attentionName?ae.attentionName(te):ae.label;return ae.working&&ae.workingName?ae.workingName:me},rt=ae=>{const te=P.get(ae);if(te===void 0)return null;const me=Za(Q,ae),xe=me==="more"?oe:G,Le=xe.indexOf(ae),Ke=Le<=0,ct=Le===-1||Le>=xe.length-1,Re=te.attention??0,Ye=Fn(te),kt=z===ae,Vt=e?"left":"right",hn=te.isActive?no:"text-ink-muted hover:bg-row-hover hover:text-ink",ln=c.jsx(te.icon,{size:16,"aria-hidden":"true",className:T("shrink-0",te.isActive&&"text-accent")}),Qn=c.jsxs("button",{type:"button",ref:Jt=>{Jt?ye.current.set(ae,Jt):ye.current.delete(ae)},onClick:()=>{if(Ee.current){Ee.current=!1;return}te.onSelect?te.onSelect():t(te.path)},onPointerDown:B?Jt=>et(ae,Jt):void 0,onPointerMove:B?tt:void 0,onPointerUp:B?Jt=>{ie.current?.pointerId===Jt.pointerId&&Nt(!0)}:void 0,onPointerCancel:B?()=>Nt(!1,!0):void 0,onKeyDown:B?Jt=>{if(Jt.key==="ContextMenu"||Jt.shiftKey&&Jt.key==="F10"){Jt.preventDefault(),fe(ae);return}Jt.altKey&&(Jt.key!=="ArrowUp"&&Jt.key!=="ArrowDown"||(Jt.preventDefault(),Bt(ae,{kind:"move",delta:Jt.key==="ArrowUp"?-1:1})))}:void 0,"data-tour-tag":te.tourTag,"aria-current":te.isActive?"page":void 0,"aria-haspopup":B?"menu":void 0,"aria-label":s&&Ye===te.label?void 0:Ye,className:T("flex h-full min-w-0 flex-1 items-center gap-2 rounded-md",s?"px-2":"justify-center px-0"),children:[s?ln:c.jsxs("span",{className:"relative flex size-7 shrink-0 items-center justify-center",children:[ln,Re>0&&c.jsx("span",{className:"pointer-events-none absolute -top-0.5 -end-0.5 flex",children:c.jsx(Sa,{variant:"attentionQuiet",shape:"pill",size:"count",className:"h-3.5 min-w-3.5 px-0.75 leading-none","data-tour-tag":te.attentionTag,children:Re})})]}),!s&&te.working&&c.jsx("span",{className:"inline-flex",children:c.jsx(qr,{size:16,"aria-hidden":"true",className:"text-accent motion-safe:animate-spin"})}),s&&c.jsx("span",{className:"truncate",children:te.label})]}),Es=B?c.jsxs(La,{open:U===ae,onOpenChange:Jt=>fe(Jt?ae:null),children:[c.jsx(sa,{asChild:!0,children:s?c.jsx("button",{type:"button","data-sidebar-row-menu":"","aria-label":p("ui.shell.sidebar_navigation.row_actions",{name:te.label}),className:T("me-0.5 flex size-6 shrink-0 items-center justify-center rounded-sm","text-ink-muted opacity-0 transition-opacity duration-fast ease-out-quart","hover:bg-row-hover hover:text-ink","group-hover/row:opacity-100 group-focus-within/row:opacity-100","focus-visible:opacity-100 data-[state=open]:opacity-100",z!==null&&"pointer-events-none opacity-0!"),children:c.jsx(Wl,{size:16,"aria-hidden":"true"})}):c.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-1 end-0 w-0"})}),c.jsxs(Ba,{align:"start",side:Vt,sideOffset:s?6:16,className:"min-w-44",onCloseAutoFocus:Jt=>{Jt.preventDefault(),Ae(ae)},children:[c.jsx(Ot,{disabled:Ke,onSelect:()=>Bt(ae,{kind:"move",delta:-1}),children:p("ui.shell.sidebar_navigation.move_up")}),c.jsx(Ot,{disabled:ct,onSelect:()=>Bt(ae,{kind:"move",delta:1}),children:p("ui.shell.sidebar_navigation.move_down")}),c.jsx(Js,{}),me==="more"?c.jsx(Ot,{onSelect:()=>Bt(ae,{kind:"region",region:"visible"}),children:p("ui.shell.sidebar_navigation.show_in_sidebar")}):c.jsx(Ot,{onSelect:()=>Bt(ae,{kind:"region",region:"more"}),children:p("ui.shell.sidebar_navigation.move_to_more")}),!ok(Q,I_)&&c.jsxs(c.Fragment,{children:[c.jsx(Js,{}),c.jsx(Ot,{onSelect:()=>Bt(ae,{kind:"reset"}),children:p("ui.shell.sidebar_navigation.reset_layout")})]})]})]}):null;return c.jsxs("li",{"data-sidebar-row":ae,"data-sidebar-region":me,onContextMenu:B?Jt=>{Jt.preventDefault(),fe(ae)}:void 0,className:T("group/row relative flex h-[30px] w-full items-center rounded-md","transition-colors duration-fast ease-out-quart",hn,kt&&zz,kt&&qz),children:[s?Qn:c.jsx(vd,{content:Fn(te),side:Vt,suppressed:z!==null,children:Qn}),Es,s&&(Re>0||te.working)&&c.jsxs("span",{"aria-hidden":"true",className:"pointer-events-none inline-flex shrink-0 items-center gap-1 pe-2",children:[Re>0&&c.jsx(Sa,{variant:"attentionQuiet",shape:"pill",size:"count","data-tour-tag":te.attentionTag,children:Re}),te.working&&c.jsx(qr,{size:16,"aria-hidden":"true",className:"text-accent motion-safe:animate-spin"})]})]},te.tourTag)},on=H===null?null:c.jsx("span",{"aria-hidden":"true","data-sidebar-drop-indicator":"",className:"pointer-events-none absolute inset-x-1 z-10 h-0.5 -translate-y-px rounded-full bg-accent",style:{top:H}}),Ws=(z===null?null:Za(Q,z))==="more"?p("ui.shell.sidebar_navigation.show_in_sidebar"):p("ui.shell.sidebar_navigation.move_to_more"),xn=z===null?null:s?c.jsx("div",{"data-sidebar-drop-band":"",className:"absolute inset-x-0 top-full z-20 mt-1 flex h-7 items-center justify-center rounded-md border border-dashed border-control bg-surface text-meta text-ink-dim",children:Ws}):c.jsx(vd,{content:Ws,side:e?"left":"right",children:c.jsx("div",{"data-sidebar-drop-band":"",className:"absolute inset-x-0 top-full z-20 mx-auto mt-1 flex h-6 w-8 items-center justify-center rounded-sm border border-dashed border-control bg-surface",children:c.jsx("span",{"aria-hidden":"true",className:"h-0.5 w-4 rounded-full bg-ink-dim"})})}),Kn=c.jsx("span",{className:"sr-only","aria-live":"polite","aria-atomic":"true",children:j}),bs=s?p("ui.shell.sidebar_navigation.collapse_sidebar"):p("ui.shell.sidebar_navigation.expand_sidebar"),mn=s?e?Di:cu:e?cu:Di,Qt=navigator.platform.toUpperCase().indexOf("MAC")>=0,kn=Et(a.data,"session_catalogue",2),Ht=De(ae=>ae.activeDraftKey),jn=De(ae=>ae.drafts),vn=!!Ht&&!(Ht?jn[Ht]:void 0)?.target,Je=()=>{De.getState().stageDraft(void 0,!0),t("/chat")},_e=p("ui.shell.sidebar_navigation.new_chat_shortcut",{shortcut:NB(Qt).replace("+","")}),ge=p("ui.shell.sidebar_navigation.search_accessible",{everything:zo("everything",Qt),chats:zo("chats",Qt)}),Se=p("ui.shell.sidebar_navigation.search_tooltip",{everything:zo("everything",Qt),chats:zo("chats",Qt)}),O=(ae,te,me,xe)=>{const Le=ae;return c.jsxs("button",{type:"button",...xe.attrs,onClick:xe.onClick,disabled:xe.disabled,"aria-label":xe.ariaLabel,"aria-current":xe.current?"page":void 0,className:T(Ij,xe.current?no:"text-ink-muted hover:bg-row-hover hover:text-ink","disabled:text-ink-disabled disabled:hover:bg-transparent"),children:[c.jsx(Le,{size:16,"aria-hidden":"true",className:"shrink-0"}),c.jsx("span",{className:"truncate",children:te}),c.jsx("span",{"aria-hidden":"true",className:"ms-auto",children:c.jsx(Er,{shortcut:me,joined:!0})})]})},X=O(wE,p("ui.shell.sidebar_navigation.new_chat"),NB(Qt),{onClick:Je,ariaLabel:_e,current:vn,disabled:!kn,attrs:{"data-tour-tag":"nav-item-chat","data-new-chat-row":""}}),K=O(Jd,p("ui.shell.sidebar_navigation.search"),fJe("everything",Qt),{onClick:i,ariaLabel:ge,attrs:{"data-command-palette-trigger":"",title:Se}}),Y=(ae,te,me)=>{const xe=ae;return c.jsx(vd,{content:te,side:e?"left":"right",children:c.jsx("button",{type:"button",...me.attrs,onClick:me.onClick,disabled:me.disabled,"aria-label":te,className:T("flex size-8 items-center justify-center rounded-sm text-ink-muted","transition-colors duration-fast ease-out-quart","hover:bg-row-hover hover:text-ink","disabled:text-ink-disabled disabled:hover:bg-transparent"),children:c.jsxs("span",{className:"relative flex size-7 items-center justify-center",children:[c.jsx(xe,{size:16,"aria-hidden":"true"}),(me.attention??0)>0&&c.jsx("span",{className:"pointer-events-none absolute -top-0.5 -end-0.5 flex",children:c.jsx(Sa,{variant:"attentionQuiet",shape:"pill",size:"count",className:"h-3.5 min-w-3.5 px-0.75 leading-none","data-tour-tag":me.attentionTag,children:me.attention})}),me.working&&c.jsx("span",{className:"pointer-events-none absolute -bottom-0.5 -end-0.5 flex",children:c.jsx(qr,{size:12,"aria-hidden":"true",className:"text-accent motion-safe:animate-spin"})})]})})})},ee=c.jsx("div",{className:T("pointer-events-none opacity-0 transition-opacity duration-fast ease-out-quart","group-hover/sidebar:pointer-events-auto group-hover/sidebar:opacity-100","group-focus-within/sidebar:pointer-events-auto group-focus-within/sidebar:opacity-100"),children:c.jsx(vd,{content:bs,side:e?"left":"right",children:c.jsx(le,{variant:"ghost",size:"icon-sm",onClick:r,"aria-label":bs,"aria-expanded":s,"aria-keyshortcuts":oI(Qt),children:c.jsx(mn,{"aria-hidden":"true"})})})}),Z=()=>{if(oe.length===0)return null;const ae=oe.map(Le=>P.get(Le)).filter(Le=>Le!==void 0),te=ae.reduce((Le,Ke)=>Le+(Ke.attention??0),0),me=ae.some(Le=>Le.working===!0),xe=te>0?p("ui.shell.sidebar_navigation.more_waiting",{count:te,countText:String(te)}):me?p("ui.shell.sidebar_navigation.more_working"):p("ui.library.page.more_destinations");return c.jsxs("li",{className:T("flex flex-col",s?"gap-0.5":"items-center gap-1"),children:[s?c.jsxs("button",{type:"button","data-tour-tag":"nav-item-more","data-sidebar-more":"","aria-expanded":W,"aria-controls":"sidebar-more-destinations","aria-label":xe,onClick:()=>_(!W),className:T(Ij,"text-ink-muted hover:bg-row-hover hover:text-ink"),children:[c.jsx(Wl,{size:16,"aria-hidden":"true",className:"shrink-0"}),c.jsx("span",{className:"min-w-0 flex-1 truncate text-start",children:p("ui.library.page.more")}),(te>0||me)&&c.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1",children:[te>0&&c.jsx(Sa,{variant:"attentionQuiet",shape:"pill",size:"count","data-tour-tag":"nav-more-badge",children:te}),me&&c.jsx(qr,{size:16,"aria-hidden":"true",className:"text-accent motion-safe:animate-spin"})]}),c.jsx(mi,{size:14,"aria-hidden":"true",className:T("shrink-0 transition-transform duration-fast",W&&"rotate-180")})]}):Y(Wl,xe,{onClick:()=>_(!W),attention:te,attentionTag:"nav-more-badge",working:me,attrs:{"aria-expanded":W,"aria-controls":"sidebar-more-destinations","data-tour-tag":"nav-item-more","data-sidebar-more":""}}),W&&c.jsx("ul",{id:"sidebar-more-destinations",className:T("flex flex-col gap-0.5",!s&&"items-center gap-1"),children:oe.map(rt)})]},"nav-overflow")},Ce=c.jsx(vd,{content:p("ui.shell.sidebar_navigation.settings"),side:"top",children:c.jsx("button",{type:"button","data-tour-tag":"nav-item-settings",onClick:()=>t("/settings"),"aria-current":n==="settings"?"page":void 0,"aria-label":p("ui.shell.sidebar_navigation.settings"),className:T("flex size-8 shrink-0 items-center justify-center rounded-sm text-ink-muted","transition-colors duration-fast ease-out-quart","hover:bg-row-hover hover:text-ink",n==="settings"&&"text-ink"),children:c.jsx(Yc,{size:16,"aria-hidden":"true"})})});return s?c.jsxs("div",{"data-sidebar-shell":"","data-glass-region":"sidebar",className:"panel-top-pad group/sidebar flex h-full min-h-0 flex-col overflow-hidden bg-surface",children:[c.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 pe-2 ps-4",children:[c.jsx(Dj,{expanded:!0}),c.jsx("span",{className:"ms-auto",children:ee})]}),c.jsxs("div",{className:"flex shrink-0 flex-col gap-2 px-2 pb-2",children:[c.jsxs("div",{className:"flex flex-col gap-0.5",children:[X,K]}),c.jsxs("div",{className:"relative",children:[c.jsxs("div",{ref:Fe,"data-sidebar-destinations-area":"","data-sidebar-dragging":z!==null?"":void 0,className:"relative min-h-0 max-h-[50dvh] overflow-y-auto select-none",children:[c.jsxs("ul",{"data-sidebar-destinations":"",className:"flex flex-col gap-0.5",children:[G.map(rt),Z()]}),on]}),xn]}),Kn]}),c.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:rn}),c.jsxs("div",{className:"flex min-h-10 shrink-0 items-center justify-between gap-1 px-2 pb-2",children:[c.jsx(vR,{expanded:!0}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(Fj,{}),Ce]})]})]}):c.jsxs("div",{"data-sidebar-strip":"","data-glass-region":"sidebar",className:"panel-top-pad group/sidebar flex h-full min-h-0 flex-col items-center bg-surface",children:[c.jsx(_rt,{}),c.jsx("div",{className:"flex h-10 shrink-0 items-center justify-center",children:c.jsx(Dj,{expanded:!1})}),c.jsxs("ul",{className:"flex flex-col items-center gap-1",children:[c.jsx("li",{children:Y(Di,bs,{onClick:r,attrs:{"aria-expanded":!1,"aria-keyshortcuts":oI(Qt)}})}),c.jsx("li",{children:Y(wE,_e,{onClick:Je,disabled:!kn,attrs:{"data-tour-tag":"nav-item-chat"}})}),c.jsx("li",{children:Y(Jd,ge,{onClick:i,attrs:{"data-command-palette-trigger":""}})})]}),c.jsxs("div",{ref:Fe,"data-sidebar-destinations-area":"","data-sidebar-dragging":z!==null?"":void 0,className:"relative mt-4 flex flex-col items-center gap-1 select-none",children:[c.jsxs("ul",{"data-sidebar-destinations":"",className:"flex flex-col items-center gap-1",children:[G.map(rt),Z()]}),on,xn]}),Kn,c.jsxs("div",{className:"mt-auto flex flex-col items-center gap-1 pb-2",children:[c.jsx(Fj,{}),Ce,c.jsx(vR,{expanded:!1})]})]})},yrt=1,Srt=()=>{const{isAuthenticated:e,user:t}=YR(),{hasBeenNotified:n,setHasBeenNotified:s}=Qq(),[r,i]=m.useState(!1),[a,o]=m.useState(null),l=m.useCallback(async()=>{if(!(!e||!t?.radientUser?.account?.tenant_id))try{const f=await lse({operation:"credits",tenantId:t.radientUser.account.tenant_id});if(!f||typeof f.balance!="number")throw new Error(p("ui.common.errors.credit_balance_invalid"));o(f.balance)}catch(f){console.error("Failed to fetch Radient credits:",f),o(null)}},[e,t?.radientUser?.account?.tenant_id]);return m.useEffect(()=>{e&&l()},[e,l]),m.useEffect(()=>{e&&a!==null?a<yrt?n||i(!0):(i(!1),n&&s(!1)):i(!1)},[e,n,a,s]),{isLowCreditsDialogOpen:r,openRadientConsole:()=>{window.api?.openExternal?window.api.openExternal("https://console.radienthq.com"):window.open("https://console.radienthq.com","_blank"),s(!0),i(!1)},closeLowCreditsDialog:()=>{i(!1)},onLowCreditsDialogClose:()=>{s(!0),i(!1)},currentCredits:a}};function krt(){const e=xi();m.useEffect(()=>{const t=r=>{e(r==="back"?-1:1)},n=r=>{const i=Wse(r);i&&(r.preventDefault(),t(i))},s=r=>{const i=$se(r);i&&(r.preventDefault(),t(i))};return window.addEventListener("keydown",n),window.addEventListener("mouseup",s),()=>{window.removeEventListener("keydown",n),window.removeEventListener("mouseup",s)}},[e])}function Ert(){const e=navigator.windowControlsOverlay;if(!e?.getTitlebarAreaRect)return null;try{const t=e.getTitlebarAreaRect();return t.width<=0&&t.height<=0?null:{x:t.x,y:t.y,width:t.width,height:t.height}}catch{return null}}function Trt(e,t,n){const s=document.documentElement;if(t==="mac"){s.dataset.chromeLeading="true",s.dataset.chromeTrailing="false";return}if(e===null){s.dataset.chromeLeading="false",s.dataset.chromeTrailing="false";return}s.dataset.chromeLeading=e.x<=1?"true":"false",s.dataset.chromeTrailing=Math.abs(e.x+e.width-n)<=1?"true":"false"}function Rrt(e){const t=window.api?.windowChrome;if(!t)return;const n=getComputedStyle(document.documentElement),s=n.getPropertyValue("--lo-canvas").trim(),r=n.getPropertyValue("--lo-ink-muted").trim(),i=n.getPropertyValue("--lo-ink-dim").trim();!s||!r||!i||t.report({themeId:e,colors:{ground:s,symbol:r,symbolInactive:i}})}function Art(){m.useLayoutEffect(()=>{if(!window.api?.windowChrome)return;const t=document.documentElement.dataset.chromePlatform??"linux",n=()=>Trt(Ert(),t,window.innerWidth);n();const s=navigator.windowControlsOverlay;return s?.addEventListener?.("geometrychange",n),window.addEventListener("resize",n),()=>{s?.removeEventListener?.("geometrychange",n),window.removeEventListener("resize",n)}},[]),m.useEffect(()=>{const e=window.api?.windowChrome;if(e)return e.onState(t=>{document.documentElement.dataset.chromeFullscreen=t.fullScreen?"true":"false"})},[])}const Frt=m.lazy(()=>Va(()=>import("./agent-details-page-BWNrXmxX.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]),import.meta.url).then(e=>({default:e.AgentDetailsPage}))),Drt=m.lazy(()=>Va(()=>import("./agent-hub-page-Cka41wII.js"),__vite__mapDeps([15,1,2,3,5,16,7,6,8,4,9,10,11,12,17,18,19,20,21,13,14]),import.meta.url).then(e=>({default:e.AgentHubPage}))),Pj=m.lazy(()=>Va(()=>import("./agents-page-B10LHSJd.js"),__vite__mapDeps([22,6,1,2,3,5,7,8,17,13,14]),import.meta.url).then(e=>({default:e.AgentsPage}))),Irt=m.lazy(()=>Va(()=>import("./schedules-page-Bn3e8WY7.js"),__vite__mapDeps([23,1,2,3,5,16,7,6,8,19,10,24,13,14]),import.meta.url).then(e=>({default:e.SchedulesPage}))),Nj=m.lazy(()=>Va(()=>import("./projects-page-qWSJC9oD.js"),__vite__mapDeps([25,1,2,3,6,5,7,8,16,13,14,26]),import.meta.url).then(e=>({default:e.ProjectsPage}))),Mj=m.lazy(()=>Va(()=>import("./library-page-C4z59b5g.js").then(e=>e.l),__vite__mapDeps([27,1,2,3,13,5,14,16,6,7,8,12,28,26]),import.meta.url).then(e=>({default:e.LibraryPage}))),Prt=m.lazy(()=>Va(()=>import("./team-bridge-page-BSwTmi7d.js"),__vite__mapDeps([29,1,2,3,5,7,6,8,21,28,13,14]),import.meta.url).then(e=>({default:e.TeamBridgePage}))),Nrt=m.lazy(()=>Va(()=>import("./browser-page-aNCnBYZQ.js"),__vite__mapDeps([30,1,2,3,7,5,6,8,13,14]),import.meta.url).then(e=>({default:e.BrowserPage}))),Mrt=m.lazy(()=>Va(()=>import("./mesh-page-CY-Frpsh.js"),__vite__mapDeps([31,1,2,3,5,16,7,6,8,13,14]),import.meta.url).then(e=>({default:e.MeshPage}))),Ort=m.lazy(()=>Va(()=>import("./settings-page-DrhoPGFS.js"),__vite__mapDeps([32,1,2,3,13,5,14,6,7,8,16,18,33,11,24,10,19]),import.meta.url).then(e=>({default:e.SettingsPage}))),Lrt=m.lazy(()=>Va(()=>import("./browser-webauthn-prompt-CHrTpdBn.js"),__vite__mapDeps([34,1,2,3,5,7,6,8,13,14]),import.meta.url).then(e=>({default:e.BrowserWebauthnPrompt}))),Brt=()=>{Qe(),Art(),Ost(),cse();const{pathname:e}=kR(),t=e.startsWith("/chat")||e.startsWith("/browser"),{isOnboardingActive:n}=Nue(),{isLowCreditsDialogOpen:s,openRadientConsole:r,onLowCreditsDialogClose:i}=Srt(),{isCommandPaletteOpen:a,isCreateAgentDialogOpen:o,isSidebarCollapsed:l,closeCreateAgentDialog:u}=st();Wc(a,"command-palette"),Wc(o,"dialog","create-agent"),Wc(n,"onboarding"),Wc(s,"dialog","low-credits");const d=xi(),h=ns(),f=Et(h.data,"session_catalogue",2),g=Et(h.data,"session_archive");m.useEffect(()=>{De.getState().requestArchiveConfirm(null)},[e]);const v=Yr(h.data,"peers"),b=Yr(h.data,"library"),x=Yr(h.data,"team_bridge_conversations");Mst(Et(h.data,"team_bridge_conversations"));const w=I=>{De.getState().stageDraft({kind:"agent",name:I.name}),d("/chat"),u()};PJe(),jst(),zse(),krt(),kve();const _=De(I=>I.setActiveSession),C=De(I=>{const P=I.activeDraftKey?I.drafts[I.activeDraftKey]:void 0;return vv(I.activeDraftKey,P?.sessionId,I.activeSessionId)}),S=Tde({displayedSessionId:C,archiveEnabled:g}),y=st(I=>I.setConsolePaneOpen),R=st(I=>I.setBrowserPaneOpen),E=st(I=>I.setConsoleActiveSurface);m.useEffect(()=>{const I=window.api?.desktop?.onOpenConversation?.((P,N)=>{P!==null&&performance.mark("lop:open:requested"),_(P),N!==void 0&&P!==null&&(E(N),y(!0)),d("/chat")});return()=>I?.()},[d,_,y,E]);const[F,A]=m.useState(null);return m.useEffect(()=>{const I=window.api?.desktop?.teamBridge,P=()=>{I?.pendingOpen?.().then(L=>{L&&A(L)}).catch(()=>{})},N=I?.onOpen?.(P);return P(),()=>N?.()},[]),m.useEffect(()=>{!F||x!=="enabled"||(d(Gnt(F)),A(null))},[F,x,d]),m.useEffect(()=>{const I=window.api?.console?.onReveal?.(P=>{if(P.mode!=="none"&&!(P.mode==="session"&&P.session_id!==C)){if(P.mode==="open"){if(!use({targetSessionId:P.session_id,displayedSessionId:C,activeElement:document.activeElement,commandPaletteOpen:a}))return;_(P.session_id)}E(P.surface),y(!0)}});return()=>I?.()},[C,a,_,y,E]),zde(),aJe(),m.useEffect(()=>{const I=window.api?.browser?.onConsentAttention?.(P=>{const N=Dde(P.requesterSessionId,De.getState().sessions);if(Rde(P.entryId),N.kind==="browser"){d("/browser");return}_(N.sessionId),R(!0),d("/chat")});return()=>I?.()},[d,_,R]),m.useEffect(()=>{const I=P=>{n||f&&lJe(P)&&(P.preventDefault(),De.getState().stageDraft(void 0,!0),d("/chat"))};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[f,n,d]),c.jsx(ont,{children:c.jsx("div",{className:"relative flex h-screen flex-col overflow-hidden","data-titlebar-sidebar-collapsed":l?"true":"false",children:c.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[a&&c.jsx(AJe,{}),c.jsx(cnt,{}),c.jsx(cJe,{}),c.jsx(dse,{}),c.jsx(NJe,{enabled:v==="enabled"}),c.jsx(RZe,{open:n}),c.jsx(lnt,{}),c.jsx(gnt,{}),g&&c.jsx(Xde,{}),c.jsx(lde,{}),c.jsx(m.Suspense,{fallback:null,children:c.jsx(Lrt,{})}),c.jsx(_de,{blocked:n||s||a||o||S,sessionId:e.startsWith("/chat")?C??null:null}),c.jsx(Ust,{open:s,onClose:i,onGoToConsole:r}),c.jsx(jue,{open:o,onClose:u,onAgentCreated:w}),c.jsx(hse,{sidebar:c.jsx(Crt,{}),content:c.jsxs("main",{"data-glass-region":"canvas-backing",className:"panel-top-pad flex grow flex-col overflow-hidden",children:[t?null:c.jsx("div",{"data-chrome-route-band":""}),c.jsx(m.Suspense,{fallback:c.jsx("div",{className:"flex grow items-center justify-center",children:c.jsx(An,{size:"lg",label:p("ui.common.loading.page")})}),children:c.jsxs(pQ,{children:[c.jsx(yr,{path:"/",element:c.jsx(lI,{to:"/chat",replace:!0})}),c.jsx(yr,{path:"/chat",element:c.jsx(IB,{})}),c.jsx(yr,{path:"/chat/:agentId",element:c.jsx(IB,{})}),c.jsx(yr,{path:"/agents",element:c.jsx(Pj,{})}),c.jsx(yr,{path:"/agents/:agentId",element:c.jsx(Pj,{})}),c.jsx(yr,{path:"/settings",element:c.jsx(Ort,{})}),c.jsx(yr,{path:"/agent-hub",element:c.jsx(Drt,{})}),c.jsx(yr,{path:"/agent-hub/:agentId",element:c.jsx(Frt,{})}),c.jsx(yr,{path:"/schedules",element:c.jsx(Irt,{})}),c.jsx(yr,{path:"/projects",element:c.jsx(Nj,{})}),c.jsx(yr,{path:"/projects/:projectId",element:c.jsx(Nj,{})}),c.jsx(yr,{path:"/browser",element:c.jsx(Nrt,{})}),b==="enabled"&&c.jsxs(c.Fragment,{children:[c.jsx(yr,{path:"/library",element:c.jsx(Mj,{})}),c.jsx(yr,{path:"/library/assets/:assetId",element:c.jsx(Mj,{})})]}),x==="enabled"&&c.jsx(yr,{path:"/team-bridge",element:c.jsx(Prt,{})}),v==="enabled"&&c.jsx(yr,{path:"/mesh",element:c.jsx(Mrt,{})}),c.jsx(yr,{path:"*",element:c.jsx(lI,{to:"/chat",replace:!0})})]})})]})})]})})})};let Bo=null,mf=null,Jg=null,vf=null,lk=null;const jrt={soundsArm:async()=>{if(tf.getState().element)throw new Error("sounds safety: element already exists");if(Bo)throw new Error("sounds safety: graph already armed");return Bo=new AudioContext,await Bo.resume(),pse(e=>{if(!Bo)throw new Error("sounds safety: no context");const t=Bo.createMediaElementSource(e);Jg=Bo.createGain(),Jg.gain.value=0,mf=Bo.createAnalyser(),vf=Bo.createAnalyser(),t.connect(vf),vf.connect(Jg),Jg.connect(mf),mf.connect(Bo.destination)}),{armed:!0,contextState:Bo.state}},soundsFacts:()=>{const e=tf.getState(),t=new Float32Array(mf?.fftSize??32);mf?.getFloatTimeDomainData(t);const n=new Float32Array(vf?.fftSize??32);return vf?.getFloatTimeDomainData(n),{ownerId:e.ownerId,status:e.status,time:e.element?.currentTime??0,duration:e.element?.duration??0,paused:e.element?.paused??!0,gain:Jg?.gain.value??null,inputRms:vf?Math.sqrt(n.reduce((s,r)=>s+r*r,0)/n.length):null,players:Array.from(document.querySelectorAll("[data-sound-player]")).map(s=>({status:s.getAttribute("data-sound-status"),clock:s.querySelector("[data-sound-time]")?.textContent,clip:s.querySelectorAll("canvas")[1]?.style.clipPath,numeric:getComputedStyle(s.querySelector("[data-sound-time]")??s).fontVariantNumeric})),rms:mf?Math.sqrt(t.reduce((s,r)=>s+r*r,0)/t.length):null,src:e.element?.src??null,nativeElements:document.querySelectorAll("audio").length,canvas:Object.values(_s.getState().conversations).map(s=>({selectedTab:s.selectedTabId,files:s.files?.map(r=>({id:r.id,path:r.path,artifact:r.artifact??null}))}))}},soundsScrub:e=>{const t=e,n=document.querySelector(t.selector);if(!n)throw new Error("sounds: no slider");const s=n.getBoundingClientRect(),r=(u,d)=>n.dispatchEvent(new PointerEvent(u,{pointerId:17,pointerType:"mouse",clientX:d,clientY:s.y+s.height/2,bubbles:!0})),i=n.setPointerCapture,a=n.releasePointerCapture;n.setPointerCapture=()=>{},n.releasePointerCapture=()=>{},r("pointerdown",s.left+1),r("pointermove",s.left+s.width*t.fraction);const o=()=>n.closest("[data-sound-player]")?.getAttribute("data-sound-status"),l=performance.now()+1500;return new Promise(u=>{const d=()=>{const h=o();if(h!=="scrubbing"&&performance.now()<l){requestAnimationFrame(d);return}lk=()=>{r("pointerup",s.left+s.width*t.fraction),n.setPointerCapture=i,n.releasePointerCapture=a},u({during:h,seconds:tf.getState().element?.currentTime})};requestAnimationFrame(d)})},soundsScrubFinish:()=>(lk?.(),lk=null,{committed:!0}),soundsEnd:()=>{const e=tf.getState();if(!e.ownerId||!e.element)throw new Error("sounds: no active playback");return e.seek(e.ownerId,e.element.duration-.12),{requested:!0}},soundsSpeech:async()=>{const e=tf.getState();if(!e.element?.src)throw new Error("sounds: fixture not resolved");const{fetchAttachmentBlob:t}=await Va(async()=>{const{fetchAttachmentBlob:r}=await import("./conversation-input-sync-DxHw4wST.js").then(i=>i.kN);return{fetchAttachmentBlob:r}},__vite__mapDeps([6,1,2,3,5,7,8]),import.meta.url),n=De.getState().activeSessionId,s=e.ownerId?.startsWith("sound:")?e.ownerId.slice(6):null;if(!n||!s)throw new Error("sounds: missing attachment identity");return await fse.getState().speak("sounds-driver",()=>t({sessionId:n,childId:null},s)),{ownerId:tf.getState().ownerId}}};function Ed(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}const Hrt=3,Urt=3e3;function Grt(e){return e instanceof CSSTransition&&e.playState==="running"}function Vrt(e){const t=e.effect,n=t instanceof KeyframeEffect?t.target:null,s=e.transitionProperty,i=/^[a-z-]+$/.test(s)&&n instanceof Element?getComputedStyle(n).getPropertyValue(s).trim()||"(empty)":"(unreadable)";return`${s||"(unnamed property)"} on ${uv(n)??"an element no longer in the document"} = ${i}`}async function Wrt(e=Urt){const t=performance.now();let n=0;for(;;){await Ed();const s=Math.round(performance.now()-t),r=document.getAnimations().filter(Grt);if(n=r.length===0?n+1:0,n>=Hrt)return{waitedMs:s,timedOut:!1,pending:[]};if(s>e)return{waitedMs:s,timedOut:!0,pending:r.map(Vrt)}}}const $rt=/^#/;function s0(){const e=window.location.hash.replace($rt,"");return e===""?"/":e}function uv(e){if(!e)return null;const t=e.getAttribute("aria-label")??e.textContent??"";return`${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""} "${t.trim().slice(0,60)}"`}function zrt(e){const t=e.getBoundingClientRect(),n=t.left+t.width/2,s=t.top+t.height/2,r=document.elementFromPoint(n,s),i=r!==null&&(r===e||e.contains(r)),a=document.elementsFromPoint(n,s).slice(0,4).map(l=>uv(l)),o={bubbles:!0,cancelable:!0,composed:!0,button:0,buttons:1,clientX:n,clientY:s,view:window};return e.dispatchEvent(new PointerEvent("pointerdown",{...o,pointerId:1,isPrimary:!0})),e.dispatchEvent(new MouseEvent("mousedown",o)),e.dispatchEvent(new PointerEvent("pointerup",{...o,buttons:0,pointerId:1,isPrimary:!0})),e.dispatchEvent(new MouseEvent("mouseup",{...o,buttons:0})),e.dispatchEvent(new MouseEvent("click",{...o,buttons:0})),{hitTest:i,hit:uv(r),stack:a,disabled:e instanceof HTMLButtonElement?e.disabled:null,rect:{x:t.x,y:t.y,width:t.width,height:t.height}}}function Zg(e,t){if(typeof e!="string"||e==="")throw new Error(`${t} must be a non-empty string`);return e}async function qrt(e,t=1e4){const n=Date.now();for(;s0()!==e;){if(Date.now()-n>t)throw new Error(`route did not become ${e} (it is ${s0()})`);await new Promise(s=>setTimeout(s,50))}return await Ed(),s0()}const bR=["dev-driver","query-fetch-probe"];let r0=null;function Krt(){if(r0)return r0;const e=[],t=cI.prototype.fetch;return cI.prototype.fetch=function(...s){return e.push({at:Date.now(),key:JSON.stringify(this.queryKey),stack:(new Error().stack??"").split(`
706
706
  `).slice(2).join(" | ")}),t.apply(this,s)},r0=e,e}function Yrt(e){const t=r0??[],n=JSON.stringify(bR),s=t.filter(i=>i.key!==n&&(e===void 0||i.key.includes(e))),r=new Map;for(const i of s){const a=r.get(i.stack)??{key:i.key,count:0,firstAt:i.at,lastAt:i.at};a.count+=1,a.lastAt=i.at,r.set(i.stack,a)}return{armed:r0!==null,total:s.length,probeRecords:t.filter(i=>i.key===n).length,callers:[...r.entries()].map(([i,a])=>({stack:i,...a})).sort((i,a)=>i.firstAt-a.firstAt)}}function Xrt(){const e=window.__loDevDriver;return e?.armed?e.install({...jrt,hello:()=>({armed:!0,outDir:e.outDir,title:document.title,route:s0(),href:window.location.href,theme:st.getState().themeName,viewport:{width:window.innerWidth,height:window.innerHeight,devicePixelRatio:window.devicePixelRatio},visibilityState:document.visibilityState,hasFocus:document.hasFocus(),apiBaseUrl:Gs.baseUrl,userAgent:navigator.userAgent}),filesFacts:()=>gse(),state:()=>{const t=st.getState(),n=De.getState();return{route:s0(),theme:t.themeName,commandPaletteOpen:t.isCommandPaletteOpen,canvasOpen:t.isCanvasOpen,runPanelOpen:t.isRunPanelOpen,browserPaneOpen:t.isBrowserPaneOpen,rightSlotWidth:t.rightSlotWidth,rightSlotKey:t.rightSlotKey??null,rightSlotMemory:t.rightSlotMemory.map(([s,r])=>[s,r]),activeSessionId:n.activeSessionId,activeDraftKey:n.activeDraftKey,drafts:Object.fromEntries(Object.entries(n.drafts).map(([s,r])=>[s,{sessionId:r.sessionId??null,error:r.error!==void 0,undelivered:r.undelivered!==void 0,submitted:r.submittedText!==void 0,admissionAttempted:r.admissionAttempted===!0,model:r.model??null}])),sessionCount:n.sessions.length,cataloguePinnedCount:n.sessions.filter(s=>s.pinned===!0).length,cataloguePageable:n.cataloguePageable,catalogueActivityHead:n.catalogueActivityHead,scopes:Object.fromEntries(Object.entries(n.scopes).map(([s,r])=>[s,{ids:r.ids.length,nextCursor:r.nextCursor,loading:r.loading,error:r.error}])),countsTotal:n.counts?.total??null,archiveAttempts:n.answerSeq,archiveFailure:n.archiveFailure?{sessionId:n.archiveFailure.sessionId,archived:n.archiveFailure.archived}:null,onboardingVisible:!!document.querySelector("[data-onboarding-modal]")}},queries:()=>sw.getQueryCache().getAll().map(t=>({key:JSON.stringify(t.queryKey),status:t.state.status,fetchStatus:t.state.fetchStatus,isLoading:t.state.status==="pending"&&t.state.fetchStatus==="fetching",error:t.state.error instanceof Error?t.state.error.message:null,hasData:t.state.data!==void 0,updatedAt:t.state.dataUpdatedAt,failureCount:t.state.fetchFailureCount,observers:t.getObserversCount()})),queryFetches:async t=>{const n=t??{};if(!n.arm)return Yrt(n.key);const s=Krt(),r=JSON.stringify(bR),i=s.length;return await sw.fetchQuery({queryKey:bR,queryFn:()=>null,retry:!1,staleTime:0}),{armed:!0,validated:s.slice(i).some(a=>a.key===r)}},navigate:async t=>{const n=Zg(t,"navigate path");if(!n.startsWith("/"))throw new Error(`navigate path must start with "/" (got "${n}")`);return window.location.hash=`#${n}`,{route:await qrt(n)}},setTheme:async t=>{const n=Zg(t,"theme name");st.getState().setTheme(n),await Ed();const s=document.documentElement.getAttribute("data-theme"),r=await Wrt();return{theme:st.getState().themeName,dataTheme:s,settledAfterMs:r.waitedMs,settleTimedOut:r.timedOut,settlePending:r.pending}},setSidebarWidth:async t=>{const n=Number(t?.width);if(!Number.isFinite(n))throw new Error("sidebar width must be a number");const s=gQ(n);return st.getState().setChatSidebarWidth(s),await Ed(),{width:st.getState().chatSidebarWidth,clamped:s!==n}},measure:async t=>{const n=typeof t=="string"?{selector:t}:t,s=Zg(n?.selector,"measure selector"),r=typeof n?.timeoutMs=="number"?n.timeoutMs:1e4,i=Date.now();let a=null;for(;a===null&&(a=document.querySelector(s),a===null);){if(Date.now()-i>r)throw new Error(`nothing matches ${s} after ${r}ms of waiting`);await new Promise(d=>setTimeout(d,100))}const o=a.getBoundingClientRect(),l={x:Math.round(o.left+o.width/2),y:Math.round(o.top+o.height/2)},u=document.elementFromPoint(l.x,l.y);return{selector:s,target:uv(a),centre:l,rect:{x:Math.round(o.x),y:Math.round(o.y),width:Math.round(o.width),height:Math.round(o.height)},hitTest:u!==null&&(u===a||a.contains(u)),focused:a===document.activeElement,inViewport:o.top>=0&&o.left>=0&&o.bottom<=window.innerHeight&&o.right<=window.innerWidth}},press:async t=>{const n=typeof t=="string"?{selector:t}:t,s=Zg(n?.selector,"press selector"),r=typeof n?.timeoutMs=="number"?n.timeoutMs:1e4,i=Date.now();let a=null;for(;a===null&&(a=document.querySelector(s),a===null);){if(Date.now()-i>r)throw new Error(`nothing matches ${s} after ${r}ms of waiting`);await new Promise(l=>setTimeout(l,100))}const o=zrt(a);return await Ed(),{selector:s,target:uv(a),...o}},openCanvasDocument:async t=>{const n=t,s=Zg(n?.path,"canvas document path"),r=typeof n?.title=="string"?n.title:void 0,[i]=await window.api.probeFiles([s]);if(!i||!i.exists||!i.isFile)throw new Error(`no file at ${i?.resolved??s}`);const a=i.resolved??s,o=zc(a,{title:r,type:pp(a),availability:"present",sizeBytes:i.sizeBytes??void 0,lastAgentModified:i.mtimeMs??void 0,readMtimeMs:i.mtimeMs??void 0}),l=Z_[eh(a,o.type)??"code"];if(l==="utf-8"||l==="base64"){const h=await window.api.readFile(o.path,l);if(!h.success)throw new Error(`could not read ${o.path}`);o.content=h.data}const u=De.getState(),d=TR(u.activeDraftKey,u.activeSessionId)??u.stageDraft();return st.getState().setCanvasOpen(!0),_s.getState().addFileAndSelect(d,o),n?.mention===!0&&_s.getState().addMentionedFile(d,o),await Ed(),{conversationId:d,documentId:o.id,readMtimeMs:o.readMtimeMs??null,contentLength:o.content.length,encoding:l}},stageLiveConsents:async t=>{const s=t?.count;if(typeof s!="number"||!Number.isInteger(s)||s<0)throw new Error(`stageLiveConsents count must be a non-negative integer (got ${JSON.stringify(s)})`);const r=Date.now();return qse({tabs:[],activeTabId:null,url:"",title:"",loading:!1,canGoBack:!1,canGoForward:!1,pendingConsent:Array.from({length:s},(i,a)=>({entryId:`dev-driver-probe-${a+1}`,origin:`https://dev-driver-probe-${a+1}.example.com`,authority:`dev-driver-probe-${a+1}.example.com`,broad:null,expiresAt:r+10*6e4,requesterSessionId:null})),approvals:[],navFailure:null}),await Ed(),{count:s}}}):[]}function Qrt(){const e=m.useMemo(FR,[]),t=m.useRef(null);return m.useEffect(()=>{const n=window.api?.miniView;if(!n?.onRegistration)return;let s=!1;const r=a=>{if(s)return;const o=t.current;if(t.current=a.status,o===null||a.status===o||a.status==="registered")return;const l=mQ(a.value,e);sn(mse(a.status,l))};n.getRegistration?.()?.then(r)?.catch(()=>{});const i=n.onRegistration(r);return()=>{s=!0,i?.()}},[e]),null}const Jrt=`
707
707
  /*
708
708
  * A transition declared on ::-webkit-scrollbar-thumb does not animate in