@tickernelz/wardmote-ui 2026.1108.1 → 2026.1108.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/assets/{CompanyExport-DUnuQia9.js → CompanyExport-nSZ6c22o.js} +1 -1
  2. package/dist/assets/{Terminal-D1ruwJKK.js → Terminal-BUKNL-hS.js} +1 -1
  3. package/dist/assets/{dist-BlfE4iqp.js → dist-7JK5o5w2.js} +1 -1
  4. package/dist/assets/{dist-DtHqErgw.js → dist-BJVIAntd.js} +1 -1
  5. package/dist/assets/{dist-DwulSeaC.js → dist-BNQK72Ay.js} +1 -1
  6. package/dist/assets/{dist-BM1c6ixo.js → dist-BRZ2juoF.js} +1 -1
  7. package/dist/assets/{dist-BlthiXtb.js → dist-BYmxsnlZ.js} +1 -1
  8. package/dist/assets/{dist-B0W7Yi42.js → dist-Be2PH9Ri.js} +1 -1
  9. package/dist/assets/{dist-Do3PUu3w.js → dist-Bs-s6dPt.js} +1 -1
  10. package/dist/assets/{dist-Ca2ao84r.js → dist-C-AEDno-.js} +1 -1
  11. package/dist/assets/{dist-BIH3XOAA.js → dist-CPFoA4ty.js} +1 -1
  12. package/dist/assets/{dist-CcZe9JAO.js → dist-CWYWSO70.js} +1 -1
  13. package/dist/assets/{dist-DMD4VbFv.js → dist-CoBeqEhN.js} +1 -1
  14. package/dist/assets/{dist-BxPHMXlf.js → dist-CsYwdeKQ.js} +1 -1
  15. package/dist/assets/{dist-8AduNOQx.js → dist-CwygYsQk.js} +1 -1
  16. package/dist/assets/{dist-CfUv27eg.js → dist-DCmyl8JS.js} +1 -1
  17. package/dist/assets/{dist-DeYTUba7.js → dist-DLhVtuRQ.js} +1 -1
  18. package/dist/assets/{dist-DTvLpQIg.js → dist-DX49WtIu.js} +1 -1
  19. package/dist/assets/{dist-B6VGqBMw.js → dist-D_0NfuCy.js} +1 -1
  20. package/dist/assets/{dist-CGwpvx3Z.js → dist-DpJyVhoi.js} +1 -1
  21. package/dist/assets/{dist-C_VeG_Q6.js → dist-DwUD8svp.js} +1 -1
  22. package/dist/assets/{dist-BOfv8ix1.js → dist-DxGmGQAd.js} +1 -1
  23. package/dist/assets/{dist-Dmjj6qqj.js → dist-YLpD_m68.js} +1 -1
  24. package/dist/assets/{dist-C518NMMv.js → dist-aSaqj57N.js} +1 -1
  25. package/dist/assets/{dist-B8zM63sM.js → dist-fm9IOgs2.js} +1 -1
  26. package/dist/assets/{index-CKKKBvW4.js → index-CXBON4gu.js} +4 -4
  27. package/dist/index.html +1 -1
  28. package/dist/sw.js +1 -1
  29. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-Dmjj6qqj.js","assets/dist-DwulSeaC.js","assets/dist-C518NMMv.js","assets/dist-BOfv8ix1.js","assets/dist-BM1c6ixo.js","assets/rolldown-runtime-ZpX3ckPj.js","assets/dist-BlfE4iqp.js","assets/dist-Do3PUu3w.js","assets/dist-B8zM63sM.js","assets/dist-CfUv27eg.js","assets/dist-B0W7Yi42.js","assets/dist-DeYTUba7.js","assets/dist-8AduNOQx.js","assets/dist-DTvLpQIg.js","assets/dist-B6VGqBMw.js","assets/dist-CGwpvx3Z.js","assets/dist-DMD4VbFv.js","assets/dist-BxPHMXlf.js","assets/dist-DtHqErgw.js","assets/dist-CcZe9JAO.js","assets/dist-C_VeG_Q6.js","assets/dist-BIH3XOAA.js","assets/dockerfile-BttNdtK0.js","assets/simple-mode-B79cVo-x.js","assets/factor-CM3-9V3b.js","assets/nsis-KFC6hioG.js","assets/pug-C20tNwmy.js","assets/javascript-Cblpdx44.js","assets/dist-Ca2ao84r.js","assets/dist-BlthiXtb.js","assets/runtime-IAg0vdY9.js","assets/model-DL5biheO.js","assets/definition-CvJN1sEp.js","assets/prod-COP_vZWu.js","assets/mermaid.core-Be3XJK9z.js","assets/preload-helper-CceJXRIF.js","assets/chunk-Y2CYZVJY-OvsAdhaO.js","assets/src-Bssc388C.js","assets/chunk-DU6HZSFF-mLZ_DAj9.js","assets/chunk-75Z2AOVW-CTyOxDW3.js","assets/dist-Cj4C2HPs.js","assets/chunk-PWAF6VOD-DHqPPKbd.js","assets/chunk-GMAD6QVW-Vk29EsOn.js","assets/chunk-P2QGCYS3-DD1uZyrA.js","assets/chunk-4HAMMTFA-Duh1dbZg.js","assets/rough.esm-DnC5Tr1g.js","assets/chunk-GVQU2GXP-D5bNpR4K.js","assets/chunk-OSK3NFVY-BfvIkdmA.js","assets/line-Dk_ouzM8.js","assets/path-D6mommQw.js","assets/array-CL5Tisss.js","assets/graphlib-DHhK3saS.js","assets/chunk-L3NEJ4N5-GADujcju.js","assets/CompanyExport-DUnuQia9.js","assets/x-CzBf9g0R.js","assets/clipboard-oERS_NGj.js","assets/Terminal-D1ruwJKK.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-YLpD_m68.js","assets/dist-BNQK72Ay.js","assets/dist-aSaqj57N.js","assets/dist-DxGmGQAd.js","assets/dist-BRZ2juoF.js","assets/rolldown-runtime-ZpX3ckPj.js","assets/dist-7JK5o5w2.js","assets/dist-Bs-s6dPt.js","assets/dist-fm9IOgs2.js","assets/dist-DCmyl8JS.js","assets/dist-Be2PH9Ri.js","assets/dist-DLhVtuRQ.js","assets/dist-CwygYsQk.js","assets/dist-DX49WtIu.js","assets/dist-D_0NfuCy.js","assets/dist-DpJyVhoi.js","assets/dist-CoBeqEhN.js","assets/dist-CsYwdeKQ.js","assets/dist-BJVIAntd.js","assets/dist-CWYWSO70.js","assets/dist-DwUD8svp.js","assets/dist-CPFoA4ty.js","assets/dockerfile-BttNdtK0.js","assets/simple-mode-B79cVo-x.js","assets/factor-CM3-9V3b.js","assets/nsis-KFC6hioG.js","assets/pug-C20tNwmy.js","assets/javascript-Cblpdx44.js","assets/dist-C-AEDno-.js","assets/dist-BYmxsnlZ.js","assets/runtime-IAg0vdY9.js","assets/model-DL5biheO.js","assets/definition-CvJN1sEp.js","assets/prod-COP_vZWu.js","assets/mermaid.core-Be3XJK9z.js","assets/preload-helper-CceJXRIF.js","assets/chunk-Y2CYZVJY-OvsAdhaO.js","assets/src-Bssc388C.js","assets/chunk-DU6HZSFF-mLZ_DAj9.js","assets/chunk-75Z2AOVW-CTyOxDW3.js","assets/dist-Cj4C2HPs.js","assets/chunk-PWAF6VOD-DHqPPKbd.js","assets/chunk-GMAD6QVW-Vk29EsOn.js","assets/chunk-P2QGCYS3-DD1uZyrA.js","assets/chunk-4HAMMTFA-Duh1dbZg.js","assets/rough.esm-DnC5Tr1g.js","assets/chunk-GVQU2GXP-D5bNpR4K.js","assets/chunk-OSK3NFVY-BfvIkdmA.js","assets/line-Dk_ouzM8.js","assets/path-D6mommQw.js","assets/array-CL5Tisss.js","assets/graphlib-DHhK3saS.js","assets/chunk-L3NEJ4N5-GADujcju.js","assets/CompanyExport-nSZ6c22o.js","assets/x-CzBf9g0R.js","assets/clipboard-oERS_NGj.js","assets/Terminal-BUKNL-hS.js"])))=>i.map(i=>d[i]);
2
2
  var AIt=Object.defineProperty;var i=(e,t)=>AIt(e,"name",{value:t,configurable:!0});import{i as B1,n as LQ,t as ih}from"./rolldown-runtime-ZpX3ckPj.js";import{$ as IIt,$a as TIt,$i as sZ,$n as Ff,$r as s6,$t as IUe,A as I0,Aa as Xz,Ai as TUe,An as EIt,Ao as i3e,Ar as RIt,At as MIt,B as Gd,Ba as Tc,Bi as T3,Bn as LIt,Bo as cpe,Br as EUe,Bt as DIt,C as RUe,Ca as z1,Ci as T0,Cn as eie,Co as dpe,Cr as PIt,Ct as O,D as hk,Da as eq,Di as $It,Dn as OIt,Do as a3e,Dr as FIt,Dt as BIt,E as hp,Ei as zIt,En as qIt,Eo as MUe,Er as UIt,Et as KIt,F as LUe,Fa as o3e,Fi as DUe,Fn as pM,Fo as H8,Fr as WIt,Ft as By,G as upe,Ga as QIt,Gi as PUe,Gn as M5,Gr as $Ue,Gt as VIt,H as HIt,Ha as le,Hi as GIt,Hn as YIt,Hr as OUe,Ht as FUe,I as BUe,Ia as zUe,Ii as tq,In as l3e,Io as JIt,Ir as ZIt,It as XIt,J as qUe,Ja as UUe,Ji as eTt,Jn as G8,Jr as tTt,Jt as nTt,K as Q,Ka as sTt,Ki as c3e,Kn as rTt,Kr as KUe,Kt as hpe,L as iTt,La as aTt,Li as JI,Ln as oTt,Lo as Ct,Lr as lTt,Lt as WUe,M as K0,Ma as cTt,Mi as L5,Mn as dTt,Mo as rZ,Mr as d3e,Mt as uTt,N as ta,Na as iZ,Ni as hTt,Nn as mTt,No as pTt,Nr as fTt,Nt as QUe,O as Mp,Oa as u3e,Oi as gTt,On as xTt,Oo as h3e,Or as vTt,Ot as m3e,P as bTt,Pa as D5,Pi as Mg,Pn as yTt,Po as kTt,Pr as wTt,Pt as P5,Q as Sr,Qa as nq,Qi as jTt,Qn as NTt,Qr as CTt,Qt as DC,R as Qo,Ra as mpe,Ri as VUe,Rn as STt,Ro as _Tt,Rr as ATt,Rt as ITt,S as ppe,Sa as TTt,Si as fpe,Sn as gpe,So as ETt,Sr as RTt,St as HUe,Ta as MTt,Ti as LTt,Tn as GUe,To as tie,Tr as DTt,Tt as YUe,U as p3e,Ua as PTt,Ui as JUe,Un as $Tt,Ur as OTt,Ut as nie,V as Qg,Va as ss,Vi as xpe,Vn as f3e,Vr as FTt,Vt as vpe,W as g3e,Wa as x3e,Wi as _v,Wn as ZUe,Wr as BTt,Wt as sq,X as XUe,Xa as W0,Xi as v3e,Xn as eKe,Xr as zTt,Xt as qTt,Y as ai,Ya as ZI,Yi as tKe,Yn as UTt,Yr as KTt,Yt as WTt,Z as Zh,Za as QTt,Zi as VTt,Zn as b3e,Zr as y3e,Zt as HTt,_ as GTt,_a as k3e,_i as bpe,_n as w3e,_o as YTt,_r as JTt,_t as Y8,a as ype,aa as ZTt,ai as XTt,an as qv,ao as ie,ar as j3e,at as rq,b as N3e,ba as sie,bi as rie,bn as nKe,bo as C3e,br as e4t,bt as t4t,c as sKe,ca as n4t,ci as s4t,cn as r4t,co as i4t,cr as LA,ct as $5,da as a4t,di as o4t,dn as l4t,do as c4t,dr as rKe,dt as Nr,ea as d4t,ei as WF,en as S3e,eo as iq,er as Af,et as aq,f as kpe,fa as u4t,fi as h4t,fn as m4t,fo as p4t,fr as NS,ft as iKe,g as XI,ga as _3e,gi as f4t,gn as A3e,go as wpe,gr as oq,gt as gn,h as DQ,ha as aKe,hi as g4t,ho as x4t,hr as v4t,ht as b4t,i as y4t,ia as PQ,ii as iie,in as J8,io as ye,ir as fM,it as Ei,j as $r,ja as k4t,ji as w4t,jn as j4t,jo as N4t,jr as jpe,jt as I3e,k as Jf,ka as C4t,ki as S4t,ko as av,kr as oKe,kt as _4t,l as Npe,la as A4t,li as aie,ln as I4t,lo as T3e,lr as T4t,lt as _p,m as Cpe,ma as lKe,mi as E3e,mn as $Q,mo as E4t,mr as cKe,n as yd,na as R4t,nn as M4t,no as zk,nr as dKe,nt as L4t,o as D4t,oa as OQ,oi as R3e,on as P4t,oo as $4t,or as O4t,ot as Xj,p as F4t,pa as FQ,pi as M3e,pn as uKe,po as B4t,pr as oie,pt as hKe,q as z4t,qa as CN,qi as mKe,qn as L3e,qr as q4t,qt as Spe,r as wt,ra as U4t,ri as pKe,rn as Uv,ro as K4t,rr as _pe,rt as m0,s as fKe,sa as gKe,si as xKe,so as W4t,sr as Q4t,st as gM,t as ks,ta as vKe,ti as D3e,tn as Ape,to as DA,tr as xM,tt as ho,u as Ipe,ua as V4t,ui as bKe,un as Tpe,uo as H4t,ur as G4t,ut as Epe,v as Rpe,va as Y4t,vi as PA,vn as yKe,vo as J4t,vr as Z4t,vt as X4t,w as Mpe,wa as eEt,wi as lq,wn as tEt,wo as nEt,wr as kKe,wt as Ji,x as wKe,xa as Z8,xi as Lpe,xn as jKe,xo as Qh,xr as sEt,xt as jb,y as Dpe,ya as rEt,yi as iEt,yn as B4,yo as aEt,yr as oEt,yt as lEt,z as Ppe,za as cEt,zi as NKe,zn as dEt,zo as CKe,zr as uEt}from"./x-CzBf9g0R.js";import{t as ln}from"./preload-helper-CceJXRIF.js";import{$n as Ia,$t as lie,A as hEt,An as P3e,At as ac,B as oj,Bn as SKe,Bt as Zf,C as mEt,Cn as cq,Ct as Yd,D as BQ,Dn as $3e,Dt as Lp,E as E3,En as oc,Et as X8,F as pEt,Fn as QF,Ft as If,Gn as CS,Gt as As,H as fEt,Hn as So,Ht as Ch,In as gEt,It as kr,J as _Ke,Jn as xEt,Jt as Xy,K as vEt,Kn as ot,Kt as sn,L as bEt,Ln as yEt,Lt as dq,M as ix,Mn as mk,Mt as Qc,N as kEt,Nn as wEt,Nt as eD,O as AKe,On as jEt,Ot as Ao,P as eT,Pn as NEt,Pt as zQ,Qn as Mi,Qt as cr,Rn as CEt,Rt as IKe,S as SEt,Sn as Mt,St as tD,T as _Et,Tn as qQ,Tt as nR,Un as AEt,Ut as tT,V as IEt,Vn as TEt,Vt as SS,W as vM,Wn as Nh,Wt as mi,X as EEt,Xn as TKe,Xt as g0,Yn as Ri,Yt as bM,Z as l9,Zn as $pe,Zt as REt,_ as Ss,_n as O3e,_t as ax,a as Hs,an as MEt,at as Xf,b as ir,bn as LEt,bt as rl,c as DEt,cn as F3e,ct as Xv,d as PEt,dn as B3e,dt as UQ,en as Vs,et as uq,f as $,fn as $Et,ft as Jr,g as Ope,gn as c9,gt as js,h as Ye,hn as OEt,ht as t3,i as FEt,in as BEt,it as hq,j as zEt,jn as pk,jt as qEt,k as UEt,kn as aZ,kt as KEt,l as Qa,ln as WEt,lt as fk,m as nD,mn as EKe,mt as QEt,n as RKe,nn as VEt,nt as HEt,o as GEt,on as cie,ot as gk,p as O5,pn as YEt,pt as JEt,qn as ZEt,qt as n3,r as XEt,rn as gr,s as Eh,sn as MKe,st as eRt,t as pi,tn as tRt,u as ri,un as nRt,ut as eb,v as sRt,vn as LKe,vt as Kv,w as Fpe,wn as z3e,wt as Xh,x as rRt,xn as D2,xt as ct,y as _S,yn as iRt,yt as Bpe,z as DKe,zn as aRt,zt as oRt}from"./clipboard-oERS_NGj.js";import{$ as KQ,A as bg,B as lRt,C as cRt,D as sD,E as dRt,F as die,G as Av,H as yM,I as mq,J as zpe,K as wh,L as PKe,M as d9,N as q3e,O as z4,P as ra,Q as uRt,R as $Ke,S as hRt,T as U3e,U as kM,V as K3e,W as mRt,X as oZ,Y as sp,Z as pRt,_ as fRt,a as gRt,at as xRt,b as vRt,c as OKe,d as FKe,et as bRt,f as BKe,g as rD,h as yRt,i as iD,it as kRt,j as Hu,k as W3e,l as zKe,m as qKe,n as wRt,nt as jRt,o as NRt,p as UKe,q as pq,r as KKe,rt as CRt,s as Q3e,t as u9,tt as WKe,u as QKe,v as SRt,w as uie,x as qpe,y as _Rt,z as VKe}from"./mention-chips-BKRdYPgz.js";import{a as q1,c as aD,d as Upe,f as HKe,i as oD,l as lD,m as GKe,n as WQ,o as cD,p as nT,r as U1,s as Kpe,t as QQ,u as VQ}from"./dist-BsvRtKyc.js";i((function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function s(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}i(s,"getFetchOpts");function r(a){if(a.ep)return;a.ep=!0;const o=s(a);fetch(a.href,o)}i(r,"processPreload")}),"polyfill")();var ARt=class extends wpe{static{i(this,"InfiniteQueryObserver")}constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:s}=e,r=super.createResult(e,t),{isFetching:a,isRefetching:o,isError:l,isRefetchError:c}=r,d=s.fetchMeta?.fetchMore?.direction,u=l&&d==="forward",h=a&&d==="forward",p=l&&d==="backward",f=a&&d==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:J4t(t,s.data),hasPreviousPage:aEt(t,s.data),isFetchNextPageError:u,isFetchingNextPage:h,isFetchPreviousPageError:p,isFetchingPreviousPage:f,isRefetchError:c&&!u&&!p,isRefetching:o&&!h&&!f}}},IRt=class extends dpe{static{i(this,"MutationCache")}#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,s){const r=new x4t({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:s});return this.add(r),r}add(e){this.#e.add(e);const t=h9(e);if(typeof t=="string"){const s=this.#t.get(t);s?s.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=h9(e);if(typeof t=="string"){const s=this.#t.get(t);if(s)if(s.length>1){const r=s.indexOf(e);r!==-1&&s.splice(r,1)}else s[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=h9(e);if(typeof t=="string"){const s=this.#t.get(t)?.find(r=>r.state.status==="pending");return!s||s===e}else return!0}runNext(e){const t=h9(e);return typeof t=="string"?this.#t.get(t)?.find(s=>s!==e&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Qh.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(s=>a3e(t,s))}findAll(e={}){return this.getAll().filter(t=>a3e(e,t))}notify(e){Qh.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return Qh.batch(()=>Promise.all(e.map(t=>t.continue().catch(av))))}};function h9(e){return e.options.scope?.id}i(h9,"scopeFor");function V3e(e,t){const s=new Set(t);return e.filter(r=>!s.has(r))}i(V3e,"difference");var TRt=class extends dpe{static{i(this,"QueriesObserver")}#e;#t;#n;#r;#s;#i;#a;#o;#l;#c=[];constructor(e,t,s){super(),this.#e=e,this.#r=s,this.#n=[],this.#s=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#s.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#s.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,Qh.batch(()=>{const s=this.#s,r=this.#h(this.#n);r.forEach(h=>h.observer.setOptions(h.defaultedQueryOptions));const a=r.map(h=>h.observer),o=a.map(h=>h.getCurrentResult()),l=s.length!==a.length,c=a.some((h,p)=>h!==s[p]),d=l||c,u=d?!0:o.some((h,p)=>{const f=this.#t[p];return!f||!pTt(h,f)});!d&&!u||(d&&(this.#c=r,this.#s=a),this.#t=o,this.hasListeners()&&(d&&(V3e(s,a).forEach(h=>{h.destroy()}),V3e(a,s).forEach(h=>{h.subscribe(p=>{this.#m(h,p)})})),this.#p()))})}getCurrentResult(){return this.#t}getQueries(){return this.#s.map(e=>e.getCurrentQuery())}getObservers(){return this.#s}getOptimisticResult(e,t){const s=this.#h(e),r=s.map(o=>o.observer.getOptimisticResult(o.defaultedQueryOptions)),a=s.map(o=>o.defaultedQueryOptions.queryHash);return[r,o=>this.#u(o??r,t,a),()=>this.#d(r,s)]}#d(e,t){const s=new Set;return t.map((r,a)=>{const o=e[a];return r.defaultedQueryOptions.notifyOnChangeProps?o:r.observer.trackResult(o,l=>{s.has(l)||(s.add(l),t.forEach(c=>{c.observer.trackProp(l)}))})})}#u(e,t,s){if(t){const r=this.#l,a=s!==void 0&&r!==void 0&&(r.length!==s.length||s.some((o,l)=>o!==r[l]));return(this.#t!==this.#o||a||t!==this.#a)&&(this.#a=t,this.#o=this.#t,s!==void 0&&(this.#l=s),this.#i=N4t(this.#i,t(e))),this.#i}return e}#f(){return!this.#r?.combine||this.#s.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#h(e){const t=new Map;this.#s.forEach(r=>{const a=r.options.queryHash;if(!a)return;const o=t.get(a);o?o.push(r):t.set(a,[r])});const s=[];return e.forEach(r=>{const a=this.#e.defaultQueryOptions(r),o=t.get(a.queryHash)?.shift()??new wpe(this.#e,a);s.push({defaultedQueryOptions:a,observer:o})}),s}#m(e,t){const s=this.#s.indexOf(e);s!==-1&&(this.#t=this.#t.slice(),this.#t[s]=t,this.#p())}#p(){if(this.hasListeners()){const e=this.#f(),t=this.#i,s=e?t:this.#u(this.#d(this.#t,this.#c),this.#r?.combine);(e||t!==s)&&Qh.batch(()=>{this.listeners.forEach(r=>{r(this.#t)})})}}},ERt=class extends dpe{static{i(this,"QueryCache")}#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,s){const r=t.queryKey,a=t.queryHash??MUe(r,t);let o=this.get(a);return o||(o=new YTt({client:e,queryKey:r,queryHash:a,options:e.defaultQueryOptions(t),state:s,defaultOptions:e.getQueryDefaults(r)}),this.add(o)),o}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Qh.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(s=>h3e(t,s))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(s=>h3e(e,s)):t}notify(e){Qh.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Qh.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Qh.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},dD=class{static{i(this,"QueryClient")}#e;#t;#n;#r;#s;#i;#a;#o;constructor(e={}){this.#e=e.queryCache||new ERt,this.#t=e.mutationCache||new IRt,this.#n=e.defaultOptions||{},this.#r=new Map,this.#s=new Map,this.#i=0}mount(){this.#i++,this.#i===1&&(this.#a=ETt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#o=C3e.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#i--,this.#i===0&&(this.#a?.(),this.#a=void 0,this.#o?.(),this.#o=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),s=this.#e.build(this,t),r=s.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&s.isStaleByTime(rZ(t.staleTime,s))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:s})=>[t,s.data])}setQueryData(e,t,s){const r=this.defaultQueryOptions({queryKey:e}),a=this.#e.get(r.queryHash)?.state.data,o=nEt(t,a);if(o!==void 0)return this.#e.build(this,r).setData(o,{...s,manual:!0})}setQueriesData(e,t,s){return Qh.batch(()=>this.#e.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,s)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;Qh.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=this.#e;return Qh.batch(()=>{const r=s.findAll(e),a=new Set(r);return r.forEach(o=>{o.reset()}),this.refetchQueries({type:"active",predicate:i(o=>a.has(o),"predicate")},t)})}cancelQueries(e,t={}){const s={revert:!0,...t},r=Qh.batch(()=>this.#e.findAll(e).map(a=>a.cancel(s)));return Promise.all(r).then(av).catch(av)}invalidateQueries(e,t={}){return Qh.batch(()=>(this.#e.findAll(e).forEach(s=>{s.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const s={...t,cancelRefetch:t.cancelRefetch??!0},r=Qh.batch(()=>this.#e.findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,s);return s.throwOnError||(o=o.catch(av)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(r).then(av)}async query(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const s=this.#e.build(this,t),r=s.isStaleByTime(rZ(t.staleTime,s))?await s.fetch(t):s.state.data,a=t.select;return a?a(r):r}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const s=this.#e.build(this,t);return s.isStaleByTime(rZ(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(av).catch(av)}infiniteQuery(e){return e._type="infinite",this.query(e)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(av).catch(av)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return C3e.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(tie(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#r.values()],s={};return t.forEach(r=>{i3e(e,r.queryKey)&&Object.assign(s,r.defaultOptions)}),s}setMutationDefaults(e,t){this.#s.set(tie(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#s.values()],s={};return t.forEach(r=>{i3e(e,r.mutationKey)&&Object.assign(s,r.defaultOptions)}),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=MUe(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===kTt&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},m=B1(cpe(),1);function $m({queries:e,...t},s){const r=Ct(s),a=E4t(),o=B4t(),l=t.subscribed!==!1,c=m.useMemo(()=>e.map(v=>{const b=r.defaultQueryOptions(v);return b._optimisticResults=a?"isRestoring":l?"optimistic":void 0,b}),[e,r,a,l]);c.forEach(v=>{W4t(v);const b=r.getQueryCache().get(v.queryHash);H4t(v,o,b)}),p4t(o);const[d]=m.useState(()=>new TRt(r,c,t)),[u,h,p]=d.getOptimisticResult(c,t.combine),f=!a&&l;m.useSyncExternalStore(m.useCallback(v=>f?d.subscribe(Qh.batchCalls(v)):av,[d,f]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),m.useEffect(()=>{d.setQueries(c,t)},[c,t,d]);const g=u.some((v,b)=>T3e(c[b],v))?u.flatMap((v,b)=>{const y=c[b];if(y&&T3e(y,v)){const k=new wpe(r,y);return i4t(y,k,o)}return[]}):[];if(g.length>0)throw Promise.all(g);const x=u.find((v,b)=>{const y=c[b];return y&&c4t({result:v,errorResetBoundary:o,throwOnError:y.throwOnError,query:r.getQueryCache().get(y.queryHash),suspense:y.suspense})});if(x)throw x.error;return h(p())}i($m,"useQueries");function Nb(e,t){return $4t(e,ARt,t)}i(Nb,"useInfiniteQuery");var RRt="document",MRt=80,LRt={markdown:"md",html:"html",json:"json",text:"txt"};function DRt(e){return e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,MRt).replace(/-+$/g,"")||RRt}i(DRt,"documentExportSlug");function PRt(e){return LRt[(e??"").trim().toLowerCase()]??"md"}i(PRt,"documentExportExtension");function H3e(e,t){const s=t.replace(/^\.+/,"").toLowerCase()||"md";return`${DRt(e)}.${s}`}i(H3e,"documentExportFileName");function hie(e){const t=new Set([e.targetIssueId]);if(e.type==="create_issue"){e.draft.parentId&&t.add(e.draft.parentId);for(const s of e.draft.blockedByIssueIds??[])t.add(s)}if(e.type==="resolve_blocker")for(const s of e.removeBlockedByIssueIds)t.add(s);return[...t]}i(hie,"decisionEffectTargetIssueIds");var $Rt=new Set(["terminated","pending_approval","paused"]),ORt=new Set(["active","idle","running","error"]);function FRt(e){return ORt.has(e)&&!$Rt.has(e)}i(FRt,"isAgentStatusInvokable");function q4(e){return e==="done"||e==="cancelled"}i(q4,"isPipelineTerminalStageKind");function YKe(e){const t={};for(const s of e)(t[s.stageId]??=[]).push(s);return t}i(YKe,"groupWarningsByStage");function uD(e){return e.createdByUserId?{kind:"user",id:e.createdByUserId}:e.createdByAgentId?e.responsibleUserId?{kind:"user",id:e.responsibleUserId,viaAgentId:e.createdByAgentId}:{kind:"agent",id:e.createdByAgentId}:e.responsibleUserId?{kind:"user",id:e.responsibleUserId}:null}i(uD,"deriveOriginatingActor");function JKe(e){return e==="RESPONSIBLE_USER_UNAUTHORIZED"||e==="RESPONSIBLE_USER_UNAVAILABLE"}i(JKe,"isResponsibleUserDenialCode");function hD(e){const t=e?.trim();return t&&t.length>0?t:"the responsible user"}i(hD,"responsibleUserLabel");function mie(e,t={}){const s=hD(t.userName);return e==="RESPONSIBLE_USER_UNAVAILABLE"?{code:e,tone:"unavailable",title:"Responsible user unavailable",description:`This run acts on behalf of ${s}, but that account was removed or deactivated, so its permissions can no longer be evaluated. The agent's own permissions are not enough on their own — every action still requires an active responsible user.`,recommendedAction:"Mark the work blocked and reassign a responsible user (or reactivate the account) before the agent continues."}:{code:e,tone:"unauthorized",title:"Responsible user not authorized",description:`This action was denied because ${s} — the user this run acts on behalf of — does not have permission to perform it. The agent may be allowed, but a run can never exceed the permissions of the user it acts for, so the action is blocked.`,recommendedAction:`Grant ${s} the required permission, or have someone who is authorized take this action instead.`}}i(mie,"describeResponsibleUserDenial");var BRt=["issue_write_not_visible","issue_write_actor_class_excluded","issue_write_responsible_user_ceiling","issue_write_responsible_user_unavailable","issue_write_assignee_run_lock","cross_issue_influence_cap_exceeded","cross_issue_influence_run_context_required","issue_write_attribution_spoof_rejected"];function zRt(e){const t=e?.trim();return t&&t.length>0?t:"this task"}i(zRt,"issueLabel$2");function qRt(e){const t=e?.trim();return t&&t.length>0?t:"the current assignee"}i(qRt,"assigneeLabel");function URt(e){const t=e?.trim();return t&&t.length>0?t:"this agent"}i(URt,"actorLabel$1");var KRt="create a child issue with the request in its description (issue creation is a separate, open write path) and let its assignee act";function WRt(e,t={}){const s=zRt(t.issueIdentifier),r=URt(t.actorLabel),a=qRt(t.assigneeLabel),o=hD(t.responsibleUserName);switch(e){case"issue_write_not_visible":return{code:e,status:403,tone:"boundary",boundary:"Issue visibility",title:"Task is outside this actor's visibility",description:`Issue writes are open by default, but only for tasks the actor can already read. ${s} is not visible to ${r}, so its comment, update, child, and assignment channels are all closed — the wall is visibility, not the write itself.`,whoCanAct:`${a}, and any agent or board member the task is visible to.`,sanctionedPath:`Ask the board to widen visibility for ${r}, or ${KRt}.`};case"issue_write_actor_class_excluded":return{code:e,status:403,tone:"boundary",boundary:"Actor-class boundary",title:"This actor class cannot write to tasks",description:`Default-open issue writes are a standard-trust privilege. Low-trust, skill-test, and task-bridge scopes keep their existing tight walls, so ${r} cannot write to ${s} no matter who it acts for.`,whoCanAct:"A standard-trust agent in this company, or a board member.",sanctionedPath:"Report the request upward and let a standard-trust agent make the write — actor-class scope cannot be widened per task."};case"issue_write_responsible_user_ceiling":{const l=mie("RESPONSIBLE_USER_UNAUTHORIZED",{userName:t.responsibleUserName});return{code:e,status:403,tone:"boundary",boundary:"Responsible-user ceiling",title:l.title,description:`${l.description} The write to ${s} was refused for that reason.`,whoCanAct:`${o} once authorized, or anyone already permitted to write to ${s}.`,sanctionedPath:l.recommendedAction}}case"issue_write_responsible_user_unavailable":{const l=mie("RESPONSIBLE_USER_UNAVAILABLE",{userName:t.responsibleUserName});return{code:e,status:403,tone:"boundary",boundary:"Responsible-user availability",title:l.title,description:`${l.description} The write to ${s} was refused for that reason.`,whoCanAct:`A board member, or ${r} once it has an active responsible user.`,sanctionedPath:l.recommendedAction}}case"issue_write_assignee_run_lock":return{code:e,status:409,tone:"lock",boundary:"Run checkout lock",title:"Another agent's run owns this task",description:`${a} has ${s} checked out and a run is live. Checkout and run ownership stay assignee-scoped even though writes are open, so field edits belong to the run that holds the lock until it finishes.`,whoCanAct:`${a}'s live run, or an agent holding the manage-active-checkouts permission.`,sanctionedPath:`Comment instead of patching — comments stay open and wake ${a} — or wait for the run to release the lock and retry.`};case"cross_issue_influence_cap_exceeded":{const l=t.cap??20,c=t.count??null;return{code:e,status:429,tone:"cap",boundary:`Per-run cross-issue cap of ${l} writes`,title:"This run has spent its cross-issue write budget",description:`A single heartbeat run may make at most ${l} cross-issue comments or task updates combined${c!==null?`; this was attempt ${c}`:""}. The cap bounds runaway comment sprays and loops — it is a rate backstop, not a permission decision, so ${r} is still allowed to write to ${s}.`,whoCanAct:`${r} on its next heartbeat run, or ${a} on ${s} directly.`,sanctionedPath:"Consolidate what is left into one comment on your own task, or end the run and continue on the next heartbeat — the budget resets per run."}}case"cross_issue_influence_run_context_required":return{code:e,status:403,tone:"boundary",boundary:"Heartbeat run context",title:"Cross-issue writes need a run to attribute them to",description:"Every agent comment and task update is attributed to a heartbeat run so the cross-issue cap can be counted and the audit trail can name who acted for whom. This request arrived without a valid run, so it could not be contained.",whoCanAct:`${r}, once the request carries its own run id.`,sanctionedPath:"Send the `X-Paperclip-Run-Id` header with your current run (`$PAPERCLIP_RUN_ID`) and retry."};case"issue_write_attribution_spoof_rejected":return{code:e,status:422,tone:"attribution",boundary:"Server-derived attribution",title:"Responsible user cannot be chosen by the caller",description:"`onBehalfOfUserId` is derived from the authenticated actor, never from the request body — an agent cannot pick the human whose authority it rides. The attempt was recorded in the audit log.",whoCanAct:`${r} itself: the write is allowed, only the chosen attribution is not.`,sanctionedPath:`Remove \`onBehalfOfUserId\` from the request and retry; the server fills in ${o} from your run.`}}}i(WRt,"describeIssueWriteDenial");function ZKe(e){return(typeof e=="string"?e:e?.name??"").trim()}i(ZKe,"rawNameOf");function XKe(e){const t=e.toLowerCase();return!!(t.includes("://")||t==="localhost"||t.startsWith("localhost:")||/^\d{1,3}(\.\d{1,3}){3}(:\d+)?$/.test(t)||/^[a-z0-9.-]+:\d+$/.test(t))}i(XKe,"looksLikeNetworkAddress");function pie(e){return e.split(/[\s._-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}i(pie,"titleCaseIdentifier");function QRt(e){const t=/^plugin:\s*(.+)$/i.exec(e);if(!t)return null;let s=t[1].trim();return s=s.slice(s.lastIndexOf(".")+1),s=s.replace(/^plugin[-_]/i,""),pie(s)||"Custom app"}i(QRt,"pluginPackageLabel");function xk(e,t={}){const s=t.title?.trim();if(s)return s;const r=ZKe(e);if(!r||XKe(r))return"Custom app";const a=QRt(r);if(a)return a;if(r.includes(":")&&!r.includes("://")){const o=r.slice(r.lastIndexOf(":")+1).trim();if(o)return pie(o)}return/\s/.test(r)||/[A-Z]/.test(r)?r:/[._-]/.test(r)?pie(r):r}i(xk,"humanizeConnectionDisplayName");function G3e(e){const t=ZKe(e);return t&&XKe(t)?`hosted at ${t}`:null}i(G3e,"connectionDisplaySecondaryHint");var Y3e=`I want to connect an MCP (Model Context Protocol) server to Paperclip, and I need a paste-ready config.
3
3
 
4
4
  Target server: <name the server, or ask me if I have not said>
@@ -169,7 +169,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
169
169
  `))};if((br.mac||br.android)&&h.from==o-1&&/^\. ?$/.test(s.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(h={from:l,to:c,insert:Po.of([s.text.replace("."," ")])}),this.pendingContextChange=h,!e.state.readOnly){let p=this.to-this.from+(h.to-h.from+h.insert.length);Lve(e,h,Qn.single(this.toEditorPos(s.selectionStart,p),this.toEditorPos(s.selectionEnd,p)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),h.from<h.to&&!h.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,s.updateRangeStart-1),Math.min(t.text.length,s.updateRangeStart+1)))&&this.handlers.compositionend(s)},this.handlers.characterboundsupdate=s=>{let r=[],a=null;for(let o=this.toEditorPos(s.rangeStart),l=this.toEditorPos(s.rangeEnd);o<l;o++){let c=e.coordsForChar(o);a=c&&new DOMRect(c.left,c.top,c.right-c.left,c.bottom-c.top)||a||new DOMRect,r.push(a)}t.updateCharacterBounds(s.rangeStart,r)},this.handlers.textformatupdate=s=>{let r=[];for(let a of s.getTextFormats()){let o=a.underlineStyle,l=a.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let c=this.toEditorPos(a.rangeStart),d=this.toEditorPos(a.rangeEnd);if(c<d){let u=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(l)?1:2}px`;r.push(Ui.mark({attributes:{style:u}}).range(c,d))}}}e.dispatch({effects:hct.of(Ui.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:s}=this.composing;this.composing=null,s&&this.reset(e.state)}};for(let s in this.handlers)t.addEventListener(s,this.handlers[s]);this.measureReq={read:i(s=>{let r=CL(s.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())},"read")}}applyEdits(e){let t=0,s=!1,r=this.pendingContextChange;return e.changes.iterChanges((a,o,l,c,d)=>{if(s)return;let u=d.length-(o-a);if(r&&o>=r.to)if(r.from==a&&r.to==o&&r.insert.eq(d)){r=this.pendingContextChange=null,t+=u,this.to+=u;return}else r=null,this.revertPending(e.state);if(a+=t,o+=t,o<=this.from)this.from+=u,this.to+=u;else if(a<this.to){if(a<this.from||o>this.to||this.to-this.from+d.length>3e4){s=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(o),d.toString()),this.to+=u}t+=u}),r&&!s&&this.revertPending(e.state),!s}update(e){let t=this.pendingContextChange,s=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(s.from,s.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,s=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=s||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(s,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let s=this.composing;return s&&s.drifted?s.editorBase+(e-s.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},Br=class LB{static{i(this,"EditorView")}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var s;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:r}=t;this.dispatchTransactions=t.dispatchTransactions||r&&(a=>a.forEach(o=>r(o,this)))||(a=>this.update(a)),this.dispatch=this.dispatch.bind(this),this._root=t.root||bln(t.parent)||document,this.viewState=new gTe(this,t.state||Dc.create(t)),t.scrollTo&&t.scrollTo.is(V9)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(u5).map(a=>new EX(a));for(let a of this.plugins)a.update(this);this.observer=new Wcn(this),this.inputState=new ucn(this),this.inputState.ensureHandlers(this.plugins),this.docView=new sTe(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((s=document.fonts)===null||s===void 0)&&s.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...t){let s=t.length==1&&t[0]instanceof Sp?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(s,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let s=!1,r=!1,a,o=this.state;for(let f of t){if(f.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=f.state}if(this.destroyed){this.viewState.state=o;return}let l=this.hasFocus,c=0,d=null;t.some(f=>f.annotation(Lct))?(this.inputState.notifiedFocused=l,c=1):l!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=l,d=Dct(o,l),d||(c=1));let u=this.observer.delayedAndroidKey,h=null;if(u?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(h=null)):this.observer.clear(),o.facet(Dc.phrases)!=this.state.facet(Dc.phrases))return this.setState(o);a=eTe.create(this,o,t),a.flags|=c;let p=this.viewState.scrollTarget;try{this.updateState=2;for(let f of t){if(p&&(p=p.map(f.changes)),f.scrollIntoView){let{main:g}=f.state.selection,{x,y:v}=this.state.facet(LB.cursorScrollMargin);p=new TX(g.empty?g:Qn.cursor(g.head,g.head>g.anchor?-1:1),"nearest","nearest",v,x)}for(let g of f.effects)g.is(V9)&&(p=g.value.clip(this.state))}this.viewState.update(a,p),this.bidiCache=wTe.update(this.bidiCache,a.changes),a.empty||(this.updatePlugins(a),this.inputState.update(a)),s=this.docView.update(a),this.state.facet(mR)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(s,t.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(a.startState.facet(X9)!=a.state.facet(X9)&&(this.viewState.mustMeasureContent=!0),(s||r||p||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),s&&this.docViewUpdate(),!a.empty)for(let f of this.state.facet(xle))try{f(a)}catch(g){gp(this.state,g,"update listener")}(d||h)&&Promise.resolve().then(()=>{d&&this.state==d.startState&&this.dispatch(d),h&&!_ct(this,h)&&u.force&&tA(this.contentDOM,u.key,u.keyCode)})}setState(t){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let s=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new gTe(this,t),this.plugins=t.facet(u5).map(r=>new EX(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new sTe(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}s&&this.focus(),this.requestMeasure()}updatePlugins(t){let s=t.startState.facet(u5),r=t.state.facet(u5);if(s!=r){let a=[];for(let o of r){let l=s.indexOf(o);if(l<0)a.push(new EX(o));else{let c=this.plugins[l];c.mustUpdate=t,a.push(c)}}for(let o of this.plugins)o.mustUpdate!=t&&o.destroy(this);this.plugins=a,this.pluginMap.clear()}else for(let a of this.plugins)a.mustUpdate=t;for(let a=0;a<this.plugins.length;a++)this.plugins[a].update(this);s!=r&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let s=t.value;if(s&&s.docViewUpdate)try{s.docViewUpdate(this)}catch(r){gp(this.state,r,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let s=null,r=this.viewState.scrollParent,a=this.viewState.getScrollOffset(),{scrollAnchorPos:o,scrollAnchorHeight:l,scaleY:c}=this.viewState;Math.abs(a-this.viewState.scrollOffset)>1&&(l=-1),this.viewState.scrollAnchorHeight=-1;try{for(let d=0;;d++){if(l<0){if(Glt(r||this.win))o=-1,l=this.viewState.heightMap.height/this.viewState.scaleY;else{let x=this.viewState.scrollAnchorAt(a);o=x.from,l=x.top}c=this.viewState.scaleY}this.updateState=1;let u=this.viewState.measure();if(!u&&!this.measureRequests.length&&this.viewState.scrollTarget==null||d>5)break;let h=[];u&4||([this.measureRequests,h]=[h,this.measureRequests]);let p=h.map(x=>{try{return x.read(this)}catch(v){return gp(this.state,v),kTe}}),f=eTe.create(this,this.state,[]),g=!1;f.flags|=u,s?s.flags|=u:s=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),g=this.docView.update(f),g&&this.docViewUpdate());for(let x=0;x<h.length;x++)if(p[x]!=kTe)try{let v=h[x];v.write&&v.write(p[x],this)}catch(v){gp(this.state,v)}if(g&&this.docView.updateSelection(!0),!f.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,l=-1;continue}else{let x=(o<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(o).top)/this.viewState.scaleY-l/c;if((x>1||x<-1)&&!(br.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){a=a+x,r?o<0?r.scrollTop=r.scrollHeight:r.scrollTop+=x:this.win.scrollBy(0,x),l=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(s&&!s.empty)for(let d of this.state.facet(xle))d(s)}get themeClasses(){return _le+" "+(this.state.facet(Sle)?qct:zct)+" "+this.state.facet(X9)}updateAttrs(){let t=jTe(this,mct,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),s={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Ry)?"true":"false",class:"cm-content",style:`${br.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(s["aria-readonly"]="true"),jTe(this,Eve,s);let r=this.observer.ignore(()=>{let a=GIe(this.contentDOM,this.contentAttrs,s),o=GIe(this.dom,this.editorAttrs,t);return a||o});return this.editorAttrs=t,this.contentAttrs=s,r}showAnnouncements(t){let s=!0;for(let r of t)for(let a of r.effects)if(a.is(LB.announce)){s&&(this.announceDOM.textContent=""),s=!1;let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=a.value}}mountStyles(){this.styleModules=this.state.facet(mR);let t=this.state.facet(LB.cspNonce);C1.mount(this.root,this.styleModules.concat(Ucn).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){for(let s=0;s<this.measureRequests.length;s++)if(this.measureRequests[s].key===t.key){this.measureRequests[s]=t;return}}this.measureRequests.push(t)}}plugin(t){let s=this.pluginMap.get(t);return(s===void 0||s&&s.plugin!=t)&&this.pluginMap.set(t,s=this.plugins.find(r=>r.plugin==t)||null),s&&s.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,s,r){return DX(this,t,rTe(this,t,s,r))}moveByGroup(t,s){return DX(this,t,rTe(this,t,s,r=>tcn(this,t.head,r)))}visualLineSide(t,s){let r=this.bidiSpans(t),a=this.textDirectionAt(t.from),o=r[s?r.length-1:0];return Qn.cursor(o.side(s,a)+t.from,o.forward(!s,a)?1:-1)}moveToLineBoundary(t,s,r=!0){return ecn(this,t,s,r)}moveVertically(t,s,r){return DX(this,t,ncn(this,t,s,r))}domAtPos(t,s=1){return this.docView.domAtPos(t,s)}posAtDOM(t,s=0){return this.docView.posFromDOM(t,s)}posAtCoords(t,s=!0){this.readMeasured();let r=jle(this,t,s);return r&&r.pos}posAndSideAtCoords(t,s=!0){return this.readMeasured(),jle(this,t,s)}coordsAtPos(t,s=1){this.readMeasured();let r=this.state.doc.lineAt(t),a=this.bidiSpans(r),o=a[Rv.find(a,t-r.from,-1,s)];return this.docView.coordsAt(t,s,o.dir==ql.RTL)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(cct)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>Hcn)return tct(t.length);let s=this.textDirectionAt(t.from),r;for(let o of this.bidiCache)if(o.from==t.from&&o.dir==s&&(o.fresh||ect(o.isolates,r=XIe(this,t))))return o.order;r||(r=XIe(this,t));let a=_ln(t.text,s,r);return this.bidiCache.push(new wTe(t.from,t.to,s,r,!0,a)),a}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||br.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Hlt(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,s={}){var r,a,o,l;return V9.of(new TX(typeof t=="number"?Qn.cursor(t):t,(r=s.y)!==null&&r!==void 0?r:"nearest",(a=s.x)!==null&&a!==void 0?a:"nearest",(o=s.yMargin)!==null&&o!==void 0?o:5,(l=s.xMargin)!==null&&l!==void 0?l:5))}scrollSnapshot(){let{scrollTop:t,scrollLeft:s}=this.scrollDOM,r=this.viewState.scrollAnchorAt(t);return V9.of(new TX(Qn.cursor(r.from),"start","start",r.top-t,s,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return rh.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return rh.define(()=>({}),{eventObservers:t})}static theme(t,s){let r=C1.newName(),a=[X9.of(r),mR.of(Ale(`.${r}`,t))];return s&&s.dark&&a.push(Sle.of(!0)),a}static baseTheme(t){return YS.lowest(mR.of(Ale("."+_le,t,Uct)))}static findFromDOM(t){var s;let r=t.querySelector(".cm-content"),a=r&&td.get(r)||td.get(t);return((s=a?.root)===null||s===void 0?void 0:s.view)||null}};Br.styleModule=mR;Br.inputHandler=oct;Br.clipboardInputFilter=Ive;Br.clipboardOutputFilter=Tve;Br.scrollHandler=uct;Br.focusChangeEffect=lct;Br.perLineTextDirection=cct;Br.exceptionSink=act;Br.updateListener=xle;Br.editable=Ry;Br.mouseSelectionStyle=ict;Br.dragMovesSelection=rct;Br.clickAddsSelectionRange=sct;Br.decorations=EH;Br.blockWrappers=pct;Br.outerDecorations=Rve;Br.atomicRanges=j7;Br.bidiIsolatedRanges=fct;Br.cursorScrollMargin=Rr.define({combine:i(e=>{let t=5,s=5;for(let r of e)typeof r=="number"?t=s=r:{x:t,y:s}=r;return{x:t,y:s}},"combine")});Br.scrollMargins=gct;Br.darkTheme=Sle;Br.cspNonce=Rr.define({combine:i(e=>e.length?e[0]:"","combine")});Br.contentAttributes=Eve;Br.editorAttributes=mct;Br.lineWrapping=Br.contentAttributes.of({class:"cm-lineWrapping"});Br.announce=pa.define();var Hcn=4096,kTe={},wTe=class Kct{static{i(this,"CachedOrder")}constructor(t,s,r,a,o,l){this.from=t,this.to=s,this.dir=r,this.isolates=a,this.fresh=o,this.order=l}static update(t,s){if(s.empty&&!t.some(o=>o.fresh))return t;let r=[],a=t.length?t[t.length-1].dir:ql.LTR;for(let o=Math.max(0,t.length-10);o<t.length;o++){let l=t[o];l.dir==a&&!s.touchesRange(l.from,l.to)&&r.push(new Kct(s.mapPos(l.from,1),s.mapPos(l.to,-1),l.dir,l.isolates,!1,l.order))}return r}};function jTe(e,t,s){for(let r=e.state.facet(t),a=r.length-1;a>=0;a--){let o=r[a],l=typeof o=="function"?o(e):o;l&&Nve(l,s)}return s}i(jTe,"attrsFromFacet");var Gcn=br.mac?"mac":br.windows?"win":br.linux?"linux":"key";function Ycn(e,t){const s=e.split(/-(?!$)/);let r=s[s.length-1];r=="Space"&&(r=" ");let a,o,l,c;for(let d=0;d<s.length-1;++d){const u=s[d];if(/^(cmd|meta|m)$/i.test(u))c=!0;else if(/^a(lt)?$/i.test(u))a=!0;else if(/^(c|ctrl|control)$/i.test(u))o=!0;else if(/^s(hift)?$/i.test(u))l=!0;else if(/^mod$/i.test(u))t=="mac"?c=!0:o=!0;else throw new Error("Unrecognized modifier name: "+u)}return a&&(r="Alt-"+r),o&&(r="Ctrl-"+r),c&&(r="Meta-"+r),l&&(r="Shift-"+r),r}i(Ycn,"normalizeKeyName");function e$(e,t,s){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),s!==!1&&t.shiftKey&&(e="Shift-"+e),e}i(e$,"modifiers");var Jcn=YS.default(Br.domEventHandlers({keydown(e,t){return Qct(Wct(t.state),e,t,"editor")}})),DH=Rr.define({enables:Jcn}),NTe=new WeakMap;function Wct(e){let t=e.facet(DH),s=NTe.get(t);return s||NTe.set(t,s=edn(t.reduce((r,a)=>r.concat(a),[]))),s}i(Wct,"getKeymap");function Zcn(e,t,s){return Qct(Wct(e.state),t,e,s)}i(Zcn,"runScopeHandlers");var ij=null,Xcn=4e3;function edn(e,t=Gcn){let s=Object.create(null),r=Object.create(null),a=i((l,c)=>{let d=r[l];if(d==null)r[l]=c;else if(d!=c)throw new Error("Key binding "+l+" is used both as a regular binding and as a multi-stroke prefix")},"checkPrefix"),o=i((l,c,d,u,h)=>{var p,f;let g=s[l]||(s[l]=Object.create(null)),x=c.split(/ (?!$)/).map(y=>Ycn(y,t));for(let y=1;y<x.length;y++){let k=x.slice(0,y).join(" ");a(k,!0),g[k]||(g[k]={preventDefault:!0,stopPropagation:!1,run:[j=>{let N=ij={view:j,prefix:k,scope:l};return setTimeout(()=>{ij==N&&(ij=null)},Xcn),!0}]})}let v=x.join(" ");a(v,!1);let b=g[v]||(g[v]={preventDefault:!1,stopPropagation:!1,run:((f=(p=g._any)===null||p===void 0?void 0:p.run)===null||f===void 0?void 0:f.slice())||[]});d&&b.run.push(d),u&&(b.preventDefault=!0),h&&(b.stopPropagation=!0)},"add");for(let l of e){let c=l.scope?l.scope.split(" "):["editor"];if(l.any)for(let u of c){let h=s[u]||(s[u]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:p}=l;for(let f in h)h[f].run.push(g=>p(g,Ile))}let d=l[t]||l.key;if(d)for(let u of c)o(u,d,l.run,l.preventDefault,l.stopPropagation),l.shift&&o(u,"Shift-"+d,l.shift,l.preventDefault,l.stopPropagation)}return s}i(edn,"buildKeymap");var Ile=null;function Qct(e,t,s,r){Ile=t;let a=hln(t),o=lp(a,0),l=kv(o)==a.length&&a!=" ",c="",d=!1,u=!1,h=!1;ij&&ij.view==s&&ij.scope==r&&(c=ij.prefix+" ",Tct.indexOf(t.keyCode)<0&&(u=!0,ij=null));let p=new Set,f=i(b=>{if(b){for(let y of b.run)if(!p.has(y)&&(p.add(y),y(s)))return b.stopPropagation&&(h=!0),!0;b.preventDefault&&(b.stopPropagation&&(h=!0),u=!0)}return!1},"runFor"),g=e[r],x,v;return g&&(f(g[c+e$(a,t,!l)])?d=!0:l&&(t.altKey||t.metaKey||t.ctrlKey)&&!(br.windows&&t.ctrlKey&&t.altKey)&&!(br.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(x=S1[t.keyCode])&&x!=a?(f(g[c+e$(x,t,!0)])||t.shiftKey&&(v=jL[t.keyCode])!=a&&v!=x&&f(g[c+e$(v,t,!1)]))&&(d=!0):l&&t.shiftKey&&f(g[c+e$(a,t,!0)])&&(d=!0),!d&&f(g._any)&&(d=!0)),u&&(d=!0),d&&h&&t.stopPropagation(),Ile=null,d}i(Qct,"runHandlers");var T6=class Vct{static{i(this,"RectangleMarker")}constructor(t,s,r,a,o){this.className=t,this.left=s,this.top=r,this.width=a,this.height=o}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,s){return s.className!=this.className?!1:(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",this.width!=null&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,s,r){if(r.empty){let a=t.coordsAtPos(r.head,r.assoc||1);if(!a)return[];let o=Hct(t);return[new Vct(s,a.left-o.left,a.top-o.top,null,a.bottom-a.top)]}else return tdn(t,s,r)}};function Hct(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==ql.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}i(Hct,"getBase");function CTe(e,t,s,r){let a=e.coordsAtPos(t,s*2);if(!a)return r;let o=e.dom.getBoundingClientRect(),l=(a.top+a.bottom)/2,c=e.posAtCoords({x:o.left+1,y:l}),d=e.posAtCoords({x:o.right-1,y:l});return c==null||d==null?r:{from:Math.max(r.from,Math.min(c,d)),to:Math.min(r.to,Math.max(c,d))}}i(CTe,"wrappedLine");function tdn(e,t,s){if(s.to<=e.viewport.from||s.from>=e.viewport.to)return[];let r=Math.max(s.from,e.viewport.from),a=Math.min(s.to,e.viewport.to),o=e.textDirection==ql.LTR,l=e.contentDOM,c=l.getBoundingClientRect(),d=Hct(e),u=l.querySelector(".cm-line"),h=u&&window.getComputedStyle(u),p=c.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),f=c.right-(h?parseInt(h.paddingRight):0),g=wle(e,r,1),x=wle(e,a,-1),v=g.type==Th.Text?g:null,b=x.type==Th.Text?x:null;if(v&&(e.lineWrapping||g.widgetLineBreaks)&&(v=CTe(e,r,1,v)),b&&(e.lineWrapping||x.widgetLineBreaks)&&(b=CTe(e,a,-1,b)),v&&b&&v.from==b.from&&v.to==b.to)return k(j(s.from,s.to,v));{let S=v?j(s.from,null,v):N(g,!1),A=b?j(null,s.to,b):N(x,!0),I=[];return(v||g).to<(b||x).from-(v&&b?1:0)||g.widgetLineBreaks>1&&S.bottom+e.defaultLineHeight/2<A.top?I.push(y(p,S.bottom,f,A.top)):S.bottom<A.top&&e.elementAtHeight((S.bottom+A.top)/2).type==Th.Text&&(S.bottom=A.top=(S.bottom+A.top)/2),k(S).concat(I).concat(k(A))}function y(S,A,I,_){return new T6(t,S-d.left,A-d.top,Math.max(0,I-S),_-A)}i(y,"piece");function k({top:S,bottom:A,horizontal:I}){let _=[];for(let T=0;T<I.length;T+=2)_.push(y(I[T],S,I[T+1],A));return _}i(k,"pieces");function j(S,A,I){let _=1e9,T=-1e9,E=[];function M(K,L,B,z,U){let W=e.coordsAtPos(K,K==I.to?-2:2),F=e.coordsAtPos(B,B==I.from?2:-2);!W||!F||(_=Math.min(W.top,F.top,_),T=Math.max(W.bottom,F.bottom,T),U==ql.LTR?E.push(o&&L?p:W.left,o&&z?f:F.right):E.push(!o&&z?p:F.left,!o&&L?f:W.right))}i(M,"addSpan");let P=S??I.from,D=A??I.to;for(let K of e.visibleRanges)if(K.to>P&&K.from<D)for(let L=Math.max(K.from,P),B=Math.min(K.to,D);;){let z=e.state.doc.lineAt(L);for(let U of e.bidiSpans(z)){let W=U.from+z.from,F=U.to+z.from;if(W>=B)break;F>L&&M(Math.max(W,L),S==null&&W<=P,Math.min(F,B),A==null&&F>=D,U.dir)}if(L=z.to+1,L>=B)break}return E.length==0&&M(P,S==null,D,A==null,e.textDirection),{top:_,bottom:T,horizontal:E}}i(j,"drawForLine");function N(S,A){let I=c.top+(A?S.top:S.bottom);return{top:I,bottom:I,horizontal:[]}}i(N,"drawForWidget")}i(tdn,"rectanglesForRange");function ndn(e,t){return e.constructor==t.constructor&&e.eq(t)}i(ndn,"sameMarker");var sdn=class{static{i(this,"LayerView")}constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(DB)!=e.state.facet(DB)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,s=e.facet(DB);for(;t<s.length&&s[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,s)=>!ndn(t,this.drawn[s]))){let t=this.dom.firstChild,s=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[s].constructor&&r.update(t,this.drawn[s])?(t=t.nextSibling,s++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e,br.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},DB=Rr.define();function Gct(e){return[rh.define(t=>new sdn(t,e)),DB.of(e)]}i(Gct,"layer");var uI=Rr.define({combine(e){return Rb(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:i((t,s)=>Math.min(t,s),"cursorBlinkRate"),drawRangeCursor:i((t,s)=>t||s,"drawRangeCursor")})}});function rdn(e={}){return[uI.of(e),idn,adn,ldn,dct.of(!0)]}i(rdn,"drawSelection");function Yct(e){return e.startState.facet(uI)!=e.state.facet(uI)}i(Yct,"configChanged");var idn=Gct({above:!0,markers(e){let{state:t}=e,s=t.facet(uI),r=[];for(let a of t.selection.ranges){let o=a==t.selection.main;if(a.empty||s.drawRangeCursor&&!(o&&br.ios&&s.iosSelectionHandles)){let l=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",c=a.empty?a:Qn.cursor(a.head,a.assoc);for(let d of T6.forRange(e,l,c))r.push(d)}}return r},update(e,t){e.transactions.some(r=>r.selection)&&(t.style.animationName=t.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let s=Yct(e);return s&&STe(e.state,t),e.docChanged||e.selectionSet||s},mount(e,t){STe(t.state,e)},class:"cm-cursorLayer"});function STe(e,t){t.style.animationDuration=e.facet(uI).cursorBlinkRate+"ms"}i(STe,"setBlinkRate");var adn=Gct({above:!1,markers(e){let t=[],{main:s,ranges:r}=e.state.selection;for(let a of r)if(!a.empty)for(let o of T6.forRange(e,"cm-selectionBackground",a))t.push(o);if(br.ios&&!s.empty&&e.state.facet(uI).iosSelectionHandles){for(let a of T6.forRange(e,"cm-selectionHandle cm-selectionHandle-start",Qn.cursor(s.from,1)))t.push(a);for(let a of T6.forRange(e,"cm-selectionHandle cm-selectionHandle-end",Qn.cursor(s.to,1)))t.push(a)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||Yct(e)},class:"cm-selectionLayer"}),odn=br.gecko&&br.gecko_version==153?"#ffffff01":"transparent",ldn=YS.highest(Br.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${odn} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Jct=pa.define({map(e,t){return e==null?null:t.mapPos(e)}}),gR=zp.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((s,r)=>r.is(Jct)?r.value:s,e)}}),cdn=rh.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let s=e.state.field(gR);s==null?this.cursor!=null&&((t=this.cursor)===null||t===void 0||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(gR)!=s||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(gR),s=t!=null&&e.coordsAtPos(t);if(!s)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:s.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:s.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:s.bottom-s.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:s}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/s+"px",this.cursor.style.height=e.height/s+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(gR)!=e&&this.view.dispatch({effects:Jct.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){(e.target==this.view.contentDOM||!this.view.contentDOM.contains(e.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function ddn(){return[gR,cdn]}i(ddn,"dropCursor");function _Te(e,t,s,r,a){t.lastIndex=0;for(let o=e.iterRange(s,r),l=s,c;!o.next().done;l+=o.value.length)if(!o.lineBreak)for(;c=t.exec(o.value);)a(l+c.index,c)}i(_Te,"iterMatches");function udn(e,t){let s=e.visibleRanges;if(s.length==1&&s[0].from==e.viewport.from&&s[0].to==e.viewport.to)return s;let r=[];for(let{from:a,to:o}of s)a=Math.max(e.state.doc.lineAt(a).from,a-t),o=Math.min(e.state.doc.lineAt(o).to,o+t),r.length&&r[r.length-1].to>=a?r[r.length-1].to=o:r.push({from:a,to:o});return r}i(udn,"matchRanges");var hdn=class{static{i(this,"MatchDecorator")}constructor(e){const{regexp:t,decoration:s,decorate:r,boundary:a,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,r)this.addMatch=(l,c,d,u)=>r(u,d,d+l[0].length,l,c);else if(typeof s=="function")this.addMatch=(l,c,d,u)=>{let h=s(l,c,d);h&&u(d,d+l[0].length,h)};else if(s)this.addMatch=(l,c,d,u)=>u(d,d+l[0].length,s);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=a,this.maxLength=o}createDeco(e){let t=new Bj,s=t.add.bind(t);for(let{from:r,to:a}of udn(e,this.maxLength))_Te(e.state.doc,this.regexp,r,a,(o,l)=>this.addMatch(l,e,o,s));return t.finish()}updateDeco(e,t){let s=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((a,o,l,c)=>{c>=e.view.viewport.from&&l<=e.view.viewport.to&&(s=Math.min(l,s),r=Math.max(c,r))}),e.viewportMoved||r-s>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),s,r):t}updateRange(e,t,s,r){for(let a of e.visibleRanges){let o=Math.max(a.from,s),l=Math.min(a.to,r);if(l>=o){let c=e.state.doc.lineAt(o),d=c.to<l?e.state.doc.lineAt(l):c,u=Math.max(a.from,c.from),h=Math.min(a.to,d.to);if(this.boundary){for(;o>c.from;o--)if(this.boundary.test(c.text[o-1-c.from])){u=o;break}for(;l<d.to;l++)if(this.boundary.test(d.text[l-d.from])){h=l;break}}let p=[],f,g=i((x,v,b)=>p.push(b.range(x,v)),"add");if(c==d)for(this.regexp.lastIndex=u-c.from;(f=this.regexp.exec(c.text))&&f.index<h-c.from;)this.addMatch(f,e,f.index+c.from,g);else _Te(e.state.doc,this.regexp,u,h,(x,v)=>this.addMatch(v,e,x,g));t=t.update({filterFrom:u,filterTo:h,filter:i((x,v)=>x<u||v>h,"filter"),add:p})}}return t}},Tle=/x/.unicode!=null?"gu":"g",mdn=new RegExp(`[\0-\b
170
170
  --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,Tle),pdn={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},OX=null;function fdn(){var e;if(OX==null&&typeof document<"u"&&document.body){let t=document.body.style;OX=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return OX||!1}i(fdn,"supportsTabSize");var PB=Rr.define({combine(e){let t=Rb(e,{render:null,specialChars:mdn,addSpecialChars:null});return(t.replaceTabs=!fdn())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,Tle)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,Tle)),t}});function gdn(e={}){return[PB.of(e),xdn()]}i(gdn,"highlightSpecialChars");var ATe=null;function xdn(){return ATe||(ATe=rh.fromClass(class{constructor(e){this.view=e,this.decorations=Ui.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(PB)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new hdn({regexp:e.specialChars,decoration:i((t,s,r)=>{let{doc:a}=s.state,o=lp(t[0],0);if(o==9){let l=a.lineAt(r),c=s.state.tabSize,d=JS(l.text,c,r-l.from);return Ui.replace({widget:new kdn((c-d%c)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=Ui.replace({widget:new ydn(e,o)}))},"decoration"),boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(PB);e.startState.facet(PB)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:i(e=>e.decorations,"decorations")}))}i(xdn,"specialCharPlugin");var vdn="•";function bdn(e){return e>=32?vdn:e==10?"␤":String.fromCharCode(9216+e)}i(bdn,"placeholder$1");var ydn=class extends aw{static{i(this,"SpecialCharWidget")}constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=bdn(this.code),s=e.state.phrase("Control character")+" "+(pdn[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,s,t);if(r)return r;let a=document.createElement("span");return a.textContent=t,a.title=s,a.setAttribute("aria-label",s),a.className="cm-specialChar",a}ignoreEvent(){return!1}},kdn=class extends aw{static{i(this,"TabWidget")}constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}};function wdn(){return Ndn}i(wdn,"highlightActiveLine");var jdn=Ui.line({class:"cm-activeLine"}),Ndn=rh.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,s=[];for(let r of e.state.selection.ranges){let a=e.lineBlockAt(r.head);a.from>t&&(s.push(jdn.range(a.from)),t=a.from)}return Ui.set(s)}},{decorations:i(e=>e.decorations,"decorations")}),Ele=2e3;function Cdn(e,t,s){let r=Math.min(t.line,s.line),a=Math.max(t.line,s.line),o=[];if(t.off>Ele||s.off>Ele||t.col<0||s.col<0){let l=Math.min(t.off,s.off),c=Math.max(t.off,s.off);for(let d=r;d<=a;d++){let u=e.doc.line(d);u.length<=c&&o.push(Qn.range(u.from+l,u.to+c))}}else{let l=Math.min(t.col,s.col),c=Math.max(t.col,s.col);for(let d=r;d<=a;d++){let u=e.doc.line(d),h=ile(u.text,l,e.tabSize,!0);if(h<0)o.push(Qn.cursor(u.to));else{let p=ile(u.text,c,e.tabSize);o.push(Qn.range(u.from+h,u.from+p))}}}return o}i(Cdn,"rectangleFor");function Sdn(e,t){let s=e.coordsAtPos(e.viewport.from);return s?Math.round(Math.abs((s.left-t)/e.defaultCharacterWidth)):-1}i(Sdn,"absoluteColumn");function ITe(e,t){let s=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(s),a=s-r.from,o=a>Ele?-1:a==r.length?Sdn(e,t.clientX):JS(r.text,e.state.tabSize,s-r.from);return{line:r.number,col:o,off:a}}i(ITe,"getPos");function _dn(e,t){let s=ITe(e,t),r=e.state.selection;return s?{update(a){if(a.docChanged){let o=a.changes.mapPos(a.startState.doc.line(s.line).from),l=a.state.doc.lineAt(o);s={line:l.number,col:s.col,off:Math.min(s.off,l.length)},r=r.map(a.changes)}},get(a,o,l){let c=ITe(e,a);if(!c)return r;let d=Cdn(e.state,s,c);return d.length?l?Qn.create(d.concat(r.ranges)):Qn.create(d):r}}:null}i(_dn,"rectangleSelectionStyle");function Adn(e){let t=e?.eventFilter||(s=>s.altKey&&s.button==0);return Br.mouseSelectionStyle.of((s,r)=>t(r)?_dn(s,r):null)}i(Adn,"rectangularSelection");var Idn={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},Tdn={style:"cursor: crosshair"};function Edn(e={}){let[t,s]=Idn[e.key||"Alt"],r=rh.fromClass(class{constructor(a){this.view=a,this.isDown=!1}set(a){this.isDown!=a&&(this.isDown=a,this.view.update([]))}},{eventObservers:{keydown(a){this.set(a.keyCode==t||s(a))},keyup(a){(a.keyCode==t||!s(a))&&this.set(!1)},mousemove(a){this.set(s(a))}}});return[r,Br.contentAttributes.of(a=>{var o;return!((o=a.plugin(r))===null||o===void 0)&&o.isDown?Tdn:null})]}i(Edn,"crosshairCursor");var t$="-10000px",Zct=class{static{i(this,"TooltipViewManager")}constructor(e,t,s,r){this.facet=t,this.createTooltipView=s,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let a=null;this.tooltipViews=this.tooltips.map(o=>a=s(o,a))}update(e,t){var s;let r=e.state.facet(this.facet),a=r.filter(c=>c);if(r===this.input){for(let c of this.tooltipViews)c.update&&c.update(e);return!1}let o=[],l=t?[]:null;for(let c=0;c<a.length;c++){let d=a[c],u=-1;if(d){for(let h=0;h<this.tooltips.length;h++){let p=this.tooltips[h];p&&p.create==d.create&&(u=h)}if(u<0)o[c]=this.createTooltipView(d,c?o[c-1]:null),l&&(l[c]=!!d.above);else{let h=o[c]=this.tooltipViews[u];l&&(l[c]=t[u]),h.update&&h.update(e)}}}for(let c of this.tooltipViews)o.indexOf(c)<0&&(this.removeTooltipView(c),(s=c.destroy)===null||s===void 0||s.call(c));return t&&(l.forEach((c,d)=>t[d]=c),t.length=l.length),this.input=r,this.tooltips=a,this.tooltipViews=o,!0}};function Rdn(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}i(Rdn,"windowSpace");var FX=Rr.define({combine:i(e=>{var t,s,r;return{position:br.ios?"absolute":((t=e.find(a=>a.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((s=e.find(a=>a.parent))===null||s===void 0?void 0:s.parent)||null,tooltipSpace:((r=e.find(a=>a.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||Rdn}},"combine")}),TTe=new WeakMap,Dve=rh.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(FX);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Zct(e,Pve,(s,r)=>this.createTooltip(s,r),s=>{this.resizeObserver&&this.resizeObserver.unobserve(s.dom),s.dom.remove()}),this.above=this.manager.tooltips.map(s=>!!s.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(s=>{Date.now()>this.lastTransaction-50&&s.length>0&&s[s.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let s=t||e.geometryChanged,r=e.state.facet(FX);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let a of this.manager.tooltipViews)a.dom.style.position=this.position;s=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let a of this.manager.tooltipViews)this.container.appendChild(a.dom);s=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);s&&this.maybeMeasure()}createTooltip(e,t){let s=e.create(this.view),r=t?t.dom:null;if(s.dom.classList.add("cm-tooltip"),e.arrow&&!s.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let a=document.createElement("div");a.className="cm-tooltip-arrow",s.dom.appendChild(a)}return s.dom.style.position=this.position,s.dom.style.top=t$,s.dom.style.left="0px",this.container.insertBefore(s.dom,r),s.mount&&s.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(s.dom),s}destroy(){var e,t,s;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(e=r.destroy)===null||e===void 0||e.call(r);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(s=this.intersectionObserver)===null||s===void 0||s.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,s=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:o}=this.manager.tooltipViews[0];if(br.safari){let l=o.getBoundingClientRect();s=Math.abs(l.top+1e4)>1||Math.abs(l.left)>1}else s=!!o.offsetParent&&o.offsetParent!=this.container.ownerDocument.body}if(s||this.position=="absolute")if(this.parent){let o=this.parent.getBoundingClientRect();o.width&&o.height&&(e=o.width/this.parent.offsetWidth,t=o.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),a=Mve(this.view);return{visible:{left:r.left+a.left,top:r.top+a.top,right:r.right-a.right,bottom:r.bottom-a.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((o,l)=>{let c=this.manager.tooltipViews[l];return c.getCoords?c.getCoords(o.pos):this.view.coordsAtPos(o.pos)}),size:this.manager.tooltipViews.map(({dom:o})=>o.getBoundingClientRect()),space:this.view.state.facet(FX).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:s}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let c of this.manager.tooltipViews)c.dom.style.position="absolute"}let{visible:s,space:r,scaleX:a,scaleY:o}=e,l=[];for(let c=0;c<this.manager.tooltips.length;c++){let d=this.manager.tooltips[c],u=this.manager.tooltipViews[c],{dom:h}=u,p=e.pos[c],f=e.size[c];if(!p||d.clip!==!1&&(p.bottom<=Math.max(s.top,r.top)||p.top>=Math.min(s.bottom,r.bottom)||p.right<Math.max(s.left,r.left)-.1||p.left>Math.min(s.right,r.right)+.1)){h.style.top=t$;continue}let g=d.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,x=g?7:0,v=f.right-f.left,b=(t=TTe.get(u))!==null&&t!==void 0?t:f.bottom-f.top,y=u.offset||Ldn,k=this.view.textDirection==ql.LTR,j=f.width>r.right-r.left?k?r.left:r.right-f.width:k?Math.max(r.left,Math.min(p.left-(g?14:0)+y.x,r.right-v)):Math.min(Math.max(r.left,p.left-v+(g?14:0)-y.x),r.right-v),N=this.above[c];!d.strictSide&&(N?p.top-b-x-y.y<r.top:p.bottom+b+x+y.y>r.bottom)&&N==r.bottom-p.bottom>p.top-r.top&&(N=this.above[c]=!N);let S=(N?p.top-r.top:r.bottom-p.bottom)-x;if(S<b&&u.resize!==!1){if(S<this.view.defaultLineHeight){h.style.top=t$;continue}TTe.set(u,b),h.style.height=(b=S)/o+"px"}else h.style.height&&(h.style.height="");let A=N?p.top-b-x-y.y:p.bottom+x+y.y,I=j+v;if(u.overlap!==!0)for(let _ of l)_.left<I&&_.right>j&&_.top<A+b&&_.bottom>A&&(A=N?_.top-b-2-x:_.bottom+x+2);if(this.position=="absolute"?(h.style.top=(A-e.parent.top)/o+"px",ETe(h,(j-e.parent.left)/a)):(h.style.top=A/o+"px",ETe(h,j/a)),g){let _=p.left+(k?y.x:-y.x)-(j+14-7);g.style.left=_/a+"px"}u.overlap!==!0&&l.push({left:j,top:A,right:I,bottom:A+b}),h.classList.toggle("cm-tooltip-above",N),h.classList.toggle("cm-tooltip-below",!N),u.positioned&&u.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=t$}},{eventObservers:{scroll(){this.maybeMeasure()}}});function ETe(e,t){let s=parseInt(e.style.left,10);(isNaN(s)||Math.abs(t-s)>1)&&(e.style.left=t+"px")}i(ETe,"setLeftStyle");var Mdn=Br.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Ldn={x:0,y:0},Pve=Rr.define({enables:[Dve,Mdn]}),XU=Rr.define({combine:i(e=>e.reduce((t,s)=>t.concat(s),[]),"combine")}),Xct=class edt{static{i(this,"HoverTooltipHost")}static create(t){return new edt(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Zct(t,XU,(s,r)=>this.createHostedView(s,r),s=>s.dom.remove())}createHostedView(t,s){let r=t.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,s?s.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(t){for(let s of this.manager.tooltipViews)s.mount&&s.mount(t);this.mounted=!0}positioned(t){for(let s of this.manager.tooltipViews)s.positioned&&s.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let s of this.manager.tooltipViews)(t=s.destroy)===null||t===void 0||t.call(s)}passProp(t){let s;for(let r of this.manager.tooltipViews){let a=r[t];if(a!==void 0){if(s===void 0)s=a;else if(s!==a)return}}return s}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},Ddn=Pve.compute([XU],e=>{let t=e.facet(XU);return t.length===0?null:{pos:Math.min(...t.map(s=>s.pos)),end:Math.max(...t.map(s=>{var r;return(r=s.end)!==null&&r!==void 0?r:s.pos})),create:Xct.create,above:t[0].above,arrow:t.some(s=>s.arrow)}}),Pdn=Rr.define(),$dn=class{static{i(this,"HoverPlugin")}constructor(e,t,s,r,a,o){this.view=e,this.source=t,this.field=s,this.locked=r,this.setHover=a,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,s=e.docView.tile.nearest(t.target);if(!s)return;let r,a=1;if(s.isWidget())r=s.posAtStart;else{if(r=e.posAtCoords(t),r==null)return;let o=e.coordsAtPos(r);if(!o||t.y<o.top||t.y>o.bottom||t.x<o.left-e.defaultCharacterWidth||t.x>o.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(r)).find(d=>d.from<=r&&d.to>=r),c=l&&l.dir==ql.RTL?-1:1;a=t.x<o.left?-c:c}this.activateHover(e,r,a)}activateHover(e,t,s,r){let a=this.source(e,t,s),o=i(l=>{if(l&&!(Array.isArray(l)&&!l.length)){let c=Array.isArray(l)?l:[l];r&&this.locked.set(c,r),e.dispatch({effects:this.setHover.of(c)})}},"done");if(a&&"then"in a){let l=this.pending={pos:t};a.then(c=>{this.pending==l&&(this.pending=null,o(c))},c=>gp(e.state,c,"hover tooltip"))}else o(a)}get tooltip(){let e=this.view.plugin(Dve),t=e?e.manager.tooltips.findIndex(s=>s.create==Xct.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,s;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:a}=this;if(r.length&&!this.locked.has(r)&&a&&!Odn(a.dom,e)||this.pending){let{pos:o}=r[0]||this.pending,l=(s=(t=r[0])===null||t===void 0?void 0:t.end)!==null&&s!==void 0?s:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!Fdn(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:s}=this;s&&s.dom.contains(e.relatedTarget)?this.watchTooltipLeave(s.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i(s=>{e.removeEventListener("mouseleave",t);let{active:r}=this;r.length&&!this.locked.has(r)&&!this.view.dom.contains(s.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})},"watch");e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},n$=4;function Odn(e,t){let{left:s,right:r,top:a,bottom:o}=e.getBoundingClientRect(),l;if(l=e.querySelector(".cm-tooltip-arrow")){let c=l.getBoundingClientRect();a=Math.min(c.top,a),o=Math.max(c.bottom,o)}return t.clientX>=s-n$&&t.clientX<=r+n$&&t.clientY>=a-n$&&t.clientY<=o+n$}i(Odn,"isInTooltip");function Fdn(e,t,s,r,a,o){let l=e.scrollDOM.getBoundingClientRect(),c=e.documentTop+e.documentPadding.top+e.contentHeight;if(l.left>r||l.right<r||l.top>a||Math.min(l.bottom,c)<a)return!1;let d=e.posAtCoords({x:r,y:a},!1);return d>=t&&d<=s}i(Fdn,"isOverRange");function Bdn(e,t={}){let s=pa.define(),r=new WeakMap,a=zp.define({create(){return[]},update(l,c){let d=r.get(l);if(l.length&&(t.hideOnChange&&(c.docChanged||c.selection)?l=[]:d&&d(c)?l=[]:t.hideOn&&(l=l.filter(u=>!t.hideOn(c,u)))),c.docChanged&&l.length){let u=[];for(let h of l){let p=c.changes.mapPos(h.pos,-1,_m.TrackDel);if(p!=null){let f=Object.assign(Object.create(null),h);f.pos=p,f.end!=null&&(f.end=c.changes.mapPos(f.end)),u.push(f)}}l=u}for(let u of c.effects)u.is(s)&&(l=u.value,d=void 0),(u.is(zdn)&&!u.value||u.value==a)&&(l=[]);return l.length&&d&&r.set(l,d),l},provide:i(l=>XU.from(l),"provide")});const o=rh.define(l=>new $dn(l,e,a,r,s,t.hoverTime||300));return{active:a,extension:[a,o,Pdn.of(o),Ddn]}}i(Bdn,"hoverTooltip");function tdt(e,t){let s=e.plugin(Dve);if(!s)return null;let r=s.manager.tooltips.indexOf(t);return r<0?null:s.manager.tooltipViews[r]}i(tdt,"getTooltip");var zdn=pa.define(),RTe=Rr.define({combine(e){let t,s;for(let r of e)t=t||r.topContainer,s=s||r.bottomContainer;return{topContainer:t,bottomContainer:s}}});function $ve(e,t){let s=e.plugin(ndt),r=s?s.specs.indexOf(t):-1;return r>-1?s.panels[r]:null}i($ve,"getPanel");var ndt=rh.fromClass(class{constructor(e){this.input=e.state.facet(AL),this.specs=this.input.filter(s=>s),this.panels=this.specs.map(s=>s(e));let t=e.state.facet(RTe);this.top=new s$(e,!0,t.topContainer),this.bottom=new s$(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(s=>s.top)),this.bottom.sync(this.panels.filter(s=>!s.top));for(let s of this.panels)s.dom.classList.add("cm-panel"),s.mount&&s.mount()}update(e){let t=e.state.facet(RTe);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new s$(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new s$(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let s=e.state.facet(AL);if(s!=this.input){let r=s.filter(d=>d),a=[],o=[],l=[],c=[];for(let d of r){let u=this.specs.indexOf(d),h;u<0?(h=d(e.view),c.push(h)):(h=this.panels[u],h.update&&h.update(e)),a.push(h),(h.top?o:l).push(h)}this.specs=r,this.panels=a,this.top.sync(o),this.bottom.sync(l);for(let d of c)d.dom.classList.add("cm-panel"),d.mount&&d.mount()}else for(let r of this.panels)r.update&&r.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:i(e=>Br.scrollMargins.of(t=>{let s=t.plugin(e);return s&&{top:s.top.scrollMargin(),bottom:s.bottom.scrollMargin()}}),"provide")}),s$=class{static{i(this,"PanelGroup")}constructor(e,t,s){this.view=e,this.top=t,this.container=s,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=MTe(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=MTe(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function MTe(e){let t=e.nextSibling;return e.remove(),t}i(MTe,"rm");var AL=Rr.define({enables:ndt});function qdn(e,t){let s,r=new Promise(l=>s=l),a=i(l=>Udn(l,t,s),"panelCtor");e.state.field(BX,!1)?e.dispatch({effects:sdt.of(a)}):e.dispatch({effects:pa.appendConfig.of(BX.init(()=>[a]))});let o=rdt.of(a);return{close:o,result:r.then(l=>((e.win.queueMicrotask||(c=>e.win.setTimeout(c,10)))(()=>{e.state.field(BX).indexOf(a)>-1&&e.dispatch({effects:o})}),l))}}i(qdn,"showDialog");var BX=zp.define({create(){return[]},update(e,t){for(let s of t.effects)s.is(sdt)?e=[s.value].concat(e):s.is(rdt)&&(e=e.filter(r=>r!=s.value));return e},provide:i(e=>AL.computeN([e],t=>t.field(e)),"provide")}),sdt=pa.define(),rdt=pa.define();function Udn(e,t,s){let r=t.content?t.content(e,()=>l(null)):null;if(!r){if(r=gl("form"),t.input){let c=gl("input",t.input);/^(text|password|number|email|tel|url)$/.test(c.type)&&c.classList.add("cm-textfield"),c.name||(c.name="input"),r.appendChild(gl("label",(t.label||"")+": ",c))}else r.appendChild(document.createTextNode(t.label||""));r.appendChild(document.createTextNode(" ")),r.appendChild(gl("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let a=r.nodeName=="FORM"?[r]:r.querySelectorAll("form");for(let c=0;c<a.length;c++){let d=a[c];d.addEventListener("keydown",u=>{u.keyCode==27?(u.preventDefault(),l(null)):u.keyCode==13&&(u.preventDefault(),l(d))}),d.addEventListener("submit",u=>{u.preventDefault(),l(d)})}let o=gl("div",r,gl("button",{onclick:i(()=>l(null),"onclick"),"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));t.class&&(o.className=t.class),o.classList.add("cm-dialog");function l(c){o.contains(o.ownerDocument.activeElement)&&e.focus(),s(c)}return i(l,"done"),{dom:o,top:t.top,mount:i(()=>{if(t.focus){let c;typeof t.focus=="string"?c=r.querySelector(t.focus):c=r.querySelector("input")||r.querySelector("button"),c&&"select"in c?c.select():c&&"focus"in c&&c.focus()}},"mount")}}i(Udn,"createDialog");var Rk=class extends N1{static{i(this,"GutterMarker")}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Rk.prototype.elementClass="";Rk.prototype.toDOM=void 0;Rk.prototype.mapMode=_m.TrackBefore;Rk.prototype.startSide=Rk.prototype.endSide=-1;Rk.prototype.point=!0;var $B=Rr.define(),Kdn=Rr.define(),Wdn={class:"",renderEmptyElements:!1,elementStyle:"",markers:i(()=>Nl.empty,"markers"),lineMarker:i(()=>null,"lineMarker"),widgetMarker:i(()=>null,"widgetMarker"),lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},E6=Rr.define();function Qdn(e){return[idt(),E6.of({...Wdn,...e})]}i(Qdn,"gutter");var Rle=Rr.define({combine:i(e=>e.some(t=>t),"combine")});function idt(e){let t=[Vdn];return e&&e.fixed===!1&&t.push(Rle.of(!0)),t}i(idt,"gutters");var Vdn=rh.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(E6).map(t=>new DTe(e,t)),this.fixed=!e.state.facet(Rle);for(let t of this.gutters)t.config.side=="after"?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,s=e.view.viewport,r=Math.min(t.to,s.to)-Math.max(t.from,s.from);this.syncGutters(r<(s.to-s.from)*.8)}if(e.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(Rle)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let s=Nl.iter(this.view.state.facet($B),this.view.viewport.from),r=[],a=this.gutters.map(o=>new Hdn(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(o.type)){let l=!0;for(let c of o.type)if(c.type==Th.Text&&l){Mle(s,r,c.from);for(let d of a)d.line(this.view,c,r);l=!1}else if(c.widget)for(let d of a)d.widget(this.view,c)}else if(o.type==Th.Text){Mle(s,r,o.from);for(let l of a)l.line(this.view,o,r)}else if(o.widget)for(let l of a)l.widget(this.view,o);for(let o of a)o.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(E6),s=e.state.facet(E6),r=e.docChanged||e.heightChanged||e.viewportChanged||!Nl.eq(e.startState.facet($B),e.state.facet($B),e.view.viewport.from,e.view.viewport.to);if(t==s)for(let a of this.gutters)a.update(e)&&(r=!0);else{r=!0;let a=[];for(let o of s){let l=t.indexOf(o);l<0?a.push(new DTe(this.view,o)):(this.gutters[l].update(e),a.push(this.gutters[l]))}for(let o of this.gutters)o.dom.remove(),a.indexOf(o)<0&&o.destroy();for(let o of a)o.config.side=="after"?this.getDOMAfter().appendChild(o.dom):this.dom.appendChild(o.dom);this.gutters=a}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:i(e=>Br.scrollMargins.of(t=>{let s=t.plugin(e);if(!s||s.gutters.length==0||!s.fixed)return null;let r=s.dom.offsetWidth*t.scaleX,a=s.domAfter?s.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==ql.LTR?{left:r,right:a}:{right:r,left:a}}),"provide")});function LTe(e){return Array.isArray(e)?e:[e]}i(LTe,"asArray");function Mle(e,t,s){for(;e.value&&e.from<=s;)e.from==s&&t.push(e.value),e.next()}i(Mle,"advanceCursor");var Hdn=class{static{i(this,"UpdateContext")}constructor(e,t,s){this.gutter=e,this.height=s,this.i=0,this.cursor=Nl.iter(e.markers,t.from)}addElement(e,t,s){let{gutter:r}=this,a=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let l=new adt(e,o,a,s);r.elements.push(l),r.dom.appendChild(l.dom)}else r.elements[this.i].update(e,o,a,s);this.height=t.bottom,this.i++}line(e,t,s){let r=[];Mle(this.cursor,r,t.from),s.length&&(r=r.concat(s));let a=this.gutter.config.lineMarker(e,t,r);a&&r.unshift(a);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let s=this.gutter.config.widgetMarker(e,t.widget,t),r=s?[s]:null;for(let a of e.state.facet(Kdn)){let o=a(e,t.widget,t);o&&(r||(r=[])).push(o)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},DTe=class{static{i(this,"SingleGutterView")}constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let s in t.domEventHandlers)this.dom.addEventListener(s,r=>{let a=r.target,o;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let c=a.getBoundingClientRect();o=(c.top+c.bottom)/2}else o=r.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[s](e,l,r)&&r.preventDefault()});this.markers=LTe(t.markers(e)),t.initialSpacer&&(this.spacer=new adt(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=LTe(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let s=e.view.viewport;return!Nl.eq(this.markers,t,s.from,s.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},adt=class{static{i(this,"GutterElement")}constructor(e,t,s,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,s,r)}update(e,t,s,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=s&&(this.dom.style.marginTop=(this.above=s)?s+"px":""),Gdn(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let s="cm-gutterElement",r=this.dom.firstChild;for(let a=0,o=0;;){let l=o,c=a<t.length?t[a++]:null,d=!1;if(c){let u=c.elementClass;u&&(s+=" "+u);for(let h=o;h<this.markers.length;h++)if(this.markers[h].compare(c)){l=h,d=!0;break}}else l=this.markers.length;for(;o<l;){let u=this.markers[o++];if(u.toDOM){u.destroy(r);let h=r.nextSibling;r.remove(),r=h}}if(!c)break;c.toDOM&&(d?r=r.nextSibling:this.dom.insertBefore(c.toDOM(e),r)),d&&o++}this.dom.className=s,this.markers=t}destroy(){this.setMarkers(null,[])}};function Gdn(e,t){if(e.length!=t.length)return!1;for(let s=0;s<e.length;s++)if(!e[s].compare(t[s]))return!1;return!0}i(Gdn,"sameMarkers");var Ydn=Rr.define(),Jdn=Rr.define(),h5=Rr.define({combine(e){return Rb(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,s){let r=Object.assign({},t);for(let a in s){let o=r[a],l=s[a];r[a]=o?(c,d,u)=>o(c,d,u)||l(c,d,u):l}return r}})}}),zX=class extends Rk{static{i(this,"NumberMarker")}constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function qX(e,t){return e.state.facet(h5).formatNumber(t,e.state)}i(qX,"formatNumber");var Zdn=E6.compute([h5],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(Ydn)},lineMarker(t,s,r){return r.some(a=>a.toDOM)?null:new zX(qX(t,t.state.doc.lineAt(s.from).number))},widgetMarker:i((t,s,r)=>{for(let a of t.state.facet(Jdn)){let o=a(t,s,r);if(o)return o}return null},"widgetMarker"),lineMarkerChange:i(t=>t.startState.facet(h5)!=t.state.facet(h5),"lineMarkerChange"),initialSpacer(t){return new zX(qX(t,PTe(t.state.doc.lines)))},updateSpacer(t,s){let r=qX(s.view,PTe(s.view.state.doc.lines));return r==t.number?t:new zX(r)},domEventHandlers:e.facet(h5).domEventHandlers,side:"before"}));function odt(e={}){return[h5.of(e),idt(),Zdn]}i(odt,"lineNumbers");function PTe(e){let t=9;for(;t<e;)t=t*10+9;return t}i(PTe,"maxLineNumber");var Xdn=new class extends Rk{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},eun=$B.compute(["selection"],e=>{let t=[],s=-1;for(let r of e.selection.ranges){let a=e.doc.lineAt(r.head).from;a>s&&(s=a,t.push(Xdn.range(a)))}return Nl.of(t)});function tun(){return eun}i(tun,"highlightActiveLineGutter");var nun=0,Sy=class Lle{static{i(this,"Tag")}constructor(t,s,r,a){this.name=t,this.set=s,this.base=r,this.modified=a,this.id=nun++}toString(){let{name:t}=this;for(let s of this.modified)s.name&&(t=`${s.name}(${t})`);return t}static define(t,s){let r=typeof t=="string"?t:"?";if(t instanceof Lle&&(s=t),s?.base)throw new Error("Can not derive from a modified tag");let a=new Lle(r,[],null,[]);if(a.set.push(a),s)for(let o of s.set)a.set.push(o);return a}static defineModifier(t){let s=new $Te(t);return r=>r.modified.indexOf(s)>-1?r:$Te.get(r.base||r,r.modified.concat(s).sort((a,o)=>a.id-o.id))}},sun=0,$Te=class ldt{static{i(this,"Modifier")}constructor(t){this.name=t,this.instances=[],this.id=sun++}static get(t,s){if(!s.length)return t;let r=s[0].instances.find(c=>c.base==t&&run(s,c.modified));if(r)return r;let a=[],o=new Sy(t.name,a,t,s);for(let c of s)c.instances.push(o);let l=iun(s);for(let c of t.set)if(!c.modified.length)for(let d of l)a.push(ldt.get(c,d));return o}};function run(e,t){return e.length==t.length&&e.every((s,r)=>s==t[r])}i(run,"sameArray");function iun(e){let t=[[]];for(let s=0;s<e.length;s++)for(let r=0,a=t.length;r<a;r++)t.push(t[r].concat(e[s]));return t.sort((s,r)=>r.length-s.length)}i(iun,"powerSet");function aun(e){let t=Object.create(null);for(let s in e){let r=e[s];Array.isArray(r)||(r=[r]);for(let a of s.split(" "))if(a){let o=[],l=2,c=a;for(let h=0;;){if(c=="..."&&h>0&&h+3==a.length){l=1;break}let p=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(c);if(!p)throw new RangeError("Invalid path: "+a);if(o.push(p[0]=="*"?"":p[0][0]=='"'?JSON.parse(p[0]):p[0]),h+=p[0].length,h==a.length)break;let f=a[h++];if(h==a.length&&f=="!"){l=0;break}if(f!="/")throw new RangeError("Invalid path: "+a);c=a.slice(h)}let d=o.length-1,u=o[d];if(!u)throw new RangeError("Invalid path: "+a);t[u]=new IL(r,l,d>0?o.slice(0,d):null).sort(t[u])}}return cdt.add(t)}i(aun,"styleTags");var cdt=new Oa({combine(e,t){let s,r,a;for(;e||t;){if(!e||t&&e.depth>=t.depth?(a=t,t=t.next):(a=e,e=e.next),s&&s.mode==a.mode&&!a.context&&!s.context)continue;let o=new IL(a.tags,a.mode,a.context);s?s.next=o:r=o,s=o}return r}}),IL=class{static{i(this,"Rule")}constructor(e,t,s,r){this.tags=e,this.mode=t,this.context=s,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};IL.empty=new IL([],2,null);function ddt(e,t){let s=Object.create(null);for(let o of e)if(!Array.isArray(o.tag))s[o.tag.id]=o.class;else for(let l of o.tag)s[l.id]=o.class;let{scope:r,all:a=null}=t||{};return{style:i(o=>{let l=a;for(let c of o)for(let d of c.set){let u=s[d.id];if(u){l=l?l+" "+u:u;break}}return l},"style"),scope:r}}i(ddt,"tagHighlighter");function oun(e,t){let s=null;for(let r of e){let a=r.style(t);a&&(s=s?s+" "+a:a)}return s}i(oun,"highlightTags");function lun(e,t,s,r=0,a=e.length){let o=new cun(r,Array.isArray(t)?t:[t],s);o.highlightRange(e.cursor(),r,a,"",o.highlighters),o.flush(a)}i(lun,"highlightTree");var cun=class{static{i(this,"HighlightBuilder")}constructor(e,t,s){this.at=e,this.highlighters=t,this.span=s,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,s,r,a){let{type:o,from:l,to:c}=e;if(l>=s||c<=t)return;o.isTop&&(a=this.highlighters.filter(f=>!f.scope||f.scope(o)));let d=r,u=dun(e)||IL.empty,h=oun(a,u.tags);if(h&&(d&&(d+=" "),d+=h,u.mode==1&&(r+=(r?" ":"")+h)),this.startSpan(Math.max(t,l),d),u.opaque)return;let p=e.tree&&e.tree.prop(Oa.mounted);if(p&&p.overlay){let f=e.node.enter(p.overlay[0].from+l,1),g=this.highlighters.filter(v=>!v.scope||v.scope(p.tree.type)),x=e.firstChild();for(let v=0,b=l;;v++){let y=v<p.overlay.length?p.overlay[v]:null,k=y?y.from+l:c,j=Math.max(t,b),N=Math.min(s,k);if(j<N&&x)for(;e.from<N&&(this.highlightRange(e,j,N,r,a),this.startSpan(Math.min(N,e.to),d),!(e.to>=k||!e.nextSibling())););if(!y||k>s)break;b=y.to+l,b>t&&(this.highlightRange(f.cursor(),Math.max(t,y.from+l),Math.min(s,b),"",g),this.startSpan(Math.min(s,b),d))}x&&e.parent()}else if(e.firstChild()){p&&(r="");do if(!(e.to<=t)){if(e.from>=s)break;this.highlightRange(e,t,s,r,a),this.startSpan(Math.min(s,e.to),d)}while(e.nextSibling());e.parent()}}};function dun(e){let t=e.type.prop(cdt);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}i(dun,"getStyleTags");var mr=Sy.define,r$=mr(),Xw=mr(),OTe=mr(Xw),FTe=mr(Xw),ej=mr(),i$=mr(ej),UX=mr(ej),sv=mr(),RN=mr(sv),zx=mr(),qx=mr(),Dle=mr(),aE=mr(Dle),a$=mr(),mn={comment:r$,lineComment:mr(r$),blockComment:mr(r$),docComment:mr(r$),name:Xw,variableName:mr(Xw),typeName:OTe,tagName:mr(OTe),propertyName:FTe,attributeName:mr(FTe),className:mr(Xw),labelName:mr(Xw),namespace:mr(Xw),macroName:mr(Xw),literal:ej,string:i$,docString:mr(i$),character:mr(i$),attributeValue:mr(i$),number:UX,integer:mr(UX),float:mr(UX),bool:mr(ej),regexp:mr(ej),escape:mr(ej),color:mr(ej),url:mr(ej),keyword:zx,self:mr(zx),null:mr(zx),atom:mr(zx),unit:mr(zx),modifier:mr(zx),operatorKeyword:mr(zx),controlKeyword:mr(zx),definitionKeyword:mr(zx),moduleKeyword:mr(zx),operator:qx,derefOperator:mr(qx),arithmeticOperator:mr(qx),logicOperator:mr(qx),bitwiseOperator:mr(qx),compareOperator:mr(qx),updateOperator:mr(qx),definitionOperator:mr(qx),typeOperator:mr(qx),controlOperator:mr(qx),punctuation:Dle,separator:mr(Dle),bracket:aE,angleBracket:mr(aE),squareBracket:mr(aE),paren:mr(aE),brace:mr(aE),content:sv,heading:RN,heading1:mr(RN),heading2:mr(RN),heading3:mr(RN),heading4:mr(RN),heading5:mr(RN),heading6:mr(RN),contentSeparator:mr(sv),list:mr(sv),quote:mr(sv),emphasis:mr(sv),strong:mr(sv),link:mr(sv),monospace:mr(sv),strikethrough:mr(sv),inserted:mr(),deleted:mr(),changed:mr(),invalid:mr(),meta:a$,documentMeta:mr(a$),annotation:mr(a$),processingInstruction:mr(a$),definition:Sy.defineModifier("definition"),constant:Sy.defineModifier("constant"),function:Sy.defineModifier("function"),standard:Sy.defineModifier("standard"),local:Sy.defineModifier("local"),special:Sy.defineModifier("special")};for(let e in mn){let t=mn[e];t instanceof Sy&&(t.name=e)}var m9s=ddt([{tag:mn.link,class:"tok-link"},{tag:mn.heading,class:"tok-heading"},{tag:mn.emphasis,class:"tok-emphasis"},{tag:mn.strong,class:"tok-strong"},{tag:mn.keyword,class:"tok-keyword"},{tag:mn.atom,class:"tok-atom"},{tag:mn.bool,class:"tok-bool"},{tag:mn.url,class:"tok-url"},{tag:mn.labelName,class:"tok-labelName"},{tag:mn.inserted,class:"tok-inserted"},{tag:mn.deleted,class:"tok-deleted"},{tag:mn.literal,class:"tok-literal"},{tag:mn.string,class:"tok-string"},{tag:mn.number,class:"tok-number"},{tag:[mn.regexp,mn.escape,mn.special(mn.string)],class:"tok-string2"},{tag:mn.variableName,class:"tok-variableName"},{tag:mn.local(mn.variableName),class:"tok-variableName tok-local"},{tag:mn.definition(mn.variableName),class:"tok-variableName tok-definition"},{tag:mn.special(mn.variableName),class:"tok-variableName2"},{tag:mn.definition(mn.propertyName),class:"tok-propertyName tok-definition"},{tag:mn.typeName,class:"tok-typeName"},{tag:mn.namespace,class:"tok-namespace"},{tag:mn.className,class:"tok-className"},{tag:mn.macroName,class:"tok-macroName"},{tag:mn.propertyName,class:"tok-propertyName"},{tag:mn.operator,class:"tok-operator"},{tag:mn.comment,class:"tok-comment"},{tag:mn.meta,class:"tok-meta"},{tag:mn.invalid,class:"tok-invalid"},{tag:mn.punctuation,class:"tok-punctuation"}]),KX,OC=new Oa;function udt(e){return Rr.define({combine:e?t=>t.concat(e):void 0})}i(udt,"defineLanguageFacet");var uun=new Oa,Mf=class{static{i(this,"Language")}constructor(e,t,s=[],r=""){this.data=e,this.name=r,Dc.prototype.hasOwnProperty("tree")||Object.defineProperty(Dc.prototype,"tree",{get(){return sm(this)}}),this.parser=t,this.extension=[A1.of(this),Dc.languageData.of((a,o,l)=>{let c=BTe(a,o,l),d=c.type.prop(OC);if(!d)return[];let u=a.facet(d),h=c.type.prop(uun);if(h){let p=c.resolve(o-c.from,l);for(let f of h)if(f.test(p,a)){let g=a.facet(f.facet);return f.type=="replace"?g:g.concat(u)}}return u})].concat(s)}isActiveAt(e,t,s=-1){return BTe(e,t,s).type.prop(OC)==this.data}findRegions(e){let t=e.facet(A1);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let s=[],r=i((a,o)=>{if(a.prop(OC)==this.data){s.push({from:o,to:o+a.length});return}let l=a.prop(Oa.mounted);if(l){if(l.tree.prop(OC)==this.data){if(l.overlay)for(let c of l.overlay)s.push({from:c.from+o,to:c.to+o});else s.push({from:o,to:o+a.length});return}else if(l.overlay){let c=s.length;if(r(l.tree,l.overlay[0].from+o),s.length>c)return}}for(let c=0;c<a.children.length;c++){let d=a.children[c];d instanceof kc&&r(d,a.positions[c]+o)}},"explore");return r(sm(e),0),s}get allowsNesting(){return!0}};Mf.setState=pa.define();function BTe(e,t,s){let r=e.facet(A1),a=sm(e).topNode;if(!r||r.allowsNesting)for(let o=a;o;o=o.enter(t,s,$l.ExcludeBuffers|$l.EnterBracketed))o.type.isTop&&(a=o);return a}i(BTe,"topNodeAt");var p9s=class Ple extends Mf{static{i(this,"LRLanguage")}constructor(t,s,r){super(t,s,[],r),this.parser=s}static define(t){let s=udt(t.languageData);return new Ple(s,t.parser.configure({props:[OC.add(r=>r.isTop?s:void 0)]}),t.name)}configure(t,s){return new Ple(this.data,this.parser.configure(t),s||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function sm(e){let t=e.field(Mf.state,!1);return t?t.tree:kc.empty}i(sm,"syntaxTree");var hun=class{static{i(this,"DocInput")}constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let s=this.cursorPos-this.string.length;return e<s||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-s,t-s)}},oE=null,$le=class Ole{static{i(this,"ParseContext")}constructor(t,s,r=[],a,o,l,c,d){this.parser=t,this.state=s,this.fragments=r,this.tree=a,this.treeLen=o,this.viewport=l,this.skipped=c,this.scheduleOn=d,this.parse=null,this.tempSkipped=[]}static create(t,s,r){return new Ole(t,s,[],kc.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hun(this.state.doc),this.fragments)}work(t,s){return s!=null&&s>=this.state.doc.length&&(s=void 0),this.tree!=kc.empty&&this.isDone(s??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof t=="number"){let a=Date.now()+t;t=i(()=>Date.now()>a,"until")}for(this.parse||(this.parse=this.startParse()),s!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>s)&&s<this.state.doc.length&&this.parse.stopAt(s);;){let a=this.parse.advance();if(a)if(this.fragments=this.withoutTempSkipped(Z5.addTree(a,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=a,this.parse=null,this.treeLen<(s??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,s;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(s=this.parse.advance()););}),this.treeLen=t,this.tree=s,this.fragments=this.withoutTempSkipped(Z5.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let s=oE;oE=this;try{return t()}finally{oE=s}}withoutTempSkipped(t){for(let s;s=this.tempSkipped.pop();)t=zTe(t,s.from,s.to);return t}changes(t,s){let{fragments:r,tree:a,treeLen:o,viewport:l,skipped:c}=this;if(this.takeTree(),!t.empty){let d=[];if(t.iterChangedRanges((u,h,p,f)=>d.push({fromA:u,toA:h,fromB:p,toB:f})),r=Z5.applyChanges(r,d),a=kc.empty,o=0,l={from:t.mapPos(l.from,-1),to:t.mapPos(l.to,1)},this.skipped.length){c=[];for(let u of this.skipped){let h=t.mapPos(u.from,1),p=t.mapPos(u.to,-1);h<p&&c.push({from:h,to:p})}}}return new Ole(this.parser,s,r,a,o,l,c,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let s=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:a,to:o}=this.skipped[r];a<t.to&&o>t.from&&(this.fragments=zTe(this.fragments,a,o),this.skipped.splice(r--,1))}return this.skipped.length>=s?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,s){this.skipped.push({from:t,to:s})}static getSkippingParser(t){return new class extends olt{createParse(s,r,a){let o=a[0].from,l=a[a.length-1].to;return{parsedPos:o,advance(){let c=oE;if(c){for(let d of a)c.tempSkipped.push(d);t&&(c.scheduleOn=c.scheduleOn?Promise.all([c.scheduleOn,t]):t)}return this.parsedPos=l,new kc(B0.none,[],[],l-o)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let s=this.fragments;return this.treeLen>=t&&s.length&&s[0].from==0&&s[0].to>=t}static get(){return oE}};function zTe(e,t,s){return Z5.applyChanges(e,[{fromA:t,toA:s,fromB:t,toB:s}])}i(zTe,"cutFragments");var Fle=class Ble{static{i(this,"LanguageState")}constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let s=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),s.viewport.to);return s.work(20,r)||s.takeTree(),new Ble(s)}static init(t){let s=Math.min(3e3,t.doc.length),r=$le.create(t.facet(A1).parser,t,{from:0,to:s});return r.work(20,s)||r.takeTree(),new Ble(r)}};Mf.state=zp.define({create:Fle.init,update(e,t){for(let s of t.effects)if(s.is(Mf.setState))return s.value;return t.startState.facet(A1)!=t.state.facet(A1)?Fle.init(t.state):e.apply(t)}});var hdt=i(e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)},"requestIdle");typeof requestIdleCallback<"u"&&(hdt=i(e=>{let t=-1,s=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(s):cancelIdleCallback(t)},"requestIdle"));var WX=typeof navigator<"u"&&(!((KX=navigator.scheduling)===null||KX===void 0)&&KX.isInputPending)?()=>navigator.scheduling.isInputPending():null,mun=rh.fromClass(class{static{i(this,"ParseWorker")}constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let s=this.view.state.field(Mf.state).context;(s.updateViewport(t.view.viewport)||this.view.viewport.to>s.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(s)}scheduleWork(){if(this.working)return;let{state:t}=this.view,s=t.field(Mf.state);(s.tree!=s.context.tree||!s.context.isDone(t.doc.length))&&(this.working=hdt(this.work))}work(t){this.working=null;let s=Date.now();if(this.chunkEnd<s&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=s+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:a}}=this.view,o=r.field(Mf.state);if(o.tree==o.context.tree&&o.context.isDone(a+1e5))return;let l=Date.now()+Math.min(this.chunkBudget,100,t&&!WX?Math.max(25,t.timeRemaining()-5):1e9),c=o.context.treeLen<a&&r.doc.length>a+1e3,d=o.context.work(()=>WX&&WX()||Date.now()>l,a+(c?0:1e5));this.chunkBudget-=Date.now()-s,(d||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:Mf.setState.of(new Fle(o.context))})),this.chunkBudget>0&&!(d&&!c)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(s=>gp(this.view.state,s)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),A1=Rr.define({combine(e){return e.length?e[0]:null},enables:i(e=>[Mf.state,mun,Br.contentAttributes.compute([e],t=>{let s=t.facet(e);return s&&s.name?{"data-language":s.name}:{}})],"enables")}),pun=class{static{i(this,"LanguageSupport")}constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},cn=class mdt{static{i(this,"LanguageDescription")}constructor(t,s,r,a,o,l=void 0){this.name=t,this.alias=s,this.extensions=r,this.filename=a,this.loadFunc=o,this.support=l,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:s,support:r}=t;if(!s){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");s=i(()=>Promise.resolve(r),"load")}return new mdt(t.name,(t.alias||[]).concat(t.name).map(a=>a.toLowerCase()),t.extensions||[],t.filename,s,r)}static matchFilename(t,s){for(let a of t)if(a.filename&&a.filename.test(s))return a;let r=/\.([^.]+)$/.exec(s);if(r){for(let a of t)if(a.extensions.indexOf(r[1])>-1)return a}return null}static matchLanguageName(t,s,r=!0){s=s.toLowerCase();for(let a of t)if(a.alias.some(o=>o==s))return a;if(r)for(let a of t)for(let o of a.alias){let l=s.indexOf(o);if(l>-1&&(o.length>2||!/\w/.test(s[l-1])&&!/\w/.test(s[l+o.length])))return a}return null}},fun=Rr.define(),PH=Rr.define({combine:i(e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(s=>s!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t},"combine")});function I1(e){let t=e.facet(PH);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}i(I1,"getIndentUnit");function hI(e,t){let s="",r=e.tabSize,a=e.facet(PH)[0];if(a==" "){for(;t>=r;)s+=" ",t-=r;a=" "}for(let o=0;o<t;o++)s+=a;return s}i(hI,"indentString");function Ove(e,t){e instanceof Dc&&(e=new $H(e));for(let r of e.state.facet(fun)){let a=r(e,t);if(a!==void 0)return a}let s=sm(e.state);return s.length>=t?gun(e,s,t):null}i(Ove,"getIndentation");var $H=class{static{i(this,"IndentContext")}constructor(e,t={}){this.state=e,this.options=t,this.unit=I1(e)}lineAt(e,t=1){let s=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:a}=this.options;return r!=null&&r>=s.from&&r<=s.to?a&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:s.text.slice(r-s.from),from:r}:{text:s.text.slice(0,r-s.from),from:s.from}:s}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:s,from:r}=this.lineAt(e,t);return s.slice(e-r,Math.min(s.length,e+100-r))}column(e,t=1){let{text:s,from:r}=this.lineAt(e,t),a=this.countColumn(s,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(a+=o-this.countColumn(s,s.search(/\S|$/))),a}countColumn(e,t=e.length){return JS(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:s,from:r}=this.lineAt(e,t),a=this.options.overrideIndentation;if(a){let o=a(r);if(o>-1)return o}return this.countColumn(s,s.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},pdt=new Oa;function gun(e,t,s){let r=t.resolveStack(s),a=t.resolveInner(s,-1).resolve(s,0).enterUnfinishedNodesBefore(s);if(a!=r.node){let o=[];for(let l=a;l&&!(l.from<r.node.from||l.to>r.node.to||l.from==r.node.from&&l.type==r.node.type);l=l.parent)o.push(l);for(let l=o.length-1;l>=0;l--)r={node:o[l],next:r}}return fdt(r,e,s)}i(gun,"syntaxIndentation");function fdt(e,t,s){for(let r=e;r;r=r.next){let a=vun(r.node);if(a)return a(yun.create(t,s,r))}return 0}i(fdt,"indentFor");function xun(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}i(xun,"ignoreClosed");function vun(e){let t=e.type.prop(pdt);if(t)return t;let s=e.firstChild,r;if(s&&(r=s.type.prop(Oa.closedBy))){let a=e.lastChild,o=a&&r.indexOf(a.name)>-1;return l=>xdt(l,!0,1,void 0,o&&!xun(l)?a.from:void 0)}return e.parent==null?bun:null}i(vun,"indentStrategy");function bun(){return 0}i(bun,"topIndent");var yun=class gdt extends $H{static{i(this,"TreeIndentContext")}constructor(t,s,r){super(t.state,t.options),this.base=t,this.pos=s,this.context=r}get node(){return this.context.node}static create(t,s,r){return new gdt(t,s,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let s=this.state.doc.lineAt(t.from);for(;;){let r=t.resolve(s.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(kun(r,t))break;s=this.state.doc.lineAt(r.from)}return this.lineIndent(s.from)}continue(){return fdt(this.context.next,this.base,this.pos)}};function kun(e,t){for(let s=t;s;s=s.parent)if(e==s)return!0;return!1}i(kun,"isParent");function wun(e){let t=e.node,s=t.childAfter(t.from),r=t.lastChild;if(!s)return null;let a=e.options.simulateBreak,o=e.state.doc.lineAt(s.from),l=a==null||a<=o.from?o.to:Math.min(o.to,a);for(let c=s.to;;){let d=t.childAfter(c);if(!d||d==r)return null;if(!d.type.isSkipped){if(d.from>=l)return null;let u=/^ */.exec(o.text.slice(s.to-o.from))[0].length;return{from:s.from,to:s.to+u}}c=d.to}}i(wun,"bracketedAligned");function g9s({closing:e,align:t=!0,units:s=1}){return r=>xdt(r,t,s,e)}i(g9s,"delimitedIndent");function xdt(e,t,s,r,a){let o=e.textAfter,l=o.match(/^\s*/)[0].length,c=r&&o.slice(l,l+r.length)==r||a==e.pos+l,d=t?wun(e):null;return d?c?e.column(d.from):e.column(d.to):e.baseIndent+(c?0:e.unit*s)}i(xdt,"delimitedStrategy");var x9s=i(e=>e.baseIndent,"flatIndent");function v9s({except:e,units:t=1}={}){return s=>{let r=e&&e.test(s.textAfter);return s.baseIndent+(r?0:t*s.unit)}}i(v9s,"continuedIndent");var jun=200;function Nun(){return Dc.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let s=e.newDoc,{head:r}=e.newSelection.main,a=s.lineAt(r);if(r>a.from+jun)return e;let o=s.sliceString(a.from,r);if(!t.some(u=>u.test(o)))return e;let{state:l}=e,c=-1,d=[];for(let{head:u}of l.selection.ranges){let h=l.doc.lineAt(u);if(h.from==c)continue;c=h.from;let p=Ove(l,h.from);if(p==null)continue;let f=/^\s*/.exec(h.text)[0],g=hI(l,p);f!=g&&d.push({from:h.from,to:h.from+f.length,insert:g})}return d.length?[e,{changes:d,sequential:!0}]:e})}i(Nun,"indentOnInput");var Cun=Rr.define(),Sun=new Oa;function b9s(e){let t=e.firstChild,s=e.lastChild;return t&&t.to<s.from?{from:t.to,to:s.type.isError?e.to:s.from}:null}i(b9s,"foldInside");function _un(e,t,s){let r=sm(e);if(r.length<s)return null;let a=r.resolveStack(s,1),o=null;for(let l=a;l;l=l.next){let c=l.node;if(c.to<=s||c.from>s)continue;if(o&&c.from<t)break;let d=c.type.prop(Sun);if(d&&(c.to<r.length-50||r.length==e.doc.length||!Aun(c))){let u=d(c,e);u&&u.from<=s&&u.from>=t&&u.to>s&&(o=u)}}return o}i(_un,"syntaxFolding");function Aun(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}i(Aun,"isUnfinished");function eK(e,t,s){for(let r of e.facet(Cun)){let a=r(e,t,s);if(a)return a}return _un(e,t,s)}i(eK,"foldable");function vdt(e,t){let s=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return s>=r?void 0:{from:s,to:r}}i(vdt,"mapRange");var OH=pa.define({map:vdt}),N7=pa.define({map:vdt});function bdt(e){let t=[];for(let{head:s}of e.state.selection.ranges)t.some(r=>r.from<=s&&r.to>=s)||t.push(e.lineBlockAt(s));return t}i(bdt,"selectedLines");var X3=zp.define({create(){return Ui.none},update(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((r,a)=>e=qTe(e,r,a)),e=e.map(t.changes);let s=[];for(let r of t.effects)r.is(OH)&&!Iun(e,r.value.from,r.value.to)?s.push(r.value):r.is(N7)&&(e=e.update({filter:i((a,o)=>r.value.from!=a||r.value.to!=o,"filter"),filterFrom:r.value.from,filterTo:r.value.to}));if(s.length){let{preparePlaceholder:r}=t.state.facet(Fve),a=s.map(o=>(r?Ui.replace({widget:new Pun(r(t.state,o))}):UTe).range(o.from,o.to));e=e.update({add:a})}return t.selection&&(e=qTe(e,t.selection.main.head)),e},provide:i(e=>Br.decorations.from(e),"provide"),toJSON(e,t){let s=[];return e.between(0,t.doc.length,(r,a)=>{s.push(r,a)}),s},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let s=0;s<e.length;){let r=e[s++],a=e[s++];if(typeof r!="number"||typeof a!="number")throw new RangeError("Invalid JSON for fold state");t.push(UTe.range(r,a))}return Ui.set(t,!0)}});function qTe(e,t,s=t){let r=!1;return e.between(t,s,(a,o)=>{a<s&&o>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:s,filter:i((a,o)=>a>=s||o<=t,"filter")}):e}i(qTe,"clearTouchedFolds");function tK(e,t,s){var r;let a=null;return(r=e.field(X3,!1))===null||r===void 0||r.between(t,s,(o,l)=>{(!a||a.from>o)&&(a={from:o,to:l})}),a}i(tK,"findFold");function Iun(e,t,s){let r=!1;return e.between(t,t,(a,o)=>{a==t&&o==s&&(r=!0)}),r}i(Iun,"foldExists");function ydt(e,t){return e.field(X3,!1)?t:t.concat(pa.appendConfig.of(wdt()))}i(ydt,"maybeEnable");var Tun=i(e=>{for(let t of bdt(e)){let s=eK(e.state,t.from,t.to);if(s)return e.dispatch({effects:ydt(e.state,[OH.of(s),kdt(e,s)])}),!0}return!1},"foldCode"),Eun=i(e=>{if(!e.state.field(X3,!1))return!1;let t=[];for(let s of bdt(e)){let r=tK(e.state,s.from,s.to);r&&t.push(N7.of(r),kdt(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0},"unfoldCode");function kdt(e,t,s=!0){let r=e.state.doc.lineAt(t.from).number,a=e.state.doc.lineAt(t.to).number;return Br.announce.of(`${e.state.phrase(s?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${a}.`)}i(kdt,"announceFold");var Run=i(e=>{let{state:t}=e,s=[];for(let r=0;r<t.doc.length;){let a=e.lineBlockAt(r),o=eK(t,a.from,a.to);o&&s.push(OH.of(o)),r=(o?e.lineBlockAt(o.to):a).to+1}return s.length&&e.dispatch({effects:ydt(e.state,s)}),!!s.length},"foldAll"),Mun=i(e=>{let t=e.state.field(X3,!1);if(!t||!t.size)return!1;let s=[];return t.between(0,e.state.doc.length,(r,a)=>{s.push(N7.of({from:r,to:a}))}),e.dispatch({effects:s}),!0},"unfoldAll"),Lun=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Tun},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Eun},{key:"Ctrl-Alt-[",run:Run},{key:"Ctrl-Alt-]",run:Mun}],Dun={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Fve=Rr.define({combine(e){return Rb(e,Dun)}});function wdt(e){let t=[X3,Fun];return e&&t.push(Fve.of(e)),t}i(wdt,"codeFolding");function jdt(e,t){let{state:s}=e,r=s.facet(Fve),a=i(l=>{let c=e.lineBlockAt(e.posAtDOM(l.target)),d=tK(e.state,c.from,c.to);d&&e.dispatch({effects:N7.of(d)}),l.preventDefault()},"onclick");if(r.placeholderDOM)return r.placeholderDOM(e,a,t);let o=document.createElement("span");return o.textContent=r.placeholderText,o.setAttribute("aria-label",s.phrase("folded code")),o.title=s.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=a,o}i(jdt,"widgetToDOM");var UTe=Ui.replace({widget:new class extends aw{toDOM(e){return jdt(e,null)}}}),Pun=class extends aw{static{i(this,"PreparedFoldWidget")}constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return jdt(e,this.value)}},$un={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:i(()=>!1,"foldingChanged")},QX=class extends Rk{static{i(this,"FoldMarker")}constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}};function Oun(e={}){let t={...$un,...e},s=new QX(t,!0),r=new QX(t,!1),a=rh.fromClass(class{constructor(l){this.from=l.viewport.from,this.markers=this.buildMarkers(l)}update(l){(l.docChanged||l.viewportChanged||l.startState.facet(A1)!=l.state.facet(A1)||l.startState.field(X3,!1)!=l.state.field(X3,!1)||sm(l.startState)!=sm(l.state)||t.foldingChanged(l))&&(this.markers=this.buildMarkers(l.view))}buildMarkers(l){let c=new Bj;for(let d of l.viewportLineBlocks){let u=tK(l.state,d.from,d.to)?r:eK(l.state,d.from,d.to)?s:null;u&&c.add(d.from,d.from,u)}return c.finish()}}),{domEventHandlers:o}=t;return[a,Qdn({class:"cm-foldGutter",markers(l){var c;return((c=l.plugin(a))===null||c===void 0?void 0:c.markers)||Nl.empty},initialSpacer(){return new QX(t,!1)},domEventHandlers:{...o,click:i((l,c,d)=>{if(o.click&&o.click(l,c,d))return!0;let u=tK(l.state,c.from,c.to);if(u)return l.dispatch({effects:N7.of(u)}),!0;let h=eK(l.state,c.from,c.to);return h?(l.dispatch({effects:OH.of(h)}),!0):!1},"click")}}),wdt()]}i(Oun,"foldGutter");var Fun=Br.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}}),Bve=class Ndt{static{i(this,"HighlightStyle")}constructor(t,s){this.specs=t;let r;function a(c){let d=C1.newName();return(r||(r=Object.create(null)))["."+d]=c,d}i(a,"def");const o=typeof s.all=="string"?s.all:s.all?a(s.all):void 0,l=s.scope;this.scope=l instanceof Mf?c=>c.prop(OC)==l.data:l?c=>c==l:void 0,this.style=ddt(t.map(c=>({tag:c.tag,class:c.class||a(Object.assign({},c,{tag:null}))})),{all:o}).style,this.module=r?new C1(r):null,this.themeType=s.themeType}static define(t,s){return new Ndt(t,s||{})}},zle=Rr.define(),Cdt=Rr.define({combine(e){return e.length?[e[0]]:null}});function VX(e){let t=e.facet(zle);return t.length?t:e.facet(Cdt)}i(VX,"getHighlighters");function Sdt(e,t){let s=[zun],r;return e instanceof Bve&&(e.module&&s.push(Br.styleModule.of(e.module)),r=e.themeType),t?.fallback?s.push(Cdt.of(e)):r?s.push(zle.computeN([Br.darkTheme],a=>a.facet(Br.darkTheme)==(r=="dark")?[e]:[])):s.push(zle.of(e)),s}i(Sdt,"syntaxHighlighting");var Bun=class{static{i(this,"TreeHighlighter")}constructor(e){this.markCache=Object.create(null),this.tree=sm(e.state),this.decorations=this.buildDeco(e,VX(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=sm(e.state),s=VX(e.state),r=s!=VX(e.startState),{viewport:a}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<a.to&&!r&&t.type==this.tree.type&&o>=a.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,s),this.decoratedTo=a.to)}buildDeco(e,t){if(!t||!this.tree.length)return Ui.none;let s=new Bj;for(let{from:r,to:a}of e.visibleRanges)lun(this.tree,t,(o,l,c)=>{s.add(o,l,this.markCache[c]||(this.markCache[c]=Ui.mark({class:c})))},r,a);return s.finish()}},zun=YS.high(rh.fromClass(Bun,{decorations:i(e=>e.decorations,"decorations")})),qun=Bve.define([{tag:mn.meta,color:"#404740"},{tag:mn.link,textDecoration:"underline"},{tag:mn.heading,textDecoration:"underline",fontWeight:"bold"},{tag:mn.emphasis,fontStyle:"italic"},{tag:mn.strong,fontWeight:"bold"},{tag:mn.strikethrough,textDecoration:"line-through"},{tag:mn.keyword,color:"#708"},{tag:[mn.atom,mn.bool,mn.url,mn.contentSeparator,mn.labelName],color:"#219"},{tag:[mn.literal,mn.inserted],color:"#164"},{tag:[mn.string,mn.deleted],color:"#a11"},{tag:[mn.regexp,mn.escape,mn.special(mn.string)],color:"#e40"},{tag:mn.definition(mn.variableName),color:"#00f"},{tag:mn.local(mn.variableName),color:"#30a"},{tag:[mn.typeName,mn.namespace],color:"#085"},{tag:mn.className,color:"#167"},{tag:[mn.special(mn.variableName),mn.macroName],color:"#256"},{tag:mn.definition(mn.propertyName),color:"#00c"},{tag:mn.comment,color:"#940"},{tag:mn.invalid,color:"#f00"}]),Uun=Br.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),_dt=1e4,Adt="()[]{}",Idt=Rr.define({combine(e){return Rb(e,{afterCursor:!0,brackets:Adt,maxScanDistance:_dt,renderMatch:Qun})}}),Kun=Ui.mark({class:"cm-matchingBracket"}),Wun=Ui.mark({class:"cm-nonmatchingBracket"});function Qun(e){let t=[],s=e.matched?Kun:Wun;return t.push(s.range(e.start.from,e.start.to)),e.end&&t.push(s.range(e.end.from,e.end.to)),t}i(Qun,"defaultRenderMatch");function KTe(e){let t=[],s=e.facet(Idt);for(let r of e.selection.ranges){if(!r.empty)continue;let a=Mv(e,r.head,-1,s)||r.head>0&&Mv(e,r.head-1,1,s)||s.afterCursor&&(Mv(e,r.head,1,s)||r.head<e.doc.length&&Mv(e,r.head+1,-1,s));a&&(t=t.concat(s.renderMatch(a,e)))}return Ui.set(t,!0)}i(KTe,"bracketDeco");var Vun=[rh.fromClass(class{constructor(e){this.paused=!1,this.decorations=KTe(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=KTe(e.state),this.paused=!1))}},{decorations:i(e=>e.decorations,"decorations")}),Uun];function Hun(e={}){return[Idt.of(e),Vun]}i(Hun,"bracketMatching");var Gun=new Oa;function qle(e,t,s){let r=e.prop(t<0?Oa.openedBy:Oa.closedBy);if(r)return r;if(e.name.length==1){let a=s.indexOf(e.name);if(a>-1&&a%2==(t<0?1:0))return[s[a+t]]}return null}i(qle,"matchingNodes");function Ule(e){let t=e.type.prop(Gun);return t?t(e.node):e}i(Ule,"findHandle");function Mv(e,t,s,r={}){let a=r.maxScanDistance||_dt,o=r.brackets||Adt,l=sm(e),c=l.resolveInner(t,s);for(let d=c;d;d=d.parent){let u=qle(d.type,s,o);if(u&&d.from<d.to){let h=Ule(d);if(h&&(s>0?t>=h.from&&t<h.to:t>h.from&&t<=h.to))return Yun(e,t,s,d,h,u,o)}}return Jun(e,t,s,l,c.type,a,o)}i(Mv,"matchBrackets");function Yun(e,t,s,r,a,o,l){let c=r.parent,d={from:a.from,to:a.to},u=0,h=c?.cursor();if(h&&(s<0?h.childBefore(r.from):h.childAfter(r.to)))do if(s<0?h.to<=r.from:h.from>=r.to){if(u==0&&o.indexOf(h.type.name)>-1&&h.from<h.to){let p=Ule(h);return{start:d,end:p?{from:p.from,to:p.to}:void 0,matched:!0}}else if(qle(h.type,s,l))u++;else if(qle(h.type,-s,l)){if(u==0){let p=Ule(h);return{start:d,end:p&&p.from<p.to?{from:p.from,to:p.to}:void 0,matched:!1}}u--}}while(s<0?h.prevSibling():h.nextSibling());return{start:d,matched:!1}}i(Yun,"matchMarkedBrackets");function Jun(e,t,s,r,a,o,l){if(s<0?!t:t==e.doc.length)return null;let c=s<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),d=l.indexOf(c);if(d<0||d%2==0!=s>0)return null;let u={from:s<0?t-1:t,to:s>0?t+1:t},h=e.doc.iterRange(t,s>0?e.doc.length:0),p=0;for(let f=0;!h.next().done&&f<=o;){let g=h.value;s<0&&(f+=g.length);let x=t+f*s;for(let v=s>0?0:g.length-1,b=s>0?g.length:-1;v!=b;v+=s){let y=l.indexOf(g[v]);if(!(y<0||r.resolveInner(x+v,1).type!=a))if(y%2==0==s>0)p++;else{if(p==1)return{start:u,end:{from:x+v,to:x+v+1},matched:y>>1==d>>1};p--}}s>0&&(f+=g.length)}return h.done?{start:u,matched:!1}:null}i(Jun,"matchPlainBrackets");function WTe(e,t,s,r=0,a=0){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let o=a;for(let l=r;l<t;l++)e.charCodeAt(l)==9?o+=s-o%s:o++;return o}i(WTe,"countCol");var Tdt=class{static{i(this,"StringStream")}constructor(e,t,s,r){this.string=e,this.tabSize=t,this.indentUnit=s,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),s;if(typeof e=="string"?s=t==e:s=t&&(e instanceof RegExp?e.test(t):e(t)),s)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=WTe(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var e;return(e=this.overrideIndent)!==null&&e!==void 0?e:WTe(this.string,null,this.tabSize)}match(e,t,s){if(typeof e=="string"){let r=i(a=>s?a.toLowerCase():a,"cased");return r(this.string.substr(this.pos,e.length))==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}else{let r=this.string.slice(this.pos).match(e);return r&&r.index>0?null:(r&&t!==!1&&(this.pos+=r[0].length),r)}}current(){return this.string.slice(this.start,this.pos)}};function Zun(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||Xun,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||qve,mergeTokens:e.mergeTokens!==!1}}i(Zun,"fullParser");function Xun(e){if(typeof e!="object")return e;let t={};for(let s in e){let r=e[s];t[s]=r instanceof Array?r.slice():r}return t}i(Xun,"defaultCopyState");var QTe=new WeakMap,ehn=class Edt extends Mf{static{i(this,"StreamLanguage")}constructor(t){let s=udt(t.languageData),r=Zun(t),a,o=new class extends olt{createParse(l,c,d){return new nhn(a,l,c,d)}};super(s,o,[],t.name),this.topNode=ihn(s,this),a=this,this.streamParser=r,this.stateAfter=new Oa({perNode:!0}),this.tokenTable=t.tokenTable?new Ddt(r.tokenTable):rhn}static define(t){return new Edt(t)}getIndent(t){let s,{overrideIndentation:r}=t.options;r&&(s=QTe.get(t.state),s!=null&&s<t.pos-1e4&&(s=void 0));let a=zve(this,t.node.tree,t.node.from,t.node.from,s??t.pos),o,l;if(a?(l=a.state,o=a.pos+1):(l=this.streamParser.startState(t.unit),o=t.node.from),t.pos-o>1e4)return null;for(;o<t.pos;){let d=t.state.doc.lineAt(o),u=Math.min(t.pos,d.to);if(d.length){let h=r?r(d.from):-1,p=new Tdt(d.text,t.state.tabSize,t.unit,h<0?void 0:h);for(;p.pos<u-d.from;)Mdt(this.streamParser.token,p,l)}else this.streamParser.blankLine(l,t.unit);if(u==t.pos)break;o=d.to+1}let c=t.lineAt(t.pos);return r&&s==null&&QTe.set(t.state,c.from),this.streamParser.indent(l,/^\s*(.*)/.exec(c.text)[1],t)}get allowsNesting(){return!1}};function zve(e,t,s,r,a){let o=s>=r&&s+t.length<=a&&t.prop(e.stateAfter);if(o)return{state:e.streamParser.copyState(o),pos:s+t.length};for(let l=t.children.length-1;l>=0;l--){let c=t.children[l],d=s+t.positions[l],u=c instanceof kc&&d<a&&zve(e,c,d,r,a);if(u)return u}return null}i(zve,"findState");function Rdt(e,t,s,r,a){if(a&&s<=0&&r>=t.length)return t;!a&&s==0&&t.type==e.topNode&&(a=!0);for(let o=t.children.length-1;o>=0;o--){let l=t.positions[o],c=t.children[o],d;if(l<r&&c instanceof kc){if(!(d=Rdt(e,c,s-l,r-l,a)))break;return a?new kc(t.type,t.children.slice(0,o).concat(d),t.positions.slice(0,o+1),l+d.length):d}}return null}i(Rdt,"cutTree");function thn(e,t,s,r,a){for(let o of t){let l=o.from+(o.openStart?25:0),c=o.to-(o.openEnd?25:0),d=l<=s&&c>s&&zve(e,o.tree,0-o.offset,s,c),u;if(d&&d.pos<=r&&(u=Rdt(e,o.tree,s+o.offset,d.pos+o.offset,!1)))return{state:d.state,tree:u}}return{state:e.streamParser.startState(a?I1(a):4),tree:kc.empty}}i(thn,"findStartInFragments");var nhn=class{static{i(this,"Parse")}constructor(e,t,s,r){this.lang=e,this.input=t,this.fragments=s,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let a=$le.get(),o=r[0].from,{state:l,tree:c}=thn(e,s,o,this.to,a?.state);this.state=l,this.parsedPos=this.chunkStart=o+c.length;for(let d=0;d<c.children.length;d++)this.chunks.push(c.children[d]),this.chunkPos.push(c.positions[d]);a&&this.parsedPos<a.viewport.from-1e5&&r.some(d=>d.from<=a.viewport.from&&d.to>=a.viewport.from)&&(this.state=this.lang.streamParser.startState(I1(a.state)),a.skipUntilInView(this.parsedPos,a.viewport.from),this.parsedPos=a.viewport.from),this.moveRangeIndex()}advance(){let e=$le.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),s=Math.min(t,this.chunkStart+512);for(e&&(s=Math.min(s,e.viewport.to));this.parsedPos<s;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
171
171
  `&&(t="");else{let s=t.indexOf(`
172
- `);s>-1&&(t=t.slice(0,s))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),s=e+t.length;for(let r=this.rangeIndex;;){let a=this.ranges[r].to;if(a>=s||(t=t.slice(0,a-(s-t.length)),r++,r==this.ranges.length))break;let o=this.ranges[r].from,l=this.lineAfter(o);t+=l,s=o+l.length}return{line:t,end:s}}skipGapsTo(e,t,s){for(;;){let r=this.ranges[this.rangeIndex].to,a=e+t;if(s>0?r>a:r>=a)break;let o=this.ranges[++this.rangeIndex].from;t+=o-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,s,r){let a=4;if(this.ranges.length>1){r=this.skipGapsTo(t,r,1),t+=r;let l=this.chunk.length;r=this.skipGapsTo(s,r,-1),s+=r,a+=this.chunk.length-l}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&a==4&&o>=0&&this.chunk[o]==e&&this.chunk[o+2]==t?this.chunk[o+2]=s:this.chunk.push(e,t,s,a),r}parseLine(e){let{line:t,end:s}=this.nextLine(),r=0,{streamParser:a}=this.lang,o=new Tdt(t,e?e.state.tabSize:4,e?I1(e.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let l=Mdt(a.token,o,this.state);if(l&&(r=this.emitToken(this.lang.tokenTable.resolve(l),this.parsedPos+o.start,this.parsedPos+o.pos,r)),o.start>1e4)break}this.parsedPos=s,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=kc.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:shn,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new kc(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new kc(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Mdt(e,t,s){t.start=t.pos;for(let r=0;r<10;r++){let a=e(t,s);if(t.pos>t.start)return a}throw new Error("Stream parser failed to advance stream.")}i(Mdt,"readToken");var qve=Object.create(null),TL=[B0.none],shn=new Ton(TL),VTe=[],HTe=Object.create(null),Ldt=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Ldt[e]=Pdt(qve,t);var Ddt=class{static{i(this,"TokenTable")}constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Ldt)}resolve(e){return e?this.table[e]||(this.table[e]=Pdt(this.extra,e)):0}},rhn=new Ddt(qve);function HX(e,t){VTe.indexOf(e)>-1||VTe.push(e)}i(HX,"warnForPart");function Pdt(e,t){let s=[];for(let c of t.split(" ")){let d=[];for(let u of c.split(".")){let h=e[u]||mn[u];h?typeof h=="function"?d.length?d=d.map(h):HX(u,`Modifier ${u} used at start of tag`):d.length?HX(u,`Tag ${u} used as modifier`):d=Array.isArray(h)?h:[h]:HX(u,`Unknown highlighting tag ${u}`)}for(let u of d)s.push(u)}if(!s.length)return 0;let r=t.replace(/ /g,"_"),a=r+" "+s.map(c=>c.id),o=HTe[a];if(o)return o.id;let l=HTe[a]=B0.define({id:TL.length,name:r,props:[aun({[r]:s})]});return TL.push(l),l.id}i(Pdt,"createTokenType");function ihn(e,t){let s=B0.define({id:TL.length,name:"Document",props:[OC.add(()=>e),pdt.add(()=>r=>t.getIndent(r))],top:!0});return TL.push(s),s}i(ihn,"docID");var y9s={rtl:Ui.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:ql.RTL}),ltr:Ui.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:ql.LTR}),auto:Ui.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};function Gn(e){return new pun(ehn.define(e))}i(Gn,"legacy");function Pw(e){return ln(()=>import("./dist-Dmjj6qqj.js").then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([0,1,2]))}i(Pw,"sql");var ahn=[cn.of({name:"C",extensions:["c","h","ino"],load(){return ln(()=>import("./dist-BOfv8ix1.js").then(e=>e.cpp()),__vite__mapDeps([3,2]))}}),cn.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return ln(()=>import("./dist-BOfv8ix1.js").then(e=>e.cpp()),__vite__mapDeps([3,2]))}}),cn.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Pw("Cassandra")}}),cn.of({name:"CSS",extensions:["css"],load(){return ln(()=>import("./dist-BM1c6ixo.js").then(e=>e.i).then(e=>e.css()),__vite__mapDeps([4,5,2]))}}),cn.of({name:"Go",extensions:["go"],load(){return ln(()=>import("./dist-BlfE4iqp.js").then(e=>e.go()),__vite__mapDeps([6,1,2]))}}),cn.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return ln(()=>import("./dist-Do3PUu3w.js").then(e=>e.html()),__vite__mapDeps([7,2,4,5,8,1]))}}),cn.of({name:"Java",extensions:["java"],load(){return ln(()=>import("./dist-CfUv27eg.js").then(e=>e.java()),__vite__mapDeps([9,2]))}}),cn.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return ln(()=>import("./dist-B8zM63sM.js").then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,5,1,2]))}}),cn.of({name:"Jinja",extensions:["j2","jinja","jinja2"],load(){return ln(()=>import("./dist-B0W7Yi42.js").then(e=>e.jinja()),__vite__mapDeps([10,2,7,4,5,8,1]))}}),cn.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return ln(()=>import("./dist-DeYTUba7.js").then(e=>e.json()),__vite__mapDeps([11,2]))}}),cn.of({name:"JSX",extensions:["jsx"],load(){return ln(()=>import("./dist-B8zM63sM.js").then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([8,5,1,2]))}}),cn.of({name:"LESS",extensions:["less"],load(){return ln(()=>import("./dist-8AduNOQx.js").then(e=>e.less()),__vite__mapDeps([12,2,4,5]))}}),cn.of({name:"Liquid",extensions:["liquid"],load(){return ln(()=>import("./dist-DTvLpQIg.js").then(e=>e.liquid()),__vite__mapDeps([13,2,7,4,5,8,1]))}}),cn.of({name:"MariaDB SQL",load(){return Pw("MariaSQL")}}),cn.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return ln(()=>import("./dist-B6VGqBMw.js").then(e=>e.markdown()),__vite__mapDeps([14,1,7,2,4,5,8]))}}),cn.of({name:"MS SQL",load(){return Pw("MSSQL")}}),cn.of({name:"MySQL",load(){return Pw("MySQL")}}),cn.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return ln(()=>import("./dist-CGwpvx3Z.js").then(e=>e.php()),__vite__mapDeps([15,2,7,4,5,8,1]))}}),cn.of({name:"PLSQL",extensions:["pls"],load(){return Pw("PLSQL")}}),cn.of({name:"PostgreSQL",load(){return Pw("PostgreSQL")}}),cn.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return ln(()=>import("./dist-DMD4VbFv.js").then(e=>e.python()),__vite__mapDeps([16,1,2]))}}),cn.of({name:"Rust",extensions:["rs"],load(){return ln(()=>import("./dist-BxPHMXlf.js").then(e=>e.rust()),__vite__mapDeps([17,2]))}}),cn.of({name:"Sass",extensions:["sass"],load(){return ln(()=>import("./dist-DtHqErgw.js").then(e=>e.sass({indented:!0})),__vite__mapDeps([18,2,4,5]))}}),cn.of({name:"SCSS",extensions:["scss"],load(){return ln(()=>import("./dist-DtHqErgw.js").then(e=>e.sass()),__vite__mapDeps([18,2,4,5]))}}),cn.of({name:"SQL",extensions:["sql"],load(){return Pw("StandardSQL")}}),cn.of({name:"SQLite",load(){return Pw("SQLite")}}),cn.of({name:"TSX",extensions:["tsx"],load(){return ln(()=>import("./dist-B8zM63sM.js").then(e=>e.t).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([8,5,1,2]))}}),cn.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return ln(()=>import("./dist-B8zM63sM.js").then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,5,1,2]))}}),cn.of({name:"WebAssembly",extensions:["wat","wast"],load(){return ln(()=>import("./dist-CcZe9JAO.js").then(e=>e.wast()),__vite__mapDeps([19,2]))}}),cn.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return ln(()=>import("./dist-C_VeG_Q6.js").then(e=>e.xml()),__vite__mapDeps([20,2]))}}),cn.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return ln(()=>import("./dist-BIH3XOAA.js").then(e=>e.yaml()),__vite__mapDeps([21,2]))}}),cn.of({name:"APL",extensions:["dyalog","apl"],load(){return ln(()=>import("./apl-MHzTCvfx.js").then(e=>Gn(e.apl)),[])}}),cn.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return ln(()=>import("./asciiarmor-DFLNSgns.js").then(e=>Gn(e.asciiArmor)),[])}}),cn.of({name:"ASN.1",extensions:["asn","asn1"],load(){return ln(()=>import("./asn1-CfPVWRYE.js").then(e=>Gn(e.asn1({}))),[])}}),cn.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return ln(()=>import("./asterisk-CJ4OeA7Y.js").then(e=>Gn(e.asterisk)),[])}}),cn.of({name:"Brainfuck",extensions:["b","bf"],load(){return ln(()=>import("./brainfuck-NEHkmXMc.js").then(e=>Gn(e.brainfuck)),[])}}),cn.of({name:"Cobol",extensions:["cob","cpy"],load(){return ln(()=>import("./cobol-Bo8Zw9gB.js").then(e=>Gn(e.cobol)),[])}}),cn.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return ln(()=>import("./clike-CIx9nZSv.js").then(e=>Gn(e.csharp)),[])}}),cn.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return ln(()=>import("./clojure-DFaIEz5O.js").then(e=>Gn(e.clojure)),[])}}),cn.of({name:"ClojureScript",extensions:["cljs"],load(){return ln(()=>import("./clojure-DFaIEz5O.js").then(e=>Gn(e.clojure)),[])}}),cn.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return ln(()=>import("./css-DEZwfVpY.js").then(e=>Gn(e.gss)),[])}}),cn.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return ln(()=>import("./cmake-koz-qBlo.js").then(e=>Gn(e.cmake)),[])}}),cn.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return ln(()=>import("./coffeescript-CXYzYf-Y.js").then(e=>Gn(e.coffeeScript)),[])}}),cn.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return ln(()=>import("./commonlisp-C4OOCwkD.js").then(e=>Gn(e.commonLisp)),[])}}),cn.of({name:"Cypher",extensions:["cyp","cypher"],load(){return ln(()=>import("./cypher-z2oFsVv2.js").then(e=>Gn(e.cypher)),[])}}),cn.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return ln(()=>import("./python-C2DOnsac.js").then(e=>Gn(e.cython)),[])}}),cn.of({name:"Crystal",extensions:["cr"],load(){return ln(()=>import("./crystal-BlJXQDvy.js").then(e=>Gn(e.crystal)),[])}}),cn.of({name:"D",extensions:["d"],load(){return ln(()=>import("./d-Dkt6y7AQ.js").then(e=>Gn(e.d)),[])}}),cn.of({name:"Dart",extensions:["dart"],load(){return ln(()=>import("./clike-CIx9nZSv.js").then(e=>Gn(e.dart)),[])}}),cn.of({name:"diff",extensions:["diff","patch"],load(){return ln(()=>import("./diff-C60bAYOU.js").then(e=>Gn(e.diff)),[])}}),cn.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return ln(()=>import("./dockerfile-BttNdtK0.js").then(e=>Gn(e.dockerFile)),__vite__mapDeps([22,23]))}}),cn.of({name:"DTD",extensions:["dtd"],load(){return ln(()=>import("./dtd-CCVZU5Da.js").then(e=>Gn(e.dtd)),[])}}),cn.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return ln(()=>import("./dylan-3pmV5wzs.js").then(e=>Gn(e.dylan)),[])}}),cn.of({name:"EBNF",load(){return ln(()=>import("./ebnf-bm-I2WIh.js").then(e=>Gn(e.ebnf)),[])}}),cn.of({name:"ECL",extensions:["ecl"],load(){return ln(()=>import("./ecl-BIv3PrZb.js").then(e=>Gn(e.ecl)),[])}}),cn.of({name:"edn",extensions:["edn"],load(){return ln(()=>import("./clojure-DFaIEz5O.js").then(e=>Gn(e.clojure)),[])}}),cn.of({name:"Eiffel",extensions:["e"],load(){return ln(()=>import("./eiffel-DuLnr4-r.js").then(e=>Gn(e.eiffel)),[])}}),cn.of({name:"Elm",extensions:["elm"],load(){return ln(()=>import("./elm-njbaCU-L.js").then(e=>Gn(e.elm)),[])}}),cn.of({name:"Erlang",extensions:["erl"],load(){return ln(()=>import("./erlang-CuhOC2I8.js").then(e=>Gn(e.erlang)),[])}}),cn.of({name:"Esper",load(){return ln(()=>import("./sql-C3kWxFGw.js").then(e=>Gn(e.esper)),[])}}),cn.of({name:"Factor",extensions:["factor"],load(){return ln(()=>import("./factor-CM3-9V3b.js").then(e=>Gn(e.factor)),__vite__mapDeps([24,23]))}}),cn.of({name:"FCL",load(){return ln(()=>import("./fcl-nWsMJ92o.js").then(e=>Gn(e.fcl)),[])}}),cn.of({name:"Forth",extensions:["forth","fth","4th"],load(){return ln(()=>import("./forth-BQ9HrCVY.js").then(e=>Gn(e.forth)),[])}}),cn.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return ln(()=>import("./fortran-DHJe28ev.js").then(e=>Gn(e.fortran)),[])}}),cn.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return ln(()=>import("./mllike-DuNQsEw8.js").then(e=>Gn(e.fSharp)),[])}}),cn.of({name:"Gas",extensions:["s"],load(){return ln(()=>import("./gas-ByO0qYMr.js").then(e=>Gn(e.gas)),[])}}),cn.of({name:"Gherkin",extensions:["feature"],load(){return ln(()=>import("./gherkin-CwOmHL5K.js").then(e=>Gn(e.gherkin)),[])}}),cn.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return ln(()=>import("./groovy-ByXGF8cx.js").then(e=>Gn(e.groovy)),[])}}),cn.of({name:"Haskell",extensions:["hs"],load(){return ln(()=>import("./haskell-CHSpCNOy.js").then(e=>Gn(e.haskell)),[])}}),cn.of({name:"Haxe",extensions:["hx"],load(){return ln(()=>import("./haxe-P2jh68ck.js").then(e=>Gn(e.haxe)),[])}}),cn.of({name:"HXML",extensions:["hxml"],load(){return ln(()=>import("./haxe-P2jh68ck.js").then(e=>Gn(e.hxml)),[])}}),cn.of({name:"HTTP",load(){return ln(()=>import("./http-0jwMmfWP.js").then(e=>Gn(e.http)),[])}}),cn.of({name:"IDL",extensions:["pro"],load(){return ln(()=>import("./idl-DTVVj6r5.js").then(e=>Gn(e.idl)),[])}}),cn.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return ln(()=>import("./javascript-Cblpdx44.js").then(e=>Gn(e.jsonld)),[])}}),cn.of({name:"Julia",extensions:["jl"],load(){return ln(()=>import("./julia-KVJvUu_F.js").then(e=>Gn(e.julia)),[])}}),cn.of({name:"Kotlin",extensions:["kt","kts"],load(){return ln(()=>import("./clike-CIx9nZSv.js").then(e=>Gn(e.kotlin)),[])}}),cn.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return ln(()=>import("./livescript-DSHsJPcD.js").then(e=>Gn(e.liveScript)),[])}}),cn.of({name:"Lua",extensions:["lua"],load(){return ln(()=>import("./lua-Vher-70I.js").then(e=>Gn(e.lua)),[])}}),cn.of({name:"mIRC",extensions:["mrc"],load(){return ln(()=>import("./mirc-BGWbO906.js").then(e=>Gn(e.mirc)),[])}}),cn.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return ln(()=>import("./mathematica-CE9SaVsW.js").then(e=>Gn(e.mathematica)),[])}}),cn.of({name:"Modelica",extensions:["mo"],load(){return ln(()=>import("./modelica-5XCgKQt8.js").then(e=>Gn(e.modelica)),[])}}),cn.of({name:"MUMPS",extensions:["mps"],load(){return ln(()=>import("./mumps-C7oS353s.js").then(e=>Gn(e.mumps)),[])}}),cn.of({name:"Mbox",extensions:["mbox"],load(){return ln(()=>import("./mbox-JGl1Fgvq.js").then(e=>Gn(e.mbox)),[])}}),cn.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return ln(()=>import("./nginx-DXVlpyCz.js").then(e=>Gn(e.nginx)),[])}}),cn.of({name:"NSIS",extensions:["nsh","nsi"],load(){return ln(()=>import("./nsis-KFC6hioG.js").then(e=>Gn(e.nsis)),__vite__mapDeps([25,23]))}}),cn.of({name:"NTriples",extensions:["nt","nq"],load(){return ln(()=>import("./ntriples-5ckCopnn.js").then(e=>Gn(e.ntriples)),[])}}),cn.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return ln(()=>import("./clike-CIx9nZSv.js").then(e=>Gn(e.objectiveC)),[])}}),cn.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return ln(()=>import("./clike-CIx9nZSv.js").then(e=>Gn(e.objectiveCpp)),[])}}),cn.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return ln(()=>import("./mllike-DuNQsEw8.js").then(e=>Gn(e.oCaml)),[])}}),cn.of({name:"Octave",extensions:["m"],load(){return ln(()=>import("./octave-D1J2QQNt.js").then(e=>Gn(e.octave)),[])}}),cn.of({name:"Oz",extensions:["oz"],load(){return ln(()=>import("./oz-CPsllMDD.js").then(e=>Gn(e.oz)),[])}}),cn.of({name:"Pascal",extensions:["p","pas"],load(){return ln(()=>import("./pascal-B-I6JP0Y.js").then(e=>Gn(e.pascal)),[])}}),cn.of({name:"Perl",extensions:["pl","pm"],load(){return ln(()=>import("./perl-CI8WIWBi.js").then(e=>Gn(e.perl)),[])}}),cn.of({name:"Pig",extensions:["pig"],load(){return ln(()=>import("./pig-FQI0W3S3.js").then(e=>Gn(e.pig)),[])}}),cn.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return ln(()=>import("./powershell-BAu6x78A.js").then(e=>Gn(e.powerShell)),[])}}),cn.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return ln(()=>import("./properties-BKTTDgau.js").then(e=>Gn(e.properties)),[])}}),cn.of({name:"ProtoBuf",extensions:["proto"],load(){return ln(()=>import("./protobuf-UWh8gh_j.js").then(e=>Gn(e.protobuf)),[])}}),cn.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return ln(()=>import("./pug-C20tNwmy.js").then(e=>Gn(e.pug)),__vite__mapDeps([26,27]))}}),cn.of({name:"Puppet",extensions:["pp"],load(){return ln(()=>import("./puppet-BAHVzCkO.js").then(e=>Gn(e.puppet)),[])}}),cn.of({name:"Q",extensions:["q"],load(){return ln(()=>import("./q-Cooe-Nh8.js").then(e=>Gn(e.q)),[])}}),cn.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return ln(()=>import("./r-CktBKya9.js").then(e=>Gn(e.r)),[])}}),cn.of({name:"RPM Changes",load(){return ln(()=>import("./rpm-Csj9nLHl.js").then(e=>Gn(e.rpmChanges)),[])}}),cn.of({name:"RPM Spec",extensions:["spec"],load(){return ln(()=>import("./rpm-Csj9nLHl.js").then(e=>Gn(e.rpmSpec)),[])}}),cn.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return ln(()=>import("./ruby-bGx9eo-K.js").then(e=>Gn(e.ruby)),[])}}),cn.of({name:"SAS",extensions:["sas"],load(){return ln(()=>import("./sas-Drou_EQ9.js").then(e=>Gn(e.sas)),[])}}),cn.of({name:"Scala",extensions:["scala"],load(){return ln(()=>import("./clike-CIx9nZSv.js").then(e=>Gn(e.scala)),[])}}),cn.of({name:"Scheme",extensions:["scm","ss"],load(){return ln(()=>import("./scheme-DcjG9bAf.js").then(e=>Gn(e.scheme)),[])}}),cn.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return ln(()=>import("./shell-BSKClwid.js").then(e=>Gn(e.shell)),[])}}),cn.of({name:"Sieve",extensions:["siv","sieve"],load(){return ln(()=>import("./sieve-CcvsXPZo.js").then(e=>Gn(e.sieve)),[])}}),cn.of({name:"Smalltalk",extensions:["st"],load(){return ln(()=>import("./smalltalk-Cmg-4mjQ.js").then(e=>Gn(e.smalltalk)),[])}}),cn.of({name:"Solr",load(){return ln(()=>import("./solr-Dj8ahEwG.js").then(e=>Gn(e.solr)),[])}}),cn.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return ln(()=>import("./mllike-DuNQsEw8.js").then(e=>Gn(e.sml)),[])}}),cn.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return ln(()=>import("./sparql-LAJYmgfk.js").then(e=>Gn(e.sparql)),[])}}),cn.of({name:"Spreadsheet",alias:["excel","formula"],load(){return ln(()=>import("./spreadsheet-B8doD_pL.js").then(e=>Gn(e.spreadsheet)),[])}}),cn.of({name:"Squirrel",extensions:["nut"],load(){return ln(()=>import("./clike-CIx9nZSv.js").then(e=>Gn(e.squirrel)),[])}}),cn.of({name:"Stylus",extensions:["styl"],load(){return ln(()=>import("./stylus-BS-Ienrc.js").then(e=>Gn(e.stylus)),[])}}),cn.of({name:"Swift",extensions:["swift"],load(){return ln(()=>import("./swift-BD82LMDK.js").then(e=>Gn(e.swift)),[])}}),cn.of({name:"sTeX",load(){return ln(()=>import("./stex-CW6K5Nmu.js").then(e=>Gn(e.stex)),[])}}),cn.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return ln(()=>import("./stex-CW6K5Nmu.js").then(e=>Gn(e.stex)),[])}}),cn.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return ln(()=>import("./verilog-BVYlmXGg.js").then(e=>Gn(e.verilog)),[])}}),cn.of({name:"Tcl",extensions:["tcl"],load(){return ln(()=>import("./tcl-RZa1cqc-.js").then(e=>Gn(e.tcl)),[])}}),cn.of({name:"Textile",extensions:["textile"],load(){return ln(()=>import("./textile-C-BY_OGF.js").then(e=>Gn(e.textile)),[])}}),cn.of({name:"TiddlyWiki",load(){return ln(()=>import("./tiddlywiki-C9bm_Oju.js").then(e=>Gn(e.tiddlyWiki)),[])}}),cn.of({name:"Tiki wiki",load(){return ln(()=>import("./tiki-DJOT-rFT.js").then(e=>Gn(e.tiki)),[])}}),cn.of({name:"TOML",extensions:["toml"],load(){return ln(()=>import("./toml-Civ2fTsu.js").then(e=>Gn(e.toml)),[])}}),cn.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return ln(()=>import("./troff-Lns35Xcq.js").then(e=>Gn(e.troff)),[])}}),cn.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return ln(()=>import("./ttcn-7vlxVTUK.js").then(e=>Gn(e.ttcn)),[])}}),cn.of({name:"TTCN_CFG",extensions:["cfg"],load(){return ln(()=>import("./ttcn-cfg-B8qhhp6o.js").then(e=>Gn(e.ttcnCfg)),[])}}),cn.of({name:"Turtle",extensions:["ttl"],load(){return ln(()=>import("./turtle-DTIS1YQ7.js").then(e=>Gn(e.turtle)),[])}}),cn.of({name:"Web IDL",extensions:["webidl"],load(){return ln(()=>import("./webidl-ChvzbZ5-.js").then(e=>Gn(e.webIDL)),[])}}),cn.of({name:"VB.NET",extensions:["vb"],load(){return ln(()=>import("./vb-BO8UacKu.js").then(e=>Gn(e.vb)),[])}}),cn.of({name:"VBScript",extensions:["vbs"],load(){return ln(()=>import("./vbscript-DWLru3lT.js").then(e=>Gn(e.vbScript)),[])}}),cn.of({name:"Velocity",extensions:["vtl"],load(){return ln(()=>import("./velocity-BIIn-Nl2.js").then(e=>Gn(e.velocity)),[])}}),cn.of({name:"Verilog",extensions:["v"],load(){return ln(()=>import("./verilog-BVYlmXGg.js").then(e=>Gn(e.verilog)),[])}}),cn.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return ln(()=>import("./vhdl-Cn8cC8Yb.js").then(e=>Gn(e.vhdl)),[])}}),cn.of({name:"XQuery",extensions:["xy","xquery","xq","xqm","xqy"],load(){return ln(()=>import("./xquery-BKN7qEbU.js").then(e=>Gn(e.xQuery)),[])}}),cn.of({name:"Yacas",extensions:["ys"],load(){return ln(()=>import("./yacas-BG9ha7tU.js").then(e=>Gn(e.yacas)),[])}}),cn.of({name:"Z80",extensions:["z80"],load(){return ln(()=>import("./z80-CB2cGLew.js").then(e=>Gn(e.z80)),[])}}),cn.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return ln(()=>import("./mscgen-mVFg19ri.js").then(e=>Gn(e.mscgen)),[])}}),cn.of({name:"Xù",extensions:["xu"],load(){return ln(()=>import("./mscgen-mVFg19ri.js").then(e=>Gn(e.xu)),[])}}),cn.of({name:"MsGenny",extensions:["msgenny"],load(){return ln(()=>import("./mscgen-mVFg19ri.js").then(e=>Gn(e.msgenny)),[])}}),cn.of({name:"Vue",extensions:["vue"],load(){return ln(()=>import("./dist-Ca2ao84r.js").then(e=>e.vue()),__vite__mapDeps([28,2,8,5,1,7,4]))}}),cn.of({name:"Angular Template",load(){return ln(()=>import("./dist-BlthiXtb.js").then(e=>e.angular()),__vite__mapDeps([29,2,8,5,1,7,4]))}})],GTe=Eb.define(),ohn=Rr.define(),EL=class xR{static{i(this,"HistEvent$1")}constructor(t,s,r,a,o){this.changes=t,this.effects=s,this.mapped=r,this.startSelection=a,this.selectionsAfter=o}setSelAfter(t){return new xR(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,s,r;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(s=this.mapped)===null||s===void 0?void 0:s.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(a=>a.toJSON())}}static fromJSON(t){return new xR(t.changes&&ag.fromJSON(t.changes),[],t.mapped&&m3.fromJSON(t.mapped),t.startSelection&&Qn.fromJSON(t.startSelection),t.selectionsAfter.map(Qn.fromJSON))}static fromTransaction(t,s){let r=Lf;for(let a of t.startState.facet(ohn)){let o=a(t);o.length&&(r=r.concat(o))}return!r.length&&t.changes.empty?null:new xR(t.changes.invert(t.startState.doc),r,void 0,s||t.startState.selection,Lf)}static selection(t){return new xR(void 0,Lf,void 0,void 0,t)}};function Kle(e,t,s,r){let a=t+1>s+20?t-s-1:0,o=e.slice(a,t);return o.push(r),o}i(Kle,"updateBranch$1");function lhn(e,t){let s=[],r=!1;return e.iterChangedRanges((a,o)=>s.push(a,o)),t.iterChangedRanges((a,o,l,c)=>{for(let d=0;d<s.length;){let u=s[d++],h=s[d++];c>=u&&l<=h&&(r=!0)}}),r}i(lhn,"isAdjacent$1");function chn(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((s,r)=>s.empty!=t.ranges[r].empty).length===0}i(chn,"eqSelectionShape$1");function $dt(e,t){return e.length?t.length?e.concat(t):e:t}i($dt,"conc$1");var Lf=[],dhn=200;function uhn(e,t){if(e.length){let s=e[e.length-1],r=s.selectionsAfter.slice(Math.max(0,s.selectionsAfter.length-dhn));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),Kle(e,e.length-1,1e9,s.setSelAfter(r)))}else return[EL.selection([t])]}i(uhn,"addSelection$1");function hhn(e){let t=e[e.length-1],s=e.slice();return s[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),s}i(hhn,"popSelection$1");function GX(e,t){if(!e.length)return e;let s=e.length,r=Lf;for(;s;){let a=mhn(e[s-1],t,r);if(a.changes&&!a.changes.empty||a.effects.length){let o=e.slice(0,s);return o[s-1]=a,o}else t=a.mapped,s--,r=a.selectionsAfter}return r.length?[EL.selection(r)]:Lf}i(GX,"addMappingToBranch$1");function mhn(e,t,s){let r=$dt(e.selectionsAfter.length?e.selectionsAfter.map(c=>c.map(t)):Lf,s);if(!e.changes)return EL.selection(r);let a=e.changes.map(t),o=t.mapDesc(e.changes,!0),l=e.mapped?e.mapped.composeDesc(o):o;return new EL(a,pa.mapEffects(e.effects,t),l,e.startSelection.map(o),r)}i(mhn,"mapEvent$1");var phn=/^(input\.type|delete)($|\.)/,YTe=class vR{static{i(this,"HistoryState$1")}constructor(t,s,r=0,a=void 0){this.done=t,this.undone=s,this.prevTime=r,this.prevUserEvent=a}isolate(){return this.prevTime?new vR(this.done,this.undone):this}addChanges(t,s,r,a,o){let l=this.done,c=l[l.length-1];return c&&c.changes&&!c.changes.empty&&t.changes&&(!r||phn.test(r))&&(!c.selectionsAfter.length&&s-this.prevTime<a.newGroupDelay&&a.joinToEvent(o,lhn(c.changes,t.changes))||r=="input.type.compose")?l=Kle(l,l.length-1,a.minDepth,new EL(t.changes.compose(c.changes),$dt(pa.mapEffects(t.effects,c.changes),c.effects),c.mapped,c.startSelection,Lf)):l=Kle(l,l.length,a.minDepth,t),new vR(l,Lf,s,r)}addSelection(t,s,r,a){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:Lf;return o.length>0&&s-this.prevTime<a&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&chn(o[o.length-1],t)?this:new vR(uhn(this.done,t),this.undone,s,r)}addMapping(t){return new vR(GX(this.done,t),GX(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,s,r){let a=t==0?this.done:this.undone;if(a.length==0)return null;let o=a[a.length-1],l=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):s.selection);if(r&&o.selectionsAfter.length)return s.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:GTe.of({side:t,rest:hhn(a),selection:l}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let c=a.length==1?Lf:a.slice(0,a.length-1);return o.mapped&&(c=GX(c,o.mapped)),s.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:GTe.of({side:t,rest:c,selection:l}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}};YTe.empty=new YTe(Lf,Lf);var k9s=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Odt(e,t){let s=-1;return e.changeByRange(r=>{let a=[];for(let l=r.from;l<=r.to;){let c=e.doc.lineAt(l);c.number>s&&(r.empty||r.to>c.from)&&(t(c,a,r),s=c.number),l=c.to+1}let o=e.changes(a);return{changes:a,range:Qn.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}i(Odt,"changeBySelectedLine$1");var fhn=i(({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Odt(e,(s,r)=>{r.push({from:s.from,insert:e.facet(PH)})}),{userEvent:"input.indent"})),!0),"indentMore$1"),ghn=i(({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Odt(e,(s,r)=>{let a=/^\s*/.exec(s.text)[0];if(!a)return;let o=JS(a,e.tabSize),l=0,c=hI(e,Math.max(0,o-I1(e)));for(;l<a.length&&l<c.length&&a.charCodeAt(l)==c.charCodeAt(l);)l++;r.push({from:s.from+l,to:s.from+a.length,insert:c.slice(l)})}),{userEvent:"delete.dedent"})),!0),"indentLess$1"),xhn={key:"Tab",run:fhn,shift:ghn},JTe="#2e3440",Uve="#3b4252",ZTe="#434c5e",o$="#4c566a",XTe="#e5e9f0",Wle="#eceff4",YX="#8fbcbb",e4e="#88c0d0",vhn="#81a1c1",kg="#5e81ac",bhn="#bf616a",X_="#d08770",JX="#ebcb8b",t4e="#a3be8c",yhn="#b48ead",n4e="#d30102",Kve=Wle,ZX=Kve,khn="#ffffff",XX=Uve,whn=Kve,s4e=Uve,jhn=Br.theme({"&":{color:JTe,backgroundColor:khn},".cm-content":{caretColor:s4e},".cm-cursor, .cm-dropCursor":{borderLeftColor:s4e},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:whn},".cm-panels":{backgroundColor:Kve,color:o$},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:`1px solid ${o$}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:XTe},".cm-activeLine":{backgroundColor:ZX},".cm-selectionMatch":{backgroundColor:XTe},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${o$}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:Wle},".cm-gutters":{backgroundColor:Wle,color:JTe,border:"none"},".cm-activeLineGutter":{backgroundColor:ZX},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:XX},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:XX,borderBottomColor:XX},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:ZX,color:o$}}},{dark:!1}),Nhn=Bve.define([{tag:mn.keyword,color:kg},{tag:[mn.name,mn.deleted,mn.character,mn.propertyName,mn.macroName],color:X_},{tag:[mn.variableName],color:X_},{tag:[mn.function(mn.variableName)],color:kg},{tag:[mn.labelName],color:vhn},{tag:[mn.color,mn.constant(mn.name),mn.standard(mn.name)],color:kg},{tag:[mn.definition(mn.name),mn.separator],color:t4e},{tag:[mn.brace],color:YX},{tag:[mn.annotation],color:n4e},{tag:[mn.number,mn.changed,mn.annotation,mn.modifier,mn.self,mn.namespace],color:e4e},{tag:[mn.typeName,mn.className],color:JX},{tag:[mn.operator,mn.operatorKeyword],color:t4e},{tag:[mn.tagName],color:yhn},{tag:[mn.squareBracket],color:bhn},{tag:[mn.angleBracket],color:X_},{tag:[mn.attributeName],color:JX},{tag:[mn.regexp],color:kg},{tag:[mn.quote],color:Uve},{tag:[mn.string],color:X_},{tag:mn.link,color:YX,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[mn.url,mn.escape,mn.special(mn.string)],color:X_},{tag:[mn.meta],color:e4e},{tag:[mn.comment],color:ZTe,fontStyle:"italic"},{tag:mn.strong,fontWeight:"bold",color:kg},{tag:mn.emphasis,fontStyle:"italic",color:kg},{tag:mn.strikethrough,textDecoration:"line-through"},{tag:mn.heading,fontWeight:"bold",color:kg},{tag:mn.special(mn.heading1),fontWeight:"bold",color:kg},{tag:mn.heading1,fontWeight:"bold",color:kg},{tag:[mn.heading2,mn.heading3,mn.heading4],fontWeight:"bold",color:kg},{tag:[mn.heading5,mn.heading6],color:kg},{tag:[mn.atom,mn.bool,mn.special(mn.variableName)],color:X_},{tag:[mn.processingInstruction,mn.inserted],color:YX},{tag:[mn.contentSeparator],color:JX},{tag:mn.invalid,color:ZTe,borderBottom:`1px dotted ${n4e}`}]),Chn=[jhn,Sdt(Nhn)],Shn=i(e=>{let{state:t}=e,s=t.doc.lineAt(t.selection.main.from),r=Qve(e.state,s.from);return r.line?_hn(e):r.block?Ihn(e):!1},"toggleComment");function Wve(e,t){return({state:s,dispatch:r})=>{if(s.readOnly)return!1;let a=e(t,s);return a?(r(s.update(a)),!0):!1}}i(Wve,"command");var _hn=Wve(Rhn,0),Ahn=Wve(Fdt,0),Ihn=Wve((e,t)=>Fdt(e,t,Ehn(t)),0);function Qve(e,t){let s=e.languageDataAt("commentTokens",t,1);return s.length?s[0]:{}}i(Qve,"getConfig");var l$=50;function Thn(e,{open:t,close:s},r,a){let o=e.sliceDoc(r-l$,r),l=e.sliceDoc(a,a+l$),c=/\s*$/.exec(o)[0].length,d=/^\s*/.exec(l)[0].length,u=o.length-c;if(o.slice(u-t.length,u)==t&&l.slice(d,d+s.length)==s)return{open:{pos:r-c,margin:c&&1},close:{pos:a+d,margin:d&&1}};let h,p;a-r<=100?h=p=e.sliceDoc(r,a):(h=e.sliceDoc(r,r+l$),p=e.sliceDoc(a-l$,a));let f=/^\s*/.exec(h)[0].length,g=/\s*$/.exec(p)[0].length,x=p.length-g-s.length;return h.slice(f,f+t.length)==t&&p.slice(x,x+s.length)==s?{open:{pos:r+f+t.length,margin:/\s/.test(h.charAt(f+t.length))?1:0},close:{pos:a-g-s.length,margin:/\s/.test(p.charAt(x-1))?1:0}}:null}i(Thn,"findBlockComment");function Ehn(e){let t=[];for(let s of e.selection.ranges){let r=e.doc.lineAt(s.from),a=s.to<=r.to?r:e.doc.lineAt(s.to);a.from>r.from&&a.from==s.to&&(a=s.to==r.to+1?r:e.doc.lineAt(s.to-1));let o=t.length-1;o>=0&&t[o].to>r.from?t[o].to=a.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:a.to})}return t}i(Ehn,"selectedLineRanges");function Fdt(e,t,s=t.selection.ranges){let r=s.map(o=>Qve(t,o.from).block);if(!r.every(o=>o))return null;let a=s.map((o,l)=>Thn(t,r[l],o.from,o.to));if(e!=2&&!a.every(o=>o))return{changes:t.changes(s.map((o,l)=>a[l]?[]:[{from:o.from,insert:r[l].open+" "},{from:o.to,insert:" "+r[l].close}]))};if(e!=1&&a.some(o=>o)){let o=[];for(let l=0,c;l<a.length;l++)if(c=a[l]){let d=r[l],{open:u,close:h}=c;o.push({from:u.pos-d.open.length,to:u.pos+u.margin},{from:h.pos-h.margin,to:h.pos+d.close.length})}return{changes:o}}return null}i(Fdt,"changeBlockComment");function Rhn(e,t,s=t.selection.ranges){let r=[],a=-1;e:for(let{from:o,to:l}of s){let c=r.length,d=1e9,u;for(let h=o;h<=l;){let p=t.doc.lineAt(h);if(u==null&&(u=Qve(t,p.from).line,!u))continue e;if(p.from>a&&(o==l||l>p.from)){a=p.from;let f=/^\s*/.exec(p.text)[0].length,g=f==p.length,x=p.text.slice(f,f+u.length)==u?f:-1;f<p.text.length&&f<d&&(d=f),r.push({line:p,comment:x,token:u,indent:f,empty:g,single:!1})}h=p.to+1}if(d<1e9)for(let h=c;h<r.length;h++)r[h].indent<r[h].line.text.length&&(r[h].indent=d);r.length==c+1&&(r[c].single=!0)}if(e!=2&&r.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:c,token:d,indent:u,empty:h,single:p}of r)(p||!h)&&o.push({from:c.from+u,insert:d+" "});let l=t.changes(o);return{changes:l,selection:t.selection.map(l,1)}}else if(e!=1&&r.some(o=>o.comment>=0)){let o=[];for(let{line:l,comment:c,token:d}of r)if(c>=0){let u=l.from+c,h=u+d.length;l.text[h-l.from]==" "&&h++,o.push({from:u,to:h})}return{changes:o}}return null}i(Rhn,"changeLineComment");var Qle=Eb.define(),Mhn=Eb.define(),Lhn=Rr.define(),Bdt=Rr.define({combine(e){return Rb(e,{minDepth:100,newGroupDelay:500,joinToEvent:i((t,s)=>s,"joinToEvent")},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:i((t,s)=>(r,a)=>t(r,a)||s(r,a),"joinToEvent")})}}),zdt=zp.define({create(){return R6.empty},update(e,t){let s=t.state.facet(Bdt),r=t.annotation(Qle);if(r){let d=Qy.fromTransaction(t,r.selection),u=r.side,h=u==0?e.undone:e.done;return d?h=nK(h,h.length,s.minDepth,d):h=Kdt(h,t.startState.selection),new R6(u==0?r.rest:h,u==0?h:r.rest)}let a=t.annotation(Mhn);if((a=="full"||a=="before")&&(e=e.isolate()),t.annotation(Sp.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let o=Qy.fromTransaction(t),l=t.annotation(Sp.time),c=t.annotation(Sp.userEvent);return o?e=e.addChanges(o,l,c,s,t):t.selection&&(e=e.addSelection(t.startState.selection,l,c,s.newGroupDelay)),(a=="full"||a=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new R6(e.done.map(Qy.fromJSON),e.undone.map(Qy.fromJSON))}});function Dhn(e={}){return[zdt,Bdt.of(e),Br.domEventHandlers({beforeinput(t,s){let r=t.inputType=="historyUndo"?qdt:t.inputType=="historyRedo"?Vle:null;return r?(t.preventDefault(),r(s)):!1}})]}i(Dhn,"history");function FH(e,t){return function({state:s,dispatch:r}){if(!t&&s.readOnly)return!1;let a=s.field(zdt,!1);if(!a)return!1;let o=a.pop(e,s,t);return o?(r(o),!0):!1}}i(FH,"cmd");var qdt=FH(0,!1),Vle=FH(1,!1),Phn=FH(0,!0),$hn=FH(1,!0),Qy=class bR{static{i(this,"HistEvent")}constructor(t,s,r,a,o){this.changes=t,this.effects=s,this.mapped=r,this.startSelection=a,this.selectionsAfter=o}setSelAfter(t){return new bR(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,s,r;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(s=this.mapped)===null||s===void 0?void 0:s.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(a=>a.toJSON())}}static fromJSON(t){return new bR(t.changes&&ag.fromJSON(t.changes),[],t.mapped&&m3.fromJSON(t.mapped),t.startSelection&&Qn.fromJSON(t.startSelection),t.selectionsAfter.map(Qn.fromJSON))}static fromTransaction(t,s){let r=Df;for(let a of t.startState.facet(Lhn)){let o=a(t);o.length&&(r=r.concat(o))}return!r.length&&t.changes.empty?null:new bR(t.changes.invert(t.startState.doc),r,void 0,s||t.startState.selection,Df)}static selection(t){return new bR(void 0,Df,void 0,void 0,t)}};function nK(e,t,s,r){let a=t+1>s+20?t-s-1:0,o=e.slice(a,t);return o.push(r),o}i(nK,"updateBranch");function Ohn(e,t){let s=[],r=!1;return e.iterChangedRanges((a,o)=>s.push(a,o)),t.iterChangedRanges((a,o,l,c)=>{for(let d=0;d<s.length;){let u=s[d++],h=s[d++];c>=u&&l<=h&&(r=!0)}}),r}i(Ohn,"isAdjacent");function Fhn(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((s,r)=>s.empty!=t.ranges[r].empty).length===0}i(Fhn,"eqSelectionShape");function Udt(e,t){return e.length?t.length?e.concat(t):e:t}i(Udt,"conc");var Df=[],Bhn=200;function Kdt(e,t){if(e.length){let s=e[e.length-1],r=s.selectionsAfter.slice(Math.max(0,s.selectionsAfter.length-Bhn));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),nK(e,e.length-1,1e9,s.setSelAfter(r)))}else return[Qy.selection([t])]}i(Kdt,"addSelection");function zhn(e){let t=e[e.length-1],s=e.slice();return s[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),s}i(zhn,"popSelection");function eee(e,t){if(!e.length)return e;let s=e.length,r=Df;for(;s;){let a=qhn(e[s-1],t,r);if(a.changes&&!a.changes.empty||a.effects.length){let o=e.slice(0,s);return o[s-1]=a,o}else t=a.mapped,s--,r=a.selectionsAfter}return r.length?[Qy.selection(r)]:Df}i(eee,"addMappingToBranch");function qhn(e,t,s){let r=Udt(e.selectionsAfter.length?e.selectionsAfter.map(c=>c.map(t)):Df,s);if(!e.changes)return Qy.selection(r);let a=e.changes.map(t),o=t.mapDesc(e.changes,!0),l=e.mapped?e.mapped.composeDesc(o):o;return new Qy(a,pa.mapEffects(e.effects,t),l,e.startSelection.map(o),r)}i(qhn,"mapEvent");var Uhn=/^(input\.type|delete)($|\.)/,R6=class yR{static{i(this,"HistoryState")}constructor(t,s,r=0,a=void 0){this.done=t,this.undone=s,this.prevTime=r,this.prevUserEvent=a}isolate(){return this.prevTime?new yR(this.done,this.undone):this}addChanges(t,s,r,a,o){let l=this.done,c=l[l.length-1];return c&&c.changes&&!c.changes.empty&&t.changes&&(!r||Uhn.test(r))&&(!c.selectionsAfter.length&&s-this.prevTime<a.newGroupDelay&&a.joinToEvent(o,Ohn(c.changes,t.changes))||r=="input.type.compose")?l=nK(l,l.length-1,a.minDepth,new Qy(t.changes.compose(c.changes),Udt(pa.mapEffects(t.effects,c.changes),c.effects),c.mapped,c.startSelection,Df)):l=nK(l,l.length,a.minDepth,t),new yR(l,Df,s,r)}addSelection(t,s,r,a){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:Df;return o.length>0&&s-this.prevTime<a&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Fhn(o[o.length-1],t)?this:new yR(Kdt(this.done,t),this.undone,s,r)}addMapping(t){return new yR(eee(this.done,t),eee(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,s,r){let a=t==0?this.done:this.undone;if(a.length==0)return null;let o=a[a.length-1],l=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):s.selection);if(r&&o.selectionsAfter.length)return s.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:Qle.of({side:t,rest:zhn(a),selection:l}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let c=a.length==1?Df:a.slice(0,a.length-1);return o.mapped&&(c=eee(c,o.mapped)),s.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:Qle.of({side:t,rest:c,selection:l}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}};R6.empty=new R6(Df,Df);var Khn=[{key:"Mod-z",run:qdt,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Vle,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Vle,preventDefault:!0},{key:"Mod-u",run:Phn,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:$hn,preventDefault:!0}];function LT(e,t){return Qn.create(e.ranges.map(t),e.mainIndex)}i(LT,"updateSel");function Ex(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}i(Ex,"setSel");function Rx({state:e,dispatch:t},s){let r=LT(e.selection,s);return r.eq(e.selection,!0)?!1:(t(Ex(e,r)),!0)}i(Rx,"moveSel");function BH(e,t){return Qn.cursor(t?e.to:e.from)}i(BH,"rangeEnd");function Wdt(e,t){return Rx(e,s=>s.empty?e.moveByChar(s,t):BH(s,t))}i(Wdt,"cursorByChar");function om(e){return e.textDirectionAt(e.state.selection.main.head)==ql.LTR}i(om,"ltrAtCursor");var Qdt=i(e=>Wdt(e,!om(e)),"cursorCharLeft"),Vdt=i(e=>Wdt(e,om(e)),"cursorCharRight");function Hdt(e,t){return Rx(e,s=>s.empty?e.moveByGroup(s,t):BH(s,t))}i(Hdt,"cursorByGroup");var Whn=i(e=>Hdt(e,!om(e)),"cursorGroupLeft"),Qhn=i(e=>Hdt(e,om(e)),"cursorGroupRight"),w9s=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Vhn(e,t,s){if(t.type.prop(s))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}i(Vhn,"interestingNode");function zH(e,t,s){let r=sm(e).resolveInner(t.head),a=s?Oa.closedBy:Oa.openedBy;for(let d=t.head;;){let u=s?r.childAfter(d):r.childBefore(d);if(!u)break;Vhn(e,u,a)?r=u:d=s?u.to:u.from}let o=r.type.prop(a),l,c;return o&&(l=s?Mv(e,r.from,1):Mv(e,r.to,-1))&&l.matched?c=s?l.end.to:l.end.from:c=s?r.to:r.from,Qn.cursor(c,s?-1:1)}i(zH,"moveBySyntax");var Hhn=i(e=>Rx(e,t=>zH(e.state,t,!om(e))),"cursorSyntaxLeft"),Ghn=i(e=>Rx(e,t=>zH(e.state,t,om(e))),"cursorSyntaxRight");function Gdt(e,t){return Rx(e,s=>{if(!s.empty)return BH(s,t);let r=e.moveVertically(s,t);return r.head!=s.head?r:e.moveToLineBoundary(s,t)})}i(Gdt,"cursorByLine");var Ydt=i(e=>Gdt(e,!1),"cursorLineUp"),Jdt=i(e=>Gdt(e,!0),"cursorLineDown");function Zdt(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,s=0,r=0,a;if(t){for(let o of e.state.facet(Br.scrollMargins)){let l=o(e);l?.top&&(s=Math.max(l?.top,s)),l?.bottom&&(r=Math.max(l?.bottom,r))}a=e.scrollDOM.clientHeight-s-r}else a=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:s,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,a-5)}}i(Zdt,"pageInfo");function Xdt(e,t){let s=Zdt(e),{state:r}=e,a=LT(r.selection,l=>l.empty?e.moveVertically(l,t,s.height):BH(l,t));if(a.eq(r.selection))return!1;let o;if(s.selfScroll){let l=e.coordsAtPos(r.selection.main.head),c=e.scrollDOM.getBoundingClientRect(),d=c.top+s.marginTop,u=c.bottom-s.marginBottom;l&&l.top>d&&l.bottom<u&&(o=Br.scrollIntoView(a.main.head,{y:"start",yMargin:l.top-d}))}return e.dispatch(Ex(r,a),{effects:o}),!0}i(Xdt,"cursorByPage");var r4e=i(e=>Xdt(e,!1),"cursorPageUp"),Hle=i(e=>Xdt(e,!0),"cursorPageDown");function X1(e,t,s){let r=e.lineBlockAt(t.head),a=e.moveToLineBoundary(t,s);if(a.head==t.head&&a.head!=(s?r.to:r.from)&&(a=e.moveToLineBoundary(t,s,!1)),!s&&a.head==r.from&&r.length){let o=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&t.head!=r.from+o&&(a=Qn.cursor(r.from+o))}return a}i(X1,"moveByLineBoundary");var Yhn=i(e=>Rx(e,t=>X1(e,t,!0)),"cursorLineBoundaryForward"),Jhn=i(e=>Rx(e,t=>X1(e,t,!1)),"cursorLineBoundaryBackward"),Zhn=i(e=>Rx(e,t=>X1(e,t,!om(e))),"cursorLineBoundaryLeft"),Xhn=i(e=>Rx(e,t=>X1(e,t,om(e))),"cursorLineBoundaryRight"),emn=i(e=>Rx(e,t=>Qn.cursor(e.lineBlockAt(t.head).from,1)),"cursorLineStart"),tmn=i(e=>Rx(e,t=>Qn.cursor(e.lineBlockAt(t.head).to,-1)),"cursorLineEnd");function nmn(e,t,s){let r=!1,a=LT(e.selection,o=>{let l=Mv(e,o.head,-1)||Mv(e,o.head,1)||o.head>0&&Mv(e,o.head-1,1)||o.head<e.doc.length&&Mv(e,o.head+1,-1);if(!l||!l.end)return o;r=!0;let c=l.start.from==o.head?l.end.to:l.end.from;return s?Qn.range(o.anchor,c):Qn.cursor(c)});return r?(t(Ex(e,a)),!0):!1}i(nmn,"toMatchingBracket");var smn=i(({state:e,dispatch:t})=>nmn(e,t,!1),"cursorMatchingBracket");function hg(e,t){let s=LT(e.state.selection,r=>{let a=t(r);return Qn.range(r.anchor,a.head,a.goalColumn,a.bidiLevel||void 0)});return s.eq(e.state.selection)?!1:(e.dispatch(Ex(e.state,s)),!0)}i(hg,"extendSel");function eut(e,t){return hg(e,s=>e.moveByChar(s,t))}i(eut,"selectByChar");var tut=i(e=>eut(e,!om(e)),"selectCharLeft"),nut=i(e=>eut(e,om(e)),"selectCharRight");function sut(e,t){return hg(e,s=>e.moveByGroup(s,t))}i(sut,"selectByGroup");var rmn=i(e=>sut(e,!om(e)),"selectGroupLeft"),imn=i(e=>sut(e,om(e)),"selectGroupRight"),amn=i(e=>hg(e,t=>zH(e.state,t,!om(e))),"selectSyntaxLeft"),omn=i(e=>hg(e,t=>zH(e.state,t,om(e))),"selectSyntaxRight");function rut(e,t){return hg(e,s=>e.moveVertically(s,t))}i(rut,"selectByLine");var iut=i(e=>rut(e,!1),"selectLineUp"),aut=i(e=>rut(e,!0),"selectLineDown");function out(e,t){return hg(e,s=>e.moveVertically(s,t,Zdt(e).height))}i(out,"selectByPage");var i4e=i(e=>out(e,!1),"selectPageUp"),a4e=i(e=>out(e,!0),"selectPageDown"),lmn=i(e=>hg(e,t=>X1(e,t,!0)),"selectLineBoundaryForward"),cmn=i(e=>hg(e,t=>X1(e,t,!1)),"selectLineBoundaryBackward"),dmn=i(e=>hg(e,t=>X1(e,t,!om(e))),"selectLineBoundaryLeft"),umn=i(e=>hg(e,t=>X1(e,t,om(e))),"selectLineBoundaryRight"),hmn=i(e=>hg(e,t=>Qn.cursor(e.lineBlockAt(t.head).from)),"selectLineStart"),mmn=i(e=>hg(e,t=>Qn.cursor(e.lineBlockAt(t.head).to)),"selectLineEnd"),o4e=i(({state:e,dispatch:t})=>(t(Ex(e,{anchor:0})),!0),"cursorDocStart"),l4e=i(({state:e,dispatch:t})=>(t(Ex(e,{anchor:e.doc.length})),!0),"cursorDocEnd"),c4e=i(({state:e,dispatch:t})=>(t(Ex(e,{anchor:e.selection.main.anchor,head:0})),!0),"selectDocStart"),d4e=i(({state:e,dispatch:t})=>(t(Ex(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),"selectDocEnd"),pmn=i(({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),"selectAll"),fmn=i(({state:e,dispatch:t})=>{let s=qH(e).map(({from:r,to:a})=>Qn.range(r,Math.min(a+1,e.doc.length)));return t(e.update({selection:Qn.create(s),userEvent:"select"})),!0},"selectLine"),gmn=i(({state:e,dispatch:t})=>{let s=LT(e.selection,r=>{let a=sm(e),o=a.resolveStack(r.from,1);if(r.empty){let l=a.resolveStack(r.from,-1);l.node.from>=o.node.from&&l.node.to<=o.node.to&&(o=l)}for(let l=o;l;l=l.next){let{node:c}=l;if((c.from<r.from&&c.to>=r.to||c.to>r.to&&c.from<=r.from)&&l.next)return Qn.range(c.to,c.from)}return r});return s.eq(e.selection)?!1:(t(Ex(e,s)),!0)},"selectParentSyntax");function lut(e,t){let{state:s}=e,r=s.selection,a=s.selection.ranges.slice();for(let o of s.selection.ranges){let l=s.doc.lineAt(o.head);if(t?l.to<e.state.doc.length:l.from>0)for(let c=o;;){let d=e.moveVertically(c,t);if(d.head<l.from||d.head>l.to){a.some(u=>u.head==d.head)||a.push(d);break}else{if(d.head==c.head)break;c=d}}}return a.length==r.ranges.length?!1:(e.dispatch(Ex(s,Qn.create(a,a.length-1))),!0)}i(lut,"addCursorVertically");var xmn=i(e=>lut(e,!1),"addCursorAbove"),vmn=i(e=>lut(e,!0),"addCursorBelow"),bmn=i(({state:e,dispatch:t})=>{let s=e.selection,r=null;return s.ranges.length>1?r=Qn.create([s.main]):s.main.empty||(r=Qn.create([Qn.cursor(s.main.head)])),r?(t(Ex(e,r)),!0):!1},"simplifySelection");function C7(e,t){if(e.state.readOnly)return!1;let s="delete.selection",{state:r}=e,a=r.changeByRange(o=>{let{from:l,to:c}=o;if(l==c){let d=t(o);d<l?(s="delete.backward",d=c$(e,d,!1)):d>l&&(s="delete.forward",d=c$(e,d,!0)),l=Math.min(l,d),c=Math.max(c,d)}else l=c$(e,l,!1),c=c$(e,c,!0);return l==c?{range:o}:{changes:{from:l,to:c},range:Qn.cursor(l,l<o.head?-1:1)}});return a.changes.empty?!1:(e.dispatch(r.update(a,{scrollIntoView:!0,userEvent:s,effects:s=="delete.selection"?Br.announce.of(r.phrase("Selection deleted")):void 0})),!0)}i(C7,"deleteBy");function c$(e,t,s){if(e instanceof Br)for(let r of e.state.facet(Br.atomicRanges).map(a=>a(e)))r.between(t,t,(a,o)=>{a<t&&o>t&&(t=s?o:a)});return t}i(c$,"skipAtomic");var cut=i((e,t,s)=>C7(e,r=>{let a=r.from,{state:o}=e,l=o.doc.lineAt(a),c,d;if(s&&!t&&a>l.from&&a<l.from+200&&!/[^ \t]/.test(c=l.text.slice(0,a-l.from))){if(c[c.length-1]==" ")return a-1;let u=JS(c,o.tabSize)%I1(o)||I1(o);for(let h=0;h<u&&c[c.length-1-h]==" ";h++)a--;d=a}else d=Zu(l.text,a-l.from,t,t)+l.from,d==a&&l.number!=(t?o.doc.lines:1)?d+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(l.text.slice(d-l.from,a-l.from))&&(d=Zu(l.text,d-l.from,!1,!1)+l.from);return d}),"deleteByChar"),Gle=i(e=>cut(e,!1,!0),"deleteCharBackward"),dut=i(e=>cut(e,!0,!1),"deleteCharForward"),uut=i((e,t)=>C7(e,s=>{let r=s.head,{state:a}=e,o=a.doc.lineAt(r),l=a.charCategorizer(r);for(let c=null;;){if(r==(t?o.to:o.from)){r==s.head&&o.number!=(t?a.doc.lines:1)&&(r+=t?1:-1);break}let d=Zu(o.text,r-o.from,t)+o.from,u=o.text.slice(Math.min(r,d)-o.from,Math.max(r,d)-o.from),h=l(u);if(c!=null&&h!=c)break;(u!=" "||r!=s.head)&&(c=h),r=d}return r}),"deleteByGroup"),hut=i(e=>uut(e,!1),"deleteGroupBackward"),ymn=i(e=>uut(e,!0),"deleteGroupForward"),kmn=i(e=>C7(e,t=>{let s=e.lineBlockAt(t.head).to;return t.head<s?s:Math.min(e.state.doc.length,t.head+1)}),"deleteToLineEnd"),wmn=i(e=>C7(e,t=>{let s=e.moveToLineBoundary(t,!1).head;return t.head>s?s:Math.max(0,t.head-1)}),"deleteLineBoundaryBackward"),jmn=i(e=>C7(e,t=>{let s=e.moveToLineBoundary(t,!0).head;return t.head<s?s:Math.min(e.state.doc.length,t.head+1)}),"deleteLineBoundaryForward"),Nmn=i(({state:e,dispatch:t})=>{if(e.readOnly)return!1;let s=e.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:Po.of(["",""])},range:Qn.cursor(r.from)}));return t(e.update(s,{scrollIntoView:!0,userEvent:"input"})),!0},"splitLine"),Cmn=i(({state:e,dispatch:t})=>{if(e.readOnly)return!1;let s=e.changeByRange(r=>{if(!r.empty||r.from==0||r.from==e.doc.length)return{range:r};let a=r.from,o=e.doc.lineAt(a),l=a==o.from?a-1:Zu(o.text,a-o.from,!1)+o.from,c=a==o.to?a+1:Zu(o.text,a-o.from,!0)+o.from;return{changes:{from:l,to:c,insert:e.doc.slice(a,c).append(e.doc.slice(l,a))},range:Qn.cursor(c)}});return s.changes.empty?!1:(t(e.update(s,{scrollIntoView:!0,userEvent:"move.character"})),!0)},"transposeChars");function qH(e){let t=[],s=-1;for(let r of e.selection.ranges){let a=e.doc.lineAt(r.from),o=e.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=e.doc.lineAt(r.to-1)),s>=a.number){let l=t[t.length-1];l.to=o.to,l.ranges.push(r)}else t.push({from:a.from,to:o.to,ranges:[r]});s=o.number+1}return t}i(qH,"selectedLineBlocks");function mut(e,t,s){if(e.readOnly)return!1;let r=[],a=[];for(let o of qH(e)){if(s?o.to==e.doc.length:o.from==0)continue;let l=e.doc.lineAt(s?o.to+1:o.from-1),c=l.length+1;if(s){r.push({from:o.to,to:l.to},{from:o.from,insert:l.text+e.lineBreak});for(let d of o.ranges)a.push(Qn.range(Math.min(e.doc.length,d.anchor+c),Math.min(e.doc.length,d.head+c)))}else{r.push({from:l.from,to:o.from},{from:o.to,insert:e.lineBreak+l.text});for(let d of o.ranges)a.push(Qn.range(d.anchor-c,d.head-c))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:Qn.create(a,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}i(mut,"moveLine");var Smn=i(({state:e,dispatch:t})=>mut(e,t,!1),"moveLineUp"),_mn=i(({state:e,dispatch:t})=>mut(e,t,!0),"moveLineDown");function put(e,t,s){if(e.readOnly)return!1;let r=[];for(let o of qH(e))s?r.push({from:o.from,insert:e.doc.slice(o.from,o.to)+e.lineBreak}):r.push({from:o.to,insert:e.lineBreak+e.doc.slice(o.from,o.to)});let a=e.changes(r);return t(e.update({changes:a,selection:e.selection.map(a,s?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}i(put,"copyLine");var Amn=i(({state:e,dispatch:t})=>put(e,t,!1),"copyLineUp"),Imn=i(({state:e,dispatch:t})=>put(e,t,!0),"copyLineDown"),Tmn=i(e=>{if(e.state.readOnly)return!1;let{state:t}=e,s=t.changes(qH(t).map(({from:a,to:o})=>(a>0?a--:o<t.doc.length&&o++,{from:a,to:o}))),r=LT(t.selection,a=>{let o;if(e.lineWrapping){let l=e.lineBlockAt(a.head),c=e.coordsAtPos(a.head,a.assoc||1);c&&(o=l.bottom+e.documentTop-c.bottom+e.defaultLineHeight/2)}return e.moveVertically(a,!0,o)}).map(s);return e.dispatch({changes:s,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0},"deleteLine");function Emn(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let s=sm(e).resolveInner(t),r=s.childBefore(t),a=s.childAfter(t),o;return r&&a&&r.to<=t&&a.from>=t&&(o=r.type.prop(Oa.closedBy))&&o.indexOf(a.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(a.from).from&&!/\S/.test(e.sliceDoc(r.to,a.from))?{from:r.to,to:a.from}:null}i(Emn,"isBetweenBrackets");var u4e=fut(!1),Rmn=fut(!0);function fut(e){return({state:t,dispatch:s})=>{if(t.readOnly)return!1;let r=t.changeByRange(a=>{let{from:o,to:l}=a,c=t.doc.lineAt(o),d=!e&&o==l&&Emn(t,o);e&&(o=l=(l<=c.to?c:t.doc.lineAt(l)).to);let u=new $H(t,{simulateBreak:o,simulateDoubleBreak:!!d}),h=Ove(u,o);for(h==null&&(h=JS(/^\s*/.exec(t.doc.lineAt(o).text)[0],t.tabSize));l<c.to&&/\s/.test(c.text[l-c.from]);)l++;d?{from:o,to:l}=d:o>c.from&&o<c.from+100&&!/\S/.test(c.text.slice(0,o))&&(o=c.from);let p=["",hI(t,h)];return d&&p.push(hI(t,u.lineIndent(c.from,-1))),{changes:{from:o,to:l,insert:Po.of(p)},range:Qn.cursor(o+1+p[1].length)}});return s(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}i(fut,"newlineAndIndent");function Vve(e,t){let s=-1;return e.changeByRange(r=>{let a=[];for(let l=r.from;l<=r.to;){let c=e.doc.lineAt(l);c.number>s&&(r.empty||r.to>c.from)&&(t(c,a,r),s=c.number),l=c.to+1}let o=e.changes(a);return{changes:a,range:Qn.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}i(Vve,"changeBySelectedLine");var Mmn=i(({state:e,dispatch:t})=>{if(e.readOnly)return!1;let s=Object.create(null),r=new $H(e,{overrideIndentation:i(o=>{let l=s[o];return l??-1},"overrideIndentation")}),a=Vve(e,(o,l,c)=>{let d=Ove(r,o.from);if(d==null)return;/\S/.test(o.text)||(d=0);let u=/^\s*/.exec(o.text)[0],h=hI(e,d);(u!=h||c.from<o.from+u.length)&&(s[o.from]=d,l.push({from:o.from,to:o.from+u.length,insert:h}))});return a.changes.empty||t(e.update(a,{userEvent:"indent"})),!0},"indentSelection"),Lmn=i(({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Vve(e,(s,r)=>{r.push({from:s.from,insert:e.facet(PH)})}),{userEvent:"input.indent"})),!0),"indentMore"),Dmn=i(({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Vve(e,(s,r)=>{let a=/^\s*/.exec(s.text)[0];if(!a)return;let o=JS(a,e.tabSize),l=0,c=hI(e,Math.max(0,o-I1(e)));for(;l<a.length&&l<c.length&&a.charCodeAt(l)==c.charCodeAt(l);)l++;r.push({from:s.from+l,to:s.from+a.length,insert:c.slice(l)})}),{userEvent:"delete.dedent"})),!0),"indentLess"),Pmn=i(e=>(e.setTabFocusMode(),!0),"toggleTabFocusMode"),$mn=[{key:"Ctrl-b",run:Qdt,shift:tut,preventDefault:!0},{key:"Ctrl-f",run:Vdt,shift:nut},{key:"Ctrl-p",run:Ydt,shift:iut},{key:"Ctrl-n",run:Jdt,shift:aut},{key:"Ctrl-a",run:emn,shift:hmn},{key:"Ctrl-e",run:tmn,shift:mmn},{key:"Ctrl-d",run:dut},{key:"Ctrl-h",run:Gle},{key:"Ctrl-k",run:kmn},{key:"Ctrl-Alt-h",run:hut},{key:"Ctrl-o",run:Nmn},{key:"Ctrl-t",run:Cmn},{key:"Ctrl-v",run:Hle}],Omn=[{key:"ArrowLeft",run:Qdt,shift:tut,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Whn,shift:rmn,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Zhn,shift:dmn,preventDefault:!0},{key:"ArrowRight",run:Vdt,shift:nut,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Qhn,shift:imn,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Xhn,shift:umn,preventDefault:!0},{key:"ArrowUp",run:Ydt,shift:iut,preventDefault:!0},{mac:"Cmd-ArrowUp",run:o4e,shift:c4e},{mac:"Ctrl-ArrowUp",run:r4e,shift:i4e},{key:"ArrowDown",run:Jdt,shift:aut,preventDefault:!0},{mac:"Cmd-ArrowDown",run:l4e,shift:d4e},{mac:"Ctrl-ArrowDown",run:Hle,shift:a4e},{key:"PageUp",run:r4e,shift:i4e},{key:"PageDown",run:Hle,shift:a4e},{key:"Home",run:Jhn,shift:cmn,preventDefault:!0},{key:"Mod-Home",run:o4e,shift:c4e},{key:"End",run:Yhn,shift:lmn,preventDefault:!0},{key:"Mod-End",run:l4e,shift:d4e},{key:"Enter",run:u4e,shift:u4e},{key:"Mod-a",run:pmn},{key:"Backspace",run:Gle,shift:Gle,preventDefault:!0},{key:"Delete",run:dut,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:hut,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:ymn,preventDefault:!0},{mac:"Mod-Backspace",run:wmn,preventDefault:!0},{mac:"Mod-Delete",run:jmn,preventDefault:!0}].concat($mn.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Fmn=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Hhn,shift:amn},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Ghn,shift:omn},{key:"Alt-ArrowUp",run:Smn},{key:"Shift-Alt-ArrowUp",run:Amn},{key:"Alt-ArrowDown",run:_mn},{key:"Shift-Alt-ArrowDown",run:Imn},{key:"Mod-Alt-ArrowUp",run:xmn},{key:"Mod-Alt-ArrowDown",run:vmn},{key:"Escape",run:bmn},{key:"Mod-Enter",run:Rmn},{key:"Alt-l",mac:"Ctrl-l",run:fmn},{key:"Mod-i",run:gmn,preventDefault:!0},{key:"Mod-[",run:Dmn},{key:"Mod-]",run:Lmn},{key:"Mod-Alt-\\",run:Mmn},{key:"Shift-Mod-k",run:Tmn},{key:"Shift-Mod-\\",run:smn},{key:"Mod-/",run:Shn},{key:"Alt-A",run:Ahn},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Pmn}].concat(Omn),h4e=typeof String.prototype.normalize=="function"?e=>e.normalize("NFKD"):e=>e,mI=class{static{i(this,"SearchCursor")}constructor(e,t,s=0,r=e.length,a,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(s,r),this.bufferStart=s,this.normalize=a?l=>a(h4e(l)):h4e,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return lp(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=yve(e),s=this.bufferStart+this.bufferPos;this.bufferPos+=kv(e);let r=this.normalize(t);if(r.length)for(let a=0,o=s;;a++){let l=r.charCodeAt(a),c=this.match(l,o,this.bufferPos+this.bufferStart);if(a==r.length-1){if(c)return this.value=c,this;break}o==s&&a<t.length&&t.charCodeAt(a)==l&&o++}}}match(e,t,s){let r=null;for(let a=0;a<this.matches.length;a+=2){let o=this.matches[a],l=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?r={from:this.matches[a+1],to:s}:(this.matches[a]++,l=!0)),l||(this.matches.splice(a,2),a-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:s}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<"u"&&(mI.prototype[Symbol.iterator]=function(){return this});var gut={from:-1,to:-1,match:/.*/.exec("")},Hve="gm"+(/x/.unicode==null?"":"u"),xut=class{static{i(this,"RegExpCursor")}constructor(e,t,s,r=0,a=e.length){if(this.text=e,this.to=a,this.curLine="",this.done=!1,this.value=gut,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new vut(e,t,s,r,a);this.re=new RegExp(t,Hve+(s?.ignoreCase?"i":"")),this.test=s?.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=sK(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let s=this.curLineStart+t.index,r=s+t[0].length;if(this.matchPos=sK(this.text,r+(s==r?1:0)),s==this.curLineStart+this.curLine.length&&this.nextLine(),(s<r||s>this.value.to)&&(!this.test||this.test(s,r,t)))return this.value={from:s,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},tee=new WeakMap,m4e=class OB{static{i(this,"FlattenedDoc")}constructor(t,s){this.from=t,this.text=s}get to(){return this.from+this.text.length}static get(t,s,r){let a=tee.get(t);if(!a||a.from>=r||a.to<=s){let c=new OB(s,t.sliceString(s,r));return tee.set(t,c),c}if(a.from==s&&a.to==r)return a;let{text:o,from:l}=a;return l>s&&(o=t.sliceString(s,l)+o,l=s),a.to<r&&(o+=t.sliceString(a.to,r)),tee.set(t,new OB(l,o)),new OB(s,o.slice(s-l,r-l))}},vut=class{static{i(this,"MultilineRegExpCursor")}constructor(e,t,s,r,a){this.text=e,this.to=a,this.done=!1,this.value=gut,this.matchPos=sK(e,r),this.re=new RegExp(t,Hve+(s?.ignoreCase?"i":"")),this.test=s?.test,this.flat=m4e.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let s=this.flat.from+t.index,r=s+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(s,r,t)))return this.value={from:s,to:r,match:t},this.matchPos=sK(this.text,r+(s==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=m4e.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<"u"&&(xut.prototype[Symbol.iterator]=vut.prototype[Symbol.iterator]=function(){return this});function Bmn(e){try{return new RegExp(e,Hve),!0}catch{return!1}}i(Bmn,"validRegExp");function sK(e,t){if(t>=e.length)return t;let s=e.lineAt(t),r;for(;t<s.to&&(r=s.text.charCodeAt(t-s.from))>=56320&&r<57344;)t++;return t}i(sK,"toCharEnd");var zmn=i(e=>{let{state:t}=e,s=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:a}=qdn(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:s},focus:!0,submitLabel:t.phrase("go")});return a.then(o=>{let l=o&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(o.elements.line.value);if(!l){e.dispatch({effects:r});return}let c=t.doc.lineAt(t.selection.main.head),[,d,u,h,p]=l,f=h?+h.slice(1):0,g=u?+u:c.number;if(u&&p){let b=g/100;d&&(b=b*(d=="-"?-1:1)+c.number/t.doc.lines),g=Math.round(t.doc.lines*b)}else u&&d&&(g=g*(d=="-"?-1:1)+c.number);let x=t.doc.line(Math.max(1,Math.min(t.doc.lines,g))),v=Qn.cursor(x.from+Math.max(0,Math.min(f,x.length)));e.dispatch({effects:[r,Br.scrollIntoView(v.from,{y:"center"})],selection:v})}),!0},"gotoLine"),qmn={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},but=Rr.define({combine(e){return Rb(e,qmn,{highlightWordAroundCursor:i((t,s)=>t||s,"highlightWordAroundCursor"),minSelectionLength:Math.min,maxMatches:Math.min})}});function Umn(e){let t=[Hmn,Vmn];return e&&t.push(but.of(e)),t}i(Umn,"highlightSelectionMatches");var Kmn=Ui.mark({class:"cm-selectionMatch"}),Wmn=Ui.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function p4e(e,t,s,r){return(s==0||e(t.sliceDoc(s-1,s))!=wc.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=wc.Word)}i(p4e,"insideWordBoundaries");function Qmn(e,t,s,r){return e(t.sliceDoc(s,s+1))==wc.Word&&e(t.sliceDoc(r-1,r))==wc.Word}i(Qmn,"insideWord");var Vmn=rh.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(but),{state:s}=e,r=s.selection;if(r.ranges.length>1)return Ui.none;let a=r.main,o,l=null;if(a.empty){if(!t.highlightWordAroundCursor)return Ui.none;let d=s.wordAt(a.head);if(!d)return Ui.none;l=s.charCategorizer(a.head),o=s.sliceDoc(d.from,d.to)}else{let d=a.to-a.from;if(d<t.minSelectionLength||d>200)return Ui.none;if(t.wholeWords){if(o=s.sliceDoc(a.from,a.to),l=s.charCategorizer(a.head),!(p4e(l,s,a.from,a.to)&&Qmn(l,s,a.from,a.to)))return Ui.none}else if(o=s.sliceDoc(a.from,a.to),!o)return Ui.none}let c=[];for(let d of e.visibleRanges){let u=new mI(s.doc,o,d.from,d.to);for(;!u.next().done;){let{from:h,to:p}=u.value;if((!l||p4e(l,s,h,p))&&(a.empty&&h<=a.from&&p>=a.to?c.push(Wmn.range(h,p)):(h>=a.to||p<=a.from)&&c.push(Kmn.range(h,p)),c.length>t.maxMatches))return Ui.none}}return Ui.set(c)}},{decorations:i(e=>e.decorations,"decorations")}),Hmn=Br.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Gmn=i(({state:e,dispatch:t})=>{let{selection:s}=e,r=Qn.create(s.ranges.map(a=>e.wordAt(a.head)||Qn.cursor(a.head)),s.mainIndex);return r.eq(s)?!1:(t(e.update({selection:r})),!0)},"selectWord");function Ymn(e,t){let{main:s,ranges:r}=e.selection,a=e.wordAt(s.head),o=a&&a.from==s.from&&a.to==s.to;for(let l=!1,c=new mI(e.doc,t,r[r.length-1].to);;)if(c.next(),c.done){if(l)return null;c=new mI(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),l=!0}else{if(l&&r.some(d=>d.from==c.value.from))continue;if(o){let d=e.wordAt(c.value.from);if(!d||d.from!=c.value.from||d.to!=c.value.to)continue}return c.value}}i(Ymn,"findNextOccurrence");var Jmn=i(({state:e,dispatch:t})=>{let{ranges:s}=e.selection;if(s.some(o=>o.from===o.to))return Gmn({state:e,dispatch:t});let r=e.sliceDoc(s[0].from,s[0].to);if(e.selection.ranges.some(o=>e.sliceDoc(o.from,o.to)!=r))return!1;let a=Ymn(e,r);return a?(t(e.update({selection:e.selection.addRange(Qn.range(a.from,a.to),!1),effects:Br.scrollIntoView(a.to)})),!0):!1},"selectNextOccurrence"),DT=Rr.define({combine(e){return Rb(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:i(t=>new upn(t),"createPanel"),scrollToMatch:i(t=>Br.scrollIntoView(t),"scrollToMatch")})}}),yut=class{static{i(this,"SearchQuery")}constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Bmn(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,s)=>s=="n"?`
172
+ `);s>-1&&(t=t.slice(0,s))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),s=e+t.length;for(let r=this.rangeIndex;;){let a=this.ranges[r].to;if(a>=s||(t=t.slice(0,a-(s-t.length)),r++,r==this.ranges.length))break;let o=this.ranges[r].from,l=this.lineAfter(o);t+=l,s=o+l.length}return{line:t,end:s}}skipGapsTo(e,t,s){for(;;){let r=this.ranges[this.rangeIndex].to,a=e+t;if(s>0?r>a:r>=a)break;let o=this.ranges[++this.rangeIndex].from;t+=o-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,s,r){let a=4;if(this.ranges.length>1){r=this.skipGapsTo(t,r,1),t+=r;let l=this.chunk.length;r=this.skipGapsTo(s,r,-1),s+=r,a+=this.chunk.length-l}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&a==4&&o>=0&&this.chunk[o]==e&&this.chunk[o+2]==t?this.chunk[o+2]=s:this.chunk.push(e,t,s,a),r}parseLine(e){let{line:t,end:s}=this.nextLine(),r=0,{streamParser:a}=this.lang,o=new Tdt(t,e?e.state.tabSize:4,e?I1(e.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let l=Mdt(a.token,o,this.state);if(l&&(r=this.emitToken(this.lang.tokenTable.resolve(l),this.parsedPos+o.start,this.parsedPos+o.pos,r)),o.start>1e4)break}this.parsedPos=s,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=kc.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:shn,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new kc(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new kc(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Mdt(e,t,s){t.start=t.pos;for(let r=0;r<10;r++){let a=e(t,s);if(t.pos>t.start)return a}throw new Error("Stream parser failed to advance stream.")}i(Mdt,"readToken");var qve=Object.create(null),TL=[B0.none],shn=new Ton(TL),VTe=[],HTe=Object.create(null),Ldt=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Ldt[e]=Pdt(qve,t);var Ddt=class{static{i(this,"TokenTable")}constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Ldt)}resolve(e){return e?this.table[e]||(this.table[e]=Pdt(this.extra,e)):0}},rhn=new Ddt(qve);function HX(e,t){VTe.indexOf(e)>-1||VTe.push(e)}i(HX,"warnForPart");function Pdt(e,t){let s=[];for(let c of t.split(" ")){let d=[];for(let u of c.split(".")){let h=e[u]||mn[u];h?typeof h=="function"?d.length?d=d.map(h):HX(u,`Modifier ${u} used at start of tag`):d.length?HX(u,`Tag ${u} used as modifier`):d=Array.isArray(h)?h:[h]:HX(u,`Unknown highlighting tag ${u}`)}for(let u of d)s.push(u)}if(!s.length)return 0;let r=t.replace(/ /g,"_"),a=r+" "+s.map(c=>c.id),o=HTe[a];if(o)return o.id;let l=HTe[a]=B0.define({id:TL.length,name:r,props:[aun({[r]:s})]});return TL.push(l),l.id}i(Pdt,"createTokenType");function ihn(e,t){let s=B0.define({id:TL.length,name:"Document",props:[OC.add(()=>e),pdt.add(()=>r=>t.getIndent(r))],top:!0});return TL.push(s),s}i(ihn,"docID");var y9s={rtl:Ui.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:ql.RTL}),ltr:Ui.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:ql.LTR}),auto:Ui.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};function Gn(e){return new pun(ehn.define(e))}i(Gn,"legacy");function Pw(e){return ln(()=>import("./dist-YLpD_m68.js").then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([0,1,2]))}i(Pw,"sql");var ahn=[cn.of({name:"C",extensions:["c","h","ino"],load(){return ln(()=>import("./dist-DxGmGQAd.js").then(e=>e.cpp()),__vite__mapDeps([3,2]))}}),cn.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return ln(()=>import("./dist-DxGmGQAd.js").then(e=>e.cpp()),__vite__mapDeps([3,2]))}}),cn.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Pw("Cassandra")}}),cn.of({name:"CSS",extensions:["css"],load(){return ln(()=>import("./dist-BRZ2juoF.js").then(e=>e.i).then(e=>e.css()),__vite__mapDeps([4,5,2]))}}),cn.of({name:"Go",extensions:["go"],load(){return ln(()=>import("./dist-7JK5o5w2.js").then(e=>e.go()),__vite__mapDeps([6,1,2]))}}),cn.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return ln(()=>import("./dist-Bs-s6dPt.js").then(e=>e.html()),__vite__mapDeps([7,2,4,5,8,1]))}}),cn.of({name:"Java",extensions:["java"],load(){return ln(()=>import("./dist-DCmyl8JS.js").then(e=>e.java()),__vite__mapDeps([9,2]))}}),cn.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return ln(()=>import("./dist-fm9IOgs2.js").then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,5,1,2]))}}),cn.of({name:"Jinja",extensions:["j2","jinja","jinja2"],load(){return ln(()=>import("./dist-Be2PH9Ri.js").then(e=>e.jinja()),__vite__mapDeps([10,2,7,4,5,8,1]))}}),cn.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return ln(()=>import("./dist-DLhVtuRQ.js").then(e=>e.json()),__vite__mapDeps([11,2]))}}),cn.of({name:"JSX",extensions:["jsx"],load(){return ln(()=>import("./dist-fm9IOgs2.js").then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([8,5,1,2]))}}),cn.of({name:"LESS",extensions:["less"],load(){return ln(()=>import("./dist-CwygYsQk.js").then(e=>e.less()),__vite__mapDeps([12,2,4,5]))}}),cn.of({name:"Liquid",extensions:["liquid"],load(){return ln(()=>import("./dist-DX49WtIu.js").then(e=>e.liquid()),__vite__mapDeps([13,2,7,4,5,8,1]))}}),cn.of({name:"MariaDB SQL",load(){return Pw("MariaSQL")}}),cn.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return ln(()=>import("./dist-D_0NfuCy.js").then(e=>e.markdown()),__vite__mapDeps([14,1,7,2,4,5,8]))}}),cn.of({name:"MS SQL",load(){return Pw("MSSQL")}}),cn.of({name:"MySQL",load(){return Pw("MySQL")}}),cn.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return ln(()=>import("./dist-DpJyVhoi.js").then(e=>e.php()),__vite__mapDeps([15,2,7,4,5,8,1]))}}),cn.of({name:"PLSQL",extensions:["pls"],load(){return Pw("PLSQL")}}),cn.of({name:"PostgreSQL",load(){return Pw("PostgreSQL")}}),cn.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return ln(()=>import("./dist-CoBeqEhN.js").then(e=>e.python()),__vite__mapDeps([16,1,2]))}}),cn.of({name:"Rust",extensions:["rs"],load(){return ln(()=>import("./dist-CsYwdeKQ.js").then(e=>e.rust()),__vite__mapDeps([17,2]))}}),cn.of({name:"Sass",extensions:["sass"],load(){return ln(()=>import("./dist-BJVIAntd.js").then(e=>e.sass({indented:!0})),__vite__mapDeps([18,2,4,5]))}}),cn.of({name:"SCSS",extensions:["scss"],load(){return ln(()=>import("./dist-BJVIAntd.js").then(e=>e.sass()),__vite__mapDeps([18,2,4,5]))}}),cn.of({name:"SQL",extensions:["sql"],load(){return Pw("StandardSQL")}}),cn.of({name:"SQLite",load(){return Pw("SQLite")}}),cn.of({name:"TSX",extensions:["tsx"],load(){return ln(()=>import("./dist-fm9IOgs2.js").then(e=>e.t).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([8,5,1,2]))}}),cn.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return ln(()=>import("./dist-fm9IOgs2.js").then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,5,1,2]))}}),cn.of({name:"WebAssembly",extensions:["wat","wast"],load(){return ln(()=>import("./dist-CWYWSO70.js").then(e=>e.wast()),__vite__mapDeps([19,2]))}}),cn.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return ln(()=>import("./dist-DwUD8svp.js").then(e=>e.xml()),__vite__mapDeps([20,2]))}}),cn.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return ln(()=>import("./dist-CPFoA4ty.js").then(e=>e.yaml()),__vite__mapDeps([21,2]))}}),cn.of({name:"APL",extensions:["dyalog","apl"],load(){return ln(()=>import("./apl-MHzTCvfx.js").then(e=>Gn(e.apl)),[])}}),cn.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return ln(()=>import("./asciiarmor-DFLNSgns.js").then(e=>Gn(e.asciiArmor)),[])}}),cn.of({name:"ASN.1",extensions:["asn","asn1"],load(){return ln(()=>import("./asn1-CfPVWRYE.js").then(e=>Gn(e.asn1({}))),[])}}),cn.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return ln(()=>import("./asterisk-CJ4OeA7Y.js").then(e=>Gn(e.asterisk)),[])}}),cn.of({name:"Brainfuck",extensions:["b","bf"],load(){return ln(()=>import("./brainfuck-NEHkmXMc.js").then(e=>Gn(e.brainfuck)),[])}}),cn.of({name:"Cobol",extensions:["cob","cpy"],load(){return ln(()=>import("./cobol-Bo8Zw9gB.js").then(e=>Gn(e.cobol)),[])}}),cn.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return ln(()=>import("./clike-CIx9nZSv.js").then(e=>Gn(e.csharp)),[])}}),cn.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return ln(()=>import("./clojure-DFaIEz5O.js").then(e=>Gn(e.clojure)),[])}}),cn.of({name:"ClojureScript",extensions:["cljs"],load(){return ln(()=>import("./clojure-DFaIEz5O.js").then(e=>Gn(e.clojure)),[])}}),cn.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return ln(()=>import("./css-DEZwfVpY.js").then(e=>Gn(e.gss)),[])}}),cn.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return ln(()=>import("./cmake-koz-qBlo.js").then(e=>Gn(e.cmake)),[])}}),cn.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return ln(()=>import("./coffeescript-CXYzYf-Y.js").then(e=>Gn(e.coffeeScript)),[])}}),cn.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return ln(()=>import("./commonlisp-C4OOCwkD.js").then(e=>Gn(e.commonLisp)),[])}}),cn.of({name:"Cypher",extensions:["cyp","cypher"],load(){return ln(()=>import("./cypher-z2oFsVv2.js").then(e=>Gn(e.cypher)),[])}}),cn.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return ln(()=>import("./python-C2DOnsac.js").then(e=>Gn(e.cython)),[])}}),cn.of({name:"Crystal",extensions:["cr"],load(){return ln(()=>import("./crystal-BlJXQDvy.js").then(e=>Gn(e.crystal)),[])}}),cn.of({name:"D",extensions:["d"],load(){return ln(()=>import("./d-Dkt6y7AQ.js").then(e=>Gn(e.d)),[])}}),cn.of({name:"Dart",extensions:["dart"],load(){return ln(()=>import("./clike-CIx9nZSv.js").then(e=>Gn(e.dart)),[])}}),cn.of({name:"diff",extensions:["diff","patch"],load(){return ln(()=>import("./diff-C60bAYOU.js").then(e=>Gn(e.diff)),[])}}),cn.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return ln(()=>import("./dockerfile-BttNdtK0.js").then(e=>Gn(e.dockerFile)),__vite__mapDeps([22,23]))}}),cn.of({name:"DTD",extensions:["dtd"],load(){return ln(()=>import("./dtd-CCVZU5Da.js").then(e=>Gn(e.dtd)),[])}}),cn.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return ln(()=>import("./dylan-3pmV5wzs.js").then(e=>Gn(e.dylan)),[])}}),cn.of({name:"EBNF",load(){return ln(()=>import("./ebnf-bm-I2WIh.js").then(e=>Gn(e.ebnf)),[])}}),cn.of({name:"ECL",extensions:["ecl"],load(){return ln(()=>import("./ecl-BIv3PrZb.js").then(e=>Gn(e.ecl)),[])}}),cn.of({name:"edn",extensions:["edn"],load(){return ln(()=>import("./clojure-DFaIEz5O.js").then(e=>Gn(e.clojure)),[])}}),cn.of({name:"Eiffel",extensions:["e"],load(){return ln(()=>import("./eiffel-DuLnr4-r.js").then(e=>Gn(e.eiffel)),[])}}),cn.of({name:"Elm",extensions:["elm"],load(){return ln(()=>import("./elm-njbaCU-L.js").then(e=>Gn(e.elm)),[])}}),cn.of({name:"Erlang",extensions:["erl"],load(){return ln(()=>import("./erlang-CuhOC2I8.js").then(e=>Gn(e.erlang)),[])}}),cn.of({name:"Esper",load(){return ln(()=>import("./sql-C3kWxFGw.js").then(e=>Gn(e.esper)),[])}}),cn.of({name:"Factor",extensions:["factor"],load(){return ln(()=>import("./factor-CM3-9V3b.js").then(e=>Gn(e.factor)),__vite__mapDeps([24,23]))}}),cn.of({name:"FCL",load(){return ln(()=>import("./fcl-nWsMJ92o.js").then(e=>Gn(e.fcl)),[])}}),cn.of({name:"Forth",extensions:["forth","fth","4th"],load(){return ln(()=>import("./forth-BQ9HrCVY.js").then(e=>Gn(e.forth)),[])}}),cn.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return ln(()=>import("./fortran-DHJe28ev.js").then(e=>Gn(e.fortran)),[])}}),cn.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return ln(()=>import("./mllike-DuNQsEw8.js").then(e=>Gn(e.fSharp)),[])}}),cn.of({name:"Gas",extensions:["s"],load(){return ln(()=>import("./gas-ByO0qYMr.js").then(e=>Gn(e.gas)),[])}}),cn.of({name:"Gherkin",extensions:["feature"],load(){return ln(()=>import("./gherkin-CwOmHL5K.js").then(e=>Gn(e.gherkin)),[])}}),cn.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return ln(()=>import("./groovy-ByXGF8cx.js").then(e=>Gn(e.groovy)),[])}}),cn.of({name:"Haskell",extensions:["hs"],load(){return ln(()=>import("./haskell-CHSpCNOy.js").then(e=>Gn(e.haskell)),[])}}),cn.of({name:"Haxe",extensions:["hx"],load(){return ln(()=>import("./haxe-P2jh68ck.js").then(e=>Gn(e.haxe)),[])}}),cn.of({name:"HXML",extensions:["hxml"],load(){return ln(()=>import("./haxe-P2jh68ck.js").then(e=>Gn(e.hxml)),[])}}),cn.of({name:"HTTP",load(){return ln(()=>import("./http-0jwMmfWP.js").then(e=>Gn(e.http)),[])}}),cn.of({name:"IDL",extensions:["pro"],load(){return ln(()=>import("./idl-DTVVj6r5.js").then(e=>Gn(e.idl)),[])}}),cn.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return ln(()=>import("./javascript-Cblpdx44.js").then(e=>Gn(e.jsonld)),[])}}),cn.of({name:"Julia",extensions:["jl"],load(){return ln(()=>import("./julia-KVJvUu_F.js").then(e=>Gn(e.julia)),[])}}),cn.of({name:"Kotlin",extensions:["kt","kts"],load(){return ln(()=>import("./clike-CIx9nZSv.js").then(e=>Gn(e.kotlin)),[])}}),cn.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return ln(()=>import("./livescript-DSHsJPcD.js").then(e=>Gn(e.liveScript)),[])}}),cn.of({name:"Lua",extensions:["lua"],load(){return ln(()=>import("./lua-Vher-70I.js").then(e=>Gn(e.lua)),[])}}),cn.of({name:"mIRC",extensions:["mrc"],load(){return ln(()=>import("./mirc-BGWbO906.js").then(e=>Gn(e.mirc)),[])}}),cn.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return ln(()=>import("./mathematica-CE9SaVsW.js").then(e=>Gn(e.mathematica)),[])}}),cn.of({name:"Modelica",extensions:["mo"],load(){return ln(()=>import("./modelica-5XCgKQt8.js").then(e=>Gn(e.modelica)),[])}}),cn.of({name:"MUMPS",extensions:["mps"],load(){return ln(()=>import("./mumps-C7oS353s.js").then(e=>Gn(e.mumps)),[])}}),cn.of({name:"Mbox",extensions:["mbox"],load(){return ln(()=>import("./mbox-JGl1Fgvq.js").then(e=>Gn(e.mbox)),[])}}),cn.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return ln(()=>import("./nginx-DXVlpyCz.js").then(e=>Gn(e.nginx)),[])}}),cn.of({name:"NSIS",extensions:["nsh","nsi"],load(){return ln(()=>import("./nsis-KFC6hioG.js").then(e=>Gn(e.nsis)),__vite__mapDeps([25,23]))}}),cn.of({name:"NTriples",extensions:["nt","nq"],load(){return ln(()=>import("./ntriples-5ckCopnn.js").then(e=>Gn(e.ntriples)),[])}}),cn.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return ln(()=>import("./clike-CIx9nZSv.js").then(e=>Gn(e.objectiveC)),[])}}),cn.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return ln(()=>import("./clike-CIx9nZSv.js").then(e=>Gn(e.objectiveCpp)),[])}}),cn.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return ln(()=>import("./mllike-DuNQsEw8.js").then(e=>Gn(e.oCaml)),[])}}),cn.of({name:"Octave",extensions:["m"],load(){return ln(()=>import("./octave-D1J2QQNt.js").then(e=>Gn(e.octave)),[])}}),cn.of({name:"Oz",extensions:["oz"],load(){return ln(()=>import("./oz-CPsllMDD.js").then(e=>Gn(e.oz)),[])}}),cn.of({name:"Pascal",extensions:["p","pas"],load(){return ln(()=>import("./pascal-B-I6JP0Y.js").then(e=>Gn(e.pascal)),[])}}),cn.of({name:"Perl",extensions:["pl","pm"],load(){return ln(()=>import("./perl-CI8WIWBi.js").then(e=>Gn(e.perl)),[])}}),cn.of({name:"Pig",extensions:["pig"],load(){return ln(()=>import("./pig-FQI0W3S3.js").then(e=>Gn(e.pig)),[])}}),cn.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return ln(()=>import("./powershell-BAu6x78A.js").then(e=>Gn(e.powerShell)),[])}}),cn.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return ln(()=>import("./properties-BKTTDgau.js").then(e=>Gn(e.properties)),[])}}),cn.of({name:"ProtoBuf",extensions:["proto"],load(){return ln(()=>import("./protobuf-UWh8gh_j.js").then(e=>Gn(e.protobuf)),[])}}),cn.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return ln(()=>import("./pug-C20tNwmy.js").then(e=>Gn(e.pug)),__vite__mapDeps([26,27]))}}),cn.of({name:"Puppet",extensions:["pp"],load(){return ln(()=>import("./puppet-BAHVzCkO.js").then(e=>Gn(e.puppet)),[])}}),cn.of({name:"Q",extensions:["q"],load(){return ln(()=>import("./q-Cooe-Nh8.js").then(e=>Gn(e.q)),[])}}),cn.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return ln(()=>import("./r-CktBKya9.js").then(e=>Gn(e.r)),[])}}),cn.of({name:"RPM Changes",load(){return ln(()=>import("./rpm-Csj9nLHl.js").then(e=>Gn(e.rpmChanges)),[])}}),cn.of({name:"RPM Spec",extensions:["spec"],load(){return ln(()=>import("./rpm-Csj9nLHl.js").then(e=>Gn(e.rpmSpec)),[])}}),cn.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return ln(()=>import("./ruby-bGx9eo-K.js").then(e=>Gn(e.ruby)),[])}}),cn.of({name:"SAS",extensions:["sas"],load(){return ln(()=>import("./sas-Drou_EQ9.js").then(e=>Gn(e.sas)),[])}}),cn.of({name:"Scala",extensions:["scala"],load(){return ln(()=>import("./clike-CIx9nZSv.js").then(e=>Gn(e.scala)),[])}}),cn.of({name:"Scheme",extensions:["scm","ss"],load(){return ln(()=>import("./scheme-DcjG9bAf.js").then(e=>Gn(e.scheme)),[])}}),cn.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return ln(()=>import("./shell-BSKClwid.js").then(e=>Gn(e.shell)),[])}}),cn.of({name:"Sieve",extensions:["siv","sieve"],load(){return ln(()=>import("./sieve-CcvsXPZo.js").then(e=>Gn(e.sieve)),[])}}),cn.of({name:"Smalltalk",extensions:["st"],load(){return ln(()=>import("./smalltalk-Cmg-4mjQ.js").then(e=>Gn(e.smalltalk)),[])}}),cn.of({name:"Solr",load(){return ln(()=>import("./solr-Dj8ahEwG.js").then(e=>Gn(e.solr)),[])}}),cn.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return ln(()=>import("./mllike-DuNQsEw8.js").then(e=>Gn(e.sml)),[])}}),cn.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return ln(()=>import("./sparql-LAJYmgfk.js").then(e=>Gn(e.sparql)),[])}}),cn.of({name:"Spreadsheet",alias:["excel","formula"],load(){return ln(()=>import("./spreadsheet-B8doD_pL.js").then(e=>Gn(e.spreadsheet)),[])}}),cn.of({name:"Squirrel",extensions:["nut"],load(){return ln(()=>import("./clike-CIx9nZSv.js").then(e=>Gn(e.squirrel)),[])}}),cn.of({name:"Stylus",extensions:["styl"],load(){return ln(()=>import("./stylus-BS-Ienrc.js").then(e=>Gn(e.stylus)),[])}}),cn.of({name:"Swift",extensions:["swift"],load(){return ln(()=>import("./swift-BD82LMDK.js").then(e=>Gn(e.swift)),[])}}),cn.of({name:"sTeX",load(){return ln(()=>import("./stex-CW6K5Nmu.js").then(e=>Gn(e.stex)),[])}}),cn.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return ln(()=>import("./stex-CW6K5Nmu.js").then(e=>Gn(e.stex)),[])}}),cn.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return ln(()=>import("./verilog-BVYlmXGg.js").then(e=>Gn(e.verilog)),[])}}),cn.of({name:"Tcl",extensions:["tcl"],load(){return ln(()=>import("./tcl-RZa1cqc-.js").then(e=>Gn(e.tcl)),[])}}),cn.of({name:"Textile",extensions:["textile"],load(){return ln(()=>import("./textile-C-BY_OGF.js").then(e=>Gn(e.textile)),[])}}),cn.of({name:"TiddlyWiki",load(){return ln(()=>import("./tiddlywiki-C9bm_Oju.js").then(e=>Gn(e.tiddlyWiki)),[])}}),cn.of({name:"Tiki wiki",load(){return ln(()=>import("./tiki-DJOT-rFT.js").then(e=>Gn(e.tiki)),[])}}),cn.of({name:"TOML",extensions:["toml"],load(){return ln(()=>import("./toml-Civ2fTsu.js").then(e=>Gn(e.toml)),[])}}),cn.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return ln(()=>import("./troff-Lns35Xcq.js").then(e=>Gn(e.troff)),[])}}),cn.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return ln(()=>import("./ttcn-7vlxVTUK.js").then(e=>Gn(e.ttcn)),[])}}),cn.of({name:"TTCN_CFG",extensions:["cfg"],load(){return ln(()=>import("./ttcn-cfg-B8qhhp6o.js").then(e=>Gn(e.ttcnCfg)),[])}}),cn.of({name:"Turtle",extensions:["ttl"],load(){return ln(()=>import("./turtle-DTIS1YQ7.js").then(e=>Gn(e.turtle)),[])}}),cn.of({name:"Web IDL",extensions:["webidl"],load(){return ln(()=>import("./webidl-ChvzbZ5-.js").then(e=>Gn(e.webIDL)),[])}}),cn.of({name:"VB.NET",extensions:["vb"],load(){return ln(()=>import("./vb-BO8UacKu.js").then(e=>Gn(e.vb)),[])}}),cn.of({name:"VBScript",extensions:["vbs"],load(){return ln(()=>import("./vbscript-DWLru3lT.js").then(e=>Gn(e.vbScript)),[])}}),cn.of({name:"Velocity",extensions:["vtl"],load(){return ln(()=>import("./velocity-BIIn-Nl2.js").then(e=>Gn(e.velocity)),[])}}),cn.of({name:"Verilog",extensions:["v"],load(){return ln(()=>import("./verilog-BVYlmXGg.js").then(e=>Gn(e.verilog)),[])}}),cn.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return ln(()=>import("./vhdl-Cn8cC8Yb.js").then(e=>Gn(e.vhdl)),[])}}),cn.of({name:"XQuery",extensions:["xy","xquery","xq","xqm","xqy"],load(){return ln(()=>import("./xquery-BKN7qEbU.js").then(e=>Gn(e.xQuery)),[])}}),cn.of({name:"Yacas",extensions:["ys"],load(){return ln(()=>import("./yacas-BG9ha7tU.js").then(e=>Gn(e.yacas)),[])}}),cn.of({name:"Z80",extensions:["z80"],load(){return ln(()=>import("./z80-CB2cGLew.js").then(e=>Gn(e.z80)),[])}}),cn.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return ln(()=>import("./mscgen-mVFg19ri.js").then(e=>Gn(e.mscgen)),[])}}),cn.of({name:"Xù",extensions:["xu"],load(){return ln(()=>import("./mscgen-mVFg19ri.js").then(e=>Gn(e.xu)),[])}}),cn.of({name:"MsGenny",extensions:["msgenny"],load(){return ln(()=>import("./mscgen-mVFg19ri.js").then(e=>Gn(e.msgenny)),[])}}),cn.of({name:"Vue",extensions:["vue"],load(){return ln(()=>import("./dist-C-AEDno-.js").then(e=>e.vue()),__vite__mapDeps([28,2,8,5,1,7,4]))}}),cn.of({name:"Angular Template",load(){return ln(()=>import("./dist-BYmxsnlZ.js").then(e=>e.angular()),__vite__mapDeps([29,2,8,5,1,7,4]))}})],GTe=Eb.define(),ohn=Rr.define(),EL=class xR{static{i(this,"HistEvent$1")}constructor(t,s,r,a,o){this.changes=t,this.effects=s,this.mapped=r,this.startSelection=a,this.selectionsAfter=o}setSelAfter(t){return new xR(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,s,r;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(s=this.mapped)===null||s===void 0?void 0:s.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(a=>a.toJSON())}}static fromJSON(t){return new xR(t.changes&&ag.fromJSON(t.changes),[],t.mapped&&m3.fromJSON(t.mapped),t.startSelection&&Qn.fromJSON(t.startSelection),t.selectionsAfter.map(Qn.fromJSON))}static fromTransaction(t,s){let r=Lf;for(let a of t.startState.facet(ohn)){let o=a(t);o.length&&(r=r.concat(o))}return!r.length&&t.changes.empty?null:new xR(t.changes.invert(t.startState.doc),r,void 0,s||t.startState.selection,Lf)}static selection(t){return new xR(void 0,Lf,void 0,void 0,t)}};function Kle(e,t,s,r){let a=t+1>s+20?t-s-1:0,o=e.slice(a,t);return o.push(r),o}i(Kle,"updateBranch$1");function lhn(e,t){let s=[],r=!1;return e.iterChangedRanges((a,o)=>s.push(a,o)),t.iterChangedRanges((a,o,l,c)=>{for(let d=0;d<s.length;){let u=s[d++],h=s[d++];c>=u&&l<=h&&(r=!0)}}),r}i(lhn,"isAdjacent$1");function chn(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((s,r)=>s.empty!=t.ranges[r].empty).length===0}i(chn,"eqSelectionShape$1");function $dt(e,t){return e.length?t.length?e.concat(t):e:t}i($dt,"conc$1");var Lf=[],dhn=200;function uhn(e,t){if(e.length){let s=e[e.length-1],r=s.selectionsAfter.slice(Math.max(0,s.selectionsAfter.length-dhn));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),Kle(e,e.length-1,1e9,s.setSelAfter(r)))}else return[EL.selection([t])]}i(uhn,"addSelection$1");function hhn(e){let t=e[e.length-1],s=e.slice();return s[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),s}i(hhn,"popSelection$1");function GX(e,t){if(!e.length)return e;let s=e.length,r=Lf;for(;s;){let a=mhn(e[s-1],t,r);if(a.changes&&!a.changes.empty||a.effects.length){let o=e.slice(0,s);return o[s-1]=a,o}else t=a.mapped,s--,r=a.selectionsAfter}return r.length?[EL.selection(r)]:Lf}i(GX,"addMappingToBranch$1");function mhn(e,t,s){let r=$dt(e.selectionsAfter.length?e.selectionsAfter.map(c=>c.map(t)):Lf,s);if(!e.changes)return EL.selection(r);let a=e.changes.map(t),o=t.mapDesc(e.changes,!0),l=e.mapped?e.mapped.composeDesc(o):o;return new EL(a,pa.mapEffects(e.effects,t),l,e.startSelection.map(o),r)}i(mhn,"mapEvent$1");var phn=/^(input\.type|delete)($|\.)/,YTe=class vR{static{i(this,"HistoryState$1")}constructor(t,s,r=0,a=void 0){this.done=t,this.undone=s,this.prevTime=r,this.prevUserEvent=a}isolate(){return this.prevTime?new vR(this.done,this.undone):this}addChanges(t,s,r,a,o){let l=this.done,c=l[l.length-1];return c&&c.changes&&!c.changes.empty&&t.changes&&(!r||phn.test(r))&&(!c.selectionsAfter.length&&s-this.prevTime<a.newGroupDelay&&a.joinToEvent(o,lhn(c.changes,t.changes))||r=="input.type.compose")?l=Kle(l,l.length-1,a.minDepth,new EL(t.changes.compose(c.changes),$dt(pa.mapEffects(t.effects,c.changes),c.effects),c.mapped,c.startSelection,Lf)):l=Kle(l,l.length,a.minDepth,t),new vR(l,Lf,s,r)}addSelection(t,s,r,a){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:Lf;return o.length>0&&s-this.prevTime<a&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&chn(o[o.length-1],t)?this:new vR(uhn(this.done,t),this.undone,s,r)}addMapping(t){return new vR(GX(this.done,t),GX(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,s,r){let a=t==0?this.done:this.undone;if(a.length==0)return null;let o=a[a.length-1],l=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):s.selection);if(r&&o.selectionsAfter.length)return s.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:GTe.of({side:t,rest:hhn(a),selection:l}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let c=a.length==1?Lf:a.slice(0,a.length-1);return o.mapped&&(c=GX(c,o.mapped)),s.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:GTe.of({side:t,rest:c,selection:l}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}};YTe.empty=new YTe(Lf,Lf);var k9s=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Odt(e,t){let s=-1;return e.changeByRange(r=>{let a=[];for(let l=r.from;l<=r.to;){let c=e.doc.lineAt(l);c.number>s&&(r.empty||r.to>c.from)&&(t(c,a,r),s=c.number),l=c.to+1}let o=e.changes(a);return{changes:a,range:Qn.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}i(Odt,"changeBySelectedLine$1");var fhn=i(({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Odt(e,(s,r)=>{r.push({from:s.from,insert:e.facet(PH)})}),{userEvent:"input.indent"})),!0),"indentMore$1"),ghn=i(({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Odt(e,(s,r)=>{let a=/^\s*/.exec(s.text)[0];if(!a)return;let o=JS(a,e.tabSize),l=0,c=hI(e,Math.max(0,o-I1(e)));for(;l<a.length&&l<c.length&&a.charCodeAt(l)==c.charCodeAt(l);)l++;r.push({from:s.from+l,to:s.from+a.length,insert:c.slice(l)})}),{userEvent:"delete.dedent"})),!0),"indentLess$1"),xhn={key:"Tab",run:fhn,shift:ghn},JTe="#2e3440",Uve="#3b4252",ZTe="#434c5e",o$="#4c566a",XTe="#e5e9f0",Wle="#eceff4",YX="#8fbcbb",e4e="#88c0d0",vhn="#81a1c1",kg="#5e81ac",bhn="#bf616a",X_="#d08770",JX="#ebcb8b",t4e="#a3be8c",yhn="#b48ead",n4e="#d30102",Kve=Wle,ZX=Kve,khn="#ffffff",XX=Uve,whn=Kve,s4e=Uve,jhn=Br.theme({"&":{color:JTe,backgroundColor:khn},".cm-content":{caretColor:s4e},".cm-cursor, .cm-dropCursor":{borderLeftColor:s4e},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:whn},".cm-panels":{backgroundColor:Kve,color:o$},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:`1px solid ${o$}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:XTe},".cm-activeLine":{backgroundColor:ZX},".cm-selectionMatch":{backgroundColor:XTe},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${o$}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:Wle},".cm-gutters":{backgroundColor:Wle,color:JTe,border:"none"},".cm-activeLineGutter":{backgroundColor:ZX},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:XX},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:XX,borderBottomColor:XX},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:ZX,color:o$}}},{dark:!1}),Nhn=Bve.define([{tag:mn.keyword,color:kg},{tag:[mn.name,mn.deleted,mn.character,mn.propertyName,mn.macroName],color:X_},{tag:[mn.variableName],color:X_},{tag:[mn.function(mn.variableName)],color:kg},{tag:[mn.labelName],color:vhn},{tag:[mn.color,mn.constant(mn.name),mn.standard(mn.name)],color:kg},{tag:[mn.definition(mn.name),mn.separator],color:t4e},{tag:[mn.brace],color:YX},{tag:[mn.annotation],color:n4e},{tag:[mn.number,mn.changed,mn.annotation,mn.modifier,mn.self,mn.namespace],color:e4e},{tag:[mn.typeName,mn.className],color:JX},{tag:[mn.operator,mn.operatorKeyword],color:t4e},{tag:[mn.tagName],color:yhn},{tag:[mn.squareBracket],color:bhn},{tag:[mn.angleBracket],color:X_},{tag:[mn.attributeName],color:JX},{tag:[mn.regexp],color:kg},{tag:[mn.quote],color:Uve},{tag:[mn.string],color:X_},{tag:mn.link,color:YX,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[mn.url,mn.escape,mn.special(mn.string)],color:X_},{tag:[mn.meta],color:e4e},{tag:[mn.comment],color:ZTe,fontStyle:"italic"},{tag:mn.strong,fontWeight:"bold",color:kg},{tag:mn.emphasis,fontStyle:"italic",color:kg},{tag:mn.strikethrough,textDecoration:"line-through"},{tag:mn.heading,fontWeight:"bold",color:kg},{tag:mn.special(mn.heading1),fontWeight:"bold",color:kg},{tag:mn.heading1,fontWeight:"bold",color:kg},{tag:[mn.heading2,mn.heading3,mn.heading4],fontWeight:"bold",color:kg},{tag:[mn.heading5,mn.heading6],color:kg},{tag:[mn.atom,mn.bool,mn.special(mn.variableName)],color:X_},{tag:[mn.processingInstruction,mn.inserted],color:YX},{tag:[mn.contentSeparator],color:JX},{tag:mn.invalid,color:ZTe,borderBottom:`1px dotted ${n4e}`}]),Chn=[jhn,Sdt(Nhn)],Shn=i(e=>{let{state:t}=e,s=t.doc.lineAt(t.selection.main.from),r=Qve(e.state,s.from);return r.line?_hn(e):r.block?Ihn(e):!1},"toggleComment");function Wve(e,t){return({state:s,dispatch:r})=>{if(s.readOnly)return!1;let a=e(t,s);return a?(r(s.update(a)),!0):!1}}i(Wve,"command");var _hn=Wve(Rhn,0),Ahn=Wve(Fdt,0),Ihn=Wve((e,t)=>Fdt(e,t,Ehn(t)),0);function Qve(e,t){let s=e.languageDataAt("commentTokens",t,1);return s.length?s[0]:{}}i(Qve,"getConfig");var l$=50;function Thn(e,{open:t,close:s},r,a){let o=e.sliceDoc(r-l$,r),l=e.sliceDoc(a,a+l$),c=/\s*$/.exec(o)[0].length,d=/^\s*/.exec(l)[0].length,u=o.length-c;if(o.slice(u-t.length,u)==t&&l.slice(d,d+s.length)==s)return{open:{pos:r-c,margin:c&&1},close:{pos:a+d,margin:d&&1}};let h,p;a-r<=100?h=p=e.sliceDoc(r,a):(h=e.sliceDoc(r,r+l$),p=e.sliceDoc(a-l$,a));let f=/^\s*/.exec(h)[0].length,g=/\s*$/.exec(p)[0].length,x=p.length-g-s.length;return h.slice(f,f+t.length)==t&&p.slice(x,x+s.length)==s?{open:{pos:r+f+t.length,margin:/\s/.test(h.charAt(f+t.length))?1:0},close:{pos:a-g-s.length,margin:/\s/.test(p.charAt(x-1))?1:0}}:null}i(Thn,"findBlockComment");function Ehn(e){let t=[];for(let s of e.selection.ranges){let r=e.doc.lineAt(s.from),a=s.to<=r.to?r:e.doc.lineAt(s.to);a.from>r.from&&a.from==s.to&&(a=s.to==r.to+1?r:e.doc.lineAt(s.to-1));let o=t.length-1;o>=0&&t[o].to>r.from?t[o].to=a.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:a.to})}return t}i(Ehn,"selectedLineRanges");function Fdt(e,t,s=t.selection.ranges){let r=s.map(o=>Qve(t,o.from).block);if(!r.every(o=>o))return null;let a=s.map((o,l)=>Thn(t,r[l],o.from,o.to));if(e!=2&&!a.every(o=>o))return{changes:t.changes(s.map((o,l)=>a[l]?[]:[{from:o.from,insert:r[l].open+" "},{from:o.to,insert:" "+r[l].close}]))};if(e!=1&&a.some(o=>o)){let o=[];for(let l=0,c;l<a.length;l++)if(c=a[l]){let d=r[l],{open:u,close:h}=c;o.push({from:u.pos-d.open.length,to:u.pos+u.margin},{from:h.pos-h.margin,to:h.pos+d.close.length})}return{changes:o}}return null}i(Fdt,"changeBlockComment");function Rhn(e,t,s=t.selection.ranges){let r=[],a=-1;e:for(let{from:o,to:l}of s){let c=r.length,d=1e9,u;for(let h=o;h<=l;){let p=t.doc.lineAt(h);if(u==null&&(u=Qve(t,p.from).line,!u))continue e;if(p.from>a&&(o==l||l>p.from)){a=p.from;let f=/^\s*/.exec(p.text)[0].length,g=f==p.length,x=p.text.slice(f,f+u.length)==u?f:-1;f<p.text.length&&f<d&&(d=f),r.push({line:p,comment:x,token:u,indent:f,empty:g,single:!1})}h=p.to+1}if(d<1e9)for(let h=c;h<r.length;h++)r[h].indent<r[h].line.text.length&&(r[h].indent=d);r.length==c+1&&(r[c].single=!0)}if(e!=2&&r.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:c,token:d,indent:u,empty:h,single:p}of r)(p||!h)&&o.push({from:c.from+u,insert:d+" "});let l=t.changes(o);return{changes:l,selection:t.selection.map(l,1)}}else if(e!=1&&r.some(o=>o.comment>=0)){let o=[];for(let{line:l,comment:c,token:d}of r)if(c>=0){let u=l.from+c,h=u+d.length;l.text[h-l.from]==" "&&h++,o.push({from:u,to:h})}return{changes:o}}return null}i(Rhn,"changeLineComment");var Qle=Eb.define(),Mhn=Eb.define(),Lhn=Rr.define(),Bdt=Rr.define({combine(e){return Rb(e,{minDepth:100,newGroupDelay:500,joinToEvent:i((t,s)=>s,"joinToEvent")},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:i((t,s)=>(r,a)=>t(r,a)||s(r,a),"joinToEvent")})}}),zdt=zp.define({create(){return R6.empty},update(e,t){let s=t.state.facet(Bdt),r=t.annotation(Qle);if(r){let d=Qy.fromTransaction(t,r.selection),u=r.side,h=u==0?e.undone:e.done;return d?h=nK(h,h.length,s.minDepth,d):h=Kdt(h,t.startState.selection),new R6(u==0?r.rest:h,u==0?h:r.rest)}let a=t.annotation(Mhn);if((a=="full"||a=="before")&&(e=e.isolate()),t.annotation(Sp.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let o=Qy.fromTransaction(t),l=t.annotation(Sp.time),c=t.annotation(Sp.userEvent);return o?e=e.addChanges(o,l,c,s,t):t.selection&&(e=e.addSelection(t.startState.selection,l,c,s.newGroupDelay)),(a=="full"||a=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new R6(e.done.map(Qy.fromJSON),e.undone.map(Qy.fromJSON))}});function Dhn(e={}){return[zdt,Bdt.of(e),Br.domEventHandlers({beforeinput(t,s){let r=t.inputType=="historyUndo"?qdt:t.inputType=="historyRedo"?Vle:null;return r?(t.preventDefault(),r(s)):!1}})]}i(Dhn,"history");function FH(e,t){return function({state:s,dispatch:r}){if(!t&&s.readOnly)return!1;let a=s.field(zdt,!1);if(!a)return!1;let o=a.pop(e,s,t);return o?(r(o),!0):!1}}i(FH,"cmd");var qdt=FH(0,!1),Vle=FH(1,!1),Phn=FH(0,!0),$hn=FH(1,!0),Qy=class bR{static{i(this,"HistEvent")}constructor(t,s,r,a,o){this.changes=t,this.effects=s,this.mapped=r,this.startSelection=a,this.selectionsAfter=o}setSelAfter(t){return new bR(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,s,r;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(s=this.mapped)===null||s===void 0?void 0:s.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(a=>a.toJSON())}}static fromJSON(t){return new bR(t.changes&&ag.fromJSON(t.changes),[],t.mapped&&m3.fromJSON(t.mapped),t.startSelection&&Qn.fromJSON(t.startSelection),t.selectionsAfter.map(Qn.fromJSON))}static fromTransaction(t,s){let r=Df;for(let a of t.startState.facet(Lhn)){let o=a(t);o.length&&(r=r.concat(o))}return!r.length&&t.changes.empty?null:new bR(t.changes.invert(t.startState.doc),r,void 0,s||t.startState.selection,Df)}static selection(t){return new bR(void 0,Df,void 0,void 0,t)}};function nK(e,t,s,r){let a=t+1>s+20?t-s-1:0,o=e.slice(a,t);return o.push(r),o}i(nK,"updateBranch");function Ohn(e,t){let s=[],r=!1;return e.iterChangedRanges((a,o)=>s.push(a,o)),t.iterChangedRanges((a,o,l,c)=>{for(let d=0;d<s.length;){let u=s[d++],h=s[d++];c>=u&&l<=h&&(r=!0)}}),r}i(Ohn,"isAdjacent");function Fhn(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((s,r)=>s.empty!=t.ranges[r].empty).length===0}i(Fhn,"eqSelectionShape");function Udt(e,t){return e.length?t.length?e.concat(t):e:t}i(Udt,"conc");var Df=[],Bhn=200;function Kdt(e,t){if(e.length){let s=e[e.length-1],r=s.selectionsAfter.slice(Math.max(0,s.selectionsAfter.length-Bhn));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),nK(e,e.length-1,1e9,s.setSelAfter(r)))}else return[Qy.selection([t])]}i(Kdt,"addSelection");function zhn(e){let t=e[e.length-1],s=e.slice();return s[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),s}i(zhn,"popSelection");function eee(e,t){if(!e.length)return e;let s=e.length,r=Df;for(;s;){let a=qhn(e[s-1],t,r);if(a.changes&&!a.changes.empty||a.effects.length){let o=e.slice(0,s);return o[s-1]=a,o}else t=a.mapped,s--,r=a.selectionsAfter}return r.length?[Qy.selection(r)]:Df}i(eee,"addMappingToBranch");function qhn(e,t,s){let r=Udt(e.selectionsAfter.length?e.selectionsAfter.map(c=>c.map(t)):Df,s);if(!e.changes)return Qy.selection(r);let a=e.changes.map(t),o=t.mapDesc(e.changes,!0),l=e.mapped?e.mapped.composeDesc(o):o;return new Qy(a,pa.mapEffects(e.effects,t),l,e.startSelection.map(o),r)}i(qhn,"mapEvent");var Uhn=/^(input\.type|delete)($|\.)/,R6=class yR{static{i(this,"HistoryState")}constructor(t,s,r=0,a=void 0){this.done=t,this.undone=s,this.prevTime=r,this.prevUserEvent=a}isolate(){return this.prevTime?new yR(this.done,this.undone):this}addChanges(t,s,r,a,o){let l=this.done,c=l[l.length-1];return c&&c.changes&&!c.changes.empty&&t.changes&&(!r||Uhn.test(r))&&(!c.selectionsAfter.length&&s-this.prevTime<a.newGroupDelay&&a.joinToEvent(o,Ohn(c.changes,t.changes))||r=="input.type.compose")?l=nK(l,l.length-1,a.minDepth,new Qy(t.changes.compose(c.changes),Udt(pa.mapEffects(t.effects,c.changes),c.effects),c.mapped,c.startSelection,Df)):l=nK(l,l.length,a.minDepth,t),new yR(l,Df,s,r)}addSelection(t,s,r,a){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:Df;return o.length>0&&s-this.prevTime<a&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Fhn(o[o.length-1],t)?this:new yR(Kdt(this.done,t),this.undone,s,r)}addMapping(t){return new yR(eee(this.done,t),eee(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,s,r){let a=t==0?this.done:this.undone;if(a.length==0)return null;let o=a[a.length-1],l=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):s.selection);if(r&&o.selectionsAfter.length)return s.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:Qle.of({side:t,rest:zhn(a),selection:l}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let c=a.length==1?Df:a.slice(0,a.length-1);return o.mapped&&(c=eee(c,o.mapped)),s.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:Qle.of({side:t,rest:c,selection:l}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}};R6.empty=new R6(Df,Df);var Khn=[{key:"Mod-z",run:qdt,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Vle,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Vle,preventDefault:!0},{key:"Mod-u",run:Phn,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:$hn,preventDefault:!0}];function LT(e,t){return Qn.create(e.ranges.map(t),e.mainIndex)}i(LT,"updateSel");function Ex(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}i(Ex,"setSel");function Rx({state:e,dispatch:t},s){let r=LT(e.selection,s);return r.eq(e.selection,!0)?!1:(t(Ex(e,r)),!0)}i(Rx,"moveSel");function BH(e,t){return Qn.cursor(t?e.to:e.from)}i(BH,"rangeEnd");function Wdt(e,t){return Rx(e,s=>s.empty?e.moveByChar(s,t):BH(s,t))}i(Wdt,"cursorByChar");function om(e){return e.textDirectionAt(e.state.selection.main.head)==ql.LTR}i(om,"ltrAtCursor");var Qdt=i(e=>Wdt(e,!om(e)),"cursorCharLeft"),Vdt=i(e=>Wdt(e,om(e)),"cursorCharRight");function Hdt(e,t){return Rx(e,s=>s.empty?e.moveByGroup(s,t):BH(s,t))}i(Hdt,"cursorByGroup");var Whn=i(e=>Hdt(e,!om(e)),"cursorGroupLeft"),Qhn=i(e=>Hdt(e,om(e)),"cursorGroupRight"),w9s=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Vhn(e,t,s){if(t.type.prop(s))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}i(Vhn,"interestingNode");function zH(e,t,s){let r=sm(e).resolveInner(t.head),a=s?Oa.closedBy:Oa.openedBy;for(let d=t.head;;){let u=s?r.childAfter(d):r.childBefore(d);if(!u)break;Vhn(e,u,a)?r=u:d=s?u.to:u.from}let o=r.type.prop(a),l,c;return o&&(l=s?Mv(e,r.from,1):Mv(e,r.to,-1))&&l.matched?c=s?l.end.to:l.end.from:c=s?r.to:r.from,Qn.cursor(c,s?-1:1)}i(zH,"moveBySyntax");var Hhn=i(e=>Rx(e,t=>zH(e.state,t,!om(e))),"cursorSyntaxLeft"),Ghn=i(e=>Rx(e,t=>zH(e.state,t,om(e))),"cursorSyntaxRight");function Gdt(e,t){return Rx(e,s=>{if(!s.empty)return BH(s,t);let r=e.moveVertically(s,t);return r.head!=s.head?r:e.moveToLineBoundary(s,t)})}i(Gdt,"cursorByLine");var Ydt=i(e=>Gdt(e,!1),"cursorLineUp"),Jdt=i(e=>Gdt(e,!0),"cursorLineDown");function Zdt(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,s=0,r=0,a;if(t){for(let o of e.state.facet(Br.scrollMargins)){let l=o(e);l?.top&&(s=Math.max(l?.top,s)),l?.bottom&&(r=Math.max(l?.bottom,r))}a=e.scrollDOM.clientHeight-s-r}else a=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:s,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,a-5)}}i(Zdt,"pageInfo");function Xdt(e,t){let s=Zdt(e),{state:r}=e,a=LT(r.selection,l=>l.empty?e.moveVertically(l,t,s.height):BH(l,t));if(a.eq(r.selection))return!1;let o;if(s.selfScroll){let l=e.coordsAtPos(r.selection.main.head),c=e.scrollDOM.getBoundingClientRect(),d=c.top+s.marginTop,u=c.bottom-s.marginBottom;l&&l.top>d&&l.bottom<u&&(o=Br.scrollIntoView(a.main.head,{y:"start",yMargin:l.top-d}))}return e.dispatch(Ex(r,a),{effects:o}),!0}i(Xdt,"cursorByPage");var r4e=i(e=>Xdt(e,!1),"cursorPageUp"),Hle=i(e=>Xdt(e,!0),"cursorPageDown");function X1(e,t,s){let r=e.lineBlockAt(t.head),a=e.moveToLineBoundary(t,s);if(a.head==t.head&&a.head!=(s?r.to:r.from)&&(a=e.moveToLineBoundary(t,s,!1)),!s&&a.head==r.from&&r.length){let o=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&t.head!=r.from+o&&(a=Qn.cursor(r.from+o))}return a}i(X1,"moveByLineBoundary");var Yhn=i(e=>Rx(e,t=>X1(e,t,!0)),"cursorLineBoundaryForward"),Jhn=i(e=>Rx(e,t=>X1(e,t,!1)),"cursorLineBoundaryBackward"),Zhn=i(e=>Rx(e,t=>X1(e,t,!om(e))),"cursorLineBoundaryLeft"),Xhn=i(e=>Rx(e,t=>X1(e,t,om(e))),"cursorLineBoundaryRight"),emn=i(e=>Rx(e,t=>Qn.cursor(e.lineBlockAt(t.head).from,1)),"cursorLineStart"),tmn=i(e=>Rx(e,t=>Qn.cursor(e.lineBlockAt(t.head).to,-1)),"cursorLineEnd");function nmn(e,t,s){let r=!1,a=LT(e.selection,o=>{let l=Mv(e,o.head,-1)||Mv(e,o.head,1)||o.head>0&&Mv(e,o.head-1,1)||o.head<e.doc.length&&Mv(e,o.head+1,-1);if(!l||!l.end)return o;r=!0;let c=l.start.from==o.head?l.end.to:l.end.from;return s?Qn.range(o.anchor,c):Qn.cursor(c)});return r?(t(Ex(e,a)),!0):!1}i(nmn,"toMatchingBracket");var smn=i(({state:e,dispatch:t})=>nmn(e,t,!1),"cursorMatchingBracket");function hg(e,t){let s=LT(e.state.selection,r=>{let a=t(r);return Qn.range(r.anchor,a.head,a.goalColumn,a.bidiLevel||void 0)});return s.eq(e.state.selection)?!1:(e.dispatch(Ex(e.state,s)),!0)}i(hg,"extendSel");function eut(e,t){return hg(e,s=>e.moveByChar(s,t))}i(eut,"selectByChar");var tut=i(e=>eut(e,!om(e)),"selectCharLeft"),nut=i(e=>eut(e,om(e)),"selectCharRight");function sut(e,t){return hg(e,s=>e.moveByGroup(s,t))}i(sut,"selectByGroup");var rmn=i(e=>sut(e,!om(e)),"selectGroupLeft"),imn=i(e=>sut(e,om(e)),"selectGroupRight"),amn=i(e=>hg(e,t=>zH(e.state,t,!om(e))),"selectSyntaxLeft"),omn=i(e=>hg(e,t=>zH(e.state,t,om(e))),"selectSyntaxRight");function rut(e,t){return hg(e,s=>e.moveVertically(s,t))}i(rut,"selectByLine");var iut=i(e=>rut(e,!1),"selectLineUp"),aut=i(e=>rut(e,!0),"selectLineDown");function out(e,t){return hg(e,s=>e.moveVertically(s,t,Zdt(e).height))}i(out,"selectByPage");var i4e=i(e=>out(e,!1),"selectPageUp"),a4e=i(e=>out(e,!0),"selectPageDown"),lmn=i(e=>hg(e,t=>X1(e,t,!0)),"selectLineBoundaryForward"),cmn=i(e=>hg(e,t=>X1(e,t,!1)),"selectLineBoundaryBackward"),dmn=i(e=>hg(e,t=>X1(e,t,!om(e))),"selectLineBoundaryLeft"),umn=i(e=>hg(e,t=>X1(e,t,om(e))),"selectLineBoundaryRight"),hmn=i(e=>hg(e,t=>Qn.cursor(e.lineBlockAt(t.head).from)),"selectLineStart"),mmn=i(e=>hg(e,t=>Qn.cursor(e.lineBlockAt(t.head).to)),"selectLineEnd"),o4e=i(({state:e,dispatch:t})=>(t(Ex(e,{anchor:0})),!0),"cursorDocStart"),l4e=i(({state:e,dispatch:t})=>(t(Ex(e,{anchor:e.doc.length})),!0),"cursorDocEnd"),c4e=i(({state:e,dispatch:t})=>(t(Ex(e,{anchor:e.selection.main.anchor,head:0})),!0),"selectDocStart"),d4e=i(({state:e,dispatch:t})=>(t(Ex(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),"selectDocEnd"),pmn=i(({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),"selectAll"),fmn=i(({state:e,dispatch:t})=>{let s=qH(e).map(({from:r,to:a})=>Qn.range(r,Math.min(a+1,e.doc.length)));return t(e.update({selection:Qn.create(s),userEvent:"select"})),!0},"selectLine"),gmn=i(({state:e,dispatch:t})=>{let s=LT(e.selection,r=>{let a=sm(e),o=a.resolveStack(r.from,1);if(r.empty){let l=a.resolveStack(r.from,-1);l.node.from>=o.node.from&&l.node.to<=o.node.to&&(o=l)}for(let l=o;l;l=l.next){let{node:c}=l;if((c.from<r.from&&c.to>=r.to||c.to>r.to&&c.from<=r.from)&&l.next)return Qn.range(c.to,c.from)}return r});return s.eq(e.selection)?!1:(t(Ex(e,s)),!0)},"selectParentSyntax");function lut(e,t){let{state:s}=e,r=s.selection,a=s.selection.ranges.slice();for(let o of s.selection.ranges){let l=s.doc.lineAt(o.head);if(t?l.to<e.state.doc.length:l.from>0)for(let c=o;;){let d=e.moveVertically(c,t);if(d.head<l.from||d.head>l.to){a.some(u=>u.head==d.head)||a.push(d);break}else{if(d.head==c.head)break;c=d}}}return a.length==r.ranges.length?!1:(e.dispatch(Ex(s,Qn.create(a,a.length-1))),!0)}i(lut,"addCursorVertically");var xmn=i(e=>lut(e,!1),"addCursorAbove"),vmn=i(e=>lut(e,!0),"addCursorBelow"),bmn=i(({state:e,dispatch:t})=>{let s=e.selection,r=null;return s.ranges.length>1?r=Qn.create([s.main]):s.main.empty||(r=Qn.create([Qn.cursor(s.main.head)])),r?(t(Ex(e,r)),!0):!1},"simplifySelection");function C7(e,t){if(e.state.readOnly)return!1;let s="delete.selection",{state:r}=e,a=r.changeByRange(o=>{let{from:l,to:c}=o;if(l==c){let d=t(o);d<l?(s="delete.backward",d=c$(e,d,!1)):d>l&&(s="delete.forward",d=c$(e,d,!0)),l=Math.min(l,d),c=Math.max(c,d)}else l=c$(e,l,!1),c=c$(e,c,!0);return l==c?{range:o}:{changes:{from:l,to:c},range:Qn.cursor(l,l<o.head?-1:1)}});return a.changes.empty?!1:(e.dispatch(r.update(a,{scrollIntoView:!0,userEvent:s,effects:s=="delete.selection"?Br.announce.of(r.phrase("Selection deleted")):void 0})),!0)}i(C7,"deleteBy");function c$(e,t,s){if(e instanceof Br)for(let r of e.state.facet(Br.atomicRanges).map(a=>a(e)))r.between(t,t,(a,o)=>{a<t&&o>t&&(t=s?o:a)});return t}i(c$,"skipAtomic");var cut=i((e,t,s)=>C7(e,r=>{let a=r.from,{state:o}=e,l=o.doc.lineAt(a),c,d;if(s&&!t&&a>l.from&&a<l.from+200&&!/[^ \t]/.test(c=l.text.slice(0,a-l.from))){if(c[c.length-1]==" ")return a-1;let u=JS(c,o.tabSize)%I1(o)||I1(o);for(let h=0;h<u&&c[c.length-1-h]==" ";h++)a--;d=a}else d=Zu(l.text,a-l.from,t,t)+l.from,d==a&&l.number!=(t?o.doc.lines:1)?d+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(l.text.slice(d-l.from,a-l.from))&&(d=Zu(l.text,d-l.from,!1,!1)+l.from);return d}),"deleteByChar"),Gle=i(e=>cut(e,!1,!0),"deleteCharBackward"),dut=i(e=>cut(e,!0,!1),"deleteCharForward"),uut=i((e,t)=>C7(e,s=>{let r=s.head,{state:a}=e,o=a.doc.lineAt(r),l=a.charCategorizer(r);for(let c=null;;){if(r==(t?o.to:o.from)){r==s.head&&o.number!=(t?a.doc.lines:1)&&(r+=t?1:-1);break}let d=Zu(o.text,r-o.from,t)+o.from,u=o.text.slice(Math.min(r,d)-o.from,Math.max(r,d)-o.from),h=l(u);if(c!=null&&h!=c)break;(u!=" "||r!=s.head)&&(c=h),r=d}return r}),"deleteByGroup"),hut=i(e=>uut(e,!1),"deleteGroupBackward"),ymn=i(e=>uut(e,!0),"deleteGroupForward"),kmn=i(e=>C7(e,t=>{let s=e.lineBlockAt(t.head).to;return t.head<s?s:Math.min(e.state.doc.length,t.head+1)}),"deleteToLineEnd"),wmn=i(e=>C7(e,t=>{let s=e.moveToLineBoundary(t,!1).head;return t.head>s?s:Math.max(0,t.head-1)}),"deleteLineBoundaryBackward"),jmn=i(e=>C7(e,t=>{let s=e.moveToLineBoundary(t,!0).head;return t.head<s?s:Math.min(e.state.doc.length,t.head+1)}),"deleteLineBoundaryForward"),Nmn=i(({state:e,dispatch:t})=>{if(e.readOnly)return!1;let s=e.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:Po.of(["",""])},range:Qn.cursor(r.from)}));return t(e.update(s,{scrollIntoView:!0,userEvent:"input"})),!0},"splitLine"),Cmn=i(({state:e,dispatch:t})=>{if(e.readOnly)return!1;let s=e.changeByRange(r=>{if(!r.empty||r.from==0||r.from==e.doc.length)return{range:r};let a=r.from,o=e.doc.lineAt(a),l=a==o.from?a-1:Zu(o.text,a-o.from,!1)+o.from,c=a==o.to?a+1:Zu(o.text,a-o.from,!0)+o.from;return{changes:{from:l,to:c,insert:e.doc.slice(a,c).append(e.doc.slice(l,a))},range:Qn.cursor(c)}});return s.changes.empty?!1:(t(e.update(s,{scrollIntoView:!0,userEvent:"move.character"})),!0)},"transposeChars");function qH(e){let t=[],s=-1;for(let r of e.selection.ranges){let a=e.doc.lineAt(r.from),o=e.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=e.doc.lineAt(r.to-1)),s>=a.number){let l=t[t.length-1];l.to=o.to,l.ranges.push(r)}else t.push({from:a.from,to:o.to,ranges:[r]});s=o.number+1}return t}i(qH,"selectedLineBlocks");function mut(e,t,s){if(e.readOnly)return!1;let r=[],a=[];for(let o of qH(e)){if(s?o.to==e.doc.length:o.from==0)continue;let l=e.doc.lineAt(s?o.to+1:o.from-1),c=l.length+1;if(s){r.push({from:o.to,to:l.to},{from:o.from,insert:l.text+e.lineBreak});for(let d of o.ranges)a.push(Qn.range(Math.min(e.doc.length,d.anchor+c),Math.min(e.doc.length,d.head+c)))}else{r.push({from:l.from,to:o.from},{from:o.to,insert:e.lineBreak+l.text});for(let d of o.ranges)a.push(Qn.range(d.anchor-c,d.head-c))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:Qn.create(a,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}i(mut,"moveLine");var Smn=i(({state:e,dispatch:t})=>mut(e,t,!1),"moveLineUp"),_mn=i(({state:e,dispatch:t})=>mut(e,t,!0),"moveLineDown");function put(e,t,s){if(e.readOnly)return!1;let r=[];for(let o of qH(e))s?r.push({from:o.from,insert:e.doc.slice(o.from,o.to)+e.lineBreak}):r.push({from:o.to,insert:e.lineBreak+e.doc.slice(o.from,o.to)});let a=e.changes(r);return t(e.update({changes:a,selection:e.selection.map(a,s?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}i(put,"copyLine");var Amn=i(({state:e,dispatch:t})=>put(e,t,!1),"copyLineUp"),Imn=i(({state:e,dispatch:t})=>put(e,t,!0),"copyLineDown"),Tmn=i(e=>{if(e.state.readOnly)return!1;let{state:t}=e,s=t.changes(qH(t).map(({from:a,to:o})=>(a>0?a--:o<t.doc.length&&o++,{from:a,to:o}))),r=LT(t.selection,a=>{let o;if(e.lineWrapping){let l=e.lineBlockAt(a.head),c=e.coordsAtPos(a.head,a.assoc||1);c&&(o=l.bottom+e.documentTop-c.bottom+e.defaultLineHeight/2)}return e.moveVertically(a,!0,o)}).map(s);return e.dispatch({changes:s,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0},"deleteLine");function Emn(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let s=sm(e).resolveInner(t),r=s.childBefore(t),a=s.childAfter(t),o;return r&&a&&r.to<=t&&a.from>=t&&(o=r.type.prop(Oa.closedBy))&&o.indexOf(a.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(a.from).from&&!/\S/.test(e.sliceDoc(r.to,a.from))?{from:r.to,to:a.from}:null}i(Emn,"isBetweenBrackets");var u4e=fut(!1),Rmn=fut(!0);function fut(e){return({state:t,dispatch:s})=>{if(t.readOnly)return!1;let r=t.changeByRange(a=>{let{from:o,to:l}=a,c=t.doc.lineAt(o),d=!e&&o==l&&Emn(t,o);e&&(o=l=(l<=c.to?c:t.doc.lineAt(l)).to);let u=new $H(t,{simulateBreak:o,simulateDoubleBreak:!!d}),h=Ove(u,o);for(h==null&&(h=JS(/^\s*/.exec(t.doc.lineAt(o).text)[0],t.tabSize));l<c.to&&/\s/.test(c.text[l-c.from]);)l++;d?{from:o,to:l}=d:o>c.from&&o<c.from+100&&!/\S/.test(c.text.slice(0,o))&&(o=c.from);let p=["",hI(t,h)];return d&&p.push(hI(t,u.lineIndent(c.from,-1))),{changes:{from:o,to:l,insert:Po.of(p)},range:Qn.cursor(o+1+p[1].length)}});return s(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}i(fut,"newlineAndIndent");function Vve(e,t){let s=-1;return e.changeByRange(r=>{let a=[];for(let l=r.from;l<=r.to;){let c=e.doc.lineAt(l);c.number>s&&(r.empty||r.to>c.from)&&(t(c,a,r),s=c.number),l=c.to+1}let o=e.changes(a);return{changes:a,range:Qn.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}i(Vve,"changeBySelectedLine");var Mmn=i(({state:e,dispatch:t})=>{if(e.readOnly)return!1;let s=Object.create(null),r=new $H(e,{overrideIndentation:i(o=>{let l=s[o];return l??-1},"overrideIndentation")}),a=Vve(e,(o,l,c)=>{let d=Ove(r,o.from);if(d==null)return;/\S/.test(o.text)||(d=0);let u=/^\s*/.exec(o.text)[0],h=hI(e,d);(u!=h||c.from<o.from+u.length)&&(s[o.from]=d,l.push({from:o.from,to:o.from+u.length,insert:h}))});return a.changes.empty||t(e.update(a,{userEvent:"indent"})),!0},"indentSelection"),Lmn=i(({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Vve(e,(s,r)=>{r.push({from:s.from,insert:e.facet(PH)})}),{userEvent:"input.indent"})),!0),"indentMore"),Dmn=i(({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Vve(e,(s,r)=>{let a=/^\s*/.exec(s.text)[0];if(!a)return;let o=JS(a,e.tabSize),l=0,c=hI(e,Math.max(0,o-I1(e)));for(;l<a.length&&l<c.length&&a.charCodeAt(l)==c.charCodeAt(l);)l++;r.push({from:s.from+l,to:s.from+a.length,insert:c.slice(l)})}),{userEvent:"delete.dedent"})),!0),"indentLess"),Pmn=i(e=>(e.setTabFocusMode(),!0),"toggleTabFocusMode"),$mn=[{key:"Ctrl-b",run:Qdt,shift:tut,preventDefault:!0},{key:"Ctrl-f",run:Vdt,shift:nut},{key:"Ctrl-p",run:Ydt,shift:iut},{key:"Ctrl-n",run:Jdt,shift:aut},{key:"Ctrl-a",run:emn,shift:hmn},{key:"Ctrl-e",run:tmn,shift:mmn},{key:"Ctrl-d",run:dut},{key:"Ctrl-h",run:Gle},{key:"Ctrl-k",run:kmn},{key:"Ctrl-Alt-h",run:hut},{key:"Ctrl-o",run:Nmn},{key:"Ctrl-t",run:Cmn},{key:"Ctrl-v",run:Hle}],Omn=[{key:"ArrowLeft",run:Qdt,shift:tut,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Whn,shift:rmn,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Zhn,shift:dmn,preventDefault:!0},{key:"ArrowRight",run:Vdt,shift:nut,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Qhn,shift:imn,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Xhn,shift:umn,preventDefault:!0},{key:"ArrowUp",run:Ydt,shift:iut,preventDefault:!0},{mac:"Cmd-ArrowUp",run:o4e,shift:c4e},{mac:"Ctrl-ArrowUp",run:r4e,shift:i4e},{key:"ArrowDown",run:Jdt,shift:aut,preventDefault:!0},{mac:"Cmd-ArrowDown",run:l4e,shift:d4e},{mac:"Ctrl-ArrowDown",run:Hle,shift:a4e},{key:"PageUp",run:r4e,shift:i4e},{key:"PageDown",run:Hle,shift:a4e},{key:"Home",run:Jhn,shift:cmn,preventDefault:!0},{key:"Mod-Home",run:o4e,shift:c4e},{key:"End",run:Yhn,shift:lmn,preventDefault:!0},{key:"Mod-End",run:l4e,shift:d4e},{key:"Enter",run:u4e,shift:u4e},{key:"Mod-a",run:pmn},{key:"Backspace",run:Gle,shift:Gle,preventDefault:!0},{key:"Delete",run:dut,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:hut,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:ymn,preventDefault:!0},{mac:"Mod-Backspace",run:wmn,preventDefault:!0},{mac:"Mod-Delete",run:jmn,preventDefault:!0}].concat($mn.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Fmn=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Hhn,shift:amn},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Ghn,shift:omn},{key:"Alt-ArrowUp",run:Smn},{key:"Shift-Alt-ArrowUp",run:Amn},{key:"Alt-ArrowDown",run:_mn},{key:"Shift-Alt-ArrowDown",run:Imn},{key:"Mod-Alt-ArrowUp",run:xmn},{key:"Mod-Alt-ArrowDown",run:vmn},{key:"Escape",run:bmn},{key:"Mod-Enter",run:Rmn},{key:"Alt-l",mac:"Ctrl-l",run:fmn},{key:"Mod-i",run:gmn,preventDefault:!0},{key:"Mod-[",run:Dmn},{key:"Mod-]",run:Lmn},{key:"Mod-Alt-\\",run:Mmn},{key:"Shift-Mod-k",run:Tmn},{key:"Shift-Mod-\\",run:smn},{key:"Mod-/",run:Shn},{key:"Alt-A",run:Ahn},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Pmn}].concat(Omn),h4e=typeof String.prototype.normalize=="function"?e=>e.normalize("NFKD"):e=>e,mI=class{static{i(this,"SearchCursor")}constructor(e,t,s=0,r=e.length,a,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(s,r),this.bufferStart=s,this.normalize=a?l=>a(h4e(l)):h4e,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return lp(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=yve(e),s=this.bufferStart+this.bufferPos;this.bufferPos+=kv(e);let r=this.normalize(t);if(r.length)for(let a=0,o=s;;a++){let l=r.charCodeAt(a),c=this.match(l,o,this.bufferPos+this.bufferStart);if(a==r.length-1){if(c)return this.value=c,this;break}o==s&&a<t.length&&t.charCodeAt(a)==l&&o++}}}match(e,t,s){let r=null;for(let a=0;a<this.matches.length;a+=2){let o=this.matches[a],l=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?r={from:this.matches[a+1],to:s}:(this.matches[a]++,l=!0)),l||(this.matches.splice(a,2),a-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:s}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<"u"&&(mI.prototype[Symbol.iterator]=function(){return this});var gut={from:-1,to:-1,match:/.*/.exec("")},Hve="gm"+(/x/.unicode==null?"":"u"),xut=class{static{i(this,"RegExpCursor")}constructor(e,t,s,r=0,a=e.length){if(this.text=e,this.to=a,this.curLine="",this.done=!1,this.value=gut,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new vut(e,t,s,r,a);this.re=new RegExp(t,Hve+(s?.ignoreCase?"i":"")),this.test=s?.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=sK(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let s=this.curLineStart+t.index,r=s+t[0].length;if(this.matchPos=sK(this.text,r+(s==r?1:0)),s==this.curLineStart+this.curLine.length&&this.nextLine(),(s<r||s>this.value.to)&&(!this.test||this.test(s,r,t)))return this.value={from:s,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},tee=new WeakMap,m4e=class OB{static{i(this,"FlattenedDoc")}constructor(t,s){this.from=t,this.text=s}get to(){return this.from+this.text.length}static get(t,s,r){let a=tee.get(t);if(!a||a.from>=r||a.to<=s){let c=new OB(s,t.sliceString(s,r));return tee.set(t,c),c}if(a.from==s&&a.to==r)return a;let{text:o,from:l}=a;return l>s&&(o=t.sliceString(s,l)+o,l=s),a.to<r&&(o+=t.sliceString(a.to,r)),tee.set(t,new OB(l,o)),new OB(s,o.slice(s-l,r-l))}},vut=class{static{i(this,"MultilineRegExpCursor")}constructor(e,t,s,r,a){this.text=e,this.to=a,this.done=!1,this.value=gut,this.matchPos=sK(e,r),this.re=new RegExp(t,Hve+(s?.ignoreCase?"i":"")),this.test=s?.test,this.flat=m4e.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let s=this.flat.from+t.index,r=s+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(s,r,t)))return this.value={from:s,to:r,match:t},this.matchPos=sK(this.text,r+(s==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=m4e.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<"u"&&(xut.prototype[Symbol.iterator]=vut.prototype[Symbol.iterator]=function(){return this});function Bmn(e){try{return new RegExp(e,Hve),!0}catch{return!1}}i(Bmn,"validRegExp");function sK(e,t){if(t>=e.length)return t;let s=e.lineAt(t),r;for(;t<s.to&&(r=s.text.charCodeAt(t-s.from))>=56320&&r<57344;)t++;return t}i(sK,"toCharEnd");var zmn=i(e=>{let{state:t}=e,s=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:a}=qdn(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:s},focus:!0,submitLabel:t.phrase("go")});return a.then(o=>{let l=o&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(o.elements.line.value);if(!l){e.dispatch({effects:r});return}let c=t.doc.lineAt(t.selection.main.head),[,d,u,h,p]=l,f=h?+h.slice(1):0,g=u?+u:c.number;if(u&&p){let b=g/100;d&&(b=b*(d=="-"?-1:1)+c.number/t.doc.lines),g=Math.round(t.doc.lines*b)}else u&&d&&(g=g*(d=="-"?-1:1)+c.number);let x=t.doc.line(Math.max(1,Math.min(t.doc.lines,g))),v=Qn.cursor(x.from+Math.max(0,Math.min(f,x.length)));e.dispatch({effects:[r,Br.scrollIntoView(v.from,{y:"center"})],selection:v})}),!0},"gotoLine"),qmn={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},but=Rr.define({combine(e){return Rb(e,qmn,{highlightWordAroundCursor:i((t,s)=>t||s,"highlightWordAroundCursor"),minSelectionLength:Math.min,maxMatches:Math.min})}});function Umn(e){let t=[Hmn,Vmn];return e&&t.push(but.of(e)),t}i(Umn,"highlightSelectionMatches");var Kmn=Ui.mark({class:"cm-selectionMatch"}),Wmn=Ui.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function p4e(e,t,s,r){return(s==0||e(t.sliceDoc(s-1,s))!=wc.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=wc.Word)}i(p4e,"insideWordBoundaries");function Qmn(e,t,s,r){return e(t.sliceDoc(s,s+1))==wc.Word&&e(t.sliceDoc(r-1,r))==wc.Word}i(Qmn,"insideWord");var Vmn=rh.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(but),{state:s}=e,r=s.selection;if(r.ranges.length>1)return Ui.none;let a=r.main,o,l=null;if(a.empty){if(!t.highlightWordAroundCursor)return Ui.none;let d=s.wordAt(a.head);if(!d)return Ui.none;l=s.charCategorizer(a.head),o=s.sliceDoc(d.from,d.to)}else{let d=a.to-a.from;if(d<t.minSelectionLength||d>200)return Ui.none;if(t.wholeWords){if(o=s.sliceDoc(a.from,a.to),l=s.charCategorizer(a.head),!(p4e(l,s,a.from,a.to)&&Qmn(l,s,a.from,a.to)))return Ui.none}else if(o=s.sliceDoc(a.from,a.to),!o)return Ui.none}let c=[];for(let d of e.visibleRanges){let u=new mI(s.doc,o,d.from,d.to);for(;!u.next().done;){let{from:h,to:p}=u.value;if((!l||p4e(l,s,h,p))&&(a.empty&&h<=a.from&&p>=a.to?c.push(Wmn.range(h,p)):(h>=a.to||p<=a.from)&&c.push(Kmn.range(h,p)),c.length>t.maxMatches))return Ui.none}}return Ui.set(c)}},{decorations:i(e=>e.decorations,"decorations")}),Hmn=Br.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Gmn=i(({state:e,dispatch:t})=>{let{selection:s}=e,r=Qn.create(s.ranges.map(a=>e.wordAt(a.head)||Qn.cursor(a.head)),s.mainIndex);return r.eq(s)?!1:(t(e.update({selection:r})),!0)},"selectWord");function Ymn(e,t){let{main:s,ranges:r}=e.selection,a=e.wordAt(s.head),o=a&&a.from==s.from&&a.to==s.to;for(let l=!1,c=new mI(e.doc,t,r[r.length-1].to);;)if(c.next(),c.done){if(l)return null;c=new mI(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),l=!0}else{if(l&&r.some(d=>d.from==c.value.from))continue;if(o){let d=e.wordAt(c.value.from);if(!d||d.from!=c.value.from||d.to!=c.value.to)continue}return c.value}}i(Ymn,"findNextOccurrence");var Jmn=i(({state:e,dispatch:t})=>{let{ranges:s}=e.selection;if(s.some(o=>o.from===o.to))return Gmn({state:e,dispatch:t});let r=e.sliceDoc(s[0].from,s[0].to);if(e.selection.ranges.some(o=>e.sliceDoc(o.from,o.to)!=r))return!1;let a=Ymn(e,r);return a?(t(e.update({selection:e.selection.addRange(Qn.range(a.from,a.to),!1),effects:Br.scrollIntoView(a.to)})),!0):!1},"selectNextOccurrence"),DT=Rr.define({combine(e){return Rb(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:i(t=>new upn(t),"createPanel"),scrollToMatch:i(t=>Br.scrollIntoView(t),"scrollToMatch")})}}),yut=class{static{i(this,"SearchQuery")}constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||Bmn(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,s)=>s=="n"?`
173
173
  `:s=="r"?"\r":s=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new spn(this):new epn(this)}getCursor(e,t=0,s){let r=e.doc?e:Dc.create({doc:e});return s==null&&(s=r.doc.length),this.regexp?U2(this,r,t,s):q2(this,r,t,s)}},kut=class{static{i(this,"QueryType")}constructor(e){this.spec=e}};function Zmn(e,t,s){return(r,a,o,l)=>s&&!s(r,a,o,l)?!1:e(r>=l&&a<=l+o.length?o.slice(r-l,a-l):t.doc.sliceString(r,a),t,r,a)}i(Zmn,"wrapStringTest");function q2(e,t,s,r){let a;return e.wholeWord&&(a=Xmn(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(a=Zmn(e.test,t,a)),new mI(t.doc,e.unquoted,s,r,e.caseSensitive?void 0:o=>o.toLowerCase(),a)}i(q2,"stringCursor");function Xmn(e,t){return(s,r,a,o)=>((o>s||o+a.length<r)&&(o=Math.max(0,s-2),a=e.sliceString(o,Math.min(e.length,r+2))),(t(rK(a,s-o))!=wc.Word||t(iK(a,s-o))!=wc.Word)&&(t(iK(a,r-o))!=wc.Word||t(rK(a,r-o))!=wc.Word))}i(Xmn,"stringWordTest");var epn=class extends kut{static{i(this,"StringQuery")}constructor(e){super(e)}nextMatch(e,t,s){let r=q2(this.spec,e,s,e.doc.length).nextOverlapping();if(r.done){let a=Math.min(e.doc.length,t+this.spec.unquoted.length);r=q2(this.spec,e,0,a).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==s?null:r.value}prevMatchInRange(e,t,s){for(let r=s;;){let a=Math.max(t,r-1e4-this.spec.unquoted.length),o=q2(this.spec,e,a,r),l=null;for(;!o.nextOverlapping().done;)l=o.value;if(l)return l;if(a==t)return null;r-=1e4}}prevMatch(e,t,s){let r=this.prevMatchInRange(e,0,t);return r||(r=this.prevMatchInRange(e,Math.max(0,s-this.spec.unquoted.length),e.doc.length)),r&&(r.from!=t||r.to!=s)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let s=q2(this.spec,e,0,e.doc.length),r=[];for(;!s.next().done;){if(r.length>=t)return null;r.push(s.value)}return r}highlight(e,t,s,r){let a=q2(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(s+this.spec.unquoted.length,e.doc.length));for(;!a.next().done;)r(a.value.from,a.value.to)}};function tpn(e,t,s){return(r,a,o)=>(!s||s(r,a,o))&&e(o[0],t,r,a)}i(tpn,"wrapRegexpTest");function U2(e,t,s,r){let a;return e.wholeWord&&(a=npn(t.charCategorizer(t.selection.main.head))),e.test&&(a=tpn(e.test,t,a)),new xut(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:a},s,r)}i(U2,"regexpCursor");function rK(e,t){return e.slice(Zu(e,t,!1),t)}i(rK,"charBefore");function iK(e,t){return e.slice(t,Zu(e,t))}i(iK,"charAfter");function npn(e){return(t,s,r)=>!r[0].length||(e(rK(r.input,r.index))!=wc.Word||e(iK(r.input,r.index))!=wc.Word)&&(e(iK(r.input,r.index+r[0].length))!=wc.Word||e(rK(r.input,r.index+r[0].length))!=wc.Word)}i(npn,"regexpWordTest");var spn=class extends kut{static{i(this,"RegExpQuery")}nextMatch(e,t,s){let r=U2(this.spec,e,s,e.doc.length).next();return r.done&&(r=U2(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,s){for(let r=1;;r++){let a=Math.max(t,s-r*1e4),o=U2(this.spec,e,a,s),l=null;for(;!o.next().done;)l=o.value;if(l&&(a==t||l.from>a+10))return l;if(a==t)return null}}prevMatch(e,t,s){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,s,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,s)=>{if(s=="&")return e.match[0];if(s=="$")return"$";for(let r=s.length;r>0;r--){let a=+s.slice(0,r);if(a>0&&a<e.match.length)return e.match[a]+s.slice(r)}return t})}matchAll(e,t){let s=U2(this.spec,e,0,e.doc.length),r=[];for(;!s.next().done;){if(r.length>=t)return null;r.push(s.value)}return r}highlight(e,t,s,r){let a=U2(this.spec,e,Math.max(0,t-250),Math.min(s+250,e.doc.length));for(;!a.next().done;)r(a.value.from,a.value.to)}},RL=pa.define(),Gve=pa.define(),zj=zp.define({create(e){return new nee(Yle(e).create(),null)},update(e,t){for(let s of t.effects)s.is(RL)?e=new nee(s.value.create(),e.panel):s.is(Gve)&&(e=new nee(e.query,s.value?Yve:null));return e},provide:i(e=>AL.from(e,t=>t.panel),"provide")}),nee=class{static{i(this,"SearchState")}constructor(e,t){this.query=e,this.panel=t}},rpn=Ui.mark({class:"cm-searchMatch"}),ipn=Ui.mark({class:"cm-searchMatch cm-searchMatch-selected"}),apn=rh.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(zj))}update(e){let t=e.state.field(zj);(t!=e.startState.field(zj)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return Ui.none;let{view:s}=this,r=new Bj;for(let a=0,o=s.visibleRanges,l=o.length;a<l;a++){let{from:c,to:d}=o[a];for(;a<l-1&&d>o[a+1].from-500;)d=o[++a].to;e.highlight(s.state,c,d,(u,h)=>{let p=s.state.selection.ranges.some(f=>f.from==u&&f.to==h);r.add(u,h,p?ipn:rpn)})}return r.finish()}},{decorations:i(e=>e.decorations,"decorations")});function S7(e){return t=>{let s=t.state.field(zj,!1);return s&&s.query.spec.valid?e(t,s):Nut(t)}}i(S7,"searchCommand");var aK=S7((e,{query:t})=>{let{to:s}=e.state.selection.main,r=t.nextMatch(e.state,s,s);if(!r)return!1;let a=Qn.single(r.from,r.to),o=e.state.facet(DT);return e.dispatch({selection:a,effects:[Jve(e,r),o.scrollToMatch(a.main,e)],userEvent:"select.search"}),jut(e),!0}),oK=S7((e,{query:t})=>{let{state:s}=e,{from:r}=s.selection.main,a=t.prevMatch(s,r,r);if(!a)return!1;let o=Qn.single(a.from,a.to),l=e.state.facet(DT);return e.dispatch({selection:o,effects:[Jve(e,a),l.scrollToMatch(o.main,e)],userEvent:"select.search"}),jut(e),!0}),opn=S7((e,{query:t})=>{let s=t.matchAll(e.state,1e3);return!s||!s.length?!1:(e.dispatch({selection:Qn.create(s.map(r=>Qn.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),lpn=i(({state:e,dispatch:t})=>{let s=e.selection;if(s.ranges.length>1||s.main.empty)return!1;let{from:r,to:a}=s.main,o=[],l=0;for(let c=new mI(e.doc,e.sliceDoc(r,a));!c.next().done;){if(o.length>1e3)return!1;c.value.from==r&&(l=o.length),o.push(Qn.range(c.value.from,c.value.to))}return t(e.update({selection:Qn.create(o,l),userEvent:"select.search.matches"})),!0},"selectSelectionMatches"),f4e=S7((e,{query:t})=>{let{state:s}=e,{from:r,to:a}=s.selection.main;if(s.readOnly)return!1;let o=t.nextMatch(s,r,r);if(!o)return!1;let l=o,c=[],d,u,h=[];l.from==r&&l.to==a&&(u=s.toText(t.getReplacement(l)),c.push({from:l.from,to:l.to,insert:u}),l=t.nextMatch(s,l.from,l.to),h.push(Br.announce.of(s.phrase("replaced match on line $",s.doc.lineAt(r).number)+".")));let p=e.state.changes(c);return l&&(d=Qn.single(l.from,l.to).map(p),h.push(Jve(e,l)),h.push(s.facet(DT).scrollToMatch(d.main,e))),e.dispatch({changes:p,selection:d,effects:h,userEvent:"input.replace"}),!0}),cpn=S7((e,{query:t})=>{if(e.state.readOnly)return!1;let s=t.matchAll(e.state,1e9).map(a=>{let{from:o,to:l}=a;return{from:o,to:l,insert:t.getReplacement(a)}});if(!s.length)return!1;let r=e.state.phrase("replaced $ matches",s.length)+".";return e.dispatch({changes:s,effects:Br.announce.of(r),userEvent:"input.replace.all"}),!0});function Yve(e){return e.state.facet(DT).createPanel(e)}i(Yve,"createSearchPanel");function Yle(e,t){var s,r,a,o,l;let c=e.selection.main,d=c.empty||c.to>c.from+100?"":e.sliceDoc(c.from,c.to);if(t&&!d)return t;let u=e.facet(DT);return new yut({search:((s=t?.literal)!==null&&s!==void 0?s:u.literal)?d:d.replace(/\n/g,"\\n"),caseSensitive:(r=t?.caseSensitive)!==null&&r!==void 0?r:u.caseSensitive,literal:(a=t?.literal)!==null&&a!==void 0?a:u.literal,regexp:(o=t?.regexp)!==null&&o!==void 0?o:u.regexp,wholeWord:(l=t?.wholeWord)!==null&&l!==void 0?l:u.wholeWord})}i(Yle,"defaultQuery");function wut(e){let t=$ve(e,Yve);return t&&t.dom.querySelector("[main-field]")}i(wut,"getSearchInput");function jut(e){let t=wut(e);t&&t==e.root.activeElement&&t.select()}i(jut,"selectSearchInput");var Nut=i(e=>{let t=e.state.field(zj,!1);if(t&&t.panel){let s=wut(e);if(s&&s!=e.root.activeElement){let r=Yle(e.state,t.query.spec);r.valid&&e.dispatch({effects:RL.of(r)}),s.focus(),s.select()}}else e.dispatch({effects:[Gve.of(!0),t?RL.of(Yle(e.state,t.query.spec)):pa.appendConfig.of(mpn)]});return!0},"openSearchPanel"),Cut=i(e=>{let t=e.state.field(zj,!1);if(!t||!t.panel)return!1;let s=$ve(e,Yve);return s&&s.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:Gve.of(!1)}),!0},"closeSearchPanel"),dpn=[{key:"Mod-f",run:Nut,scope:"editor search-panel"},{key:"F3",run:aK,shift:oK,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:aK,shift:oK,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Cut,scope:"editor search-panel"},{key:"Mod-Shift-l",run:lpn},{key:"Mod-Alt-g",run:zmn},{key:"Mod-d",run:Jmn,preventDefault:!0}],upn=class{static{i(this,"SearchPanel")}constructor(e){this.view=e;let t=this.query=e.state.field(zj).query.spec;this.commit=this.commit.bind(this),this.searchField=gl("input",{value:t.search,placeholder:Xp(e,"Find"),"aria-label":Xp(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=gl("input",{value:t.replace,placeholder:Xp(e,"Replace"),"aria-label":Xp(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=gl("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=gl("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=gl("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function s(r,a,o){return gl("button",{class:"cm-button",name:r,onclick:a,type:"button"},o)}i(s,"button"),this.dom=gl("div",{onkeydown:i(r=>this.keydown(r),"onkeydown"),class:"cm-search"},[this.searchField,s("next",()=>aK(e),[Xp(e,"next")]),s("prev",()=>oK(e),[Xp(e,"previous")]),s("select",()=>opn(e),[Xp(e,"all")]),gl("label",null,[this.caseField,Xp(e,"match case")]),gl("label",null,[this.reField,Xp(e,"regexp")]),gl("label",null,[this.wordField,Xp(e,"by word")]),...e.state.readOnly?[]:[gl("br"),this.replaceField,s("replace",()=>f4e(e),[Xp(e,"replace")]),s("replaceAll",()=>cpn(e),[Xp(e,"replace all")])],gl("button",{name:"close",onclick:i(()=>Cut(e),"onclick"),"aria-label":Xp(e,"close"),type:"button"},["×"])])}commit(){let e=new yut({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:RL.of(e)}))}keydown(e){Zcn(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?oK:aK)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),f4e(this.view))}update(e){for(let t of e.transactions)for(let s of t.effects)s.is(RL)&&!s.value.eq(this.query)&&this.setQuery(s.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(DT).top}};function Xp(e,t){return e.state.phrase(t)}i(Xp,"phrase");var d$=30,u$=/[\s\.,:;?!]/;function Jve(e,{from:t,to:s}){let r=e.state.doc.lineAt(t),a=e.state.doc.lineAt(s).to,o=Math.max(r.from,t-d$),l=Math.min(a,s+d$),c=e.state.sliceDoc(o,l);if(o!=r.from){for(let d=0;d<d$;d++)if(!u$.test(c[d+1])&&u$.test(c[d])){c=c.slice(d);break}}if(l!=a){for(let d=c.length-1;d>c.length-d$;d--)if(!u$.test(c[d-1])&&u$.test(c[d])){c=c.slice(0,d);break}}return Br.announce.of(`${e.state.phrase("current match")}. ${c} ${e.state.phrase("on line")} ${r.number}.`)}i(Jve,"announceMatch");var hpn=Br.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),mpn=[zj,YS.low(apn),hpn],Sut=class{static{i(this,"CompletionContext")}constructor(e,t,s,r){this.state=e,this.pos=t,this.explicit=s,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=sm(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),s=Math.max(t.from,this.pos-250),r=t.text.slice(s-t.from,this.pos-t.from),a=r.search(_ut(e,!1));return a<0?null:{from:s+a,to:this.pos,text:r.slice(a)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,s){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),s&&s.onDocChange&&(this.abortOnDocChange=!0))}};function g4e(e){let t=Object.keys(e).join(""),s=/\w/.test(t);return s&&(t=t.replace(/\w/g,"")),`[${s?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}i(g4e,"toSet");function ppn(e){let t=Object.create(null),s=Object.create(null);for(let{label:a}of e){t[a[0]]=!0;for(let o=1;o<a.length;o++)s[a[o]]=!0}let r=g4e(t)+g4e(s)+"*$";return[new RegExp("^"+r),new RegExp(r)]}i(ppn,"prefixMatch");function fpn(e){let t=e.map(a=>typeof a=="string"?{label:a}:a),[s,r]=t.every(a=>/^\w+$/.test(a.label))?[/\w*$/,/\w+$/]:ppn(t);return a=>{let o=a.matchBefore(r);return o||a.explicit?{from:o?o.from:a.pos,options:t,validFor:s}:null}}i(fpn,"completeFromList");var x4e=class{static{i(this,"Option")}constructor(e,t,s,r){this.completion=e,this.source=t,this.match=s,this.score=r}};function f3(e){return e.selection.main.from}i(f3,"cur");function _ut(e,t){var s;let{source:r}=e,a=t&&r[0]!="^",o=r[r.length-1]!="$";return!a&&!o?e:new RegExp(`${a?"^":""}(?:${r})${o?"$":""}`,(s=e.flags)!==null&&s!==void 0?s:e.ignoreCase?"i":"")}i(_ut,"ensureAnchor");var Aut=Eb.define();function gpn(e,t,s,r){let{main:a}=e.selection,o=s-a.from,l=r-a.from;return{...e.changeByRange(c=>{if(c!=a&&s!=r&&e.sliceDoc(c.from+o,c.from+l)!=e.sliceDoc(s,r))return{range:c};let d=e.toText(t);return{changes:{from:c.from+o,to:r==a.from?c.to:c.from+l,insert:d},range:Qn.cursor(c.from+o+d.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}i(gpn,"insertCompletionText");var v4e=new WeakMap;function xpn(e){if(!Array.isArray(e))return e;let t=v4e.get(e);return t||v4e.set(e,t=fpn(e)),t}i(xpn,"asSource");var lK=pa.define(),ML=pa.define(),vpn=class{static{i(this,"FuzzyMatcher")}constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let s=lp(e,t),r=kv(s);this.chars.push(s);let a=e.slice(t,t+r),o=a.toUpperCase();this.folded.push(lp(o==a?a.toLowerCase():o,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:s,any:r,precise:a,byWord:o}=this;if(t.length==1){let y=lp(e,0),k=kv(y),j=k==e.length?0:-100;if(y!=t[0])if(y==s[0])j+=-200;else return null;return this.ret(j,[0,k])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let c=t.length,d=0;if(l<0){for(let y=0,k=Math.min(e.length,200);y<k&&d<c;){let j=lp(e,y);(j==t[d]||j==s[d])&&(r[d++]=y),y+=kv(j)}if(d<c)return null}let u=0,h=0,p=!1,f=0,g=-1,x=-1,v=/[a-z]/.test(e),b=!0;for(let y=0,k=Math.min(e.length,200),j=0;y<k&&h<c;){let N=lp(e,y);l<0&&(u<c&&N==t[u]&&(a[u++]=y),f<c&&(N==t[f]||N==s[f]?(f==0&&(g=y),x=y+1,f++):f=0));let S,A=N<255?N>=48&&N<=57||N>=97&&N<=122?2:N>=65&&N<=90?1:0:(S=yve(N))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!y||A==1&&v||j==0&&A!=0)&&(t[h]==N||s[h]==N&&(p=!0)?o[h++]=y:o.length&&(b=!1)),j=A,y+=kv(N)}return h==c&&o[0]==0&&b?this.result(-100+(p?-200:0),o,e):f==c&&g==0?this.ret(-200-e.length+(x==e.length?0:-100),[0,x]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):f==c?this.ret(-900-e.length,[g,x]):h==c?this.result(-100+(p?-200:0)+-700+(b?0:-1100),o,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,s){let r=[],a=0;for(let o of t){let l=o+(this.astral?kv(lp(s,o)):1);a&&r[a-1]==o?r[a-1]=l:(r[a++]=o,r[a++]=l)}return this.ret(e-s.length,r)}},bpn=class{static{i(this,"StrictMatcher")}constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),s=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return s==null?null:(this.matched=[0,t.length],this.score=s+(e.length==this.pattern.length?0:-100),this)}},Ju=Rr.define({combine(e){return Rb(e,{activateOnTyping:!0,activateOnCompletion:i(()=>!1,"activateOnCompletion"),activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:i(()=>"","tooltipClass"),optionClass:i(()=>"","optionClass"),aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:ypn,filterStrict:!1,compareCompletions:i((t,s)=>(t.sortText||t.label).localeCompare(s.sortText||s.label),"compareCompletions"),interactionDelay:75,updateSyncTime:100},{defaultKeymap:i((t,s)=>t&&s,"defaultKeymap"),closeOnBlur:i((t,s)=>t&&s,"closeOnBlur"),icons:i((t,s)=>t&&s,"icons"),tooltipClass:i((t,s)=>r=>b4e(t(r),s(r)),"tooltipClass"),optionClass:i((t,s)=>r=>b4e(t(r),s(r)),"optionClass"),addToOptions:i((t,s)=>t.concat(s),"addToOptions"),filterStrict:i((t,s)=>t||s,"filterStrict")})}});function b4e(e,t){return e?t?e+" "+t:e:t}i(b4e,"joinClass");function ypn(e,t,s,r,a,o){let l=e.textDirection==ql.RTL,c=l,d=!1,u="top",h,p,f=t.left-a.left,g=a.right-t.right,x=r.right-r.left,v=r.bottom-r.top;if(c&&f<Math.min(x,g)?c=!1:!c&&g<Math.min(x,f)&&(c=!0),x<=(c?f:g))h=Math.max(a.top,Math.min(s.top,a.bottom-v))-t.top,p=Math.min(400,c?f:g);else{d=!0,p=Math.min(400,(l?t.right:a.right-t.left)-30);let k=a.bottom-t.bottom;k>=v||k>t.top?h=s.bottom-t.top:(u="bottom",h=t.bottom-s.top)}let b=(t.bottom-t.top)/o.offsetHeight,y=(t.right-t.left)/o.offsetWidth;return{style:`${u}: ${h/b}px; max-width: ${p/y}px`,class:"cm-completionInfo-"+(d?l?"left-narrow":"right-narrow":c?"left":"right")}}i(ypn,"defaultPositionInfo");function kpn(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(s){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),s.type&&r.classList.add(...s.type.split(/\s+/g).map(a=>"cm-completionIcon-"+a)),r.setAttribute("aria-hidden","true"),r},position:20}),t.push({render(s,r,a,o){let l=document.createElement("span");l.className="cm-completionLabel";let c=s.displayLabel||s.label,d=0;for(let u=0;u<o.length;){let h=o[u++],p=o[u++];h>d&&l.appendChild(document.createTextNode(c.slice(d,h)));let f=l.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(c.slice(h,p))),f.className="cm-completionMatchedText",d=p}return d<c.length&&l.appendChild(document.createTextNode(c.slice(d))),l},position:50},{render(s){if(!s.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=s.detail,r},position:80}),t.sort((s,r)=>s.position-r.position).map(s=>s.render)}i(kpn,"optionContent");function see(e,t,s){if(e<=s)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let a=Math.floor(t/s);return{from:a*s,to:(a+1)*s}}let r=Math.floor((e-t)/s);return{from:e-(r+1)*s,to:e-r*s}}i(see,"rangeAroundSelected");var wpn=class{static{i(this,"CompletionTooltip")}constructor(e,t,s){this.view=e,this.stateField=t,this.applyCompletion=s,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:i(()=>this.measureInfo(),"read"),write:i(c=>this.placeInfo(c),"write"),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:a,selected:o}=r.open,l=e.state.facet(Ju);this.optionContent=kpn(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=see(a.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",c=>{let{options:d}=e.state.field(t).open;for(let u=c.target,h;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(h=/-(\d+)$/.exec(u.id))&&+h[1]<d.length){this.applyCompletion(e,d[+h[1]]),c.preventDefault();return}}),this.dom.addEventListener("focusout",c=>{let d=e.state.field(this.stateField,!1);d&&d.tooltip&&e.state.facet(Ju).closeOnBlur&&c.relatedTarget!=e.contentDOM&&e.dispatch({effects:ML.of(null)})}),this.showOptions(a,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let s=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),s!=r){let{options:a,selected:o,disabled:l}=s.open;(!r.open||r.open.options!=a)&&(this.range=see(a.length,o,e.state.facet(Ju).maxRenderedOptions),this.showOptions(a,s.id)),this.updateSel(),l!=((t=r.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let s of this.currentClass.split(" "))s&&this.dom.classList.remove(s);for(let s of t.split(" "))s&&this.dom.classList.add(s);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=see(t.options.length,t.selected,this.view.state.facet(Ju).maxRenderedOptions),this.showOptions(t.options,e.id));let s=this.updateSelectedOption(t.selected);if(s){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:a}=r;if(!a)return;let o=typeof a=="string"?document.createTextNode(a):a(r);if(!o)return;"then"in o?o.then(l=>{l&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(l,r)}).catch(l=>gp(this.view.state,l,"completion info")):(this.addInfoPane(o,r),s.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let s=this.info=document.createElement("div");if(s.className="cm-tooltip cm-completionInfo",s.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)s.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:a}=e;s.appendChild(r),this.infoDestroy=a||null}this.dom.appendChild(s),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let s=this.list.firstChild,r=this.range.from;s;s=s.nextSibling,r++)s.nodeName!="LI"||!s.id?r--:r==e?s.hasAttribute("aria-selected")||(s.setAttribute("aria-selected","true"),t=s):s.hasAttribute("aria-selected")&&(s.removeAttribute("aria-selected"),s.removeAttribute("aria-describedby"));return t&&Npn(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),s=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),a=this.space;if(!a){let o=this.dom.ownerDocument.documentElement;a={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return r.top>Math.min(a.bottom,t.bottom)-10||r.bottom<Math.max(a.top,t.top)+10?null:this.view.state.facet(Ju).positionInfo(this.view,t,r,s,a,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,s){const r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",o=>{o.target==r&&o.preventDefault()});let a=null;for(let o=s.from;o<s.to;o++){let{completion:l,match:c}=e[o],{section:d}=l;if(d){let p=typeof d=="string"?d:d.name;if(p!=a&&(o>s.from||s.from==0))if(a=p,typeof d!="string"&&d.header)r.appendChild(d.header(d));else{let f=r.appendChild(document.createElement("completion-section"));f.textContent=p}}const u=r.appendChild(document.createElement("li"));u.id=t+"-"+o,u.setAttribute("role","option");let h=this.optionClass(l);h&&(u.className=h);for(let p of this.optionContent){let f=p(l,this.view.state,this.view,c);f&&u.appendChild(f)}}return s.from&&r.classList.add("cm-completionListIncompleteTop"),s.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}};function jpn(e,t){return s=>new wpn(s,e,t)}i(jpn,"completionTooltip");function Npn(e,t){let s=e.getBoundingClientRect(),r=t.getBoundingClientRect(),a=s.height/e.offsetHeight;r.top<s.top?e.scrollTop-=(s.top-r.top)/a:r.bottom>s.bottom&&(e.scrollTop+=(r.bottom-s.bottom)/a)}i(Npn,"scrollIntoView");function y4e(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}i(y4e,"score");function Cpn(e,t){let s=[],r=null,a=null,o=i(h=>{s.push(h);let{section:p}=h.completion;if(p){r||(r=[]);let f=typeof p=="string"?p:p.name;r.some(g=>g.name==f)||r.push(typeof p=="string"?{name:f}:p)}},"addOption"),l=t.facet(Ju);for(let h of e)if(h.hasResult()){let p=h.result.getMatch;if(h.result.filter===!1)for(let f of h.result.options)o(new x4e(f,h.source,p?p(f):[],1e9-s.length));else{let f=t.sliceDoc(h.from,h.to),g,x=l.filterStrict?new bpn(f):new vpn(f);for(let v of h.result.options)if(g=x.match(v.label)){let b=v.displayLabel?p?p(v,g.matched):[]:g.matched,y=g.score+(v.boost||0);if(o(new x4e(v,h.source,b,y)),typeof v.section=="object"&&v.section.rank==="dynamic"){let{name:k}=v.section;a||(a=Object.create(null)),a[k]=Math.max(y,a[k]||-1e9)}}}}if(r){let h=Object.create(null),p=0,f=i((g,x)=>(g.rank==="dynamic"&&x.rank==="dynamic"?a[x.name]-a[g.name]:0)||(typeof g.rank=="number"?g.rank:1e9)-(typeof x.rank=="number"?x.rank:1e9)||(g.name<x.name?-1:1),"cmp");for(let g of r.sort(f))p-=1e5,h[g.name]=p;for(let g of s){let{section:x}=g.completion;x&&(g.score+=h[typeof x=="string"?x:x.name])}}let c=[],d=null,u=l.compareCompletions;for(let h of s.sort((p,f)=>f.score-p.score||u(p.completion,f.completion))){let p=h.completion;!d||d.label!=p.label||d.detail!=p.detail||d.type!=null&&p.type!=null&&d.type!=p.type||d.apply!=p.apply||d.boost!=p.boost?c.push(h):y4e(h.completion)>y4e(d)&&(c[c.length-1]=h),d=h.completion}return c}i(Cpn,"sortOptions");var Spn=class kR{static{i(this,"CompletionDialog")}constructor(t,s,r,a,o,l){this.options=t,this.attrs=s,this.tooltip=r,this.timestamp=a,this.selected=o,this.disabled=l}setSelected(t,s){return t==this.selected||t>=this.options.length?this:new kR(this.options,k4e(s,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,s,r,a,o,l){if(a&&!l&&t.some(u=>u.isPending))return a.setDisabled();let c=Cpn(t,s);if(!c.length)return a&&t.some(u=>u.isPending)?a.setDisabled():null;let d=s.facet(Ju).selectOnOpen?0:-1;if(a&&a.selected!=d&&a.selected!=-1){let u=a.options[a.selected].completion;for(let h=0;h<c.length;h++)if(c[h].completion==u){d=h;break}}return new kR(c,k4e(r,d),{pos:t.reduce((u,h)=>h.hasResult()?Math.min(u,h.from):u,1e8),create:Mpn,above:o.aboveCursor},a?a.timestamp:Date.now(),d,!1)}map(t){return new kR(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new kR(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},_pn=class Jle{static{i(this,"CompletionState")}constructor(t,s,r){this.active=t,this.id=s,this.open=r}static start(){return new Jle(Epn,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:s}=t,r=s.facet(Ju),a=(r.override||s.languageDataAt("autocomplete",f3(s)).map(xpn)).map(c=>(this.active.find(d=>d.source==c)||new FC(c,this.active.some(d=>d.state!=0)?1:0)).update(t,r));a.length==this.active.length&&a.every((c,d)=>c==this.active[d])&&(a=this.active);let o=this.open,l=t.effects.some(c=>c.is(Zve));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(c=>c.hasResult()&&t.changes.touchesRange(c.from,c.to))||!Apn(a,this.active)||l?o=Spn.build(a,s,this.id,o,r,l):o&&o.disabled&&!a.some(c=>c.isPending)&&(o=null),!o&&a.every(c=>!c.isPending)&&a.some(c=>c.hasResult())&&(a=a.map(c=>c.hasResult()?new FC(c.source,0):c));for(let c of t.effects)c.is(Eut)&&(o=o&&o.setSelected(c.value,this.id));return a==this.active&&o==this.open?this:new Jle(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Ipn:Tpn}};function Apn(e,t){if(e==t)return!0;for(let s=0,r=0;;){for(;s<e.length&&!e[s].hasResult();)s++;for(;r<t.length&&!t[r].hasResult();)r++;let a=s==e.length,o=r==t.length;if(a||o)return a==o;if(e[s++].result!=t[r++].result)return!1}}i(Apn,"sameResults");var Ipn={"aria-autocomplete":"list"},Tpn={};function k4e(e,t){let s={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(s["aria-activedescendant"]=e+"-"+t),s}i(k4e,"makeAttrs");var Epn=[];function Iut(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(Aut);if(r&&t.activateOnCompletion(r))return 12}let s=e.isUserEvent("input.type");return s&&t.activateOnTyping?5:s?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}i(Iut,"getUpdateType");var FC=class wR{static{i(this,"ActiveSource")}constructor(t,s,r=!1){this.source=t,this.state=s,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(t,s){let r=Iut(t,s),a=this;(r&8||r&16&&this.touches(t))&&(a=new wR(a.source,0)),r&4&&a.state==0&&(a=new wR(this.source,1)),a=a.updateFor(t,r);for(let o of t.effects)if(o.is(lK))a=new wR(a.source,1,o.value);else if(o.is(ML))a=new wR(a.source,0);else if(o.is(Zve))for(let l of o.value)l.source==a.source&&(a=l);return a}updateFor(t,s){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(f3(t.state))}},Tut=class FB extends FC{static{i(this,"ActiveResult")}constructor(t,s,r,a,o,l){super(t,3,s),this.limit=r,this.result=a,this.from=o,this.to=l}hasResult(){return!0}updateFor(t,s){var r;if(!(s&3))return this.map(t.changes);let a=this.result;a.map&&!t.changes.empty&&(a=a.map(a,t.changes));let o=t.changes.mapPos(this.from),l=t.changes.mapPos(this.to,1),c=f3(t.state);if(c>l||!a||s&2&&(f3(t.startState)==this.from||c<this.limit))return new FC(this.source,s&4?1:0);let d=t.changes.mapPos(this.limit);return Rpn(a.validFor,t.state,o,l)?new FB(this.source,this.explicit,d,a,o,l):a.update&&(a=a.update(a,o,l,new Sut(t.state,c,!1)))?new FB(this.source,this.explicit,d,a,a.from,(r=a.to)!==null&&r!==void 0?r:f3(t.state)):new FC(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new FB(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new FC(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}};function Rpn(e,t,s,r){if(!e)return!1;let a=t.sliceDoc(s,r);return typeof e=="function"?e(a,s,r,t):_ut(e,!0).test(a)}i(Rpn,"checkValid");var Zve=pa.define({map(e,t){return e.map(s=>s.map(t))}}),Eut=pa.define(),cp=zp.define({create(){return _pn.start()},update(e,t){return e.update(t)},provide:i(e=>[Pve.from(e,t=>t.tooltip),Br.contentAttributes.from(e,t=>t.attrs)],"provide")});function Xve(e,t){const s=t.completion.apply||t.completion.label;let r=e.state.field(cp).active.find(a=>a.source==t.source);return r instanceof Tut?(typeof s=="string"?e.dispatch({...gpn(e.state,s,r.from,r.to),annotations:Aut.of(t.completion)}):s(e,t.completion,r.from,r.to),!0):!1}i(Xve,"applyCompletion");var Mpn=jpn(cp,Xve);function h$(e,t="option"){return s=>{let r=s.state.field(cp,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<s.state.facet(Ju).interactionDelay)return!1;let a=1,o;t=="page"&&(o=tdt(s,r.open.tooltip))&&(a=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:l}=r.open.options,c=r.open.selected>-1?r.open.selected+a*(e?1:-1):e?0:l-1;return c<0?c=t=="page"?0:l-1:c>=l&&(c=t=="page"?l-1:0),s.dispatch({effects:Eut.of(c)}),!0}}i(h$,"moveCompletionSelection");var Lpn=i(e=>{let t=e.state.field(cp,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ju).interactionDelay?!1:Xve(e,t.open.options[t.open.selected])},"acceptCompletion"),ree=i(e=>e.state.field(cp,!1)?(e.dispatch({effects:lK.of(!0)}),!0):!1,"startCompletion"),Dpn=i(e=>{let t=e.state.field(cp,!1);return!t||!t.active.some(s=>s.state!=0)?!1:(e.dispatch({effects:ML.of(null)}),!0)},"closeCompletion"),Ppn=class{static{i(this,"RunningQuery")}constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},$pn=50,Opn=1e3,Fpn=rh.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(cp).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(cp),s=e.state.facet(Ju);if(!e.selectionSet&&!e.docChanged&&e.startState.field(cp)==t)return;let r=e.transactions.some(o=>{let l=Iut(o,s);return l&8||(o.selection||o.docChanged)&&!(l&3)});for(let o=0;o<this.running.length;o++){let l=this.running[o];if(r||l.context.abortOnDocChange&&e.docChanged||l.updates.length+e.transactions.length>$pn&&Date.now()-l.time>Opn){for(let c of l.context.abortListeners)try{c()}catch(d){gp(this.view.state,d)}l.context.abortListeners=null,this.running.splice(o--,1)}else l.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(o=>o.effects.some(l=>l.is(lK)))&&(this.pendingStart=!0);let a=this.pendingStart?50:s.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(o=>o.isPending&&!this.running.some(l=>l.active.source==o.source))?setTimeout(()=>this.startUpdate(),a):-1,this.composing!=0)for(let o of e.transactions)o.isUserEvent("input.type")?this.composing=2:this.composing==2&&o.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(cp);for(let s of t.active)s.isPending&&!this.running.some(r=>r.active.source==s.source)&&this.startQuery(s);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ju).updateSyncTime))}startQuery(e){let{state:t}=this.view,s=f3(t),r=new Sut(t,s,e.explicit,this.view),a=new Ppn(e,r);this.running.push(a),Promise.resolve(e.source(r)).then(o=>{a.context.aborted||(a.done=o||null,this.scheduleAccept())},o=>{this.view.dispatch({effects:ML.of(null)}),gp(this.view.state,o)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ju).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],s=this.view.state.facet(Ju),r=this.view.state.field(cp);for(let a=0;a<this.running.length;a++){let o=this.running[a];if(o.done===void 0)continue;if(this.running.splice(a--,1),o.done){let c=f3(o.updates.length?o.updates[0].startState:this.view.state),d=Math.min(c,o.done.from+(o.active.explicit?0:1)),u=new Tut(o.active.source,o.active.explicit,d,o.done,o.done.from,(e=o.done.to)!==null&&e!==void 0?e:c);for(let h of o.updates)u=u.update(h,s);if(u.hasResult()){t.push(u);continue}}let l=r.active.find(c=>c.source==o.active.source);if(l&&l.isPending)if(o.done==null){let c=new FC(o.active.source,0);for(let d of o.updates)c=c.update(d,s);c.isPending||t.push(c)}else this.startQuery(l)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:Zve.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(cp,!1);if(t&&t.tooltip&&this.view.state.facet(Ju).closeOnBlur){let s=t.open&&tdt(this.view,t.open.tooltip);(!s||!s.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:ML.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:lK.of(!1)}),20),this.composing=0}}}),Bpn=typeof navigator=="object"&&/Win/.test(navigator.platform),zpn=YS.highest(Br.domEventHandlers({keydown(e,t){let s=t.state.field(cp,!1);if(!s||!s.open||s.open.disabled||s.open.selected<0||e.key.length>1||e.ctrlKey&&!(Bpn&&e.altKey)||e.metaKey)return!1;let r=s.open.options[s.open.selected],a=s.active.find(l=>l.source==r.source),o=r.completion.commitCharacters||a.result.commitCharacters;return o&&o.indexOf(e.key)>-1&&Xve(t,r),!1}})),qpn=Br.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),LL={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},BC=pa.define({map(e,t){let s=t.mapPos(e,-1,_m.TrackAfter);return s??void 0}}),ebe=new class extends N1{};ebe.startSide=1;ebe.endSide=-1;var Rut=zp.define({create(){return Nl.empty},update(e,t){if(e=e.map(t.changes),t.selection){let s=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:i(r=>r>=s.from&&r<=s.to,"filter")})}for(let s of t.effects)s.is(BC)&&(e=e.update({add:[ebe.range(s.value,s.value+1)]}));return e}});function Upn(){return[Wpn,Rut]}i(Upn,"closeBrackets");var w4e="()[]{}<>«»»«[]{}";function Mut(e){for(let t=0;t<16;t+=2)if(w4e.charCodeAt(t)==e)return w4e.charAt(t+1);return yve(e<128?e:e+1)}i(Mut,"closing");function Lut(e,t){return e.languageDataAt("closeBrackets",t)[0]||LL}i(Lut,"config");var Kpn=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Wpn=Br.inputHandler.of((e,t,s,r)=>{if((Kpn?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let a=e.state.selection.main;if(r.length>2||r.length==2&&kv(lp(r,0))==1||t!=a.from||s!=a.to)return!1;let o=Hpn(e.state,r);return o?(e.dispatch(o),!0):!1}),Qpn=i(({state:e,dispatch:t})=>{if(e.readOnly)return!1;let s=Lut(e,e.selection.main.head).brackets||LL.brackets,r=null,a=e.changeByRange(o=>{if(o.empty){let l=Gpn(e.doc,o.head);for(let c of s)if(c==l&&UH(e.doc,o.head)==Mut(lp(c,0)))return{changes:{from:o.head-c.length,to:o.head+c.length},range:Qn.cursor(o.head-c.length)}}return{range:r=o}});return r||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!r},"deleteBracketPair"),Vpn=[{key:"Backspace",run:Qpn}];function Hpn(e,t){let s=Lut(e,e.selection.main.head),r=s.brackets||LL.brackets;for(let a of r){let o=Mut(lp(a,0));if(t==a)return o==a?Zpn(e,a,r.indexOf(a+a+a)>-1,s):Ypn(e,a,o,s.before||LL.before);if(t==o&&Dut(e,e.selection.main.from))return Jpn(e,a,o)}return null}i(Hpn,"insertBracket");function Dut(e,t){let s=!1;return e.field(Rut).between(0,e.doc.length,r=>{r==t&&(s=!0)}),s}i(Dut,"closedBracketAt");function UH(e,t){let s=e.sliceString(t,t+2);return s.slice(0,kv(lp(s,0)))}i(UH,"nextChar");function Gpn(e,t){let s=e.sliceString(t-2,t);return kv(lp(s,0))==s.length?s:s.slice(1)}i(Gpn,"prevChar");function Ypn(e,t,s,r){let a=null,o=e.changeByRange(l=>{if(!l.empty)return{changes:[{insert:t,from:l.from},{insert:s,from:l.to}],effects:BC.of(l.to+t.length),range:Qn.range(l.anchor+t.length,l.head+t.length)};let c=UH(e.doc,l.head);return!c||/\s/.test(c)||r.indexOf(c)>-1?{changes:{insert:t+s,from:l.head},effects:BC.of(l.head+t.length),range:Qn.cursor(l.head+t.length)}:{range:a=l}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}i(Ypn,"handleOpen");function Jpn(e,t,s){let r=null,a=e.changeByRange(o=>o.empty&&UH(e.doc,o.head)==s?{changes:{from:o.head,to:o.head+s.length,insert:s},range:Qn.cursor(o.head+s.length)}:r={range:o});return r?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}i(Jpn,"handleClose");function Zpn(e,t,s,r){let a=r.stringPrefixes||LL.stringPrefixes,o=null,l=e.changeByRange(c=>{if(!c.empty)return{changes:[{insert:t,from:c.from},{insert:t,from:c.to}],effects:BC.of(c.to+t.length),range:Qn.range(c.anchor+t.length,c.head+t.length)};let d=c.head,u=UH(e.doc,d),h;if(u==t){if(j4e(e,d))return{changes:{insert:t+t,from:d},effects:BC.of(d+t.length),range:Qn.cursor(d+t.length)};if(Dut(e,d)){let p=s&&e.sliceDoc(d,d+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:d,to:d+p.length,insert:p},range:Qn.cursor(d+p.length)}}}else{if(s&&e.sliceDoc(d-2*t.length,d)==t+t&&(h=N4e(e,d-2*t.length,a))>-1&&j4e(e,h))return{changes:{insert:t+t+t+t,from:d},effects:BC.of(d+t.length),range:Qn.cursor(d+t.length)};if(e.charCategorizer(d)(u)!=wc.Word&&N4e(e,d,a)>-1&&!Xpn(e,d,t,a))return{changes:{insert:t+t,from:d},effects:BC.of(d+t.length),range:Qn.cursor(d+t.length)}}return{range:o=c}});return o?null:e.update(l,{scrollIntoView:!0,userEvent:"input.type"})}i(Zpn,"handleSame");function j4e(e,t){let s=sm(e).resolveInner(t+1);return s.parent&&s.from==t}i(j4e,"nodeStart");function Xpn(e,t,s,r){let a=sm(e).resolveInner(t,-1),o=r.reduce((l,c)=>Math.max(l,c.length),0);for(let l=0;l<5;l++){let c=e.sliceDoc(a.from,Math.min(a.to,a.from+s.length+o)),d=c.indexOf(s);if(!d||d>-1&&r.indexOf(c.slice(0,d))>-1){let h=a.firstChild;for(;h&&h.from==a.from&&h.to-h.from>s.length+d;){if(e.sliceDoc(h.to-s.length,h.to)==s)return!1;h=h.firstChild}return!0}let u=a.to==t&&a.parent;if(!u)break;a=u}return!1}i(Xpn,"probablyInString");function N4e(e,t,s){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=wc.Word)return t;for(let a of s){let o=t-a.length;if(e.sliceDoc(o,t)==a&&r(e.sliceDoc(o-1,o))!=wc.Word)return o}return-1}i(N4e,"canStartStringAt");function e0n(e={}){return[zpn,cp,Ju.of(e),Fpn,t0n,qpn]}i(e0n,"autocompletion");var Put=[{key:"Ctrl-Space",run:ree},{mac:"Alt-`",run:ree},{mac:"Alt-i",run:ree},{key:"Escape",run:Dpn},{key:"ArrowDown",run:h$(!0)},{key:"ArrowUp",run:h$(!1)},{key:"PageDown",run:h$(!0,"page")},{key:"PageUp",run:h$(!1,"page")},{key:"Enter",run:Lpn}],t0n=YS.highest(DH.computeN([Ju],e=>e.facet(Ju).defaultKeymap?[Put]:[])),C4e=class{static{i(this,"SelectedDiagnostic")}constructor(e,t,s){this.from=e,this.to=t,this.diagnostic=s}},lE=class $ut{static{i(this,"LintState")}constructor(t,s,r){this.diagnostics=t,this.panel=s,this.selected=r}static init(t,s,r){let a=r.facet(DL).markerFilter;a&&(t=a(t,r));let o=t.slice().sort((g,x)=>g.from-x.from||g.to-x.to),l=new Bj,c=[],d=0,u=r.doc.iter(),h=0,p=r.doc.length;for(let g=0;;){let x=g==o.length?null:o[g];if(!x&&!c.length)break;let v,b;if(c.length)v=d,b=c.reduce((j,N)=>Math.min(j,N.to),x&&x.from>v?x.from:1e8);else{if(v=x.from,v>p)break;b=x.to,c.push(x),g++}for(;g<o.length;){let j=o[g];if(j.from==v&&(j.to>j.from||j.to==v))c.push(j),g++,b=Math.min(j.to,b);else{b=Math.min(j.from,b);break}}b=Math.min(b,p);let y=!1;if(c.some(j=>j.from==v&&(j.to==b||b==p))&&(y=v==b,!y&&b-v<10)){let j=v-(h+u.value.length);j>0&&(u.next(j),h=v);for(let N=v;;){if(N>=b){y=!0;break}if(!u.lineBreak&&h+u.value.length>N)break;N=h+u.value.length,h+=u.value.length,u.next()}}let k=p0n(c);if(y)l.add(v,v,Ui.widget({widget:new d0n(k),diagnostics:c.slice()}));else{let j=c.reduce((N,S)=>S.markClass?N+" "+S.markClass:N,"");l.add(v,b,Ui.mark({class:"cm-lintRange cm-lintRange-"+k+j,diagnostics:c.slice(),inclusiveEnd:c.some(N=>N.to>b)}))}if(d=b,d==p)break;for(let j=0;j<c.length;j++)c[j].to<=d&&c.splice(j--,1)}let f=l.finish();return new $ut(f,s,T1(f))}};function T1(e,t=null,s=0){let r=null;return e.between(s,1e9,(a,o,{spec:l})=>{if(!(t&&l.diagnostics.indexOf(t)<0))if(!r)r=new C4e(a,o,t||l.diagnostics[0]);else{if(l.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new C4e(r.from,o,r.diagnostic)}}),r}i(T1,"findDiagnostic");function n0n(e,t){let s=t.pos,r=t.end||s,a=e.state.facet(DL).hideOn(e,s,r);if(a!=null)return a;let o=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(l=>l.is(Out))||e.changes.touchesRange(o.from,Math.max(o.to,r)))}i(n0n,"hideTooltip");function s0n(e,t){return e.field(b0,!1)?t:t.concat(pa.appendConfig.of(f0n))}i(s0n,"maybeEnableLint");var Out=pa.define(),tbe=pa.define(),Fut=pa.define(),b0=zp.define({create(){return new lE(Ui.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let s=e.diagnostics.map(t.changes),r=null,a=e.panel;if(e.selected){let o=t.changes.mapPos(e.selected.from,1);r=T1(s,e.selected.diagnostic,o)||T1(s,null,o)}!s.size&&a&&t.state.facet(DL).autoPanel&&(a=null),e=new lE(s,a,r)}for(let s of t.effects)if(s.is(Out)){let r=t.state.facet(DL).autoPanel?s.value.length?Zle.open:null:e.panel;e=lE.init(s.value,r,t.state)}else s.is(tbe)?e=new lE(e.diagnostics,s.value?Zle.open:null,e.selected):s.is(Fut)&&(e=new lE(e.diagnostics,e.panel,s.value));return e},provide:i(e=>[AL.from(e,t=>t.panel),Br.decorations.from(e,t=>t.diagnostics)],"provide")}),r0n=Ui.mark({class:"cm-lintRange cm-lintRange-active"});function i0n(e,t,s){let{diagnostics:r}=e.state.field(b0),a,o=-1,l=-1;r.between(t-(s<0?1:0),t+(s>0?1:0),(d,u,{spec:h})=>{if(t>=d&&t<=u&&(d==u||(t>d||s>0)&&(t<u||s<0)))return a=h.diagnostics,o=d,l=u,!1});let c=e.state.facet(DL).tooltipFilter;return a&&c&&(a=c(a,e.state)),a?{pos:o,end:l,above:e.state.doc.lineAt(o).to<l,create(){return{dom:a0n(e,a)}}}:null}i(i0n,"lintTooltip");function a0n(e,t){return gl("ul",{class:"cm-tooltip-lint"},t.map(s=>zut(e,s,!1)))}i(a0n,"diagnosticsTooltip");var o0n=i(e=>{let t=e.state.field(b0,!1);(!t||!t.panel)&&e.dispatch({effects:s0n(e.state,[tbe.of(!0)])});let s=$ve(e,Zle.open);return s&&s.dom.querySelector(".cm-panel-lint ul").focus(),!0},"openLintPanel"),S4e=i(e=>{let t=e.state.field(b0,!1);return!t||!t.panel?!1:(e.dispatch({effects:tbe.of(!1)}),!0)},"closeLintPanel"),l0n=i(e=>{let t=e.state.field(b0,!1);if(!t)return!1;let s=e.state.selection.main,r=T1(t.diagnostics,null,s.to+1);return!r&&(r=T1(t.diagnostics,null,0),!r||r.from==s.from&&r.to==s.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)},"nextDiagnostic"),c0n=[{key:"Mod-Shift-m",run:o0n,preventDefault:!0},{key:"F8",run:l0n}],DL=Rr.define({combine(e){return{sources:e.map(t=>t.source).filter(t=>t!=null),...Rb(e.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:i(()=>null,"hideOn")},{delay:Math.max,markerFilter:_4e,tooltipFilter:_4e,needsRefresh:i((t,s)=>t?s?r=>t(r)||s(r):t:s,"needsRefresh"),hideOn:i((t,s)=>t?s?(r,a,o)=>t(r,a,o)||s(r,a,o):t:s,"hideOn"),autoPanel:i((t,s)=>t||s,"autoPanel")})}}});function _4e(e,t){return e?t?(s,r)=>t(e(s,r),r):e:t}i(_4e,"combineFilter");function But(e){let t=[];if(e)e:for(let{name:s}of e){for(let r=0;r<s.length;r++){let a=s[r];if(/[a-zA-Z]/.test(a)&&!t.some(o=>o.toLowerCase()==a.toLowerCase())){t.push(a);continue e}}t.push("")}return t}i(But,"assignKeys");function zut(e,t,s){var r;let a=s?But(t.actions):[];return gl("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},gl("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),(r=t.actions)===null||r===void 0?void 0:r.map((o,l)=>{let c=!1,d=i(g=>{if(g.preventDefault(),c)return;c=!0;let x=T1(e.state.field(b0).diagnostics,t);x&&o.apply(e,x.from,x.to)},"click"),{name:u}=o,h=a[l]?u.indexOf(a[l]):-1,p=h<0?u:[u.slice(0,h),gl("u",u.slice(h,h+1)),u.slice(h+1)],f=o.markClass?" "+o.markClass:"";return gl("button",{type:"button",class:"cm-diagnosticAction"+f,onclick:d,onmousedown:d,"aria-label":` Action: ${u}${h<0?"":` (access key "${a[l]})"`}.`},p)}),t.source&&gl("div",{class:"cm-diagnosticSource"},t.source))}i(zut,"renderDiagnostic");var d0n=class extends aw{static{i(this,"DiagnosticWidget")}constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return gl("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},A4e=class{static{i(this,"PanelItem")}constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=zut(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},Zle=class qut{static{i(this,"LintPanel")}constructor(t){this.view=t,this.items=[];let s=i(a=>{if(!(a.ctrlKey||a.altKey||a.metaKey)){if(a.keyCode==27)S4e(this.view),this.view.focus();else if(a.keyCode==38||a.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(a.keyCode==40||a.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(a.keyCode==36)this.moveSelection(0);else if(a.keyCode==35)this.moveSelection(this.items.length-1);else if(a.keyCode==13)this.view.focus();else if(a.keyCode>=65&&a.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],l=But(o.actions);for(let c=0;c<l.length;c++)if(l[c].toUpperCase().charCodeAt(0)==a.keyCode){let d=T1(this.view.state.field(b0).diagnostics,o);d&&o.actions[c].apply(t,d.from,d.to)}}else return;a.preventDefault()}},"onkeydown"),r=i(a=>{for(let o=0;o<this.items.length;o++)this.items[o].dom.contains(a.target)&&this.moveSelection(o)},"onclick");this.list=gl("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:s,onclick:r}),this.dom=gl("div",{class:"cm-panel-lint"},this.list,gl("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:i(()=>S4e(this.view),"onclick")},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(b0).selected;if(!t)return-1;for(let s=0;s<this.items.length;s++)if(this.items[s].diagnostic==t.diagnostic)return s;return-1}update(){let{diagnostics:t,selected:s}=this.view.state.field(b0),r=0,a=!1,o=null,l=new Set;for(t.between(0,this.view.state.doc.length,(c,d,{spec:u})=>{for(let h of u.diagnostics){if(l.has(h))continue;l.add(h);let p=-1,f;for(let g=r;g<this.items.length;g++)if(this.items[g].diagnostic==h){p=g;break}p<0?(f=new A4e(this.view,h),this.items.splice(r,0,f),a=!0):(f=this.items[p],p>r&&(this.items.splice(r,p-r),a=!0)),s&&f.diagnostic==s.diagnostic?f.dom.hasAttribute("aria-selected")||(f.dom.setAttribute("aria-selected","true"),o=f):f.dom.hasAttribute("aria-selected")&&f.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)a=!0,this.items.pop();this.items.length==0&&(this.items.push(new A4e(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),a=!0),o?(this.list.setAttribute("aria-activedescendant",o.id),this.view.requestMeasure({key:this,read:i(()=>({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),"read"),write:i(({sel:c,panel:d})=>{let u=d.height/this.list.offsetHeight;c.top<d.top?this.list.scrollTop-=(d.top-c.top)/u:c.bottom>d.bottom&&(this.list.scrollTop+=(c.bottom-d.bottom)/u)},"write")})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),a&&this.sync()}sync(){let t=this.list.firstChild;function s(){let r=t;t=r.nextSibling,r.remove()}i(s,"rm");for(let r of this.items)if(r.dom.parentNode==this.list){for(;t!=r.dom;)s();t=r.dom.nextSibling}else this.list.insertBefore(r.dom,t);for(;t;)s()}moveSelection(t){if(this.selectedIndex<0)return;let s=T1(this.view.state.field(b0).diagnostics,this.items[t].diagnostic);s&&this.view.dispatch({selection:{anchor:s.from,head:s.to},scrollIntoView:!0,effects:Fut.of(s)})}static open(t){return new qut(t)}};function u0n(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}i(u0n,"svg$2");function m$(e){return u0n(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}i(m$,"underline");var h0n=Br.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:m$("#d11")},".cm-lintRange-warning":{backgroundImage:m$("orange")},".cm-lintRange-info":{backgroundImage:m$("#999")},".cm-lintRange-hint":{backgroundImage:m$("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function m0n(e){return e=="error"?4:e=="warning"?3:e=="info"?2:1}i(m0n,"severityWeight");function p0n(e){let t="hint",s=1;for(let r of e){let a=m0n(r.severity);a>s&&(s=a,t=r.severity)}return t}i(p0n,"maxSeverity");var f0n=[b0,Br.decorations.compute([b0],e=>{let{selected:t,panel:s}=e.field(b0);return!t||!s||t.from==t.to?Ui.none:Ui.set([r0n.range(t.from,t.to)])}),Bdn(i0n,{hideOn:n0n}),h0n],g0n=[odt(),tun(),gdn(),Dhn(),Oun(),rdn(),ddn(),Dc.allowMultipleSelections.of(!0),Nun(),Sdt(qun,{fallback:!0}),Hun(),Upn(),e0n(),Adn(),Edn(),wdn(),Umn(),DH.of([...Vpn,...Fmn,...dpn,...Khn,...Lun,...Put,...c0n])];function x0n(e,t,s){const r=Nk(yc),a=f0(aat),o=m.useRef(null),{lexicalNode:l}=Boe(),c=m.useRef(!1),d=m.useRef(!1),u=m.useCallback(()=>{a({editorType:"codeblock",rootNode:l,editorRef:o.current})},[l,a]),h=m.useCallback(p=>{var f,g,x,v,b,y;if(p.key==="ArrowDown"){const k=(g=(f=o.current)==null?void 0:f.getCodemirror())==null?void 0:g.state;k&&k.doc.length===k.selection.ranges[0].to&&(c.current?(r?.update(()=>{var j,N;const S=jp(e);S.getNextSibling()?((N=(j=o.current)==null?void 0:j.getCodemirror())==null||N.contentDOM.blur(),S.selectNext()):S.insertAfter(sl())}),c.current=!1):c.current=!0)}else if(p.key==="ArrowUp"){const k=(v=(x=o.current)==null?void 0:x.getCodemirror())==null?void 0:v.state;k&&k.selection.ranges[0].from===0&&(d.current?(r?.update(()=>{var j,N;const S=jp(e);S.getPreviousSibling()&&((N=(j=o.current)==null?void 0:j.getCodemirror())==null||N.contentDOM.blur(),S.selectPrevious())}),d.current=!1):d.current=!0)}else if(p.key==="Enter")p.stopPropagation();else if(p.key==="Backspace"||p.key==="Delete"){const k=(y=(b=o.current)==null?void 0:b.getCodemirror())==null?void 0:y.state;k?.doc.length===0&&r?.update(()=>{jp(e).remove()})}},[r,e]);return m.useEffect(()=>{const p=o.current;return setTimeout(()=>{var f,g;(f=p?.getCodemirror())==null||f.contentDOM.addEventListener("focus",u),(g=p?.getCodemirror())==null||g.contentDOM.addEventListener("keydown",h)},300),()=>{var f,g;(f=p?.getCodemirror())==null||f.contentDOM.removeEventListener("focus",u),(g=p?.getCodemirror())==null||g.contentDOM.removeEventListener("keydown",h)}},[o,u,h,t]),m.useEffect(()=>{s.subscribe(()=>{var p,f;(f=(p=o.current)==null?void 0:p.getCodemirror())==null||f.focus(),u()})},[s,o,e,u]),o}i(x0n,"useCodeMirrorRef");var v0n=m.forwardRef(({title:e,children:t},s)=>{const r=Nk(HS);return m.createElement(x0e,{delayDuration:100},m.createElement(v0e,null,m.createElement(b0e,{ref:s,asChild:!0},m.createElement("span",{className:vs.tooltipTrigger},t)),m.createElement(y0e,{container:r?.current},m.createElement(k0e,{className:(0,bl.default)(vs.tooltipContent),sideOffset:10},e))))}),b0n=m.forwardRef(({children:e,className:t,...s},r)=>m.createElement(eQe,{...s,ref:r,className:(0,bl.default)(t,vs.selectItem)},m.createElement(tQe,null,e))),y0n=i(({title:e,placeholder:t,className:s})=>{const[r,a]=Sx(fx,nw);return m.createElement(v0n,{title:e},m.createElement(QWe,{"aria-label":t,className:(0,bl.default)(vs.selectTrigger,s),"data-toolbar-item":!0,disabled:r},m.createElement(VWe,{placeholder:t}),m.createElement(HWe,{className:vs.selectDropdownArrow},a("arrow_drop_down"))))},"SelectTrigger$1"),k0n=i(({children:e,className:t=vs.selectContainer})=>{const s=Nk(HS);return m.createElement(GWe,{container:s?.current},m.createElement(YWe,{className:(0,bl.default)(t,"mdxeditor-select-content"),onCloseAutoFocus:i(r=>{r.preventDefault()},"onCloseAutoFocus"),position:"popper"},m.createElement(ZWe,{"data-editor-dropdown":!0,style:{maxHeight:"var(--radix-select-content-available-height)"}},e)))},"SelectContent$1"),w0n=i(e=>m.createElement(WWe,{value:e.value||"",onValueChange:e.onChange,disabled:e.disabled},m.createElement(y0n,{title:e.triggerTitle,placeholder:e.placeholder}),m.createElement(k0n,null,e.items.map((t,s)=>t==="separator"?m.createElement(sQe,{key:s}):m.createElement(b0n,{key:s,value:t.value},t.label)))),"Select$1"),Uut=i(({language:e,nodeKey:t,code:s,focusEmitter:r})=>{const a=sw(),{parentEditor:o,lexicalNode:l}=Boe(),[c,d,u,h,p]=Sx(fx,tce,nce,nw,ece),f=x0n(t,e,r),{setCode:g}=Boe(),x=m.useRef(null),v=m.useRef(null),{value:b,items:y}=m.useMemo(()=>j0n(p,e),[p,e]),k=m.useRef(g);return k.current=g,f.current={getCodemirror:i(()=>x.current,"getCodemirror")},m.useEffect(()=>{const j=v.current;return(async()=>{const N=[...d,g0n,Chn,odt(),DH.of([xhn]),Br.lineWrapping,Br.updateListener.of(({state:S})=>{k.current(S.doc.toString())}),Br.domEventHandlers({focus:i(()=>{o.update(()=>{sg(null)})},"focus")})];if(c&&N.push(Dc.readOnly.of(!0)),e!==""){const S=p.keyMap[e]??e,A=p.supportMap[S];if(A)N.push(A.extension);else if(u){const I=ahn.find(_=>_.name===e||_.alias.includes(e)||_.extensions.includes(e));if(I)try{const _=await I.load();N.push(_.extension)}catch{}}}j.innerHTML="",x.current=new Br({parent:j,state:Dc.create({doc:s,extensions:N})}),j.addEventListener("keydown",I4e)})(),()=>{var N;(N=x.current)==null||N.destroy(),x.current=null,j.removeEventListener("keydown",I4e)}},[c,e,...d]),m.createElement("div",{className:vs.codeMirrorWrapper},m.createElement("div",{className:vs.codeMirrorToolbar},m.createElement(w0n,{disabled:c,value:b,onChange:i(j=>{o.update(()=>{l.setLanguage(j==="__EMPTY_VALUE__"?"":j),setTimeout(()=>{o.update(()=>{l.getLatest().select()})})})},"onChange"),triggerTitle:a("codeBlock.selectLanguage","Select code block language"),placeholder:a("codeBlock.inlineLanguage","Language"),items:y}),m.createElement("button",{className:vs.iconButton,type:"button",disabled:c,title:a("codeblock.delete","Delete code block"),onClick:i(j=>{j.preventDefault(),o.update(()=>{l.remove()})},"onClick")},h("delete_small"))),m.createElement("div",{ref:v}))},"CodeMirrorEditor");function I4e(e){e.stopPropagation()}i(I4e,"stopPropagationHandler");function Xle(e){var t;const s=[],r={},a={};if(Array.isArray(e))for(const o of e){const l=((t=o.alias)==null?void 0:t[0])??o.name.toLowerCase(),c=l||"__EMPTY_VALUE__";if(s.push({value:c,label:o.name}),r[l]=c,o.alias)for(const d of o.alias)r[d]=c;if(o.extensions)for(const d of o.extensions)r[d]=c;r[o.name.toLowerCase()]=c,o.support&&(a[c]=o.support)}else{const o={};for(const[l,c]of Object.entries(e))c in o||(o[c]=l,s.push({value:l||"__EMPTY_VALUE__",label:c})),r[l]=o[c]||"__EMPTY_VALUE__"}return{items:s,keyMap:r,supportMap:a}}i(Xle,"normalizeCodeBlockLanguages");function j0n(e,t){const s=e.keyMap[t]??t;return!s||e.items.some(r=>r.value===s)?{value:s,items:e.items}:{value:s,items:[...e.items,{value:s,label:t}]}}i(j0n,"getCodeBlockLanguageSelectData");var ece=Dr(Xle({js:"JavaScript",ts:"TypeScript",tsx:"TypeScript (React)",jsx:"JavaScript (React)",css:"CSS"})),N0n=Ed(e=>{e.link(e.pipe(N0n,p1(({language:t,code:s})=>({code:s,language:t,meta:""}))),Xot)}),tce=Dr([]),nce=Dr(!0),C0n=Fp({update(e,t){e.pubIn({[ece]:Xle(t?.codeBlockLanguages??{}),[tce]:t?.codeMirrorExtensions??[],[nce]:t?.autoLoadLanguageSupport??!0})},init(e,t){const s=Xle(t?.codeBlockLanguages??{});e.pubIn({[ece]:s,[tce]:t?.codeMirrorExtensions??[],[Con]:S0n(s),[nce]:t?.autoLoadLanguageSupport??!0})}});function S0n(e){return{match(t,s){return!s||Object.hasOwn(e.keyMap,t??"")},priority:1,Editor:Uut}}i(S0n,"buildCodeBlockDescriptor");Tx();function _0n({url:e,title:t,text:s,onSubmit:r,onCancel:a,linkAutocompleteSuggestions:o,showLinkTitleField:l,showAnchorTextField:c}){const{register:d,handleSubmit:u,control:h,setValue:p,reset:f}=dot({values:{url:e,title:t,text:s}}),g=sw();return m.createElement("form",{onSubmit:i(x=>{u(r)(x),x.stopPropagation(),x.preventDefault()},"onSubmit"),onReset:i(x=>{x.stopPropagation(),a()},"onReset"),onKeyDown:i(x=>{x.key==="Escape"&&(x.stopPropagation(),a())},"onKeyDown"),className:(0,bl.default)(vs.multiFieldForm,vs.linkDialogEditForm)},m.createElement("div",{className:vs.formField},m.createElement("label",{htmlFor:"link-url"},g("createLink.url","URL")),m.createElement(Uot,{register:d,initialInputValue:e,inputName:"url",suggestions:o,setValue:p,control:h,placeholder:g("createLink.urlPlaceholder","Select or paste an URL"),autofocus:!0})),c?m.createElement("div",{className:vs.formField},m.createElement("label",{htmlFor:"link-text",title:g("createLink.textTooltip","The text to be displayed for the link")},g("createLink.text","Anchor text")),m.createElement("input",{id:"link-text",className:vs.textInput,size:40,...d("text")})):null,l?m.createElement("div",{className:vs.formField},m.createElement("label",{htmlFor:"link-title",title:g("createLink.titleTooltip","The link's title attribute, shown on hover")},g("createLink.title","Link title")),m.createElement("input",{id:"link-title",className:vs.textInput,size:40,...d("title")})):null,m.createElement("div",{style:{display:"flex",justifyContent:"flex-end",gap:"var(--spacing-2)"}},m.createElement("button",{type:"submit",title:g("createLink.saveTooltip","Set URL"),"aria-label":g("createLink.saveTooltip","Set URL"),className:(0,bl.default)(vs.primaryButton)},g("dialogControls.save","Save")),m.createElement("button",{type:"reset",title:g("createLink.cancelTooltip","Cancel change"),"aria-label":g("createLink.cancelTooltip","Cancel change"),className:(0,bl.default)(vs.secondaryButton)},g("dialogControls.cancel","Cancel"))))}i(_0n,"LinkEditForm");var A0n=i(()=>{const[e,t,s,r,a,o,l,c]=Sx(HS,sat,yc,nw,Fh,Jut,Zut,eht),d=f0(Wut),u=f0(Qut),h=f0(Vut),p=f0(Hut),f=f0(Gut);m.useEffect(()=>{const k=t?.closest(".mdxeditor-root-contenteditable"),j=i(()=>{s?.getEditorState().read(()=>{d(!0)})},"update");return window.addEventListener("resize",j),window.addEventListener("scroll",j),k?.addEventListener("scroll",j),()=>{window.removeEventListener("resize",j),window.removeEventListener("scroll",j),k?.removeEventListener("scroll",j)}},[s,t,d]);const[g,x]=m.useState(!1),v=sw();if(a.type==="inactive")return null;const b=a.rectangle,y=a.type==="preview"&&a.url.startsWith("http");return m.createElement(Ipe,{open:!0},m.createElement(y4t,{"data-visible":a.type==="edit",className:vs.linkDialogAnchor,style:{top:`${b.top}px`,left:`${b.left}px`,width:`${b.width}px`,height:`${b.height}px`}}),m.createElement(Npe,{container:e?.current},m.createElement(D4t,{className:(0,bl.default)(vs.linkDialogPopoverContent),sideOffset:5,updatePositionStrategy:"always",onOpenAutoFocus:i(k=>{k.preventDefault()},"onOpenAutoFocus"),key:a.linkNodeKey},a.type==="edit"&&m.createElement(_0n,{url:a.url,title:a.title,text:a.text,onSubmit:u,onCancel:h.bind(null),linkAutocompleteSuggestions:o,showLinkTitleField:c,showAnchorTextField:a.withAnchorText}),a.type==="preview"&&m.createElement(m.Fragment,null,m.createElement("a",{className:vs.linkDialogPreviewAnchor,"data-testid":"link-dialog-preview",href:a.href??"about:blank",...y?{target:"_blank",rel:"noreferrer"}:{},onClick:i(k=>{l!==null&&(k.preventDefault(),l(a.url))},"onClick"),title:y?v("linkPreview.open","Open {{url}} in new window",{url:a.url}):a.url},m.createElement("span",null,a.url),y&&r("open_in_new")),m.createElement(iee,{onClick:i(()=>{p()},"onClick"),title:v("linkPreview.edit","Edit link URL"),"aria-label":v("linkPreview.edit","Edit link URL")},r("edit")),m.createElement(x0e,null,m.createElement(v0e,{open:g},m.createElement(b0e,{asChild:!0},m.createElement(iee,{title:v("linkPreview.copyToClipboard","Copy to clipboard"),"aria-label":v("linkPreview.copyToClipboard","Copy to clipboard"),onClick:i(()=>{window.navigator.clipboard.writeText(a.url).then(()=>{x(!0),setTimeout(()=>{x(!1)},1e3)})},"onClick")},r(g?"check":"content_copy"))),m.createElement(y0e,{container:e?.current},m.createElement(k0e,{className:(0,bl.default)(vs.tooltipContent),sideOffset:5},v("linkPreview.copied","Copied!"),m.createElement(TQe,null))))),m.createElement(iee,{title:v("linkPreview.remove","Remove link"),"aria-label":v("linkPreview.remove","Remove link"),onClick:i(()=>{f()},"onClick")},r("link_off"))),m.createElement(ype,{className:vs.popoverArrow}))))},"LinkDialog"),iee=m.forwardRef(({className:e,...t},s)=>m.createElement("button",{className:(0,bl.default)(vs.actionButton,e),ref:s,...t}));function cK(e){if(!e)return null;const t=Ysn(e);if(t===null)return null;const s=t.getParent();return md(s)?s:md(t)?t:null}i(cK,"getLinkNodeInSelection");function Kut(e=ar()){if(!co(e))return null;const t=e.getNodes(),s=t.length===1?t[0]:null;return Ef(s)&&s.isInline()?s:null}i(Kut,"getSelectedInlineDecorator");function aee(e,t,s){return e?e.getEditorState().read(()=>{const r=t===""?null:jp(t),a=ar(),o=or(a)?cK(a):null,l=md(r)?r:o;return l?.sanitizeUrl(s)??"about:blank"}):"about:blank"}i(aee,"getPreviewHref");var Wut=Ed(),Fh=Dr({type:"inactive"},e=>{e.pub(fL,t=>t.registerCommand(dH,()=>e.getValue(Fh).type==="preview"?(e.pub(Fh,{type:"inactive"}),!0):!1,Fl)),e.sub(e.pipe(gL),t=>{t!=="rich-text"&&e.pub(Fh,{type:"inactive"})}),e.pub(fL,t=>t.registerCommand(lrt,s=>{if(s.key==="k"&&(Nat?s.metaKey:s.ctrlKey)&&!e.getValue(fx)){const r=ar();return or(r)||Kut(r)!==null?(e.pub(Yut),s.stopPropagation(),s.preventDefault(),!0):!1}return!1},lL)),e.sub(e.pipe(Hut,Mc(Fh,yc)),([,t,s])=>{if(t.type==="preview")setTimeout(()=>{s?.getEditorState().read(()=>{const r=jp(t.linkNodeKey),a=md(r)?r.getTextContent().length>0&&r.getChildrenSize()<=1:!1,o=a&&r?r.getTextContent():"";e.pub(Fh,{type:"edit",initialUrl:t.url,url:t.url,title:t.title,text:o,withAnchorText:a,linkNodeKey:t.linkNodeKey,decoratorNodeKey:t.decoratorNodeKey,rectangle:t.rectangle})})});else throw new Error("Cannot switch to edit mode when not in preview mode")}),e.sub(e.pipe(Qut,Mc(yc,Fh,rI)),([t,s,r,a])=>{var o,l,c;const d=((o=t.text)==null?void 0:o.trim())??"",u=((l=t.url)==null?void 0:l.trim())??"",h=((c=t.title)==null?void 0:c.trim())??"";if(u!==""){if(r.decoratorNodeKey!==void 0){let p="",f=!1;if(s?.update(()=>{const g=jp(r.decoratorNodeKey);if(g===null)return;const x=hU();if(x.add(g.getKey()),sg(x),f=s.dispatchCommand(hj,u),!f)return;const v=g.getParent();md(v)&&(v.setTitle(h),p=v.getKey())},{discrete:!0}),p==="")return;e.pub(Fh,{type:"preview",linkNodeKey:p,decoratorNodeKey:r.decoratorNodeKey,rectangle:r.rectangle,title:h,url:u,href:aee(s,p,u)});return}if(a?.isCollapsed()){const p=d||h||u;s?.update(()=>{const f=cK(a);if(f)if(km(f)){const g=Tk(u,{title:h});g.append(mx(d)),f.replace(g),g.select()}else f.setURL(u),f.setTitle(h),T4e(f.getFirstChild(),d);else{const g=Tk(u,{title:h});g.append(mx(p)),ST([g]),g.select()}},{discrete:!0})}else s?.update(()=>{T4e(a?.anchor.getNode(),d)}),s?.dispatchCommand(hj,{url:u,title:h});e.pub(Fh,{type:"preview",linkNodeKey:r.linkNodeKey,rectangle:r.rectangle,title:h,url:u,href:aee(s,r.linkNodeKey??"",u)})}else r.type==="edit"&&r.initialUrl!==""&&(r.decoratorNodeKey!==void 0?s?.update(()=>{const p=jp(r.decoratorNodeKey);if(p===null)return;const f=hU();f.add(p.getKey()),sg(f),s.dispatchCommand(hj,null)}):s?.dispatchCommand(hj,null)),e.pub(Fh,{type:"inactive"})}),e.link(e.pipe(Vut,Mc(Fh,yc),p1(([,t,s])=>{if(t.type==="edit")return s?.focus(),t.initialUrl===""?{type:"inactive"}:{type:"preview",url:t.initialUrl,href:aee(s,t.linkNodeKey,t.initialUrl),linkNodeKey:t.linkNodeKey,decoratorNodeKey:t.decoratorNodeKey,rectangle:t.rectangle};throw new Error("Cannot cancel edit when not in edit mode")})),Fh),e.link(e.pipe(e.combine(rI,Wut),Mc(yc,Fh,fx),p1(([[t],s,r,a])=>{if(r.decoratorNodeKey!==void 0&&s&&!a){if(s.getEditorState().read(()=>{const l=ar();if(!co(l))return null;const c=l.getNodes();return c.length===1?c[0].getKey():null})!==r.decoratorNodeKey)return{type:"inactive"};const o=yat(s,r.decoratorNodeKey);return o===null?{type:"inactive"}:{...r,rectangle:o}}if(or(t)&&s&&!a){const o=cK(t);if(!t.isCollapsed())return{type:"inactive"};if(o){const l=kat(s);return l?{type:"preview",url:o.getURL(),href:o.sanitizeUrl(o.getURL()),linkNodeKey:o.getKey(),title:o.getTitle(),rectangle:l}:{type:"inactive"}}else return{type:"inactive"}}else return{type:"inactive"}})),Fh)}),Qut=Ed(),Vut=Y1(),j9s=Y1(),Hut=Y1(),Gut=Y1(e=>{e.sub(e.pipe(Gut,Mc(yc)),([,t])=>{t?.dispatchCommand(hj,null)})}),Yut=Y1(e=>{e.sub(e.pipe(Yut,Mc(rI,yc)),([,t,s])=>{if(!s)return;const r=s.getEditorState().read(()=>{const a=Kut();if(a===null)return null;const o=a.getParent(),l=md(o)?o:null;return{nodeKey:a.getKey(),url:l?.getURL()??"",title:l?.getTitle()??"",linkNodeKey:l?.getKey()??""}});if(r!==null){const a=yat(s,r.nodeKey);if(a===null)return;e.pub(Fh,{type:"edit",initialUrl:r.url,url:r.url,title:r.title,text:"",withAnchorText:!1,linkNodeKey:r.linkNodeKey,decoratorNodeKey:r.nodeKey,rectangle:a});return}or(t)&&s.focus(()=>{setTimeout(()=>{s.getEditorState().read(()=>{const a=cK(t),o=kat(s);if(o===null)return;const l=a?.getURL()??"",c=a?.getURL()??"",d=a?.getTitle()??"",u=a?.getKey()??"",h=a?a.getTextContent().length>0&&a.getChildrenSize()<=1:t.isCollapsed(),p=h&&a?a.getTextContent():"";e.pub(Fh,{type:"edit",initialUrl:l,url:c,title:d,text:p,withAnchorText:h,linkNodeKey:u,rectangle:o})})})})})}),Jut=Dr([]),Zut=Dr(null),Xut=Dr(null,e=>{e.pub(fL,t=>{function s(r){const[a,o]=e.getValues([fx,Xut]);!a||o===null||t.update(()=>{const l=Ak(r.target);if(l!==null){const c=ic(l,d=>d instanceof Tb);c!==null&&o(r,c,c.getURL())}})}return i(s,"onClick"),t.registerRootListener((r,a)=>{r&&r.addEventListener("click",s),a&&a.removeEventListener("click",s)})})});function T4e(e,t){ca(e)&&t&&(e.setTextContent(t),e.selectStart())}i(T4e,"updateLinkText");var eht=Dr(!0),I0n=Fp({init(e,t){e.pub(RT,t?.LinkDialog??A0n),e.pub(Zut,t?.onClickLinkCallback??null),e.pub(Xut,t?.onReadOnlyClickLinkCallback??null),e.pub(eht,t?.showLinkTitleField??!0)},update(e,t={}){e.pub(Jut,t.linkAutocompleteSuggestions??[])}});function T0n(e,t){let s=e;for(let r=Kf(e,t);r&&(aht(r.origin)||pU(r.origin));r=r.getAdjacentCaret())s=r.origin;return s}i(T0n,"le$4");function E0n(e){return T0n(e,"previous")}i(E0n,"ue$4");function tht(e,t){for(const s of e.childNodes)if(po(s)&&s.tagName===t||tht(s,t))return!0;return!1}i(tht,"xe$3");var jR="data-language",cE="data-highlight-language",p$="data-theme",nbe=class nht extends cb{static{i(this,"ve$3")}__language;__theme;__isSyntaxHighlightSupported;static getType(){return"code"}static clone(t){return new nht(t.__language,t.__key)}constructor(t,s){super(s),this.__language=t||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(t){super.afterCloneFrom(t),this.__language=t.__language,this.__theme=t.__theme,this.__isSyntaxHighlightSupported=t.__isSyntaxHighlightSupported}createDOM(t){const s=Ip().createElement("code");px(s,t.theme.code),s.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(s.setAttribute(jR,r),this.getIsSyntaxHighlightSupported()&&s.setAttribute(cE,r));const a=this.getTheme();a&&s.setAttribute(p$,a);const o=this.getStyle();return o&&pB(s.style,o),s}updateDOM(t,s,r){const a=this.__language,o=t.__language;a?a!==o&&s.setAttribute(jR,a):o&&s.removeAttribute(jR);const l=this.__isSyntaxHighlightSupported;t.__isSyntaxHighlightSupported&&o?l&&a?a!==o&&s.setAttribute(cE,a):s.removeAttribute(cE):l&&a&&s.setAttribute(cE,a);const c=this.__theme,d=t.__theme;c?c!==d&&s.setAttribute(p$,c):d&&s.removeAttribute(p$);const u=this.__style,h=t.__style;return u!==h&&pB(s.style,u,h),!1}exportDOM(t){const s=Ip().createElement("pre");px(s,t._config.theme.code),s.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(s.setAttribute(jR,r),this.getIsSyntaxHighlightSupported()&&s.setAttribute(cE,r));const a=this.getTheme();a&&s.setAttribute(p$,a);const o=this.getStyle();return o&&pB(s.style,o),{element:s}}static importDOM(){return{code:i(t=>t.textContent!=null&&(/\r?\n/.test(t.textContent)||tht(t,"BR"))?{conversion:E4e,priority:1}:null,"code"),div:i(()=>({conversion:R0n,priority:1}),"div"),pre:i(()=>({conversion:E4e,priority:0}),"pre"),table:i(t=>oee(t)?{conversion:M0n,priority:3}:null,"table"),td:i(t=>{const s=t,r=s.closest("table");return s.classList.contains("js-file-line")||r&&oee(r)?{conversion:R4e,priority:3}:null},"td"),tr:i(t=>{const s=t.closest("table");return s&&oee(s)?{conversion:R4e,priority:3}:null},"tr")}}static importJSON(t){return Am().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setLanguage(t.language).setTheme(t.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(t,s=!0){if(!Z1(nh(),"@lexical/code")){const l=L0n(t);if(l)return l}const{anchor:r,focus:a}=t,o=(r.isBefore(a)?r:a).getNode();if(ca(o)){let l=E0n(o);const c=[];for(;;)if(pU(l))c.push(Oge()),l=l.getNextSibling();else{if(!aht(l))break;{let x=0;const v=l.getTextContent(),b=l.getTextContentSize();for(;x<b&&v[x]===" ";)x++;if(x!==0&&c.push(iht(" ".repeat(x))),x!==b)break;l=l.getNextSibling()}}const d=o.splitText(r.offset)[0],u=r.offset===0?0:1,h=d.getIndexWithinParent()+u,p=o.getParentOrThrow(),f=[ab(),...c];p.splice(h,0,f);const g=c[c.length-1];g?g.select():r.offset===0?d.selectPrevious():d.getNextSibling().selectNext(0,0)}if(PL(o)){const{offset:l}=t.anchor;o.splice(l,0,[ab()]),o.select(l+1,l+1)}return null}canIndent(){return!1}collapseAtStart(){const t=sl();return this.getChildren().forEach(s=>t.append(s)),this.replace(t),!0}setLanguage(t){const s=this.getWritable();return s.__language=t||void 0,s}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(t){const s=this.getWritable();return s.__isSyntaxHighlightSupported=t,s}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(t){const s=this.getWritable();return s.__theme=t||void 0,s}getTheme(){return this.getLatest().__theme}};function Am(e,t){return Bst(nbe).setLanguage(e).setTheme(t)}i(Am,"Ce$4");function PL(e){return e instanceof nbe}i(PL,"Ne$2");function E4e(e){return{node:Am(e.getAttribute(jR))}}i(E4e,"Te$3");function R0n(e){const t=e,s=M4e(t);return s||(function(r){let a=r.parentElement;for(;a!==null;){if(M4e(a))return!0;a=a.parentElement}return!1})(t)?{node:s?Am():null}:{node:null}}i(R0n,"Ae$3");function M0n(){return{node:Am()}}i(M0n,"Oe$3");function R4e(){return{node:null}}i(R4e,"Pe$4");function M4e(e){return e.style.fontFamily.match("monospace")!==null}i(M4e,"we$4");function oee(e){return e.classList.contains("js-file-line-container")}i(oee,"He$4");function L0n(e){const{anchor:t}=e;if(e.isCollapsed()&&t.type==="element"){const s=t.getNode();if(PL(s)){const r=s.getChildrenSize();if(r>=2&&t.offset===r){const a=s.getLastChild();if(ob(a)&&ob(a.getPreviousSibling())){const o=sl();return s.splice(r-2,2,[]).insertAfter(o,!1),o.select(),o}}}}return null}i(L0n,"De$4");var sht=class rht extends _T{static{i(this,"ke$3")}__highlightType;constructor(t="",s,r){super(t,r),this.__highlightType=s}static getType(){return"code-highlight"}static clone(t){return new rht(t.__text,t.__highlightType||void 0,t.__key)}afterCloneFrom(t){super.afterCloneFrom(t),this.__highlightType=t.__highlightType}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(t){const s=this.getWritable();return s.__highlightType=t||void 0,s}canHaveFormat(){return!1}createDOM(t){const s=super.createDOM(t),r=lee(t.theme,this.__highlightType);return px(s,r),s}updateDOM(t,s,r){const a=super.updateDOM(t,s,r),o=lee(r.theme,t.__highlightType),l=lee(r.theme,this.__highlightType);return o!==l&&(o&&hH(s,o),l&&px(s,l)),a}static importJSON(t){return iht().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setHighlightType(t.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(t){return this}isParentRequired(){return!0}createParentElementNode(){return Am()}};function lee(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}i(lee,"Be$3");function iht(e="",t){return Yk(new sht(e,t))}i(iht,"Fe$3");function aht(e){return e instanceof sht}i(aht,"Le$3");var oht="data-language";function lht(e){return e.style.fontFamily.match("monospace")!==null}i(lht,"Ee$3");function sce(e){let t=e.parentElement;for(;t!==null;){if(lht(t))return!0;t=t.parentElement}return!1}i(sce,"Me$3");var D0n=iit([{$import:i((e,t)=>e.$importChildren(t),"$import"),match:sh.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"}]),P0n={$import:i((e,t)=>[Am(t.getAttribute(oht)).splice(0,0,e.$importChildren(t))],"$import"),match:sh.tag("pre"),name:"@lexical/code/pre"},$0n={$import:i((e,t,s)=>{const r=t.textContent||"";return/\r?\n/.test(r)||t.querySelector("br")!==null?[Am(t.getAttribute(oht)).splice(0,0,e.$importChildren(t))]:s()},"$import"),match:sh.tag("code"),name:"@lexical/code/code-multiline"};function f$(e){if(!po(e))return!1;const t=e.style.fontFamily,s=e.style.whiteSpace;return typeof t=="string"&&/monospace/i.test(t)&&typeof s=="string"&&s.startsWith("pre")}i(f$,"Ie$3");function O0n(e){let t=!1;const s=[];let r="",a=!1;const o=i(()=>{a&&(s.push(r),r="",a=!1)},"o");for(const l of Array.from(e.childNodes))if(po(l))l.tagName==="DIV"?(o(),s.push(l.textContent||""),t=!0):l.tagName==="BR"?(o(),s.push(""),t=!0):(r+=l.textContent||"",a=!0);else if(uH(l)){const c=l.textContent||"";c.length>0&&(r+=c,a=!0)}return o(),t?s:null}i(O0n,"je$2");var N9s=iit([{$import:i((e,t,s)=>{if(!f$(t)||sce(t))return s();const r=O0n(t);return r===null||r.length===0?s():[Am().splice(0,0,Wae(r.join(`
174
174
  `)))]},"$import"),match:sh.tag("div"),name:"@lexical/code/vscode-wrapper"},{$import:i((e,t,s)=>{if(!f$(t)||sce(t))return s();const r=t.previousElementSibling;if(r&&f$(r))return[];const a=[];let o=t;for(;o&&f$(o);)a.push(o.tagName==="BR"?"":o.textContent||""),o=o.nextElementSibling;return a.length<2?s():[Am().splice(0,0,Wae(a.join(`
175
175
  `)))]},"$import"),match:sh.tag("div","br"),name:"@lexical/code/vscode-line-run"}]),F0n={$import:i((e,t,s)=>lht(t)?[Am().splice(0,0,e.$importChildren(t))]:sce(t)?e.$importChildren(t):s(),"$import"),match:sh.tag("div"),name:"@lexical/code/div"},C9s=[{$import:i((e,t)=>[Am().splice(0,0,e.$importChildren(t,{rules:D0n}))],"$import"),match:sh.tag("table").classAll("js-file-line-container"),name:"@lexical/code/github-code-table"},{$import:i((e,t)=>e.$importChildren(t),"$import"),match:sh.tag("td").classAll("js-file-line"),name:"@lexical/code/github-code-cell-by-class"},$0n,P0n,F0n];function rce(e,t){const s={};for(const r of e){const a=t(r);a&&(s[a]?s[a].push(r):s[a]=[r])}return s}i(rce,"Q$2");function B0n(e){const t=rce(e,s=>s.type);return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}i(B0n,"V$4");var L4e=/[!-/:-@[-`{-~\s]/;function D4e(e){return e.replace(/\\([!-/:-@[-`{-~])/g,"$1").replace(/&#(\d+);/g,(t,s)=>String.fromCodePoint(Number(s)))}i(D4e,"nt$3");var z0n=/^(\s*)(\d{1,})\.\s/,q0n=/^(\s*)[-*+]\s/,U0n=/^(\s*)(?:[-*+]\s)?\s?(\[(\s|x)?\])\s/i,K0n=/^(#{1,6})\s/,W0n=/^>\s/,Q0n=/^([ \t]*`{3,})([\w-]+)?[ \t]?/,V0n=/^[ \t]*`{3,}$/,NR=h7("mdListMarker",{parse:i(e=>typeof e=="string"&&/^[-*+]$/.test(e)?e:"-","parse"),resetOnCopyNode:!0}),P4e=h7("mdCodeFence",{parse:i(e=>typeof e=="string"&&/^`{3,}$/.test(e)?e:"```","parse"),resetOnCopyNode:!0}),H0n=h7("mdHardLineBreak",{parse:i(e=>typeof e=="string"&&/^(\\| {2,})$/.test(e)?e:"","parse"),resetOnCopyNode:!0});function G0n(e){if(e.endsWith("\\"))return[e.slice(0,-1),"\\"];const t=e.match(/^(.*?\S)( {2,})$/);return t?[t[1],t[2]]:null}i(G0n,"It$3");function Y0n(e){const t=e.getChildren(),s=t.length-1,r=t[s];if(!ca(r))return null;const a=r.getTextContent(),o=G0n(a);if(o!==null){const[l,c]=o;return r.setTextContent(l),c}return/^ {2,}$/.test(a)&&(function(l,c){for(let d=c-1;d>=0;d--){if(ob(l[d]))return!1;if(/\S/.test(l[d].getTextContent()))return!0}return!1})(t,s)?(r.setTextContent(""),a):null}i(Y0n,"Tt$3");function J0n(e){const t=ab(),s=Y0n(e);return s!==null&&H5(t,H0n,s),t}i(J0n,"$t$3");var cht=i(e=>(t,s,r,a)=>{const o=e(r);o.append(...s),t.replace(o),a||o.select(0,0)},"Et$2"),sbe=i(e=>(t,s,r,a)=>{const o=t.getPreviousSibling(),l=t.getNextSibling(),c=rg(e==="check"?r[3]==="x":void 0),d=r[0].trim()[0],u=e!=="bullet"&&e!=="check"||d!==NR.parse(d)?void 0:d;if(gi(l)&&l.getListType()===e){u&&H5(l,NR,u);const p=l.getFirstChild();p!==null?p.insertBefore(c):l.append(c),e==="number"&&l.setStart(Number(r[2])),t.remove()}else if(gi(o)&&o.getListType()===e)u&&H5(o,NR,u),o.append(c),t.remove();else{const p=Wf(e,e==="number"?Number(r[2]):void 0);u&&H5(p,NR,u),p.append(c),t.replace(p)}c.append(...s),a||c.select(0,0);const h=(function(p){const f=p.match(/\t/g),g=p.match(/ /g);let x=0;return f&&(x+=f.length),g&&(x+=Math.floor(g.length/4)),x})(r[1]);h&&c.setIndent(h)},"vt$2"),KH=i((e,t,s,r)=>{const a=[],o=e.getChildren();let l=0;for(const c of o)if(Gi(c)){if(c.getChildrenSize()===1){const g=c.getFirstChild();if(gi(g)){const x=KH(g,t,s+1,r);x&&a.push(x);continue}}if(r&&!c.getChildren().some(g=>g.isSelected(r)))continue;const d=" ".repeat(4*s),u=e.getListType(),h=Bge(e,NR),p=u==="number"?`${e.getStart()+l}. `:u==="check"?`${h} [${c.getChecked()?"x":" "}] `:h+" ";let f=t(c);u!=="number"&&(f=f.replace(/^(\s{0,3}\d+)(\.\s)/,"$1\\$2")),a.push(d+p+f),l++}return a.join(`
@@ -411,7 +411,7 @@ ${MIt}
411
411
  `}i(ISn,"buildAgentOnboardingPrompt");function TSn(e){const t=(e.connectionCandidates??[]).map(o=>o.trim()).filter(Boolean),s=new Set;let r=null;try{r=new URL(e.onboardingTextUrl),s.add(r.toString())}catch{const o=e.onboardingTextUrl.trim();o&&s.add(o)}if(!r){for(const o of t)s.add(o);return Array.from(s)}const a=`${r.pathname}${r.search}`;for(const o of t)try{const l=new URL(o);s.add(`${l.origin}${a}`)}catch{s.add(o)}return Array.from(s)}i(TSn,"buildCandidateOnboardingUrls");function ESn(e){const t=e.testResolutionUrl?.trim();if(t)return t;try{const s=new URL(e.onboardingTextUrl),r=s.pathname.replace(/\/onboarding\.txt$/,"/test-resolution");return`${s.origin}${r}`}catch{return null}}i(ESn,"buildResolutionTestUrl");function $ft({children:e,className:t,...s}){const[r,a]=(0,m.useState)(null),o=(0,m.useRef)(null),l=$7();return(0,m.useLayoutEffect)(()=>{const c=r,d=o.current;if(!c||!d||typeof ResizeObserver>"u")return;let u,h;const p=new ResizeObserver(()=>{const f=getComputedStyle(c),g=d.getBoundingClientRect().height+parseFloat(f.borderTopWidth)+parseFloat(f.borderBottomWidth);if(g===u)return;const x=h?.playState==="running"?c.getBoundingClientRect().height:u;if(h?.cancel(),u=g,x===void 0||l||typeof c.animate!="function")return;const v=uye("--motion-ease-out-expo");h=c.animate([{height:`${x}px`},{height:`${g}px`}],{duration:HL("--onboarding-motion-step"),easing:Array.isArray(v)?`cubic-bezier(${v.join(",")})`:v})});return p.observe(d),()=>{p.disconnect(),h?.cancel()}},[r,l]),(0,n.jsx)(zn,{...s,ref:a,className:Q("overflow-hidden p-0",t),children:(0,n.jsx)("div",{ref:o,className:"flex max-h-(--sz-calc-18) shrink-0 flex-col",children:e})})}i($ft,"AnimatedDialogContent");var Oft=[{id:"dot",name:"Dot",adapter:"openai_dot",description:"Your Dot in ChatGPT"},{id:"other",name:"Other",adapter:"http",description:"Any agent that can connect to Wardmote"}];function mde({onSelect:e,dotDisabledReason:t}){return(0,n.jsx)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3",children:Oft.map(s=>(0,n.jsxs)("button",{type:"button",onClick:i(()=>e(s.id),"onClick"),disabled:s.id==="dot"&&!!t,title:s.id==="dot"?t:void 0,className:"flex aspect-square flex-col items-center justify-center gap-3 rounded-lg border border-line bg-bg-2 px-3 py-4 text-center transition-colors disabled:opacity-50 hover:bg-bg-3/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus",children:[(0,n.jsx)(Zg,{type:s.adapter,className:"size-8"}),(0,n.jsx)("span",{className:"text-sm font-medium",children:s.name}),(0,n.jsx)("span",{className:"sr-only",children:s.description})]},s.id))})}i(mde,"ExternalAgentPresetPicker");var RSn=[{title:"Connected to Wardmote",description:"Your Dot has connected to this agent."},{title:"Task updates enabled",description:"Your Dot is subscribed to new assignments and messages."},{title:"Test event confirmed",description:"Your Dot received our test and replied to Wardmote."}];function Fft({state:e}){const t={waiting:0,connected:1,subscribed:2,testing:2,finishing:3,ready:3}[e.phase],s=e.problem==="agent_unavailable"?"Connection checks passed, but this agent cannot receive tasks. Resolve the agent’s setup blocker in Wardmote.":e.problem==="offline"?"Connection updates paused. Reconnect to check the latest status.":e.problem==="prompt_unavailable"?"This setup prompt was replaced in another window. Create a fresh prompt to continue.":e.problem==="event_timeout"?"Your Dot connected, but hasn’t confirmed the test event. Ask it to check Wardmote, then retry.":e.phase==="finishing"?"Your Dot confirmed the test event. Wardmote is finishing agent setup.":e.phase==="ready"?"Your Dot is ready for tasks. Messages can travel both ways.":e.phase==="waiting"?"Watching for your Dot. Updates will appear here automatically.":e.phase==="connected"?"Your Dot connected. Waiting for it to enable task updates.":"Waiting for your Dot to confirm a test event. No task will be created.";return(0,n.jsxs)("section",{"aria-label":"Dot connection checks",className:"space-y-4",children:[(0,n.jsx)("ol",{className:"space-y-4",children:RSn.map((r,a)=>{const o=a<t,l=a===t&&e.problem==="event_timeout",c=a===t&&!e.problem,d=o?sn:l?mo:c?ct:Zf;return(0,n.jsxs)("li",{className:"flex items-start gap-3","aria-current":c?"step":void 0,children:[(0,n.jsx)("span",{className:Q("flex size-6 shrink-0 items-center justify-center rounded-full",o?"bg-bg-3 text-ink":l?"text-bad":"text-ink-3"),children:(0,n.jsx)(d,{className:Q("size-4",c&&"animate-spin motion-reduce:animate-none")})}),(0,n.jsxs)("div",{className:"min-w-0 pt-0.5",children:[(0,n.jsxs)("p",{className:Q("text-sm",o||c||l?"font-medium":"text-ink-3"),children:[r.title,(0,n.jsx)("span",{className:"sr-only",children:o?": complete":l?": needs attention":c?": in progress":": waiting"})]}),o&&(0,n.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-ink-3",children:r.description})]})]},r.title)})}),(0,n.jsx)("p",{role:e.problem&&e.problem!=="prompt_unavailable"?"alert":"status","aria-live":"polite",className:Q("text-sm leading-relaxed",e.problem&&e.problem!=="prompt_unavailable"?"text-bad":"text-ink-3"),children:s})]})}i(Fft,"DotConnectionChecks");function MSn({preset:e,prompt:t,companyName:s,connection:r,onSelect:a,onBack:o,onClose:l,onCopied:c,onRetry:d,onNewPrompt:u,dotDisabledReason:h,busy:p=!1,error:f,approvalHref:g}){const x=Oft.find(j=>j.id===e),v=e==="dot",b=v&&r.phase==="ready"&&!r.problem,y=v&&r.phase!=="waiting",k=r.problem==="agent_unavailable"?"Agent unavailable":r.problem==="offline"?"Updates paused":r.problem==="event_timeout"?"Needs attention":r.phase==="finishing"?"Finishing setup…":r.phase==="connected"?"Connecting…":"Confirming connection…";return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"min-h-0 space-y-6 overflow-y-auto px-6 pb-6 pt-8 sm:px-8",children:[(0,n.jsxs)("div",{className:"space-y-3 pr-5",children:[x&&(0,n.jsx)(Zg,{type:x.adapter,className:"size-10"}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(qn,{className:"text-xl font-semibold tracking-tight",children:x?v?b?"Your Dot is connected":"Connect your Dot":"Invite your agent":"Invite an external agent"}),(0,n.jsx)(ds,{className:"text-sm leading-relaxed",children:x?b?`Your Dot can now receive assignments and work with ${s}.`:r.problem==="agent_unavailable"?"Your Dot is connected. This agent must be available in Wardmote before it can receive assignments.":r.phase==="finishing"?"Your Dot has connected and confirmed task updates. Wardmote is preparing it for assignments.":y?"Your Dot has connected. We’re checking that task updates can travel both ways.":v?"Copy the setup prompt and send it to your Dot in ChatGPT. Your Dot will connect itself; we’ll watch for it here.":"Copy the invitation prompt and send it to your agent. Approve its join request in Wardmote when it’s ready.":`Bring an agent you already use into ${s}.`})]})]}),f&&(0,n.jsxs)("div",{role:"alert",className:"space-y-3 text-sm text-bad",children:[(0,n.jsx)("p",{children:f}),(0,n.jsx)($,{variant:"secondary",disabled:p,onClick:d,children:"Try again"})]}),x?g?(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"An organization admin needs to approve this agent before Dot can connect. This page will update after approval."}):p&&!t&&r.phase==="waiting"?(0,n.jsx)("p",{role:"status",className:"text-sm text-ink-3",children:"Preparing your invitation…"}):v?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"border-t pt-6",children:[(0,n.jsx)(Fft,{state:r}),r.phase==="waiting"&&(0,n.jsx)("p",{className:"mt-4 text-xs text-ink-3",children:"Dot uses your OpenAI account. Provider usage and cost aren’t reported to Wardmote."})]}),r.problem==="event_timeout"&&(0,n.jsx)($,{variant:"secondary",disabled:p,onClick:d,children:"Retry test event"}),r.problem==="offline"&&(0,n.jsx)($,{variant:"secondary",disabled:p,onClick:d,children:"Reconnect updates"})]}):(0,n.jsxs)("p",{className:"text-sm leading-relaxed text-ink-3",children:["The invitation includes everything your agent needs to join ",s,". You can review its request before granting access."]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(mde,{onSelect:a,dotDisabledReason:h}),h&&(0,n.jsx)("p",{className:"text-sm text-ink-3",children:h})]})]}),(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3 border-t px-6 py-4 sm:px-8",children:[(0,n.jsxs)($,{variant:"ghost",onClick:x?o:l,children:[x&&(0,n.jsx)(cc,{className:"size-4"}),x?"Back":"Cancel"]}),x&&(g?(0,n.jsx)($,{asChild:!0,children:(0,n.jsx)(Ye,{to:g,onClick:l,children:"Review approval"})}):b?(0,n.jsx)($,{onClick:l,children:"Done"}):y?(0,n.jsxs)($,{disabled:!0,"aria-live":"polite",children:[!r.problem&&(0,n.jsx)(ct,{className:"size-4 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),k]}):v&&r.problem==="prompt_unavailable"?(0,n.jsx)($,{disabled:p,onClick:u,children:"Create a new prompt"}):!t||p?(0,n.jsx)($,{disabled:!0,children:p?"Preparing…":"Waiting for Dot…"}):(0,n.jsx)(D1,{prompt:t,label:v?"Copy setup prompt":"Copy invitation prompt",title:v?"Connect your Dot":"Invite your agent",description:v?"Send this whole prompt to your Dot in ChatGPT.":"Send this whole prompt to your agent.",agent:v?{name:"Dot",src:"/brands/adapters/openai-dot.svg"}:void 0,align:"end",className:"min-w-0 shrink",onCopied:c},e))]})]})}i(MSn,"ExternalAgentInviteContent");function LSn({companyId:e,onClose:t,onBack:s}){const r=Ct(),{selectedCompany:a}=gn(),[o,l]=(0,m.useState)(null),[c,d]=(0,m.useState)(null),[u,h]=(0,m.useState)(null),[p,f]=(0,m.useState)(null),[g,x]=(0,m.useState)(""),v=(0,m.useRef)(!1),b=ie({queryKey:O.instance.experimentalSettings,queryFn:Fr.getExperimental}),y=b.isPending?"Loading available agents…":b.error?"Unable to load feature settings. Try again after refreshing.":!b.data?.enableOpenAiDot||!b.data.enablePublicMcp?"Turn on OpenAI Dot and Assistant connections in Settings > Features.":void 0,k=["dot-binding",e,c?.agent.id],j=ie({queryKey:k,queryFn:i(({signal:W})=>A$.connection(e,c.agent.id,W),"queryFn"),enabled:o==="dot"&&!!c,retry:!1,staleTime:0,refetchInterval:i(W=>W.state.error||W.state.data?.agentLifecycleState==="ready"&&W.state.data.canConfigureConnection&&W.state.data.binding?.status==="ready"&&W.state.data.binding.subscriptionVerified?!1:2500,"refetchInterval")}),N=ye({mutationFn:i(async W=>{if(W==="dot"){const G=await A$.create(e);d(G),await r.invalidateQueries({queryKey:O.agents.list(e)});return}const F=await jr.createCompanyInvite(e,{allowedJoinTypes:"agent",humanRole:null,agentMessage:null});r.invalidateQueries({queryKey:O.access.invites(e,"all",5)});const Y=F.onboardingTextUrl??F.onboardingTextPath??`/api/invites/${F.token}/onboarding.txt`,V=await jr.getInviteOnboarding(F.token).catch(()=>null);x(ISn({onboardingTextUrl:new URL(Y,window.location.origin).href,connectionCandidates:V?.onboarding.connectivity?.connectionCandidates??null,testResolutionUrl:V?.onboarding.connectivity?.testResolutionEndpoint?.url??null}))},"mutationFn"),gcTime:0}),S=ye({mutationFn:i(async W=>{const F=await A$.pair(e,c.agent.id,W);h(F),f(null)},"mutationFn"),onSuccess:i(()=>{r.invalidateQueries({queryKey:k})},"onSuccess"),onError:i(()=>{j.refetch()},"onError"),gcTime:0}),A=ye({mutationFn:i(()=>A$.retry(e,c.agent.id,j.data.binding.id),"mutationFn"),onSuccess:i(()=>{r.invalidateQueries({queryKey:k})},"onSuccess")}),I=j.data?.binding,_=o==="dot"&&j.data?.enabled&&!!j.data.resourceUrl&&j.data.canConfigureConnection&&(!I||I.status==="pairing")&&!u&&!j.error&&!S.isError&&!v.current&&(!p||I?.id===p);(0,m.useEffect)(()=>{_&&j.isFetchedAfterMount&&!j.isFetching&&!S.isPending&&(v.current=!0,S.mutate(I?.id))},[_,j.isFetchedAfterMount,j.isFetching,S.isPending,S.mutate,I?.id]),(0,m.useEffect)(()=>{if(!u)return;const W=window.setTimeout(()=>{v.current=!1,f(u.bindingId),h(null)},Math.max(0,Date.parse(u.expiresAt)-Date.now()));return()=>window.clearTimeout(W)},[u]);const T=I?.status==="ready"&&I.subscriptionVerified,E=j.data?.agentLifecycleState==="ready"&&j.data.canConfigureConnection,M=["preparing","verifying"].includes(j.data?.agentLifecycleState??"")&&j.data?.canConfigureConnection,P={phase:T?E?"ready":M?"finishing":"ready":I?.hasPendingChallenge?"testing":I?.subscriptionVerified?"subscribed":I?.connected?"connected":"waiting",problem:j.error?"offline":T&&!E&&!M?"agent_unavailable":I?.status==="pairing"&&!_&&!S.isPending&&!j.isFetching&&!S.isError&&u?.bindingId!==I.id?"prompt_unavailable":I?.challengeExpiresAt&&!I.hasPendingChallenge&&I.status!=="ready"?"event_timeout":void 0},D=(j.data?.agentStatus??c?.agent.status)==="pending_approval",K=j.data&&!j.data.canConfigureConnection&&!D,L=o==="dot"?u&&u.bindingId===I?.id&&j.data?.resourceUrl&&c?P0t({companyId:e,agentId:c.agent.id,resourceUrl:j.data.resourceUrl,...u}):"":g,B=(N.variables===o?N.error:null)??(o==="dot"?(I?.connected?null:S.error)??A.error:null),z=N.isPending||S.isPending||A.isPending||_||o==="dot"&&!!c&&(j.isPending||!L&&j.isFetching),U=i(()=>{if(K){j.refetch();return}if(j.error){j.refetch();return}if(N.error||!c){o&&N.mutate(o);return}if(S.error&&!I?.connected){S.mutate(I?.status==="pairing"?I.id:void 0);return}A.mutate()},"retry");return(0,n.jsx)(Bn,{open:!0,onOpenChange:i(W=>{W||t()},"onOpenChange"),children:(0,n.jsx)($ft,{className:"sm:max-w-(--sz-560px)",children:(0,n.jsx)(MSn,{preset:o,prompt:L,companyName:a?.name??"your organization",connection:P,dotDisabledReason:y,busy:z,error:B?.message??(K?j.data?.agentLifecycleState==="terminated"?"This agent was terminated. Invite another agent to connect Dot.":"Resume this agent before connecting Dot.":void 0),approvalHref:D&&c?.approvalId?`/approvals/${c.approvalId}`:void 0,onSelect:i(W=>{l(W),(W==="dot"?!c:!g)&&N.mutate(W)},"onSelect"),onBack:i(()=>l(null),"onBack"),onClose:o?t:s,onCopied:i(()=>{o==="dot"&&j.refetch()},"onCopied"),onRetry:U,onNewPrompt:i(()=>S.mutate(I?.id),"onNewPrompt")})})})}i(LSn,"ExternalAgentInviteDialog");function DSn(){const{newAgentOpen:e,closeNewAgent:t}=AD(),{selectedCompanyId:s}=gn();return e?(0,n.jsx)(PSn,{companyId:s,onClose:t},s):null}i(DSn,"NewAgentDialog");function PSn({companyId:e,onClose:t}){const s=ir(),[r,a]=(0,m.useState)(!1);return r&&e?(0,n.jsx)(LSn,{companyId:e,onClose:t,onBack:i(()=>a(!1),"onBack")}):(0,n.jsx)(Nft,{open:!0,onClose:t,onInvite:e?()=>a(!0):void 0,onContinue:i(o=>{t(),s(`/agents/new?${new URLSearchParams(o)}`)},"onContinue")})}i(PSn,"NewAgentDialogContent");var $Sn=[{title:"Inbox",shortcuts:[{keys:["j"],label:"Move down"},{keys:["↓"],label:"Move down"},{keys:["k"],label:"Move up"},{keys:["↑"],label:"Move up"},{keys:["←"],label:"Collapse selected group"},{keys:["→"],label:"Expand selected group"},{keys:["Enter"],label:"Open selected item"},{keys:["a"],label:"Archive item"},{keys:["y"],label:"Archive item"},{keys:["r"],label:"Mark as read"},{keys:["U"],label:"Mark as unread"}]},{title:"Task detail",shortcuts:[{keys:["y"],label:"Quick-archive back to inbox"},{keys:["g","i"],label:"Go to inbox"},{keys:["g","c"],label:"Focus comment composer"}]},{title:"Decisions",shortcuts:[{keys:["j"],label:"Move down"},{keys:["↓"],label:"Move down"},{keys:["k"],label:"Move up"},{keys:["↑"],label:"Move up"},{keys:["Enter"],label:"Open or close selected decision"},{keys:["x"],label:"Dismiss selected decision"}]},{title:"Global",shortcuts:[{keys:["/"],label:"Search current page or quick search"},{keys:["c"],label:"New task"},{keys:["["],label:"Toggle sidebar"},{keys:["]"],label:"Toggle panel"},{keys:["?"],label:"Show keyboard shortcuts"}]}];function R6e({children:e}){return(0,n.jsx)("kbd",{className:"inline-flex h-6 min-w-6 items-center justify-center rounded border border-line bg-bg-3 px-1.5 font-mono text-xs font-medium text-ink shadow-(--shadow-extract-10)",children:e})}i(R6e,"KeyCap");function OSn(){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"divide-y divide-line border-t border-line",children:$Sn.map(e=>(0,n.jsxs)("div",{className:"px-5 py-3",children:[(0,n.jsx)("h3",{className:"mb-2 text-(length:--text-micro) font-semibold uppercase tracking-wider text-ink-3",children:e.title}),(0,n.jsx)("div",{className:"space-y-1.5",children:e.shortcuts.map(t=>(0,n.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,n.jsx)("span",{className:"text-sm text-ink/90",children:t.label}),(0,n.jsx)("div",{className:"flex items-center gap-1",children:t.keys.map((s,r)=>(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[r>0&&(0,n.jsx)("span",{className:"text-xs text-ink-3",children:t.combo?"+":"then"}),(0,n.jsx)(R6e,{children:s})]},s))})]},t.label+t.keys.join()))})]},e.title))}),(0,n.jsx)("div",{className:"border-t border-line px-5 py-3",children:(0,n.jsxs)("p",{className:"text-xs text-ink-3",children:["Press ",(0,n.jsx)(R6e,{children:"Esc"})," to close · Shortcuts are disabled in text fields"]})})]})}i(OSn,"KeyboardShortcutsCheatsheetContent");function FSn({open:e,onOpenChange:t}){return(0,n.jsx)(Bn,{open:e,onOpenChange:t,children:(0,n.jsxs)(zn,{className:"sm:max-w-md gap-0 p-0 overflow-hidden",showCloseButton:!1,children:[(0,n.jsx)(rs,{className:"px-5 pt-5 pb-3",children:(0,n.jsx)(qn,{className:"text-base",children:"Keyboard shortcuts"})}),(0,n.jsx)(OSn,{})]})})}i(FSn,"KeyboardShortcutsCheatsheet");var BSn={info:"border-sky-300 bg-sky-50 text-sky-900 dark:border-sky-500/25 dark:bg-sky-950/60 dark:text-sky-100",success:"border-emerald-300 bg-emerald-50 text-emerald-900 dark:border-emerald-500/25 dark:bg-emerald-950/60 dark:text-emerald-100",warn:"border-amber-300 bg-amber-50 text-amber-900 dark:border-amber-500/25 dark:bg-amber-950/60 dark:text-amber-100",error:"border-red-300 bg-red-50 text-red-900 dark:border-red-500/30 dark:bg-red-950/60 dark:text-red-100"},zSn={info:"bg-sky-500 dark:bg-sky-400",success:"bg-emerald-500 dark:bg-emerald-400",warn:"bg-amber-500 dark:bg-amber-400",error:"bg-red-500 dark:bg-red-400"};function qSn({toast:e,onDismiss:t}){const[s,r]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{const a=requestAnimationFrame(()=>r(!0));return()=>cancelAnimationFrame(a)},[]),(0,n.jsx)("li",{className:Q("pointer-events-auto rounded-sm border shadow-lg backdrop-blur-xl transition-(--tp-transform-opacity) duration-200 ease-out",s?"translate-y-0 opacity-100":"translate-y-3 opacity-0",BSn[e.tone]),children:(0,n.jsxs)("div",{className:"flex items-start gap-3 px-3 py-2.5",children:[e.actor?.type==="agent"?(0,n.jsx)(lr,{agent:{id:e.actor.id,name:e.actor.name,appearance:e.actor.appearance},size:24}):e.actor?.type==="user"?(0,n.jsxs)(yl,{size:"sm","aria-hidden":"true",children:[e.actor.image&&(0,n.jsx)(th,{src:e.actor.image,alt:""}),(0,n.jsx)(kl,{children:_b(e.actor.name)})]}):(0,n.jsx)("span",{className:Q("mt-1 h-2 w-2 shrink-0 rounded-full",zSn[e.tone])}),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("p",{className:"text-sm font-semibold leading-5",children:e.title}),e.body&&(0,n.jsx)("p",{className:"mt-1 text-xs leading-4 opacity-70",children:e.body}),e.action&&(e.action.onClick?(0,n.jsx)("button",{type:"button",onClick:i(()=>{e.action?.onClick?.(),t(e.id)},"onClick"),className:"mt-2 inline-flex text-xs font-medium underline underline-offset-4 hover:opacity-90",children:e.action.label}):e.action.href?(0,n.jsx)(Ye,{to:e.action.href,onClick:i(()=>t(e.id),"onClick"),className:"mt-2 inline-flex text-xs font-medium underline underline-offset-4 hover:opacity-90",children:e.action.label}):null)]}),(0,n.jsx)("button",{type:"button","aria-label":"Dismiss notification",onClick:i(()=>t(e.id),"onClick"),className:"mt-0.5 shrink-0 rounded p-1 opacity-50 hover:bg-black/10 hover:opacity-100 dark:hover:bg-white/10",children:(0,n.jsx)(ks,{className:"h-3.5 w-3.5"})})]})})}i(qSn,"AnimatedToast");function USn(){const e=PEt(),{dismissToast:t}=ri();return e.length===0?null:(0,n.jsx)("aside",{"aria-live":"polite","aria-atomic":"false",className:"pointer-events-none fixed bottom-3 left-3 z-(--z-120) w-full max-w-sm px-1",children:(0,n.jsx)("ol",{className:"flex w-full flex-col-reverse gap-2",children:e.map(s=>(0,n.jsx)(qSn,{toast:s,onDismiss:t},s.id))})})}i(USn,"ToastViewport");async function M6e(e,t){const s=await fetch(`/api/announcements/${e}`,{credentials:"same-origin",cache:"no-store",...t});if(!s.ok)throw new ss("Announcement request failed",s.status,null);return s}i(M6e,"request");var L6e={async current(e){const t=await(await M6e("current",{signal:e})).json();return t===null?null:qIt.parse(t)},async dismiss(e,t,s){await M6e(`${encodeURIComponent(e)}/dismiss`,{method:"POST",signal:s,headers:{"Content-Type":"application/json"},body:JSON.stringify({companyId:t})})}},pde=new Map;function _ye(e){return`paperclip.announcement-dismissals.v1:${encodeURIComponent(e)}:`}i(_ye,"announcementStoragePrefix");function I$(e){const t=_ye(e),s=new Map;try{for(let r=0;r<localStorage.length;r++){const a=localStorage.key(r);if(!a?.startsWith(t))continue;const o=a.slice(t.length),l=localStorage.getItem(a);GUe.safeParse(o).success&&(l==="pending"||l==="synced")&&pde.set(a,l==="pending")}}catch{}for(const[r,a]of pde)r.startsWith(t)&&s.set(r.slice(t.length),a);return s}i(I$,"readAnnouncementDismissals");function nte(e,t,s){const r=`${_ye(e)}${t}`;pde.set(r,s);try{return localStorage.setItem(r,s?"pending":"synced"),!0}catch{return!1}}i(nte,"saveAnnouncementDismissal");var KSn=3e3;function WSn(e){const{userId:t,enabled:s}=e,r=(0,m.useRef)(e);r.current=e;const[a,o]=(0,m.useState)(null),l=(0,m.useRef)(()=>{});(0,m.useEffect)(()=>{if(o(null),!t||!s)return;let d=!1,u=0,h=null,p;const f=new Map,g=new Set,x=_ye(t);let v=null;try{v=new BroadcastChannel(x)}catch{}const b=i(()=>!d&&r.current.userId===t&&r.current.enabled,"active");async function y(T,E=!0){if(!b()||f.has(T)||!r.current.companyId)return;const M=new AbortController;f.set(T,M);const P=setTimeout(()=>M.abort(),1e4);try{await L6e.dismiss(T,r.current.companyId,M.signal),b()&&nte(t,T,!1)}catch{b()&&!g.has(T)&&(g.add(T),r.current.onSaveFailure(E))}finally{clearTimeout(P),f.delete(T)}}i(y,"sync");async function k(){for(const[T,E]of I$(t)){if(!b())return;E&&await y(T)}}i(k,"flush");function j(){u++,clearTimeout(p),h?.abort(),h=null,o(null)}i(j,"suspend");function N(){if(!b()||document.visibilityState==="hidden")return;j();const T=u,E=new AbortController;h=E;const M=i(()=>b()&&u===T&&!E.signal.aborted,"stillCurrent");let P=!1,D=!1,K=null;const L=i(()=>{!M()||!P||!D||K&&!I$(t).has(K.id)&&(!K.expiresAt||Date.parse(K.expiresAt)>Date.now())&&o({userId:t,announcement:K})},"show");p=setTimeout(()=>{P=!0,L()},KSn),k(),L6e.current(E.signal).then(B=>{K=B,D=!0,L()}).catch(()=>{})}i(N,"resume");function S(){const T=I$(t);o(E=>E?.userId===t&&T.has(E.announcement.id)?null:E)}i(S,"receive");function A(T){T.key?.startsWith(x)&&S()}i(A,"onStorage");function I(){document.visibilityState==="hidden"?j():N()}i(I,"onVisibility");function _(){k()}return i(_,"onOnline"),v&&(v.onmessage=T=>{const E=GUe.safeParse(T.data);E.success&&(I$(t).has(E.data)||nte(t,E.data,!0),S())}),l.current=T=>{if(!b())return;const E=nte(t,T,!0);o(null),u++,h?.abort();try{v?.postMessage(T)}catch{}y(T,E)},document.addEventListener("visibilitychange",I),window.addEventListener("online",_),window.addEventListener("storage",A),N(),()=>{d=!0,u++,clearTimeout(p),h?.abort();for(const T of f.values())T.abort();v?.close(),document.removeEventListener("visibilitychange",I),window.removeEventListener("online",_),window.removeEventListener("storage",A),l.current=()=>{}}},[t,s]);const c=s&&a?.userId===t?a.announcement:null;return(0,m.useEffect)(()=>{if(!c?.expiresAt)return;let d;const u=i(()=>{const h=Date.parse(c.expiresAt)-Date.now();h<=0?o(null):d=setTimeout(u,Math.min(h,2147483647))},"check");return u(),()=>clearTimeout(d)},[c]),{announcement:c,dismiss:(0,m.useCallback)(d=>l.current(d),[])}}i(WSn,"useAnnouncement");function hs({className:e,interactive:t=!1,...s}){return(0,n.jsx)("div",{"data-slot":"card",className:Q("bg-bg-2 text-ink flex flex-col gap-6 rounded-lg border py-6",t&&"cursor-pointer transition-colors hover:border-ink/20 hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus",e),...s})}i(hs,"Card$1");function zo({className:e,...t}){return(0,n.jsx)("div",{"data-slot":"card-header",className:Q("@container/card-header grid auto-rows-min grid-rows-(--gtr-1) items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-(--gtc-17) [.border-b]:pb-6",e),...t})}i(zo,"CardHeader");function jl({className:e,...t}){return(0,n.jsx)("div",{"data-slot":"card-title",className:Q("leading-none font-semibold",e),...t})}i(jl,"CardTitle");function yu({className:e,...t}){return(0,n.jsx)("div",{"data-slot":"card-description",className:Q("text-ink-3 text-sm",e),...t})}i(yu,"CardDescription");function QSn({className:e,...t}){return(0,n.jsx)("div",{"data-slot":"card-action",className:Q("col-start-2 row-span-2 row-start-1 self-start justify-self-end",e),...t})}i(QSn,"CardAction");function la({className:e,...t}){return(0,n.jsx)("div",{"data-slot":"card-content",className:Q("px-6",e),...t})}i(la,"CardContent");function VSn({className:e,...t}){return(0,n.jsx)("div",{"data-slot":"card-footer",className:Q("flex items-center px-6 [.border-t]:pt-6",e),...t})}i(VSn,"CardFooter");function HSn(e,t){const s=$7(),r=t??`/api/announcements/${encodeURIComponent(e.id)}/animation`,a=`${r}:${e.animation?.path??""}`,[o,l]=(0,m.useState)(null),c=!!e.animation&&!s;return(0,m.useEffect)(()=>{if(!c)return;const d=new AbortController,u=setTimeout(()=>d.abort(),5e3);return(async()=>{try{const h=await fetch(r,{credentials:"same-origin",cache:"no-store",redirect:"error",referrerPolicy:"no-referrer",signal:d.signal});if(!h.ok||h.headers.get("content-type")?.split(";")[0]!=="text/html")return;const p=await h.text();d.signal.aborted||l({key:a,document:`<meta http-equiv="Content-Security-Policy" content="${tEt}">${p}`})}catch{}finally{clearTimeout(u)}})(),()=>{d.abort(),clearTimeout(u)}},[c,a,r]),c&&o?.key===a?o.document:null}i(HSn,"useAnnouncementAnimation");function D6e({action:e,primary:t,onClick:s}){const r=(0,n.jsxs)(n.Fragment,{children:[e.label,!t&&e.kind==="external"&&(0,n.jsx)(qo,{className:"size-3.5 shrink-0","aria-hidden":"true"})]}),a=i(o=>{o.button===1&&s()},"onAuxClick");return(0,n.jsx)($,{asChild:!0,variant:t?"primary":"ghost",size:"sm",className:"h-auto min-h-9 min-w-0 whitespace-normal py-2 text-left",children:e.kind==="external"?(0,n.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",onClick:s,onAuxClick:a,children:r}):(0,n.jsx)(Ye,{to:e.path,onClick:s,onAuxClick:a,children:r})})}i(D6e,"Action");function iz({announcement:e,onDismiss:t,imageSrc:s,animationSrc:r,className:a}){const o=(0,m.useId)(),[l,c]=(0,m.useState)(null),d=s??`/api/announcements/${encodeURIComponent(e.id)}/image`,u=!!(e.image&&l!==d),h=HSn(e,r),p=!!h;return(0,n.jsxs)(hs,{role:"region","aria-labelledby":o,className:Q("relative w-full max-w-(--announcement-width) gap-0 overflow-hidden rounded-xl p-0 shadow-sm",a),onKeyDown:i(f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),t())},"onKeyDown"),children:[(u||h)&&(0,n.jsxs)("div",{className:"relative h-(--announcement-image-mobile-height) w-full shrink-0 overflow-hidden bg-bg-3 md:h-(--announcement-image-height)",children:[u&&(0,n.jsx)("img",{src:d,alt:p?"":e.image.alt,referrerPolicy:"no-referrer",onError:i(()=>c(d),"onError"),className:"h-full w-full object-cover"}),p&&(0,n.jsx)("div",{role:"img","aria-label":e.animation.alt,className:"pointer-events-none absolute inset-0",children:(0,n.jsx)("iframe",{title:e.animation.alt,"aria-hidden":"true",tabIndex:-1,sandbox:"",referrerPolicy:"no-referrer",srcDoc:h,className:"h-full w-full border-0"})})]}),(0,n.jsx)($,{variant:"secondary",size:"icon","aria-label":"Dismiss announcement",onClick:t,className:"absolute right-2 top-2 z-10 size-8 rounded-full shadow-sm",children:(0,n.jsx)(ks,{className:"size-4","aria-hidden":"true"})}),(0,n.jsxs)("div",{className:Q("flex flex-col gap-1 px-4 py-4",!u&&!h&&"pr-12"),children:[(0,n.jsx)("p",{className:"text-xs text-ink-3",children:e.eyebrow}),(0,n.jsx)("h2",{id:o,className:"break-words text-base font-semibold leading-snug",children:e.title}),(0,n.jsx)("p",{className:"break-words text-sm leading-snug text-ink-3",children:e.description})]}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-t px-3 py-2",children:[e.secondaryLink&&(0,n.jsx)(D6e,{action:e.secondaryLink,onClick:t}),(0,n.jsx)("div",{className:"ml-auto min-w-0 max-w-full",children:(0,n.jsx)(D6e,{action:e.primaryAction,primary:!0,onClick:t})})]})]})}i(iz,"AnnouncementCard");var GSn='[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"], [aria-modal="true"]:not([data-state="closed"]), dialog[open]';function YSn(e){const[t,s]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{if(!e)return;const r=i(()=>s(!!document.querySelector(GSn)),"scan");r();const a=new MutationObserver(r);return a.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-state","aria-modal","open"]}),()=>a.disconnect()},[e]),t}i(YSn,"useModalOpen");function JSn({health:e}){const{userId:t,settled:s}=jb(),{selectedCompanyId:r,loading:a}=gn(),{onboardingOpen:o}=dT(),l=Eh(),c=DEt(),d=e?.deploymentMode==="local_trusted"?"local-board":s?t:null,{announcement:u,dismiss:h}=WSn({userId:d,companyId:r,enabled:!!(d&&!a&&r&&!o),onSaveFailure:i(f=>l?.pushToast({title:f?"Dismissed in this browser":"Dismissed for this visit",body:"Couldn’t save across devices. We’ll retry when you reconnect or return.",tone:"info",dedupeKey:"announcement-dismissal-sync"}),"onSaveFailure")}),p=YSn(!!u);return!u||p||(c?.length??0)>0?null:(0,n.jsx)("aside",{"aria-label":"Wardmote announcements",className:"announcement-well fixed left-3 bottom-(--announcement-mobile-bottom) z-40 w-(--announcement-available-width) max-w-(--announcement-width) max-h-(--announcement-mobile-max-height) overflow-y-auto md:bottom-3 md:max-h-(--announcement-max-height)",children:(0,n.jsx)(iz,{announcement:u,onDismiss:i(()=>h(u.id),"onDismiss")},u.id)})}i(JSn,"AnnouncementWell");function fG(e){const t=e.split("/").filter(Boolean);return t.length===1?t[0]?.toLowerCase()==="onboarding":t.length===2?t[1]?.toLowerCase()==="onboarding":!1}i(fG,"isOnboardingPath");function ZSn(e){const t=e.split("/").filter(Boolean);if(t.length===2&&t[1]?.toLowerCase()==="onboarding")return t[0]}i(ZSn,"companyPrefixFromOnboardingPath");function FK(){return 3}i(FK,"onboardingStepForCompany");function XSn(e){const{pathname:t,companyPrefix:s,companies:r,cloudManaged:a}=e;if(!fG(t))return null;const o=i(()=>r.length===1?{initialStep:FK(),companyId:r[0].id}:null,"managedFallback");if(!s)return a?o():{initialStep:1};const l=r.find(c=>c.issuePrefix.toUpperCase()===s.toUpperCase())??null;return l?{initialStep:FK(),companyId:l.id}:a?o():{initialStep:1}}i(XSn,"resolveRouteOnboardingOptions");function e_n(e){return!e.agentsLoaded||e.agentsRefreshing||e.agentCount>0?!1:!fG(e.pathname)}i(e_n,"shouldRouteAgentlessCompanyToOnboarding");function Aye(e){return!e.hasCompanies&&!fG(e.pathname)}i(Aye,"shouldRedirectCompanylessRouteToOnboarding");function t_n(e){return e.onboardingOpen||!e.routeDismissed}i(t_n,"isOnboardingWizardActive");function n_n({context:e}){const{slots:t,errorMessage:s}=Q0({slotTypes:["appShellOverlay"],companyId:e.companyId});return s||t.length===0?null:(0,n.jsx)("aside",{className:"plugin-app-shell-overlays","aria-label":"Application extensions",children:t.map(r=>(0,n.jsx)(jx,{slot:r,context:e,className:"plugin-app-shell-overlay"},`${r.pluginId}:${r.pluginVersion}:${r.id}`))})}i(n_n,"AppShellEntries");function s_n({localTrusted:e=!1}){const{userId:t,settled:s}=jb(),{selectedCompanyId:r,selectedCompany:a,loading:o}=gn(),{onboardingOpen:l,onboardingRouteDismissed:c}=dT(),{pathname:d}=Ri(),u=s?t??(e?"local-board":null):null,h=l||!c&&fG(d);if(!u||o||h)return null;const p={companyId:r,companyPrefix:a?.issuePrefix??null,projectId:null,entityId:null,entityType:null,parentEntityId:null,userId:t};return(0,n.jsx)(n_n,{context:p},JSON.stringify([u,r]))}i(s_n,"PluginAppShellOverlays");var P6e="relative flex min-h-(--sz-calc-11) min-w-0 flex-col items-center justify-center gap-1 rounded-md text-(length:--text-nano) font-medium transition-colors";function r_n({visible:e}){const{selectedCompanyId:t}=gn(),{sidebarOpen:s,setSidebarOpen:r}=Io(),a=kV(t),{enabled:o}=MS(),{enabled:l}=VD(),c=(0,m.useMemo)(()=>[{to:"/dashboard",label:"Home",icon:VHe},...l?[]:[{to:"/inbox",label:"Inbox",icon:w0,badge:a.inbox}],{to:"/issues",label:"Tasks",icon:mi,badge:l?a.inbox:void 0},...o?[{to:"/chats",label:"Chat",icon:AM}]:[]],[a.inbox,o,l]);return(0,n.jsx)("nav",{className:"mobile-bottom-nav fixed inset-x-0 bottom-0 z-30 bg-bg-3 pb-(--sz-safe-bottom)","data-visible":e,inert:!e,"aria-label":"Mobile navigation",children:(0,n.jsxs)("div",{className:"grid h-16 px-1",style:{gridTemplateColumns:`repeat(${c.length+1}, minmax(0, 1fr))`},children:[c.map(d=>{const u=d.icon;return(0,n.jsx)(Ope,{to:d.to,state:qA,className:i(({isActive:h})=>Q(P6e,h?"text-ink":"text-ink-3"),"className"),children:i(({isActive:h})=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"relative",children:[(0,n.jsx)(u,{className:Q("h-(--sz-18px) w-(--sz-18px)",h&&"stroke-(length:--sw-2_3)")}),d.badge!=null&&d.badge>0&&(0,n.jsx)(lt,{variant:"ghost",className:"absolute -end-2 -top-2 bg-accent px-1.5 text-(length:--text-nano) leading-none text-accent-ink",children:d.badge>99?"99+":d.badge})]}),(0,n.jsx)("span",{className:"truncate",children:d.label})]}),"children")},d.label)}),(0,n.jsxs)("button",{type:"button","aria-expanded":s,onClick:i(()=>r(!0),"onClick"),className:Q(P6e,s?"text-ink":"text-ink-3"),children:[(0,n.jsx)(yGe,{className:"h-(--sz-18px) w-(--sz-18px)"}),(0,n.jsx)("span",{className:"truncate",children:"More"})]})]})})}i(r_n,"MobileBottomNav");function b5(e){if(typeof document>"u")return null;const t=document.querySelector(`meta[name="${e}"]`)?.getAttribute("content")?.trim();return t||null}i(b5,"readMetaContent");function fde(e){if(!e)return null;const t=e.startsWith("#")?e.slice(1):e;return/^[0-9a-fA-F]{3}$/.test(t)?`#${t.split("").map(s=>`${s}${s}`).join("").toLowerCase()}`:/^[0-9a-fA-F]{6}$/.test(t)?`#${t.toLowerCase()}`:null}i(fde,"normalizeHexColor");function i_n(e){const t=fde(e)??"#000000";return{r:Number.parseInt(t.slice(1,3),16),g:Number.parseInt(t.slice(3,5),16),b:Number.parseInt(t.slice(5,7),16)}}i(i_n,"hexToRgb");function ste(e){const t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}i(ste,"relativeLuminanceChannel");function a_n(e){const{r:t,g:s,b:r}=i_n(e),a=.2126*ste(t)+.7152*ste(s)+.0722*ste(r);return 1.05/(a+.05)>=(a+.05)/.05?NRt:gRt}i(a_n,"pickReadableTextColor");function o_n(){return b5("paperclip-worktree-enabled")==="true"}i(o_n,"isWorktreeRuntime");function l_n(){return b5("paperclip-instance-id")}i(l_n,"getWorktreeInstanceId");function c_n(){if(b5("paperclip-worktree-enabled")!=="true")return null;const e=b5("paperclip-worktree-name"),t=fde(b5("paperclip-worktree-color"));return!e||!t?null:{enabled:!0,name:e,color:t,textColor:fde(b5("paperclip-worktree-text-color"))??a_n(t)}}i(c_n,"getWorktreeUiBranding");function d_n(){const e=c_n(),{copied:t,failed:s,copy:r}=vx(),a=(0,m.useCallback)(()=>{e&&r(e.name)},[e,r]);return e?(0,n.jsx)("div",{className:"relative overflow-hidden border-b px-3 py-1.5 text-(length:--text-micro) font-medium tracking-(--tracking-caps) uppercase",style:{backgroundColor:e.color,color:e.textColor,borderColor:`${e.textColor}22`,boxShadow:`inset 0 -1px 0 ${e.textColor}18`,backgroundImage:`linear-gradient(90deg, ${e.textColor}14, transparent 28%, transparent 72%, ${e.textColor}12), repeating-linear-gradient(135deg, transparent 0 10px, ${e.textColor}08 10px 20px)`},children:(0,n.jsxs)("div",{className:"flex items-center gap-2 overflow-hidden whitespace-nowrap",children:[(0,n.jsx)("span",{className:"shrink-0 opacity-70",children:"Worktree"}),(0,n.jsx)("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-current opacity-70","aria-hidden":"true"}),(0,n.jsx)("button",{type:"button",onClick:a,title:"Click to copy worktree name",className:"truncate font-semibold tracking-(--tracking-eyebrow) cursor-pointer hover:opacity-80 transition-opacity bg-transparent border-none p-0 text-current uppercase text-(length:--text-micro)",children:t?"Copied!":s?"Copy failed":e.name})]})}):null}i(d_n,"WorktreeBanner");var u_n=3e4;function h_n(e){if(!e)return null;const t=new Date(e).getTime();if(Number.isNaN(t))return null;const s=Date.now()-t;if(s<6e4)return"just now";const r=Math.round(s/6e4);if(r<60)return`${r}m ago`;const a=Math.round(r/60);return a<24?`${a}h ago`:`${Math.round(a/24)}d ago`}i(h_n,"formatRelativeTimestamp");function m_n(e){return e.reason==="backend_changes_and_pending_migrations"?"backend files changed and migrations are pending":e.reason==="pending_migrations"?"pending migrations need a fresh boot":"backend files changed since this server booted"}i(m_n,"describeReason");function p_n({devServer:e}){const[t,s]=(0,m.useState)(!1);if((0,m.useEffect)(()=>{if(!t)return;const d=window.setTimeout(()=>{s(!1)},u_n);return()=>window.clearTimeout(d)},[t]),!e?.enabled||!e.restartRequired)return null;const r=e,a=h_n(e.lastChangedAt),o=e.changedPathsSample.slice(0,3),l=`${e.activeRunCount} live run${e.activeRunCount===1?"":"s"}`;async function c(){const d=r.activeRunCount>0?`Restart Wardmote now? This may interrupt ${l}.`:"Restart Wardmote now?";if(window.confirm(d)){s(!0);try{await Op.requestDevServerRestart()}catch(u){s(!1),window.alert(u instanceof Error?u.message:"Failed to request restart")}}}return i(c,"requestRestartNow"),(0,n.jsx)("div",{className:"border-b border-amber-300/60 bg-amber-50 text-amber-950 dark:border-amber-500/25 dark:bg-amber-500/10 dark:text-amber-100",children:(0,n.jsxs)("div",{className:"flex flex-col gap-3 px-3 py-2.5 md:flex-row md:items-center md:justify-between",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 text-xs font-semibold uppercase tracking-(--tracking-caps)",children:[(0,n.jsx)(En,{className:"h-3.5 w-3.5 shrink-0"}),(0,n.jsx)("span",{children:"Restart Required"}),e.autoRestartEnabled?(0,n.jsx)(lt,{variant:"ghost",className:"bg-amber-900/10 text-(length:--text-nano) tracking-(--tracking-eyebrow) dark:bg-amber-100/10",children:"Auto-Restart On"}):null]}),(0,n.jsxs)("p",{className:"mt-1 text-sm",children:[m_n(e),a?` · updated ${a}`:""]}),(0,n.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-amber-900/80 dark:text-amber-100/75",children:[o.length>0?(0,n.jsxs)("span",{children:["Changed: ",o.join(", "),e.changedPathCount>o.length?` +${e.changedPathCount-o.length} more`:""]}):null,e.pendingMigrations.length>0?(0,n.jsxs)("span",{children:["Pending migrations: ",e.pendingMigrations.slice(0,2).join(", "),e.pendingMigrations.length>2?` +${e.pendingMigrations.length-2} more`:""]}):null]})]}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs font-medium md:justify-end",children:[e.waitingForIdle?(0,n.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full bg-amber-900/10 px-3 py-1.5 dark:bg-amber-100/10",children:[(0,n.jsx)(yPt,{className:"h-3.5 w-3.5"}),(0,n.jsxs)("span",{children:["Waiting for ",l," to finish"]})]}):e.autoRestartEnabled?(0,n.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full bg-amber-900/10 px-3 py-1.5 dark:bg-amber-100/10",children:[(0,n.jsx)(ba,{className:"h-3.5 w-3.5"}),(0,n.jsx)("span",{children:"Auto-restart will trigger when the instance is idle"})]}):(0,n.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full bg-amber-900/10 px-3 py-1.5 dark:bg-amber-100/10",children:[(0,n.jsx)(ba,{className:"h-3.5 w-3.5"}),(0,n.jsxs)("span",{children:["Restart ",(0,n.jsx)("code",{children:"pnpm dev:once"})," after the active work is safe to interrupt"]})]}),(0,n.jsxs)($,{variant:"primary",size:"sm",type:"button",onClick:i(()=>{c()},"onClick"),disabled:t,children:[(0,n.jsx)(ba,{className:"h-3.5 w-3.5"}),(0,n.jsx)("span",{children:t?"Restart requested":"Restart now"})]})]})]})})}i(p_n,"DevRestartBanner");var Bft=["standalone","fullscreen","window-controls-overlay"];function f_n(e){return`(display-mode: ${e})`}i(f_n,"displayModeQuery");function g_n(){if(!(typeof window>"u"||typeof window.matchMedia!="function"))return window.matchMedia.bind(window)}i(g_n,"defaultMatchMedia");function gde(e=g_n(),t=typeof navigator>"u"?void 0:navigator.standalone){return t===!0?!0:e?Bft.some(s=>e(f_n(s)).matches):!1}i(gde,"isChromelessDisplayMode");function T$({label:e,children:t,onClick:s}){return(0,n.jsxs)(Zs,{children:[(0,n.jsx)(Xs,{asChild:!0,children:(0,n.jsx)($,{type:"button",variant:"ghost",size:"icon-sm",className:"size-8","aria-label":e,onClick:i(()=>{s()},"onClick"),children:t})}),(0,n.jsx)(er,{children:e})]})}i(T$,"ControlButton");function x_n(e=typeof window>"u"?null:window.history.state){const t=e?.idx;return typeof t=="number"&&t>0}i(x_n,"hasInAppHistory");function v_n(){const[e,t]=(0,m.useState)(()=>typeof window<"u"?gde():!1);return(0,m.useEffect)(()=>{if(typeof window>"u")return;const s=i(()=>t(gde()),"update");if(s(),typeof window.matchMedia!="function")return;const r=Bft.map(a=>window.matchMedia(`(display-mode: ${a})`));return r.every(a=>typeof a.addEventListener=="function")?(r.forEach(a=>a.addEventListener("change",s)),()=>r.forEach(a=>a.removeEventListener("change",s))):(r.forEach(a=>a.addListener(s)),()=>r.forEach(a=>a.removeListener(s)))},[]),e}i(v_n,"useChromeless");function $6e({mobile:e,onNavigateHome:t}){const s=v_n(),r=Eh(),a=(0,m.useCallback)(()=>{if(x_n()){window.history.back();return}t?t():window.location.assign("/dashboard")},[t]),o=(0,m.useCallback)(()=>{window.location.reload()},[]),l=(0,m.useCallback)(async()=>{const d=window.location.href;try{if(navigator.share){await navigator.share({title:document.title||"Wardmote",url:d});return}await pi(d),r?.pushToast({title:"Link copied",tone:"success"})}catch(u){if(u instanceof DOMException&&u.name==="AbortError")return;r?.pushToast({title:"Share failed",body:"Try opening the page in your browser.",tone:"error"})}},[r]),c=(0,m.useCallback)(()=>{window.open(window.location.href,"_blank","noopener,noreferrer")},[]);return s?(0,n.jsxs)("div",{className:Q("flex items-center gap-1",e?"h-10 border-b border-line bg-bg/95 px-3 backdrop-blur supports-[backdrop-filter]:bg-bg/85":"h-9 border-b border-line px-2"),children:[(0,n.jsx)(T$,{label:"Back",onClick:a,children:(0,n.jsx)(cc,{className:"h-4 w-4"})}),(0,n.jsx)("div",{className:"flex-1"}),(0,n.jsx)(T$,{label:"Refresh",onClick:o,children:(0,n.jsx)(Aa,{className:"h-4 w-4"})}),(0,n.jsx)(T$,{label:"Share",onClick:l,children:(0,n.jsx)(B0e,{className:"h-4 w-4"})}),(0,n.jsx)(T$,{label:"Open in Browser",onClick:c,children:(0,n.jsx)(Us,{className:"h-4 w-4"})})]}):null}i($6e,"StandaloneBrowserControls");function b_n(e){return e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}i(b_n,"formatTime$3");function y_n(){const e=W0(),[t,s]=(0,m.useState)(null);return(0,m.useEffect)(()=>{if(!e){s(null);return}let r=!1;const a=new Date;return BIt().then(o=>{r||s(o&&o<a?o:a)}),()=>{r=!0}},[e]),e?(0,n.jsxs)("div",{role:"status",className:"flex items-start gap-2 border-b border-line bg-warn-soft px-4 py-2 text-sm text-ink",children:[(0,n.jsx)(RPt,{className:"mt-0.5 size-4 shrink-0 text-warn","aria-hidden":"true"}),(0,n.jsxs)("span",{children:[(0,n.jsx)("b",{className:"font-semibold",children:"You are offline."})," ",t?`Showing what was loaded at ${b_n(t)}. `:"Showing what was already loaded. ","Approvals and replies wait until you are back."]})]}):null}i(y_n,"OfflineBanner");function zft(){return typeof navigator>"u"?null:navigator.windowControlsOverlay??null}i(zft,"overlay");function k_n(e){const t=zft();return t?.addEventListener("geometrychange",e),()=>t?.removeEventListener("geometrychange",e)}i(k_n,"subscribe$3");function w_n(){return(0,m.useSyncExternalStore)(k_n,()=>zft()?.visible===!0,()=>!1)}i(w_n,"useWindowControlsOverlayVisible");var j_n={WebkitAppRegion:"drag",appRegion:"drag"},N_n={WebkitAppRegion:"no-drag",appRegion:"no-drag"};function C_n(){const{selectedCompanyId:e}=gn(),{inbox:t}=kV(e);return(0,n.jsxs)("div",{"data-slot":"window-titlebar",className:"flex shrink-0 items-center gap-2 border-b border-line bg-bg px-3 text-xs text-ink-2",style:{...j_n,marginLeft:"env(titlebar-area-x, 0px)",width:"env(titlebar-area-width, 100%)",height:"env(titlebar-area-height, 33px)"},children:[(0,n.jsx)($0,{className:"size-4 shrink-0 text-ink","aria-hidden":"true"}),(0,n.jsx)("span",{className:"font-semibold text-ink",children:"Wardmote"}),(0,n.jsxs)(Ye,{to:"/inbox",style:N_n,className:"ml-1 inline-flex items-center gap-1 rounded-(--r-sm) px-1.5 py-0.5 hover:bg-bg-3 hover:text-ink","aria-label":t>0?`Inbox, ${t} waiting`:"Inbox",children:["Inbox",t>0?(0,n.jsx)("span",{className:"rounded-(--r-pill) bg-accent px-1.5 text-(length:--text-micro) font-semibold text-accent-ink tabular-nums",children:t}):null]})]})}i(C_n,"TitleBarContent");function S_n(){return w_n()?(0,n.jsx)(C_n,{}):null}i(S_n,"WindowTitleBar");var __n=16384,A_n=40;function I_n(e){if(!e)return;const t=[];for(const s of e.slice(0,__n).split(`
412
412
  `).slice(0,41)){const r=/^\s*(?:at|in) ([A-Za-z_$][\w$.-]{0,99})(?:\s|$)/.exec(s)?.[1]??/^([A-Za-z_$][\w$.-]{0,99})@/.exec(s)?.[1];if(r&&t.push(` at ${r}`),t.length===A_n)break}return t.length?`
413
413
  ${t.join(`
414
- `)}`:void 0}i(I_n,"sanitizeComponentStack");function qft(){const e={};if(typeof document<"u"){try{const t=document.readyState;(t==="loading"||t==="interactive"||t==="complete")&&(e.ready_state=t)}catch{}try{const t=document.visibilityState;(t==="visible"||t==="hidden")&&(e.visibility_state=t)}catch{}try{const t=document.documentElement.classList;e.translation_marker=t.contains("translated-ltr")||t.contains("translated-rtl")}catch{}}return e}i(qft,"readBrowserErrorState");function T_n(e){const t=I_n(e.componentStack);return{tags:{react_error_boundary:e.boundary},contexts:{react:t?{componentStack:t}:{},browser_state:qft()}}}i(T_n,"buildBrowserErrorContext");var O6e=Promise.resolve();function Iye(e){const t=O6e.then(e);return O6e=t.catch(()=>{}),t}i(Iye,"enqueue");var CI=null;function E_n(e,t){return Iye(async()=>{if(!CI)try{const s=await ln(()=>import("./prod-COP_vZWu.js"),__vite__mapDeps([33,5]));s.init(M_n(e,t)),CI=s}catch{}})}i(E_n,"initBrowserErrorMonitoring");function R_n(){return Iye(async()=>{const e=CI;if(CI=null,!e)return;const t=e.getClient();try{e.getCurrentScope().setClient(void 0)}catch{}try{await t?.close(2e3)}catch{}})}i(R_n,"teardownBrowserErrorMonitoring");function Tye(e,t){let s;try{t&&(s=T_n(t))}catch{}Iye(async()=>{try{s?CI?.captureException(e,s):CI?.captureException(e)}catch{}})}i(Tye,"captureBrowserException");function M_n(e,t){return{dsn:e,environment:t??void 0,release:"ec0b842f4589897d2209c950af15edad80964c10",tracesSampleRate:0,sendDefaultPii:!1,beforeSend:i((s,r)=>{try{if(s.contexts={...s.contexts,browser_state:s.contexts?.browser_state??qft()},s.tags={...s.tags,browser_build_mode:"production"},s.exception?.values?.some(a=>a.mechanism?.type==="onunhandledrejection"||a.mechanism?.type==="auto.browser.global_handlers.onunhandledrejection")){const a=r.originalException;s.tags.browser_rejection_kind=a===null?"null":typeof a}}catch{}return s},"beforeSend"),integrations:i(s=>s.filter(r=>r.name!=="HttpContext"&&r.name!=="Breadcrumbs"),"integrations")}}i(M_n,"buildBrowserSentryInitOptions");var L_n=class extends m.Component{static{i(this,"RouteErrorBoundaryInner")}state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,t){Tye(e,{boundary:"route",componentStack:t.componentStack})}componentDidUpdate(e){this.state.error&&e.resetKey!==this.props.resetKey&&this.setState({error:null})}render(){const{error:e}=this.state;return e?(0,n.jsxs)("div",{className:"mx-auto max-w-2xl space-y-4 px-4 py-10",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"This page hit an error"}),(0,n.jsx)("p",{className:"mt-1 text-sm text-ink-3",children:"Something went wrong while rendering this page. You can go back and try again, or reload."})]}),(0,n.jsx)("pre",{className:"overflow-auto rounded-md border border-bad/30 bg-bad/10 px-3 py-2 text-xs text-bad whitespace-pre-wrap",children:e.message}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)($,{variant:"secondary",size:"sm",onClick:this.props.onReset,children:"Go back"}),(0,n.jsx)($,{size:"sm",onClick:i(()=>window.location.reload(),"onClick"),children:"Reload page"})]})]}):this.props.children}};function D_n({children:e}){const t=Ri(),s=ir(),r=`${t.pathname}${t.search}`;return(0,n.jsx)(L_n,{resetKey:r,onReset:i(()=>s(-1),"onReset"),children:e})}i(D_n,"RouteErrorBoundary");var F6e={bot:Uo,cpu:If,brain:Xy,zap:hq,rocket:JEt,code:oRt,terminal:gk,shield:UQ,eye:Om,search:Jr,wrench:Xf,hammer:X8,lightbulb:tD,sparkles:eb,star:fk,heart:nR,flame:qEt,bug:n3,cog:IKe,database:eD,globe:Lp,lock:rl,mail:Bpe,"message-square":Kv,"file-code":Qc,"git-branch":Ao,package:ax,puzzle:t3,target:Xv,wand:W0e,atom:REt,"circuit-board":_7t,radar:QEt,swords:xPt,telescope:eRt,microscope:Y7t,crown:zQ,gem:KEt,hexagon:Xh,pentagon:rPt,fingerprint:_ie},P_n="bot";function $_n(e){return e&&a4t.includes(e)?F6e[e]:F6e[P_n]}i($_n,"getAgentIcon");function BK({icon:e,className:t}){const s=$_n(e);return(0,n.jsx)(s,{className:t})}i(BK,"AgentIcon");function Uft({open:e,onOpenChange:t,...s}){return(0,n.jsx)(Bn,{open:e,onOpenChange:t,children:(0,n.jsxs)(zn,{"aria-describedby":void 0,className:"gap-0 overflow-hidden p-0 sm:max-w-md",children:[(0,n.jsxs)("div",{className:"px-4 pt-4 pb-3",children:[(0,n.jsx)(qn,{children:"Chat with an agent"}),s.existingChatAgentIds&&(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"One conversation per agent. Pick up where you left off."})]}),(0,n.jsx)(O_n,{...s,onComplete:i(()=>t(!1),"onComplete")},String(e))]})})}i(Uft,"AgentChatPicker");function O_n({agents:e,onSelect:t,onComplete:s,loading:r,error:a,onRetry:o,existingChatAgentIds:l,renderAgentIcon:c}){const d=(0,m.useRef)(!1),u=(0,m.useRef)(null);(0,m.useEffect)(()=>(d.current=!0,()=>{d.current=!1,u.current?.abort()}),[]);const[h,p]=(0,m.useState)(""),[f,g]=(0,m.useState)(null),[x,v]=(0,m.useState)(null);async function b(y){if(f)return;g(y.id),v(null);const k=new AbortController;u.current=k;try{await t(y,k.signal),d.current&&s()}catch(j){v(j instanceof Error?j.message:"Couldn’t open chat. Try again.")}finally{g(null)}}return i(b,"selectAgent"),(0,n.jsxs)(PS,{children:[(0,n.jsx)($S,{"aria-label":"Search agents by name or role",placeholder:"Search by name or role…",value:h,onValueChange:p}),x&&(0,n.jsx)("p",{role:"alert",className:"px-4 py-3 text-sm text-bad",children:x}),f&&(0,n.jsx)("p",{role:"status",className:"sr-only",children:"Opening conversation…"}),a?(0,n.jsxs)("div",{role:"alert",className:"flex flex-col items-start gap-2 p-4 text-sm",children:[(0,n.jsx)("p",{children:"Couldn’t load agents. Try again."}),o&&(0,n.jsx)($,{variant:"secondary",size:"sm",onClick:o,children:"Retry"})]}):r?(0,n.jsx)("p",{role:"status",className:"p-4 text-sm text-ink-3",children:"Loading agents…"}):(0,n.jsxs)(OS,{children:[(0,n.jsx)(FS,{children:(0,n.jsxs)("div",{className:"flex flex-col items-center gap-2 px-4",children:[(0,n.jsx)("span",{children:e.length?`No agents match “${h}”`:"No agents yet."}),e.length?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-xs text-ink-3",children:"Try another name or role."}),(0,n.jsx)($,{variant:"ghost",size:"sm",onClick:i(()=>p(""),"onClick"),children:"Clear search"})]}):(0,n.jsx)("span",{className:"text-xs text-ink-3",children:"Create an agent from the Agents page to start chatting."})]})}),(0,n.jsx)(qh,{children:e.map(y=>(0,n.jsxs)(jo,{value:y.id,keywords:[y.name,y.title??"",y.role],onSelect:i(()=>{b(y)},"onSelect"),disabled:f!==null,className:"gap-3 px-3 py-3",children:[c?c(y):(0,n.jsx)(BK,{icon:y.icon,className:"size-4 shrink-0"}),(0,n.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,n.jsx)("span",{className:"truncate font-medium",children:y.name}),(0,n.jsx)("span",{className:"truncate text-xs text-ink-3",children:y.title??y.role})]}),l&&(0,n.jsx)("span",{className:"shrink-0 text-xs text-ink-3",children:l.includes(y.id)?"Open chat":"New chat"}),y.status==="paused"&&(0,n.jsx)("span",{className:"text-xs text-(--status-agent-paused)",children:"Paused"}),y.status==="terminated"&&(0,n.jsx)("span",{className:"text-xs text-ink-3",children:"Terminated"}),y.status==="pending_approval"&&(0,n.jsx)("span",{className:"text-xs text-ink-3",children:"Awaiting approval"})]},y.id))})]})]})}i(O_n,"AgentChatPickerResults");function az({agents:e,existingChatAgentIds:t,availableAgents:s=e,activeId:r,previews:a={},loading:o=!1,error:l,onRetry:c,initialSearch:d="",onSelect:u,onBrowse:h,onAddChat:p,historyLoading:f,historyError:g,onRetryHistory:x}){const v=ir(),[b,y]=(0,m.useState)(!1),[k,j]=(0,m.useState)(d),N=(0,m.useRef)(null),S=(0,m.useId)(),A=k.trim().toLocaleLowerCase(),I=e.filter(T=>`${T.name} ${T.title??""} ${T.role}`.toLocaleLowerCase().includes(A));function _(){j(""),N.current?.focus()}return i(_,"focusSearch"),(0,n.jsxs)("aside",{"aria-labelledby":S,className:"flex h-full min-h-0 flex-col border-r border-line bg-bg",children:[(0,n.jsxs)("div",{className:"flex shrink-0 flex-col gap-4 px-3 pb-4 pt-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsx)("h2",{id:S,className:"text-sm font-semibold",children:"Chat"}),(0,n.jsx)($,{variant:"secondary",size:"icon-sm","aria-label":"Add chat",title:"Add chat",onClick:i(()=>y(!0),"onClick"),children:(0,n.jsx)(js,{className:"size-4"})})]}),(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)(Jr,{"aria-hidden":"true",className:"pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-ink-3"}),(0,n.jsx)(mt,{ref:N,"aria-label":"Search agents",placeholder:"Find an agent",value:k,onChange:i(T=>j(T.target.value),"onChange"),onKeyDown:i(T=>{T.key==="Escape"&&(T.stopPropagation(),j(""))},"onKeyDown"),className:"h-8 pl-8 pr-8 text-xs md:text-xs"}),k&&(0,n.jsx)($,{variant:"ghost",size:"icon-xs","aria-label":"Clear search",className:"absolute right-1 top-1/2 -translate-y-1/2",onClick:_,children:(0,n.jsx)(ks,{className:"size-3"})})]})]}),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto px-3 pb-3 scrollbar-auto-hide",children:[(0,n.jsx)("p",{className:"px-2 text-(length:--text-micro) font-medium uppercase tracking-widest text-ink-3",children:A?"Search results":"Teammates"}),(0,n.jsx)("span",{role:"status",className:"sr-only",children:o?"Loading agents":`${I.length} ${I.length===1?"agent":"agents"}`}),f&&(0,n.jsx)("p",{role:"status",className:"px-2 text-xs text-ink-3",children:"Loading chat history…"}),g&&(0,n.jsxs)("div",{role:"alert",className:"flex flex-col items-start gap-2 px-2 py-3",children:[(0,n.jsx)("p",{className:"text-xs text-ink-3",children:"Some chat history couldn’t load."}),(0,n.jsx)($,{variant:"secondary",size:"sm",onClick:x,children:"Retry chat history"})]}),l?(0,n.jsxs)("div",{role:"alert",className:"flex flex-col items-start gap-2 px-2 py-6",children:[(0,n.jsx)("p",{className:"text-sm",children:"Couldn’t load your chats."}),(0,n.jsx)($,{variant:"secondary",size:"sm",onClick:c,children:"Try again"})]}):o?(0,n.jsx)("div",{"aria-hidden":"true",className:"flex flex-col gap-1",children:[0,1,2,3].map(T=>(0,n.jsxs)("div",{className:"flex items-center gap-3 rounded-md px-2 py-3 motion-safe:animate-pulse",children:[(0,n.jsx)("div",{className:"size-8 shrink-0 rounded-lg bg-bg-3"}),(0,n.jsxs)("div",{className:"flex flex-1 flex-col gap-2",children:[(0,n.jsx)("div",{className:"h-3 w-2/3 rounded-sm bg-bg-3"}),(0,n.jsx)("div",{className:"h-2 w-full rounded-sm bg-bg-3"})]})]},T))}):I.length?(0,n.jsx)("nav",{"aria-label":"Agent conversations",className:"flex flex-col gap-1",children:I.map(T=>(0,n.jsxs)(Ye,{to:`/chats/${encodeURIComponent(T.status==="terminated"?T.id:Gd(T))}`,"aria-current":r===T.id?"page":void 0,title:`${T.name}${T.title?` · ${T.title}`:""}`,onClick:i(E=>{u&&(E.preventDefault(),u(T))},"onClick"),className:Q("flex min-w-0 items-center gap-3 rounded-md px-2 py-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus",r===T.id?r1.active:r1.rest),children:[(0,n.jsx)(lr,{agent:T,size:32}),(0,n.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,n.jsx)("span",{className:"truncate text-sm font-medium",children:T.name}),(0,n.jsx)("span",{className:"truncate text-xs text-ink-3",children:T.status==="terminated"?"Terminated":T.status==="paused"?"Paused":a[T.id]??T.title??"Start a conversation"})]})]},T.id))}):!e.length&&(f||g)?null:(0,n.jsxs)("div",{className:"flex flex-col items-start gap-2 px-2 py-6",children:[(0,n.jsx)("p",{className:"text-sm font-medium",children:e.length?"No agents found":"No chats yet"}),(0,n.jsx)("p",{className:"text-xs leading-relaxed text-ink-3",children:e.length?"Try another name or role.":"Choose an agent to start a conversation."}),!e.length&&(0,n.jsx)($,{variant:"secondary",size:"sm",onClick:i(()=>y(!0),"onClick"),children:"Choose an agent"}),e.length>0&&(0,n.jsx)($,{variant:"secondary",size:"sm",onClick:_,children:"Clear search"})]})]}),(0,n.jsx)("div",{className:"shrink-0 px-3 py-4",children:(0,n.jsx)($,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 px-2",asChild:!h,onClick:h,children:h?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(Jc,{className:"size-4"}),"Browse all agents"]}):(0,n.jsxs)(Ye,{to:"/agents/all",children:[(0,n.jsx)(Jc,{className:"size-4"}),"Browse all agents"]})})}),(0,n.jsx)(Uft,{agents:s,open:b,onOpenChange:y,existingChatAgentIds:t??e.map(T=>T.id),loading:o,error:l,onRetry:c,renderAgentIcon:i(T=>(0,n.jsx)(lr,{agent:T,size:32}),"renderAgentIcon"),onSelect:i(async(T,E)=>{p?await p(T,E):u?await u(T,E):v(`/chats/${encodeURIComponent(Gd(T))}`),E?.aborted||j("")},"onSelect")})]})}i(az,"AgentConversationSidebar");var zK={list:i(e=>le.get(`/companies/${e}/chats`),"list"),get:i((e,t)=>le.get(`/companies/${e}/chats/${encodeURIComponent(t)}`),"get"),ensure:i((e,t)=>le.post(`/companies/${e}/chats/${encodeURIComponent(t)}`,{}),"ensure")};function Kft(){const{selectedCompanyId:e}=gn(),{enabled:t,loaded:s}=MS(),r=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn")}),a=r.data?.user?.id??r.data?.session?.userId??null;return{companyId:e,userId:a,enabled:t,loaded:s,agents:ie({queryKey:O.agents.list(e),queryFn:i(()=>Pt.list(e),"queryFn"),enabled:t&&!!e}),chats:ie({queryKey:O.agentChats.list(e,a),queryFn:i(()=>zK.list(e),"queryFn"),enabled:t&&!!e&&r.isSuccess}),session:r}}i(Kft,"useAgentChatNavigation");function Wft(e,t){const s=Ct(),r=ir(),{isMobile:a,setSidebarOpen:o}=Io(),l=(0,m.useRef)({companyId:e,userId:t,mounted:!0});return(0,m.useEffect)(()=>{const c={companyId:e,userId:t,mounted:!0};return l.current=c,()=>{c.mounted=!1}},[e,t]),(0,m.useCallback)(async(c,d)=>{if(!e||c.companyId!==e)throw new Error("Choose an agent from this company.");const u=l.current,h=await zK.ensure(e,c.id);s.setQueryData(O.agentChats.detail(e,t,c.id),h),s.setQueryData(O.issues.detail(h.id),h),s.setQueryData(O.agentChats.list(e,t),p=>[h,...(p??[]).filter(f=>f.id!==h.id)].sort((f,g)=>new Date(g.updatedAt).getTime()-new Date(f.updatedAt).getTime()||g.id.localeCompare(f.id))),!(!u.mounted||l.current!==u||d?.aborted)&&(r(`/chats/${encodeURIComponent(Gd(c))}`),a&&o(!1))},[s,e,t,r,a,o])}i(Wft,"useOpenAgentChat");function F_n(){const{companyId:e,userId:t,agents:s,chats:r,session:a}=Kft(),o=Wft(e,t),l=ir(),c=RS(e),{isMobile:d,setSidebarOpen:u}=Io(),{pathname:h}=Ri(),p=h.split("/chats/")[1]?.split("/")[0],f=s.data??[],g=s.isSuccess?[...new Set((r.data??[]).flatMap(S=>S.conversationAgentId&&!f.some(A=>A.id===S.conversationAgentId)?[S.conversationAgentId]:[]))]:[],x=$m({queries:g.map(S=>({queryKey:O.agents.detail(S),queryFn:i(()=>Pt.get(S,e),"queryFn")}))}),v=new Map(f.map(S=>[S.id,S]));for(const S of x)S.data&&v.set(S.data.id,S.data);const b=[...v.values()].find(S=>S.id===p||S.status!=="terminated"&&encodeURIComponent(Gd(S))===p),y=(r.data??[]).flatMap(S=>{const A=S.conversationAgentId?v.get(S.conversationAgentId):void 0;return A?[A]:[]});b&&!y.some(S=>S.id===b.id)&&y.unshift(b);const k=new Set(y.map(S=>S.id)),j=f.filter(S=>!k.has(S.id)&&S.status!=="terminated"&&(!c.isSuccess||P3(c.data,"agent",S.id)!=="left")).sort((S,A)=>S.name.localeCompare(A.name,void 0,{sensitivity:"base"})),N=Object.fromEntries((r.data??[]).filter(S=>S.conversationState==="active").map(S=>[S.conversationAgentId,"Working…"]));return(0,n.jsx)(az,{agents:[...y,...j],availableAgents:f,existingChatAgentIds:y.map(S=>S.id),activeId:b?.id,previews:N,loading:s.isPending||r.isPending||a.isPending,error:s.error??r.error??a.error,onRetry:i(()=>{s.refetch(),r.refetch(),a.refetch()},"onRetry"),historyLoading:x.some(S=>S.isPending),historyError:x.find(S=>S.error)?.error,onRetryHistory:i(()=>{x.filter(S=>S.isError).forEach(S=>{S.refetch()})},"onRetryHistory"),onAddChat:o,onSelect:i(S=>{l(`/chats/${encodeURIComponent(S.status==="terminated"?S.id:Gd(S))}`),d&&u(!1)},"onSelect")},`${e}:${t}`)}i(F_n,"AgentConversationsSidebar");var E$=232,xde=208,vde=420,B6e=16;function qK(e){return Math.min(vde,Math.max(xde,e))}i(qK,"clampSidebarWidth");function z6e(e){if(typeof window>"u")return E$;try{const t=window.localStorage.getItem(e);if(!t)return E$;const s=Number.parseInt(t,10);return Number.isFinite(s)?qK(s):E$}catch{return E$}}i(z6e,"readStoredSidebarWidth");function q6e(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,String(qK(t)))}catch{}}i(q6e,"writeStoredSidebarWidth");function B_n({children:e,open:t,collapsed:s=!1,peeking:r=!1,resizable:a=!1,storageKey:o="paperclip.sidebar.width",className:l,onPanelMouseEnter:c,onPanelMouseLeave:d,onPanelFocusCapture:u,onPanelBlurCapture:h}){const[p,f]=(0,m.useState)(()=>z6e(o)),[g,x]=(0,m.useState)(!1),v=(0,m.useRef)(p),b=(0,m.useRef)(null);(0,m.useEffect)(()=>{const D=z6e(o);v.current=D,f(D)},[o]);const y=t?p:0,k=t?s?72:y:0,j=t?s&&!r?72:y:0,N=j>k,S=a&&t&&!s,A=(0,m.useMemo)(()=>({width:`${k}px`}),[k]),I=(0,m.useMemo)(()=>({width:`${j}px`}),[j]),_=(0,m.useCallback)(D=>{const K=qK(D);v.current=K,f(K),q6e(o,K)},[o]),T=(0,m.useCallback)(D=>{S&&(D.preventDefault(),D.currentTarget.setPointerCapture(D.pointerId),b.current={startX:D.clientX,startWidth:v.current},x(!0))},[S]),E=(0,m.useCallback)(D=>{if(!b.current)return;const K=qK(b.current.startWidth+D.clientX-b.current.startX);v.current=K,f(K)},[]),M=(0,m.useCallback)(()=>{b.current&&(b.current=null,x(!1),q6e(o,v.current))},[o]),P=(0,m.useCallback)(D=>{S&&(D.key==="ArrowLeft"?(D.preventDefault(),_(p-B6e)):D.key==="ArrowRight"?(D.preventDefault(),_(p+B6e)):D.key==="Home"?(D.preventDefault(),_(xde)):D.key==="End"&&(D.preventDefault(),_(vde)))},[S,_,p]);return(0,n.jsxs)("div",{className:Q("relative h-full shrink-0",l),style:A,children:[(0,n.jsx)("div",{className:Q("absolute inset-y-0 left-0 flex flex-col overflow-hidden",N?"z-30 border-r border-line bg-bg shadow-lg":"z-0"),style:I,"data-sidebar-overlay":N?"":void 0,onMouseEnter:c,onMouseLeave:d,onFocusCapture:u,onBlurCapture:h,children:e}),S?(0,n.jsx)("div",{role:"separator","aria-label":"Resize sidebar","aria-orientation":"vertical","aria-valuemin":xde,"aria-valuemax":vde,"aria-valuenow":p,tabIndex:0,"data-dragging":g?"":void 0,className:"group absolute inset-y-0 z-20 cursor-col-resize touch-none outline-none",style:{right:-4,width:8},onPointerDown:T,onPointerMove:E,onPointerUp:M,onPointerCancel:M,onLostPointerCapture:M,onKeyDown:P,children:(0,n.jsx)("div",{className:Q("mx-auto h-full w-0.5 transition-colors",g?"bg-focus":"bg-transparent group-hover:bg-focus group-focus-visible:bg-focus")})}):null]})}i(B_n,"SidebarShell");function R$({children:e,className:t}){return(0,n.jsx)("div",{"data-secondary-sidebar":"",className:Q("h-full w-full min-w-0 overflow-hidden",t),children:(0,n.jsx)(GJe,{children:e})})}i(R$,"SecondarySidebar");var Qft={listStacks:i(()=>le.get("/cloud/stacks"),"listStacks")};function gG(e,t){const s=e?.trim();if(!s)return null;try{const r=new URL(t,s);return r.protocol!=="https:"&&r.protocol!=="http:"?null:r.toString()}catch{return null}}i(gG,"cloudAppUrl");function Vft(e){return gG(e,"/stacks/new")}i(Vft,"cloudStackCreateUrl");function Hft(e){if(!e.startsWith("/")||e.startsWith("//")||/[\\\x00-\x20]/.test(e))return"/";const t=new URL(e,"https://tenant.invalid");return t.pathname.replace(/\/+$/,"")==="/auth"?"/":`${t.pathname}${t.search}${t.hash}`}i(Hft,"tenantSignInReturnPath");function z_n(e,t,s){const r=t?.trim();if(!r)return null;const a=gG(e,`/v1/stacks/${encodeURIComponent(r)}/entry-redirect`);if(!a)return null;const o=new URL(a);return o.searchParams.set("returnTo",Hft(s)),o.toString()}i(z_n,"cloudStackEntryUrl");function Gft(e,t){const s=t?.trim();return s?gG(e,`/workspaces/${encodeURIComponent(s)}/settings?section=people`):null}i(Gft,"cloudStackInviteUrl");function q_n(e){return gG(e,"/orgs?manage=1")}i(q_n,"cloudPortfolioManageUrl");function U_n(){const e=im(),t=!!e,s=ie({queryKey:O.cloud.stacks,queryFn:i(()=>Qft.listStacks(),"queryFn"),enabled:t,staleTime:3e4,retry:!1});if(!e||s.isError)return null;const r=s.data?.stacks.find(a=>a.isCurrent);return r?.role!=="owner"&&r?.role!=="admin"?null:Gft(e.cloudBaseUrl,r.stackSlug)}i(U_n,"useCloudInviteUrl");function K_n(e,t){if(!t)return!1;if(t.source==="local_implicit"||t.isInstanceAdmin)return!0;if(!e)return!1;const s=t.memberships?.find(r=>r.companyId===e&&r.status==="active");return s?.membershipRole==="owner"||s?.membershipRole==="admin"||s?.membershipRole==="operator"||s?.membershipRole==="member"}i(K_n,"canInviteCompanyMembers");function W_n(e=!0){const t=Y8(),s=ie({queryKey:O.access.currentBoardAccess,queryFn:i(()=>jr.getCurrentBoardAccess(),"queryFn"),enabled:e,retry:!1,staleTime:3e4});return e&&K_n(t?.selectedCompanyId,s.data)}i(W_n,"useCanInviteCompanyMembers");function Q_n(e){const t=window.location.hostname.endsWith(".staging.paperclip.app"),{data:s,isError:r}=ie({queryKey:O.stagingCommit,queryFn:i(()=>Op.get(),"queryFn"),enabled:t&&e,staleTime:0,retry:!1});return t&&!r?s?.commit??null:null}i(Q_n,"useStagingCommit");function V_n(e){return e?.trim().toLowerCase().replace(/['"]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||null}i(V_n,"slugifyUserPart");function H_n(e){const t=[e?.id,e?.name,e?.email?.split("@")[0],e?.email];for(const s of t){const r=V_n(s);if(r)return`/u/${r}`}return"/u/me"}i(H_n,"userProfilePath");var Yft="paperclip.theme",G_n="#0d0e11",Y_n="#f6f7f9",Jft=(0,m.createContext)(void 0);function J_n(){return typeof document>"u"||document.documentElement.classList.contains("dark")?"dark":"light"}i(J_n,"resolveThemeFromDocument");function Z_n(){if(typeof window>"u")return!1;try{const e=window.localStorage.getItem(Yft);return e==="light"||e==="dark"}catch{return!1}}i(Z_n,"hasStoredTheme");function X_n(e){if(typeof document>"u")return;const t=e==="dark",s=document.documentElement;s.classList.toggle("dark",t),s.style.colorScheme=t?"dark":"light";for(const r of document.querySelectorAll('meta[name="theme-color"]'))r.setAttribute("content",t?G_n:Y_n)}i(X_n,"applyTheme");function e2n({children:e}){const[t,s]=(0,m.useState)(()=>J_n()),[r,a]=(0,m.useState)(()=>Z_n()),o=(0,m.useCallback)(d=>{a(!0),s(d)},[]),l=(0,m.useCallback)(()=>{a(!0),s(d=>d==="dark"?"light":"dark")},[]);(0,m.useEffect)(()=>{if(X_n(t),!!r)try{localStorage.setItem(Yft,t)}catch{}},[t,r]),(0,m.useEffect)(()=>{if(r||typeof window>"u"||typeof window.matchMedia!="function")return;const d=window.matchMedia("(prefers-color-scheme: dark)"),u=i(h=>{s(h.matches?"dark":"light")},"handleChange");return d.addEventListener("change",u),()=>d.removeEventListener("change",u)},[r]);const c=(0,m.useMemo)(()=>({theme:t,setTheme:o,toggleTheme:l}),[t,o,l]);return(0,n.jsx)(Jft.Provider,{value:c,children:e})}i(e2n,"ThemeProvider");function Zft(){const e=(0,m.useContext)(Jft);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}i(Zft,"useTheme");var t2n="Toggle the app appearance.";function q6({className:e,variant:t="icon",onAfterToggle:s}){const{theme:r,toggleTheme:a}=Zft(),o=r==="dark",l=o?"Switch to light mode":"Switch to dark mode",c=o?QYe:Z7t;function d(){a(),s?.()}return i(d,"handleClick"),t==="compact-menu-action"?(0,n.jsxs)("button",{type:"button",className:Q("flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-ink transition-colors hover:bg-bg-3",e),onClick:d,"aria-label":l,children:[(0,n.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-ink-3",children:(0,n.jsx)(c,{className:"size-4"})}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:l})]}):t==="menu-action"?(0,n.jsxs)("button",{type:"button",className:Q("flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-bg-3/60",e),onClick:d,"aria-label":l,children:[(0,n.jsx)("span",{className:"mt-0.5 rounded-lg border border-line bg-bg/70 p-2 text-ink-3",children:(0,n.jsx)(c,{className:"size-4"})}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"block text-sm font-medium text-ink",children:l}),(0,n.jsx)("span",{className:"block text-xs text-ink-3",children:t2n})]})]}):(0,n.jsx)($,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,"aria-label":l,title:l,className:Q("",e),children:(0,n.jsx)(c,{})})}i(q6,"ThemeToggle");var t8=null,Xft=!1,bde=!1,yde=new Set;function n8(){for(const e of yde)e()}i(n8,"emit");function n2n(e=typeof navigator>"u"?"":navigator.userAgent,t=typeof navigator>"u"?0:navigator.maxTouchPoints){return/iPhone|iPad|iPod/i.test(e)?!0:/Macintosh/i.test(e)&&t>1}i(n2n,"isIosSafariLike");function s2n(e=window){const t=i(r=>{r.preventDefault(),t8=r,n8()},"onPrompt"),s=i(()=>{t8=null,Xft=!0,n8()},"onInstalled");return e.addEventListener("beforeinstallprompt",t),e.addEventListener("appinstalled",s),()=>{e.removeEventListener("beforeinstallprompt",t),e.removeEventListener("appinstalled",s)}}i(s2n,"captureInstallPrompt");function r2n(){return Xft||gde()?"installed":t8?"prompt":n2n()?"ios-manual":"unavailable"}i(r2n,"installAvailability");async function egt(){const e=t8;if(!e)return"unavailable";t8=null,n8(),await e.prompt();const{outcome:t}=await e.userChoice;return t}i(egt,"promptInstall");function UK(e){bde!==e&&(bde=e,n8())}i(UK,"setIosInstallHelpOpen");function i2n(){return bde}i(i2n,"iosInstallHelpOpen");function a2n(){return(0,m.useSyncExternalStore)(Eye,i2n,()=>!1)}i(a2n,"useIosInstallHelpOpen");function Eye(e){return yde.add(e),()=>{yde.delete(e)}}i(Eye,"subscribe$2");function Rye(){return(0,m.useSyncExternalStore)(Eye,r2n,()=>"unavailable")}i(Rye,"useInstallAvailability");function o2n(e){const t=Rye();return(0,m.useSyncExternalStore)(Eye,()=>d2n(t,e),()=>!1)}i(o2n,"useInstallNudgeVisible");var l2n=2592e6,kde="wardmote.install.visits",U6e="wardmote.install.visit-counted",tgt="wardmote.install.snoozed-until";function wde(e,t){const s=Number(e.getItem(t));return Number.isFinite(s)?s:0}i(wde,"readNumber$2");function c2n(e=window.localStorage,t=window.sessionStorage){try{if(t.getItem(U6e))return;t.setItem(U6e,"1"),e.setItem(kde,String(wde(e,kde)+1))}catch{return}}i(c2n,"recordAppVisit");function d2n(e,t,s=Date.now(),r=window.localStorage){if(e!=="prompt"&&e!=="ios-manual"||/^\/(?:[^/]+\/)?onboarding(?:\/|$)/.test(t))return!1;try{return wde(r,kde)>=3&&wde(r,tgt)<=s}catch{return!1}}i(d2n,"installNudgeVisible");function u2n(e=Date.now(),t=window.localStorage){try{t.setItem(tgt,String(e+l2n))}catch{return}finally{n8()}}i(u2n,"snoozeInstallNudge");var K6e="Install app",h2n="Add Wardmote to your home screen or dock.";function m2n({variant:e,onAfterAction:t}){const s=Rye();if(s==="installed"||s==="unavailable")return null;const r=i(()=>{s==="ios-manual"?UK(!0):egt(),t?.()},"handleClick");return e==="compact-menu-action"?(0,n.jsxs)("button",{type:"button",className:"flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-ink transition-colors hover:bg-bg-3",onClick:r,children:[(0,n.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-ink-3",children:(0,n.jsx)(xo,{className:"size-4"})}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:K6e})]}):(0,n.jsxs)("button",{type:"button",className:"flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-bg-3/60",onClick:r,children:[(0,n.jsx)("span",{className:"mt-0.5 rounded-lg border border-line bg-bg/70 p-2 text-ink-3",children:(0,n.jsx)(xo,{className:"size-4"})}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"block text-sm font-medium text-ink",children:K6e}),(0,n.jsx)("span",{className:"block text-xs text-ink-3",children:h2n})]})]})}i(m2n,"InstallAppMenuAction");function p2n(){const e=a2n();return(0,n.jsx)(Bn,{open:e,onOpenChange:UK,children:(0,n.jsxs)(zn,{children:[(0,n.jsxs)(rs,{children:[(0,n.jsx)(qn,{children:"Install Wardmote"}),(0,n.jsx)(ds,{children:"Add Wardmote to your Home Screen from Safari."})]}),(0,n.jsxs)("ol",{className:"space-y-3 text-sm text-ink",children:[(0,n.jsxs)(rte,{index:1,icon:(0,n.jsx)(mPt,{className:"size-4"}),children:["Tap ",(0,n.jsx)("strong",{children:"Share"})," in the Safari toolbar."]}),(0,n.jsxs)(rte,{index:2,icon:(0,n.jsx)(gPt,{className:"size-4"}),children:["Choose ",(0,n.jsx)("strong",{children:"Add to Home Screen"}),"."]}),(0,n.jsxs)(rte,{index:3,children:["Keep ",(0,n.jsx)("strong",{children:"Open as Web App"})," on, then tap ",(0,n.jsx)("strong",{children:"Add"}),"."]})]}),(0,n.jsx)(fr,{children:(0,n.jsx)($,{type:"button",onClick:i(()=>UK(!1),"onClick"),children:"Done"})})]})})}i(p2n,"IosInstallHelpDialog");function rte({index:e,icon:t,children:s}){return(0,n.jsxs)("li",{className:"flex items-start gap-3",children:[(0,n.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full border border-line text-xs font-semibold text-ink-3",children:e}),(0,n.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t?(0,n.jsx)("span",{className:"text-ink-3",children:t}):null,(0,n.jsx)("span",{children:s})]})]})}i(rte,"InstallStep");function f2n(e){if(!e)return"Unavailable";const t=new Date(e);return Number.isNaN(t.getTime())?"Unavailable":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)}i(f2n,"formatTimestamp$2");function g2n(e){return!!e&&!Number.isNaN(new Date(e).getTime())}i(g2n,"isValidTimestamp");function x2n(e){return e?.devServer?.lastRestartAt??e?.serverInfo?.processStartedAt??null}i(x2n,"restartTimestamp");function v2n(e){const t=e?.serverInfo?.git;return t?.available?`${t.shortSha} · ${t.subject}`:"Commit unavailable"}i(v2n,"commitLabel");function b2n(e){const t=e?.serverInfo?.git;if(!t?.available)return"Unavailable";const s=t.localChanges;if(!s||!s.available)return"Change status unavailable";if(!s.hasLocalChanges)return"Clean checkout";const r=[[s.stagedFileCount,"staged"],[s.unstagedFileCount,"unstaged"],[s.untrackedFileCount,"untracked"]].filter(([a])=>Number(a)>0).map(([a,o])=>`${a} ${o}`);return r.length>0?`Local changes present (${r.join(", ")})`:"Local changes present"}i(b2n,"localChangesLabel");function ite({icon:e,label:t,value:s,dateTime:r}){return(0,n.jsxs)("div",{className:"flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left",children:[(0,n.jsx)("span",{className:"mt-0.5 rounded-lg border border-line bg-bg/70 p-2 text-ink-3",children:(0,n.jsx)(e,{className:"size-4"})}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"block text-sm font-medium text-ink",children:t}),r?(0,n.jsx)("time",{dateTime:r,className:"block break-words text-xs text-ink-3",children:s}):(0,n.jsx)("span",{className:"block break-words text-xs text-ink-3",children:s})]})]})}i(ite,"ServerInfoRow");function y2n(){const e=ie({queryKey:O.instance.experimentalSettings,queryFn:i(()=>Fr.getExperimental(),"queryFn")}).data?.enableServerInfoDebugView===!0,t=ie({queryKey:O.health,queryFn:i(()=>Op.get(),"queryFn"),enabled:e,refetchOnMount:"always",refetchInterval:i(h=>h.state.data?.devServer?.enabled?2e3:!1,"refetchInterval")});if(!e)return null;const s=t.data,r=t.isLoading&&!s,a=t.isError,o=x2n(s),l=g2n(o),c=a?"Health unavailable":r?"Loading...":f2n(o),d=a?"Health unavailable":r?"Loading...":v2n(s),u=a?"Health unavailable":r?"Loading...":b2n(s);return(0,n.jsxs)("div",{className:"mt-2 border-t border-line pt-2",children:[(0,n.jsx)("p",{className:"px-3 pb-1 pt-1 text-(length:--text-micro) font-medium uppercase tracking-wide text-ink-3",children:"Server"}),(0,n.jsx)(ite,{icon:E0,label:"Last restarted",value:c,dateTime:!a&&!r&&l?o:null}),(0,n.jsx)(ite,{icon:A0e,label:"Running commit",value:d}),(0,n.jsx)(ite,{icon:D7t,label:"Checkout state",value:u})]})}i(y2n,"SidebarServerInfo");var k2n="/company/settings/members?tab=invites",w2n="https://docs.paperclip.ing/",j2n="https://paperclip.ing/feedback";function N2n(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length>=2?`${t[0]?.[0]??""}${t[t.length-1]?.[0]??""}`.toUpperCase():e.slice(0,2).toUpperCase()}i(N2n,"deriveInitials$1");function ate({label:e,icon:t,onClick:s,href:r,external:a=!1,topLevel:o=!1}){const l="flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-ink transition-colors hover:bg-bg-3",c=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-ink-3",children:(0,n.jsx)(t,{className:"size-4"})}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e})]});return r?a?(0,n.jsx)("a",{href:r,target:"_blank",rel:"noreferrer",className:l,onClick:s,children:c}):o?(0,n.jsx)("a",{href:r,className:l,onClick:s,children:c}):(0,n.jsx)(Ye,{to:r,className:l,onClick:s,children:c}):(0,n.jsx)("button",{type:"button",className:l,onClick:s,children:c})}i(ate,"MenuAction");function W6e({deploymentMode:e,open:t,onOpenChange:s,forceExpanded:r=!1}){const o=!!im(),{hidden:l,loaded:c}=V0(),d=U_n(),u=W_n(!o),h=o?d:u?k2n:null,p=c&&h!==null&&!pM(l,"company.members")&&!pM(l,"company.invites"),[f,g]=(0,m.useState)(!1),{isMobile:x,setSidebarOpen:v,collapsed:b,peeking:y}=Io(),k=b&&!y&&!r,j=t??f,N=Q_n(j),S=s??g,{data:A}=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),retry:!1}),I=LV({onSignedOut:P}),_=A?.user.name?.trim()||"Board",T=A?.user.email?.trim()||(e==="authenticated"?"Signed in":"Local workspace board"),E=N2n(_),M=H_n(A?.user);function P(){S(!1),x&&v(!1)}i(P,"closeNavigationChrome");function D(){I.mutate()}return i(D,"handleSignOut"),(0,n.jsx)("div",{className:"bg-line/50 px-3 py-2 dark:bg-bg-3",children:(0,n.jsxs)("div",{className:Q("flex items-center gap-0.5",!k&&"px-2"),children:[(0,n.jsxs)(cr,{open:j,onOpenChange:S,children:[(0,n.jsx)(gr,{asChild:!0,children:(0,n.jsxs)("button",{type:"button",className:Q("flex min-w-0 items-center gap-2.5 rounded-lg text-left text-(length:--text-compact) font-medium text-ink/80 transition-colors hover:bg-bg-3 hover:text-ink",k?"w-full px-3 py-2":"flex-1 px-2 py-1.5"),"aria-label":"Open account menu",children:[(0,n.jsxs)(yl,{size:"sm",children:[A?.user.image?(0,n.jsx)(th,{src:A.user.image,alt:_}):null,(0,n.jsx)(kl,{children:E})]}),(0,n.jsx)("span",{className:Q("min-w-0 flex-1 truncate",k&&"block w-0 min-w-0 -ms-2.5 overflow-hidden whitespace-nowrap text-transparent select-none"),children:_})]})}),(0,n.jsxs)(Vs,{side:"top",align:"start",sideOffset:10,className:"min-h-(--profile-popover-min-height) w-(--profile-popover-width) max-w-(--sz-calc-24) overflow-hidden rounded-xl border-line bg-bg-2 p-0 shadow-(--shadow-profile-popover)",children:[(0,n.jsxs)("div",{className:"relative flex h-(--profile-popover-header-height) shrink-0 items-center gap-2.5 px-3.5",children:[(0,n.jsx)(Ye,{to:M,"aria-label":"View profile",onClick:P,className:"absolute inset-0 transition-colors hover:bg-bg-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus"}),(0,n.jsxs)(yl,{className:"pointer-events-none relative size-9",children:[A?.user.image?(0,n.jsx)(th,{src:A.user.image,alt:_}):null,(0,n.jsx)(kl,{className:"text-xs text-ink",children:E})]}),(0,n.jsxs)("div",{className:"pointer-events-none relative min-w-0 flex-1",children:[(0,n.jsx)("h2",{className:"truncate text-sm font-semibold leading-(--profile-popover-label-line-height) text-ink",children:_}),(0,n.jsx)("p",{className:"truncate text-(length:--text-micro) leading-(--profile-popover-meta-line-height) text-ink-3",children:T}),N?(0,n.jsxs)("a",{className:"pointer-events-auto block truncate font-mono text-(length:--text-micro) leading-(--profile-popover-meta-line-height) text-ink-3 hover:underline focus-visible:underline",href:`https://github.com/paperclipai/paperclip/commit/${N}`,target:"_blank",rel:"noreferrer","aria-label":`View commit ${N} on GitHub`,title:N,children:["SHA ",N.slice(0,7)]}):null]})]}),(0,n.jsxs)("div",{className:"flex flex-1 flex-col gap-0.5 border-t border-line px-2.5 pb-2.5 pt-2",children:[(0,n.jsx)(ate,{label:"Settings",icon:M0,href:"/company/settings",onClick:P}),p&&h?(0,n.jsx)(ate,{label:"Invite",icon:Sb,href:h,topLevel:o,onClick:P}):null,(0,n.jsx)(ate,{label:"Documentation",icon:yD,href:w2n,external:!0,onClick:i(()=>S(!1),"onClick")}),(0,n.jsx)(q6,{variant:"compact-menu-action",onAfterToggle:i(()=>S(!1),"onAfterToggle")}),(0,n.jsx)(m2n,{variant:"compact-menu-action",onAfterAction:i(()=>S(!1),"onAfterAction")}),e==="authenticated"?(0,n.jsxs)("button",{type:"button",className:Q("flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-ink transition-colors hover:bg-bad/10",I.isPending&&"cursor-not-allowed opacity-60"),onClick:D,disabled:I.isPending,children:[(0,n.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-ink-3",children:(0,n.jsx)(lT,{className:"size-4"})}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:I.isPending?"Signing out...":"Sign out"})]}):null,(0,n.jsx)(y2n,{})]})]})]}),!k&&!o?(0,n.jsxs)(Zs,{children:[(0,n.jsx)(Xs,{asChild:!0,children:(0,n.jsx)("a",{href:j2n,target:"_blank",rel:"noreferrer","aria-label":"Share feedback",className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-3/50 transition-colors hover:bg-bg-3 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus",children:(0,n.jsx)(Cb,{className:"h-4 w-4","aria-hidden":"true"})})}),(0,n.jsx)(er,{side:"top",children:"Share feedback"})]}):null]})})}i(W6e,"SidebarAccountMenu");var C2n=["input","textarea","select","[contenteditable='true']","[contenteditable='plaintext-only']","[role='textbox']","[role='combobox']"].join(", "),S2n="[data-page-search-target='true']",_2n=new Set(["Shift","Meta","Control","Alt"]);function ow(e){return e instanceof HTMLElement?e.isContentEditable?!0:!!e.closest(C2n):!1}i(ow,"isKeyboardShortcutTextInputTarget");function pb(e=document){return!!e.querySelector("[role='dialog'][aria-modal='true']")}i(pb,"hasBlockingShortcutDialog");function A2n(e){if(!e.isConnected||"disabled"in e&&typeof e.disabled=="boolean"&&e.disabled||e.closest("[hidden], [aria-hidden='true'], [inert]")||e.closest("[role='dialog'][aria-modal='true']"))return!1;const t=window.getComputedStyle(e);return t.display==="none"||t.visibility==="hidden"?!1:e.getClientRects().length>0||e===document.activeElement}i(A2n,"isVisibleShortcutTarget");function I2n(e=document){return Array.from(e.querySelectorAll(S2n)).find(t=>A2n(t))??null}i(I2n,"findPageSearchShortcutTarget");function T2n(e=document){const t=I2n(e);return t?(t.focus(),(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&t.select(),!0):!1}i(T2n,"focusPageSearchShortcutTarget");function ngt({key:e,isComposing:t}){return e==="Enter"&&!t}i(ngt,"shouldBlurPageSearchOnEnter");function sgt({key:e,isComposing:t,currentValue:s}){return e==="Escape"&&!t&&s.length===0}i(sgt,"shouldBlurPageSearchOnEscape");function xG(e){return _2n.has(e)}i(xG,"isModifierOnlyKey");function E2n({defaultPrevented:e,key:t,metaKey:s,ctrlKey:r,altKey:a,target:o,hasOpenDialog:l,hasSelection:c}){if(e||s||r||a||xG(t)||l||ow(o))return"ignore";switch(t){case"j":case"ArrowDown":return"next";case"k":case"ArrowUp":return"previous";case"Enter":return c?"toggle":"ignore";case"x":return c?"dismiss":"ignore";default:return"ignore"}}i(E2n,"resolveAttentionQueueKeyAction");function R2n({armed:e,defaultPrevented:t,key:s,metaKey:r,ctrlKey:a,altKey:o,target:l,hasOpenDialog:c}){return!e||t||r||a||o||xG(s)||c||ow(l)?"ignore":s.toLowerCase()==="y"?"archive":"ignore"}i(R2n,"resolveInboxQuickArchiveKeyAction");function M2n({hasUndoableArchive:e,defaultPrevented:t,key:s,metaKey:r,ctrlKey:a,altKey:o,target:l,hasOpenDialog:c}){return!e||t||r||a||o||xG(s)||c||ow(l)?"ignore":s==="u"?"undo_archive":"ignore"}i(M2n,"resolveInboxUndoArchiveKeyAction");function rgt({armed:e,defaultPrevented:t,key:s,metaKey:r,ctrlKey:a,altKey:o,target:l,hasOpenDialog:c}){if(t)return e?"disarm":"ignore";if(r||a||o||xG(s))return"ignore";if(c||ow(l))return e?"disarm":"ignore";const d=s.toLowerCase();return e?d==="i"?"navigate_inbox":d==="c"?"focus_comment":d==="f"?"open_file_viewer":d==="g"?"arm":"disarm":d==="g"?"arm":"ignore"}i(rgt,"resolveIssueDetailGoKeyAction");function L2n({onNewIssue:e,onSearch:t,onToggleSidebar:s,onTogglePanel:r,onShowShortcuts:a,onGoToInbox:o}){(0,m.useEffect)(()=>{let l=!1,c=null;const d=i(()=>{c!==null&&(window.clearTimeout(c),c=null)},"clearGoChordTimeout"),u=i(()=>{l=!1,d()},"disarmGoChord"),h=i(()=>{l=!0,d(),c=window.setTimeout(()=>{l=!1,c=null},1200)},"armGoChord");function p(x){if(x.defaultPrevented){u();return}if(o){const v=rgt({armed:l,defaultPrevented:x.defaultPrevented,key:x.key,metaKey:x.metaKey,ctrlKey:x.ctrlKey,altKey:x.altKey,target:x.target,hasOpenDialog:pb()});if(v==="arm"){h();return}if(v==="navigate_inbox"){u(),x.preventDefault(),o();return}if(v==="focus_comment"||v==="open_file_viewer"){u(),x.preventDefault();return}v==="disarm"&&u()}if(!ow(x.target)&&!pb()){if(x.key==="/"&&!x.metaKey&&!x.ctrlKey&&!x.altKey){x.preventDefault(),T2n()||t?.();return}if(x.key==="?"&&!x.metaKey&&!x.ctrlKey&&!x.altKey){x.preventDefault(),a?.();return}x.key==="c"&&!x.metaKey&&!x.ctrlKey&&!x.altKey&&(x.preventDefault(),e?.()),x.key==="["&&!x.metaKey&&!x.ctrlKey&&(x.preventDefault(),s?.()),x.key==="]"&&!x.metaKey&&!x.ctrlKey&&(x.preventDefault(),r?.())}}i(p,"handleKeyDown");const f=i(()=>u(),"handlePointerDown"),g=i(x=>{x.target instanceof HTMLElement&&x.target!==document.body&&u()},"handleFocusIn");return document.addEventListener("pointerdown",f,!0),document.addEventListener("focusin",g,!0),document.addEventListener("keydown",p),()=>{u(),document.removeEventListener("pointerdown",f,!0),document.removeEventListener("focusin",g,!0),document.removeEventListener("keydown",p)}},[e,t,s,r,a,o])}i(L2n,"useKeyboardShortcuts");var D2n=new Set(["auth","invite","board-claim","cli-auth","docs","s"]);function igt(e){const t=(e.split("?")[0]??"").split("/").filter(Boolean);if(t.length===0)return!0;const[s]=t;return!D2n.has(s)}i(igt,"isRememberableCompanyPath");function P2n(e){const t=E3(e.companyPrefix);return e.companies.find(s=>E3(s.issuePrefix)===t)??null}i(P2n,"findCompanyByPrefix");function $2n(e){const t=Fpe(e.pathname);return t?P2n({companies:e.companies,companyPrefix:t})?.id??null:e.fallbackCompanyId}i($2n,"getRememberedPathOwnerCompanyId");function O2n(e){const t=e.path?BQ(e.path):"/dashboard";if(!igt(t))return"/dashboard";const[s,r]=(t.split("?")[0]??"").split("/").filter(Boolean);if(s==="issues"&&r){const a=/^([A-Za-z]+)-\d+$/.exec(r);if(a&&E3(a[1]??"")!==E3(e.companyPrefix))return"/dashboard"}return t}i(O2n,"sanitizeRememberedPathForCompany");var agt="paperclip.companyPaths";function ogt(){try{const e=localStorage.getItem(agt);if(e)return JSON.parse(e)}catch{}return{}}i(ogt,"getCompanyPaths");function F2n(e,t){const s=ogt();s[e]=t,localStorage.setItem(agt,JSON.stringify(s))}i(F2n,"saveCompanyPath");function B2n(){const{companies:e,selectedCompanyId:t,selectedCompany:s,selectionSource:r}=gn(),a=Ri(),o=ir(),l=(0,m.useRef)(t),c=(0,m.useMemo)(()=>$2n({companies:e,pathname:a.pathname,fallbackCompanyId:l.current}),[e,a.pathname]),d=a.pathname+a.search;(0,m.useEffect)(()=>{const u=c,h=BQ(d);u&&igt(h)&&F2n(u,h)},[d,c]),(0,m.useEffect)(()=>{if(t){if(l.current!==null&&t!==l.current&&r!=="route_sync"&&s){const u=ogt(),h=O2n({path:u[t],companyPrefix:s.issuePrefix});o(`/${s.issuePrefix}${h}`,{replace:!0})}l.current=t}},[s,t,r,o])}i(B2n,"useCompanyPageMemory");var z2n=class{static{i(this,"MobileNavScrollTracker")}options;lastTop;lastMaxTop;visible=!0;direction=0;distance=0;constructor(e,t,s){this.options=e,this.lastTop=t,this.lastMaxTop=s}update(e,t){const s=Math.max(0,Math.min(e,t)),r=s-Math.max(this.lastTop,this.options.topZone),a=t!==this.lastMaxTop;if(this.lastTop=s,this.lastMaxTop=t,s<=this.options.topZone)this.visible=!0,this.direction=0,this.distance=0;else if(a)this.direction=0,this.distance=0;else if(r!==0){const o=Math.sign(r);o!==this.direction&&(this.distance=0),this.direction=o,this.distance+=Math.abs(r);const l=o>0?this.options.hideDistance:this.options.showDistance;this.distance>=l&&(this.visible=o<0,this.distance=0)}return this.visible}};function q2n(e,t){const[s,r]=(0,m.useState)(!0);return(0,m.useEffect)(()=>{if(r(!0),!e)return;const a=getComputedStyle(document.documentElement),o=i(p=>Number.parseFloat(a.getPropertyValue(p))||0,"distance"),l=i(()=>{const p=document.scrollingElement??document.documentElement;return{top:window.scrollY||p.scrollTop||0,max:Math.max(0,p.scrollHeight-p.clientHeight)}},"scrollBounds"),c=l(),d=new z2n({topZone:o("--mobile-nav-scroll-top-zone"),hideDistance:o("--mobile-nav-scroll-hide-distance"),showDistance:o("--mobile-nav-scroll-show-distance")},c.top,c.max);let u=null;const h=i(()=>{u===null&&(u=requestAnimationFrame(()=>{u=null;const{top:p,max:f}=l(),g=d.visible,x=d.update(p,f);x!==g&&r(x)}))},"onScroll");return window.addEventListener("scroll",h,{passive:!0}),()=>{window.removeEventListener("scroll",h),u!==null&&cancelAnimationFrame(u)}},[e,t]),s}i(q2n,"useMobileNavVisibility");function U2n(e){const{matchedCompany:t,selectedCompanyId:s,companies:r}=e;return!t||t.status!=="archived"||s===t.id?null:r.find(a=>a.id===s&&a.status!=="archived")??r.find(a=>a.status!=="archived")??null}i(U2n,"resolveArchivedCompanyBounce");function K2n(e){const{archivedCompanyId:t,companies:s,cloudPortfolioUrl:r}=e,a=s.find(o=>o.id!==t&&o.status!=="archived");return a?{kind:"company",company:a}:r?{kind:"cloud_portfolio",url:r}:{kind:"companies_list"}}i(K2n,"resolveCompanyArchiveDeparture");function W2n(e){const{selectionSource:t,selectedCompanyId:s,routeCompanyId:r}=e;return!(s===r||t==="manual"&&s)}i(W2n,"shouldSyncCompanySelectionFromRoute");function Q2n(e,t){return e instanceof HTMLElement?!(t instanceof HTMLElement)||!document.contains(t)||t===document.body||t===document.documentElement?!0:!e.contains(t):!1}i(Q2n,"shouldFocusMainContentAfterNavigation");function V2n(e){if(!(e instanceof HTMLElement))return()=>{};const t=window.requestAnimationFrame(()=>{Q2n(e,document.activeElement)&&e.focus({preventScroll:!0})});return()=>window.cancelAnimationFrame(t)}i(V2n,"scheduleMainContentFocus");function H2n(e=document,t=window){const s=i(()=>{e.documentElement.scrollTop!==0&&(e.documentElement.scrollTop=0),e.body.scrollTop!==0&&(e.body.scrollTop=0)},"onScroll");return t.addEventListener("scroll",s,{capture:!0}),()=>t.removeEventListener("scroll",s,{capture:!0})}i(H2n,"pinDocumentScrollToZero");function A0({scope:e="global",requestedPrefix:t}){const s=Ri(),{setBreadcrumbs:r}=Hs(),{companies:a,selectedCompany:o}=gn();(0,m.useEffect)(()=>{r([{label:"Not Found"}])},[r]);const l=o??a[0]??null,c=l?`/${l.issuePrefix}/dashboard`:"/",d=`${s.pathname}${s.search}${s.hash}`,u=t?.toUpperCase(),h=e==="invalid_company_prefix"?"Organization not found":"Page not found",p=e==="invalid_company_prefix"?`No organization matches prefix "${u??"unknown"}".`:"This route does not exist.";return(0,n.jsx)("div",{className:"mx-auto max-w-2xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("div",{className:"rounded-md border border-bad/20 bg-bad/10 p-2",children:(0,n.jsx)(En,{className:"h-5 w-5 text-bad"})}),(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"text-xl font-semibold",children:h}),(0,n.jsx)("p",{className:"text-sm text-ink-3",children:p})]})]}),(0,n.jsxs)("div",{className:"mt-4 rounded-md border border-line bg-bg-3/20 px-3 py-2 text-xs text-ink-3",children:["Requested path: ",(0,n.jsx)("code",{className:"font-mono",children:d})]}),(0,n.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,n.jsx)($,{asChild:!0,children:(0,n.jsxs)(Ye,{to:c,children:[(0,n.jsx)(dq,{className:"mr-1.5 h-4 w-4"}),"Open dashboard"]})}),(0,n.jsx)($,{variant:"secondary",asChild:!0,children:(0,n.jsx)(Ye,{to:"/",children:"Go home"})})]})]})})}i(A0,"NotFoundPage");function G2n(e,t){return RXe(e,t)[0]?.toLowerCase()??null}i(G2n,"getCompanyRouteSegment");var Y2n=new Set(["browse","connections","assistant-connection","connect","chat","vercel-connect","review","attention","gateways","advanced","app"]);function J2n({sidebarSections:e}){const{sidebarOpen:t,setSidebarOpen:s,toggleSidebar:r,collapsed:a,peeking:o,setPeeking:l,isMobile:c,isTablet:d}=Io(),{openNewIssue:u,openOnboarding:h}=Oc(),{togglePanelVisible:p}=Hk(),f=Eh()?.pushToast??null,{companies:g,loading:x,selectedCompany:v,selectedCompanyId:b,selectionSource:y,setSelectedCompanyId:k}=gn(),{companyPrefix:j,pluginRoutePath:N,agentId:S,routineId:A}=Mi(),I=ir(),_=Ri(),T=$pe(),E=yUt(_.pathname,j),M=E.builtInContextualSurface==="settings",P=E.companySegments,D=E.isTaskDetail,{enabled:K}=MS(),L=K&&P[0]?.toLowerCase()==="chats",B=D||L,z=P[0]?.toLowerCase()==="tools",U=P[0]?.toLowerCase()==="apps",W=U&&P[1]&&!Y2n.has(P[1].toLowerCase())?P[1]:null,F=U&&P[1]?.toLowerCase()==="app"&&P[2]?P[2]:null,Y=(0,m.useRef)(!1),V=(0,m.useRef)(null),G=(0,m.useRef)(null),ne=(0,m.useRef)(new aOt),Z=(0,m.useRef)(_.key),J=q2n(c&&!D,_.pathname),[se,H]=(0,m.useState)(!1),ee=(0,m.useMemo)(()=>{if(!j)return null;const yt=j.toUpperCase();return g.find(ze=>ze.issuePrefix.toUpperCase()===yt)??null},[g,j]),te=!!j&&!x&&g.length>0&&!ee,oe=(0,m.useMemo)(()=>N?.toLowerCase()??G2n(_.pathname,j),[j,_.pathname,N]),ae=ee?.id??null,ge=ee?.issuePrefix??null,{slots:xe}=Q0({slotTypes:["page","routeSidebar"],companyId:ae,enabled:!!(ae&&oe)}),ce=(0,m.useMemo)(()=>QZe(xe,oe),[oe,xe]),de=(0,m.useMemo)(()=>({companyId:ae,companyPrefix:ge}),[ae,ge]),be=M?(0,n.jsx)(NUt,{}):W?(0,n.jsx)(__e,{kind:"connection",connectionId:W}):F?(0,n.jsx)(__e,{kind:"application",applicationId:F}):U||z?(0,n.jsx)($Ut,{}):ce?(0,n.jsx)(WD,{surface:`plugin:${ce.id}`,title:ce.displayName,children:(0,n.jsx)(jx,{slot:ce,context:de,className:"min-h-0 flex-1",missingBehavior:"placeholder"})}):null,me=L?(0,n.jsx)(F_n,{}):E.builtInContextualSurface==="agent"&&S?(0,n.jsx)(JUt,{agentRef:S}):E.builtInContextualSurface==="routine"&&A?(0,n.jsx)(sOt,{children:(0,n.jsx)(eKt,{routineId:A})}):E.builtInContextualSurface==="skills"?(0,n.jsx)(sKt,{}):be,we=me!=null,ue=we&&(L||E.builtInContextualSurface==="skills"||E.builtInContextualSurface==="agent"||E.builtInContextualSurface==="routine"||U||z),pe=M&&(c||d),Se=we&&!ue&&!(d&&M),De=ue,Te=we?ce&&!E.builtInContextualSurface?`plugin:${ce.id}`:E.builtInContextualSurface:null,st=(0,m.useRef)(null),{data:fe}=ie({queryKey:O.health,queryFn:i(()=>Op.get(),"queryFn"),retry:!1,refetchInterval:i(yt=>yt.state.data?.devServer?.enabled?2e3:!1,"refetchInterval"),refetchIntervalInBackground:!1});(0,m.useEffect)(()=>{const yt=st.current;Te&&j&&yt&&yt.surface!==Te&&yt.pathname!==_.pathname&&kUt({surface:Te,companyPrefix:j,previousPathname:yt.pathname}),st.current={pathname:_.pathname,surface:Te}},[j,Te,_.pathname]),(0,m.useEffect)(()=>{x||Y.current||fe?.deploymentMode!=="authenticated"&&(fe?.cloud||g.length===0&&(Y.current=!0,h()))},[g,x,h,fe?.cloud,fe?.deploymentMode]),(0,m.useEffect)(()=>{if(!j||x||g.length===0)return;if(!ee){const ze=(b?g.find(Ve=>Ve.id===b):null)??g[0]??null;ze&&b!==ze.id&&k(ze.id,{source:"route_sync"});return}if(j!==ee.issuePrefix){const ze=_.pathname.replace(/^\/[^/]+/,"");I(`/${ee.issuePrefix}${ze}${_.search}`,{replace:!0});return}const yt=U2n({matchedCompany:ee,selectedCompanyId:b,companies:g});if(yt){f?.({title:`${ee.name} is archived`,body:`Switched to ${yt.name}.`,tone:"info",dedupeKey:`archived-company-bounce:${ee.id}`}),k(yt.id,{source:"route_sync"}),I(`/${yt.issuePrefix}/dashboard`,{replace:!0});return}W2n({selectionSource:y,selectedCompanyId:b,routeCompanyId:ee.id})&&k(ee.id,{source:"route_sync"})},[j,g,x,ee,_.pathname,_.search,I,f,y,b,k]);const Be=p,ke=(0,m.useCallback)(()=>{document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0,cancelable:!0}))},[]),$t=(0,m.useRef)(null),Ie=(0,m.useRef)(!1),Re=(0,m.useRef)(!1),Je=(0,m.useCallback)(()=>{$t.current!==null&&(window.clearTimeout($t.current),$t.current=null)},[]),je=(0,m.useCallback)(()=>{Je(),$t.current=window.setTimeout(()=>l(!0),50)},[Je,l]),Fe=(0,m.useCallback)(()=>{Je(),l(!0)},[Je,l]),Ue=(0,m.useCallback)(()=>{Je(),$t.current=window.setTimeout(()=>l(!1),120)},[Je,l]),qe=(0,m.useCallback)(()=>{Ie.current=!0,a&&!Re.current&&je()},[a,je]),Ne=(0,m.useCallback)(()=>{Ie.current=!1,Re.current=!1,Ue()},[Ue]),Le=(0,m.useCallback)(()=>{Re.current||Fe()},[Fe]),et=(0,m.useCallback)(()=>{Ie.current||Ue()},[Ue]);(0,m.useEffect)(()=>Je,[Je]);const at=(0,m.useRef)(a);return(0,m.useEffect)(()=>{a!==at.current&&(a?(Je(),l(!1),Re.current=Ie.current):Re.current=!1,at.current=a)},[a,Je,l]),(0,m.useEffect)(()=>{if(!o)return;const yt=i(ze=>{ze.key==="Escape"&&(Je(),l(!1))},"onKeyDown");return window.addEventListener("keydown",yt),()=>window.removeEventListener("keydown",yt)},[o,Je,l]),B2n(),L2n({onNewIssue:i(()=>u(),"onNewIssue"),onSearch:ke,onToggleSidebar:r,onTogglePanel:Be,onShowShortcuts:i(()=>H(!0),"onShowShortcuts"),onGoToInbox:i(()=>I("/inbox"),"onGoToInbox")}),(0,m.useEffect)(()=>{if(!c)return;const yt=30,ze=50,Ve=75;let dt=0,Ee=0;const it=i(Ke=>{const Rt=Ke.touches[0];dt=Rt.clientX,Ee=Rt.clientY},"onTouchStart"),he=i(Ke=>{const Rt=Ke.changedTouches[0],ht=Rt.clientX-dt;if(!(Math.abs(Rt.clientY-Ee)>Ve)){if(!t&&dt<yt&&ht>ze){s(!0);return}t&&ht<-50&&s(!1)}},"onTouchEnd");return document.addEventListener("touchstart",it,{passive:!0}),document.addEventListener("touchend",he,{passive:!0}),()=>{document.removeEventListener("touchstart",it),document.removeEventListener("touchend",he)}},[c,t,s]),(0,m.useEffect)(()=>{const yt=document.body.style.overflow;return document.body.style.overflow=c?"visible":"clip",()=>{document.body.style.overflow=yt}},[c]),(0,m.useEffect)(()=>{if(!c)return H2n()},[c]),(0,m.useEffect)(()=>{if(typeof document>"u")return;const yt=G.current;return V2n(yt)},[_.pathname]),(0,m.useEffect)(()=>{const yt=G.current;if(!yt)return;const ze=i(()=>{ne.current.remember(Z.current,yt.scrollTop)},"recordScroll");return yt.addEventListener("scroll",ze,{passive:!0}),()=>yt.removeEventListener("scroll",ze)},[]),(0,m.useLayoutEffect)(()=>{const yt=G.current,ze=iOt({previousPathname:V.current,pathname:_.pathname,navigationType:T,state:_.state});V.current=_.pathname;const Ve=T==="POP",dt=Ve?ne.current.recall(_.key):0;if(Z.current=_.key,Ve){ESe(yt,dt);const Ee=requestAnimationFrame(()=>ESe(yt,dt));return()=>cancelAnimationFrame(Ee)}ze&&oOt(yt)},[_.key,_.pathname,_.state,T]),(0,n.jsx)(tOt,{children:(0,n.jsxs)("div",{"data-app-shell":"",className:Q("bg-bg text-ink pt-(--sz-safe-top)",c?"min-h-dvh overflow-x-clip":"flex h-dvh flex-col overflow-clip"),children:[(0,n.jsx)("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:left-3 focus:top-3 focus:z-(--z-200) focus:rounded-md focus:bg-bg focus:px-3 focus:py-2 focus:text-sm focus:font-medium focus:shadow-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-focus",children:"Skip to Main Content"}),(0,n.jsx)(S_n,{}),(0,n.jsx)(d_n,{}),(0,n.jsx)(p_n,{devServer:fe?.devServer}),(0,n.jsx)(y_n,{}),(0,n.jsxs)("div",{className:Q("min-h-0 flex-1",c?"w-full":"flex overflow-clip"),children:[c&&t&&(0,n.jsx)("button",{type:"button",className:"fixed inset-0 z-40 bg-black/50",onClick:i(()=>s(!1),"onClick"),"aria-label":"Close sidebar"}),c?(0,n.jsxs)("div",{className:Q("fixed inset-y-0 left-0 z-50 flex flex-col overflow-hidden pt-(--sz-safe-top) transition-transform duration-100 ease-out",t?"translate-x-0":"-translate-x-full"),children:[(0,n.jsx)("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:(0,n.jsx)("div",{className:"w-60 shrink-0 overflow-hidden",children:we?(0,n.jsx)(R$,{children:me}):(0,n.jsx)(j_e,{children:e})})}),(0,n.jsx)(W6e,{deploymentMode:fe?.deploymentMode,forceExpanded:Se})]}):(0,n.jsxs)(B_n,{open:t,collapsed:Se?!1:a,peeking:Se?!1:o,resizable:!0,onPanelMouseEnter:Se?void 0:qe,onPanelMouseLeave:Se?void 0:Ne,onPanelFocusCapture:!Se&&a?Le:void 0,onPanelBlurCapture:!Se&&a?et:void 0,children:[(0,n.jsx)("div",{className:"flex flex-1 min-h-0",children:Se?(0,n.jsx)(R$,{children:me}):(0,n.jsx)(j_e,{children:e})}),(0,n.jsx)(W6e,{deploymentMode:fe?.deploymentMode,forceExpanded:Se})]}),!c&&De&&!ue?(0,n.jsx)(R$,{className:"w-60 shrink-0",children:me}):null,(0,n.jsxs)("div",{className:Q("flex min-w-0 flex-col",c?"w-full":"h-full flex-1"),children:[(0,n.jsxs)("div",{"data-slot":c?"mobile-topbar":void 0,className:Q(!c&&B&&"hidden",c&&"sticky top-0 z-20 bg-bg/95 backdrop-blur supports-[backdrop-filter]:bg-bg/85"),children:[(0,n.jsx)($6e,{mobile:c,onNavigateHome:i(()=>I("/dashboard"),"onNavigateHome")}),(0,n.jsx)(T_e,{}),pe?(0,n.jsx)("div",{className:"border-b border-line px-4 pb-3",children:(0,n.jsx)(IUt,{})}):null]}),(0,n.jsxs)("div",{className:Q(c?"block":"relative flex flex-1 min-h-0",!c&&B&&"streamlined-task-detail-surface"),children:[!c&&ue?(0,n.jsx)(R$,{className:"w-60 shrink-0 bg-bg",children:me}):null,(0,n.jsxs)("div",{className:Q(!c&&B?"flex min-w-0 flex-1 flex-col":"contents"),children:[!c&&B?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)($6e,{mobile:!1,onNavigateHome:i(()=>I("/dashboard"),"onNavigateHome")}),(0,n.jsx)(T_e,{taskDetailLayout:!0})]}):null,(0,n.jsx)("main",{id:"main-content",ref:G,tabIndex:-1,style:c?{"--tc-composer-bottom":"var(--sz-calc-14)"}:void 0,className:Q("flex-1 p-4 outline-none md:p-6",!c&&B&&"pt-0 md:pt-0",c?"overflow-visible pb-(--sz-calc-14)":"overflow-auto [scrollbar-gutter:stable]"),children:te?(0,n.jsx)(A0,{scope:"invalid_company_prefix",requestedPrefix:j??v?.issuePrefix}):(0,n.jsx)(D_n,{children:(0,n.jsx)(CS,{})})})]}),(0,n.jsx)(UWt,{taskDetailLayout:!c&&B})]})]})]}),c&&(0,n.jsx)(r_n,{visible:J}),(0,n.jsx)(EQt,{}),(0,n.jsx)(bxn,{}),(0,n.jsx)(CSn,{}),(0,n.jsx)(ASn,{}),(0,n.jsx)(DSn,{}),(0,n.jsx)(FSn,{open:se,onOpenChange:H}),(0,n.jsx)(USn,{}),(0,n.jsx)(JSn,{health:fe}),(0,n.jsx)(s_n,{localTrusted:fe?.deploymentMode==="local_trusted"})]})})}i(J2n,"Layout");var Q6e=null;function Z2n(){return Q6e??=new dD,Q6e}i(Z2n,"getDetachedClient");function X2n(){const e=(0,m.useContext)(H8),{data:t,isFetched:s}=ie({queryKey:O.instance.experimentalSettings,queryFn:i(()=>Fr.getExperimental(),"queryFn"),enabled:e!=null},e??Z2n());return e?{enabled:t?.enableConferenceRoomChat===!0,loaded:s}:{enabled:!1,loaded:!0}}i(X2n,"useConferenceRoomChatEnabled");function e5n(){const{enabled:e,loaded:t}=X2n();return t?e?(0,n.jsx)(CS,{}):(0,n.jsx)(Ss,{to:"/dashboard",replace:!0}):null}i(e5n,"ConferenceRoomChatGate");var t5n=["session-start","human-message","agent-message","thinking","responding","responding-burst","tool-call","diff","working","running","completed","activity-phases","awaiting-approval","plan-todo","interrupted","refused","truncated","live-token-cost"],n5n={"session-start":{id:"session-start",label:"Session start",tier:"live",surface:"thread",protocol:'acpx.session → TranscriptEntry kind:"init"'},"human-message":{id:"human-message",label:"Human message",tier:"live",surface:"thread",protocol:'IssueComment authorType:"user"'},"agent-message":{id:"agent-message",label:"Final response",tier:"live",surface:"thread",protocol:'PRP item.delta kind:"agentMessage" channel:"final"'},thinking:{id:"thinking",label:"Thinking",tier:"live",surface:"thread",protocol:"text_delta stream:thought (ACP agent_thought_chunk)"},responding:{id:"responding",label:"Progress update (streaming)",tier:"live",surface:"thread",protocol:'PRP item.delta kind:"agentMessage" channel:"progress"'},"responding-burst":{id:"responding-burst",label:"Progress update burst",tier:"live",surface:"thread",protocol:"text_delta stream:output ×N, tool calls between (PAP-368 dwell)"},"tool-call":{id:"tool-call",label:"Tool call",tier:"live",surface:"thread",protocol:"acpx.tool_call (ACP tool_call / tool_call_update)"},diff:{id:"diff",label:"Diff",tier:"live",surface:"thread",protocol:'ToolCallContent type:"diff" → TranscriptEntry kind:"diff"'},working:{id:"working",label:"Working",tier:"live",surface:"thread",protocol:"heartbeat.run.progress + acpx.status"},running:{id:"running",label:"Running",tier:"live",surface:"thread",protocol:'message.status.type === "running"'},completed:{id:"completed",label:"Completed (collapsed)",tier:"live",surface:"thread",protocol:"acpx.result (StopReason in subtype)"},"activity-phases":{id:"activity-phases",label:"Long-run activity phases",tier:"live",surface:"thread",protocol:"assistant boundaries + chronological tool calls"},"awaiting-approval":{id:"awaiting-approval",label:"Awaiting approval",tier:"tier-b",surface:"thread",protocol:"ACP RequestPermissionRequest + PermissionOptionKind"},"plan-todo":{id:"plan-todo",label:"Plan / todo",tier:"tier-b",surface:"plan",protocol:"ACP Plan { entries: PlanEntry[] }, PlanEntryStatus"},interrupted:{id:"interrupted",label:"Interrupted",tier:"tier-b",surface:"thread",protocol:'AcpRuntimeTurnResult.status:"cancelled" / StopReason "cancelled"'},refused:{id:"refused",label:"Refused",tier:"tier-b",surface:"thread",protocol:'StopReason "refusal"'},truncated:{id:"truncated",label:"Truncated",tier:"tier-b",surface:"thread",protocol:'StopReason "max_tokens" | "max_turn_requests"'},"live-token-cost":{id:"live-token-cost",label:"Live token / cost",tier:"tier-b",surface:"thread",protocol:"ACP UsageUpdate { used, size, cost }"}},Q9s=t5n.map(e=>n5n[e]);function lgt({browser:e,label:t="Browser",onOpen:s}){const r=e.status==="closed"||e.status==="failed";return(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2 py-1 text-sm","aria-label":`${t} session`,children:[(0,n.jsx)(Lp,{className:"size-4 shrink-0 text-ink-3","aria-hidden":!0}),(0,n.jsx)("span",{children:t}),(0,n.jsxs)("span",{className:"text-ink-3",children:["· ",e.status]}),s&&(0,n.jsx)($,{variant:"ghost",size:"sm",onClick:i(()=>s(e.id),"onClick"),children:r?"View session":"Open browser"})]})}i(lgt,"TaskBrowserActivity");function cgt({item:e}){return(0,n.jsx)("article",{className:"rounded-lg border border-line bg-bg-2 p-3","aria-label":`Project created: ${e.name}`,children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)(F7t,{className:"mt-0.5 size-4 shrink-0 text-ink-3","aria-hidden":!0}),(0,n.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,n.jsx)("p",{className:"text-xs text-ink-3",children:"Project created"}),(0,n.jsx)(Ye,{to:`/projects/${e.projectId}`,className:"break-words text-sm font-medium hover:underline focus-visible:underline",children:e.name}),e.description&&(0,n.jsx)("p",{className:"line-clamp-3 text-sm text-ink-3",children:e.description}),e.repositories.length>0&&(0,n.jsx)("ul",{className:"space-y-1 pt-1",children:e.repositories.map(t=>(0,n.jsxs)("li",{className:"flex min-w-0 items-center gap-2 text-xs text-ink-3",children:[(0,n.jsx)(Ao,{className:"size-3 shrink-0","aria-hidden":!0}),(0,n.jsx)("a",{className:"truncate hover:underline focus-visible:underline",href:t.url,target:"_blank",rel:"noreferrer",children:t.name})]},t.id))})]})]})})}i(cgt,"TaskChatProjectCreatedCard");function s5n({item:e,onOpen:t}){return(0,n.jsx)("article",{className:"rounded-lg border border-line bg-bg-2 p-3","aria-label":`Skill created: ${e.name}`,children:(0,n.jsxs)("button",{type:"button",className:"flex w-full items-start gap-3 text-left",onClick:i(()=>t?.(e.skillId,e.name),"onClick"),children:[(0,n.jsx)(Xf,{className:"mt-0.5 size-4 shrink-0 text-ink-3","aria-hidden":!0}),(0,n.jsxs)("span",{className:"min-w-0 flex-1 space-y-1",children:[(0,n.jsx)("span",{className:"block text-xs text-ink-3",children:"Skill created"}),(0,n.jsx)("span",{className:"block break-words text-sm font-medium hover:underline focus-visible:underline",children:e.name}),e.description?(0,n.jsx)("span",{className:"block line-clamp-3 text-sm text-ink-3",children:e.description}):null]})]})})}i(s5n,"TaskChatSkillCreatedCard");function r5n(e,t){const s=t||{};return(e[e.length-1]===""?[...e,""]:e).join((s.padRight?" ":"")+","+(s.padLeft===!1?"":" ")).trim()}i(r5n,"stringify$1");var i5n=/[ \t\n\f\r]/g;function a5n(e){return typeof e=="object"?e.type==="text"?V6e(e.value):!1:V6e(e)}i(a5n,"whitespace");function V6e(e){return e.replace(i5n,"")===""}i(V6e,"empty");var q7=class{static{i(this,"Schema")}constructor(e,t,s){this.normal=t,this.property=e,s&&(this.space=s)}};q7.prototype.normal={};q7.prototype.property={};q7.prototype.space=void 0;function dgt(e,t){const s={},r={};for(const a of e)Object.assign(s,a.property),Object.assign(r,a.normal);return new q7(s,r,t)}i(dgt,"merge");function jde(e){return e.toLowerCase()}i(jde,"normalize$1");var qp=class{static{i(this,"Info")}constructor(e,t){this.attribute=t,this.property=e}};qp.prototype.attribute="";qp.prototype.booleanish=!1;qp.prototype.boolean=!1;qp.prototype.commaOrSpaceSeparated=!1;qp.prototype.commaSeparated=!1;qp.prototype.defined=!1;qp.prototype.mustUseProperty=!1;qp.prototype.number=!1;qp.prototype.overloadedBoolean=!1;qp.prototype.property="";qp.prototype.spaceSeparated=!1;qp.prototype.space=void 0;var Nde=LQ({boolean:i(()=>ea,"boolean"),booleanish:i(()=>Od,"booleanish"),commaOrSpaceSeparated:i(()=>l0,"commaOrSpaceSeparated"),commaSeparated:i(()=>v3,"commaSeparated"),number:i(()=>ws,"number"),overloadedBoolean:i(()=>Cde,"overloadedBoolean"),spaceSeparated:i(()=>Dl,"spaceSeparated")}),o5n=0,ea=t_(),Od=t_(),Cde=t_(),ws=t_(),Dl=t_(),v3=t_(),l0=t_();function t_(){return 2**++o5n}i(t_,"increment");var ote=Object.keys(Nde),Mye=class extends qp{static{i(this,"DefinedInfo")}constructor(e,t,s,r){let a=-1;if(super(e,t),H6e(this,"space",r),typeof s=="number")for(;++a<ote.length;){const o=ote[a];H6e(this,ote[a],(s&Nde[o])===Nde[o])}}};Mye.prototype.defined=!0;function H6e(e,t,s){s&&(e[t]=s)}i(H6e,"mark");function zT(e){const t={},s={};for(const[r,a]of Object.entries(e.properties)){const o=new Mye(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,s[jde(r)]=r,s[jde(o.attribute)]=r}return new q7(t,s,e.space)}i(zT,"create$1");var ugt=zT({properties:{ariaActiveDescendant:null,ariaAtomic:Od,ariaAutoComplete:null,ariaBusy:Od,ariaChecked:Od,ariaColCount:ws,ariaColIndex:ws,ariaColSpan:ws,ariaControls:Dl,ariaCurrent:null,ariaDescribedBy:Dl,ariaDetails:null,ariaDisabled:Od,ariaDropEffect:Dl,ariaErrorMessage:null,ariaExpanded:Od,ariaFlowTo:Dl,ariaGrabbed:Od,ariaHasPopup:null,ariaHidden:Od,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Dl,ariaLevel:ws,ariaLive:null,ariaModal:Od,ariaMultiLine:Od,ariaMultiSelectable:Od,ariaOrientation:null,ariaOwns:Dl,ariaPlaceholder:null,ariaPosInSet:ws,ariaPressed:Od,ariaReadOnly:Od,ariaRelevant:null,ariaRequired:Od,ariaRoleDescription:Dl,ariaRowCount:ws,ariaRowIndex:ws,ariaRowSpan:ws,ariaSelected:Od,ariaSetSize:ws,ariaSort:null,ariaValueMax:ws,ariaValueMin:ws,ariaValueNow:ws,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function hgt(e,t){return t in e?e[t]:t}i(hgt,"caseSensitiveTransform");function mgt(e,t){return hgt(e,t.toLowerCase())}i(mgt,"caseInsensitiveTransform");var l5n=zT({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:v3,acceptCharset:Dl,accessKey:Dl,action:null,allow:null,allowFullScreen:ea,allowPaymentRequest:ea,allowUserMedia:ea,alpha:ea,alt:null,as:null,async:ea,autoCapitalize:null,autoComplete:Dl,autoFocus:ea,autoPlay:ea,blocking:Dl,capture:null,charSet:null,checked:ea,cite:null,className:Dl,closedBy:null,colorSpace:null,cols:ws,colSpan:ws,command:null,commandFor:null,content:null,contentEditable:Od,controls:ea,controlsList:Dl,coords:ws|v3,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ea,defer:ea,dir:null,dirName:null,disabled:ea,download:Cde,draggable:Od,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ea,formTarget:null,headers:Dl,height:ws,hidden:Cde,high:ws,href:null,hrefLang:null,htmlFor:Dl,httpEquiv:Dl,id:null,imageSizes:null,imageSrcSet:null,inert:ea,inputMode:null,integrity:null,is:null,isMap:ea,itemId:null,itemProp:Dl,itemRef:Dl,itemScope:ea,itemType:Dl,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ea,low:ws,manifest:null,max:null,maxLength:ws,media:null,method:null,min:null,minLength:ws,multiple:ea,muted:ea,name:null,nonce:null,noModule:ea,noValidate:ea,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ea,optimum:ws,pattern:null,ping:Dl,placeholder:null,playsInline:ea,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ea,referrerPolicy:null,rel:Dl,required:ea,reversed:ea,rows:ws,rowSpan:ws,sandbox:Dl,scope:null,scoped:ea,seamless:ea,selected:ea,shadowRootClonable:ea,shadowRootCustomElementRegistry:ea,shadowRootDelegatesFocus:ea,shadowRootMode:null,shadowRootSerializable:ea,shape:null,size:ws,sizes:null,slot:null,span:ws,spellCheck:Od,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ws,step:null,style:null,tabIndex:ws,target:null,title:null,translate:null,type:null,typeMustMatch:ea,useMap:null,value:Od,width:ws,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Dl,axis:null,background:null,bgColor:null,border:ws,borderColor:null,bottomMargin:ws,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ea,declare:ea,event:null,face:null,frame:null,frameBorder:null,hSpace:ws,leftMargin:ws,link:null,longDesc:null,lowSrc:null,marginHeight:ws,marginWidth:ws,noResize:ea,noHref:ea,noShade:ea,noWrap:ea,object:null,profile:null,prompt:null,rev:null,rightMargin:ws,rules:null,scheme:null,scrolling:Od,standby:null,summary:null,text:null,topMargin:ws,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ws,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:ea,disablePictureInPicture:ea,disableRemotePlayback:ea,exportParts:v3,part:Dl,prefix:null,property:null,results:ws,security:null,unselectable:null},space:"html",transform:mgt}),c5n=zT({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:l0,accentHeight:ws,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ws,amplitude:ws,arabicForm:null,ascent:ws,attributeName:null,attributeType:null,azimuth:ws,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ws,by:null,calcMode:null,capHeight:ws,className:Dl,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ws,diffuseConstant:ws,direction:null,display:null,dur:null,divisor:ws,dominantBaseline:null,download:ea,dx:null,dy:null,edgeMode:null,editable:null,elevation:ws,enableBackground:null,end:null,event:null,exponent:ws,externalResourcesRequired:null,fill:null,fillOpacity:ws,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:v3,g2:v3,glyphName:v3,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ws,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ws,horizOriginX:ws,horizOriginY:ws,id:null,ideographic:ws,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ws,k:ws,k1:ws,k2:ws,k3:ws,k4:ws,kernelMatrix:l0,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ws,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ws,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ws,overlineThickness:ws,paintOrder:null,panose1:null,path:null,pathLength:ws,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Dl,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ws,pointsAtY:ws,pointsAtZ:ws,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:l0,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:l0,rev:l0,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:l0,requiredFeatures:l0,requiredFonts:l0,requiredFormats:l0,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ws,specularExponent:ws,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ws,strikethroughThickness:ws,string:null,stroke:null,strokeDashArray:l0,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ws,strokeOpacity:ws,strokeWidth:null,style:null,surfaceScale:ws,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:l0,tabIndex:ws,tableValues:null,target:null,targetX:ws,targetY:ws,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:l0,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ws,underlineThickness:ws,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ws,values:null,vAlphabetic:ws,vMathematical:ws,vectorEffect:null,vHanging:ws,vIdeographic:ws,version:null,vertAdvY:ws,vertOriginX:ws,vertOriginY:ws,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ws,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:hgt}),pgt=zT({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),fgt=zT({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:mgt}),ggt=zT({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),d5n={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},u5n=/[A-Z]/g,G6e=/-[a-z]/g,h5n=/^data[-\w.:]+$/i;function m5n(e,t){const s=jde(t);let r=t,a=qp;if(s in e.normal)return e.property[e.normal[s]];if(s.length>4&&s.slice(0,4)==="data"&&h5n.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(G6e,f5n);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!G6e.test(o)){let l=o.replace(u5n,p5n);l.charAt(0)!=="-"&&(l="-"+l),t="data"+l}}a=Mye}return new a(r,t)}i(m5n,"find");function p5n(e){return"-"+e.toLowerCase()}i(p5n,"kebab");function f5n(e){return e.charAt(1).toUpperCase()}i(f5n,"camelcase");var g5n=dgt([ugt,l5n,pgt,fgt,ggt],"html"),Lye=dgt([ugt,c5n,pgt,fgt,ggt],"svg");function x5n(e){return e.join(" ").trim()}i(x5n,"stringify");var v5n=ih(((e,t)=>{var s=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,a=/^\s*/,o=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,l=/^:\s*/,c=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,d=/^[;\s]*/,u=/^\s+|\s+$/g,h=`
414
+ `)}`:void 0}i(I_n,"sanitizeComponentStack");function qft(){const e={};if(typeof document<"u"){try{const t=document.readyState;(t==="loading"||t==="interactive"||t==="complete")&&(e.ready_state=t)}catch{}try{const t=document.visibilityState;(t==="visible"||t==="hidden")&&(e.visibility_state=t)}catch{}try{const t=document.documentElement.classList;e.translation_marker=t.contains("translated-ltr")||t.contains("translated-rtl")}catch{}}return e}i(qft,"readBrowserErrorState");function T_n(e){const t=I_n(e.componentStack);return{tags:{react_error_boundary:e.boundary},contexts:{react:t?{componentStack:t}:{},browser_state:qft()}}}i(T_n,"buildBrowserErrorContext");var O6e=Promise.resolve();function Iye(e){const t=O6e.then(e);return O6e=t.catch(()=>{}),t}i(Iye,"enqueue");var CI=null;function E_n(e,t){return Iye(async()=>{if(!CI)try{const s=await ln(()=>import("./prod-COP_vZWu.js"),__vite__mapDeps([33,5]));s.init(M_n(e,t)),CI=s}catch{}})}i(E_n,"initBrowserErrorMonitoring");function R_n(){return Iye(async()=>{const e=CI;if(CI=null,!e)return;const t=e.getClient();try{e.getCurrentScope().setClient(void 0)}catch{}try{await t?.close(2e3)}catch{}})}i(R_n,"teardownBrowserErrorMonitoring");function Tye(e,t){let s;try{t&&(s=T_n(t))}catch{}Iye(async()=>{try{s?CI?.captureException(e,s):CI?.captureException(e)}catch{}})}i(Tye,"captureBrowserException");function M_n(e,t){return{dsn:e,environment:t??void 0,release:"f92c1812bc0971c83889445b4e665765035416ff",tracesSampleRate:0,sendDefaultPii:!1,beforeSend:i((s,r)=>{try{if(s.contexts={...s.contexts,browser_state:s.contexts?.browser_state??qft()},s.tags={...s.tags,browser_build_mode:"production"},s.exception?.values?.some(a=>a.mechanism?.type==="onunhandledrejection"||a.mechanism?.type==="auto.browser.global_handlers.onunhandledrejection")){const a=r.originalException;s.tags.browser_rejection_kind=a===null?"null":typeof a}}catch{}return s},"beforeSend"),integrations:i(s=>s.filter(r=>r.name!=="HttpContext"&&r.name!=="Breadcrumbs"),"integrations")}}i(M_n,"buildBrowserSentryInitOptions");var L_n=class extends m.Component{static{i(this,"RouteErrorBoundaryInner")}state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,t){Tye(e,{boundary:"route",componentStack:t.componentStack})}componentDidUpdate(e){this.state.error&&e.resetKey!==this.props.resetKey&&this.setState({error:null})}render(){const{error:e}=this.state;return e?(0,n.jsxs)("div",{className:"mx-auto max-w-2xl space-y-4 px-4 py-10",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"This page hit an error"}),(0,n.jsx)("p",{className:"mt-1 text-sm text-ink-3",children:"Something went wrong while rendering this page. You can go back and try again, or reload."})]}),(0,n.jsx)("pre",{className:"overflow-auto rounded-md border border-bad/30 bg-bad/10 px-3 py-2 text-xs text-bad whitespace-pre-wrap",children:e.message}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)($,{variant:"secondary",size:"sm",onClick:this.props.onReset,children:"Go back"}),(0,n.jsx)($,{size:"sm",onClick:i(()=>window.location.reload(),"onClick"),children:"Reload page"})]})]}):this.props.children}};function D_n({children:e}){const t=Ri(),s=ir(),r=`${t.pathname}${t.search}`;return(0,n.jsx)(L_n,{resetKey:r,onReset:i(()=>s(-1),"onReset"),children:e})}i(D_n,"RouteErrorBoundary");var F6e={bot:Uo,cpu:If,brain:Xy,zap:hq,rocket:JEt,code:oRt,terminal:gk,shield:UQ,eye:Om,search:Jr,wrench:Xf,hammer:X8,lightbulb:tD,sparkles:eb,star:fk,heart:nR,flame:qEt,bug:n3,cog:IKe,database:eD,globe:Lp,lock:rl,mail:Bpe,"message-square":Kv,"file-code":Qc,"git-branch":Ao,package:ax,puzzle:t3,target:Xv,wand:W0e,atom:REt,"circuit-board":_7t,radar:QEt,swords:xPt,telescope:eRt,microscope:Y7t,crown:zQ,gem:KEt,hexagon:Xh,pentagon:rPt,fingerprint:_ie},P_n="bot";function $_n(e){return e&&a4t.includes(e)?F6e[e]:F6e[P_n]}i($_n,"getAgentIcon");function BK({icon:e,className:t}){const s=$_n(e);return(0,n.jsx)(s,{className:t})}i(BK,"AgentIcon");function Uft({open:e,onOpenChange:t,...s}){return(0,n.jsx)(Bn,{open:e,onOpenChange:t,children:(0,n.jsxs)(zn,{"aria-describedby":void 0,className:"gap-0 overflow-hidden p-0 sm:max-w-md",children:[(0,n.jsxs)("div",{className:"px-4 pt-4 pb-3",children:[(0,n.jsx)(qn,{children:"Chat with an agent"}),s.existingChatAgentIds&&(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"One conversation per agent. Pick up where you left off."})]}),(0,n.jsx)(O_n,{...s,onComplete:i(()=>t(!1),"onComplete")},String(e))]})})}i(Uft,"AgentChatPicker");function O_n({agents:e,onSelect:t,onComplete:s,loading:r,error:a,onRetry:o,existingChatAgentIds:l,renderAgentIcon:c}){const d=(0,m.useRef)(!1),u=(0,m.useRef)(null);(0,m.useEffect)(()=>(d.current=!0,()=>{d.current=!1,u.current?.abort()}),[]);const[h,p]=(0,m.useState)(""),[f,g]=(0,m.useState)(null),[x,v]=(0,m.useState)(null);async function b(y){if(f)return;g(y.id),v(null);const k=new AbortController;u.current=k;try{await t(y,k.signal),d.current&&s()}catch(j){v(j instanceof Error?j.message:"Couldn’t open chat. Try again.")}finally{g(null)}}return i(b,"selectAgent"),(0,n.jsxs)(PS,{children:[(0,n.jsx)($S,{"aria-label":"Search agents by name or role",placeholder:"Search by name or role…",value:h,onValueChange:p}),x&&(0,n.jsx)("p",{role:"alert",className:"px-4 py-3 text-sm text-bad",children:x}),f&&(0,n.jsx)("p",{role:"status",className:"sr-only",children:"Opening conversation…"}),a?(0,n.jsxs)("div",{role:"alert",className:"flex flex-col items-start gap-2 p-4 text-sm",children:[(0,n.jsx)("p",{children:"Couldn’t load agents. Try again."}),o&&(0,n.jsx)($,{variant:"secondary",size:"sm",onClick:o,children:"Retry"})]}):r?(0,n.jsx)("p",{role:"status",className:"p-4 text-sm text-ink-3",children:"Loading agents…"}):(0,n.jsxs)(OS,{children:[(0,n.jsx)(FS,{children:(0,n.jsxs)("div",{className:"flex flex-col items-center gap-2 px-4",children:[(0,n.jsx)("span",{children:e.length?`No agents match “${h}”`:"No agents yet."}),e.length?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-xs text-ink-3",children:"Try another name or role."}),(0,n.jsx)($,{variant:"ghost",size:"sm",onClick:i(()=>p(""),"onClick"),children:"Clear search"})]}):(0,n.jsx)("span",{className:"text-xs text-ink-3",children:"Create an agent from the Agents page to start chatting."})]})}),(0,n.jsx)(qh,{children:e.map(y=>(0,n.jsxs)(jo,{value:y.id,keywords:[y.name,y.title??"",y.role],onSelect:i(()=>{b(y)},"onSelect"),disabled:f!==null,className:"gap-3 px-3 py-3",children:[c?c(y):(0,n.jsx)(BK,{icon:y.icon,className:"size-4 shrink-0"}),(0,n.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,n.jsx)("span",{className:"truncate font-medium",children:y.name}),(0,n.jsx)("span",{className:"truncate text-xs text-ink-3",children:y.title??y.role})]}),l&&(0,n.jsx)("span",{className:"shrink-0 text-xs text-ink-3",children:l.includes(y.id)?"Open chat":"New chat"}),y.status==="paused"&&(0,n.jsx)("span",{className:"text-xs text-(--status-agent-paused)",children:"Paused"}),y.status==="terminated"&&(0,n.jsx)("span",{className:"text-xs text-ink-3",children:"Terminated"}),y.status==="pending_approval"&&(0,n.jsx)("span",{className:"text-xs text-ink-3",children:"Awaiting approval"})]},y.id))})]})]})}i(O_n,"AgentChatPickerResults");function az({agents:e,existingChatAgentIds:t,availableAgents:s=e,activeId:r,previews:a={},loading:o=!1,error:l,onRetry:c,initialSearch:d="",onSelect:u,onBrowse:h,onAddChat:p,historyLoading:f,historyError:g,onRetryHistory:x}){const v=ir(),[b,y]=(0,m.useState)(!1),[k,j]=(0,m.useState)(d),N=(0,m.useRef)(null),S=(0,m.useId)(),A=k.trim().toLocaleLowerCase(),I=e.filter(T=>`${T.name} ${T.title??""} ${T.role}`.toLocaleLowerCase().includes(A));function _(){j(""),N.current?.focus()}return i(_,"focusSearch"),(0,n.jsxs)("aside",{"aria-labelledby":S,className:"flex h-full min-h-0 flex-col border-r border-line bg-bg",children:[(0,n.jsxs)("div",{className:"flex shrink-0 flex-col gap-4 px-3 pb-4 pt-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsx)("h2",{id:S,className:"text-sm font-semibold",children:"Chat"}),(0,n.jsx)($,{variant:"secondary",size:"icon-sm","aria-label":"Add chat",title:"Add chat",onClick:i(()=>y(!0),"onClick"),children:(0,n.jsx)(js,{className:"size-4"})})]}),(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)(Jr,{"aria-hidden":"true",className:"pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-ink-3"}),(0,n.jsx)(mt,{ref:N,"aria-label":"Search agents",placeholder:"Find an agent",value:k,onChange:i(T=>j(T.target.value),"onChange"),onKeyDown:i(T=>{T.key==="Escape"&&(T.stopPropagation(),j(""))},"onKeyDown"),className:"h-8 pl-8 pr-8 text-xs md:text-xs"}),k&&(0,n.jsx)($,{variant:"ghost",size:"icon-xs","aria-label":"Clear search",className:"absolute right-1 top-1/2 -translate-y-1/2",onClick:_,children:(0,n.jsx)(ks,{className:"size-3"})})]})]}),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto px-3 pb-3 scrollbar-auto-hide",children:[(0,n.jsx)("p",{className:"px-2 text-(length:--text-micro) font-medium uppercase tracking-widest text-ink-3",children:A?"Search results":"Teammates"}),(0,n.jsx)("span",{role:"status",className:"sr-only",children:o?"Loading agents":`${I.length} ${I.length===1?"agent":"agents"}`}),f&&(0,n.jsx)("p",{role:"status",className:"px-2 text-xs text-ink-3",children:"Loading chat history…"}),g&&(0,n.jsxs)("div",{role:"alert",className:"flex flex-col items-start gap-2 px-2 py-3",children:[(0,n.jsx)("p",{className:"text-xs text-ink-3",children:"Some chat history couldn’t load."}),(0,n.jsx)($,{variant:"secondary",size:"sm",onClick:x,children:"Retry chat history"})]}),l?(0,n.jsxs)("div",{role:"alert",className:"flex flex-col items-start gap-2 px-2 py-6",children:[(0,n.jsx)("p",{className:"text-sm",children:"Couldn’t load your chats."}),(0,n.jsx)($,{variant:"secondary",size:"sm",onClick:c,children:"Try again"})]}):o?(0,n.jsx)("div",{"aria-hidden":"true",className:"flex flex-col gap-1",children:[0,1,2,3].map(T=>(0,n.jsxs)("div",{className:"flex items-center gap-3 rounded-md px-2 py-3 motion-safe:animate-pulse",children:[(0,n.jsx)("div",{className:"size-8 shrink-0 rounded-lg bg-bg-3"}),(0,n.jsxs)("div",{className:"flex flex-1 flex-col gap-2",children:[(0,n.jsx)("div",{className:"h-3 w-2/3 rounded-sm bg-bg-3"}),(0,n.jsx)("div",{className:"h-2 w-full rounded-sm bg-bg-3"})]})]},T))}):I.length?(0,n.jsx)("nav",{"aria-label":"Agent conversations",className:"flex flex-col gap-1",children:I.map(T=>(0,n.jsxs)(Ye,{to:`/chats/${encodeURIComponent(T.status==="terminated"?T.id:Gd(T))}`,"aria-current":r===T.id?"page":void 0,title:`${T.name}${T.title?` · ${T.title}`:""}`,onClick:i(E=>{u&&(E.preventDefault(),u(T))},"onClick"),className:Q("flex min-w-0 items-center gap-3 rounded-md px-2 py-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus",r===T.id?r1.active:r1.rest),children:[(0,n.jsx)(lr,{agent:T,size:32}),(0,n.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,n.jsx)("span",{className:"truncate text-sm font-medium",children:T.name}),(0,n.jsx)("span",{className:"truncate text-xs text-ink-3",children:T.status==="terminated"?"Terminated":T.status==="paused"?"Paused":a[T.id]??T.title??"Start a conversation"})]})]},T.id))}):!e.length&&(f||g)?null:(0,n.jsxs)("div",{className:"flex flex-col items-start gap-2 px-2 py-6",children:[(0,n.jsx)("p",{className:"text-sm font-medium",children:e.length?"No agents found":"No chats yet"}),(0,n.jsx)("p",{className:"text-xs leading-relaxed text-ink-3",children:e.length?"Try another name or role.":"Choose an agent to start a conversation."}),!e.length&&(0,n.jsx)($,{variant:"secondary",size:"sm",onClick:i(()=>y(!0),"onClick"),children:"Choose an agent"}),e.length>0&&(0,n.jsx)($,{variant:"secondary",size:"sm",onClick:_,children:"Clear search"})]})]}),(0,n.jsx)("div",{className:"shrink-0 px-3 py-4",children:(0,n.jsx)($,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 px-2",asChild:!h,onClick:h,children:h?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(Jc,{className:"size-4"}),"Browse all agents"]}):(0,n.jsxs)(Ye,{to:"/agents/all",children:[(0,n.jsx)(Jc,{className:"size-4"}),"Browse all agents"]})})}),(0,n.jsx)(Uft,{agents:s,open:b,onOpenChange:y,existingChatAgentIds:t??e.map(T=>T.id),loading:o,error:l,onRetry:c,renderAgentIcon:i(T=>(0,n.jsx)(lr,{agent:T,size:32}),"renderAgentIcon"),onSelect:i(async(T,E)=>{p?await p(T,E):u?await u(T,E):v(`/chats/${encodeURIComponent(Gd(T))}`),E?.aborted||j("")},"onSelect")})]})}i(az,"AgentConversationSidebar");var zK={list:i(e=>le.get(`/companies/${e}/chats`),"list"),get:i((e,t)=>le.get(`/companies/${e}/chats/${encodeURIComponent(t)}`),"get"),ensure:i((e,t)=>le.post(`/companies/${e}/chats/${encodeURIComponent(t)}`,{}),"ensure")};function Kft(){const{selectedCompanyId:e}=gn(),{enabled:t,loaded:s}=MS(),r=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn")}),a=r.data?.user?.id??r.data?.session?.userId??null;return{companyId:e,userId:a,enabled:t,loaded:s,agents:ie({queryKey:O.agents.list(e),queryFn:i(()=>Pt.list(e),"queryFn"),enabled:t&&!!e}),chats:ie({queryKey:O.agentChats.list(e,a),queryFn:i(()=>zK.list(e),"queryFn"),enabled:t&&!!e&&r.isSuccess}),session:r}}i(Kft,"useAgentChatNavigation");function Wft(e,t){const s=Ct(),r=ir(),{isMobile:a,setSidebarOpen:o}=Io(),l=(0,m.useRef)({companyId:e,userId:t,mounted:!0});return(0,m.useEffect)(()=>{const c={companyId:e,userId:t,mounted:!0};return l.current=c,()=>{c.mounted=!1}},[e,t]),(0,m.useCallback)(async(c,d)=>{if(!e||c.companyId!==e)throw new Error("Choose an agent from this company.");const u=l.current,h=await zK.ensure(e,c.id);s.setQueryData(O.agentChats.detail(e,t,c.id),h),s.setQueryData(O.issues.detail(h.id),h),s.setQueryData(O.agentChats.list(e,t),p=>[h,...(p??[]).filter(f=>f.id!==h.id)].sort((f,g)=>new Date(g.updatedAt).getTime()-new Date(f.updatedAt).getTime()||g.id.localeCompare(f.id))),!(!u.mounted||l.current!==u||d?.aborted)&&(r(`/chats/${encodeURIComponent(Gd(c))}`),a&&o(!1))},[s,e,t,r,a,o])}i(Wft,"useOpenAgentChat");function F_n(){const{companyId:e,userId:t,agents:s,chats:r,session:a}=Kft(),o=Wft(e,t),l=ir(),c=RS(e),{isMobile:d,setSidebarOpen:u}=Io(),{pathname:h}=Ri(),p=h.split("/chats/")[1]?.split("/")[0],f=s.data??[],g=s.isSuccess?[...new Set((r.data??[]).flatMap(S=>S.conversationAgentId&&!f.some(A=>A.id===S.conversationAgentId)?[S.conversationAgentId]:[]))]:[],x=$m({queries:g.map(S=>({queryKey:O.agents.detail(S),queryFn:i(()=>Pt.get(S,e),"queryFn")}))}),v=new Map(f.map(S=>[S.id,S]));for(const S of x)S.data&&v.set(S.data.id,S.data);const b=[...v.values()].find(S=>S.id===p||S.status!=="terminated"&&encodeURIComponent(Gd(S))===p),y=(r.data??[]).flatMap(S=>{const A=S.conversationAgentId?v.get(S.conversationAgentId):void 0;return A?[A]:[]});b&&!y.some(S=>S.id===b.id)&&y.unshift(b);const k=new Set(y.map(S=>S.id)),j=f.filter(S=>!k.has(S.id)&&S.status!=="terminated"&&(!c.isSuccess||P3(c.data,"agent",S.id)!=="left")).sort((S,A)=>S.name.localeCompare(A.name,void 0,{sensitivity:"base"})),N=Object.fromEntries((r.data??[]).filter(S=>S.conversationState==="active").map(S=>[S.conversationAgentId,"Working…"]));return(0,n.jsx)(az,{agents:[...y,...j],availableAgents:f,existingChatAgentIds:y.map(S=>S.id),activeId:b?.id,previews:N,loading:s.isPending||r.isPending||a.isPending,error:s.error??r.error??a.error,onRetry:i(()=>{s.refetch(),r.refetch(),a.refetch()},"onRetry"),historyLoading:x.some(S=>S.isPending),historyError:x.find(S=>S.error)?.error,onRetryHistory:i(()=>{x.filter(S=>S.isError).forEach(S=>{S.refetch()})},"onRetryHistory"),onAddChat:o,onSelect:i(S=>{l(`/chats/${encodeURIComponent(S.status==="terminated"?S.id:Gd(S))}`),d&&u(!1)},"onSelect")},`${e}:${t}`)}i(F_n,"AgentConversationsSidebar");var E$=232,xde=208,vde=420,B6e=16;function qK(e){return Math.min(vde,Math.max(xde,e))}i(qK,"clampSidebarWidth");function z6e(e){if(typeof window>"u")return E$;try{const t=window.localStorage.getItem(e);if(!t)return E$;const s=Number.parseInt(t,10);return Number.isFinite(s)?qK(s):E$}catch{return E$}}i(z6e,"readStoredSidebarWidth");function q6e(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,String(qK(t)))}catch{}}i(q6e,"writeStoredSidebarWidth");function B_n({children:e,open:t,collapsed:s=!1,peeking:r=!1,resizable:a=!1,storageKey:o="paperclip.sidebar.width",className:l,onPanelMouseEnter:c,onPanelMouseLeave:d,onPanelFocusCapture:u,onPanelBlurCapture:h}){const[p,f]=(0,m.useState)(()=>z6e(o)),[g,x]=(0,m.useState)(!1),v=(0,m.useRef)(p),b=(0,m.useRef)(null);(0,m.useEffect)(()=>{const D=z6e(o);v.current=D,f(D)},[o]);const y=t?p:0,k=t?s?72:y:0,j=t?s&&!r?72:y:0,N=j>k,S=a&&t&&!s,A=(0,m.useMemo)(()=>({width:`${k}px`}),[k]),I=(0,m.useMemo)(()=>({width:`${j}px`}),[j]),_=(0,m.useCallback)(D=>{const K=qK(D);v.current=K,f(K),q6e(o,K)},[o]),T=(0,m.useCallback)(D=>{S&&(D.preventDefault(),D.currentTarget.setPointerCapture(D.pointerId),b.current={startX:D.clientX,startWidth:v.current},x(!0))},[S]),E=(0,m.useCallback)(D=>{if(!b.current)return;const K=qK(b.current.startWidth+D.clientX-b.current.startX);v.current=K,f(K)},[]),M=(0,m.useCallback)(()=>{b.current&&(b.current=null,x(!1),q6e(o,v.current))},[o]),P=(0,m.useCallback)(D=>{S&&(D.key==="ArrowLeft"?(D.preventDefault(),_(p-B6e)):D.key==="ArrowRight"?(D.preventDefault(),_(p+B6e)):D.key==="Home"?(D.preventDefault(),_(xde)):D.key==="End"&&(D.preventDefault(),_(vde)))},[S,_,p]);return(0,n.jsxs)("div",{className:Q("relative h-full shrink-0",l),style:A,children:[(0,n.jsx)("div",{className:Q("absolute inset-y-0 left-0 flex flex-col overflow-hidden",N?"z-30 border-r border-line bg-bg shadow-lg":"z-0"),style:I,"data-sidebar-overlay":N?"":void 0,onMouseEnter:c,onMouseLeave:d,onFocusCapture:u,onBlurCapture:h,children:e}),S?(0,n.jsx)("div",{role:"separator","aria-label":"Resize sidebar","aria-orientation":"vertical","aria-valuemin":xde,"aria-valuemax":vde,"aria-valuenow":p,tabIndex:0,"data-dragging":g?"":void 0,className:"group absolute inset-y-0 z-20 cursor-col-resize touch-none outline-none",style:{right:-4,width:8},onPointerDown:T,onPointerMove:E,onPointerUp:M,onPointerCancel:M,onLostPointerCapture:M,onKeyDown:P,children:(0,n.jsx)("div",{className:Q("mx-auto h-full w-0.5 transition-colors",g?"bg-focus":"bg-transparent group-hover:bg-focus group-focus-visible:bg-focus")})}):null]})}i(B_n,"SidebarShell");function R$({children:e,className:t}){return(0,n.jsx)("div",{"data-secondary-sidebar":"",className:Q("h-full w-full min-w-0 overflow-hidden",t),children:(0,n.jsx)(GJe,{children:e})})}i(R$,"SecondarySidebar");var Qft={listStacks:i(()=>le.get("/cloud/stacks"),"listStacks")};function gG(e,t){const s=e?.trim();if(!s)return null;try{const r=new URL(t,s);return r.protocol!=="https:"&&r.protocol!=="http:"?null:r.toString()}catch{return null}}i(gG,"cloudAppUrl");function Vft(e){return gG(e,"/stacks/new")}i(Vft,"cloudStackCreateUrl");function Hft(e){if(!e.startsWith("/")||e.startsWith("//")||/[\\\x00-\x20]/.test(e))return"/";const t=new URL(e,"https://tenant.invalid");return t.pathname.replace(/\/+$/,"")==="/auth"?"/":`${t.pathname}${t.search}${t.hash}`}i(Hft,"tenantSignInReturnPath");function z_n(e,t,s){const r=t?.trim();if(!r)return null;const a=gG(e,`/v1/stacks/${encodeURIComponent(r)}/entry-redirect`);if(!a)return null;const o=new URL(a);return o.searchParams.set("returnTo",Hft(s)),o.toString()}i(z_n,"cloudStackEntryUrl");function Gft(e,t){const s=t?.trim();return s?gG(e,`/workspaces/${encodeURIComponent(s)}/settings?section=people`):null}i(Gft,"cloudStackInviteUrl");function q_n(e){return gG(e,"/orgs?manage=1")}i(q_n,"cloudPortfolioManageUrl");function U_n(){const e=im(),t=!!e,s=ie({queryKey:O.cloud.stacks,queryFn:i(()=>Qft.listStacks(),"queryFn"),enabled:t,staleTime:3e4,retry:!1});if(!e||s.isError)return null;const r=s.data?.stacks.find(a=>a.isCurrent);return r?.role!=="owner"&&r?.role!=="admin"?null:Gft(e.cloudBaseUrl,r.stackSlug)}i(U_n,"useCloudInviteUrl");function K_n(e,t){if(!t)return!1;if(t.source==="local_implicit"||t.isInstanceAdmin)return!0;if(!e)return!1;const s=t.memberships?.find(r=>r.companyId===e&&r.status==="active");return s?.membershipRole==="owner"||s?.membershipRole==="admin"||s?.membershipRole==="operator"||s?.membershipRole==="member"}i(K_n,"canInviteCompanyMembers");function W_n(e=!0){const t=Y8(),s=ie({queryKey:O.access.currentBoardAccess,queryFn:i(()=>jr.getCurrentBoardAccess(),"queryFn"),enabled:e,retry:!1,staleTime:3e4});return e&&K_n(t?.selectedCompanyId,s.data)}i(W_n,"useCanInviteCompanyMembers");function Q_n(e){const t=window.location.hostname.endsWith(".staging.paperclip.app"),{data:s,isError:r}=ie({queryKey:O.stagingCommit,queryFn:i(()=>Op.get(),"queryFn"),enabled:t&&e,staleTime:0,retry:!1});return t&&!r?s?.commit??null:null}i(Q_n,"useStagingCommit");function V_n(e){return e?.trim().toLowerCase().replace(/['"]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||null}i(V_n,"slugifyUserPart");function H_n(e){const t=[e?.id,e?.name,e?.email?.split("@")[0],e?.email];for(const s of t){const r=V_n(s);if(r)return`/u/${r}`}return"/u/me"}i(H_n,"userProfilePath");var Yft="paperclip.theme",G_n="#0d0e11",Y_n="#f6f7f9",Jft=(0,m.createContext)(void 0);function J_n(){return typeof document>"u"||document.documentElement.classList.contains("dark")?"dark":"light"}i(J_n,"resolveThemeFromDocument");function Z_n(){if(typeof window>"u")return!1;try{const e=window.localStorage.getItem(Yft);return e==="light"||e==="dark"}catch{return!1}}i(Z_n,"hasStoredTheme");function X_n(e){if(typeof document>"u")return;const t=e==="dark",s=document.documentElement;s.classList.toggle("dark",t),s.style.colorScheme=t?"dark":"light";for(const r of document.querySelectorAll('meta[name="theme-color"]'))r.setAttribute("content",t?G_n:Y_n)}i(X_n,"applyTheme");function e2n({children:e}){const[t,s]=(0,m.useState)(()=>J_n()),[r,a]=(0,m.useState)(()=>Z_n()),o=(0,m.useCallback)(d=>{a(!0),s(d)},[]),l=(0,m.useCallback)(()=>{a(!0),s(d=>d==="dark"?"light":"dark")},[]);(0,m.useEffect)(()=>{if(X_n(t),!!r)try{localStorage.setItem(Yft,t)}catch{}},[t,r]),(0,m.useEffect)(()=>{if(r||typeof window>"u"||typeof window.matchMedia!="function")return;const d=window.matchMedia("(prefers-color-scheme: dark)"),u=i(h=>{s(h.matches?"dark":"light")},"handleChange");return d.addEventListener("change",u),()=>d.removeEventListener("change",u)},[r]);const c=(0,m.useMemo)(()=>({theme:t,setTheme:o,toggleTheme:l}),[t,o,l]);return(0,n.jsx)(Jft.Provider,{value:c,children:e})}i(e2n,"ThemeProvider");function Zft(){const e=(0,m.useContext)(Jft);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}i(Zft,"useTheme");var t2n="Toggle the app appearance.";function q6({className:e,variant:t="icon",onAfterToggle:s}){const{theme:r,toggleTheme:a}=Zft(),o=r==="dark",l=o?"Switch to light mode":"Switch to dark mode",c=o?QYe:Z7t;function d(){a(),s?.()}return i(d,"handleClick"),t==="compact-menu-action"?(0,n.jsxs)("button",{type:"button",className:Q("flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-ink transition-colors hover:bg-bg-3",e),onClick:d,"aria-label":l,children:[(0,n.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-ink-3",children:(0,n.jsx)(c,{className:"size-4"})}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:l})]}):t==="menu-action"?(0,n.jsxs)("button",{type:"button",className:Q("flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-bg-3/60",e),onClick:d,"aria-label":l,children:[(0,n.jsx)("span",{className:"mt-0.5 rounded-lg border border-line bg-bg/70 p-2 text-ink-3",children:(0,n.jsx)(c,{className:"size-4"})}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"block text-sm font-medium text-ink",children:l}),(0,n.jsx)("span",{className:"block text-xs text-ink-3",children:t2n})]})]}):(0,n.jsx)($,{type:"button",variant:"ghost",size:"icon-sm",onClick:d,"aria-label":l,title:l,className:Q("",e),children:(0,n.jsx)(c,{})})}i(q6,"ThemeToggle");var t8=null,Xft=!1,bde=!1,yde=new Set;function n8(){for(const e of yde)e()}i(n8,"emit");function n2n(e=typeof navigator>"u"?"":navigator.userAgent,t=typeof navigator>"u"?0:navigator.maxTouchPoints){return/iPhone|iPad|iPod/i.test(e)?!0:/Macintosh/i.test(e)&&t>1}i(n2n,"isIosSafariLike");function s2n(e=window){const t=i(r=>{r.preventDefault(),t8=r,n8()},"onPrompt"),s=i(()=>{t8=null,Xft=!0,n8()},"onInstalled");return e.addEventListener("beforeinstallprompt",t),e.addEventListener("appinstalled",s),()=>{e.removeEventListener("beforeinstallprompt",t),e.removeEventListener("appinstalled",s)}}i(s2n,"captureInstallPrompt");function r2n(){return Xft||gde()?"installed":t8?"prompt":n2n()?"ios-manual":"unavailable"}i(r2n,"installAvailability");async function egt(){const e=t8;if(!e)return"unavailable";t8=null,n8(),await e.prompt();const{outcome:t}=await e.userChoice;return t}i(egt,"promptInstall");function UK(e){bde!==e&&(bde=e,n8())}i(UK,"setIosInstallHelpOpen");function i2n(){return bde}i(i2n,"iosInstallHelpOpen");function a2n(){return(0,m.useSyncExternalStore)(Eye,i2n,()=>!1)}i(a2n,"useIosInstallHelpOpen");function Eye(e){return yde.add(e),()=>{yde.delete(e)}}i(Eye,"subscribe$2");function Rye(){return(0,m.useSyncExternalStore)(Eye,r2n,()=>"unavailable")}i(Rye,"useInstallAvailability");function o2n(e){const t=Rye();return(0,m.useSyncExternalStore)(Eye,()=>d2n(t,e),()=>!1)}i(o2n,"useInstallNudgeVisible");var l2n=2592e6,kde="wardmote.install.visits",U6e="wardmote.install.visit-counted",tgt="wardmote.install.snoozed-until";function wde(e,t){const s=Number(e.getItem(t));return Number.isFinite(s)?s:0}i(wde,"readNumber$2");function c2n(e=window.localStorage,t=window.sessionStorage){try{if(t.getItem(U6e))return;t.setItem(U6e,"1"),e.setItem(kde,String(wde(e,kde)+1))}catch{return}}i(c2n,"recordAppVisit");function d2n(e,t,s=Date.now(),r=window.localStorage){if(e!=="prompt"&&e!=="ios-manual"||/^\/(?:[^/]+\/)?onboarding(?:\/|$)/.test(t))return!1;try{return wde(r,kde)>=3&&wde(r,tgt)<=s}catch{return!1}}i(d2n,"installNudgeVisible");function u2n(e=Date.now(),t=window.localStorage){try{t.setItem(tgt,String(e+l2n))}catch{return}finally{n8()}}i(u2n,"snoozeInstallNudge");var K6e="Install app",h2n="Add Wardmote to your home screen or dock.";function m2n({variant:e,onAfterAction:t}){const s=Rye();if(s==="installed"||s==="unavailable")return null;const r=i(()=>{s==="ios-manual"?UK(!0):egt(),t?.()},"handleClick");return e==="compact-menu-action"?(0,n.jsxs)("button",{type:"button",className:"flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-ink transition-colors hover:bg-bg-3",onClick:r,children:[(0,n.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-ink-3",children:(0,n.jsx)(xo,{className:"size-4"})}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:K6e})]}):(0,n.jsxs)("button",{type:"button",className:"flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left transition-colors hover:bg-bg-3/60",onClick:r,children:[(0,n.jsx)("span",{className:"mt-0.5 rounded-lg border border-line bg-bg/70 p-2 text-ink-3",children:(0,n.jsx)(xo,{className:"size-4"})}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"block text-sm font-medium text-ink",children:K6e}),(0,n.jsx)("span",{className:"block text-xs text-ink-3",children:h2n})]})]})}i(m2n,"InstallAppMenuAction");function p2n(){const e=a2n();return(0,n.jsx)(Bn,{open:e,onOpenChange:UK,children:(0,n.jsxs)(zn,{children:[(0,n.jsxs)(rs,{children:[(0,n.jsx)(qn,{children:"Install Wardmote"}),(0,n.jsx)(ds,{children:"Add Wardmote to your Home Screen from Safari."})]}),(0,n.jsxs)("ol",{className:"space-y-3 text-sm text-ink",children:[(0,n.jsxs)(rte,{index:1,icon:(0,n.jsx)(mPt,{className:"size-4"}),children:["Tap ",(0,n.jsx)("strong",{children:"Share"})," in the Safari toolbar."]}),(0,n.jsxs)(rte,{index:2,icon:(0,n.jsx)(gPt,{className:"size-4"}),children:["Choose ",(0,n.jsx)("strong",{children:"Add to Home Screen"}),"."]}),(0,n.jsxs)(rte,{index:3,children:["Keep ",(0,n.jsx)("strong",{children:"Open as Web App"})," on, then tap ",(0,n.jsx)("strong",{children:"Add"}),"."]})]}),(0,n.jsx)(fr,{children:(0,n.jsx)($,{type:"button",onClick:i(()=>UK(!1),"onClick"),children:"Done"})})]})})}i(p2n,"IosInstallHelpDialog");function rte({index:e,icon:t,children:s}){return(0,n.jsxs)("li",{className:"flex items-start gap-3",children:[(0,n.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full border border-line text-xs font-semibold text-ink-3",children:e}),(0,n.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t?(0,n.jsx)("span",{className:"text-ink-3",children:t}):null,(0,n.jsx)("span",{children:s})]})]})}i(rte,"InstallStep");function f2n(e){if(!e)return"Unavailable";const t=new Date(e);return Number.isNaN(t.getTime())?"Unavailable":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(t)}i(f2n,"formatTimestamp$2");function g2n(e){return!!e&&!Number.isNaN(new Date(e).getTime())}i(g2n,"isValidTimestamp");function x2n(e){return e?.devServer?.lastRestartAt??e?.serverInfo?.processStartedAt??null}i(x2n,"restartTimestamp");function v2n(e){const t=e?.serverInfo?.git;return t?.available?`${t.shortSha} · ${t.subject}`:"Commit unavailable"}i(v2n,"commitLabel");function b2n(e){const t=e?.serverInfo?.git;if(!t?.available)return"Unavailable";const s=t.localChanges;if(!s||!s.available)return"Change status unavailable";if(!s.hasLocalChanges)return"Clean checkout";const r=[[s.stagedFileCount,"staged"],[s.unstagedFileCount,"unstaged"],[s.untrackedFileCount,"untracked"]].filter(([a])=>Number(a)>0).map(([a,o])=>`${a} ${o}`);return r.length>0?`Local changes present (${r.join(", ")})`:"Local changes present"}i(b2n,"localChangesLabel");function ite({icon:e,label:t,value:s,dateTime:r}){return(0,n.jsxs)("div",{className:"flex w-full items-start gap-3 rounded-xl px-3 py-3 text-left",children:[(0,n.jsx)("span",{className:"mt-0.5 rounded-lg border border-line bg-bg/70 p-2 text-ink-3",children:(0,n.jsx)(e,{className:"size-4"})}),(0,n.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"block text-sm font-medium text-ink",children:t}),r?(0,n.jsx)("time",{dateTime:r,className:"block break-words text-xs text-ink-3",children:s}):(0,n.jsx)("span",{className:"block break-words text-xs text-ink-3",children:s})]})]})}i(ite,"ServerInfoRow");function y2n(){const e=ie({queryKey:O.instance.experimentalSettings,queryFn:i(()=>Fr.getExperimental(),"queryFn")}).data?.enableServerInfoDebugView===!0,t=ie({queryKey:O.health,queryFn:i(()=>Op.get(),"queryFn"),enabled:e,refetchOnMount:"always",refetchInterval:i(h=>h.state.data?.devServer?.enabled?2e3:!1,"refetchInterval")});if(!e)return null;const s=t.data,r=t.isLoading&&!s,a=t.isError,o=x2n(s),l=g2n(o),c=a?"Health unavailable":r?"Loading...":f2n(o),d=a?"Health unavailable":r?"Loading...":v2n(s),u=a?"Health unavailable":r?"Loading...":b2n(s);return(0,n.jsxs)("div",{className:"mt-2 border-t border-line pt-2",children:[(0,n.jsx)("p",{className:"px-3 pb-1 pt-1 text-(length:--text-micro) font-medium uppercase tracking-wide text-ink-3",children:"Server"}),(0,n.jsx)(ite,{icon:E0,label:"Last restarted",value:c,dateTime:!a&&!r&&l?o:null}),(0,n.jsx)(ite,{icon:A0e,label:"Running commit",value:d}),(0,n.jsx)(ite,{icon:D7t,label:"Checkout state",value:u})]})}i(y2n,"SidebarServerInfo");var k2n="/company/settings/members?tab=invites",w2n="https://docs.paperclip.ing/",j2n="https://paperclip.ing/feedback";function N2n(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length>=2?`${t[0]?.[0]??""}${t[t.length-1]?.[0]??""}`.toUpperCase():e.slice(0,2).toUpperCase()}i(N2n,"deriveInitials$1");function ate({label:e,icon:t,onClick:s,href:r,external:a=!1,topLevel:o=!1}){const l="flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-ink transition-colors hover:bg-bg-3",c=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-ink-3",children:(0,n.jsx)(t,{className:"size-4"})}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e})]});return r?a?(0,n.jsx)("a",{href:r,target:"_blank",rel:"noreferrer",className:l,onClick:s,children:c}):o?(0,n.jsx)("a",{href:r,className:l,onClick:s,children:c}):(0,n.jsx)(Ye,{to:r,className:l,onClick:s,children:c}):(0,n.jsx)("button",{type:"button",className:l,onClick:s,children:c})}i(ate,"MenuAction");function W6e({deploymentMode:e,open:t,onOpenChange:s,forceExpanded:r=!1}){const o=!!im(),{hidden:l,loaded:c}=V0(),d=U_n(),u=W_n(!o),h=o?d:u?k2n:null,p=c&&h!==null&&!pM(l,"company.members")&&!pM(l,"company.invites"),[f,g]=(0,m.useState)(!1),{isMobile:x,setSidebarOpen:v,collapsed:b,peeking:y}=Io(),k=b&&!y&&!r,j=t??f,N=Q_n(j),S=s??g,{data:A}=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),retry:!1}),I=LV({onSignedOut:P}),_=A?.user.name?.trim()||"Board",T=A?.user.email?.trim()||(e==="authenticated"?"Signed in":"Local workspace board"),E=N2n(_),M=H_n(A?.user);function P(){S(!1),x&&v(!1)}i(P,"closeNavigationChrome");function D(){I.mutate()}return i(D,"handleSignOut"),(0,n.jsx)("div",{className:"bg-line/50 px-3 py-2 dark:bg-bg-3",children:(0,n.jsxs)("div",{className:Q("flex items-center gap-0.5",!k&&"px-2"),children:[(0,n.jsxs)(cr,{open:j,onOpenChange:S,children:[(0,n.jsx)(gr,{asChild:!0,children:(0,n.jsxs)("button",{type:"button",className:Q("flex min-w-0 items-center gap-2.5 rounded-lg text-left text-(length:--text-compact) font-medium text-ink/80 transition-colors hover:bg-bg-3 hover:text-ink",k?"w-full px-3 py-2":"flex-1 px-2 py-1.5"),"aria-label":"Open account menu",children:[(0,n.jsxs)(yl,{size:"sm",children:[A?.user.image?(0,n.jsx)(th,{src:A.user.image,alt:_}):null,(0,n.jsx)(kl,{children:E})]}),(0,n.jsx)("span",{className:Q("min-w-0 flex-1 truncate",k&&"block w-0 min-w-0 -ms-2.5 overflow-hidden whitespace-nowrap text-transparent select-none"),children:_})]})}),(0,n.jsxs)(Vs,{side:"top",align:"start",sideOffset:10,className:"min-h-(--profile-popover-min-height) w-(--profile-popover-width) max-w-(--sz-calc-24) overflow-hidden rounded-xl border-line bg-bg-2 p-0 shadow-(--shadow-profile-popover)",children:[(0,n.jsxs)("div",{className:"relative flex h-(--profile-popover-header-height) shrink-0 items-center gap-2.5 px-3.5",children:[(0,n.jsx)(Ye,{to:M,"aria-label":"View profile",onClick:P,className:"absolute inset-0 transition-colors hover:bg-bg-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus"}),(0,n.jsxs)(yl,{className:"pointer-events-none relative size-9",children:[A?.user.image?(0,n.jsx)(th,{src:A.user.image,alt:_}):null,(0,n.jsx)(kl,{className:"text-xs text-ink",children:E})]}),(0,n.jsxs)("div",{className:"pointer-events-none relative min-w-0 flex-1",children:[(0,n.jsx)("h2",{className:"truncate text-sm font-semibold leading-(--profile-popover-label-line-height) text-ink",children:_}),(0,n.jsx)("p",{className:"truncate text-(length:--text-micro) leading-(--profile-popover-meta-line-height) text-ink-3",children:T}),N?(0,n.jsxs)("a",{className:"pointer-events-auto block truncate font-mono text-(length:--text-micro) leading-(--profile-popover-meta-line-height) text-ink-3 hover:underline focus-visible:underline",href:`https://github.com/paperclipai/paperclip/commit/${N}`,target:"_blank",rel:"noreferrer","aria-label":`View commit ${N} on GitHub`,title:N,children:["SHA ",N.slice(0,7)]}):null]})]}),(0,n.jsxs)("div",{className:"flex flex-1 flex-col gap-0.5 border-t border-line px-2.5 pb-2.5 pt-2",children:[(0,n.jsx)(ate,{label:"Settings",icon:M0,href:"/company/settings",onClick:P}),p&&h?(0,n.jsx)(ate,{label:"Invite",icon:Sb,href:h,topLevel:o,onClick:P}):null,(0,n.jsx)(ate,{label:"Documentation",icon:yD,href:w2n,external:!0,onClick:i(()=>S(!1),"onClick")}),(0,n.jsx)(q6,{variant:"compact-menu-action",onAfterToggle:i(()=>S(!1),"onAfterToggle")}),(0,n.jsx)(m2n,{variant:"compact-menu-action",onAfterAction:i(()=>S(!1),"onAfterAction")}),e==="authenticated"?(0,n.jsxs)("button",{type:"button",className:Q("flex h-(--profile-popover-row-height) w-full items-center gap-(--profile-popover-row-gap) rounded-lg px-2.5 text-left text-(length:--text-compact) font-medium leading-(--profile-popover-label-line-height) text-ink transition-colors hover:bg-bad/10",I.isPending&&"cursor-not-allowed opacity-60"),onClick:D,disabled:I.isPending,children:[(0,n.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center text-ink-3",children:(0,n.jsx)(lT,{className:"size-4"})}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate",children:I.isPending?"Signing out...":"Sign out"})]}):null,(0,n.jsx)(y2n,{})]})]})]}),!k&&!o?(0,n.jsxs)(Zs,{children:[(0,n.jsx)(Xs,{asChild:!0,children:(0,n.jsx)("a",{href:j2n,target:"_blank",rel:"noreferrer","aria-label":"Share feedback",className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-3/50 transition-colors hover:bg-bg-3 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus",children:(0,n.jsx)(Cb,{className:"h-4 w-4","aria-hidden":"true"})})}),(0,n.jsx)(er,{side:"top",children:"Share feedback"})]}):null]})})}i(W6e,"SidebarAccountMenu");var C2n=["input","textarea","select","[contenteditable='true']","[contenteditable='plaintext-only']","[role='textbox']","[role='combobox']"].join(", "),S2n="[data-page-search-target='true']",_2n=new Set(["Shift","Meta","Control","Alt"]);function ow(e){return e instanceof HTMLElement?e.isContentEditable?!0:!!e.closest(C2n):!1}i(ow,"isKeyboardShortcutTextInputTarget");function pb(e=document){return!!e.querySelector("[role='dialog'][aria-modal='true']")}i(pb,"hasBlockingShortcutDialog");function A2n(e){if(!e.isConnected||"disabled"in e&&typeof e.disabled=="boolean"&&e.disabled||e.closest("[hidden], [aria-hidden='true'], [inert]")||e.closest("[role='dialog'][aria-modal='true']"))return!1;const t=window.getComputedStyle(e);return t.display==="none"||t.visibility==="hidden"?!1:e.getClientRects().length>0||e===document.activeElement}i(A2n,"isVisibleShortcutTarget");function I2n(e=document){return Array.from(e.querySelectorAll(S2n)).find(t=>A2n(t))??null}i(I2n,"findPageSearchShortcutTarget");function T2n(e=document){const t=I2n(e);return t?(t.focus(),(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&t.select(),!0):!1}i(T2n,"focusPageSearchShortcutTarget");function ngt({key:e,isComposing:t}){return e==="Enter"&&!t}i(ngt,"shouldBlurPageSearchOnEnter");function sgt({key:e,isComposing:t,currentValue:s}){return e==="Escape"&&!t&&s.length===0}i(sgt,"shouldBlurPageSearchOnEscape");function xG(e){return _2n.has(e)}i(xG,"isModifierOnlyKey");function E2n({defaultPrevented:e,key:t,metaKey:s,ctrlKey:r,altKey:a,target:o,hasOpenDialog:l,hasSelection:c}){if(e||s||r||a||xG(t)||l||ow(o))return"ignore";switch(t){case"j":case"ArrowDown":return"next";case"k":case"ArrowUp":return"previous";case"Enter":return c?"toggle":"ignore";case"x":return c?"dismiss":"ignore";default:return"ignore"}}i(E2n,"resolveAttentionQueueKeyAction");function R2n({armed:e,defaultPrevented:t,key:s,metaKey:r,ctrlKey:a,altKey:o,target:l,hasOpenDialog:c}){return!e||t||r||a||o||xG(s)||c||ow(l)?"ignore":s.toLowerCase()==="y"?"archive":"ignore"}i(R2n,"resolveInboxQuickArchiveKeyAction");function M2n({hasUndoableArchive:e,defaultPrevented:t,key:s,metaKey:r,ctrlKey:a,altKey:o,target:l,hasOpenDialog:c}){return!e||t||r||a||o||xG(s)||c||ow(l)?"ignore":s==="u"?"undo_archive":"ignore"}i(M2n,"resolveInboxUndoArchiveKeyAction");function rgt({armed:e,defaultPrevented:t,key:s,metaKey:r,ctrlKey:a,altKey:o,target:l,hasOpenDialog:c}){if(t)return e?"disarm":"ignore";if(r||a||o||xG(s))return"ignore";if(c||ow(l))return e?"disarm":"ignore";const d=s.toLowerCase();return e?d==="i"?"navigate_inbox":d==="c"?"focus_comment":d==="f"?"open_file_viewer":d==="g"?"arm":"disarm":d==="g"?"arm":"ignore"}i(rgt,"resolveIssueDetailGoKeyAction");function L2n({onNewIssue:e,onSearch:t,onToggleSidebar:s,onTogglePanel:r,onShowShortcuts:a,onGoToInbox:o}){(0,m.useEffect)(()=>{let l=!1,c=null;const d=i(()=>{c!==null&&(window.clearTimeout(c),c=null)},"clearGoChordTimeout"),u=i(()=>{l=!1,d()},"disarmGoChord"),h=i(()=>{l=!0,d(),c=window.setTimeout(()=>{l=!1,c=null},1200)},"armGoChord");function p(x){if(x.defaultPrevented){u();return}if(o){const v=rgt({armed:l,defaultPrevented:x.defaultPrevented,key:x.key,metaKey:x.metaKey,ctrlKey:x.ctrlKey,altKey:x.altKey,target:x.target,hasOpenDialog:pb()});if(v==="arm"){h();return}if(v==="navigate_inbox"){u(),x.preventDefault(),o();return}if(v==="focus_comment"||v==="open_file_viewer"){u(),x.preventDefault();return}v==="disarm"&&u()}if(!ow(x.target)&&!pb()){if(x.key==="/"&&!x.metaKey&&!x.ctrlKey&&!x.altKey){x.preventDefault(),T2n()||t?.();return}if(x.key==="?"&&!x.metaKey&&!x.ctrlKey&&!x.altKey){x.preventDefault(),a?.();return}x.key==="c"&&!x.metaKey&&!x.ctrlKey&&!x.altKey&&(x.preventDefault(),e?.()),x.key==="["&&!x.metaKey&&!x.ctrlKey&&(x.preventDefault(),s?.()),x.key==="]"&&!x.metaKey&&!x.ctrlKey&&(x.preventDefault(),r?.())}}i(p,"handleKeyDown");const f=i(()=>u(),"handlePointerDown"),g=i(x=>{x.target instanceof HTMLElement&&x.target!==document.body&&u()},"handleFocusIn");return document.addEventListener("pointerdown",f,!0),document.addEventListener("focusin",g,!0),document.addEventListener("keydown",p),()=>{u(),document.removeEventListener("pointerdown",f,!0),document.removeEventListener("focusin",g,!0),document.removeEventListener("keydown",p)}},[e,t,s,r,a,o])}i(L2n,"useKeyboardShortcuts");var D2n=new Set(["auth","invite","board-claim","cli-auth","docs","s"]);function igt(e){const t=(e.split("?")[0]??"").split("/").filter(Boolean);if(t.length===0)return!0;const[s]=t;return!D2n.has(s)}i(igt,"isRememberableCompanyPath");function P2n(e){const t=E3(e.companyPrefix);return e.companies.find(s=>E3(s.issuePrefix)===t)??null}i(P2n,"findCompanyByPrefix");function $2n(e){const t=Fpe(e.pathname);return t?P2n({companies:e.companies,companyPrefix:t})?.id??null:e.fallbackCompanyId}i($2n,"getRememberedPathOwnerCompanyId");function O2n(e){const t=e.path?BQ(e.path):"/dashboard";if(!igt(t))return"/dashboard";const[s,r]=(t.split("?")[0]??"").split("/").filter(Boolean);if(s==="issues"&&r){const a=/^([A-Za-z]+)-\d+$/.exec(r);if(a&&E3(a[1]??"")!==E3(e.companyPrefix))return"/dashboard"}return t}i(O2n,"sanitizeRememberedPathForCompany");var agt="paperclip.companyPaths";function ogt(){try{const e=localStorage.getItem(agt);if(e)return JSON.parse(e)}catch{}return{}}i(ogt,"getCompanyPaths");function F2n(e,t){const s=ogt();s[e]=t,localStorage.setItem(agt,JSON.stringify(s))}i(F2n,"saveCompanyPath");function B2n(){const{companies:e,selectedCompanyId:t,selectedCompany:s,selectionSource:r}=gn(),a=Ri(),o=ir(),l=(0,m.useRef)(t),c=(0,m.useMemo)(()=>$2n({companies:e,pathname:a.pathname,fallbackCompanyId:l.current}),[e,a.pathname]),d=a.pathname+a.search;(0,m.useEffect)(()=>{const u=c,h=BQ(d);u&&igt(h)&&F2n(u,h)},[d,c]),(0,m.useEffect)(()=>{if(t){if(l.current!==null&&t!==l.current&&r!=="route_sync"&&s){const u=ogt(),h=O2n({path:u[t],companyPrefix:s.issuePrefix});o(`/${s.issuePrefix}${h}`,{replace:!0})}l.current=t}},[s,t,r,o])}i(B2n,"useCompanyPageMemory");var z2n=class{static{i(this,"MobileNavScrollTracker")}options;lastTop;lastMaxTop;visible=!0;direction=0;distance=0;constructor(e,t,s){this.options=e,this.lastTop=t,this.lastMaxTop=s}update(e,t){const s=Math.max(0,Math.min(e,t)),r=s-Math.max(this.lastTop,this.options.topZone),a=t!==this.lastMaxTop;if(this.lastTop=s,this.lastMaxTop=t,s<=this.options.topZone)this.visible=!0,this.direction=0,this.distance=0;else if(a)this.direction=0,this.distance=0;else if(r!==0){const o=Math.sign(r);o!==this.direction&&(this.distance=0),this.direction=o,this.distance+=Math.abs(r);const l=o>0?this.options.hideDistance:this.options.showDistance;this.distance>=l&&(this.visible=o<0,this.distance=0)}return this.visible}};function q2n(e,t){const[s,r]=(0,m.useState)(!0);return(0,m.useEffect)(()=>{if(r(!0),!e)return;const a=getComputedStyle(document.documentElement),o=i(p=>Number.parseFloat(a.getPropertyValue(p))||0,"distance"),l=i(()=>{const p=document.scrollingElement??document.documentElement;return{top:window.scrollY||p.scrollTop||0,max:Math.max(0,p.scrollHeight-p.clientHeight)}},"scrollBounds"),c=l(),d=new z2n({topZone:o("--mobile-nav-scroll-top-zone"),hideDistance:o("--mobile-nav-scroll-hide-distance"),showDistance:o("--mobile-nav-scroll-show-distance")},c.top,c.max);let u=null;const h=i(()=>{u===null&&(u=requestAnimationFrame(()=>{u=null;const{top:p,max:f}=l(),g=d.visible,x=d.update(p,f);x!==g&&r(x)}))},"onScroll");return window.addEventListener("scroll",h,{passive:!0}),()=>{window.removeEventListener("scroll",h),u!==null&&cancelAnimationFrame(u)}},[e,t]),s}i(q2n,"useMobileNavVisibility");function U2n(e){const{matchedCompany:t,selectedCompanyId:s,companies:r}=e;return!t||t.status!=="archived"||s===t.id?null:r.find(a=>a.id===s&&a.status!=="archived")??r.find(a=>a.status!=="archived")??null}i(U2n,"resolveArchivedCompanyBounce");function K2n(e){const{archivedCompanyId:t,companies:s,cloudPortfolioUrl:r}=e,a=s.find(o=>o.id!==t&&o.status!=="archived");return a?{kind:"company",company:a}:r?{kind:"cloud_portfolio",url:r}:{kind:"companies_list"}}i(K2n,"resolveCompanyArchiveDeparture");function W2n(e){const{selectionSource:t,selectedCompanyId:s,routeCompanyId:r}=e;return!(s===r||t==="manual"&&s)}i(W2n,"shouldSyncCompanySelectionFromRoute");function Q2n(e,t){return e instanceof HTMLElement?!(t instanceof HTMLElement)||!document.contains(t)||t===document.body||t===document.documentElement?!0:!e.contains(t):!1}i(Q2n,"shouldFocusMainContentAfterNavigation");function V2n(e){if(!(e instanceof HTMLElement))return()=>{};const t=window.requestAnimationFrame(()=>{Q2n(e,document.activeElement)&&e.focus({preventScroll:!0})});return()=>window.cancelAnimationFrame(t)}i(V2n,"scheduleMainContentFocus");function H2n(e=document,t=window){const s=i(()=>{e.documentElement.scrollTop!==0&&(e.documentElement.scrollTop=0),e.body.scrollTop!==0&&(e.body.scrollTop=0)},"onScroll");return t.addEventListener("scroll",s,{capture:!0}),()=>t.removeEventListener("scroll",s,{capture:!0})}i(H2n,"pinDocumentScrollToZero");function A0({scope:e="global",requestedPrefix:t}){const s=Ri(),{setBreadcrumbs:r}=Hs(),{companies:a,selectedCompany:o}=gn();(0,m.useEffect)(()=>{r([{label:"Not Found"}])},[r]);const l=o??a[0]??null,c=l?`/${l.issuePrefix}/dashboard`:"/",d=`${s.pathname}${s.search}${s.hash}`,u=t?.toUpperCase(),h=e==="invalid_company_prefix"?"Organization not found":"Page not found",p=e==="invalid_company_prefix"?`No organization matches prefix "${u??"unknown"}".`:"This route does not exist.";return(0,n.jsx)("div",{className:"mx-auto max-w-2xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("div",{className:"rounded-md border border-bad/20 bg-bad/10 p-2",children:(0,n.jsx)(En,{className:"h-5 w-5 text-bad"})}),(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"text-xl font-semibold",children:h}),(0,n.jsx)("p",{className:"text-sm text-ink-3",children:p})]})]}),(0,n.jsxs)("div",{className:"mt-4 rounded-md border border-line bg-bg-3/20 px-3 py-2 text-xs text-ink-3",children:["Requested path: ",(0,n.jsx)("code",{className:"font-mono",children:d})]}),(0,n.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,n.jsx)($,{asChild:!0,children:(0,n.jsxs)(Ye,{to:c,children:[(0,n.jsx)(dq,{className:"mr-1.5 h-4 w-4"}),"Open dashboard"]})}),(0,n.jsx)($,{variant:"secondary",asChild:!0,children:(0,n.jsx)(Ye,{to:"/",children:"Go home"})})]})]})})}i(A0,"NotFoundPage");function G2n(e,t){return RXe(e,t)[0]?.toLowerCase()??null}i(G2n,"getCompanyRouteSegment");var Y2n=new Set(["browse","connections","assistant-connection","connect","chat","vercel-connect","review","attention","gateways","advanced","app"]);function J2n({sidebarSections:e}){const{sidebarOpen:t,setSidebarOpen:s,toggleSidebar:r,collapsed:a,peeking:o,setPeeking:l,isMobile:c,isTablet:d}=Io(),{openNewIssue:u,openOnboarding:h}=Oc(),{togglePanelVisible:p}=Hk(),f=Eh()?.pushToast??null,{companies:g,loading:x,selectedCompany:v,selectedCompanyId:b,selectionSource:y,setSelectedCompanyId:k}=gn(),{companyPrefix:j,pluginRoutePath:N,agentId:S,routineId:A}=Mi(),I=ir(),_=Ri(),T=$pe(),E=yUt(_.pathname,j),M=E.builtInContextualSurface==="settings",P=E.companySegments,D=E.isTaskDetail,{enabled:K}=MS(),L=K&&P[0]?.toLowerCase()==="chats",B=D||L,z=P[0]?.toLowerCase()==="tools",U=P[0]?.toLowerCase()==="apps",W=U&&P[1]&&!Y2n.has(P[1].toLowerCase())?P[1]:null,F=U&&P[1]?.toLowerCase()==="app"&&P[2]?P[2]:null,Y=(0,m.useRef)(!1),V=(0,m.useRef)(null),G=(0,m.useRef)(null),ne=(0,m.useRef)(new aOt),Z=(0,m.useRef)(_.key),J=q2n(c&&!D,_.pathname),[se,H]=(0,m.useState)(!1),ee=(0,m.useMemo)(()=>{if(!j)return null;const yt=j.toUpperCase();return g.find(ze=>ze.issuePrefix.toUpperCase()===yt)??null},[g,j]),te=!!j&&!x&&g.length>0&&!ee,oe=(0,m.useMemo)(()=>N?.toLowerCase()??G2n(_.pathname,j),[j,_.pathname,N]),ae=ee?.id??null,ge=ee?.issuePrefix??null,{slots:xe}=Q0({slotTypes:["page","routeSidebar"],companyId:ae,enabled:!!(ae&&oe)}),ce=(0,m.useMemo)(()=>QZe(xe,oe),[oe,xe]),de=(0,m.useMemo)(()=>({companyId:ae,companyPrefix:ge}),[ae,ge]),be=M?(0,n.jsx)(NUt,{}):W?(0,n.jsx)(__e,{kind:"connection",connectionId:W}):F?(0,n.jsx)(__e,{kind:"application",applicationId:F}):U||z?(0,n.jsx)($Ut,{}):ce?(0,n.jsx)(WD,{surface:`plugin:${ce.id}`,title:ce.displayName,children:(0,n.jsx)(jx,{slot:ce,context:de,className:"min-h-0 flex-1",missingBehavior:"placeholder"})}):null,me=L?(0,n.jsx)(F_n,{}):E.builtInContextualSurface==="agent"&&S?(0,n.jsx)(JUt,{agentRef:S}):E.builtInContextualSurface==="routine"&&A?(0,n.jsx)(sOt,{children:(0,n.jsx)(eKt,{routineId:A})}):E.builtInContextualSurface==="skills"?(0,n.jsx)(sKt,{}):be,we=me!=null,ue=we&&(L||E.builtInContextualSurface==="skills"||E.builtInContextualSurface==="agent"||E.builtInContextualSurface==="routine"||U||z),pe=M&&(c||d),Se=we&&!ue&&!(d&&M),De=ue,Te=we?ce&&!E.builtInContextualSurface?`plugin:${ce.id}`:E.builtInContextualSurface:null,st=(0,m.useRef)(null),{data:fe}=ie({queryKey:O.health,queryFn:i(()=>Op.get(),"queryFn"),retry:!1,refetchInterval:i(yt=>yt.state.data?.devServer?.enabled?2e3:!1,"refetchInterval"),refetchIntervalInBackground:!1});(0,m.useEffect)(()=>{const yt=st.current;Te&&j&&yt&&yt.surface!==Te&&yt.pathname!==_.pathname&&kUt({surface:Te,companyPrefix:j,previousPathname:yt.pathname}),st.current={pathname:_.pathname,surface:Te}},[j,Te,_.pathname]),(0,m.useEffect)(()=>{x||Y.current||fe?.deploymentMode!=="authenticated"&&(fe?.cloud||g.length===0&&(Y.current=!0,h()))},[g,x,h,fe?.cloud,fe?.deploymentMode]),(0,m.useEffect)(()=>{if(!j||x||g.length===0)return;if(!ee){const ze=(b?g.find(Ve=>Ve.id===b):null)??g[0]??null;ze&&b!==ze.id&&k(ze.id,{source:"route_sync"});return}if(j!==ee.issuePrefix){const ze=_.pathname.replace(/^\/[^/]+/,"");I(`/${ee.issuePrefix}${ze}${_.search}`,{replace:!0});return}const yt=U2n({matchedCompany:ee,selectedCompanyId:b,companies:g});if(yt){f?.({title:`${ee.name} is archived`,body:`Switched to ${yt.name}.`,tone:"info",dedupeKey:`archived-company-bounce:${ee.id}`}),k(yt.id,{source:"route_sync"}),I(`/${yt.issuePrefix}/dashboard`,{replace:!0});return}W2n({selectionSource:y,selectedCompanyId:b,routeCompanyId:ee.id})&&k(ee.id,{source:"route_sync"})},[j,g,x,ee,_.pathname,_.search,I,f,y,b,k]);const Be=p,ke=(0,m.useCallback)(()=>{document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0,cancelable:!0}))},[]),$t=(0,m.useRef)(null),Ie=(0,m.useRef)(!1),Re=(0,m.useRef)(!1),Je=(0,m.useCallback)(()=>{$t.current!==null&&(window.clearTimeout($t.current),$t.current=null)},[]),je=(0,m.useCallback)(()=>{Je(),$t.current=window.setTimeout(()=>l(!0),50)},[Je,l]),Fe=(0,m.useCallback)(()=>{Je(),l(!0)},[Je,l]),Ue=(0,m.useCallback)(()=>{Je(),$t.current=window.setTimeout(()=>l(!1),120)},[Je,l]),qe=(0,m.useCallback)(()=>{Ie.current=!0,a&&!Re.current&&je()},[a,je]),Ne=(0,m.useCallback)(()=>{Ie.current=!1,Re.current=!1,Ue()},[Ue]),Le=(0,m.useCallback)(()=>{Re.current||Fe()},[Fe]),et=(0,m.useCallback)(()=>{Ie.current||Ue()},[Ue]);(0,m.useEffect)(()=>Je,[Je]);const at=(0,m.useRef)(a);return(0,m.useEffect)(()=>{a!==at.current&&(a?(Je(),l(!1),Re.current=Ie.current):Re.current=!1,at.current=a)},[a,Je,l]),(0,m.useEffect)(()=>{if(!o)return;const yt=i(ze=>{ze.key==="Escape"&&(Je(),l(!1))},"onKeyDown");return window.addEventListener("keydown",yt),()=>window.removeEventListener("keydown",yt)},[o,Je,l]),B2n(),L2n({onNewIssue:i(()=>u(),"onNewIssue"),onSearch:ke,onToggleSidebar:r,onTogglePanel:Be,onShowShortcuts:i(()=>H(!0),"onShowShortcuts"),onGoToInbox:i(()=>I("/inbox"),"onGoToInbox")}),(0,m.useEffect)(()=>{if(!c)return;const yt=30,ze=50,Ve=75;let dt=0,Ee=0;const it=i(Ke=>{const Rt=Ke.touches[0];dt=Rt.clientX,Ee=Rt.clientY},"onTouchStart"),he=i(Ke=>{const Rt=Ke.changedTouches[0],ht=Rt.clientX-dt;if(!(Math.abs(Rt.clientY-Ee)>Ve)){if(!t&&dt<yt&&ht>ze){s(!0);return}t&&ht<-50&&s(!1)}},"onTouchEnd");return document.addEventListener("touchstart",it,{passive:!0}),document.addEventListener("touchend",he,{passive:!0}),()=>{document.removeEventListener("touchstart",it),document.removeEventListener("touchend",he)}},[c,t,s]),(0,m.useEffect)(()=>{const yt=document.body.style.overflow;return document.body.style.overflow=c?"visible":"clip",()=>{document.body.style.overflow=yt}},[c]),(0,m.useEffect)(()=>{if(!c)return H2n()},[c]),(0,m.useEffect)(()=>{if(typeof document>"u")return;const yt=G.current;return V2n(yt)},[_.pathname]),(0,m.useEffect)(()=>{const yt=G.current;if(!yt)return;const ze=i(()=>{ne.current.remember(Z.current,yt.scrollTop)},"recordScroll");return yt.addEventListener("scroll",ze,{passive:!0}),()=>yt.removeEventListener("scroll",ze)},[]),(0,m.useLayoutEffect)(()=>{const yt=G.current,ze=iOt({previousPathname:V.current,pathname:_.pathname,navigationType:T,state:_.state});V.current=_.pathname;const Ve=T==="POP",dt=Ve?ne.current.recall(_.key):0;if(Z.current=_.key,Ve){ESe(yt,dt);const Ee=requestAnimationFrame(()=>ESe(yt,dt));return()=>cancelAnimationFrame(Ee)}ze&&oOt(yt)},[_.key,_.pathname,_.state,T]),(0,n.jsx)(tOt,{children:(0,n.jsxs)("div",{"data-app-shell":"",className:Q("bg-bg text-ink pt-(--sz-safe-top)",c?"min-h-dvh overflow-x-clip":"flex h-dvh flex-col overflow-clip"),children:[(0,n.jsx)("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:fixed focus:left-3 focus:top-3 focus:z-(--z-200) focus:rounded-md focus:bg-bg focus:px-3 focus:py-2 focus:text-sm focus:font-medium focus:shadow-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-focus",children:"Skip to Main Content"}),(0,n.jsx)(S_n,{}),(0,n.jsx)(d_n,{}),(0,n.jsx)(p_n,{devServer:fe?.devServer}),(0,n.jsx)(y_n,{}),(0,n.jsxs)("div",{className:Q("min-h-0 flex-1",c?"w-full":"flex overflow-clip"),children:[c&&t&&(0,n.jsx)("button",{type:"button",className:"fixed inset-0 z-40 bg-black/50",onClick:i(()=>s(!1),"onClick"),"aria-label":"Close sidebar"}),c?(0,n.jsxs)("div",{className:Q("fixed inset-y-0 left-0 z-50 flex flex-col overflow-hidden pt-(--sz-safe-top) transition-transform duration-100 ease-out",t?"translate-x-0":"-translate-x-full"),children:[(0,n.jsx)("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:(0,n.jsx)("div",{className:"w-60 shrink-0 overflow-hidden",children:we?(0,n.jsx)(R$,{children:me}):(0,n.jsx)(j_e,{children:e})})}),(0,n.jsx)(W6e,{deploymentMode:fe?.deploymentMode,forceExpanded:Se})]}):(0,n.jsxs)(B_n,{open:t,collapsed:Se?!1:a,peeking:Se?!1:o,resizable:!0,onPanelMouseEnter:Se?void 0:qe,onPanelMouseLeave:Se?void 0:Ne,onPanelFocusCapture:!Se&&a?Le:void 0,onPanelBlurCapture:!Se&&a?et:void 0,children:[(0,n.jsx)("div",{className:"flex flex-1 min-h-0",children:Se?(0,n.jsx)(R$,{children:me}):(0,n.jsx)(j_e,{children:e})}),(0,n.jsx)(W6e,{deploymentMode:fe?.deploymentMode,forceExpanded:Se})]}),!c&&De&&!ue?(0,n.jsx)(R$,{className:"w-60 shrink-0",children:me}):null,(0,n.jsxs)("div",{className:Q("flex min-w-0 flex-col",c?"w-full":"h-full flex-1"),children:[(0,n.jsxs)("div",{"data-slot":c?"mobile-topbar":void 0,className:Q(!c&&B&&"hidden",c&&"sticky top-0 z-20 bg-bg/95 backdrop-blur supports-[backdrop-filter]:bg-bg/85"),children:[(0,n.jsx)($6e,{mobile:c,onNavigateHome:i(()=>I("/dashboard"),"onNavigateHome")}),(0,n.jsx)(T_e,{}),pe?(0,n.jsx)("div",{className:"border-b border-line px-4 pb-3",children:(0,n.jsx)(IUt,{})}):null]}),(0,n.jsxs)("div",{className:Q(c?"block":"relative flex flex-1 min-h-0",!c&&B&&"streamlined-task-detail-surface"),children:[!c&&ue?(0,n.jsx)(R$,{className:"w-60 shrink-0 bg-bg",children:me}):null,(0,n.jsxs)("div",{className:Q(!c&&B?"flex min-w-0 flex-1 flex-col":"contents"),children:[!c&&B?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)($6e,{mobile:!1,onNavigateHome:i(()=>I("/dashboard"),"onNavigateHome")}),(0,n.jsx)(T_e,{taskDetailLayout:!0})]}):null,(0,n.jsx)("main",{id:"main-content",ref:G,tabIndex:-1,style:c?{"--tc-composer-bottom":"var(--sz-calc-14)"}:void 0,className:Q("flex-1 p-4 outline-none md:p-6",!c&&B&&"pt-0 md:pt-0",c?"overflow-visible pb-(--sz-calc-14)":"overflow-auto [scrollbar-gutter:stable]"),children:te?(0,n.jsx)(A0,{scope:"invalid_company_prefix",requestedPrefix:j??v?.issuePrefix}):(0,n.jsx)(D_n,{children:(0,n.jsx)(CS,{})})})]}),(0,n.jsx)(UWt,{taskDetailLayout:!c&&B})]})]})]}),c&&(0,n.jsx)(r_n,{visible:J}),(0,n.jsx)(EQt,{}),(0,n.jsx)(bxn,{}),(0,n.jsx)(CSn,{}),(0,n.jsx)(ASn,{}),(0,n.jsx)(DSn,{}),(0,n.jsx)(FSn,{open:se,onOpenChange:H}),(0,n.jsx)(USn,{}),(0,n.jsx)(JSn,{health:fe}),(0,n.jsx)(s_n,{localTrusted:fe?.deploymentMode==="local_trusted"})]})})}i(J2n,"Layout");var Q6e=null;function Z2n(){return Q6e??=new dD,Q6e}i(Z2n,"getDetachedClient");function X2n(){const e=(0,m.useContext)(H8),{data:t,isFetched:s}=ie({queryKey:O.instance.experimentalSettings,queryFn:i(()=>Fr.getExperimental(),"queryFn"),enabled:e!=null},e??Z2n());return e?{enabled:t?.enableConferenceRoomChat===!0,loaded:s}:{enabled:!1,loaded:!0}}i(X2n,"useConferenceRoomChatEnabled");function e5n(){const{enabled:e,loaded:t}=X2n();return t?e?(0,n.jsx)(CS,{}):(0,n.jsx)(Ss,{to:"/dashboard",replace:!0}):null}i(e5n,"ConferenceRoomChatGate");var t5n=["session-start","human-message","agent-message","thinking","responding","responding-burst","tool-call","diff","working","running","completed","activity-phases","awaiting-approval","plan-todo","interrupted","refused","truncated","live-token-cost"],n5n={"session-start":{id:"session-start",label:"Session start",tier:"live",surface:"thread",protocol:'acpx.session → TranscriptEntry kind:"init"'},"human-message":{id:"human-message",label:"Human message",tier:"live",surface:"thread",protocol:'IssueComment authorType:"user"'},"agent-message":{id:"agent-message",label:"Final response",tier:"live",surface:"thread",protocol:'PRP item.delta kind:"agentMessage" channel:"final"'},thinking:{id:"thinking",label:"Thinking",tier:"live",surface:"thread",protocol:"text_delta stream:thought (ACP agent_thought_chunk)"},responding:{id:"responding",label:"Progress update (streaming)",tier:"live",surface:"thread",protocol:'PRP item.delta kind:"agentMessage" channel:"progress"'},"responding-burst":{id:"responding-burst",label:"Progress update burst",tier:"live",surface:"thread",protocol:"text_delta stream:output ×N, tool calls between (PAP-368 dwell)"},"tool-call":{id:"tool-call",label:"Tool call",tier:"live",surface:"thread",protocol:"acpx.tool_call (ACP tool_call / tool_call_update)"},diff:{id:"diff",label:"Diff",tier:"live",surface:"thread",protocol:'ToolCallContent type:"diff" → TranscriptEntry kind:"diff"'},working:{id:"working",label:"Working",tier:"live",surface:"thread",protocol:"heartbeat.run.progress + acpx.status"},running:{id:"running",label:"Running",tier:"live",surface:"thread",protocol:'message.status.type === "running"'},completed:{id:"completed",label:"Completed (collapsed)",tier:"live",surface:"thread",protocol:"acpx.result (StopReason in subtype)"},"activity-phases":{id:"activity-phases",label:"Long-run activity phases",tier:"live",surface:"thread",protocol:"assistant boundaries + chronological tool calls"},"awaiting-approval":{id:"awaiting-approval",label:"Awaiting approval",tier:"tier-b",surface:"thread",protocol:"ACP RequestPermissionRequest + PermissionOptionKind"},"plan-todo":{id:"plan-todo",label:"Plan / todo",tier:"tier-b",surface:"plan",protocol:"ACP Plan { entries: PlanEntry[] }, PlanEntryStatus"},interrupted:{id:"interrupted",label:"Interrupted",tier:"tier-b",surface:"thread",protocol:'AcpRuntimeTurnResult.status:"cancelled" / StopReason "cancelled"'},refused:{id:"refused",label:"Refused",tier:"tier-b",surface:"thread",protocol:'StopReason "refusal"'},truncated:{id:"truncated",label:"Truncated",tier:"tier-b",surface:"thread",protocol:'StopReason "max_tokens" | "max_turn_requests"'},"live-token-cost":{id:"live-token-cost",label:"Live token / cost",tier:"tier-b",surface:"thread",protocol:"ACP UsageUpdate { used, size, cost }"}},Q9s=t5n.map(e=>n5n[e]);function lgt({browser:e,label:t="Browser",onOpen:s}){const r=e.status==="closed"||e.status==="failed";return(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2 py-1 text-sm","aria-label":`${t} session`,children:[(0,n.jsx)(Lp,{className:"size-4 shrink-0 text-ink-3","aria-hidden":!0}),(0,n.jsx)("span",{children:t}),(0,n.jsxs)("span",{className:"text-ink-3",children:["· ",e.status]}),s&&(0,n.jsx)($,{variant:"ghost",size:"sm",onClick:i(()=>s(e.id),"onClick"),children:r?"View session":"Open browser"})]})}i(lgt,"TaskBrowserActivity");function cgt({item:e}){return(0,n.jsx)("article",{className:"rounded-lg border border-line bg-bg-2 p-3","aria-label":`Project created: ${e.name}`,children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)(F7t,{className:"mt-0.5 size-4 shrink-0 text-ink-3","aria-hidden":!0}),(0,n.jsxs)("div",{className:"min-w-0 flex-1 space-y-1",children:[(0,n.jsx)("p",{className:"text-xs text-ink-3",children:"Project created"}),(0,n.jsx)(Ye,{to:`/projects/${e.projectId}`,className:"break-words text-sm font-medium hover:underline focus-visible:underline",children:e.name}),e.description&&(0,n.jsx)("p",{className:"line-clamp-3 text-sm text-ink-3",children:e.description}),e.repositories.length>0&&(0,n.jsx)("ul",{className:"space-y-1 pt-1",children:e.repositories.map(t=>(0,n.jsxs)("li",{className:"flex min-w-0 items-center gap-2 text-xs text-ink-3",children:[(0,n.jsx)(Ao,{className:"size-3 shrink-0","aria-hidden":!0}),(0,n.jsx)("a",{className:"truncate hover:underline focus-visible:underline",href:t.url,target:"_blank",rel:"noreferrer",children:t.name})]},t.id))})]})]})})}i(cgt,"TaskChatProjectCreatedCard");function s5n({item:e,onOpen:t}){return(0,n.jsx)("article",{className:"rounded-lg border border-line bg-bg-2 p-3","aria-label":`Skill created: ${e.name}`,children:(0,n.jsxs)("button",{type:"button",className:"flex w-full items-start gap-3 text-left",onClick:i(()=>t?.(e.skillId,e.name),"onClick"),children:[(0,n.jsx)(Xf,{className:"mt-0.5 size-4 shrink-0 text-ink-3","aria-hidden":!0}),(0,n.jsxs)("span",{className:"min-w-0 flex-1 space-y-1",children:[(0,n.jsx)("span",{className:"block text-xs text-ink-3",children:"Skill created"}),(0,n.jsx)("span",{className:"block break-words text-sm font-medium hover:underline focus-visible:underline",children:e.name}),e.description?(0,n.jsx)("span",{className:"block line-clamp-3 text-sm text-ink-3",children:e.description}):null]})]})})}i(s5n,"TaskChatSkillCreatedCard");function r5n(e,t){const s=t||{};return(e[e.length-1]===""?[...e,""]:e).join((s.padRight?" ":"")+","+(s.padLeft===!1?"":" ")).trim()}i(r5n,"stringify$1");var i5n=/[ \t\n\f\r]/g;function a5n(e){return typeof e=="object"?e.type==="text"?V6e(e.value):!1:V6e(e)}i(a5n,"whitespace");function V6e(e){return e.replace(i5n,"")===""}i(V6e,"empty");var q7=class{static{i(this,"Schema")}constructor(e,t,s){this.normal=t,this.property=e,s&&(this.space=s)}};q7.prototype.normal={};q7.prototype.property={};q7.prototype.space=void 0;function dgt(e,t){const s={},r={};for(const a of e)Object.assign(s,a.property),Object.assign(r,a.normal);return new q7(s,r,t)}i(dgt,"merge");function jde(e){return e.toLowerCase()}i(jde,"normalize$1");var qp=class{static{i(this,"Info")}constructor(e,t){this.attribute=t,this.property=e}};qp.prototype.attribute="";qp.prototype.booleanish=!1;qp.prototype.boolean=!1;qp.prototype.commaOrSpaceSeparated=!1;qp.prototype.commaSeparated=!1;qp.prototype.defined=!1;qp.prototype.mustUseProperty=!1;qp.prototype.number=!1;qp.prototype.overloadedBoolean=!1;qp.prototype.property="";qp.prototype.spaceSeparated=!1;qp.prototype.space=void 0;var Nde=LQ({boolean:i(()=>ea,"boolean"),booleanish:i(()=>Od,"booleanish"),commaOrSpaceSeparated:i(()=>l0,"commaOrSpaceSeparated"),commaSeparated:i(()=>v3,"commaSeparated"),number:i(()=>ws,"number"),overloadedBoolean:i(()=>Cde,"overloadedBoolean"),spaceSeparated:i(()=>Dl,"spaceSeparated")}),o5n=0,ea=t_(),Od=t_(),Cde=t_(),ws=t_(),Dl=t_(),v3=t_(),l0=t_();function t_(){return 2**++o5n}i(t_,"increment");var ote=Object.keys(Nde),Mye=class extends qp{static{i(this,"DefinedInfo")}constructor(e,t,s,r){let a=-1;if(super(e,t),H6e(this,"space",r),typeof s=="number")for(;++a<ote.length;){const o=ote[a];H6e(this,ote[a],(s&Nde[o])===Nde[o])}}};Mye.prototype.defined=!0;function H6e(e,t,s){s&&(e[t]=s)}i(H6e,"mark");function zT(e){const t={},s={};for(const[r,a]of Object.entries(e.properties)){const o=new Mye(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,s[jde(r)]=r,s[jde(o.attribute)]=r}return new q7(t,s,e.space)}i(zT,"create$1");var ugt=zT({properties:{ariaActiveDescendant:null,ariaAtomic:Od,ariaAutoComplete:null,ariaBusy:Od,ariaChecked:Od,ariaColCount:ws,ariaColIndex:ws,ariaColSpan:ws,ariaControls:Dl,ariaCurrent:null,ariaDescribedBy:Dl,ariaDetails:null,ariaDisabled:Od,ariaDropEffect:Dl,ariaErrorMessage:null,ariaExpanded:Od,ariaFlowTo:Dl,ariaGrabbed:Od,ariaHasPopup:null,ariaHidden:Od,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Dl,ariaLevel:ws,ariaLive:null,ariaModal:Od,ariaMultiLine:Od,ariaMultiSelectable:Od,ariaOrientation:null,ariaOwns:Dl,ariaPlaceholder:null,ariaPosInSet:ws,ariaPressed:Od,ariaReadOnly:Od,ariaRelevant:null,ariaRequired:Od,ariaRoleDescription:Dl,ariaRowCount:ws,ariaRowIndex:ws,ariaRowSpan:ws,ariaSelected:Od,ariaSetSize:ws,ariaSort:null,ariaValueMax:ws,ariaValueMin:ws,ariaValueNow:ws,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function hgt(e,t){return t in e?e[t]:t}i(hgt,"caseSensitiveTransform");function mgt(e,t){return hgt(e,t.toLowerCase())}i(mgt,"caseInsensitiveTransform");var l5n=zT({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:v3,acceptCharset:Dl,accessKey:Dl,action:null,allow:null,allowFullScreen:ea,allowPaymentRequest:ea,allowUserMedia:ea,alpha:ea,alt:null,as:null,async:ea,autoCapitalize:null,autoComplete:Dl,autoFocus:ea,autoPlay:ea,blocking:Dl,capture:null,charSet:null,checked:ea,cite:null,className:Dl,closedBy:null,colorSpace:null,cols:ws,colSpan:ws,command:null,commandFor:null,content:null,contentEditable:Od,controls:ea,controlsList:Dl,coords:ws|v3,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ea,defer:ea,dir:null,dirName:null,disabled:ea,download:Cde,draggable:Od,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ea,formTarget:null,headers:Dl,height:ws,hidden:Cde,high:ws,href:null,hrefLang:null,htmlFor:Dl,httpEquiv:Dl,id:null,imageSizes:null,imageSrcSet:null,inert:ea,inputMode:null,integrity:null,is:null,isMap:ea,itemId:null,itemProp:Dl,itemRef:Dl,itemScope:ea,itemType:Dl,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ea,low:ws,manifest:null,max:null,maxLength:ws,media:null,method:null,min:null,minLength:ws,multiple:ea,muted:ea,name:null,nonce:null,noModule:ea,noValidate:ea,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ea,optimum:ws,pattern:null,ping:Dl,placeholder:null,playsInline:ea,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ea,referrerPolicy:null,rel:Dl,required:ea,reversed:ea,rows:ws,rowSpan:ws,sandbox:Dl,scope:null,scoped:ea,seamless:ea,selected:ea,shadowRootClonable:ea,shadowRootCustomElementRegistry:ea,shadowRootDelegatesFocus:ea,shadowRootMode:null,shadowRootSerializable:ea,shape:null,size:ws,sizes:null,slot:null,span:ws,spellCheck:Od,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ws,step:null,style:null,tabIndex:ws,target:null,title:null,translate:null,type:null,typeMustMatch:ea,useMap:null,value:Od,width:ws,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Dl,axis:null,background:null,bgColor:null,border:ws,borderColor:null,bottomMargin:ws,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ea,declare:ea,event:null,face:null,frame:null,frameBorder:null,hSpace:ws,leftMargin:ws,link:null,longDesc:null,lowSrc:null,marginHeight:ws,marginWidth:ws,noResize:ea,noHref:ea,noShade:ea,noWrap:ea,object:null,profile:null,prompt:null,rev:null,rightMargin:ws,rules:null,scheme:null,scrolling:Od,standby:null,summary:null,text:null,topMargin:ws,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ws,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:ea,disablePictureInPicture:ea,disableRemotePlayback:ea,exportParts:v3,part:Dl,prefix:null,property:null,results:ws,security:null,unselectable:null},space:"html",transform:mgt}),c5n=zT({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:l0,accentHeight:ws,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ws,amplitude:ws,arabicForm:null,ascent:ws,attributeName:null,attributeType:null,azimuth:ws,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ws,by:null,calcMode:null,capHeight:ws,className:Dl,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ws,diffuseConstant:ws,direction:null,display:null,dur:null,divisor:ws,dominantBaseline:null,download:ea,dx:null,dy:null,edgeMode:null,editable:null,elevation:ws,enableBackground:null,end:null,event:null,exponent:ws,externalResourcesRequired:null,fill:null,fillOpacity:ws,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:v3,g2:v3,glyphName:v3,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ws,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ws,horizOriginX:ws,horizOriginY:ws,id:null,ideographic:ws,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ws,k:ws,k1:ws,k2:ws,k3:ws,k4:ws,kernelMatrix:l0,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ws,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ws,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ws,overlineThickness:ws,paintOrder:null,panose1:null,path:null,pathLength:ws,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Dl,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ws,pointsAtY:ws,pointsAtZ:ws,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:l0,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:l0,rev:l0,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:l0,requiredFeatures:l0,requiredFonts:l0,requiredFormats:l0,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ws,specularExponent:ws,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ws,strikethroughThickness:ws,string:null,stroke:null,strokeDashArray:l0,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ws,strokeOpacity:ws,strokeWidth:null,style:null,surfaceScale:ws,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:l0,tabIndex:ws,tableValues:null,target:null,targetX:ws,targetY:ws,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:l0,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ws,underlineThickness:ws,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ws,values:null,vAlphabetic:ws,vMathematical:ws,vectorEffect:null,vHanging:ws,vIdeographic:ws,version:null,vertAdvY:ws,vertOriginX:ws,vertOriginY:ws,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ws,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:hgt}),pgt=zT({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),fgt=zT({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:mgt}),ggt=zT({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),d5n={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},u5n=/[A-Z]/g,G6e=/-[a-z]/g,h5n=/^data[-\w.:]+$/i;function m5n(e,t){const s=jde(t);let r=t,a=qp;if(s in e.normal)return e.property[e.normal[s]];if(s.length>4&&s.slice(0,4)==="data"&&h5n.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(G6e,f5n);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!G6e.test(o)){let l=o.replace(u5n,p5n);l.charAt(0)!=="-"&&(l="-"+l),t="data"+l}}a=Mye}return new a(r,t)}i(m5n,"find");function p5n(e){return"-"+e.toLowerCase()}i(p5n,"kebab");function f5n(e){return e.charAt(1).toUpperCase()}i(f5n,"camelcase");var g5n=dgt([ugt,l5n,pgt,fgt,ggt],"html"),Lye=dgt([ugt,c5n,pgt,fgt,ggt],"svg");function x5n(e){return e.join(" ").trim()}i(x5n,"stringify");var v5n=ih(((e,t)=>{var s=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,a=/^\s*/,o=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,l=/^:\s*/,c=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,d=/^[;\s]*/,u=/^\s+|\s+$/g,h=`
415
415
  `,p="/",f="*",g="",x="comment",v="declaration";function b(k,j){if(typeof k!="string")throw new TypeError("First argument must be a string");if(!k)return[];j=j||{};var N=1,S=1;function A(B){var z=B.match(r);z&&(N+=z.length);var U=B.lastIndexOf(h);S=~U?B.length-U:S+B.length}i(A,"updatePosition");function I(){var B={line:N,column:S};return function(z){return z.position=new _(B),M(),z}}i(I,"position");function _(B){this.start=B,this.end={line:N,column:S},this.source=j.source}i(_,"Position"),_.prototype.content=k;function T(B){var z=new Error(j.source+":"+N+":"+S+": "+B);if(z.reason=B,z.filename=j.source,z.line=N,z.column=S,z.source=k,!j.silent)throw z}i(T,"error");function E(B){var z=B.exec(k);if(z){var U=z[0];return A(U),k=k.slice(U.length),z}}i(E,"match");function M(){E(a)}i(M,"whitespace");function P(B){var z;for(B=B||[];z=D();)z!==!1&&B.push(z);return B}i(P,"comments");function D(){var B=I();if(!(p!=k.charAt(0)||f!=k.charAt(1))){for(var z=2;g!=k.charAt(z)&&(f!=k.charAt(z)||p!=k.charAt(z+1));)++z;if(z+=2,g===k.charAt(z-1))return T("End of comment missing");var U=k.slice(2,z-2);return S+=2,A(U),k=k.slice(z),S+=2,B({type:x,comment:U})}}i(D,"comment");function K(){var B=I(),z=E(o);if(z){if(D(),!E(l))return T("property missing ':'");var U=E(c),W=B({type:v,property:y(z[0].replace(s,g)),value:U?y(U[0].replace(s,g)):g});return E(d),W}}i(K,"declaration");function L(){var B=[];P(B);for(var z;z=K();)z!==!1&&(B.push(z),P(B));return B}return i(L,"declarations"),M(),L()}i(b,"index");function y(k){return k?k.replace(u,g):g}i(y,"trim"),t.exports=b})),b5n=ih((e=>{var t=e&&e.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var s=t(v5n());function r(a,o){let l=null;if(!a||typeof a!="string")return l;const c=(0,s.default)(a),d=typeof o=="function";return c.forEach(u=>{if(u.type!=="declaration")return;const{property:h,value:p}=u;d?o(h,p,u):p&&(l=l||{},l[h]=p)}),l}i(r,"StyleToObject")})),y5n=ih((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,s=/-([a-z])/g,r=/^[^-]+$/,a=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,l=i(function(h){return!h||r.test(h)||t.test(h)},"skipCamelCase"),c=i(function(h,p){return p.toUpperCase()},"capitalize"),d=i(function(h,p){return"".concat(p,"-")},"trimHyphen"),u=i(function(h,p){return p===void 0&&(p={}),l(h)?h:(h=h.toLowerCase(),p.reactCompat?h=h.replace(o,d):h=h.replace(a,d),h.replace(s,c))},"camelCase");e.camelCase=u})),k5n=ih(((e,t)=>{var s=(e&&e.__importDefault||function(o){return o&&o.__esModule?o:{default:o}})(b5n()),r=y5n();function a(o,l){var c={};return!o||typeof o!="string"||(0,s.default)(o,function(d,u){d&&u&&(c[(0,r.camelCase)(d,l)]=u)}),c}i(a,"StyleToJS"),a.default=a,t.exports=a})),xgt=vgt("end"),Dye=vgt("start");function vgt(e){return t;function t(s){const r=s&&s.position&&s.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}i(vgt,"point");function w5n(e){const t=Dye(e),s=xgt(e);if(t&&s)return{start:t,end:s}}i(w5n,"position");var j5n=B1(k5n(),1),Pye={}.hasOwnProperty,N5n=new Map,C5n=/[A-Z]/g,S5n=new Set(["table","tbody","thead","tfoot","tr"]),_5n=new Set(["td","th"]),bgt="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function A5n(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const s=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=P5n(s,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=D5n(s,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:s,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Lye:g5n,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=ygt(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}i(A5n,"toJsxRuntime");function ygt(e,t,s){if(t.type==="element")return I5n(e,t,s);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return T5n(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return R5n(e,t,s);if(t.type==="mdxjsEsm")return E5n(e,t);if(t.type==="root")return M5n(e,t,s);if(t.type==="text")return L5n(e,t)}i(ygt,"one$1");function I5n(e,t,s){const r=e.schema;let a=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(a=Lye,e.schema=a),e.ancestors.push(t);const o=wgt(e,t.tagName,!1),l=$5n(e,t);let c=Oye(e,t);return S5n.has(t.tagName)&&(c=c.filter(function(d){return typeof d=="string"?!a5n(d):!0})),kgt(e,l,o,t),$ye(l,c),e.ancestors.pop(),e.schema=r,e.create(t,o,l,s)}i(I5n,"element");function T5n(e,t){if(t.data&&t.data.estree&&e.evaluater){const s=t.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}s8(e,t.position)}i(T5n,"mdxExpression");function E5n(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);s8(e,t.position)}i(E5n,"mdxEsm");function R5n(e,t,s){const r=e.schema;let a=r;t.name==="svg"&&r.space==="html"&&(a=Lye,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:wgt(e,t.name,!0),l=O5n(e,t),c=Oye(e,t);return kgt(e,l,o,t),$ye(l,c),e.ancestors.pop(),e.schema=r,e.create(t,o,l,s)}i(R5n,"mdxJsxElement");function M5n(e,t,s){const r={};return $ye(r,Oye(e,t)),e.create(t,e.Fragment,r,s)}i(M5n,"root$2");function L5n(e,t){return t.value}i(L5n,"text$5");function kgt(e,t,s,r){typeof s!="string"&&s!==e.Fragment&&e.passNode&&(t.node=r)}i(kgt,"addNode");function $ye(e,t){if(t.length>0){const s=t.length>1?t:t[0];s&&(e.children=s)}}i($ye,"addChildren");function D5n(e,t,s){return r;function r(a,o,l,c){const d=Array.isArray(l.children)?s:t;return c?d(o,l,c):d(o,l)}}i(D5n,"productionCreate");function P5n(e,t){return s;function s(r,a,o,l){const c=Array.isArray(o.children),d=Dye(r);return t(a,o,l,c,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}i(P5n,"developmentCreate");function $5n(e,t){const s={};let r,a;for(a in t.properties)if(a!=="children"&&Pye.call(t.properties,a)){const o=F5n(e,a,t.properties[a]);if(o){const[l,c]=o;e.tableCellAlignToStyle&&l==="align"&&typeof c=="string"&&_5n.has(t.tagName)?r=c:s[l]=c}}if(r){const o=s.style||(s.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return s}i($5n,"createElementProps");function O5n(e,t){const s={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const a=r.data.estree.body[0];a.type;const o=a.expression;o.type;const l=o.properties[0];l.type,Object.assign(s,e.evaluater.evaluateExpression(l.argument))}else s8(e,t.position);else{const a=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,o=e.evaluater.evaluateExpression(l.expression)}else s8(e,t.position);else o=r.value===null?!0:r.value;s[a]=o}return s}i(O5n,"createJsxElementProps");function Oye(e,t){const s=[];let r=-1;const a=e.passKeys?new Map:N5n;for(;++r<t.children.length;){const o=t.children[r];let l;if(e.passKeys){const d=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(d){const u=a.get(d)||0;l=d+"-"+u,a.set(d,u+1)}}const c=ygt(e,o,l);c!==void 0&&s.push(c)}return s}i(Oye,"createChildren");function F5n(e,t,s){const r=m5n(e.schema,t);if(!(s==null||typeof s=="number"&&Number.isNaN(s))){if(Array.isArray(s)&&(s=r.commaSeparated?r5n(s):x5n(s)),r.property==="style"){let a=typeof s=="object"?s:B5n(e,String(s));return e.stylePropertyNameCase==="css"&&(a=z5n(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&r.space?d5n[r.property]||r.property:r.attribute,s]}}i(F5n,"createProperty");function B5n(e,t){try{return(0,j5n.default)(t,{reactCompat:!0})}catch(s){if(e.ignoreInvalidStyle)return{};const r=s,a=new Hu("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=bgt+"#cannot-parse-style-attribute",a}}i(B5n,"parseStyle");function wgt(e,t,s){let r;if(!s)r={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let o=-1,l;for(;++o<a.length;){const c=W3e(a[o])?{type:"Identifier",name:a[o]}:{type:"Literal",value:a[o]};l=l?{type:"MemberExpression",object:l,property:c,computed:!!(o&&c.type==="Literal"),optional:!1}:c}r=l}else r=W3e(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const a=r.value;return Pye.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(r);s8(e)}i(wgt,"findComponentFromName");function s8(e,t){const s=new Hu("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=bgt+"#cannot-handle-mdx-estrees-without-createevaluater",s}i(s8,"crashEstree");function z5n(e){const t={};let s;for(s in e)Pye.call(e,s)&&(t[q5n(s)]=e[s]);return t}i(z5n,"transformStylesToCssCasing");function q5n(e){let t=e.replace(C5n,U5n);return t.slice(0,3)==="ms-"&&(t="-"+t),t}i(q5n,"transformStyleToCssCasing");function U5n(e){return"-"+e.toLowerCase()}i(U5n,"toDash");var lte={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]};function K5n(e){const t=this;t.parser=s;function s(r){return qKe(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}i(s,"parser")}i(K5n,"remarkParse");function W5n(e,t){const s={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,s),e.applyData(t,s)}i(W5n,"blockquote");function Q5n(e,t){const s={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,s),[e.applyData(t,s),{type:"text",value:`
416
416
  `}]}i(Q5n,"hardBreak");function V5n(e,t){const s=t.value?t.value+`
417
417
  `:"",r={},a=t.lang?t.lang.split(/\s+/):[];a.length>0&&(r.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:s}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}i(V5n,"code$1");function H5n(e,t){const s={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}i(H5n,"strikethrough");function G5n(e,t){const s={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}i(G5n,"emphasis");function Y5n(e,t){const s=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),a=ET(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let l,c=e.footnoteCounts.get(r);c===void 0?(c=0,e.footnoteOrder.push(r),l=e.footnoteOrder.length):l=o+1,c+=1,e.footnoteCounts.set(r,c);const d={type:"element",tagName:"a",properties:{href:"#"+s+"fn-"+a,id:s+"fnref-"+a+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(l)}]};e.patch(t,d);const u={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,u),e.applyData(t,u)}i(Y5n,"footnoteReference$1");function J5n(e,t){const s={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}i(J5n,"heading");function Z5n(e,t){if(e.options.allowDangerousHtml){const s={type:"raw",value:t.value};return e.patch(t,s),e.applyData(t,s)}}i(Z5n,"html");function jgt(e,t){const s=t.referenceType;let r="]";if(s==="collapsed"?r+="[]":s==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const l=a[a.length-1];return l&&l.type==="text"?l.value+=r:a.push({type:"text",value:r}),a}i(jgt,"revert");function X5n(e,t){const s=String(t.identifier).toUpperCase(),r=e.definitionById.get(s);if(!r)return jgt(e,t);const a={src:ET(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(a.title=r.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}i(X5n,"imageReference");function eAn(e,t){const s={src:ET(t.url)};t.alt!==null&&t.alt!==void 0&&(s.alt=t.alt),t.title!==null&&t.title!==void 0&&(s.title=t.title);const r={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,r),e.applyData(t,r)}i(eAn,"image");function tAn(e,t){const s={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,s);const r={type:"element",tagName:"code",properties:{},children:[s]};return e.patch(t,r),e.applyData(t,r)}i(tAn,"inlineCode");function nAn(e,t){const s=String(t.identifier).toUpperCase(),r=e.definitionById.get(s);if(!r)return jgt(e,t);const a={href:ET(r.url||"")};r.title!==null&&r.title!==void 0&&(a.title=r.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}i(nAn,"linkReference");function sAn(e,t){const s={href:ET(t.url)};t.title!==null&&t.title!==void 0&&(s.title=t.title);const r={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}i(sAn,"link");function rAn(e,t,s){const r=e.all(t),a=s?iAn(s):Ngt(t),o={},l=[];if(typeof t.checked=="boolean"){const h=r[0];let p;h&&h.type==="element"&&h.tagName==="p"?p=h:(p={type:"element",tagName:"p",properties:{},children:[]},r.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let c=-1;for(;++c<r.length;){const h=r[c];(a||c!==0||h.type!=="element"||h.tagName!=="p")&&l.push({type:"text",value:`
@@ -749,7 +749,7 @@ Last resolved: user values resolve per member`;return(0,n.jsxs)("div",{role:"row
749
749
 
750
750
  Review the **original** file.`,markdown:!0,downloadUrl:"data:text/markdown,%23%20Project%20notes"}),(0,n.jsx)(Jue,{title:"notes.txt",text:"Plain text stays literal: <example>",markdown:!1,downloadUrl:"data:text/plain,Plain%20text"})]})]}),(0,n.jsxs)(Tr,{title:"Connection recovery",children:[(0,n.jsx)(dr,{title:"Waiting for server",children:(0,n.jsx)(hz,{temporary:!0,retrying:!1,onRetry:i(()=>{},"onRetry")})}),(0,n.jsx)(dr,{title:"Checking connection",children:(0,n.jsx)(hz,{temporary:!0,retrying:!0,onRetry:i(()=>{},"onRetry")})}),(0,n.jsx)(dr,{title:"Access check failed",children:(0,n.jsx)(hz,{temporary:!1,retrying:!1,onRetry:i(()=>{},"onRetry")})})]}),(0,n.jsxs)(Tr,{title:"Browser session footer",children:[(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Fit to pane follows the visible panel. Fixed viewport presets and session actions live in the footer menu. Costs stay in task reporting. The idle countdown appears only in the final five minutes. Full panel, activity, and settings states are in Storybook under Browser Use."}),["running","idle","closing-soon","closed"].map(P=>(0,n.jsx)(dr,{title:P==="closing-soon"?"Closing soon":P,children:(0,n.jsx)(FNt,{browser:{id:"design-browser",sessionId:"design-session",issueId:"design-task",status:P==="closing-soon"?"idle":P,runStatus:"completed",progress:null,error:null,costCents:15,idleDeadline:new Date(P==="closing-soon"?282e3:6e5).toISOString(),expiresAt:null,createdAt:new Date(0).toISOString()},now:0,onControl:i(()=>{},"onControl"),onReconnect:i(()=>{},"onReconnect"),onResize:i(()=>{},"onResize")})},P))]}),(0,n.jsxs)(Tr,{title:"Browser activity in the task feed",children:[(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Each browser appears once at its opening time among the task messages. Its status updates in place; the action opens its side-panel tab."}),["starting","running","idle","closed","failed"].map(P=>(0,n.jsx)(dr,{title:P,children:(0,n.jsx)(lgt,{browser:{id:`design-${P}`,sessionId:`design-${P}`,issueId:"design-task",status:P,runStatus:"completed",progress:null,error:null,costCents:0,idleDeadline:null,expiresAt:null,createdAt:new Date(0).toISOString()},onOpen:i(()=>{},"onOpen")})},P))]}),(0,n.jsxs)(Tr,{title:"Media artifacts",children:[(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Images and videos use gallery tiles. The whole tile opens the task gallery; files and links keep compact, fully clickable rows. Task/Artifact Gallery in Storybook covers playable videos, mixed files, narrow panels, and unavailable previews."}),(0,n.jsxs)("div",{className:"grid max-w-2xl grid-cols-1 gap-3 sm:grid-cols-2",children:[(0,n.jsx)(Dde,{id:"design-image",title:"Launch artwork",contentPath:"/announcement-preview.svg",contentType:"image/svg+xml",originalFilename:"launch.svg",detail:"Image"}),(0,n.jsx)(Dde,{id:"design-video",title:"Video preview unavailable",contentPath:"",contentType:"video/mp4",originalFilename:"preview.mp4",detail:"Video"})]})]}),(0,n.jsx)(Tr,{title:"AI Connections",children:(0,n.jsx)(V6s,{})}),(0,n.jsxs)(Tr,{title:"Built-in Agent Lifecycle Chips",children:[(0,n.jsxs)("p",{className:"text-sm text-ink-3",children:["A derived lifecycle chip (amber) for attention states. The lifecycle chip is separate from the agent status vocabulary and only shows for"," ",(0,n.jsx)("span",{className:"font-mono",children:"needs_setup"})," / ",(0,n.jsx)("span",{className:"font-mono",children:"pending_approval"}),"."]}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,n.jsx)(o6,{status:"needs_setup"}),(0,n.jsx)(o6,{status:"pending_approval"}),(0,n.jsx)(o6,{status:"needs_setup",compact:!0})]}),(0,n.jsxs)("p",{className:"mt-3 text-sm text-ink-3",children:[(0,n.jsx)("span",{className:"font-mono",children:"<BuiltInAgentGate agentKey>"})," composes"," ",(0,n.jsx)("span",{className:"font-mono",children:"PageSkeleton"})," + ",(0,n.jsx)("span",{className:"font-mono",children:"EmptyState"})," ","+ ",(0,n.jsx)("span",{className:"font-mono",children:"InlineBanner"})," to render the loading / setup / pending-approval / paused / ready states of a feature that depends on a built-in agent."]})]})]})}i(MMs,"DesignGuide");function LMs(){const e=[{path:".agents/review/SKILL.md",name:"Review",description:"Review changes before release.",error:null,inspection:{requirements:null,references:[],warnings:[],files:[{path:"SKILL.md",kind:"skill",sizeBytes:120,encoding:"utf8",executable:!1},{path:"scripts/check.sh",kind:"script",sizeBytes:45,encoding:"utf8",executable:!0}]}},{path:".agents/review/nested/SKILL.md",name:"Nested skill",description:"An independently selected package.",error:null,note:"New skill"},{path:"broken/SKILL.md",name:"Needs attention",description:null,error:"Missing required description."}],[t,s]=(0,m.useState)(new Set(e.map(o=>o.path))),[r,a]=(0,m.useState)([]);return(0,n.jsx)(r5t,{candidates:e,selected:t,excludedFolders:r,onChange:i((o,l)=>{s(o),a(l)},"onChange")})}i(LMs,"SkillSourceTreeShowcase");function X5t(){return(0,n.jsxs)(lt,{variant:"outline",className:"text-ink-3",children:[(0,n.jsx)(rl,{"aria-hidden":"true"}),"Managed by Paperclip Cloud"]})}i(X5t,"ManagedByCloudBadge");function eAt({name:e,summary:t,badges:s,status:r,checked:a,disabled:o,onCheckedChange:l,children:c}){return(0,n.jsxs)("div",{className:"flex flex-col gap-3 border-t border-line px-4 py-3 first:border-t-0 sm:px-5",children:[(0,n.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:e}),s]}),(0,n.jsx)("p",{className:"text-sm text-ink-3",children:t}),r?(0,n.jsx)("p",{className:"text-xs text-ink-3 sm:hidden",children:r}):null]}),(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-3",children:[r?(0,n.jsx)("span",{className:Q("hidden max-w-64 text-right text-xs text-ink-3 sm:block"),children:r}):null,(0,n.jsx)(ma,{checked:a,disabled:o,onCheckedChange:l,"aria-label":e})]})]}),c]})}i(eAt,"FeatureSettingRow");function tAt({id:e,title:t,meta:s,children:r}){return(0,n.jsxs)("section",{"aria-labelledby":e,className:"overflow-hidden rounded-lg border border-line bg-bg-2",children:[(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3 border-b border-line px-4 py-2.5 sm:px-5",children:[(0,n.jsx)("h2",{id:e,className:"text-xs font-semibold uppercase tracking-wide text-ink-3",children:t}),s?(0,n.jsx)("span",{className:"text-xs text-ink-3",children:s}):null]}),(0,n.jsx)("div",{children:r})]})}i(tAt,"FeatureSettingGroup");function nAt(){const e=Ct(),{hidden:t}=V0(),[s,r]=(0,m.useState)(null),a=ie({queryKey:O.instance.experimentalSettings,queryFn:i(()=>Fr.getExperimental(),"queryFn")}),o=ye({mutationFn:i(p=>Fr.updateExperimental(p),"mutationFn"),onMutate:i(async p=>{await e.cancelQueries({queryKey:O.instance.experimentalSettings});const f=e.getQueryData(O.instance.experimentalSettings);return f&&e.setQueryData(O.instance.experimentalSettings,{...f,...p}),{previous:f}},"onMutate"),onSuccess:i(async p=>{r(null),e.setQueryData(O.instance.experimentalSettings,p),await Promise.all([e.invalidateQueries({queryKey:O.instance.experimentalSettings}),e.invalidateQueries({queryKey:O.adapters.all}),e.invalidateQueries({queryKey:["built-in-agents"]}),e.invalidateQueries({queryKey:O.health}),e.invalidateQueries({queryKey:["apps"]})])},"onSuccess"),onError:i((p,f,g)=>{g?.previous&&e.setQueryData(O.instance.experimentalSettings,g.previous),r(p.message||"Failed to save the change.")},"onError")}),l=a.data,c=l?.managedKeys??{};return{query:a,settings:l,error:s,isManaged:i(p=>c[p]?.managed===!0,"isManaged"),isHidden:i(p=>t.has(yTt(p)),"isHidden"),isOn:i(p=>l?.[p]===!0,"isOn"),isCloudManaged:l?.managedKeys!==void 0,pending:o.isPending,save:i(p=>o.mutate(p),"save")}}i(nAt,"useInstanceFeatureSettings");var DMs={collaboration:"Working together",automation:"Automation",integrations:"Integrations",workspace:"Workspaces",display:"Display"},PMs={minimal:"Minimal",standard:"Standard",everything:"Everything"},$Ms=ZUe("features");function OMs(e){return M5(e,"features")?.name??e}i(OMs,"featureName");function FMs(){const{setBreadcrumbs:e}=Hs(),t=nAt(),[s,r]=(0,m.useState)("");(0,m.useEffect)(()=>{e([{label:"Settings",href:"/company/settings"},{label:"Features"}])},[e]);const a=$Ms.filter(g=>!t.isHidden(g)),o=s.trim().toLowerCase(),l=i(g=>{if(!o)return!0;const x=M5(g,"features");return[x?.name,x?.summary,x?.whenOn,g].some(v=>v?.toLowerCase().includes(o))},"matches");if(t.query.isLoading)return(0,n.jsx)("div",{className:"text-sm text-ink-3",children:"Loading features..."});if(t.query.error)return(0,n.jsx)("div",{className:"text-sm text-bad",children:t.query.error.message||"Failed to load features."});const c=t.settings??{},d=a.filter(t.isOn).length,u=YIt(c),h=i(g=>{const x=Object.fromEntries(Object.entries(rTt(g)).filter(([v])=>!t.isManaged(v)&&!t.isHidden(v)));t.save(x)},"applyPreset"),p=i((g,x)=>{const v={[g]:x};if(x)for(const b of L3e(g,c))v[b]=!0;else{const b=i(y=>{for(const k of $Tt(y))v[k]!==!1&&(v[k]=!1,b(k))},"disable");b(g)}t.save(v)},"toggle"),f=dEt.map(g=>({group:g,keys:a.filter(x=>M5(x,"features")?.group===g)})).filter(({keys:g})=>g.length>0).map(({group:g,keys:x})=>({group:g,keys:x,shown:x.filter(l)})).filter(({shown:g})=>g.length>0);return(0,n.jsxs)("div",{className:"max-w-4xl space-y-5",children:[(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Features"}),(0,n.jsxs)("p",{className:"text-sm text-ink-3",children:[d," of ",a.length," on. Turning one off hides it; nothing is deleted."]})]}),(0,n.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,n.jsx)("div",{role:"group","aria-label":"Preset",className:"inline-flex shrink-0 rounded-md border border-line p-0.5",children:LIt.map(g=>(0,n.jsx)("button",{type:"button","aria-pressed":u===g,disabled:t.pending,onClick:i(()=>h(g),"onClick"),className:Q("rounded-(--rad-4) px-3 py-1 text-sm transition-colors disabled:cursor-not-allowed",u===g?"bg-bg-3 font-medium text-ink":"text-ink-3 hover:text-ink"),children:PMs[g]},g))}),(0,n.jsxs)("label",{className:"relative flex-1",children:[(0,n.jsx)("span",{className:"sr-only",children:"Search features"}),(0,n.jsx)(Jr,{"aria-hidden":"true",className:"pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-ink-3"}),(0,n.jsx)(mt,{type:"search",value:s,onChange:i(g=>r(g.target.value),"onChange"),placeholder:"Search features",className:"pl-8"})]})]}),t.error?(0,n.jsx)("div",{role:"alert",className:"rounded-md border border-bad/40 px-3 py-2 text-sm text-bad",children:t.error}):null,f.length===0?(0,n.jsxs)("p",{className:"text-sm text-ink-3",children:['No feature matches "',s.trim(),'".']}):f.map(({group:g,keys:x,shown:v})=>(0,n.jsx)(tAt,{id:`feature-group-${g}`,title:DMs[g],meta:`${x.filter(t.isOn).length} of ${x.length} on`,children:v.map(b=>{const y=M5(b,"features"),k=t.isOn(b),j=t.isManaged(b),N=L3e(b,c),S=!k&&N.some(t.isManaged),A=!y.finished&&!k;return(0,n.jsxs)(eAt,{name:y.name,summary:y.summary,checked:k,disabled:t.pending||j||A||S,onCheckedChange:i(I=>p(b,I),"onCheckedChange"),status:k?y.whenOn:y.whenOff,badges:(0,n.jsxs)(n.Fragment,{children:[y.finished?null:(0,n.jsx)(lt,{variant:"secondary",children:"Not finished yet"}),j?(0,n.jsx)(X5t,{}):null]}),children:[y.requires.length>0?(0,n.jsxs)("p",{className:"text-xs text-ink-3",children:["Needs ",y.requires.map(OMs).join(" and "),N.length>0&&!S?"; turning this on turns it on too.":"."]}):null,b==="enableIsolatedWorkspaces"&&k?(0,n.jsxs)("label",{className:"flex items-start gap-2 text-sm",children:[(0,n.jsx)(Ci,{checked:t.isOn("enableIsolatedWorkspacesByDefault"),disabled:t.pending||t.isManaged("enableIsolatedWorkspacesByDefault"),onCheckedChange:i(I=>t.save({enableIsolatedWorkspacesByDefault:I===!0}),"onCheckedChange"),className:"mt-0.5"}),(0,n.jsxs)("span",{children:[(0,n.jsx)("span",{className:"font-medium",children:"Use for new projects"}),(0,n.jsx)("span",{className:"block text-ink-3",children:"Projects without their own workspace policy get isolated workspaces."})]})]}):null]},b)})},g)),(0,n.jsxs)("p",{className:"text-sm text-ink-3",children:["Runtime and developer switches are in"," ",(0,n.jsx)(Ye,{to:`${u0}/advanced`,className:"underline underline-offset-4",children:"Advanced"}),"."]})]})}i(FMs,"InstanceFeatures");function eR(e,t){return`${e} ${t}${e===1?"":"s"}`}i(eR,"plural");function BMs(e){return`$${(e/100).toFixed(2)}`}i(BMs,"formatCost");function zMs(e){return e===null?"-":e<60?`${Math.round(e)} s`:`${Math.round(e/60)} min`}i(zMs,"formatDuration$1");function qMs({companyId:e}){const t=ie({queryKey:O.agentDefaults.presetUsage(e),queryFn:i(()=>iP.presetUsage(e),"queryFn")}),s=t.data?.rows??[];return(0,n.jsxs)("section",{"aria-labelledby":"preset-usage-title",className:"overflow-hidden rounded-lg border border-line bg-bg-2",children:[(0,n.jsx)("div",{className:"flex items-baseline justify-between gap-3 border-b border-line px-4 py-2.5 sm:px-5",children:(0,n.jsx)("h2",{id:"preset-usage-title",className:"text-xs font-semibold uppercase tracking-wide text-ink-3",children:"Style presets, last 7 days"})}),t.isLoading?(0,n.jsx)("p",{className:"px-4 py-3 text-sm text-ink-3 sm:px-5",children:"Loading..."}):s.length===0?(0,n.jsx)("p",{className:"px-4 py-3 text-sm text-ink-3 sm:px-5",children:"No runs with a Style preset yet. Numbers appear once agents run with one."}):(0,n.jsx)("div",{className:"px-4 sm:px-5",children:(0,n.jsxs)("table",{"aria-label":"Style presets, last 7 days",className:"stack-table w-full text-sm",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{className:"text-left text-xs text-ink-3",children:[(0,n.jsx)("th",{className:"py-2 font-medium",children:"Preset"}),(0,n.jsx)("th",{className:"py-2 font-medium",children:"Runs"}),(0,n.jsx)("th",{className:"py-2 font-medium",children:"Avg duration"}),(0,n.jsx)("th",{className:"py-2 text-right font-medium",children:"Cost"})]})}),(0,n.jsx)("tbody",{children:s.map(r=>(0,n.jsxs)("tr",{className:"border-t border-line",children:[(0,n.jsx)("td",{"data-cell":"title",children:vpe[r.preset]?.label??r.preset}),(0,n.jsx)("td",{"data-cell":"meta","data-label":"Runs",children:r.runs}),(0,n.jsx)("td",{"data-cell":"meta","data-label":"Avg",children:zMs(r.avgDurationSec)}),(0,n.jsx)("td",{"data-cell":"end",className:"text-right tabular-nums",children:BMs(r.costCents)})]},r.preset))})]})})]})}i(qMs,"PresetUsageTable");function UMs(){const{setBreadcrumbs:e}=Hs(),{selectedCompanyId:t}=gn(),s=Ct(),r=Dwe(t),a=Lwe(t),o=pjt(t),l=ie({queryKey:O.agents.list(t??""),queryFn:i(()=>Pt.list(t),"queryFn"),enabled:!!t}),[c,d]=(0,m.useState)({}),[u,h]=(0,m.useState)(null);(0,m.useEffect)(()=>{e([{label:"Settings",href:"/company/settings"},{label:"Agent defaults"}])},[e]);const p=r.data?.values??{},f=(0,m.useMemo)(()=>Spe(p),[p]),g=(0,m.useMemo)(()=>hpe(f,c),[f,c]),x=(0,m.useMemo)(()=>(l.data??[]).filter(S=>S.adapterType==="omp_local"&&S.status!=="terminated").map(S=>({id:S.id,name:S.name,adapterConfig:S.adapterConfig??{}})),[l.data]),v=(0,m.useMemo)(()=>TW(g),[g]),b=(0,m.useMemo)(()=>HTt(x,p,v),[x,p,v]),y=hjt(f,g),k=ye({mutationFn:i(()=>iP.save(t,v),"mutationFn"),onSuccess:i(async()=>{d({}),h(null),await Promise.all([s.invalidateQueries({queryKey:O.agentDefaults.values(t)}),s.invalidateQueries({queryKey:O.agents.list(t)}),s.invalidateQueries({queryKey:["agents","detail"]})])},"onSuccess"),onError:i(S=>h(S instanceof Error?S.message:"Defaults were not saved."),"onError")});if(!t)return null;if(r.isLoading)return(0,n.jsx)("div",{className:"text-sm text-ink-3",children:"Loading agent defaults..."});if(r.error)return(0,n.jsx)("div",{className:"text-sm text-bad",children:r.error.message||"Failed to load agent defaults."});const j=x.filter(S=>sq(S.adapterConfig,p,P5.flatMap(A=>[...By[A]]))).length,N=(o.data?.settings.length??0)+QUe.length;return(0,n.jsxs)("div",{className:"max-w-4xl space-y-5 pb-4",children:[(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Agent defaults"}),(0,n.jsxs)("p",{className:"text-sm text-ink-3",children:["Every OMP agent starts from these. ",eR(j,"agent")," ",j===1?"has":"have"," its own values for some of them."]})]}),a.error?(0,n.jsxs)("div",{role:"alert",className:"rounded-md border border-warn px-3 py-2 text-sm text-ink-2",children:["OMP did not report its models: ",a.error.message,". Model choices stay empty until it does."]}):null,(0,n.jsx)("section",{"aria-label":"Agent defaults",className:"overflow-hidden rounded-lg border border-line bg-bg-2",children:P5.map(S=>{const A=x.filter(I=>!sq(I.adapterConfig,p,By[S])).length;return(0,n.jsx)(cjt,{label:IW[S].label,sub:(0,n.jsxs)(n.Fragment,{children:[IW[S].help,x.length>0?(0,n.jsxs)("span",{className:"block text-xs",children:[eR(A,"agent")," follow this"]}):null]}),children:(0,n.jsx)(djt,{control:S,config:g,models:a.data??[],disabled:k.isPending,onPatch:i(I=>d(_=>({..._,...I})),"onPatch")})},S)})}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,n.jsxs)(Ye,{to:"/company/settings/agent-defaults/all",className:"inline-flex min-h-6 items-center gap-1 text-sm text-accent underline underline-offset-4",children:["All settings",o.data?` (${N})`:"",(0,n.jsx)(zl,{"aria-hidden":"true",className:"size-3.5"})]}),(0,n.jsx)("span",{className:"text-sm text-ink-3",children:"For people who know OMP keys"})]}),(0,n.jsx)(qMs,{companyId:t}),y.length>0?(0,n.jsx)(Mwe,{saving:k.isPending,error:u,onDiscard:i(()=>{d({}),h(null)},"onDiscard"),onSave:i(()=>k.mutate(),"onSave"),summary:(0,n.jsxs)("span",{children:[(0,n.jsx)("b",{children:eR(y.length,"change")})," · applies to ",eR(b.following,"agent"),b.ownValues>0?` · ${eR(b.ownValues,"agent")} ${b.ownValues===1?"keeps its":"keep their"} own value`:""," · ",b.following===0?"no session changes":b.sessionKept?"keeps their sessions":"their next run starts a new session"]})}):null]})}i(UMs,"AgentDefaults");function KMs(){const{setBreadcrumbs:e}=Hs(),{selectedCompanyId:t}=gn(),s=Ct(),r=Lwe(t),[a,o]=(0,m.useState)(!1),[l,c]=(0,m.useState)(!1);(0,m.useEffect)(()=>{e([{label:"Settings",href:"/company/settings"},{label:"Models and providers"}])},[e]);const d=(0,m.useMemo)(()=>{const h=new Map;for(const p of r.data??[]){const f=p.provider??p.id.split("/")[0]??"";h.set(f,(h.get(f)??0)+1)}return[...h.entries()].sort(([p],[f])=>p.localeCompare(f))},[r.data]),u=i(async()=>{if(t){o(!0);try{const h=await Pt.adapterModels(t,AW,{refresh:!0});s.setQueryData(O.agents.adapterModels(t,AW),h)}finally{o(!1)}}},"checkAgain");return t?(0,n.jsxs)("div",{className:"max-w-4xl space-y-5 pb-4",children:[(0,n.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Models and providers"}),(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Imported from OMP. Keys stay in OMP's credential store; Wardmote never reads or keeps them."})]}),(0,n.jsxs)("div",{className:"flex shrink-0 gap-2",children:[(0,n.jsxs)($,{type:"button",variant:"secondary",size:"sm",disabled:a,onClick:u,children:[(0,n.jsx)(Aa,{"aria-hidden":"true",className:a?"motion-safe:animate-spin":void 0}),"Check again"]}),(0,n.jsxs)($,{type:"button",size:"sm",onClick:i(()=>c(h=>!h),"onClick"),"aria-expanded":l,children:[(0,n.jsx)(js,{"aria-hidden":"true"}),"Add provider"]})]})]}),l?(0,n.jsxs)("div",{className:"space-y-2 rounded-lg border border-line bg-bg-2 px-4 py-3 text-sm sm:px-5",children:[(0,n.jsx)("p",{children:"Sign in on the machine where agents run. OMP opens the provider's sign-in page or asks for a key, and stores it itself."}),(0,n.jsx)("pre",{className:"overflow-x-auto rounded-md bg-bg-3 px-3 py-2 font-mono text-xs",children:"omp login"}),(0,n.jsx)("p",{className:"text-ink-3",children:"Then press Check again."})]}):null,r.error?(0,n.jsxs)("div",{role:"alert",className:"rounded-md border border-warn px-3 py-2 text-sm text-ink-2",children:["OMP did not answer: ",r.error.message,". Check that omp is installed and on the server's PATH."]}):null,(0,n.jsxs)("section",{"aria-labelledby":"providers-title",className:"overflow-hidden rounded-lg border border-line bg-bg-2",children:[(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3 border-b border-line px-4 py-2.5 sm:px-5",children:[(0,n.jsx)("h2",{id:"providers-title",className:"text-xs font-semibold uppercase tracking-wide text-ink-3",children:"Providers"}),(0,n.jsx)("span",{className:"text-xs text-ink-3",children:r.data?`${r.data.length} models`:""})]}),r.isLoading?(0,n.jsx)("p",{className:"px-4 py-3 text-sm text-ink-3 sm:px-5",children:"Asking OMP..."}):d.length===0?(0,n.jsx)("p",{className:"px-4 py-3 text-sm text-ink-3 sm:px-5",children:"OMP reports no signed-in provider yet. Use Add provider."}):(0,n.jsx)("div",{className:"px-4 sm:px-5",children:(0,n.jsxs)("table",{"aria-label":"Providers",className:"stack-table w-full text-sm",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{className:"text-left text-xs text-ink-3",children:[(0,n.jsx)("th",{className:"py-2 font-medium",children:"Provider"}),(0,n.jsx)("th",{className:"py-2 font-medium",children:"Models"}),(0,n.jsx)("th",{className:"py-2 text-right font-medium",children:"Status"})]})}),(0,n.jsx)("tbody",{children:d.map(([h,p])=>(0,n.jsxs)("tr",{className:"border-t border-line",children:[(0,n.jsx)("td",{"data-cell":"title",className:"font-medium",children:h}),(0,n.jsx)("td",{"data-cell":"meta","data-label":"Models",children:p}),(0,n.jsx)("td",{"data-cell":"end",className:"text-right",children:(0,n.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-ok",children:[(0,n.jsx)("span",{"aria-hidden":"true",className:"size-2 rounded-full bg-ok"}),"Signed in"]})})]},h))})]})})]})]}):null}i(KMs,"ModelsAndProviders");var WMs={developer:"Developer",runtime:"Runtime"},QMs=ZUe("advanced");function VMs(e,t){return e?.enableWorktreeRunExecution!==!0?{kind:"off"}:e.worktreeRunExecutionActivatedAt?t?e.worktreeRunExecutionActivationInstanceId!==t?{kind:"fail_closed",reason:"instance_mismatch"}:{kind:"armed",activatedAt:e.worktreeRunExecutionActivatedAt}:{kind:"fail_closed",reason:"missing_instance_id"}:{kind:"fail_closed",reason:"missing_cutoff"}}i(VMs,"resolveWorktreeRunExecutionDisplayState");function HMs(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}i(HMs,"formatActivationTimestamp");function GMs({state:e}){return e.kind==="armed"?(0,n.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-line px-3 py-2 text-sm",children:[(0,n.jsx)(Wo,{"aria-hidden":"true",className:"size-4 shrink-0 text-(--status-task-done)"}),(0,n.jsxs)("span",{children:["Running tasks created after ",(0,n.jsx)("span",{className:"font-medium",children:HMs(e.activatedAt)}),"."]})]}):e.kind==="fail_closed"?(0,n.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-line px-3 py-2 text-sm",children:[(0,n.jsx)(En,{"aria-hidden":"true",className:"mt-0.5 size-4 shrink-0 text-ink-3"}),(0,n.jsxs)("div",{className:"space-y-0.5",children:[(0,n.jsx)("p",{className:"font-medium",children:"Execution is suppressed, so it is effectively off."}),(0,n.jsxs)("p",{className:"text-ink-3",children:[e.reason==="instance_mismatch"?"This was turned on in a different instance and copied here, so no tasks run automatically.":"This is missing its activation cutoff, so no tasks run automatically."," ","Turn it off and on again to run tasks created here."]})]})]}):null}i(GMs,"WorktreeRunExecutionState");function YMs(){const{setBreadcrumbs:e}=Hs(),t=nAt();if((0,m.useEffect)(()=>{e([{label:"Settings",href:"/company/settings"},{label:"Advanced"}])},[e]),t.query.isLoading)return(0,n.jsx)("div",{className:"text-sm text-ink-3",children:"Loading advanced settings..."});if(t.query.error)return(0,n.jsx)("div",{className:"text-sm text-bad",children:t.query.error.message||"Failed to load advanced settings."});const s=o_n(),r=QMs.filter(u=>!t.isHidden(u)&&(u!=="enableWorktreeRunExecution"||s)),a=i(u=>t.isCloudManaged?f3e[u].cloudDefault:f3e[u].selfHostedDefault,"defaultOf"),o=i(u=>t.isOn(u)!==a(u),"changed"),l=r.filter(u=>o(u)&&!t.isManaged(u)),c=i(()=>{t.save(Object.fromEntries(l.map(u=>[u,a(u)])))},"reset"),d=STt.map(u=>({group:u,keys:r.filter(h=>M5(h,"advanced")?.group===u)})).filter(({keys:u})=>u.length>0);return(0,n.jsxs)("div",{className:"max-w-4xl space-y-5",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Advanced"}),(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Tools for people who run or develop this instance."})]}),(0,n.jsxs)($,{variant:"secondary",disabled:t.pending||l.length===0,onClick:c,children:[(0,n.jsx)(ba,{"aria-hidden":"true"}),"Reset to defaults"]})]}),(0,n.jsxs)("div",{role:"note",className:"flex items-start gap-3 rounded-lg border border-line bg-bg-2 px-4 py-3 text-sm",children:[(0,n.jsx)(En,{"aria-hidden":"true",className:"mt-0.5 size-4 shrink-0 text-ink-3"}),(0,n.jsx)("p",{children:"These change how runs are executed or show internal data. Leave them alone unless you know why you need one."})]}),t.error?(0,n.jsx)("div",{role:"alert",className:"rounded-md border border-bad/40 px-3 py-2 text-sm text-bad",children:t.error}):null,d.map(({group:u,keys:h})=>(0,n.jsx)(tAt,{id:`advanced-group-${u}`,title:WMs[u],children:h.map(p=>{const f=M5(p,"advanced"),g=t.isManaged(p);return(0,n.jsx)(eAt,{name:f.name,summary:f.summary,checked:t.isOn(p),disabled:t.pending||g,onCheckedChange:i(x=>t.save({[p]:x}),"onCheckedChange"),badges:(0,n.jsxs)(n.Fragment,{children:[o(p)?(0,n.jsx)(lt,{variant:"outline",children:"changed"}):null,g?(0,n.jsx)(X5t,{}):null]}),children:p==="enableWorktreeRunExecution"?(0,n.jsx)(GMs,{state:VMs(t.settings,l_n())}):null},p)})},u))]})}i(YMs,"InstanceAdvanced");function JMs(){const{userId:e,settled:t}=jb(),{setBreadcrumbs:s}=Hs(),{pushToast:r}=Qa(),a=Ct(),[o,l]=(0,m.useState)(""),[c,d]=(0,m.useState)(null),[u,h]=(0,m.useState)(new Set);(0,m.useEffect)(()=>{s([{label:"Settings",href:"/company/settings"},{label:"Instance settings",href:"/company/settings/instance/general"},{label:"Access"}])},[s]);const p=ie({queryKey:O.access.adminUsers(o),queryFn:i(()=>jr.searchAdminUsers(o),"queryFn")}),f=ie({...X4t(e),enabled:t&&p.isSuccess}),g=f.data??[],x=(0,m.useMemo)(()=>p.data?.find(k=>k.id===c)??null,[c,p.data]),v=ie({queryKey:O.access.userCompanyAccess(c??""),queryFn:i(()=>jr.getUserCompanyAccess(c),"queryFn"),enabled:!!c});(0,m.useEffect)(()=>{!c&&p.data?.[0]&&d(p.data[0].id)},[c,p.data]),(0,m.useEffect)(()=>{v.data&&h(new Set(v.data.companyAccess.filter(k=>k.status==="active").map(k=>k.companyId)))},[v.data]);const b=ye({mutationFn:i(()=>jr.setUserCompanyAccess(c,[...u]),"mutationFn"),onSuccess:i(async()=>{await a.invalidateQueries({queryKey:O.access.userCompanyAccess(c)}),await a.invalidateQueries({queryKey:O.access.adminUsers(o)}),await a.invalidateQueries({queryKey:O.companies.all}),r({title:"Organization access updated",tone:"success"})},"onSuccess")}),y=ye({mutationFn:i(async k=>{if(!c)throw new Error("No user selected");return k?jr.promoteInstanceAdmin(c):jr.demoteInstanceAdmin(c)},"mutationFn"),onSuccess:i(async()=>{await a.invalidateQueries({queryKey:O.access.adminUsers(o)}),c&&await a.invalidateQueries({queryKey:O.access.userCompanyAccess(c)}),r({title:"Instance role updated",tone:"success"})},"onSuccess")});if(p.isLoading||!t||p.isSuccess&&f.isPending)return(0,n.jsx)("div",{className:"text-sm text-ink-3",children:"Loading instance access…"});if(p.error){const k=p.error instanceof ss&&p.error.status===403?"Instance admin access is required to manage users.":p.error instanceof Error?p.error.message:"Failed to load users.";return(0,n.jsx)("div",{className:"text-sm text-bad",children:k})}return f.error?(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsx)("p",{className:"text-sm text-bad",children:"Failed to load organizations. Try again before changing access."}),(0,n.jsx)($,{onClick:i(()=>{f.refetch()},"onClick"),children:"Try again"})]}):(0,n.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(UQ,{className:"h-5 w-5 text-ink-3"}),(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Instance Access"})]}),(0,n.jsx)("p",{className:"max-w-3xl text-sm text-ink-3",children:"Search users, manage instance-admin status, and control which organizations they can access."})]}),(0,n.jsxs)("div",{className:"grid gap-6 lg:grid-cols-(--gtc-34)",children:[(0,n.jsxs)(hs,{className:"block space-y-4 p-4",children:[(0,n.jsxs)("label",{className:"block space-y-2 text-sm",children:[(0,n.jsx)("span",{className:"font-medium",children:"Search users"}),(0,n.jsx)("input",{className:"w-full rounded-md border border-line bg-bg px-3 py-2",value:o,onChange:i(k=>l(k.target.value),"onChange"),placeholder:"Search by name or email"})]}),(0,n.jsx)("div",{className:"space-y-2",children:(p.data??[]).map(k=>(0,n.jsxs)("button",{type:"button",onClick:i(()=>d(k.id),"onClick"),className:`w-full rounded-lg border px-3 py-3 text-left transition-colors ${k.id===c?"border-ink bg-bg-3":"border-line hover:bg-bg-3/40"}`,children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("div",{className:"truncate font-medium",children:k.name||k.email||k.id}),(0,n.jsx)("div",{className:"truncate text-sm text-ink-3",children:k.email||k.id})]}),k.isInstanceAdmin?(0,n.jsx)(oo,{className:"h-4 w-4 text-emerald-600"}):null]}),(0,n.jsxs)("div",{className:"mt-2 text-xs text-ink-3",children:[k.activeCompanyMembershipCount," active organization memberships"]})]},k.id))})]}),(0,n.jsx)(hs,{className:"block space-y-4 p-5",children:c?v.isLoading?(0,n.jsx)("div",{className:"text-sm text-ink-3",children:"Loading user access…"}):v.error?(0,n.jsx)("div",{className:"text-sm text-bad",children:v.error instanceof Error?v.error.message:"Failed to load user access."}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-lg font-semibold",children:x?.name||x?.email||c}),(0,n.jsx)("div",{className:"text-sm text-ink-3",children:x?.email||c})]}),(0,n.jsx)($,{variant:x?.isInstanceAdmin?"secondary":"primary",onClick:i(()=>y.mutate(!(x?.isInstanceAdmin??!1)),"onClick"),disabled:y.isPending,children:x?.isInstanceAdmin?"Remove instance admin":"Promote to instance admin"})]}),(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"text-sm font-semibold",children:"Organization access"}),(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Toggle organization membership for this user. New access defaults to an active operator membership."})]}),(0,n.jsx)("div",{className:"grid gap-3 md:grid-cols-2",children:g.map(k=>(0,n.jsxs)("label",{className:"flex items-start gap-3 rounded-lg border border-line px-3 py-3",children:[(0,n.jsx)(Ci,{checked:u.has(k.id),onCheckedChange:i(j=>{h(N=>{const S=new Set(N);return j?S.add(k.id):S.delete(k.id),S})},"onCheckedChange")}),(0,n.jsxs)("span",{className:"space-y-1",children:[(0,n.jsx)("span",{className:"block text-sm font-medium",children:k.name}),(0,n.jsx)("span",{className:"block text-xs text-ink-3",children:k.issuePrefix})]})]},k.id))}),(0,n.jsx)("div",{className:"flex justify-end",children:(0,n.jsx)($,{onClick:i(()=>b.mutate(),"onClick"),disabled:b.isPending,children:b.isPending?"Saving…":"Save organization access"})})]}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("h2",{className:"text-sm font-semibold",children:"Current memberships"}),(0,n.jsx)("div",{className:"space-y-2",children:(v.data?.companyAccess??[]).map(k=>(0,n.jsxs)("div",{className:"flex items-center justify-between rounded-lg border border-line px-3 py-2 text-sm",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"font-medium",children:k.companyName||k.companyId}),(0,n.jsxs)("div",{className:"text-ink-3",children:[k.membershipRole||"unset"," • ",k.status]})]}),(0,n.jsx)("div",{className:"text-xs text-ink-3",children:new Date(k.updatedAt).toLocaleDateString()})]},k.id))})]})]}):(0,n.jsx)("div",{className:"text-sm text-ink-3",children:"Select a user to inspect instance access."})})]})]})}i(JMs,"InstanceAccess");var Jqe={getMine:i(e=>le.get(`/companies/${e}/users/me/inbox-agent-policy`),"getMine"),updateMine:i((e,t)=>le.put(`/companies/${e}/users/me/inbox-agent-policy`,t),"updateMine")},ZMs=[{value:"open",title:"Any of my agents",description:"Let any agent you manage archive tasks out of your inbox."},{value:"allowlist",title:"Only chosen agents",description:"Restrict inbox tidying to the agents you pick below."},{value:"disabled",title:"Off",description:"Agents can never archive tasks from your inbox."}];function qF(e,t){return`${e}:${[...t].sort().join(",")}`}i(qF,"policyKey");function XMs({companyId:e}){const t=Ct(),[s,r]=(0,m.useState)(null),a=(0,m.useRef)(null),o=ie({queryKey:e?O.inboxAgentPolicy.mine(e):["inbox-agent-policy","none"],queryFn:i(()=>Jqe.getMine(e),"queryFn"),enabled:!!e}),l=o.data,c=ie({queryKey:e?O.agents.list(e):["agents","none"],queryFn:i(()=>Pt.list(e),"queryFn"),enabled:!!e}),d=(0,m.useMemo)(()=>(c.data??[]).filter(ux),[c.data]),u=(0,m.useMemo)(()=>d.map(g=>({id:g.id,name:g.name,title:g.title??g.role,icon:g.icon})),[d]),h=(0,m.useMemo)(()=>new Set(s?.allowedAgentIds??[]),[s?.allowedAgentIds]);(0,m.useEffect)(()=>{if(!l)return;const g=qF(l.mode,l.allowedAgentIds);r(x=>x===null||qF(x.mode,x.allowedAgentIds)===a.current?{mode:l.mode,allowedAgentIds:l.allowedAgentIds}:x),a.current=g},[l]);const p=ye({mutationFn:i(g=>Jqe.updateMine(e,{mode:g.mode,allowedAgentIds:g.mode==="allowlist"?g.allowedAgentIds:[]}),"mutationFn"),onSuccess:i(g=>{t.setQueryData(O.inboxAgentPolicy.mine(e),g)},"onSuccess")}),f=!!(s&&l&&qF(s.mode,s.allowedAgentIds)!==qF(l.mode,l.allowedAgentIds));return o.error?(0,n.jsx)("div",{className:"text-sm text-bad",children:o.error instanceof Error?o.error.message:"Failed to load inbox agent policy."}):o.isLoading||!s?(0,n.jsx)("div",{className:"text-sm text-ink-3",children:"Loading inbox agent policy…"}):(0,n.jsxs)("section",{className:"space-y-4","aria-label":"Let agents tidy my inbox",children:[(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(w0,{className:"h-5 w-5 text-ink-3"}),(0,n.jsx)("h2",{className:"text-base font-semibold",children:"Let agents tidy my inbox"})]}),(0,n.jsx)("p",{className:"max-w-2xl text-sm text-ink-3",children:"Choose whether the agents you manage may archive tasks out of your inbox on your behalf. You can undo any archive, and every agent archive is attributed in the task's properties."})]}),(0,n.jsx)(xp,{ariaLabel:"Inbox agent archiving policy",value:s.mode,onValueChange:i(g=>r(x=>x&&{...x,mode:g}),"onValueChange"),options:ZMs,className:"max-w-2xl"}),s.mode==="allowlist"?(0,n.jsxs)("div",{className:"max-w-2xl space-y-2",children:[(0,n.jsx)("div",{className:"text-sm font-medium",children:"Agents allowed to tidy my inbox"}),(0,n.jsx)(ZS,{agents:u,selectedAgentIds:h,onChange:i(g=>r(x=>x&&{...x,allowedAgentIds:[...g]}),"onChange"),triggerLabel:h.size===0?"Select agents":`${h.size} ${h.size===1?"agent":"agents"} selected`,triggerFullWidth:!1,showSelectionPreview:!1,emptyMessage:"You don’t manage any agents yet."})]}):null,p.error?(0,n.jsx)("div",{className:"max-w-2xl rounded-md border border-bad/40 bg-bad/5 px-3 py-2 text-sm text-bad",children:p.error instanceof Error?p.error.message:"Failed to save inbox agent policy."}):null,(0,n.jsxs)("div",{className:"flex max-w-2xl items-center justify-end gap-3",children:[p.isSuccess&&!f?(0,n.jsx)("span",{className:"text-xs text-ink-3",role:"status",children:"Saved"}):null,(0,n.jsxs)($,{type:"button",disabled:!f||p.isPending,onClick:i(()=>s&&p.mutate(s),"onClick"),children:[p.isPending?(0,n.jsx)(ct,{className:"size-4 animate-spin"}):(0,n.jsx)(Qv,{className:"size-4"}),p.isPending?"Saving…":"Save"]})]})]})}i(XMs,"InboxAgentPolicyControl");var eLs={granted:"Allowed",denied:"Blocked in browser settings",default:"Not requested yet",unsupported:"Not supported in this browser"},Zqe={unknown:"Checking…",active:"Active on this device",off:"Off",unsupported:"Not supported in this browser",permission:"Waiting for notification permission","server-disabled":"Not available on this server",error:"Subscription failed"};function tLs(){const[e,t]=(0,m.useState)({});return(0,m.useEffect)(()=>{let s=!1;const r=i(()=>{Promise.all(G8.map(async o=>[o,(await f1t(o))?.name])).then(o=>{if(s)return;const l={};for(const[c,d]of o)d&&(l[c]=d);t(l)})},"refresh");r();const a=m1t(r);return()=>{s=!0,a()}},[]),e}i(tLs,"useCustomSoundNames");function nLs({kind:e,customName:t,disabled:s,onError:r}){const a=S1t(),o=a.kinds[e],l=(0,m.useId)(),[c,d]=(0,m.useState)(!1),u=hZn[e];async function h(g){const x=u1t(g);if(!x.ok){r(`${u}: ${x.error}`);return}d(!0);try{await cZn(e,g),EO(e,{soundId:a7e}),r(null)}catch(v){r(v instanceof Error?v.message:"Could not save the custom sound.")}finally{d(!1)}}i(h,"upload");async function p(){d(!0);try{await dZn(e),Ok().kinds[e].soundId==="custom"&&EO(e,{soundId:$W[e]})}finally{d(!1)}}i(p,"remove");const f=s||!o.enabled;return(0,n.jsxs)("div",{className:"flex flex-col gap-2 border-b border-line/70 py-3 last:border-b-0 sm:flex-row sm:items-center sm:gap-3",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-3 sm:w-48 sm:shrink-0",children:[(0,n.jsx)(ma,{checked:o.enabled,onCheckedChange:i(g=>EO(e,{enabled:g}),"onCheckedChange"),disabled:s,"aria-label":`${u} notifications`}),(0,n.jsx)("div",{className:"min-w-0 flex-1 truncate text-sm font-medium",title:u,children:u})]}),(0,n.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 sm:flex-1 sm:flex-nowrap",children:[(0,n.jsxs)(Pi,{value:o.soundId,onValueChange:i(g=>EO(e,{soundId:g}),"onValueChange"),disabled:f,children:[(0,n.jsx)(Oi,{className:"min-w-0 flex-1 sm:w-(--sz-170px) sm:flex-none","aria-label":`${u} sound`,children:(0,n.jsx)($i,{})}),(0,n.jsxs)(Fi,{children:[g1t.map(g=>(0,n.jsx)(bs,{value:g.id,children:g.label},g.id)),t?(0,n.jsxs)(bs,{value:a7e,children:["Custom: ",t]}):null,(0,n.jsx)(bs,{value:uZn,children:"No sound"})]})]}),(0,n.jsx)($,{type:"button",variant:"secondary",size:"icon-sm","aria-label":`Preview ${u} sound`,disabled:f||o.soundId==="none",onClick:i(()=>{k1t(e,o.soundId,a.volume)},"onClick"),children:(0,n.jsx)(Wo,{})}),(0,n.jsx)("input",{id:l,type:"file",accept:"audio/*",className:"sr-only",disabled:f||c,onChange:i(g=>{const x=g.target.files?.[0];g.target.value="",x&&h(x)},"onChange")}),(0,n.jsxs)($,{type:"button",variant:"secondary",size:"sm",disabled:f||c,onClick:i(()=>document.getElementById(l)?.click(),"onClick"),children:[c?(0,n.jsx)(ct,{className:"animate-spin"}):(0,n.jsx)(L3,{}),t?"Replace":"Custom"]}),t?(0,n.jsx)($,{type:"button",variant:"ghost",size:"icon-sm","aria-label":`Remove custom ${u} sound`,disabled:c,onClick:i(()=>{p()},"onClick"),children:(0,n.jsx)(wi,{})}):null]})]})}i(nLs,"KindRow");function sLs({userId:e}){const t=S1t(),s=jZn(),r=tLs(),[a,o]=(0,m.useState)(()=>wA()),[l,c]=(0,m.useState)(null),[d,u]=(0,m.useState)(null),[h,p]=(0,m.useState)(!1),f=l1t(),g=s.status==="active",x=(0,m.useCallback)(()=>{e&&qW(Ok(),e)},[e]);async function v(){const N=await o1t();return o(N),N==="granted"&&x(),N}i(v,"askPermission");async function b(N){X6(S=>({...S,enabled:N})),N&&wA()==="default"&&await v()}i(b,"setEnabled");async function y(N){X6(S=>({...S,pushEnabled:N})),N&&wA()==="default"&&await v()}i(y,"setPushEnabled");async function k(){p(!0),c(null),u(null);try{const N=await FW.sendWebPushTest();c(N.sent>0?`Test sent to ${N.sent} device${N.sent===1?"":"s"}.`:"No device has push turned on for your account yet.")}catch(N){u(N instanceof Error?N.message:"Could not send the test notification.")}finally{p(!1)}}i(k,"sendTest");const j=!t.enabled;return(0,n.jsxs)("section",{className:"space-y-4","aria-label":"Notifications",children:[(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(g7t,{className:"h-5 w-5 text-ink-3"}),(0,n.jsx)("h2",{className:"text-base font-semibold",children:"Notifications"})]}),(0,n.jsx)("p",{className:"max-w-2xl text-sm text-ink-3",children:"Sounds and alerts for approvals, agent questions, comments, assignments, reviews, failed runs and join requests. These settings apply to this browser only."})]}),(0,n.jsxs)("div",{className:"max-w-3xl space-y-4 rounded-md border border-line/70 p-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("div",{className:"text-sm font-medium",children:"Notifications on this device"}),(0,n.jsx)("div",{className:"text-xs text-ink-3",children:"Play sounds and show alerts for new inbox items."})]}),(0,n.jsx)(ma,{checked:t.enabled,onCheckedChange:i(N=>{b(N)},"onCheckedChange"),"aria-label":"Notifications on this device"})]}),(0,n.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("div",{className:"text-sm font-medium",children:"Browser permission"}),(0,n.jsx)("div",{className:"text-xs text-ink-3",children:eLs[a]})]}),a==="default"?(0,n.jsx)($,{type:"button",variant:"secondary",size:"sm",className:"shrink-0",onClick:i(()=>{v()},"onClick"),children:"Allow notifications"}):null]}),(0,n.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("div",{className:"text-sm font-medium",children:"Push when Wardmote is closed"}),(0,n.jsxs)("div",{className:"text-xs text-ink-3",children:[f?Zqe[s.status]:Zqe.unsupported,s.error?`: ${s.error}`:""]})]}),(0,n.jsx)(ma,{checked:t.pushEnabled,onCheckedChange:i(N=>{y(N)},"onCheckedChange"),disabled:j||!f,"aria-label":"Push when Wardmote is closed"})]}),t.enabled&&!g?(0,n.jsx)("p",{className:"rounded-md bg-bg-3 px-3 py-2 text-xs text-ink-3",children:"Push is off on this device, so background alerts only work while a Wardmote tab is visible."}):null,ZJn()?(0,n.jsx)("p",{className:"rounded-md bg-bg-3 px-3 py-2 text-xs text-ink-3",children:"On iPhone and iPad, push notifications need Wardmote added to the Home Screen (Share, then Add to Home Screen) and opened from there."}):null,(0,n.jsxs)("div",{className:"flex items-center gap-4",children:[(0,n.jsx)("label",{htmlFor:"notification-volume",className:"text-sm font-medium",children:"Volume"}),(0,n.jsx)("input",{id:"notification-volume",type:"range",min:0,max:100,step:5,value:Math.round(t.volume*100),disabled:j,onChange:i(N=>X6(S=>({...S,volume:Number(N.target.value)/100})),"onChange"),className:"h-1.5 w-full max-w-xs"}),(0,n.jsxs)("span",{className:"w-10 text-right text-xs text-ink-3",children:[Math.round(t.volume*100),"%"]})]}),(0,n.jsx)("div",{children:G8.map(N=>(0,n.jsx)(nLs,{kind:N,customName:r[N],disabled:j,onError:u},N))}),(0,n.jsx)("p",{className:"text-xs text-ink-3",children:"Custom sounds must be audio files of 512 KB or less. They play only while Wardmote is open; push notifications use your system sound."}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,n.jsxs)($,{type:"button",variant:"secondary",onClick:i(()=>{k()},"onClick"),disabled:h||j,children:[h?(0,n.jsx)(ct,{className:"animate-spin"}):(0,n.jsx)(hV,{}),"Send test notification"]}),l?(0,n.jsx)("span",{className:"text-sm text-ink-3",children:l}):null]}),d?(0,n.jsx)("div",{className:"text-sm text-bad",children:d}):null]})]})}i(sLs,"NotificationSettingsSection");function rLs(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length>=2?`${t[0]?.[0]??""}${t[t.length-1]?.[0]??""}`.toUpperCase():e.slice(0,2).toUpperCase()}i(rLs,"deriveInitials");function iLs(){const{setBreadcrumbs:e}=Hs(),{selectedCompanyId:t,selectedCompany:s}=gn(),r=Ct(),a=(0,m.useId)(),o=(0,m.useRef)(null),[l,c]=(0,m.useState)(""),[d,u]=(0,m.useState)(""),[h,p]=(0,m.useState)(null),f=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),retry:!1});(0,m.useEffect)(()=>{e([{label:"Settings",href:"/company/settings"},{label:"Profile"}])},[e]),(0,m.useEffect)(()=>{const _=f.data;_&&(c(_.user.name??""),u(_.user.image??""))},[f.data]);function g(_){r.setQueryData(O.auth.session,T=>T&&{...T,user:{...T.user,..._}})}i(g,"syncSessionProfile");async function x(_){const T=await Ji.updateProfile(_);return g(T),T}i(x,"persistProfile");function v(){return l.trim()||f.data?.user.name||"Board"}i(v,"resolveProfileName");const b=ye({mutationFn:i(_=>x(_),"mutationFn"),onSuccess:i(_=>{p(null),c(_.name??""),u(_.image??"")},"onSuccess"),onError:i(_=>{p(_ instanceof Error?_.message:"Failed to update profile.")},"onError")}),y=ye({mutationFn:i(async _=>{if(!t)throw new Error("Select an organization before uploading a profile avatar.");const T=await G1.uploadImage(t,_,`profiles/${f.data?.user.id??"board-user"}`);return x({name:v(),image:T.contentPath})},"mutationFn"),onSuccess:i(_=>{p(null),c(_.name??""),u(_.image??"")},"onSuccess"),onError:i(_=>{p(_ instanceof Error?_.message:"Failed to upload avatar.")},"onError")}),k=ye({mutationFn:i(()=>x({name:v(),image:null}),"mutationFn"),onSuccess:i(_=>{p(null),c(_.name??""),u(_.image??"")},"onSuccess"),onError:i(_=>{p(_ instanceof Error?_.message:"Failed to remove avatar.")},"onError")});if(f.isLoading)return(0,n.jsx)("div",{className:"text-sm text-ink-3",children:"Loading profile..."});if(f.error||!f.data)return(0,n.jsx)("div",{className:"text-sm text-bad",children:f.error instanceof Error?f.error.message:"Failed to load profile."});const j=l.trim()||f.data.user.name||"Board",N=d.trim()||null,S=rLs(j),A=b.isPending||y.isPending||k.isPending,I=s?`Stored in Wardmote file storage for ${s.name}.`:"Select an organization to upload an avatar into Wardmote storage.";return(0,n.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(K0e,{className:"h-5 w-5 text-ink-3"}),(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Profile"})]}),(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Control how your account appears in the sidebar and other board surfaces."})]}),h?(0,n.jsx)("div",{className:"rounded-md border border-bad/40 bg-bad/5 px-3 py-2 text-sm text-bad",children:h}):null,(0,n.jsxs)("section",{className:"space-y-8",children:[(0,n.jsxs)(hs,{className:"block relative overflow-hidden rounded-(--rad-28) border-line/70",children:[(0,n.jsx)("div",{className:"absolute inset-x-0 top-0 h-32 bg-(image:--gradient-extract-26)"}),(0,n.jsx)("div",{className:"absolute inset-0 bg-(image:--gradient-extract-7)"}),(0,n.jsx)("div",{className:"relative p-6 pt-10",children:(0,n.jsxs)("div",{className:"flex flex-wrap items-end gap-5 rounded-(--rad-24) border border-line/70 bg-bg/92 p-5 shadow-(--shadow-extract-18) backdrop-blur-sm",children:[(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("label",{htmlFor:a,className:"group relative block cursor-pointer rounded-full focus-within:outline-none focus-within:ring-2 focus-within:ring-focus focus-within:ring-offset-2 focus-within:ring-offset-bg",children:[(0,n.jsx)("input",{ref:o,id:a,type:"file",accept:"image/*",className:"sr-only",disabled:!t||A,onChange:i(_=>{const T=_.target.files?.[0];T&&(y.mutate(T),_.target.value="")},"onChange")}),(0,n.jsx)("span",{className:"absolute inset-0 z-10 rounded-full bg-black/0 transition-colors group-hover:bg-black/14 group-focus-within:bg-black/14"}),(0,n.jsx)("span",{className:"absolute bottom-1 right-1 z-20 flex size-9 items-center justify-center rounded-full border border-bg bg-accent text-accent-ink shadow-sm",children:y.isPending?(0,n.jsx)(ct,{className:"size-4 animate-spin"}):(0,n.jsx)(oSe,{className:"size-4"})}),(0,n.jsxs)(yl,{size:"lg",className:"data-[size=lg]:size-24 ring-4 ring-bg shadow-xl",children:[N?(0,n.jsx)(th,{src:N,alt:j}):null,(0,n.jsx)(kl,{children:S})]})]}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsxs)($,{type:"button",variant:"secondary",onClick:i(()=>o.current?.click(),"onClick"),disabled:!t||A,children:[y.isPending?(0,n.jsx)(ct,{className:"size-4 animate-spin"}):(0,n.jsx)(oSe,{className:"size-4"}),N?"Change photo":"Upload photo"]}),N?(0,n.jsxs)($,{type:"button",variant:"secondary",onClick:i(()=>k.mutate(),"onClick"),disabled:A,children:[k.isPending?(0,n.jsx)(ct,{className:"size-4 animate-spin"}):(0,n.jsx)(wi,{className:"size-4"}),"Remove"]}):null]})]}),(0,n.jsxs)("div",{className:"min-w-0 flex-1 space-y-2 pb-1",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"truncate text-2xl font-semibold text-ink",children:j}),(0,n.jsx)("p",{className:"truncate text-sm text-ink-3",children:f.data.user.email??"No email"})]}),(0,n.jsxs)("p",{className:"max-w-2xl text-sm leading-6 text-ink-3",children:["Click the avatar to upload a new image. ",I]})]})]})})]}),(0,n.jsxs)("form",{className:"grid gap-6 md:grid-cols-2",onSubmit:i(_=>{_.preventDefault(),b.mutate({name:v(),image:d.trim()||null})},"onSubmit"),children:[(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(Fn,{htmlFor:"profile-name",children:"Display name"}),(0,n.jsx)(mt,{id:"profile-name",value:l,onChange:i(_=>c(_.target.value),"onChange"),maxLength:120,placeholder:"Board"}),(0,n.jsx)("p",{className:"text-xs text-ink-3",children:"Shown in the sidebar account footer and comment author surfaces."})]}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(Fn,{htmlFor:"profile-email",children:"Email"}),(0,n.jsx)(mt,{id:"profile-email",value:f.data.user.email??"",readOnly:!0,disabled:!0}),(0,n.jsx)("p",{className:"text-xs text-ink-3",children:"Email is managed by your auth session and is read-only here."})]}),(0,n.jsx)("div",{className:"md:col-span-2 flex justify-end",children:(0,n.jsxs)($,{type:"submit",disabled:A||!l.trim(),children:[b.isPending?(0,n.jsx)(ct,{className:"size-4 animate-spin"}):(0,n.jsx)(Qv,{className:"size-4"}),b.isPending?"Saving...":"Save profile"]})})]}),(0,n.jsx)(XMs,{companyId:t}),(0,n.jsx)(sLs,{userId:f.data.user.id??null})]})]})}i(iLs,"ProfileSettings");function aLs(e){return e?e.split(/\r?\n/).map(t=>t.trim()).find(Boolean)??null:null}i(aLs,"firstNonEmptyLine");function Xqe(e){return aLs(e.lastError)??"Plugin entered an error state without a stored error message."}i(Xqe,"getPluginErrorSummary");function eUe(e){if(e.bundledExperimental)return!0;const t=e.packageName??"",s=e.packagePath??"";return t.includes("sandbox")||s.includes("sandbox")?!0:e.manifestJson?.environmentDrivers?.some(r=>r.kind==="sandbox_provider")===!0}i(eUe,"isExperimentalPluginIdentity");function tUe(){return(0,n.jsx)(lt,{variant:"outline",className:"border-amber-500/30 bg-amber-500/10 text-amber-700 hover:bg-amber-500/10 dark:text-amber-200",children:"Beta"})}i(tUe,"ExperimentalBadge");function oLs(){const{selectedCompany:e}=gn(),{setBreadcrumbs:t}=Hs(),s=Ct(),{pushToast:r}=ri(),[a,o]=(0,m.useState)(""),[l,c]=(0,m.useState)(!1),[d,u]=(0,m.useState)(null),[h,p]=(0,m.useState)(""),[f,g]=(0,m.useState)(null);(0,m.useEffect)(()=>{t([{label:e?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"Plugins"}])},[e?.name,t]);const{data:x,isLoading:v,error:b}=ie({queryKey:O.plugins.all,queryFn:i(()=>Yc.list(),"queryFn")}),y=ie({queryKey:O.plugins.examples,queryFn:i(()=>Yc.listBundled(),"queryFn")}),k=i(()=>{s.invalidateQueries({queryKey:O.plugins.all}),s.invalidateQueries({queryKey:O.plugins.examples}),s.invalidateQueries({queryKey:O.plugins.uiContributions})},"invalidatePluginQueries"),j=ye({mutationFn:i(D=>Yc.install(D),"mutationFn"),onSuccess:i(()=>{k(),c(!1),o(""),r({title:"Plugin installed successfully",tone:"success"})},"onSuccess"),onError:i(D=>{r({title:"Failed to install plugin",body:D.message,tone:"error"})},"onError")}),N=ye({mutationFn:i(D=>Yc.uninstall(D),"mutationFn"),onSuccess:i(()=>{k(),r({title:"Plugin uninstalled successfully",tone:"success"})},"onSuccess"),onError:i(D=>{r({title:"Failed to uninstall plugin",body:D.message,tone:"error"})},"onError")}),S=ye({mutationFn:i(D=>Yc.enable(D),"mutationFn"),onSuccess:i(()=>{k(),r({title:"Plugin enabled",tone:"success"})},"onSuccess"),onError:i(D=>{r({title:"Failed to enable plugin",body:D.message,tone:"error"})},"onError")}),A=ye({mutationFn:i(D=>Yc.disable(D),"mutationFn"),onSuccess:i(()=>{k(),r({title:"Plugin disabled",tone:"info"})},"onSuccess"),onError:i(D=>{r({title:"Failed to disable plugin",body:D.message,tone:"error"})},"onError")}),I=x??[],_=y.data??[],T=new Map(I.map(D=>[D.packageName,D])),E=new Map(_.map(D=>[D.packageName,D])),M=j.variables?.isLocalPath?j.error?.message??null:null,P=(0,m.useMemo)(()=>new Map(I.map(D=>[D.id,Xqe(D)])),[I]);return v?(0,n.jsx)("div",{className:"p-4 text-sm text-ink-3",children:"Loading plugins..."}):b?(0,n.jsx)("div",{className:"p-4 text-sm text-bad",children:"Failed to load plugins."}):(0,n.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(t3,{className:"h-6 w-6 text-ink-3"}),(0,n.jsx)("h1",{className:"text-xl font-semibold",children:"Plugin Manager"})]}),(0,n.jsxs)(Bn,{open:l,onOpenChange:c,children:[(0,n.jsx)(kk,{asChild:!0,children:(0,n.jsxs)($,{size:"sm",className:"gap-2",children:[(0,n.jsx)(js,{className:"h-4 w-4"}),"Install Plugin"]})}),(0,n.jsxs)(zn,{children:[(0,n.jsxs)(rs,{children:[(0,n.jsx)(qn,{children:"Install Plugin"}),(0,n.jsx)(ds,{children:"Enter the npm package name of the plugin you wish to install."})]}),(0,n.jsx)("div",{className:"grid gap-4 py-4",children:(0,n.jsxs)("div",{className:"grid gap-2",children:[(0,n.jsx)(Fn,{htmlFor:"packageName",children:"npm Package Name"}),(0,n.jsx)(mt,{id:"packageName",placeholder:"@tickernelz/wardmote-plugin-example",value:a,onChange:i(D=>o(D.target.value),"onChange")})]})}),(0,n.jsxs)(fr,{children:[(0,n.jsx)($,{variant:"secondary",onClick:i(()=>c(!1),"onClick"),children:"Cancel"}),(0,n.jsx)($,{onClick:i(()=>j.mutate({packageName:a}),"onClick"),disabled:!a||j.isPending,children:j.isPending?"Installing...":"Install"})]})]})]})]}),(0,n.jsx)("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 px-4 py-3",children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)(En,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-700"}),(0,n.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,n.jsx)("p",{className:"font-medium text-ink",children:"Plugins are alpha."}),(0,n.jsx)("p",{className:"text-ink-3",children:"The plugin runtime and API surface are still changing. Expect breaking changes while this feature settles."})]})]})}),(0,n.jsxs)("section",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(nb,{className:"h-5 w-5 text-ink-3"}),(0,n.jsx)("h2",{className:"text-base font-semibold",children:"Available Plugins"}),(0,n.jsx)(lt,{variant:"outline",children:"Bundled"})]}),M&&(0,n.jsx)("div",{className:"rounded-md border border-bad/25 bg-bad/[0.06] px-4 py-3 text-sm text-bad whitespace-pre-wrap break-words",children:M}),y.isLoading?(0,n.jsx)("div",{className:"text-sm text-ink-3",children:"Loading bundled plugins..."}):y.error?(0,n.jsx)("div",{className:"text-sm text-bad",children:"Failed to load bundled plugins."}):_.length===0?(0,n.jsx)("div",{className:"rounded-md border border-dashed px-4 py-3 text-sm text-ink-3",children:"No bundled plugins were found in this checkout."}):(0,n.jsx)(hs,{className:"block py-0",children:(0,n.jsx)("ul",{className:"divide-y",children:_.map(D=>{const K=T.get(D.packageName),L=j.isPending&&j.variables?.isLocalPath&&j.variables.packageName===D.localPath;return(0,n.jsx)("li",{children:(0,n.jsxs)("div",{className:"flex items-center gap-4 px-4 py-3",children:[(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)("span",{className:"font-medium",children:D.displayName}),(0,n.jsx)(lt,{variant:"outline",children:D.tag==="first-party"?"First-party":"Example"}),eUe({packageName:D.packageName,packagePath:D.localPath,bundledExperimental:D.experimental})&&(0,n.jsx)(tUe,{}),K?(0,n.jsx)(lt,{variant:K.status==="ready"?"default":"secondary",className:K.status==="ready"?"bg-green-600 hover:bg-green-700":"",children:K.status}):(0,n.jsx)(lt,{variant:"secondary",children:"Not installed"})]}),(0,n.jsx)("p",{className:"mt-1 text-sm text-ink-3",children:D.description}),(0,n.jsx)("p",{className:"mt-1 text-xs text-ink-3",children:D.packageName}),L&&!D.hasBuiltEntrypoints&&(0,n.jsx)("p",{className:"mt-2 text-xs text-ink-3",children:"Building plugin..."})]}),(0,n.jsx)("div",{className:"flex items-center gap-2 shrink-0",children:K?(0,n.jsxs)(n.Fragment,{children:[K.status!=="ready"&&(0,n.jsx)($,{variant:"secondary",size:"sm",disabled:S.isPending,onClick:i(()=>S.mutate(K.id),"onClick"),children:"Enable"}),(0,n.jsx)($,{variant:"secondary",size:"sm",asChild:!0,children:(0,n.jsx)(Ye,{to:`/company/settings/instance/plugins/${K.id}`,children:K.status==="ready"?"Open Settings":"Review"})})]}):(0,n.jsx)($,{size:"sm",disabled:L||j.isPending,onClick:i(()=>j.mutate({packageName:D.localPath,isLocalPath:!0}),"onClick"),children:L?"Installing...":"Install"})})]})},D.packageName)})})})]}),(0,n.jsxs)("section",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(t3,{className:"h-5 w-5 text-ink-3"}),(0,n.jsx)("h2",{className:"text-base font-semibold",children:"Installed Plugins"})]}),I.length?(0,n.jsx)(hs,{className:"block py-0",children:(0,n.jsx)("ul",{className:"divide-y",children:I.map(D=>(0,n.jsx)("li",{children:(0,n.jsxs)("div",{className:"flex items-start gap-4 px-4 py-3",children:[(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)(Ye,{to:`/company/settings/instance/plugins/${D.id}`,className:"font-medium hover:underline truncate block",title:D.manifestJson.displayName??D.packageName,children:D.manifestJson.displayName??D.packageName}),E.has(D.packageName)&&(0,n.jsx)(lt,{variant:"outline",children:E.get(D.packageName)?.tag==="first-party"?"First-party":"Example"}),eUe({packageName:D.packageName,packagePath:D.packagePath,manifestJson:D.manifestJson,bundledExperimental:E.get(D.packageName)?.experimental})&&(0,n.jsx)(tUe,{})]}),(0,n.jsx)("div",{children:(0,n.jsxs)("p",{className:"text-xs text-ink-3 mt-0.5 truncate",title:D.packageName,children:[D.packageName," · v",D.manifestJson.version??D.version]})}),(0,n.jsx)("p",{className:"text-sm text-ink-3 truncate mt-0.5",title:D.manifestJson.description,children:D.manifestJson.description||"No description provided."}),D.status==="error"&&(0,n.jsx)("div",{className:"mt-3 rounded-md border border-red-500/25 bg-red-500/[0.06] px-3 py-2",children:(0,n.jsxs)("div",{className:"flex flex-wrap items-start gap-3",children:[(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-red-700 dark:text-red-300",children:[(0,n.jsx)(En,{className:"h-4 w-4 shrink-0"}),(0,n.jsx)("span",{children:"Plugin error"})]}),(0,n.jsx)("p",{className:"mt-1 text-sm text-red-700/90 dark:text-red-200/90 break-words",title:D.lastError??void 0,children:P.get(D.id)})]}),(0,n.jsx)($,{variant:"danger",size:"sm",onClick:i(()=>g(D),"onClick"),children:"View full error"})]})})]}),(0,n.jsx)("div",{className:"flex shrink-0 self-center",children:(0,n.jsxs)("div",{className:"flex flex-col items-end gap-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(lt,{variant:D.status==="ready"?"default":D.status==="error"?"destructive":"secondary",className:Q("shrink-0",D.status==="ready"?"bg-green-600 hover:bg-green-700":""),children:D.status}),(0,n.jsx)($,{variant:"secondary",size:"icon-sm",className:"h-8 w-8",title:D.status==="ready"?"Disable":"Enable",onClick:i(()=>{D.status==="ready"?A.mutate(D.id):S.mutate(D.id)},"onClick"),disabled:S.isPending||A.isPending,children:(0,n.jsx)(P0e,{className:Q("h-4 w-4",D.status==="ready"?"text-green-600":"")})}),(0,n.jsx)($,{variant:"danger",size:"icon-sm",className:"h-8 w-8",title:"Uninstall",onClick:i(()=>{u(D.id),p(D.manifestJson.displayName??D.packageName)},"onClick"),disabled:N.isPending,children:(0,n.jsx)(wi,{className:"h-4 w-4"})})]}),(0,n.jsx)($,{variant:"secondary",size:"sm",className:"mt-2 h-8",asChild:!0,children:(0,n.jsxs)(Ye,{to:`/company/settings/instance/plugins/${D.id}`,children:[(0,n.jsx)(M0,{className:"h-4 w-4"}),"Configure"]})})]})})]})},D.id))})}):(0,n.jsx)(hs,{className:"bg-bg-3/30",children:(0,n.jsxs)(la,{className:"flex flex-col items-center justify-center py-10",children:[(0,n.jsx)(t3,{className:"h-10 w-10 text-ink-3 mb-4"}),(0,n.jsx)("p",{className:"text-sm font-medium",children:"No plugins installed"}),(0,n.jsx)("p",{className:"text-xs text-ink-3 mt-1",children:"Install a plugin to extend functionality."})]})})]}),(0,n.jsx)(Bn,{open:d!==null,onOpenChange:i(D=>{D||u(null)},"onOpenChange"),children:(0,n.jsxs)(zn,{children:[(0,n.jsxs)(rs,{children:[(0,n.jsx)(qn,{children:"Uninstall Plugin"}),(0,n.jsxs)(ds,{children:["Are you sure you want to uninstall ",(0,n.jsx)("strong",{children:h}),"? This action cannot be undone."]})]}),(0,n.jsxs)(fr,{children:[(0,n.jsx)($,{variant:"secondary",onClick:i(()=>u(null),"onClick"),children:"Cancel"}),(0,n.jsx)($,{variant:"delete",disabled:N.isPending,onClick:i(()=>{d&&N.mutate(d,{onSettled:i(()=>u(null),"onSettled")})},"onClick"),children:N.isPending?"Uninstalling...":"Uninstall"})]})]})}),(0,n.jsx)(Bn,{open:f!==null,onOpenChange:i(D=>{D||g(null)},"onOpenChange"),children:(0,n.jsxs)(zn,{className:"sm:max-w-2xl",children:[(0,n.jsxs)(rs,{children:[(0,n.jsx)(qn,{children:"Error Details"}),(0,n.jsxs)(ds,{children:[f?.manifestJson.displayName??f?.packageName??"Plugin"," hit an error state."]})]}),(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsx)("div",{className:"rounded-md border border-red-500/25 bg-red-500/[0.06] px-4 py-3",children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)(En,{className:"mt-0.5 h-4 w-4 shrink-0 text-red-700 dark:text-red-300"}),(0,n.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,n.jsx)("p",{className:"font-medium text-red-700 dark:text-red-300",children:"What errored"}),(0,n.jsx)("p",{className:"text-red-700/90 dark:text-red-200/90 break-words",children:f?Xqe(f):"No error summary available."})]})]})}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("p",{className:"text-sm font-medium",children:"Full error output"}),(0,n.jsx)("pre",{className:"max-h-(--sz-50vh) overflow-auto rounded-md border bg-bg-3/40 p-3 text-xs leading-5 whitespace-pre-wrap break-words",children:f?.lastError??"No stored error message."})]})]}),(0,n.jsx)(fr,{children:(0,n.jsx)($,{variant:"secondary",onClick:i(()=>g(null),"onClick"),children:"Close"})})]})})]})}i(oLs,"PluginManager");function lLs(){const{selectedCompany:e,selectedCompanyId:t}=gn(),{setBreadcrumbs:s}=Hs(),{companyPrefix:r,pluginId:a}=Mi(),{hideHostPaths:o}=Z7(),[l,c]=(0,m.useState)("configuration"),{data:d,isLoading:u}=ie({queryKey:O.plugins.detail(a),queryFn:i(()=>Yc.get(a),"queryFn"),enabled:!!a}),{data:h,isLoading:p}=ie({queryKey:O.plugins.health(a),queryFn:i(()=>Yc.health(a),"queryFn"),enabled:!!a&&d?.status==="ready",refetchInterval:3e4}),{data:f}=ie({queryKey:O.plugins.dashboard(a),queryFn:i(()=>Yc.dashboard(a),"queryFn"),enabled:!!a,refetchInterval:3e4}),{data:g}=ie({queryKey:O.plugins.logs(a),queryFn:i(()=>Yc.logs(a,{limit:50}),"queryFn"),enabled:!!a&&d?.status==="ready",refetchInterval:3e4}),x=d?.manifestJson?.instanceConfigSchema,v=x&&x.properties&&Object.keys(x.properties).length>0,b=a&&t?O.plugins.config(a,t):["plugins",a??"__missing_plugin__","companies","__missing_company__","config"],{data:y,isLoading:k}=ie({queryKey:b,queryFn:i(()=>Yc.getConfig(a,t),"queryFn"),enabled:!!a&&!!v&&!!t}),{slots:j}=Q0({slotTypes:["settingsPage"],companyId:t,enabled:!!t}),N=j.filter(K=>K.pluginId===a),S=N.length>0;if((0,m.useEffect)(()=>{s([{label:e?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"Plugins",href:"/company/settings/instance/plugins"},{label:d?.manifestJson?.displayName??d?.packageName??"Plugin Details"}])},[e?.name,s,r,d]),(0,m.useEffect)(()=>{c("configuration")},[a]),u)return(0,n.jsx)("div",{className:"p-4 text-sm text-ink-3",children:"Loading plugin details..."});if(!d)return(0,n.jsx)(Ss,{to:"/company/settings/instance/plugins",replace:!0});const A=d.status,I=d.status==="ready"?"default":d.status==="error"?"destructive":"secondary",_=d.manifestJson.description||"No description provided.",T=d.manifestJson.capabilities??[],E=d.manifestJson.environmentDrivers??[],M=d.manifestJson.localFolders??[],P=M.length>0&&!o,D=E.map(K=>K.displayName?.trim()||K.driverKey).filter((K,L,B)=>B.indexOf(K)===L).join(", ");return(0,n.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,n.jsxs)("div",{className:"flex items-center gap-4",children:[(0,n.jsx)(Ye,{to:"/company/settings/instance/plugins",children:(0,n.jsx)($,{variant:"secondary",size:"icon",className:"h-8 w-8",children:(0,n.jsx)(cc,{className:"h-4 w-4"})})}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(t3,{className:"h-6 w-6 text-ink-3"}),(0,n.jsx)("h1",{className:"text-xl font-semibold",children:d.manifestJson.displayName??d.packageName}),(0,n.jsx)(lt,{variant:I,className:"ml-2",children:A}),(0,n.jsxs)(lt,{variant:"outline",className:"ml-1",children:["v",d.manifestJson.version??d.version]})]})]}),(0,n.jsxs)(Co,{value:l,onValueChange:i(K=>c(K),"onValueChange"),className:"space-y-6",children:[(0,n.jsx)(tm,{align:"start",items:[{value:"configuration",label:"Configuration"},{value:"status",label:"Status"}],value:l,onValueChange:i(K=>c(K),"onValueChange")}),(0,n.jsx)(ki,{value:"configuration",className:"space-y-6",children:(0,n.jsxs)("div",{className:"space-y-8",children:[(0,n.jsxs)("section",{className:"space-y-5",children:[(0,n.jsx)("h2",{className:"text-base font-semibold",children:"About"}),(0,n.jsxs)("div",{className:"grid gap-8 lg:grid-cols-(--gtc-52)",children:[(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("h3",{className:"text-sm font-medium text-ink-3",children:"Description"}),(0,n.jsx)("p",{className:"text-sm leading-6 text-ink/90",children:_})]}),(0,n.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)("h3",{className:"font-medium text-ink-3",children:"Author"}),(0,n.jsx)("p",{className:"text-ink",children:d.manifestJson.author})]}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("h3",{className:"font-medium text-ink-3",children:"Categories"}),(0,n.jsx)("div",{className:"flex flex-wrap gap-2",children:d.categories.length>0?d.categories.map(K=>(0,n.jsx)(lt,{variant:"outline",className:"capitalize",children:K},K)):(0,n.jsx)("span",{className:"text-ink",children:"None"})})]})]})]})]}),(0,n.jsx)(ku,{}),(0,n.jsxs)("section",{className:"space-y-4",children:[(0,n.jsx)("div",{className:"space-y-1",children:(0,n.jsx)("h2",{className:"text-base font-semibold",children:"Settings"})}),P?(0,n.jsx)(cLs,{pluginId:a,companyId:t,declarations:M}):null,S?(0,n.jsx)("div",{className:"space-y-3",children:N.map(K=>(0,n.jsx)(jx,{slot:K,context:{companyId:t,companyPrefix:r??null},missingBehavior:"placeholder"},`${K.pluginKey}:${K.id}`))}):v?(0,n.jsx)(pLs,{pluginId:a,companyId:t,schema:x,initialValues:y?.configJson,isLoading:k,pluginStatus:d.status,supportsConfigTest:d.supportsConfigTest===!0}):E.length>0?(0,n.jsxs)("div",{className:"rounded-md border border-line/60 bg-bg-3/20 px-4 py-3 text-sm",children:[(0,n.jsx)("p",{className:"font-medium text-ink",children:"Configure this plugin from Settings → Environments."}),(0,n.jsxs)("p",{className:"mt-1 text-ink-3",children:[D||"This plugin"," registers environment runtime settings there so the execution target stays instance-scoped while secret bindings still resolve through the selected organization context."]}),(0,n.jsx)("div",{className:"mt-3",children:(0,n.jsx)(Ye,{to:"/company/settings/instance/environments",children:(0,n.jsx)($,{variant:"secondary",size:"sm",children:"Open Environments"})})})]}):P?null:(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"This plugin does not require any settings."})]})]})}),(0,n.jsx)(ki,{value:"status",className:"space-y-6",children:(0,n.jsxs)("div",{className:"grid gap-6 xl:grid-cols-(--gtc-39)",children:[(0,n.jsxs)("div",{className:"space-y-6",children:[(0,n.jsxs)(hs,{children:[(0,n.jsxs)(zo,{children:[(0,n.jsxs)(jl,{className:"text-base flex items-center gap-1.5",children:[(0,n.jsx)(If,{className:"h-4 w-4"}),"Runtime Dashboard"]}),(0,n.jsx)(yu,{children:"Worker process, scheduled jobs, and webhook deliveries"})]}),(0,n.jsx)(la,{className:"space-y-6",children:f?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,n.jsx)(If,{className:"h-3.5 w-3.5 text-ink-3"}),"Worker Process"]}),f.worker?(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[(0,n.jsxs)("div",{className:"flex justify-between",children:[(0,n.jsx)("span",{className:"text-ink-3",children:"Status"}),(0,n.jsx)(lt,{variant:f.worker.status==="running"?"default":"secondary",children:f.worker.status})]}),(0,n.jsxs)("div",{className:"flex justify-between",children:[(0,n.jsx)("span",{className:"text-ink-3",children:"PID"}),(0,n.jsx)("span",{className:"font-mono text-xs",children:f.worker.pid??"—"})]}),(0,n.jsxs)("div",{className:"flex justify-between",children:[(0,n.jsx)("span",{className:"text-ink-3",children:"Uptime"}),(0,n.jsx)("span",{className:"text-xs",children:fLs(f.worker.uptime)})]}),(0,n.jsxs)("div",{className:"flex justify-between",children:[(0,n.jsx)("span",{className:"text-ink-3",children:"Pending RPCs"}),(0,n.jsx)("span",{className:"text-xs",children:f.worker.pendingRequests})]}),f.worker.totalCrashes>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex justify-between col-span-2",children:[(0,n.jsxs)("span",{className:"text-ink-3 flex items-center gap-1",children:[(0,n.jsx)(En,{className:"h-3 w-3 text-amber-500"}),"Crashes"]}),(0,n.jsxs)("span",{className:"text-xs",children:[f.worker.consecutiveCrashes," consecutive / ",f.worker.totalCrashes," total"]})]}),f.worker.lastCrashAt&&(0,n.jsxs)("div",{className:"flex justify-between col-span-2",children:[(0,n.jsx)("span",{className:"text-ink-3",children:"Last Crash"}),(0,n.jsx)("span",{className:"text-xs",children:gLs(f.worker.lastCrashAt)})]})]})]}):(0,n.jsx)("p",{className:"text-sm text-ink-3 italic",children:"No worker process registered."})]}),(0,n.jsx)(ku,{}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,n.jsx)(yk,{className:"h-3.5 w-3.5 text-ink-3"}),"Recent Job Runs"]}),f.recentJobRuns.length>0?(0,n.jsx)("div",{className:"space-y-2",children:f.recentJobRuns.map(K=>(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md bg-bg-3/50 px-2 py-1.5 text-sm",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)(xLs,{status:K.status}),(0,n.jsx)("span",{className:"truncate font-mono text-xs",title:K.jobKey??K.jobId,children:K.jobKey??K.jobId.slice(0,8)}),(0,n.jsx)(lt,{variant:"outline",className:"px-1 py-0 text-(length:--text-nano)",children:K.trigger})]}),(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-2 text-xs text-ink-3",children:[K.durationMs!=null?(0,n.jsx)("span",{children:sUe(K.durationMs)}):null,(0,n.jsx)("span",{title:K.createdAt,children:rUe(K.createdAt)})]})]},K.id))}):(0,n.jsx)("p",{className:"text-sm text-ink-3 italic",children:"No job runs recorded yet."})]}),(0,n.jsx)(ku,{}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("h3",{className:"text-sm font-medium mb-3 flex items-center gap-1.5",children:[(0,n.jsx)(Q0e,{className:"h-3.5 w-3.5 text-ink-3"}),"Recent Webhook Deliveries"]}),f.recentWebhookDeliveries.length>0?(0,n.jsx)("div",{className:"space-y-2",children:f.recentWebhookDeliveries.map(K=>(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-md bg-bg-3/50 px-2 py-1.5 text-sm",children:[(0,n.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,n.jsx)(vLs,{status:K.status}),(0,n.jsx)("span",{className:"truncate font-mono text-xs",title:K.webhookKey,children:K.webhookKey})]}),(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-2 text-xs text-ink-3",children:[K.durationMs!=null?(0,n.jsx)("span",{children:sUe(K.durationMs)}):null,(0,n.jsx)("span",{title:K.createdAt,children:rUe(K.createdAt)})]})]},K.id))}):(0,n.jsx)("p",{className:"text-sm text-ink-3 italic",children:"No webhook deliveries recorded yet."})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1.5 border-t border-line/50 pt-2 text-xs text-ink-3",children:[(0,n.jsx)(go,{className:"h-3 w-3"}),"Last checked: ",new Date(f.checkedAt).toLocaleTimeString()]})]}):(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Runtime diagnostics are unavailable right now."})})]}),g&&g.length>0?(0,n.jsxs)(hs,{children:[(0,n.jsxs)(zo,{children:[(0,n.jsxs)(jl,{className:"text-base flex items-center gap-1.5",children:[(0,n.jsx)(cSe,{className:"h-4 w-4"}),"Recent Logs"]}),(0,n.jsxs)(yu,{children:["Last ",g.length," log entries"]})]}),(0,n.jsx)(la,{children:(0,n.jsx)("div",{className:"max-h-64 space-y-1 overflow-y-auto font-mono text-xs",children:g.map(K=>(0,n.jsxs)("div",{className:`flex gap-2 py-0.5 ${K.level==="error"?"text-bad":K.level==="warn"?"text-yellow-600 dark:text-yellow-400":K.level==="debug"?"text-ink-3/60":"text-ink-3"}`,children:[(0,n.jsx)("span",{className:"shrink-0 text-ink-3/50",children:new Date(K.createdAt).toLocaleTimeString()}),(0,n.jsx)(lt,{variant:"outline",className:"h-4 shrink-0 px-1 text-(length:--text-nano)",children:K.level}),(0,n.jsx)("span",{className:"truncate",title:K.message,children:K.message})]},K.id))})})]}):null]}),(0,n.jsxs)("div",{className:"space-y-6",children:[(0,n.jsxs)(hs,{children:[(0,n.jsx)(zo,{children:(0,n.jsxs)(jl,{className:"text-base flex items-center gap-1.5",children:[(0,n.jsx)(cSe,{className:"h-4 w-4"}),"Health Status"]})}),(0,n.jsx)(la,{children:p?(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Checking health..."}):h?(0,n.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsx)("span",{className:"text-ink-3",children:"Overall"}),(0,n.jsx)(lt,{variant:h.healthy?"default":"destructive",children:h.status})]}),h.checks.length>0?(0,n.jsx)("div",{className:"space-y-2 border-t border-line/50 pt-2",children:h.checks.map((K,L)=>(0,n.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,n.jsx)("span",{className:"truncate text-ink-3",title:K.name,children:K.name}),K.passed?(0,n.jsx)(N7t,{className:"h-4 w-4 shrink-0 text-green-500"}):(0,n.jsx)(wu,{className:"h-4 w-4 shrink-0 text-bad"})]},L))}):null,h.lastError?(0,n.jsx)("div",{className:"break-words rounded border border-bad/20 bg-bad/10 p-2 text-xs text-bad",children:h.lastError}):null]}):(0,n.jsxs)("div",{className:"space-y-3 text-sm text-ink-3",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsx)("span",{children:"Lifecycle"}),(0,n.jsx)(lt,{variant:I,children:A})]}),(0,n.jsx)("p",{children:"Health checks run once the plugin is ready."}),d.lastError?(0,n.jsx)("div",{className:"break-words rounded border border-bad/20 bg-bad/10 p-2 text-xs text-bad",children:d.lastError}):null]})})]}),(0,n.jsxs)(hs,{children:[(0,n.jsx)(zo,{children:(0,n.jsx)(jl,{className:"text-base",children:"Details"})}),(0,n.jsxs)(la,{className:"space-y-3 text-sm text-ink-3",children:[(0,n.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,n.jsx)("span",{children:"Plugin ID"}),(0,n.jsx)("span",{className:"font-mono text-xs text-right",children:d.id})]}),(0,n.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,n.jsx)("span",{children:"Plugin Key"}),(0,n.jsx)("span",{className:"font-mono text-xs text-right",children:d.pluginKey})]}),(0,n.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,n.jsx)("span",{children:"NPM Package"}),(0,n.jsx)("span",{className:"max-w-(--sz-170px) truncate text-right text-xs",title:d.packageName,children:d.packageName})]}),(0,n.jsxs)("div",{className:"flex justify-between gap-3",children:[(0,n.jsx)("span",{children:"Version"}),(0,n.jsxs)("span",{className:"text-right text-ink",children:["v",d.manifestJson.version??d.version]})]})]})]}),(0,n.jsxs)(hs,{children:[(0,n.jsx)(zo,{children:(0,n.jsxs)(jl,{className:"text-base flex items-center gap-1.5",children:[(0,n.jsx)(Vd,{className:"h-4 w-4"}),"Permissions"]})}),(0,n.jsx)(la,{children:T.length>0?(0,n.jsx)("ul",{className:"space-y-2 text-sm text-ink-3",children:T.map(K=>(0,n.jsx)("li",{className:"rounded-md bg-bg-3/40 px-2.5 py-2 font-mono text-xs text-ink/85",children:K},K))}):(0,n.jsx)("p",{className:"text-sm text-ink-3 italic",children:"No special permissions requested."})})]})]})]})})]})]})}i(lLs,"PluginSettings");function cLs({pluginId:e,companyId:t,declarations:s}){const{data:r,isLoading:a,error:o}=ie({queryKey:t?O.plugins.localFolders(e,t):["plugins",e,"companies","none","local-folders"],queryFn:i(()=>Yc.listLocalFolders(e,t),"queryFn"),enabled:!!t}),l=new Map((r?.folders??[]).map(c=>[c.folderKey,c]));return t?(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(Hl,{className:"h-4 w-4 text-ink-3"}),(0,n.jsx)("h3",{className:"text-sm font-medium",children:"Local folders"})]}),o?(0,n.jsx)("div",{className:"rounded-md border border-bad/20 bg-bad/10 px-3 py-2 text-sm text-bad",children:o.message||"Failed to load local folder settings."}):null,a?(0,n.jsxs)("div",{className:"flex items-center gap-2 py-3 text-sm text-ink-3",children:[(0,n.jsx)(ct,{className:"h-4 w-4 animate-spin"}),"Loading local folders..."]}):(0,n.jsx)("div",{className:"space-y-3",children:s.map(c=>(0,n.jsx)(dLs,{pluginId:e,companyId:t,declaration:c,status:l.get(c.folderKey)},c.folderKey))})]}):(0,n.jsx)("div",{className:"rounded-md border border-line/60 bg-bg-3/20 px-4 py-3 text-sm text-ink-3",children:"Select an organization to configure this plugin's local folders."})}i(cLs,"PluginLocalFoldersSettings");function dLs({pluginId:e,companyId:t,declaration:s,status:r}){const a=Ct(),o=r?.path??"",[l,c]=(0,m.useState)(o),[d,u]=(0,m.useState)(null);(0,m.useEffect)(()=>{c(o),u(null)},[o,s.folderKey]);const h=ye({mutationFn:i(v=>Yc.configureLocalFolder(e,t,s.folderKey,{path:v,access:s.access,requiredDirectories:s.requiredDirectories,requiredFiles:s.requiredFiles}),"mutationFn"),onSuccess:i(v=>{u({type:v.healthy?"success":"error",text:v.healthy?"Local folder saved.":"Local folder saved, but validation still needs attention."}),a.invalidateQueries({queryKey:O.plugins.localFolders(e,t)})},"onSuccess"),onError:i(v=>{u({type:"error",text:v.message||"Failed to save local folder."})},"onError")}),p=l.trim(),f=p!==o,g=r?.access??s.access??"readWrite",x=(0,m.useCallback)(()=>{if(!p){u({type:"error",text:"Local folder path is required."});return}if(!mLs(p)){u({type:"error",text:"Local folder must be a full absolute path."});return}u(null),h.mutate(p)},[h,p]);return(0,n.jsxs)("div",{className:"space-y-4 rounded-md border border-line/70 bg-bg px-4 py-4",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)("h4",{className:"text-sm font-medium",children:s.displayName}),(0,n.jsx)(lt,{variant:"outline",className:"font-mono text-(length:--text-nano)",children:s.folderKey}),(0,n.jsx)(lt,{variant:r?.healthy?"default":"secondary",children:r?.healthy?"Healthy":"Needs attention"})]}),s.description?(0,n.jsx)("p",{className:"max-w-3xl text-sm leading-5 text-ink-3",children:s.description}):null]}),(0,n.jsx)(lt,{variant:g==="readWrite"?"default":"outline",children:g==="readWrite"?"Read/write":"Read only"})]}),(0,n.jsxs)("div",{className:"grid gap-3 text-sm sm:grid-cols-3",children:[(0,n.jsx)(Jre,{label:"Configured",value:r?.configured?"Yes":"No",ok:!!r?.configured}),(0,n.jsx)(Jre,{label:"Readable",value:r?.readable?"Yes":"No",ok:!!r?.readable}),(0,n.jsx)(Jre,{label:"Writable",value:g==="read"?"Not requested":r?.writable?"Yes":"No",ok:g==="read"||!!r?.writable})]}),r?.path?(0,n.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,n.jsx)("div",{className:"text-xs font-medium text-ink-3",children:"Configured path"}),(0,n.jsx)("div",{className:"break-all rounded-md bg-bg-3/60 px-2 py-1.5 font-mono text-xs text-ink",children:r.path})]}):null,(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)("label",{className:"text-xs font-medium text-ink-3",htmlFor:`local-folder-${s.folderKey}`,children:"Local folder path"}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{id:`local-folder-${s.folderKey}`,className:"min-w-0 flex-1 rounded-md border border-line bg-bg px-2.5 py-1.5 font-mono text-sm outline-none focus:border-ink/40 focus:ring-2 focus:ring-focus/20",value:l,onChange:i(v=>{c(v.target.value),u(null)},"onChange"),placeholder:"/absolute/path/to/folder"}),(0,n.jsx)(rS,{className:"h-8"}),(0,n.jsxs)($,{size:"sm",onClick:x,disabled:h.isPending||!f||!t,children:[h.isPending?(0,n.jsx)(ct,{className:"h-3.5 w-3.5 animate-spin"}):(0,n.jsx)(Qv,{className:"h-3.5 w-3.5"}),"Save"]})]})]}),(0,n.jsx)(uLs,{status:r,declaration:s}),r?.problems?.length?(0,n.jsxs)("div",{className:"space-y-2 rounded-md border border-bad/20 bg-bad/10 px-3 py-2 text-sm text-bad",children:[(0,n.jsx)("div",{className:"font-medium",children:"Validation problems"}),(0,n.jsx)("ul",{className:"space-y-1",children:r.problems.map((v,b)=>(0,n.jsxs)("li",{children:[v.message,v.path?(0,n.jsxs)("span",{className:"font-mono",children:[" ",v.path]}):null]},`${v.code}:${v.path??""}:${b}`))})]}):null,d?(0,n.jsx)("div",{className:`rounded-md border px-3 py-2 text-sm ${d.type==="success"?"border-green-200 bg-green-50 text-green-700 dark:border-green-900 dark:bg-green-950/30 dark:text-green-400":"border-bad/20 bg-bad/10 text-bad"}`,children:d.text}):null]})}i(dLs,"PluginLocalFolderRow");function Jre({label:e,value:t,ok:s}){return(0,n.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-line/60 px-2.5 py-2",children:[(0,n.jsx)("span",{className:"text-ink-3",children:e}),(0,n.jsx)(lt,{variant:s?"default":"secondary",children:t})]})}i(Jre,"FolderStatusMetric");function uLs({status:e,declaration:t}){const s=e?.requiredDirectories??t.requiredDirectories??[],r=e?.requiredFiles??t.requiredFiles??[],a=e?.missingDirectories??s,o=e?.missingFiles??r,l=hLs(e);return s.length===0&&r.length===0?null:(0,n.jsxs)("div",{className:"grid gap-3 text-sm md:grid-cols-2",children:[(0,n.jsx)(nUe,{title:"Required directories",items:s,missingItems:a,missingLabel:"Missing directories",inspectionUnavailable:l}),(0,n.jsx)(nUe,{title:"Required files",items:r,missingItems:o,missingLabel:"Missing files",inspectionUnavailable:l})]})}i(uLs,"FolderRequirements");function hLs(e){return!e?.configured||e.readable?!1:e.problems.some(t=>t.code==="missing"||t.code==="not_readable"||t.code==="not_directory")}i(hLs,"isRootNotInspected");function nUe({title:e,items:t,missingItems:s,missingLabel:r,inspectionUnavailable:a}){return(0,n.jsxs)("div",{className:"space-y-2 rounded-md border border-line/60 px-3 py-2",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsx)("span",{className:"text-xs font-medium text-ink-3",children:e}),a?(0,n.jsx)(lt,{variant:"secondary",className:"text-(length:--text-nano)",children:"Not inspected"}):s.length>0?(0,n.jsxs)(lt,{variant:"destructive",className:"text-(length:--text-nano)",children:[s.length," missing"]}):(0,n.jsx)(lt,{variant:"outline",className:"text-(length:--text-nano)",children:"Present"})]}),t.length>0?(0,n.jsx)("div",{className:"flex flex-wrap gap-1.5",children:t.map(o=>{const l=s.includes(o);return(0,n.jsx)("span",{className:`rounded border px-1.5 py-0.5 font-mono text-(length:--text-micro) ${a?"border-amber-300/60 bg-amber-50 text-amber-700 dark:border-amber-800/70 dark:bg-amber-950/30 dark:text-amber-300":l?"border-bad/30 bg-bad/10 text-bad":"border-line bg-bg-3/50 text-ink/80"}`,children:o},o)})}):(0,n.jsx)("p",{className:"text-xs text-ink-3",children:"None declared."}),a?(0,n.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:"Configured root was not inspected."}):s.length>0?(0,n.jsxs)("p",{className:"text-xs text-bad",children:[r,": ",s.join(", ")]}):null]})}i(nUe,"RequirementList");function mLs(e){return e.startsWith("/")||/^[A-Za-z]:[\\/]/.test(e)||e.startsWith("\\\\")}i(mLs,"isLikelyAbsolutePath");function pLs({pluginId:e,companyId:t,schema:s,initialValues:r,isLoading:a,pluginStatus:o,supportsConfigTest:l}){const c=Ct(),[d,u]=(0,m.useState)(()=>({...Dv(s),...r??{}})),h=(0,m.useRef)(!1);(0,m.useEffect)(()=>{h.current=!1,u(Dv(s))},[t,e,s]),(0,m.useEffect)(()=>{r&&!h.current&&(h.current=!0,u({...Dv(s),...r}))},[r,s]);const[p,f]=(0,m.useState)({}),[g,x]=(0,m.useState)(null),[v,b]=(0,m.useState)(null),y=JSON.stringify(d)!==JSON.stringify({...Dv(s),...r??{}}),k=ye({mutationFn:i(I=>{if(!t)throw new Error("Select an organization before saving plugin configuration.");return Yc.saveConfig(e,t,I)},"mutationFn"),onSuccess:i(()=>{x({type:"success",text:"Configuration saved."}),b(null),t&&c.invalidateQueries({queryKey:O.plugins.config(e,t)}),setTimeout(()=>x(null),3e3)},"onSuccess"),onError:i(I=>{x({type:"error",text:I.message||"Failed to save configuration."})},"onError")}),j=ye({mutationFn:i(I=>{if(!t)throw new Error("Select an organization before testing plugin configuration.");return Yc.testConfig(e,t,I)},"mutationFn"),onSuccess:i(I=>{I.valid?b({type:"success",text:"Configuration test passed."}):b({type:"error",text:I.message||"Configuration test failed."})},"onSuccess"),onError:i(I=>{b({type:"error",text:I.message||"Configuration test failed."})},"onError")}),N=(0,m.useCallback)(I=>{u(I),f({}),x(null)},[]),S=(0,m.useCallback)(()=>{const I=tS(s,d);if(Object.keys(I).length>0){f(I);return}f({}),k.mutate(d)},[s,d,k]),A=(0,m.useCallback)(()=>{const I=tS(s,d);if(Object.keys(I).length>0){f(I);return}f({}),b(null),j.mutate(d)},[s,d,j]);return a?(0,n.jsxs)("div",{className:"flex items-center gap-2 text-sm text-ink-3 py-4",children:[(0,n.jsx)(ct,{className:"h-4 w-4 animate-spin"}),"Loading configuration..."]}):(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsx)(T7,{schema:s,values:d,onChange:N,errors:p,disabled:k.isPending}),g&&(0,n.jsx)("div",{className:`text-sm p-2 rounded border ${g.type==="success"?"text-green-700 bg-green-50 border-green-200 dark:text-green-400 dark:bg-green-950/30 dark:border-green-900":"text-bad bg-bad/10 border-bad/20"}`,children:g.text}),v&&(0,n.jsx)("div",{className:`text-sm p-2 rounded border ${v.type==="success"?"text-green-700 bg-green-50 border-green-200 dark:text-green-400 dark:bg-green-950/30 dark:border-green-900":"text-bad bg-bad/10 border-bad/20"}`,children:v.text}),(0,n.jsxs)("div",{className:"flex items-center gap-2 pt-2",children:[(0,n.jsx)($,{onClick:S,disabled:k.isPending||!y,size:"sm",children:k.isPending?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ct,{className:"h-3.5 w-3.5 animate-spin"}),"Saving..."]}):"Save Configuration"}),o==="ready"&&l&&(0,n.jsx)($,{variant:"secondary",onClick:A,disabled:j.isPending||!t,size:"sm",children:j.isPending?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ct,{className:"h-3.5 w-3.5 animate-spin"}),"Testing..."]}):"Test Configuration"})]})]})}i(pLs,"PluginConfigForm");function fLs(e){if(e==null)return"—";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const s=Math.floor(t/60);if(s<60)return`${s}m ${t%60}s`;const r=Math.floor(s/60);return r<24?`${r}h ${s%60}m`:`${Math.floor(r/24)}d ${r%24}h`}i(fLs,"formatUptime");function sUe(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${(e/6e4).toFixed(1)}m`}i(sUe,"formatDuration");function rUe(e){const t=Date.now()-new Date(e).getTime();if(t<0)return"just now";const s=Math.floor(t/1e3);if(s<60)return`${s}s ago`;const r=Math.floor(s/60);if(r<60)return`${r}m ago`;const a=Math.floor(r/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}i(rUe,"formatRelativeTime");function gLs(e){return new Date(e).toLocaleString()}i(gLs,"formatTimestamp");function xLs({status:e}){return(0,n.jsx)("span",{className:`inline-block h-2 w-2 rounded-full shrink-0 ${e==="success"||e==="succeeded"?"bg-green-500":e==="failed"?"bg-red-500":e==="running"?"bg-blue-500 animate-pulse":e==="cancelled"?"bg-gray-400":"bg-amber-500"}`,title:e})}i(xLs,"JobStatusDot");function vLs({status:e}){return(0,n.jsx)("span",{className:`inline-block h-2 w-2 rounded-full shrink-0 ${e==="processed"||e==="success"?"bg-green-500":e==="failed"?"bg-red-500":e==="received"?"bg-blue-500":"bg-amber-500"}`,title:e})}i(vLs,"DeliveryStatusDot");function Zre({adapter:e,canRemove:t,onToggle:s,onRemove:r,onReload:a,onReinstall:o,isToggling:l,isReloading:c,isReinstalling:d,overriddenBy:u,toggleTitleEnabled:h,toggleTitleDisabled:p,disabledBadgeLabel:f}){return(0,n.jsx)("li",{children:(0,n.jsxs)("div",{className:"flex items-center gap-4 px-4 py-3",children:[(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)("span",{className:Q("font-medium",e.disabled&&"text-ink-3 line-through"),children:e.label&&e.label!==e.type?e.label:mb(e.type)}),(0,n.jsx)(lt,{variant:"outline",children:e.source==="external"?"External":"Built-in"}),e.source==="external"&&(e.isLocalPath?(0,n.jsx)("span",{title:"Installed from local path",children:(0,n.jsx)(Hl,{className:"h-4 w-4 text-amber-500"})}):(0,n.jsx)("span",{title:"Installed from npm",children:(0,n.jsx)(ax,{className:"h-4 w-4 text-red-500"})})),e.version&&(0,n.jsxs)(lt,{variant:"secondary",className:"font-mono text-(length:--text-nano)",children:["v",e.version]}),e.overriddenBuiltin&&(0,n.jsx)(lt,{variant:"secondary",className:"text-blue-600 border-blue-400",children:"Overrides built-in"}),u&&(0,n.jsxs)(lt,{variant:"secondary",className:"text-blue-600 border-blue-400",children:["Overridden by ",u]}),e.disabled&&(0,n.jsx)(lt,{variant:"secondary",className:"text-amber-600 border-amber-400",children:f??"Hidden from menus"})]}),(0,n.jsxs)("p",{className:"text-xs text-ink-3 mt-0.5",children:[e.type,e.packageName&&e.packageName!==e.type&&(0,n.jsxs)(n.Fragment,{children:[" · ",e.packageName]})," · ",e.modelsCount," models"]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[o&&(0,n.jsx)($,{variant:"secondary",size:"icon-sm",className:"h-8 w-8",title:"Reinstall adapter (pull latest from npm)",disabled:d,onClick:i(()=>o(e.type),"onClick"),children:(0,n.jsx)(xo,{className:Q("h-4 w-4",d&&"animate-bounce")})}),a&&(0,n.jsx)($,{variant:"secondary",size:"icon-sm",className:"h-8 w-8",title:"Reload adapter (hot-swap)",disabled:c,onClick:i(()=>a(e.type),"onClick"),children:(0,n.jsx)(Aa,{className:Q("h-4 w-4",c&&"animate-spin")})}),(0,n.jsx)($,{variant:"secondary",size:"icon-sm",className:"h-8 w-8",title:e.disabled?h??"Show in agent menus":p??"Hide from agent menus",disabled:l,onClick:i(()=>s(e.type,!e.disabled),"onClick"),children:(0,n.jsx)(P0e,{className:Q("h-4 w-4",e.disabled?"text-ink-3":"text-green-600")})}),t&&(0,n.jsx)($,{variant:"danger",size:"icon-sm",className:"h-8 w-8",title:"Remove adapter",onClick:i(()=>r(e.type),"onClick"),children:(0,n.jsx)(wi,{className:"h-4 w-4"})})]})]})})}i(Zre,"AdapterRow");function bLs(e){return fetch(`https://registry.npmjs.org/${encodeURIComponent(e)}/latest`,{signal:AbortSignal.timeout(5e3)}).then(t=>t.json()).then(t=>typeof t?.version=="string"?t.version:null).catch(()=>null)}i(bLs,"fetchNpmLatestVersion");function yLs({adapter:e,open:t,isReinstalling:s,onConfirm:r,onCancel:a}){const{data:o,isLoading:l}=ie({queryKey:["npm-latest-version",e?.packageName],queryFn:i(()=>e?.packageName?bLs(e.packageName):null,"queryFn"),enabled:t&&!!e?.packageName,staleTime:6e4}),c=e?.version&&o&&e.version===o;return(0,n.jsx)(Bn,{open:t,onOpenChange:i(d=>{d||a()},"onOpenChange"),children:(0,n.jsxs)(zn,{children:[(0,n.jsxs)(rs,{children:[(0,n.jsx)(qn,{children:"Reinstall Adapter"}),(0,n.jsxs)(ds,{children:["This will pull the latest version of"," ",(0,n.jsx)("strong",{children:e?.packageName})," from npm and hot-swap the running adapter module. Existing agents will use the new version on their next run."]})]}),(0,n.jsxs)("div",{className:"rounded-md border bg-bg-3/50 px-4 py-3 text-sm space-y-1",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsx)("span",{className:"text-ink-3",children:"Package"}),(0,n.jsx)("span",{className:"font-mono",children:e?.packageName})]}),(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsx)("span",{className:"text-ink-3",children:"Current"}),(0,n.jsx)("span",{className:"font-mono",children:e?.version?`v${e.version}`:"unknown"})]}),(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsx)("span",{className:"text-ink-3",children:"Latest on npm"}),(0,n.jsx)("span",{className:"font-mono",children:l?"checking...":o?`v${o}`:"unavailable"})]}),c&&(0,n.jsx)("p",{className:"text-xs text-ink-3 pt-1",children:"Already on the latest version."})]}),(0,n.jsxs)(fr,{children:[(0,n.jsx)($,{variant:"secondary",onClick:a,disabled:s,children:"Cancel"}),(0,n.jsx)($,{disabled:s,onClick:r,children:s?"Reinstalling...":"Reinstall"})]})]})})}i(yLs,"ReinstallDialog");function iUe(){const{selectedCompany:e}=gn(),{setBreadcrumbs:t}=Hs(),s=Ct(),{pushToast:r}=ri(),[a,o]=(0,m.useState)(""),[l,c]=(0,m.useState)(""),[d,u]=(0,m.useState)(!1),[h,p]=(0,m.useState)(!1),[f,g]=(0,m.useState)(null),[x,v]=(0,m.useState)(null);(0,m.useEffect)(()=>{t([{label:e?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"Adapters"}])},[e?.name,t]);const{data:b,isLoading:y}=ie({queryKey:O.adapters.all,queryFn:i(()=>xf.list(),"queryFn")}),k=i(()=>{s.invalidateQueries({queryKey:O.adapters.all})},"invalidate"),j=ye({mutationFn:i(D=>xf.install(D),"mutationFn"),onSuccess:i(D=>{k(),p(!1),o(""),c(""),u(!1),r({title:"Adapter installed",body:`Type "${D.type}" registered successfully.${D.version?` (v${D.version})`:""}`,tone:"success"})},"onSuccess"),onError:i(D=>{r({title:"Install failed",body:D.message,tone:"error"})},"onError")}),N=ye({mutationFn:i(D=>xf.remove(D),"mutationFn"),onSuccess:i(()=>{k(),r({title:"Adapter removed",tone:"success"})},"onSuccess"),onError:i(D=>{r({title:"Removal failed",body:D.message,tone:"error"})},"onError")}),S=ye({mutationFn:i(({type:D,disabled:K})=>xf.setDisabled(D,K),"mutationFn"),onSuccess:i(()=>{k()},"onSuccess"),onError:i(D=>{r({title:"Toggle failed",body:D.message,tone:"error"})},"onError")}),A=ye({mutationFn:i(({type:D,paused:K})=>xf.setOverridePaused(D,K),"mutationFn"),onSuccess:i(()=>{k()},"onSuccess"),onError:i(D=>{r({title:"Override toggle failed",body:D.message,tone:"error"})},"onError")}),I=ye({mutationFn:i(D=>xf.reload(D),"mutationFn"),onSuccess:i(D=>{k(),Xce(D.type),MRe(D.type),r({title:"Adapter reloaded",body:`Type "${D.type}" reloaded.${D.version?` (v${D.version})`:""}`,tone:"success"})},"onSuccess"),onError:i(D=>{r({title:"Reload failed",body:D.message,tone:"error"})},"onError")}),_=ye({mutationFn:i(D=>xf.reinstall(D),"mutationFn"),onSuccess:i(D=>{k(),Xce(D.type),MRe(D.type),r({title:"Adapter reinstalled",body:`Type "${D.type}" updated from npm.${D.version?` (v${D.version})`:""}`,tone:"success"})},"onSuccess"),onError:i(D=>{r({title:"Reinstall failed",body:D.message,tone:"error"})},"onError")}),T=(b??[]).filter(D=>D.source==="builtin"),E=(b??[]).filter(D=>D.source==="external"),M=(b??[]).filter(D=>D.source==="external"&&D.overriddenBuiltin).filter(D=>!T.some(K=>K.type===D.type)).map(D=>({type:D.type,label:mb(D.type),overriddenBy:[D.packageName,D.version?`v${D.version}`:void 0].filter(Boolean).join(" "),overridePaused:!!D.overridePaused,menuDisabled:!!D.disabled}));if(y)return(0,n.jsx)("div",{className:"p-4 text-sm text-ink-3",children:"Loading adapters..."});const P=j.isPending||N.isPending||S.isPending||A.isPending||I.isPending||_.isPending;return(0,n.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(If,{className:"h-6 w-6 text-ink-3"}),(0,n.jsx)("h1",{className:"text-xl font-semibold",children:"Adapters"}),(0,n.jsx)(lt,{variant:"outline",className:"text-amber-600 border-amber-400",children:"Alpha"})]}),(0,n.jsxs)(Bn,{open:h,onOpenChange:p,children:[(0,n.jsx)(kk,{asChild:!0,children:(0,n.jsxs)($,{size:"sm",className:"gap-2",children:[(0,n.jsx)(js,{className:"h-4 w-4"}),"Install Adapter"]})}),(0,n.jsxs)(zn,{children:[(0,n.jsxs)(rs,{children:[(0,n.jsx)(qn,{children:"Install External Adapter"}),(0,n.jsxs)(ds,{children:["Add an adapter from npm or a local path. The adapter package must export ",(0,n.jsx)("code",{className:"text-xs bg-bg-3 px-1 py-0.5 rounded",children:"createServerAdapter()"}),"."]})]}),(0,n.jsxs)("div",{className:"grid gap-4 py-4",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("button",{type:"button",className:Q("inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs transition-colors",d?"border-line text-ink-3 hover:text-ink hover:bg-bg-3/50":"border-ink bg-bg-3 text-ink"),onClick:i(()=>u(!1),"onClick"),children:[(0,n.jsx)(ax,{className:"h-3.5 w-3.5"}),"npm package"]}),(0,n.jsxs)("button",{type:"button",className:Q("inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs transition-colors",d?"border-ink bg-bg-3 text-ink":"border-line text-ink-3 hover:text-ink hover:bg-bg-3/50"),onClick:i(()=>u(!0),"onClick"),children:[(0,n.jsx)(Hl,{className:"h-3.5 w-3.5"}),"Local path"]})]}),d?(0,n.jsxs)("div",{className:"grid gap-2",children:[(0,n.jsx)(Fn,{htmlFor:"adapterLocalPath",children:"Path to adapter package"}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)(mt,{id:"adapterLocalPath",className:"flex-1 font-mono text-xs",placeholder:"/mnt/e/Projects/my-adapter or E:\\Projects\\my-adapter",value:a,onChange:i(D=>o(D.target.value),"onChange")}),(0,n.jsx)(rS,{})]}),(0,n.jsx)("p",{className:"text-xs text-ink-3",children:"Accepts Linux, WSL, and Windows paths. Windows paths are auto-converted."})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"grid gap-2",children:[(0,n.jsx)(Fn,{htmlFor:"adapterPackageName",children:"Package Name"}),(0,n.jsx)(mt,{id:"adapterPackageName",placeholder:"my-paperclip-adapter",value:a,onChange:i(D=>o(D.target.value),"onChange")})]}),(0,n.jsxs)("div",{className:"grid gap-2",children:[(0,n.jsx)(Fn,{htmlFor:"adapterVersion",children:"Version (optional)"}),(0,n.jsx)(mt,{id:"adapterVersion",placeholder:"latest",value:l,onChange:i(D=>c(D.target.value),"onChange")})]})]})]}),(0,n.jsxs)(fr,{children:[(0,n.jsx)($,{variant:"secondary",onClick:i(()=>p(!1),"onClick"),children:"Cancel"}),(0,n.jsx)($,{onClick:i(()=>j.mutate({packageName:a,version:l||void 0,isLocalPath:d}),"onClick"),disabled:!a||j.isPending,children:j.isPending?"Installing...":"Install"})]})]})]})]}),(0,n.jsx)("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 px-4 py-3",children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)(En,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-700"}),(0,n.jsxs)("div",{className:"space-y-1 text-sm",children:[(0,n.jsx)("p",{className:"font-medium text-ink",children:"External adapters are alpha."}),(0,n.jsx)("p",{className:"text-ink-3",children:"The adapter plugin system is under active development. APIs and storage format may change. Use the power icon to hide adapters from agent menus without removing them."})]})]})}),(0,n.jsxs)("section",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(If,{className:"h-5 w-5 text-ink-3"}),(0,n.jsx)("h2",{className:"text-base font-semibold",children:"External Adapters"})]}),E.length===0?(0,n.jsx)(hs,{className:"bg-bg-3/30",children:(0,n.jsxs)(la,{className:"flex flex-col items-center justify-center py-10",children:[(0,n.jsx)(If,{className:"h-10 w-10 text-ink-3 mb-4"}),(0,n.jsx)("p",{className:"text-sm font-medium",children:"No external adapters installed"}),(0,n.jsx)("p",{className:"text-xs text-ink-3 mt-1",children:"Install an adapter package to extend model support."})]})}):(0,n.jsx)(hs,{className:"block py-0",children:(0,n.jsx)("ul",{className:"divide-y",children:E.map(D=>{const K=D.overriddenBuiltin,L=K&&!!D.overridePaused,B=K?{...D,disabled:L??!1}:D;return(0,n.jsx)(Zre,{adapter:B,canRemove:!0,onToggle:K?(z,U)=>A.mutate({type:z,paused:U}):(z,U)=>S.mutate({type:z,disabled:U}),onRemove:i(z=>g(z),"onRemove"),onReload:i(z=>I.mutate(z),"onReload"),onReinstall:D.isLocalPath?void 0:z=>v(D),isToggling:K?A.isPending:S.isPending,isReloading:I.isPending,isReinstalling:_.isPending,toggleTitleDisabled:K?"Pause external override":void 0,toggleTitleEnabled:K?"Resume external override":void 0,disabledBadgeLabel:K?"Override paused":void 0},D.type)})})})]}),(0,n.jsxs)("section",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(If,{className:"h-5 w-5 text-ink-3"}),(0,n.jsx)("h2",{className:"text-base font-semibold",children:"Built-in Adapters"})]}),T.length===0&&M.length===0?(0,n.jsx)("div",{className:"text-sm text-ink-3",children:"No built-in adapters found."}):(0,n.jsx)(hs,{className:"block py-0",children:(0,n.jsxs)("ul",{className:"divide-y",children:[T.map(D=>(0,n.jsx)(Zre,{adapter:D,canRemove:!1,onToggle:i((K,L)=>S.mutate({type:K,disabled:L}),"onToggle"),onRemove:i(()=>{},"onRemove"),isToggling:P},D.type)),M.map(D=>(0,n.jsx)(Zre,{adapter:{type:D.type,label:D.label,source:"builtin",modelsCount:0,loaded:!0,disabled:D.menuDisabled,capabilities:{supportsInstructionsBundle:!1,supportsSkills:!1,supportsLocalAgentJwt:!1,requiresMaterializedRuntimeSkills:!1,supportsAcp:!1}},canRemove:!1,onToggle:i((K,L)=>S.mutate({type:K,disabled:L}),"onToggle"),onRemove:i(()=>{},"onRemove"),isToggling:P,overriddenBy:D.overridePaused?void 0:D.overriddenBy},D.type))]})})]}),(0,n.jsx)(Bn,{open:f!==null,onOpenChange:i(D=>{D||g(null)},"onOpenChange"),children:(0,n.jsxs)(zn,{children:[(0,n.jsxs)(rs,{children:[(0,n.jsx)(qn,{children:"Remove Adapter"}),(0,n.jsxs)(ds,{children:["Are you sure you want to remove the ",(0,n.jsx)("strong",{children:f})," adapter? It will be unregistered and removed from the adapter store.",f&&b?.find(D=>D.type===f)?.packageName&&(0,n.jsx)(n.Fragment,{children:" npm packages will be cleaned up from disk."})," ","This action cannot be undone."]})]}),(0,n.jsxs)(fr,{children:[(0,n.jsx)($,{variant:"secondary",onClick:i(()=>g(null),"onClick"),children:"Cancel"}),(0,n.jsx)($,{variant:"delete",disabled:N.isPending,onClick:i(()=>{f&&N.mutate(f,{onSettled:i(()=>g(null),"onSettled")})},"onClick"),children:N.isPending?"Removing...":"Remove"})]})]})}),(0,n.jsx)(yLs,{adapter:x,open:x!==null,isReinstalling:_.isPending,onConfirm:i(()=>{x&&_.mutate(x.type,{onSettled:i(()=>v(null),"onSettled")})},"onConfirm"),onCancel:i(()=>v(null),"onCancel")})]})}i(iUe,"AdapterManager");function aUe(){const e=Mi(),{companyPrefix:t,pluginId:s,pluginRoutePath:r}=e,a=e["*"],{companies:o,selectedCompanyId:l}=gn(),{setBreadcrumbs:c}=Hs(),d=(0,m.useMemo)(()=>{if(!t)return null;const b=t.toUpperCase();return o.find(y=>y.issuePrefix.toUpperCase()===b)??null},[o,t]),u=!!t&&!d,h=(0,m.useMemo)(()=>d?d.id:t?null:l??null,[d,t,l]),p=(0,m.useMemo)(()=>h?o.find(b=>b.id===h)?.issuePrefix??null:null,[o,h]),{data:f}=ie({queryKey:O.plugins.uiContributions,queryFn:i(()=>Yc.listUiContributions(),"queryFn"),enabled:!!h&&(!!s||!!r)}),g=(0,m.useMemo)(()=>{if(!f)return null;if(s){const y=f.find(j=>j.pluginId===s);if(!y)return null;const k=y.slots.find(j=>j.type==="page");return k?{...k,pluginId:y.pluginId,pluginKey:y.pluginKey,pluginDisplayName:y.displayName,pluginVersion:y.version}:null}if(!r)return null;const b=f.flatMap(y=>{const k=y.slots.find(j=>j.type==="page"&&j.routePath===r);return k?[{...k,pluginId:y.pluginId,pluginKey:y.pluginKey,pluginDisplayName:y.displayName,pluginVersion:y.version}]:[]});return b.length!==1?null:b[0]??null},[s,r,f]),x=(0,m.useMemo)(()=>({companyId:h??null,companyPrefix:p}),[h,p]),v=(0,m.useMemo)(()=>{if(!r||!f)return!1;const b=f.flatMap(y=>y.slots.map(k=>({...k,pluginId:y.pluginId,pluginKey:y.pluginKey,pluginDisplayName:y.displayName,pluginVersion:y.version})));return QZe(b,r)!==null},[f,r]);if((0,m.useEffect)(()=>{if(g){if(v){c([{label:kLs(g,a)}]);return}c([{label:"Plugins",href:"/company/settings/instance/plugins"},{label:g.pluginDisplayName}])}},[g,a,c,v]),!h)return u?(0,n.jsx)(A0,{scope:"invalid_company_prefix",requestedPrefix:t}):(0,n.jsx)("div",{className:"space-y-4",children:(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Select an organization to view this page."})});if(!f)return(0,n.jsx)("div",{className:"text-sm text-ink-3",children:"Loading…"});if(!s&&r&&f.filter(b=>b.slots.some(y=>y.type==="page"&&y.routePath===r)).length>1)return(0,n.jsxs)("div",{className:"rounded-md border border-bad/30 bg-bad/5 px-3 py-2 text-sm text-bad",children:["Multiple plugins declare the route ",(0,n.jsx)("code",{children:r}),". Use the plugin-id route until the conflict is resolved."]});if(!g){if(r)return(0,n.jsx)(A0,{scope:"board"});const b=s?`/company/settings/instance/plugins/${s}`:"/company/settings/instance/plugins";return(0,n.jsx)(Ss,{to:b,replace:!0})}return(0,n.jsxs)("div",{className:"space-y-4",children:[!v&&(0,n.jsx)("div",{className:"flex items-center gap-2",children:(0,n.jsx)($,{variant:"ghost",size:"sm",asChild:!0,children:(0,n.jsxs)(Ye,{to:p?`/${p}/dashboard`:"/dashboard",children:[(0,n.jsx)(cc,{className:"h-4 w-4 mr-1"}),"Back"]})})}),(0,n.jsx)(jx,{slot:g,context:x,className:"min-h-(--sz-200px)",missingBehavior:"placeholder"})]})}i(aUe,"PluginPage");function kLs(e,t){return wLs(t)??e.displayName??e.pluginDisplayName}i(kLs,"resolveRouteSidebarPageTitle");function wLs(e){const t=(e??"").split("/").filter(Boolean).map(jLs);return t.length===0?null:t[0]==="page"&&t.length>1?oUe(t.slice(1).join("/"),{preserveCase:!0}):oUe(t[0]??null)}i(wLs,"titleFromRouteSplat");function oUe(e,t={}){const s=e?.trim();if(!s)return null;const r=s.split("/").filter(Boolean).at(-1)??s,a=(r.split("::").at(-1)??r).replace(/\.[^.]+$/,"").replace(/[-_]+/g," ").trim();return a?t.preserveCase?a:a.replace(/\b\w/g,o=>o.toUpperCase()):null}i(oUe,"titleFromPath");function jLs(e){try{return decodeURIComponent(e)}catch{return e}}i(jLs,"decodeRouteSegment");var Xre={openrouter:"OPENROUTER_API_KEY",openai:"OPENAI_API_KEY",anthropic:"ANTHROPIC_API_KEY",google:"GEMINI_API_KEY",xai:"XAI_API_KEY",groq:"GROQ_API_KEY",opencode:"OPENCODE_API_KEY"};async function NLs(e,t,s){const r=await Or.create(e,{name:`${t} · agent setup`,key:`${t}.setup.${crypto.randomUUID()}`,value:s.trim(),description:"Adapter credential supplied during agent setup."});return{binding:{type:"secret_ref",secretId:r.id,version:"latest"},remove:i(()=>Or.remove(r.id),"remove")}}i(NLs,"storeOrganizationApiKey");async function CLs(e,t,s){const r=`${t}.setup.${crypto.randomUUID()}`,a=await Or.createUserSecretDefinition(e,{key:r,name:`${t} · agent setup`,description:"Model provider credential for a new agent setup."}),o=i(()=>Or.removeUserSecretDefinition(e,a.id),"remove");try{await Or.createMyUserSecret(e,{definitionId:a.id,definitionKey:r,value:s.trim()})}catch(l){throw await o(),l}return{binding:{type:"user_secret_ref",key:r,version:"latest"},remove:o}}i(CLs,"storeProviderApiKey");function SLs({children:e,className:t}){return(0,n.jsx)("div",{className:Q("w-(--sz-560px) max-w-full rounded-xl border border-line bg-bg-2 px-8 py-10 sm:px-10 sm:py-11",t),children:e})}i(SLs,"OnboardingCard");function _Ls({title:e,lede:t,center:s}){return(0,n.jsxs)("div",{className:Q("space-y-2",s&&"text-center"),children:[(0,n.jsx)("h1",{className:"text-(length:--text-onboarding-title) font-semibold leading-(--leading-onboarding-title) tracking-tight text-ink",children:e}),t?(0,n.jsx)("p",{className:"text-base leading-relaxed text-ink-3",children:t}):null]})}i(_Ls,"OnboardingHeading");var lUe=cmt,cUe=i(e=>e.status==="fail"||e.checks.some(t=>t.code==="adapter_auth_missing"),"blocking");function ALs(){const{selectedCompanyId:e}=gn(),[t]=Ia();return e?(0,n.jsx)(ILs,{companyId:e,name:t.get("name")??"",adapterType:t.get("adapterType")??"",runnerProvider:t.get("runnerProvider")??"codex",createdAgentId:t.get("createdAgentId")},`${e}:${t.get("name")}:${t.get("adapterType")}:${t.get("runnerProvider")}`):(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Select an organization to create an agent."})}i(ALs,"NewAgentSetup");function ILs({companyId:e,name:t,adapterType:s,runnerProvider:r,createdAgentId:a}){const o=ir(),l=Ct(),{openNewIssue:c}=Oc(),d=wft(`${e}:new-agent`),u=s==="paperclip_runner",h=u&&r==="openai_dot",p=h?"openai_dot":u?r==="grok"?"grok_local":r==="claude"?"claude_local":r==="opencode"?"opencode_local":"codex_local":s,f=p==="claude_local"||p==="codex_local"||p==="grok_local"?p:null,g=p==="opencode_local",x=g,v=!h,[b,y]=(0,m.useState)(!1),[k,j]=(0,m.useState)(a?"saved":f?"connect":"runtime"),[N,S]=(0,m.useState)(""),[A,I]=(0,m.useState)(""),[_,T]=(0,m.useState)(!1),[E,M]=(0,m.useState)(""),[P,D]=(0,m.useState)("openrouter"),[K,L]=(0,m.useState)(""),[B,z]=(0,m.useState)(null),[U,W]=(0,m.useState)(()=>p==="opencode_local"?{provider:"openrouter",method:"api_key",mode:"responsible_user"}:void 0),[F,Y]=(0,m.useState)(null),V=U??F?.aiConnection,G=h0t(e,V,p),[ne,Z]=(0,m.useState)(null),J=ie({queryKey:O.agents.detail(a??"new"),queryFn:i(()=>Pt.get(a,e),"queryFn"),enabled:!!a,retry:!1}),se=ne??(J.data?.companyId===e?J.data:null),[H,ee]=(0,m.useState)(!1),[te,oe]=(0,m.useState)("idle"),[ae,ge]=(0,m.useState)(null),[xe,ce]=(0,m.useState)(null),de=(0,m.useRef)(0),be=(0,m.useRef)(!1);(0,m.useEffect)(()=>()=>{de.current++},[]);const me=i(()=>{de.current++,ge(null),oe("idle"),ce(null)},"resetTest"),we=i(()=>{Y(null),W(void 0),me(),j("connect")},"editConnection"),ue=ie({queryKey:O.adapters.all,queryFn:xf.list}),pe=ie({queryKey:O.agents.list(e),queryFn:i(()=>Pt.list(e),"queryFn")}),Se=ie({queryKey:O.environments.list(e),queryFn:i(()=>uo.list(e),"queryFn")}),De=ie({queryKey:O.instance.settings,queryFn:Fr.get}),Te=ie({queryKey:O.instance.experimentalSettings,queryFn:Fr.getExperimental}),st=ie({queryKey:O.instance.generalSettings,queryFn:Fr.getGeneral}),fe=ie({queryKey:O.environments.capabilities(e),queryFn:i(()=>uo.capabilities(e),"queryFn")}),Be=ie({queryKey:O.agents.adapterModels(e,p,null,V?.provider),queryFn:i(()=>Pt.adapterModels(e,p,{provider:V?.provider}),"queryFn"),enabled:!!p&&v&&!G,retry:!1}),ke=ie({queryKey:O.secrets.list(e),queryFn:i(()=>Or.list(e),"queryFn"),enabled:x}),$t=ie({queryKey:O.secrets.myUserSecrets(e),queryFn:i(()=>Or.listMyUserSecrets(e),"queryFn"),enabled:x,retry:!1}),Ie=wye(st.data?.executionMode,Se.data??[]),Re=Te.data?.enableManagedSandboxOnly===!0;let Je=null,je=null;try{Je=Ie.forced?Ie.kubernetesEnvironment?.id??null:AK({agentDefaultEnvironmentId:E||null,instanceDefaultEnvironmentId:De.data?.defaultEnvironmentId??null,localDefaultEnvironmentId:TK(Se.data??[]),managedSandboxOnly:Re,managedSandboxEnvironmentId:IK(Se.data??[]),visibleEnvironmentIds:(Se.data??[]).map(ut=>ut.id)})}catch(ut){je=ut instanceof Error?ut.message:"Could not resolve the environment."}const Fe=Se.data?.find(ut=>ut.id===Je),Ue=typeof Fe?.config?.provider=="string"?Fe.config.provider:"",qe=Fe?.driver==="sandbox"&&fe.data?.sandboxProviders?.[Ue]?.supportsLoginPty===!0,Ne=Xre[P]??"API_KEY",Le=$t.data?.find(ut=>ut.definition.key===Ne&&ut.secret),et=ke.data?.find(ut=>ut.key===Ne&&ut.status==="active"),at=B??(et?{type:"secret_ref",secretId:et.id,version:"latest"}:Le?{type:"user_secret_ref",key:Ne,version:"latest"}:null),yt=!!im(),ze=jft(s,{cloud:yt,nativeRunnerEnabled:Te.data?.enableNativeRunner===!0,openAiDotEnabled:Te.data?.enableOpenAiDot===!0,runnerProvider:r})&&ue.data?.some(ut=>ut.type===s&&ut.loaded&&!ut.disabled&&!Vf(s).comingSoon),Ve=!!(ze&&!je&&!Se.isPending&&!De.isPending&&!Te.isPending&&!st.isPending&&!pe.isPending&&!fe.isPending&&!Se.error&&!De.error&&!Te.error&&!st.error&&!pe.error&&!fe.error&&(!(Re||Ie.forced)||Je)),dt=te==="running"||H;function Ee(ut=F,Kt=at){const pt={...YL,adapterType:s,model:N||(p==="codex_local"?VL:""),thinkingEffort:A,envBindings:ut?.env??{},...u?{adapterSchemaValues:{provider:r==="claude"||r==="grok"?"acpx":r,...h?{allowUnmeteredProvider:b}:{},...r==="claude"||r==="grok"?{acpxAgent:r}:{}}}:{}},St=F7(s).buildAdapterConfig(pt);return s==="omp_local"&&(delete St.thinkingEffort,A&&(St.thinking=A)),u&&Object.assign(St,{provider:r==="claude"||r==="grok"?"acpx":r,...r==="claude"||r==="grok"?{acpxAgent:r}:{},...N?{model:N}:{}}),!V&&!ut?.aiConnection&&x&&Kt&&(St.env={...St.env??{},[Ne]:Kt}),St}i(Ee,"buildConfig");function it(ut=F){if(h&&!b)throw new Error("Acknowledge external provider billing before creating your Dot agent.");if(g&&(!N.trim()||!N.includes("/")))throw new Error("Choose or enter a model in provider/model format.");return Ee(ut)}i(it,"preparedConfig");function he(ut=F){return V||ut?.aiConnection?{}:{...ut?.credentials,...x&&K.trim()?{[Ne]:K.trim()}:{}}}i(he,"pendingCredentials");async function Ke(ut=F){if(!Ve)return!1;const Kt=++de.current;oe("running"),ge(null),ce(null);try{const pt=await it(ut),St=await p0t({companyId:e,adapterType:s,providerAdapter:p,adapterConfig:pt,testCredentials:he(ut),aiConnection:U??ut?.aiConnection,environmentId:Je});return Kt!==de.current?!1:(ge(St),oe(cUe(St)?"fail":St.status),!cUe(St)&&(!f||St.checks.some(Vt=>Vt.code.endsWith("hello_probe_passed"))))}catch(pt){return Kt===de.current&&(ce(pt instanceof Error?pt.message:"Could not test the agent."),oe("fail")),!1}}i(Ke,"runTest");async function Rt(){if(be.current||a||se||!Ve||!t.trim()||te==="running"||te==="fail"||f&&!F)return;be.current=!0,ee(!0),ce(null);const ut=[];let Kt=!1;try{const pt=it(),St=he();if(Object.keys(St).length&&!await Ke())return;for(const[Ut,Pn]of Object.entries(St)){const Bs=await(f?CLs:NLs)(e,Ut,Pn);ut.push(Bs),pt.env={...pt.env??{},[Ut]:Bs.binding}}const Vt=pe.data??[],tn=Vt.find(Ut=>Ut.role==="ceo"&&Ut.status!=="terminated"),Jt=await Pt.hire(e,{name:t.trim(),appearance:d.appearance,role:Vt.length?"general":"ceo",...tn?{reportsTo:tn.id}:{},adapterType:s,adapterConfig:pt,defaultEnvironmentId:E||(Ie.forced||Re?Je:null),runtimeConfig:{...mbt({heartbeatEnabled:!1}),...V?{aiConnection:V}:{}},budgetMonthlyCents:0,...F?.storedSessionId?{storedSessionId:F.storedSessionId}:{},...F?.applyStoredClaudeLogin?{applyStoredClaudeLogin:!0}:{}});Kt=!0,L(""),Y(null),Z(Jt.agent),d.clear(),j("saved"),o(`/agents/new?${new URLSearchParams({name:Jt.agent.name,adapterType:s,runnerProvider:r,createdAgentId:Jt.agent.id})}`,{replace:!0}),l.setQueryData(O.agents.detail(Jt.agent.id),Jt.agent),await Promise.all([l.invalidateQueries({queryKey:O.agents.list(e)}),l.invalidateQueries({queryKey:O.approvals.list(e)})])}catch(pt){ce(pt instanceof Error?pt.message:"Could not create the agent.")}finally{if(!Kt)try{await Promise.all(ut.map(pt=>pt.remove()))}catch{ce(pt=>`${pt?`${pt} `:""}Could not remove an unused setup credential. Remove it from Secrets before retrying.`)}l.invalidateQueries({queryKey:O.secrets.myUserSecrets(e)}),l.invalidateQueries({queryKey:O.secrets.list(e)}),be.current=!1,ee(!1)}}if(i(Rt,"finish"),a&&!se)return(0,n.jsx)("p",{role:J.error?"alert":"status",className:"text-sm text-ink-3",children:J.error?"Could not load the created agent. Return to Agents to view it.":"Loading your agent…"});if(!t||!s)return(0,n.jsx)(Nft,{open:!0,initialAdapter:s,onClose:i(()=>o("/agents/all"),"onClose"),onContinue:i(ut=>o(`/agents/new?${new URLSearchParams(ut)}`,{replace:!0}),"onContinue")});const ht=[...f?["connect"]:[],"runtime","saved"],Oe={connect:"Connect",runtime:"Configure",saved:"Confirmation"},Nt=se?.defaultEnvironmentId?Se.data?.find(ut=>ut.id===se.defaultEnvironmentId):Fe,He=se?.adapterConfig?.model||N||"Default",Pe=Nt?yI(Nt):"Local machine",ve=ue.error??Se.error??De.error??Te.error??st.error??pe.error??fe.error;return(0,n.jsx)(Xkn,{reducedMotion:"user",children:(0,n.jsxs)("div",{className:"mx-auto flex max-w-5xl flex-col gap-8 py-6",children:[(0,n.jsxs)("header",{className:"flex items-center gap-4",children:[(0,n.jsx)(wI,{appearance:se?.appearance??d.appearance,size:256,className:"size-48",trackingScope:"page",state:se||te==="pass"?"success":te==="running"?"loading":"sleepy",muted:!se&&te!=="pass"}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:t}),(0,n.jsxs)("div",{className:"flex items-center gap-2 text-sm text-ink-3",children:[(0,n.jsx)(Zg,{type:p}),(0,n.jsx)("span",{children:Vf(p).label}),u&&!h&&(0,n.jsxs)("span",{children:["·"," ",r==="codex"?"Native app server runner":"Wardmote Runner"]})]})]})]}),je&&!Se.isPending&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-bad",children:je}),ve&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-bad",children:ve.message}),ue.data&&!ze&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-bad",children:"This adapter is unavailable. Choose an enabled adapter."}),(Re||Ie.forced)&&!Se.isPending&&!Je&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-bad",children:"No managed environment is available. Configure an environment before continuing."}),(0,n.jsxs)("div",{className:"flex flex-col gap-8 md:flex-row",children:[(0,n.jsx)("nav",{"aria-label":"Agent setup steps",className:"shrink-0 md:w-44",children:(0,n.jsx)("ol",{className:"flex flex-wrap gap-2 md:flex-col",children:ht.map((ut,Kt)=>(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button","aria-current":ut===k?"step":void 0,disabled:dt||!!se||ut==="saved",onClick:i(()=>ut==="connect"&&k!=="connect"?we():j(ut),"onClick"),className:Q("flex w-full items-center gap-3 rounded-md px-3 py-3 text-left text-sm",ut===k?"bg-bg-3 font-medium":"text-ink-3"),children:[(0,n.jsx)("span",{className:Q("flex size-6 shrink-0 items-center justify-center rounded-full border text-xs",ut===k?"border-ink bg-ink text-bg":"border-line"),children:Kt+1}),Oe[ut]]})},ut))})}),(0,n.jsx)("div",{className:"min-w-0 flex-1",children:(0,n.jsx)(L7,{mode:"wait",initial:!1,children:(0,n.jsx)(xx.div,{...Fjn,children:k==="connect"&&f?(0,n.jsxs)(SLs,{className:"mx-auto",children:[(0,n.jsx)("div",{className:"mb-8",children:(0,n.jsx)(_Ls,{title:"Connect a model",center:!0})}),Ve?(0,n.jsx)(Cft,{companyId:e,adapterType:f,environmentId:Je,canLogin:qe,localEnvironment:Fe?.driver==="local",advancedConnection:{value:V,content:(0,n.jsx)(zce,{companyId:e,agentName:t,adapterType:p,model:N,environmentId:Je??void 0,value:V,preferAdvanced:!0,onChange:i(ut=>{Y(null),W(ut),me()},"onChange")})},onBack:i(()=>o("/agents/all"),"onBack"),onDraftChanged:i(()=>{Y(null),W(void 0),me()},"onDraftChanged"),testConnection:Ke,testError:xe??(ae?.checks.find(ut=>ut.level==="error")??ae?.checks.find(ut=>ut.code.includes("hello_probe")&&ut.level==="warn"))?.message,onConnected:i(ut=>{Y(ut),W(void 0),me(),j("runtime")},"onConnected")},Je??"local"):(0,n.jsx)("p",{role:"status",className:"text-sm text-ink-3",children:"Loading connection settings…"})]}):k==="saved"&&se?(0,n.jsxs)("div",{className:"space-y-6",children:[(0,n.jsxs)("div",{className:"space-y-6 rounded-lg border border-line p-6",children:[(0,n.jsxs)("h2",{className:"flex items-center gap-3 text-lg font-semibold",children:[(0,n.jsx)(sn,{className:"size-5"}),se.status==="pending_approval"?"Agent submitted for approval":h?"Your Dot agent has been created":"Your agent is ready"]}),(0,n.jsxs)("dl",{className:"grid grid-cols-2 gap-4 text-sm",children:[(0,n.jsx)("dt",{className:"text-ink-3",children:"Adapter"}),(0,n.jsx)("dd",{children:Vf(h?"openai_dot":s).label}),v&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("dt",{className:"text-ink-3",children:"Model"}),(0,n.jsx)("dd",{className:"break-all",children:String(He)})]}),(0,n.jsx)("dt",{className:"text-ink-3",children:"Environment"}),(0,n.jsx)("dd",{children:Pe})]}),(0,n.jsx)("p",{className:"text-sm text-ink-3",children:se.status==="pending_approval"?"An organization administrator must approve this agent before it can work.":h?"Pair your Dot and test event delivery in configuration before assigning work.":"Assign a task when you’re ready for this agent to work."})]}),(0,n.jsxs)("div",{className:"flex flex-wrap justify-between gap-3",children:[(0,n.jsxs)($,{variant:"secondary",onClick:i(()=>o(h?"/agents/all":`${Qg(se)}/runtime`),"onClick"),children:[(0,n.jsx)(F0e,{className:"size-4"}),h?"Back to Agents":"Edit configuration"]}),(0,n.jsxs)($,{disabled:se.status==="pending_approval",onClick:i(()=>h?o(`${Qg(se)}/runtime`):c({assigneeAgentId:se.id,status:"todo"}),"onClick"),children:[h?"Pair Dot":`Assign ${se.name} a Task`,(0,n.jsx)(zl,{className:"size-4"})]})]})]}):(0,n.jsxs)("form",{className:"space-y-8",onSubmit:i(ut=>{ut.preventDefault(),Rt()},"onSubmit"),children:[(0,n.jsx)("h2",{className:"text-xl font-semibold",children:"Configure your agent"}),(0,n.jsxs)("fieldset",{disabled:dt,className:"space-y-8",children:[(0,n.jsxs)("section",{className:"space-y-5",children:[h&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Create this agent, then copy its pairing prompt to your Dot."}),Te.data?.enablePublicMcp!==!0&&(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Turn on Assistant connections in Settings > Features before pairing."}),(0,n.jsx)(qd,{label:"Allow externally billed provider",hint:"Dot does not report token usage or cost. Wardmote cannot enforce a provider spend ceiling; known company and agent budget limits still apply.",checked:b,onChange:i(ut=>{y(ut),me()},"onChange")})]}),!f&&m0t(p)&&(0,n.jsx)(zce,{companyId:e,agentName:t,adapterType:p,model:N,environmentId:Je??void 0,value:V,onChange:i(ut=>{W(ut),me()},"onChange")}),(G?G.error:Be.error)&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-bad",children:"Could not load models. Retry or enter a model ID manually."}),v&&(0,n.jsx)("div",{className:"grid items-start gap-5 sm:grid-cols-2",children:v&&(0,n.jsx)(jye,{models:G?.models??Be.data??[],onRefreshModels:G?.refreshModels,refreshingModels:G?.refreshing,value:N,onChange:i(ut=>{S(G?.resolveModel(ut)??ut),(s==="omp_local"?!aG(A,ut,(Be.data??[]).map(pt=>rA(pt,!1))):A)&&I("");const Kt=ut.split("/")[0];g&&Xre[Kt]&&Kt!==P&&(D(Kt),L(""),z(null)),me()},"onChange"),open:_,onOpenChange:T,allowDefault:!g,required:g,creatable:!0,groupByProvider:g&&!G,preserveOrder:!!G||rye(p),effort:s==="omp_local"?{value:A||null,onChange:i(ut=>{I(ut??""),me()},"onChange")}:void 0})}),x&&!V&&(0,n.jsxs)("div",{className:"grid gap-5 sm:grid-cols-2",children:[x&&(0,n.jsx)(pr,{label:"API key provider",children:(0,n.jsx)("select",{"aria-label":"API key provider",className:lUe,value:P,onChange:i(ut=>{D(ut.target.value),S(""),L(""),z(null),me()},"onChange"),children:Object.keys(Xre).map(ut=>(0,n.jsx)("option",{value:ut,children:ut==="openrouter"?"OpenRouter":ut==="openai"?"OpenAI":ut==="anthropic"?"Anthropic":{google:"Google",xai:"xAI",groq:"Groq",opencode:"OpenCode"}[ut]??ut},ut))})}),(0,n.jsx)("div",{children:(0,n.jsx)(pr,{label:Ne,children:(0,n.jsx)("div",{className:"flex items-center gap-3",children:(0,n.jsx)(mt,{"aria-label":Ne,type:"password",autoComplete:"off",value:K,onChange:i(ut=>{L(ut.target.value),z(null),me()},"onChange"),placeholder:at?"Using saved key":"Optional if already configured"})})})}),(0,n.jsx)("div",{className:x?"sm:col-span-2":void 0,children:(0,n.jsx)(pr,{label:"Or use an organization secret",children:(0,n.jsx)(xye,{secretId:at&&typeof at=="object"&&at.type==="secret_ref"?at.secretId:"",secrets:ke.data??[],disabled:dt,onSelect:i(ut=>{z({type:"secret_ref",secretId:ut,version:"latest"}),L(""),me()},"onSelect")})})}),(0,n.jsxs)("p",{className:"text-xs text-ink-3 sm:col-span-2",children:["New keys are saved as organization secrets when you finish setup.",g&&` Use a ${P}/model ID.`]})]})]}),(0,n.jsxs)("section",{className:"space-y-5",children:[(0,n.jsx)("h3",{className:"text-sm font-semibold",children:"Environment"}),(0,n.jsxs)("select",{"aria-label":"Environment",className:lUe,value:E,disabled:Ie.forced,onChange:i(ut=>{M(ut.target.value),Y(null),me(),f&&j("connect")},"onChange"),children:[(0,n.jsxs)("option",{value:"",children:["Default: ",Pe]}),(Se.data??[]).filter(ut=>ut.status==="active"&&(!Re||ut.driver!=="local")).map(ut=>(0,n.jsx)("option",{value:ut.id,children:yI(ut)},ut.id))]})]})]}),(0,n.jsx)(f0t,{variant:h?"prerequisites":"connection",state:te,result:ae,error:xe,disabled:!Ve||dt||!!(f&&!F),onTest:i(()=>{Ke()},"onTest")}),xe&&te!=="fail"&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-bad",children:xe}),(0,n.jsxs)("div",{className:"flex justify-between border-t border-line py-5",children:[f?(0,n.jsxs)($,{type:"button",variant:"ghost",disabled:dt,onClick:we,children:[(0,n.jsx)(cc,{className:"size-4"}),"Connection"]}):(0,n.jsx)("span",{}),f&&!F?(0,n.jsxs)($,{type:"button",disabled:!Ve||dt,onClick:i(()=>j("connect"),"onClick"),children:["Connect model",(0,n.jsx)(zl,{className:"size-4"})]}):(0,n.jsxs)($,{type:"submit",disabled:!Ve||dt||te==="fail"||!!(f&&!F),children:[H?"Creating…":"Finish setup",(0,n.jsx)(sn,{className:"size-4"})]})]})]})},k)})})]})]})})}i(ILs,"Setup");function TLs(){const{setBreadcrumbs:e}=Hs();return(0,m.useEffect)(()=>{e([{label:"Agents",href:"/agents"},{label:"New agent"}])},[e]),(0,n.jsx)(ALs,{})}i(TLs,"NewAgent");var RQ="paperclip:pending-invite-token";function y1e(){return typeof window<"u"&&typeof window.localStorage<"u"}i(y1e,"canUseStorage");function dUe(e){const t=e.trim();if(!(!t||!y1e()))try{window.localStorage.setItem(RQ,t)}catch{}}i(dUe,"rememberPendingInviteToken");function UF(e){if(y1e())try{const t=window.localStorage.getItem(RQ);if(e&&t!==e.trim())return;window.localStorage.removeItem(RQ)}catch{}}i(UF,"clearPendingInviteToken");function ELs(){if(!y1e())return null;try{const e=window.localStorage.getItem(RQ)?.trim();return e?`/invite/${e}`:null}catch{return null}}i(ELs,"getRememberedInvitePath");var uUe=[" ",".","·","▪","▫","○"],RLs=1e3/24,KF=[[" ╭────╮ "," ╭╯╭──╮│ "," │ │ ││ "," │ │ ││ "," │ │ ││ "," │ │ ││ "," │ ╰──╯│ "," ╰─────╯ "],[" ╭─────╮ "," │╭──╮╰╮ "," ││ │ │ "," ││ │ │ "," ││ │ │ "," ││ │ │ "," │╰──╯ │ "," ╰────╯ "]];function hUe(e){const t=document.createElement("span");t.textContent="M",t.style.cssText="position:absolute;visibility:hidden;white-space:pre;font-size:11px;font-family:monospace;line-height:1;",e.appendChild(t);const s=t.getBoundingClientRect();return e.removeChild(t),{w:s.width,h:s.height}}i(hUe,"measureChar");function MLs(e){let t=0;for(const s of e)t=Math.max(t,s.length);return{width:t,height:e.length}}i(MLs,"spriteSize");function LLs(){const e=(0,m.useRef)(null),t=(0,m.useRef)(null);return(0,m.useEffect)(()=>{if(!e.current)return;const s=e.current,r=window.matchMedia("(prefers-reduced-motion: reduce)");let a=document.visibilityState!=="hidden",o=!1,l=0,c=0,d=0,u=0,h=7,p=11,f=new Float32Array(0),g=new Float32Array(0),x=new Float32Array(0),v=new Uint16Array(0),b=[],y="";function k(D){const K=Math.floor(Math.max(0,Math.min(.999,D))*uUe.length);return uUe[K]??" "}i(k,"toGlyph");function j(){const D=Math.max(0,Math.ceil(s.clientWidth/Math.max(1,h))),K=Math.max(0,Math.ceil(s.clientHeight/Math.max(1,p)));if(D===d&&K===u)return;d=D,u=K;const L=d*u;f=new Float32Array(L),g=new Float32Array(d),x=new Float32Array(u),v=new Uint16Array(L),b=b.filter(B=>B.x>-B.width-2&&B.x<d+2&&B.y>-B.height-2&&B.y<u+2),y=""}i(j,"rebuildGrid");function N(){if(d<=0||u<=0){s.textContent="";return}const D=Array.from({length:u},()=>Array.from({length:d},()=>" "));for(let z=0;z<u;z++)for(let U=0;U<d;U++){const W=(Math.sin(U*.11+z*.04)+Math.cos(z*.08-U*.02))*.18+.22;D[z][U]=k(W)}const K=18,L=13;for(let z=1;z<u-9;z+=L){const U=Math.floor(z/L)%2===0?2:10;for(let W=U;W<d-10;W+=K){const F=KF[(W+z)%KF.length];for(let Y=0;Y<F.length;Y++){const V=F[Y];for(let G=0;G<V.length;G++){const ne=V[G]??" ";if(ne===" ")continue;const Z=z+Y,J=W+G;Z<0||Z>=u||J<0||J>=d||(D[Z][J]=ne)}}}}const B=D.map(z=>z.join("")).join(`
751
751
  `);s.textContent=B,y=B}i(N,"drawStaticFrame");function S(){const D=KF[Math.floor(Math.random()*KF.length)],K=MLs(D),L=Math.random();let B=0,z=0,U=0,W=0;L<.68?(B=Math.random()<.5?-K.width-1:d+1,z=Math.random()*Math.max(1,u-K.height),U=B<0?.04+Math.random()*.05:-(.04+Math.random()*.05),W=(Math.random()-.5)*.014):(B=Math.random()*Math.max(1,d-K.width),z=Math.random()<.5?-K.height-1:u+1,U=(Math.random()-.5)*.014,W=z<0?.028+Math.random()*.034:-(.028+Math.random()*.034)),b.push({x:B,y:z,vx:U,vy:W,life:0,maxLife:260+Math.random()*220,drift:(Math.random()-.5)*1.2,sprite:D,width:K.width,height:K.height})}i(S,"spawnClip");function A(D,K){const L=Math.round(D.x),B=Math.round(D.y);for(let z=0;z<D.sprite.length;z++){const U=D.sprite[z],W=B+z;if(!(W<0||W>=u))for(let F=0;F<U.length;F++){const Y=U[F]??" ";if(Y===" ")continue;const V=L+F;if(V<0||V>=d)continue;const G=W*d+V,ne=Y==="│"||Y==="─"?.8:.92;f[G]=Math.max(f[G]??0,K*ne),v[G]=Y.charCodeAt(0)}}}i(A,"stampClip");function I(D){if(!o||(t.current=requestAnimationFrame(I),D-l<RLs||d<=0||u<=0))return;const K=Math.min(2,l===0?1:(D-l)/16.6667);l=D,c+=K;const L=d*u,B=Math.max(3,Math.floor(L/2200));for(;b.length<B;)S();for(let U=0;U<f.length;U++)f[U]*=.92;v.fill(0);for(let U=b.length-1;U>=0;U--){const W=b[U];W.life+=K;const F=Math.sin((W.y+W.drift+c*.12)*.09)*.0018,Y=Math.cos((W.x-W.drift-c*.09)*.08)*.0014;if(W.vx=(W.vx+F)*.998,W.vy=(W.vy+Y)*.998,W.x+=W.vx*K,W.y+=W.vy*K,W.life>=W.maxLife||W.x<-W.width-2||W.x>d+2||W.y<-W.height-2||W.y>u+2){b.splice(U,1);continue}const V=W.life/W.maxLife;A(W,V<.12?V/.12:V>.88?(1-V)/.12:1)}for(let U=0;U<d;U++)g[U]=Math.sin(U*.08+c*.06);for(let U=0;U<u;U++)x[U]=Math.cos(U*.1-c*.05);let z="";for(let U=0;U<u;U++){for(let W=0;W<d;W++){const F=U*d+W,Y=v[F];if(Y>0){z+=String.fromCharCode(Y);continue}const V=(g[W]+x[U])*.08+.1,G=Math.max(f[F]??0,V*.45);z+=k(G)}U<u-1&&(z+=`
752
- `)}z!==y&&(s.textContent=z,y=z)}i(I,"step");function _(){const D=d>0&&u>0;if(r.matches){o&&(o=!1,t.current!==null&&cancelAnimationFrame(t.current),t.current=null),D&&N();return}if(!a||!D){o&&(o=!1,t.current!==null&&cancelAnimationFrame(t.current),t.current=null);return}o||(o=!0,l=0,t.current=requestAnimationFrame(I))}i(_,"syncLoop");const T=new ResizeObserver(()=>{const D=hUe(s);h=D.w,p=D.h,j(),_()});T.observe(s);const E=i(()=>{a=document.visibilityState!=="hidden",_()},"onVisibilityChange");document.addEventListener("visibilitychange",E);const M=i(()=>{_()},"onMotionChange");r.addEventListener("change",M);const P=hUe(s);return h=P.w,p=P.h,j(),_(),()=>{o=!1,t.current!==null&&cancelAnimationFrame(t.current),T.disconnect(),document.removeEventListener("visibilitychange",E),r.removeEventListener("change",M)}},[]),(0,n.jsx)("pre",{ref:e,className:"w-full h-full m-0 p-0 overflow-hidden text-ink-3/60 select-none leading-none",style:{fontSize:"var(--text-micro)",fontFamily:"monospace"},"aria-hidden":"true"})}i(LLs,"AsciiArtAnimation");function DLs(){const e=Ct(),t=ir(),[s]=Ia(),[r,a]=(0,m.useState)("sign_in"),[o,l]=(0,m.useState)(""),[c,d]=(0,m.useState)(""),[u,h]=(0,m.useState)(""),[p,f]=(0,m.useState)(null),g="auth-error",x=(0,m.useMemo)(()=>Hft(s.get("next")||ELs()||"/"),[s]),v=ie({queryKey:O.health,queryFn:i(()=>Op.get(),"queryFn"),retry:!1}),{data:b,isLoading:y,error:k}=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),retry:!1});(0,m.useEffect)(()=>{b&&(Tke(),t(x,{replace:!0}))},[b,t,x]);const j=ye({mutationFn:i(async()=>{if(r==="sign_in"){await Ji.signInEmail({email:c.trim(),password:u});return}await Ji.signUpEmail({name:o.trim(),email:c.trim(),password:u})},"mutationFn"),onSuccess:i(async()=>{f(null),await e.invalidateQueries({queryKey:O.auth.session}),await e.invalidateQueries({queryKey:O.health}),await e.resetQueries({queryKey:O.companies.all}),t(x,{replace:!0})},"onSuccess"),onError:i(S=>{f(S instanceof Error?S.message:"Authentication failed")},"onError")}),N=c.trim().length>0&&u.trim().length>0&&(r==="sign_in"||o.trim().length>0&&u.trim().length>=8);return v.isLoading||y||b?(0,n.jsx)("div",{className:"fixed inset-0 flex items-center justify-center",children:(0,n.jsx)(bx,{className:"min-h-0"})}):v.error||k?(0,n.jsx)("p",{role:"alert",className:"p-6 text-sm text-bad",children:"Unable to check sign-in. Refresh and try again."}):v.data?.cloud?(0,n.jsx)(Eke,{cloud:v.data.cloud,returnTo:x}):(0,n.jsxs)("div",{className:"fixed inset-0 flex bg-bg",children:[(0,n.jsx)("div",{className:"absolute top-4 right-4 z-10",children:(0,n.jsx)(q6,{})}),(0,n.jsx)("div",{className:"w-full md:w-1/2 flex flex-col overflow-y-auto",children:(0,n.jsxs)("div",{className:"w-full max-w-md mx-auto my-auto px-8 py-12",children:[(0,n.jsx)("div",{className:"mb-8",children:(0,n.jsx)($0,{className:"size-8 text-ink",title:"Wardmote"})}),(0,n.jsx)("h1",{className:"text-xl font-semibold",children:r==="sign_in"?"Sign in to Wardmote":"Create your Wardmote account"}),(0,n.jsx)("p",{className:"mt-1 text-sm text-ink-3",children:r==="sign_in"?"Use your email and password to access this instance.":"Create an account for this instance. Email confirmation is not required in v1."}),(0,n.jsxs)("form",{className:"mt-6 space-y-4",method:"post",action:r==="sign_up"?"/api/auth/sign-up/email":"/api/auth/sign-in/email",onSubmit:i(S=>{if(S.preventDefault(),!j.isPending){if(!N){f("Please fill in all required fields.");return}j.mutate()}},"onSubmit"),children:[r==="sign_up"&&(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"name",className:"text-xs text-ink-3 mb-1 block",children:"Name"}),(0,n.jsx)("input",{id:"name",name:"name",className:"w-full rounded-md border border-line bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-focus placeholder:text-ink-3/50",value:o,onChange:i(S=>l(S.target.value),"onChange"),autoComplete:"name",required:!0,"aria-required":"true","aria-invalid":p?!0:void 0,"aria-describedby":p?g:void 0,autoFocus:!0})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"email",className:"text-xs text-ink-3 mb-1 block",children:"Email"}),(0,n.jsx)("input",{id:"email",name:"email",className:"w-full rounded-md border border-line bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-focus placeholder:text-ink-3/50",type:"email",value:c,onChange:i(S=>d(S.target.value),"onChange"),autoComplete:"username",required:!0,"aria-required":"true","aria-invalid":p?!0:void 0,"aria-describedby":p?g:void 0,autoFocus:r==="sign_in"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"password",className:"text-xs text-ink-3 mb-1 block",children:"Password"}),(0,n.jsx)("input",{id:"password",name:"password",className:"w-full rounded-md border border-line bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-focus placeholder:text-ink-3/50",type:"password",value:u,onChange:i(S=>h(S.target.value),"onChange"),autoComplete:r==="sign_in"?"current-password":"new-password",required:!0,"aria-required":"true","aria-invalid":p?!0:void 0,"aria-describedby":p?g:void 0})]}),p&&(0,n.jsx)("p",{id:g,role:"alert",className:"text-xs text-bad",children:p}),(0,n.jsx)($,{type:"submit",disabled:j.isPending,"aria-disabled":!N||j.isPending,className:`w-full ${!N&&!j.isPending?"opacity-50":""}`,children:j.isPending?"Working…":r==="sign_in"?"Sign In":"Create Account"})]}),(0,n.jsxs)("div",{className:"mt-5 text-sm text-ink-3",children:[r==="sign_in"?"Need an account?":"Already have an account?"," ",(0,n.jsx)("button",{type:"button",className:"font-medium text-ink underline underline-offset-2",onClick:i(()=>{f(null),a(r==="sign_in"?"sign_up":"sign_in")},"onClick"),children:r==="sign_in"?"Create one":"Sign in"})]})]})}),(0,n.jsx)("div",{className:"hidden md:block w-1/2 overflow-hidden",children:(0,n.jsx)(LLs,{})})]})}i(DLs,"AuthPage");function PLs(){const e=Ct(),t=Mi(),[s]=Ia(),r=(t.token??"").trim(),a=(s.get("code")??"").trim(),o=(0,m.useMemo)(()=>`/board-claim/${encodeURIComponent(r)}${a?`?code=${encodeURIComponent(a)}`:""}`,[r,a]),l=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),retry:!1}),c=ie({queryKey:["board-claim",r,a],queryFn:i(()=>jr.getBoardClaimStatus(r,a),"queryFn"),enabled:r.length>0&&a.length>0,retry:!1}),d=ye({mutationFn:i(()=>jr.claimBoard(r,a),"mutationFn"),onSuccess:i(async()=>{await e.invalidateQueries({queryKey:O.auth.session}),await e.invalidateQueries({queryKey:O.health}),await e.invalidateQueries({queryKey:O.companies.all}),await e.invalidateQueries({queryKey:O.companies.stats}),await c.refetch()},"onSuccess")});if(!r||!a)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-bad",children:"Invalid board claim URL."});if(c.isLoading||l.isLoading)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-ink-3",children:"Loading claim challenge..."});if(c.error)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Claim challenge unavailable"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:c.error instanceof Error?c.error.message:"Challenge is invalid or expired."})]})});const u=c.data;return u?u.status==="claimed"?(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Board ownership claimed"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"This instance is now linked to your authenticated user."}),(0,n.jsx)($,{asChild:!0,className:"mt-4",children:(0,n.jsx)(Ye,{to:"/",children:"Open board"})})]})}):l.data?(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsx)("h1",{className:"text-xl font-semibold",children:"Claim Board ownership"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"This will promote your user to instance admin and migrate organization ownership access from local trusted mode."}),d.error&&(0,n.jsx)("p",{className:"mt-3 text-sm text-bad",children:d.error instanceof Error?d.error.message:"Failed to claim board ownership"}),(0,n.jsx)($,{className:"mt-5",onClick:i(()=>d.mutate(),"onClick"),disabled:d.isPending,children:d.isPending?"Claiming…":"Claim ownership"})]})}):(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Sign in required"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"Sign in or create an account, then return to this page to claim Board ownership."}),(0,n.jsx)($,{asChild:!0,className:"mt-4",children:(0,n.jsx)(Ye,{to:`/auth?next=${encodeURIComponent(o)}`,children:"Sign in / Create account"})})]})}):(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-bad",children:"Claim challenge unavailable."})}i(PLs,"BoardClaimPage");function mUe({origin:e}){const[t,s]=(0,m.useState)(!1);let r;try{const a=new URL(e);a.origin==="https://claude.ai"?r="/brands/claude-color.svg":["https://chatgpt.com","https://chat.openai.com","https://openai.com"].includes(a.origin)&&(r="/brands/codex-color.svg")}catch{}return(0,n.jsxs)("div",{className:"flex items-center gap-2 text-sm text-ink-3",children:[r&&!t?(0,n.jsx)("img",{src:r,alt:"",className:"size-4 shrink-0 object-contain",referrerPolicy:"no-referrer",crossOrigin:"anonymous",onError:i(()=>s(!0),"onError")}):(0,n.jsx)(Lp,{className:"size-4 shrink-0","aria-hidden":"true"}),(0,n.jsx)("bdi",{className:"min-w-0 break-all",children:e})]})}i(mUe,"ClientOrigin");function pUe({agentPairingOnly:e=!1}={}){const{id:t=""}=Mi();return(0,n.jsx)(sAt,{id:t,agentPairingOnly:e},t)}i(pUe,"McpConnectPage");function $Ls({initialCode:e}={}){const[t,s]=(0,m.useState)(e??new URLSearchParams(window.location.search).get("user_code")??""),[r,a]=(0,m.useState)(t);return r?(0,n.jsx)(sAt,{id:r,device:!0,onEditCode:i(()=>a(""),"onEditCode")},r):(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"space-y-4 p-6",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)($0,{className:"size-8 shrink-0 text-ink"}),(0,n.jsx)("h1",{className:"min-w-0 text-xl font-semibold",children:"Connect your assistant to Wardmote"})]}),(0,n.jsxs)("form",{className:"space-y-4",onSubmit:i(o=>{o.preventDefault(),a(t.trim())},"onSubmit"),children:[(0,n.jsx)("label",{htmlFor:"device-code",className:"text-sm",children:"Enter the code shown by your assistant"}),(0,n.jsx)(mt,{id:"device-code",autoComplete:"off",value:t,onChange:i(o=>s(o.target.value),"onChange"),required:!0,maxLength:12}),(0,n.jsx)("div",{className:"flex justify-end",children:(0,n.jsx)($,{type:"submit",children:"Continue"})})]})]})})}i($Ls,"McpDevicePage");function sAt({id:e,device:t=!1,agentPairingOnly:s=!1,onEditCode:r}){const a=s?"/dot-mcp/requests":"/mcp/requests",[o,l]=(0,m.useState)(""),[c,d]=(0,m.useState)(""),[u,h]=(0,m.useState)(null),[p,f]=(0,m.useState)(""),[g,x]=(0,m.useState)(!0),[v,b]=(0,m.useState)(null),y=ie({queryKey:[t?"mcp-device":s?"dot-mcp-request":"mcp-request",e],queryFn:i(()=>le.get(t?`/mcp/device?user_code=${encodeURIComponent(e)}`:`${a}/${encodeURIComponent(e)}`),"queryFn"),retry:!1}),k=y.data;(0,m.useEffect)(()=>{if(h(null),f(""),!k?.agentConnection||t||!/^[A-Za-z0-9_-]{32}$/.test(c.trim()))return;let K=!0;return le.post(`${a}/${encodeURIComponent(e)}/dot-pairing/preview`,{pairingCode:c.trim()}).then(L=>{K&&h(L)}).catch(L=>{K&&f(L instanceof Error?L.message:"Unable to verify this pairing code.")}),()=>{K=!1}},[e,t,a,k?.agentConnection,c]);const j=k?.requestedCompanyId??(o||k?.companies[0]?.id||"");(0,m.useEffect)(()=>{!o&&!k?.requestedCompanyId&&k?.companies[0]&&l(k.companies[0].id)},[o,k]);const N=k?.clientName.trim(),S=N&&!/^(assistant|mcp client)$/i.test(N)?N:"your assistant",A=k?.clientOrigin||k?.redirectOrigin,I=k?.companies.find(K=>K.id===j),_=!!(!k?.agentConnection&&I?.canWrite&&g),T=!!(k?.requestedWrite&&_),E=!!(k?.requestedConfigure&&_),M=ye({mutationFn:i(K=>le.post(t?"/mcp/device/consent":`/mcp/requests/${encodeURIComponent(e)}/consent`,{decision:K,companyId:j||void 0,allowWrites:K==="approve"&&T,allowConfiguration:K==="approve"&&E,...t?{userCode:e}:{}}),"mutationFn"),onSuccess:i(({redirectUrl:K,status:L})=>{t&&L?b(L):K&&window.location.assign(K)},"onSuccess")}),P=ye({mutationFn:i(()=>le.post(`${a}/${encodeURIComponent(e)}/dot-pairing`,{pairingCode:c.trim()}),"mutationFn"),onSuccess:i(({redirectUrl:K})=>{d(""),window.location.assign(K)},"onSuccess")});if(v)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block space-y-4 p-6",children:[(0,n.jsx)($0,{className:"size-8 text-ink"}),(0,n.jsx)("h1",{className:"text-xl font-semibold",children:v==="approved"?"Access approved":"Connection declined"}),(0,n.jsx)("p",{className:"text-sm",children:v==="approved"?"Return to your assistant. It will finish connecting automatically.":"No access was granted. You can start a new connection from your assistant."}),(0,n.jsx)($,{variant:"secondary",asChild:!0,children:(0,n.jsx)(Ye,{to:"/",children:"Back to Wardmote"})})]})});const D=t?`/mcp-device?user_code=${encodeURIComponent(e)}`:`${s?"/dot-connect":"/mcp-connect"}/${e}`;return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block space-y-4 p-6",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)($0,{className:"size-8 shrink-0 text-ink",title:"Wardmote"}),(0,n.jsxs)("h1",{className:"min-w-0 break-words text-xl font-semibold",children:["Connect ",(0,n.jsx)("bdi",{children:S})," to Wardmote"]})]}),A&&(0,n.jsx)(mUe,{origin:A},A),!t&&k?.redirectOrigin&&k.redirectOrigin!==A&&(0,n.jsx)(mUe,{origin:k.redirectOrigin},k.redirectOrigin),t&&(0,n.jsxs)("p",{className:"text-sm",children:["Confirm this matches the code shown by your assistant: ",(0,n.jsx)("strong",{className:"font-mono",children:e.toUpperCase()})]}),y.isPending&&(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Loading connection request…"}),y.error&&(0,n.jsxs)("p",{className:"text-sm text-bad",children:[y.error.message," Start a new connection from your assistant."]}),t&&y.error&&(0,n.jsx)($,{variant:"secondary",onClick:r,children:"Enter a different code"}),k?.agentConnection&&!t&&(0,n.jsxs)("form",{className:"space-y-3",onSubmit:i(K=>{K.preventDefault(),P.mutate()},"onSubmit"),children:[(0,n.jsx)("p",{className:"text-sm",children:"Enter the one-use code from your Dot setup prompt to review this agent’s access. Access is granted when you click “Connect Dot with pairing code”."}),(0,n.jsx)("label",{htmlFor:"dot-pairing-code",className:"text-sm",children:"Pairing code"}),(0,n.jsx)(mt,{id:"dot-pairing-code",type:"password",autoComplete:"off",value:c,onChange:i(K=>{h(null),f(""),d(K.target.value)},"onChange"),required:!0,maxLength:32}),u&&(0,n.jsxs)("dl",{className:"space-y-2 rounded-md border border-line p-3 text-sm",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{className:"text-ink-3",children:"Company"}),(0,n.jsxs)("dd",{children:[u.company.name," ",(0,n.jsxs)("span",{className:"text-xs text-ink-3",children:["(",u.company.id,")"]})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{className:"text-ink-3",children:"Agent"}),(0,n.jsxs)("dd",{children:[u.agent.name," ",(0,n.jsxs)("span",{className:"text-xs text-ink-3",children:["(",u.agent.id,")"]})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{className:"text-ink-3",children:"Permissions"}),(0,n.jsx)("dd",{children:u.permissions})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{className:"text-ink-3",children:"Access duration"}),(0,n.jsx)("dd",{children:u.accessDuration})]})]}),p&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-bad",children:p}),P.error&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-bad",children:P.error.message}),(0,n.jsx)("div",{className:"flex justify-end",children:(0,n.jsx)($,{type:"submit",disabled:!u||!/^[A-Za-z0-9_-]{32}$/.test(c.trim())||P.isPending,children:P.isPending?"Connecting…":"Connect Dot with pairing code"})})]}),k&&(0,n.jsx)(n.Fragment,{children:k.requiresSignIn?(0,n.jsx)($,{asChild:!0,children:(0,n.jsx)(Ye,{to:`/auth?next=${encodeURIComponent(D)}`,children:"Sign in / Create account"})}):(0,n.jsxs)(n.Fragment,{children:[k.requestedCompanyId?(0,n.jsxs)("div",{className:"flex items-center gap-4 rounded-md border border-line p-4",children:[I&&(0,n.jsx)(c1,{companyName:I.name,logoUrl:I.logoUrl,className:"size-14 shrink-0 rounded-lg text-xl"}),(0,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsx)("p",{className:"text-xs text-ink-3",children:"Organization"}),I?(0,n.jsx)("p",{className:"break-words text-lg font-semibold",children:I.name}):(0,n.jsx)("p",{className:"text-sm text-bad",children:"The selected organization is no longer available to this account. Cancel and reconnect from your assistant to choose an organization you can access."})]})]}):(0,n.jsxs)("fieldset",{className:"space-y-2",disabled:M.isPending,children:[(0,n.jsx)("legend",{className:"mb-2 text-sm font-medium",children:"Organization"}),k.companies.map(K=>(0,n.jsxs)("label",{className:"flex items-center gap-3 rounded-md border border-line p-3 text-sm",children:[(0,n.jsx)("input",{type:"radio",name:"company","aria-label":K.name,value:K.id,checked:j===K.id,onChange:i(()=>l(K.id),"onChange")}),(0,n.jsx)(c1,{companyName:K.name,logoUrl:K.logoUrl,className:"size-12 shrink-0 rounded-lg"}),(0,n.jsx)("span",{className:"min-w-0 break-words font-medium",children:K.name})]},K.id)),!k.companies.length&&(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"This account has no available organizations. Ask an organization owner to add you, then reconnect from your assistant."})]}),(0,n.jsx)("p",{className:"text-sm",children:k.agentConnection?"Connect Dot as a Wardmote agent. Pair it with an agent after connecting; assigned work uses that agent’s permissions.":"Read all of your Wardmote data"}),(k.requestedWrite||k.requestedConfigure)&&!k.agentConnection&&(0,n.jsxs)("label",{htmlFor:"mcp-allow-writes",className:"flex items-start gap-3 text-sm leading-6",children:[(0,n.jsx)("span",{className:"flex h-6 shrink-0 items-center",children:(0,n.jsx)(Ci,{id:"mcp-allow-writes",checked:_,disabled:!I?.canWrite||M.isPending,onCheckedChange:i(K=>x(K===!0),"onCheckedChange")})}),(0,n.jsx)("span",{children:"Write all of your Wardmote data"})]}),I&&!I.canWrite&&(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Your role in this organization is read-only."}),M.error&&(0,n.jsx)("p",{className:"text-sm text-bad",children:M.error.message}),(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsx)($,{variant:"secondary",disabled:M.isPending,onClick:i(()=>M.mutate("deny"),"onClick"),children:"Cancel"}),(0,n.jsx)($,{className:"h-auto min-h-10 min-w-0 shrink whitespace-normal",disabled:!I||k.agentConnection&&!I.canWrite||M.isPending,onClick:i(()=>M.mutate("approve"),"onClick"),children:M.isPending?"Connecting…":k.agentConnection?"Connect Dot agent":"Connect organization"})]})]})})]})})}i(sAt,"McpConnectRequest");function OLs(){const e=Ct(),t=ie({queryKey:["mcp-connections"],queryFn:i(()=>le.get("/mcp/connections"),"queryFn"),retry:!1}),s=t.data?.filter(a=>!a.revokedAt),r=ye({mutationFn:i(a=>le.delete(`/mcp/connections/${a}`),"mutationFn"),onSuccess:i((a,o)=>(e.setQueryData(["mcp-connections"],l=>l?.filter(c=>c.id!==o)),e.invalidateQueries({queryKey:["mcp-connections"]})),"onSuccess")});return(0,n.jsxs)("div",{className:"mx-auto max-w-xl space-y-4 py-10",children:[(0,n.jsx)("h1",{className:"text-xl font-semibold",children:"Assistant connections"}),(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Revoking a connection stops its future tool calls. Work already delegated continues under your organization’s normal controls."}),t.isPending&&(0,n.jsx)("p",{className:"text-sm",children:"Loading connections…"}),(t.error||r.error)&&(0,n.jsx)("p",{className:"text-sm text-bad",children:(t.error??r.error)?.message}),s?.length===0&&(0,n.jsx)("p",{className:"text-sm",children:"No assistant connections."}),s?.map(a=>(0,n.jsxs)(hs,{className:"block space-y-2 p-4",children:[(0,n.jsx)("h2",{className:"font-medium",children:(0,n.jsx)(No,{name:vQ(a),avatarUrl:a.user?.image,initials:_b(a.user?.name??"You")})}),(0,n.jsxs)("p",{className:"text-sm text-ink-3",children:["Organization: ",a.companyName]}),(0,n.jsx)("p",{className:"text-sm",children:a.scopes.includes("paperclip:agent")?"Dot agent connection":a.scopes.includes("paperclip:write")?"Read and edit work":"Read only"}),a.scopes.includes("paperclip:configure")&&(0,n.jsx)("p",{className:"text-sm",children:"Configure agents, projects and skills"}),(0,n.jsx)($,{variant:"secondary",disabled:r.isPending,onClick:i(()=>r.mutate(a.id),"onClick"),children:"Revoke connection"})]},a.id)),(0,n.jsx)(Ye,{className:"text-sm underline",to:"/",children:"Back to Wardmote"})]})}i(OLs,"AssistantConnectionsPage");function FLs(){const e=Ct(),t=Mi(),[s]=Ia(),r=(t.id??"").trim(),a=(s.get("token")??"").trim(),o=(0,m.useMemo)(()=>`/cli-auth/${encodeURIComponent(r)}${a?`?token=${encodeURIComponent(a)}`:""}`,[r,a]),l=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),retry:!1}),c=ie({queryKey:["cli-auth-challenge",r,a],queryFn:i(()=>jr.getCliAuthChallenge(r,a),"queryFn"),enabled:r.length>0&&a.length>0,retry:!1}),d=ye({mutationFn:i(()=>jr.approveCliAuthChallenge(r,a),"mutationFn"),onSuccess:i(async()=>{await e.invalidateQueries({queryKey:O.auth.session}),await c.refetch()},"onSuccess")}),u=ye({mutationFn:i(()=>jr.cancelCliAuthChallenge(r,a),"mutationFn"),onSuccess:i(async()=>{await c.refetch()},"onSuccess")});if(!r||!a)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-bad",children:"Invalid CLI auth URL."});if(l.isLoading||c.isLoading)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-ink-3",children:"Loading CLI auth challenge..."});if(c.error)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"CLI auth challenge unavailable"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:c.error instanceof Error?c.error.message:"Challenge is invalid or expired."})]})});const h=c.data;return h?h.status==="approved"?(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsx)("h1",{className:"text-xl font-semibold",children:"CLI access approved"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"The Wardmote CLI can now finish authentication on the requesting machine."}),(0,n.jsxs)("p",{className:"mt-4 text-sm text-ink-3",children:["Command: ",(0,n.jsx)("span",{className:"font-mono text-ink",children:h.command})]})]})}):h.status==="cancelled"||h.status==="expired"?(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsx)("h1",{className:"text-xl font-semibold",children:h.status==="expired"?"CLI auth challenge expired":"CLI auth challenge cancelled"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"Start the CLI auth flow again from your terminal to generate a new approval request."})]})}):h.requiresSignIn||!l.data?(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsx)("h1",{className:"text-xl font-semibold",children:"Sign in required"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"Sign in or create an account, then return to this page to approve the CLI access request."}),(0,n.jsx)($,{asChild:!0,className:"mt-4",children:(0,n.jsx)(Ye,{to:`/auth?next=${encodeURIComponent(o)}`,children:"Sign in / Create account"})})]})}):(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsx)("h1",{className:"text-xl font-semibold",children:"Approve Wardmote CLI access"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"A local Wardmote CLI process is requesting board access to this instance."}),(0,n.jsxs)("div",{className:"mt-5 space-y-3 text-sm",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-ink-3",children:"Command"}),(0,n.jsx)("div",{className:"font-mono text-ink",children:h.command})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-ink-3",children:"Client"}),(0,n.jsx)("div",{className:"text-ink",children:h.clientName??"wardmote cli"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-ink-3",children:"Requested access"}),(0,n.jsx)("div",{className:"text-ink",children:h.requestedAccess==="instance_admin_required"?"Instance admin":"Board"})]}),h.requestedCompanyName&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-ink-3",children:"Requested organization"}),(0,n.jsx)("div",{className:"text-ink",children:h.requestedCompanyName})]})]}),(d.error||u.error)&&(0,n.jsx)("p",{className:"mt-4 text-sm text-bad",children:(d.error??u.error)instanceof Error?(d.error??u.error).message:"Failed to update CLI auth challenge"}),!h.canApprove&&(0,n.jsx)("p",{className:"mt-4 text-sm text-bad",children:"This challenge requires instance-admin access. Sign in with an instance admin account to approve it."}),(0,n.jsxs)("div",{className:"mt-5 flex gap-3",children:[(0,n.jsx)($,{onClick:i(()=>d.mutate(),"onClick"),disabled:!h.canApprove||d.isPending||u.isPending,children:d.isPending?"Approving...":"Approve CLI access"}),(0,n.jsx)($,{type:"button",variant:"secondary",onClick:i(()=>u.mutate(),"onClick"),disabled:d.isPending||u.isPending,children:u.isPending?"Cancelling...":"Cancel"})]})]})}):(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-bad",children:"CLI auth challenge unavailable."})}i(FLs,"CliAuthPage");var BLs=V4t.filter(e=>e!=="paperclip_runner"),fUe=new Set(["omp_local"]);function zLs(e,t){let s=e;for(const r of t){if(!s||typeof s!="object")return null;s=s[r]}return typeof s=="string"&&s.trim().length>0?s:null}i(zLs,"readNestedString");var L2="w-full border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none focus:border-zinc-500",gUe="border border-zinc-800 bg-zinc-950/95 p-6",xUe="flex-1 border px-3 py-2 text-sm transition-colors";function qLs(e){return e?e.charAt(0).toUpperCase()+e.slice(1):null}i(qLs,"formatHumanRole");function rAt(e){if(!e||typeof e!="object")return null;const t=e.code;return typeof t=="string"&&t.trim().length>0?t:null}i(rAt,"getAuthErrorCode");function ULs(e){if(!(e instanceof Error))return null;const t=e.message.trim();return t.length>0?t:null}i(ULs,"getAuthErrorMessage");function KLs(e,t,s){const r=rAt(e),a=ULs(e),o=s.trim().length>0?s.trim():"that email";return r==="USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL"?{tone:"info",message:`An account already exists for ${o}. Sign in below to continue with this invite.`}:r==="INVALID_EMAIL_OR_PASSWORD"?{tone:"error",message:"That email and password did not match an existing Wardmote account. Check both fields, or create an account first if you are new here."}:t==="sign_in"&&a==="Request failed: 401"?{tone:"error",message:"That email and password did not match an existing Wardmote account. Check both fields, or create an account first if you are new here."}:t==="sign_up"&&a==="Request failed: 422"?{tone:"info",message:`An account may already exist for ${o}. Try signing in instead.`}:{tone:"error",message:a??"Authentication failed"}}i(KLs,"mapInviteAuthFeedback");function vUe(e){return!!(e&&typeof e=="object"&&"bootstrapAccepted"in e)}i(vUe,"isBootstrapAcceptancePayload");function WLs(e,t){return!e||typeof e!="object"||t?!1:e.status==="approved"}i(WLs,"isApprovedHumanJoinPayload");function rpe({companyDisplayName:e,companyLogoUrl:t,className:s}){return(0,n.jsx)(c1,{companyName:e,logoUrl:t,logoFit:"contain",className:s})}i(rpe,"InviteCompanyLogo");function bUe({companyDisplayName:e,companyLogoUrl:t,invitedByUserName:s,claimSecret:r=null,claimApiKeyPath:a=null,onboardingTextUrl:o=null}){return(0,n.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,n.jsxs)("div",{className:"mx-auto max-w-md border border-zinc-800 bg-zinc-950 p-6","data-testid":"invite-pending-approval",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)(rpe,{companyDisplayName:e,companyLogoUrl:t,className:"h-12 w-12 border border-zinc-800 rounded-none"}),(0,n.jsxs)("h1",{className:"text-lg font-semibold",children:["Request to join ",e]})]}),(0,n.jsxs)("div",{className:"mt-4 space-y-3",children:[(0,n.jsxs)("p",{className:"text-sm text-zinc-400",children:["Your request is still awaiting approval. ",s??"An organization admin"," must approve your request to join."]}),(0,n.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,n.jsx)("p",{className:"text-xs text-zinc-500 mb-1",children:"Approval page"}),(0,n.jsx)("p",{className:"text-sm text-zinc-200",children:"Settings → Members"})]}),(0,n.jsxs)("p",{className:"text-sm text-zinc-400",children:["Ask them to visit ",(0,n.jsx)("span",{className:"text-zinc-200",children:"Settings → Members"})," to approve your request."]}),(0,n.jsx)("p",{className:"text-xs text-zinc-500",children:"Refresh this page after you've been approved — you'll be redirected automatically."})]}),r&&a?(0,n.jsxs)("div",{className:"mt-4 space-y-1 border border-zinc-800 p-3 text-xs text-zinc-400",children:[(0,n.jsx)("div",{className:"text-zinc-200",children:"Claim secret"}),(0,n.jsx)("div",{className:"font-mono break-all",children:r}),(0,n.jsxs)("div",{className:"font-mono break-all",children:["POST ",a]})]}):null,o?(0,n.jsxs)("div",{className:"mt-4 text-xs text-zinc-400",children:["Onboarding: ",(0,n.jsx)("span",{className:"font-mono break-all",children:o})]}):null]})})}i(bUe,"AwaitingJoinApprovalPanel");function QLs(){const e=Ct(),t=ir(),{setSelectedCompanyId:s}=gn(),r=(Mi().token??"").trim(),[a,o]=(0,m.useState)("sign_up"),[l,c]=(0,m.useState)(""),[d,u]=(0,m.useState)(""),[h,p]=(0,m.useState)(""),[f,g]=(0,m.useState)(""),[x,v]=(0,m.useState)("omp_local"),[b,y]=(0,m.useState)(""),[k,j]=(0,m.useState)(null),[N,S]=(0,m.useState)(null),[A,I]=(0,m.useState)(null),[_,T]=(0,m.useState)(!1),E="invite-auth-error",M=ie({queryKey:O.health,queryFn:i(()=>Op.get(),"queryFn"),retry:!1}),P=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),retry:!1}),D=ie({queryKey:O.access.invite(r),queryFn:i(()=>jr.getInvite(r),"queryFn"),enabled:r.length>0,retry:!1}),K=HUe({enabled:!!P.data&&!!D.data?.companyId,staleTime:0}),L=M.data?.deploymentMode!=="local_trusted"?K.isFetchedAfterMount:!0,B=L?K.data?.companies??[]:[];(0,m.useEffect)(()=>{r&&dUe(r)},[r]),(0,m.useEffect)(()=>{T(!1)},[r]),(0,m.useEffect)(()=>{if(!L)return;const de=K.data?.companies;!de||!D.data?.companyId||de.some(be=>be.id===D.data.companyId)&&UF(r)},[K.data,D.data,L,r]);const z=D.data,U=!!P.data&&!!z?.companyId&&!L,W=!!z?.companyId&&B.some(de=>de.id===z?.companyId),F=z?.companyName?.trim()||"this Wardmote company",Y=z?.companyLogoUrl?.trim()||null,V=z?.invitedByUserName?.trim()||null,G=z?.inviteMessage?.trim()||null,ne=qLs(z?.humanRole),Z=z?.joinRequestStatus??null,J=z?.joinRequestType??null,se=J==="human"&&(Z==="pending_approval"||Z==="approved"),H=M.data?.deploymentMode==="authenticated"&&!P.data&&z?.allowedJoinTypes!=="agent",ee=z?.inviteType!=="bootstrap_ceo"&&z?.allowedJoinTypes==="agent",te=!!P.data&&!ee&&z?.inviteType!=="bootstrap_ceo"&&(!Z||se)&&!U&&!W&&!k&&N===null,oe=P.data?.user.name?.trim()||P.data?.user.email?.trim()||"this account",ae=d.trim().length>0&&h.trim().length>0&&(a==="sign_in"||l.trim().length>0&&h.trim().length>=8),ge=ye({mutationFn:i(async()=>{if(!z)throw new Error("Invite not found");if(U)throw new Error("Checking your organization access. Try again in a moment.");if(W)throw new Error("This account already belongs to the organization.");return z.inviteType==="bootstrap_ceo"||z.allowedJoinTypes!=="agent"?jr.acceptInvite(r,{requestType:"human"}):jr.acceptInvite(r,{requestType:"agent",agentName:f.trim(),adapterType:x,capabilities:b.trim()||null})},"mutationFn"),onSuccess:i(async de=>{S(null),UF(r);const be=vUe(de);j({kind:be?"bootstrap":"join",payload:de}),await e.invalidateQueries({queryKey:O.auth.session}),await e.invalidateQueries({queryKey:O.access.currentBoardAccess}),await e.invalidateQueries({queryKey:O.companies.all}),z?.companyId&&WLs(de,ee)&&(s(z.companyId,{source:"manual"}),t("/",{replace:!0}))},"onSuccess"),onError:i(de=>{S(de instanceof Error?de.message:"Failed to accept invite")},"onError")});(0,m.useEffect)(()=>{!te||_||ge.isPending||(T(!0),S(null),ge.mutate())},[ge,_,te]);const xe=ye({mutationFn:i(async()=>{if(a==="sign_in"){await Ji.signInEmail({email:d.trim(),password:h});return}await Ji.signUpEmail({name:l.trim(),email:d.trim(),password:h})},"mutationFn"),onSuccess:i(async()=>{I(null),dUe(r),await e.invalidateQueries({queryKey:O.auth.session}),await e.invalidateQueries({queryKey:O.health}),await e.invalidateQueries({queryKey:O.access.currentBoardAccess});const{companies:de}=await lEt(e);if(z?.companyId&&de.some(be=>be.id===z.companyId)){UF(r),s(z.companyId,{source:"manual"}),t("/",{replace:!0});return}if(!(!z||z.inviteType!=="bootstrap_ceo"))try{vUe(await ge.mutateAsync())&&t("/",{replace:!0})}catch{return}},"onSuccess"),onError:i(de=>{const be=KLs(de,a,d);rAt(de)==="USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL"&&(o("sign_in"),p("")),I(be)},"onError")}),ce=(0,m.useMemo)(()=>z?W?"Open organization":z.inviteType==="bootstrap_ceo"?"Accept invite":ee?"Submit request":P.data?"Accept invite":"Continue":"Continue",[z,W,P.data,ee]);if(!r)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-bad",children:"Invalid invite token."});if(D.isLoading||M.isLoading||P.isLoading)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-ink-3",children:"Loading invite..."});if(U)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-ink-3",children:"Checking your access..."});if(D.error||!z)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)("div",{className:"border border-line bg-bg-2 p-6","data-testid":"invite-error",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Invite not available"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"This invite may be expired, revoked, or already used."})]})});if(Z==="approved"&&J==="human"&&W)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-ink-3",children:"Opening organization..."});if(Z==="pending_approval"&&!se)return(0,n.jsx)(bUe,{companyDisplayName:F,companyLogoUrl:Y,invitedByUserName:V});if(Z&&!se)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)("div",{className:"border border-line bg-bg-2 p-6","data-testid":"invite-error",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Invite not available"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:Z==="rejected"?"This join request was not approved.":"This invite has already been used."})]})});if(k?.kind==="bootstrap")return(0,n.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,n.jsxs)("div",{className:"mx-auto max-w-md border border-zinc-800 bg-zinc-950 p-6",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Bootstrap complete"}),(0,n.jsx)("div",{className:"mt-4",children:(0,n.jsx)($,{asChild:!0,className:"rounded-none",children:(0,n.jsx)(Ye,{to:"/",children:"Open board"})})})]})});if(k?.kind==="join"){const de=k.payload,be=typeof de.claimSecret=="string"?de.claimSecret:null,me=typeof de.claimApiKeyPath=="string"?de.claimApiKeyPath:null,we=zLs(de.onboarding,["textInstructions","url"]);return!ee&&de.status==="approved"?(0,n.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,n.jsxs)("div",{className:"mx-auto max-w-md border border-zinc-800 bg-zinc-950 p-6",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)(rpe,{companyDisplayName:F,companyLogoUrl:Y,className:"h-12 w-12 border border-zinc-800 rounded-none"}),(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"You joined the organization"})]}),(0,n.jsx)("div",{className:"mt-4",children:(0,n.jsx)($,{asChild:!0,className:"w-full rounded-none",children:(0,n.jsx)(Ye,{to:"/",children:"Open board"})})})]})}):(0,n.jsx)(bUe,{companyDisplayName:F,companyLogoUrl:Y,invitedByUserName:V,claimSecret:be,claimApiKeyPath:me,onboardingTextUrl:we})}return(0,n.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,n.jsx)("div",{className:"mx-auto max-w-5xl",children:(0,n.jsxs)("div",{className:"grid gap-6 lg:grid-cols-(--gtc-36)",children:[(0,n.jsxs)("section",{className:`${gUe} space-y-6`,children:[(0,n.jsxs)("div",{className:"flex items-start gap-4",children:[(0,n.jsx)(rpe,{companyDisplayName:F,companyLogoUrl:Y,className:"h-16 w-16 rounded-none border border-zinc-800"}),(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("p",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"You've been invited to join Wardmote"}),(0,n.jsx)("h1",{className:"mt-2 text-2xl font-semibold",children:z.inviteType==="bootstrap_ceo"?"Set up Wardmote":`Join ${F}`}),(0,n.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-zinc-300",children:ee?"Review the invite details, then submit the agent information below to start the join request.":H?"Create your Wardmote account first. If you already have one, switch to sign in and continue the invite with the same email.":"Your account is ready. Review the invite details, then accept it to continue."})]})]}),(0,n.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,n.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,n.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Organization"}),(0,n.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:F})]}),(0,n.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,n.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Invited by"}),(0,n.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:V??"Wardmote board"})]}),(0,n.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,n.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Requested access"}),(0,n.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:ee?"Agent join request":ne??"Organization access"})]}),(0,n.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,n.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Invite expires"}),(0,n.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:Zh(z.expiresAt)})]})]}),G?(0,n.jsxs)("div",{className:"border border-amber-500/40 bg-amber-500/10 p-4",children:[(0,n.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-amber-200/80",children:"Message from inviter"}),(0,n.jsx)("p",{className:"mt-2 text-sm leading-6 text-amber-50",children:G})]}):null,P.data?(0,n.jsxs)("div",{className:"border border-emerald-500/40 bg-emerald-500/10 p-4 text-sm text-emerald-50",children:["Signed in as ",(0,n.jsx)("span",{className:"font-medium",children:oe}),"."]}):null]}),(0,n.jsx)("section",{className:`${gUe} h-fit`,children:ee?(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"text-lg font-semibold",children:"Submit agent details"}),(0,n.jsxs)("p",{className:"mt-1 text-sm text-zinc-400",children:["This invite will create an approval request for a new agent in ",F,"."]})]}),(0,n.jsxs)("label",{className:"block text-sm",children:[(0,n.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Agent name"}),(0,n.jsx)("input",{className:L2,value:f,onChange:i(de=>g(de.target.value),"onChange")})]}),(0,n.jsxs)("label",{className:"block text-sm",children:[(0,n.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Adapter type"}),(0,n.jsx)("select",{className:L2,value:x,onChange:i(de=>v(de.target.value),"onChange"),children:BLs.map(de=>(0,n.jsxs)("option",{value:de,disabled:!fUe.has(de),children:[mb(de),fUe.has(de)?"":" (Coming soon)"]},de))})]}),(0,n.jsxs)("label",{className:"block text-sm",children:[(0,n.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Capabilities"}),(0,n.jsx)("textarea",{className:L2,rows:4,value:b,onChange:i(de=>y(de.target.value),"onChange")})]}),N?(0,n.jsx)("p",{className:"text-xs text-red-400",children:N}):null,(0,n.jsx)($,{className:"w-full rounded-none",disabled:ge.isPending||f.trim().length===0,onClick:i(()=>ge.mutate(),"onClick"),children:ge.isPending?"Working...":ce})]}):H?(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"text-lg font-semibold",children:a==="sign_up"?"Create your account":"Sign in to continue"}),(0,n.jsx)("p",{className:"mt-1 text-sm text-zinc-400",children:a==="sign_up"?`Start with a Wardmote account. After that, you'll come right back here to accept the invite for ${F}.`:"Use the Wardmote account that already matches this invite. If you do not have one yet, switch back to create account."})]}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)("button",{type:"button",className:`${xUe} ${a==="sign_up"?"border-zinc-100 bg-zinc-100 text-zinc-950":"border-zinc-800 text-zinc-300 hover:border-zinc-600"}`,onClick:i(()=>{I(null),o("sign_up")},"onClick"),children:"Create account"}),(0,n.jsx)("button",{type:"button",className:`${xUe} ${a==="sign_in"?"border-zinc-100 bg-zinc-100 text-zinc-950":"border-zinc-800 text-zinc-300 hover:border-zinc-600"}`,onClick:i(()=>{I(null),o("sign_in")},"onClick"),children:"I already have an account"})]}),(0,n.jsxs)("form",{className:"space-y-4",method:"post",action:a==="sign_up"?"/api/auth/sign-up/email":"/api/auth/sign-in/email",onSubmit:i(de=>{if(de.preventDefault(),!xe.isPending){if(!ae){I({tone:"error",message:"Please fill in all required fields."});return}xe.mutate()}},"onSubmit"),"data-testid":"invite-inline-auth",children:[a==="sign_up"?(0,n.jsxs)("label",{className:"block text-sm",htmlFor:"invite-name",children:[(0,n.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Name"}),(0,n.jsx)("input",{id:"invite-name",name:"name",className:L2,value:l,onChange:i(de=>{c(de.target.value),I(null)},"onChange"),autoComplete:"name",required:!0,"aria-required":"true","aria-invalid":A?.tone==="error"?!0:void 0,"aria-describedby":A?E:void 0,autoFocus:!0})]}):null,(0,n.jsxs)("label",{className:"block text-sm",htmlFor:"invite-email",children:[(0,n.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Email"}),(0,n.jsx)("input",{id:"invite-email",name:"email",type:"email",className:L2,value:d,onChange:i(de=>{u(de.target.value),I(null)},"onChange"),autoComplete:"username",required:!0,"aria-required":"true","aria-invalid":A?.tone==="error"?!0:void 0,"aria-describedby":A?E:void 0,autoFocus:a==="sign_in"})]}),(0,n.jsxs)("label",{className:"block text-sm",htmlFor:"invite-password",children:[(0,n.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Password"}),(0,n.jsx)("input",{id:"invite-password",name:"password",type:"password",className:L2,value:h,onChange:i(de=>{p(de.target.value),I(null)},"onChange"),autoComplete:a==="sign_in"?"current-password":"new-password",required:!0,"aria-required":"true","aria-invalid":A?.tone==="error"?!0:void 0,"aria-describedby":A?E:void 0})]}),A?(0,n.jsx)("p",{id:E,role:"alert",className:`text-xs ${A.tone==="info"?"text-amber-300":"text-red-400"}`,children:A.message}):null,(0,n.jsx)($,{type:"submit",className:"w-full rounded-none",disabled:xe.isPending,"aria-disabled":!ae||xe.isPending,children:xe.isPending?"Working...":a==="sign_in"?"Sign in and continue":"Create account and continue"})]}),(0,n.jsx)("p",{className:"text-xs leading-5 text-zinc-500",children:a==="sign_up"?"Already signed up before? Use the existing-account option instead so the invite lands on the right Wardmote user.":"No account yet? Switch back to create account so you can accept the invite with a new login."})]}):(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"text-lg font-semibold",children:W?"Already in this organization":te?"Completing organization access":z.inviteType==="bootstrap_ceo"?"Accept bootstrap invite":"Accept organization invite"}),(0,n.jsx)("p",{className:"mt-1 text-sm text-zinc-400",children:te?`Granting your access to ${F}.`:W?`This account already belongs to ${F}.`:`This will ${z.inviteType==="bootstrap_ceo"?"finish setting up Wardmote":`grant or complete your access to ${F}`}.`})]}),N?(0,n.jsx)("p",{className:"text-xs text-red-400",children:N}):null,te?(0,n.jsx)("div",{className:"text-sm text-zinc-400",children:ge.isPending?"Submitting request...":"Finishing sign-in..."}):(0,n.jsx)($,{className:"w-full rounded-none",disabled:ge.isPending,onClick:i(()=>{if(W&&z.companyId){UF(r),s(z.companyId,{source:"manual"}),t("/",{replace:!0});return}ge.mutate()},"onClick"),children:ge.isPending?"Working...":ce})]})})]})})})}i(QLs,"InviteLandingPage");var VLs=15e3,HLs={parent:"Parent task",child:"Sub-task",blocked_by:"Blocked by",blocks:"Blocks"};function GLs(){(0,m.useEffect)(()=>{const e=document.createElement("meta");return e.name="robots",e.content="noindex",document.head.appendChild(e),()=>e.remove()},[])}i(GLs,"useNoIndexMeta");function ipe(e,t){const s=`/s/${encodeURIComponent(e)}`;return t?`${s}/issues/${encodeURIComponent(t)}`:s}i(ipe,"sharePath");var YLs=/^(?:https?:\/\/[^/]+)?\/api\/attachments\/([^/?#]+)\/content(?:[?#].*)?$/i;function JLs(e,t){const s=YLs.exec(t.trim());return s?`/api/public/share/${encodeURIComponent(e)}/attachments/${s[1]}/content`:null}i(JLs,"publicShareImageSrc");function tR({title:e,children:t}){return(0,n.jsxs)("section",{className:"space-y-3",children:[(0,n.jsx)("h2",{className:"text-sm font-semibold text-ink-3",children:e}),t]})}i(tR,"Section");function ape({actor:e}){return(0,n.jsx)(No,{name:e.name,avatarUrl:e.iconUrl,size:"sm"})}i(ape,"ActorIdentity");function ope({value:e}){return(0,n.jsx)("time",{dateTime:e,title:Sr(e),className:"text-xs text-ink-3",children:Nr(e)})}i(ope,"Timestamp");function ZLs({agentName:e}){return(0,n.jsxs)("span",{"data-testid":"public-share-run-pill",className:"inline-flex items-center gap-1.5 rounded-full border border-line px-3 py-1 text-xs text-ink",children:[(0,n.jsx)("span",{className:"h-2 w-2 animate-pulse rounded-full bg-(--status-agent-running)","aria-hidden":!0}),e," is working…"]})}i(ZLs,"ActiveRunPill");function iAt({attachments:e}){return(0,n.jsx)(Ffe,{children:e.map(t=>{const s=Zet({name:t.filename,url:t.url,contentType:t.contentType,byteSize:t.byteSize}),r=s.icon,a=Bfe(t.byteSize);return(0,n.jsxs)(Lfe,{size:"sm",children:[(0,n.jsx)(Dfe,{children:(0,n.jsx)(r,{"aria-hidden":!0})}),(0,n.jsxs)(Pfe,{children:[(0,n.jsx)($fe,{className:"max-w-48",children:t.filename}),(0,n.jsx)(Ofe,{className:"max-w-48",children:a?`${s.label} · ${a}`:s.label})]}),(0,n.jsx)(Het,{"aria-label":`Download ${t.filename}`,render:(0,n.jsx)("a",{href:t.url,download:t.filename,rel:"noreferrer"})})]},t.id)})})}i(iAt,"AttachmentList");function XLs({related:e,token:t,isSharedRoot:s}){const r=e.identifier?`${e.identifier} · ${e.title}`:e.title,a=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(_a,{status:e.status,size:"sm"}),(0,n.jsx)("span",{className:"min-w-0 truncate",children:r})]});return(0,n.jsxs)("li",{className:"flex items-center gap-2 text-sm",children:[(0,n.jsx)("span",{className:"w-20 shrink-0 text-xs text-ink-3",children:HLs[e.relation]}),e.navigable?(0,n.jsx)(Nh,{to:s?ipe(t,e.id):ipe(t),className:"flex min-w-0 items-center gap-2 text-ink underline-offset-2 hover:underline",children:a}):(0,n.jsx)("span",{className:"flex min-w-0 items-center gap-2 text-ink-3",children:a})]})}i(XLs,"RelatedIssueRow");function e8s({comment:e,resolveImageSrc:t}){return e.kind==="redacted"?(0,n.jsxs)("li",{"data-testid":"public-share-redacted-comment",className:"flex flex-wrap items-center gap-2 rounded-lg border border-dashed border-line px-3 py-2",children:[(0,n.jsx)(ape,{actor:e.author}),(0,n.jsx)(ope,{value:e.createdAt}),(0,n.jsx)("span",{className:"text-xs italic text-ink-3",children:"Internal update"})]}):(0,n.jsxs)("li",{className:"space-y-2 rounded-lg border border-line bg-bg-2 px-3 py-3",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)(ape,{actor:e.author}),(0,n.jsx)(ope,{value:e.createdAt})]}),(0,n.jsx)(_s,{className:"text-sm",softBreaks:!0,linkIssueReferences:!1,resolveImageSrc:t,children:e.body}),e.attachments.length>0?(0,n.jsx)(iAt,{attachments:e.attachments}):null]})}i(e8s,"TimelineEntry");function t8s({document:e,resolveImageSrc:t}){return(0,n.jsxs)("details",{className:"group rounded-lg border border-line bg-bg-2",children:[(0,n.jsxs)("summary",{className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm",children:[(0,n.jsx)(ia,{className:"h-4 w-4 shrink-0 text-ink-3","aria-hidden":!0}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:e.title??e.key}),(0,n.jsx)(ope,{value:e.updatedAt})]}),(0,n.jsxs)("div",{className:"space-y-3 border-t border-line px-3 py-3",children:[(0,n.jsxs)("a",{href:e.pdfUrl,download:!0,rel:"noreferrer",className:"inline-flex items-center gap-1.5 text-xs text-ink-3 hover:text-ink",children:[(0,n.jsx)(xo,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Download PDF"]}),(0,n.jsx)(_s,{className:"text-sm",linkIssueReferences:!1,resolveImageSrc:t,children:e.body})]})]})}i(t8s,"DocumentCard");function n8s({product:e}){return(0,n.jsxs)("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg border border-line bg-bg-2 px-3 py-2 text-sm",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:e.title}),(0,n.jsxs)("span",{className:"text-xs text-ink-3",children:[e.type.replace(/_/g," ")," · ",e.status.replace(/_/g," ")]}),e.url?(0,n.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-ink-3 hover:text-ink",children:[(0,n.jsx)(Us,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Open"]}):null,e.downloadUrl?(0,n.jsxs)("a",{href:e.downloadUrl,download:!0,rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-ink-3 hover:text-ink",children:[(0,n.jsx)(xo,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Download"]}):null]})}i(n8s,"WorkProductRow");function yUe({title:e,body:t,action:s}){return(0,n.jsx)("div",{className:"flex h-dvh overflow-y-auto bg-bg px-4 text-ink",children:(0,n.jsxs)("div",{className:"m-auto w-full max-w-sm space-y-2 rounded-lg border border-line bg-bg-2 p-6 text-center",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:e}),(0,n.jsx)("p",{className:"text-sm text-ink-3",children:t}),s]})})}i(yUe,"CenteredNotice");function s8s({view:e,token:t}){const{company:s,issue:r}=e,a=(0,m.useCallback)(o=>JLs(t,o),[t]);return(0,n.jsxs)("div",{className:"h-dvh overflow-y-auto bg-bg text-ink",children:[(0,n.jsx)("header",{className:"border-b border-line",children:(0,n.jsxs)("div",{className:"mx-auto flex max-w-3xl items-center gap-3 px-4 py-3",children:[(0,n.jsx)(c1,{companyName:s.name,logoUrl:s.logoUrl,logoFit:"contain",className:"h-8 w-8 shrink-0 rounded-md"}),(0,n.jsx)("span",{className:"min-w-0 truncate text-sm font-medium",children:s.name}),(0,n.jsx)("span",{className:"ml-auto shrink-0 text-xs text-ink-3",children:"Read-only view"})]})}),(0,n.jsxs)("main",{className:"mx-auto max-w-3xl space-y-8 px-4 py-5",children:[e.isSharedRoot?null:(0,n.jsxs)(Nh,{to:ipe(t),className:"inline-flex items-center gap-1.5 text-sm text-ink-3 hover:text-ink",children:[(0,n.jsx)(cc,{className:"h-4 w-4","aria-hidden":!0}),"Back to main task"]}),(0,n.jsxs)("section",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 text-xs text-ink-3",children:[r.identifier?(0,n.jsx)("span",{children:r.identifier}):null,r.projectName?(0,n.jsx)("span",{children:r.projectName}):null]}),(0,n.jsx)("h1",{className:"break-words text-xl font-semibold",children:r.title}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,n.jsx)(Rg,{status:r.status}),(0,n.jsx)(wvt,{priority:r.priority,showLabel:!0}),r.assignee?(0,n.jsx)(ape,{actor:r.assignee}):null,e.activeRun?(0,n.jsx)(ZLs,{agentName:e.activeRun.agentName}):null]}),(0,n.jsxs)("p",{className:"text-xs text-ink-3",children:["Created ",Sr(r.createdAt)," · Updated ",Nr(r.updatedAt),r.completedAt?` · Completed ${Sr(r.completedAt)}`:""]})]}),r.description?(0,n.jsx)(_s,{className:"text-sm",softBreaks:!0,linkIssueReferences:!1,resolveImageSrc:a,children:r.description}):null,e.related.length>0?(0,n.jsx)(tR,{title:"Related tasks",children:(0,n.jsx)("ul",{className:"space-y-2",children:e.related.map(o=>(0,n.jsx)(XLs,{related:o,token:t,isSharedRoot:e.isSharedRoot},`${o.relation}:${o.id}`))})}):null,e.documents.length>0?(0,n.jsx)(tR,{title:"Documents",children:(0,n.jsx)("div",{className:"space-y-2",children:e.documents.map(o=>(0,n.jsx)(t8s,{document:o,resolveImageSrc:a},o.key))})}):null,e.attachments.length>0?(0,n.jsx)(tR,{title:"Attachments",children:(0,n.jsx)(iAt,{attachments:e.attachments})}):null,e.workProducts.length>0?(0,n.jsx)(tR,{title:"Work products",children:(0,n.jsx)("ul",{className:"space-y-2",children:e.workProducts.map(o=>(0,n.jsx)(n8s,{product:o},o.id))})}):null,(0,n.jsx)(tR,{title:"Activity",children:e.comments.length>0?(0,n.jsx)("ol",{className:"space-y-3",children:e.comments.map(o=>(0,n.jsx)(e8s,{comment:o,resolveImageSrc:a},o.id))}):(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"No updates yet."})})]})]})}i(s8s,"PublicIssueShareContent");function kUe(){const{token:e="",issueId:t}=Mi();GLs();const s=y6t.test(e),r=ie({queryKey:O.publicShare.view(e,t??null),queryFn:i(()=>t?jA.getPublicShareIssue(e,t):jA.getPublicShare(e),"queryFn"),enabled:s,retry:!1,refetchOnWindowFocus:!0,refetchInterval:i(a=>a.state.data?.activeRun?VLs:!1,"refetchInterval")});return!s||r.data===null?(0,n.jsx)(yUe,{title:"This link is not available",body:"It may have been revoked, or the address is incomplete."}):r.data?(0,n.jsx)(s8s,{view:r.data,token:e}):r.isError?(0,n.jsx)(yUe,{title:"Couldn't load this page",body:"Check your connection and try again.",action:(0,n.jsx)($,{variant:"secondary",size:"sm",className:"mt-2",onClick:i(()=>{r.refetch()},"onClick"),children:"Try again"})}):(0,n.jsx)("div",{className:"h-dvh overflow-y-auto px-4 py-6","aria-busy":"true",children:(0,n.jsxs)("div",{className:"mx-auto max-w-3xl space-y-4",children:[(0,n.jsx)(wn,{className:"h-6 w-1/2"}),(0,n.jsx)(wn,{className:"h-4 w-1/3"}),(0,n.jsx)(wn,{className:"h-24 w-full"})]})})}i(kUe,"PublicIssueSharePage");function r8s(){const{selectedCompany:e,selectedCompanyId:t}=gn(),{setBreadcrumbs:s}=Hs(),{pushToast:r}=Qa(),a=Ct(),[o,l]=(0,m.useState)("pending_approval"),[c,d]=(0,m.useState)("all");(0,m.useEffect)(()=>{s([{label:e?.name??"Organization",href:"/dashboard"},{label:"Inbox",href:"/inbox"},{label:"Join Requests"}])},[e?.name,s]);const u=ie({queryKey:O.access.joinRequests(t??"",`${o}:${c}`),queryFn:i(()=>jr.listJoinRequests(t,o,c==="all"?void 0:c),"queryFn"),enabled:!!t}),h=ye({mutationFn:i(f=>jr.approveJoinRequest(t,f),"mutationFn"),onSuccess:i(async()=>{await a.invalidateQueries({queryKey:O.access.joinRequests(t,`${o}:${c}`)}),await a.invalidateQueries({queryKey:O.access.companyMembers(t)}),await a.invalidateQueries({queryKey:O.access.companyUserDirectory(t)}),r({title:"Join request approved",tone:"success"})},"onSuccess")}),p=ye({mutationFn:i(f=>jr.rejectJoinRequest(t,f),"mutationFn"),onSuccess:i(async()=>{await a.invalidateQueries({queryKey:O.access.joinRequests(t,`${o}:${c}`)}),r({title:"Join request rejected",tone:"success"})},"onSuccess")});if(!t)return(0,n.jsx)("div",{className:"text-sm text-ink-3",children:"Select an organization to review join requests."});if(u.isLoading)return(0,n.jsx)("div",{className:"text-sm text-ink-3",children:"Loading join requests…"});if(u.error){const f=u.error instanceof ss&&u.error.status===403?"You do not have permission to review join requests for this organization.":u.error instanceof Error?u.error.message:"Failed to load join requests.";return(0,n.jsx)("div",{className:"text-sm text-bad",children:f})}return(0,n.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(_Pt,{className:"h-5 w-5 text-ink-3"}),(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Join Request Queue"})]}),(0,n.jsx)("p",{className:"max-w-3xl text-sm text-ink-3",children:"Review human and agent join requests outside the mixed inbox feed. This queue uses the same approval mutations as the inline inbox cards."})]}),(0,n.jsxs)(hs,{className:"flex-row flex-wrap gap-3 p-4",children:[(0,n.jsxs)("label",{className:"space-y-2 text-sm",children:[(0,n.jsx)("span",{className:"font-medium",children:"Status"}),(0,n.jsxs)("select",{className:"rounded-md border border-line bg-bg px-3 py-2",value:o,onChange:i(f=>l(f.target.value),"onChange"),children:[(0,n.jsx)("option",{value:"pending_approval",children:"Pending approval"}),(0,n.jsx)("option",{value:"approved",children:"Approved"}),(0,n.jsx)("option",{value:"rejected",children:"Rejected"})]})]}),(0,n.jsxs)("label",{className:"space-y-2 text-sm",children:[(0,n.jsx)("span",{className:"font-medium",children:"Request type"}),(0,n.jsxs)("select",{className:"rounded-md border border-line bg-bg px-3 py-2",value:c,onChange:i(f=>d(f.target.value),"onChange"),children:[(0,n.jsx)("option",{value:"all",children:"All"}),(0,n.jsx)("option",{value:"human",children:"Human"}),(0,n.jsx)("option",{value:"agent",children:"Agent"})]})]})]}),(0,n.jsx)("div",{className:"space-y-4",children:(u.data??[]).length===0?(0,n.jsx)("div",{className:"rounded-xl border border-dashed border-line px-4 py-8 text-sm text-ink-3",children:"No join requests match the current filters."}):u.data.map(f=>(0,n.jsxs)(hs,{className:"block p-4",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)(lt,{variant:f.status==="pending_approval"?"secondary":f.status==="approved"?"outline":"destructive",children:f.status.replace("_"," ")}),(0,n.jsx)(lt,{variant:"outline",children:f.requestType}),f.adapterType?(0,n.jsx)(lt,{variant:"outline",children:f.adapterType}):null]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-base font-medium",children:f.requestType==="human"?f.requesterUser?.name||f.requestEmailSnapshot||f.requestingUserId||"Unknown human requester":f.agentName||"Unknown agent requester"}),(0,n.jsx)("div",{className:"text-sm text-ink-3",children:f.requestType==="human"?f.requesterUser?.email||f.requestEmailSnapshot||f.requestingUserId:f.capabilities||f.requestIp})]})]}),f.status==="pending_approval"?(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)($,{variant:"secondary",onClick:i(()=>p.mutate(f.id),"onClick"),disabled:p.isPending,children:"Reject"}),(0,n.jsx)($,{onClick:i(()=>h.mutate(f.id),"onClick"),disabled:h.isPending,children:"Approve"})]}):null]}),(0,n.jsxs)("div",{className:"mt-4 grid gap-3 text-sm text-ink-3 md:grid-cols-2",children:[(0,n.jsxs)("div",{className:"rounded-lg border border-line bg-bg px-3 py-2",children:[(0,n.jsx)("div",{className:"text-xs font-medium uppercase tracking-wide",children:"Invite context"}),(0,n.jsx)("div",{className:"mt-2",children:f.invite?`${f.invite.allowedJoinTypes} join invite${f.invite.humanRole?` • default role ${f.invite.humanRole}`:""}`:"Invite metadata unavailable"}),f.invite?.inviteMessage?(0,n.jsx)("div",{className:"mt-2 text-ink",children:f.invite.inviteMessage}):null]}),(0,n.jsxs)("div",{className:"rounded-lg border border-line bg-bg px-3 py-2",children:[(0,n.jsx)("div",{className:"text-xs font-medium uppercase tracking-wide",children:"Request details"}),(0,n.jsxs)("div",{className:"mt-2",children:["Submitted ",new Date(f.createdAt).toLocaleString()]}),(0,n.jsxs)("div",{children:["Source IP ",f.requestIp]}),f.requestType==="agent"&&f.capabilities?(0,n.jsx)("div",{children:f.capabilities}):null]})]})]},f.id))})]})}i(r8s,"JoinRequestQueue");var i8s=(0,m.lazy)(()=>ln(()=>import("./CompanyExport-DUnuQia9.js").then(e=>({default:e.CompanyExport})),__vite__mapDeps([53,5,54,55,35]))),a8s=(0,m.lazy)(()=>ln(()=>import("./Terminal-D1ruwJKK.js").then(e=>({default:e.Terminal})),__vite__mapDeps([56,5,54,55,35])));function o8s({children:e}){return(0,n.jsx)(m.Suspense,{fallback:(0,n.jsx)(bx,{}),children:e})}i(o8s,"ProductionSurface");function l8s(e){const t=e;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ot,{index:!0,element:(0,n.jsx)(Ss,{to:"dashboard",replace:!0})}),(0,n.jsx)(ot,{path:"dashboard",element:(0,n.jsx)(NWn,{})}),(0,n.jsx)(ot,{path:"dashboard/live",element:(0,n.jsx)(CWn,{})}),(0,n.jsx)(ot,{path:"timeline",element:(0,n.jsx)(tv,{to:"/activity/timeline"})}),(0,n.jsx)(ot,{path:"onboarding",element:(0,n.jsx)(lAt,{})}),(0,n.jsx)(ot,{path:"companies",element:(0,n.jsx)(SWn,{})}),(0,n.jsx)(ot,{path:"company/settings",element:(0,n.jsx)(YNs,{})}),(0,n.jsx)(ot,{path:"company/settings/connections",element:(0,n.jsx)(XNs,{})}),(0,n.jsx)(ot,{path:"company/settings/agent-defaults",element:(0,n.jsx)(UMs,{})}),(0,n.jsx)(ot,{path:"company/settings/agent-defaults/all",element:(0,n.jsx)(yHn,{})}),(0,n.jsx)(ot,{path:"company/settings/models",element:(0,n.jsx)(KMs,{})}),(0,n.jsx)(ot,{path:"company/settings/environments",element:(0,n.jsx)(Ss,{to:"/company/settings/instance/environments",replace:!0})}),(0,n.jsx)(ot,{path:"company/settings/cloud-upstream",element:(0,n.jsx)(Ss,{to:"/company/export",replace:!0})}),(0,n.jsxs)(ot,{element:(0,n.jsx)(jg,{pageKey:"company.members"}),children:[(0,n.jsx)(ot,{path:"company/settings/members",element:(0,n.jsx)(qCs,{})}),(0,n.jsx)(ot,{path:"company/settings/access",element:(0,n.jsx)(UCs,{})})]}),(0,n.jsx)(ot,{element:(0,n.jsx)(jg,{pageKey:"company.invites"}),children:(0,n.jsx)(ot,{path:"company/settings/invites",element:(0,n.jsx)(Ss,{to:"/company/settings/members?tab=invites",replace:!0})})}),(0,n.jsx)(ot,{element:(0,n.jsx)(jg,{pageKey:"company.export"}),children:(0,n.jsx)(ot,{path:"company/export/*",element:(0,n.jsx)(m.Suspense,{fallback:(0,n.jsx)(bx,{}),children:(0,n.jsx)(i8s,{})})})}),(0,n.jsx)(ot,{element:(0,n.jsx)(sMn,{}),children:(0,n.jsx)(ot,{element:(0,n.jsx)(jg,{pageKey:"company.import"}),children:(0,n.jsx)(ot,{path:"company/import",element:(0,n.jsx)(F6s,{})})})}),(0,n.jsx)(ot,{element:(0,n.jsx)(jg,{pageKey:"company.secrets"}),children:(0,n.jsx)(ot,{path:"company/settings/secrets",element:(0,n.jsx)(DRs,{})})}),(0,n.jsx)(ot,{path:"company/settings/tools",element:(0,n.jsx)(NUe,{})}),(0,n.jsx)(ot,{path:"company/settings/tools/:tab",element:(0,n.jsx)(NUe,{})}),(0,n.jsx)(ot,{path:"tools",element:(0,n.jsx)(CUe,{})}),(0,n.jsx)(ot,{path:"tools/:tab",element:(0,n.jsx)(CUe,{})}),(0,n.jsx)(ot,{path:"apps",element:(0,n.jsx)(BSs,{})}),(0,n.jsx)(ot,{path:"apps/assistant-connection",element:(0,n.jsx)(kSs,{})}),(0,n.jsx)(ot,{path:"apps/browse",element:(0,n.jsx)(Ss,{to:"/apps",replace:!0})}),(0,n.jsx)(ot,{path:"apps/connections",element:(0,n.jsx)(Ss,{to:"/apps",replace:!0})}),(0,n.jsx)(ot,{path:"apps/byo",element:(0,n.jsx)(p2t,{byoOnly:!0})}),(0,n.jsx)(ot,{path:"apps/vercel-connect",element:(0,n.jsx)(wUe,{credentialSource:"vercel_connect"})}),(0,n.jsx)(ot,{path:"apps/connect",element:(0,n.jsx)(wUe,{})}),(0,n.jsx)(ot,{path:"apps/chat/connect",element:(0,n.jsx)(NF,{children:(0,n.jsx)(b_s,{})})}),(0,n.jsx)(ot,{path:"apps/chat/:endpointId",element:(0,n.jsx)(NF,{children:(0,n.jsx)(Ss,{to:"settings",replace:!0})})}),(0,n.jsx)(ot,{path:"apps/chat/:endpointId/reviews/:reviewId",element:(0,n.jsx)(NF,{children:(0,n.jsx)(aze,{})})}),(0,n.jsx)(ot,{path:"apps/chat/:endpointId/:tab",element:(0,n.jsx)(NF,{children:(0,n.jsx)(aze,{})})}),(0,n.jsx)(ot,{path:"apps/connect/:appKey",element:(0,n.jsx)(Ss,{to:"/apps",replace:!0})}),(0,n.jsx)(ot,{path:"apps/connect/:appKey/:stage",element:(0,n.jsx)(Ss,{to:"/apps",replace:!0})}),(0,n.jsx)(ot,{path:"apps/review",element:(0,n.jsx)(x5s,{})}),(0,n.jsx)(ot,{path:"apps/attention",element:(0,n.jsx)(Ss,{to:"/apps",replace:!0})}),(0,n.jsx)(ot,{path:"apps/gateways",element:(0,n.jsx)(wze,{})}),(0,n.jsx)(ot,{path:"apps/gateways/:gatewayId",element:(0,n.jsx)(Ss,{to:"overview",replace:!0})}),(0,n.jsx)(ot,{path:"apps/gateways/:gatewayId/:tab",element:(0,n.jsx)(VAs,{})}),(0,n.jsx)(ot,{path:"apps/advanced",element:(0,n.jsx)(LBe,{})}),(0,n.jsx)(ot,{path:"apps/advanced/gateways",element:(0,n.jsx)(wze,{})}),(0,n.jsx)(ot,{path:"apps/advanced/profiles/new",element:(0,n.jsx)(FBe,{mode:"new"})}),(0,n.jsx)(ot,{path:"apps/advanced/profiles/:profileId/edit",element:(0,n.jsx)(FBe,{mode:"edit"})}),(0,n.jsx)(ot,{path:"apps/advanced/profiles/:profileId",element:(0,n.jsx)(lSs,{})}),(0,n.jsx)(ot,{path:"apps/advanced/audit",element:(0,n.jsx)(Ss,{to:"/apps",replace:!0})}),(0,n.jsx)(ot,{path:"apps/advanced/run-your-own",element:(0,n.jsx)(Ss,{to:"/apps",replace:!0})}),(0,n.jsx)(ot,{path:"apps/advanced/:tab",element:(0,n.jsx)(LBe,{})}),(0,n.jsx)(ot,{path:"apps/app/:applicationId",element:(0,n.jsx)(bze,{})}),(0,n.jsx)(ot,{path:"apps/app/:applicationId/:tab",element:(0,n.jsx)(bze,{})}),(0,n.jsx)(ot,{path:"apps/:connectionId",element:(0,n.jsx)(Ss,{to:"permissions",replace:!0})}),(0,n.jsx)(ot,{path:"apps/:connectionId/:tab",element:(0,n.jsx)(oAs,{})}),(0,n.jsx)(ot,{path:"company/settings/instance",element:(0,n.jsx)(Ss,{to:"/company/settings",replace:!0})}),(0,n.jsx)(ot,{element:(0,n.jsx)(jg,{pageKey:"instance.profile"}),children:(0,n.jsx)(ot,{path:"company/settings/instance/profile",element:(0,n.jsx)(iLs,{})})}),(0,n.jsx)(ot,{path:"company/settings/instance/general",element:(0,n.jsx)(Ss,{to:"/company/settings",replace:!0})}),(0,n.jsx)(ot,{path:"company/settings/instance/heartbeats",element:(0,n.jsx)(Ss,{to:"/company/settings",replace:!0})}),(0,n.jsxs)(ot,{element:(0,n.jsx)(jg,{pageKey:"instance.environments"}),children:[(0,n.jsx)(ot,{path:"company/settings/instance/environments",element:(0,n.jsx)(pre,{})}),(0,n.jsx)(ot,{path:"company/settings/instance/environments/new",element:(0,n.jsx)(pre,{mode:"create"})}),(0,n.jsx)(ot,{path:"company/settings/instance/environments/:environmentId/edit",element:(0,n.jsx)(pre,{mode:"edit"})})]}),(0,n.jsx)(ot,{element:(0,n.jsx)(jg,{pageKey:"instance.access"}),children:(0,n.jsx)(ot,{path:"company/settings/instance/access",element:(0,n.jsx)(JMs,{})})}),(0,n.jsxs)(ot,{element:(0,n.jsx)(jg,{pageKey:"instance.experimental"}),children:[(0,n.jsx)(ot,{path:"company/settings/instance/features",element:(0,n.jsx)(FMs,{})}),(0,n.jsx)(ot,{path:"company/settings/instance/advanced",element:(0,n.jsx)(YMs,{})}),(0,n.jsx)(ot,{path:"company/settings/instance/experimental",element:(0,n.jsx)(Ss,{to:"/company/settings/instance/features",replace:!0})})]}),(0,n.jsxs)(ot,{element:(0,n.jsx)(jg,{pageKey:"instance.plugins"}),children:[(0,n.jsx)(ot,{path:"company/settings/instance/plugins",element:(0,n.jsx)(oLs,{})}),(0,n.jsx)(ot,{path:"company/settings/instance/plugins/:pluginId",element:(0,n.jsx)(lLs,{})})]}),(0,n.jsx)(ot,{element:(0,n.jsx)(jg,{pageKey:"instance.adapters"}),children:(0,n.jsx)(ot,{path:"company/settings/instance/adapters",element:(0,n.jsx)(iUe,{})})}),(0,n.jsx)(ot,{path:"company/settings/:settingsRoutePath/*",element:(0,n.jsx)(DCs,{})}),(0,n.jsx)(ot,{path:"skills/sources",element:(0,n.jsx)(Hze,{})}),(0,n.jsx)(ot,{path:"skills/sources/:sourceId",element:(0,n.jsx)(Hze,{})}),(0,n.jsx)(ot,{path:"skills/studio",element:(0,n.jsx)(zre,{})}),(0,n.jsx)(ot,{path:"skills/studio/new",element:(0,n.jsx)(zre,{})}),(0,n.jsx)(ot,{path:"skills/studio/:skillId",element:(0,n.jsx)(zre,{})}),(0,n.jsx)(ot,{path:"skills/:skillId/studio",element:(0,n.jsx)(aAt,{})}),(0,n.jsx)(ot,{path:"skills/*",element:(0,n.jsx)(lTs,{})}),(0,n.jsx)(ot,{path:"settings",element:(0,n.jsx)(LC,{})}),(0,n.jsx)(ot,{path:"settings/*",element:(0,n.jsx)(LC,{})}),(0,n.jsx)(ot,{path:"plugins/:pluginId",element:(0,n.jsx)(aUe,{})}),(0,n.jsx)(ot,{path:"org",element:(0,n.jsx)(Ss,{to:"/agents/all",replace:!0})}),(0,n.jsx)(ot,{path:"agents",element:(0,n.jsx)(Ss,{to:"/agents/all",replace:!0})}),wwe.map(s=>(0,n.jsx)(ot,{path:`agents/${s}`,element:(0,n.jsx)(yQn,{})},s)),(0,n.jsx)(ot,{path:"agents/new",element:(0,n.jsx)(TLs,{})}),(0,n.jsx)(ot,{path:"agents/:agentId",element:(0,n.jsx)(Sne,{})}),(0,n.jsx)(ot,{path:"agents/:agentId/:tab",element:(0,n.jsx)(Sne,{})}),(0,n.jsx)(ot,{path:"agents/:agentId/runs/:runId",element:(0,n.jsx)(Sne,{})}),(0,n.jsx)(ot,{path:"projects",element:(0,n.jsx)(HGn,{})}),(0,n.jsx)(ot,{path:"projects/:projectId",element:(0,n.jsx)(QN,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/overview",element:(0,n.jsx)(QN,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/issues",element:(0,n.jsx)(QN,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/issues/:filter",element:(0,n.jsx)(QN,{})}),(0,n.jsx)(ot,{element:(0,n.jsx)(Ite,{}),children:(0,n.jsx)(ot,{path:"projects/:projectId/workspaces/:workspaceId",element:(0,n.jsx)(des,{})})}),(0,n.jsx)(ot,{path:"projects/:projectId/workspaces",element:(0,n.jsx)(QN,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/configuration",element:(0,n.jsx)(QN,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/budget",element:(0,n.jsx)(QN,{})}),(0,n.jsx)(ot,{element:(0,n.jsx)(Ite,{}),children:(0,n.jsx)(ot,{path:"workspaces",element:(0,n.jsx)(mes,{})})}),(0,n.jsx)(ot,{path:"terminal",element:(0,n.jsx)(o8s,{children:(0,n.jsx)(a8s,{})})}),(0,n.jsx)(ot,{path:"issues",element:(0,n.jsx)(Pts,{})}),(0,n.jsx)(ot,{path:"tasks",element:(0,n.jsx)(Ss,{to:"/issues",replace:!0})}),(0,n.jsx)(ot,{path:"tasks/new",element:(0,n.jsx)(JDn,{})}),(0,n.jsx)(ot,{path:"search",element:(0,n.jsx)(nns,{})}),t?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ot,{path:"issues/all",element:(0,n.jsx)(uf,{view:"all"})}),(0,n.jsx)(ot,{path:"issues/active",element:(0,n.jsx)(uf,{view:"active"})}),(0,n.jsx)(ot,{path:"issues/backlog",element:(0,n.jsx)(uf,{view:"backlog"})}),(0,n.jsx)(ot,{path:"issues/done",element:(0,n.jsx)(uf,{view:"done"})}),(0,n.jsx)(ot,{path:"issues/recent",element:(0,n.jsx)(uf,{view:"recent"})})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ot,{path:"issues/all",element:(0,n.jsx)(Ss,{to:"/issues",replace:!0})}),(0,n.jsx)(ot,{path:"issues/active",element:(0,n.jsx)(Ss,{to:"/issues",replace:!0})}),(0,n.jsx)(ot,{path:"issues/backlog",element:(0,n.jsx)(Ss,{to:"/issues",replace:!0})}),(0,n.jsx)(ot,{path:"issues/done",element:(0,n.jsx)(Ss,{to:"/issues",replace:!0})}),(0,n.jsx)(ot,{path:"issues/recent",element:(0,n.jsx)(Ss,{to:"/issues",replace:!0})})]}),(0,n.jsx)(ot,{path:"chats",element:(0,n.jsx)(lhs,{})}),(0,n.jsx)(ot,{path:"chats/:agentRef",element:(0,n.jsx)(dhs,{})}),(0,n.jsx)(ot,{path:"issues/:issueId",element:(0,n.jsx)(shs,{})}),null,(0,n.jsx)(ot,{path:"routines",element:(0,n.jsx)(rms,{})}),(0,n.jsx)(ot,{path:"cases",element:(0,n.jsx)(PMe,{children:(0,n.jsx)(wMn,{})})}),(0,n.jsx)(ot,{path:"cases/:caseIdentifier",element:(0,n.jsx)(PMe,{children:(0,n.jsx)(SDn,{})})}),(0,n.jsx)(ot,{path:"pixels-office",element:(0,n.jsx)(nMn,{children:(0,n.jsx)(Dbs,{})})}),(0,n.jsx)(ot,{path:"status",element:(0,n.jsx)($Me,{children:(0,n.jsx)(gOe,{})})}),(0,n.jsx)(ot,{path:"status/:cardId",element:(0,n.jsx)($Me,{children:(0,n.jsx)(gOe,{})})}),(0,n.jsx)(ot,{path:"status-cards",element:(0,n.jsx)(SUe,{})}),(0,n.jsx)(ot,{path:"status-cards/:cardId",element:(0,n.jsx)(SUe,{})}),(0,n.jsx)(ot,{path:"review-queue",element:(0,n.jsx)($w,{children:(0,n.jsx)(w0s,{})})}),(0,n.jsx)(ot,{path:"learnings",element:(0,n.jsx)($w,{children:(0,n.jsx)(N0s,{})})}),(0,n.jsx)(ot,{path:"pipelines",element:(0,n.jsx)($w,{children:(0,n.jsx)(zse,{})})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId",element:(0,n.jsx)($w,{children:(0,n.jsx)(zse,{})})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId/add",element:(0,n.jsx)($w,{children:(0,n.jsx)(zse,{})})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId/settings",element:(0,n.jsx)($w,{children:(0,n.jsx)(xfs,{})})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId/items/:caseId",element:(0,n.jsx)($w,{children:(0,n.jsx)(qps,{})})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId/cases/:caseId",element:(0,n.jsx)($w,{children:(0,n.jsx)(Fps,{})})}),(0,n.jsx)(ot,{path:"routines/:routineId",element:(0,n.jsx)(vFe,{})}),(0,n.jsx)(ot,{path:"routines/:routineId/:section",element:(0,n.jsx)(vFe,{})}),(0,n.jsx)(ot,{element:(0,n.jsx)(Ite,{}),children:(0,n.jsxs)(ot,{element:(0,n.jsx)(rMn,{}),children:[(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId",element:(0,n.jsx)(_2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/services",element:(0,n.jsx)(_2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/configuration",element:(0,n.jsx)(_2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/runtime-logs",element:(0,n.jsx)(_2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/issues",element:(0,n.jsx)(_2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/routines",element:(0,n.jsx)(_2,{})})]})}),(0,n.jsx)(ot,{path:"goals",element:(0,n.jsx)(Tks,{})}),(0,n.jsx)(ot,{path:"goals/:goalId",element:(0,n.jsx)(zks,{})}),(0,n.jsx)(ot,{path:"artifacts",element:(0,n.jsx)(wFe,{})}),(0,n.jsx)(ot,{path:"approvals",element:(0,n.jsx)(Ss,{to:"/approvals/pending",replace:!0})}),(0,n.jsx)(ot,{path:"approvals/pending",element:(0,n.jsx)(NFe,{})}),(0,n.jsx)(ot,{path:"approvals/all",element:(0,n.jsx)(NFe,{})}),(0,n.jsx)(ot,{path:"approvals/:approvalId",element:(0,n.jsx)(qks,{})}),(0,n.jsx)(ot,{path:"activity",element:(0,n.jsx)(Cjs,{})}),(0,n.jsx)(ot,{path:"activity/runs",element:(0,n.jsx)(GR,{section:"runs"})}),(0,n.jsx)(ot,{path:"activity/costs",element:(0,n.jsx)(GR,{section:"costs"})}),(0,n.jsx)(ot,{path:"activity/budgets",element:(0,n.jsx)(GR,{section:"budgets"})}),(0,n.jsx)(ot,{path:"activity/timeline",element:(0,n.jsx)(GR,{section:"timeline"})}),(0,n.jsx)(ot,{path:"audit",element:(0,n.jsx)(tv,{to:"/activity",forceAgentMode:!0})}),(0,n.jsx)(ot,{path:"audit/activity",element:(0,n.jsx)(tv,{to:"/activity"})}),(0,n.jsx)(ot,{path:"audit/runs",element:(0,n.jsx)(tv,{to:"/activity/runs"})}),(0,n.jsx)(ot,{path:"audit/costs",element:(0,n.jsx)(tv,{to:"/activity/costs"})}),(0,n.jsx)(ot,{path:"audit/budgets",element:(0,n.jsx)(tv,{to:"/activity/budgets"})}),(0,n.jsx)(ot,{path:"audit/timeline",element:(0,n.jsx)(tv,{to:"/activity/timeline"})}),(0,n.jsx)(ot,{path:"runs",element:(0,n.jsx)(tv,{to:"/activity/runs"})}),(0,n.jsx)(ot,{path:"costs",element:(0,n.jsx)(tv,{to:"/activity/costs"})}),(0,n.jsx)(ot,{path:"budgets",element:(0,n.jsx)(tv,{to:"/activity/budgets"})}),(0,n.jsxs)(ot,{element:(0,n.jsx)(e5n,{}),children:[(0,n.jsx)(ot,{path:"board-chat",element:(0,n.jsx)(jNs,{})}),(0,n.jsx)(ot,{path:"artifacts",element:(0,n.jsx)(wFe,{})})]}),null,(0,n.jsx)(ot,{path:"decisions",element:(0,n.jsx)(V1s,{})}),(0,n.jsx)(ot,{path:"decisions/queues/:key",element:(0,n.jsx)(J1s,{})}),t?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ot,{path:"inbox",element:(0,n.jsx)(jUe,{})}),(0,n.jsx)(ot,{path:"inbox/mine",element:(0,n.jsx)(uf,{view:"mine"})}),(0,n.jsx)(ot,{path:"inbox/recent",element:(0,n.jsx)(uf,{view:"recent"})}),(0,n.jsx)(ot,{path:"inbox/unread",element:(0,n.jsx)(uf,{view:"unread"})}),(0,n.jsx)(ot,{path:"inbox/blocked",element:(0,n.jsx)(uf,{view:"blocked"})}),(0,n.jsx)(ot,{path:"inbox/all",element:(0,n.jsx)(uf,{view:"everything"})}),(0,n.jsx)(ot,{path:"inbox/new",element:(0,n.jsx)(uf,{view:"mine"})})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ot,{path:"inbox",element:(0,n.jsx)(jUe,{})}),(0,n.jsx)(ot,{path:"inbox/mine",element:(0,n.jsx)(J2,{})}),(0,n.jsx)(ot,{path:"inbox/recent",element:(0,n.jsx)(J2,{})}),(0,n.jsx)(ot,{path:"inbox/unread",element:(0,n.jsx)(J2,{})}),(0,n.jsx)(ot,{path:"inbox/blocked",element:(0,n.jsx)(J2,{})}),(0,n.jsx)(ot,{path:"inbox/all",element:(0,n.jsx)(J2,{})}),(0,n.jsx)(ot,{path:"inbox/new",element:(0,n.jsx)(Ss,{to:"/inbox/mine",replace:!0})})]}),(0,n.jsx)(ot,{path:"inbox/requests",element:(0,n.jsx)(r8s,{})}),(0,n.jsx)(ot,{path:"u/:userSlug",element:(0,n.jsx)(rks,{})}),(0,n.jsx)(ot,{path:"design-guide",element:(0,n.jsx)(MMs,{})}),(0,n.jsx)(ot,{path:"instance/settings/adapters",element:(0,n.jsx)(iUe,{})}),(0,n.jsx)(ot,{path:":pluginRoutePath/*",element:(0,n.jsx)(aUe,{})}),(0,n.jsx)(ot,{path:"*",element:(0,n.jsx)(A0,{scope:"board"})})]})}i(l8s,"boardRoutes");function wUe({credentialSource:e="paperclip_vault"}={}){const t=Ri(),s=new URLSearchParams(t.search),{enabled:r,githubEnabled:a}=e_();return z3n(s,{chatConnectorsEnabled:r,githubReviewBotsEnabled:a})?(0,n.jsx)(p2t,{credentialSource:e}):(0,n.jsx)(Ss,{to:"/apps",replace:!0})}i(wUe,"AppsConnectEntryRoute");function jUe(){const{enabled:e}=VD();return e?(0,n.jsx)(uf,{view:TEt(YSe())}):(0,n.jsx)(Ss,{to:`/inbox/${YSe()}`,replace:!0})}i(jUe,"InboxRootRedirect");function uf({view:e}){const t=Ri(),s=new URLSearchParams(t.search);return s.set(QF,e),(0,n.jsx)(Ss,{to:`/issues?${s.toString()}${t.hash}`,replace:!0})}i(uf,"TaskViewRedirect");function aAt(){const e=Ri(),{companies:t,selectedCompany:s,loading:r}=gn(),{companyPrefix:a,skillId:o}=Mi();if(r)return null;const l=(a?t.find(c=>c.issuePrefix.toUpperCase()===a.toUpperCase()):null)??s??t[0]??null;return!l||!o?(0,n.jsx)(Ss,{to:"/skills/studio",replace:!0}):(0,n.jsx)(Ss,{to:`/${l.issuePrefix}/skills/studio/${encodeURIComponent(o)}${e.search}${e.hash}`,replace:!0})}i(aAt,"LegacySkillStudioRedirect");function LC(){const e=Ri(),{companies:t,selectedCompany:s,loading:r}=gn(),{companyPrefix:a}=Mi(),{hidden:o}=V0();if(r)return(0,n.jsx)(bx,{});const l=(a?t.find(d=>d.issuePrefix.toUpperCase()===a.toUpperCase()):null)??s??t[0]??null;if(!l)return Aye({pathname:e.pathname,hasCompanies:!1})?(0,n.jsx)(Ss,{to:"/onboarding",replace:!0}):(0,n.jsx)(k1e,{});const c=pBt(UZe(`${e.pathname}${e.search}${e.hash}`),o);return(0,n.jsx)(Ss,{to:`/${l.issuePrefix}${c}`,replace:!0})}i(LC,"LegacySettingsRedirect");function NUe(){const{tab:e}=Mi();return(0,n.jsx)(Ss,{to:oAt(e),replace:!0})}i(NUe,"LegacyToolsSettingsRedirect");function CUe(){const{tab:e}=Mi();return(0,n.jsx)(Ss,{to:oAt(e),replace:!0})}i(CUe,"LegacyToolsRedirect");function oAt(e){return e?e==="applications"||e==="connections"||e==="overview"||e==="examples"||e==="runtime"||e==="audit"?"/apps":e==="policies"?"/apps/advanced/profiles":`/apps/advanced/${e}`:"/apps/advanced/profiles"}i(oAt,"legacyToolsRedirectTarget");function lAt(){const{companies:e}=gn(),{openOnboarding:t}=Oc(),{t:s}=zJe(),r=im(),a=Vft(r?.cloudBaseUrl??null),{onboardingOpen:o,onboardingRouteDismissed:l}=dT(),{companyPrefix:c}=Mi(),d=c?e.find(p=>p.issuePrefix.toUpperCase()===c.toUpperCase())??null:null;if(t_n({onboardingOpen:o,routeDismissed:l}))return null;const u=d?`Add another agent to ${d.name}`:e.length>0?"Create another organization":"Create your first organization",h=d?"Run onboarding again to add an agent and a starter task for this organization.":e.length>0?"Run onboarding again to create another organization and seed its first agent.":"Get started by creating an organization and your first agent.";return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)("div",{className:"rounded-lg border border-line bg-bg-2 p-6",children:[(0,n.jsx)("h1",{className:"text-xl font-semibold",children:u}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:h}),(0,n.jsx)("div",{className:"mt-4",children:!d&&r&&!a?(0,n.jsx)("p",{className:"text-sm text-ink-3",children:s("app.cloudCreateUnavailable",{defaultValue:"Organizations are created in Paperclip Cloud. This instance can't reach it right now — try again from your Cloud portfolio."})}):(0,n.jsx)($,{onClick:i(()=>d?t({initialStep:FK(),companyId:d.id}):r&&a?P0(a):t(),"onClick"),children:d?"Add Agent":"Start Onboarding"})})]})})}i(lAt,"OnboardingRoutePage");function c8s(){const{companies:e,selectedCompany:t,loading:s}=gn(),r=Ri();if(s)return(0,n.jsx)(bx,{});const a=t??e[0]??null;return a?(0,n.jsx)(Ss,{to:`/${a.issuePrefix}/dashboard`,replace:!0}):Aye({pathname:r.pathname,hasCompanies:!1})?(0,n.jsx)(Ss,{to:"/onboarding",replace:!0}):(0,n.jsx)(k1e,{})}i(c8s,"CompanyRootRedirect");function SUe(){const{cardId:e}=Mi(),t=sRt(),s=t?`/${t}`:"";return(0,n.jsx)(Ss,{to:`${s}/status${e?`/${e}`:""}`,replace:!0})}i(SUe,"StatusCardsLegacyRedirect");function tv({to:e,forceAgentMode:t=!1}){const s=Ri(),r=new URLSearchParams(s.search);t&&r.set("mode","agents");const a=r.toString();return(0,n.jsx)(Ss,{to:`${e}${a?`?${a}`:""}${s.hash}`,replace:!0})}i(tv,"AuditCompatibilityRedirect");function Ni(){const e=Ri(),{companies:t,selectedCompany:s,loading:r}=gn();if(r)return(0,n.jsx)(bx,{});const a=s??t[0]??null;return a?(0,n.jsx)(Ss,{to:`/${a.issuePrefix}${e.pathname}${e.search}${e.hash}`,replace:!0}):Aye({pathname:e.pathname,hasCompanies:!1})?(0,n.jsx)(Ss,{to:"/onboarding",replace:!0}):(0,n.jsx)(k1e,{})}i(Ni,"UnprefixedBoardRedirect");function k1e(){const{openOnboarding:e}=Oc(),{t}=zJe(),s=im(),r=Vft(s?.cloudBaseUrl??null);return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)("div",{className:"rounded-lg border border-line bg-bg-2 p-6",children:[(0,n.jsx)("h1",{className:"text-xl font-semibold",children:t("app.noCompanies.title",{defaultValue:"Create your first organization"})}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:t("app.noCompanies.description",{defaultValue:"Get started by creating an organization."})}),(0,n.jsx)("div",{className:"mt-4",children:s&&!r?(0,n.jsx)("p",{className:"text-sm text-ink-3",children:t("app.cloudCreateUnavailable",{defaultValue:"Organizations are created in Paperclip Cloud. This instance can't reach it right now — try again from your Cloud portfolio."})}):(0,n.jsx)($,{onClick:i(()=>s&&r?P0(r):e(),"onClick"),children:t("app.noCompanies.newCompany",{defaultValue:"New Organization"})})})]})})}i(k1e,"NoCompaniesStartPage");function d8s(){const{enabled:e}=VD();return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(ZEt,{children:[(0,n.jsx)(ot,{path:"oauth-handoff",element:(0,n.jsx)(CAs,{})}),(0,n.jsx)(ot,{path:"auth",element:(0,n.jsx)(DLs,{})}),(0,n.jsx)(ot,{path:"board-claim/:token",element:(0,n.jsx)(PLs,{})}),(0,n.jsx)(ot,{path:"mcp-connect/:id",element:(0,n.jsx)(pUe,{})}),(0,n.jsx)(ot,{path:"dot-connect/:id",element:(0,n.jsx)(pUe,{agentPairingOnly:!0})}),(0,n.jsx)(ot,{path:"mcp-device",element:(0,n.jsx)($Ls,{})}),(0,n.jsx)(ot,{path:"assistant-connections",element:(0,n.jsx)(OLs,{})}),(0,n.jsx)(ot,{path:"cli-auth/:id",element:(0,n.jsx)(FLs,{})}),(0,n.jsx)(ot,{path:"invite/:token",element:(0,n.jsx)(QLs,{})}),(0,n.jsx)(ot,{path:"s/:token",element:(0,n.jsx)(kUe,{})}),(0,n.jsx)(ot,{path:"s/:token/issues/:issueId",element:(0,n.jsx)(kUe,{})}),(0,n.jsx)(ot,{element:(0,n.jsx)(_Le,{allowMembershipRequest:!0}),children:(0,n.jsx)(ot,{path:"chat-identity/confirm",element:(0,n.jsx)(p5s,{})})}),(0,n.jsx)(ot,{path:"tests/perf/long-thread",element:(0,n.jsx)(khs,{})}),(0,n.jsx)(ot,{path:"ux-lab/bootstrap-setup",element:(0,n.jsx)(ECs,{})}),(0,n.jsx)(ot,{path:"ux-lab/responsible-user-denial",element:(0,n.jsx)(RCs,{})}),(0,n.jsx)(ot,{path:"ux-lab/cross-issue-collaboration",element:(0,n.jsx)(LCs,{})}),(0,n.jsxs)(ot,{element:(0,n.jsx)(_Le,{}),children:[(0,n.jsx)(ot,{index:!0,element:(0,n.jsx)(c8s,{})}),(0,n.jsx)(ot,{path:"onboarding",element:(0,n.jsx)(lAt,{})}),(0,n.jsx)(ot,{path:"instance",element:(0,n.jsx)(LC,{})}),(0,n.jsx)(ot,{path:"instance/settings",element:(0,n.jsx)(LC,{})}),(0,n.jsx)(ot,{path:"instance/settings/*",element:(0,n.jsx)(LC,{})}),(0,n.jsx)(ot,{path:"companies",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"dashboard",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"inbox/*",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"issues",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"tasks",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"tasks/new",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"issues/:issueId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"routines",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"routines/:routineId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"review-queue",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"learnings",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"cases",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"cases/:caseIdentifier",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"pixels-office",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"status",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"status/:cardId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"status-cards",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"status-cards/:cardId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"pipelines",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId/add",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId/settings",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId/items/:caseId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId/cases/:caseId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"artifacts",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"audit",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"audit/*",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"activity",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"activity/*",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"runs",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"costs",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"budgets",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"decisions",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"u/:userSlug",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"skills/studio",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"skills/studio/new",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"skills/studio/:skillId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"skills/:skillId/studio",element:(0,n.jsx)(aAt,{})}),(0,n.jsx)(ot,{path:"skills/*",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"settings",element:(0,n.jsx)(LC,{})}),(0,n.jsx)(ot,{path:"settings/*",element:(0,n.jsx)(LC,{})}),(0,n.jsx)(ot,{path:"agents",element:(0,n.jsx)(Ni,{})}),wwe.map(t=>(0,n.jsx)(ot,{path:`agents/${t}`,element:(0,n.jsx)(Ni,{})},t)),(0,n.jsx)(ot,{path:"agents/new",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"agents/:agentId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"agents/:agentId/:tab",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"agents/:agentId/runs/:runId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"projects",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"projects/:projectId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/overview",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/issues",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/issues/:filter",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/workspaces",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/workspaces/:workspaceId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/configuration",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"workspaces",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"terminal",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId",element:(0,n.jsx)(s2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/services",element:(0,n.jsx)(s2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/configuration",element:(0,n.jsx)(s2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/runtime-logs",element:(0,n.jsx)(s2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/issues",element:(0,n.jsx)(s2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/routines",element:(0,n.jsx)(s2,{})}),(0,n.jsx)(ot,{path:":companyPrefix",element:(0,n.jsx)(J2n,{}),children:l8s(e)}),(0,n.jsx)(ot,{path:"*",element:(0,n.jsx)(A0,{scope:"global"})})]})]}),(0,n.jsx)(GDn,{}),(0,n.jsx)(p2n,{})]})}i(d8s,"App");var u8s=class extends m.Component{static{i(this,"AppErrorBoundary")}state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,t){Tye(e,{boundary:"app",componentStack:t.componentStack})}render(){const{error:e}=this.state;return e?(0,n.jsxs)("div",{className:"mx-auto flex min-h-screen max-w-2xl flex-col justify-center space-y-4 px-4 py-10",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Wardmote hit an error"}),(0,n.jsx)("p",{className:"mt-1 text-sm text-ink-3",children:"Something went wrong while running the app. Reloading usually fixes this."})]}),(0,n.jsx)("pre",{className:"overflow-auto rounded-md border border-bad/30 bg-bad/10 px-3 py-2 text-xs text-bad whitespace-pre-wrap",children:e.message}),(0,n.jsx)("div",{children:(0,n.jsx)("button",{type:"button",className:"inline-flex items-center rounded-md border border-line-strong bg-bg px-3 py-1.5 text-sm font-medium shadow-sm hover:bg-bg-3 hover:text-ink",onClick:i(()=>window.location.reload(),"onClick"),children:"Reload page"})})]}):this.props.children}};function h8s(){const{data:e}=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),retry:!1}),t=e?.sentryDsn,s=e?.sentryEnvironment??void 0;return(0,m.useEffect)(()=>{if(t)return E_n(t,s),()=>{R_n()}},[t,s]),null}i(h8s,"SentryGate");function m8s(e){let t=Ok();d7e(t),qW(t,e.userId);const s=C1t(()=>{const o=Ok();o!==t&&(t=o,d7e(o),qW(o,e.userId))}),r=typeof navigator<"u"&&"serviceWorker"in navigator?navigator.serviceWorker:null,a=i(o=>{const l=RZn(o.data);l&&(l.type==="navigate"?e.navigate(l.url):TZn(l.notification))},"onMessage");return r?.addEventListener("message",a),r?.startMessages(),()=>{s(),r?.removeEventListener("message",a)}}i(m8s,"startNotificationRuntime");function p8s(){const e=ir(),t=(0,m.useRef)(e),{data:s}=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),retry:!1}),r=s?.user?.id??s?.session?.userId??null;return(0,m.useEffect)(()=>{t.current=e},[e]),(0,m.useEffect)(()=>{if(r)return m8s({userId:r,navigate:i(a=>t.current(a),"navigate")})},[r]),null}i(p8s,"NotificationRuntime");var f8s=36e5,g8s=3e3,x8s=2e3,_Ue="wardmote.skip-waiting",v8s="wardmote.build-id",cAt=null,lpe=new Set;function b8s(e){cAt=e;for(const t of lpe)t()}i(b8s,"publishUpdate");function y8s(e){return lpe.add(e),()=>{lpe.delete(e)}}i(y8s,"subscribe");function k8s(){return(0,m.useSyncExternalStore)(y8s,()=>cAt,()=>null)}i(k8s,"useServiceWorkerUpdate");function w8s(e){return new Promise(t=>{const s=new MessageChannel,r=i(o=>{clearTimeout(a),s.port1.close(),t(o)},"finish"),a=setTimeout(()=>r(null),x8s);s.port1.onmessage=o=>{r(typeof o.data?.buildId=="string"?o.data.buildId:null)},e.postMessage({type:v8s},[s.port2])})}i(w8s,"requestWorkerBuildId");function j8s(e={}){const t=e.container??(typeof navigator<"u"&&"serviceWorker"in navigator?navigator.serviceWorker:void 0);if(!t)return()=>{};const s=e.documentRef??document,r=e.reload??(()=>window.location.reload()),a=e.updateIntervalMs??f8s,o=e.onUpdateReady??b8s;let l=!!t.controller,c=!1,d=!1,u,h=!1;const p=i(async N=>e.pageBuildId?await w8s(N)!==e.pageBuildId:!0,"servesNewerBuild"),f=i(()=>{d||(d=!0,u!==void 0&&clearTimeout(u),r())},"reloadOnce"),g=i(async N=>{const S=await p(N);if(!h){if(!S){N.postMessage({type:_Ue});return}o(()=>{c=!0,N.postMessage({type:_Ue}),u=setTimeout(f,g8s)})}},"offerWaiting"),x=i(()=>{if(!l){l=!0;return}if(c){f();return}const N=t.controller;N&&p(N).then(S=>{S&&!h&&!c&&o(f)})},"onControllerChange");t.addEventListener("controllerchange",x);let v;const b=i(()=>{const N=v?.installing;N&&N.addEventListener("statechange",()=>{N.state==="installed"&&t.controller&&g(N)})},"watchInstalling"),y=i(()=>{v?.update().catch(()=>{})},"checkForUpdates"),k=i(()=>{s.visibilityState==="visible"&&y()},"onVisibilityChange");s.addEventListener("visibilitychange",k);const j=setInterval(y,a);return t.register("/sw.js").then(N=>{v=N,N.waiting&&t.controller&&g(N.waiting),N.addEventListener("updatefound",b)}).catch(()=>{}),()=>{h=!0,t.removeEventListener("controllerchange",x),s.removeEventListener("visibilitychange",k),v?.removeEventListener("updatefound",b),clearInterval(j),u!==void 0&&clearTimeout(u)}}i(j8s,"startServiceWorkerUpdates");var dAt="wardmote.notifications.asked-after-decision";function N8s(){try{return window.localStorage.getItem(dAt)==="1"}catch{return!0}}i(N8s,"alreadyAsked");function C8s(){try{window.localStorage.setItem(dAt,"1")}catch{return}}i(C8s,"markAsked");async function S8s(e){const t=await o1t();if(t!=="granted")return t;const s=X6(r=>({...r,enabled:!0,pushEnabled:!0}));return e&&await qW(s,e),t}i(S8s,"enableNotificationsAfterDecision");function _8s(){const{pushToast:e}=ri(),{data:t}=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),retry:!1}),s=t?.user?.id??t?.session?.userId??null;(0,m.useEffect)(()=>QTt(()=>{N8s()||!zwe()||wA()!=="default"||(C8s(),e({id:"wardmote-notify-after-decision",title:"Get notified when an agent needs a decision",body:"Turn on notifications for this device. You can change it later in Settings.",tone:"info",persistent:!0,action:{label:"Turn on",onClick:i(()=>{S8s(s)},"onClick")}}))}),[e,s])}i(_8s,"useFirstDecisionNotificationPrompt");var A8s="wardmote-update-ready";function I8s(){const{pushToast:e}=ri(),t=k8s(),s=Ct(),r=W0(),a=(0,m.useRef)(r);return(0,m.useEffect)(()=>{t&&e({id:A8s,title:"A new version is ready.",tone:"info",persistent:!0,action:{label:"Reload",onClick:t}})},[t,e]),(0,m.useEffect)(()=>{if(r){a.current=!0;return}a.current&&(a.current=!1,s.invalidateQueries())},[r,s]),_8s(),null}i(I8s,"PwaRuntime");var uAt={get:i(e=>le.get(`/companies/${e}/primary-agent/me`),"get"),set:i((e,t)=>le.put(`/companies/${e}/primary-agent/me`,t),"set")};function T8s(e){const t=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn")}),s=t.data?.user?.id??t.data?.session?.userId??"local-board",r=ie({queryKey:O.primaryAgent.mine(e??"__none__",s),queryFn:i(()=>uAt.get(e),"queryFn"),enabled:!!e&&t.isSuccess});return{...r,userId:s,loading:!!e&&(t.isPending||r.isPending&&!t.error),error:t.error??r.error,retry:i(()=>t.isError?t.refetch():r.refetch(),"retry")}}i(T8s,"usePrimaryAgent");function E8s({children:e}){const{selectedCompanyId:t}=gn(),s=T8s(t),r=Ct(),{pushToast:a}=ri(),o=(0,m.useRef)({companyId:t,userId:s.userId});o.current={companyId:t,userId:s.userId};const l=i(f=>O.primaryAgent.mine(f.companyId,f.userId),"keyFor"),c=i(f=>f.companyId===o.current.companyId&&f.userId===o.current.userId,"isCurrentScope"),d=ie({queryKey:O.agents.list(t),queryFn:i(()=>Pt.list(t),"queryFn"),enabled:!!t}),u=ye({mutationFn:i(f=>uAt.set(f.companyId,{primaryAgentId:f.agentId}),"mutationFn"),onMutate:i(async f=>{const g=l(f);await r.cancelQueries({queryKey:g});const x=r.getQueryData(g);return r.setQueryData(g,{companyId:f.companyId,userId:f.userId,primaryAgentId:f.agentId,initialized:!0}),{previous:x}},"onMutate"),onError:i((f,g,x)=>{r.setQueryData(l(g),x?.previous),c(g)&&a({title:"Couldn't change your primary agent.",body:f.message,tone:"error",action:{label:"Retry",onClick:i(()=>{c(g)&&u.mutate(g)},"onClick")}})},"onError"),onSuccess:i((f,g)=>r.setQueryData(l(g),f),"onSuccess"),onSettled:i((f,g,x)=>{r.invalidateQueries({queryKey:l(x)}),r.invalidateQueries({queryKey:O.resourceMemberships.mine(x.companyId)})},"onSettled")}),h=d.data?.find(f=>f.id===s.data?.primaryAgentId&&f.status!=="terminated")??null,p=s.error??d.error;return(0,n.jsx)(fOt,{value:t?{companyId:t,primaryAgentId:h?.id??null,primaryAgent:h,loading:s.loading||d.isPending,error:p?.message,onRetry:i(()=>{s.retry(),d.refetch()},"onRetry"),pendingAgentId:u.isPending&&c(u.variables)?u.variables.agentId:null,onChange:i(f=>u.mutate({companyId:t,userId:s.userId,agentId:f}),"onChange")}:null,children:e})}i(E8s,"PrimaryAgentProvider");function R8s(e){return{id:e.key,title:e.title,status:e.status,projectId:e.projectId??null,assigneeAgentId:e.assigneeAgentId??null,lastRun:e.lastRunAt||e.lastRunStatus?{triggeredAt:e.lastRunAt??null,status:e.lastRunStatus??null}:null}}i(R8s,"managedRoutineToRow");function M8s({routines:e,agents:t=[],projects:s=[],pluginDisplayName:r=null,emptyMessage:a="No managed routines.",runningRoutineKey:o=null,statusMutationRoutineKey:l=null,reconcilingRoutineKey:c=null,resettingRoutineKey:d=null,onRunNow:u,onToggleEnabled:h,onReconcile:p,onReset:f}){const g=new Map(t.map(v=>[v.id,v])),x=new Map(s.map(v=>[v.id,{name:v.name,color:v.color}]));return e.length===0?(0,n.jsx)("div",{className:"rounded-lg border border-line px-3 py-8 text-center text-sm text-ink-3",children:a}):(0,n.jsx)("div",{className:"rounded-lg border border-line",children:e.map(v=>{const b=R8s(v),y=v.href??(v.routineId?`/routines/${v.routineId}`:"/routines"),k=v.missingRefs??[],j=!!(v.routineId&&v.resourceKey&&k.length===0),N=v.managedByPluginDisplayName??r,S=!!(p||f);return(0,n.jsxs)("div",{className:"last:[&_a]:border-b-0",children:[(0,n.jsx)(N3t,{routine:b,projectById:x,agentById:g,runningRoutineId:o,statusMutationRoutineId:l,href:y,configureLabel:"Configure",managedByLabel:N?`Managed by ${N}`:null,runNowButton:!0,hideArchiveAction:!0,disableRunNow:!j,disableToggle:!j,secondaryDetails:(0,n.jsxs)("span",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[v.resourceKey?(0,n.jsx)("span",{children:v.resourceKey}):null,v.cronExpression?(0,n.jsxs)("span",{children:["Schedule ",v.cronExpression]}):null]}),onRunNow:i(()=>u?.(v),"onRunNow"),onToggleEnabled:i(()=>h?.(v,b.status==="active"),"onToggleEnabled")}),S?(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-line px-3 pb-3 text-xs text-ink-3 last:border-b-0",onClick:i(A=>{A.preventDefault(),A.stopPropagation()},"onClick"),children:[(0,n.jsx)("span",{children:k.length?`Missing ${k.map(A=>`${A.resourceKind}:${A.resourceKey}`).join(", ")}`:"Routine defaults can be repaired."}),(0,n.jsxs)("span",{className:"flex items-center gap-2",children:[p?(0,n.jsx)($,{size:"sm",variant:"ghost",disabled:c===v.key,onClick:i(()=>p(v),"onClick"),children:c===v.key?"Reconciling...":"Reconcile"}):null,f?(0,n.jsx)($,{size:"sm",variant:"ghost",disabled:d===v.key,onClick:i(()=>f(v),"onClick"),children:d===v.key?"Resetting...":"Reset"}):null]})]}):null]},v.key)})})}i(M8s,"ManagedRoutinesList");function AUe(e){return new Set(e??[])}i(AUe,"toPathSet");function L8s({expandedPaths:e,checkedPaths:t,selectedFile:s=null,showCheckboxes:r=!1,onToggleDir:a,onSelectFile:o,...l}){return(0,m.createElement)(x_,{...l,selectedFile:s,expandedDirs:AUe(e),checkedFiles:t?AUe(t):void 0,showCheckboxes:r,onToggleDir:a??(()=>{}),onSelectFile:o??(()=>{})})}i(L8s,"PluginSdkFileTree");function D8s(e){const[t,s]=(0,m.useState)(null);return(0,m.useEffect)(()=>{let r=!1;return ln(()=>Promise.resolve().then(()=>Zfn).then(a=>{r||s(()=>a.MarkdownEditor)}),void 0),()=>{r=!0}},[]),t?(0,m.createElement)(t,e):(0,m.createElement)("textarea",{className:e.className,value:e.value,placeholder:e.placeholder,readOnly:e.readOnly,onBlur:e.onBlur,onChange:i(r=>e.onChange(r.currentTarget.value),"onChange")})}i(D8s,"PluginSdkMarkdownEditor");function P8s(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!=null&&t!==""&&t!==!1))}i(P8s,"compactIssueFilters");function $8s({companyId:e,projectId:t=null,filters:s,viewStateKey:r="paperclip:plugin-issues-view",initialSearch:a,createIssueLabel:o,searchWithinLoadedIssues:l=!0}){const c=Ct(),d=(0,m.useMemo)(()=>P8s({...s??{},projectId:s?.projectId??t??void 0}),[s,t]),u=d.originKindPrefix??null,h=d.projectId??t??null,p=(0,m.useMemo)(()=>["plugins","sdk-ui","issues-list",e??"__no-company__",d],[e,d]),{data:f}=ie({queryKey:O.agents.list(e??"__no-company__"),queryFn:i(()=>Pt.list(e),"queryFn"),enabled:!!e}),{data:g}=ie({queryKey:O.projects.list(e??"__no-company__",{includeArchived:!0}),queryFn:i(()=>Ii.list(e,{includeArchived:!0}),"queryFn"),enabled:!!e}),x=O.liveRuns(e??"__no-company__"),v=Zc({companyId:e,resourceKey:"live-runs",queryKey:x,enabled:!!e,refetchInterval:!1,leaderOnly:!0}),{data:b,dataUpdatedAt:y}=ie({queryKey:x,queryFn:i(()=>xi.liveRunsForCompany(e),"queryFn"),enabled:v.enabled,refetchInterval:v.refetchInterval});Xc(v,b,y);const{data:k,isLoading:j,error:N}=ie({queryKey:p,queryFn:i(()=>Mt.list(e,d),"queryFn"),enabled:!!e}),S=(0,m.useMemo)(()=>f_(b,k),[k,b]),A=ye({mutationFn:i(({id:I,data:_})=>Mt.update(I,_),"mutationFn"),onSuccess:i(()=>{e&&(c.invalidateQueries({queryKey:["plugins","sdk-ui","issues-list",e]}),c.invalidateQueries({queryKey:O.issues.list(e)}),h&&(c.invalidateQueries({queryKey:O.issues.listByProject(e,h)}),u&&c.invalidateQueries({queryKey:O.issues.listPluginOperationsByProject(e,h,u)})))},"onSuccess")});return e?(0,m.createElement)(YT,{issues:k??[],isLoading:j,error:N,agents:f,projects:g,liveIssueIds:S,projectId:h??void 0,viewStateKey:r,initialSearch:a,createIssueLabel:o,searchWithinLoadedIssues:l,onUpdateIssue:i((I,_)=>A.mutate({id:I,data:_}),"onUpdateIssue")}):(0,m.createElement)("div",{className:"text-sm text-ink-3"},"Select an organization to view tasks.")}i($8s,"PluginSdkIssuesList");function O8s({companyId:e,value:t,onChange:s,placeholder:r="Responsible",noneLabel:a="No responsible",searchPlaceholder:o="Search responsible...",emptyMessage:l="No responsible found.",includeUsers:c=!0,includeTerminatedAgents:d=!1,className:u,onConfirm:h}){const p=rfe(),f=e??p.companyId??null,{data:g}=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),enabled:c}),x=g?.user?.id??g?.session?.userId??null,{data:v}=ie({queryKey:O.agents.list(f??"__no-company__"),queryFn:i(()=>Pt.list(f),"queryFn"),enabled:!!f}),{data:b}=ie({queryKey:O.access.companyUserDirectory(f??"__no-company__"),queryFn:i(()=>jr.listUserDirectory(f),"queryFn"),enabled:!!f&&c}),y=(0,m.useMemo)(()=>oae(),[]),k=(0,m.useMemo)(()=>y.map(I=>I.startsWith("agent:")?I.slice(6):null).filter(I=>!!I),[y]),j=(0,m.useMemo)(()=>h1((v??[]).filter(I=>d||I.status!=="terminated"),k),[v,d,k]),N=(0,m.useMemo)(()=>[...c?AZe(x):[],...c?gT(b?.users,{excludeUserIds:[x]}):[],...j.map(I=>({id:Vh({assigneeAgentId:I.id}),label:I.name,searchText:`${I.name} ${I.role} ${I.title??""}`}))],[b?.users,x,c,j]),S=r3(t),A=S.assigneeAgentId?j.find(I=>I.id===S.assigneeAgentId):null;return(0,m.createElement)(Dm,{value:t,options:N,recentOptionIds:y,placeholder:r,noneLabel:a,searchPlaceholder:o,emptyMessage:l,className:u,onConfirm:h,onChange:i(I=>{const _=r3(I);_.assigneeAgentId&&u1(_.assigneeAgentId),_.assigneeUserId&&KM(_.assigneeUserId),s(I,_)},"onChange"),renderTriggerValue:i(I=>I?A?(0,m.createElement)(MQ,null,(0,m.createElement)(BK,{icon:A.icon,className:"h-3.5 w-3.5 shrink-0 text-ink-3"}),(0,m.createElement)("span",{className:"truncate"},I.label)):(0,m.createElement)("span",{className:"truncate"},I.label):(0,m.createElement)("span",{className:"text-ink-3"},r),"renderTriggerValue"),renderOption:i(I=>{if(!I.id)return(0,m.createElement)("span",{className:"truncate"},I.label);const _=r3(I.id),T=_.assigneeAgentId?j.find(E=>E.id===_.assigneeAgentId):null;return(0,m.createElement)(MQ,null,T?(0,m.createElement)(BK,{icon:T.icon,className:"h-3.5 w-3.5 shrink-0 text-ink-3"}):(0,m.createElement)(bc,{className:"h-3.5 w-3.5 shrink-0 text-ink-3"}),(0,m.createElement)("span",{className:"truncate"},I.label))},"renderOption")})}i(O8s,"PluginSdkAssigneePicker");function F8s({companyId:e,value:t,onChange:s,placeholder:r="Project",noneLabel:a="No project",searchPlaceholder:o="Search projects...",emptyMessage:l="No projects found.",includeArchived:c=!1,className:d,onConfirm:u}){const h=rfe(),p=e??h.companyId??null,{data:f}=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn")}),g=f?.user?.id??f?.session?.userId??null,{data:x}=ie({queryKey:O.projects.list(p??"__no-company__",{includeArchived:c}),queryFn:i(()=>Ii.list(p,{includeArchived:c}),"queryFn"),enabled:!!p}),v=(0,m.useMemo)(()=>(x??[]).filter(N=>c||!N.archivedAt),[c,x]),{orderedProjects:b}=xT({projects:v,companyId:p,userId:g}),y=(0,m.useMemo)(()=>m1(),[]),k=(0,m.useMemo)(()=>b.map(N=>({id:N.id,label:N.name,searchText:N.description??""})),[b]),j=b.find(N=>N.id===t)??null;return(0,m.createElement)(Dm,{value:t,options:k,recentOptionIds:y,placeholder:r,noneLabel:a,searchPlaceholder:o,emptyMessage:l,className:d,onConfirm:u,onChange:i(N=>{N&&jk(N),s(N)},"onChange"),renderTriggerValue:i(N=>!N||!j?(0,m.createElement)("span",{className:"text-ink-3"},r):(0,m.createElement)(MQ,null,(0,m.createElement)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:j.color??"#6366f1"}}),(0,m.createElement)("span",{className:"truncate"},N.label)),"renderTriggerValue"),renderOption:i(N=>{if(!N.id)return(0,m.createElement)("span",{className:"truncate"},N.label);const S=b.find(A=>A.id===N.id);return(0,m.createElement)(MQ,null,(0,m.createElement)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:S?.color??"#6366f1"}}),(0,m.createElement)("span",{className:"truncate"},N.label))},"renderOption")})}i(F8s,"PluginSdkProjectPicker");function MQ({children:e}){return(0,m.createElement)("span",{className:"contents"},e)}i(MQ,"FragmentSafe");function B8s({label:e,status:t}){const s={ok:"border-emerald-300 bg-emerald-50 text-emerald-700",warning:"border-amber-300 bg-amber-50 text-amber-800",error:"border-red-300 bg-red-50 text-red-700",info:"border-slate-300 bg-slate-50 text-slate-700",pending:"border-slate-300 bg-slate-50 text-slate-600"}[t];return(0,m.createElement)("span",{className:`inline-flex w-fit items-center rounded-full border px-2 py-0.5 text-xs font-medium ${s}`},e)}i(B8s,"PluginSdkStatusBadge");function z8s({columns:e,rows:t,loading:s,emptyMessage:r="No rows."}){if(s)return(0,m.createElement)("div",{className:"text-sm text-ink-3"},"Loading...");if(!t.length)return(0,m.createElement)("div",{className:"text-sm text-ink-3"},r);const a=e.map(o=>o.width??"minmax(0, 1fr)").join(" ");return(0,m.createElement)("div",{className:"overflow-hidden rounded-md border"},(0,m.createElement)("div",{className:"hidden border-b bg-bg-3/35 px-3 py-2 text-xs font-medium uppercase tracking-wide text-ink-3 md:grid md:[grid-template-columns:var(--plugin-grid-cols)]",style:{"--plugin-grid-cols":a}},e.map(o=>(0,m.createElement)("div",{key:o.key},o.header))),(0,m.createElement)("div",{className:"divide-y"},t.map((o,l)=>(0,m.createElement)("div",{key:String(o.id??l),className:"grid gap-2 px-3 py-3 md:items-center md:[grid-template-columns:var(--plugin-grid-cols)]",style:{"--plugin-grid-cols":a}},e.map(c=>(0,m.createElement)("div",{key:c.key,className:"min-w-0 text-sm"},(0,m.createElement)("div",{className:"mb-1 text-[11px] font-medium uppercase tracking-wide text-ink-3 md:hidden"},c.header),c.render?c.render(o[c.key],o):String(o[c.key]??"")))))))}i(z8s,"PluginSdkDataTable");function q8s({pairs:e}){return(0,m.createElement)("dl",{className:"grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[max-content_minmax(0,1fr)]"},e.flatMap(t=>[(0,m.createElement)("dt",{key:`${t.label}:label`,className:"text-ink-3"},t.label),(0,m.createElement)("dd",{key:`${t.label}:value`,className:"min-w-0"},t.value)]))}i(q8s,"PluginSdkKeyValueList");function U8s({label:e,value:t,unit:s}){return(0,m.createElement)("div",{className:"rounded-md border bg-bg-2 p-3"},(0,m.createElement)("div",{className:"text-xs font-medium uppercase tracking-wide text-ink-3"},e),(0,m.createElement)("div",{className:"mt-1 text-lg font-semibold"},`${t}${s??""}`))}i(U8s,"PluginSdkMetricCard");function K8s({data:e}){return(0,m.createElement)("pre",{className:"max-h-80 overflow-auto rounded-md border bg-bg-3/30 p-2 text-xs"},JSON.stringify(e,null,2))}i(K8s,"PluginSdkJsonTree");function W8s({label:e="Loading"}){return(0,m.createElement)("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-ink-3/30 border-t-ink align-middle",role:"status","aria-label":e})}i(W8s,"PluginSdkSpinner");var Q8s=class extends m.Component{static{i(this,"PluginSdkErrorBoundary")}state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback??(0,m.createElement)("div",{className:"rounded-md border border-bad/30 p-3 text-sm text-bad"},"Plugin UI failed to render."):this.props.children}};function V8s(e,t){globalThis.__paperclipPluginBridge__={react:e,reactJsxRuntime:n,reactDom:t,sdkUi:{usePluginData:jBt,usePluginAction:NBt,useHostContext:rfe,useHostLocation:SBt,useHostNavigation:CBt,usePluginStream:ABt,usePluginToast:_Bt,copyTextToClipboard:pi,MarkdownBlock:i(({content:s,className:r,enableWikiLinks:a,wikiLinkRoot:o,resolveWikiLinkHref:l})=>(0,m.createElement)(_s,{className:r,softBreaks:!1,enableWikiLinks:a,wikiLinkRoot:o,resolveWikiLinkHref:l,children:s}),"MarkdownBlock"),MetricCard:U8s,StatusBadge:B8s,DataTable:z8s,KeyValueList:q8s,JsonTree:K8s,Spinner:W8s,ErrorBoundary:Q8s,MarkdownEditor:D8s,FileTree:L8s,IssuesList:$8s,AssigneePicker:O8s,ProjectPicker:F8s,ManagedRoutinesList:M8s}}}i(V8s,"initPluginBridge");var H8s=1e4;function G8s(e=H8s){if(typeof performance>"u"||typeof performance.clearMeasures!="function")return()=>{};const s=setInterval(i(()=>{globalThis.__paperclipKeepPerfMeasures||performance.clearMeasures()},"reap"),e);return()=>clearInterval(s)}i(G8s,"startPerfMeasureReaper");var Y8s=ih((e=>{function t(B,z){var U=B.length;B.push(z);e:for(;0<U;){var W=U-1>>>1,F=B[W];if(0<a(F,z))B[W]=z,B[U]=F,U=W;else break e}}i(t,"push");function s(B){return B.length===0?null:B[0]}i(s,"peek");function r(B){if(B.length===0)return null;var z=B[0],U=B.pop();if(U!==z){B[0]=U;e:for(var W=0,F=B.length,Y=F>>>1;W<Y;){var V=2*(W+1)-1,G=B[V],ne=V+1,Z=B[ne];if(0>a(G,U))ne<F&&0>a(Z,G)?(B[W]=Z,B[ne]=U,W=ne):(B[W]=G,B[V]=U,W=V);else if(ne<F&&0>a(Z,U))B[W]=Z,B[ne]=U,W=ne;else break e}}return z}i(r,"pop");function a(B,z){var U=B.sortIndex-z.sortIndex;return U!==0?U:B.id-z.id}if(i(a,"compare"),e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,c=l.now();e.unstable_now=function(){return l.now()-c}}var d=[],u=[],h=1,p=null,f=3,g=!1,x=!1,v=!1,b=!1,y=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function N(B){for(var z=s(u);z!==null;){if(z.callback===null)r(u);else if(z.startTime<=B)r(u),z.sortIndex=z.expirationTime,t(d,z);else break;z=s(u)}}i(N,"advanceTimers");function S(B){if(v=!1,N(B),!x)if(s(d)!==null)x=!0,A||(A=!0,P());else{var z=s(u);z!==null&&L(S,z.startTime-B)}}i(S,"handleTimeout");var A=!1,I=-1,_=5,T=-1;function E(){return b?!0:!(e.unstable_now()-T<_)}i(E,"shouldYieldToHost");function M(){if(b=!1,A){var B=e.unstable_now();T=B;var z=!0;try{e:{x=!1,v&&(v=!1,k(I),I=-1),g=!0;var U=f;try{t:{for(N(B),p=s(d);p!==null&&!(p.expirationTime>B&&E());){var W=p.callback;if(typeof W=="function"){p.callback=null,f=p.priorityLevel;var F=W(p.expirationTime<=B);if(B=e.unstable_now(),typeof F=="function"){p.callback=F,N(B),z=!0;break t}p===s(d)&&r(d),N(B)}else r(d);p=s(d)}if(p!==null)z=!0;else{var Y=s(u);Y!==null&&L(S,Y.startTime-B),z=!1}}break e}finally{p=null,f=U,g=!1}z=void 0}}finally{z?P():A=!1}}}i(M,"performWorkUntilDeadline");var P;if(typeof j=="function")P=i(function(){j(M)},"schedulePerformWorkUntilDeadline");else if(typeof MessageChannel<"u"){var D=new MessageChannel,K=D.port2;D.port1.onmessage=M,P=i(function(){K.postMessage(null)},"schedulePerformWorkUntilDeadline")}else P=i(function(){y(M,0)},"schedulePerformWorkUntilDeadline");function L(B,z){I=y(function(){B(e.unstable_now())},z)}i(L,"requestHostTimeout"),e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(B){B.callback=null},e.unstable_forceFrameRate=function(B){0>B||125<B||(_=0<B?Math.floor(1e3/B):5)},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(B){switch(f){case 1:case 2:case 3:var z=3;break;default:z=f}var U=f;f=z;try{return B()}finally{f=U}},e.unstable_requestPaint=function(){b=!0},e.unstable_runWithPriority=function(B,z){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var U=f;f=B;try{return z()}finally{f=U}},e.unstable_scheduleCallback=function(B,z,U){var W=e.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?W+U:W):U=W,B){case 1:var F=-1;break;case 2:F=250;break;case 5:F=1073741823;break;case 4:F=1e4;break;default:F=5e3}return F=U+F,B={id:h++,callback:z,priorityLevel:B,startTime:U,expirationTime:F,sortIndex:-1},U>W?(B.sortIndex=U,t(u,B),s(d)===null&&B===s(u)&&(v?(k(I),I=-1):v=!0,L(S,U-W))):(B.sortIndex=F,t(d,B),x||g||(x=!0,A||(A=!0,P()))),B},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(B){var z=f;return function(){var U=f;f=z;try{return B.apply(this,arguments)}finally{f=U}}}})),J8s=ih(((e,t)=>{t.exports=Y8s()})),Z8s=ih((e=>{var t=J8s(),s=cpe(),r=CKe();function a(w){var C="https://react.dev/errors/"+w;if(1<arguments.length){C+="?args[]="+encodeURIComponent(arguments[1]);for(var R=2;R<arguments.length;R++)C+="&args[]="+encodeURIComponent(arguments[R])}return"Minified React error #"+w+"; visit "+C+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}i(a,"formatProdErrorMessage");function o(w){return!(!w||w.nodeType!==1&&w.nodeType!==9&&w.nodeType!==11)}i(o,"isValidContainer");function l(w){var C=w,R=w;if(w.alternate)for(;C.return;)C=C.return;else{w=C;do C=w,(C.flags&4098)!==0&&(R=C.return),w=C.return;while(w)}return C.tag===3?R:null}i(l,"getNearestMountedFiber");function c(w){if(w.tag===13){var C=w.memoizedState;if(C===null&&(w=w.alternate,w!==null&&(C=w.memoizedState)),C!==null)return C.dehydrated}return null}i(c,"getSuspenseInstanceFromFiber");function d(w){if(w.tag===31){var C=w.memoizedState;if(C===null&&(w=w.alternate,w!==null&&(C=w.memoizedState)),C!==null)return C.dehydrated}return null}i(d,"getActivityInstanceFromFiber");function u(w){if(l(w)!==w)throw Error(a(188))}i(u,"assertIsMounted");function h(w){var C=w.alternate;if(!C){if(C=l(w),C===null)throw Error(a(188));return C!==w?null:w}for(var R=w,q=C;;){var X=R.return;if(X===null)break;var re=X.alternate;if(re===null){if(q=X.return,q!==null){R=q;continue}break}if(X.child===re.child){for(re=X.child;re;){if(re===R)return u(X),w;if(re===q)return u(X),C;re=re.sibling}throw Error(a(188))}if(R.return!==q.return)R=X,q=re;else{for(var Ce=!1,Ge=X.child;Ge;){if(Ge===R){Ce=!0,R=X,q=re;break}if(Ge===q){Ce=!0,q=X,R=re;break}Ge=Ge.sibling}if(!Ce){for(Ge=re.child;Ge;){if(Ge===R){Ce=!0,R=re,q=X;break}if(Ge===q){Ce=!0,q=re,R=X;break}Ge=Ge.sibling}if(!Ce)throw Error(a(189))}}if(R.alternate!==q)throw Error(a(190))}if(R.tag!==3)throw Error(a(188));return R.stateNode.current===R?w:C}i(h,"findCurrentFiberUsingSlowPath");function p(w){var C=w.tag;if(C===5||C===26||C===27||C===6)return w;for(w=w.child;w!==null;){if(C=p(w),C!==null)return C;w=w.sibling}return null}i(p,"findCurrentHostFiberImpl");var f=Object.assign,g=Symbol.for("react.element"),x=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),j=Symbol.for("react.consumer"),N=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),E=Symbol.for("react.activity"),M=Symbol.for("react.memo_cache_sentinel"),P=Symbol.iterator;function D(w){return w===null||typeof w!="object"?null:(w=P&&w[P]||w["@@iterator"],typeof w=="function"?w:null)}i(D,"getIteratorFn");var K=Symbol.for("react.client.reference");function L(w){if(w==null)return null;if(typeof w=="function")return w.$$typeof===K?null:w.displayName||w.name||null;if(typeof w=="string")return w;switch(w){case b:return"Fragment";case k:return"Profiler";case y:return"StrictMode";case A:return"Suspense";case I:return"SuspenseList";case E:return"Activity"}if(typeof w=="object")switch(w.$$typeof){case v:return"Portal";case N:return w.displayName||"Context";case j:return(w._context.displayName||"Context")+".Consumer";case S:var C=w.render;return w=w.displayName,w||(w=C.displayName||C.name||"",w=w!==""?"ForwardRef("+w+")":"ForwardRef"),w;case _:return C=w.displayName||null,C!==null?C:L(w.type)||"Memo";case T:C=w._payload,w=w._init;try{return L(w(C))}catch{}}return null}i(L,"getComponentNameFromType");var B=Array.isArray,z=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W={pending:!1,data:null,method:null,action:null},F=[],Y=-1;function V(w){return{current:w}}i(V,"createCursor");function G(w){0>Y||(w.current=F[Y],F[Y]=null,Y--)}i(G,"pop");function ne(w,C){Y++,F[Y]=w.current,w.current=C}i(ne,"push");var Z=V(null),J=V(null),se=V(null),H=V(null);function ee(w,C){switch(ne(se,C),ne(J,w),ne(Z,null),C.nodeType){case 9:case 11:w=(w=C.documentElement)&&(w=w.namespaceURI)?ECe(w):0;break;default:if(w=C.tagName,C=C.namespaceURI)C=ECe(C),w=RCe(C,w);else switch(w){case"svg":w=1;break;case"math":w=2;break;default:w=0}}G(Z),ne(Z,w)}i(ee,"pushHostContainer");function te(){G(Z),G(J),G(se)}i(te,"popHostContainer");function oe(w){w.memoizedState!==null&&ne(H,w);var C=Z.current,R=RCe(C,w.type);C!==R&&(ne(J,w),ne(Z,R))}i(oe,"pushHostContext");function ae(w){J.current===w&&(G(Z),G(J)),H.current===w&&(G(H),P4._currentValue=W)}i(ae,"popHostContext");var ge,xe;function ce(w){if(ge===void 0)try{throw Error()}catch(R){var C=R.stack.trim().match(/\n( *(at )?)/);ge=C&&C[1]||"",xe=-1<R.stack.indexOf(`
752
+ `)}z!==y&&(s.textContent=z,y=z)}i(I,"step");function _(){const D=d>0&&u>0;if(r.matches){o&&(o=!1,t.current!==null&&cancelAnimationFrame(t.current),t.current=null),D&&N();return}if(!a||!D){o&&(o=!1,t.current!==null&&cancelAnimationFrame(t.current),t.current=null);return}o||(o=!0,l=0,t.current=requestAnimationFrame(I))}i(_,"syncLoop");const T=new ResizeObserver(()=>{const D=hUe(s);h=D.w,p=D.h,j(),_()});T.observe(s);const E=i(()=>{a=document.visibilityState!=="hidden",_()},"onVisibilityChange");document.addEventListener("visibilitychange",E);const M=i(()=>{_()},"onMotionChange");r.addEventListener("change",M);const P=hUe(s);return h=P.w,p=P.h,j(),_(),()=>{o=!1,t.current!==null&&cancelAnimationFrame(t.current),T.disconnect(),document.removeEventListener("visibilitychange",E),r.removeEventListener("change",M)}},[]),(0,n.jsx)("pre",{ref:e,className:"w-full h-full m-0 p-0 overflow-hidden text-ink-3/60 select-none leading-none",style:{fontSize:"var(--text-micro)",fontFamily:"monospace"},"aria-hidden":"true"})}i(LLs,"AsciiArtAnimation");function DLs(){const e=Ct(),t=ir(),[s]=Ia(),[r,a]=(0,m.useState)("sign_in"),[o,l]=(0,m.useState)(""),[c,d]=(0,m.useState)(""),[u,h]=(0,m.useState)(""),[p,f]=(0,m.useState)(null),g="auth-error",x=(0,m.useMemo)(()=>Hft(s.get("next")||ELs()||"/"),[s]),v=ie({queryKey:O.health,queryFn:i(()=>Op.get(),"queryFn"),retry:!1}),{data:b,isLoading:y,error:k}=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),retry:!1});(0,m.useEffect)(()=>{b&&(Tke(),t(x,{replace:!0}))},[b,t,x]);const j=ye({mutationFn:i(async()=>{if(r==="sign_in"){await Ji.signInEmail({email:c.trim(),password:u});return}await Ji.signUpEmail({name:o.trim(),email:c.trim(),password:u})},"mutationFn"),onSuccess:i(async()=>{f(null),await e.invalidateQueries({queryKey:O.auth.session}),await e.invalidateQueries({queryKey:O.health}),await e.resetQueries({queryKey:O.companies.all}),t(x,{replace:!0})},"onSuccess"),onError:i(S=>{f(S instanceof Error?S.message:"Authentication failed")},"onError")}),N=c.trim().length>0&&u.trim().length>0&&(r==="sign_in"||o.trim().length>0&&u.trim().length>=8);return v.isLoading||y||b?(0,n.jsx)("div",{className:"fixed inset-0 flex items-center justify-center",children:(0,n.jsx)(bx,{className:"min-h-0"})}):v.error||k?(0,n.jsx)("p",{role:"alert",className:"p-6 text-sm text-bad",children:"Unable to check sign-in. Refresh and try again."}):v.data?.cloud?(0,n.jsx)(Eke,{cloud:v.data.cloud,returnTo:x}):(0,n.jsxs)("div",{className:"fixed inset-0 flex bg-bg",children:[(0,n.jsx)("div",{className:"absolute top-4 right-4 z-10",children:(0,n.jsx)(q6,{})}),(0,n.jsx)("div",{className:"w-full md:w-1/2 flex flex-col overflow-y-auto",children:(0,n.jsxs)("div",{className:"w-full max-w-md mx-auto my-auto px-8 py-12",children:[(0,n.jsx)("div",{className:"mb-8",children:(0,n.jsx)($0,{className:"size-8 text-ink",title:"Wardmote"})}),(0,n.jsx)("h1",{className:"text-xl font-semibold",children:r==="sign_in"?"Sign in to Wardmote":"Create your Wardmote account"}),(0,n.jsx)("p",{className:"mt-1 text-sm text-ink-3",children:r==="sign_in"?"Use your email and password to access this instance.":"Create an account for this instance. Email confirmation is not required in v1."}),(0,n.jsxs)("form",{className:"mt-6 space-y-4",method:"post",action:r==="sign_up"?"/api/auth/sign-up/email":"/api/auth/sign-in/email",onSubmit:i(S=>{if(S.preventDefault(),!j.isPending){if(!N){f("Please fill in all required fields.");return}j.mutate()}},"onSubmit"),children:[r==="sign_up"&&(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"name",className:"text-xs text-ink-3 mb-1 block",children:"Name"}),(0,n.jsx)("input",{id:"name",name:"name",className:"w-full rounded-md border border-line bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-focus placeholder:text-ink-3/50",value:o,onChange:i(S=>l(S.target.value),"onChange"),autoComplete:"name",required:!0,"aria-required":"true","aria-invalid":p?!0:void 0,"aria-describedby":p?g:void 0,autoFocus:!0})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"email",className:"text-xs text-ink-3 mb-1 block",children:"Email"}),(0,n.jsx)("input",{id:"email",name:"email",className:"w-full rounded-md border border-line bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-focus placeholder:text-ink-3/50",type:"email",value:c,onChange:i(S=>d(S.target.value),"onChange"),autoComplete:"username",required:!0,"aria-required":"true","aria-invalid":p?!0:void 0,"aria-describedby":p?g:void 0,autoFocus:r==="sign_in"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"password",className:"text-xs text-ink-3 mb-1 block",children:"Password"}),(0,n.jsx)("input",{id:"password",name:"password",className:"w-full rounded-md border border-line bg-transparent px-3 py-2 text-sm outline-none focus:ring-1 focus:ring-focus placeholder:text-ink-3/50",type:"password",value:u,onChange:i(S=>h(S.target.value),"onChange"),autoComplete:r==="sign_in"?"current-password":"new-password",required:!0,"aria-required":"true","aria-invalid":p?!0:void 0,"aria-describedby":p?g:void 0})]}),p&&(0,n.jsx)("p",{id:g,role:"alert",className:"text-xs text-bad",children:p}),(0,n.jsx)($,{type:"submit",disabled:j.isPending,"aria-disabled":!N||j.isPending,className:`w-full ${!N&&!j.isPending?"opacity-50":""}`,children:j.isPending?"Working…":r==="sign_in"?"Sign In":"Create Account"})]}),(0,n.jsxs)("div",{className:"mt-5 text-sm text-ink-3",children:[r==="sign_in"?"Need an account?":"Already have an account?"," ",(0,n.jsx)("button",{type:"button",className:"font-medium text-ink underline underline-offset-2",onClick:i(()=>{f(null),a(r==="sign_in"?"sign_up":"sign_in")},"onClick"),children:r==="sign_in"?"Create one":"Sign in"})]})]})}),(0,n.jsx)("div",{className:"hidden md:block w-1/2 overflow-hidden",children:(0,n.jsx)(LLs,{})})]})}i(DLs,"AuthPage");function PLs(){const e=Ct(),t=Mi(),[s]=Ia(),r=(t.token??"").trim(),a=(s.get("code")??"").trim(),o=(0,m.useMemo)(()=>`/board-claim/${encodeURIComponent(r)}${a?`?code=${encodeURIComponent(a)}`:""}`,[r,a]),l=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),retry:!1}),c=ie({queryKey:["board-claim",r,a],queryFn:i(()=>jr.getBoardClaimStatus(r,a),"queryFn"),enabled:r.length>0&&a.length>0,retry:!1}),d=ye({mutationFn:i(()=>jr.claimBoard(r,a),"mutationFn"),onSuccess:i(async()=>{await e.invalidateQueries({queryKey:O.auth.session}),await e.invalidateQueries({queryKey:O.health}),await e.invalidateQueries({queryKey:O.companies.all}),await e.invalidateQueries({queryKey:O.companies.stats}),await c.refetch()},"onSuccess")});if(!r||!a)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-bad",children:"Invalid board claim URL."});if(c.isLoading||l.isLoading)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-ink-3",children:"Loading claim challenge..."});if(c.error)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Claim challenge unavailable"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:c.error instanceof Error?c.error.message:"Challenge is invalid or expired."})]})});const u=c.data;return u?u.status==="claimed"?(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Board ownership claimed"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"This instance is now linked to your authenticated user."}),(0,n.jsx)($,{asChild:!0,className:"mt-4",children:(0,n.jsx)(Ye,{to:"/",children:"Open board"})})]})}):l.data?(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsx)("h1",{className:"text-xl font-semibold",children:"Claim Board ownership"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"This will promote your user to instance admin and migrate organization ownership access from local trusted mode."}),d.error&&(0,n.jsx)("p",{className:"mt-3 text-sm text-bad",children:d.error instanceof Error?d.error.message:"Failed to claim board ownership"}),(0,n.jsx)($,{className:"mt-5",onClick:i(()=>d.mutate(),"onClick"),disabled:d.isPending,children:d.isPending?"Claiming…":"Claim ownership"})]})}):(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Sign in required"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"Sign in or create an account, then return to this page to claim Board ownership."}),(0,n.jsx)($,{asChild:!0,className:"mt-4",children:(0,n.jsx)(Ye,{to:`/auth?next=${encodeURIComponent(o)}`,children:"Sign in / Create account"})})]})}):(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-bad",children:"Claim challenge unavailable."})}i(PLs,"BoardClaimPage");function mUe({origin:e}){const[t,s]=(0,m.useState)(!1);let r;try{const a=new URL(e);a.origin==="https://claude.ai"?r="/brands/claude-color.svg":["https://chatgpt.com","https://chat.openai.com","https://openai.com"].includes(a.origin)&&(r="/brands/codex-color.svg")}catch{}return(0,n.jsxs)("div",{className:"flex items-center gap-2 text-sm text-ink-3",children:[r&&!t?(0,n.jsx)("img",{src:r,alt:"",className:"size-4 shrink-0 object-contain",referrerPolicy:"no-referrer",crossOrigin:"anonymous",onError:i(()=>s(!0),"onError")}):(0,n.jsx)(Lp,{className:"size-4 shrink-0","aria-hidden":"true"}),(0,n.jsx)("bdi",{className:"min-w-0 break-all",children:e})]})}i(mUe,"ClientOrigin");function pUe({agentPairingOnly:e=!1}={}){const{id:t=""}=Mi();return(0,n.jsx)(sAt,{id:t,agentPairingOnly:e},t)}i(pUe,"McpConnectPage");function $Ls({initialCode:e}={}){const[t,s]=(0,m.useState)(e??new URLSearchParams(window.location.search).get("user_code")??""),[r,a]=(0,m.useState)(t);return r?(0,n.jsx)(sAt,{id:r,device:!0,onEditCode:i(()=>a(""),"onEditCode")},r):(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"space-y-4 p-6",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)($0,{className:"size-8 shrink-0 text-ink"}),(0,n.jsx)("h1",{className:"min-w-0 text-xl font-semibold",children:"Connect your assistant to Wardmote"})]}),(0,n.jsxs)("form",{className:"space-y-4",onSubmit:i(o=>{o.preventDefault(),a(t.trim())},"onSubmit"),children:[(0,n.jsx)("label",{htmlFor:"device-code",className:"text-sm",children:"Enter the code shown by your assistant"}),(0,n.jsx)(mt,{id:"device-code",autoComplete:"off",value:t,onChange:i(o=>s(o.target.value),"onChange"),required:!0,maxLength:12}),(0,n.jsx)("div",{className:"flex justify-end",children:(0,n.jsx)($,{type:"submit",children:"Continue"})})]})]})})}i($Ls,"McpDevicePage");function sAt({id:e,device:t=!1,agentPairingOnly:s=!1,onEditCode:r}){const a=s?"/dot-mcp/requests":"/mcp/requests",[o,l]=(0,m.useState)(""),[c,d]=(0,m.useState)(""),[u,h]=(0,m.useState)(null),[p,f]=(0,m.useState)(""),[g,x]=(0,m.useState)(!0),[v,b]=(0,m.useState)(null),y=ie({queryKey:[t?"mcp-device":s?"dot-mcp-request":"mcp-request",e],queryFn:i(()=>le.get(t?`/mcp/device?user_code=${encodeURIComponent(e)}`:`${a}/${encodeURIComponent(e)}`),"queryFn"),retry:!1}),k=y.data;(0,m.useEffect)(()=>{if(h(null),f(""),!k?.agentConnection||t||!/^[A-Za-z0-9_-]{32}$/.test(c.trim()))return;let K=!0;return le.post(`${a}/${encodeURIComponent(e)}/dot-pairing/preview`,{pairingCode:c.trim()}).then(L=>{K&&h(L)}).catch(L=>{K&&f(L instanceof Error?L.message:"Unable to verify this pairing code.")}),()=>{K=!1}},[e,t,a,k?.agentConnection,c]);const j=k?.requestedCompanyId??(o||k?.companies[0]?.id||"");(0,m.useEffect)(()=>{!o&&!k?.requestedCompanyId&&k?.companies[0]&&l(k.companies[0].id)},[o,k]);const N=k?.clientName.trim(),S=N&&!/^(assistant|mcp client)$/i.test(N)?N:"your assistant",A=k?.clientOrigin||k?.redirectOrigin,I=k?.companies.find(K=>K.id===j),_=!!(!k?.agentConnection&&I?.canWrite&&g),T=!!(k?.requestedWrite&&_),E=!!(k?.requestedConfigure&&_),M=ye({mutationFn:i(K=>le.post(t?"/mcp/device/consent":`/mcp/requests/${encodeURIComponent(e)}/consent`,{decision:K,companyId:j||void 0,allowWrites:K==="approve"&&T,allowConfiguration:K==="approve"&&E,...t?{userCode:e}:{}}),"mutationFn"),onSuccess:i(({redirectUrl:K,status:L})=>{t&&L?b(L):K&&window.location.assign(K)},"onSuccess")}),P=ye({mutationFn:i(()=>le.post(`${a}/${encodeURIComponent(e)}/dot-pairing`,{pairingCode:c.trim()}),"mutationFn"),onSuccess:i(({redirectUrl:K})=>{d(""),window.location.assign(K)},"onSuccess")});if(v)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block space-y-4 p-6",children:[(0,n.jsx)($0,{className:"size-8 text-ink"}),(0,n.jsx)("h1",{className:"text-xl font-semibold",children:v==="approved"?"Access approved":"Connection declined"}),(0,n.jsx)("p",{className:"text-sm",children:v==="approved"?"Return to your assistant. It will finish connecting automatically.":"No access was granted. You can start a new connection from your assistant."}),(0,n.jsx)($,{variant:"secondary",asChild:!0,children:(0,n.jsx)(Ye,{to:"/",children:"Back to Wardmote"})})]})});const D=t?`/mcp-device?user_code=${encodeURIComponent(e)}`:`${s?"/dot-connect":"/mcp-connect"}/${e}`;return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block space-y-4 p-6",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)($0,{className:"size-8 shrink-0 text-ink",title:"Wardmote"}),(0,n.jsxs)("h1",{className:"min-w-0 break-words text-xl font-semibold",children:["Connect ",(0,n.jsx)("bdi",{children:S})," to Wardmote"]})]}),A&&(0,n.jsx)(mUe,{origin:A},A),!t&&k?.redirectOrigin&&k.redirectOrigin!==A&&(0,n.jsx)(mUe,{origin:k.redirectOrigin},k.redirectOrigin),t&&(0,n.jsxs)("p",{className:"text-sm",children:["Confirm this matches the code shown by your assistant: ",(0,n.jsx)("strong",{className:"font-mono",children:e.toUpperCase()})]}),y.isPending&&(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Loading connection request…"}),y.error&&(0,n.jsxs)("p",{className:"text-sm text-bad",children:[y.error.message," Start a new connection from your assistant."]}),t&&y.error&&(0,n.jsx)($,{variant:"secondary",onClick:r,children:"Enter a different code"}),k?.agentConnection&&!t&&(0,n.jsxs)("form",{className:"space-y-3",onSubmit:i(K=>{K.preventDefault(),P.mutate()},"onSubmit"),children:[(0,n.jsx)("p",{className:"text-sm",children:"Enter the one-use code from your Dot setup prompt to review this agent’s access. Access is granted when you click “Connect Dot with pairing code”."}),(0,n.jsx)("label",{htmlFor:"dot-pairing-code",className:"text-sm",children:"Pairing code"}),(0,n.jsx)(mt,{id:"dot-pairing-code",type:"password",autoComplete:"off",value:c,onChange:i(K=>{h(null),f(""),d(K.target.value)},"onChange"),required:!0,maxLength:32}),u&&(0,n.jsxs)("dl",{className:"space-y-2 rounded-md border border-line p-3 text-sm",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{className:"text-ink-3",children:"Company"}),(0,n.jsxs)("dd",{children:[u.company.name," ",(0,n.jsxs)("span",{className:"text-xs text-ink-3",children:["(",u.company.id,")"]})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{className:"text-ink-3",children:"Agent"}),(0,n.jsxs)("dd",{children:[u.agent.name," ",(0,n.jsxs)("span",{className:"text-xs text-ink-3",children:["(",u.agent.id,")"]})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{className:"text-ink-3",children:"Permissions"}),(0,n.jsx)("dd",{children:u.permissions})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("dt",{className:"text-ink-3",children:"Access duration"}),(0,n.jsx)("dd",{children:u.accessDuration})]})]}),p&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-bad",children:p}),P.error&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-bad",children:P.error.message}),(0,n.jsx)("div",{className:"flex justify-end",children:(0,n.jsx)($,{type:"submit",disabled:!u||!/^[A-Za-z0-9_-]{32}$/.test(c.trim())||P.isPending,children:P.isPending?"Connecting…":"Connect Dot with pairing code"})})]}),k&&(0,n.jsx)(n.Fragment,{children:k.requiresSignIn?(0,n.jsx)($,{asChild:!0,children:(0,n.jsx)(Ye,{to:`/auth?next=${encodeURIComponent(D)}`,children:"Sign in / Create account"})}):(0,n.jsxs)(n.Fragment,{children:[k.requestedCompanyId?(0,n.jsxs)("div",{className:"flex items-center gap-4 rounded-md border border-line p-4",children:[I&&(0,n.jsx)(c1,{companyName:I.name,logoUrl:I.logoUrl,className:"size-14 shrink-0 rounded-lg text-xl"}),(0,n.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,n.jsx)("p",{className:"text-xs text-ink-3",children:"Organization"}),I?(0,n.jsx)("p",{className:"break-words text-lg font-semibold",children:I.name}):(0,n.jsx)("p",{className:"text-sm text-bad",children:"The selected organization is no longer available to this account. Cancel and reconnect from your assistant to choose an organization you can access."})]})]}):(0,n.jsxs)("fieldset",{className:"space-y-2",disabled:M.isPending,children:[(0,n.jsx)("legend",{className:"mb-2 text-sm font-medium",children:"Organization"}),k.companies.map(K=>(0,n.jsxs)("label",{className:"flex items-center gap-3 rounded-md border border-line p-3 text-sm",children:[(0,n.jsx)("input",{type:"radio",name:"company","aria-label":K.name,value:K.id,checked:j===K.id,onChange:i(()=>l(K.id),"onChange")}),(0,n.jsx)(c1,{companyName:K.name,logoUrl:K.logoUrl,className:"size-12 shrink-0 rounded-lg"}),(0,n.jsx)("span",{className:"min-w-0 break-words font-medium",children:K.name})]},K.id)),!k.companies.length&&(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"This account has no available organizations. Ask an organization owner to add you, then reconnect from your assistant."})]}),(0,n.jsx)("p",{className:"text-sm",children:k.agentConnection?"Connect Dot as a Wardmote agent. Pair it with an agent after connecting; assigned work uses that agent’s permissions.":"Read all of your Wardmote data"}),(k.requestedWrite||k.requestedConfigure)&&!k.agentConnection&&(0,n.jsxs)("label",{htmlFor:"mcp-allow-writes",className:"flex items-start gap-3 text-sm leading-6",children:[(0,n.jsx)("span",{className:"flex h-6 shrink-0 items-center",children:(0,n.jsx)(Ci,{id:"mcp-allow-writes",checked:_,disabled:!I?.canWrite||M.isPending,onCheckedChange:i(K=>x(K===!0),"onCheckedChange")})}),(0,n.jsx)("span",{children:"Write all of your Wardmote data"})]}),I&&!I.canWrite&&(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Your role in this organization is read-only."}),M.error&&(0,n.jsx)("p",{className:"text-sm text-bad",children:M.error.message}),(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,n.jsx)($,{variant:"secondary",disabled:M.isPending,onClick:i(()=>M.mutate("deny"),"onClick"),children:"Cancel"}),(0,n.jsx)($,{className:"h-auto min-h-10 min-w-0 shrink whitespace-normal",disabled:!I||k.agentConnection&&!I.canWrite||M.isPending,onClick:i(()=>M.mutate("approve"),"onClick"),children:M.isPending?"Connecting…":k.agentConnection?"Connect Dot agent":"Connect organization"})]})]})})]})})}i(sAt,"McpConnectRequest");function OLs(){const e=Ct(),t=ie({queryKey:["mcp-connections"],queryFn:i(()=>le.get("/mcp/connections"),"queryFn"),retry:!1}),s=t.data?.filter(a=>!a.revokedAt),r=ye({mutationFn:i(a=>le.delete(`/mcp/connections/${a}`),"mutationFn"),onSuccess:i((a,o)=>(e.setQueryData(["mcp-connections"],l=>l?.filter(c=>c.id!==o)),e.invalidateQueries({queryKey:["mcp-connections"]})),"onSuccess")});return(0,n.jsxs)("div",{className:"mx-auto max-w-xl space-y-4 py-10",children:[(0,n.jsx)("h1",{className:"text-xl font-semibold",children:"Assistant connections"}),(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"Revoking a connection stops its future tool calls. Work already delegated continues under your organization’s normal controls."}),t.isPending&&(0,n.jsx)("p",{className:"text-sm",children:"Loading connections…"}),(t.error||r.error)&&(0,n.jsx)("p",{className:"text-sm text-bad",children:(t.error??r.error)?.message}),s?.length===0&&(0,n.jsx)("p",{className:"text-sm",children:"No assistant connections."}),s?.map(a=>(0,n.jsxs)(hs,{className:"block space-y-2 p-4",children:[(0,n.jsx)("h2",{className:"font-medium",children:(0,n.jsx)(No,{name:vQ(a),avatarUrl:a.user?.image,initials:_b(a.user?.name??"You")})}),(0,n.jsxs)("p",{className:"text-sm text-ink-3",children:["Organization: ",a.companyName]}),(0,n.jsx)("p",{className:"text-sm",children:a.scopes.includes("paperclip:agent")?"Dot agent connection":a.scopes.includes("paperclip:write")?"Read and edit work":"Read only"}),a.scopes.includes("paperclip:configure")&&(0,n.jsx)("p",{className:"text-sm",children:"Configure agents, projects and skills"}),(0,n.jsx)($,{variant:"secondary",disabled:r.isPending,onClick:i(()=>r.mutate(a.id),"onClick"),children:"Revoke connection"})]},a.id)),(0,n.jsx)(Ye,{className:"text-sm underline",to:"/",children:"Back to Wardmote"})]})}i(OLs,"AssistantConnectionsPage");function FLs(){const e=Ct(),t=Mi(),[s]=Ia(),r=(t.id??"").trim(),a=(s.get("token")??"").trim(),o=(0,m.useMemo)(()=>`/cli-auth/${encodeURIComponent(r)}${a?`?token=${encodeURIComponent(a)}`:""}`,[r,a]),l=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),retry:!1}),c=ie({queryKey:["cli-auth-challenge",r,a],queryFn:i(()=>jr.getCliAuthChallenge(r,a),"queryFn"),enabled:r.length>0&&a.length>0,retry:!1}),d=ye({mutationFn:i(()=>jr.approveCliAuthChallenge(r,a),"mutationFn"),onSuccess:i(async()=>{await e.invalidateQueries({queryKey:O.auth.session}),await c.refetch()},"onSuccess")}),u=ye({mutationFn:i(()=>jr.cancelCliAuthChallenge(r,a),"mutationFn"),onSuccess:i(async()=>{await c.refetch()},"onSuccess")});if(!r||!a)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-bad",children:"Invalid CLI auth URL."});if(l.isLoading||c.isLoading)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-ink-3",children:"Loading CLI auth challenge..."});if(c.error)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"CLI auth challenge unavailable"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:c.error instanceof Error?c.error.message:"Challenge is invalid or expired."})]})});const h=c.data;return h?h.status==="approved"?(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsx)("h1",{className:"text-xl font-semibold",children:"CLI access approved"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"The Wardmote CLI can now finish authentication on the requesting machine."}),(0,n.jsxs)("p",{className:"mt-4 text-sm text-ink-3",children:["Command: ",(0,n.jsx)("span",{className:"font-mono text-ink",children:h.command})]})]})}):h.status==="cancelled"||h.status==="expired"?(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsx)("h1",{className:"text-xl font-semibold",children:h.status==="expired"?"CLI auth challenge expired":"CLI auth challenge cancelled"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"Start the CLI auth flow again from your terminal to generate a new approval request."})]})}):h.requiresSignIn||!l.data?(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsx)("h1",{className:"text-xl font-semibold",children:"Sign in required"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"Sign in or create an account, then return to this page to approve the CLI access request."}),(0,n.jsx)($,{asChild:!0,className:"mt-4",children:(0,n.jsx)(Ye,{to:`/auth?next=${encodeURIComponent(o)}`,children:"Sign in / Create account"})})]})}):(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)(hs,{className:"block p-6",children:[(0,n.jsx)("h1",{className:"text-xl font-semibold",children:"Approve Wardmote CLI access"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"A local Wardmote CLI process is requesting board access to this instance."}),(0,n.jsxs)("div",{className:"mt-5 space-y-3 text-sm",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-ink-3",children:"Command"}),(0,n.jsx)("div",{className:"font-mono text-ink",children:h.command})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-ink-3",children:"Client"}),(0,n.jsx)("div",{className:"text-ink",children:h.clientName??"wardmote cli"})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-ink-3",children:"Requested access"}),(0,n.jsx)("div",{className:"text-ink",children:h.requestedAccess==="instance_admin_required"?"Instance admin":"Board"})]}),h.requestedCompanyName&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-ink-3",children:"Requested organization"}),(0,n.jsx)("div",{className:"text-ink",children:h.requestedCompanyName})]})]}),(d.error||u.error)&&(0,n.jsx)("p",{className:"mt-4 text-sm text-bad",children:(d.error??u.error)instanceof Error?(d.error??u.error).message:"Failed to update CLI auth challenge"}),!h.canApprove&&(0,n.jsx)("p",{className:"mt-4 text-sm text-bad",children:"This challenge requires instance-admin access. Sign in with an instance admin account to approve it."}),(0,n.jsxs)("div",{className:"mt-5 flex gap-3",children:[(0,n.jsx)($,{onClick:i(()=>d.mutate(),"onClick"),disabled:!h.canApprove||d.isPending||u.isPending,children:d.isPending?"Approving...":"Approve CLI access"}),(0,n.jsx)($,{type:"button",variant:"secondary",onClick:i(()=>u.mutate(),"onClick"),disabled:d.isPending||u.isPending,children:u.isPending?"Cancelling...":"Cancel"})]})]})}):(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-bad",children:"CLI auth challenge unavailable."})}i(FLs,"CliAuthPage");var BLs=V4t.filter(e=>e!=="paperclip_runner"),fUe=new Set(["omp_local"]);function zLs(e,t){let s=e;for(const r of t){if(!s||typeof s!="object")return null;s=s[r]}return typeof s=="string"&&s.trim().length>0?s:null}i(zLs,"readNestedString");var L2="w-full border border-zinc-800 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none focus:border-zinc-500",gUe="border border-zinc-800 bg-zinc-950/95 p-6",xUe="flex-1 border px-3 py-2 text-sm transition-colors";function qLs(e){return e?e.charAt(0).toUpperCase()+e.slice(1):null}i(qLs,"formatHumanRole");function rAt(e){if(!e||typeof e!="object")return null;const t=e.code;return typeof t=="string"&&t.trim().length>0?t:null}i(rAt,"getAuthErrorCode");function ULs(e){if(!(e instanceof Error))return null;const t=e.message.trim();return t.length>0?t:null}i(ULs,"getAuthErrorMessage");function KLs(e,t,s){const r=rAt(e),a=ULs(e),o=s.trim().length>0?s.trim():"that email";return r==="USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL"?{tone:"info",message:`An account already exists for ${o}. Sign in below to continue with this invite.`}:r==="INVALID_EMAIL_OR_PASSWORD"?{tone:"error",message:"That email and password did not match an existing Wardmote account. Check both fields, or create an account first if you are new here."}:t==="sign_in"&&a==="Request failed: 401"?{tone:"error",message:"That email and password did not match an existing Wardmote account. Check both fields, or create an account first if you are new here."}:t==="sign_up"&&a==="Request failed: 422"?{tone:"info",message:`An account may already exist for ${o}. Try signing in instead.`}:{tone:"error",message:a??"Authentication failed"}}i(KLs,"mapInviteAuthFeedback");function vUe(e){return!!(e&&typeof e=="object"&&"bootstrapAccepted"in e)}i(vUe,"isBootstrapAcceptancePayload");function WLs(e,t){return!e||typeof e!="object"||t?!1:e.status==="approved"}i(WLs,"isApprovedHumanJoinPayload");function rpe({companyDisplayName:e,companyLogoUrl:t,className:s}){return(0,n.jsx)(c1,{companyName:e,logoUrl:t,logoFit:"contain",className:s})}i(rpe,"InviteCompanyLogo");function bUe({companyDisplayName:e,companyLogoUrl:t,invitedByUserName:s,claimSecret:r=null,claimApiKeyPath:a=null,onboardingTextUrl:o=null}){return(0,n.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,n.jsxs)("div",{className:"mx-auto max-w-md border border-zinc-800 bg-zinc-950 p-6","data-testid":"invite-pending-approval",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)(rpe,{companyDisplayName:e,companyLogoUrl:t,className:"h-12 w-12 border border-zinc-800 rounded-none"}),(0,n.jsxs)("h1",{className:"text-lg font-semibold",children:["Request to join ",e]})]}),(0,n.jsxs)("div",{className:"mt-4 space-y-3",children:[(0,n.jsxs)("p",{className:"text-sm text-zinc-400",children:["Your request is still awaiting approval. ",s??"An organization admin"," must approve your request to join."]}),(0,n.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,n.jsx)("p",{className:"text-xs text-zinc-500 mb-1",children:"Approval page"}),(0,n.jsx)("p",{className:"text-sm text-zinc-200",children:"Settings → Members"})]}),(0,n.jsxs)("p",{className:"text-sm text-zinc-400",children:["Ask them to visit ",(0,n.jsx)("span",{className:"text-zinc-200",children:"Settings → Members"})," to approve your request."]}),(0,n.jsx)("p",{className:"text-xs text-zinc-500",children:"Refresh this page after you've been approved — you'll be redirected automatically."})]}),r&&a?(0,n.jsxs)("div",{className:"mt-4 space-y-1 border border-zinc-800 p-3 text-xs text-zinc-400",children:[(0,n.jsx)("div",{className:"text-zinc-200",children:"Claim secret"}),(0,n.jsx)("div",{className:"font-mono break-all",children:r}),(0,n.jsxs)("div",{className:"font-mono break-all",children:["POST ",a]})]}):null,o?(0,n.jsxs)("div",{className:"mt-4 text-xs text-zinc-400",children:["Onboarding: ",(0,n.jsx)("span",{className:"font-mono break-all",children:o})]}):null]})})}i(bUe,"AwaitingJoinApprovalPanel");function QLs(){const e=Ct(),t=ir(),{setSelectedCompanyId:s}=gn(),r=(Mi().token??"").trim(),[a,o]=(0,m.useState)("sign_up"),[l,c]=(0,m.useState)(""),[d,u]=(0,m.useState)(""),[h,p]=(0,m.useState)(""),[f,g]=(0,m.useState)(""),[x,v]=(0,m.useState)("omp_local"),[b,y]=(0,m.useState)(""),[k,j]=(0,m.useState)(null),[N,S]=(0,m.useState)(null),[A,I]=(0,m.useState)(null),[_,T]=(0,m.useState)(!1),E="invite-auth-error",M=ie({queryKey:O.health,queryFn:i(()=>Op.get(),"queryFn"),retry:!1}),P=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),retry:!1}),D=ie({queryKey:O.access.invite(r),queryFn:i(()=>jr.getInvite(r),"queryFn"),enabled:r.length>0,retry:!1}),K=HUe({enabled:!!P.data&&!!D.data?.companyId,staleTime:0}),L=M.data?.deploymentMode!=="local_trusted"?K.isFetchedAfterMount:!0,B=L?K.data?.companies??[]:[];(0,m.useEffect)(()=>{r&&dUe(r)},[r]),(0,m.useEffect)(()=>{T(!1)},[r]),(0,m.useEffect)(()=>{if(!L)return;const de=K.data?.companies;!de||!D.data?.companyId||de.some(be=>be.id===D.data.companyId)&&UF(r)},[K.data,D.data,L,r]);const z=D.data,U=!!P.data&&!!z?.companyId&&!L,W=!!z?.companyId&&B.some(de=>de.id===z?.companyId),F=z?.companyName?.trim()||"this Wardmote company",Y=z?.companyLogoUrl?.trim()||null,V=z?.invitedByUserName?.trim()||null,G=z?.inviteMessage?.trim()||null,ne=qLs(z?.humanRole),Z=z?.joinRequestStatus??null,J=z?.joinRequestType??null,se=J==="human"&&(Z==="pending_approval"||Z==="approved"),H=M.data?.deploymentMode==="authenticated"&&!P.data&&z?.allowedJoinTypes!=="agent",ee=z?.inviteType!=="bootstrap_ceo"&&z?.allowedJoinTypes==="agent",te=!!P.data&&!ee&&z?.inviteType!=="bootstrap_ceo"&&(!Z||se)&&!U&&!W&&!k&&N===null,oe=P.data?.user.name?.trim()||P.data?.user.email?.trim()||"this account",ae=d.trim().length>0&&h.trim().length>0&&(a==="sign_in"||l.trim().length>0&&h.trim().length>=8),ge=ye({mutationFn:i(async()=>{if(!z)throw new Error("Invite not found");if(U)throw new Error("Checking your organization access. Try again in a moment.");if(W)throw new Error("This account already belongs to the organization.");return z.inviteType==="bootstrap_ceo"||z.allowedJoinTypes!=="agent"?jr.acceptInvite(r,{requestType:"human"}):jr.acceptInvite(r,{requestType:"agent",agentName:f.trim(),adapterType:x,capabilities:b.trim()||null})},"mutationFn"),onSuccess:i(async de=>{S(null),UF(r);const be=vUe(de);j({kind:be?"bootstrap":"join",payload:de}),await e.invalidateQueries({queryKey:O.auth.session}),await e.invalidateQueries({queryKey:O.access.currentBoardAccess}),await e.invalidateQueries({queryKey:O.companies.all}),z?.companyId&&WLs(de,ee)&&(s(z.companyId,{source:"manual"}),t("/",{replace:!0}))},"onSuccess"),onError:i(de=>{S(de instanceof Error?de.message:"Failed to accept invite")},"onError")});(0,m.useEffect)(()=>{!te||_||ge.isPending||(T(!0),S(null),ge.mutate())},[ge,_,te]);const xe=ye({mutationFn:i(async()=>{if(a==="sign_in"){await Ji.signInEmail({email:d.trim(),password:h});return}await Ji.signUpEmail({name:l.trim(),email:d.trim(),password:h})},"mutationFn"),onSuccess:i(async()=>{I(null),dUe(r),await e.invalidateQueries({queryKey:O.auth.session}),await e.invalidateQueries({queryKey:O.health}),await e.invalidateQueries({queryKey:O.access.currentBoardAccess});const{companies:de}=await lEt(e);if(z?.companyId&&de.some(be=>be.id===z.companyId)){UF(r),s(z.companyId,{source:"manual"}),t("/",{replace:!0});return}if(!(!z||z.inviteType!=="bootstrap_ceo"))try{vUe(await ge.mutateAsync())&&t("/",{replace:!0})}catch{return}},"onSuccess"),onError:i(de=>{const be=KLs(de,a,d);rAt(de)==="USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL"&&(o("sign_in"),p("")),I(be)},"onError")}),ce=(0,m.useMemo)(()=>z?W?"Open organization":z.inviteType==="bootstrap_ceo"?"Accept invite":ee?"Submit request":P.data?"Accept invite":"Continue":"Continue",[z,W,P.data,ee]);if(!r)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-bad",children:"Invalid invite token."});if(D.isLoading||M.isLoading||P.isLoading)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-ink-3",children:"Loading invite..."});if(U)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-ink-3",children:"Checking your access..."});if(D.error||!z)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)("div",{className:"border border-line bg-bg-2 p-6","data-testid":"invite-error",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Invite not available"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:"This invite may be expired, revoked, or already used."})]})});if(Z==="approved"&&J==="human"&&W)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10 text-sm text-ink-3",children:"Opening organization..."});if(Z==="pending_approval"&&!se)return(0,n.jsx)(bUe,{companyDisplayName:F,companyLogoUrl:Y,invitedByUserName:V});if(Z&&!se)return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)("div",{className:"border border-line bg-bg-2 p-6","data-testid":"invite-error",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Invite not available"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:Z==="rejected"?"This join request was not approved.":"This invite has already been used."})]})});if(k?.kind==="bootstrap")return(0,n.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,n.jsxs)("div",{className:"mx-auto max-w-md border border-zinc-800 bg-zinc-950 p-6",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Bootstrap complete"}),(0,n.jsx)("div",{className:"mt-4",children:(0,n.jsx)($,{asChild:!0,className:"rounded-none",children:(0,n.jsx)(Ye,{to:"/",children:"Open board"})})})]})});if(k?.kind==="join"){const de=k.payload,be=typeof de.claimSecret=="string"?de.claimSecret:null,me=typeof de.claimApiKeyPath=="string"?de.claimApiKeyPath:null,we=zLs(de.onboarding,["textInstructions","url"]);return!ee&&de.status==="approved"?(0,n.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,n.jsxs)("div",{className:"mx-auto max-w-md border border-zinc-800 bg-zinc-950 p-6",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)(rpe,{companyDisplayName:F,companyLogoUrl:Y,className:"h-12 w-12 border border-zinc-800 rounded-none"}),(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"You joined the organization"})]}),(0,n.jsx)("div",{className:"mt-4",children:(0,n.jsx)($,{asChild:!0,className:"w-full rounded-none",children:(0,n.jsx)(Ye,{to:"/",children:"Open board"})})})]})}):(0,n.jsx)(bUe,{companyDisplayName:F,companyLogoUrl:Y,invitedByUserName:V,claimSecret:be,claimApiKeyPath:me,onboardingTextUrl:we})}return(0,n.jsx)("div",{className:"min-h-screen bg-zinc-950 px-6 py-12 text-zinc-100",children:(0,n.jsx)("div",{className:"mx-auto max-w-5xl",children:(0,n.jsxs)("div",{className:"grid gap-6 lg:grid-cols-(--gtc-36)",children:[(0,n.jsxs)("section",{className:`${gUe} space-y-6`,children:[(0,n.jsxs)("div",{className:"flex items-start gap-4",children:[(0,n.jsx)(rpe,{companyDisplayName:F,companyLogoUrl:Y,className:"h-16 w-16 rounded-none border border-zinc-800"}),(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("p",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"You've been invited to join Wardmote"}),(0,n.jsx)("h1",{className:"mt-2 text-2xl font-semibold",children:z.inviteType==="bootstrap_ceo"?"Set up Wardmote":`Join ${F}`}),(0,n.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-zinc-300",children:ee?"Review the invite details, then submit the agent information below to start the join request.":H?"Create your Wardmote account first. If you already have one, switch to sign in and continue the invite with the same email.":"Your account is ready. Review the invite details, then accept it to continue."})]})]}),(0,n.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,n.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,n.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Organization"}),(0,n.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:F})]}),(0,n.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,n.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Invited by"}),(0,n.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:V??"Wardmote board"})]}),(0,n.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,n.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Requested access"}),(0,n.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:ee?"Agent join request":ne??"Organization access"})]}),(0,n.jsxs)("div",{className:"border border-zinc-800 p-3",children:[(0,n.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-zinc-500",children:"Invite expires"}),(0,n.jsx)("div",{className:"mt-1 text-sm text-zinc-100",children:Zh(z.expiresAt)})]})]}),G?(0,n.jsxs)("div",{className:"border border-amber-500/40 bg-amber-500/10 p-4",children:[(0,n.jsx)("div",{className:"text-xs uppercase tracking-(--tracking-caps) text-amber-200/80",children:"Message from inviter"}),(0,n.jsx)("p",{className:"mt-2 text-sm leading-6 text-amber-50",children:G})]}):null,P.data?(0,n.jsxs)("div",{className:"border border-emerald-500/40 bg-emerald-500/10 p-4 text-sm text-emerald-50",children:["Signed in as ",(0,n.jsx)("span",{className:"font-medium",children:oe}),"."]}):null]}),(0,n.jsx)("section",{className:`${gUe} h-fit`,children:ee?(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"text-lg font-semibold",children:"Submit agent details"}),(0,n.jsxs)("p",{className:"mt-1 text-sm text-zinc-400",children:["This invite will create an approval request for a new agent in ",F,"."]})]}),(0,n.jsxs)("label",{className:"block text-sm",children:[(0,n.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Agent name"}),(0,n.jsx)("input",{className:L2,value:f,onChange:i(de=>g(de.target.value),"onChange")})]}),(0,n.jsxs)("label",{className:"block text-sm",children:[(0,n.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Adapter type"}),(0,n.jsx)("select",{className:L2,value:x,onChange:i(de=>v(de.target.value),"onChange"),children:BLs.map(de=>(0,n.jsxs)("option",{value:de,disabled:!fUe.has(de),children:[mb(de),fUe.has(de)?"":" (Coming soon)"]},de))})]}),(0,n.jsxs)("label",{className:"block text-sm",children:[(0,n.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Capabilities"}),(0,n.jsx)("textarea",{className:L2,rows:4,value:b,onChange:i(de=>y(de.target.value),"onChange")})]}),N?(0,n.jsx)("p",{className:"text-xs text-red-400",children:N}):null,(0,n.jsx)($,{className:"w-full rounded-none",disabled:ge.isPending||f.trim().length===0,onClick:i(()=>ge.mutate(),"onClick"),children:ge.isPending?"Working...":ce})]}):H?(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"text-lg font-semibold",children:a==="sign_up"?"Create your account":"Sign in to continue"}),(0,n.jsx)("p",{className:"mt-1 text-sm text-zinc-400",children:a==="sign_up"?`Start with a Wardmote account. After that, you'll come right back here to accept the invite for ${F}.`:"Use the Wardmote account that already matches this invite. If you do not have one yet, switch back to create account."})]}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)("button",{type:"button",className:`${xUe} ${a==="sign_up"?"border-zinc-100 bg-zinc-100 text-zinc-950":"border-zinc-800 text-zinc-300 hover:border-zinc-600"}`,onClick:i(()=>{I(null),o("sign_up")},"onClick"),children:"Create account"}),(0,n.jsx)("button",{type:"button",className:`${xUe} ${a==="sign_in"?"border-zinc-100 bg-zinc-100 text-zinc-950":"border-zinc-800 text-zinc-300 hover:border-zinc-600"}`,onClick:i(()=>{I(null),o("sign_in")},"onClick"),children:"I already have an account"})]}),(0,n.jsxs)("form",{className:"space-y-4",method:"post",action:a==="sign_up"?"/api/auth/sign-up/email":"/api/auth/sign-in/email",onSubmit:i(de=>{if(de.preventDefault(),!xe.isPending){if(!ae){I({tone:"error",message:"Please fill in all required fields."});return}xe.mutate()}},"onSubmit"),"data-testid":"invite-inline-auth",children:[a==="sign_up"?(0,n.jsxs)("label",{className:"block text-sm",htmlFor:"invite-name",children:[(0,n.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Name"}),(0,n.jsx)("input",{id:"invite-name",name:"name",className:L2,value:l,onChange:i(de=>{c(de.target.value),I(null)},"onChange"),autoComplete:"name",required:!0,"aria-required":"true","aria-invalid":A?.tone==="error"?!0:void 0,"aria-describedby":A?E:void 0,autoFocus:!0})]}):null,(0,n.jsxs)("label",{className:"block text-sm",htmlFor:"invite-email",children:[(0,n.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Email"}),(0,n.jsx)("input",{id:"invite-email",name:"email",type:"email",className:L2,value:d,onChange:i(de=>{u(de.target.value),I(null)},"onChange"),autoComplete:"username",required:!0,"aria-required":"true","aria-invalid":A?.tone==="error"?!0:void 0,"aria-describedby":A?E:void 0,autoFocus:a==="sign_in"})]}),(0,n.jsxs)("label",{className:"block text-sm",htmlFor:"invite-password",children:[(0,n.jsx)("span",{className:"mb-1 block text-zinc-400",children:"Password"}),(0,n.jsx)("input",{id:"invite-password",name:"password",type:"password",className:L2,value:h,onChange:i(de=>{p(de.target.value),I(null)},"onChange"),autoComplete:a==="sign_in"?"current-password":"new-password",required:!0,"aria-required":"true","aria-invalid":A?.tone==="error"?!0:void 0,"aria-describedby":A?E:void 0})]}),A?(0,n.jsx)("p",{id:E,role:"alert",className:`text-xs ${A.tone==="info"?"text-amber-300":"text-red-400"}`,children:A.message}):null,(0,n.jsx)($,{type:"submit",className:"w-full rounded-none",disabled:xe.isPending,"aria-disabled":!ae||xe.isPending,children:xe.isPending?"Working...":a==="sign_in"?"Sign in and continue":"Create account and continue"})]}),(0,n.jsx)("p",{className:"text-xs leading-5 text-zinc-500",children:a==="sign_up"?"Already signed up before? Use the existing-account option instead so the invite lands on the right Wardmote user.":"No account yet? Switch back to create account so you can accept the invite with a new login."})]}):(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"text-lg font-semibold",children:W?"Already in this organization":te?"Completing organization access":z.inviteType==="bootstrap_ceo"?"Accept bootstrap invite":"Accept organization invite"}),(0,n.jsx)("p",{className:"mt-1 text-sm text-zinc-400",children:te?`Granting your access to ${F}.`:W?`This account already belongs to ${F}.`:`This will ${z.inviteType==="bootstrap_ceo"?"finish setting up Wardmote":`grant or complete your access to ${F}`}.`})]}),N?(0,n.jsx)("p",{className:"text-xs text-red-400",children:N}):null,te?(0,n.jsx)("div",{className:"text-sm text-zinc-400",children:ge.isPending?"Submitting request...":"Finishing sign-in..."}):(0,n.jsx)($,{className:"w-full rounded-none",disabled:ge.isPending,onClick:i(()=>{if(W&&z.companyId){UF(r),s(z.companyId,{source:"manual"}),t("/",{replace:!0});return}ge.mutate()},"onClick"),children:ge.isPending?"Working...":ce})]})})]})})})}i(QLs,"InviteLandingPage");var VLs=15e3,HLs={parent:"Parent task",child:"Sub-task",blocked_by:"Blocked by",blocks:"Blocks"};function GLs(){(0,m.useEffect)(()=>{const e=document.createElement("meta");return e.name="robots",e.content="noindex",document.head.appendChild(e),()=>e.remove()},[])}i(GLs,"useNoIndexMeta");function ipe(e,t){const s=`/s/${encodeURIComponent(e)}`;return t?`${s}/issues/${encodeURIComponent(t)}`:s}i(ipe,"sharePath");var YLs=/^(?:https?:\/\/[^/]+)?\/api\/attachments\/([^/?#]+)\/content(?:[?#].*)?$/i;function JLs(e,t){const s=YLs.exec(t.trim());return s?`/api/public/share/${encodeURIComponent(e)}/attachments/${s[1]}/content`:null}i(JLs,"publicShareImageSrc");function tR({title:e,children:t}){return(0,n.jsxs)("section",{className:"space-y-3",children:[(0,n.jsx)("h2",{className:"text-sm font-semibold text-ink-3",children:e}),t]})}i(tR,"Section");function ape({actor:e}){return(0,n.jsx)(No,{name:e.name,avatarUrl:e.iconUrl,size:"sm"})}i(ape,"ActorIdentity");function ope({value:e}){return(0,n.jsx)("time",{dateTime:e,title:Sr(e),className:"text-xs text-ink-3",children:Nr(e)})}i(ope,"Timestamp");function ZLs({agentName:e}){return(0,n.jsxs)("span",{"data-testid":"public-share-run-pill",className:"inline-flex items-center gap-1.5 rounded-full border border-line px-3 py-1 text-xs text-ink",children:[(0,n.jsx)("span",{className:"h-2 w-2 animate-pulse rounded-full bg-(--status-agent-running)","aria-hidden":!0}),e," is working…"]})}i(ZLs,"ActiveRunPill");function iAt({attachments:e}){return(0,n.jsx)(Ffe,{children:e.map(t=>{const s=Zet({name:t.filename,url:t.url,contentType:t.contentType,byteSize:t.byteSize}),r=s.icon,a=Bfe(t.byteSize);return(0,n.jsxs)(Lfe,{size:"sm",children:[(0,n.jsx)(Dfe,{children:(0,n.jsx)(r,{"aria-hidden":!0})}),(0,n.jsxs)(Pfe,{children:[(0,n.jsx)($fe,{className:"max-w-48",children:t.filename}),(0,n.jsx)(Ofe,{className:"max-w-48",children:a?`${s.label} · ${a}`:s.label})]}),(0,n.jsx)(Het,{"aria-label":`Download ${t.filename}`,render:(0,n.jsx)("a",{href:t.url,download:t.filename,rel:"noreferrer"})})]},t.id)})})}i(iAt,"AttachmentList");function XLs({related:e,token:t,isSharedRoot:s}){const r=e.identifier?`${e.identifier} · ${e.title}`:e.title,a=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(_a,{status:e.status,size:"sm"}),(0,n.jsx)("span",{className:"min-w-0 truncate",children:r})]});return(0,n.jsxs)("li",{className:"flex items-center gap-2 text-sm",children:[(0,n.jsx)("span",{className:"w-20 shrink-0 text-xs text-ink-3",children:HLs[e.relation]}),e.navigable?(0,n.jsx)(Nh,{to:s?ipe(t,e.id):ipe(t),className:"flex min-w-0 items-center gap-2 text-ink underline-offset-2 hover:underline",children:a}):(0,n.jsx)("span",{className:"flex min-w-0 items-center gap-2 text-ink-3",children:a})]})}i(XLs,"RelatedIssueRow");function e8s({comment:e,resolveImageSrc:t}){return e.kind==="redacted"?(0,n.jsxs)("li",{"data-testid":"public-share-redacted-comment",className:"flex flex-wrap items-center gap-2 rounded-lg border border-dashed border-line px-3 py-2",children:[(0,n.jsx)(ape,{actor:e.author}),(0,n.jsx)(ope,{value:e.createdAt}),(0,n.jsx)("span",{className:"text-xs italic text-ink-3",children:"Internal update"})]}):(0,n.jsxs)("li",{className:"space-y-2 rounded-lg border border-line bg-bg-2 px-3 py-3",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)(ape,{actor:e.author}),(0,n.jsx)(ope,{value:e.createdAt})]}),(0,n.jsx)(_s,{className:"text-sm",softBreaks:!0,linkIssueReferences:!1,resolveImageSrc:t,children:e.body}),e.attachments.length>0?(0,n.jsx)(iAt,{attachments:e.attachments}):null]})}i(e8s,"TimelineEntry");function t8s({document:e,resolveImageSrc:t}){return(0,n.jsxs)("details",{className:"group rounded-lg border border-line bg-bg-2",children:[(0,n.jsxs)("summary",{className:"flex cursor-pointer items-center gap-2 px-3 py-2 text-sm",children:[(0,n.jsx)(ia,{className:"h-4 w-4 shrink-0 text-ink-3","aria-hidden":!0}),(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:e.title??e.key}),(0,n.jsx)(ope,{value:e.updatedAt})]}),(0,n.jsxs)("div",{className:"space-y-3 border-t border-line px-3 py-3",children:[(0,n.jsxs)("a",{href:e.pdfUrl,download:!0,rel:"noreferrer",className:"inline-flex items-center gap-1.5 text-xs text-ink-3 hover:text-ink",children:[(0,n.jsx)(xo,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Download PDF"]}),(0,n.jsx)(_s,{className:"text-sm",linkIssueReferences:!1,resolveImageSrc:t,children:e.body})]})]})}i(t8s,"DocumentCard");function n8s({product:e}){return(0,n.jsxs)("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg border border-line bg-bg-2 px-3 py-2 text-sm",children:[(0,n.jsx)("span",{className:"min-w-0 flex-1 truncate font-medium",children:e.title}),(0,n.jsxs)("span",{className:"text-xs text-ink-3",children:[e.type.replace(/_/g," ")," · ",e.status.replace(/_/g," ")]}),e.url?(0,n.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-ink-3 hover:text-ink",children:[(0,n.jsx)(Us,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Open"]}):null,e.downloadUrl?(0,n.jsxs)("a",{href:e.downloadUrl,download:!0,rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-ink-3 hover:text-ink",children:[(0,n.jsx)(xo,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Download"]}):null]})}i(n8s,"WorkProductRow");function yUe({title:e,body:t,action:s}){return(0,n.jsx)("div",{className:"flex h-dvh overflow-y-auto bg-bg px-4 text-ink",children:(0,n.jsxs)("div",{className:"m-auto w-full max-w-sm space-y-2 rounded-lg border border-line bg-bg-2 p-6 text-center",children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:e}),(0,n.jsx)("p",{className:"text-sm text-ink-3",children:t}),s]})})}i(yUe,"CenteredNotice");function s8s({view:e,token:t}){const{company:s,issue:r}=e,a=(0,m.useCallback)(o=>JLs(t,o),[t]);return(0,n.jsxs)("div",{className:"h-dvh overflow-y-auto bg-bg text-ink",children:[(0,n.jsx)("header",{className:"border-b border-line",children:(0,n.jsxs)("div",{className:"mx-auto flex max-w-3xl items-center gap-3 px-4 py-3",children:[(0,n.jsx)(c1,{companyName:s.name,logoUrl:s.logoUrl,logoFit:"contain",className:"h-8 w-8 shrink-0 rounded-md"}),(0,n.jsx)("span",{className:"min-w-0 truncate text-sm font-medium",children:s.name}),(0,n.jsx)("span",{className:"ml-auto shrink-0 text-xs text-ink-3",children:"Read-only view"})]})}),(0,n.jsxs)("main",{className:"mx-auto max-w-3xl space-y-8 px-4 py-5",children:[e.isSharedRoot?null:(0,n.jsxs)(Nh,{to:ipe(t),className:"inline-flex items-center gap-1.5 text-sm text-ink-3 hover:text-ink",children:[(0,n.jsx)(cc,{className:"h-4 w-4","aria-hidden":!0}),"Back to main task"]}),(0,n.jsxs)("section",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 text-xs text-ink-3",children:[r.identifier?(0,n.jsx)("span",{children:r.identifier}):null,r.projectName?(0,n.jsx)("span",{children:r.projectName}):null]}),(0,n.jsx)("h1",{className:"break-words text-xl font-semibold",children:r.title}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,n.jsx)(Rg,{status:r.status}),(0,n.jsx)(wvt,{priority:r.priority,showLabel:!0}),r.assignee?(0,n.jsx)(ape,{actor:r.assignee}):null,e.activeRun?(0,n.jsx)(ZLs,{agentName:e.activeRun.agentName}):null]}),(0,n.jsxs)("p",{className:"text-xs text-ink-3",children:["Created ",Sr(r.createdAt)," · Updated ",Nr(r.updatedAt),r.completedAt?` · Completed ${Sr(r.completedAt)}`:""]})]}),r.description?(0,n.jsx)(_s,{className:"text-sm",softBreaks:!0,linkIssueReferences:!1,resolveImageSrc:a,children:r.description}):null,e.related.length>0?(0,n.jsx)(tR,{title:"Related tasks",children:(0,n.jsx)("ul",{className:"space-y-2",children:e.related.map(o=>(0,n.jsx)(XLs,{related:o,token:t,isSharedRoot:e.isSharedRoot},`${o.relation}:${o.id}`))})}):null,e.documents.length>0?(0,n.jsx)(tR,{title:"Documents",children:(0,n.jsx)("div",{className:"space-y-2",children:e.documents.map(o=>(0,n.jsx)(t8s,{document:o,resolveImageSrc:a},o.key))})}):null,e.attachments.length>0?(0,n.jsx)(tR,{title:"Attachments",children:(0,n.jsx)(iAt,{attachments:e.attachments})}):null,e.workProducts.length>0?(0,n.jsx)(tR,{title:"Work products",children:(0,n.jsx)("ul",{className:"space-y-2",children:e.workProducts.map(o=>(0,n.jsx)(n8s,{product:o},o.id))})}):null,(0,n.jsx)(tR,{title:"Activity",children:e.comments.length>0?(0,n.jsx)("ol",{className:"space-y-3",children:e.comments.map(o=>(0,n.jsx)(e8s,{comment:o,resolveImageSrc:a},o.id))}):(0,n.jsx)("p",{className:"text-sm text-ink-3",children:"No updates yet."})})]})]})}i(s8s,"PublicIssueShareContent");function kUe(){const{token:e="",issueId:t}=Mi();GLs();const s=y6t.test(e),r=ie({queryKey:O.publicShare.view(e,t??null),queryFn:i(()=>t?jA.getPublicShareIssue(e,t):jA.getPublicShare(e),"queryFn"),enabled:s,retry:!1,refetchOnWindowFocus:!0,refetchInterval:i(a=>a.state.data?.activeRun?VLs:!1,"refetchInterval")});return!s||r.data===null?(0,n.jsx)(yUe,{title:"This link is not available",body:"It may have been revoked, or the address is incomplete."}):r.data?(0,n.jsx)(s8s,{view:r.data,token:e}):r.isError?(0,n.jsx)(yUe,{title:"Couldn't load this page",body:"Check your connection and try again.",action:(0,n.jsx)($,{variant:"secondary",size:"sm",className:"mt-2",onClick:i(()=>{r.refetch()},"onClick"),children:"Try again"})}):(0,n.jsx)("div",{className:"h-dvh overflow-y-auto px-4 py-6","aria-busy":"true",children:(0,n.jsxs)("div",{className:"mx-auto max-w-3xl space-y-4",children:[(0,n.jsx)(wn,{className:"h-6 w-1/2"}),(0,n.jsx)(wn,{className:"h-4 w-1/3"}),(0,n.jsx)(wn,{className:"h-24 w-full"})]})})}i(kUe,"PublicIssueSharePage");function r8s(){const{selectedCompany:e,selectedCompanyId:t}=gn(),{setBreadcrumbs:s}=Hs(),{pushToast:r}=Qa(),a=Ct(),[o,l]=(0,m.useState)("pending_approval"),[c,d]=(0,m.useState)("all");(0,m.useEffect)(()=>{s([{label:e?.name??"Organization",href:"/dashboard"},{label:"Inbox",href:"/inbox"},{label:"Join Requests"}])},[e?.name,s]);const u=ie({queryKey:O.access.joinRequests(t??"",`${o}:${c}`),queryFn:i(()=>jr.listJoinRequests(t,o,c==="all"?void 0:c),"queryFn"),enabled:!!t}),h=ye({mutationFn:i(f=>jr.approveJoinRequest(t,f),"mutationFn"),onSuccess:i(async()=>{await a.invalidateQueries({queryKey:O.access.joinRequests(t,`${o}:${c}`)}),await a.invalidateQueries({queryKey:O.access.companyMembers(t)}),await a.invalidateQueries({queryKey:O.access.companyUserDirectory(t)}),r({title:"Join request approved",tone:"success"})},"onSuccess")}),p=ye({mutationFn:i(f=>jr.rejectJoinRequest(t,f),"mutationFn"),onSuccess:i(async()=>{await a.invalidateQueries({queryKey:O.access.joinRequests(t,`${o}:${c}`)}),r({title:"Join request rejected",tone:"success"})},"onSuccess")});if(!t)return(0,n.jsx)("div",{className:"text-sm text-ink-3",children:"Select an organization to review join requests."});if(u.isLoading)return(0,n.jsx)("div",{className:"text-sm text-ink-3",children:"Loading join requests…"});if(u.error){const f=u.error instanceof ss&&u.error.status===403?"You do not have permission to review join requests for this organization.":u.error instanceof Error?u.error.message:"Failed to load join requests.";return(0,n.jsx)("div",{className:"text-sm text-bad",children:f})}return(0,n.jsxs)("div",{className:"max-w-6xl space-y-6",children:[(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(_Pt,{className:"h-5 w-5 text-ink-3"}),(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Join Request Queue"})]}),(0,n.jsx)("p",{className:"max-w-3xl text-sm text-ink-3",children:"Review human and agent join requests outside the mixed inbox feed. This queue uses the same approval mutations as the inline inbox cards."})]}),(0,n.jsxs)(hs,{className:"flex-row flex-wrap gap-3 p-4",children:[(0,n.jsxs)("label",{className:"space-y-2 text-sm",children:[(0,n.jsx)("span",{className:"font-medium",children:"Status"}),(0,n.jsxs)("select",{className:"rounded-md border border-line bg-bg px-3 py-2",value:o,onChange:i(f=>l(f.target.value),"onChange"),children:[(0,n.jsx)("option",{value:"pending_approval",children:"Pending approval"}),(0,n.jsx)("option",{value:"approved",children:"Approved"}),(0,n.jsx)("option",{value:"rejected",children:"Rejected"})]})]}),(0,n.jsxs)("label",{className:"space-y-2 text-sm",children:[(0,n.jsx)("span",{className:"font-medium",children:"Request type"}),(0,n.jsxs)("select",{className:"rounded-md border border-line bg-bg px-3 py-2",value:c,onChange:i(f=>d(f.target.value),"onChange"),children:[(0,n.jsx)("option",{value:"all",children:"All"}),(0,n.jsx)("option",{value:"human",children:"Human"}),(0,n.jsx)("option",{value:"agent",children:"Agent"})]})]})]}),(0,n.jsx)("div",{className:"space-y-4",children:(u.data??[]).length===0?(0,n.jsx)("div",{className:"rounded-xl border border-dashed border-line px-4 py-8 text-sm text-ink-3",children:"No join requests match the current filters."}):u.data.map(f=>(0,n.jsxs)(hs,{className:"block p-4",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)(lt,{variant:f.status==="pending_approval"?"secondary":f.status==="approved"?"outline":"destructive",children:f.status.replace("_"," ")}),(0,n.jsx)(lt,{variant:"outline",children:f.requestType}),f.adapterType?(0,n.jsx)(lt,{variant:"outline",children:f.adapterType}):null]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"text-base font-medium",children:f.requestType==="human"?f.requesterUser?.name||f.requestEmailSnapshot||f.requestingUserId||"Unknown human requester":f.agentName||"Unknown agent requester"}),(0,n.jsx)("div",{className:"text-sm text-ink-3",children:f.requestType==="human"?f.requesterUser?.email||f.requestEmailSnapshot||f.requestingUserId:f.capabilities||f.requestIp})]})]}),f.status==="pending_approval"?(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)($,{variant:"secondary",onClick:i(()=>p.mutate(f.id),"onClick"),disabled:p.isPending,children:"Reject"}),(0,n.jsx)($,{onClick:i(()=>h.mutate(f.id),"onClick"),disabled:h.isPending,children:"Approve"})]}):null]}),(0,n.jsxs)("div",{className:"mt-4 grid gap-3 text-sm text-ink-3 md:grid-cols-2",children:[(0,n.jsxs)("div",{className:"rounded-lg border border-line bg-bg px-3 py-2",children:[(0,n.jsx)("div",{className:"text-xs font-medium uppercase tracking-wide",children:"Invite context"}),(0,n.jsx)("div",{className:"mt-2",children:f.invite?`${f.invite.allowedJoinTypes} join invite${f.invite.humanRole?` • default role ${f.invite.humanRole}`:""}`:"Invite metadata unavailable"}),f.invite?.inviteMessage?(0,n.jsx)("div",{className:"mt-2 text-ink",children:f.invite.inviteMessage}):null]}),(0,n.jsxs)("div",{className:"rounded-lg border border-line bg-bg px-3 py-2",children:[(0,n.jsx)("div",{className:"text-xs font-medium uppercase tracking-wide",children:"Request details"}),(0,n.jsxs)("div",{className:"mt-2",children:["Submitted ",new Date(f.createdAt).toLocaleString()]}),(0,n.jsxs)("div",{children:["Source IP ",f.requestIp]}),f.requestType==="agent"&&f.capabilities?(0,n.jsx)("div",{children:f.capabilities}):null]})]})]},f.id))})]})}i(r8s,"JoinRequestQueue");var i8s=(0,m.lazy)(()=>ln(()=>import("./CompanyExport-nSZ6c22o.js").then(e=>({default:e.CompanyExport})),__vite__mapDeps([53,5,54,55,35]))),a8s=(0,m.lazy)(()=>ln(()=>import("./Terminal-BUKNL-hS.js").then(e=>({default:e.Terminal})),__vite__mapDeps([56,5,54,55,35])));function o8s({children:e}){return(0,n.jsx)(m.Suspense,{fallback:(0,n.jsx)(bx,{}),children:e})}i(o8s,"ProductionSurface");function l8s(e){const t=e;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ot,{index:!0,element:(0,n.jsx)(Ss,{to:"dashboard",replace:!0})}),(0,n.jsx)(ot,{path:"dashboard",element:(0,n.jsx)(NWn,{})}),(0,n.jsx)(ot,{path:"dashboard/live",element:(0,n.jsx)(CWn,{})}),(0,n.jsx)(ot,{path:"timeline",element:(0,n.jsx)(tv,{to:"/activity/timeline"})}),(0,n.jsx)(ot,{path:"onboarding",element:(0,n.jsx)(lAt,{})}),(0,n.jsx)(ot,{path:"companies",element:(0,n.jsx)(SWn,{})}),(0,n.jsx)(ot,{path:"company/settings",element:(0,n.jsx)(YNs,{})}),(0,n.jsx)(ot,{path:"company/settings/connections",element:(0,n.jsx)(XNs,{})}),(0,n.jsx)(ot,{path:"company/settings/agent-defaults",element:(0,n.jsx)(UMs,{})}),(0,n.jsx)(ot,{path:"company/settings/agent-defaults/all",element:(0,n.jsx)(yHn,{})}),(0,n.jsx)(ot,{path:"company/settings/models",element:(0,n.jsx)(KMs,{})}),(0,n.jsx)(ot,{path:"company/settings/environments",element:(0,n.jsx)(Ss,{to:"/company/settings/instance/environments",replace:!0})}),(0,n.jsx)(ot,{path:"company/settings/cloud-upstream",element:(0,n.jsx)(Ss,{to:"/company/export",replace:!0})}),(0,n.jsxs)(ot,{element:(0,n.jsx)(jg,{pageKey:"company.members"}),children:[(0,n.jsx)(ot,{path:"company/settings/members",element:(0,n.jsx)(qCs,{})}),(0,n.jsx)(ot,{path:"company/settings/access",element:(0,n.jsx)(UCs,{})})]}),(0,n.jsx)(ot,{element:(0,n.jsx)(jg,{pageKey:"company.invites"}),children:(0,n.jsx)(ot,{path:"company/settings/invites",element:(0,n.jsx)(Ss,{to:"/company/settings/members?tab=invites",replace:!0})})}),(0,n.jsx)(ot,{element:(0,n.jsx)(jg,{pageKey:"company.export"}),children:(0,n.jsx)(ot,{path:"company/export/*",element:(0,n.jsx)(m.Suspense,{fallback:(0,n.jsx)(bx,{}),children:(0,n.jsx)(i8s,{})})})}),(0,n.jsx)(ot,{element:(0,n.jsx)(sMn,{}),children:(0,n.jsx)(ot,{element:(0,n.jsx)(jg,{pageKey:"company.import"}),children:(0,n.jsx)(ot,{path:"company/import",element:(0,n.jsx)(F6s,{})})})}),(0,n.jsx)(ot,{element:(0,n.jsx)(jg,{pageKey:"company.secrets"}),children:(0,n.jsx)(ot,{path:"company/settings/secrets",element:(0,n.jsx)(DRs,{})})}),(0,n.jsx)(ot,{path:"company/settings/tools",element:(0,n.jsx)(NUe,{})}),(0,n.jsx)(ot,{path:"company/settings/tools/:tab",element:(0,n.jsx)(NUe,{})}),(0,n.jsx)(ot,{path:"tools",element:(0,n.jsx)(CUe,{})}),(0,n.jsx)(ot,{path:"tools/:tab",element:(0,n.jsx)(CUe,{})}),(0,n.jsx)(ot,{path:"apps",element:(0,n.jsx)(BSs,{})}),(0,n.jsx)(ot,{path:"apps/assistant-connection",element:(0,n.jsx)(kSs,{})}),(0,n.jsx)(ot,{path:"apps/browse",element:(0,n.jsx)(Ss,{to:"/apps",replace:!0})}),(0,n.jsx)(ot,{path:"apps/connections",element:(0,n.jsx)(Ss,{to:"/apps",replace:!0})}),(0,n.jsx)(ot,{path:"apps/byo",element:(0,n.jsx)(p2t,{byoOnly:!0})}),(0,n.jsx)(ot,{path:"apps/vercel-connect",element:(0,n.jsx)(wUe,{credentialSource:"vercel_connect"})}),(0,n.jsx)(ot,{path:"apps/connect",element:(0,n.jsx)(wUe,{})}),(0,n.jsx)(ot,{path:"apps/chat/connect",element:(0,n.jsx)(NF,{children:(0,n.jsx)(b_s,{})})}),(0,n.jsx)(ot,{path:"apps/chat/:endpointId",element:(0,n.jsx)(NF,{children:(0,n.jsx)(Ss,{to:"settings",replace:!0})})}),(0,n.jsx)(ot,{path:"apps/chat/:endpointId/reviews/:reviewId",element:(0,n.jsx)(NF,{children:(0,n.jsx)(aze,{})})}),(0,n.jsx)(ot,{path:"apps/chat/:endpointId/:tab",element:(0,n.jsx)(NF,{children:(0,n.jsx)(aze,{})})}),(0,n.jsx)(ot,{path:"apps/connect/:appKey",element:(0,n.jsx)(Ss,{to:"/apps",replace:!0})}),(0,n.jsx)(ot,{path:"apps/connect/:appKey/:stage",element:(0,n.jsx)(Ss,{to:"/apps",replace:!0})}),(0,n.jsx)(ot,{path:"apps/review",element:(0,n.jsx)(x5s,{})}),(0,n.jsx)(ot,{path:"apps/attention",element:(0,n.jsx)(Ss,{to:"/apps",replace:!0})}),(0,n.jsx)(ot,{path:"apps/gateways",element:(0,n.jsx)(wze,{})}),(0,n.jsx)(ot,{path:"apps/gateways/:gatewayId",element:(0,n.jsx)(Ss,{to:"overview",replace:!0})}),(0,n.jsx)(ot,{path:"apps/gateways/:gatewayId/:tab",element:(0,n.jsx)(VAs,{})}),(0,n.jsx)(ot,{path:"apps/advanced",element:(0,n.jsx)(LBe,{})}),(0,n.jsx)(ot,{path:"apps/advanced/gateways",element:(0,n.jsx)(wze,{})}),(0,n.jsx)(ot,{path:"apps/advanced/profiles/new",element:(0,n.jsx)(FBe,{mode:"new"})}),(0,n.jsx)(ot,{path:"apps/advanced/profiles/:profileId/edit",element:(0,n.jsx)(FBe,{mode:"edit"})}),(0,n.jsx)(ot,{path:"apps/advanced/profiles/:profileId",element:(0,n.jsx)(lSs,{})}),(0,n.jsx)(ot,{path:"apps/advanced/audit",element:(0,n.jsx)(Ss,{to:"/apps",replace:!0})}),(0,n.jsx)(ot,{path:"apps/advanced/run-your-own",element:(0,n.jsx)(Ss,{to:"/apps",replace:!0})}),(0,n.jsx)(ot,{path:"apps/advanced/:tab",element:(0,n.jsx)(LBe,{})}),(0,n.jsx)(ot,{path:"apps/app/:applicationId",element:(0,n.jsx)(bze,{})}),(0,n.jsx)(ot,{path:"apps/app/:applicationId/:tab",element:(0,n.jsx)(bze,{})}),(0,n.jsx)(ot,{path:"apps/:connectionId",element:(0,n.jsx)(Ss,{to:"permissions",replace:!0})}),(0,n.jsx)(ot,{path:"apps/:connectionId/:tab",element:(0,n.jsx)(oAs,{})}),(0,n.jsx)(ot,{path:"company/settings/instance",element:(0,n.jsx)(Ss,{to:"/company/settings",replace:!0})}),(0,n.jsx)(ot,{element:(0,n.jsx)(jg,{pageKey:"instance.profile"}),children:(0,n.jsx)(ot,{path:"company/settings/instance/profile",element:(0,n.jsx)(iLs,{})})}),(0,n.jsx)(ot,{path:"company/settings/instance/general",element:(0,n.jsx)(Ss,{to:"/company/settings",replace:!0})}),(0,n.jsx)(ot,{path:"company/settings/instance/heartbeats",element:(0,n.jsx)(Ss,{to:"/company/settings",replace:!0})}),(0,n.jsxs)(ot,{element:(0,n.jsx)(jg,{pageKey:"instance.environments"}),children:[(0,n.jsx)(ot,{path:"company/settings/instance/environments",element:(0,n.jsx)(pre,{})}),(0,n.jsx)(ot,{path:"company/settings/instance/environments/new",element:(0,n.jsx)(pre,{mode:"create"})}),(0,n.jsx)(ot,{path:"company/settings/instance/environments/:environmentId/edit",element:(0,n.jsx)(pre,{mode:"edit"})})]}),(0,n.jsx)(ot,{element:(0,n.jsx)(jg,{pageKey:"instance.access"}),children:(0,n.jsx)(ot,{path:"company/settings/instance/access",element:(0,n.jsx)(JMs,{})})}),(0,n.jsxs)(ot,{element:(0,n.jsx)(jg,{pageKey:"instance.experimental"}),children:[(0,n.jsx)(ot,{path:"company/settings/instance/features",element:(0,n.jsx)(FMs,{})}),(0,n.jsx)(ot,{path:"company/settings/instance/advanced",element:(0,n.jsx)(YMs,{})}),(0,n.jsx)(ot,{path:"company/settings/instance/experimental",element:(0,n.jsx)(Ss,{to:"/company/settings/instance/features",replace:!0})})]}),(0,n.jsxs)(ot,{element:(0,n.jsx)(jg,{pageKey:"instance.plugins"}),children:[(0,n.jsx)(ot,{path:"company/settings/instance/plugins",element:(0,n.jsx)(oLs,{})}),(0,n.jsx)(ot,{path:"company/settings/instance/plugins/:pluginId",element:(0,n.jsx)(lLs,{})})]}),(0,n.jsx)(ot,{element:(0,n.jsx)(jg,{pageKey:"instance.adapters"}),children:(0,n.jsx)(ot,{path:"company/settings/instance/adapters",element:(0,n.jsx)(iUe,{})})}),(0,n.jsx)(ot,{path:"company/settings/:settingsRoutePath/*",element:(0,n.jsx)(DCs,{})}),(0,n.jsx)(ot,{path:"skills/sources",element:(0,n.jsx)(Hze,{})}),(0,n.jsx)(ot,{path:"skills/sources/:sourceId",element:(0,n.jsx)(Hze,{})}),(0,n.jsx)(ot,{path:"skills/studio",element:(0,n.jsx)(zre,{})}),(0,n.jsx)(ot,{path:"skills/studio/new",element:(0,n.jsx)(zre,{})}),(0,n.jsx)(ot,{path:"skills/studio/:skillId",element:(0,n.jsx)(zre,{})}),(0,n.jsx)(ot,{path:"skills/:skillId/studio",element:(0,n.jsx)(aAt,{})}),(0,n.jsx)(ot,{path:"skills/*",element:(0,n.jsx)(lTs,{})}),(0,n.jsx)(ot,{path:"settings",element:(0,n.jsx)(LC,{})}),(0,n.jsx)(ot,{path:"settings/*",element:(0,n.jsx)(LC,{})}),(0,n.jsx)(ot,{path:"plugins/:pluginId",element:(0,n.jsx)(aUe,{})}),(0,n.jsx)(ot,{path:"org",element:(0,n.jsx)(Ss,{to:"/agents/all",replace:!0})}),(0,n.jsx)(ot,{path:"agents",element:(0,n.jsx)(Ss,{to:"/agents/all",replace:!0})}),wwe.map(s=>(0,n.jsx)(ot,{path:`agents/${s}`,element:(0,n.jsx)(yQn,{})},s)),(0,n.jsx)(ot,{path:"agents/new",element:(0,n.jsx)(TLs,{})}),(0,n.jsx)(ot,{path:"agents/:agentId",element:(0,n.jsx)(Sne,{})}),(0,n.jsx)(ot,{path:"agents/:agentId/:tab",element:(0,n.jsx)(Sne,{})}),(0,n.jsx)(ot,{path:"agents/:agentId/runs/:runId",element:(0,n.jsx)(Sne,{})}),(0,n.jsx)(ot,{path:"projects",element:(0,n.jsx)(HGn,{})}),(0,n.jsx)(ot,{path:"projects/:projectId",element:(0,n.jsx)(QN,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/overview",element:(0,n.jsx)(QN,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/issues",element:(0,n.jsx)(QN,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/issues/:filter",element:(0,n.jsx)(QN,{})}),(0,n.jsx)(ot,{element:(0,n.jsx)(Ite,{}),children:(0,n.jsx)(ot,{path:"projects/:projectId/workspaces/:workspaceId",element:(0,n.jsx)(des,{})})}),(0,n.jsx)(ot,{path:"projects/:projectId/workspaces",element:(0,n.jsx)(QN,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/configuration",element:(0,n.jsx)(QN,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/budget",element:(0,n.jsx)(QN,{})}),(0,n.jsx)(ot,{element:(0,n.jsx)(Ite,{}),children:(0,n.jsx)(ot,{path:"workspaces",element:(0,n.jsx)(mes,{})})}),(0,n.jsx)(ot,{path:"terminal",element:(0,n.jsx)(o8s,{children:(0,n.jsx)(a8s,{})})}),(0,n.jsx)(ot,{path:"issues",element:(0,n.jsx)(Pts,{})}),(0,n.jsx)(ot,{path:"tasks",element:(0,n.jsx)(Ss,{to:"/issues",replace:!0})}),(0,n.jsx)(ot,{path:"tasks/new",element:(0,n.jsx)(JDn,{})}),(0,n.jsx)(ot,{path:"search",element:(0,n.jsx)(nns,{})}),t?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ot,{path:"issues/all",element:(0,n.jsx)(uf,{view:"all"})}),(0,n.jsx)(ot,{path:"issues/active",element:(0,n.jsx)(uf,{view:"active"})}),(0,n.jsx)(ot,{path:"issues/backlog",element:(0,n.jsx)(uf,{view:"backlog"})}),(0,n.jsx)(ot,{path:"issues/done",element:(0,n.jsx)(uf,{view:"done"})}),(0,n.jsx)(ot,{path:"issues/recent",element:(0,n.jsx)(uf,{view:"recent"})})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ot,{path:"issues/all",element:(0,n.jsx)(Ss,{to:"/issues",replace:!0})}),(0,n.jsx)(ot,{path:"issues/active",element:(0,n.jsx)(Ss,{to:"/issues",replace:!0})}),(0,n.jsx)(ot,{path:"issues/backlog",element:(0,n.jsx)(Ss,{to:"/issues",replace:!0})}),(0,n.jsx)(ot,{path:"issues/done",element:(0,n.jsx)(Ss,{to:"/issues",replace:!0})}),(0,n.jsx)(ot,{path:"issues/recent",element:(0,n.jsx)(Ss,{to:"/issues",replace:!0})})]}),(0,n.jsx)(ot,{path:"chats",element:(0,n.jsx)(lhs,{})}),(0,n.jsx)(ot,{path:"chats/:agentRef",element:(0,n.jsx)(dhs,{})}),(0,n.jsx)(ot,{path:"issues/:issueId",element:(0,n.jsx)(shs,{})}),null,(0,n.jsx)(ot,{path:"routines",element:(0,n.jsx)(rms,{})}),(0,n.jsx)(ot,{path:"cases",element:(0,n.jsx)(PMe,{children:(0,n.jsx)(wMn,{})})}),(0,n.jsx)(ot,{path:"cases/:caseIdentifier",element:(0,n.jsx)(PMe,{children:(0,n.jsx)(SDn,{})})}),(0,n.jsx)(ot,{path:"pixels-office",element:(0,n.jsx)(nMn,{children:(0,n.jsx)(Dbs,{})})}),(0,n.jsx)(ot,{path:"status",element:(0,n.jsx)($Me,{children:(0,n.jsx)(gOe,{})})}),(0,n.jsx)(ot,{path:"status/:cardId",element:(0,n.jsx)($Me,{children:(0,n.jsx)(gOe,{})})}),(0,n.jsx)(ot,{path:"status-cards",element:(0,n.jsx)(SUe,{})}),(0,n.jsx)(ot,{path:"status-cards/:cardId",element:(0,n.jsx)(SUe,{})}),(0,n.jsx)(ot,{path:"review-queue",element:(0,n.jsx)($w,{children:(0,n.jsx)(w0s,{})})}),(0,n.jsx)(ot,{path:"learnings",element:(0,n.jsx)($w,{children:(0,n.jsx)(N0s,{})})}),(0,n.jsx)(ot,{path:"pipelines",element:(0,n.jsx)($w,{children:(0,n.jsx)(zse,{})})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId",element:(0,n.jsx)($w,{children:(0,n.jsx)(zse,{})})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId/add",element:(0,n.jsx)($w,{children:(0,n.jsx)(zse,{})})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId/settings",element:(0,n.jsx)($w,{children:(0,n.jsx)(xfs,{})})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId/items/:caseId",element:(0,n.jsx)($w,{children:(0,n.jsx)(qps,{})})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId/cases/:caseId",element:(0,n.jsx)($w,{children:(0,n.jsx)(Fps,{})})}),(0,n.jsx)(ot,{path:"routines/:routineId",element:(0,n.jsx)(vFe,{})}),(0,n.jsx)(ot,{path:"routines/:routineId/:section",element:(0,n.jsx)(vFe,{})}),(0,n.jsx)(ot,{element:(0,n.jsx)(Ite,{}),children:(0,n.jsxs)(ot,{element:(0,n.jsx)(rMn,{}),children:[(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId",element:(0,n.jsx)(_2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/services",element:(0,n.jsx)(_2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/configuration",element:(0,n.jsx)(_2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/runtime-logs",element:(0,n.jsx)(_2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/issues",element:(0,n.jsx)(_2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/routines",element:(0,n.jsx)(_2,{})})]})}),(0,n.jsx)(ot,{path:"goals",element:(0,n.jsx)(Tks,{})}),(0,n.jsx)(ot,{path:"goals/:goalId",element:(0,n.jsx)(zks,{})}),(0,n.jsx)(ot,{path:"artifacts",element:(0,n.jsx)(wFe,{})}),(0,n.jsx)(ot,{path:"approvals",element:(0,n.jsx)(Ss,{to:"/approvals/pending",replace:!0})}),(0,n.jsx)(ot,{path:"approvals/pending",element:(0,n.jsx)(NFe,{})}),(0,n.jsx)(ot,{path:"approvals/all",element:(0,n.jsx)(NFe,{})}),(0,n.jsx)(ot,{path:"approvals/:approvalId",element:(0,n.jsx)(qks,{})}),(0,n.jsx)(ot,{path:"activity",element:(0,n.jsx)(Cjs,{})}),(0,n.jsx)(ot,{path:"activity/runs",element:(0,n.jsx)(GR,{section:"runs"})}),(0,n.jsx)(ot,{path:"activity/costs",element:(0,n.jsx)(GR,{section:"costs"})}),(0,n.jsx)(ot,{path:"activity/budgets",element:(0,n.jsx)(GR,{section:"budgets"})}),(0,n.jsx)(ot,{path:"activity/timeline",element:(0,n.jsx)(GR,{section:"timeline"})}),(0,n.jsx)(ot,{path:"audit",element:(0,n.jsx)(tv,{to:"/activity",forceAgentMode:!0})}),(0,n.jsx)(ot,{path:"audit/activity",element:(0,n.jsx)(tv,{to:"/activity"})}),(0,n.jsx)(ot,{path:"audit/runs",element:(0,n.jsx)(tv,{to:"/activity/runs"})}),(0,n.jsx)(ot,{path:"audit/costs",element:(0,n.jsx)(tv,{to:"/activity/costs"})}),(0,n.jsx)(ot,{path:"audit/budgets",element:(0,n.jsx)(tv,{to:"/activity/budgets"})}),(0,n.jsx)(ot,{path:"audit/timeline",element:(0,n.jsx)(tv,{to:"/activity/timeline"})}),(0,n.jsx)(ot,{path:"runs",element:(0,n.jsx)(tv,{to:"/activity/runs"})}),(0,n.jsx)(ot,{path:"costs",element:(0,n.jsx)(tv,{to:"/activity/costs"})}),(0,n.jsx)(ot,{path:"budgets",element:(0,n.jsx)(tv,{to:"/activity/budgets"})}),(0,n.jsxs)(ot,{element:(0,n.jsx)(e5n,{}),children:[(0,n.jsx)(ot,{path:"board-chat",element:(0,n.jsx)(jNs,{})}),(0,n.jsx)(ot,{path:"artifacts",element:(0,n.jsx)(wFe,{})})]}),null,(0,n.jsx)(ot,{path:"decisions",element:(0,n.jsx)(V1s,{})}),(0,n.jsx)(ot,{path:"decisions/queues/:key",element:(0,n.jsx)(J1s,{})}),t?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ot,{path:"inbox",element:(0,n.jsx)(jUe,{})}),(0,n.jsx)(ot,{path:"inbox/mine",element:(0,n.jsx)(uf,{view:"mine"})}),(0,n.jsx)(ot,{path:"inbox/recent",element:(0,n.jsx)(uf,{view:"recent"})}),(0,n.jsx)(ot,{path:"inbox/unread",element:(0,n.jsx)(uf,{view:"unread"})}),(0,n.jsx)(ot,{path:"inbox/blocked",element:(0,n.jsx)(uf,{view:"blocked"})}),(0,n.jsx)(ot,{path:"inbox/all",element:(0,n.jsx)(uf,{view:"everything"})}),(0,n.jsx)(ot,{path:"inbox/new",element:(0,n.jsx)(uf,{view:"mine"})})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(ot,{path:"inbox",element:(0,n.jsx)(jUe,{})}),(0,n.jsx)(ot,{path:"inbox/mine",element:(0,n.jsx)(J2,{})}),(0,n.jsx)(ot,{path:"inbox/recent",element:(0,n.jsx)(J2,{})}),(0,n.jsx)(ot,{path:"inbox/unread",element:(0,n.jsx)(J2,{})}),(0,n.jsx)(ot,{path:"inbox/blocked",element:(0,n.jsx)(J2,{})}),(0,n.jsx)(ot,{path:"inbox/all",element:(0,n.jsx)(J2,{})}),(0,n.jsx)(ot,{path:"inbox/new",element:(0,n.jsx)(Ss,{to:"/inbox/mine",replace:!0})})]}),(0,n.jsx)(ot,{path:"inbox/requests",element:(0,n.jsx)(r8s,{})}),(0,n.jsx)(ot,{path:"u/:userSlug",element:(0,n.jsx)(rks,{})}),(0,n.jsx)(ot,{path:"design-guide",element:(0,n.jsx)(MMs,{})}),(0,n.jsx)(ot,{path:"instance/settings/adapters",element:(0,n.jsx)(iUe,{})}),(0,n.jsx)(ot,{path:":pluginRoutePath/*",element:(0,n.jsx)(aUe,{})}),(0,n.jsx)(ot,{path:"*",element:(0,n.jsx)(A0,{scope:"board"})})]})}i(l8s,"boardRoutes");function wUe({credentialSource:e="paperclip_vault"}={}){const t=Ri(),s=new URLSearchParams(t.search),{enabled:r,githubEnabled:a}=e_();return z3n(s,{chatConnectorsEnabled:r,githubReviewBotsEnabled:a})?(0,n.jsx)(p2t,{credentialSource:e}):(0,n.jsx)(Ss,{to:"/apps",replace:!0})}i(wUe,"AppsConnectEntryRoute");function jUe(){const{enabled:e}=VD();return e?(0,n.jsx)(uf,{view:TEt(YSe())}):(0,n.jsx)(Ss,{to:`/inbox/${YSe()}`,replace:!0})}i(jUe,"InboxRootRedirect");function uf({view:e}){const t=Ri(),s=new URLSearchParams(t.search);return s.set(QF,e),(0,n.jsx)(Ss,{to:`/issues?${s.toString()}${t.hash}`,replace:!0})}i(uf,"TaskViewRedirect");function aAt(){const e=Ri(),{companies:t,selectedCompany:s,loading:r}=gn(),{companyPrefix:a,skillId:o}=Mi();if(r)return null;const l=(a?t.find(c=>c.issuePrefix.toUpperCase()===a.toUpperCase()):null)??s??t[0]??null;return!l||!o?(0,n.jsx)(Ss,{to:"/skills/studio",replace:!0}):(0,n.jsx)(Ss,{to:`/${l.issuePrefix}/skills/studio/${encodeURIComponent(o)}${e.search}${e.hash}`,replace:!0})}i(aAt,"LegacySkillStudioRedirect");function LC(){const e=Ri(),{companies:t,selectedCompany:s,loading:r}=gn(),{companyPrefix:a}=Mi(),{hidden:o}=V0();if(r)return(0,n.jsx)(bx,{});const l=(a?t.find(d=>d.issuePrefix.toUpperCase()===a.toUpperCase()):null)??s??t[0]??null;if(!l)return Aye({pathname:e.pathname,hasCompanies:!1})?(0,n.jsx)(Ss,{to:"/onboarding",replace:!0}):(0,n.jsx)(k1e,{});const c=pBt(UZe(`${e.pathname}${e.search}${e.hash}`),o);return(0,n.jsx)(Ss,{to:`/${l.issuePrefix}${c}`,replace:!0})}i(LC,"LegacySettingsRedirect");function NUe(){const{tab:e}=Mi();return(0,n.jsx)(Ss,{to:oAt(e),replace:!0})}i(NUe,"LegacyToolsSettingsRedirect");function CUe(){const{tab:e}=Mi();return(0,n.jsx)(Ss,{to:oAt(e),replace:!0})}i(CUe,"LegacyToolsRedirect");function oAt(e){return e?e==="applications"||e==="connections"||e==="overview"||e==="examples"||e==="runtime"||e==="audit"?"/apps":e==="policies"?"/apps/advanced/profiles":`/apps/advanced/${e}`:"/apps/advanced/profiles"}i(oAt,"legacyToolsRedirectTarget");function lAt(){const{companies:e}=gn(),{openOnboarding:t}=Oc(),{t:s}=zJe(),r=im(),a=Vft(r?.cloudBaseUrl??null),{onboardingOpen:o,onboardingRouteDismissed:l}=dT(),{companyPrefix:c}=Mi(),d=c?e.find(p=>p.issuePrefix.toUpperCase()===c.toUpperCase())??null:null;if(t_n({onboardingOpen:o,routeDismissed:l}))return null;const u=d?`Add another agent to ${d.name}`:e.length>0?"Create another organization":"Create your first organization",h=d?"Run onboarding again to add an agent and a starter task for this organization.":e.length>0?"Run onboarding again to create another organization and seed its first agent.":"Get started by creating an organization and your first agent.";return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)("div",{className:"rounded-lg border border-line bg-bg-2 p-6",children:[(0,n.jsx)("h1",{className:"text-xl font-semibold",children:u}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:h}),(0,n.jsx)("div",{className:"mt-4",children:!d&&r&&!a?(0,n.jsx)("p",{className:"text-sm text-ink-3",children:s("app.cloudCreateUnavailable",{defaultValue:"Organizations are created in Paperclip Cloud. This instance can't reach it right now — try again from your Cloud portfolio."})}):(0,n.jsx)($,{onClick:i(()=>d?t({initialStep:FK(),companyId:d.id}):r&&a?P0(a):t(),"onClick"),children:d?"Add Agent":"Start Onboarding"})})]})})}i(lAt,"OnboardingRoutePage");function c8s(){const{companies:e,selectedCompany:t,loading:s}=gn(),r=Ri();if(s)return(0,n.jsx)(bx,{});const a=t??e[0]??null;return a?(0,n.jsx)(Ss,{to:`/${a.issuePrefix}/dashboard`,replace:!0}):Aye({pathname:r.pathname,hasCompanies:!1})?(0,n.jsx)(Ss,{to:"/onboarding",replace:!0}):(0,n.jsx)(k1e,{})}i(c8s,"CompanyRootRedirect");function SUe(){const{cardId:e}=Mi(),t=sRt(),s=t?`/${t}`:"";return(0,n.jsx)(Ss,{to:`${s}/status${e?`/${e}`:""}`,replace:!0})}i(SUe,"StatusCardsLegacyRedirect");function tv({to:e,forceAgentMode:t=!1}){const s=Ri(),r=new URLSearchParams(s.search);t&&r.set("mode","agents");const a=r.toString();return(0,n.jsx)(Ss,{to:`${e}${a?`?${a}`:""}${s.hash}`,replace:!0})}i(tv,"AuditCompatibilityRedirect");function Ni(){const e=Ri(),{companies:t,selectedCompany:s,loading:r}=gn();if(r)return(0,n.jsx)(bx,{});const a=s??t[0]??null;return a?(0,n.jsx)(Ss,{to:`/${a.issuePrefix}${e.pathname}${e.search}${e.hash}`,replace:!0}):Aye({pathname:e.pathname,hasCompanies:!1})?(0,n.jsx)(Ss,{to:"/onboarding",replace:!0}):(0,n.jsx)(k1e,{})}i(Ni,"UnprefixedBoardRedirect");function k1e(){const{openOnboarding:e}=Oc(),{t}=zJe(),s=im(),r=Vft(s?.cloudBaseUrl??null);return(0,n.jsx)("div",{className:"mx-auto max-w-xl py-10",children:(0,n.jsxs)("div",{className:"rounded-lg border border-line bg-bg-2 p-6",children:[(0,n.jsx)("h1",{className:"text-xl font-semibold",children:t("app.noCompanies.title",{defaultValue:"Create your first organization"})}),(0,n.jsx)("p",{className:"mt-2 text-sm text-ink-3",children:t("app.noCompanies.description",{defaultValue:"Get started by creating an organization."})}),(0,n.jsx)("div",{className:"mt-4",children:s&&!r?(0,n.jsx)("p",{className:"text-sm text-ink-3",children:t("app.cloudCreateUnavailable",{defaultValue:"Organizations are created in Paperclip Cloud. This instance can't reach it right now — try again from your Cloud portfolio."})}):(0,n.jsx)($,{onClick:i(()=>s&&r?P0(r):e(),"onClick"),children:t("app.noCompanies.newCompany",{defaultValue:"New Organization"})})})]})})}i(k1e,"NoCompaniesStartPage");function d8s(){const{enabled:e}=VD();return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(ZEt,{children:[(0,n.jsx)(ot,{path:"oauth-handoff",element:(0,n.jsx)(CAs,{})}),(0,n.jsx)(ot,{path:"auth",element:(0,n.jsx)(DLs,{})}),(0,n.jsx)(ot,{path:"board-claim/:token",element:(0,n.jsx)(PLs,{})}),(0,n.jsx)(ot,{path:"mcp-connect/:id",element:(0,n.jsx)(pUe,{})}),(0,n.jsx)(ot,{path:"dot-connect/:id",element:(0,n.jsx)(pUe,{agentPairingOnly:!0})}),(0,n.jsx)(ot,{path:"mcp-device",element:(0,n.jsx)($Ls,{})}),(0,n.jsx)(ot,{path:"assistant-connections",element:(0,n.jsx)(OLs,{})}),(0,n.jsx)(ot,{path:"cli-auth/:id",element:(0,n.jsx)(FLs,{})}),(0,n.jsx)(ot,{path:"invite/:token",element:(0,n.jsx)(QLs,{})}),(0,n.jsx)(ot,{path:"s/:token",element:(0,n.jsx)(kUe,{})}),(0,n.jsx)(ot,{path:"s/:token/issues/:issueId",element:(0,n.jsx)(kUe,{})}),(0,n.jsx)(ot,{element:(0,n.jsx)(_Le,{allowMembershipRequest:!0}),children:(0,n.jsx)(ot,{path:"chat-identity/confirm",element:(0,n.jsx)(p5s,{})})}),(0,n.jsx)(ot,{path:"tests/perf/long-thread",element:(0,n.jsx)(khs,{})}),(0,n.jsx)(ot,{path:"ux-lab/bootstrap-setup",element:(0,n.jsx)(ECs,{})}),(0,n.jsx)(ot,{path:"ux-lab/responsible-user-denial",element:(0,n.jsx)(RCs,{})}),(0,n.jsx)(ot,{path:"ux-lab/cross-issue-collaboration",element:(0,n.jsx)(LCs,{})}),(0,n.jsxs)(ot,{element:(0,n.jsx)(_Le,{}),children:[(0,n.jsx)(ot,{index:!0,element:(0,n.jsx)(c8s,{})}),(0,n.jsx)(ot,{path:"onboarding",element:(0,n.jsx)(lAt,{})}),(0,n.jsx)(ot,{path:"instance",element:(0,n.jsx)(LC,{})}),(0,n.jsx)(ot,{path:"instance/settings",element:(0,n.jsx)(LC,{})}),(0,n.jsx)(ot,{path:"instance/settings/*",element:(0,n.jsx)(LC,{})}),(0,n.jsx)(ot,{path:"companies",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"dashboard",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"inbox/*",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"issues",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"tasks",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"tasks/new",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"issues/:issueId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"routines",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"routines/:routineId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"review-queue",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"learnings",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"cases",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"cases/:caseIdentifier",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"pixels-office",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"status",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"status/:cardId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"status-cards",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"status-cards/:cardId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"pipelines",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId/add",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId/settings",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId/items/:caseId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"pipelines/:pipelineId/cases/:caseId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"artifacts",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"audit",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"audit/*",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"activity",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"activity/*",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"runs",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"costs",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"budgets",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"decisions",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"u/:userSlug",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"skills/studio",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"skills/studio/new",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"skills/studio/:skillId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"skills/:skillId/studio",element:(0,n.jsx)(aAt,{})}),(0,n.jsx)(ot,{path:"skills/*",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"settings",element:(0,n.jsx)(LC,{})}),(0,n.jsx)(ot,{path:"settings/*",element:(0,n.jsx)(LC,{})}),(0,n.jsx)(ot,{path:"agents",element:(0,n.jsx)(Ni,{})}),wwe.map(t=>(0,n.jsx)(ot,{path:`agents/${t}`,element:(0,n.jsx)(Ni,{})},t)),(0,n.jsx)(ot,{path:"agents/new",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"agents/:agentId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"agents/:agentId/:tab",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"agents/:agentId/runs/:runId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"projects",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"projects/:projectId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/overview",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/issues",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/issues/:filter",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/workspaces",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/workspaces/:workspaceId",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"projects/:projectId/configuration",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"workspaces",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"terminal",element:(0,n.jsx)(Ni,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId",element:(0,n.jsx)(s2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/services",element:(0,n.jsx)(s2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/configuration",element:(0,n.jsx)(s2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/runtime-logs",element:(0,n.jsx)(s2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/issues",element:(0,n.jsx)(s2,{})}),(0,n.jsx)(ot,{path:"execution-workspaces/:workspaceId/routines",element:(0,n.jsx)(s2,{})}),(0,n.jsx)(ot,{path:":companyPrefix",element:(0,n.jsx)(J2n,{}),children:l8s(e)}),(0,n.jsx)(ot,{path:"*",element:(0,n.jsx)(A0,{scope:"global"})})]})]}),(0,n.jsx)(GDn,{}),(0,n.jsx)(p2n,{})]})}i(d8s,"App");var u8s=class extends m.Component{static{i(this,"AppErrorBoundary")}state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:new Error(String(e))}}componentDidCatch(e,t){Tye(e,{boundary:"app",componentStack:t.componentStack})}render(){const{error:e}=this.state;return e?(0,n.jsxs)("div",{className:"mx-auto flex min-h-screen max-w-2xl flex-col justify-center space-y-4 px-4 py-10",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"text-lg font-semibold",children:"Wardmote hit an error"}),(0,n.jsx)("p",{className:"mt-1 text-sm text-ink-3",children:"Something went wrong while running the app. Reloading usually fixes this."})]}),(0,n.jsx)("pre",{className:"overflow-auto rounded-md border border-bad/30 bg-bad/10 px-3 py-2 text-xs text-bad whitespace-pre-wrap",children:e.message}),(0,n.jsx)("div",{children:(0,n.jsx)("button",{type:"button",className:"inline-flex items-center rounded-md border border-line-strong bg-bg px-3 py-1.5 text-sm font-medium shadow-sm hover:bg-bg-3 hover:text-ink",onClick:i(()=>window.location.reload(),"onClick"),children:"Reload page"})})]}):this.props.children}};function h8s(){const{data:e}=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),retry:!1}),t=e?.sentryDsn,s=e?.sentryEnvironment??void 0;return(0,m.useEffect)(()=>{if(t)return E_n(t,s),()=>{R_n()}},[t,s]),null}i(h8s,"SentryGate");function m8s(e){let t=Ok();d7e(t),qW(t,e.userId);const s=C1t(()=>{const o=Ok();o!==t&&(t=o,d7e(o),qW(o,e.userId))}),r=typeof navigator<"u"&&"serviceWorker"in navigator?navigator.serviceWorker:null,a=i(o=>{const l=RZn(o.data);l&&(l.type==="navigate"?e.navigate(l.url):TZn(l.notification))},"onMessage");return r?.addEventListener("message",a),r?.startMessages(),()=>{s(),r?.removeEventListener("message",a)}}i(m8s,"startNotificationRuntime");function p8s(){const e=ir(),t=(0,m.useRef)(e),{data:s}=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),retry:!1}),r=s?.user?.id??s?.session?.userId??null;return(0,m.useEffect)(()=>{t.current=e},[e]),(0,m.useEffect)(()=>{if(r)return m8s({userId:r,navigate:i(a=>t.current(a),"navigate")})},[r]),null}i(p8s,"NotificationRuntime");var f8s=36e5,g8s=3e3,x8s=2e3,_Ue="wardmote.skip-waiting",v8s="wardmote.build-id",cAt=null,lpe=new Set;function b8s(e){cAt=e;for(const t of lpe)t()}i(b8s,"publishUpdate");function y8s(e){return lpe.add(e),()=>{lpe.delete(e)}}i(y8s,"subscribe");function k8s(){return(0,m.useSyncExternalStore)(y8s,()=>cAt,()=>null)}i(k8s,"useServiceWorkerUpdate");function w8s(e){return new Promise(t=>{const s=new MessageChannel,r=i(o=>{clearTimeout(a),s.port1.close(),t(o)},"finish"),a=setTimeout(()=>r(null),x8s);s.port1.onmessage=o=>{r(typeof o.data?.buildId=="string"?o.data.buildId:null)},e.postMessage({type:v8s},[s.port2])})}i(w8s,"requestWorkerBuildId");function j8s(e={}){const t=e.container??(typeof navigator<"u"&&"serviceWorker"in navigator?navigator.serviceWorker:void 0);if(!t)return()=>{};const s=e.documentRef??document,r=e.reload??(()=>window.location.reload()),a=e.updateIntervalMs??f8s,o=e.onUpdateReady??b8s;let l=!!t.controller,c=!1,d=!1,u,h=!1;const p=i(async N=>e.pageBuildId?await w8s(N)!==e.pageBuildId:!0,"servesNewerBuild"),f=i(()=>{d||(d=!0,u!==void 0&&clearTimeout(u),r())},"reloadOnce"),g=i(async N=>{const S=await p(N);if(!h){if(!S){N.postMessage({type:_Ue});return}o(()=>{c=!0,N.postMessage({type:_Ue}),u=setTimeout(f,g8s)})}},"offerWaiting"),x=i(()=>{if(!l){l=!0;return}if(c){f();return}const N=t.controller;N&&p(N).then(S=>{S&&!h&&!c&&o(f)})},"onControllerChange");t.addEventListener("controllerchange",x);let v;const b=i(()=>{const N=v?.installing;N&&N.addEventListener("statechange",()=>{N.state==="installed"&&t.controller&&g(N)})},"watchInstalling"),y=i(()=>{v?.update().catch(()=>{})},"checkForUpdates"),k=i(()=>{s.visibilityState==="visible"&&y()},"onVisibilityChange");s.addEventListener("visibilitychange",k);const j=setInterval(y,a);return t.register("/sw.js").then(N=>{v=N,N.waiting&&t.controller&&g(N.waiting),N.addEventListener("updatefound",b)}).catch(()=>{}),()=>{h=!0,t.removeEventListener("controllerchange",x),s.removeEventListener("visibilitychange",k),v?.removeEventListener("updatefound",b),clearInterval(j),u!==void 0&&clearTimeout(u)}}i(j8s,"startServiceWorkerUpdates");var dAt="wardmote.notifications.asked-after-decision";function N8s(){try{return window.localStorage.getItem(dAt)==="1"}catch{return!0}}i(N8s,"alreadyAsked");function C8s(){try{window.localStorage.setItem(dAt,"1")}catch{return}}i(C8s,"markAsked");async function S8s(e){const t=await o1t();if(t!=="granted")return t;const s=X6(r=>({...r,enabled:!0,pushEnabled:!0}));return e&&await qW(s,e),t}i(S8s,"enableNotificationsAfterDecision");function _8s(){const{pushToast:e}=ri(),{data:t}=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),retry:!1}),s=t?.user?.id??t?.session?.userId??null;(0,m.useEffect)(()=>QTt(()=>{N8s()||!zwe()||wA()!=="default"||(C8s(),e({id:"wardmote-notify-after-decision",title:"Get notified when an agent needs a decision",body:"Turn on notifications for this device. You can change it later in Settings.",tone:"info",persistent:!0,action:{label:"Turn on",onClick:i(()=>{S8s(s)},"onClick")}}))}),[e,s])}i(_8s,"useFirstDecisionNotificationPrompt");var A8s="wardmote-update-ready";function I8s(){const{pushToast:e}=ri(),t=k8s(),s=Ct(),r=W0(),a=(0,m.useRef)(r);return(0,m.useEffect)(()=>{t&&e({id:A8s,title:"A new version is ready.",tone:"info",persistent:!0,action:{label:"Reload",onClick:t}})},[t,e]),(0,m.useEffect)(()=>{if(r){a.current=!0;return}a.current&&(a.current=!1,s.invalidateQueries())},[r,s]),_8s(),null}i(I8s,"PwaRuntime");var uAt={get:i(e=>le.get(`/companies/${e}/primary-agent/me`),"get"),set:i((e,t)=>le.put(`/companies/${e}/primary-agent/me`,t),"set")};function T8s(e){const t=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn")}),s=t.data?.user?.id??t.data?.session?.userId??"local-board",r=ie({queryKey:O.primaryAgent.mine(e??"__none__",s),queryFn:i(()=>uAt.get(e),"queryFn"),enabled:!!e&&t.isSuccess});return{...r,userId:s,loading:!!e&&(t.isPending||r.isPending&&!t.error),error:t.error??r.error,retry:i(()=>t.isError?t.refetch():r.refetch(),"retry")}}i(T8s,"usePrimaryAgent");function E8s({children:e}){const{selectedCompanyId:t}=gn(),s=T8s(t),r=Ct(),{pushToast:a}=ri(),o=(0,m.useRef)({companyId:t,userId:s.userId});o.current={companyId:t,userId:s.userId};const l=i(f=>O.primaryAgent.mine(f.companyId,f.userId),"keyFor"),c=i(f=>f.companyId===o.current.companyId&&f.userId===o.current.userId,"isCurrentScope"),d=ie({queryKey:O.agents.list(t),queryFn:i(()=>Pt.list(t),"queryFn"),enabled:!!t}),u=ye({mutationFn:i(f=>uAt.set(f.companyId,{primaryAgentId:f.agentId}),"mutationFn"),onMutate:i(async f=>{const g=l(f);await r.cancelQueries({queryKey:g});const x=r.getQueryData(g);return r.setQueryData(g,{companyId:f.companyId,userId:f.userId,primaryAgentId:f.agentId,initialized:!0}),{previous:x}},"onMutate"),onError:i((f,g,x)=>{r.setQueryData(l(g),x?.previous),c(g)&&a({title:"Couldn't change your primary agent.",body:f.message,tone:"error",action:{label:"Retry",onClick:i(()=>{c(g)&&u.mutate(g)},"onClick")}})},"onError"),onSuccess:i((f,g)=>r.setQueryData(l(g),f),"onSuccess"),onSettled:i((f,g,x)=>{r.invalidateQueries({queryKey:l(x)}),r.invalidateQueries({queryKey:O.resourceMemberships.mine(x.companyId)})},"onSettled")}),h=d.data?.find(f=>f.id===s.data?.primaryAgentId&&f.status!=="terminated")??null,p=s.error??d.error;return(0,n.jsx)(fOt,{value:t?{companyId:t,primaryAgentId:h?.id??null,primaryAgent:h,loading:s.loading||d.isPending,error:p?.message,onRetry:i(()=>{s.retry(),d.refetch()},"onRetry"),pendingAgentId:u.isPending&&c(u.variables)?u.variables.agentId:null,onChange:i(f=>u.mutate({companyId:t,userId:s.userId,agentId:f}),"onChange")}:null,children:e})}i(E8s,"PrimaryAgentProvider");function R8s(e){return{id:e.key,title:e.title,status:e.status,projectId:e.projectId??null,assigneeAgentId:e.assigneeAgentId??null,lastRun:e.lastRunAt||e.lastRunStatus?{triggeredAt:e.lastRunAt??null,status:e.lastRunStatus??null}:null}}i(R8s,"managedRoutineToRow");function M8s({routines:e,agents:t=[],projects:s=[],pluginDisplayName:r=null,emptyMessage:a="No managed routines.",runningRoutineKey:o=null,statusMutationRoutineKey:l=null,reconcilingRoutineKey:c=null,resettingRoutineKey:d=null,onRunNow:u,onToggleEnabled:h,onReconcile:p,onReset:f}){const g=new Map(t.map(v=>[v.id,v])),x=new Map(s.map(v=>[v.id,{name:v.name,color:v.color}]));return e.length===0?(0,n.jsx)("div",{className:"rounded-lg border border-line px-3 py-8 text-center text-sm text-ink-3",children:a}):(0,n.jsx)("div",{className:"rounded-lg border border-line",children:e.map(v=>{const b=R8s(v),y=v.href??(v.routineId?`/routines/${v.routineId}`:"/routines"),k=v.missingRefs??[],j=!!(v.routineId&&v.resourceKey&&k.length===0),N=v.managedByPluginDisplayName??r,S=!!(p||f);return(0,n.jsxs)("div",{className:"last:[&_a]:border-b-0",children:[(0,n.jsx)(N3t,{routine:b,projectById:x,agentById:g,runningRoutineId:o,statusMutationRoutineId:l,href:y,configureLabel:"Configure",managedByLabel:N?`Managed by ${N}`:null,runNowButton:!0,hideArchiveAction:!0,disableRunNow:!j,disableToggle:!j,secondaryDetails:(0,n.jsxs)("span",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[v.resourceKey?(0,n.jsx)("span",{children:v.resourceKey}):null,v.cronExpression?(0,n.jsxs)("span",{children:["Schedule ",v.cronExpression]}):null]}),onRunNow:i(()=>u?.(v),"onRunNow"),onToggleEnabled:i(()=>h?.(v,b.status==="active"),"onToggleEnabled")}),S?(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-line px-3 pb-3 text-xs text-ink-3 last:border-b-0",onClick:i(A=>{A.preventDefault(),A.stopPropagation()},"onClick"),children:[(0,n.jsx)("span",{children:k.length?`Missing ${k.map(A=>`${A.resourceKind}:${A.resourceKey}`).join(", ")}`:"Routine defaults can be repaired."}),(0,n.jsxs)("span",{className:"flex items-center gap-2",children:[p?(0,n.jsx)($,{size:"sm",variant:"ghost",disabled:c===v.key,onClick:i(()=>p(v),"onClick"),children:c===v.key?"Reconciling...":"Reconcile"}):null,f?(0,n.jsx)($,{size:"sm",variant:"ghost",disabled:d===v.key,onClick:i(()=>f(v),"onClick"),children:d===v.key?"Resetting...":"Reset"}):null]})]}):null]},v.key)})})}i(M8s,"ManagedRoutinesList");function AUe(e){return new Set(e??[])}i(AUe,"toPathSet");function L8s({expandedPaths:e,checkedPaths:t,selectedFile:s=null,showCheckboxes:r=!1,onToggleDir:a,onSelectFile:o,...l}){return(0,m.createElement)(x_,{...l,selectedFile:s,expandedDirs:AUe(e),checkedFiles:t?AUe(t):void 0,showCheckboxes:r,onToggleDir:a??(()=>{}),onSelectFile:o??(()=>{})})}i(L8s,"PluginSdkFileTree");function D8s(e){const[t,s]=(0,m.useState)(null);return(0,m.useEffect)(()=>{let r=!1;return ln(()=>Promise.resolve().then(()=>Zfn).then(a=>{r||s(()=>a.MarkdownEditor)}),void 0),()=>{r=!0}},[]),t?(0,m.createElement)(t,e):(0,m.createElement)("textarea",{className:e.className,value:e.value,placeholder:e.placeholder,readOnly:e.readOnly,onBlur:e.onBlur,onChange:i(r=>e.onChange(r.currentTarget.value),"onChange")})}i(D8s,"PluginSdkMarkdownEditor");function P8s(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!=null&&t!==""&&t!==!1))}i(P8s,"compactIssueFilters");function $8s({companyId:e,projectId:t=null,filters:s,viewStateKey:r="paperclip:plugin-issues-view",initialSearch:a,createIssueLabel:o,searchWithinLoadedIssues:l=!0}){const c=Ct(),d=(0,m.useMemo)(()=>P8s({...s??{},projectId:s?.projectId??t??void 0}),[s,t]),u=d.originKindPrefix??null,h=d.projectId??t??null,p=(0,m.useMemo)(()=>["plugins","sdk-ui","issues-list",e??"__no-company__",d],[e,d]),{data:f}=ie({queryKey:O.agents.list(e??"__no-company__"),queryFn:i(()=>Pt.list(e),"queryFn"),enabled:!!e}),{data:g}=ie({queryKey:O.projects.list(e??"__no-company__",{includeArchived:!0}),queryFn:i(()=>Ii.list(e,{includeArchived:!0}),"queryFn"),enabled:!!e}),x=O.liveRuns(e??"__no-company__"),v=Zc({companyId:e,resourceKey:"live-runs",queryKey:x,enabled:!!e,refetchInterval:!1,leaderOnly:!0}),{data:b,dataUpdatedAt:y}=ie({queryKey:x,queryFn:i(()=>xi.liveRunsForCompany(e),"queryFn"),enabled:v.enabled,refetchInterval:v.refetchInterval});Xc(v,b,y);const{data:k,isLoading:j,error:N}=ie({queryKey:p,queryFn:i(()=>Mt.list(e,d),"queryFn"),enabled:!!e}),S=(0,m.useMemo)(()=>f_(b,k),[k,b]),A=ye({mutationFn:i(({id:I,data:_})=>Mt.update(I,_),"mutationFn"),onSuccess:i(()=>{e&&(c.invalidateQueries({queryKey:["plugins","sdk-ui","issues-list",e]}),c.invalidateQueries({queryKey:O.issues.list(e)}),h&&(c.invalidateQueries({queryKey:O.issues.listByProject(e,h)}),u&&c.invalidateQueries({queryKey:O.issues.listPluginOperationsByProject(e,h,u)})))},"onSuccess")});return e?(0,m.createElement)(YT,{issues:k??[],isLoading:j,error:N,agents:f,projects:g,liveIssueIds:S,projectId:h??void 0,viewStateKey:r,initialSearch:a,createIssueLabel:o,searchWithinLoadedIssues:l,onUpdateIssue:i((I,_)=>A.mutate({id:I,data:_}),"onUpdateIssue")}):(0,m.createElement)("div",{className:"text-sm text-ink-3"},"Select an organization to view tasks.")}i($8s,"PluginSdkIssuesList");function O8s({companyId:e,value:t,onChange:s,placeholder:r="Responsible",noneLabel:a="No responsible",searchPlaceholder:o="Search responsible...",emptyMessage:l="No responsible found.",includeUsers:c=!0,includeTerminatedAgents:d=!1,className:u,onConfirm:h}){const p=rfe(),f=e??p.companyId??null,{data:g}=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn"),enabled:c}),x=g?.user?.id??g?.session?.userId??null,{data:v}=ie({queryKey:O.agents.list(f??"__no-company__"),queryFn:i(()=>Pt.list(f),"queryFn"),enabled:!!f}),{data:b}=ie({queryKey:O.access.companyUserDirectory(f??"__no-company__"),queryFn:i(()=>jr.listUserDirectory(f),"queryFn"),enabled:!!f&&c}),y=(0,m.useMemo)(()=>oae(),[]),k=(0,m.useMemo)(()=>y.map(I=>I.startsWith("agent:")?I.slice(6):null).filter(I=>!!I),[y]),j=(0,m.useMemo)(()=>h1((v??[]).filter(I=>d||I.status!=="terminated"),k),[v,d,k]),N=(0,m.useMemo)(()=>[...c?AZe(x):[],...c?gT(b?.users,{excludeUserIds:[x]}):[],...j.map(I=>({id:Vh({assigneeAgentId:I.id}),label:I.name,searchText:`${I.name} ${I.role} ${I.title??""}`}))],[b?.users,x,c,j]),S=r3(t),A=S.assigneeAgentId?j.find(I=>I.id===S.assigneeAgentId):null;return(0,m.createElement)(Dm,{value:t,options:N,recentOptionIds:y,placeholder:r,noneLabel:a,searchPlaceholder:o,emptyMessage:l,className:u,onConfirm:h,onChange:i(I=>{const _=r3(I);_.assigneeAgentId&&u1(_.assigneeAgentId),_.assigneeUserId&&KM(_.assigneeUserId),s(I,_)},"onChange"),renderTriggerValue:i(I=>I?A?(0,m.createElement)(MQ,null,(0,m.createElement)(BK,{icon:A.icon,className:"h-3.5 w-3.5 shrink-0 text-ink-3"}),(0,m.createElement)("span",{className:"truncate"},I.label)):(0,m.createElement)("span",{className:"truncate"},I.label):(0,m.createElement)("span",{className:"text-ink-3"},r),"renderTriggerValue"),renderOption:i(I=>{if(!I.id)return(0,m.createElement)("span",{className:"truncate"},I.label);const _=r3(I.id),T=_.assigneeAgentId?j.find(E=>E.id===_.assigneeAgentId):null;return(0,m.createElement)(MQ,null,T?(0,m.createElement)(BK,{icon:T.icon,className:"h-3.5 w-3.5 shrink-0 text-ink-3"}):(0,m.createElement)(bc,{className:"h-3.5 w-3.5 shrink-0 text-ink-3"}),(0,m.createElement)("span",{className:"truncate"},I.label))},"renderOption")})}i(O8s,"PluginSdkAssigneePicker");function F8s({companyId:e,value:t,onChange:s,placeholder:r="Project",noneLabel:a="No project",searchPlaceholder:o="Search projects...",emptyMessage:l="No projects found.",includeArchived:c=!1,className:d,onConfirm:u}){const h=rfe(),p=e??h.companyId??null,{data:f}=ie({queryKey:O.auth.session,queryFn:i(()=>Ji.getSession(),"queryFn")}),g=f?.user?.id??f?.session?.userId??null,{data:x}=ie({queryKey:O.projects.list(p??"__no-company__",{includeArchived:c}),queryFn:i(()=>Ii.list(p,{includeArchived:c}),"queryFn"),enabled:!!p}),v=(0,m.useMemo)(()=>(x??[]).filter(N=>c||!N.archivedAt),[c,x]),{orderedProjects:b}=xT({projects:v,companyId:p,userId:g}),y=(0,m.useMemo)(()=>m1(),[]),k=(0,m.useMemo)(()=>b.map(N=>({id:N.id,label:N.name,searchText:N.description??""})),[b]),j=b.find(N=>N.id===t)??null;return(0,m.createElement)(Dm,{value:t,options:k,recentOptionIds:y,placeholder:r,noneLabel:a,searchPlaceholder:o,emptyMessage:l,className:d,onConfirm:u,onChange:i(N=>{N&&jk(N),s(N)},"onChange"),renderTriggerValue:i(N=>!N||!j?(0,m.createElement)("span",{className:"text-ink-3"},r):(0,m.createElement)(MQ,null,(0,m.createElement)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:j.color??"#6366f1"}}),(0,m.createElement)("span",{className:"truncate"},N.label)),"renderTriggerValue"),renderOption:i(N=>{if(!N.id)return(0,m.createElement)("span",{className:"truncate"},N.label);const S=b.find(A=>A.id===N.id);return(0,m.createElement)(MQ,null,(0,m.createElement)("span",{className:"h-3.5 w-3.5 shrink-0 rounded-sm",style:{backgroundColor:S?.color??"#6366f1"}}),(0,m.createElement)("span",{className:"truncate"},N.label))},"renderOption")})}i(F8s,"PluginSdkProjectPicker");function MQ({children:e}){return(0,m.createElement)("span",{className:"contents"},e)}i(MQ,"FragmentSafe");function B8s({label:e,status:t}){const s={ok:"border-emerald-300 bg-emerald-50 text-emerald-700",warning:"border-amber-300 bg-amber-50 text-amber-800",error:"border-red-300 bg-red-50 text-red-700",info:"border-slate-300 bg-slate-50 text-slate-700",pending:"border-slate-300 bg-slate-50 text-slate-600"}[t];return(0,m.createElement)("span",{className:`inline-flex w-fit items-center rounded-full border px-2 py-0.5 text-xs font-medium ${s}`},e)}i(B8s,"PluginSdkStatusBadge");function z8s({columns:e,rows:t,loading:s,emptyMessage:r="No rows."}){if(s)return(0,m.createElement)("div",{className:"text-sm text-ink-3"},"Loading...");if(!t.length)return(0,m.createElement)("div",{className:"text-sm text-ink-3"},r);const a=e.map(o=>o.width??"minmax(0, 1fr)").join(" ");return(0,m.createElement)("div",{className:"overflow-hidden rounded-md border"},(0,m.createElement)("div",{className:"hidden border-b bg-bg-3/35 px-3 py-2 text-xs font-medium uppercase tracking-wide text-ink-3 md:grid md:[grid-template-columns:var(--plugin-grid-cols)]",style:{"--plugin-grid-cols":a}},e.map(o=>(0,m.createElement)("div",{key:o.key},o.header))),(0,m.createElement)("div",{className:"divide-y"},t.map((o,l)=>(0,m.createElement)("div",{key:String(o.id??l),className:"grid gap-2 px-3 py-3 md:items-center md:[grid-template-columns:var(--plugin-grid-cols)]",style:{"--plugin-grid-cols":a}},e.map(c=>(0,m.createElement)("div",{key:c.key,className:"min-w-0 text-sm"},(0,m.createElement)("div",{className:"mb-1 text-[11px] font-medium uppercase tracking-wide text-ink-3 md:hidden"},c.header),c.render?c.render(o[c.key],o):String(o[c.key]??"")))))))}i(z8s,"PluginSdkDataTable");function q8s({pairs:e}){return(0,m.createElement)("dl",{className:"grid gap-x-4 gap-y-1 text-sm sm:grid-cols-[max-content_minmax(0,1fr)]"},e.flatMap(t=>[(0,m.createElement)("dt",{key:`${t.label}:label`,className:"text-ink-3"},t.label),(0,m.createElement)("dd",{key:`${t.label}:value`,className:"min-w-0"},t.value)]))}i(q8s,"PluginSdkKeyValueList");function U8s({label:e,value:t,unit:s}){return(0,m.createElement)("div",{className:"rounded-md border bg-bg-2 p-3"},(0,m.createElement)("div",{className:"text-xs font-medium uppercase tracking-wide text-ink-3"},e),(0,m.createElement)("div",{className:"mt-1 text-lg font-semibold"},`${t}${s??""}`))}i(U8s,"PluginSdkMetricCard");function K8s({data:e}){return(0,m.createElement)("pre",{className:"max-h-80 overflow-auto rounded-md border bg-bg-3/30 p-2 text-xs"},JSON.stringify(e,null,2))}i(K8s,"PluginSdkJsonTree");function W8s({label:e="Loading"}){return(0,m.createElement)("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-ink-3/30 border-t-ink align-middle",role:"status","aria-label":e})}i(W8s,"PluginSdkSpinner");var Q8s=class extends m.Component{static{i(this,"PluginSdkErrorBoundary")}state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback??(0,m.createElement)("div",{className:"rounded-md border border-bad/30 p-3 text-sm text-bad"},"Plugin UI failed to render."):this.props.children}};function V8s(e,t){globalThis.__paperclipPluginBridge__={react:e,reactJsxRuntime:n,reactDom:t,sdkUi:{usePluginData:jBt,usePluginAction:NBt,useHostContext:rfe,useHostLocation:SBt,useHostNavigation:CBt,usePluginStream:ABt,usePluginToast:_Bt,copyTextToClipboard:pi,MarkdownBlock:i(({content:s,className:r,enableWikiLinks:a,wikiLinkRoot:o,resolveWikiLinkHref:l})=>(0,m.createElement)(_s,{className:r,softBreaks:!1,enableWikiLinks:a,wikiLinkRoot:o,resolveWikiLinkHref:l,children:s}),"MarkdownBlock"),MetricCard:U8s,StatusBadge:B8s,DataTable:z8s,KeyValueList:q8s,JsonTree:K8s,Spinner:W8s,ErrorBoundary:Q8s,MarkdownEditor:D8s,FileTree:L8s,IssuesList:$8s,AssigneePicker:O8s,ProjectPicker:F8s,ManagedRoutinesList:M8s}}}i(V8s,"initPluginBridge");var H8s=1e4;function G8s(e=H8s){if(typeof performance>"u"||typeof performance.clearMeasures!="function")return()=>{};const s=setInterval(i(()=>{globalThis.__paperclipKeepPerfMeasures||performance.clearMeasures()},"reap"),e);return()=>clearInterval(s)}i(G8s,"startPerfMeasureReaper");var Y8s=ih((e=>{function t(B,z){var U=B.length;B.push(z);e:for(;0<U;){var W=U-1>>>1,F=B[W];if(0<a(F,z))B[W]=z,B[U]=F,U=W;else break e}}i(t,"push");function s(B){return B.length===0?null:B[0]}i(s,"peek");function r(B){if(B.length===0)return null;var z=B[0],U=B.pop();if(U!==z){B[0]=U;e:for(var W=0,F=B.length,Y=F>>>1;W<Y;){var V=2*(W+1)-1,G=B[V],ne=V+1,Z=B[ne];if(0>a(G,U))ne<F&&0>a(Z,G)?(B[W]=Z,B[ne]=U,W=ne):(B[W]=G,B[V]=U,W=V);else if(ne<F&&0>a(Z,U))B[W]=Z,B[ne]=U,W=ne;else break e}}return z}i(r,"pop");function a(B,z){var U=B.sortIndex-z.sortIndex;return U!==0?U:B.id-z.id}if(i(a,"compare"),e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,c=l.now();e.unstable_now=function(){return l.now()-c}}var d=[],u=[],h=1,p=null,f=3,g=!1,x=!1,v=!1,b=!1,y=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function N(B){for(var z=s(u);z!==null;){if(z.callback===null)r(u);else if(z.startTime<=B)r(u),z.sortIndex=z.expirationTime,t(d,z);else break;z=s(u)}}i(N,"advanceTimers");function S(B){if(v=!1,N(B),!x)if(s(d)!==null)x=!0,A||(A=!0,P());else{var z=s(u);z!==null&&L(S,z.startTime-B)}}i(S,"handleTimeout");var A=!1,I=-1,_=5,T=-1;function E(){return b?!0:!(e.unstable_now()-T<_)}i(E,"shouldYieldToHost");function M(){if(b=!1,A){var B=e.unstable_now();T=B;var z=!0;try{e:{x=!1,v&&(v=!1,k(I),I=-1),g=!0;var U=f;try{t:{for(N(B),p=s(d);p!==null&&!(p.expirationTime>B&&E());){var W=p.callback;if(typeof W=="function"){p.callback=null,f=p.priorityLevel;var F=W(p.expirationTime<=B);if(B=e.unstable_now(),typeof F=="function"){p.callback=F,N(B),z=!0;break t}p===s(d)&&r(d),N(B)}else r(d);p=s(d)}if(p!==null)z=!0;else{var Y=s(u);Y!==null&&L(S,Y.startTime-B),z=!1}}break e}finally{p=null,f=U,g=!1}z=void 0}}finally{z?P():A=!1}}}i(M,"performWorkUntilDeadline");var P;if(typeof j=="function")P=i(function(){j(M)},"schedulePerformWorkUntilDeadline");else if(typeof MessageChannel<"u"){var D=new MessageChannel,K=D.port2;D.port1.onmessage=M,P=i(function(){K.postMessage(null)},"schedulePerformWorkUntilDeadline")}else P=i(function(){y(M,0)},"schedulePerformWorkUntilDeadline");function L(B,z){I=y(function(){B(e.unstable_now())},z)}i(L,"requestHostTimeout"),e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(B){B.callback=null},e.unstable_forceFrameRate=function(B){0>B||125<B||(_=0<B?Math.floor(1e3/B):5)},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(B){switch(f){case 1:case 2:case 3:var z=3;break;default:z=f}var U=f;f=z;try{return B()}finally{f=U}},e.unstable_requestPaint=function(){b=!0},e.unstable_runWithPriority=function(B,z){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var U=f;f=B;try{return z()}finally{f=U}},e.unstable_scheduleCallback=function(B,z,U){var W=e.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?W+U:W):U=W,B){case 1:var F=-1;break;case 2:F=250;break;case 5:F=1073741823;break;case 4:F=1e4;break;default:F=5e3}return F=U+F,B={id:h++,callback:z,priorityLevel:B,startTime:U,expirationTime:F,sortIndex:-1},U>W?(B.sortIndex=U,t(u,B),s(d)===null&&B===s(u)&&(v?(k(I),I=-1):v=!0,L(S,U-W))):(B.sortIndex=F,t(d,B),x||g||(x=!0,A||(A=!0,P()))),B},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(B){var z=f;return function(){var U=f;f=z;try{return B.apply(this,arguments)}finally{f=U}}}})),J8s=ih(((e,t)=>{t.exports=Y8s()})),Z8s=ih((e=>{var t=J8s(),s=cpe(),r=CKe();function a(w){var C="https://react.dev/errors/"+w;if(1<arguments.length){C+="?args[]="+encodeURIComponent(arguments[1]);for(var R=2;R<arguments.length;R++)C+="&args[]="+encodeURIComponent(arguments[R])}return"Minified React error #"+w+"; visit "+C+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}i(a,"formatProdErrorMessage");function o(w){return!(!w||w.nodeType!==1&&w.nodeType!==9&&w.nodeType!==11)}i(o,"isValidContainer");function l(w){var C=w,R=w;if(w.alternate)for(;C.return;)C=C.return;else{w=C;do C=w,(C.flags&4098)!==0&&(R=C.return),w=C.return;while(w)}return C.tag===3?R:null}i(l,"getNearestMountedFiber");function c(w){if(w.tag===13){var C=w.memoizedState;if(C===null&&(w=w.alternate,w!==null&&(C=w.memoizedState)),C!==null)return C.dehydrated}return null}i(c,"getSuspenseInstanceFromFiber");function d(w){if(w.tag===31){var C=w.memoizedState;if(C===null&&(w=w.alternate,w!==null&&(C=w.memoizedState)),C!==null)return C.dehydrated}return null}i(d,"getActivityInstanceFromFiber");function u(w){if(l(w)!==w)throw Error(a(188))}i(u,"assertIsMounted");function h(w){var C=w.alternate;if(!C){if(C=l(w),C===null)throw Error(a(188));return C!==w?null:w}for(var R=w,q=C;;){var X=R.return;if(X===null)break;var re=X.alternate;if(re===null){if(q=X.return,q!==null){R=q;continue}break}if(X.child===re.child){for(re=X.child;re;){if(re===R)return u(X),w;if(re===q)return u(X),C;re=re.sibling}throw Error(a(188))}if(R.return!==q.return)R=X,q=re;else{for(var Ce=!1,Ge=X.child;Ge;){if(Ge===R){Ce=!0,R=X,q=re;break}if(Ge===q){Ce=!0,q=X,R=re;break}Ge=Ge.sibling}if(!Ce){for(Ge=re.child;Ge;){if(Ge===R){Ce=!0,R=re,q=X;break}if(Ge===q){Ce=!0,q=re,R=X;break}Ge=Ge.sibling}if(!Ce)throw Error(a(189))}}if(R.alternate!==q)throw Error(a(190))}if(R.tag!==3)throw Error(a(188));return R.stateNode.current===R?w:C}i(h,"findCurrentFiberUsingSlowPath");function p(w){var C=w.tag;if(C===5||C===26||C===27||C===6)return w;for(w=w.child;w!==null;){if(C=p(w),C!==null)return C;w=w.sibling}return null}i(p,"findCurrentHostFiberImpl");var f=Object.assign,g=Symbol.for("react.element"),x=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),j=Symbol.for("react.consumer"),N=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),E=Symbol.for("react.activity"),M=Symbol.for("react.memo_cache_sentinel"),P=Symbol.iterator;function D(w){return w===null||typeof w!="object"?null:(w=P&&w[P]||w["@@iterator"],typeof w=="function"?w:null)}i(D,"getIteratorFn");var K=Symbol.for("react.client.reference");function L(w){if(w==null)return null;if(typeof w=="function")return w.$$typeof===K?null:w.displayName||w.name||null;if(typeof w=="string")return w;switch(w){case b:return"Fragment";case k:return"Profiler";case y:return"StrictMode";case A:return"Suspense";case I:return"SuspenseList";case E:return"Activity"}if(typeof w=="object")switch(w.$$typeof){case v:return"Portal";case N:return w.displayName||"Context";case j:return(w._context.displayName||"Context")+".Consumer";case S:var C=w.render;return w=w.displayName,w||(w=C.displayName||C.name||"",w=w!==""?"ForwardRef("+w+")":"ForwardRef"),w;case _:return C=w.displayName||null,C!==null?C:L(w.type)||"Memo";case T:C=w._payload,w=w._init;try{return L(w(C))}catch{}}return null}i(L,"getComponentNameFromType");var B=Array.isArray,z=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W={pending:!1,data:null,method:null,action:null},F=[],Y=-1;function V(w){return{current:w}}i(V,"createCursor");function G(w){0>Y||(w.current=F[Y],F[Y]=null,Y--)}i(G,"pop");function ne(w,C){Y++,F[Y]=w.current,w.current=C}i(ne,"push");var Z=V(null),J=V(null),se=V(null),H=V(null);function ee(w,C){switch(ne(se,C),ne(J,w),ne(Z,null),C.nodeType){case 9:case 11:w=(w=C.documentElement)&&(w=w.namespaceURI)?ECe(w):0;break;default:if(w=C.tagName,C=C.namespaceURI)C=ECe(C),w=RCe(C,w);else switch(w){case"svg":w=1;break;case"math":w=2;break;default:w=0}}G(Z),ne(Z,w)}i(ee,"pushHostContainer");function te(){G(Z),G(J),G(se)}i(te,"popHostContainer");function oe(w){w.memoizedState!==null&&ne(H,w);var C=Z.current,R=RCe(C,w.type);C!==R&&(ne(J,w),ne(Z,R))}i(oe,"pushHostContext");function ae(w){J.current===w&&(G(Z),G(J)),H.current===w&&(G(H),P4._currentValue=W)}i(ae,"popHostContext");var ge,xe;function ce(w){if(ge===void 0)try{throw Error()}catch(R){var C=R.stack.trim().match(/\n( *(at )?)/);ge=C&&C[1]||"",xe=-1<R.stack.indexOf(`
753
753
  at`)?" (<anonymous>)":-1<R.stack.indexOf("@")?"@unknown:0:0":""}return`
754
754
  `+ge+w+xe}i(ce,"describeBuiltInComponentFrame");var de=!1;function be(w,C){if(!w||de)return"";de=!0;var R=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var q={DetermineComponentFrameRoot:i(function(){try{if(C){var Wn=i(function(){throw Error()},"Fake");if(Object.defineProperty(Wn.prototype,"props",{set:i(function(){throw Error()},"set")}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Wn,[])}catch(un){var rn=un}Reflect.construct(w,[],Wn)}else{try{Wn.call()}catch(un){rn=un}w.call(Wn.prototype)}}else{try{throw Error()}catch(un){rn=un}(Wn=w())&&typeof Wn.catch=="function"&&Wn.catch(function(){})}}catch(un){if(un&&rn&&typeof un.stack=="string")return[un.stack,rn.stack]}return[null,null]},"DetermineComponentFrameRoot")};q.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var X=Object.getOwnPropertyDescriptor(q.DetermineComponentFrameRoot,"name");X&&X.configurable&&Object.defineProperty(q.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var re=q.DetermineComponentFrameRoot(),Ce=re[0],Ge=re[1];if(Ce&&Ge){var At=Ce.split(`
755
755
  `),en=Ge.split(`