local-operator-ui 0.34.37 → 0.34.38

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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./agent-details-page-Cn-cbdV5.js","./index-D_Ya8nt7.js","./index-B_itKtEm.css","./use-memberships-query-DdlKnrP8.js","./conversation-input-sync-DeCSVDem.js","./ui-preferences-store-DApxrOwj.js","./error-boundary-sr-ahxTS.js","./conversation-input-sync-CIGg7Rga.css","./use-download-agent-mutation-DlnhukoP.js","./en-US-BcB1DWxG.js","./book-open-McoghV-V.js","./console-mirror-D_HrghW0.js","./console-mirror-DOrYoP_4.css","./agent-hub-page-D9pswF7S.js","./page-header-cUi3kof4.js","./radient-auth-buttons-De0E7l-6.js","./org-surface-gate-CPSbPHbt.js","./format-CZUObkkr.js","./agents-page-BjX3Lv17.js","./schedules-page-CjtX0IBz.js","./parseISO-CZfAC2_J.js","./projects-page-DUsbGH6v.js","./use-session-snapshot-CW8M_OHU.js","./browser-page-DzG2V1CA.js","./mesh-page-Bccygj_9.js","./settings-page-B2DmcFgi.js","./notebook-pen-DG_DgpzX.js","./browser-webauthn-prompt-DoSh0kSS.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./agent-details-page-TpBQjIfy.js","./index-D_Ya8nt7.js","./index-B_itKtEm.css","./use-memberships-query-DdlKnrP8.js","./conversation-input-sync-DeCSVDem.js","./ui-preferences-store-DApxrOwj.js","./error-boundary-sr-ahxTS.js","./conversation-input-sync-CIGg7Rga.css","./use-download-agent-mutation-CNtCKWgJ.js","./en-US-BcB1DWxG.js","./book-open-McoghV-V.js","./console-mirror-D_HrghW0.js","./console-mirror-DOrYoP_4.css","./agent-hub-page-BwXLGE4W.js","./page-header-cUi3kof4.js","./radient-auth-buttons-zXDJkEGk.js","./org-surface-gate-CPSbPHbt.js","./format-CZUObkkr.js","./agents-page-DvFU6Y5_.js","./schedules-page-Btb8nn58.js","./parseISO-CZfAC2_J.js","./projects-page-aLyO9q2b.js","./use-session-snapshot-CW8M_OHU.js","./browser-page-BRc9g9nj.js","./mesh-page-D2E7RiVp.js","./settings-page-BaIqVV9F.js","./notebook-pen-DG_DgpzX.js","./browser-webauthn-prompt-DoSh0kSS.js"])))=>i.map(i=>d[i]);
2
2
  import{r as g,j as c,c as _,b as Ge,f as qA,l as uV,u as dV,s as hV,v as iS,a as fV,R as pV}from"./index-D_Ya8nt7.js";import{ag as Ce,dP as gV,dQ as aS,dR as iw,cg as qv,bG as Eh,ce as La,bP as qk,aF as Os,a6 as ha,a7 as ws,aw as $t,aM as Cs,aN as vs,u as hn,av as Mc,aT as Qm,ci as mV,aU as Jm,dS as f3,dT as vV,a as os,b as yt,c as Zm,dU as Kg,dV as xV,dW as bV,dX as wV,dY as CV,aQ as p3,aP as Yr,dZ as Kk,d_ as el,d$ as RC,e0 as AC,ds as ac,cj as Yk,cS as _l,cA as Kv,cz as yV,cy as Ks,cB as an,e1 as g3,e2 as SV,e3 as oS,d as Ct,aG as m3,e4 as KA,e5 as EV,e6 as kV,e7 as lS,e8 as _V,e9 as TV,ea as RV,eb as AV,ar as kh,ec as YA,ed as XA,ee as FV,ef as DV,eg as PV,eh as v3,ei as IV,ej as NV,ek as x3,el as aw,em as ow,en as MV,eo as OV,ep as LV,eq as QA,er as BV,es as gh,et as b3,eu as jV,ev as HV,ew as UV,ex as GV,ey as $V,ez as VV,eA as WV,eB as w3,eC as zV,T as za,eD as qV,az as ui,eE as C3,eF as KV,eG as JA,eH as YV,eI as XV,eJ as qa,eK as y3,eL as S3,eM as QV,eN as JV,eO as ZA,eP as ZV,eQ as eW,aV as If,eR as tW,eS as nW,eT as sW,b4 as E3,eU as k3,eV as cg,eW as FC,eX as lw,eY as rW,eZ as iW,e_ as aW,e$ as oW,f0 as lW,f1 as Fo,f2 as cW,f3 as uW,bF as ef,f4 as Xu,f5 as dW,a2 as Xk,f6 as e2,f7 as hW,f8 as fW,f9 as pW,fa as gW,fb as mW,fc as vW,fd as ah,cW as xW,fe as bW,ff as wW,cZ as CW,fg as cw,fh as cS,fi as yW,fj as SW,fk as EW,fl as kW,ai as Pu,fm as _W,fn as TW,fo as RW,fp as AW,ax as FW,fq as _3,aX as T3,aZ as $a,fr as R3,aR as Qk,cT as uw,aY as Nf,bL as Qu,fs as dw,ft as DW,fu as PW,fv as IW,fw as NW,fx as MW,fy as OW,fz as LW,fA as BW,fB as t2,fC as jW,fD as HW,fE as Jk,fF as n2,c$ as UW,fG as GW,fH as A3,fI as $W,fJ as VW,fK as F3,fL as s2,fM as WW,fN as ze,fO as e0,fP as zW,fQ as Zk,bJ as qW,fR as KW,fS as YW,fT as r2,fU as XW,fV as QW,fW as tf,fX as JW,fY as ZW,fZ as ez,f_ as D3,f$ as P3,g0 as tz,g1 as nz,g2 as sz,g3 as rz,g4 as iz,g5 as az,g6 as oz,ak as ns,aj as _h,g7 as i2,g8 as lz,an as xo,g9 as cz,ga as uz,co as t0,cp as n0,gb as hw,gc as fa,gd as dz,ge as En,gf as Jt,gg as s0,gh as Yg,gi as fw,gj as e_,gk as pw,gl as hz,gm as fz,gn as pz,go as dn,gp as Xg,gq as I3,gr as Zi,gs as Ju,gt as gz,gu as mz,gv as vz,gw as xz,gx as a2,gy as bz,gz as wz,gA as Cz,gB as N3,gC as yz,gD as Th,gE as M3,gF as O3,gG as t_,gH as Ex,gI as L3,Q as n_,gJ as uS,gK as s_,gL as DC,gM as Sz,gN as Ez,gO as kz,gP as mh,gQ as dS,gR as B3,gS as _z,gT as j3,gU as Tz,gV as Rz,gW as Az,gX as Fz,gY as Dz,gZ as Pz,g_ as Iz,g$ as Nz,h0 as Mz,h1 as Oz,h2 as kx,h3 as Lz,h4 as Bz,h5 as jz,h6 as Hz,h7 as Uz,h8 as Gz,h9 as r_,ha as $z,hb as H3,B as Xe,hc as Vz,hd as gw,he as r0,bO as U3,bS as Wz,hf as o2,a$ as G3,hg as zz,hh as qz,hi as Kz,hj as Yz,hk as Xz,hl as Qz,ap as xr,hm as Jz,hn as Zz,ho as eq,hp as tq,hq as nq,hr as sq,hs as rq,ht as iq,hu as aq,hv as oq,hw as lq,hx as cq,hy as uq,hz as nf,hA as mw,hB as i_,hC as dq,hD as hq,hE as fq,hF as $3,hG as pq,hH as l2,hI as gq,hJ as a_,hK as mq,hL as o_,hM as i0,hN as a0,hO as vq,hP as V3,hQ as Qg,hR as xq,hS as bq,hT as wq,hU as Cq,hV as yq,hW as Sq,hX as c2,hY as W3,cm as z3,hZ as Eq,h_ as kq,ct as vw,h$ as _q,i0 as Tq,i1 as Rq,i2 as u2,i3 as xw,i4 as Aq,i5 as Fq,i6 as Dq,i7 as Pq,i8 as q3,U as Iq,i9 as PC,ia as Nq,ib as K3,be as ug,ic as Y3,dN as Mq,id as Oq,bR as l_,ie as pc,ig as c_,ih as X3,ii as Lq,ba as Bq,bb as bw,b7 as sf,ij as Q3,ik as jq,il as J3,im as Z3,cx as dg,aO as o0,bf as Zu,io as d2,ip as Hq,iq as Rh,ir as _x,is as h2,it as Uq,iu as Gq,iv as $q,iw as Vq,ix as Wq,iy as u_,iz as zq,iA as qq,iB as f2,iC as Kq,iD as e4,iE as Yq,iF as Xq,dj as Qq,iG as Jq,iH as d_,iI as Zq,iJ as eK,iK as V0,iL as t4,iM as hS,Z as p2,iN as tK,iO as nK,iP as sK,iQ as Iu,dl as n4,dm as h_,iR as rK,iS as iK,iT as aK,iU as s4,ck as oK,iV as g2,a3 as m2,iW as lK,iX as r4,iY as cK,iZ as uK,i_ as v2,i$ as dK,b1 as x2,b2,b3 as w2,aq as hK,j0 as fK,j1 as pK,j2 as gK,j3 as mK,j4 as zd,j5 as qd,j6 as vK,j7 as xK,j8 as bK,j9 as wK,ja as i4,jb as CK,jc as a4,jd as fS,je as pS,jf as IC,jg as yK,jh as SK,ji as oh,jj as EK,af as Tx,ah as o4,al as kK,$ as C2,jk as _K,jl as TK,jm as RK,jn as AK,jo as FK,jp as DK,jq as PK,jr as l4,js as IK,jt as gS,ju as Yv,jv as c4,jw as u4,jx as NK,jy as MK,jz as OK,jA as LK,jB as d4,jC as Mf,jD as BK,jE as jK,jF as f_,b5 as HK,jG as UK,jH as GK,jI as $K,jJ as VK,jK as WK,jL as zK,jM as qK,jN as KK,jO as YK,jP as XK,b0 as QK,jQ as y2,jR as JK,jS as NC,jT as S2,jU as ZK,jV as eY,jW as tY,jX as nY,jY as sY,jZ as rY,j_ as iY,j$ as aY,k0 as oY,k1 as lY,k2 as cY,k3 as uY,k4 as E2,k5 as dY,k6 as hY,aa as fY,ab as pY,ac as gY,ad as mY,ae as vY,k7 as xY,k8 as bY,k9 as wY,ka as CY,kb as yY,kc as SY,kd as EY,am as kY,ke as _Y,kf as TY,kg as RY,kh as k2,c_ as h4,ki as p_,kj as AY,aW as f4,kk as p4,kl as FY,km as DY,kn as g4,ko as PY,kp as br,kq as Xl,kr as m4,ks as v4,cH as x4,kt as b4,ku as g_,kv as yi,kw as IY,kx as NY,ky as MY,kz as OY,kA as LY,kB as BY,kC as jY,kD as HY,kE as UY,kF as GY,kG as $Y,kH as w4,kI as VY,kJ as WY,kK as zY,kL as qY,kM as KY,kN as mS,kO as YY,kP as XY,kQ as _2,kR as C4,kS as QY,kT as JY,kU as ZY,kV as T2,kW as eX,kX as tX,kY as nX,kZ as sX,k_ as rX,k$ as iX,l0 as aX,l1 as oX,dp as wo,l2 as y4,l3 as lX,di as Rx,l4 as cX,bK as uX,dd as dX,l5 as R2,l6 as hX,l7 as fX,l8 as pX,l9 as gX,cO as mX,d4 as vX,la as xX,lb as bX,lc as wX,ld as CX,aL as S4,d3 as A2,le as yX,a4 as SX,bg as Tl,lf as EX,lg as kX,lh as _X,li as Jr,a_ as F2,lj as Ax,lk as D2,ll as TX,lm as MC,ln as OC,lo as P2,lp as LC,lq as I2,lr as E4,ls as k4,lt as _4,lu as RX,as as AX,at as FX,lv as DX,au as PX}from"./conversation-input-sync-DeCSVDem.js";import{c as at,a8 as IX,a9 as T4,aa as NX,ab as MX,ac as OX,ad as LX,ae as BX,af as jX,ag as pp,ah as HX,ai as Of,S as Rn,j as Lo,B as ce,L as tr,I as Ds,T as m_,C as Ls,X as On,aj as vS,ak as Eu,q as Do,p as ra,i as v_,a as rf,a7 as ww,f as rt,R as Lf,al as xd,am as bd,an as x_,ao as Sc,A as zr,ap as b_,s as Jg,t as Zg,u as em,v as tm,w as nm,D as Rl,k as Po,l as Al,m as Fx,n as Ai,o as jt,aq as Cw,r as Ec,a5 as w_,ar as xS,as as UX,at as GX,au as $X,N as R4,O as A4,P as bS,e as Xv,a6 as VX,U as Dx,V as WX,W as sm,av as zX,b as F4,aw as qX,d as D4,ax as KX,ay as N2,Z as YX,a3 as wS,Y as XX,az as CS,aA as QX,aB as P4,y as C_,Q as JX,_ as ZX,$ as eQ,a0 as tQ,a1 as nQ,a2 as sQ,aC as rQ,aD as iQ,aE as aQ,aF as oQ,aG as I4,g as M2,h as O2,E as lQ}from"./error-boundary-sr-ahxTS.js";import{u as Ve,r as N4,g as M4,c as l0,h as L2,C as cQ,i as uQ,j as dQ,k as Gp,l as hQ,m as O4,S as BC,t as fQ,n as B2,o as j2,q as pQ,s as H2,v as gQ,w as su,x as W0,y as mQ,z as vQ,A as xQ,B as U2,E as G2,F as bQ,G as wQ,H as CQ,I as yQ,J as $2,L as V2,M as W2,N as SQ,O as EQ,P as kQ,Q as _Q,R as TQ,U as z2,V as RQ,W as AQ,X as q2,Y as FQ,d as K2,Z as DQ,T as PQ,_ as IQ,$ as NQ,a0 as MQ,a1 as z0,a2 as q0,a3 as Y2,a4 as K0,a5 as Y0,a6 as X2,a7 as Q2,a8 as OQ,a9 as Qv,aa as LQ,ab as BQ,p as jQ,ac as J2,ad as HQ,ae as UQ,af as Z2,ag as GQ}from"./ui-preferences-store-DApxrOwj.js";import{C as $Q}from"./console-mirror-D_HrghW0.js";const yS=8e3,L4=1e4;function VQ(e){return e?`“${e}”`:"Conversation"}const WQ="archived.";function zQ(e){return Ce.getState().archiveFacts[e]}function qQ(e){const t=Ce.getState(),n=t.archiveFacts[e];return n?n.archived:t.sessions.find(s=>s.session_id===e)?.archived}function KQ(){const e=Ce(t=>t.archiveUndo);g.useEffect(()=>{if(e===null)return;let t=!1;const n=()=>{t||(t=!0,r())},s=()=>{n();const i=Ce.getState().archiveUndo;i!==null&&i.sessionId===e.sessionId&&i.at===e.at&&Ce.getState().setArchiveUndo(null)},r=Ce.subscribe(()=>{const i=zQ(e.sessionId);i!==void 0&&!i.answered||gV(e.archived,qQ(e.sessionId))||s()});return n},[e])}function YQ(e){return e===1?"Draft":`${e} drafts`}const XQ="discarded.",QQ=e=>{const t=aS(e),n=t.length,s=t.filter(o=>!o.active).length,r=n===1?"chat":"chats",i=e.filter(o=>iw(o)!==null&&aS([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`:""}},B4=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.`,JQ=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?B4(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(" ")}},jC="archive",eF="drafts-undo",tF="bulk-read-deferral",ZQ=8e3;function eJ(){const e=Ce(h=>h.archiveFailure),t=Ce(h=>h.archiveUndo),n=Ce(h=>h.draftsUndo),s=Ce(h=>h.bulkReadDeferral),r=Ce(h=>h.clearArchiveFailure),i=Ce(h=>h.setArchiveUndo),a=Ce(h=>h.setSessionArchived),o=Ce(h=>h.restoreDraftsUndo);KQ();const l=g.useRef(null);g.useEffect(()=>{if(e===null&&t===null){if(l.current===null)return;l.current=null,qv(jC);return}const h=e&&t?t.at>e.at?"offer":"failure":e?"failure":"offer",f=h==="offer"?t?.at??0:e?.at??0,p=l.current;l.current={kind:h,at:f},p!==null&&p.kind!==h&&f>p.at&&(h==="failure"?i(null):r());const m=(v,x)=>()=>{const b=Ce.getState();v==="offer"?b.archiveUndo?.at===x&&b.setArchiveUndo(null):b.archiveFailure?.at===x&&b.clearArchiveFailure();const w=l.current;w!==null&&w.kind===v&&w.at===x&&(l.current=null)};if(h==="failure"&&e){Eh(`Could not ${e.archived?"archive":"unarchive"} “${e.title}”.${e.detail?` ${e.detail}`:""}`,{id:jC,duration:L4,onAutoClose:m("failure",e.at),onDismiss:m("failure",e.at),action:{label:"Retry",onClick:v=>{v.preventDefault(),a(e.sessionId,e.archived,e.title)}}});return}t&&La(c.jsxs("span",{className:_("flex min-w-0 items-baseline gap-1"),children:[c.jsx("span",{className:_("min-w-0 truncate"),children:VQ(t.title)}),c.jsx("span",{className:_("shrink-0"),children:WQ})]}),{id:jC,duration:yS,classNames:{content:"min-w-0"},onAutoClose:m("offer",t.at),onDismiss:m("offer",t.at),action:{label:"Undo",onClick:v=>{v.preventDefault(),a(t.sessionId,!t.archived,t.title)}}})},[e,t,i,r,a]);const u=g.useRef(!1);g.useEffect(()=>{if(n===null){if(!u.current)return;u.current=!1,qv(eF);return}u.current=!0;const h=()=>{const f=Ce.getState();f.draftsUndo?.at===n.at&&(f.setDraftsUndo(null),u.current=!1)};La(c.jsxs("span",{className:_("flex min-w-0 items-baseline gap-1"),children:[c.jsx("span",{className:_("min-w-0 truncate"),children:YQ(n.keys.length)}),c.jsx("span",{className:_("shrink-0"),children:XQ})]}),{id:eF,duration:yS,classNames:{content:"min-w-0"},onAutoClose:h,onDismiss:h,action:{label:"Undo",onClick:f=>{f.preventDefault(),o();const p=Ce.getState(),m=p.stagedByDiscard;p.setStagedByDiscard(null),n.keys.length===1&&m!==null&&Ce.getState().activeDraftKey===m&&Ce.getState().openDraft(n.keys[0])}}})},[n,o]);const d=g.useRef(!1);return g.useEffect(()=>{if(s===null){if(!d.current)return;d.current=!1,qv(tF);return}d.current=!0;const h=()=>{const f=Ce.getState();f.bulkReadDeferral?.at===s.at&&(f.clearBulkReadDeferral(),d.current=!1)};La(B4(s.count),{id:tF,duration:ZQ,onAutoClose:h,onDismiss:h})},[s]),null}var Ia,Ne=typeof window<"u"?window:void 0,ri=typeof globalThis<"u"?globalThis:Ne,j4=Array.prototype,nF=j4.forEach,sF=j4.indexOf,Ti=ri?.navigator,mt=ri?.document,ni=ri?.location,SS=ri?.fetch,ES=ri!=null&&ri.XMLHttpRequest&&"withCredentials"in new ri.XMLHttpRequest?ri.XMLHttpRequest:void 0,rF=ri?.AbortController,Rs=Ti?.userAgent,Ht=Ne??{},il={DEBUG:!1,LIB_VERSION:"1.235.6"},HC="$copy_autocapture",tJ=["$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"})(Ia||(Ia={}));var nJ=["fatal","error","warning","log","info","debug"];function Qt(e,t){return e.indexOf(t)!==-1}var yw=function(e){return e.trim()},y_=function(e){return e.replace(/^\$/,"")},sJ=Array.isArray,H4=Object.prototype,U4=H4.hasOwnProperty,Sw=H4.toString,ss=sJ||function(e){return Sw.call(e)==="[object Array]"},Ba=e=>typeof e=="function",rs=e=>e===Object(e)&&!ss(e),vh=e=>{if(rs(e)){for(var t in e)if(U4.call(e,t))return!1;return!0}return!1},ft=e=>e===void 0,Fs=e=>Sw.call(e)=="[object String]",kS=e=>Fs(e)&&e.trim().length===0,Oc=e=>e===null,Sn=e=>ft(e)||Oc(e),Wr=e=>Sw.call(e)=="[object Number]",ol=e=>Sw.call(e)==="[object Boolean]",rJ=e=>e instanceof FormData,iJ=e=>Qt(tJ,e),G4=e=>{var t={_log:function(n){if(Ne&&(il.DEBUG||Ht.POSTHOG_DEBUG)&&!ft(Ne.console)&&Ne.console){for(var s=("__rrweb_original__"in Ne.console[n])?Ne.console[n].__rrweb_original__:Ne.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=>G4("".concat(e," ").concat(n))};return t},wt=G4("[PostHog.js]"),Rr=wt.createLogger,aJ=Rr("[ExternalScriptsLoader]"),iF=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return aJ.warn("".concat(t," was requested but loading of external scripts is disabled.")),n("Loading of external scripts is disabled");var s=mt?.querySelectorAll("script");if(s){for(var r=0;r<s.length;r++)if(s[r].src===t)return n()}var i=()=>{if(!mt)return n("document not found");var a=mt.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=mt.querySelectorAll("body > script");l.length>0?(o=l[0].parentNode)===null||o===void 0||o.insertBefore(a,l[0]):mt.body.appendChild(a)};mt!=null&&mt.body?i():mt?.addEventListener("DOMContentLoaded",i)};function aF(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 je(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?aF(Object(n),!0).forEach(function(s){st(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):aF(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function st(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $4(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}Ht.__PosthogExtensions__=Ht.__PosthogExtensions__||{},Ht.__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);iF(e,a,n)},Ht.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{var s=e.requestRouter.endpointFor("api",t);iF(e,s,n)};var Px={};function gc(e,t,n){if(ss(e)){if(nF&&e.forEach===nF)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)===Px)return}}}function In(e,t,n){if(!Sn(e)){if(ss(e))return gc(e,t,n);if(rJ(e)){for(var s of e.entries())if(t.call(n,s[1],s[0])===Px)return}else for(var r in e)if(U4.call(e,r)&&t.call(n,e[r],r)===Px)return}}var ps=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 gc(n,function(r){for(var i in r)r[i]!==void 0&&(e[i]=r[i])}),e},Jv=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 gc(n,function(r){gc(r,function(i){e.push(i)})}),e};function Zv(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 oF=function(e){try{return e()}catch{return}},oJ=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){wt.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),wt.critical(r)}}},rm=function(e){var t={};return In(e,function(n,s){Fs(n)&&n.length>0&&(t[s]=n)}),t};function lJ(e,t){return n=e,s=i=>Fs(i)&&!Oc(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),ss(a)?(l=[],gc(a,u=>{l.push(i(u))})):(l={},In(a,(u,d)=>{r.has(u)||(l[d]=i(u,d))})),l);var l}(n);var n,s,r}var cJ=["herokuapp.com","vercel.app","netlify.app"];function uJ(e){var t=e?.hostname;if(!Fs(t))return!1;var n=t.split(".").slice(-2).join(".");for(var s of cJ)if(n===s)return!1;return!0}function V4(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return e[n]}function ms(e,t,n,s){var{capture:r=!1,passive:i=!0}=s??{};e?.addEventListener(t,n,{capture:r,passive:i})}var W4="$people_distinct_id",$p="__alias",Vp="__timers",lF="$autocapture_disabled_server_side",_S="$heatmaps_enabled_server_side",cF="$exception_capture_enabled_server_side",uF="$web_vitals_enabled_server_side",z4="$dead_clicks_enabled_server_side",dF="$web_vitals_allowed_metrics",TS="$session_recording_enabled_server_side",hF="$console_log_recording_enabled_server_side",fF="$session_recording_network_payload_capture",pF="$session_recording_masking",gF="$session_recording_canvas_recording",mF="$replay_sample_rate",vF="$replay_minimum_duration",xF="$replay_script_config",Ix="$sesid",Wp="$session_is_sampled",UC="$session_recording_url_trigger_activated_session",GC="$session_recording_event_trigger_activated_session",xh="$enabled_feature_flags",ex="$early_access_features",RS="$feature_flag_details",zp="$stored_person_properties",uu="$stored_group_properties",AS="$surveys",X0="$surveys_activated",Nx="$flag_call_reported",nl="$user_state",FS="$client_session_props",DS="$capture_rate_limit",PS="$initial_campaign_params",IS="$initial_referrer_info",NS="$initial_person_info",Mx="$epp",q4="__POSTHOG_TOOLBAR__",bF="$posthog_cookieless",dJ=[W4,$p,"__cmpns",Vp,TS,_S,Ix,xh,nl,ex,RS,uu,zp,AS,Nx,FS,DS,PS,IS,Mx];function wF(e){var t;return e instanceof Element&&(e.id===q4||!((t=e.closest)===null||t===void 0||!t.call(e,".toolbar-global-fade-container")))}function Ew(e){return!!e&&e.nodeType===1}function mc(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function K4(e){return!!e&&e.nodeType===3}function Y4(e){return!!e&&e.nodeType===11}function S_(e){return e?yw(e).split(/\s+/):[]}function CF(e){var t=Ne?.location.href;return!!(t&&e&&e.some(n=>t.match(n)))}function Ox(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 S_(t)}function X4(e){return Sn(e)?null:yw(e).split(/(\s+)/).filter(t=>af(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function kw(e){var t="";return OS(e)&&!Z4(e)&&e.childNodes&&e.childNodes.length&&In(e.childNodes,function(n){var s;K4(n)&&n.textContent&&(t+=(s=X4(n.textContent))!==null&&s!==void 0?s:"")}),yw(t)}function Q4(e){return ft(e.target)?e.srcElement||null:(t=e.target)!==null&&t!==void 0&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var MS=["a","button","form","input","select","textarea","label"];function J4(e){var t=e.parentNode;return!(!t||!Ew(t))&&t}function hJ(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(!Ne||!e||mc(e,"html")||!Ew(e)||n!=null&&n.url_allowlist&&!CF(n.url_allowlist)||n!=null&&n.url_ignorelist&&CF(n.url_ignorelist))return!1;if(n!=null&&n.dom_event_allowlist){var i=n.dom_event_allowlist;if(i&&!i.some(p=>t.type===p))return!1}for(var a=!1,o=[e],l=!0,u=e;u.parentNode&&!mc(u,"body");)if(Y4(u.parentNode))o.push(u.parentNode.host),u=u.parentNode.host;else{if(!(l=J4(u)))break;if(s||MS.indexOf(l.tagName.toLowerCase())>-1)a=!0;else{var d=Ne.getComputedStyle(l);d&&d.getPropertyValue("cursor")==="pointer"&&(a=!0)}o.push(l),u=l}if(!function(p,m){var v=m?.element_allowlist;if(ft(v))return!0;var x=function(C){if(v.some(E=>C.tagName.toLowerCase()===E))return{v:!0}};for(var b of p){var w=x(b);if(typeof w=="object")return w.v}return!1}(o,n)||!function(p,m){var v=m?.css_selector_allowlist;if(ft(v))return!0;var x=function(C){if(v.some(E=>C.matches(E)))return{v:!0}};for(var b of p){var w=x(b);if(typeof w=="object")return w.v}return!1}(o,n))return!1;var h=Ne.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&&(MS.indexOf(f)>-1||e.getAttribute("contenteditable")==="true")}}function OS(e){for(var t=e;t.parentNode&&!mc(t,"body");t=t.parentNode){var n=Ox(t);if(Qt(n,"ph-sensitive")||Qt(n,"ph-no-capture"))return!1}if(Qt(Ox(e),"ph-include"))return!0;var s=e.type||"";if(Fs(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=e.name||e.id||"";return!(Fs(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 Z4(e){return!!(mc(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||mc(e,"select")||mc(e,"textarea")||e.getAttribute("contenteditable")==="true")}var eB="(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})",fJ=new RegExp("^(?:".concat(eB,")$")),pJ=new RegExp(eB),tB="\\d{3}-?\\d{2}-?\\d{4}",gJ=new RegExp("^(".concat(tB,")$")),mJ=new RegExp("(".concat(tB,")"));function af(e){var t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return!(Sn(e)||Fs(e)&&(e=yw(e),(t?fJ:pJ).test((e||"").replace(/[- ]/g,""))||(t?gJ:mJ).test(e)))}function nB(e){var t=kw(e);return af(t="".concat(t," ").concat(sB(e)).trim())?t:""}function sB(e){var t="";return e&&e.childNodes&&e.childNodes.length&&In(e.childNodes,function(n){var s;if(n&&((s=n.tagName)===null||s===void 0?void 0:s.toLowerCase())==="span")try{var r=kw(n);t="".concat(t," ").concat(r).trim(),n.childNodes&&n.childNodes.length&&(t="".concat(t," ").concat(sB(n)).trim())}catch(i){wt.error("[AutoCapture]",i)}}),t}function vJ(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=je(je(je(je({},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 Zv(l).sort((d,h)=>{var[f]=d,[p]=h;return f.localeCompare(p)}).forEach(d=>{var[h,f]=d;return u[yF(h.toString())]=yF(f.toString())}),a+=":",a+=Zv(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:xJ(n),attr_id:n.attr__id,nth_child:n.nth_child,nth_of_type:n.nth_of_type,attributes:{}};return Zv(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 yF(e){return e.replace(/"|\\"/g,'\\"')}function xJ(e){var t=e.attr__class;return t?ss(t)?t:S_(t):void 0}class rB{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 bJ=["localhost","127.0.0.1"],Ah=e=>{var t=mt?.createElement("a");return ft(t)?null:(t.href=e,t)},wJ=function(e){var t,n,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"&",r=[];return In(e,function(i,a){ft(i)||ft(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)},Lx=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(!ss(n)||n.length<2)return"";var a=n[1];try{a=decodeURIComponent(a)}catch{wt.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},$C=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("=");ss(f)&&(t.includes(f[0])?d.push(f[0]+"="+n):d.push(u[h]))}var p=l;return o!=null&&(p+="?"+d.join("&")),i!=null&&(p+="#"+i),p},Bx=function(e,t){var n=e.match(new RegExp(t+"=([^&]*)"));return n?n[1]:null},SF=Rr("[AutoCapture]");function VC(e,t){return t.length>e?t.slice(0,e)+"...":t}function CJ(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!Ew(t));return t}function yJ(e,t,n,s){var r=e.tagName.toLowerCase(),i={tag_name:r};MS.indexOf(r)>-1&&!n&&(r.toLowerCase()==="a"||r.toLowerCase()==="button"?i.$el_text=VC(1024,nB(e)):i.$el_text=VC(1024,kw(e)));var a=Ox(e);a.length>0&&(i.classes=a.filter(function(d){return d!==""})),In(e.attributes,function(d){var h;if((!Z4(e)||["name","id","class","aria-label"].indexOf(d.name)!==-1)&&(s==null||!s.includes(d.name))&&!t&&af(d.value)&&(h=d.name,!Fs(h)||h.substring(0,10)!=="_ngcontent"&&h.substring(0,7)!=="_nghost")){var f=d.value;d.name==="class"&&(f=S_(f).join(" ")),i["attr__"+d.name]=VC(1024,f)}});for(var o=1,l=1,u=e;u=CJ(u);)o++,u.tagName===e.tagName&&l++;return i.nth_child=o,i.nth_of_type=l,i}function SJ(e,t){for(var n,s,{e:r,maskAllElementAttributes:i,maskAllText:a,elementAttributeIgnoreList:o,elementsChainAsString:l}=t,u=[e],d=e;d.parentNode&&!mc(d,"body");)Y4(d.parentNode)?(u.push(d.parentNode.host),d=d.parentNode.host):(u.push(d.parentNode),d=d.parentNode);var h,f=[],p={},m=!1,v=!1;if(In(u,E=>{var y=OS(E);E.tagName.toLowerCase()==="a"&&(m=E.getAttribute("href"),m=y&&m&&af(m)&&m),Qt(Ox(E),"ph-no-capture")&&(v=!0),f.push(yJ(E,i,a,o));var k=function(T){if(!OS(T))return{};var P={};return In(T.attributes,function(A){if(A.name&&A.name.indexOf("data-ph-capture-attribute")===0){var N=A.name.replace("data-ph-capture-attribute-",""),M=A.value;N&&M&&af(M)&&(P[N]=M)}}),P}(E);ps(p,k)}),v)return{props:{},explicitNoCapture:v};if(a||(e.tagName.toLowerCase()==="a"||e.tagName.toLowerCase()==="button"?f[0].$el_text=nB(e):f[0].$el_text=kw(e)),m){var x,b;f[0].attr__href=m;var w=(x=Ah(m))===null||x===void 0?void 0:x.host,C=Ne==null||(b=Ne.location)===null||b===void 0?void 0:b.host;w&&C&&w!==C&&(h=m)}return{props:ps({$event_type:r.type,$ce_version:1},l?{}:{$elements:f},{$elements_chain:vJ(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}:{},p)}}let EJ=class{constructor(t){st(this,"_initialized",!1),st(this,"_isDisabledServerSide",null),st(this,"rageclicks",new rB),st(this,"_elementsChainAsString",!1),this.instance=t,this._elementSelectors=null}get config(){var t,n,s=rs(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(Ne&&mt){var t=s=>{s=s||Ne?.event;try{this._captureEvent(s)}catch(r){SF.error("Failed to capture event",r)}};if(ms(mt,"submit",t,{capture:!0}),ms(mt,"change",t,{capture:!0}),ms(mt,"click",t,{capture:!0}),this.config.capture_copied_text){var n=s=>{s=s||Ne?.event,this._captureEvent(s,HC)};ms(mt,"copy",n,{capture:!0}),ms(mt,"cut",n,{capture:!0})}}}else SF.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({[lF]:!!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=mt?.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[lF],r=this._isDisabledServerSide;if(Oc(r)&&!ol(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=Q4(t);K4(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===HC;if(r&&hJ(r,t,this.config,i,i?["copy","cut"]:void 0)){var{props:a,explicitNoCapture:o}=SJ(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===HC){var u,d=X4(Ne==null||(u=Ne.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 Ba(mt?.querySelectorAll)}};Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return Wr(e)&&isFinite(e)&&Math.floor(e)===e});var EF="0123456789abcdef";let kJ=class LS{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 LS(i)}toString(){for(var t="",n=0;n<this.bytes.length;n++)t=t+EF.charAt(this.bytes[n]>>>4)+EF.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 LS(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}},_J=class{constructor(){st(this,"timestamp",0),st(this,"counter",0),st(this,"random",new TJ)}generate(){var t=this.generateOrAbort();if(ft(t)){this.timestamp=0;var n=this.generateOrAbort();if(ft(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 kJ.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 kF,iB=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};Ne&&!ft(Ne.crypto)&&crypto.getRandomValues&&(iB=e=>crypto.getRandomValues(e));let TJ=class{constructor(){st(this,"buffer",new Uint32Array(8)),st(this,"cursor",1/0)}nextUint32(){return this.cursor>=this.buffer.length&&(iB(this.buffer),this.cursor=0),this.buffer[this.cursor++]}};var oc=()=>RJ().toString(),RJ=()=>(kF||(kF=new _J)).generate(),AJ="Thu, 01 Jan 1970 00:00:00 GMT",gp="",FJ=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function DJ(e,t){if(t){var n=function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:mt;if(gp)return gp;if(!i||["localhost","127.0.0.1"].includes(r))return"";for(var a=r.split("."),o=Math.min(a.length,8),l="dmn_chk_"+oc(),u=new RegExp("(^|;)\\s*"+l+"=1");!gp&&o--;){var d=a.slice(o).join("."),h=l+"=1;domain=."+d;i.cookie=h,u.test(i.cookie)&&(i.cookie=h+";expires="+AJ,gp=d)}return gp}(e);if(!n){var s=(r=>{var i=r.match(FJ);return i?i[0]:""})(e);s!==n&&wt.info("Warning: cookie subdomain discovery mismatch",s,n),n=s}return n?"; domain=."+n:""}return""}var tc,dl={is_supported:()=>!!mt,error:function(e){wt.error("cookieStore error: "+e)},get:function(e){if(mt){try{for(var t=e+"=",n=mt.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(dl.get(e))||{}}catch{}return t},set:function(e,t,n,s,r){if(mt)try{var i="",a="",o=DJ(mt.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&&wt.warn("cookieStore warning: large cookie, len="+u.length),mt.cookie=u,u}catch{return}},remove:function(e,t){try{dl.set(e,"",-1,t)}catch{return}}},WC=null,Ns={is_supported:function(){if(!Oc(WC))return WC;var e=!0;if(ft(Ne))e=!1;else try{var t="__mplssupport__";Ns.set(t,"xyz"),Ns.get(t)!=='"xyz"'&&(e=!1),Ns.remove(t)}catch{e=!1}return e||wt.error("localStorage unsupported; falling back to cookie store"),WC=e,e},error:function(e){wt.error("localStorage error: "+e)},get:function(e){try{return Ne?.localStorage.getItem(e)}catch(t){Ns.error(t)}return null},parse:function(e){try{return JSON.parse(Ns.get(e))||{}}catch{}return null},set:function(e,t){try{Ne?.localStorage.setItem(e,JSON.stringify(t))}catch(n){Ns.error(n)}},remove:function(e){try{Ne?.localStorage.removeItem(e)}catch(t){Ns.error(t)}}},PJ=["distinct_id",Ix,Wp,Mx,NS],Q0=je(je({},Ns),{},{parse:function(e){try{var t={};try{t=dl.parse(e)||{}}catch{}var n=ps(t,JSON.parse(Ns.get(e)||"{}"));return Ns.set(e,n),n}catch{}return null},set:function(e,t,n,s,r,i){try{Ns.set(e,t,void 0,void 0,i);var a={};PJ.forEach(o=>{t[o]&&(a[o]=t[o])}),Object.keys(a).length&&dl.set(e,a,n,s,r,i)}catch(o){Ns.error(o)}},remove:function(e,t){try{Ne?.localStorage.removeItem(e),dl.remove(e,t)}catch(n){Ns.error(n)}}}),J0={},IJ={is_supported:function(){return!0},error:function(e){wt.error("memoryStorage error: "+e)},get:function(e){return J0[e]||null},parse:function(e){return J0[e]||null},set:function(e,t){J0[e]=t},remove:function(e){delete J0[e]}},ru=null,ir={is_supported:function(){if(!Oc(ru))return ru;if(ru=!0,ft(Ne))ru=!1;else try{var e="__support__";ir.set(e,"xyz"),ir.get(e)!=='"xyz"'&&(ru=!1),ir.remove(e)}catch{ru=!1}return ru},error:function(e){wt.error("sessionStorage error: ",e)},get:function(e){try{return Ne?.sessionStorage.getItem(e)}catch(t){ir.error(t)}return null},parse:function(e){try{return JSON.parse(ir.get(e))||null}catch{}return null},set:function(e,t){try{Ne?.sessionStorage.setItem(e,JSON.stringify(t))}catch(n){ir.error(n)}},remove:function(e){try{Ne?.sessionStorage.removeItem(e)}catch(t){ir.error(t)}}};(function(e){e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED"})(tc||(tc={}));let NJ=class{constructor(t){this.instance=t}get config(){return this.instance.config}get consent(){return this.getDnt()?tc.DENIED:this.storedConsent}isOptedOut(){return this.consent===tc.DENIED||this.consent===tc.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"?tc.GRANTED:t==="0"?tc.DENIED:tc.PENDING}get storage(){if(!this._storage){var t=this.config.opt_out_capturing_persistence_type;this._storage=t==="localStorage"?Ns:dl;var n=t==="localStorage"?dl:Ns;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&&!!V4([Ti?.doNotTrack,Ti?.msDoNotTrack,Ht.doNotTrack],t=>Qt([!0,1,"1","yes"],t))}};var Z0=Rr("[Dead Clicks]"),MJ=()=>!0,OJ=e=>{var t,n=!((t=e.instance.persistence)===null||t===void 0||!t.get_property(z4)),s=e.instance.config.capture_dead_clicks;return ol(s)?s:n};let aB=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({[z4]:t?.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.loadScript(()=>{this.start()})}loadScript(t){var n,s,r;(n=Ht.__PosthogExtensions__)!==null&&n!==void 0&&n.initDeadClicksAutocapture&&t(),(s=Ht.__PosthogExtensions__)===null||s===void 0||(r=s.loadExternalDependency)===null||r===void 0||r.call(s,this.instance,"dead-clicks-autocapture",i=>{i?Z0.error("failed to load script",i):t()})}start(){var t;if(mt){if(!this._lazyLoadedDeadClicksAutocapture&&(t=Ht.__PosthogExtensions__)!==null&&t!==void 0&&t.initDeadClicksAutocapture){var n=rs(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};n.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=Ht.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this._lazyLoadedDeadClicksAutocapture.start(mt),Z0.info("starting...")}}else Z0.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Z0.info("stopping..."))}};var zC=Rr("[ExceptionAutocapture]");let LJ=class{constructor(t){var n;st(this,"startCapturing",()=>{var s;if(Ne&&this.isEnabled&&(s=Ht.__PosthogExtensions__)!==null&&s!==void 0&&s.errorWrappingFunctions){var r=Ht.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Ht.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=Ht.__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){zC.error("failed to start",o),this.stopCapturing()}}}),this.instance=t,this.remoteEnabled=!((n=this.instance.persistence)===null||n===void 0||!n.props[cF]),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 rs(t)?n=je(je({},n),t):(ft(t)?this.remoteEnabled:t)&&(n=je(je({},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&&(zC.info("enabled"),this.loadScript(this.startCapturing))}loadScript(t){var n,s,r;(n=Ht.__PosthogExtensions__)!==null&&n!==void 0&&n.errorWrappingFunctions&&t(),(s=Ht.__PosthogExtensions__)===null||s===void 0||(r=s.loadExternalDependency)===null||r===void 0||r.call(s,this.instance,"exception-autocapture",i=>{if(i)return zC.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({[cF]: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 oB(e){return!ft(Event)&&lB(e,Event)}function lB(e,t){try{return e instanceof t}catch{return!1}}function tx(e,t){return Object.prototype.toString.call(e)==="[object ".concat(t,"]")}function qC(e){return tx(e,"DOMError")}var _F=/\(error: (.*)\)/,TF=50,bh="?";function KC(e,t,n,s){var r={platform:"web:javascript",filename:e,function:t==="<anonymous>"?bh:t,in_app:!0};return ft(n)||(r.lineno=n),ft(s)||(r.colno=s),r}var BJ=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,jJ=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,HJ=/\((\S*)(?::(\d+))(?::(\d+))\)/,UJ=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,GJ=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,$J=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=_F.test(u)?u.replace(_F,"$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>=TF)break}}}return function(p){if(!p.length)return[];var m=Array.from(p);return m.reverse(),m.slice(0,TF).map(v=>je(je({},v),{},{filename:v.filename||VJ(m).filename,function:v.function||bh}))}(a)}}([30,e=>{var t=BJ.exec(e);if(t){var[,n,s,r]=t;return KC(n,bh,+s,+r)}var i=jJ.exec(e);if(i){if(i[2]&&i[2].indexOf("eval")===0){var a=HJ.exec(i[2]);a&&(i[2]=a[1],i[3]=a[2],i[4]=a[3])}var[o,l]=AF(i[1]||bh,i[2]);return KC(l,o,i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}}],[50,e=>{var t=UJ.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var n=GJ.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]||bh;return[r,s]=AF(r,s),KC(s,r,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}}]);function VJ(e){return e[e.length-1]||{}}var ev,RF,YC,AF=(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]:bh,n?"safari-extension:".concat(t):"safari-web-extension:".concat(t)]:[e,t]},WJ=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;function E_(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=e.stacktrace||e.stack||"",s=function(a){return a&&zJ.test(a.message)?1:0}(e);try{var r=$J,i=function(a,o){var l=function(u){var d=globalThis._posthogChunkIds;if(!d)return{};var h=Object.keys(d);return YC&&h.length===RF||(RF=h.length,YC=h.reduce((f,p)=>{ev||(ev={});var m=ev[p];if(m)f[m[0]]=m[1];else for(var v=u(p),x=v.length-1;x>=0;x--){var b=v[x],w=b?.filename,C=d[p];if(w&&C){f[w]=C,ev[p]=[w,C];break}}return f},{})),YC}(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 zJ=/Minified React error #\d+;/i;function XC(e,t){var n,s,r=E_(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 QC(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=E_(t.syntheticException,1);l.length&&(o.stacktrace={frames:l,type:"raw"})}return{$exception_list:[o],$exception_level:"error"}}function qJ(e){return Fs(e)&&!kS(e)&&nJ.indexOf(e)>=0}function KJ(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:oB(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 p=f.length;p>0;p--){var m=f.slice(0,p).join(", ");if(!(m.length>h))return p===f.length||m.length<=h?m:"".concat(m.slice(0,h),"...")}return""}(e)),l={type:a,value:o,mechanism:{handled:r,synthetic:i}};if(t!=null&&t.syntheticException){var u=E_(t?.syntheticException,1);u.length&&(l.stacktrace={frames:u,type:"raw"})}return{$exception_list:[l],$exception_level:qJ(e.level)?e.level:"error"}}function YJ(e,t){var{error:n,event:s}=e,r={$exception_list:[]},i=n||s;if(qC(i)||function(p){return tx(p,"DOMException")}(i)){var a=i;if(function(p){return"stack"in p}(i))r=XC(i,t);else{var o=a.name||(qC(a)?"DOMError":"DOMException"),l=a.message?"".concat(o,": ").concat(a.message):o,u=qC(a)?"DOMError":"DOMException";r=QC(l,je(je({},t),{},{overrideExceptionType:u,defaultExceptionMessage:l}))}return"code"in a&&(r.$exception_DOMException_code="".concat(a.code)),r}if(function(p){return tx(p,"ErrorEvent")}(i)&&i.error)return XC(i.error,t);if(function(p){switch(Object.prototype.toString.call(p)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":return!0;default:return lB(p,Error)}}(i))return XC(i,t);if(function(p){return tx(p,"Object")}(i)||oB(i))return KJ(i,t);if(ft(n)&&Fs(s)){var d="Error",h=s,f=s.match(WJ);return f&&(d=f[1],h=f[2]),QC(h,je(je({},t),{},{overrideExceptionType:d,defaultExceptionMessage:h}))}return QC(i,t)}function jx(e){var t,n;return((t=JSON.stringify(e,(n=[],function(s,r){if(rs(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 BS(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[BS({size:jx(s),data:s,sessionId:e.sessionId,windowId:e.windowId}),BS({size:jx(r),data:r,sessionId:e.sessionId,windowId:e.windowId})].flatMap(i=>i)}return[e]}var sl=(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))(sl||{}),Da=(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))(Da||{}),jS="[SessionRecording]",HS="redacted",tv={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"]},XJ=["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"],QJ=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],JJ=["/s/","/e/","/i/"];function FF(e,t,n,s){if(Sn(e))return e;var r=t?.["content-length"]||function(i){return new Blob([i]).size}(e);return Fs(r)&&(r=parseInt(r)),r>n?jS+" ".concat(s," body too large to record (").concat(r," bytes)"):e}function DF(e,t){if(Sn(e))return e;var n=e;return af(n,!1)||(n=jS+" "+t+" body "+HS),In(QJ,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=jS+" "+t+" body "+HS+" as might contain: "+s)}),n}var ZJ=(e,t)=>{var n,s,r,i={payloadSizeLimitBytes:tv.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...tv.performanceEntryTypeToObserve],payloadHostDenyList:[...t.payloadHostDenyList||[],...tv.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=FF(f.requestBody,f.requestHeaders,r,"Request")),f!=null&&f.responseBody&&(f.responseBody=FF(f.responseBody,f.responseHeaders,r,"Response")),f)),d=f=>{return u(((v,x)=>{var b,w=Ah(v.name),C=x.indexOf("http")===0?(b=Ah(x))===null||b===void 0?void 0:b.pathname:x;C==="/"&&(C="");var E=w?.pathname.replace(C||"","");if(!(w&&E&&JJ.some(y=>E.indexOf(y)===0)))return v})((m=(p=f).requestHeaders,Sn(m)||In(Object.keys(m??{}),v=>{XJ.includes(v.toLowerCase())&&(m[v]=HS)}),p),e.api_host));var p,m},h=Ba(e.session_recording.maskNetworkRequestFn);return h&&Ba(e.session_recording.maskCapturedNetworkRequestFn)&&wt.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),h&&(e.session_recording.maskCapturedNetworkRequestFn=f=>{var p=e.session_recording.maskNetworkRequestFn({url:f.name});return je(je({},f),{},{name:p?.url})}),i.maskRequestFn=Ba(e.session_recording.maskCapturedNetworkRequestFn)?f=>{var p,m,v,x=d(f);return x&&(p=(m=(v=e.session_recording).maskCapturedNetworkRequestFn)===null||m===void 0?void 0:m.call(v,x))!==null&&p!==void 0?p:void 0}:f=>function(p){if(!ft(p))return p.requestBody=DF(p.requestBody,"Request"),p.responseBody=DF(p.responseBody,"Response"),p}(d(f)),je(je(je({},tv),i),{},{recordHeaders:a,recordBody:o,recordPerformance:l,recordInitialRequests:l})};function ea(e,t,n,s,r){return t>n&&(wt.warn("min cannot be greater than max."),t=n),Wr(e)?e>n?(s&&wt.warn(s+" cannot be greater than max: "+n+". Using max value instead."),n):e<t?(s&&wt.warn(s+" cannot be less than min: "+t+". Using min value instead."),t):e:(s&&wt.warn(s+" must be a number. using max or fallback. max: "+n+", fallback: "+r),ea(r||n,t,n,s))}let eZ=class{constructor(t){var n,s,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};st(this,"bucketSize",100),st(this,"refillRate",10),st(this,"mutationBuckets",{}),st(this,"loggedTracker",{}),st(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]})}),st(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]}),st(this,"numberOfChanges",i=>{var a,o,l,u,d,h,f,p;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=(p=i.adds)===null||p===void 0?void 0:p.length)!==null&&f!==void 0?f:0)}),st(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,[p,m]=this.getNodeOrRelevantParent(u.id);return this.mutationBuckets[p]===0?!1:(this.mutationBuckets[p]=(d=this.mutationBuckets[p])!==null&&d!==void 0?d:this.bucketSize,this.mutationBuckets[p]=Math.max(this.mutationBuckets[p]-1,0),this.mutationBuckets[p]===0&&(this.loggedTracker[p]||(this.loggedTracker[p]=!0,(h=(f=this.options).onBlockedNode)===null||h===void 0||h.call(f,p,m))),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 ia=Uint8Array,ii=Uint16Array,of=Uint32Array,k_=new ia([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]),__=new ia([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]),PF=new ia([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),cB=function(e,t){for(var n=new ii(31),s=0;s<31;++s)n[s]=t+=1<<e[s-1];var r=new of(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]},uB=cB(k_,2),tZ=uB[0],US=uB[1];tZ[28]=258,US[258]=28;for(var IF=cB(__,0)[1],dB=new ii(32768),jn=0;jn<32768;++jn){var iu=(43690&jn)>>>1|(21845&jn)<<1;iu=(61680&(iu=(52428&iu)>>>2|(13107&iu)<<2))>>>4|(3855&iu)<<4,dB[jn]=((65280&iu)>>>8|(255&iu)<<8)>>>1}var hg=function(e,t,n){for(var s=e.length,r=0,i=new ii(t);r<s;++r)++i[e[r]-1];var a,o=new ii(t);for(r=0;r<t;++r)o[r]=o[r-1]+i[r-1]<<1;for(a=new ii(s),r=0;r<s;++r)a[r]=dB[o[e[r]-1]++]>>>15-e[r];return a},ed=new ia(288);for(jn=0;jn<144;++jn)ed[jn]=8;for(jn=144;jn<256;++jn)ed[jn]=9;for(jn=256;jn<280;++jn)ed[jn]=7;for(jn=280;jn<288;++jn)ed[jn]=8;var Hx=new ia(32);for(jn=0;jn<32;++jn)Hx[jn]=5;var nZ=hg(ed,9),sZ=hg(Hx,5),hB=function(e){return(e/8>>0)+(7&e&&1)},fB=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var s=new(e instanceof ii?ii:e instanceof of?of:ia)(n-t);return s.set(e.subarray(t,n)),s},Zo=function(e,t,n){n<<=7&t;var s=t/8>>0;e[s]|=n,e[s+1]|=n>>>8},mp=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},JC=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 ia(0),0];if(r==1){var a=new ia(n[0].s+1);return a[n[0].s]=1,[a,1]}n.sort(function(y,k){return y.f-k.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 p=new ii(f+1),m=GS(n[d-1],p,0);if(m>t){s=0;var v=0,x=m-t,b=1<<x;for(i.sort(function(y,k){return p[k.s]-p[y.s]||y.f-k.f});s<r;++s){var w=i[s].s;if(!(p[w]>t))break;v+=b-(1<<m-p[w]),p[w]=t}for(v>>>=x;v>0;){var C=i[s].s;p[C]<t?v-=1<<t-p[C]++-1:++s}for(;s>=0&&v;--s){var E=i[s].s;p[E]==t&&(--p[E],++v)}m=t}return[new ia(p),m]},GS=function(e,t,n){return e.s==-1?Math.max(GS(e.l,t,n+1),GS(e.r,t,n+1)):t[e.s]=n},NF=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new ii(++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]},vp=function(e,t){for(var n=0,s=0;s<t.length;++s)n+=e[s]*t[s];return n},$S=function(e,t,n){var s=n.length,r=hB(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)},MF=function(e,t,n,s,r,i,a,o,l,u,d){Zo(t,d++,n),++r[256];for(var h=JC(r,15),f=h[0],p=h[1],m=JC(i,15),v=m[0],x=m[1],b=NF(f),w=b[0],C=b[1],E=NF(v),y=E[0],k=E[1],T=new ii(19),P=0;P<w.length;++P)T[31&w[P]]++;for(P=0;P<y.length;++P)T[31&y[P]]++;for(var A=JC(T,7),N=A[0],M=A[1],I=19;I>4&&!N[PF[I-1]];--I);var H,G,j,J,Y=u+5<<3,oe=vp(r,ed)+vp(i,Hx)+a,U=vp(r,f)+vp(i,v)+a+14+3*I+vp(T,N)+(2*T[16]+3*T[17]+7*T[18]);if(Y<=oe&&Y<=U)return $S(t,d,e.subarray(l,l+u));if(Zo(t,d,1+(U<oe)),d+=2,U<oe){H=hg(f,p),G=f,j=hg(v,x),J=v;var te=hg(N,M);for(Zo(t,d,C-257),Zo(t,d+5,k-1),Zo(t,d+10,I-4),d+=14,P=0;P<I;++P)Zo(t,d+3*P,N[PF[P]]);d+=3*I;for(var le=[w,y],R=0;R<2;++R){var L=le[R];for(P=0;P<L.length;++P){var D=31&L[P];Zo(t,d,te[D]),d+=N[D],D>15&&(Zo(t,d,L[P]>>>5&127),d+=L[P]>>>12)}}}else H=nZ,G=ed,j=sZ,J=Hx;for(P=0;P<o;++P)if(s[P]>255){D=s[P]>>>18&31,mp(t,d,H[D+257]),d+=G[D+257],D>7&&(Zo(t,d,s[P]>>>23&31),d+=k_[D]);var W=31&s[P];mp(t,d,j[W]),d+=J[W],W>3&&(mp(t,d,s[P]>>>5&8191),d+=__[W])}else mp(t,d,H[s[P]]),d+=G[s[P]];return mp(t,d,H[256]),d+G[256]},rZ=new of([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),iZ=function(){for(var e=new of(256),t=0;t<256;++t){for(var n=t,s=9;--s;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),aZ=function(){var e=4294967295;return{p:function(t){for(var n=e,s=0;s<t.length;++s)n=iZ[255&n^t[s]]^n>>>8;e=n},d:function(){return 4294967295^e}}},oZ=function(e,t,n,s,r){return function(i,a,o,l,u,d){var h=i.length,f=new ia(l+h+5*(1+Math.floor(h/7e3))+u),p=f.subarray(l,f.length-u),m=0;if(!a||h<8)for(var v=0;v<=h;v+=65535){var x=v+65535;x<h?m=$S(p,m,i.subarray(v,x)):(p[v]=d,m=$S(p,m,i.subarray(v,h)))}else{for(var b=rZ[a-1],w=b>>>13,C=8191&b,E=(1<<o)-1,y=new ii(32768),k=new ii(E+1),T=Math.ceil(o/3),P=2*T,A=function(de){return(i[de]^i[de+1]<<T^i[de+2]<<P)&E},N=new of(25e3),M=new ii(288),I=new ii(32),H=0,G=0,j=(v=0,0),J=0,Y=0;v<h;++v){var oe=A(v),U=32767&v,te=k[oe];if(y[U]=te,k[oe]=U,J<=v){var le=h-v;if((H>7e3||j>24576)&&le>423){m=MF(i,p,0,N,M,I,G,j,Y,v-Y,m),j=H=G=0,Y=v;for(var R=0;R<286;++R)M[R]=0;for(R=0;R<30;++R)I[R]=0}var L=2,D=0,W=C,Z=U-te&32767;if(le>2&&oe==A(v-Z))for(var se=Math.min(w,le)-1,ae=Math.min(32767,v),re=Math.min(258,le);Z<=ae&&--W&&U!=te;){if(i[v+L]==i[v+L-Z]){for(var Q=0;Q<re&&i[v+Q]==i[v+Q-Z];++Q);if(Q>L){if(L=Q,D=Z,Q>se)break;var pe=Math.min(Z,Q-2),O=0;for(R=0;R<pe;++R){var me=v-Z+R+32768&32767,ke=me-y[me]+32768&32767;ke>O&&(O=ke,te=me)}}}Z+=(U=te)-(te=y[U])+32768&32767}if(D){N[j++]=268435456|US[L]<<18|IF[D];var He=31&US[L],ie=31&IF[D];G+=k_[He]+__[ie],++M[257+He],++I[ie],J=v+L,++H}else N[j++]=i[v],++M[i[v]]}}m=MF(i,p,d,N,M,I,G,j,Y,v-Y,m)}return fB(f,0,l+hB(m)+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)},VS=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},lZ=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&&VS(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)}},cZ=function(e){return 10+(e.filename&&e.filename.length+1||0)};function pB(e,t){t===void 0&&(t={});var n=aZ(),s=e.length;n.p(e);var r=oZ(e,t,cZ(t),8),i=r.length;return lZ(r,t),VS(r,i-8,n.d()),VS(r,i-4,s),r}function gB(e,t){var n=e.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(e);for(var s=new ia(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 ia(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 fB(s,0,r)}function uZ(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 qp="[SessionRecording]",gr=Rr(qp);function nv(){var e,t;return Ht==null||(e=Ht.__PosthogExtensions__)===null||e===void 0||(t=e.rrweb)===null||t===void 0?void 0:t.record}var dZ=3e5,hZ=[Da.MouseMove,Da.MouseInteraction,Da.Scroll,Da.ViewportResize,Da.Input,Da.TouchMove,Da.MediaInteraction,Da.Drag],OF=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1});function au(e){return function(t,n){for(var s="",r=0;r<t.length;){var i=t[r++];s+=String.fromCharCode(i)}return s}(pB(gB(JSON.stringify(e))))}function LF(e){return e.type===sl.Custom&&e.data.tag==="sessionIdle"}function BF(e,t){return t.some(n=>n.matching==="regex"&&new RegExp(n.url).test(e))}let fZ=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(qp+" 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:dZ}get isSampled(){var t=this.instance.get_property(Wp);return ol(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(TS),n=!this.instance.config.disable_session_recording;return Ne&&t&&n}get isConsoleLogCaptureEnabled(){var t=!!this.instance.get_property(hF),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(gF),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(fF),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=rs(this.instance.config.capture_performance)?this.instance.config.capture_performance.network_timing:this.instance.config.capture_performance,l=!!(ol(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(pF),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 ft(u)&&ft(d)&&ft(h)?void 0:{maskAllInputs:u==null||u,maskTextSelector:d,blockSelector:h}}get sampleRate(){var t=this.instance.get_property(mF);return Wr(t)?t:null}get minimumDuration(){var t=this.instance.get_property(vF);return Wr(t)?t:null}get status(){return this.receivedDecide?this.isRecordingEnabled?this.isSampled===!1?"disabled":this._urlBlocked?"paused":Sn(this._linkedFlag)||this._linkedFlagSeen?this.triggerStatus==="trigger_pending"?"buffering":ol(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(UC))===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(GC))===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(st(this,"queuedRRWebEvents",[]),st(this,"isIdle","unknown"),st(this,"_linkedFlagSeen",!1),st(this,"_lastActivityTimestamp",Date.now()),st(this,"_linkedFlag",null),st(this,"_removePageViewCaptureHook",void 0),st(this,"_onSessionIdListener",void 0),st(this,"_persistDecideOnSessionListener",void 0),st(this,"_samplingSessionListener",void 0),st(this,"_urlTriggers",[]),st(this,"_urlBlocklist",[]),st(this,"_urlBlocked",!1),st(this,"_eventTriggers",[]),st(this,"_removeEventTriggerCaptureHook",void 0),st(this,"_forceAllowLocalhostNetworkCapture",!1),st(this,"_onBeforeUnload",()=>{this._flushBuffer()}),st(this,"_onOffline",()=>{this._tryAddCustomEvent("browser offline",{})}),st(this,"_onOnline",()=>{this._tryAddCustomEvent("browser online",{})}),st(this,"_onVisibilityChange",()=>{if(mt!=null&&mt.visibilityState){var r="window "+mt.visibilityState;this._tryAddCustomEvent(r,{})}}),this.instance=t,this._captureStarted=!1,this._endpoint="/s/",this.stopRrweb=void 0,this.receivedDecide=!1,!this.instance.sessionManager)throw gr.error("started without valid sessionManager"),new Error(qp+" started without valid sessionManager. This is a bug.");if(this.instance.config.__preview_experimental_cookieless_mode)throw new Error(qp+" 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&&gr.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),ms(Ne,"beforeunload",this._onBeforeUnload),ms(Ne,"offline",this._onOffline),ms(Ne,"online",this._onOnline),ms(Ne,"visibilitychange",this._onVisibilityChange),this._setupSampling(),this._addEventTriggerListener(),Sn(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){gr.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(GC),(o=this.instance)===null||o===void 0||(l=o.persistence)===null||l===void 0||l.unregister(UC))}))):this.stopRecording()}stopRecording(){var t,n,s,r;this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1,Ne?.removeEventListener("beforeunload",this._onBeforeUnload),Ne?.removeEventListener("offline",this._onOffline),Ne?.removeEventListener("online",this._onOnline),Ne?.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,gr.info("stopped"))}_resetSampling(){var t;(t=this.instance.persistence)===null||t===void 0||t.unregister(Wp)}makeSamplingDecision(t){var n,s=this.sessionId!==t,r=this.sampleRate;if(Wr(r)){var i=this.isSampled,a=s||!ol(i),o=a?uZ(t,r):i;a&&(o?this._reportStarted("sampled"):gr.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({[Wp]: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(),!Sn(this._linkedFlag)&&!this._linkedFlagSeen){var l=Fs(this._linkedFlag)?this._linkedFlag:this._linkedFlag.flag,u=Fs(this._linkedFlag)?null:this._linkedFlag.variant;this.instance.onFeatureFlags((d,h)=>{var f=rs(h)&&l in h,p=u?h[l]===u:f;p&&this._reportStarted("linked_flag_matched",{linkedFlag:l,linkedVariant:u}),this._linkedFlagSeen=p})}(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(){Wr(this.sampleRate)&&Sn(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,p,m=(i=t.sessionRecording)===null||i===void 0?void 0:i.sampleRate,v=Sn(m)?null:parseFloat(m);Sn(v)&&this._resetSampling();var x=(a=t.sessionRecording)===null||a===void 0?void 0:a.minimumDurationMilliseconds;s.register({[TS]:!!t.sessionRecording,[hF]:(o=t.sessionRecording)===null||o===void 0?void 0:o.consoleLogRecordingEnabled,[fF]:je({capturePerformance:t.capturePerformance},(l=t.sessionRecording)===null||l===void 0?void 0:l.networkPayloadCapture),[pF]:(u=t.sessionRecording)===null||u===void 0?void 0:u.masking,[gF]:{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},[mF]:v,[vF]:ft(x)?null:x,[xF]:(p=t.sessionRecording)===null||p===void 0?void 0:p.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(!ft(Object.assign)&&!ft(Array.from)&&!(this._captureStarted||this.instance.config.disable_session_recording||this.instance.consent.isOptedOut())){var n,s;this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId(),nv()?this._onScriptLoaded():(n=Ht.__PosthogExtensions__)===null||n===void 0||(s=n.loadExternalDependency)===null||s===void 0||s.call(n,this.instance,this.scriptName,r=>{if(r)return gr.error("could not load recorder",r);this._onScriptLoaded()}),gr.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(xF))===null||s===void 0?void 0:s.script)||"recorder"}isInteractiveEvent(t){var n;return t.type===3&&hZ.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}):gr.warn("could not emit queued rrweb event.",n,t),!1}}_tryAddCustomEvent(t,n){return this._tryRRWebMethod(OF(()=>nv().addCustomEvent(t,n)))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(OF(()=>nv().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=je({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=nv();if(u){this.mutationRateLimiter=(t=this.mutationRateLimiter)!==null&&t!==void 0?t:new eZ(u,{refillRate:this.instance.config.session_recording.__mutationRateLimiterRefillRate,bucketSize:this.instance.config.session_recording.__mutationRateLimiterBucketSize,onBlockedNode:(h,f)=>{var p="Too many mutations on node '".concat(h,"'. Rate limiting. This could be due to SVG animations or something similar");gr.info(p,{node:f}),this.log(qp+" "+p,"warn")}});var d=this._gatherRRWebPlugins();this.stopRrweb=u(je({emit:h=>{this.onRRwebEmit(h)},plugins:d},i)),this._lastActivityTimestamp=Date.now(),this.isIdle=ol(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 gr.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=Ht.__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=Ht.__PosthogExtensions__)===null||s===void 0||(r=s.rrwebPlugins)===null||r===void 0?void 0:r.getRecordNetworkPlugin;return this.networkPayloadCapture&&Ba(o)&&(!bJ.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?i.push(o(ZJ(this.instance.config,this.networkPayloadCapture))):gr.info("NetworkCapture not started because we are on localhost.")),i}onRRwebEmit(t){var n;if(this._processQueuedEvents(),t&&rs(t)){if(t.type===sl.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===sl.Custom&&h.data.tag==="recording paused"}(t)){t.type===sl.FullSnapshot&&this._scheduleFullSnapshot(),t.type===sl.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&&rs(f)&&f.type===6&&rs(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 p=[],m=0;m<f.data.payload.payload.length;m++)f.data.payload.payload[m]&&f.data.payload.payload[m].length>2e3?p.push(f.data.payload.payload[m].slice(0,2e3)+"...[truncated]"):p.push(f.data.payload.payload[m]);return f.data.payload.payload=p,h}return h}(r);if(this._updateWindowAndSessionIds(i),this.isIdle!==!0||LF(i)){if(LF(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(jx(h)<1024)return h;try{if(h.type===sl.FullSnapshot)return je(je({},h),{},{data:au(h.data),cv:"2024-10"});if(h.type===sl.IncrementalSnapshot&&h.data.source===Da.Mutation)return je(je({},h),{},{cv:"2024-10",data:je(je({},h.data),{},{texts:au(h.data.texts),attributes:au(h.data.attributes),removes:au(h.data.removes),adds:au(h.data.adds)})});if(h.type===sl.IncrementalSnapshot&&h.data.source===Da.StyleSheetRule)return je(je({},h),{},{cv:"2024-10",data:je(je({},h.data),{},{adds:h.data.adds?au(h.data.adds):void 0,removes:h.data.removes?au(h.data.removes):void 0})})}catch(f){gr.error("could not compress event - will use uncompressed event",f)}return h}(i):i,d={$snapshot_bytes:jx(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&&Ne){var t=this._maskUrl(Ne.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=Wr(n)&&n>=0,r=Wr(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&&BS(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:il.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(Ne!==void 0&&Ne.location.href){var t=Ne.location.href,n=this._urlBlocked,s=BF(t,this._urlBlocklist);s&&!n?this._pauseRecording():!s&&n&&this._resumeRecording(),BF(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"?UC:GC]:this.sessionId}),this._flushBuffer(),this._reportStarted(t+"_trigger_matched"))}_pauseRecording(){this._urlBlocked||(this._urlBlocked=!0,clearInterval(this._fullSnapshotTimer),gr.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"}),gr.info("recording resumed"))}_addEventTriggerListener(){this._eventTriggers.length!==0&&Sn(this._removeEventTriggerCaptureHook)&&(this._removeEventTriggerCaptureHook=this.instance.on("eventCaptured",t=>{try{this._eventTriggers.includes(t.event)&&this._activateTrigger("event")}catch(n){gr.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({[Wp]:!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}),gr.info(t.replace("_"," "),n),Qt(["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 ZC=Rr("[SegmentIntegration]");function pZ(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()||oc();s.config.get_device_id=u,l.id()&&(s.register({distinct_id:l.id(),$device_id:u()}),s.persistence.set_property(nl,"identified")),r()},o=i.user();"then"in o&&Ba(o.then)?o.then(l=>a(l)):a(o)})(e,()=>{n.register((s=>{Promise&&Promise.resolve||ZC.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()||(ZC.info("No userId set, resetting PostHog"),s.reset()),i.event.userId&&i.event.userId!==s.get_distinct_id()&&(ZC.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 mB="posthog-js";function vB(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)||[],p=f.map(v=>je(je({},v),{},{stacktrace:v.stacktrace?je(je({},v.stacktrace),{},{type:"raw",frames:(v.stacktrace.frames||[]).map(x=>je(je({},x),{},{platform:"web:javascript"}))}):void 0})),m={$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:p,$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&&(m.$sentry_url=(s||"https://sentry.io/organizations/")+t+"/issues/?project="+n+"&query="+i.event_id),e.exceptions.sendExceptionEvent(m),i}}let gZ=class{constructor(t,n,s,r,i){this.name=mB,this.setupOnce=function(a){a(vB(t,{organization:n,projectId:s,prefix:r,severityAllowList:i}))}}};var rl,mZ=Ne!=null&&Ne.location?Bx(Ne.location.hash,"__posthog")||Bx(location.hash,"state"):null,jF="_postHogToolbarParams",HF=Rr("[Toolbar]");(function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED"})(rl||(rl={}));class vZ{constructor(t){this.instance=t}setToolbarState(t){Ht.ph_toolbar_state=t}getToolbarState(){var t;return(t=Ht.ph_toolbar_state)!==null&&t!==void 0?t:rl.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(!Ne||!mt)return!1;s=(t=s)!==null&&t!==void 0?t:Ne.location,i=(n=i)!==null&&n!==void 0?n:Ne.history;try{if(!r){try{Ne.localStorage.setItem("test","test"),Ne.localStorage.removeItem("test")}catch{return!1}r=Ne?.localStorage}var a,o=mZ||Bx(s.hash,"__posthog")||Bx(s.hash,"state"),l=o?oF(()=>JSON.parse(atob(decodeURIComponent(o))))||oF(()=>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(jF)||"{}")).source="localstorage",delete a.userIntent),!(!a.token||this.instance.config.token!==a.token)&&(this.loadToolbar(a),!0)}catch{return!1}}_callLoadToolbar(t){var n=Ht.ph_load_toolbar||Ht.ph_load_editor;!Sn(n)&&Ba(n)?n(t,this.instance):HF.warn("No toolbar load function found")}loadToolbar(t){var n=!(mt==null||!mt.getElementById(q4));if(!Ne||n)return!1;var s=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,r=je(je({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(Ne.localStorage.setItem(jF,JSON.stringify(je(je({},r),{},{source:void 0}))),this.getToolbarState()===rl.LOADED)this._callLoadToolbar(r);else if(this.getToolbarState()===rl.UNINITIALIZED){var i,a;this.setToolbarState(rl.LOADING),(i=Ht.__PosthogExtensions__)===null||i===void 0||(a=i.loadExternalDependency)===null||a===void 0||a.call(i,this.instance,"toolbar",o=>{if(o)return HF.error("[Toolbar] Failed to load",o),void this.setToolbarState(rl.UNINITIALIZED);this.setToolbarState(rl.LOADED),this._callLoadToolbar(r)}),ms(Ne,"turbolinks:load",()=>{this.setToolbarState(rl.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 xZ=Rr("[TracingHeaders]");class bZ{constructor(t){st(this,"_restoreXHRPatch",void 0),st(this,"_restoreFetchPatch",void 0),st(this,"_startCapturing",()=>{var n,s,r,i;ft(this._restoreXHRPatch)&&((n=Ht.__PosthogExtensions__)===null||n===void 0||(s=n.tracingHeadersPatchFns)===null||s===void 0||s._patchXHR(this.instance.sessionManager)),ft(this._restoreFetchPatch)&&((r=Ht.__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=Ht.__PosthogExtensions__)!==null&&n!==void 0&&n.tracingHeadersPatchFns&&t(),(s=Ht.__PosthogExtensions__)===null||s===void 0||(r=s.loadExternalDependency)===null||r===void 0||r.call(s,this.instance,"tracing-headers",i=>{if(i)return xZ.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 Vl=Rr("[Web Vitals]"),UF=9e5;class wZ{constructor(t){var n;st(this,"_enabledServerSide",!1),st(this,"_initialized",!1),st(this,"buffer",{url:void 0,metrics:[],firstMetricTimestamp:void 0}),st(this,"_flushToCapture",()=>{clearTimeout(this._delayedFlushTimer),this.buffer.metrics.length!==0&&(this.instance.capture("$web_vitals",this.buffer.metrics.reduce((s,r)=>je(je({},s),{},{["$web_vitals_".concat(r.name,"_event")]:je({},r),["$web_vitals_".concat(r.name,"_value")]:r.value}),{})),this.buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})}),st(this,"_addToBuffer",s=>{var r,i=(r=this.instance.sessionManager)===null||r===void 0?void 0:r.checkAndGetSessionAndWindowId(!0);if(ft(i))Vl.error("Could not read session ID. Dropping metrics!");else{this.buffer=this.buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var a=this._currentURL();ft(a)||(Sn(s?.name)||Sn(s?.value)?Vl.error("Invalid metric received",s):this._maxAllowedValue&&s.value>=this._maxAllowedValue?Vl.error("Ignoring metric with value >= "+this._maxAllowedValue,s):(this.buffer.url!==a&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),ft(this.buffer.url)&&(this.buffer.url=a),this.buffer.firstMetricTimestamp=ft(this.buffer.firstMetricTimestamp)?Date.now():this.buffer.firstMetricTimestamp,s.attribution&&s.attribution.interactionTargetElement&&(s.attribution.interactionTargetElement=void 0),this.buffer.metrics.push(je(je({},s),{},{$current_url:a,$session_id:i.sessionId,$window_id:i.windowId,timestamp:Date.now()})),this.buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()))}}),st(this,"_startCapturing",()=>{var s,r,i,a,o=Ht.__PosthogExtensions__;ft(o)||ft(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):Vl.error("web vitals callbacks not loaded - not starting")}),this.instance=t,this._enabledServerSide=!((n=this.instance.persistence)===null||n===void 0||!n.props[uF]),this.startIfEnabled()}get allowedMetrics(){var t,n,s=rs(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 ft(s)?((n=this.instance.persistence)===null||n===void 0?void 0:n.props[dF])||["CLS","FCP","INP","LCP"]:s}get flushToCaptureTimeoutMs(){return(rs(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var t=rs(this.instance.config.capture_performance)&&Wr(this.instance.config.capture_performance.__web_vitals_max_value)?this.instance.config.capture_performance.__web_vitals_max_value:UF;return 0<t&&t<=6e4?UF:t}get isEnabled(){var t=ni?.protocol;if(t!=="http:"&&t!=="https:")return Vl.info("Web Vitals are disabled on non-http/https protocols"),!1;var n=rs(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals:ol(this.instance.config.capture_performance)?this.instance.config.capture_performance:void 0;return ol(n)?n:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(Vl.info("enabled, starting..."),this.loadScript(this._startCapturing))}onRemoteConfig(t){var n=rs(t.capturePerformance)&&!!t.capturePerformance.web_vitals,s=rs(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this.instance.persistence&&(this.instance.persistence.register({[uF]:n}),this.instance.persistence.register({[dF]:s})),this._enabledServerSide=n,this.startIfEnabled()}loadScript(t){var n,s,r;(n=Ht.__PosthogExtensions__)!==null&&n!==void 0&&n.postHogWebVitalsCallbacks&&t(),(s=Ht.__PosthogExtensions__)===null||s===void 0||(r=s.loadExternalDependency)===null||r===void 0||r.call(s,this.instance,"web-vitals",i=>{i?Vl.error("failed to load script",i):t()})}_currentURL(){var t=Ne?Ne.location.href:void 0;return t||Vl.error("Could not determine current URL"),t}}var CZ=Rr("[Heatmaps]");function GF(e){return rs(e)&&"clientX"in e&&"clientY"in e&&Wr(e.clientX)&&Wr(e.clientY)}class yZ{constructor(t){var n;st(this,"rageclicks",new rB),st(this,"_enabledServerSide",!1),st(this,"_initialized",!1),st(this,"_flushInterval",null),this.instance=t,this._enabledServerSide=!((n=this.instance.persistence)===null||n===void 0||!n.props[_S])}get flushIntervalMilliseconds(){var t=5e3;return rs(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 ft(this.instance.config.capture_heatmaps)?ft(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;CZ.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({[_S]: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(){Ne&&mt&&(ms(Ne,"beforeunload",this.flush.bind(this)),ms(mt,"click",t=>this._onClick(t||Ne?.event),{capture:!0}),ms(mt,"mousemove",t=>this._onMouseMove(t||Ne?.event),{capture:!0}),this.deadClicksCapture=new aB(this.instance,MJ,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&&Ew(d)&&!mc(d,"body");){if(d===u)return!1;if(Qt(l,Ne?.getComputedStyle(d).position))return!0;d=J4(d)}return!1}(Q4(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(!wF(t.target)&&GF(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(je(je({},r),{},{type:"rageclick"})),this._capture(r)}}_onMouseMove(t){!wF(t.target)&&GF(t)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(()=>{this._capture(this._getProperties(t,"mousemove"))},500))}_capture(t){if(Ne){var n=Ne.location.href;this.buffer=this.buffer||{},this.buffer[n]||(this.buffer[n]=[]),this.buffer[n].push(t)}}flush(){this.buffer&&!vh(this.buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class SZ{constructor(t){this._instance=t}doPageView(t,n){var s,r=this._previousPageViewProperties(t,n);return this._currentPageview={pathname:(s=Ne?.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(!(ft(a)||ft(o)||ft(l)||ft(u)||ft(d)||ft(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),p=a<=1?1:ea(l/a,0,1),m=u<=1?1:ea(d/u,0,1),v=u<=1?1:ea(h/u,0,1);r=ps(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:f,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:p,$prev_pageview_last_content:d,$prev_pageview_last_content_percentage:m,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:v})}}return s.pathname&&(r.$prev_pageview_pathname=s.pathname),s.timestamp&&(r.$prev_pageview_duration=(t.getTime()-s.timestamp.getTime())/1e3),r}}let EZ=class{constructor(t){this.instance=t}sendExceptionEvent(t){this.instance.capture("$exception",t,{_noTruncate:!0,_batchKey:"exceptionEvent"})}};var aa="Mobile",Ux="iOS",Co="Android",im="Tablet",xB=Co+" "+im,bB="iPad",wB="Apple",CB=wB+" Watch",am="Safari",lf="BlackBerry",yB="Samsung",SB=yB+"Browser",EB=yB+" Internet",td="Chrome",kZ=td+" OS",kB=td+" "+Ux,T_="Internet Explorer",_B=T_+" "+aa,R_="Opera",_Z=R_+" Mini",A_="Edge",TB="Microsoft "+A_,Fh="Firefox",RB=Fh+" "+Ux,om="Nintendo",lm="PlayStation",Dh="Xbox",AB=Co+" "+aa,FB=aa+" "+am,Kp="Windows",WS=Kp+" Phone",$F="Nokia",zS="Ouya",DB="Generic",TZ=DB+" "+aa.toLowerCase(),PB=DB+" "+im.toLowerCase(),qS="Konqueror",Ur="(\\d+(\\.\\d+)?)",ey=new RegExp("Version/"+Ur),RZ=new RegExp(Dh,"i"),AZ=new RegExp(lm+" \\w+","i"),FZ=new RegExp(om+" \\w+","i"),F_=new RegExp(lf+"|PlayBook|BB10","i"),DZ={"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"},KS,PZ=(e,t)=>t&&Qt(t,wB)||function(n){return Qt(n,am)&&!Qt(n,td)&&!Qt(n,Co)}(e),VF=function(e,t){return t=t||"",Qt(e," OPR/")&&Qt(e,"Mini")?_Z:Qt(e," OPR/")?R_:F_.test(e)?lf:Qt(e,"IE"+aa)||Qt(e,"WPDesktop")?_B:Qt(e,SB)?EB:Qt(e,A_)||Qt(e,"Edg/")?TB:Qt(e,"FBIOS")?"Facebook "+aa:Qt(e,"UCWEB")||Qt(e,"UCBrowser")?"UC Browser":Qt(e,"CriOS")?kB:Qt(e,"CrMo")||Qt(e,td)?td:Qt(e,Co)&&Qt(e,am)?AB:Qt(e,"FxiOS")?RB:Qt(e.toLowerCase(),qS.toLowerCase())?qS:PZ(e,t)?Qt(e,aa)?FB:am:Qt(e,Fh)?Fh:Qt(e,"MSIE")||Qt(e,"Trident/")?T_:Qt(e,"Gecko")?Fh:""},IZ={[_B]:[new RegExp("rv:"+Ur)],[TB]:[new RegExp(A_+"?\\/"+Ur)],[td]:[new RegExp("("+td+"|CrMo)\\/"+Ur)],[kB]:[new RegExp("CriOS\\/"+Ur)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ur)],[am]:[ey],[FB]:[ey],[R_]:[new RegExp("(Opera|OPR)\\/"+Ur)],[Fh]:[new RegExp(Fh+"\\/"+Ur)],[RB]:[new RegExp("FxiOS\\/"+Ur)],[qS]:[new RegExp("Konqueror[:/]?"+Ur,"i")],[lf]:[new RegExp(lf+" "+Ur),ey],[AB]:[new RegExp("android\\s"+Ur,"i")],[EB]:[new RegExp(SB+"\\/"+Ur)],[T_]:[new RegExp("(rv:|MSIE )"+Ur)],Mozilla:[new RegExp("rv:"+Ur)]},WF=[[new RegExp(Dh+"; "+Dh+" (.*?)[);]","i"),e=>[Dh,e&&e[1]||""]],[new RegExp(om,"i"),[om,""]],[new RegExp(lm,"i"),[lm,""]],[F_,[lf,""]],[new RegExp(Kp,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[WS,""];if(new RegExp(aa).test(t)&&!/IEMobile\b/.test(t))return[Kp+" "+aa,""];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var s=n[1],r=DZ[s]||"";return/arm/i.test(t)&&(r="RT"),[Kp,r]}return[Kp,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[Ux,t.join(".")]}return[Ux,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=ft(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+Co+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Co+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[Co,t.join(".")]}return[Co,""]}],[/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/,[kZ,""]],[/Linux|debian/i,["Linux",""]]],zF=function(e){return FZ.test(e)?om:AZ.test(e)?lm:RZ.test(e)?Dh:new RegExp(zS,"i").test(e)?zS:new RegExp("("+WS+"|WPDesktop)","i").test(e)?WS:/iPad/.test(e)?bB:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?CB:F_.test(e)?lf:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp($F,"i").test(e)?$F:/(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(aa).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)?Co:xB:Co:new RegExp("(pda|"+aa+")","i").test(e)?TZ:new RegExp(im,"i").test(e)&&!new RegExp(im+" pc","i").test(e)?PB:""},sv="https?://(.*)",nx=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","irclid","_kx"],NZ=Jv(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],nx),ty="<masked>",qn={campaignParams:function(){var{customTrackedParams:e,maskPersonalDataProperties:t,customPersonalDataProperties:n}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!mt)return{};var s=t?Jv([],nx,n||[]):[];return this._campaignParamsFromUrl($C(mt.URL,s,ty),e)},_campaignParamsFromUrl:function(e,t){var n=NZ.concat(t||[]),s={};return In(n,function(r){var i=Lx(e,r);s[r]=i||null}),s},_searchEngine:function(e){return e?e.search(sv+"google.([^/?]*)")===0?"google":e.search(sv+"bing.com")===0?"bing":e.search(sv+"yahoo.com")===0?"yahoo":e.search(sv+"duckduckgo.com")===0?"duckduckgo":null:null},_searchInfoFromReferrer:function(e){var t=qn._searchEngine(e),n=t!="yahoo"?"q":"p",s={};if(!Oc(t)){s.$search_engine=t;var r=mt?Lx(mt.referrer,n):"";r.length&&(s.ph_keyword=r)}return s},searchInfo:function(){var e=mt?.referrer;return e?this._searchInfoFromReferrer(e):{}},browser:VF,browserVersion:function(e,t){var n=VF(e,t),s=IZ[n];if(ft(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<WF.length;t++){var[n,s]=WF[t],r=n.exec(e),i=r&&(Ba(s)?s(r,e):s);if(i)return i}return["",""]},device:zF,deviceType:function(e){var t=zF(e);return t===bB||t===xB||t==="Kobo"||t==="Kindle Fire"||t===PB?im:t===om||t===Dh||t===lm||t===zS?"Console":t===CB?"Wearable":t?aa:"Desktop"},referrer:function(){return mt?.referrer||"$direct"},referringDomain:function(){var e;return mt!=null&&mt.referrer&&((e=Ah(mt.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?Jv([],nx,t||[]):[],s=ni?.href.substring(0,1e3);return{r:this.referrer().substring(0,1e3),u:s?$C(s,n,ty):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=Ah(n))===null||t===void 0?void 0:t.host};if(s){r.$current_url=s;var i=Ah(s);r.$host=i?.host,r.$pathname=i?.pathname;var a=this._campaignParamsFromUrl(s);ps(r,a)}if(n){var o=this._searchInfoFromReferrer(n);ps(r,o)}return r},initialPersonPropsFromInfo:function(e){var t=this.personPropsFromInfo(e),n={};return In(t,function(s,r){n["$initial_".concat(y_(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(!Rs)return{};var n=e?Jv([],nx,t||[]):[],[s,r]=qn.os(Rs);return ps(rm({$os:s,$os_version:r,$browser:qn.browser(Rs,navigator.vendor),$device:qn.device(Rs),$device_type:qn.deviceType(Rs),$timezone:qn.timezone(),$timezone_offset:qn.timezoneOffset()}),{$current_url:$C(ni?.href,n,ty),$host:ni?.host,$pathname:ni?.pathname,$raw_user_agent:Rs.length>1e3?Rs.substring(0,997)+"...":Rs,$browser_version:qn.browserVersion(Rs,navigator.vendor),$browser_language:qn.browserLanguage(),$browser_language_prefix:qn.browserLanguagePrefix(),$screen_height:Ne?.screen.height,$screen_width:Ne?.screen.width,$viewport_height:Ne?.innerHeight,$viewport_width:Ne?.innerWidth,$lib:"web",$lib_version:il.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(!Rs)return{};var[e,t]=qn.os(Rs);return ps(rm({$os:e,$os_version:t,$browser:qn.browser(Rs,navigator.vendor)}),{$browser_version:qn.browserVersion(Rs,navigator.vendor)})}},lo=Rr("[FeatureFlags]"),ny="$active_feature_flags",Kd="$override_feature_flags",qF="$feature_flag_payloads",xp="$override_feature_flag_payloads",KF="$feature_flag_request_id",YF=e=>{var t={};for(var[n,s]of Zv(e||{}))s&&(t[n]=s);return t},MZ=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]}))):lo.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"})(KS||(KS={}));class OZ{constructor(t){st(this,"_override_warning",!1),st(this,"_hasLoadedFlags",!1),st(this,"_requestInFlight",!1),st(this,"_reloadingDisabled",!1),st(this,"_additionalReloadRequested",!1),st(this,"_decideCalled",!1),st(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(RS),n=this.instance.get_property(Kd),s=this.instance.get_property(xp);if(!s&&!n)return t||{};var r=ps({},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=ft(d)?(o=u?.enabled)!==null&&o!==void 0&&o:!!d,f=ft(d)?u.variant:typeof d=="string"?d:void 0,p=s?.[a],m=je(je({},u),{},{enabled:h,variant:h?f??u?.variant:void 0});h!==u?.enabled&&(m.original_enabled=u?.enabled),f!==u?.variant&&(m.original_variant=u?.variant),p&&(m.metadata=je(je({},u?.metadata),{},{payload:p,original_payload:u==null||(l=u.metadata)===null||l===void 0?void 0:l.payload})),r[a]=m}return this._override_warning||(lo.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:s,finalDetails:r}),this._override_warning=!0),r}getFlagVariants(){var t=this.instance.get_property(xh),n=this.instance.get_property(Kd);if(!n)return t||{};for(var s=ps({},t),r=Object.keys(n),i=0;i<r.length;i++)s[r[i]]=n[r[i]];return this._override_warning||(lo.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:n,finalFlags:s}),this._override_warning=!0),s}getFlagPayloads(){var t=this.instance.get_property(qF),n=this.instance.get_property(xp);if(!n)return t||{};for(var s=ps({},t||{}),r=Object.keys(n),i=0;i<r.length;i++)s[r[i]]=n[r[i]];return this._override_warning||(lo.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:je(je({},((n=this.instance.persistence)===null||n===void 0?void 0:n.get_initial_props())||{}),this.instance.get_property(zp)||{}),group_properties:this.instance.get_property(uu)};(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=qn.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:Ia.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(KS.FeatureFlags)?lo.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(KF)||void 0,a=this.instance.get_property(Nx)||{};if((n.send_event||!("send_event"in n))&&(!(t in a)||!a[t].includes(r))){var o,l,u,d,h,f,p,m,v,x,b;ss(a[t])?a[t].push(r):a[t]=[r],(o=this.instance.persistence)===null||o===void 0||o.register({[Nx]:a});var w=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};ft(w==null||(f=w.metadata)===null||f===void 0?void 0:f.version)||(C.$feature_flag_version=w.metadata.version);var E,y=(p=w==null||(m=w.reason)===null||m===void 0?void 0:m.description)!==null&&p!==void 0?p:w==null||(v=w.reason)===null||v===void 0?void 0:v.code;y&&(C.$feature_flag_reason=y),w!=null&&(x=w.metadata)!==null&&x!==void 0&&x.id&&(C.$feature_flag_id=w.metadata.id),ft(w?.original_variant)&&ft(w?.original_enabled)||(C.$feature_flag_original_response=ft(w.original_variant)?w.original_enabled:w.original_variant),w!=null&&(b=w.metadata)!==null&&b!==void 0&&b.original_payload&&(C.$feature_flag_original_payload=w==null||(E=w.metadata)===null||E===void 0?void 0:E.original_payload),this.instance.capture("$feature_flag_called",C)}return s}lo.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:Ia.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);lo.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=MZ(a),f=h.flags,p=h.featureFlags,m=h.featureFlagPayloads;if(p){var v=a.requestId;if(ss(p)){lo.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var x={};if(p)for(var b=0;b<p.length;b++)x[p[b]]=!0;o&&o.register({[ny]:p,[xh]:x})}else{var w=p,C=m,E=f;a.errorsWhileComputingFlags&&(w=je(je({},l),w),C=je(je({},u),C),E=je(je({},d),E)),o&&o.register(je({[ny]:Object.keys(YF(w)),[xh]:w||{},[qF]:C||{},[RS]:E||{}},v?{[KF]:v}:{}))}}})(t,this.instance.persistence,s,r,i),this._fireFeatureFlagsCallbacks(n)}}override(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];lo.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:n})}overrideFeatureFlags(t){if(!this.instance.__loaded||!this.instance.persistence)return lo.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(t===!1)return this.instance.persistence.unregister(Kd),this.instance.persistence.unregister(xp),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(Kd);else if(s.flags)if(ss(s.flags)){for(var r={},i=0;i<s.flags.length;i++)r[s.flags[i]]=!0;this.instance.persistence.register({[Kd]:r})}else this.instance.persistence.register({[Kd]:s.flags})}return"payloads"in s&&(s.payloads===!1?this.instance.persistence.unregister(xp):s.payloads&&this.instance.persistence.register({[xp]: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(ex)||[]).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=je(je({},this.getFlagVariants()),{},{[t]:n});(s=this.instance.persistence)===null||s===void 0||s.register({[ny]:Object.keys(YF(o)),[xh]: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(ex),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({[ex]: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(zp)||{};this.instance.register({[zp]:je(je({},s),t)}),n&&this.instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this.instance.unregister(zp)}setGroupPropertiesForFlags(t){var n=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],s=this.instance.get_property(uu)||{};Object.keys(s).length!==0&&Object.keys(s).forEach(r=>{s[r]=je(je({},s[r]),t[r]),delete t[r]}),this.instance.register({[uu]:je(je({},s),t)}),n&&this.instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var n=this.instance.get_property(uu)||{};this.instance.register({[uu]:je(je({},n),{},{[t]:{}})})}else this.instance.unregister(uu)}}var LZ=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class sy{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&&wt.info("Persistence loaded",t.persistence,je({},this.props)),this.update_config(t,t),this.save()}buildStorage(t){LZ.indexOf(t.persistence.toLowerCase())===-1&&(wt.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");var n=t.persistence.toLowerCase();return n==="localstorage"&&Ns.is_supported()?Ns:n==="localstorage+cookie"&&Q0.is_supported()?Q0:n==="sessionstorage"&&ir.is_supported()?ir:n==="memory"?IJ:n==="cookie"?dl:Q0.is_supported()?Q0:dl}properties(){var t={};return In(this.props,function(n,s){if(s===xh&&rs(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,(Oc(a=dJ)?l:sF&&a.indexOf===sF?a.indexOf(o)!=-1:(In(a,function(u){if(l||(l=u===o))return Px}),l))||(t[s]=n);var a,o,l}),t}load(){if(!this.disabled){var t=this.storage.parse(this.name);t&&(this.props=ps({},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(rs(t)){ft(n)&&(n="None"),this.expire_days=ft(s)?this.default_expiry:s;var r=!1;if(In(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(rs(t)){this.expire_days=ft(n)?this.default_expiry:n;var s=!1;if(In(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=qn.campaignParams({customTrackedParams:this.config.custom_campaign_params,maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties});vh(rm(t))||this.register(t),this.campaign_params_saved=!0}}update_search_keyword(){this.register(qn.searchInfo())}update_referrer_info(){this.register_once(qn.referrerInfo(),void 0)}set_initial_person_info(){this.props[PS]||this.props[IS]||this.register_once({[NS]:qn.personInfo({maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties})},void 0)}get_referrer_info(){return rm({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}get_initial_props(){var t={};In([IS,PS],r=>{var i=this.props[r];i&&In(i,function(a,o){t["$initial_"+y_(o)]=a})});var n=this.props[NS];if(n){var s=qn.initialPersonPropsFromInfo(n);ps(t,s)}return t}safe_merge(t){return In(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[Vp]||{};s[t]=n,this.props[Vp]=s,this.save()}remove_event_timer(t){var n=(this.props[Vp]||{})[t];return ft(n)||(delete this.props[Vp][t],this.save()),n}get_property(t){return this.props[t]}set_property(t,n){this.props[t]=n,this.save()}}var IB,is,NB,gu,XF,MB,YS,OB,QF,XS,JF,ZF,eD,tD,QS={},LB=[],BZ=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,D_=Array.isArray;function lc(e,t){for(var n in t)e[n]=t[n];return e}function BB(e){var t=e.parentNode;t&&t.removeChild(e)}function ry(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??++NB,__i:-1,__u:0};return r==null&&is.vnode!=null&&is.vnode(i),i}function P_(e){return e.children}function sx(e,t){this.props=e,this.context=t}function cf(e,t){if(t==null)return e.__?cf(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"?cf(e):null}function jB(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 jB(e)}}function JS(e){(!e.__d&&(e.__d=!0)&&gu.push(e)&&!Gx.__r++||XF!==is.debounceRendering)&&((XF=is.debounceRendering)||MB)(Gx)}function Gx(){var e,t,n,s,r,i,a,o,l;for(gu.sort(YS);e=gu.shift();)e.__d&&(t=gu.length,s=void 0,i=(r=(n=e).__v).__e,o=[],l=[],(a=n.__P)&&((s=lc({},r)).__v=r.__v+1,is.vnode&&is.vnode(s),GB(a,s,r,n.__n,a.ownerSVGElement!==void 0,32&r.__u?[i]:null,o,i??cf(r),!!(32&r.__u),l),s.__.__k[s.__i]=s,UZ(o,s,l),s.__e!=i&&jB(s)),gu.length>t&&gu.sort(YS));Gx.__r=0}function HB(e,t,n,s,r,i,a,o,l,u,d){var h,f,p,m,v,x=s&&s.__k||LB,b=t.length;for(n.__d=l,jZ(n,t,x),l=n.__d,h=0;h<b;h++)(p=n.__k[h])!=null&&typeof p!="boolean"&&typeof p!="function"&&(f=p.__i===-1?QS:x[p.__i]||QS,p.__i=h,GB(e,p,f,r,i,a,o,l,u,d),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&I_(f.ref,null,p),d.push(p.ref,p.__c||m,p)),v==null&&m!=null&&(v=m),65536&p.__u||f.__k===p.__k?l=UB(p,l,e):typeof p.type=="function"&&p.__d!==void 0?l=p.__d:m&&(l=m.nextSibling),p.__d=void 0,p.__u&=-196609);n.__d=l,n.__e=v}function jZ(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?ry(null,r,null,null,r):D_(r)?ry(P_,{children:r},null,null,null):r.constructor===void 0&&r.__b>0?ry(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):r)!=null?(r.__=e,r.__b=e.__b+1,o=HZ(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=cf(i)),ZS(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=cf(i)),ZS(i,i))}function UB(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=UB(s[r],t,n));return t}return e.__e!=t&&(n.insertBefore(e.__e,t||null),t=e.__e),t&&t.nextSibling}function HZ(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 nD(e,t,n){t[0]==="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||BZ.test(t)?n:n+"px"}function rv(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||nD(e.style,t,"");if(n)for(t in n)s&&n[t]===s[t]||nD(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?rD:sD,i)):e.removeEventListener(t,i?rD:sD,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 sD(e){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(is.event?is.event(e):e)}function rD(e){return this.l[e.type+!0](is.event?is.event(e):e)}function GB(e,t,n,s,r,i,a,o,l,u){var d,h,f,p,m,v,x,b,w,C,E,y,k,T,P,A=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),i=[o=t.__e=n.__e]),(d=is.__b)&&d(t);e:if(typeof A=="function")try{if(b=t.props,w=(d=A.contextType)&&s[d.__c],C=d?w?w.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(b,C):(t.__c=h=new sx(b,C),h.constructor=A,h.render=$Z),w&&w.sub(h),h.props=b,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=lc({},h.__s)),lc(h.__s,A.getDerivedStateFromProps(b,h.__s))),p=h.props,m=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&&b!==p&&h.componentWillReceiveProps!=null&&h.componentWillReceiveProps(b,C),!h.__e&&(h.shouldComponentUpdate!=null&&h.shouldComponentUpdate(b,h.__s,C)===!1||t.__v===n.__v)){for(t.__v!==n.__v&&(h.props=b,h.state=h.__s,h.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.forEach(function(N){N&&(N.__=t)}),E=0;E<h._sb.length;E++)h.__h.push(h._sb[E]);h._sb=[],h.__h.length&&a.push(h);break e}h.componentWillUpdate!=null&&h.componentWillUpdate(b,h.__s,C),h.componentDidUpdate!=null&&h.__h.push(function(){h.componentDidUpdate(p,m,v)})}if(h.context=C,h.props=b,h.__P=e,h.__e=!1,y=is.__r,k=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),T=0;T<h._sb.length;T++)h.__h.push(h._sb[T]);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&&++k<25);h.state=h.__s,h.getChildContext!=null&&(s=lc(lc({},s),h.getChildContext())),f||h.getSnapshotBeforeUpdate==null||(v=h.getSnapshotBeforeUpdate(p,m)),HB(e,D_(P=d!=null&&d.type===P_&&d.key==null?d.props.children:d)?P:[P],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(N){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),is.__e(N,t,n)}else i==null&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=GZ(n.__e,t,n,s,r,i,a,l,u);(d=is.diffed)&&d(t)}function UZ(e,t,n){t.__d=void 0;for(var s=0;s<n.length;s++)I_(n[s],n[++s],n[++s]);is.__c&&is.__c(t,e),e.some(function(r){try{e=r.__h,r.__h=[],e.some(function(i){i.call(r)})}catch(i){is.__e(i,r.__v)}})}function GZ(e,t,n,s,r,i,a,o,l){var u,d,h,f,p,m,v,x=n.props,b=t.props,w=t.type;if(w==="svg"&&(r=!0),i!=null){for(u=0;u<i.length;u++)if((p=i[u])&&"setAttribute"in p==!!w&&(w?p.localName===w:p.nodeType===3)){e=p,i[u]=null;break}}if(e==null){if(w===null)return document.createTextNode(b);e=r?document.createElementNS("http://www.w3.org/2000/svg",w):document.createElement(w,b.is&&b),i=null,o=!1}if(w===null)x===b||o&&e.data===b||(e.data=b);else{if(i=i&&IB.call(e.childNodes),x=n.props||QS,!o&&i!=null)for(x={},u=0;u<e.attributes.length;u++)x[(p=e.attributes[u]).name]=p.value;for(u in x)p=x[u],u=="children"||(u=="dangerouslySetInnerHTML"?h=p:u==="key"||u in b||rv(e,u,null,p,r));for(u in b)p=b[u],u=="children"?f=p:u=="dangerouslySetInnerHTML"?d=p:u=="value"?m=p:u=="checked"?v=p:u==="key"||o&&typeof p!="function"||x[u]===p||rv(e,u,p,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=""),HB(e,D_(f)?f:[f],t,n,s,r&&w!=="foreignObject",i,a,i?i[0]:n.__k&&cf(n,0),o,l),i!=null)for(u=i.length;u--;)i[u]!=null&&BB(i[u]);o||(u="value",m!==void 0&&(m!==e[u]||w==="progress"&&!m||w==="option"&&m!==x[u])&&rv(e,u,m,x[u],!1),u="checked",v!==void 0&&v!==e[u]&&rv(e,u,v,x[u],!1))}return e}function I_(e,t,n){try{typeof e=="function"?e(t):e.current=t}catch(s){is.__e(s,n)}}function ZS(e,t,n){var s,r;if(is.unmount&&is.unmount(e),(s=e.ref)&&(s.current&&s.current!==e.__e||I_(s,null,t)),(s=e.__c)!=null){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(i){is.__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]&&ZS(s[r],t,n||typeof e.type!="function");n||e.__e==null||BB(e.__e),e.__=e.__e=e.__d=void 0}function $Z(e,t,n){return this.constructor(e,n)}IB=LB.slice,is={__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}},NB=0,sx.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=lc({},this.state),typeof e=="function"&&(e=e(lc({},n),this.props)),e&&lc(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),JS(this))},sx.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),JS(this))},sx.prototype.render=P_,gu=[],MB=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,YS=function(e,t){return e.__v.__b-t.__v.__b},Gx.__r=0,OB=0,function(e){e.Button="button",e.Tab="tab",e.Selector="selector"}(QF||(QF={})),function(e){e.Left="left",e.Center="center",e.Right="right",e.NextToTrigger="next_to_trigger"}(XS||(XS={})),function(e){e.Popover="popover",e.API="api",e.Widget="widget"}(JF||(JF={})),function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"}(ZF||(ZF={})),function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"}(eD||(eD={})),function(e){e.Once="once",e.Recurring="recurring",e.Always="always"}(tD||(tD={}));var uf=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=Rr("[Surveys]"),iD={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=>uf(t,n)),not_regex:(e,t)=>e.every(n=>!uf(t,n)),exact:(e,t)=>e.some(n=>t===n),is_not:(e,t)=>e.every(n=>t!==n)};function aD(e){return e??"icontains"}XS.Right;(function(e,t){var n={__c:t="__cC"+OB++,__: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,JS(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 $B=class{constructor(){st(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)}},VZ=class lh{constructor(t){st(this,"_debugEventEmitter",new $B),st(this,"checkStep",(n,s)=>this.checkStepEvent(n,s)&&this.checkStepUrl(n,s)&&this.checkStepElement(n,s)),st(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(!ft((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(!ft((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"||!lh.matchString(r,n?.url,n?.url_matching||"contains"))return!1}return!0}static matchString(t,n,s){switch(s){case"regex":return!!Ne&&uf(t,n);case"exact":return n===t;case"contains":var r=lh.escapeStringRegexp(n).replace(/_/g,".").replace(/%/g,".*");return uf(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&&!lh.matchString(i.href||"",n?.href,n?.href_matching||"exact"))&&(n==null||!n.tag_name||i.tag_name===n?.tag_name)&&!(n!=null&&n.text&&!lh.matchString(i.text||"",n?.text,n?.text_matching||"exact")&&!lh.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}},eE=class VB{constructor(t){this.instance=t,this.eventToSurveys=new Map,this.actionToSurveys=new Map}register(t){var n;ft((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 VZ(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,p;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||(p=f.values)===null||p===void 0||p.forEach(m=>{if(m&&m.name){var v=this.actionToSurveys.get(m.name);v&&v.push(s.id),this.actionToSurveys.set(m.name,v||[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[X0])||[];if(VB.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[X0])||[];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({[X0]:[...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[X0];return s||[]}getEventToSurveys(){return this.eventToSurveys}_getActionMatcher(){return this.actionMatcher}};st(eE,"SURVEY_SHOWN_EVENT_NAME","survey shown");let WZ=class{constructor(t){st(this,"_isFetchingSurveys",!1),st(this,"_isInitializingSurveys",!1),st(this,"_surveyCallbacks",[]),this.instance=t,this._surveyEventReceiver=null}onRemoteConfig(t){var n=t.surveys;if(Sn(n))return sr.warn("Decide not loaded yet. Not loading surveys.");var s=ss(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=Ht?.__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 eE(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 eE(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(AS);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,p,m,v,x,b,w,C,E,y,k,T;return((f=h.conditions)===null||f===void 0?void 0:f.events)&&((p=h.conditions)===null||p===void 0||(m=p.events)===null||m===void 0?void 0:m.values)&&((v=h.conditions)===null||v===void 0||(x=v.events)===null||x===void 0||(b=x.values)===null||b===void 0?void 0:b.length)>0||((w=h.conditions)===null||w===void 0?void 0:w.actions)&&((C=h.conditions)===null||C===void 0||(E=C.actions)===null||E===void 0?void 0:E.values)&&((y=h.conditions)===null||y===void 0||(k=y.actions)===null||k===void 0||(T=k.values)===null||T===void 0?void 0:T.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({[AS]: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(p){var m,v,x;if((m=p.conditions)===null||m===void 0||!m.url)return!0;var b=Ne==null||(v=Ne.location)===null||v===void 0?void 0:v.href;if(!b)return!1;var w=[p.conditions.url];return iD[aD((x=p.conditions)===null||x===void 0?void 0:x.urlMatchType)](w,b)}(l),h=(u=l.conditions)===null||u===void 0||!u.selector||mt?.querySelector(l.conditions.selector),f=function(p){var m,v,x;if((m=p.conditions)===null||m===void 0||!m.deviceTypes||((v=p.conditions)===null||v===void 0?void 0:v.deviceTypes.length)===0)return!0;if(!Rs)return!1;var b=qn.deviceType(Rs);return iD[aD((x=p.conditions)===null||x===void 0?void 0:x.deviceTypesMatchType)](p.conditions.deviceTypes,b)}(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,p,m,v,x,b;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 w=this.isSurveyFeatureFlagEnabled(l.linked_flag_key),C=this.isSurveyFeatureFlagEnabled(l.targeting_flag_key),E=((d=(h=l.conditions)===null||h===void 0||(f=h.events)===null||f===void 0||(p=f.values)===null||p===void 0?void 0:p.length)!==null&&d!==void 0?d:0)>0,y=((m=(v=l.conditions)===null||v===void 0||(x=v.actions)===null||x===void 0||(b=x.values)===null||b===void 0?void 0:b.length)!==null&&m!==void 0?m:0)>0,k=!E&&!y||a?.includes(l.id),T=this._canActivateRepeatedly(l)||this.isSurveyFeatureFlagEnabled(l.internal_targeting_flag_key),P=this.checkFlags(l);return w&&C&&T&&k&&P});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 Sn((n=Ht.__PosthogExtensions__)===null||n===void 0?void 0:n.canActivateRepeatedly)?(sr.warn("init was not called"),!1):Ht.__PosthogExtensions__.canActivateRepeatedly(t)}canRenderSurvey(t){if(Sn(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?je({},this._surveyManager.canRenderSurvey(r)):{visible:!1,disabledReason:"Survey not found"}}),n}renderSurvey(t,n){Sn(this._surveyManager)?sr.warn("init was not called"):this.getSurveys(s=>{var r=s.filter(i=>i.id===t)[0];this._surveyManager.renderSurvey(r,mt?.querySelector(n))})}};var oD=Rr("[RateLimiter]");let zZ=class{constructor(t){var n,s;st(this,"serverLimits",{}),st(this,"lastEventRateLimited",!1),st(this,"checkForLimiting",r=>{var i=r.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach(a=>{oD.info("".concat(a||"events"," is quota limited.")),this.serverLimits[a]=new Date().getTime()+6e4})}catch(a){return void oD.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(DS))!==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(DS,a),{isRateLimited:o,remainingTokens:a.tokens}}isServerRateLimited(t){var n=this.serverLimits[t||"events"]||!1;return n!==!1&&new Date().getTime()<n}};var ou=Rr("[RemoteConfig]");let qZ=class{constructor(t){this.instance=t}get remoteConfig(){var t,n;return(t=Ht._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=Ht.__PosthogExtensions__)!==null&&n!==void 0&&n.loadExternalDependency?(s=Ht.__PosthogExtensions__)===null||s===void 0||(r=s.loadExternalDependency)===null||r===void 0||r.call(s,this.instance,"remote-config",()=>t(this.remoteConfig)):(ou.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 ou.info("Using preloaded remote config",this.remoteConfig),void this.onRemoteConfig(this.remoteConfig);if(this.instance.config.advanced_disable_decide)return void ou.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(t=>{if(!t)return ou.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){ou.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()):ou.info("__preview_remote_config is disabled. Logging config instead",t):ou.error("Failed to fetch remote config from PostHog.")}};var KZ=function(e){var t,n,s,r,i="";for(t=n=0,s=(e=(e+"").replace(/\r\n/g,`
4
4
  `).replace(/\r/g,`
@@ -412,7 +412,7 @@ import{r as g,j as c,c as _,b as Ge,f as qA,l as uV,u as dV,s as hV,v as iS,a as
412
412
  *
413
413
  * This source code is licensed under the ISC license.
414
414
  * See the LICENSE file in the root directory of this source tree.
415
- */const Lne=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Bne=at("user",Lne);var jne=Object.defineProperty,vc=(e,t)=>jne(e,"name",{value:t,configurable:!0}),L_="ContextMenu",[Hne,iXe]=IX(L_,[T4]),c0=T4(),[Une,a6]=Hne(L_),Gne=vc(e=>{const{__scopeContextMenu:t,children:n,onOpenChange:s,open:r,dir:i,modal:a=!0}=e,o=g.useRef(!1),[l,u]=OX({prop:r,defaultProp:!1,onChange:s,caller:L_}),d=c0(t);return c.jsx(Une,{scope:t,open:l,onOpenChange:u,modal:a,hasInteractedRef:o,children:c.jsx(LX,{...d,dir:i,open:l,onOpenChange:u,modal:a,children:n})})},"ContextMenu"),$ne="ContextMenuTrigger",Vne=g.forwardRef(vc(function(t,n){const{__scopeContextMenu:s,disabled:r=!1,...i}=t,a=a6($ne,s),o=c0(s),[l,u]=g.useState({x:0,y:0}),d=g.useMemo(()=>({current:{getBoundingClientRect:vc(()=>DOMRect.fromRect({width:0,height:0,...l}),"getBoundingClientRect")}}),[l]),h=g.useRef(0),f=g.useCallback(()=>window.clearTimeout(h.current),[]),p=vc(m=>{a.hasInteractedRef.current=!0,u({x:m.clientX,y:m.clientY}),a.onOpenChange(!0)},"handleOpen");return g.useEffect(()=>f,[f]),g.useEffect(()=>void(r&&f()),[r,f]),c.jsxs(c.Fragment,{children:[c.jsx(BX,{...o,virtualRef:d}),c.jsx(jX.span,{"data-state":a.open?"open":"closed","data-disabled":r?"":void 0,...i,ref:n,style:{WebkitTouchCallout:"none",...t.style},onContextMenu:r?t.onContextMenu:pp(t.onContextMenu,m=>{f(),p(m),m.preventDefault()}),onPointerDown:r?t.onPointerDown:pp(t.onPointerDown,Xp(m=>{f(),a.open&&a.onOpenChange(!1),h.current=window.setTimeout(()=>p(m),700)})),onPointerMove:r?t.onPointerMove:pp(t.onPointerMove,Xp(f)),onPointerCancel:r?t.onPointerCancel:pp(t.onPointerCancel,Xp(f)),onPointerUp:r?t.onPointerUp:pp(t.onPointerUp,Xp(f))})]})},"ContextMenuTrigger")),Wne=vc(e=>{const{__scopeContextMenu:t,...n}=e,s=c0(t);return c.jsx(HX,{...s,...n})},"ContextMenuPortal"),zne="ContextMenuContent",qne=g.forwardRef(vc(function(t,n){const{__scopeContextMenu:s,...r}=t,i=a6(zne,s),a=c0(s),o=g.useRef(!1);return c.jsx(NX,{...a,...r,ref:n,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:l=>{t.onCloseAutoFocus?.(l),!l.defaultPrevented&&o.current&&l.preventDefault(),o.current=!1},onInteractOutside:l=>{t.onInteractOutside?.(l),!l.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"ContextMenuContent")),Kne=g.forwardRef(vc(function(t,n){const{__scopeContextMenu:s,...r}=t,i=c0(s);return c.jsx(MX,{...i,...r,ref:n})},"ContextMenuItem"));function Xp(e){return t=>t.pointerType!=="mouse"?e(t):void 0}vc(Xp,"whenTouchOrPen");var Yne=Gne,Xne=Vne,Qne=Wne,Jne=qne,Zne=Kne;const hl=["agents"],oE=(e=1,t=50,n=0,s,r,i)=>{const{shouldEnableQuery:a,getConnectivityError:o}=qk(),l=o();return g.useEffect(()=>{l&&console.error("Agents connectivity error:",l.message)},[l]),Os({enabled:a({bypassInternetCheck:!0}),queryKey:[...hl,e,t,s,r,i],queryFn:async()=>{try{const d=await ha(ws.baseUrl).agents.listAgents(e,t,s,r,i);if(d.status>=400||!d.result)throw new Error(d.message||"Failed to fetch agents");return d.result}catch(u){const d=u instanceof Error?u.message:"An unknown error occurred while fetching agents";throw $t(d),u}},refetchOnWindowFocus:!1,refetchOnMount:!1,refetchInterval:n,placeholderData:u=>u,staleTime:30*1e3})},ese=e=>{const{shouldEnableQuery:t,getConnectivityError:n}=qk(),s=n();return g.useEffect(()=>{s&&console.error("Agent connectivity error:",s.message)},[s]),Os({enabled:t({bypassInternetCheck:!0})&&!!e,queryKey:[...hl,e],queryFn:async()=>{if(!e)return null;try{const i=await ha(ws.baseUrl).agents.getAgent(e);if(i.status>=400)throw new Error(i.message||`Failed to fetch agent ${e}`);return i.result}catch(r){if(!(r instanceof Error&&(r.message.includes("404")||r.message.includes("not found")))){const a=r instanceof Error?r.message:`An unknown error occurred while fetching agent ${e}`;$t(a)}throw r}},refetchOnWindowFocus:!1,refetchOnMount:!1,staleTime:30*1e3})},tse=()=>{const e=hn(),t=ha(ws.baseUrl);return Cs({mutationFn:async n=>{try{const s=await t.agents.createAgent(n);if(s.status>=400)throw new Error(s.message||"Failed to create agent");return s.result}catch(s){const r=s instanceof Error?s.message:"An unknown error occurred while creating the agent";throw $t(r),s}},onSuccess:()=>{e.invalidateQueries({queryKey:hl}),vs("Agent created")},onError:n=>{console.error("Error creating agent:",n)}})},aXe=()=>{const e=hn(),t=ha(ws.baseUrl);return Cs({mutationFn:async n=>{try{const s=await t.agents.deleteAgent(n);if(s.status>=400)throw new Error(s.message||`Failed to delete agent ${n}`);return s}catch(s){const r=s instanceof Error?s.message:`An unknown error occurred while deleting agent ${n}`;throw $t(r),s}},onSuccess:(n,s)=>{e.removeQueries({queryKey:[...hl,s],exact:!0}),e.invalidateQueries({queryKey:hl}),vs("Agent deleted")},onError:n=>{console.error("Error deleting agent:",n)}})},oXe=()=>{const e=hn(),t=ha(ws.baseUrl);return Cs({mutationFn:async n=>{try{const s=await t.agents.importAgent(n);if(s.status>=400)throw new Error(s.message||"Failed to import agent");return s.result}catch(s){const r=s instanceof Error?s.message:"An unknown error occurred while importing the agent";throw $t(r),s}},onSuccess:n=>(e.invalidateQueries({queryKey:hl}),vs("Agent imported"),n),onError:n=>{console.error("Error importing agent:",n)}})},lXe=()=>{const e=ha(ws.baseUrl);return Cs({mutationFn:async t=>{try{return await e.agents.exportAgent(t)}catch(n){const s=n instanceof Error?n.message:`An unknown error occurred while exporting agent ${t}`;throw $t(s),n}},onSuccess:()=>{vs("Agent exported")},onError:t=>{console.error("Error exporting agent:",t)}})},Lc=({open:e,title:t,message:n,confirmText:s="Confirm",cancelText:r="Cancel",isDangerous:i=!1,onConfirm:a,onCancel:o,focusCancelSignal:l,busy:u=!1,busyText:d,panelClassName:h})=>{const f=g.useRef(null);g.useEffect(()=>{!e||l===void 0||f.current?.focus()},[l,e]);const p=i?c.jsxs(c.Fragment,{children:[c.jsx(Lo,{size:19,className:"text-danger","aria-hidden":"true"}),c.jsx("span",{className:"text-danger",children:t})]}):t,m=c.jsxs(c.Fragment,{children:[c.jsx(Qm,{ref:f,"data-cancel-action":!0,onClick:o,disabled:u,className:"focus:outline-2 focus:outline-solid focus:outline-accent focus:outline-offset-2",children:r}),i?c.jsx(mV,{"data-confirm-action":!0,onClick:a,disabled:u,"aria-busy":u,startIcon:u?c.jsx(Rn,{size:"xs"}):void 0,children:u&&d?d:s}):c.jsx(Jm,{"data-confirm-action":!0,onClick:a,disabled:u,"aria-busy":u,startIcon:u?c.jsx(Rn,{size:"xs"}):void 0,children:u&&d?d:s})]});return c.jsx(Mc,{open:e,onClose:o,title:p,actions:m,maxWidth:"xs",dialogProps:{closeDisabled:u,...h?{className:h}:{},onEscapeKeyDown:v=>{u&&v.preventDefault()},onInteractOutside:v=>{u&&v.preventDefault()}},children:c.jsx(Of,{asChild:!0,children:c.jsx("div",{className:"text-body text-ink-muted",children:n})})})},Ph="$$material";function lE(){return lE=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},lE.apply(null,arguments)}function nse(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}function sse(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),e.nonce!==void 0&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}var rse=function(){function e(n){var s=this;this._insertTag=function(r){var i;s.tags.length===0?s.insertionPoint?i=s.insertionPoint.nextSibling:s.prepend?i=s.container.firstChild:i=s.before:i=s.tags[s.tags.length-1].nextSibling,s.container.insertBefore(r,i),s.tags.push(r)},this.isSpeedy=n.speedy===void 0?!0:n.speedy,this.tags=[],this.ctr=0,this.nonce=n.nonce,this.key=n.key,this.container=n.container,this.prepend=n.prepend,this.insertionPoint=n.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(s){s.forEach(this._insertTag)},t.insert=function(s){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(sse(this));var r=this.tags[this.tags.length-1];if(this.isSpeedy){var i=nse(r);try{i.insertRule(s,i.cssRules.length)}catch{}}else r.appendChild(document.createTextNode(s));this.ctr++},t.flush=function(){this.tags.forEach(function(s){var r;return(r=s.parentNode)==null?void 0:r.removeChild(s)}),this.tags=[],this.ctr=0},e}(),vr="-ms-",Kx="-moz-",fn="-webkit-",o6="comm",B_="rule",j_="decl",ise="@import",l6="@keyframes",ase="@layer",ose=Math.abs,Rw=String.fromCharCode,lse=Object.assign;function cse(e,t){return ar(e,0)^45?(((t<<2^ar(e,0))<<2^ar(e,1))<<2^ar(e,2))<<2^ar(e,3):0}function c6(e){return e.trim()}function use(e,t){return(e=t.exec(e))?e[0]:e}function pn(e,t,n){return e.replace(t,n)}function cE(e,t){return e.indexOf(t)}function ar(e,t){return e.charCodeAt(t)|0}function cm(e,t,n){return e.slice(t,n)}function po(e){return e.length}function H_(e){return e.length}function iv(e,t){return t.push(e),e}function dse(e,t){return e.map(t).join("")}var Aw=1,hf=1,u6=0,di=0,As=0,Bf="";function Fw(e,t,n,s,r,i,a){return{value:e,root:t,parent:n,type:s,props:r,children:i,line:Aw,column:hf,length:a,return:""}}function bp(e,t){return lse(Fw("",null,null,"",null,null,0),e,{length:-e.length},t)}function hse(){return As}function fse(){return As=di>0?ar(Bf,--di):0,hf--,As===10&&(hf=1,Aw--),As}function Fi(){return As=di<u6?ar(Bf,di++):0,hf++,As===10&&(hf=1,Aw++),As}function ko(){return ar(Bf,di)}function rx(){return di}function u0(e,t){return cm(Bf,e,t)}function um(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function d6(e){return Aw=hf=1,u6=po(Bf=e),di=0,[]}function h6(e){return Bf="",e}function ix(e){return c6(u0(di-1,uE(e===91?e+2:e===40?e+1:e)))}function pse(e){for(;(As=ko())&&As<33;)Fi();return um(e)>2||um(As)>3?"":" "}function gse(e,t){for(;--t&&Fi()&&!(As<48||As>102||As>57&&As<65||As>70&&As<97););return u0(e,rx()+(t<6&&ko()==32&&Fi()==32))}function uE(e){for(;Fi();)switch(As){case e:return di;case 34:case 39:e!==34&&e!==39&&uE(As);break;case 40:e===41&&uE(e);break;case 92:Fi();break}return di}function mse(e,t){for(;Fi()&&e+As!==57;)if(e+As===84&&ko()===47)break;return"/*"+u0(t,di-1)+"*"+Rw(e===47?e:Fi())}function vse(e){for(;!um(ko());)Fi();return u0(e,di)}function xse(e){return h6(ax("",null,null,null,[""],e=d6(e),0,[0],e))}function ax(e,t,n,s,r,i,a,o,l){for(var u=0,d=0,h=a,f=0,p=0,m=0,v=1,x=1,b=1,w=0,C="",E=r,y=i,k=s,T=C;x;)switch(m=w,w=Fi()){case 40:if(m!=108&&ar(T,h-1)==58){cE(T+=pn(ix(w),"&","&\f"),"&\f")!=-1&&(b=-1);break}case 34:case 39:case 91:T+=ix(w);break;case 9:case 10:case 13:case 32:T+=pse(m);break;case 92:T+=gse(rx()-1,7);continue;case 47:switch(ko()){case 42:case 47:iv(bse(mse(Fi(),rx()),t,n),l);break;default:T+="/"}break;case 123*v:o[u++]=po(T)*b;case 125*v:case 59:case 0:switch(w){case 0:case 125:x=0;case 59+d:b==-1&&(T=pn(T,/\f/g,"")),p>0&&po(T)-h&&iv(p>32?yD(T+";",s,n,h-1):yD(pn(T," ","")+";",s,n,h-2),l);break;case 59:T+=";";default:if(iv(k=CD(T,t,n,u,d,r,o,C,E=[],y=[],h),i),w===123)if(d===0)ax(T,t,k,k,E,i,h,o,y);else switch(f===99&&ar(T,3)===110?100:f){case 100:case 108:case 109:case 115:ax(e,k,k,s&&iv(CD(e,k,k,0,0,r,o,C,r,E=[],h),y),r,y,h,o,s?E:y);break;default:ax(T,k,k,k,[""],y,0,o,y)}}u=d=p=0,v=b=1,C=T="",h=a;break;case 58:h=1+po(T),p=m;default:if(v<1){if(w==123)--v;else if(w==125&&v++==0&&fse()==125)continue}switch(T+=Rw(w),w*v){case 38:b=d>0?1:(T+="\f",-1);break;case 44:o[u++]=(po(T)-1)*b,b=1;break;case 64:ko()===45&&(T+=ix(Fi())),f=ko(),d=h=po(C=T+=vse(rx())),w++;break;case 45:m===45&&po(T)==2&&(v=0)}}return i}function CD(e,t,n,s,r,i,a,o,l,u,d){for(var h=r-1,f=r===0?i:[""],p=H_(f),m=0,v=0,x=0;m<s;++m)for(var b=0,w=cm(e,h+1,h=ose(v=a[m])),C=e;b<p;++b)(C=c6(v>0?f[b]+" "+w:pn(w,/&\f/g,f[b])))&&(l[x++]=C);return Fw(e,t,n,r===0?B_:o,l,u,d)}function bse(e,t,n){return Fw(e,t,n,o6,Rw(hse()),cm(e,2,-2),0)}function yD(e,t,n,s){return Fw(e,t,n,j_,cm(e,0,s),cm(e,s+1,-1),s)}function Ih(e,t){for(var n="",s=H_(e),r=0;r<s;r++)n+=t(e[r],r,e,t)||"";return n}function wse(e,t,n,s){switch(e.type){case ase:if(e.children.length)break;case ise:case j_:return e.return=e.return||e.value;case o6:return"";case l6:return e.return=e.value+"{"+Ih(e.children,s)+"}";case B_:e.value=e.props.join(",")}return po(n=Ih(e.children,s))?e.return=e.value+"{"+n+"}":""}function Cse(e){var t=H_(e);return function(n,s,r,i){for(var a="",o=0;o<t;o++)a+=e[o](n,s,r,i)||"";return a}}function yse(e){return function(t){t.root||(t=t.return)&&e(t)}}function Sse(e){var t=Object.create(null);return function(n){return t[n]===void 0&&(t[n]=e(n)),t[n]}}var Ese=function(t,n,s){for(var r=0,i=0;r=i,i=ko(),r===38&&i===12&&(n[s]=1),!um(i);)Fi();return u0(t,di)},kse=function(t,n){var s=-1,r=44;do switch(um(r)){case 0:r===38&&ko()===12&&(n[s]=1),t[s]+=Ese(di-1,n,s);break;case 2:t[s]+=ix(r);break;case 4:if(r===44){t[++s]=ko()===58?"&\f":"",n[s]=t[s].length;break}default:t[s]+=Rw(r)}while(r=Fi());return t},_se=function(t,n){return h6(kse(d6(t),n))},SD=new WeakMap,Tse=function(t){if(!(t.type!=="rule"||!t.parent||t.length<1)){for(var n=t.value,s=t.parent,r=t.column===s.column&&t.line===s.line;s.type!=="rule";)if(s=s.parent,!s)return;if(!(t.props.length===1&&n.charCodeAt(0)!==58&&!SD.get(s))&&!r){SD.set(t,!0);for(var i=[],a=_se(n,i),o=s.props,l=0,u=0;l<a.length;l++)for(var d=0;d<o.length;d++,u++)t.props[u]=i[l]?a[l].replace(/&\f/g,o[d]):o[d]+" "+a[l]}}},Rse=function(t){if(t.type==="decl"){var n=t.value;n.charCodeAt(0)===108&&n.charCodeAt(2)===98&&(t.return="",t.value="")}};function f6(e,t){switch(cse(e,t)){case 5103:return fn+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return fn+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return fn+e+Kx+e+vr+e+e;case 6828:case 4268:return fn+e+vr+e+e;case 6165:return fn+e+vr+"flex-"+e+e;case 5187:return fn+e+pn(e,/(\w+).+(:[^]+)/,fn+"box-$1$2"+vr+"flex-$1$2")+e;case 5443:return fn+e+vr+"flex-item-"+pn(e,/flex-|-self/,"")+e;case 4675:return fn+e+vr+"flex-line-pack"+pn(e,/align-content|flex-|-self/,"")+e;case 5548:return fn+e+vr+pn(e,"shrink","negative")+e;case 5292:return fn+e+vr+pn(e,"basis","preferred-size")+e;case 6060:return fn+"box-"+pn(e,"-grow","")+fn+e+vr+pn(e,"grow","positive")+e;case 4554:return fn+pn(e,/([^-])(transform)/g,"$1"+fn+"$2")+e;case 6187:return pn(pn(pn(e,/(zoom-|grab)/,fn+"$1"),/(image-set)/,fn+"$1"),e,"")+e;case 5495:case 3959:return pn(e,/(image-set\([^]*)/,fn+"$1$`$1");case 4968:return pn(pn(e,/(.+:)(flex-)?(.*)/,fn+"box-pack:$3"+vr+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+fn+e+e;case 4095:case 3583:case 4068:case 2532:return pn(e,/(.+)-inline(.+)/,fn+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(po(e)-1-t>6)switch(ar(e,t+1)){case 109:if(ar(e,t+4)!==45)break;case 102:return pn(e,/(.+:)(.+)-([^]+)/,"$1"+fn+"$2-$3$1"+Kx+(ar(e,t+3)==108?"$3":"$2-$3"))+e;case 115:return~cE(e,"stretch")?f6(pn(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(ar(e,t+1)!==115)break;case 6444:switch(ar(e,po(e)-3-(~cE(e,"!important")&&10))){case 107:return pn(e,":",":"+fn)+e;case 101:return pn(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+fn+(ar(e,14)===45?"inline-":"")+"box$3$1"+fn+"$2$3$1"+vr+"$2box$3")+e}break;case 5936:switch(ar(e,t+11)){case 114:return fn+e+vr+pn(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return fn+e+vr+pn(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return fn+e+vr+pn(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return fn+e+vr+e+e}return e}var Ase=function(t,n,s,r){if(t.length>-1&&!t.return)switch(t.type){case j_:t.return=f6(t.value,t.length);break;case l6:return Ih([bp(t,{value:pn(t.value,"@","@"+fn)})],r);case B_:if(t.length)return dse(t.props,function(i){switch(use(i,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return Ih([bp(t,{props:[pn(i,/:(read-\w+)/,":"+Kx+"$1")]})],r);case"::placeholder":return Ih([bp(t,{props:[pn(i,/:(plac\w+)/,":"+fn+"input-$1")]}),bp(t,{props:[pn(i,/:(plac\w+)/,":"+Kx+"$1")]}),bp(t,{props:[pn(i,/:(plac\w+)/,vr+"input-$1")]})],r)}return""})}},Fse=[Ase],Dse=function(t){var n=t.key;if(n==="css"){var s=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(s,function(v){var x=v.getAttribute("data-emotion");x.indexOf(" ")!==-1&&(document.head.appendChild(v),v.setAttribute("data-s",""))})}var r=t.stylisPlugins||Fse,i={},a,o=[];a=t.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+n+' "]'),function(v){for(var x=v.getAttribute("data-emotion").split(" "),b=1;b<x.length;b++)i[x[b]]=!0;o.push(v)});var l,u=[Tse,Rse];{var d,h=[wse,yse(function(v){d.insert(v)})],f=Cse(u.concat(r,h)),p=function(x){return Ih(xse(x),f)};l=function(x,b,w,C){d=w,p(x?x+"{"+b.styles+"}":b.styles),C&&(m.inserted[b.name]=!0)}}var m={key:n,sheet:new rse({key:n,container:a,nonce:t.nonce,speedy:t.speedy,prepend:t.prepend,insertionPoint:t.insertionPoint}),nonce:t.nonce,inserted:i,registered:{},insert:l};return m.sheet.hydrate(o),m},cy={exports:{}},xn={};/** @license React v16.13.1
415
+ */const Lne=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Bne=at("user",Lne);var jne=Object.defineProperty,vc=(e,t)=>jne(e,"name",{value:t,configurable:!0}),L_="ContextMenu",[Hne,iXe]=IX(L_,[T4]),c0=T4(),[Une,a6]=Hne(L_),Gne=vc(e=>{const{__scopeContextMenu:t,children:n,onOpenChange:s,open:r,dir:i,modal:a=!0}=e,o=g.useRef(!1),[l,u]=OX({prop:r,defaultProp:!1,onChange:s,caller:L_}),d=c0(t);return c.jsx(Une,{scope:t,open:l,onOpenChange:u,modal:a,hasInteractedRef:o,children:c.jsx(LX,{...d,dir:i,open:l,onOpenChange:u,modal:a,children:n})})},"ContextMenu"),$ne="ContextMenuTrigger",Vne=g.forwardRef(vc(function(t,n){const{__scopeContextMenu:s,disabled:r=!1,...i}=t,a=a6($ne,s),o=c0(s),[l,u]=g.useState({x:0,y:0}),d=g.useMemo(()=>({current:{getBoundingClientRect:vc(()=>DOMRect.fromRect({width:0,height:0,...l}),"getBoundingClientRect")}}),[l]),h=g.useRef(0),f=g.useCallback(()=>window.clearTimeout(h.current),[]),p=vc(m=>{a.hasInteractedRef.current=!0,u({x:m.clientX,y:m.clientY}),a.onOpenChange(!0)},"handleOpen");return g.useEffect(()=>f,[f]),g.useEffect(()=>void(r&&f()),[r,f]),c.jsxs(c.Fragment,{children:[c.jsx(BX,{...o,virtualRef:d}),c.jsx(jX.span,{"data-state":a.open?"open":"closed","data-disabled":r?"":void 0,...i,ref:n,style:{WebkitTouchCallout:"none",...t.style},onContextMenu:r?t.onContextMenu:pp(t.onContextMenu,m=>{f(),p(m),m.preventDefault()}),onPointerDown:r?t.onPointerDown:pp(t.onPointerDown,Xp(m=>{f(),a.open&&a.onOpenChange(!1),h.current=window.setTimeout(()=>p(m),700)})),onPointerMove:r?t.onPointerMove:pp(t.onPointerMove,Xp(f)),onPointerCancel:r?t.onPointerCancel:pp(t.onPointerCancel,Xp(f)),onPointerUp:r?t.onPointerUp:pp(t.onPointerUp,Xp(f))})]})},"ContextMenuTrigger")),Wne=vc(e=>{const{__scopeContextMenu:t,...n}=e,s=c0(t);return c.jsx(HX,{...s,...n})},"ContextMenuPortal"),zne="ContextMenuContent",qne=g.forwardRef(vc(function(t,n){const{__scopeContextMenu:s,...r}=t,i=a6(zne,s),a=c0(s),o=g.useRef(!1);return c.jsx(NX,{...a,...r,ref:n,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:l=>{t.onCloseAutoFocus?.(l),!l.defaultPrevented&&o.current&&l.preventDefault(),o.current=!1},onInteractOutside:l=>{t.onInteractOutside?.(l),!l.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...t.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"ContextMenuContent")),Kne=g.forwardRef(vc(function(t,n){const{__scopeContextMenu:s,...r}=t,i=c0(s);return c.jsx(MX,{...i,...r,ref:n})},"ContextMenuItem"));function Xp(e){return t=>t.pointerType!=="mouse"?e(t):void 0}vc(Xp,"whenTouchOrPen");var Yne=Gne,Xne=Vne,Qne=Wne,Jne=qne,Zne=Kne;const hl=["agents"],oE=(e=1,t=50,n=0,s,r,i)=>{const{shouldEnableQuery:a,getConnectivityError:o}=qk(),l=o();return g.useEffect(()=>{l&&console.error("Agents connectivity error:",l.message)},[l]),Os({enabled:a({bypassInternetCheck:!0}),queryKey:[...hl,e,t,s,r,i],queryFn:async()=>{try{const d=await ha(ws.baseUrl).agents.listAgents(e,t,s,r,i);if(d.status>=400||!d.result)throw new Error(d.message||"Failed to fetch agents");return d.result}catch(u){const d=u instanceof Error?u.message:"An unknown error occurred while fetching agents";throw $t(d),u}},refetchOnWindowFocus:!1,refetchOnMount:!1,refetchInterval:n,placeholderData:u=>u,staleTime:30*1e3})},ese=e=>{const{shouldEnableQuery:t,getConnectivityError:n}=qk(),s=n();return g.useEffect(()=>{s&&console.error("Agent connectivity error:",s.message)},[s]),Os({enabled:t({bypassInternetCheck:!0})&&!!e,queryKey:[...hl,e],queryFn:async()=>{if(!e)return null;try{const i=await ha(ws.baseUrl).agents.getAgent(e);if(i.status>=400)throw new Error(i.message||`Failed to fetch agent ${e}`);return i.result}catch(r){if(!(r instanceof Error&&(r.message.includes("404")||r.message.includes("not found")))){const a=r instanceof Error?r.message:`An unknown error occurred while fetching agent ${e}`;$t(a)}throw r}},refetchOnWindowFocus:!1,refetchOnMount:!1,staleTime:30*1e3})},tse=()=>{const e=hn(),t=ha(ws.baseUrl);return Cs({mutationFn:async n=>{try{const s=await t.agents.createAgent(n);if(s.status>=400)throw new Error(s.message||"Failed to create agent");return s.result}catch(s){const r=s instanceof Error?s.message:"An unknown error occurred while creating the agent";throw $t(r),s}},onSuccess:()=>{e.invalidateQueries({queryKey:hl}),vs("Agent created")},onError:n=>{console.error("Error creating agent:",n)}})},aXe=()=>{const e=hn(),t=ha(ws.baseUrl);return Cs({mutationFn:async n=>{try{const s=await t.agents.deleteAgent(n);if(s.status>=400)throw new Error(s.message||`Failed to delete agent ${n}`);return s}catch(s){const r=s instanceof Error?s.message:`An unknown error occurred while deleting agent ${n}`;throw $t(r),s}},onSuccess:(n,s)=>{e.removeQueries({queryKey:[...hl,s],exact:!0}),e.invalidateQueries({queryKey:hl}),vs("Agent deleted")},onError:n=>{console.error("Error deleting agent:",n)}})},oXe=()=>{const e=hn(),t=ha(ws.baseUrl);return Cs({mutationFn:async n=>{try{const s=await t.agents.importAgent(n);if(s.status>=400)throw new Error(s.message||"Failed to import agent");return s.result}catch(s){const r=s instanceof Error?s.message:"An unknown error occurred while importing the agent";throw $t(r),s}},onSuccess:n=>(e.invalidateQueries({queryKey:hl}),vs("Agent imported"),n),onError:n=>{console.error("Error importing agent:",n)}})},lXe=()=>{const e=ha(ws.baseUrl);return Cs({mutationFn:async t=>{try{return await e.agents.exportAgent(t)}catch(n){const s=n instanceof Error?n.message:`An unknown error occurred while exporting agent ${t}`;throw $t(s),n}},onSuccess:()=>{vs("Agent exported")},onError:t=>{console.error("Error exporting agent:",t)}})},Lc=({open:e,title:t,message:n,confirmText:s="Confirm",cancelText:r="Cancel",isDangerous:i=!1,onConfirm:a,onCancel:o,focusCancelSignal:l,busy:u=!1,busyText:d,panelClassName:h})=>{const f=g.useRef(null);g.useEffect(()=>{!e||l===void 0||f.current?.focus()},[l,e]);const p=i?c.jsxs(c.Fragment,{children:[c.jsx(Lo,{size:19,className:"shrink-0 text-danger","aria-hidden":"true"}),c.jsx("span",{className:"min-w-0 text-danger",children:t})]}):t,m=c.jsxs(c.Fragment,{children:[c.jsx(Qm,{ref:f,"data-cancel-action":!0,onClick:o,disabled:u,className:"focus:outline-2 focus:outline-solid focus:outline-accent focus:outline-offset-2",children:r}),i?c.jsx(mV,{"data-confirm-action":!0,onClick:a,disabled:u,"aria-busy":u,startIcon:u?c.jsx(Rn,{size:"xs"}):void 0,children:u&&d?d:s}):c.jsx(Jm,{"data-confirm-action":!0,onClick:a,disabled:u,"aria-busy":u,startIcon:u?c.jsx(Rn,{size:"xs"}):void 0,children:u&&d?d:s})]});return c.jsx(Mc,{open:e,onClose:o,title:p,actions:m,maxWidth:"xs",dialogProps:{closeDisabled:u,...h?{className:h}:{},onEscapeKeyDown:v=>{u&&v.preventDefault()},onInteractOutside:v=>{u&&v.preventDefault()}},children:c.jsx(Of,{asChild:!0,children:c.jsx("div",{className:"text-body text-ink-muted",children:n})})})},Ph="$$material";function lE(){return lE=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},lE.apply(null,arguments)}function nse(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}function sse(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),e.nonce!==void 0&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}var rse=function(){function e(n){var s=this;this._insertTag=function(r){var i;s.tags.length===0?s.insertionPoint?i=s.insertionPoint.nextSibling:s.prepend?i=s.container.firstChild:i=s.before:i=s.tags[s.tags.length-1].nextSibling,s.container.insertBefore(r,i),s.tags.push(r)},this.isSpeedy=n.speedy===void 0?!0:n.speedy,this.tags=[],this.ctr=0,this.nonce=n.nonce,this.key=n.key,this.container=n.container,this.prepend=n.prepend,this.insertionPoint=n.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(s){s.forEach(this._insertTag)},t.insert=function(s){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(sse(this));var r=this.tags[this.tags.length-1];if(this.isSpeedy){var i=nse(r);try{i.insertRule(s,i.cssRules.length)}catch{}}else r.appendChild(document.createTextNode(s));this.ctr++},t.flush=function(){this.tags.forEach(function(s){var r;return(r=s.parentNode)==null?void 0:r.removeChild(s)}),this.tags=[],this.ctr=0},e}(),vr="-ms-",Kx="-moz-",fn="-webkit-",o6="comm",B_="rule",j_="decl",ise="@import",l6="@keyframes",ase="@layer",ose=Math.abs,Rw=String.fromCharCode,lse=Object.assign;function cse(e,t){return ar(e,0)^45?(((t<<2^ar(e,0))<<2^ar(e,1))<<2^ar(e,2))<<2^ar(e,3):0}function c6(e){return e.trim()}function use(e,t){return(e=t.exec(e))?e[0]:e}function pn(e,t,n){return e.replace(t,n)}function cE(e,t){return e.indexOf(t)}function ar(e,t){return e.charCodeAt(t)|0}function cm(e,t,n){return e.slice(t,n)}function po(e){return e.length}function H_(e){return e.length}function iv(e,t){return t.push(e),e}function dse(e,t){return e.map(t).join("")}var Aw=1,hf=1,u6=0,di=0,As=0,Bf="";function Fw(e,t,n,s,r,i,a){return{value:e,root:t,parent:n,type:s,props:r,children:i,line:Aw,column:hf,length:a,return:""}}function bp(e,t){return lse(Fw("",null,null,"",null,null,0),e,{length:-e.length},t)}function hse(){return As}function fse(){return As=di>0?ar(Bf,--di):0,hf--,As===10&&(hf=1,Aw--),As}function Fi(){return As=di<u6?ar(Bf,di++):0,hf++,As===10&&(hf=1,Aw++),As}function ko(){return ar(Bf,di)}function rx(){return di}function u0(e,t){return cm(Bf,e,t)}function um(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function d6(e){return Aw=hf=1,u6=po(Bf=e),di=0,[]}function h6(e){return Bf="",e}function ix(e){return c6(u0(di-1,uE(e===91?e+2:e===40?e+1:e)))}function pse(e){for(;(As=ko())&&As<33;)Fi();return um(e)>2||um(As)>3?"":" "}function gse(e,t){for(;--t&&Fi()&&!(As<48||As>102||As>57&&As<65||As>70&&As<97););return u0(e,rx()+(t<6&&ko()==32&&Fi()==32))}function uE(e){for(;Fi();)switch(As){case e:return di;case 34:case 39:e!==34&&e!==39&&uE(As);break;case 40:e===41&&uE(e);break;case 92:Fi();break}return di}function mse(e,t){for(;Fi()&&e+As!==57;)if(e+As===84&&ko()===47)break;return"/*"+u0(t,di-1)+"*"+Rw(e===47?e:Fi())}function vse(e){for(;!um(ko());)Fi();return u0(e,di)}function xse(e){return h6(ax("",null,null,null,[""],e=d6(e),0,[0],e))}function ax(e,t,n,s,r,i,a,o,l){for(var u=0,d=0,h=a,f=0,p=0,m=0,v=1,x=1,b=1,w=0,C="",E=r,y=i,k=s,T=C;x;)switch(m=w,w=Fi()){case 40:if(m!=108&&ar(T,h-1)==58){cE(T+=pn(ix(w),"&","&\f"),"&\f")!=-1&&(b=-1);break}case 34:case 39:case 91:T+=ix(w);break;case 9:case 10:case 13:case 32:T+=pse(m);break;case 92:T+=gse(rx()-1,7);continue;case 47:switch(ko()){case 42:case 47:iv(bse(mse(Fi(),rx()),t,n),l);break;default:T+="/"}break;case 123*v:o[u++]=po(T)*b;case 125*v:case 59:case 0:switch(w){case 0:case 125:x=0;case 59+d:b==-1&&(T=pn(T,/\f/g,"")),p>0&&po(T)-h&&iv(p>32?yD(T+";",s,n,h-1):yD(pn(T," ","")+";",s,n,h-2),l);break;case 59:T+=";";default:if(iv(k=CD(T,t,n,u,d,r,o,C,E=[],y=[],h),i),w===123)if(d===0)ax(T,t,k,k,E,i,h,o,y);else switch(f===99&&ar(T,3)===110?100:f){case 100:case 108:case 109:case 115:ax(e,k,k,s&&iv(CD(e,k,k,0,0,r,o,C,r,E=[],h),y),r,y,h,o,s?E:y);break;default:ax(T,k,k,k,[""],y,0,o,y)}}u=d=p=0,v=b=1,C=T="",h=a;break;case 58:h=1+po(T),p=m;default:if(v<1){if(w==123)--v;else if(w==125&&v++==0&&fse()==125)continue}switch(T+=Rw(w),w*v){case 38:b=d>0?1:(T+="\f",-1);break;case 44:o[u++]=(po(T)-1)*b,b=1;break;case 64:ko()===45&&(T+=ix(Fi())),f=ko(),d=h=po(C=T+=vse(rx())),w++;break;case 45:m===45&&po(T)==2&&(v=0)}}return i}function CD(e,t,n,s,r,i,a,o,l,u,d){for(var h=r-1,f=r===0?i:[""],p=H_(f),m=0,v=0,x=0;m<s;++m)for(var b=0,w=cm(e,h+1,h=ose(v=a[m])),C=e;b<p;++b)(C=c6(v>0?f[b]+" "+w:pn(w,/&\f/g,f[b])))&&(l[x++]=C);return Fw(e,t,n,r===0?B_:o,l,u,d)}function bse(e,t,n){return Fw(e,t,n,o6,Rw(hse()),cm(e,2,-2),0)}function yD(e,t,n,s){return Fw(e,t,n,j_,cm(e,0,s),cm(e,s+1,-1),s)}function Ih(e,t){for(var n="",s=H_(e),r=0;r<s;r++)n+=t(e[r],r,e,t)||"";return n}function wse(e,t,n,s){switch(e.type){case ase:if(e.children.length)break;case ise:case j_:return e.return=e.return||e.value;case o6:return"";case l6:return e.return=e.value+"{"+Ih(e.children,s)+"}";case B_:e.value=e.props.join(",")}return po(n=Ih(e.children,s))?e.return=e.value+"{"+n+"}":""}function Cse(e){var t=H_(e);return function(n,s,r,i){for(var a="",o=0;o<t;o++)a+=e[o](n,s,r,i)||"";return a}}function yse(e){return function(t){t.root||(t=t.return)&&e(t)}}function Sse(e){var t=Object.create(null);return function(n){return t[n]===void 0&&(t[n]=e(n)),t[n]}}var Ese=function(t,n,s){for(var r=0,i=0;r=i,i=ko(),r===38&&i===12&&(n[s]=1),!um(i);)Fi();return u0(t,di)},kse=function(t,n){var s=-1,r=44;do switch(um(r)){case 0:r===38&&ko()===12&&(n[s]=1),t[s]+=Ese(di-1,n,s);break;case 2:t[s]+=ix(r);break;case 4:if(r===44){t[++s]=ko()===58?"&\f":"",n[s]=t[s].length;break}default:t[s]+=Rw(r)}while(r=Fi());return t},_se=function(t,n){return h6(kse(d6(t),n))},SD=new WeakMap,Tse=function(t){if(!(t.type!=="rule"||!t.parent||t.length<1)){for(var n=t.value,s=t.parent,r=t.column===s.column&&t.line===s.line;s.type!=="rule";)if(s=s.parent,!s)return;if(!(t.props.length===1&&n.charCodeAt(0)!==58&&!SD.get(s))&&!r){SD.set(t,!0);for(var i=[],a=_se(n,i),o=s.props,l=0,u=0;l<a.length;l++)for(var d=0;d<o.length;d++,u++)t.props[u]=i[l]?a[l].replace(/&\f/g,o[d]):o[d]+" "+a[l]}}},Rse=function(t){if(t.type==="decl"){var n=t.value;n.charCodeAt(0)===108&&n.charCodeAt(2)===98&&(t.return="",t.value="")}};function f6(e,t){switch(cse(e,t)){case 5103:return fn+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return fn+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return fn+e+Kx+e+vr+e+e;case 6828:case 4268:return fn+e+vr+e+e;case 6165:return fn+e+vr+"flex-"+e+e;case 5187:return fn+e+pn(e,/(\w+).+(:[^]+)/,fn+"box-$1$2"+vr+"flex-$1$2")+e;case 5443:return fn+e+vr+"flex-item-"+pn(e,/flex-|-self/,"")+e;case 4675:return fn+e+vr+"flex-line-pack"+pn(e,/align-content|flex-|-self/,"")+e;case 5548:return fn+e+vr+pn(e,"shrink","negative")+e;case 5292:return fn+e+vr+pn(e,"basis","preferred-size")+e;case 6060:return fn+"box-"+pn(e,"-grow","")+fn+e+vr+pn(e,"grow","positive")+e;case 4554:return fn+pn(e,/([^-])(transform)/g,"$1"+fn+"$2")+e;case 6187:return pn(pn(pn(e,/(zoom-|grab)/,fn+"$1"),/(image-set)/,fn+"$1"),e,"")+e;case 5495:case 3959:return pn(e,/(image-set\([^]*)/,fn+"$1$`$1");case 4968:return pn(pn(e,/(.+:)(flex-)?(.*)/,fn+"box-pack:$3"+vr+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+fn+e+e;case 4095:case 3583:case 4068:case 2532:return pn(e,/(.+)-inline(.+)/,fn+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(po(e)-1-t>6)switch(ar(e,t+1)){case 109:if(ar(e,t+4)!==45)break;case 102:return pn(e,/(.+:)(.+)-([^]+)/,"$1"+fn+"$2-$3$1"+Kx+(ar(e,t+3)==108?"$3":"$2-$3"))+e;case 115:return~cE(e,"stretch")?f6(pn(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(ar(e,t+1)!==115)break;case 6444:switch(ar(e,po(e)-3-(~cE(e,"!important")&&10))){case 107:return pn(e,":",":"+fn)+e;case 101:return pn(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+fn+(ar(e,14)===45?"inline-":"")+"box$3$1"+fn+"$2$3$1"+vr+"$2box$3")+e}break;case 5936:switch(ar(e,t+11)){case 114:return fn+e+vr+pn(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return fn+e+vr+pn(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return fn+e+vr+pn(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return fn+e+vr+e+e}return e}var Ase=function(t,n,s,r){if(t.length>-1&&!t.return)switch(t.type){case j_:t.return=f6(t.value,t.length);break;case l6:return Ih([bp(t,{value:pn(t.value,"@","@"+fn)})],r);case B_:if(t.length)return dse(t.props,function(i){switch(use(i,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return Ih([bp(t,{props:[pn(i,/:(read-\w+)/,":"+Kx+"$1")]})],r);case"::placeholder":return Ih([bp(t,{props:[pn(i,/:(plac\w+)/,":"+fn+"input-$1")]}),bp(t,{props:[pn(i,/:(plac\w+)/,":"+Kx+"$1")]}),bp(t,{props:[pn(i,/:(plac\w+)/,vr+"input-$1")]})],r)}return""})}},Fse=[Ase],Dse=function(t){var n=t.key;if(n==="css"){var s=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(s,function(v){var x=v.getAttribute("data-emotion");x.indexOf(" ")!==-1&&(document.head.appendChild(v),v.setAttribute("data-s",""))})}var r=t.stylisPlugins||Fse,i={},a,o=[];a=t.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+n+' "]'),function(v){for(var x=v.getAttribute("data-emotion").split(" "),b=1;b<x.length;b++)i[x[b]]=!0;o.push(v)});var l,u=[Tse,Rse];{var d,h=[wse,yse(function(v){d.insert(v)})],f=Cse(u.concat(r,h)),p=function(x){return Ih(xse(x),f)};l=function(x,b,w,C){d=w,p(x?x+"{"+b.styles+"}":b.styles),C&&(m.inserted[b.name]=!0)}}var m={key:n,sheet:new rse({key:n,container:a,nonce:t.nonce,speedy:t.speedy,prepend:t.prepend,insertionPoint:t.insertionPoint}),nonce:t.nonce,inserted:i,registered:{},insert:l};return m.sheet.hydrate(o),m},cy={exports:{}},xn={};/** @license React v16.13.1
416
416
  * react-is.production.min.js
417
417
  *
418
418
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -449,7 +449,7 @@ try {
449
449
  } catch(e){}})();`}},"mui-color-scheme-init")}function ure(){}const dre=({key:e,storageWindow:t})=>(!t&&typeof window<"u"&&(t=window),{get(n){if(typeof window>"u")return;if(!t)return n;let s;try{s=t.localStorage.getItem(e)}catch{}return s||n},set:n=>{if(t)try{t.localStorage.setItem(e,n)}catch{}},subscribe:n=>{if(!t)return ure;const s=r=>{const i=r.newValue;r.key===e&&n(i)};return t.addEventListener("storage",s),()=>{t.removeEventListener("storage",s)}}});function hy(){}function ND(e){if(typeof window<"u"&&typeof window.matchMedia=="function"&&e==="system")return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function E6(e,t){if(e.mode==="light"||e.mode==="system"&&e.systemMode==="light")return t("light");if(e.mode==="dark"||e.mode==="system"&&e.systemMode==="dark")return t("dark")}function hre(e){return E6(e,t=>{if(t==="light")return e.lightColorScheme;if(t==="dark")return e.darkColorScheme})}function fre(e){const{defaultMode:t="light",defaultLightColorScheme:n,defaultDarkColorScheme:s,supportedColorSchemes:r=[],modeStorageKey:i=V_,colorSchemeStorageKey:a=W_,storageWindow:o=typeof window>"u"?void 0:window,storageManager:l=dre,noSsr:u=!1}=e,d=r.join(","),h=r.length>1,f=g.useMemo(()=>l?.({key:i,storageWindow:o}),[l,i,o]),p=g.useMemo(()=>l?.({key:`${a}-light`,storageWindow:o}),[l,a,o]),m=g.useMemo(()=>l?.({key:`${a}-dark`,storageWindow:o}),[l,a,o]),[v,x]=g.useState(()=>{const P=f?.get(t)||t,A=p?.get(n)||n,N=m?.get(s)||s;return{mode:P,systemMode:ND(P),lightColorScheme:A,darkColorScheme:N}}),[b,w]=g.useState(u||!h);g.useEffect(()=>{w(!0)},[]);const C=hre(v),E=g.useCallback(P=>{x(A=>{if(P===A.mode)return A;const N=P??t;return f?.set(N),{...A,mode:N,systemMode:ND(N)}})},[f,t]),y=g.useCallback(P=>{P?typeof P=="string"?P&&!d.includes(P)?console.error(`\`${P}\` does not exist in \`theme.colorSchemes\`.`):x(A=>{const N={...A};return E6(A,M=>{M==="light"&&(p?.set(P),N.lightColorScheme=P),M==="dark"&&(m?.set(P),N.darkColorScheme=P)}),N}):x(A=>{const N={...A},M=P.light===null?n:P.light,I=P.dark===null?s:P.dark;return M&&(d.includes(M)?(N.lightColorScheme=M,p?.set(M)):console.error(`\`${M}\` does not exist in \`theme.colorSchemes\`.`)),I&&(d.includes(I)?(N.darkColorScheme=I,m?.set(I)):console.error(`\`${I}\` does not exist in \`theme.colorSchemes\`.`)),N}):x(A=>(p?.set(n),m?.set(s),{...A,lightColorScheme:n,darkColorScheme:s}))},[d,p,m,n,s]),k=g.useCallback(P=>{v.mode==="system"&&x(A=>{const N=P?.matches?"dark":"light";return A.systemMode===N?A:{...A,systemMode:N}})},[v.mode]),T=g.useRef(k);return T.current=k,g.useEffect(()=>{if(typeof window.matchMedia!="function"||!h)return;const P=(...N)=>T.current(...N),A=window.matchMedia("(prefers-color-scheme: dark)");return A.addListener(P),P(A),()=>{A.removeListener(P)}},[h]),g.useEffect(()=>{if(h){const P=f?.subscribe(M=>{(!M||["light","dark","system"].includes(M))&&E(M||t)})||hy,A=p?.subscribe(M=>{(!M||d.match(M))&&y({light:M})})||hy,N=m?.subscribe(M=>{(!M||d.match(M))&&y({dark:M})})||hy;return()=>{P(),A(),N()}}},[y,E,d,t,o,h,f,p,m]),{...v,mode:b?v.mode:void 0,systemMode:b?v.systemMode:void 0,colorScheme:b?C:void 0,setMode:E,setColorScheme:y}}const pre="*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}";function gre(e){const{themeId:t,theme:n={},modeStorageKey:s=V_,colorSchemeStorageKey:r=W_,disableTransitionOnChange:i=!1,defaultColorScheme:a,resolveTheme:o}=e,l={allColorSchemes:[],colorScheme:void 0,darkColorScheme:void 0,lightColorScheme:void 0,mode:void 0,setColorScheme:()=>{},setMode:()=>{},systemMode:void 0},u=g.createContext(void 0),d=()=>g.useContext(u)||l,h={},f={};function p(b){const{children:w,theme:C,modeStorageKey:E=s,colorSchemeStorageKey:y=r,disableTransitionOnChange:k=i,storageManager:T,storageWindow:P=typeof window>"u"?void 0:window,documentNode:A=typeof document>"u"?void 0:document,colorSchemeNode:N=typeof document>"u"?void 0:document.documentElement,disableNestedContext:M=!1,disableStyleSheetGeneration:I=!1,defaultMode:H="system",noSsr:G}=b,j=g.useRef(!1),J=$_(),Y=g.useContext(u),oe=!!Y&&!M,U=g.useMemo(()=>C||(typeof n=="function"?n():n),[C]),te=U[t],le=te||U,{colorSchemes:R=h,components:L=f,cssVarPrefix:D}=le,W=Object.keys(R).filter(dt=>!!R[dt]).join(","),Z=g.useMemo(()=>W.split(","),[W]),se=typeof a=="string"?a:a.light,ae=typeof a=="string"?a:a.dark,re=R[se]&&R[ae]?H:R[le.defaultColorScheme]?.palette?.mode||le.palette?.mode,{mode:Q,setMode:pe,systemMode:O,lightColorScheme:me,darkColorScheme:ke,colorScheme:He,setColorScheme:ie}=fre({supportedColorSchemes:Z,defaultLightColorScheme:se,defaultDarkColorScheme:ae,modeStorageKey:E,colorSchemeStorageKey:y,defaultMode:re,storageManager:T,storageWindow:P,noSsr:G});let de=Q,Pe=He;oe&&(de=Y.mode,Pe=Y.colorScheme);const Qe=g.useMemo(()=>{const dt=Pe||le.defaultColorScheme,Et=le.generateThemeVars?.()||le.vars,Lt={...le,components:L,colorSchemes:R,cssVarPrefix:D,vars:Et};if(typeof Lt.generateSpacing=="function"&&(Lt.spacing=Lt.generateSpacing()),dt){const nn=R[dt];nn&&typeof nn=="object"&&Object.keys(nn).forEach(vt=>{nn[vt]&&typeof nn[vt]=="object"?Lt[vt]={...Lt[vt],...nn[vt]}:Lt[vt]=nn[vt]})}return o?o(Lt):Lt},[le,Pe,L,R,D]),Ae=le.colorSchemeSelector;ere(()=>{if(Pe&&N&&Ae&&Ae!=="media"){const dt=Ae;let Et=Ae;if(dt==="class"&&(Et=".%s"),dt==="data"&&(Et="[data-%s]"),dt?.startsWith("data-")&&!dt.includes("%s")&&(Et=`[${dt}="%s"]`),Et.startsWith("."))N.classList.remove(...Z.map(Lt=>Et.substring(1).replace("%s",Lt))),N.classList.add(Et.substring(1).replace("%s",Pe));else{const Lt=Et.replace("%s",Pe).match(/\[([^\]]+)\]/);if(Lt){const[nn,vt]=Lt[1].split("=");vt||Z.forEach(Wt=>{N.removeAttribute(nn.replace(Pe,Wt))}),N.setAttribute(nn,vt?vt.replace(/"|'/g,""):"")}else N.setAttribute(Et,Pe)}}},[Pe,Ae,N,Z]),g.useEffect(()=>{let dt;if(k&&j.current&&A){const Et=A.createElement("style");Et.appendChild(A.createTextNode(pre)),A.head.appendChild(Et),window.getComputedStyle(A.body),dt=setTimeout(()=>{A.head.removeChild(Et)},1)}return()=>{clearTimeout(dt)}},[Pe,k,A]),g.useEffect(()=>(j.current=!0,()=>{j.current=!1}),[]);const ve=g.useMemo(()=>({allColorSchemes:Z,colorScheme:Pe,darkColorScheme:ke,lightColorScheme:me,mode:de,setColorScheme:ie,setMode:pe,systemMode:O}),[Z,Pe,ke,me,de,ie,pe,O,Qe.colorSchemeSelector]);let Ze=!0;(I||le.cssVariables===!1||oe&&J?.cssVarPrefix===D)&&(Ze=!1);const gt=c.jsxs(g.Fragment,{children:[c.jsx(S6,{themeId:te?t:void 0,theme:Qe,children:w}),Ze&&c.jsx(Qse,{styles:Qe.generateStyleSheets?.()||[]})]});return oe?gt:c.jsx(u.Provider,{value:ve,children:gt})}const m=typeof a=="string"?a:a.light,v=typeof a=="string"?a:a.dark;return{CssVarsProvider:p,useColorScheme:d,getInitColorSchemeScript:b=>cre({colorSchemeStorageKey:r,defaultLightColorScheme:m,defaultDarkColorScheme:v,modeStorageKey:s,...b})}}function fy({theme:e,...t}){const n=Ph in e?e[Ph]:void 0;return c.jsx(S6,{...t,themeId:n?Ph:void 0,theme:n||e})}const av={colorSchemeStorageKey:"mui-color-scheme",defaultLightColorScheme:"light",defaultDarkColorScheme:"dark",modeStorageKey:"mui-mode"},{CssVarsProvider:mre}=gre({themeId:Ph,theme:()=>uV({cssVariables:!0}),colorSchemeStorageKey:av.colorSchemeStorageKey,modeStorageKey:av.modeStorageKey,defaultColorScheme:{light:av.defaultLightColorScheme,dark:av.defaultDarkColorScheme},resolveTheme:e=>{const t={...e,typography:dV(e.palette,e.typography)};return t.unstable_sx=function(s){return hV({sx:s,theme:this})},t}}),vre=mre;function xre({theme:e,...t}){if(typeof e=="function")return c.jsx(fy,{theme:e,...t});const n=Ph in e?e[Ph]:e;return"colorSchemes"in n?c.jsx(vre,{theme:e,...t}):"vars"in n?c.jsx(fy,{theme:e,...t}):c.jsx(fy,{theme:{...e,vars:null},...t})}function py(e,t){const[n,s]=g.useState(!1);return g.useEffect(()=>{if(!e){s(!1);return}const r=setTimeout(()=>s(!0),t);return()=>clearTimeout(r)},[e,t]),n}const MD=/^Error invoking remote method '[^']+':\s*/,bre=/^browser_unavailable:\s+/;function z_(e){let n=(e instanceof Error?e.message:String(e)).trim();for(;MD.test(n);)n=n.replace(MD,"").trim();return n.replace(bre,"").trim()}const gy="The app could not reach the update server. Check this machine's connection, then try again.",OD={download:"The update could not be downloaded. Check this machine's connection, then start the download again.",install:"The update could not be installed. Check this machine's connection, then start it again from the update panel.",quit:"The app could not quit to finish the install. Quit the app yourself, then let the update finish."},wre="The update check could not finish. The app will try again at its next check.",Cre=72,yre=400,k6=/https?:\/\/|\b(?:net::)?(?:ERR_[A-Z0-9_]+|[A-Z]{2,}_[A-Z_]+)\b|\bE[A-Z]{3,}\b|HttpError|(?:\b[45]\d\d\s+[A-Z][a-z]|:\s*[45]\d\d\b)/,_6=/^(Error downloading update|Error starting the update|Error quitting for the update)\b/i;function Sre(e){switch(_6.exec(e)?.[1]?.toLowerCase()){case"error downloading update":return"download";case"error starting the update":return"install";case"error quitting for the update":return"quit";default:return null}}function Ere(e){return e.replace(_6,"").replace(Rre,"").trim()}const kre=[],_re=/[:\uff1a\u2014]+$/,Tre=/\s+/,Rre=/^[:\uff1a\s]+/;function T6(e){const t=f3(e).trim(),n=Sre(t),s=vV(t);if(s===null){if(n!==null){const l=Ere(t);return{sentence:OD[n],detail:l===""?null:l,action:null}}return Fre(t)?{sentence:t,detail:null,action:null}:{sentence:wre,detail:t===""?null:t,action:null}}const r=Are(s);if(n!==null)return{sentence:OD[n],detail:r,action:null};const i="check";if(!s.clause)return{sentence:gy,detail:r,action:i};const a=t.slice(0,s.start),o=t.slice(s.end).trim();return!LD(a)||o!==""&&!LD(o)?{sentence:gy,detail:r,action:i}:{sentence:`${a}${gy}${t.slice(s.end)}`,detail:r,action:i}}function Are(e){if(e.code.startsWith("net::"))return e.code;const t=e.clauseText.trim();return t===""||t===e.code?null:t}function LD(e){const t=e.trim().replace(_re,"").trim();return t===""?!0:t.includes(`
450
450
  `)||t.length>Cre||k6.test(t)?!1:kre.includes(t.toLowerCase())}function Fre(e){const t=e.trim();return t===""||t.length>yre||k6.test(t)?!1:t.split(Tre).length>=4}function q_(e){return e.phase==="update"?e.message:Dre(e.message)}function Dre(e){return T6(e).sentence}function tl(e){return f3(z_(e))}const Pre=/cannot find .* in the latest release artifacts/i;function BD(e){return Pre.test(e)?"muted":"show"}const my=12e3,Ire=5e3,R6=()=>({firstNegativeAt:null});function Nre(e,t){return t.isOnline?{state:R6(),report:!1}:e.firstNegativeAt===null?{state:{firstNegativeAt:t.at},report:!1}:{state:e,report:t.at-e.firstNegativeAt>=Ire}}const Mre=()=>{const e=os(),t=yt(e.data,"auth"),n=Zm(t),{shouldEnableQuery:s}=qk(),r=Os({queryKey:["open-credentials"],enabled:!t&&!e.isPending&&s({bypassInternetCheck:!0}),queryFn:()=>bV.listOpenCredentials(ws.baseUrl),staleTime:5e3,retry:!1}),{isModalComplete:i,isModalActive:a,activateModalOnboarding:o,deactivateModalOnboarding:l,resetOnboarding:u}=Kg();let d;e.isPending?d={status:"loading"}:t?n.isSuccess?d={status:"ready",providers:n.data}:n.isError?d={status:"failed"}:d={status:"loading"}:d={status:"unavailable"};let h;t||e.isPending?h={status:"loading"}:r.isSuccess&&r.data?h={status:"ready",keys:r.data.keys}:r.isError?h={status:"error"}:h={status:"loading"};const p=xV({onboardingComplete:i,census:d,legacy:h})==="first_time";return g.useEffect(()=>{p&&!a&&o()},[p,a,o]),{isFirstTimeUser:p,isOnboardingActive:a,activateOnboarding:o,deactivateOnboarding:l,resetOnboarding:u}},A6=()=>{const e=hn(),t=wV(s=>s.clearConversation),n=CV(s=>s.clearConversationHistory);return Cs({mutationFn:async({agentId:s})=>ha(ws.baseUrl).agents.clearAgentConversation(s),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:["agent",r.agentId,"conversation"]}),e.invalidateQueries({queryKey:["conversation-messages",r.agentId]}),t(r.agentId),n(r.agentId),vs("Conversation cleared")},onError:s=>{console.error("Error clearing agent conversation:",s),$t(`Failed to clear conversation: ${s instanceof Error?s.message:"Unknown error"}`)}})},Ore=()=>{const{agentId:e}=p3(),t=Yr(),n=()=>{const i=Kk();return el(i,"/chat")?"chat":"agents"};return{agentId:e,navigateToAgent:(i,a)=>{if(!i)return;const o=a||n();t(`/${o}/${i}`)},clearAgentId:i=>{const a=i||n();t(`/${a}`)}}},Lre=()=>{const e=Kk();return el(e,"/chat")?"chat":el(e,"/agents")?"agents":el(e,"/settings")?"settings":el(e,"/agent-hub")?"agent-hub":el(e,"/schedules")?"schedules":el(e,"/projects")?"projects":el(e,"/browser")?"browser":el(e,"/mesh")?"mesh":"chat"},F6=(e=50,t,n)=>{const s=g.useRef(null),r=t||s,[i,a]=g.useState(!1),o=g.useRef(!1),l=g.useRef(0),u=g.useRef(n),d=g.useCallback(()=>{const p=r.current;if(!p)return;const{scrollTop:m,scrollHeight:v,clientHeight:x}=p,b=Math.abs(m),C=v>x&&b>e;a(C)},[e,r]),h=g.useCallback(()=>{const p=r.current;p&&requestAnimationFrame(()=>{p.scrollTo({top:0,behavior:"smooth"}),requestAnimationFrame(d)})},[r,d]),f=g.useCallback(()=>{!r.current||o.current||(o.current=!0,requestAnimationFrame(()=>{d(),o.current=!1}))},[r,d]);return g.useEffect(()=>{const p=r.current;if(!p)return;u.current!==n&&(a(!1),l.current=0,u.current=n),p.addEventListener("scroll",f,{passive:!0});const m=requestAnimationFrame(d),v=window.setTimeout(d,100),x=window.setTimeout(d,500);return()=>{p.removeEventListener("scroll",f),cancelAnimationFrame(m),clearTimeout(v),clearTimeout(x)}},[r,n,f,d]),g.useEffect(()=>{const p=()=>{d()};return window.addEventListener("resize",p,{passive:!0}),()=>{window.removeEventListener("resize",p)}},[d]),g.useEffect(()=>{const p=r.current;if(!p)return;const m=new ResizeObserver(()=>{d()});return m.observe(p),()=>{m.disconnect()}},[r,d]),{containerRef:r,isFarFromBottom:i,scrollToBottom:h}};function jD(e){const t=g.useRef(e);return g.useEffect(()=>{t.current=e}),g.useCallback((...n)=>t.current(...n),[])}const Bre=()=>{const e=hn(),t=ha(ws.baseUrl);return Cs({mutationFn:async({agentId:n,update:s})=>{try{const r=await t.agents.updateAgent(n,s);if(r.status>=400)throw new Error(r.message||`Failed to update agent ${n}`);return r.result}catch(r){const i=r instanceof Error?r.message:`An unknown error occurred while updating agent ${n}`;throw $t(i),r}},onSuccess:async(n,{agentId:s})=>{await e.invalidateQueries({queryKey:hl,refetchType:"none"}),e.setQueryData([...hl,s],r=>r&&{...r,...n}),await e.refetchQueries({queryKey:hl,type:"all"}),vs("Agent updated")},onError:n=>{console.error("Error updating agent:",n)}})},D6=()=>{const e=hn(),t=ha(ws.baseUrl);return Cs({mutationFn:async n=>{try{const s=await t.config.updateConfig(n);if(s.status>=400)throw new Error(s.message||"Failed to update configuration");return s.result}catch(s){const r=s instanceof Error?s.message:"An unknown error occurred while updating configuration";throw $t(r),s}},onSuccess:async n=>{await e.invalidateQueries({queryKey:RC,refetchType:"none"}),e.setQueryData(RC,s=>s&&{...s,...n}),await e.refetchQueries({queryKey:RC,type:"all"}),vs("Configuration updated")},onError:n=>{console.error("Error updating configuration:",n)}})},jre=e=>{const t=hn(),n=ha(ws.baseUrl);return Cs({mutationFn:async s=>{try{const r=await n.credentials.updateCredential(s);if(r.status>=400)throw new Error(r.message||"Failed to update credential");return r}catch(r){const i=r instanceof Error?r.message:"An unknown error occurred while updating credential";throw $t(i),r}},onSuccess:async(s,r)=>{await t.invalidateQueries({queryKey:AC,refetchType:"none"}),t.setQueryData(AC,i=>i&&(i.keys.includes(r.key)?i:{...i,keys:[...i.keys,r.key]})),await t.refetchQueries({queryKey:AC,type:"all"})},onError:s=>{console.error("Error updating credential:",s)}})},Hre=({open:e,onClose:t,onAgentCreated:n})=>{const s=Yr(),[r,i]=g.useState(""),[a,o]=g.useState(""),l=g.useRef(null),u=()=>{t(),setTimeout(()=>{s("/agent-hub")},200)},d=tse(),h=async x=>{if(x.preventDefault(),!r.trim())return;const b={name:r.trim(),description:a.trim()||void 0};try{const w=await d.mutateAsync(b),C=w?.name?.trim()||b.name;i(""),o(""),n&&w?.id&&n({id:w.id,name:C}),t()}catch(w){console.error("Failed to create agent:",w)}},f=d.isPending,p=f||!r.trim(),m=c.jsxs(c.Fragment,{children:[c.jsx(kc,{size:19,className:"text-accent","aria-hidden":"true"}),"Create new agent"]}),v=c.jsxs(c.Fragment,{children:[c.jsx(Qm,{onClick:t,disabled:f,"data-tour-tag":"create-agent-dialog-cancel-button",children:"Cancel"}),c.jsx(Jm,{type:"submit",form:"create-agent-form",disabled:p,startIcon:f?c.jsx(Rn,{}):null,children:"Create agent"})]});return c.jsxs(Mc,{open:e,onClose:t,title:m,actions:v,maxWidth:"sm",dataTourTag:"create-agent-dialog",dialogProps:{onOpenAutoFocus:x=>{x.preventDefault(),l.current?.focus()}},children:[c.jsx("p",{className:"text-body-sm text-ink-muted",children:"Configure your new AI assistant with a name and optional description"}),c.jsxs(ce,{variant:"link",onClick:u,className:"mt-1 mb-4 text-body-sm",children:["Browse Agent hub to fetch ready-made agents",c.jsx(ac,{"aria-hidden":"true"})]}),c.jsx("form",{id:"create-agent-form",onSubmit:h,children:c.jsxs("div",{className:"flex flex-col gap-5",children:[c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsx(tr,{htmlFor:"create-agent-name",children:"Agent name"}),c.jsx(Ds,{ref:l,id:"create-agent-name",inputSize:"lg",value:r,onChange:x=>i(x.target.value),required:!0,disabled:f,placeholder:"Enter a name for your agent"})]}),c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsx(tr,{htmlFor:"create-agent-description",children:"Description (optional)"}),c.jsx(m_,{id:"create-agent-description",rows:2,value:a,onChange:x=>o(x.target.value),disabled:f,placeholder:"Describe what this agent does"})]})]})})]})},HD=({value:e,label:t,onSave:n,multiline:s=!1,rows:r=4,placeholder:i="Enter value...",icon:a,isSaving:o=!1,readOnly:l=!1})=>{const[u,d]=g.useState(!1),[h,f]=g.useState(e),[p,m]=g.useState(e),[v,x]=g.useState(e),[b,w]=g.useState(!1),[C,E]=g.useState(!1),y=g.useRef(null),k=g.useRef(null),T=g.useId(),P=o||b;g.useEffect(()=>{u||(f(e),m(e)),x(e)},[e,u]),g.useEffect(()=>{if(u){const R=setTimeout(()=>{y.current&&(y.current.focus(),y.current.select())},0);return()=>clearTimeout(R)}},[u]);const A=()=>{l||d(!0)},N=R=>{f(R.target.value)},M=()=>{f(v),d(!1)},I=async()=>{if(!(P||h===v)){w(!0);try{await n(h),x(h),m(h),d(!1)}catch(R){console.error("Failed to save editable field:",R)}finally{w(!1)}}},H=R=>{setTimeout(()=>{const L=R.relatedTarget;!(k.current?.contains(L)??!1)&&h===v&&d(!1)},0)},G=R=>{R.key==="Escape"?M():R.key==="Enter"&&(!s||s&&(R.ctrlKey||R.metaKey))&&(R.preventDefault(),h!==v?I():d(!1))},j=R=>{R.preventDefault(),R.stopPropagation(),!(l||P||C)&&(E(!0),w(!0),f(""),m(""),n("").then(()=>{x(""),d(!1)}).catch(L=>{console.error("Failed to clear field:",L),f(v),m(v)}).finally(()=>{E(!1),w(!1)}))},J=R=>{l||(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),A())},Y=h!==v,oe=!l&&!P&&v!=="",U=oe&&!Y,te=P?"pr-20":U?"pr-28":Y?"pr-18":"pr-10",le="opacity-0 transition-opacity duration-fast ease-out-quart group-hover:opacity-100 group-focus-within:opacity-100";return c.jsxs("div",{children:[(t||a)&&c.jsxs(tr,{htmlFor:T,className:"mb-1.5 flex items-center gap-2 text-ink-muted",children:[a,t]}),u?c.jsxs("div",{className:"relative",children:[s?c.jsx(m_,{id:T,ref:y,value:h,onChange:N,onBlur:H,onKeyDown:G,rows:r,placeholder:i,autoComplete:"off",className:_("min-h-9",te)}):c.jsx(Ds,{id:T,ref:y,value:h,onChange:N,onBlur:H,onKeyDown:G,placeholder:i,autoComplete:"off",className:_("text-ellipsis",te)}),c.jsx("div",{ref:k,className:_("absolute right-1.5 z-10 flex items-center gap-1",s?"top-1.5":"top-1/2 -translate-y-1/2"),children:P?c.jsx("span",{className:"px-2 text-ink-dim text-meta",children:C?"Clearing...":"Saving..."}):c.jsxs(c.Fragment,{children:[Y&&c.jsx(ce,{variant:"ghost",size:"icon-sm",onClick:I,title:"Save changes (Enter)","aria-label":`Save ${t}`,className:"text-success hover:bg-success-wash hover:text-success",children:c.jsx(Ls,{})}),c.jsx(ce,{variant:"ghost",size:"icon-sm",onClick:M,title:"Cancel (Escape)","aria-label":`Cancel editing ${t}`,className:"text-danger hover:bg-danger-wash hover:text-danger",children:c.jsx(On,{})}),U&&c.jsxs(ce,{variant:"danger",size:"sm",onClick:j,title:"Clear field","aria-label":`Clear ${t}`,children:[c.jsx(mD,{}),"Clear"]})]})})]}):c.jsxs("div",{className:"group relative w-full",children:[c.jsx("button",{type:"button",onClick:A,"aria-label":`Current value: ${p||i}.${l?"":" Click to edit."}`,onKeyDown:J,disabled:l,className:_("flex w-full rounded-sm border border-control bg-surface px-3 text-left text-body-sm text-ink","transition-colors duration-fast ease-out-quart","disabled:cursor-default disabled:border-hairline disabled:bg-sunken disabled:text-ink-disabled",s?"min-h-8 items-start py-2":"h-8 items-center",!l&&"cursor-pointer hover:bg-elevated"),children:p?c.jsx("span",{className:_("min-w-0 flex-1 pr-8",s?"whitespace-pre-wrap break-words":"truncate"),children:p}):c.jsx("span",{className:"min-w-0 flex-1 truncate pr-8 text-ink-dim",children:i})}),!l&&c.jsx(ce,{variant:"ghost",size:"icon-sm",onClick:A,title:"Edit","aria-label":`Edit ${t}`,tabIndex:-1,className:_("absolute top-1/2 right-1.5 -translate-y-1/2",le),children:c.jsx(Yk,{})}),oe&&c.jsxs(ce,{variant:"danger",size:"sm",onClick:j,title:"Clear field","aria-label":`Clear ${t}`,tabIndex:-1,className:_("absolute top-1/2 right-9 -translate-y-1/2",le),children:[c.jsx(mD,{}),"Clear"]})]})]})},P6=({size:e=24,className:t})=>c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:t,"aria-hidden":"true",children:[c.jsx("path",{d:"M12 2 20.7 7 20.7 17 12 22 3.3 17 3.3 7Z"}),c.jsx("path",{d:"M12 12V6.2"}),c.jsx("path",{d:"m12 12 5-2.9"}),c.jsx("path",{d:"m12 12 5 2.9"}),c.jsx("path",{d:"M12 12v5.8"}),c.jsx("path",{d:"m12 12-5 2.9"}),c.jsx("path",{d:"m12 12-5-2.9"})]}),Yd=({value:e,label:t,description:n,min:s,max:r,step:i=1,unit:a,onChange:o,icon:l,isSaving:u=!1})=>{const[d,h]=g.useState(e),[f,p]=g.useState(e.toString()),[m,v]=g.useState(!1),x=g.useId(),b=`${x}-label`,w=`${x}-description`,C=g.useRef(d);C.current=d,g.useEffect(()=>{m||(h(e),p(e.toString()))},[e,m]);const E=g.useCallback(async()=>{if(u)return;const H=Math.max(s,Math.min(r,C.current));if(h(H),p(H.toString()),H!==e)try{await o(H)}catch(G){console.error("Error updating setting via slider:",G),h(e),p(e.toString())}},[u,s,r,e,o]),y=H=>{const G=Number(H.target.value);h(G),p(G.toString())},k=()=>{const H=()=>{window.removeEventListener("pointerup",H),E()};window.addEventListener("pointerup",H)},T=H=>{(H.key.startsWith("Arrow")||H.key==="Home"||H.key==="End")&&E()},P=H=>{p(H.target.value)},A=async()=>{if(v(!1),u)return;let H=Number.parseFloat(f);if(Number.isNaN(H))H=e;else if(H=Math.max(s,Math.min(r,H)),i){H=Math.round(H/i)*i;const G=i.toString().split(".")[1]?.length||0;H=Number.parseFloat(H.toFixed(G))}if(H!==e){h(H),p(H.toString());try{await o(H)}catch(G){console.error("Error updating setting via input:",G),h(e),p(e.toString())}}else h(e),p(e.toString())},N=()=>{v(!0)},M=H=>{H.key==="Enter"&&H.target.blur()},I=r>s?`${((d-s)/(r-s)*100).toFixed(2)}%`:"0%";return c.jsxs("div",{children:[c.jsxs("div",{className:"flex min-h-8 items-center justify-between gap-4",children:[c.jsxs("label",{id:b,htmlFor:`${x}-range`,className:"flex min-w-0 items-center gap-2 text-body text-ink",children:[l&&c.jsx(l,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim"}),c.jsx("span",{className:"truncate",children:t})]}),c.jsx("div",{className:"flex shrink-0 items-center gap-2",children:u?c.jsx(Rn,{size:"md",label:`Saving ${t}`}):c.jsxs(c.Fragment,{children:[c.jsx(Ds,{inputSize:"sm",type:"number",value:f,onChange:P,onBlur:A,onFocus:N,onKeyDown:M,min:s,max:r,step:i,disabled:u,"aria-labelledby":b,"aria-describedby":n?w:void 0,className:"w-18 text-right [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"}),a&&c.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:a})]})})]}),n&&c.jsx("p",{id:w,className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:n}),c.jsx("input",{id:`${x}-range`,type:"range",value:d,min:s,max:r,step:i,disabled:u,onChange:y,onPointerDown:k,onKeyUp:T,onBlur:()=>void E(),"aria-labelledby":b,"aria-describedby":n?w:void 0,style:{"--fill":I},className:"mt-3 h-4 w-full cursor-pointer appearance-none bg-transparent bg-center bg-no-repeat bg-[length:100%_6px] bg-[linear-gradient(to_right,var(--color-accent)_0_var(--fill),var(--color-sunken)_var(--fill)_100%)] disabled:cursor-not-allowed disabled:bg-none disabled:bg-sunken [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-accent [&::-webkit-slider-thumb]:transition-colors [&::-webkit-slider-thumb]:duration-fast [&::-webkit-slider-thumb]:ease-out-quart [&::-webkit-slider-thumb]:hover:bg-accent-hover disabled:[&::-webkit-slider-thumb]:bg-ink-disabled"}),c.jsxs("div",{className:"flex justify-between font-mono text-mono-sm text-ink-dim",children:[c.jsx("span",{children:s}),c.jsx("span",{children:r})]})]})};function Ure(e,t){return e&&e.version===t?e:null}function Gre(e){switch(e){case"verifying":return"Verifying the update against the app it will replace…";case"staging":return"Staging the update next to the app it will replace…";case"starting":return"Starting the installer. The app closes for a moment…";default:return"Preparing to install…"}}function $re(e){return`Local Operator updated to v${e}.`}const Vre=/\/(?![\/\d])/g,UD=e=>e.replace(Vre,"/​"),du=({detail:e,stacked:t=!1})=>{const[n,s]=g.useState(!1),r=c.jsxs(ce,{variant:"ghost",size:"sm",className:t?"-ml-2":void 0,onClick:()=>{navigator.clipboard.writeText(e).then(()=>s(!0)).catch(()=>{})},children:[n?c.jsx(Ls,{}):c.jsx(_l,{}),n?"Copied":"Copy details"]});return c.jsx("div",{className:t?"mt-4 flex flex-col items-start gap-1":"mt-4 flex items-start gap-2",children:t?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-meta text-ink-dim",children:"Details:"}),c.jsx("span",{className:"font-mono text-mono-sm break-all text-ink-dim",children:UD(e)}),r]}):c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:"Details:"}),c.jsx("span",{className:"min-w-0 flex-1 break-words font-mono text-mono-sm text-ink-dim",children:UD(e)}),r]})})},Wre=({open:e,message:t,onClose:n,autoHideDuration:s,onRetry:r,retrying:i=!1})=>{const{sentence:a,detail:o,action:l}=T6(t);return c.jsxs(Kv,{open:e,autoHideDuration:s,onClose:n,variant:"danger",action:l==="check"&&r?c.jsx(ce,{variant:"primary",size:"sm",onClick:r,disabled:i,children:i?"Checking...":"Try again"}):null,children:[c.jsx("p",{children:a}),o!==null?c.jsx(du,{detail:o,stacked:!0}):null]})},zre=/^v/i,fE=(e,t)=>{const n=o=>o.trim().replace(zre,""),s=n(e),r=n(t);if(s===r)return!0;if(s.includes("-")||r.includes("-"))return!1;const i=s.split(".").map(Number),a=r.split(".").map(Number);for(let o=0;o<Math.max(i.length,a.length);o++){const l=i[o]??0,u=a[o]??0;if(!Number.isFinite(l)||!Number.isFinite(u))return!1;if(l>u)return!0;if(l<u)return!1}return!0},I6=e=>{const{target:t,sourceBuild:n}=e.expectation;return n?!0:t==null?!1:e.reported!=null&&fE(e.reported,t)},qre=e=>e.manual===!0&&I6({reported:e.currentVersion,expectation:e.expectation}),GD=e=>`${e.installVersion??"?"}|${e.runningVersion??"?"}`,N6="usually a few seconds, up to half a minute",Kre="The app waits up to ten minutes for them, then stops rather than cutting a turn short, so nothing in flight is cut off",Yre=`Restarting puts the server offline while it comes back - ${N6}. Nothing in flight is cut off, and sessions that are still working move onto the new build when they next stop or go idle.`,Xre=`The server is already offline, so the only cost left is the wait for it to come back - ${N6}.`,Qre=e=>e?`The server update to ${e} did not complete.`:"The server update did not complete.",Jre=e=>{const t=Math.max(1,Math.round(e/1e3)),n=(i,a)=>`${i} ${a}${i===1?"":"s"}`;if(t<60)return`Waiting ${n(t,"second")} so far`;const s=t%60,r=Math.floor(t/60);return s===0?`Waiting ${n(r,"minute")} so far`:`Waiting ${n(r,"minute")} ${n(s,"second")} so far`},Zre={"installed-bundle-not-sealed":"This app can't update itself","download-verification-failed":"The update couldn't be verified","artifact-metadata-missing":"The update couldn't be verified","insufficient-disk-space":"Not enough disk space to update","artifact-cannot-launch":"The update can't be launched"},Ta=({className:e,tone:t="notice",role:n,onClose:s,closeLabel:r="Close release details",children:i,...a})=>{const o=g.useRef(null);return g.useEffect(()=>{s&&o.current?.focus()},[s]),Eu(!0,"update-notice"),c.jsxs("div",{"data-titlebar-no-drag":"",...s?{"data-release-detail":""}:{},ref:o,tabIndex:s?-1:void 0,role:n??(t==="failed"?"alert":"status"),onKeyDown:s?l=>{l.key==="Escape"&&(l.stopPropagation(),s())}:void 0,className:_("fixed top-4 right-4 z-50 w-100 max-w-[calc(100vw-2rem)]","rounded-lg bg-elevated shadow-overlay","[&_a]:text-accent [&_a]:underline-offset-4 [&_a]:hover:underline",e),...a,children:[s?c.jsx(ce,{type:"button",variant:"ghost",size:"icon-sm",onClick:s,"aria-label":r,className:"absolute top-2 right-2 z-10",children:c.jsx(On,{"aria-hidden":"true"})}):null,c.jsx("div",{"data-release-detail-scroll":"",className:"max-h-[calc(100vh-2rem)] overflow-y-auto rounded-lg p-4",children:i})]})},lu=({children:e,tone:t="notice"})=>c.jsxs("h2",{className:_("mb-3 flex items-center gap-2 text-heading text-ink"),children:[t==="failed"&&c.jsx(Lo,{className:"size-4 shrink-0 text-danger","aria-hidden":!0}),e]}),eie=({output:e})=>{const[t,n]=g.useState(!1);return c.jsxs("div",{className:"mt-2",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("span",{className:"text-meta text-ink-dim",children:"Installer output:"}),c.jsxs(ce,{variant:"ghost",size:"sm",onClick:()=>{navigator.clipboard.writeText(e).then(()=>n(!0)).catch(()=>{})},children:[t?c.jsx(Ls,{}):c.jsx(_l,{}),t?"Copied":"Copy output"]})]}),c.jsx("pre",{className:"mt-1 max-h-40 overflow-auto whitespace-pre-wrap break-words rounded-sm bg-sunken p-2 font-mono text-mono-sm text-ink-dim",children:e})]})},tie=e=>{const t=e.indexOf(`
451
451
 
452
- `);if(t===-1)return{sentence:e,output:null};const n=e.slice(t+2).trim();return{sentence:e.slice(0,t),output:n.length>0?n:null}},ov=({command:e})=>{const[t,n]=g.useState(!1);return c.jsxs("div",{className:"mt-2 flex items-start gap-2",children:[c.jsx("code",{className:"min-w-0 flex-1 rounded-sm bg-sunken p-2 text-mono-sm break-all text-ink",children:e}),c.jsxs(ce,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(e).then(()=>n(!0)).catch(()=>{})},children:[t?c.jsx(Ls,{}):c.jsx(_l,{}),t?"Copied":"Copy command"]})]})},nie=["[&_:is(h1,h2,h3,h4,h5,h6)]:mt-3 [&_:is(h1,h2,h3,h4,h5,h6)]:mb-1 [&_:is(h1,h2,h3,h4,h5,h6)]:font-semibold [&_:is(h1,h2,h3,h4,h5,h6)]:text-ink","[&_h1]:text-heading [&_h2]:text-heading [&_h3]:text-body [&_h4]:text-body [&_h5]:text-body-sm [&_h6]:text-body-sm","[&_p]:my-1.5 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0","[&_:is(ul,ol)]:my-1.5 [&_:is(ul,ol)]:pl-5 [&_ul_li]:list-disc [&_ol_li]:list-decimal [&_li]:my-0.5","[&_code]:rounded-xs [&_code]:bg-sunken [&_code]:px-1 [&_code]:font-mono [&_code]:text-mono-sm"].join(" "),$D=({command:e,sourceBuild:t,appOwned:n=!1})=>n?null:t&&!e?c.jsx("p",{className:"mt-2 text-body text-ink",children:"This server follows this machine's checkout, so there is no command to run here."}):c.jsx("p",{className:"mt-2 text-body text-ink",children:t?"Run this in a terminal. This install was built from this machine's checkout, so `lop update` installs the published release over it - and if this machine has `lop-update`, the script that rebuilds this install from the checkout, run that afterwards to keep following it.":e?"Run this in a terminal, then check for updates again to pick up the new server version.":"Then check for updates again to pick up the new server version."}),sie=/^\d+\.\d+/,vu=e=>{if(typeof e!="string")return null;const t=e.trim();return sie.test(t)?t:null},M6=e=>e?.restartsServer??e?.restartable!==!1,rie=e=>M6(e)?e.remedy??"The app updates this install and then restarts the server it started, so nothing in flight is cut off. Sessions that are still working move onto the new build when they next stop or go idle.":"The app updates this install itself. The server you are using was started outside Local Operator, so it keeps running the old build until it restarts, and nothing in flight is dropped.",VD=e=>typeof e!="number"?"Sessions that are still running the old build will move onto the new build when they next stop or go idle.":e===0?null:e===1?"1 session is still running the old build; it will move onto the new build when it next stops or goes idle.":`${e} sessions are still running the old build; they will move onto the new build when they next stop or go idle.`,O6=({latestVersion:e,installVersion:t,runningVersion:n})=>{const s=vu(t),r=vu(n);if(s&&r&&s!==r)return`Server version ${e} is available. The install on this machine is at ${s}, and the server you are using is running ${r} until it restarts.`;const i=r??s;return i?`Server version ${e} is available. You are currently using version ${i}.`:`Server version ${e} is available.`},iie=({latestVersion:e,runningVersion:t,installVersion:n,className:s})=>e?c.jsx("p",{className:_("mb-2 text-body text-ink-muted",s),children:O6({latestVersion:e,installVersion:n,runningVersion:t})}):null,Ra=({className:e,...t})=>c.jsx("div",{className:_("mt-6 flex flex-wrap justify-end gap-3",e),...t}),WD=({className:e,...t})=>c.jsx("div",{className:_("mt-4 mb-2",e),...t}),aie=({autoCheck:e=!0,slowWaitHintMs:t})=>{const[n,s]=g.useState(!1),[r,i]=g.useState(!1),[a,o]=g.useState(!1),[l,u]=g.useState(null),[d,h]=g.useState(!1),[f,p]=g.useState(null),[m,v]=g.useState(!1),[x,b]=g.useState(null),[w,C]=g.useState(!1),[E,y]=g.useState("unknown"),k=py(n,t??my),T=py(d,t??my),P=py(r,t??my),[A,N]=g.useState(!1),[M,I]=g.useState(null),[H,G]=g.useState(!1),[j,J]=g.useState(null),[Y,oe]=g.useState(!1),[U,te]=g.useState(null),[le,R]=g.useState(null),L=g.useRef(null),[D,W]=g.useState(null),[Z,se]=g.useState(null),[ae,re]=g.useState(!1),[Q,pe]=g.useState(null),O=g.useRef({target:null,sourceBuild:!1}),me=g.useRef({terminal:!1,inFlight:!1}),[ke,He]=g.useState(!1),[ie,de]=g.useState(null),[Pe,Qe]=g.useState(null),[Ae,ve]=g.useState(null),[Ze,gt]=g.useState(null),[dt,Et]=g.useState(null),{shouldShowUpdate:Lt,deferUpdate:nn}=yV(),vt=Ks(xe=>xe.detailOpen),Wt=Ks(xe=>xe.noteQuietOffer),_t=Ks(xe=>xe.clearQuietOffer),St=Ks(xe=>xe.clearSurface),en=Ks(xe=>xe.closeDetail),Bt=Ks(xe=>xe.noteRunningVersion),Mt=Ks(xe=>xe.noteInFlight),Ir=Ks(xe=>xe.noteDownloadPercent);g.useEffect(()=>{Mt(an.UI,d||ke)},[d,ke,Mt]),g.useEffect(()=>{Mt(an.BACKEND,r)},[r,Mt]),g.useEffect(()=>{Ir(an.UI,d&&f?Math.round(f.percent):null)},[d,f,Ir]);const Ps=g.useRef(null);g.useEffect(()=>{Ps.current=j},[j]),g.useEffect(()=>{window.api.systemInfo.getAppVersion().then(xe=>y(xe)).catch(()=>y("unknown"))},[]),g.useEffect(()=>{Bt(an.UI,E)},[E,Bt]);const dr=g.useRef([]);g.useEffect(()=>{const xe=g3.filter(B=>vt[B]),ot=dr.current.filter(B=>!xe.includes(B));ot.length>0&&xe.length===0&&typeof document<"u"&&document.querySelector(`[data-update-indicator-open="${ot[0]}"]`)?.focus(),dr.current=xe},[vt]);const mn=g.useCallback(xe=>{switch(BD(xe)){case"muted":return console.warn(`Update check reported no artifact for this build: ${xe}`),!1;default:return b(xe),C(!0),!0}},[]),Hs=g.useCallback(xe=>{const ot=Ks.getState();ot.offers[xe]!==null&&ot.openDetail(xe)},[]),Tt=g.useCallback(async xe=>{try{s(!0),xe?.keepFailure!==!0&&b(null),await window.api.updater.checkForUpdates(xe?.manual===void 0?void 0:{manual:xe.manual}),xe?.keepFailure===!0&&b(null),xe?.manual===!0&&Hs(an.UI)}catch(ot){if(xe?.manual!==!0)return;const B=tl(ot);BD(B)==="muted"&&(o(!1),u(null)),mn(B)}finally{s(!1)}},[Hs,mn]),Nr=g.useCallback(async()=>{try{s(!0),b(null);const xe=await window.api.updater.checkForAllUpdates({manual:!0});xe.app==="available"&&Hs(an.UI),xe.server==="available"&&Hs(an.BACKEND)}catch(xe){mn(tl(xe))}finally{s(!1)}},[Hs,mn]),Mi=g.useCallback(async()=>{try{h(!0),b(null),await window.api.updater.downloadUpdate()}catch(xe){b(`Error downloading update: ${tl(xe)}`),h(!1),C(!0)}},[]),Us=g.useCallback(async()=>{He(!0),b(null),de(null);try{await window.api.updater.quitAndInstall()||He(!1)}catch(xe){He(!1),b(`Error starting the update: ${tl(xe)}`),C(!0)}},[]),fi=g.useCallback(async()=>{try{await window.api.updater.quitForUpdateInstall()}catch(xe){b(`Error quitting for the update: ${tl(xe)}`),C(!0)}},[]),sn=g.useCallback(xe=>{xe&&window.api.openExternal(xe)},[]),cs=g.useCallback(()=>{const xe=me.current;return xe.inFlight?(xe.terminal=!0,xe.inFlight=!1,!0):!1},[]),Mn=g.useCallback(xe=>{const ot=vu(xe.installVersion),B=vu(xe.runningVersion),z=xe.kind==="restart-failed";if(!ot||!B&&!z||B!==null&&ot===B||B!==null&&fE(B,ot))return!1;const V=GD(xe);return L.current===V?!1:(R(xe),!0)},[]),Tn=g.useCallback(async xe=>{me.current={terminal:!1,inFlight:!0};try{s(!0),i(!0),b(null),I(null);const ot=xe??Ps.current?.latestVersion??void 0;await window.api.updater.updateBackend(ot)===!1&&!me.current.terminal&&I({message:Qre(ot)})}catch(ot){me.current.terminal||I({message:`The server update could not be started: ${tl(ot)}`})}finally{me.current.inFlight=!1,s(!1),i(!1),W(null)}},[]),Gs=g.useCallback(()=>{C(!1),b(null)},[]),Fn=g.useCallback(()=>{j&&(nn(an.BACKEND,j.latestVersion),G(!1),J(null)),St(an.BACKEND),Gs()},[St,Gs,nn,j]),_e=g.useCallback(()=>{I(null),Fn()},[Fn]),De=g.useCallback(()=>{l&&(nn(an.UI,l.version),o(!1),v(!1)),St(an.UI),Gs()},[St,Gs,nn,l]);g.useEffect(()=>{const xe=window.api.updater.onUpdateAvailable(be=>{Lt(an.UI,be.version)&&(gt(null),o(!0),u(be),C(!0),Wt(an.UI,{version:be.version}))}),ot=window.api.updater.onUpdateNotAvailable(()=>{o(!1),u(null),St(an.UI)}),B=window.api.updater.onUpdateDownloaded(be=>{h(!1),Lt(an.UI,be.version)&&(gt(null),v(!0),u(be),C(!0),_t(an.UI))}),z=window.api.updater.onUpdateError(be=>{const qe=tl(be);mn(qe)&&(s(!1),h(!1))}),V=window.api.updater.onBackendUpdateManualRequired(be=>{cs(),O.current={target:be.latestVersion??Ps.current?.latestVersion??null,sourceBuild:be.sourceBuild===!0},re(!0),pe(be),s(!1),i(!1),G(!1),J(null),_t(an.BACKEND)}),K=window.api.updater.onUpdateInstallBlocked(be=>{ve(be),s(!1),i(!1),h(!1)}),q=window.api.updater.onUpdateInstallFailed(be=>{gt(be),Et(null),s(!1)}),X=window.api.updater.onUpdateInstallInFlight(be=>{Et(be),gt(null),s(!1)}),fe=window.api.updater.onUpdateInstallProgress(be=>{de(be.phase)}),Ee=window.api.updater.onUpdateInstallSucceeded(be=>{Qe(be.version)}),ge=window.api.updater.onUpdateProgress(be=>{p(be)}),we=window.api.updater.onBackendUpdateAvailable(be=>{if(qre({manual:be.manual,currentVersion:be.currentVersion,expectation:O.current})&&(re(!1),pe(null),O.current={target:null,sourceBuild:!1}),Lt(an.BACKEND,be.latestVersion)){const qe={...be,canManageUpdate:be.canManageUpdate??!be.updateCommand.includes("manually")};G(!0),J(qe),Bt(an.BACKEND,qe.runningVersion??qe.currentVersion??null),Wt(an.BACKEND,{version:qe.latestVersion,summary:qe.releaseNotes?.summary??null}),I(null),C(!0)}}),Se=window.api.updater.onBackendUpdateNotAvailable(be=>{const qe=Ps.current;St(an.BACKEND),G(tn=>qe&&fE(be.version,qe.latestVersion)?(J(null),!1):tn);const xt=O.current;(xt.target==null||I6({reported:be.version,expectation:xt}))&&(re(!1),pe(null),O.current={target:null,sourceBuild:!1}),vu(be.runningVersion)&&Mn({installVersion:be.version,runningVersion:be.runningVersion??null,notRestarted:!0,unattended:!1,restartable:be.restartable!==!1,releaseRead:be.releaseRead!==!1,appOwnedEnvironment:be.appOwnedEnvironment===!0,kind:"up-to-date"})}),Ue=window.api.updater.onBackendUpdateCompleted(be=>{cs(),G(!1),J(null),St(an.BACKEND),s(!1),i(!1),W(null);const qe=be?.serverDidNotComeBack===!0&&!vu(be.runningVersion);if(be&&(!be.restarted||be.unattended===!0)&&be.moved!==!0&&Mn({installVersion:be.installVersion,runningVersion:be.runningVersion,notRestarted:!be.restarted,unattended:be.unattended===!0,restartable:be.restartable!==!1,releaseRead:!0,appOwnedEnvironment:be.appOwnedEnvironment===!0,kind:qe?"restart-failed":"landed"}))return;const xt=typeof be?.sessionsOnOldBuild=="number"?be.sessionsOnOldBuild:null;te(xt),oe(!0),C(!0),setTimeout(()=>{oe(!1)},VD(xt)===null?6e3:8e3)}),Je=window.api.updater.onBackendUpdateProgress(({phase:be,sourceRebuild:qe,waitedMs:xt})=>{W(be),se(be==="draining"&&typeof xt=="number"?xt:null),N(qe===!0)}),ut=window.api.updater.onBackendUpdateError(be=>{if(be.phase==="update"&&cs()){I({message:q_(be),installerOutput:be.installerOutput,logPath:be.logPath,refusal:be.refusal}),W(null),s(!1),i(!1);return}b(tl(be.message)),C(!0)});return e&&Tt(),()=>{xe(),ot(),B(),z(),ge(),we(),Se(),Ue(),Je(),ut(),V(),K(),q(),X(),fe(),Ee()}},[Mn,cs,e,Tt,_t,St,Wt,Bt,mn,Lt]);const Oe=(xe,ot)=>c.jsxs(c.Fragment,{children:[xe,Pe!==null?c.jsx(Kv,{open:!0,autoHideDuration:8e3,onClose:()=>Qe(null),variant:"success",children:$re(Pe)}):null,x!==null?c.jsx(Wre,{open:w,message:x,onClose:Gs,onRetry:()=>void Tt({manual:!0,keepFailure:!0}),retrying:n}):ot]});if(Ze)return Oe(c.jsxs(Ta,{tone:"failed",children:[c.jsx(lu,{tone:"failed",children:Ze.cancelledByRelaunch?"The update was cancelled":"The last update didn't finish"}),c.jsx("p",{className:"mb-2 text-body text-ink-muted",children:Ze.message}),c.jsx("p",{className:"mt-2 text-body text-ink",children:Ze.remedy.text}),(Ze.attempts??1)>1&&c.jsxs("p",{className:"mt-1 text-body-sm text-ink-muted",children:["Version ",Ze.targetVersion," has failed to install"," ",Ze.attempts," times on this machine."]}),c.jsx("p",{className:"mt-1 text-body-sm text-ink-muted",children:"This is also recorded in Settings, under Application updates."}),c.jsxs(Ra,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:()=>gt(null),children:"Update later"}),c.jsx(ce,{variant:"outline",size:"sm",onClick:()=>void Tt({manual:!0}),disabled:n,children:n?"Checking...":"Check for updates"}),c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>sn(Ze.remedy.url),children:"Open download page"})]}),Ze.detail&&c.jsx(du,{detail:Ze.detail})]}));if(dt)return Oe(c.jsxs(Ta,{role:"alert",children:[c.jsx(lu,{children:"The update is still installing"}),c.jsx("p",{className:"mb-2 text-body text-ink-muted",children:dt.message}),c.jsxs(Ra,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:()=>Et(null),children:"Keep using Local Operator (cancels the install)"}),c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>void fi(),children:"Quit and let the update finish"})]}),dt.detail&&c.jsx(du,{detail:dt.detail})]}));if(n)return Oe(c.jsxs(Ta,{children:[c.jsx("h2",{className:"mb-3 text-heading text-ink",children:r?"Updating server":"Checking for updates"}),c.jsx("p",{className:"mb-2 text-body text-ink-muted",children:r?D==="installing"?A?"Rebuilding the server from this machine's checkout. The app waited for the turns running on this machine to finish first, and the rebuild reinstalls this install in place - so a turn started while it runs can still be interrupted - and it can take several minutes (up to half an hour). It can't be interrupted once it has started.":`Rolling the server onto ${vu(j?.latestVersion)??"the new build"}. Nothing in flight is cut off - the turns running on this machine keep running. The update can't be interrupted once it has started.`:D==="restarting"?"The new build has landed. Nothing in flight was cut off - the turns running on this machine kept running - and the server is restarting onto the new build now, so it is offline while it comes back: usually a few seconds, up to half a minute. After that the app starts a runtime again for any session the restart left without one, which can take up to a minute.":D==="draining"?`Waiting for the turns running on this machine to finish. ${Kre} - and the update can't be interrupted while it waits.`:M6(j)?"Please wait while the server is being updated. The server will temporarily go offline while it restarts to apply the update. The update can't be interrupted once it has started.":"Please wait while the server is being updated. The update can't be interrupted once it has started.":"Please wait while we check for available updates..."}),k&&!r&&c.jsx("p",{className:"mt-1 text-body-sm text-ink-muted",children:"Still checking. A slow or stalled connection can hold this for about a minute and a half - the app stops waiting on its own."}),P&&r&&D==="installing"&&!A&&c.jsx("p",{className:"mt-1 text-body-sm text-ink-muted",children:"Still installing. A slow connection or a cold cache can hold this longer - the app stops waiting on its own."}),D==="draining"&&Z!==null&&c.jsx("p",{className:"mt-1 text-body-sm text-ink-muted tabular-nums",children:Jre(Z)}),c.jsx(WD,{children:c.jsx(vS,{})})]}));if(Ae)return Oe(c.jsxs(Ta,{tone:"failed",children:[c.jsx(lu,{tone:"failed",children:Ae.heading??Zre[Ae.code]??"The update wasn't installed"}),c.jsx("p",{className:"mb-2 text-body text-ink-muted",children:Ae.message}),c.jsx("p",{className:"mt-2 text-body text-ink",children:Ae.remedy.text}),Ae.remedy.command&&c.jsx(ov,{command:Ae.remedy.command}),c.jsxs(Ra,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:()=>{ve(null),St(an.UI)},children:Ae.dismissLabel??"Update later"}),Ae.remedy.url?c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>sn(Ae.remedy.url),children:"Open download page"}):c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>void Tt({manual:!0}),disabled:n,children:n?"Checking...":"Check for updates"})]}),Ae.detail&&c.jsx(du,{detail:Ae.detail})]}));if(ae&&Q)return Oe(c.jsxs(Ta,{children:[c.jsx(lu,{children:Q.appOwned?"The app cannot update this server":"The server needs updating by hand"}),c.jsx("p",{className:"mb-2 text-body text-ink",children:Q.message}),c.jsx(iie,{latestVersion:Q.latestVersion,runningVersion:Q.currentVersion,installVersion:Q.installVersion}),Q.command?c.jsx(ov,{command:Q.command}):null,c.jsx($D,{command:!!Q.command,sourceBuild:Q.sourceBuild===!0,appOwned:Q.appOwned===!0}),c.jsxs(Ra,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:()=>{re(!1),pe(null),St(an.BACKEND)},children:"Update later"}),c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>void Nr(),disabled:n,children:n?"Checking...":"Check for updates"})]}),Q.detail&&c.jsx(du,{detail:Q.detail})]}));if(a&&!m&&l&&vt[an.UI])return Oe(c.jsxs(Ta,{onClose:()=>en(an.UI),closeLabel:"Close app update details",children:[c.jsx("h2",{className:"mb-3 text-heading text-ink",children:"Update available"}),c.jsxs("p",{className:"mb-2 text-body text-ink-muted",children:["Version ",l.version," is available. You are currently using version ",E,"."]}),l.releaseNotes&&c.jsxs("div",{className:_("mt-2 text-body text-ink-muted",nie),children:["Release notes:"," ",typeof l.releaseNotes=="string"?c.jsxs(c.Fragment,{children:[SV(oie(l.releaseNotes,400)),l.releaseNotes.length>400&&c.jsx("a",{href:zD(l),target:"_blank",rel:"noopener noreferrer",className:"ml-2",children:"View full release notes"})]}):c.jsx("a",{href:zD(l),target:"_blank",rel:"noopener noreferrer",children:"See release notes on GitHub"})]}),d&&f&&c.jsxs(WD,{children:[c.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Downloading: ",Math.round(f.percent),"%"]}),c.jsx(vS,{value:f.percent,className:"mt-2"}),c.jsxs("p",{className:"mt-1 text-mono-sm text-ink-dim",title:`${f.transferred.toLocaleString()} of ${f.total.toLocaleString()} bytes`,children:[oS(f.transferred)," of"," ",oS(f.total)]})]}),T&&c.jsx("p",{className:"mb-2 text-body-sm text-ink-muted",children:"Still downloading. A download that stops making progress is cancelled after about 90 seconds."}),c.jsx(Ra,{children:!d&&c.jsxs(c.Fragment,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:De,disabled:d,children:"Update later"}),c.jsx(ce,{variant:"primary",size:"sm",onClick:Mi,disabled:d,children:"Download update"})]})})]}));if(m&&l)return Oe(c.jsxs(Ta,{children:[c.jsx("h2",{className:"mb-3 text-heading text-ink",children:"Update ready to install"}),c.jsxs("p",{className:"mb-2 text-body text-ink-muted",children:["Version ",l.version," has been downloaded. You are currently using version ",E,"."]}),c.jsx("p",{className:"mt-2 text-body text-ink-muted",children:"Installing closes the app while the update is verified and put in place — usually a few seconds, occasionally a few minutes. Don't reopen it until it starts by itself. Opening it while the update is installing cancels the install."}),ke?c.jsx("output",{className:"mt-2 block text-body text-ink-muted",children:Gre(ie)}):null,c.jsxs(Ra,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:De,disabled:ke,children:"Update later"}),c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>void Us(),disabled:ke,children:"Install now"})]})]}),c.jsx(Kv,{open:w,autoHideDuration:6e3,onClose:Gs,variant:"success",children:"Update downloaded and ready to install"}));if(M){const xe=M.installerOutput?{sentence:M.message,output:M.installerOutput}:tie(M.message),ot=M.refusal;return Oe(ot?c.jsxs(Ta,{children:[c.jsx(lu,{children:"The update didn't start"}),c.jsx("p",{className:"mb-2 text-body text-ink",children:xe.sentence}),xe.output&&c.jsx("p",{className:"text-body-sm text-ink-muted",children:xe.output}),ot.command&&c.jsxs("div",{className:"mt-2",children:[c.jsx("p",{className:"text-body-sm text-ink-muted",children:"To update now, run this yourself in a terminal:"}),c.jsx(ov,{command:ot.command})]}),M.logPath&&c.jsx("div",{className:"mt-2",children:c.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>{window.api.showItemInFolder(M.logPath)},children:"Reveal update log"})}),c.jsxs(Ra,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:()=>void Tn(),children:"Try again"}),c.jsx(ce,{variant:"primary",size:"sm",onClick:_e,children:"Update later"})]})]}):c.jsxs(Ta,{tone:"failed",children:[c.jsx(lu,{tone:"failed",children:"The server update didn't finish"}),c.jsx("p",{className:"mb-2 text-body text-ink-muted",children:xe.sentence}),xe.output&&c.jsx(eie,{output:xe.output}),M.logPath&&c.jsx("div",{className:"mt-2",children:c.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>{window.api.showItemInFolder(M.logPath)},children:"Reveal update log"})}),c.jsxs(Ra,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:_e,children:"Update later"}),c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>void Tn(),children:"Try again"})]})]}))}if(H&&j&&vt[an.BACKEND]){const xe=Ure(j.releaseNotes,j.latestVersion);return Oe(c.jsxs(Ta,{onClose:()=>en(an.BACKEND),closeLabel:"Close server update details",children:[c.jsx("h2",{className:"mb-3 text-heading text-ink",children:"Server update available"}),c.jsx("p",{className:"mb-2 text-body text-ink-muted",children:O6({latestVersion:j.latestVersion,installVersion:j.currentVersion,runningVersion:j.runningVersion})}),xe&&c.jsxs("div",{className:"mt-2 break-words text-body text-ink-muted",children:["Release notes: ",xe.summary," ",c.jsxs("a",{href:xe.url,target:"_blank",rel:"noopener noreferrer",className:"whitespace-nowrap",children:["View full release notes for ",xe.version]})]}),!j.appOwned&&c.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:"Updating the server will improve AI functionality, improve security, and fix bugs."}),j.canManageUpdate?c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"mt-4 text-body text-ink",children:rie(j)}),c.jsxs(Ra,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:Fn,disabled:n,children:"Update later"}),c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>void Tn(),disabled:n,children:n?"Updating...":"Update server"})]}),j.detail&&c.jsx(du,{detail:j.detail})]}):c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"mt-4 text-body text-ink",children:j.remedy??"The server is installed outside the app, so use the tool you installed it with - uv, pipx or pip:"}),j.updateCommand&&c.jsx(ov,{command:j.updateCommand}),c.jsx($D,{command:!!j.updateCommand,sourceBuild:j.sourceBuild===!0,appOwned:j.appOwned===!0}),c.jsxs(Ra,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:Fn,disabled:n,children:j.appOwned?"Understood":"Update later"}),!j.appOwned&&c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>void Nr(),disabled:n,children:n?"Checking...":"Check for updates"})]}),j.detail&&c.jsx(du,{detail:j.detail})]})]}))}if(Y){const xe=VD(U);return Oe(null,c.jsxs(Kv,{open:!0,autoHideDuration:xe===null?6e3:8e3,onClose:()=>oe(!1),variant:"success",children:["Server update completed successfully",xe===null?null:c.jsx("p",{className:"text-body-sm text-ink",children:xe})]}))}if(le){const{installVersion:xe,runningVersion:ot,unattended:B,restartable:z,releaseRead:V,appOwnedEnvironment:K,kind:q}=le,X=z&&K,fe=q==="restart-failed";return Oe(c.jsxs(Ta,{children:[c.jsx(lu,{children:fe?"The server did not come back after the restart":"The server is on an older build than the install"}),c.jsx("p",{className:"mb-2 text-body text-ink-muted",children:q==="up-to-date"?V?`This machine's install is up to date${xe?` (${xe})`:""}, and the server serving this app is still running ${ot??"an older build"}.`:`This machine's install is ${xe??"a newer build"}, and the server serving this app is still running ${ot??"an older build"}.`:q==="restart-failed"?`The install is now at ${xe??"the new version"}, and the server serving this app did not answer after it was restarted.`:B?`An update you started before quitting finished while Local Operator was closed, so the install is now at ${xe??"a newer version"}. Nothing restarted the server that was serving you${ot?`, which still reports ${ot}`:""}.`:z?`The install is now at ${xe??"the new version"}, but the server serving this app is still running ${ot??"the build it loaded"}. That restart did not take.`:`The install is now at ${xe??"the new version"}, but the server serving this app was started outside Local Operator, so it was left running${ot?` on ${ot}`:""}.`}),c.jsx("p",{className:"mb-2 text-body text-ink-muted",children:fe?X?`This app started that server, so it can restart it. ${Xre}`:"Nothing is serving this conversation until that server is running again.":X?`This app started that server, so it can restart it onto the new build now. ${Yre}`:z?"Restart Local Operator and the server comes back on the new build.":"The server serving this app was started outside Local Operator, which does not restart a server it did not start: stop it and start Local Operator again, or restart whatever started it, and it comes back on the new build."}),c.jsxs(Ra,{children:[c.jsx(ce,{variant:X?"outline":"primary",size:"sm",onClick:()=>{L.current=GD(le),R(null)},children:"Understood"}),X&&c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>{R(null),Tn(xe)},children:"Restart the server"})]})]}))}return Oe(null)},oie=(e,t)=>e.length<=t?e:`${e.substring(0,t)}...`,zD=e=>{if(e.releaseNotes&&typeof e.releaseNotes!="string"){const t=e.releaseNotes,n=`https://github.com/damianvtran/local-operator-ui/releases/tag/v${e.version}`;return t.path||n}return`https://github.com/damianvtran/local-operator-ui/releases/tag/v${e.version}`};let Nh=null;const Yx=new Set;function lie(e){if(e!==Nh){Nh=e;for(const t of Yx)t()}}function cie(e){if(Nh!==null&&!(e!==void 0&&Nh!==e)){Nh=null;for(const t of Yx)t()}}function qD(){return Nh}function uie(e){return Yx.add(e),()=>{Yx.delete(e)}}function L6(){return g.useSyncExternalStore(g.useCallback(uie,[]),qD,qD)}function die(e,t){return e===null?{kind:"browser"}:t.some(s=>s.session_id===e)?{kind:"conversation",sessionId:e}:{kind:"browser"}}function hie(e,t){return e===null||t===void 0?!1:!t.some(n=>n.entryId===e)}function fie(e,t,n){return e===null||t===void 0?!0:t.some(s=>s.entryId===e&&s.expiresAt>n)}const pie=6e4,B6=6e4,gie=5,mie=5*B6;function j6(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"?t.origin:null}catch{return null}}function H6(e,t){return e.filter(n=>t<n.expiresAt)}function KD(e,t){let n=0;for(const s of e)t<s.expiresAt&&(n+=1);return n}function vie(e,t){const n=e-t;if(n<=0)return null;if(n<pie)return"expires in under a minute";const s=Math.ceil(n/B6);return s===1?"expires in 1 minute":`expires in ${s} minutes`}function xie(e,t){return H6(e,t).map((n,s)=>({request:n,ordinal:s+1,remaining:vie(n.expiresAt,t)}))}function bie(e,t){const n=new Map;for(const r of e)n.has(r.request.origin)||n.set(r.request.origin,r.ordinal);const s={};for(const r of t){if(r.owner!=="agent")continue;const i=j6(r.url);if(!i)continue;const a=n.get(i);a!==void 0&&(s[r.tabId]=a)}return s}function wie(e,t,n,s,r,i){const a=new Set(t.map(d=>d.entryId)),o=e.filter(d=>!a.has(d.entryId)&&!s.has(d.entryId)).map(d=>({key:d.entryId,kind:d.expiresAt<=i?"expired":"withdrawn",origin:d.origin,authority:d.authority,at:i})),l=t.filter(d=>d.expiresAt<=i&&!s.has(d.entryId)).map(d=>({key:d.entryId,kind:"expired",origin:d.origin,authority:d.authority,at:i})),u=new Set([...r,...n.map(d=>d.key)]);return[...o,...l].filter(d=>!u.has(d.key)).concat(n).filter(d=>i-d.at<mie).slice(0,gie)}function Cie(e){switch(e){case"origin":return"This site";case"domain":return"Whole domain";case"host":return"This host";case"deny":return"Denied";case"session":return"This session only"}}function yie(e,t){return t==="all"?[...e]:e.filter(n=>n.requesterSessionId===t.sessionId)}let K_=Date.now();const pE=new Set;let wp=null,vy=0;function U6(e){K_=e;for(const t of pE)t(e)}function Y_(){return U6(Date.now()),K_}function Sie(){return vy+=1,wp===null&&(wp=setInterval(()=>U6(Date.now()),1e3)),()=>{vy-=1,!(vy>0||wp===null)&&(clearInterval(wp),wp=null)}}function G6(e){const[t,n]=g.useState(()=>K_),s=e(t);return g.useEffect(()=>{if(s!==0)return Sie()},[s]),g.useEffect(()=>(pE.add(n),()=>{pE.delete(n)}),[]),t}function $6(e,t){const n=G6(d=>H6(e,d).length),s=g.useRef([]),[r,i]=g.useState([]),a=g.useRef(new Set),o=g.useRef(new Set),l=g.useCallback((d,h,f)=>i(p=>wie(d,h,p,a.current,o.current,f)),[]);g.useEffect(()=>{for(const d of r)o.current.add(d.key)},[r]),g.useEffect(()=>{const d=Y_(),h=s.current;s.current=e,l(h,e,d)},[e,l]),g.useEffect(()=>{l(e,e,n)},[n,e,l]);const u=xie(e,n);return{now:n,rows:u,resolved:r,waiting:bie(u,t),count:u.length,noteDecision:g.useCallback(d=>{a.current.add(d)},[])}}function ff(){return window.api?.browser??null}function V6(){return ff()!==null}const gE={state:null,readError:null};let pf=gE;const ox=new Set;let Xx=null,mE=!1,Qx=0,Jx=0;function hm(e){pf=e;for(const t of ox)t()}function vE(){return pf}function Eie(){pf.readError!==null&&hm({state:pf.state,readError:null})}function kie(e){Jx=Qx,hm({state:e,readError:null})}async function gg(){const e=ff();if(!e)return null;const t=++Qx;try{const n=await e.state();return!n||!Array.isArray(n.tabs)?null:(t>Jx&&(Jx=t,hm({state:n,readError:null})),n)}catch(n){return t===Qx&&hm({state:pf.state,readError:z_(n)}),null}}function _ie(e){return ox.add(e),Tie(),()=>{ox.delete(e),ox.size===0&&Rie()}}function Tie(){const e=ff();if(e){if(!Xx){const t=e.onStateChanged(()=>void gg()),n=e.onConsentChanged(()=>void gg());Xx=()=>{t(),n()}}mE||(mE=!0,gg())}}function Rie(){Xx?.(),Xx=null,mE=!1,pf!==gE&&hm(gE),Jx=Qx}function Aie(){return g.useSyncExternalStore(_ie,vE,vE)}function xy(e){ff()?.setContentRect(e).catch(()=>{})}function Pw(){const{state:e,readError:t}=Aie();return{state:e,readError:t,refresh:gg,clearReadError:Eie}}function Fie(){const{state:e,readError:t,refresh:n,clearReadError:s}=Pw(),[r,i]=g.useState(null),[a,o]=g.useState(null),l=V6(),u=r??t,d=g.useCallback(async()=>{const C=await n();C?.url&&C.url!=="about:blank"&&o(null)},[n]),h=g.useCallback(async C=>{let E=!0;try{await C(),i(null)}catch(y){E=!1,i(z_(y))}return await d(),E},[d]),f=g.useCallback(C=>h(C).then(()=>{}),[h]),p=g.useCallback(()=>{i(null),s()},[s]),m=g.useRef(null),v=g.useRef(null),x=g.useCallback(C=>{if(C===null){m.current!==null&&(cancelAnimationFrame(m.current),m.current=null),v.current=null,xy(null);return}v.current=C,m.current===null&&(m.current=requestAnimationFrame(()=>{m.current=null,xy(v.current)}))},[]);g.useEffect(()=>()=>{m.current!==null&&cancelAnimationFrame(m.current),xy(null)},[]);const b=g.useCallback(C=>{ff()?.setViewVisible(C).catch(()=>{})},[]),w=ff();return g.useMemo(()=>({state:e,pendingUrl:a,error:u,dismissError:p,available:l,refresh:d,newTab:C=>f(()=>w?.newTab(C??null)),closeTab:C=>h(()=>w?.closeTab(C)),closeTabs:C=>h(()=>w?.closeTabs(C)),activateTab:C=>f(()=>w?.activateTab(C)),navigate:C=>(o(C),f(()=>w?.navigate(C))),reload:()=>f(()=>w?.reload()),stop:()=>f(()=>w?.stop()),retry:()=>f(()=>w?.retry()),history:C=>f(()=>w?.history(C)),setContentRect:x,setViewVisible:b,respondToConsent:(C,E)=>f(()=>w?.respondToConsent(C,E)),handOver:(C,E)=>f(()=>w?.handOver(C,E)),revokeHandOver:C=>f(()=>w?.revokeHandOver(C)),revokeApproval:C=>f(()=>w?.revokeApproval(C)),revokeAllApprovals:()=>f(()=>w?.revokeAllApprovals()),forgetSite:C=>f(()=>w?.forgetSite(C)),clearData:C=>f(()=>w?.clearData(C)),revealDownloads:()=>f(async()=>{const E=(await w?.revealDownloads())?.message;typeof E=="string"&&E&&$t(`Could not open the downloads folder. ${E}`)})}),[e,a,u,p,l,d,h,f,x,b,w])}function Die(){const e=L6(),n=Pw().state?.pendingConsent,s=hie(e,n),r=g.useRef(null);g.useEffect(()=>{e===null||r.current===e||(r.current=e,gg().then(()=>{const i=r.current;if(i===null)return;r.current=null;const a=vE().state?.pendingConsent;a!==void 0&&(fie(i,a,Y_())||La("That request is no longer waiting."))}))},[e]),g.useEffect(()=>{e===null||!s||cie(e)},[e,s])}const Pie=`It leaves your lists. You can undo for ${yS/1e3} seconds; after that, search above your chats, turn on “Include archived”, then Unarchive it.`,Iie="this conversation",Nie="Archive";function YD(e){return document.querySelector(`[data-session-row="${CSS.escape(e)}"]`)}function W6(e){const t=Array.from(document.querySelectorAll('[data-sidebar-region="chats"] [data-chat-row]')),n=e.closest("[data-session-row]")?.querySelector("[data-chat-row]")??null,s=n!==null&&t.includes(n)?t:Array.from(document.querySelectorAll("[data-chat-row]")),r=n===null?-1:s.indexOf(n);return()=>{const i=s.map((o,l)=>({element:o,position:l})).filter(({element:o})=>o.isConnected);(i.find(({position:o})=>o>r)?.element??i.filter(({position:o})=>o<r).at(-1)?.element)?.focus({preventScroll:!0})}}const Mie=()=>{const e=Ce(u=>u.archiveCandidate),t=Ce(u=>u.sessions),n=Ce(u=>u.requestArchiveConfirm),s=Ce(u=>u.setSessionArchived),r=g.useRef(null),i=g.useRef(null),a=g.useRef(!1),o=g.useRef(!1);g.useEffect(()=>{if(e!==null){i.current=e.sessionId,a.current=e.fromRow,o.current=e.fromHeader===!0,r.current=document.activeElement instanceof HTMLElement?document.activeElement:null;return}const u=i.current,d=a.current,f=o.current?null:r.current;if(r.current=null,i.current=null,f?.isConnected&&(f.focus({preventScroll:!0}),document.activeElement===f))return;const p=u===null?null:YD(u)?.querySelector("[data-chat-row]")??null,m=document.querySelector("[data-conversation-actions]");(d?p??m:m??p)?.focus({preventScroll:!0})},[e]);const l=t.find(u=>u.session_id===e?.sessionId)?.title||e?.title||null;return c.jsx(Lc,{open:e!==null,title:c.jsxs("span",{className:"flex min-w-0 items-center",children:[c.jsx("span",{className:"shrink-0",children:`${Nie} ${l===null?"":"“"}`}),c.jsx("span",{className:"min-w-0 truncate",children:l===null?Iie:l}),c.jsx("span",{className:"shrink-0",children:l===null?"?":"”?"})]}),message:c.jsx("p",{children:Pie}),confirmText:"Archive",cancelText:"Cancel",isDangerous:!1,onConfirm:()=>{if(!e)return;const{sessionId:u,fromRow:d}=e;n(null);const h=d?YD(u):null,f=h===null?null:W6(h);s(u,!0,t.find(p=>p.session_id===u)?.title??void 0).then(p=>{p&&f?.()})},onCancel:()=>n(null)})};function jf(e,t){const s=Ce.getState().openSession(t),r=`/chat/${t}`;return e(r),s.then(i=>{if(i||Kk()!==r)return;const a=Ce.getState();if(a.activeDraftKey){e("/chat",{replace:!0});return}const o=a.activeSessionId;e(o?`/chat/${o}`:"/chat",{replace:!0})}),s}const z6=["desktop","aida"],Oie="aida";function Lie(){const e=os();return d0(yt(e.data,"aida",1)).data?.name??"Aida"}function hXe(e,t){return e===Oie?t:e}function d0(e){return Os({queryKey:z6,queryFn:()=>Ct({op:"aida.status"}),enabled:e,staleTime:3e4,retry:m3})}async function Bie(e){return Ct({op:"aida.control",action:e})}function X_(){const e=hn();return g.useCallback(async t=>{const n=await Bie(t);return e.invalidateQueries({queryKey:z6}),n},[e])}function q6(){const e=X_();return g.useCallback(async t=>{const n=t?.session_id??null,s=n?null:await e("open"),r=n??s?.session_id??null;if(!r)throw new Error("Aida's conversation could not be opened.");return r},[e])}function jie(){const e=q6();return g.useCallback(async(t,n)=>{const s=await e(n);return jf(t,s),s},[e])}const XD={}.hasOwnProperty;function K6(e,t){const n=t||{};function s(r,...i){let a=s.invalid;const o=s.handlers;if(r&&XD.call(r,e)){const l=String(r[e]);a=XD.call(o,l)?o[l]:s.unknown}if(a)return a.call(this,r,...i)}return s.handlers=n.handlers||{},s.invalid=n.invalid,s.unknown=n.unknown,s}const Hie={}.hasOwnProperty;function Y6(e,t){let n=-1,s;if(t.extensions)for(;++n<t.extensions.length;)Y6(e,t.extensions[n]);for(s in t)if(Hie.call(t,s))switch(s){case"extensions":break;case"unsafe":{QD(e[s],t[s]);break}case"join":{QD(e[s],t[s]);break}case"handlers":{Uie(e[s],t[s]);break}default:e.options[s]=t[s]}return e}function QD(e,t){t&&e.push(...t)}function Uie(e,t){t&&Object.assign(e,t)}const Gie=[$ie];function $ie(e,t,n,s){if(t.type==="code"&&KA(t,s)&&(e.type==="list"||e.type===t.type&&KA(e,s)))return!1;if("spread"in n&&typeof n.spread=="boolean")return e.type==="paragraph"&&(e.type===t.type||t.type==="definition"||t.type==="heading"&&EV(t,s))?void 0:n.spread?1:0}const cu=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],Vie=[{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:`
452
+ `);if(t===-1)return{sentence:e,output:null};const n=e.slice(t+2).trim();return{sentence:e.slice(0,t),output:n.length>0?n:null}},ov=({command:e})=>{const[t,n]=g.useState(!1);return c.jsxs("div",{className:"mt-2 flex items-start gap-2",children:[c.jsx("code",{className:"min-w-0 flex-1 rounded-sm bg-sunken p-2 text-mono-sm break-all text-ink",children:e}),c.jsxs(ce,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(e).then(()=>n(!0)).catch(()=>{})},children:[t?c.jsx(Ls,{}):c.jsx(_l,{}),t?"Copied":"Copy command"]})]})},nie=["[&_:is(h1,h2,h3,h4,h5,h6)]:mt-3 [&_:is(h1,h2,h3,h4,h5,h6)]:mb-1 [&_:is(h1,h2,h3,h4,h5,h6)]:font-semibold [&_:is(h1,h2,h3,h4,h5,h6)]:text-ink","[&_h1]:text-heading [&_h2]:text-heading [&_h3]:text-body [&_h4]:text-body [&_h5]:text-body-sm [&_h6]:text-body-sm","[&_p]:my-1.5 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0","[&_:is(ul,ol)]:my-1.5 [&_:is(ul,ol)]:pl-5 [&_ul_li]:list-disc [&_ol_li]:list-decimal [&_li]:my-0.5","[&_code]:rounded-xs [&_code]:bg-sunken [&_code]:px-1 [&_code]:font-mono [&_code]:text-mono-sm"].join(" "),$D=({command:e,sourceBuild:t,appOwned:n=!1})=>n?null:t&&!e?c.jsx("p",{className:"mt-2 text-body text-ink",children:"This server follows this machine's checkout, so there is no command to run here."}):c.jsx("p",{className:"mt-2 text-body text-ink",children:t?"Run this in a terminal. This install was built from this machine's checkout, so `lop update` installs the published release over it - and if this machine has `lop-update`, the script that rebuilds this install from the checkout, run that afterwards to keep following it.":e?"Run this in a terminal, then check for updates again to pick up the new server version.":"Then check for updates again to pick up the new server version."}),sie=/^\d+\.\d+/,vu=e=>{if(typeof e!="string")return null;const t=e.trim();return sie.test(t)?t:null},M6=e=>e?.restartsServer??e?.restartable!==!1,rie=e=>M6(e)?e.remedy??"The app updates this install and then restarts the server it started, so nothing in flight is cut off. Sessions that are still working move onto the new build when they next stop or go idle.":"The app updates this install itself. The server you are using was started outside Local Operator, so it keeps running the old build until it restarts, and nothing in flight is dropped.",VD=e=>typeof e!="number"?"Sessions that are still running the old build will move onto the new build when they next stop or go idle.":e===0?null:e===1?"1 session is still running the old build; it will move onto the new build when it next stops or goes idle.":`${e} sessions are still running the old build; they will move onto the new build when they next stop or go idle.`,O6=({latestVersion:e,installVersion:t,runningVersion:n})=>{const s=vu(t),r=vu(n);if(s&&r&&s!==r)return`Server version ${e} is available. The install on this machine is at ${s}, and the server you are using is running ${r} until it restarts.`;const i=r??s;return i?`Server version ${e} is available. You are currently using version ${i}.`:`Server version ${e} is available.`},iie=({latestVersion:e,runningVersion:t,installVersion:n,className:s})=>e?c.jsx("p",{className:_("mb-2 text-body text-ink-muted",s),children:O6({latestVersion:e,installVersion:n,runningVersion:t})}):null,Ra=({className:e,...t})=>c.jsx("div",{className:_("mt-6 flex flex-wrap justify-end gap-3",e),...t}),WD=({className:e,...t})=>c.jsx("div",{className:_("mt-4 mb-2",e),...t}),aie=({autoCheck:e=!0,slowWaitHintMs:t})=>{const[n,s]=g.useState(!1),[r,i]=g.useState(!1),[a,o]=g.useState(!1),[l,u]=g.useState(null),[d,h]=g.useState(!1),[f,p]=g.useState(null),[m,v]=g.useState(!1),[x,b]=g.useState(null),[w,C]=g.useState(!1),[E,y]=g.useState("unknown"),k=py(n,t??my),T=py(d,t??my),P=py(r,t??my),[A,N]=g.useState(!1),[M,I]=g.useState(null),[H,G]=g.useState(!1),[j,J]=g.useState(null),[Y,oe]=g.useState(!1),[U,te]=g.useState(null),[le,R]=g.useState(null),L=g.useRef(null),[D,W]=g.useState(null),[Z,se]=g.useState(null),[ae,re]=g.useState(!1),[Q,pe]=g.useState(null),O=g.useRef({target:null,sourceBuild:!1}),me=g.useRef({terminal:!1,inFlight:!1}),[ke,He]=g.useState(!1),[ie,de]=g.useState(null),[Pe,Qe]=g.useState(null),[Ae,ve]=g.useState(null),[Ze,gt]=g.useState(null),[dt,Et]=g.useState(null),{shouldShowUpdate:Lt,deferUpdate:nn}=yV(),vt=Ks(xe=>xe.detailOpen),Wt=Ks(xe=>xe.noteQuietOffer),_t=Ks(xe=>xe.clearQuietOffer),St=Ks(xe=>xe.clearSurface),en=Ks(xe=>xe.closeDetail),Bt=Ks(xe=>xe.noteRunningVersion),Mt=Ks(xe=>xe.noteInFlight),Ir=Ks(xe=>xe.noteDownloadPercent);g.useEffect(()=>{Mt(an.UI,d||ke)},[d,ke,Mt]),g.useEffect(()=>{Mt(an.BACKEND,r)},[r,Mt]),g.useEffect(()=>{Ir(an.UI,d&&f?Math.round(f.percent):null)},[d,f,Ir]);const Ps=g.useRef(null);g.useEffect(()=>{Ps.current=j},[j]),g.useEffect(()=>{window.api.systemInfo.getAppVersion().then(xe=>y(xe)).catch(()=>y("unknown"))},[]),g.useEffect(()=>{Bt(an.UI,E)},[E,Bt]);const dr=g.useRef([]);g.useEffect(()=>{const xe=g3.filter(B=>vt[B]),ot=dr.current.filter(B=>!xe.includes(B));ot.length>0&&xe.length===0&&typeof document<"u"&&document.querySelector(`[data-update-indicator-open="${ot[0]}"]`)?.focus(),dr.current=xe},[vt]);const mn=g.useCallback(xe=>{switch(BD(xe)){case"muted":return console.warn(`Update check reported no artifact for this build: ${xe}`),!1;default:return b(xe),C(!0),!0}},[]),Hs=g.useCallback(xe=>{const ot=Ks.getState();ot.offers[xe]!==null&&ot.openDetail(xe)},[]),Tt=g.useCallback(async xe=>{try{s(!0),xe?.keepFailure!==!0&&b(null),await window.api.updater.checkForUpdates(xe?.manual===void 0?void 0:{manual:xe.manual}),xe?.keepFailure===!0&&b(null),xe?.manual===!0&&Hs(an.UI)}catch(ot){if(xe?.manual!==!0)return;const B=tl(ot);BD(B)==="muted"&&(o(!1),u(null)),mn(B)}finally{s(!1)}},[Hs,mn]),Nr=g.useCallback(async()=>{try{s(!0),b(null);const xe=await window.api.updater.checkForAllUpdates({manual:!0});xe.app==="available"&&Hs(an.UI),xe.server==="available"&&Hs(an.BACKEND)}catch(xe){mn(tl(xe))}finally{s(!1)}},[Hs,mn]),Mi=g.useCallback(async()=>{try{h(!0),b(null),await window.api.updater.downloadUpdate()}catch(xe){b(`Error downloading update: ${tl(xe)}`),h(!1),C(!0)}},[]),Us=g.useCallback(async()=>{He(!0),b(null),de(null);try{await window.api.updater.quitAndInstall()||He(!1)}catch(xe){He(!1),b(`Error starting the update: ${tl(xe)}`),C(!0)}},[]),fi=g.useCallback(async()=>{try{await window.api.updater.quitForUpdateInstall()}catch(xe){b(`Error quitting for the update: ${tl(xe)}`),C(!0)}},[]),sn=g.useCallback(xe=>{xe&&window.api.openExternal(xe)},[]),cs=g.useCallback(()=>{const xe=me.current;return xe.inFlight?(xe.terminal=!0,xe.inFlight=!1,!0):!1},[]),Mn=g.useCallback(xe=>{const ot=vu(xe.installVersion),B=vu(xe.runningVersion),z=xe.kind==="restart-failed";if(!ot||!B&&!z||B!==null&&ot===B||B!==null&&fE(B,ot))return!1;const V=GD(xe);return L.current===V?!1:(R(xe),!0)},[]),Tn=g.useCallback(async xe=>{me.current={terminal:!1,inFlight:!0};try{s(!0),i(!0),b(null),I(null);const ot=xe??Ps.current?.latestVersion??void 0;await window.api.updater.updateBackend(ot)===!1&&!me.current.terminal&&I({message:Qre(ot)})}catch(ot){me.current.terminal||I({message:`The server update could not be started: ${tl(ot)}`})}finally{me.current.inFlight=!1,s(!1),i(!1),W(null)}},[]),Gs=g.useCallback(()=>{C(!1),b(null)},[]),Fn=g.useCallback(()=>{j&&(nn(an.BACKEND,j.latestVersion),G(!1),J(null)),St(an.BACKEND),Gs()},[St,Gs,nn,j]),_e=g.useCallback(()=>{I(null),Fn()},[Fn]),De=g.useCallback(()=>{l&&(nn(an.UI,l.version),o(!1),v(!1)),St(an.UI),Gs()},[St,Gs,nn,l]);g.useEffect(()=>{const xe=window.api.updater.onUpdateAvailable(be=>{Lt(an.UI,be.version)&&(gt(null),o(!0),u(be),C(!0),Wt(an.UI,{version:be.version}))}),ot=window.api.updater.onUpdateNotAvailable(()=>{o(!1),u(null),St(an.UI)}),B=window.api.updater.onUpdateDownloaded(be=>{h(!1),Lt(an.UI,be.version)&&(gt(null),v(!0),u(be),C(!0),_t(an.UI))}),z=window.api.updater.onUpdateError(be=>{const qe=tl(be);mn(qe)&&(s(!1),h(!1))}),V=window.api.updater.onBackendUpdateManualRequired(be=>{cs(),O.current={target:be.latestVersion??Ps.current?.latestVersion??null,sourceBuild:be.sourceBuild===!0},re(!0),pe(be),s(!1),i(!1),G(!1),J(null),_t(an.BACKEND)}),K=window.api.updater.onUpdateInstallBlocked(be=>{ve(be),s(!1),i(!1),h(!1)}),q=window.api.updater.onUpdateInstallFailed(be=>{gt(be),Et(null),s(!1)}),X=window.api.updater.onUpdateInstallInFlight(be=>{Et(be),gt(null),s(!1)}),fe=window.api.updater.onUpdateInstallProgress(be=>{de(be.phase)}),Ee=window.api.updater.onUpdateInstallSucceeded(be=>{Qe(be.version)}),ge=window.api.updater.onUpdateProgress(be=>{p(be)}),we=window.api.updater.onBackendUpdateAvailable(be=>{if(qre({manual:be.manual,currentVersion:be.currentVersion,expectation:O.current})&&(re(!1),pe(null),O.current={target:null,sourceBuild:!1}),Lt(an.BACKEND,be.latestVersion)){const qe={...be,canManageUpdate:be.canManageUpdate??!be.updateCommand.includes("manually")};G(!0),J(qe),Bt(an.BACKEND,qe.runningVersion??qe.currentVersion??null),Wt(an.BACKEND,{version:qe.latestVersion,summary:qe.releaseNotes?.summary??null}),I(null),C(!0)}}),Se=window.api.updater.onBackendUpdateNotAvailable(be=>{const qe=Ps.current;St(an.BACKEND),G(tn=>qe&&fE(be.version,qe.latestVersion)?(J(null),!1):tn);const xt=O.current;(xt.target==null||I6({reported:be.version,expectation:xt}))&&(re(!1),pe(null),O.current={target:null,sourceBuild:!1}),vu(be.runningVersion)&&Mn({installVersion:be.version,runningVersion:be.runningVersion??null,notRestarted:!0,unattended:!1,restartable:be.restartable!==!1,releaseRead:be.releaseRead!==!1,appOwnedEnvironment:be.appOwnedEnvironment===!0,kind:"up-to-date"})}),Ue=window.api.updater.onBackendUpdateCompleted(be=>{cs(),G(!1),J(null),St(an.BACKEND),s(!1),i(!1),W(null);const qe=be?.serverDidNotComeBack===!0&&!vu(be.runningVersion);if(be&&(!be.restarted||be.unattended===!0)&&be.moved!==!0&&Mn({installVersion:be.installVersion,runningVersion:be.runningVersion,notRestarted:!be.restarted,unattended:be.unattended===!0,restartable:be.restartable!==!1,releaseRead:!0,appOwnedEnvironment:be.appOwnedEnvironment===!0,kind:qe?"restart-failed":"landed"}))return;const xt=typeof be?.sessionsOnOldBuild=="number"?be.sessionsOnOldBuild:null;te(xt),oe(!0),C(!0),setTimeout(()=>{oe(!1)},VD(xt)===null?6e3:8e3)}),Je=window.api.updater.onBackendUpdateProgress(({phase:be,sourceRebuild:qe,waitedMs:xt})=>{W(be),se(be==="draining"&&typeof xt=="number"?xt:null),N(qe===!0)}),ut=window.api.updater.onBackendUpdateError(be=>{if(be.phase==="update"&&cs()){I({message:q_(be),installerOutput:be.installerOutput,logPath:be.logPath,refusal:be.refusal}),W(null),s(!1),i(!1);return}b(tl(be.message)),C(!0)});return e&&Tt(),()=>{xe(),ot(),B(),z(),ge(),we(),Se(),Ue(),Je(),ut(),V(),K(),q(),X(),fe(),Ee()}},[Mn,cs,e,Tt,_t,St,Wt,Bt,mn,Lt]);const Oe=(xe,ot)=>c.jsxs(c.Fragment,{children:[xe,Pe!==null?c.jsx(Kv,{open:!0,autoHideDuration:8e3,onClose:()=>Qe(null),variant:"success",children:$re(Pe)}):null,x!==null?c.jsx(Wre,{open:w,message:x,onClose:Gs,onRetry:()=>void Tt({manual:!0,keepFailure:!0}),retrying:n}):ot]});if(Ze)return Oe(c.jsxs(Ta,{tone:"failed",children:[c.jsx(lu,{tone:"failed",children:Ze.cancelledByRelaunch?"The update was cancelled":"The last update didn't finish"}),c.jsx("p",{className:"mb-2 text-body text-ink-muted",children:Ze.message}),c.jsx("p",{className:"mt-2 text-body text-ink",children:Ze.remedy.text}),(Ze.attempts??1)>1&&c.jsxs("p",{className:"mt-1 text-body-sm text-ink-muted",children:["Version ",Ze.targetVersion," has failed to install"," ",Ze.attempts," times on this machine."]}),c.jsx("p",{className:"mt-1 text-body-sm text-ink-muted",children:"This is also recorded in Settings, under Application updates."}),c.jsxs(Ra,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:()=>gt(null),children:"Update later"}),c.jsx(ce,{variant:"outline",size:"sm",onClick:()=>void Tt({manual:!0}),disabled:n,children:n?"Checking...":"Check for updates"}),c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>sn(Ze.remedy.url),children:"Open download page"})]}),Ze.detail&&c.jsx(du,{detail:Ze.detail})]}));if(dt)return Oe(c.jsxs(Ta,{role:"alert",children:[c.jsx(lu,{children:"The update is still installing"}),c.jsx("p",{className:"mb-2 text-body text-ink-muted",children:dt.message}),c.jsxs(Ra,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:()=>Et(null),children:"Keep using Local Operator (cancels the install)"}),c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>void fi(),children:"Quit and let the update finish"})]}),dt.detail&&c.jsx(du,{detail:dt.detail})]}));if(n)return Oe(c.jsxs(Ta,{children:[c.jsx("h2",{className:"mb-3 text-heading text-ink",children:r?"Updating server":"Checking for updates"}),c.jsx("p",{className:"mb-2 text-body text-ink-muted",children:r?D==="installing"?A?"Rebuilding the server from this machine's checkout. The app waited for the turns running on this machine to finish first, and the rebuild reinstalls this install in place - so a turn started while it runs can still be interrupted - and it can take several minutes (up to half an hour). It can't be interrupted once it has started.":`Rolling the server onto ${vu(j?.latestVersion)??"the new build"}. Nothing in flight is cut off - the turns running on this machine keep running. The update can't be interrupted once it has started.`:D==="restarting"?"The new build has landed. Nothing in flight was cut off - the turns running on this machine kept running - and the server is restarting onto the new build now, so it is offline while it comes back: usually a few seconds, up to half a minute. After that the app starts a runtime again for any session the restart left without one, which can take up to a minute.":D==="draining"?`Waiting for the turns running on this machine to finish. ${Kre} - and the update can't be interrupted while it waits.`:M6(j)?"Please wait while the server is being updated. The server will temporarily go offline while it restarts to apply the update. The update can't be interrupted once it has started.":"Please wait while the server is being updated. The update can't be interrupted once it has started.":"Please wait while we check for available updates..."}),k&&!r&&c.jsx("p",{className:"mt-1 text-body-sm text-ink-muted",children:"Still checking. A slow or stalled connection can hold this for about a minute and a half - the app stops waiting on its own."}),P&&r&&D==="installing"&&!A&&c.jsx("p",{className:"mt-1 text-body-sm text-ink-muted",children:"Still installing. A slow connection or a cold cache can hold this longer - the app stops waiting on its own."}),D==="draining"&&Z!==null&&c.jsx("p",{className:"mt-1 text-body-sm text-ink-muted tabular-nums",children:Jre(Z)}),c.jsx(WD,{children:c.jsx(vS,{})})]}));if(Ae)return Oe(c.jsxs(Ta,{tone:"failed",children:[c.jsx(lu,{tone:"failed",children:Ae.heading??Zre[Ae.code]??"The update wasn't installed"}),c.jsx("p",{className:"mb-2 text-body text-ink-muted",children:Ae.message}),c.jsx("p",{className:"mt-2 text-body text-ink",children:Ae.remedy.text}),Ae.remedy.command&&c.jsx(ov,{command:Ae.remedy.command}),c.jsxs(Ra,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:()=>{ve(null),St(an.UI)},children:Ae.dismissLabel??"Update later"}),Ae.remedy.url?c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>sn(Ae.remedy.url),children:"Open download page"}):c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>void Tt({manual:!0}),disabled:n,children:n?"Checking...":"Check for updates"})]}),Ae.detail&&c.jsx(du,{detail:Ae.detail})]}));if(ae&&Q)return Oe(c.jsxs(Ta,{children:[c.jsx(lu,{children:Q.appOwned?"The app cannot update this server":"The server needs updating by hand"}),c.jsx("p",{className:"mb-2 text-body text-ink",children:Q.message}),c.jsx(iie,{latestVersion:Q.latestVersion,runningVersion:Q.currentVersion,installVersion:Q.installVersion}),Q.command?c.jsx(ov,{command:Q.command}):null,c.jsx($D,{command:!!Q.command,sourceBuild:Q.sourceBuild===!0,appOwned:Q.appOwned===!0}),c.jsxs(Ra,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:()=>{re(!1),pe(null),St(an.BACKEND)},children:"Update later"}),c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>void Nr(),disabled:n,children:n?"Checking...":"Check for updates"})]}),Q.detail&&c.jsx(du,{detail:Q.detail})]}));if(a&&!m&&l&&vt[an.UI])return Oe(c.jsxs(Ta,{onClose:()=>en(an.UI),closeLabel:"Close app update details",children:[c.jsx("h2",{className:"mb-3 text-heading text-ink",children:"Update available"}),c.jsxs("p",{className:"mb-2 text-body text-ink-muted",children:["Version ",l.version," is available. You are currently using version ",E,"."]}),l.releaseNotes&&c.jsxs("div",{className:_("mt-2 text-body text-ink-muted",nie),children:["Release notes:"," ",typeof l.releaseNotes=="string"?c.jsxs(c.Fragment,{children:[SV(oie(l.releaseNotes,400)),l.releaseNotes.length>400&&c.jsx("a",{href:zD(l),target:"_blank",rel:"noopener noreferrer",className:"ml-2",children:"View full release notes"})]}):c.jsx("a",{href:zD(l),target:"_blank",rel:"noopener noreferrer",children:"See release notes on GitHub"})]}),d&&f&&c.jsxs(WD,{children:[c.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Downloading: ",Math.round(f.percent),"%"]}),c.jsx(vS,{value:f.percent,className:"mt-2"}),c.jsxs("p",{className:"mt-1 text-mono-sm text-ink-dim",title:`${f.transferred.toLocaleString()} of ${f.total.toLocaleString()} bytes`,children:[oS(f.transferred)," of"," ",oS(f.total)]})]}),T&&c.jsx("p",{className:"mb-2 text-body-sm text-ink-muted",children:"Still downloading. A download that stops making progress is cancelled after about 90 seconds."}),c.jsx(Ra,{children:!d&&c.jsxs(c.Fragment,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:De,disabled:d,children:"Update later"}),c.jsx(ce,{variant:"primary",size:"sm",onClick:Mi,disabled:d,children:"Download update"})]})})]}));if(m&&l)return Oe(c.jsxs(Ta,{children:[c.jsx("h2",{className:"mb-3 text-heading text-ink",children:"Update ready to install"}),c.jsxs("p",{className:"mb-2 text-body text-ink-muted",children:["Version ",l.version," has been downloaded. You are currently using version ",E,"."]}),c.jsx("p",{className:"mt-2 text-body text-ink-muted",children:"Installing closes the app while the update is verified and put in place — usually a few seconds, occasionally a few minutes. Don't reopen it until it starts by itself. Opening it while the update is installing cancels the install."}),ke?c.jsx("output",{className:"mt-2 block text-body text-ink-muted",children:Gre(ie)}):null,c.jsxs(Ra,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:De,disabled:ke,children:"Update later"}),c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>void Us(),disabled:ke,children:"Install now"})]})]}),c.jsx(Kv,{open:w,autoHideDuration:6e3,onClose:Gs,variant:"success",children:"Update downloaded and ready to install"}));if(M){const xe=M.installerOutput?{sentence:M.message,output:M.installerOutput}:tie(M.message),ot=M.refusal;return Oe(ot?c.jsxs(Ta,{children:[c.jsx(lu,{children:"The update didn't start"}),c.jsx("p",{className:"mb-2 text-body text-ink",children:xe.sentence}),xe.output&&c.jsx("p",{className:"text-body-sm text-ink-muted",children:xe.output}),ot.command&&c.jsxs("div",{className:"mt-2",children:[c.jsx("p",{className:"text-body-sm text-ink-muted",children:"To update now, run this yourself in a terminal:"}),c.jsx(ov,{command:ot.command})]}),M.logPath&&c.jsx("div",{className:"mt-2",children:c.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>{window.api.showItemInFolder(M.logPath)},children:"Reveal update log"})}),c.jsxs(Ra,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:()=>void Tn(),children:"Try again"}),c.jsx(ce,{variant:"primary",size:"sm",onClick:_e,children:"Update later"})]})]}):c.jsxs(Ta,{tone:"failed",children:[c.jsx(lu,{tone:"failed",children:"The server update didn't finish"}),c.jsx("p",{className:"mb-2 text-body text-ink-muted",children:xe.sentence}),xe.output&&c.jsx(eie,{output:xe.output}),M.logPath&&c.jsx("div",{className:"mt-2",children:c.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>{window.api.showItemInFolder(M.logPath)},children:"Reveal update log"})}),c.jsxs(Ra,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:_e,children:"Update later"}),c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>void Tn(),children:"Try again"})]})]}))}if(H&&j&&vt[an.BACKEND]){const xe=Ure(j.releaseNotes,j.latestVersion);return Oe(c.jsxs(Ta,{onClose:()=>en(an.BACKEND),closeLabel:"Close server update details",children:[c.jsx("h2",{className:"mb-3 text-heading text-ink",children:"Server update available"}),c.jsx("p",{className:"mb-2 text-body text-ink-muted",children:O6({latestVersion:j.latestVersion,installVersion:j.currentVersion,runningVersion:j.runningVersion})}),xe&&c.jsxs("div",{className:"mt-2 break-words text-body text-ink-muted",children:["Release notes: ",xe.summary," ",c.jsxs("a",{href:xe.url,target:"_blank",rel:"noopener noreferrer",className:"whitespace-nowrap",children:["View full release notes for ",xe.version]})]}),!j.appOwned&&c.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:"Updating the server will improve AI functionality, improve security, and fix bugs."}),j.canManageUpdate?c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"mt-4 text-body text-ink",children:rie(j)}),c.jsxs(Ra,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:Fn,disabled:n,children:"Update later"}),c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>void Tn(),disabled:n,children:n?"Updating...":"Update server"})]}),j.detail&&c.jsx(du,{detail:j.detail})]}):c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"mt-4 text-body text-ink",children:j.remedy??"The server is installed outside the app, so use the tool you installed it with - uv, pipx or pip:"}),j.updateCommand&&c.jsx(ov,{command:j.updateCommand}),c.jsx($D,{command:!!j.updateCommand,sourceBuild:j.sourceBuild===!0,appOwned:j.appOwned===!0}),c.jsxs(Ra,{children:[c.jsx(ce,{variant:"outline",size:"sm",onClick:Fn,disabled:n,children:j.appOwned?"Understood":"Update later"}),!j.appOwned&&c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>void Nr(),disabled:n,children:n?"Checking...":"Check for updates"})]}),j.detail&&c.jsx(du,{detail:j.detail})]})]}))}if(Y){const xe=VD(U);return Oe(null,c.jsxs(Kv,{open:!0,autoHideDuration:xe===null?6e3:8e3,onClose:()=>oe(!1),variant:"success",children:["Server update completed successfully",xe===null?null:c.jsx("p",{className:"text-body-sm text-ink",children:xe})]}))}if(le){const{installVersion:xe,runningVersion:ot,unattended:B,restartable:z,releaseRead:V,appOwnedEnvironment:K,kind:q}=le,X=z&&K,fe=q==="restart-failed";return Oe(c.jsxs(Ta,{children:[c.jsx(lu,{children:fe?"The server did not come back after the restart":"The server is on an older build than the install"}),c.jsx("p",{className:"mb-2 text-body text-ink-muted",children:q==="up-to-date"?V?`This machine's install is up to date${xe?` (${xe})`:""}, and the server serving this app is still running ${ot??"an older build"}.`:`This machine's install is ${xe??"a newer build"}, and the server serving this app is still running ${ot??"an older build"}.`:q==="restart-failed"?`The install is now at ${xe??"the new version"}, and the server serving this app did not answer after it was restarted.`:B?`An update you started before quitting finished while Local Operator was closed, so the install is now at ${xe??"a newer version"}. Nothing restarted the server that was serving you${ot?`, which still reports ${ot}`:""}.`:z?`The install is now at ${xe??"the new version"}, but the server serving this app is still running ${ot??"the build it loaded"}. That restart did not take.`:`The install is now at ${xe??"the new version"}, but the server serving this app was started outside Local Operator, so it was left running${ot?` on ${ot}`:""}.`}),c.jsx("p",{className:"mb-2 text-body text-ink-muted",children:fe?X?`This app started that server, so it can restart it. ${Xre}`:"Nothing is serving this conversation until that server is running again.":X?`This app started that server, so it can restart it onto the new build now. ${Yre}`:z?"Restart Local Operator and the server comes back on the new build.":"The server serving this app was started outside Local Operator, which does not restart a server it did not start: stop it and start Local Operator again, or restart whatever started it, and it comes back on the new build."}),c.jsxs(Ra,{children:[c.jsx(ce,{variant:X?"outline":"primary",size:"sm",onClick:()=>{L.current=GD(le),R(null)},children:"Understood"}),X&&c.jsx(ce,{variant:"primary",size:"sm",onClick:()=>{R(null),Tn(xe)},children:"Restart the server"})]})]}))}return Oe(null)},oie=(e,t)=>e.length<=t?e:`${e.substring(0,t)}...`,zD=e=>{if(e.releaseNotes&&typeof e.releaseNotes!="string"){const t=e.releaseNotes,n=`https://github.com/damianvtran/local-operator-ui/releases/tag/v${e.version}`;return t.path||n}return`https://github.com/damianvtran/local-operator-ui/releases/tag/v${e.version}`};let Nh=null;const Yx=new Set;function lie(e){if(e!==Nh){Nh=e;for(const t of Yx)t()}}function cie(e){if(Nh!==null&&!(e!==void 0&&Nh!==e)){Nh=null;for(const t of Yx)t()}}function qD(){return Nh}function uie(e){return Yx.add(e),()=>{Yx.delete(e)}}function L6(){return g.useSyncExternalStore(g.useCallback(uie,[]),qD,qD)}function die(e,t){return e===null?{kind:"browser"}:t.some(s=>s.session_id===e)?{kind:"conversation",sessionId:e}:{kind:"browser"}}function hie(e,t){return e===null||t===void 0?!1:!t.some(n=>n.entryId===e)}function fie(e,t,n){return e===null||t===void 0?!0:t.some(s=>s.entryId===e&&s.expiresAt>n)}const pie=6e4,B6=6e4,gie=5,mie=5*B6;function j6(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"?t.origin:null}catch{return null}}function H6(e,t){return e.filter(n=>t<n.expiresAt)}function KD(e,t){let n=0;for(const s of e)t<s.expiresAt&&(n+=1);return n}function vie(e,t){const n=e-t;if(n<=0)return null;if(n<pie)return"expires in under a minute";const s=Math.ceil(n/B6);return s===1?"expires in 1 minute":`expires in ${s} minutes`}function xie(e,t){return H6(e,t).map((n,s)=>({request:n,ordinal:s+1,remaining:vie(n.expiresAt,t)}))}function bie(e,t){const n=new Map;for(const r of e)n.has(r.request.origin)||n.set(r.request.origin,r.ordinal);const s={};for(const r of t){if(r.owner!=="agent")continue;const i=j6(r.url);if(!i)continue;const a=n.get(i);a!==void 0&&(s[r.tabId]=a)}return s}function wie(e,t,n,s,r,i){const a=new Set(t.map(d=>d.entryId)),o=e.filter(d=>!a.has(d.entryId)&&!s.has(d.entryId)).map(d=>({key:d.entryId,kind:d.expiresAt<=i?"expired":"withdrawn",origin:d.origin,authority:d.authority,at:i})),l=t.filter(d=>d.expiresAt<=i&&!s.has(d.entryId)).map(d=>({key:d.entryId,kind:"expired",origin:d.origin,authority:d.authority,at:i})),u=new Set([...r,...n.map(d=>d.key)]);return[...o,...l].filter(d=>!u.has(d.key)).concat(n).filter(d=>i-d.at<mie).slice(0,gie)}function Cie(e){switch(e){case"origin":return"This site";case"domain":return"Whole domain";case"host":return"This host";case"deny":return"Denied";case"session":return"This session only"}}function yie(e,t){return t==="all"?[...e]:e.filter(n=>n.requesterSessionId===t.sessionId)}let K_=Date.now();const pE=new Set;let wp=null,vy=0;function U6(e){K_=e;for(const t of pE)t(e)}function Y_(){return U6(Date.now()),K_}function Sie(){return vy+=1,wp===null&&(wp=setInterval(()=>U6(Date.now()),1e3)),()=>{vy-=1,!(vy>0||wp===null)&&(clearInterval(wp),wp=null)}}function G6(e){const[t,n]=g.useState(()=>K_),s=e(t);return g.useEffect(()=>{if(s!==0)return Sie()},[s]),g.useEffect(()=>(pE.add(n),()=>{pE.delete(n)}),[]),t}function $6(e,t){const n=G6(d=>H6(e,d).length),s=g.useRef([]),[r,i]=g.useState([]),a=g.useRef(new Set),o=g.useRef(new Set),l=g.useCallback((d,h,f)=>i(p=>wie(d,h,p,a.current,o.current,f)),[]);g.useEffect(()=>{for(const d of r)o.current.add(d.key)},[r]),g.useEffect(()=>{const d=Y_(),h=s.current;s.current=e,l(h,e,d)},[e,l]),g.useEffect(()=>{l(e,e,n)},[n,e,l]);const u=xie(e,n);return{now:n,rows:u,resolved:r,waiting:bie(u,t),count:u.length,noteDecision:g.useCallback(d=>{a.current.add(d)},[])}}function ff(){return window.api?.browser??null}function V6(){return ff()!==null}const gE={state:null,readError:null};let pf=gE;const ox=new Set;let Xx=null,mE=!1,Qx=0,Jx=0;function hm(e){pf=e;for(const t of ox)t()}function vE(){return pf}function Eie(){pf.readError!==null&&hm({state:pf.state,readError:null})}function kie(e){Jx=Qx,hm({state:e,readError:null})}async function gg(){const e=ff();if(!e)return null;const t=++Qx;try{const n=await e.state();return!n||!Array.isArray(n.tabs)?null:(t>Jx&&(Jx=t,hm({state:n,readError:null})),n)}catch(n){return t===Qx&&hm({state:pf.state,readError:z_(n)}),null}}function _ie(e){return ox.add(e),Tie(),()=>{ox.delete(e),ox.size===0&&Rie()}}function Tie(){const e=ff();if(e){if(!Xx){const t=e.onStateChanged(()=>void gg()),n=e.onConsentChanged(()=>void gg());Xx=()=>{t(),n()}}mE||(mE=!0,gg())}}function Rie(){Xx?.(),Xx=null,mE=!1,pf!==gE&&hm(gE),Jx=Qx}function Aie(){return g.useSyncExternalStore(_ie,vE,vE)}function xy(e){ff()?.setContentRect(e).catch(()=>{})}function Pw(){const{state:e,readError:t}=Aie();return{state:e,readError:t,refresh:gg,clearReadError:Eie}}function Fie(){const{state:e,readError:t,refresh:n,clearReadError:s}=Pw(),[r,i]=g.useState(null),[a,o]=g.useState(null),l=V6(),u=r??t,d=g.useCallback(async()=>{const C=await n();C?.url&&C.url!=="about:blank"&&o(null)},[n]),h=g.useCallback(async C=>{let E=!0;try{await C(),i(null)}catch(y){E=!1,i(z_(y))}return await d(),E},[d]),f=g.useCallback(C=>h(C).then(()=>{}),[h]),p=g.useCallback(()=>{i(null),s()},[s]),m=g.useRef(null),v=g.useRef(null),x=g.useCallback(C=>{if(C===null){m.current!==null&&(cancelAnimationFrame(m.current),m.current=null),v.current=null,xy(null);return}v.current=C,m.current===null&&(m.current=requestAnimationFrame(()=>{m.current=null,xy(v.current)}))},[]);g.useEffect(()=>()=>{m.current!==null&&cancelAnimationFrame(m.current),xy(null)},[]);const b=g.useCallback(C=>{ff()?.setViewVisible(C).catch(()=>{})},[]),w=ff();return g.useMemo(()=>({state:e,pendingUrl:a,error:u,dismissError:p,available:l,refresh:d,newTab:C=>f(()=>w?.newTab(C??null)),closeTab:C=>h(()=>w?.closeTab(C)),closeTabs:C=>h(()=>w?.closeTabs(C)),activateTab:C=>f(()=>w?.activateTab(C)),navigate:C=>(o(C),f(()=>w?.navigate(C))),reload:()=>f(()=>w?.reload()),stop:()=>f(()=>w?.stop()),retry:()=>f(()=>w?.retry()),history:C=>f(()=>w?.history(C)),setContentRect:x,setViewVisible:b,respondToConsent:(C,E)=>f(()=>w?.respondToConsent(C,E)),handOver:(C,E)=>f(()=>w?.handOver(C,E)),revokeHandOver:C=>f(()=>w?.revokeHandOver(C)),revokeApproval:C=>f(()=>w?.revokeApproval(C)),revokeAllApprovals:()=>f(()=>w?.revokeAllApprovals()),forgetSite:C=>f(()=>w?.forgetSite(C)),clearData:C=>f(()=>w?.clearData(C)),revealDownloads:()=>f(async()=>{const E=(await w?.revealDownloads())?.message;typeof E=="string"&&E&&$t(`Could not open the downloads folder. ${E}`)})}),[e,a,u,p,l,d,h,f,x,b,w])}function Die(){const e=L6(),n=Pw().state?.pendingConsent,s=hie(e,n),r=g.useRef(null);g.useEffect(()=>{e===null||r.current===e||(r.current=e,gg().then(()=>{const i=r.current;if(i===null)return;r.current=null;const a=vE().state?.pendingConsent;a!==void 0&&(fie(i,a,Y_())||La("That request is no longer waiting."))}))},[e]),g.useEffect(()=>{e===null||!s||cie(e)},[e,s])}const Pie=`It leaves your lists. You can undo for ${yS/1e3} seconds; after that, search above your chats, turn on “Include archived”, then Unarchive it.`,Iie="this conversation",Nie="Archive";function YD(e){return document.querySelector(`[data-session-row="${CSS.escape(e)}"]`)}function W6(e){const t=Array.from(document.querySelectorAll('[data-sidebar-region="chats"] [data-chat-row]')),n=e.closest("[data-session-row]")?.querySelector("[data-chat-row]")??null,s=n!==null&&t.includes(n)?t:Array.from(document.querySelectorAll("[data-chat-row]")),r=n===null?-1:s.indexOf(n);return()=>{const i=s.map((o,l)=>({element:o,position:l})).filter(({element:o})=>o.isConnected);(i.find(({position:o})=>o>r)?.element??i.filter(({position:o})=>o<r).at(-1)?.element)?.focus({preventScroll:!0})}}const Mie=()=>{const e=Ce(u=>u.archiveCandidate),t=Ce(u=>u.sessions),n=Ce(u=>u.requestArchiveConfirm),s=Ce(u=>u.setSessionArchived),r=g.useRef(null),i=g.useRef(null),a=g.useRef(!1),o=g.useRef(!1);g.useEffect(()=>{if(e!==null){i.current=e.sessionId,a.current=e.fromRow,o.current=e.fromHeader===!0,r.current=document.activeElement instanceof HTMLElement?document.activeElement:null;return}const u=i.current,d=a.current,f=o.current?null:r.current;if(r.current=null,i.current=null,f?.isConnected&&(f.focus({preventScroll:!0}),document.activeElement===f))return;const p=u===null?null:YD(u)?.querySelector("[data-chat-row]")??null,m=document.querySelector("[data-conversation-actions]");(d?p??m:m??p)?.focus({preventScroll:!0})},[e]);const l=t.find(u=>u.session_id===e?.sessionId)?.title||e?.title||null;return c.jsx(Lc,{open:e!==null,title:c.jsxs("span",{className:"flex min-w-0 items-center",children:[c.jsx("span",{className:"shrink-0",children:`${Nie} ${l===null?"":"“"}`}),c.jsx("span",{className:"min-w-0 truncate",children:l===null?Iie:l}),c.jsx("span",{className:"shrink-0",children:l===null?"?":"”?"})]}),message:c.jsx("p",{children:Pie}),confirmText:"Archive",cancelText:"Cancel",isDangerous:!0,onConfirm:()=>{if(!e)return;const{sessionId:u,fromRow:d}=e;n(null);const h=d?YD(u):null,f=h===null?null:W6(h);s(u,!0,t.find(p=>p.session_id===u)?.title??void 0).then(p=>{p&&f?.()})},onCancel:()=>n(null)})};function jf(e,t){const s=Ce.getState().openSession(t),r=`/chat/${t}`;return e(r),s.then(i=>{if(i||Kk()!==r)return;const a=Ce.getState();if(a.activeDraftKey){e("/chat",{replace:!0});return}const o=a.activeSessionId;e(o?`/chat/${o}`:"/chat",{replace:!0})}),s}const z6=["desktop","aida"],Oie="aida";function Lie(){const e=os();return d0(yt(e.data,"aida",1)).data?.name??"Aida"}function hXe(e,t){return e===Oie?t:e}function d0(e){return Os({queryKey:z6,queryFn:()=>Ct({op:"aida.status"}),enabled:e,staleTime:3e4,retry:m3})}async function Bie(e){return Ct({op:"aida.control",action:e})}function X_(){const e=hn();return g.useCallback(async t=>{const n=await Bie(t);return e.invalidateQueries({queryKey:z6}),n},[e])}function q6(){const e=X_();return g.useCallback(async t=>{const n=t?.session_id??null,s=n?null:await e("open"),r=n??s?.session_id??null;if(!r)throw new Error("Aida's conversation could not be opened.");return r},[e])}function jie(){const e=q6();return g.useCallback(async(t,n)=>{const s=await e(n);return jf(t,s),s},[e])}const XD={}.hasOwnProperty;function K6(e,t){const n=t||{};function s(r,...i){let a=s.invalid;const o=s.handlers;if(r&&XD.call(r,e)){const l=String(r[e]);a=XD.call(o,l)?o[l]:s.unknown}if(a)return a.call(this,r,...i)}return s.handlers=n.handlers||{},s.invalid=n.invalid,s.unknown=n.unknown,s}const Hie={}.hasOwnProperty;function Y6(e,t){let n=-1,s;if(t.extensions)for(;++n<t.extensions.length;)Y6(e,t.extensions[n]);for(s in t)if(Hie.call(t,s))switch(s){case"extensions":break;case"unsafe":{QD(e[s],t[s]);break}case"join":{QD(e[s],t[s]);break}case"handlers":{Uie(e[s],t[s]);break}default:e.options[s]=t[s]}return e}function QD(e,t){t&&e.push(...t)}function Uie(e,t){t&&Object.assign(e,t)}const Gie=[$ie];function $ie(e,t,n,s){if(t.type==="code"&&KA(t,s)&&(e.type==="list"||e.type===t.type&&KA(e,s)))return!1;if("spread"in n&&typeof n.spread=="boolean")return e.type==="paragraph"&&(e.type===t.type||t.type==="definition"||t.type==="heading"&&EV(t,s))?void 0:n.spread?1:0}const cu=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"],Vie=[{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"\r",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:`
453
453
  `,inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde","codeFencedMetaGraveAccent","codeFencedMetaTilde","destinationLiteral","headingAtx"]},{character:" ",after:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",before:"[\\r\\n]",inConstruct:"phrasing"},{character:" ",inConstruct:["codeFencedLangGraveAccent","codeFencedLangTilde"]},{character:"!",after:"\\[",inConstruct:"phrasing",notInConstruct:cu},{character:'"',inConstruct:"titleQuote"},{atBreak:!0,character:"#"},{character:"#",inConstruct:"headingAtx",after:`(?:[\r
454
454
  ]|$)`},{character:"&",after:"[#A-Za-z]",inConstruct:"phrasing"},{character:"'",inConstruct:"titleApostrophe"},{character:"(",inConstruct:"destinationRaw"},{before:"\\]",character:"(",inConstruct:"phrasing",notInConstruct:cu},{atBreak:!0,before:"\\d+",character:")"},{character:")",inConstruct:"destinationRaw"},{atBreak:!0,character:"*",after:`(?:[ \r
455
455
  *])`},{character:"*",inConstruct:"phrasing",notInConstruct:cu},{atBreak:!0,character:"+",after:`(?:[ \r
@@ -674,7 +674,7 @@ ${q7(s)}`)}function w7e(e){const t=new Map;for(const n of e){const s=f2(n.path);
674
674
  * LICENSE file in the root directory of this source tree.
675
675
  */var AL;function IWe(){if(AL)return Hp;AL=1;var e=Ge,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,p=null;u!==void 0&&(f=""+u),l.key!==void 0&&(f=""+l.key),l.ref!==void 0&&(p=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:p,props:h,_owner:r.current}}return Hp.Fragment=n,Hp.jsx=a,Hp.jsxs=a,Hp}var FL;function NWe(){return FL||(FL=1,RL.exports=IWe()),RL.exports}var MWe=NWe();/*! shepherd.js 14.5.0 */function OWe(e){return e instanceof Element}function Tf(e){return e instanceof HTMLElement}function Ic(e){return typeof e=="function"}function qm(e){return typeof e=="string"}function Er(e){return e===void 0}class sA{on(t,n,s,r=!1){var i;return Er(this.bindings)&&(this.bindings={}),Er(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(Er(this.bindings)||Er(this.bindings[t]))return this;if(Er(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(!Er(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 ci(){return ci=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},ci.apply(null,arguments)}function rA(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 $c={defaultMerge:Symbol("deepmerge-ts: default merge"),skip:Symbol("deepmerge-ts: skip")};$c.defaultMerge;function LWe(e,t){return t}function BWe(e,t){return e.filter(n=>n!==void 0)}var DL;(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"})(DL||(DL={}));function PL(e){return typeof e!="object"||e===null?0:Array.isArray(e)?2:UWe(e)?1:e instanceof Set?3:e instanceof Map?4:5}function jWe(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 HWe(e,t){return typeof e=="object"&&Object.prototype.propertyIsEnumerable.call(e,t)}function h9(e){return{*[Symbol.iterator](){for(const t of e)for(const n of t)yield n}}}const IL=new Set(["[object Object]","[object Module]"]);function UWe(e){if(!IL.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"||!IL.has(Object.prototype.toString.call(n))||!n.hasOwnProperty("isPrototypeOf"))}function GWe(e,t,n){const s={};for(const r of jWe(e)){const i=[];for(const l of e)HWe(l,r)&&i.push(l[r]);if(i.length===0)continue;const a=t.metaDataUpdater(n,{key:r,parents:e}),o=f9(i,t,a);o!==$c.skip&&(r==="__proto__"?Object.defineProperty(s,r,{value:o,configurable:!0,enumerable:!0,writable:!0}):s[r]=o)}return s}function $We(e){return e.flat()}function VWe(e){return new Set(h9(e))}function WWe(e){return new Map(h9(e))}function zWe(e){return e.at(-1)}const Wv={mergeRecords:GWe,mergeArrays:$We,mergeSets:VWe,mergeMaps:WWe,mergeOthers:zWe};function iA(...e){return qWe({})(...e)}function qWe(e,t){const n=KWe(e,s);function s(...r){return f9(r,n,t)}return s}function KWe(e,t){var n,s,r;return{defaultMergeFunctions:Wv,mergeFunctions:ci({},Wv,Object.fromEntries(Object.entries(e).filter(([i,a])=>Object.hasOwn(Wv,i)).map(([i,a])=>a===!1?[i,Wv.mergeOthers]:[i,a]))),metaDataUpdater:(n=e.metaDataUpdater)!=null?n:LWe,deepmerge:t,useImplicitDefaultMerging:(s=e.enableImplicitDefaultMerging)!=null?s:!1,filterValues:e.filterValues===!1?void 0:(r=e.filterValues)!=null?r:BWe,actions:$c}}function f9(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 nS(r,t,n);const i=PL(r[0]);if(i!==0&&i!==5){for(let a=1;a<r.length;a++)if(PL(r[a])!==i)return nS(r,t,n)}switch(i){case 1:return YWe(r,t,n);case 2:return XWe(r,t,n);case 3:return QWe(r,t,n);case 4:return JWe(r,t,n);default:return nS(r,t,n)}}function YWe(e,t,n){const s=t.mergeFunctions.mergeRecords(e,t,n);return s===$c.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeRecords!==t.defaultMergeFunctions.mergeRecords?t.defaultMergeFunctions.mergeRecords(e,t,n):s}function XWe(e,t,n){const s=t.mergeFunctions.mergeArrays(e,t,n);return s===$c.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeArrays!==t.defaultMergeFunctions.mergeArrays?t.defaultMergeFunctions.mergeArrays(e):s}function QWe(e,t,n){const s=t.mergeFunctions.mergeSets(e,t,n);return s===$c.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeSets!==t.defaultMergeFunctions.mergeSets?t.defaultMergeFunctions.mergeSets(e):s}function JWe(e,t,n){const s=t.mergeFunctions.mergeMaps(e,t,n);return s===$c.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeMaps!==t.defaultMergeFunctions.mergeMaps?t.defaultMergeFunctions.mergeMaps(e):s}function nS(e,t,n){const s=t.mergeFunctions.mergeOthers(e,t,n);return s===$c.defaultMerge||t.useImplicitDefaultMerging&&s===void 0&&t.mergeFunctions.mergeOthers!==t.defaultMergeFunctions.mergeOthers?t.defaultMergeFunctions.mergeOthers(e):s}function aA(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 ZWe(e,t){return n=>{if(e.isOpen()){const s=e.el&&n.currentTarget===e.el;(!Er(t)&&n.currentTarget.matches(t)||s)&&e.tour.next()}}}function eze(e){const{event:t,selector:n}=e.options.advanceOn||{};if(t){const s=ZWe(e,n);let r=null;if(!Er(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 tze{constructor(t){}}class nze{constructor(t,n){}}function p9(e){return!qm(e)||e===""?"":e.charAt(e.length-1)!=="-"?`${e}-`:e}function sze(e){const t=e.options.attachTo||{},n=Object.assign({},t);if(Ic(n.element)&&(n.element=n.element.call(e)),qm(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 rze(e){return e.options.extraHighlights?e.options.extraHighlights.flatMap(t=>Array.from(document.querySelectorAll(t))):[]}function g9(e){return e==null?!0:!e.element||!e.on}function m9(){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 ize=["top","right","bottom","left"],NL=["start","end"],ML=ize.reduce((e,t)=>e.concat(t,t+"-"+NL[0],t+"-"+NL[1]),[]),Rf=Math.min,qu=Math.max,ew=Math.round,zv=Math.floor,Ao=e=>({x:e,y:e}),aze={left:"right",right:"left",bottom:"top",top:"bottom"},oze={start:"end",end:"start"};function Hk(e,t,n){return qu(e,Rf(t,n))}function md(e,t){return typeof e=="function"?e(t):e}function kl(e){return e.split("-")[0]}function bl(e){return e.split("-")[1]}function oA(e){return e==="x"?"y":"x"}function lA(e){return e==="y"?"height":"width"}function Af(e){return["top","bottom"].includes(kl(e))?"y":"x"}function cA(e){return oA(Af(e))}function v9(e,t,n){n===void 0&&(n=!1);const s=bl(e),r=cA(e),i=lA(r);let a=r==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=nw(a)),[a,nw(a)]}function lze(e){const t=nw(e);return[tw(e),t,tw(t)]}function tw(e){return e.replace(/start|end/g,t=>oze[t])}function cze(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 uze(e,t,n,s){const r=bl(e);let i=cze(kl(e),n==="start",s);return r&&(i=i.map(a=>a+"-"+r),t&&(i=i.concat(i.map(tw)))),i}function nw(e){return e.replace(/left|right|bottom|top/g,t=>aze[t])}function dze(e){return ci({top:0,right:0,bottom:0,left:0},e)}function x9(e){return typeof e!="number"?dze(e):{top:e,right:e,bottom:e,left:e}}function sw(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 hze=["crossAxis","alignment","allowedPlacements","autoAlignment"],fze=["mainAxis","crossAxis","fallbackPlacements","fallbackStrategy","fallbackAxisSideDirection","flipAlignment"],pze=["mainAxis","crossAxis","limiter"];function OL(e,t,n){let{reference:s,floating:r}=e;const i=Af(t),a=cA(t),o=lA(a),l=kl(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 p;switch(l){case"top":p={x:d,y:s.y-r.height};break;case"bottom":p={x:d,y:s.y+s.height};break;case"right":p={x:s.x+s.width,y:h};break;case"left":p={x:s.x-r.width,y:h};break;default:p={x:s.x,y:s.y}}switch(bl(t)){case"start":p[a]-=f*(n&&u?-1:1);break;case"end":p[a]+=f*(n&&u?-1:1);break}return p}const gze=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}=OL(u,s,l),f=s,p={},m=0;for(let v=0;v<o.length;v++){const{name:x,fn:b}=o[v],{x:w,y:C,data:E,reset:y}=await b({x:d,y:h,initialPlacement:s,placement:f,strategy:r,middlewareData:p,rects:u,platform:a,elements:{reference:e,floating:t}});d=w??d,h=C??h,p=ci({},p,{[x]:ci({},p[x],E)}),y&&m<=50&&(m++,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}=OL(u,f,l)),v=-1)}return{x:d,y:h,placement:f,strategy:r,middlewareData:p}};async function uA(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:p=0}=md(t,e),m=x9(p),v=o[f?h==="floating"?"reference":"floating":h],x=sw(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(v)))==null||n?v:v.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:u,rootBoundary:d,strategy:l})),b=h==="floating"?{x:s,y:r,width:a.floating.width,height:a.floating.height}:a.reference,w=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),C=await(i.isElement==null?void 0:i.isElement(w))?await(i.getScale==null?void 0:i.getScale(w))||{x:1,y:1}:{x:1,y:1},E=sw(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:b,offsetParent:w,strategy:l}):b);return{top:(x.top-E.top+m.top)/C.y,bottom:(E.bottom-x.bottom+m.bottom)/C.y,left:(x.left-E.left+m.left)/C.x,right:(E.right-x.right+m.right)/C.x}}const mze=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}=md(e,t)||{};if(u==null)return{};const h=x9(d),f={x:n,y:s},p=cA(r),m=lA(p),v=await a.getDimensions(u),x=p==="y",b=x?"top":"left",w=x?"bottom":"right",C=x?"clientHeight":"clientWidth",E=i.reference[m]+i.reference[p]-f[p]-i.floating[m],y=f[p]-i.reference[p],k=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let T=k?k[C]:0;(!T||!await(a.isElement==null?void 0:a.isElement(k)))&&(T=o.floating[C]||i.floating[m]);const P=E/2-y/2,A=T/2-v[m]/2-1,N=Rf(h[b],A),M=Rf(h[w],A),I=N,H=T-v[m]-M,G=T/2-v[m]/2+P,j=Hk(I,G,H),J=!l.arrow&&bl(r)!=null&&G!==j&&i.reference[m]/2-(G<I?N:M)-v[m]/2<0,Y=J?G<I?G-I:G-H:0;return{[p]:f[p]+Y,data:ci({[p]:j,centerOffset:G-j-Y},J&&{alignmentOffset:Y}),reset:J}}});function vze(e,t,n){return(e?[...n.filter(s=>bl(s)===e),...n.filter(s=>bl(s)!==e)]:n.filter(s=>kl(s)===s)).filter(s=>e?bl(s)===e||(t?tw(s)!==s:!1):!0)}const xze=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=md(e,t),{crossAxis:h=!1,alignment:f,allowedPlacements:p=ML,autoAlignment:m=!0}=d,v=rA(d,hze),x=f!==void 0||p===ML?vze(f||null,m,p):p,b=await uA(t,v),w=((n=a.autoPlacement)==null?void 0:n.index)||0,C=x[w];if(C==null)return{};const E=v9(C,i,await(l.isRTL==null?void 0:l.isRTL(u.floating)));if(o!==C)return{reset:{placement:x[0]}};const y=[b[kl(C)],b[E[0]],b[E[1]]],k=[...((s=a.autoPlacement)==null?void 0:s.overflows)||[],{placement:C,overflows:y}],T=x[w+1];if(T)return{data:{index:w+1,overflows:k},reset:{placement:T}};const P=k.map(N=>{const M=bl(N.placement);return[N.placement,M&&h?N.overflows.slice(0,2).reduce((I,H)=>I+H,0):N.overflows[0],N.overflows]}).sort((N,M)=>N[1]-M[1]),A=((r=P.filter(N=>N[2].slice(0,bl(N[0])?2:3).every(M=>M<=0))[0])==null?void 0:r[0])||P[0][0];return A!==o?{data:{index:w+1,overflows:k},reset:{placement:A}}:{}}}},bze=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=md(e,t),{mainAxis:h=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:x=!0}=d,b=rA(d,fze);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const w=kl(r),C=Af(o),E=kl(o)===o,y=await(l.isRTL==null?void 0:l.isRTL(u.floating)),k=p||(E||!x?[nw(o)]:lze(o)),T=v!=="none";!p&&T&&k.push(...uze(o,x,v,y));const P=[o,...k],A=await uA(t,b),N=[];let M=((s=i.flip)==null?void 0:s.overflows)||[];if(h&&N.push(A[w]),f){const j=v9(r,a,y);N.push(A[j[0]],A[j[1]])}if(M=[...M,{placement:r,overflows:N}],!N.every(j=>j<=0)){var I,H;const j=(((I=i.flip)==null?void 0:I.index)||0)+1,J=P[j];if(J)return{data:{index:j,overflows:M},reset:{placement:J}};let Y=(H=M.filter(oe=>oe.overflows[0]<=0).sort((oe,U)=>oe.overflows[1]-U.overflows[1])[0])==null?void 0:H.placement;if(!Y)switch(m){case"bestFit":{var G;const oe=(G=M.filter(U=>{if(T){const te=Af(U.placement);return te===C||te==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(te=>te>0).reduce((te,le)=>te+le,0)]).sort((U,te)=>U[1]-te[1])[0])==null?void 0:G[0];oe&&(Y=oe);break}case"initialPlacement":Y=o;break}if(r!==Y)return{reset:{placement:Y}}}return{}}}},wze=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:r}=t,i=md(e,t),{mainAxis:a=!0,crossAxis:o=!1,limiter:l={fn:b=>{let{x:w,y:C}=b;return{x:w,y:C}}}}=i,u=rA(i,pze),d={x:n,y:s},h=await uA(t,u),f=Af(kl(r)),p=oA(f);let m=d[p],v=d[f];if(a){const b=p==="y"?"top":"left",w=p==="y"?"bottom":"right",C=m+h[b],E=m-h[w];m=Hk(C,m,E)}if(o){const b=f==="y"?"top":"left",w=f==="y"?"bottom":"right",C=v+h[b],E=v-h[w];v=Hk(C,v,E)}const x=l.fn(ci({},t,{[p]:m,[f]:v}));return ci({},x,{data:{x:x.x-n,y:x.y-s}})}}},Cze=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}=md(e,t),d={x:n,y:s},h=Af(r),f=oA(h);let p=d[f],m=d[h];const v=md(o,t),x=typeof v=="number"?{mainAxis:v,crossAxis:0}:ci({mainAxis:0,crossAxis:0},v);if(l){const C=f==="y"?"height":"width",E=i.reference[f]-i.floating[C]+x.mainAxis,y=i.reference[f]+i.reference[C]-x.mainAxis;p<E?p=E:p>y&&(p=y)}if(u){var b,w;const C=f==="y"?"width":"height",E=["top","left"].includes(kl(r)),y=i.reference[h]-i.floating[C]+(E&&((b=a.offset)==null?void 0:b[h])||0)+(E?0:x.crossAxis),k=i.reference[h]+i.reference[C]+(E?0:((w=a.offset)==null?void 0:w[h])||0)-(E?x.crossAxis:0);m<y?m=y:m>k&&(m=k)}return{[f]:p,[h]:m}}}};function fC(){return typeof window<"u"}function Zf(e){return b9(e)?(e.nodeName||"").toLowerCase():"#document"}function Di(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Go(e){var t;return(t=(b9(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function b9(e){return fC()?e instanceof Node||e instanceof Di(e).Node:!1}function Va(e){return fC()?e instanceof Element||e instanceof Di(e).Element:!1}function Mo(e){return fC()?e instanceof HTMLElement||e instanceof Di(e).HTMLElement:!1}function LL(e){return!fC()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Di(e).ShadowRoot}function P0(e){const{overflow:t,overflowX:n,overflowY:s,display:r}=Wa(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!["inline","contents"].includes(r)}function yze(e){return["table","td","th"].includes(Zf(e))}function pC(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function dA(e){const t=hA(),n=Va(e)?Wa(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 Sze(e){let t=Nc(e);for(;Mo(t)&&!Ff(t);){if(dA(t))return t;if(pC(t))return null;t=Nc(t)}return null}function hA(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Ff(e){return["html","body","#document"].includes(Zf(e))}function Wa(e){return Di(e).getComputedStyle(e)}function gC(e){return Va(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Nc(e){if(Zf(e)==="html")return e;const t=e.assignedSlot||e.parentNode||LL(e)&&e.host||Go(e);return LL(t)?t.host:t}function w9(e){const t=Nc(e);return Ff(t)?e.ownerDocument?e.ownerDocument.body:e.body:Mo(t)&&P0(t)?t:w9(t)}function Km(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=w9(e),i=r===((s=e.ownerDocument)==null?void 0:s.body),a=Di(r);if(i){const o=Uk(a);return t.concat(a,a.visualViewport||[],P0(r)?r:[],o&&n?Km(o):[])}return t.concat(r,Km(r,[],n))}function Uk(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function C9(e){const t=Wa(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const r=Mo(e),i=r?e.offsetWidth:n,a=r?e.offsetHeight:s,o=ew(n)!==i||ew(s)!==a;return o&&(n=i,s=a),{width:n,height:s,$:o}}function fA(e){return Va(e)?e:e.contextElement}function Jh(e){const t=fA(e);if(!Mo(t))return Ao(1);const n=t.getBoundingClientRect(),{width:s,height:r,$:i}=C9(t);let a=(i?ew(n.width):n.width)/s,o=(i?ew(n.height):n.height)/r;return(!a||!Number.isFinite(a))&&(a=1),(!o||!Number.isFinite(o))&&(o=1),{x:a,y:o}}const Eze=Ao(0);function y9(e){const t=Di(e);return!hA()||!t.visualViewport?Eze:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function kze(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Di(e)?!1:t}function vd(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),i=fA(e);let a=Ao(1);t&&(s?Va(s)&&(a=Jh(s)):a=Jh(e));const o=kze(i,n,s)?y9(i):Ao(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=Di(i),p=s&&Va(s)?Di(s):s;let m=f,v=Uk(m);for(;v&&s&&p!==m;){const x=Jh(v),b=v.getBoundingClientRect(),w=Wa(v),C=b.left+(v.clientLeft+parseFloat(w.paddingLeft))*x.x,E=b.top+(v.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,u*=x.y,d*=x.x,h*=x.y,l+=C,u+=E,m=Di(v),v=Uk(m)}}return sw({width:d,height:h,x:l,y:u})}function pA(e,t){const n=gC(e).scrollLeft;return t?t.left+n:vd(Go(e)).left+n}function S9(e,t,n){n===void 0&&(n=!1);const s=e.getBoundingClientRect(),r=s.left+t.scrollLeft-(n?0:pA(e,s)),i=s.top+t.scrollTop;return{x:r,y:i}}function _ze(e){let{elements:t,rect:n,offsetParent:s,strategy:r}=e;const i=r==="fixed",a=Go(s),o=t?pC(t.floating):!1;if(s===a||o&&i)return n;let l={scrollLeft:0,scrollTop:0},u=Ao(1);const d=Ao(0),h=Mo(s);if((h||!h&&!i)&&((Zf(s)!=="body"||P0(a))&&(l=gC(s)),Mo(s))){const p=vd(s);u=Jh(s),d.x=p.x+s.clientLeft,d.y=p.y+s.clientTop}const f=a&&!h&&!i?S9(a,l,!0):Ao(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 Tze(e){return Array.from(e.getClientRects())}function Rze(e){const t=Go(e),n=gC(e),s=e.ownerDocument.body,r=qu(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),i=qu(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let a=-n.scrollLeft+pA(e);const o=-n.scrollTop;return Wa(s).direction==="rtl"&&(a+=qu(t.clientWidth,s.clientWidth)-r),{width:r,height:i,x:a,y:o}}function Aze(e,t){const n=Di(e),s=Go(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=hA();(!u||u&&t==="fixed")&&(o=r.offsetLeft,l=r.offsetTop)}return{width:i,height:a,x:o,y:l}}function Fze(e,t){const n=vd(e,!0,t==="fixed"),s=n.top+e.clientTop,r=n.left+e.clientLeft,i=Mo(e)?Jh(e):Ao(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 BL(e,t,n){let s;if(t==="viewport")s=Aze(e,n);else if(t==="document")s=Rze(Go(e));else if(Va(t))s=Fze(t,n);else{const r=y9(e);s={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return sw(s)}function E9(e,t){const n=Nc(e);return n===t||!Va(n)||Ff(n)?!1:Wa(n).position==="fixed"||E9(n,t)}function Dze(e,t){const n=t.get(e);if(n)return n;let s=Km(e,[],!1).filter(o=>Va(o)&&Zf(o)!=="body"),r=null;const i=Wa(e).position==="fixed";let a=i?Nc(e):e;for(;Va(a)&&!Ff(a);){const o=Wa(a),l=dA(a);!l&&o.position==="fixed"&&(r=null),(i?!l&&!r:!l&&o.position==="static"&&r&&["absolute","fixed"].includes(r.position)||P0(a)&&!l&&E9(e,a))?s=s.filter(u=>u!==a):r=o,a=Nc(a)}return t.set(e,s),s}function Pze(e){let{element:t,boundary:n,rootBoundary:s,strategy:r}=e;const i=[...n==="clippingAncestors"?pC(t)?[]:Dze(t,this._c):[].concat(n),s],a=i[0],o=i.reduce((l,u)=>{const d=BL(t,u,r);return l.top=qu(d.top,l.top),l.right=Rf(d.right,l.right),l.bottom=Rf(d.bottom,l.bottom),l.left=qu(d.left,l.left),l},BL(t,a,r));return{width:o.right-o.left,height:o.bottom-o.top,x:o.left,y:o.top}}function Ize(e){const{width:t,height:n}=C9(e);return{width:t,height:n}}function Nze(e,t,n){const s=Mo(t),r=Go(t),i=n==="fixed",a=vd(e,!0,i,t);let o={scrollLeft:0,scrollTop:0};const l=Ao(0);if(s||!s&&!i)if((Zf(t)!=="body"||P0(r))&&(o=gC(t)),s){const f=vd(t,!0,i,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else r&&(l.x=pA(r));const u=r&&!s&&!i?S9(r,o):Ao(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 sS(e){return Wa(e).position==="static"}function jL(e,t){if(!Mo(e)||Wa(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Go(e)===n&&(n=n.ownerDocument.body),n}function k9(e,t){const n=Di(e);if(pC(e))return n;if(!Mo(e)){let r=Nc(e);for(;r&&!Ff(r);){if(Va(r)&&!sS(r))return r;r=Nc(r)}return n}let s=jL(e,t);for(;s&&yze(s)&&sS(s);)s=jL(s,t);return s&&Ff(s)&&sS(s)&&!dA(s)?n:s||Sze(e)||n}const Mze=async function(e){const t=this.getOffsetParent||k9,n=this.getDimensions,s=await n(e.floating);return{reference:Nze(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function Oze(e){return Wa(e).direction==="rtl"}const Lze={convertOffsetParentRelativeRectToViewportRelativeRect:_ze,getDocumentElement:Go,getClippingRect:Pze,getOffsetParent:k9,getElementRects:Mze,getClientRects:Tze,getDimensions:Ize,getScale:Jh,isElement:Va,isRTL:Oze};function Bze(e,t){let n=null,s;const r=Go(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 p=zv(d),m=zv(r.clientWidth-(u+h)),v=zv(r.clientHeight-(d+f)),x=zv(u),b={rootMargin:-p+"px "+-m+"px "+-v+"px "+-x+"px",threshold:qu(0,Rf(1,l))||1};let w=!0;function C(E){const y=E[0].intersectionRatio;if(y!==l){if(!w)return a();y?a(!1,y):s=setTimeout(()=>{a(!1,1e-7)},1e3)}w=!1}try{n=new IntersectionObserver(C,ci({},b,{root:r.ownerDocument}))}catch{n=new IntersectionObserver(C,b)}n.observe(e)}return a(!0),i}function jze(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=fA(e),d=r||i?[...u?Km(u):[],...Km(t)]:[];d.forEach(b=>{r&&b.addEventListener("scroll",n,{passive:!0}),i&&b.addEventListener("resize",n)});const h=u&&o?Bze(u,n):null;let f=-1,p=null;a&&(p=new ResizeObserver(b=>{let[w]=b;w&&w.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var C;(C=p)==null||C.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let m,v=l?vd(e):null;l&&x();function x(){const b=vd(e);v&&(b.x!==v.x||b.y!==v.y||b.width!==v.width||b.height!==v.height)&&n(),v=b,m=requestAnimationFrame(x)}return n(),()=>{var b;d.forEach(w=>{r&&w.removeEventListener("scroll",n),i&&w.removeEventListener("resize",n)}),h?.(),(b=p)==null||b.disconnect(),p=null,l&&cancelAnimationFrame(m)}}const Hze=xze,Uze=wze,Gze=bze,$ze=mze,Vze=Cze,Wze=(e,t,n)=>{const s=new Map,r=ci({platform:Lze},n),i=ci({},r.platform,{_c:s});return gze(e,t,ci({},r,{platform:i}))};function zze(e){e.cleanup&&e.cleanup();const t=e._getResolvedAttachToOptions();let n=t.element;const s=Jze(t,e),r=g9(t);return r&&(n=document.body,e.shepherdElementComponent.getElement().classList.add("shepherd-centered")),e.cleanup=jze(n,e.el,()=>{if(!e.el){e.cleanup==null||e.cleanup();return}Yze(n,e,s,r)}),e.target=t.element,s}function qze(e,t){return{floatingUIOptions:iA(e.floatingUIOptions||{},t.floatingUIOptions||{})}}function Kze(e){e.cleanup&&e.cleanup(),e.cleanup=null}function Yze(e,t,n,s){return Wze(e,t.el,n).then(Xze(t,s)).then(r=>new Promise(i=>{setTimeout(()=>i(r),300)})).then(r=>{r!=null&&r.el&&r.el.focus({preventScroll:!0})})}function Xze(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,Qze(e.el,i)),e)}function Qze(e,t){const n=e.querySelector(".shepherd-arrow");if(Tf(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 Jze(e,t){var n,s,r;const i={strategy:"absolute"};i.middleware=[];const a=Zze(t),o=g9(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(Hze({crossAxis:!0,alignment:u?e==null||(d=e.on)==null?void 0:d.split("-").pop():null}))}else i.middleware.push(Gze());if(i.middleware.push(Uze({limiter:Vze(),crossAxis:!0})),a){const h=typeof t.options.arrow=="object"?t.options.arrow:{padding:4};i.middleware.push($ze({element:a,padding:u?h.padding:0}))}l||(i.placement=e.on)}return iA(i,t.options.floatingUIOptions||{})}function Zze(e){return e.options.arrow&&e.el?e.el.querySelector(".shepherd-arrow"):!1}function Ni(){}function eqe(e,t){for(const n in t)e[n]=t[n];return e}function _9(e){return e()}function HL(){return Object.create(null)}function I0(e){e.forEach(_9)}function gA(e){return typeof e=="function"}function Ol(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function tqe(e){return Object.keys(e).length===0}function Df(e,t){e.appendChild(t)}function Ja(e,t,n){e.insertBefore(t,n||null)}function ma(e){e.parentNode&&e.parentNode.removeChild(e)}function nqe(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function Oo(e){return document.createElement(e)}function UL(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function T9(e){return document.createTextNode(e)}function rw(){return T9(" ")}function sqe(){return T9("")}function mC(e,t,n,s){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n,s)}function Nn(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}const rqe=["width","height"];function GL(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&&rqe.indexOf(s)===-1?e[s]=t[s]:Nn(e,s,t[s])}function iqe(e){return Array.from(e.childNodes)}function sh(e,t,n){e.classList.toggle(t,!!n)}let Ym;function Wg(e){Ym=e}function R9(){if(!Ym)throw new Error("Function called outside component initialization");return Ym}function aqe(e){R9().$$.on_mount.push(e)}function mA(e){R9().$$.after_update.push(e)}const ph=[],Pf=[];let Zh=[];const $L=[],oqe=Promise.resolve();let Gk=!1;function lqe(){Gk||(Gk=!0,oqe.then(A9))}function $k(e){Zh.push(e)}const rS=new Set;let rh=0;function A9(){if(rh!==0)return;const e=Ym;do{try{for(;rh<ph.length;){const t=ph[rh];rh++,Wg(t),cqe(t.$$)}}catch(t){throw ph.length=0,rh=0,t}for(Wg(null),ph.length=0,rh=0;Pf.length;)Pf.pop()();for(let t=0;t<Zh.length;t+=1){const n=Zh[t];rS.has(n)||(rS.add(n),n())}Zh.length=0}while(ph.length);for(;$L.length;)$L.pop()();Gk=!1,rS.clear(),Wg(e)}function cqe(e){if(e.fragment!==null){e.update(),I0(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach($k)}}function uqe(e){const t=[],n=[];Zh.forEach(s=>e.indexOf(s)===-1?t.push(s):n.push(s)),n.forEach(s=>s()),Zh=t}const Sx=new Set;let Au;function Ku(){Au={r:0,c:[],p:Au}}function Yu(){Au.r||I0(Au.c),Au=Au.p}function yn(e,t){e&&e.i&&(Sx.delete(e),e.i(t))}function gs(e,t,n,s){if(e&&e.o){if(Sx.has(e))return;Sx.add(e),Au.c.push(()=>{Sx.delete(e),s&&(n&&e.d(1),s())}),e.o(t)}else s&&s()}function VL(e){return e?.length!==void 0?e:Array.from(e)}function dqe(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 Nd(e){e&&e.c()}function Vc(e,t,n){const{fragment:s,after_update:r}=e.$$;s&&s.m(t,n),$k(()=>{const i=e.$$.on_mount.map(_9).filter(gA);e.$$.on_destroy?e.$$.on_destroy.push(...i):I0(i),e.$$.on_mount=[]}),r.forEach($k)}function Wc(e,t){const n=e.$$;n.fragment!==null&&(uqe(n.after_update),I0(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function hqe(e,t){e.$$.dirty[0]===-1&&(ph.push(e),lqe(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function Ll(e,t,n,s,r,i,a=null,o=[-1]){const l=Ym;Wg(e);const u=e.$$={fragment:null,ctx:[],props:i,update:Ni,not_equal:r,bound:HL(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:HL(),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,...p)=>{const m=p.length?p[0]:f;return u.ctx&&r(u.ctx[h],u.ctx[h]=m)&&(!u.skip_bound&&u.bound[h]&&u.bound[h](m),d&&hqe(e,h)),f}):[],u.update(),d=!0,I0(u.before_update),u.fragment=s?s(u.ctx):!1,t.target){if(t.hydrate){const h=iqe(t.target);u.fragment&&u.fragment.l(h),h.forEach(ma)}else u.fragment&&u.fragment.c();t.intro&&yn(e.$$.fragment),Vc(e,t.target,t.anchor),A9()}Wg(l)}class Bl{constructor(){this.$$=void 0,this.$$set=void 0}$destroy(){Wc(this,1),this.$destroy=Ni}$on(t,n){if(!gA(n))return Ni;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&&!tqe(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const fqe="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(fqe);function pqe(e){let t,n,s,r,i;return{c(){t=Oo("button"),Nn(t,"aria-label",n=e[3]?e[3]:null),Nn(t,"class",s=`${e[1]||""} shepherd-button ${e[4]?"shepherd-button-secondary":""}`),t.disabled=e[2],Nn(t,"tabindex","0"),Nn(t,"type","button")},m(a,o){Ja(a,t,o),t.innerHTML=e[5],r||(i=mC(t,"click",function(){gA(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)&&Nn(t,"aria-label",n),o&18&&s!==(s=`${e[1]||""} shepherd-button ${e[4]?"shepherd-button-secondary":""}`)&&Nn(t,"class",s),o&4&&(t.disabled=e[2])},i:Ni,o:Ni,d(a){a&&ma(t),r=!1,i()}}}function gqe(e,t,n){let{config:s,step:r}=t,i,a,o,l,u,d;function h(f){return Ic(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 mqe extends Bl{constructor(t){super(),Ll(this,t,gqe,pqe,Ol,{config:6,step:7})}}function WL(e,t,n){const s=e.slice();return s[2]=t[n],s}function zL(e){let t,n,s=VL(e[1]),r=[];for(let a=0;a<s.length;a+=1)r[a]=qL(WL(e,s,a));const i=a=>gs(r[a],1,1,()=>{r[a]=null});return{c(){for(let a=0;a<r.length;a+=1)r[a].c();t=sqe()},m(a,o){for(let l=0;l<r.length;l+=1)r[l]&&r[l].m(a,o);Ja(a,t,o),n=!0},p(a,o){if(o&3){s=VL(a[1]);let l;for(l=0;l<s.length;l+=1){const u=WL(a,s,l);r[l]?(r[l].p(u,o),yn(r[l],1)):(r[l]=qL(u),r[l].c(),yn(r[l],1),r[l].m(t.parentNode,t))}for(Ku(),l=s.length;l<r.length;l+=1)i(l);Yu()}},i(a){if(!n){for(let o=0;o<s.length;o+=1)yn(r[o]);n=!0}},o(a){r=r.filter(Boolean);for(let o=0;o<r.length;o+=1)gs(r[o]);n=!1},d(a){a&&ma(t),nqe(r,a)}}}function qL(e){let t,n;return t=new mqe({props:{config:e[2],step:e[0]}}),{c(){Nd(t.$$.fragment)},m(s,r){Vc(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||(yn(t.$$.fragment,s),n=!0)},o(s){gs(t.$$.fragment,s),n=!1},d(s){Wc(t,s)}}}function vqe(e){let t,n,s=e[1]&&zL(e);return{c(){t=Oo("footer"),s&&s.c(),Nn(t,"class","shepherd-footer")},m(r,i){Ja(r,t,i),s&&s.m(t,null),n=!0},p(r,[i]){r[1]?s?(s.p(r,i),i&2&&yn(s,1)):(s=zL(r),s.c(),yn(s,1),s.m(t,null)):s&&(Ku(),gs(s,1,1,()=>{s=null}),Yu())},i(r){n||(yn(s),n=!0)},o(r){gs(s),n=!1},d(r){r&&ma(t),s&&s.d()}}}function xqe(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 bqe extends Bl{constructor(t){super(),Ll(this,t,xqe,vqe,Ol,{step:0})}}function wqe(e){let t,n,s,r,i;return{c(){t=Oo("button"),n=Oo("span"),n.textContent="×",Nn(n,"aria-hidden","true"),Nn(t,"aria-label",s=e[0].label?e[0].label:"Close Tour"),Nn(t,"class","shepherd-cancel-icon"),Nn(t,"type","button")},m(a,o){Ja(a,t,o),Df(t,n),r||(i=mC(t,"click",e[1]),r=!0)},p(a,[o]){o&1&&s!==(s=a[0].label?a[0].label:"Close Tour")&&Nn(t,"aria-label",s)},i:Ni,o:Ni,d(a){a&&ma(t),r=!1,i()}}}function Cqe(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 yqe extends Bl{constructor(t){super(),Ll(this,t,Cqe,wqe,Ol,{cancelIcon:0,step:2})}}function Sqe(e){let t;return{c(){t=Oo("h3"),Nn(t,"id",e[1]),Nn(t,"class","shepherd-title")},m(n,s){Ja(n,t,s),e[3](t)},p(n,[s]){s&2&&Nn(t,"id",n[1])},i:Ni,o:Ni,d(n){n&&ma(t),e[3](null)}}}function Eqe(e,t,n){let{labelId:s,element:r,title:i}=t;mA(()=>{Ic(i)&&n(2,i=i()),n(0,r.innerHTML=i,r)});function a(o){Pf[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 kqe extends Bl{constructor(t){super(),Ll(this,t,Eqe,Sqe,Ol,{labelId:1,element:0,title:2})}}function KL(e){let t,n;return t=new kqe({props:{labelId:e[0],title:e[2]}}),{c(){Nd(t.$$.fragment)},m(s,r){Vc(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||(yn(t.$$.fragment,s),n=!0)},o(s){gs(t.$$.fragment,s),n=!1},d(s){Wc(t,s)}}}function YL(e){let t,n;return t=new yqe({props:{cancelIcon:e[3],step:e[1]}}),{c(){Nd(t.$$.fragment)},m(s,r){Vc(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||(yn(t.$$.fragment,s),n=!0)},o(s){gs(t.$$.fragment,s),n=!1},d(s){Wc(t,s)}}}function _qe(e){let t,n,s,r=e[2]&&KL(e),i=e[3]&&e[3].enabled&&YL(e);return{c(){t=Oo("header"),r&&r.c(),n=rw(),i&&i.c(),Nn(t,"class","shepherd-header")},m(a,o){Ja(a,t,o),r&&r.m(t,null),Df(t,n),i&&i.m(t,null),s=!0},p(a,[o]){a[2]?r?(r.p(a,o),o&4&&yn(r,1)):(r=KL(a),r.c(),yn(r,1),r.m(t,n)):r&&(Ku(),gs(r,1,1,()=>{r=null}),Yu()),a[3]&&a[3].enabled?i?(i.p(a,o),o&8&&yn(i,1)):(i=YL(a),i.c(),yn(i,1),i.m(t,null)):i&&(Ku(),gs(i,1,1,()=>{i=null}),Yu())},i(a){s||(yn(r),yn(i),s=!0)},o(a){gs(r),gs(i),s=!1},d(a){a&&ma(t),r&&r.d(),i&&i.d()}}}function Tqe(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 Rqe extends Bl{constructor(t){super(),Ll(this,t,Tqe,_qe,Ol,{labelId:0,step:1})}}function Aqe(e){let t;return{c(){t=Oo("div"),Nn(t,"class","shepherd-text"),Nn(t,"id",e[1])},m(n,s){Ja(n,t,s),e[3](t)},p(n,[s]){s&2&&Nn(t,"id",n[1])},i:Ni,o:Ni,d(n){n&&ma(t),e[3](null)}}}function Fqe(e,t,n){let{descriptionId:s,element:r,step:i}=t;mA(()=>{let{text:o}=i.options;Ic(o)&&(o=o.call(i)),Tf(o)?r.appendChild(o):n(0,r.innerHTML=o,r)});function a(o){Pf[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 Dqe extends Bl{constructor(t){super(),Ll(this,t,Fqe,Aqe,Ol,{descriptionId:1,element:0,step:2})}}function XL(e){let t,n;return t=new Rqe({props:{labelId:e[1],step:e[2]}}),{c(){Nd(t.$$.fragment)},m(s,r){Vc(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||(yn(t.$$.fragment,s),n=!0)},o(s){gs(t.$$.fragment,s),n=!1},d(s){Wc(t,s)}}}function QL(e){let t,n;return t=new Dqe({props:{descriptionId:e[0],step:e[2]}}),{c(){Nd(t.$$.fragment)},m(s,r){Vc(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||(yn(t.$$.fragment,s),n=!0)},o(s){gs(t.$$.fragment,s),n=!1},d(s){Wc(t,s)}}}function JL(e){let t,n;return t=new bqe({props:{step:e[2]}}),{c(){Nd(t.$$.fragment)},m(s,r){Vc(t,s,r),n=!0},p(s,r){const i={};r&4&&(i.step=s[2]),t.$set(i)},i(s){n||(yn(t.$$.fragment,s),n=!0)},o(s){gs(t.$$.fragment,s),n=!1},d(s){Wc(t,s)}}}function Pqe(e){let t,n=!Er(e[2].options.title)||e[2].options.cancelIcon&&e[2].options.cancelIcon.enabled,s,r=!Er(e[2].options.text),i,a=Array.isArray(e[2].options.buttons)&&e[2].options.buttons.length,o,l=n&&XL(e),u=r&&QL(e),d=a&&JL(e);return{c(){t=Oo("div"),l&&l.c(),s=rw(),u&&u.c(),i=rw(),d&&d.c(),Nn(t,"class","shepherd-content")},m(h,f){Ja(h,t,f),l&&l.m(t,null),Df(t,s),u&&u.m(t,null),Df(t,i),d&&d.m(t,null),o=!0},p(h,[f]){f&4&&(n=!Er(h[2].options.title)||h[2].options.cancelIcon&&h[2].options.cancelIcon.enabled),n?l?(l.p(h,f),f&4&&yn(l,1)):(l=XL(h),l.c(),yn(l,1),l.m(t,s)):l&&(Ku(),gs(l,1,1,()=>{l=null}),Yu()),f&4&&(r=!Er(h[2].options.text)),r?u?(u.p(h,f),f&4&&yn(u,1)):(u=QL(h),u.c(),yn(u,1),u.m(t,i)):u&&(Ku(),gs(u,1,1,()=>{u=null}),Yu()),f&4&&(a=Array.isArray(h[2].options.buttons)&&h[2].options.buttons.length),a?d?(d.p(h,f),f&4&&yn(d,1)):(d=JL(h),d.c(),yn(d,1),d.m(t,null)):d&&(Ku(),gs(d,1,1,()=>{d=null}),Yu())},i(h){o||(yn(l),yn(u),yn(d),o=!0)},o(h){gs(l),gs(u),gs(d),o=!1},d(h){h&&ma(t),l&&l.d(),u&&u.d(),d&&d.d()}}}function Iqe(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 Nqe extends Bl{constructor(t){super(),Ll(this,t,Iqe,Pqe,Ol,{descriptionId:0,labelId:1,step:2})}}function ZL(e){let t;return{c(){t=Oo("div"),Nn(t,"class","shepherd-arrow"),Nn(t,"data-popper-arrow","")},m(n,s){Ja(n,t,s)},d(n){n&&ma(t)}}}function Mqe(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&&ZL();s=new Nqe({props:{descriptionId:e[2],labelId:e[3],step:e[4]}});let d=[{"aria-describedby":r=Er(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=eqe(h,d[f]);return{c(){t=Oo("dialog"),u&&u.c(),n=rw(),Nd(s.$$.fragment),GL(t,h),sh(t,"shepherd-has-cancel-icon",e[5]),sh(t,"shepherd-has-title",e[6]),sh(t,"shepherd-element",!0)},m(f,p){Ja(f,t,p),u&&u.m(t,null),Df(t,n),Vc(s,t,null),e[13](t),a=!0,o||(l=mC(t,"keydown",e[7]),o=!0)},p(f,[p]){f[4].options.arrow&&f[4].options.attachTo&&f[4].options.attachTo.element&&f[4].options.attachTo.on?u||(u=ZL(),u.c(),u.m(t,n)):u&&(u.d(1),u=null);const m={};p&4&&(m.descriptionId=f[2]),p&8&&(m.labelId=f[3]),p&16&&(m.step=f[4]),s.$set(m),GL(t,h=dqe(d,[(!a||p&20&&r!==(r=Er(f[4].options.text)?null:f[2]))&&{"aria-describedby":r},(!a||p&24&&i!==(i=f[4].options.title?f[3]:null))&&{"aria-labelledby":i},p&2&&f[1],{open:"true"}])),sh(t,"shepherd-has-cancel-icon",f[5]),sh(t,"shepherd-has-title",f[6]),sh(t,"shepherd-element",!0)},i(f){a||(yn(s.$$.fragment,f),a=!0)},o(f){gs(s.$$.fragment,f),a=!1},d(f){f&&ma(t),u&&u.d(),Wc(s),e[13](null),o=!1,l()}}}const Oqe=9,Lqe=27,Bqe=37,jqe=39;function e3(e){return e.split(" ").filter(t=>!!t.length)}function Hqe(e,t,n){let{classPrefix:s,element:r,descriptionId:i,firstFocusableElement:a,focusableElements:o,labelId:l,lastFocusableElement:u,step:d,dataStepId:h}=t,f,p,m;const v=()=>r;aqe(()=>{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])}),mA(()=>{m!==d.options.classes&&x()});function x(){b(m),m=d.options.classes,w(m)}function b(y){if(qm(y)){const k=e3(y);k.length&&r.classList.remove(...k)}}function w(y){if(qm(y)){const k=e3(y);k.length&&r.classList.add(...k)}}const C=y=>{const{tour:k}=d;switch(y.keyCode){case Oqe: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 Lqe:k.options.exitOnEsc&&(y.preventDefault(),y.stopPropagation(),d.cancel());break;case Bqe:k.options.keyboardNavigation&&(y.preventDefault(),y.stopPropagation(),k.back());break;case jqe:k.options.keyboardNavigation&&(y.preventDefault(),y.stopPropagation(),k.next());break}};function E(y){Pf[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,p=d.options&&d.options.title))},[r,h,i,l,d,f,p,C,a,o,u,s,v,E]}class Uqe extends Bl{constructor(t){super(),Ll(this,t,Hqe,Mqe,Ol,{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 Vk extends sA{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?p9(this.tour.options.classPrefix):"",this.styles=t.styles,this._resolvedAttachTo=null,aA(this),this._setOptions(n),this}cancel(){this.tour.cancel(),this.trigger("cancel")}complete(){this.tour.complete(),this.trigger("complete")}destroy(){Kze(this),Tf(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=rze(this),this._resolvedExtraHighlightElements}_resolveAttachToOptions(){return this._resolvedAttachTo=sze(this),this._resolvedAttachTo}_getResolvedAttachToOptions(){return this._resolvedAttachTo===null?this._resolveAttachToOptions():this._resolvedAttachTo}isOpen(){return!!(this.el&&!this.el.hidden)}show(){return Ic(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 Uqe({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();Ic(this.options.scrollToHandler)?this.options.scrollToHandler(n):OWe(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=iA({},n||{}),this.options=Object.assign({arrow:!0},n,t,qze(n,t));const{when:s}=this.options;this.options.classes=this._getClassOptions(t),this.destroy(),this.id=this.options.id||`step-${m9()}`,s&&Object.keys(s).forEach(r=>{this.on(r,s[r],this)})}_setupElements(){Er(this.el)||this.destroy(),this.el=this._createTooltipContent(),this.options.advanceOn&&eze(this),zze(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 Gqe(e){if(e){const{steps:t}=e;t.forEach(n=>{n.options&&n.options.canClickTarget===!1&&n.options.attachTo&&(Tf(n.target)&&n.target.classList.remove("shepherd-target-click-disabled"),n._resolvedExtraHighlightElements&&n._resolvedExtraHighlightElements.forEach(s=>{Tf(s)&&s.classList.remove("shepherd-target-click-disabled")}))})}}function $qe(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:p=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-p} a${p},${p},0,0,0,${p},${p} 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 Vqe(e){let t,n,s,r,i;return{c(){t=UL("svg"),n=UL("path"),Nn(n,"d",e[2]),Nn(t,"class",s=`${e[1]?"shepherd-modal-is-visible":""} shepherd-modal-overlay-container`)},m(a,o){Ja(a,t,o),Df(t,n),e[11](t),r||(i=mC(t,"touchmove",e[3]),r=!0)},p(a,[o]){o&4&&Nn(n,"d",a[2]),o&2&&s!==(s=`${a[1]?"shepherd-modal-is-visible":""} shepherd-modal-overlay-container`)&&Nn(t,"class",s)},i:Ni,o:Ni,d(a){a&&ma(t),e[11](null),r=!1,i()}}}function F9(e){if(!e)return null;const t=e instanceof HTMLElement&&window.getComputedStyle(e).overflowY;return t!=="hidden"&&t!=="visible"&&e.scrollHeight>=e.clientHeight?e:F9(e.parentElement)}function Wqe(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 zqe(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 qqe(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),b()}function h(E=0,y=0,k=0,T=0,P,A,N){if(A){const M=[A,...N||[]];n(4,r=[]);for(const I of M){if(!I||M.indexOf(I)!==M.lastIndexOf(I))continue;const{y:H,height:G}=zqe(I,P),{x:j,width:J,left:Y}=I.getBoundingClientRect();M.some(oe=>{if(oe===I)return!1;const U=oe.getBoundingClientRect();return j>=U.left&&j+J<=U.right&&H>=U.top&&H+G<=U.bottom})||r.push({width:J+E*2,height:G+E*2,x:(j||Y)+k-E,y:H+T-E,r:y})}}else u()}function f(E){b(),E.tour.options.useModalOverlay?(w(E),p()):d()}function p(){n(1,i=!0)}const m=E=>{E.preventDefault()},v=E=>{E.stopPropagation()};function x(){window.addEventListener("touchmove",m,{passive:!1})}function b(){a&&(cancelAnimationFrame(a),a=void 0),window.removeEventListener("touchmove",m,{passive:!1})}function w(E){const{modalOverlayOpeningPadding:y,modalOverlayOpeningRadius:k,modalOverlayOpeningXOffset:T=0,modalOverlayOpeningYOffset:P=0}=E.options,A=Wqe(E.target),N=F9(E.target),M=()=>{a=void 0,h(y,k,T+A.left,P+A.top,N,E.target,E._resolvedExtraHighlightElements),a=requestAnimationFrame(M)};M(),x()}function C(E){Pf[E?"unshift":"push"](()=>{s=E,n(0,s)})}return e.$$set=E=>{"element"in E&&n(0,s=E.element),"openingProperties"in E&&n(4,r=E.openingProperties)},e.$$.update=()=>{e.$$.dirty&16&&n(2,o=$qe(r))},[s,i,o,v,r,l,u,d,h,f,p,C]}class Kqe extends Bl{constructor(t){super(),Ll(this,t,qqe,Vqe,Ol,{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 Yqe extends sA{constructor(){super(),this.activeTour=void 0,aA(this)}}class Xqe extends sA{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,aA(this);const n={exitOnEsc:!0,keyboardNavigation:!0};return this.options=Object.assign({},n,t),this.classPrefix=p9(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,Fu.trigger(r,i)})})(s)}),this._setTourID(t.id),this}addStep(t,n){let s=t;return s instanceof Vk?s.tour=this:s=new Vk(this,s),Er(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;Ic(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 Fu.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=qm(t)?this.getById(t):this.steps[t];s&&(this._updateStateBeforeShow(),Ic(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()),Gqe(this),this.trigger(t,{index:n}),Fu.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)}Tf(this.focusedElBeforeOpen)&&this.focusedElBeforeOpen.focus()}_setupActiveTour(){this.trigger("active",{tour:this}),Fu.activeTour=this}setupModal(){this.modal=new Kqe({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||m9();this.id=`${n}--${s}`}}const Fu=new Yqe,D9=typeof window>"u";Fu.Step=D9?tze:Vk;Fu.Tour=D9?nze:Xqe;const vC=g.createContext(void 0);vC.Consumer;const Qqe=({children:e})=>MWe.jsx(vC.Provider,{value:{Shepherd:Fu},children:e}),Jqe=""+new URL("agentic-sequence-CExfswgi.png",import.meta.url).href,Zqe=""+new URL("canvas-code-inline-edit-DLji9b0m.png",import.meta.url).href,eKe=""+new URL("canvas-overview-CruGEIRC.png",import.meta.url).href,tKe=""+new URL("canvas-variables-view-DrA20zqs.png",import.meta.url).href,nKe=""+new URL("chat-attachments-_3cRrONU.png",import.meta.url).href,sKe=""+new URL("chat-full-view-e-eJPzrw.png",import.meta.url).href,rKe=""+new URL("chat-input-CU-CA7Se.png",import.meta.url).href,iKe=""+new URL("inline-edit-canvas-O9conTkE.png",import.meta.url).href,aKe=e=>{const t=Array.from(document.querySelectorAll(`[data-tour-tag="${e}"]`));return t.find(n=>n.offsetParent!==null)??t[0]??null},t3=e=>{document.querySelector(`[data-tour-action="${e}"]`)?.click()},n3=[{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="${sKe}" 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="${rKe}" 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="${nKe}" 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="${Jqe}" 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}=Ve.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>${vo("everything",!0)}</code> on Mac and <code>${vo("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>${vo("chats",!0)}</code> on Mac and <code>${vo("chats",!1)}</code> on Windows or Linux and the palette opens already searching your chats, so you can jump straight to one — and <code>${vo("commands",!0)}</code> on Mac and <code>${vo("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}=Ve.getState();e(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const{closeCommandPalette:e}=Ve.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}=Ve.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="${eKe}" 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="${iKe}" 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.
676
676
  <br /><img src="${Zqe}" 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="${tKe}" 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").
677
- 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:()=>aKe("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(){t3("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(()=>{t3("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()}}]}],oKe=()=>{const e=Yr(),{completeTourOnboarding:t}=Kg(),n=g.useContext(vC),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=Kg.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(n3)}else l.steps.length===0&&l.addSteps(n3);typeof l.start=="function"?(e("/"),l.start()):console.warn("Shepherd tour instance does not have a start method.",l)}}},lKe=()=>{const{isModalComplete:e,isTourComplete:t}=Kg(),{startTour:n}=oKe(),s=Ge.useContext(vC),{data:r}=oE(1,1);return g.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},cKe=({children:e})=>c.jsxs(Qqe,{children:[e,c.jsx(lKe,{})]}),uKe=()=>{const{open:e,focusGroup:t,providerId:n,closeConnect:s}=p4(),r=g.useRef(null);g.useEffect(()=>{e&&(r.current=document.activeElement instanceof HTMLElement?document.activeElement:null)},[e]);const i=Yr();return c.jsx(xd,{open:e,onOpenChange:a=>{a||s()},children:c.jsxs(bd,{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(Sc,{className:"text-title",children:"Connect a model provider"}),c.jsx(Of,{className:"text-body-sm text-ink-muted",children:"Your agents need a model to think with. Sign in with an account you already have, or add an API key."})]}),e?c.jsx(u9,{context:"dialog",featuredOnly:!0,focusGroup:t,initialProviderId:n,onDone:s,onChangeModel:()=>{s(),i("/settings")}}):null]})})},dKe=({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:_("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})]}),oQe=({label:e,value:t,className:n,valueClassName:s})=>c.jsxs("div",{className:_("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:_("mt-0.5 break-words text-body-sm",s??"text-ink"),children:t})]}),lQe=({children:e,className:t})=>c.jsx("div",{className:_("grid grid-cols-[repeat(auto-fit,minmax(160px,1fr))] gap-x-6 gap-y-4",t),children:e});async function P9(e){await Ct({op:"settings.edit",key:wo,value:e.value}),cX(e.queryClient)}async function hKe(e){await P9(e),e.queryClient.setQueryData(Rx.all,t=>t&&{...t,settings:t.settings.map(n=>n.key===wo?{...n,value:e.value,is_default:e.value===n.default}:n)});try{return await e.queryClient.fetchQuery({queryKey:Rx.all,queryFn:()=>Ct({op:"settings.list"}),staleTime:0,retry:!1}),"confirmed"}catch{return"readback-unknown"}}const cQe=({focus:e=!1})=>{const t=hn(),n=os(),s=yt(n.data,"settings"),r=Os({queryKey:Rx.all,queryFn:()=>Ct({op:"settings.list"}),enabled:s,retry:!1,refetchOnReconnect:!0}),i=r.data?.settings.find(P=>P.key===wo),[a,o]=g.useState(!1),[l,u]=g.useState(null),[d,h]=g.useState(!1),[f,p]=g.useState(!1),m=g.useRef(!1),v=g.useRef(null),x=g.useRef(!1);g.useEffect(()=>{if(!e){x.current=!1;return}!i||x.current||(v.current?.querySelector("[role=combobox]")?.focus(),x.current=!0)},[e,i]),g.useEffect(()=>{r.isSuccess&&!r.isFetching&&h(!1)},[r.isFetching,r.isSuccess]);const b=async P=>{if(!(!i||m.current||d||!i.choices.some(A=>A.value===P))){m.current=!0,o(!0),u(null),p(!1);try{const A=await hKe({value:P,queryClient:t});h(A==="readback-unknown"),p(A==="confirmed")}catch(A){u({value:P,message:A instanceof Error?A.message:""})}finally{m.current=!1,o(!1)}}},w=async()=>{const[P,A]=await Promise.all([r.refetch(),n.refetch()]);!P.isError&&!A.isError&&h(!1)},C=!r.data&&r.error||!n.data&&n.error,E=n.data&&(!s||r.data&&!i),y=!C&&!E&&!i,k=n.data?.features?.i18n?n.data.language:void 0,T=typeof k=="string"&&k!==""?k:void 0;return c.jsx(dKe,{title:ze("ui.settings.language.dialog.title"),icon:ZB,description:ze("ui.settings.language.general.description"),children:c.jsxs("div",{ref:v,"data-setting-key":wo,className:"flex flex-col gap-3","aria-busy":a,children:[y&&c.jsx("output",{className:"text-meta text-ink-dim",children:ze("ui.settings.language.dialog.loading")}),E&&c.jsx("p",{className:"text-meta text-ink-dim",children:ze("ui.settings.language.dialog.unavailable")}),i&&c.jsx(y4,{setting:{...p_(i),label:ze("ui.settings.language.dialog.title")},value:String(i.value),onValueChange:P=>{b(P)},disabled:a||d,suppressEffectiveNote:!0}),c.jsx("output",{id:lX(wo),"aria-live":"polite",className:"text-meta text-ink-dim",children:a?ze("ui.settings.language.general.pending"):f?ze("ui.settings.language.general.saved"):T?ze(d||n.error?"ui.settings.language.general.last_known":"ui.settings.language.general.effective",{locale:T}):ze("ui.settings.language.general.no_resolution")}),(C||l||d)&&c.jsx(zr,{variant:"danger",children:c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsx("p",{role:"alert",children:l?ze("ui.settings.language.general.write_error",{message:l.message}):d?ze("ui.settings.language.general.readback_error"):ze("ui.settings.language.dialog.unavailable")}),c.jsx(ce,{variant:"outline",size:"sm",disabled:a||r.isFetching||n.isFetching,onClick:()=>{l?b(l.value):w()},children:ze("ui.settings.language.dialog.retry")})]})})]})})},fKe=()=>{const e=Bk(J=>J.open),t=Bk(J=>J.closeLanguage),n=hn(),s=os(),r=yt(s.data,"settings"),i=Os({queryKey:Rx.all,queryFn:()=>Ct({op:"settings.list"}),enabled:e&&r,staleTime:1e4}),a=g.useRef(null),o=uX(),l=(i.data?.settings??[]).find(J=>J.key===wo),u=l?p_(l):void 0,[d,h]=g.useState(null),[f,p]=g.useState(!1),[m,v]=g.useState(!1),[x,b]=g.useState(null),w=g.useRef(null);g.useEffect(()=>{e&&h(null)},[e]),g.useEffect(()=>{if(!e||!u)return;const J=String(u.value??"");(d===null||d===w.current)&&h(J),w.current=J},[e,u,d]),g.useEffect(()=>{e&&(v(!1),b(null))},[e]);const C=d??String(u?.value??""),E=!!u&&C!==String(u?.value??""),y=!u||!E||f,k=async()=>{if(!(!u||!E)){p(!0),b(null);try{await P9({value:C,queryClient:n}),v(!0),h(null),await i.refetch()}catch(J){b(J instanceof Error?J.message:"The language could not be saved.")}finally{p(!1)}}},T=!!s.data,P=T&&!r,A=s.error&&!s.data?s.error:null,N=A??i.error,M=!T&&!N,{sentence:I,remedy:H}=dX(o??null,"Your settings could not be loaded.",N),G=s.isFetching||i.isFetching,j=u?"combo":N?"retry":"none";return g.useEffect(()=>{!e||j==="none"||requestAnimationFrame(()=>{a.current?.querySelector(j==="combo"?'[role="combobox"]':"[data-language-retry]")?.focus()})},[e,j]),c.jsx(xd,{open:e,onOpenChange:J=>!J&&t(),children:c.jsxs(bd,{ref:a,onOpenAutoFocus:J=>J.preventDefault(),className:"max-w-[min(28rem,calc(100vw-4rem))] gap-4",children:[c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx(Sc,{className:"text-title",children:ze("ui.settings.language.dialog.title")}),c.jsx(Of,{className:"text-body-sm text-ink-muted",children:ze("ui.settings.language.dialog.description")})]}),M?c.jsxs("div",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[c.jsx(Rn,{}),ze("ui.settings.language.dialog.loading")]}):P?c.jsx(zr,{variant:"warning",children:c.jsx("span",{children:ze("ui.settings.language.dialog.unavailable")})}):N?c.jsx(zr,{variant:"warning",children:c.jsxs("div",{className:"flex items-center justify-between gap-3",children:[c.jsx("span",{children:I}),H&&c.jsx(ce,{variant:"secondary",size:"sm",className:"shrink-0","data-language-retry":"",onClick:()=>{A?s.refetch():i.refetch()},disabled:G,children:G?ze("ui.settings.language.dialog.retrying"):ze("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(Rn,{}),ze("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:R2(wo),className:"text-meta text-ink-dim",children:u.help}),c.jsx(y4,{setting:u,value:C,disabled:f,helpId:R2(wo),effectiveNoteId:hX(wo,fX),onValueChange:J=>{v(!1),h(J)}})]}),x&&c.jsx("p",{className:"text-meta text-danger",children:x}),c.jsx("div",{className:"flex min-h-8 items-center justify-end",children:m&&!E?c.jsxs("output",{"data-language-save":"",className:"inline-flex items-center gap-1.5 text-body-sm text-ink",children:[c.jsx(Ls,{"aria-hidden":"true",className:"size-3.5"}),ze("ui.settings.language.dialog.saved")]}):c.jsx(ce,{onClick:k,disabled:y,"data-language-save":"",children:f?`${ze("ui.settings.language.dialog.save")}...`:ze("ui.settings.language.dialog.save")})})]}):c.jsx(zr,{variant:"warning",children:c.jsx("span",{children:ze("ui.settings.language.dialog.unavailable")})})]})})};function pKe(){const{data:e}=os();g.useEffect(()=>{e&&pX(e)},[e]);const t=c_(),n=hn(),s=g.useRef(null);g.useEffect(()=>{const r=t.configChange;if(!r)return;const i=`${r.epoch}:${r.seq}`;s.current!==i&&r.changedKeys.includes(wo)&&(s.current=i,n.invalidateQueries({queryKey:Fo.capabilities}),n.invalidateQueries({queryKey:Fo.settings}),!gX()&&La(ze("ui.settings.language.external_notice",{language:r.language}),{id:"i18n-language-external"}))},[t.configChange,n])}function gKe(e,t){if(e.defaultPrevented||e.repeat||e.isComposing||!(e.metaKey||e.ctrlKey))return null;const n=mX(e);if(n===null)return null;const s=BQ(t.bindings).get(n);return s===void 0||d_(e.target)||!ele(I9(s),t.route)?null:s}const I9=e=>e.slice(6);function mKe(e){const t=Ce.getState(),n=t.activeDraftKey?t.drafts[t.activeDraftKey]:void 0,s=Mf(t.activeDraftKey,n?.sessionId,t.activeSessionId)??null;xu(I9(e),{sessionId:s,askScope:s===null?"fleet":"session"})}function vKe(){g.useEffect(()=>{const e=t=>{const n=Ve.getState(),s=gKe(t,{bindings:n.shortcutBindings,route:n.rightSlotRoute});s!==null&&(t.preventDefault(),mKe(s))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[])}const xKe=""+new URL("radient-icon-1024x1024-D_JJedvo.png",import.meta.url).href,N9=l0()(jQ(e=>({hasBeenNotified:!1,setHasBeenNotified:t=>{e({hasBeenNotified:t})}}),{name:"low-credits-storage"})),bKe=({open:e,onClose:t,onGoToConsole:n})=>{const{setHasBeenNotified:s}=N9(),{prices:r,isLoading:i,error:a}=vX(),o=d=>typeof d!="number"?"$...":`$${d.toFixed(2)} USD`,l=()=>{s(!0),t()},u=()=>{s(!0),n()};return c.jsx(Mc,{open:e,onClose:l,title:c.jsxs(c.Fragment,{children:[c.jsx("img",{src:xKe,alt:"Radient icon",className:"size-7"}),"Running low on Radient credits?"]}),maxWidth:"sm",fullWidth:!1,actions:c.jsxs(c.Fragment,{children:[c.jsx(Qm,{onClick:l,children:"Maybe later"}),c.jsx(Jm,{onClick:u,startIcon:c.jsx(ac,{size:18}),className:"min-w-55",children:"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:["Unlock the full power of Local Operator with"," ",c.jsx("span",{className:"font-bold text-accent",children:"Radient Pass"}),"."]}),c.jsx("p",{className:"text-body-sm text-ink-muted",children:"Radient Automatic is often cheaper than bringing your own key: its smart model routing picks the most cost-effective model for each step of your agentic workflows."}),c.jsx("p",{className:"text-body-sm text-ink-muted",children:"It's pay-as-you-go with no commitments. Load up what you need, starting small for maximum flexibility."}),c.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Plus, get"," ",c.jsx("span",{className:"font-medium text-ink",children:i?c.jsx(Rn,{size:"sm",className:"mr-0.5 align-middle"}):o(r?.default_registration_credits)})," ","in bonus credits with your first purchase.",a&&c.jsx("span",{className:"mt-1 block text-meta text-danger",children:"Could not load bonus credit information."})]}),c.jsx("p",{className:"text-meta text-ink-dim",children:"You can also reach the Radient Console from Settings at any time."})]})})},wKe=(e,t)=>t?aS(e.filter(n=>n.session_id===t)).length:0;function CKe(e){return Ce(t=>wKe(t.sessions,e))}const yKe=(e,t)=>t?e.some(n=>n.session_id===t&&n.status?.code==="busy"):!1;function SKe(e){return Ce(t=>yKe(t.sessions,e))}const EKe=[];function kKe(){const{state:e}=Pw(),t=e?.pendingConsent??EKe,n=G6(s=>KD(t,s));return g.useEffect(()=>{t.length>0&&Y_()},[t]),KD(t,n)}const M9={approvals:["desktop","mesh","approvals"]},_Ke=15e3,TKe=new Set(["requested","approved","connecting","failed"]);function RKe(e){return TKe.has(e)}function AKe(e){return e==="requested"}function FKe(e){return e.filter(t=>AKe(t.state)).length}function uQe(e){return e==="requested"}function dQe(e){return RKe(e)}function hQe(e){switch(e){case"requested":return"Waiting for you";case"approved":return"Approved";case"connecting":return"Connecting…";case"connected":return"Connected";case"denied":return"Denied";case"expired":return"Expired";case"failed":return"Failed";default:return e}}function Du(e){return typeof e=="object"&&e!==null}function DKe(e){const t=Du(e)?e:{};return{deviceId:Rt(t.device_id),name:Rt(t.name),host:Rt(t.host),user:Rt(t.user),transport:Rt(t.transport),hostKeyFp:Rt(t.host_key_fp)}}function PKe(e){const t=Du(e)?e:{};return{connect:_o(t.connect,!1),install:_o(t.install,!1),anchor:Du(t.anchor),networkId:Rt(t.network_id),role:Rt(t.role),unattended:_o(t.unattended,!1),grants:gf(t.grant)}}function IKe(e){const t=Array.isArray(e)?e:e?.approvals??[];if(!Array.isArray(t))return[];const n=[];for(const s of t){if(!Du(s))continue;const r=Rt(s.approval_id),i=Rt(s.state);if(!r||!i)continue;const a=!Du(s.device)&&Du(s.machine)?"machine":"device",o=Du(s.requested_by)?s.requested_by:{};n.push({approvalId:r,state:i,kind:a,where:DKe(a==="machine"?s.machine:s.device),what:PKe(s.what),requestedBy:{surface:Rt(o.surface),sessionId:Rt(o.session_id),deviceId:Rt(o.device_id)},expiresAt:uc(s.expires_at)})}return n}function NKe(e){return e.kind==="machine"?"this machine":lj({device_id:e.where.deviceId,name:e.where.name})}function fQe(e,t){const n=MKe(e),s=LKe(e,t).map(r=>r.clause);return s.length?`${n}: ${OKe(s)}.`:`${n}.`}function MKe(e){return e.kind==="machine"?"Set up operator authority on this machine":`Onboard ${NKe(e)}`}function OKe(e){return e.length===1?e[0]:`${e.slice(0,-1).join(", ")}; ${e[e.length-1]}`}function pQe(e){const{user:t,host:n,transport:s,name:r}=e.where,i=[n?t?`${t}@${n}`:n:"",s?`via ${s}`:"",r&&r!==n?`(${r})`:""].filter(Boolean);return i.length?i.join(" "):null}function gQe(e){return e.where.hostKeyFp||null}function mQe(e){const{surface:t,sessionId:n}=e.requestedBy,s=[t||"",n?`session ${n.slice(-6)}`:""].filter(Boolean);return s.length?`asked by ${s.join(" · ")}`:null}function LKe(e,t){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?`connect over ${e.where.transport}`:"connect to it",consequence:e.where.transport?`this machine may connect to it over ${e.where.transport}`:"this machine may connect to it"}),s&&u.push({term:"install",clause:e.kind==="machine"?"install Local Operator":"install Local Operator there",consequence:e.kind==="machine"?"Local Operator is installed on this machine":"Local Operator is installed on it"}),r&&u.push({term:"install operator anchor",clause:"check approvals signed on your machines",consequence:"that device can check approvals signed on your machines; nothing there can sign"}),i){const d=t?.get(i),h=`join ${d||i} as ${a||"?"}`;u.push({term:h,clause:h,consequence:`it joins ${d||i} as ${a||"?"}`})}o&&u.push({term:"trust unattended sessions",clause:"run sessions there without an approval prompt",consequence:"sessions you start on that device run without an approval prompt there"});for(const d of BKe(l,o)){const h=jKe[d];u.push({term:h?.term??`grant ${d}`,clause:HKe[d]??`use the ${d} capability`,consequence:h?.gloss??`you may ${d} on that device`})}return u}function BKe(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 jKe={unattended:{term:"trust unattended sessions",gloss:"sessions you start on that device run without an approval prompt there"},broker_credential:{term:"borrow logins there",gloss:"your sessions may use the logins stored on that device"}},HKe={list:"see its sessions",view:"watch a session there",prompt:"send prompts to a session there",steer:"steer a running turn there",stop:"stop a session there",slash:"run slash commands there",delete:"archive or delete a session there",move:"move sessions to or from there",broker_credential:"borrow the logins stored there",approve:"answer approval prompts there",unattended:"run sessions there without an approval prompt"};function vQe(e,t){if(e===null||e<=0)return null;const n=e-t;if(n<=0)return null;if(n<60)return"expires in under a minute";const s=Math.ceil(n/60);if(s<90)return s===1?"expires in 1 minute":`expires in ${s} minutes`;const r=Math.ceil(s/60);return r===1?"expires in 1 hour":`expires in ${r} hours`}function UKe(e,{poll:t=!0}={}){return Os({queryKey:M9.approvals,enabled:e,queryFn:async()=>IKe(await Ct({op:"approvals.list"})),retry:!1,staleTime:t?1e4:Number.POSITIVE_INFINITY,refetchInterval:e&&t?_Ke:!1,refetchOnWindowFocus:t})}function xQe(){const e=hn();return Cs({mutationFn:async t=>{const n=t.decision==="approve"?{op:"approvals.approve",approvalId:t.approvalId}:{op:"approvals.deny",approvalId:t.approvalId};await Ct(n)},onSettled:()=>{e.invalidateQueries({queryKey:M9.approvals}),e.invalidateQueries({queryKey:wl.networks}),e.invalidateQueries({queryKey:wl.peers})}})}function bQe(e){const t=e?.message;return typeof t=="string"&&t.trim()?t.trim():"The approvals could not be read."}function wQe(e){const t=e;return{code:Rt(t?.code)||"approval_refused",sentence:Rt(t?.message)||"The decision could not be answered."}}const s3=e=>{const t=wX(e.type),n=typeof e.percent=="number"?`, ${Math.round(e.percent)}%`:"";return`${t} in progress${n}.`},O9=e=>bX({type:e.type,version:e.offer.version}),GKe=e=>`${e.map(s=>O9(s)).map((s,r)=>r===0?s:`${s.charAt(0).toLowerCase()}${s.slice(1)}`).join(" and ")} available. Show the update notice.`,$Ke=({surfaces:e,inflight:t,onShow:n,onDismiss:s})=>{if(t===null&&e.length===0)return null;if(t!==null)return c.jsx(rt,{side:"top",collisionPadding:8,content:s3(t),children:c.jsx("output",{"data-update-foot-icon":"","data-update-foot-icon-state":"inflight","aria-label":s3(t),className:"flex size-8 shrink-0 items-center justify-center text-accent",children:c.jsx(qa,{className:"size-4 shrink-0 motion-safe:animate-spin","aria-hidden":"true"})})});const r=e.find(i=>(i.offer.summary??"").trim()!=="");return c.jsx(rt,{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:[O9(i)," 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:"Show the update notice."})]}),children:c.jsx("button",{type:"button","data-update-foot-icon":"","data-update-foot-icon-state":"available","aria-label":GKe(e),onClick:n,onKeyDown:i=>{i.key!=="Escape"||!s||(i.stopPropagation(),s())},className:_("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(Y3,{className:"size-4 shrink-0","aria-hidden":"true"})})})},r3=()=>{const e=Ks(p=>p.followed),t=Ks(p=>p.running),n=Ks(p=>p.offers),s=Ks(p=>p.detailOpen),r=Ks(p=>p.inflight),i=Ks(p=>p.downloadPercent),a=Ks(p=>p.openNotice),o=Ks(p=>p.noticeOpen),l=Ks(p=>p.dismissNotice),u=g.useMemo(()=>{const p={followed:e,running:t,offers:n,detailOpen:s};return g3.filter(m=>xX(p,m)).map(m=>{const v=n[m];return v?{type:m,offer:v}:null}).filter(m=>m!==null)},[e,t,n,s]),d=g.useMemo(()=>r[an.BACKEND]?{type:an.BACKEND,percent:null}:r[an.UI]?{type:an.UI,percent:i[an.UI]}:null,[r,i]),h=g.useCallback(()=>a(),[a]),f=g.useCallback(()=>l(),[l]);return c.jsx($Ke,{surfaces:u,inflight:d,onShow:h,onDismiss:o?f:void 0})},i3=({expanded:e})=>c.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[c.jsx(CX,{className:"size-6",label:e?void 0:"Local Operator"}),e&&c.jsx("span",{className:"truncate font-semibold text-body text-ink",children:"Local Operator"})]}),Wk=Ge.memo(({expanded:e,useAuth:t=!1})=>{const n=Yr(),{user:s,isAuthenticated:r,accountRead:i,signOut:a}=S4(),o=i==="checking"?"Checking account…":A2(i)?"Account unavailable":null,l=s?.name??o??"User",u=A2(i),d=s?.email??"",h=u?"Reconnect Radient":d,f=u?"/settings?section=providers&provider=radient":"/settings",p=u?"Reconnect Radient":"Account settings",m=g.useCallback(async()=>{r&&(await a(),window.location.reload())},[r,a]),v=g.useMemo(()=>{const w=s?.name;return w?w.split(" ").map(C=>C.charAt(0)).join("").toUpperCase().substring(0,2):null},[s?.name]),x=c.jsxs("button",{type:"button",onClick:t?void 0:()=>n(f),"aria-label":e?void 0:p,className:_("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(F4,{className:"size-7 shrink-0",children:c.jsx(D4,{className:"border border-control bg-elevated text-ink",children:v??c.jsx(Bne,{size:14,"aria-hidden":"true"})})}),e&&l&&c.jsxs("span",{className:"min-w-0 text-left",children:[c.jsx("span",{className:"block truncate text-body-sm text-ink",children:l}),h&&c.jsx("span",{className:_("block truncate text-meta",u?"text-accent":"text-ink-dim"),children:h})]})]}),b=e?x:c.jsx(rt,{content:p,side:"right",children:x});return t?c.jsxs(Rl,{children:[e?c.jsx(Po,{asChild:!0,children:x}):c.jsx(rt,{content:p,side:"right",children:c.jsx(Po,{asChild:!0,children:x})}),c.jsxs(Al,{align:"end",side:"top",className:"min-w-50",children:[u?c.jsxs(jt,{onSelect:()=>n(f),children:[c.jsx(w_,{size:16,"aria-hidden":"true"}),"Reconnect Radient"]}):null,c.jsxs(jt,{onSelect:()=>n("/settings"),children:[c.jsx(cc,{size:16,"aria-hidden":"true"}),"Settings"]}),c.jsxs(jt,{children:[c.jsx(ane,{size:16,"aria-hidden":"true"}),"Privacy and security"]}),c.jsx(Ai,{}),c.jsxs(jt,{onSelect:m,className:"text-danger focus:bg-danger-wash focus:text-danger",children:[c.jsx(Ete,{size:16,"aria-hidden":"true"}),"Sign out"]})]})]}):b});Wk.displayName="UserProfileSidebar";const VKe=()=>{const e=c_(),t=os(),n=Ce(o=>o.setCataloguePageable),s=Ce(o=>o.fetchSessions),r=yt(t.data,"session_catalogue_page");g.useEffect(()=>{n(r)},[r,n]);const i=$a(t.data,"session_catalogue",2)==="enabled",a=g.useCallback(()=>s(r?Q3:uw,r),[s,r]);return g.useEffect(()=>{i&&a()},[i,a,e.catalogueRevision]),null},WKe="flex h-[30px] w-full items-center gap-2 rounded-md px-2 text-body-sm transition-colors duration-fast ease-out-quart",zKe=()=>{const e=Yr(),t=Lre(),{expanded:n,mode:s,onCollapse:r}=yX(),i=Ve(re=>re.openCommandPalette),a=os(),o=Ce(re=>re.activeSessionId),l=kKe(),u=$a(a.data,"peers")==="enabled",d=rT(u),h=$a(a.data,"approvals")==="enabled",f=UKe(d==="member"&&h,{poll:!0}),p=FKe(f.data??[]),m=yt(a.data,"projects",1),v=yt(a.data,"aida",1),x=d0(v),b=v&&x.data?.enabled===!0,w=x.data?.name??"Aida",C=jie(),E=CKe(x.data?.session_id),y=SKe(x.data?.session_id),k=()=>{C(e,x.data).catch(re=>$t(oh(re)))},T=[...b?[{icon:Mee,label:w,path:"/chat",isActive:t==="chat"&&!!x.data?.session_id&&o===x.data?.session_id,tourTag:"nav-item-aida",onSelect:k,attention:E,attentionTag:"nav-aida-badge",attentionName:re=>`${w}, ${re} missed message${re===1?"":"s"}`,working:y,workingName:`${w}, working`}]:[],{icon:kc,label:"Agents",path:"/agents",isActive:t==="agents",tourTag:"nav-item-agents"},...m?[{icon:QB,label:"Projects",path:"/projects",isActive:t==="projects",tourTag:"nav-item-projects"}]:[],{icon:XB,label:"Schedules",path:"/schedules",isActive:t==="schedules",tourTag:"nav-item-schedules"},{icon:Qu,label:"Browser",path:"/browser",isActive:t==="browser",tourTag:"nav-item-browser",attention:l,attentionTag:"nav-browser-badge",attentionName:re=>`Browser, ${re} waiting`},{icon:i6,label:"Agent hub",path:"/agent-hub",isActive:t==="agent-hub",tourTag:"nav-item-agent-hub"},...d==="member"?[{icon:f4,label:"Mesh",path:"/mesh",isActive:t==="mesh",tourTag:"nav-item-mesh",attention:p,attentionTag:"nav-mesh-badge",attentionName:re=>`Mesh, ${re} waiting`}]:[]],P=c.jsx(t7e,{selectedConversation:o??void 0,onSelectConversation:re=>void jf(e,re),onStageDraft:(re,Q)=>{Ce.getState().stageDraft(re,Q),e("/chat")}}),A=re=>{const Q=re.attention??0,pe=Q>0&&re.attentionName?re.attentionName(Q):re.label;return re.working&&re.workingName?re.workingName:pe},N=re=>{const Q=re.attention??0,pe=A(re),O=re.isActive?fo:"text-ink-muted hover:bg-row-hover hover:text-ink";return c.jsx("li",{className:_("flex h-[30px] w-full items-center rounded-md","transition-colors duration-fast ease-out-quart",O),children:c.jsxs("button",{type:"button",onClick:()=>re.onSelect?re.onSelect():e(re.path),"data-tour-tag":re.tourTag,"aria-current":re.isActive?"page":void 0,"aria-label":n&&pe===re.label?void 0:pe,className:_("flex h-full min-w-0 flex-1 items-center gap-2 rounded-md",n?"px-2":"justify-center px-0"),children:[c.jsx(re.icon,{size:16,"aria-hidden":"true",className:_("shrink-0",re.isActive&&"text-accent")}),n&&c.jsx("span",{className:"truncate",children:re.label}),Q>0&&c.jsx("span",{className:_(n&&"ml-auto","inline-flex"),children:c.jsx(Ec,{variant:"attentionQuiet",shape:"pill",size:"count","data-tour-tag":re.attentionTag,children:Q})}),re.working&&c.jsx("span",{className:_(n&&"ml-auto","inline-flex"),children:c.jsx(qa,{size:16,"aria-hidden":"true",className:"text-accent motion-safe:animate-spin"})})]})},re.tourTag)},M=re=>n?N(re):c.jsx("li",{children:c.jsx(rt,{content:A(re),side:"right",children:N(re)})},re.tourTag),I=s==="overlay"?"Close sidebar":n?"Collapse sidebar":"Expand sidebar",H=s==="overlay"?On:n?ef:Do,G=navigator.platform.toUpperCase().indexOf("MAC")>=0,j=yt(a.data,"session_catalogue",2),J=Ce(re=>re.activeDraftKey),Y=Ce(re=>re.drafts),oe=!!J&&!(J?Y[J]:void 0)?.target,U=()=>{Ce.getState().stageDraft(void 0,!0),e("/chat")},te=`New chat (${mL(G).replace("+","")})`,le=`Search (${vo("everything",G)}) — chats (${vo("chats",G)})`,R=`Search everything (${vo("everything",G)}) · your chats (${vo("chats",G)})`,L=(re,Q,pe,O)=>{const me=re;return c.jsxs("button",{type:"button",...O.attrs,onClick:O.onClick,disabled:O.disabled,"aria-label":O.ariaLabel,"aria-current":O.current?"page":void 0,className:_(WKe,O.current?fo:"text-ink-muted hover:bg-row-hover hover:text-ink","disabled:text-ink-disabled disabled:hover:bg-transparent"),children:[c.jsx(me,{size:16,"aria-hidden":"true",className:"shrink-0"}),c.jsx("span",{className:"truncate",children:Q}),c.jsx("span",{"aria-hidden":"true",className:"ml-auto",children:c.jsx(xr,{shortcut:pe,joined:!0})})]})},D=L(aE,"New chat",mL(G),{onClick:U,ariaLabel:te,current:oe,disabled:!j,attrs:{"data-tour-tag":"nav-item-chat","data-new-chat-row":""}}),W=L(Zu,"Search",EVe("everything",G),{onClick:i,ariaLabel:le,attrs:{"data-command-palette-trigger":"",title:R}}),Z=(re,Q,pe)=>{const O=re;return c.jsx(rt,{content:Q,side:"right",children:c.jsx("button",{type:"button",...pe.attrs,onClick:pe.onClick,disabled:pe.disabled,"aria-label":Q,className:_("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.jsx(O,{size:16,"aria-hidden":"true"})})})},se=c.jsx("div",{className:_(s!=="overlay"&&_("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(rt,{content:I,side:"right",children:c.jsx(ce,{variant:"ghost",size:"icon-sm",onClick:r,"aria-label":I,"aria-expanded":s==="overlay"?void 0:n,"aria-keyshortcuts":J2(G),children:c.jsx(H,{"aria-hidden":"true"})})})}),ae=c.jsx(rt,{content:"Settings",side:"top",children:c.jsx("button",{type:"button","data-tour-tag":"nav-item-settings",onClick:()=>e("/settings"),"aria-current":t==="settings"?"page":void 0,"aria-label":"Settings",className:_("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",t==="settings"&&"text-ink"),children:c.jsx(cc,{size:16,"aria-hidden":"true"})})});return n?c.jsxs("div",{"data-sidebar-shell":"",className:"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 pr-2 pl-4",children:[c.jsx(i3,{expanded:!0}),c.jsx("span",{className:"ml-auto",children:se})]}),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:[D,W]}),c.jsx("ul",{className:"flex flex-col gap-0.5",children:T.map(M)})]}),c.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:P}),c.jsxs("div",{className:"flex min-h-10 shrink-0 items-center justify-between gap-1 px-2 pb-2",children:[c.jsx(Wk,{expanded:!0}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(r3,{}),ae]})]})]}):c.jsxs("div",{"data-sidebar-strip":"",className:"group/sidebar flex h-full min-h-0 flex-col items-center bg-surface",children:[c.jsx(VKe,{}),c.jsx("div",{className:"flex h-10 shrink-0 items-center justify-center",children:c.jsx(i3,{expanded:!1})}),c.jsxs("ul",{className:"flex flex-col items-center gap-1",children:[c.jsx("li",{children:Z(Do,I,{onClick:r,attrs:{"aria-expanded":!1,"aria-keyshortcuts":J2(G)}})}),c.jsx("li",{children:Z(aE,te,{onClick:U,disabled:!j,attrs:{"data-tour-tag":"nav-item-chat"}})}),c.jsx("li",{children:Z(Zu,le,{onClick:i,attrs:{"data-command-palette-trigger":""}})})]}),c.jsx("ul",{className:"mt-4 flex flex-col items-center gap-1",children:T.map(M)}),c.jsxs("div",{className:"mt-auto flex flex-col items-center gap-1 pb-2",children:[c.jsx(r3,{}),ae,c.jsx(Wk,{expanded:!1})]})]})},qKe=1,KKe=()=>{const{isAuthenticated:e,user:t}=S4(),{hasBeenNotified:n,setHasBeenNotified:s}=N9(),[r,i]=g.useState(!1),[a,o]=g.useState(null),l=g.useCallback(async()=>{if(!(!e||!t?.radientUser?.account?.tenant_id))try{const f=await SX({operation:"credits",tenantId:t.radientUser.account.tenant_id});if(!f||typeof f.balance!="number")throw new Error("Invalid credit balance response format");o(f.balance)}catch(f){console.error("Failed to fetch Radient credits:",f),o(null)}},[e,t?.radientUser?.account?.tenant_id]);return g.useEffect(()=>{e&&l()},[e,l]),g.useEffect(()=>{e&&a!==null?a<qKe?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 YKe(){const e=Yr();g.useEffect(()=>{const t=r=>{e(r==="back"?-1:1)},n=r=>{const i=Mue(r);i&&(r.preventDefault(),t(i))},s=r=>{const i=Oue(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 XKe(){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 QKe(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 JKe(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 ZKe(){g.useLayoutEffect(()=>{if(!window.api?.windowChrome)return;const t=document.documentElement.dataset.chromePlatform??"linux",n=()=>QKe(XKe(),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)}},[]),g.useEffect(()=>{const e=window.api?.windowChrome;if(e)return e.onState(t=>{document.documentElement.dataset.chromeFullscreen=t.fullScreen?"true":"false"})},[])}const eYe=g.lazy(()=>Tl(()=>import("./agent-details-page-Cn-cbdV5.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]),import.meta.url).then(e=>({default:e.AgentDetailsPage}))),tYe=g.lazy(()=>Tl(()=>import("./agent-hub-page-D9pswF7S.js"),__vite__mapDeps([13,1,2,4,5,6,7,14,3,8,9,10,15,16,17,11,12]),import.meta.url).then(e=>({default:e.AgentHubPage}))),a3=g.lazy(()=>Tl(()=>import("./agents-page-BjX3Lv17.js"),__vite__mapDeps([18,4,5,1,2,6,7,11,12]),import.meta.url).then(e=>({default:e.AgentsPage}))),nYe=g.lazy(()=>Tl(()=>import("./schedules-page-CjtX0IBz.js"),__vite__mapDeps([19,1,2,4,5,6,7,14,17,9,20,11,12]),import.meta.url).then(e=>({default:e.SchedulesPage}))),o3=g.lazy(()=>Tl(()=>import("./projects-page-DUsbGH6v.js"),__vite__mapDeps([21,1,2,4,5,6,7,14,22,11,12]),import.meta.url).then(e=>({default:e.ProjectsPage}))),sYe=g.lazy(()=>Tl(()=>import("./browser-page-DzG2V1CA.js"),__vite__mapDeps([23,1,2,4,5,6,7,11,12]),import.meta.url).then(e=>({default:e.BrowserPage}))),rYe=g.lazy(()=>Tl(()=>import("./mesh-page-Bccygj_9.js"),__vite__mapDeps([24,1,2,4,5,6,7,14,11,12]),import.meta.url).then(e=>({default:e.MeshPage}))),iYe=g.lazy(()=>Tl(()=>import("./settings-page-B2DmcFgi.js"),__vite__mapDeps([25,1,2,4,5,6,7,14,15,26,10,20,9,17,11,12]),import.meta.url).then(e=>({default:e.SettingsPage}))),aYe=g.lazy(()=>Tl(()=>import("./browser-webauthn-prompt-DoSh0kSS.js"),__vite__mapDeps([27,1,2,4,5,6,7]),import.meta.url).then(e=>({default:e.BrowserWebauthnPrompt}))),oYe=()=>{ZKe(),pKe();const{pathname:e}=l_(),t=e.startsWith("/chat")||e.startsWith("/browser"),{isOnboardingActive:n}=Mre(),{isLowCreditsDialogOpen:s,openRadientConsole:r,onLowCreditsDialogClose:i}=KKe(),{isCommandPaletteOpen:a,isCreateAgentDialogOpen:o,isSidebarCollapsed:l,closeCreateAgentDialog:u}=Ve();Eu(a,"command-palette"),Eu(o,"create-agent-dialog"),Eu(n,"onboarding"),Eu(s,"low-credits");const d=Yr(),h=os(),f=yt(h.data,"session_catalogue",2),p=yt(h.data,"session_archive");g.useEffect(()=>{Ce.getState().requestArchiveConfirm(null)},[e]);const m=$a(h.data,"peers"),v=y=>{Ce.getState().stageDraft({kind:"agent",name:y.name}),d("/chat"),u()};qVe(),vKe(),DVe(),YKe(),ade();const x=Ce(y=>y.setActiveSession),b=Ce(y=>{const k=y.activeDraftKey?y.drafts[y.activeDraftKey]:void 0;return Mf(y.activeDraftKey,k?.sessionId,y.activeSessionId)}),w=Ve(y=>y.setConsolePaneOpen),C=Ve(y=>y.setBrowserPaneOpen),E=Ve(y=>y.setConsoleActiveSurface);return g.useEffect(()=>{const y=window.api?.desktop?.onOpenConversation?.((k,T)=>{k!==null&&performance.mark("lop:open:requested"),x(k),T!==void 0&&k!==null&&(E(T),w(!0)),d("/chat")});return()=>y?.()},[d,x,w,E]),g.useEffect(()=>{const y=window.api?.console?.onReveal?.(k=>{k.mode!=="none"&&(k.mode==="session"&&k.session_id!==b||(k.mode==="open"&&x(k.session_id),E(k.surface),w(!0)))});return()=>y?.()},[b,x,w,E]),Die(),vVe(),g.useEffect(()=>{const y=window.api?.browser?.onConsentAttention?.(k=>{const T=die(k.requesterSessionId,Ce.getState().sessions);if(lie(k.entryId),T.kind==="browser"){d("/browser");return}x(T.sessionId),C(!0),d("/chat")});return()=>y?.()},[d,x,C]),g.useEffect(()=>{const y=k=>{n||f&&bVe(k)&&(k.preventDefault(),Ce.getState().stageDraft(void 0,!0),d("/chat"))};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[f,n,d]),c.jsx(cKe,{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($Ve,{}),c.jsx(wVe,{}),c.jsx(EX,{}),c.jsx(KVe,{enabled:m==="enabled"}),c.jsx(PWe,{open:n}),c.jsx(uKe,{}),c.jsx(fKe,{}),p&&c.jsx(Mie,{}),c.jsx(aie,{}),c.jsx(g.Suspense,{fallback:null,children:c.jsx(aYe,{})}),c.jsx(bKe,{open:s,onClose:i,onGoToConsole:r}),c.jsx(Hre,{open:o,onClose:u,onAgentCreated:v}),c.jsx(kX,{sidebar:c.jsx(zKe,{}),content:c.jsxs("main",{className:"flex grow flex-col overflow-hidden",children:[t?null:c.jsx("div",{"data-chrome-route-band":""}),c.jsx(g.Suspense,{fallback:c.jsx("div",{className:"flex grow items-center justify-center",children:c.jsx(Rn,{size:"lg",label:"Loading page"})}),children:c.jsxs(_X,{children:[c.jsx(Jr,{path:"/",element:c.jsx(F2,{to:"/chat",replace:!0})}),c.jsx(Jr,{path:"/chat",element:c.jsx(pL,{})}),c.jsx(Jr,{path:"/chat/:agentId",element:c.jsx(pL,{})}),c.jsx(Jr,{path:"/agents",element:c.jsx(a3,{})}),c.jsx(Jr,{path:"/agents/:agentId",element:c.jsx(a3,{})}),c.jsx(Jr,{path:"/settings",element:c.jsx(iYe,{})}),c.jsx(Jr,{path:"/agent-hub",element:c.jsx(tYe,{})}),c.jsx(Jr,{path:"/agent-hub/:agentId",element:c.jsx(eYe,{})}),c.jsx(Jr,{path:"/schedules",element:c.jsx(nYe,{})}),c.jsx(Jr,{path:"/projects",element:c.jsx(o3,{})}),c.jsx(Jr,{path:"/projects/:projectId",element:c.jsx(o3,{})}),c.jsx(Jr,{path:"/browser",element:c.jsx(sYe,{})}),m==="enabled"&&c.jsx(Jr,{path:"/mesh",element:c.jsx(rYe,{})}),c.jsx(Jr,{path:"*",element:c.jsx(F2,{to:"/chat",replace:!0})})]})})]})})]})})})};function Su(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}const lYe=3,cYe=3e3;function uYe(e){return e instanceof CSSTransition&&e.playState==="running"}function dYe(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 ${Xm(n)??"an element no longer in the document"} = ${i}`}async function hYe(e=cYe){const t=performance.now();let n=0;for(;;){await Su();const s=Math.round(performance.now()-t),r=document.getAnimations().filter(uYe);if(n=r.length===0?n+1:0,n>=lYe)return{waitedMs:s,timedOut:!1,pending:[]};if(s>e)return{waitedMs:s,timedOut:!0,pending:r.map(dYe)}}}const fYe=/^#/;function zg(){const e=window.location.hash.replace(fYe,"");return e===""?"/":e}function Xm(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 pYe(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=>Xm(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:Xm(r),stack:a,disabled:e instanceof HTMLButtonElement?e.disabled:null,rect:{x:t.x,y:t.y,width:t.width,height:t.height}}}function Up(e,t){if(typeof e!="string"||e==="")throw new Error(`${t} must be a non-empty string`);return e}async function gYe(e,t=1e4){const n=Date.now();for(;zg()!==e;){if(Date.now()-n>t)throw new Error(`route did not become ${e} (it is ${zg()})`);await new Promise(s=>setTimeout(s,50))}return await Su(),zg()}const zk=["dev-driver","query-fetch-probe"];let qg=null;function mYe(){if(qg)return qg;const e=[],t=D2.prototype.fetch;return D2.prototype.fetch=function(...s){return e.push({at:Date.now(),key:JSON.stringify(this.queryKey),stack:(new Error().stack??"").split(`
677
+ 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:()=>aKe("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(){t3("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(()=>{t3("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()}}]}],oKe=()=>{const e=Yr(),{completeTourOnboarding:t}=Kg(),n=g.useContext(vC),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=Kg.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(n3)}else l.steps.length===0&&l.addSteps(n3);typeof l.start=="function"?(e("/"),l.start()):console.warn("Shepherd tour instance does not have a start method.",l)}}},lKe=()=>{const{isModalComplete:e,isTourComplete:t}=Kg(),{startTour:n}=oKe(),s=Ge.useContext(vC),{data:r}=oE(1,1);return g.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},cKe=({children:e})=>c.jsxs(Qqe,{children:[e,c.jsx(lKe,{})]}),uKe=()=>{const{open:e,focusGroup:t,providerId:n,closeConnect:s}=p4(),r=g.useRef(null);g.useEffect(()=>{e&&(r.current=document.activeElement instanceof HTMLElement?document.activeElement:null)},[e]);const i=Yr();return c.jsx(xd,{open:e,onOpenChange:a=>{a||s()},children:c.jsxs(bd,{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(Sc,{className:"text-title",children:"Connect a model provider"}),c.jsx(Of,{className:"text-body-sm text-ink-muted",children:"Your agents need a model to think with. Sign in with an account you already have, or add an API key."})]}),e?c.jsx(u9,{context:"dialog",featuredOnly:!0,focusGroup:t,initialProviderId:n,onDone:s,onChangeModel:()=>{s(),i("/settings")}}):null]})})},dKe=({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:_("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})]}),oQe=({label:e,value:t,className:n,valueClassName:s})=>c.jsxs("div",{className:_("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:_("mt-0.5 break-words text-body-sm",s??"text-ink"),children:t})]}),lQe=({children:e,className:t})=>c.jsx("div",{className:_("grid grid-cols-[repeat(auto-fit,minmax(160px,1fr))] gap-x-6 gap-y-4",t),children:e});async function P9(e){await Ct({op:"settings.edit",key:wo,value:e.value}),cX(e.queryClient)}async function hKe(e){await P9(e),e.queryClient.setQueryData(Rx.all,t=>t&&{...t,settings:t.settings.map(n=>n.key===wo?{...n,value:e.value,is_default:e.value===n.default}:n)});try{return await e.queryClient.fetchQuery({queryKey:Rx.all,queryFn:()=>Ct({op:"settings.list"}),staleTime:0,retry:!1}),"confirmed"}catch{return"readback-unknown"}}const cQe=({focus:e=!1})=>{const t=hn(),n=os(),s=yt(n.data,"settings"),r=Os({queryKey:Rx.all,queryFn:()=>Ct({op:"settings.list"}),enabled:s,retry:!1,refetchOnReconnect:!0}),i=r.data?.settings.find(P=>P.key===wo),[a,o]=g.useState(!1),[l,u]=g.useState(null),[d,h]=g.useState(!1),[f,p]=g.useState(!1),m=g.useRef(!1),v=g.useRef(null),x=g.useRef(!1);g.useEffect(()=>{if(!e){x.current=!1;return}!i||x.current||(v.current?.querySelector("[role=combobox]")?.focus(),x.current=!0)},[e,i]),g.useEffect(()=>{r.isSuccess&&!r.isFetching&&h(!1)},[r.isFetching,r.isSuccess]);const b=async P=>{if(!(!i||m.current||d||!i.choices.some(A=>A.value===P))){m.current=!0,o(!0),u(null),p(!1);try{const A=await hKe({value:P,queryClient:t});h(A==="readback-unknown"),p(A==="confirmed")}catch(A){u({value:P,message:A instanceof Error?A.message:""})}finally{m.current=!1,o(!1)}}},w=async()=>{const[P,A]=await Promise.all([r.refetch(),n.refetch()]);!P.isError&&!A.isError&&h(!1)},C=!r.data&&r.error||!n.data&&n.error,E=n.data&&(!s||r.data&&!i),y=!C&&!E&&!i,k=n.data?.features?.i18n?n.data.language:void 0,T=typeof k=="string"&&k!==""?k:void 0;return c.jsx(dKe,{title:ze("ui.settings.language.dialog.title"),icon:ZB,description:ze("ui.settings.language.general.description"),children:c.jsxs("div",{ref:v,"data-setting-key":wo,className:"flex flex-col gap-3","aria-busy":a,children:[y&&c.jsx("output",{className:"text-meta text-ink-dim",children:ze("ui.settings.language.dialog.loading")}),E&&c.jsx("p",{className:"text-meta text-ink-dim",children:ze("ui.settings.language.dialog.unavailable")}),i&&c.jsx(y4,{setting:{...p_(i),label:ze("ui.settings.language.dialog.title")},value:String(i.value),onValueChange:P=>{b(P)},disabled:a||d,suppressEffectiveNote:!0}),c.jsx("output",{id:lX(wo),"aria-live":"polite",className:"text-meta text-ink-dim",children:a?ze("ui.settings.language.general.pending"):f?ze("ui.settings.language.general.saved"):T?ze(d||n.error?"ui.settings.language.general.last_known":"ui.settings.language.general.effective",{locale:T}):ze("ui.settings.language.general.no_resolution")}),(C||l||d)&&c.jsx(zr,{variant:"danger",children:c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsx("p",{role:"alert",children:l?ze("ui.settings.language.general.write_error",{message:l.message}):d?ze("ui.settings.language.general.readback_error"):ze("ui.settings.language.dialog.unavailable")}),c.jsx(ce,{variant:"outline",size:"sm",disabled:a||r.isFetching||n.isFetching,onClick:()=>{l?b(l.value):w()},children:ze("ui.settings.language.dialog.retry")})]})})]})})},fKe=()=>{const e=Bk(J=>J.open),t=Bk(J=>J.closeLanguage),n=hn(),s=os(),r=yt(s.data,"settings"),i=Os({queryKey:Rx.all,queryFn:()=>Ct({op:"settings.list"}),enabled:e&&r,staleTime:1e4}),a=g.useRef(null),o=uX(),l=(i.data?.settings??[]).find(J=>J.key===wo),u=l?p_(l):void 0,[d,h]=g.useState(null),[f,p]=g.useState(!1),[m,v]=g.useState(!1),[x,b]=g.useState(null),w=g.useRef(null);g.useEffect(()=>{e&&h(null)},[e]),g.useEffect(()=>{if(!e||!u)return;const J=String(u.value??"");(d===null||d===w.current)&&h(J),w.current=J},[e,u,d]),g.useEffect(()=>{e&&(v(!1),b(null))},[e]);const C=d??String(u?.value??""),E=!!u&&C!==String(u?.value??""),y=!u||!E||f,k=async()=>{if(!(!u||!E)){p(!0),b(null);try{await P9({value:C,queryClient:n}),v(!0),h(null),await i.refetch()}catch(J){b(J instanceof Error?J.message:"The language could not be saved.")}finally{p(!1)}}},T=!!s.data,P=T&&!r,A=s.error&&!s.data?s.error:null,N=A??i.error,M=!T&&!N,{sentence:I,remedy:H}=dX(o??null,"Your settings could not be loaded.",N),G=s.isFetching||i.isFetching,j=u?"combo":N?"retry":"none";return g.useEffect(()=>{!e||j==="none"||requestAnimationFrame(()=>{a.current?.querySelector(j==="combo"?'[role="combobox"]':"[data-language-retry]")?.focus()})},[e,j]),c.jsx(xd,{open:e,onOpenChange:J=>!J&&t(),children:c.jsxs(bd,{ref:a,onOpenAutoFocus:J=>J.preventDefault(),className:"max-w-[min(28rem,calc(100vw-4rem))] gap-4",children:[c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx(Sc,{className:"text-title",children:ze("ui.settings.language.dialog.title")}),c.jsx(Of,{className:"text-body-sm text-ink-muted",children:ze("ui.settings.language.dialog.description")})]}),M?c.jsxs("div",{className:"flex items-center gap-2 text-body-sm text-ink-muted",children:[c.jsx(Rn,{}),ze("ui.settings.language.dialog.loading")]}):P?c.jsx(zr,{variant:"warning",children:c.jsx("span",{children:ze("ui.settings.language.dialog.unavailable")})}):N?c.jsx(zr,{variant:"warning",children:c.jsxs("div",{className:"flex items-center justify-between gap-3",children:[c.jsx("span",{children:I}),H&&c.jsx(ce,{variant:"secondary",size:"sm",className:"shrink-0","data-language-retry":"",onClick:()=>{A?s.refetch():i.refetch()},disabled:G,children:G?ze("ui.settings.language.dialog.retrying"):ze("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(Rn,{}),ze("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:R2(wo),className:"text-meta text-ink-dim",children:u.help}),c.jsx(y4,{setting:u,value:C,disabled:f,helpId:R2(wo),effectiveNoteId:hX(wo,fX),onValueChange:J=>{v(!1),h(J)}})]}),x&&c.jsx("p",{className:"text-meta text-danger",children:x}),c.jsx("div",{className:"flex min-h-8 items-center justify-end",children:m&&!E?c.jsxs("output",{"data-language-save":"",className:"inline-flex items-center gap-1.5 text-body-sm text-ink",children:[c.jsx(Ls,{"aria-hidden":"true",className:"size-3.5"}),ze("ui.settings.language.dialog.saved")]}):c.jsx(ce,{onClick:k,disabled:y,"data-language-save":"",children:f?`${ze("ui.settings.language.dialog.save")}...`:ze("ui.settings.language.dialog.save")})})]}):c.jsx(zr,{variant:"warning",children:c.jsx("span",{children:ze("ui.settings.language.dialog.unavailable")})})]})})};function pKe(){const{data:e}=os();g.useEffect(()=>{e&&pX(e)},[e]);const t=c_(),n=hn(),s=g.useRef(null);g.useEffect(()=>{const r=t.configChange;if(!r)return;const i=`${r.epoch}:${r.seq}`;s.current!==i&&r.changedKeys.includes(wo)&&(s.current=i,n.invalidateQueries({queryKey:Fo.capabilities}),n.invalidateQueries({queryKey:Fo.settings}),!gX()&&La(ze("ui.settings.language.external_notice",{language:r.language}),{id:"i18n-language-external"}))},[t.configChange,n])}function gKe(e,t){if(e.defaultPrevented||e.repeat||e.isComposing||!(e.metaKey||e.ctrlKey))return null;const n=mX(e);if(n===null)return null;const s=BQ(t.bindings).get(n);return s===void 0||d_(e.target)||!ele(I9(s),t.route)?null:s}const I9=e=>e.slice(6);function mKe(e){const t=Ce.getState(),n=t.activeDraftKey?t.drafts[t.activeDraftKey]:void 0,s=Mf(t.activeDraftKey,n?.sessionId,t.activeSessionId)??null;xu(I9(e),{sessionId:s,askScope:s===null?"fleet":"session"})}function vKe(){g.useEffect(()=>{const e=t=>{const n=Ve.getState(),s=gKe(t,{bindings:n.shortcutBindings,route:n.rightSlotRoute});s!==null&&(t.preventDefault(),mKe(s))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[])}const xKe=""+new URL("radient-icon-1024x1024-D_JJedvo.png",import.meta.url).href,N9=l0()(jQ(e=>({hasBeenNotified:!1,setHasBeenNotified:t=>{e({hasBeenNotified:t})}}),{name:"low-credits-storage"})),bKe=({open:e,onClose:t,onGoToConsole:n})=>{const{setHasBeenNotified:s}=N9(),{prices:r,isLoading:i,error:a}=vX(),o=d=>typeof d!="number"?"$...":`$${d.toFixed(2)} USD`,l=()=>{s(!0),t()},u=()=>{s(!0),n()};return c.jsx(Mc,{open:e,onClose:l,title:c.jsxs(c.Fragment,{children:[c.jsx("img",{src:xKe,alt:"Radient icon",className:"size-7"}),"Running low on Radient credits?"]}),maxWidth:"sm",fullWidth:!1,actions:c.jsxs(c.Fragment,{children:[c.jsx(Qm,{onClick:l,children:"Maybe later"}),c.jsx(Jm,{onClick:u,startIcon:c.jsx(ac,{size:18}),className:"min-w-55",children:"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:["Unlock the full power of Local Operator with"," ",c.jsx("span",{className:"font-bold text-accent",children:"Radient Pass"}),"."]}),c.jsx("p",{className:"text-body-sm text-ink-muted",children:"Radient Automatic is often cheaper than bringing your own key: its smart model routing picks the most cost-effective model for each step of your agentic workflows."}),c.jsx("p",{className:"text-body-sm text-ink-muted",children:"It's pay-as-you-go with no commitments. Load up what you need, starting small for maximum flexibility."}),c.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Plus, get"," ",c.jsx("span",{className:"font-medium text-ink",children:i?c.jsx(Rn,{size:"sm",className:"mr-0.5 align-middle"}):o(r?.default_registration_credits)})," ","in bonus credits with your first purchase.",a&&c.jsx("span",{className:"mt-1 block text-meta text-danger",children:"Could not load bonus credit information."})]}),c.jsx("p",{className:"text-meta text-ink-dim",children:"You can also reach the Radient Console from Settings at any time."})]})})},wKe=(e,t)=>t?aS(e.filter(n=>n.session_id===t)).length:0;function CKe(e){return Ce(t=>wKe(t.sessions,e))}const yKe=(e,t)=>t?e.some(n=>n.session_id===t&&n.status?.code==="busy"):!1;function SKe(e){return Ce(t=>yKe(t.sessions,e))}const EKe=[];function kKe(){const{state:e}=Pw(),t=e?.pendingConsent??EKe,n=G6(s=>KD(t,s));return g.useEffect(()=>{t.length>0&&Y_()},[t]),KD(t,n)}const M9={approvals:["desktop","mesh","approvals"]},_Ke=15e3,TKe=new Set(["requested","approved","connecting","failed"]);function RKe(e){return TKe.has(e)}function AKe(e){return e==="requested"}function FKe(e){return e.filter(t=>AKe(t.state)).length}function uQe(e){return e==="requested"}function dQe(e){return RKe(e)}function hQe(e){switch(e){case"requested":return"Waiting for you";case"approved":return"Approved";case"connecting":return"Connecting…";case"connected":return"Connected";case"denied":return"Denied";case"expired":return"Expired";case"failed":return"Failed";default:return e}}function Du(e){return typeof e=="object"&&e!==null}function DKe(e){const t=Du(e)?e:{};return{deviceId:Rt(t.device_id),name:Rt(t.name),host:Rt(t.host),user:Rt(t.user),transport:Rt(t.transport),hostKeyFp:Rt(t.host_key_fp)}}function PKe(e){const t=Du(e)?e:{};return{connect:_o(t.connect,!1),install:_o(t.install,!1),anchor:Du(t.anchor),networkId:Rt(t.network_id),role:Rt(t.role),unattended:_o(t.unattended,!1),grants:gf(t.grant)}}function IKe(e){const t=Array.isArray(e)?e:e?.approvals??[];if(!Array.isArray(t))return[];const n=[];for(const s of t){if(!Du(s))continue;const r=Rt(s.approval_id),i=Rt(s.state);if(!r||!i)continue;const a=!Du(s.device)&&Du(s.machine)?"machine":"device",o=Du(s.requested_by)?s.requested_by:{};n.push({approvalId:r,state:i,kind:a,where:DKe(a==="machine"?s.machine:s.device),what:PKe(s.what),requestedBy:{surface:Rt(o.surface),sessionId:Rt(o.session_id),deviceId:Rt(o.device_id)},expiresAt:uc(s.expires_at)})}return n}function NKe(e){return e.kind==="machine"?"this machine":lj({device_id:e.where.deviceId,name:e.where.name})}function fQe(e,t){const n=MKe(e),s=LKe(e,t).map(r=>r.clause);return s.length?`${n}: ${OKe(s)}.`:`${n}.`}function MKe(e){return e.kind==="machine"?"Set up operator authority on this machine":`Onboard ${NKe(e)}`}function OKe(e){return e.length===1?e[0]:`${e.slice(0,-1).join(", ")}; ${e[e.length-1]}`}function pQe(e){const{user:t,host:n,transport:s,name:r}=e.where,i=[n?t?`${t}@${n}`:n:"",s?`via ${s}`:"",r&&r!==n?`(${r})`:""].filter(Boolean);return i.length?i.join(" "):null}function gQe(e){return e.where.hostKeyFp||null}function mQe(e){const{surface:t,sessionId:n}=e.requestedBy,s=[t||"",n?`session ${n.slice(-6)}`:""].filter(Boolean);return s.length?`asked by ${s.join(" · ")}`:null}function LKe(e,t){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?`connect over ${e.where.transport}`:"connect to it",consequence:e.where.transport?`this machine may connect to it over ${e.where.transport}`:"this machine may connect to it"}),s&&u.push({term:"install",clause:e.kind==="machine"?"install Local Operator":"install Local Operator there",consequence:e.kind==="machine"?"Local Operator is installed on this machine":"Local Operator is installed on it"}),r&&u.push({term:"install operator anchor",clause:"check approvals signed on your machines",consequence:"that device can check approvals signed on your machines; nothing there can sign"}),i){const d=t?.get(i),h=`join ${d||i} as ${a||"?"}`;u.push({term:h,clause:h,consequence:`it joins ${d||i} as ${a||"?"}`})}o&&u.push({term:"trust unattended sessions",clause:"run sessions there without an approval prompt",consequence:"sessions you start on that device run without an approval prompt there"});for(const d of BKe(l,o)){const h=jKe[d];u.push({term:h?.term??`grant ${d}`,clause:HKe[d]??`use the ${d} capability`,consequence:h?.gloss??`you may ${d} on that device`})}return u}function BKe(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 jKe={unattended:{term:"trust unattended sessions",gloss:"sessions you start on that device run without an approval prompt there"},broker_credential:{term:"borrow logins there",gloss:"your sessions may use the logins stored on that device"}},HKe={list:"see its sessions",view:"watch a session there",prompt:"send prompts to a session there",steer:"steer a running turn there",stop:"stop a session there",slash:"run slash commands there",delete:"archive or delete a session there",move:"move sessions to or from there",broker_credential:"borrow the logins stored there",approve:"answer approval prompts there",unattended:"run sessions there without an approval prompt"};function vQe(e,t){if(e===null||e<=0)return null;const n=e-t;if(n<=0)return null;if(n<60)return"expires in under a minute";const s=Math.ceil(n/60);if(s<90)return s===1?"expires in 1 minute":`expires in ${s} minutes`;const r=Math.ceil(s/60);return r===1?"expires in 1 hour":`expires in ${r} hours`}function UKe(e,{poll:t=!0}={}){return Os({queryKey:M9.approvals,enabled:e,queryFn:async()=>IKe(await Ct({op:"approvals.list"})),retry:!1,staleTime:t?1e4:Number.POSITIVE_INFINITY,refetchInterval:e&&t?_Ke:!1,refetchOnWindowFocus:t})}function xQe(){const e=hn();return Cs({mutationFn:async t=>{const n=t.decision==="approve"?{op:"approvals.approve",approvalId:t.approvalId}:{op:"approvals.deny",approvalId:t.approvalId};await Ct(n)},onSettled:()=>{e.invalidateQueries({queryKey:M9.approvals}),e.invalidateQueries({queryKey:wl.networks}),e.invalidateQueries({queryKey:wl.peers})}})}function bQe(e){const t=e?.message;return typeof t=="string"&&t.trim()?t.trim():"The approvals could not be read."}function wQe(e){const t=e;return{code:Rt(t?.code)||"approval_refused",sentence:Rt(t?.message)||"The decision could not be answered."}}const s3=e=>{const t=wX(e.type),n=typeof e.percent=="number"?`, ${Math.round(e.percent)}%`:"";return`${t} in progress${n}.`},O9=e=>bX({type:e.type,version:e.offer.version}),GKe=e=>`${e.map(s=>O9(s)).map((s,r)=>r===0?s:`${s.charAt(0).toLowerCase()}${s.slice(1)}`).join(" and ")} available. Show the update notice.`,$Ke=({surfaces:e,inflight:t,onShow:n,onDismiss:s})=>{if(t===null&&e.length===0)return null;if(t!==null)return c.jsx(rt,{side:"top",collisionPadding:8,content:s3(t),children:c.jsx("output",{"data-update-foot-icon":"","data-update-foot-icon-state":"inflight","aria-label":s3(t),className:"flex size-8 shrink-0 items-center justify-center text-accent",children:c.jsx(qa,{className:"size-4 shrink-0 motion-safe:animate-spin","aria-hidden":"true"})})});const r=e.find(i=>(i.offer.summary??"").trim()!=="");return c.jsx(rt,{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:[O9(i)," 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:"Show the update notice."})]}),children:c.jsx("button",{type:"button","data-update-foot-icon":"","data-update-foot-icon-state":"available","aria-label":GKe(e),onClick:n,onKeyDown:i=>{i.key!=="Escape"||!s||(i.stopPropagation(),s())},className:_("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(Y3,{className:"size-4 shrink-0","aria-hidden":"true"})})})},r3=()=>{const e=Ks(p=>p.followed),t=Ks(p=>p.running),n=Ks(p=>p.offers),s=Ks(p=>p.detailOpen),r=Ks(p=>p.inflight),i=Ks(p=>p.downloadPercent),a=Ks(p=>p.openNotice),o=Ks(p=>p.noticeOpen),l=Ks(p=>p.dismissNotice),u=g.useMemo(()=>{const p={followed:e,running:t,offers:n,detailOpen:s};return g3.filter(m=>xX(p,m)).map(m=>{const v=n[m];return v?{type:m,offer:v}:null}).filter(m=>m!==null)},[e,t,n,s]),d=g.useMemo(()=>r[an.BACKEND]?{type:an.BACKEND,percent:null}:r[an.UI]?{type:an.UI,percent:i[an.UI]}:null,[r,i]),h=g.useCallback(()=>a(),[a]),f=g.useCallback(()=>l(),[l]);return c.jsx($Ke,{surfaces:u,inflight:d,onShow:h,onDismiss:o?f:void 0})},i3=({expanded:e})=>c.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[c.jsx(CX,{className:"size-6",label:e?void 0:"Local Operator"}),e&&c.jsx("span",{className:"truncate font-semibold text-body text-ink",children:"Local Operator"})]}),Wk=Ge.memo(({expanded:e,useAuth:t=!1})=>{const n=Yr(),{user:s,isAuthenticated:r,accountRead:i,signOut:a}=S4(),o=i==="checking"?"Checking account…":A2(i)?"Account unavailable":null,l=s?.name??o??"User",u=A2(i),d=s?.email??"",h=u?"Reconnect Radient":d,f=u?"/settings?section=providers&provider=radient":"/settings",p=u?"Reconnect Radient":"Account settings",m=g.useCallback(async()=>{r&&(await a(),window.location.reload())},[r,a]),v=g.useMemo(()=>{const w=s?.name;return w?w.split(" ").map(C=>C.charAt(0)).join("").toUpperCase().substring(0,2):null},[s?.name]),x=c.jsxs("button",{type:"button",onClick:t?void 0:()=>n(f),"aria-label":e?void 0:p,className:_("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(F4,{className:"size-7 shrink-0",children:c.jsx(D4,{className:"border border-control bg-elevated text-ink",children:v??c.jsx(Bne,{size:14,"aria-hidden":"true"})})}),e&&l&&c.jsxs("span",{className:"min-w-0 text-left",children:[c.jsx("span",{className:"block truncate text-body-sm text-ink",children:l}),h&&c.jsx("span",{className:_("block truncate text-meta",u?"text-accent":"text-ink-dim"),children:h})]})]}),b=e?x:c.jsx(rt,{content:p,side:"right",children:x});return t?c.jsxs(Rl,{children:[e?c.jsx(Po,{asChild:!0,children:x}):c.jsx(rt,{content:p,side:"right",children:c.jsx(Po,{asChild:!0,children:x})}),c.jsxs(Al,{align:"end",side:"top",className:"min-w-50",children:[u?c.jsxs(jt,{onSelect:()=>n(f),children:[c.jsx(w_,{size:16,"aria-hidden":"true"}),"Reconnect Radient"]}):null,c.jsxs(jt,{onSelect:()=>n("/settings"),children:[c.jsx(cc,{size:16,"aria-hidden":"true"}),"Settings"]}),c.jsxs(jt,{children:[c.jsx(ane,{size:16,"aria-hidden":"true"}),"Privacy and security"]}),c.jsx(Ai,{}),c.jsxs(jt,{onSelect:m,className:"text-danger focus:bg-danger-wash focus:text-danger",children:[c.jsx(Ete,{size:16,"aria-hidden":"true"}),"Sign out"]})]})]}):b});Wk.displayName="UserProfileSidebar";const VKe=()=>{const e=c_(),t=os(),n=Ce(o=>o.setCataloguePageable),s=Ce(o=>o.fetchSessions),r=yt(t.data,"session_catalogue_page");g.useEffect(()=>{n(r)},[r,n]);const i=$a(t.data,"session_catalogue",2)==="enabled",a=g.useCallback(()=>s(r?Q3:uw,r),[s,r]);return g.useEffect(()=>{i&&a()},[i,a,e.catalogueRevision]),null},WKe="flex h-[30px] w-full items-center gap-2 rounded-md px-2 text-body-sm transition-colors duration-fast ease-out-quart",zKe=()=>{const e=Yr(),t=Lre(),{expanded:n,mode:s,onCollapse:r}=yX(),i=Ve(re=>re.openCommandPalette),a=os(),o=Ce(re=>re.activeSessionId),l=kKe(),u=$a(a.data,"peers")==="enabled",d=rT(u),h=$a(a.data,"approvals")==="enabled",f=UKe(d==="member"&&h,{poll:!0}),p=FKe(f.data??[]),m=yt(a.data,"projects",1),v=yt(a.data,"aida",1),x=d0(v),b=v&&x.data?.enabled===!0,w=x.data?.name??"Aida",C=jie(),E=CKe(x.data?.session_id),y=SKe(x.data?.session_id),k=()=>{C(e,x.data).catch(re=>$t(oh(re)))},T=[...b?[{icon:Mee,label:w,path:"/chat",isActive:t==="chat"&&!!x.data?.session_id&&o===x.data?.session_id,tourTag:"nav-item-aida",onSelect:k,attention:E,attentionTag:"nav-aida-badge",attentionName:re=>`${w}, ${re} missed message${re===1?"":"s"}`,working:y,workingName:`${w}, working`}]:[],{icon:kc,label:"Agents",path:"/agents",isActive:t==="agents",tourTag:"nav-item-agents"},...m?[{icon:QB,label:"Projects",path:"/projects",isActive:t==="projects",tourTag:"nav-item-projects"}]:[],{icon:XB,label:"Schedules",path:"/schedules",isActive:t==="schedules",tourTag:"nav-item-schedules"},{icon:Qu,label:"Browser",path:"/browser",isActive:t==="browser",tourTag:"nav-item-browser",attention:l,attentionTag:"nav-browser-badge",attentionName:re=>`Browser, ${re} waiting`},{icon:i6,label:"Agent hub",path:"/agent-hub",isActive:t==="agent-hub",tourTag:"nav-item-agent-hub"},...d==="member"?[{icon:f4,label:"Mesh",path:"/mesh",isActive:t==="mesh",tourTag:"nav-item-mesh",attention:p,attentionTag:"nav-mesh-badge",attentionName:re=>`Mesh, ${re} waiting`}]:[]],P=c.jsx(t7e,{selectedConversation:o??void 0,onSelectConversation:re=>void jf(e,re),onStageDraft:(re,Q)=>{Ce.getState().stageDraft(re,Q),e("/chat")}}),A=re=>{const Q=re.attention??0,pe=Q>0&&re.attentionName?re.attentionName(Q):re.label;return re.working&&re.workingName?re.workingName:pe},N=re=>{const Q=re.attention??0,pe=A(re),O=re.isActive?fo:"text-ink-muted hover:bg-row-hover hover:text-ink";return c.jsx("li",{className:_("flex h-[30px] w-full items-center rounded-md","transition-colors duration-fast ease-out-quart",O),children:c.jsxs("button",{type:"button",onClick:()=>re.onSelect?re.onSelect():e(re.path),"data-tour-tag":re.tourTag,"aria-current":re.isActive?"page":void 0,"aria-label":n&&pe===re.label?void 0:pe,className:_("flex h-full min-w-0 flex-1 items-center gap-2 rounded-md",n?"px-2":"justify-center px-0"),children:[c.jsx(re.icon,{size:16,"aria-hidden":"true",className:_("shrink-0",re.isActive&&"text-accent")}),n&&c.jsx("span",{className:"truncate",children:re.label}),Q>0&&c.jsx("span",{className:_(n&&"ml-auto","inline-flex"),children:c.jsx(Ec,{variant:"attentionQuiet",shape:"pill",size:"count","data-tour-tag":re.attentionTag,children:Q})}),re.working&&c.jsx("span",{className:_(n&&"ml-auto","inline-flex"),children:c.jsx(qa,{size:16,"aria-hidden":"true",className:"text-accent motion-safe:animate-spin"})})]})},re.tourTag)},M=re=>n?N(re):c.jsx("li",{children:c.jsx(rt,{content:A(re),side:"right",children:N(re)})},re.tourTag),I=s==="overlay"?"Close sidebar":n?"Collapse sidebar":"Expand sidebar",H=s==="overlay"?On:n?ef:Do,G=navigator.platform.toUpperCase().indexOf("MAC")>=0,j=yt(a.data,"session_catalogue",2),J=Ce(re=>re.activeDraftKey),Y=Ce(re=>re.drafts),oe=!!J&&!(J?Y[J]:void 0)?.target,U=()=>{Ce.getState().stageDraft(void 0,!0),e("/chat")},te=`New chat (${mL(G).replace("+","")})`,le=`Search (${vo("everything",G)}) — chats (${vo("chats",G)})`,R=`Search everything (${vo("everything",G)}) · your chats (${vo("chats",G)})`,L=(re,Q,pe,O)=>{const me=re;return c.jsxs("button",{type:"button",...O.attrs,onClick:O.onClick,disabled:O.disabled,"aria-label":O.ariaLabel,"aria-current":O.current?"page":void 0,className:_(WKe,O.current?fo:"text-ink-muted hover:bg-row-hover hover:text-ink","disabled:text-ink-disabled disabled:hover:bg-transparent"),children:[c.jsx(me,{size:16,"aria-hidden":"true",className:"shrink-0"}),c.jsx("span",{className:"truncate",children:Q}),c.jsx("span",{"aria-hidden":"true",className:"ml-auto",children:c.jsx(xr,{shortcut:pe,joined:!0})})]})},D=L(aE,"New chat",mL(G),{onClick:U,ariaLabel:te,current:oe,disabled:!j,attrs:{"data-tour-tag":"nav-item-chat","data-new-chat-row":""}}),W=L(Zu,"Search",EVe("everything",G),{onClick:i,ariaLabel:le,attrs:{"data-command-palette-trigger":"",title:R}}),Z=(re,Q,pe)=>{const O=re;return c.jsx(rt,{content:Q,side:"right",children:c.jsx("button",{type:"button",...pe.attrs,onClick:pe.onClick,disabled:pe.disabled,"aria-label":Q,className:_("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.jsx(O,{size:16,"aria-hidden":"true"})})})},se=c.jsx("div",{className:_(s!=="overlay"&&_("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(rt,{content:I,side:"right",children:c.jsx(ce,{variant:"ghost",size:"icon-sm",onClick:r,"aria-label":I,"aria-expanded":s==="overlay"?void 0:n,"aria-keyshortcuts":J2(G),children:c.jsx(H,{"aria-hidden":"true"})})})}),ae=c.jsx(rt,{content:"Settings",side:"top",children:c.jsx("button",{type:"button","data-tour-tag":"nav-item-settings",onClick:()=>e("/settings"),"aria-current":t==="settings"?"page":void 0,"aria-label":"Settings",className:_("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",t==="settings"&&"text-ink"),children:c.jsx(cc,{size:16,"aria-hidden":"true"})})});return n?c.jsxs("div",{"data-sidebar-shell":"",className:"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 pr-2 pl-4",children:[c.jsx(i3,{expanded:!0}),c.jsx("span",{className:"ml-auto",children:se})]}),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:[D,W]}),c.jsx("ul",{className:"flex flex-col gap-0.5",children:T.map(M)})]}),c.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:P}),c.jsxs("div",{className:"flex min-h-10 shrink-0 items-center justify-between gap-1 px-2 pb-2",children:[c.jsx(Wk,{expanded:!0}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx(r3,{}),ae]})]})]}):c.jsxs("div",{"data-sidebar-strip":"",className:"group/sidebar flex h-full min-h-0 flex-col items-center bg-surface",children:[c.jsx(VKe,{}),c.jsx("div",{className:"flex h-10 shrink-0 items-center justify-center",children:c.jsx(i3,{expanded:!1})}),c.jsxs("ul",{className:"flex flex-col items-center gap-1",children:[c.jsx("li",{children:Z(Do,I,{onClick:r,attrs:{"aria-expanded":!1,"aria-keyshortcuts":J2(G)}})}),c.jsx("li",{children:Z(aE,te,{onClick:U,disabled:!j,attrs:{"data-tour-tag":"nav-item-chat"}})}),c.jsx("li",{children:Z(Zu,le,{onClick:i,attrs:{"data-command-palette-trigger":""}})})]}),c.jsx("ul",{className:"mt-4 flex flex-col items-center gap-1",children:T.map(M)}),c.jsxs("div",{className:"mt-auto flex flex-col items-center gap-1 pb-2",children:[c.jsx(r3,{}),ae,c.jsx(Wk,{expanded:!1})]})]})},qKe=1,KKe=()=>{const{isAuthenticated:e,user:t}=S4(),{hasBeenNotified:n,setHasBeenNotified:s}=N9(),[r,i]=g.useState(!1),[a,o]=g.useState(null),l=g.useCallback(async()=>{if(!(!e||!t?.radientUser?.account?.tenant_id))try{const f=await SX({operation:"credits",tenantId:t.radientUser.account.tenant_id});if(!f||typeof f.balance!="number")throw new Error("Invalid credit balance response format");o(f.balance)}catch(f){console.error("Failed to fetch Radient credits:",f),o(null)}},[e,t?.radientUser?.account?.tenant_id]);return g.useEffect(()=>{e&&l()},[e,l]),g.useEffect(()=>{e&&a!==null?a<qKe?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 YKe(){const e=Yr();g.useEffect(()=>{const t=r=>{e(r==="back"?-1:1)},n=r=>{const i=Mue(r);i&&(r.preventDefault(),t(i))},s=r=>{const i=Oue(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 XKe(){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 QKe(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 JKe(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 ZKe(){g.useLayoutEffect(()=>{if(!window.api?.windowChrome)return;const t=document.documentElement.dataset.chromePlatform??"linux",n=()=>QKe(XKe(),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)}},[]),g.useEffect(()=>{const e=window.api?.windowChrome;if(e)return e.onState(t=>{document.documentElement.dataset.chromeFullscreen=t.fullScreen?"true":"false"})},[])}const eYe=g.lazy(()=>Tl(()=>import("./agent-details-page-TpBQjIfy.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]),import.meta.url).then(e=>({default:e.AgentDetailsPage}))),tYe=g.lazy(()=>Tl(()=>import("./agent-hub-page-BwXLGE4W.js"),__vite__mapDeps([13,1,2,4,5,6,7,14,3,8,9,10,15,16,17,11,12]),import.meta.url).then(e=>({default:e.AgentHubPage}))),a3=g.lazy(()=>Tl(()=>import("./agents-page-DvFU6Y5_.js"),__vite__mapDeps([18,4,5,1,2,6,7,11,12]),import.meta.url).then(e=>({default:e.AgentsPage}))),nYe=g.lazy(()=>Tl(()=>import("./schedules-page-Btb8nn58.js"),__vite__mapDeps([19,1,2,4,5,6,7,14,17,9,20,11,12]),import.meta.url).then(e=>({default:e.SchedulesPage}))),o3=g.lazy(()=>Tl(()=>import("./projects-page-aLyO9q2b.js"),__vite__mapDeps([21,1,2,4,5,6,7,14,22,11,12]),import.meta.url).then(e=>({default:e.ProjectsPage}))),sYe=g.lazy(()=>Tl(()=>import("./browser-page-BRc9g9nj.js"),__vite__mapDeps([23,1,2,4,5,6,7,11,12]),import.meta.url).then(e=>({default:e.BrowserPage}))),rYe=g.lazy(()=>Tl(()=>import("./mesh-page-D2E7RiVp.js"),__vite__mapDeps([24,1,2,4,5,6,7,14,11,12]),import.meta.url).then(e=>({default:e.MeshPage}))),iYe=g.lazy(()=>Tl(()=>import("./settings-page-BaIqVV9F.js"),__vite__mapDeps([25,1,2,4,5,6,7,14,15,26,10,20,9,17,11,12]),import.meta.url).then(e=>({default:e.SettingsPage}))),aYe=g.lazy(()=>Tl(()=>import("./browser-webauthn-prompt-DoSh0kSS.js"),__vite__mapDeps([27,1,2,4,5,6,7]),import.meta.url).then(e=>({default:e.BrowserWebauthnPrompt}))),oYe=()=>{ZKe(),pKe();const{pathname:e}=l_(),t=e.startsWith("/chat")||e.startsWith("/browser"),{isOnboardingActive:n}=Mre(),{isLowCreditsDialogOpen:s,openRadientConsole:r,onLowCreditsDialogClose:i}=KKe(),{isCommandPaletteOpen:a,isCreateAgentDialogOpen:o,isSidebarCollapsed:l,closeCreateAgentDialog:u}=Ve();Eu(a,"command-palette"),Eu(o,"create-agent-dialog"),Eu(n,"onboarding"),Eu(s,"low-credits");const d=Yr(),h=os(),f=yt(h.data,"session_catalogue",2),p=yt(h.data,"session_archive");g.useEffect(()=>{Ce.getState().requestArchiveConfirm(null)},[e]);const m=$a(h.data,"peers"),v=y=>{Ce.getState().stageDraft({kind:"agent",name:y.name}),d("/chat"),u()};qVe(),vKe(),DVe(),YKe(),ade();const x=Ce(y=>y.setActiveSession),b=Ce(y=>{const k=y.activeDraftKey?y.drafts[y.activeDraftKey]:void 0;return Mf(y.activeDraftKey,k?.sessionId,y.activeSessionId)}),w=Ve(y=>y.setConsolePaneOpen),C=Ve(y=>y.setBrowserPaneOpen),E=Ve(y=>y.setConsoleActiveSurface);return g.useEffect(()=>{const y=window.api?.desktop?.onOpenConversation?.((k,T)=>{k!==null&&performance.mark("lop:open:requested"),x(k),T!==void 0&&k!==null&&(E(T),w(!0)),d("/chat")});return()=>y?.()},[d,x,w,E]),g.useEffect(()=>{const y=window.api?.console?.onReveal?.(k=>{k.mode!=="none"&&(k.mode==="session"&&k.session_id!==b||(k.mode==="open"&&x(k.session_id),E(k.surface),w(!0)))});return()=>y?.()},[b,x,w,E]),Die(),vVe(),g.useEffect(()=>{const y=window.api?.browser?.onConsentAttention?.(k=>{const T=die(k.requesterSessionId,Ce.getState().sessions);if(lie(k.entryId),T.kind==="browser"){d("/browser");return}x(T.sessionId),C(!0),d("/chat")});return()=>y?.()},[d,x,C]),g.useEffect(()=>{const y=k=>{n||f&&bVe(k)&&(k.preventDefault(),Ce.getState().stageDraft(void 0,!0),d("/chat"))};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[f,n,d]),c.jsx(cKe,{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($Ve,{}),c.jsx(wVe,{}),c.jsx(EX,{}),c.jsx(KVe,{enabled:m==="enabled"}),c.jsx(PWe,{open:n}),c.jsx(uKe,{}),c.jsx(fKe,{}),p&&c.jsx(Mie,{}),c.jsx(aie,{}),c.jsx(g.Suspense,{fallback:null,children:c.jsx(aYe,{})}),c.jsx(bKe,{open:s,onClose:i,onGoToConsole:r}),c.jsx(Hre,{open:o,onClose:u,onAgentCreated:v}),c.jsx(kX,{sidebar:c.jsx(zKe,{}),content:c.jsxs("main",{className:"flex grow flex-col overflow-hidden",children:[t?null:c.jsx("div",{"data-chrome-route-band":""}),c.jsx(g.Suspense,{fallback:c.jsx("div",{className:"flex grow items-center justify-center",children:c.jsx(Rn,{size:"lg",label:"Loading page"})}),children:c.jsxs(_X,{children:[c.jsx(Jr,{path:"/",element:c.jsx(F2,{to:"/chat",replace:!0})}),c.jsx(Jr,{path:"/chat",element:c.jsx(pL,{})}),c.jsx(Jr,{path:"/chat/:agentId",element:c.jsx(pL,{})}),c.jsx(Jr,{path:"/agents",element:c.jsx(a3,{})}),c.jsx(Jr,{path:"/agents/:agentId",element:c.jsx(a3,{})}),c.jsx(Jr,{path:"/settings",element:c.jsx(iYe,{})}),c.jsx(Jr,{path:"/agent-hub",element:c.jsx(tYe,{})}),c.jsx(Jr,{path:"/agent-hub/:agentId",element:c.jsx(eYe,{})}),c.jsx(Jr,{path:"/schedules",element:c.jsx(nYe,{})}),c.jsx(Jr,{path:"/projects",element:c.jsx(o3,{})}),c.jsx(Jr,{path:"/projects/:projectId",element:c.jsx(o3,{})}),c.jsx(Jr,{path:"/browser",element:c.jsx(sYe,{})}),m==="enabled"&&c.jsx(Jr,{path:"/mesh",element:c.jsx(rYe,{})}),c.jsx(Jr,{path:"*",element:c.jsx(F2,{to:"/chat",replace:!0})})]})})]})})]})})})};function Su(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}const lYe=3,cYe=3e3;function uYe(e){return e instanceof CSSTransition&&e.playState==="running"}function dYe(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 ${Xm(n)??"an element no longer in the document"} = ${i}`}async function hYe(e=cYe){const t=performance.now();let n=0;for(;;){await Su();const s=Math.round(performance.now()-t),r=document.getAnimations().filter(uYe);if(n=r.length===0?n+1:0,n>=lYe)return{waitedMs:s,timedOut:!1,pending:[]};if(s>e)return{waitedMs:s,timedOut:!0,pending:r.map(dYe)}}}const fYe=/^#/;function zg(){const e=window.location.hash.replace(fYe,"");return e===""?"/":e}function Xm(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 pYe(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=>Xm(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:Xm(r),stack:a,disabled:e instanceof HTMLButtonElement?e.disabled:null,rect:{x:t.x,y:t.y,width:t.width,height:t.height}}}function Up(e,t){if(typeof e!="string"||e==="")throw new Error(`${t} must be a non-empty string`);return e}async function gYe(e,t=1e4){const n=Date.now();for(;zg()!==e;){if(Date.now()-n>t)throw new Error(`route did not become ${e} (it is ${zg()})`);await new Promise(s=>setTimeout(s,50))}return await Su(),zg()}const zk=["dev-driver","query-fetch-probe"];let qg=null;function mYe(){if(qg)return qg;const e=[],t=D2.prototype.fetch;return D2.prototype.fetch=function(...s){return e.push({at:Date.now(),key:JSON.stringify(this.queryKey),stack:(new Error().stack??"").split(`
678
678
  `).slice(2).join(" | ")}),t.apply(this,s)},qg=e,e}function vYe(e){const t=qg??[],n=JSON.stringify(zk),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:qg!==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 xYe(){const e=window.__loDevDriver;return e?.armed?e.install({hello:()=>({armed:!0,outDir:e.outDir,title:document.title,route:zg(),href:window.location.href,theme:Ve.getState().themeName,viewport:{width:window.innerWidth,height:window.innerHeight,devicePixelRatio:window.devicePixelRatio},visibilityState:document.visibilityState,hasFocus:document.hasFocus(),apiBaseUrl:ws.baseUrl,userAgent:navigator.userAgent}),state:()=>{const t=Ve.getState(),n=Ce.getState();return{route:zg(),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}])),sessionCount:n.sessions.length,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:()=>Ax.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 vYe(n.key);const s=mYe(),r=JSON.stringify(zk),i=s.length;return await Ax.fetchQuery({queryKey:zk,queryFn:()=>null,retry:!1,staleTime:0}),{armed:!0,validated:s.slice(i).some(a=>a.key===r)}},navigate:async t=>{const n=Up(t,"navigate path");if(!n.startsWith("/"))throw new Error(`navigate path must start with "/" (got "${n}")`);return window.location.hash=`#${n}`,{route:await gYe(n)}},setTheme:async t=>{const n=Up(t,"theme name");Ve.getState().setTheme(n),await Su();const s=document.documentElement.getAttribute("data-theme"),r=await hYe();return{theme:Ve.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=HQ(n);return Ve.getState().setChatSidebarWidth(s),await Su(),{width:Ve.getState().chatSidebarWidth,clamped:s!==n}},measure:async t=>{const n=typeof t=="string"?{selector:t}:t,s=Up(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:Xm(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=Up(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=pYe(a);return await Su(),{selector:s,target:Xm(a),...o}},openCanvasDocument:async t=>{const n=t,s=Up(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=_h(a,{title:r,type:nf(a),availability:"present",sizeBytes:i.sizeBytes??void 0,lastAgentModified:i.mtimeMs??void 0,readMtimeMs:i.mtimeMs??void 0}),l=gw[r0(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=Ce.getState(),d=f_(u.activeDraftKey,u.activeSessionId)??u.stageDraft();return Ve.getState().setCanvasOpen(!0),ns.getState().addFileAndSelect(d,o),n?.mention===!0&&ns.getState().addMentionedFile(d,o),await Su(),{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 kie({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 Su(),{count:s}}}):[]}function bYe(){const e=g.useMemo(Xk,[]),t=g.useRef(null);return g.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=UQ(a.value,e);$t(TX(a.status,l))};n.getRegistration?.()?.then(r)?.catch(()=>{});const i=n.onRegistration(r);return()=>{s=!0,i?.()}},[e]),null}const wYe=`
679
679
  /*
680
680
  * A transition declared on ::-webkit-scrollbar-thumb does not animate in