local-operator-ui 0.47.8 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/main/index.js +488 -170
- package/out/renderer/assets/{_basePickBy-ojkoQ439.js → _basePickBy-Dv9-f1zg.js} +1 -1
- package/out/renderer/assets/{_baseUniq-Cgz7Hj_a.js → _baseUniq-DhaZAHoq.js} +1 -1
- package/out/renderer/assets/{agent-details-page-B5287Wxd.js → agent-details-page-CR3LqA6j.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-D3p-cWKe.js → agent-hub-page-CUrnlAxA.js} +1 -1
- package/out/renderer/assets/{agents-page-Dfj750IG.js → agents-page-C7yY-2qp.js} +3 -3
- package/out/renderer/assets/{arc-QdUtBTFo.js → arc-LL7ee6-c.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-B6bGif-A.js → architectureDiagram-IEHRJDOE-Bdpg_P_k.js} +1 -1
- package/out/renderer/assets/{avatar-cropper-C0NbIvss.js → avatar-cropper-DIvwbJ-E.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-DNZk1EMc.js → blockDiagram-JOT3LUYC-DOdFevdL.js} +1 -1
- package/out/renderer/assets/{book-open-DAO2iRnF.js → book-open-13BlWsMx.js} +1 -1
- package/out/renderer/assets/browser-page-Ducxyk3P.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-6rWrqh9J.js → browser-webauthn-prompt-DiRIL08d.js} +1 -1
- package/out/renderer/assets/{building-2-DpO451z6.js → building-2-9N44CmaA.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-l_7VtVOD.js → c4Diagram-VJAJSXHY-CjyVs5O2.js} +1 -1
- package/out/renderer/assets/channel-DnjDWcac.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-BZPnQwiD.js → chunk-4BMEZGHF-tE6rpM2C.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-CrfIH5iq.js → chunk-A2AXSNBT-DV0Fb7U9.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-CaPCVkD8.js → chunk-AEK57VVT-BLSpH8f8.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-bEDpLmbt.js → chunk-D6G4REZN-rSj-_6yc.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-CsrG7rfM.js → chunk-RZ5BOZE2-jPXnSJCa.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-F1EtkaMn.js → chunk-XZIHB7SX-MRXkZaZL.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-QToYz1ed.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-QToYz1ed.js +1 -0
- package/out/renderer/assets/clone-DhcIbbVE.js +1 -0
- package/out/renderer/assets/{console-mirror-CY6eZKQD.js → console-mirror-Du1Dfi6G.js} +1 -1
- package/out/renderer/assets/{consoleCapture-Cj71UOvJ.js → consoleCapture-B8I_oIj6.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-CT1X3xzg.js → conversation-input-sync-CZrU8Pug.js} +5 -5
- package/out/renderer/assets/{dagre-OKDRZEBW-KbsJOd-j.js → dagre-OKDRZEBW-Cm4oWZdS.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-P_0af2wd.js → diagram-SSKATNLV-B-SuT3th.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-CkyDCyPd.js → diagram-VNBRO52H-C_87XaDb.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-BaiH25Qu.js → erDiagram-Q7BY3M3F-CNUTHNRl.js} +1 -1
- package/out/renderer/assets/{error-boundary-CD9E-FB_.js → error-boundary-CwJn067i.js} +22 -22
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-DB1HkaCE.js → flowDiagram-4HSFHLVR-CNWPnM24.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-DnoZ-mEJ.js → ganttDiagram-APWFNJXF-DsY3XLIc.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-DcrBUoZ8.js → gitGraphDiagram-7IBYFJ6S-BC2rtoKr.js} +1 -1
- package/out/renderer/assets/{graph-Da9ZlHpw.js → graph-8FfBtXyF.js} +1 -1
- package/out/renderer/assets/{hash-BGVcZhsd.js → hash-CYo8ILV1.js} +1 -1
- package/out/renderer/assets/{heart-CC5rFmGg.js → heart-BNMX-lJj.js} +1 -1
- package/out/renderer/assets/{image-plus-Dc4Ph61z.js → image-plus-CJJBBm-x.js} +1 -1
- package/out/renderer/assets/{index-BiI-eK_K.js → index-Bw2_HcHz.js} +1 -1
- package/out/renderer/assets/{index-DSl-Zp-F.js → index-CAHaHqgX.js} +3 -3
- package/out/renderer/assets/{index-G0fTK0HE.js → index-Cbu_OqUM.js} +1 -1
- package/out/renderer/assets/{index-xeR22aZz.css → index-DY_OTUQR.css} +1 -1
- package/out/renderer/assets/infoDiagram-PH2N3AL5--dcCt49k.js +2 -0
- package/out/renderer/assets/{installer-M2B_gKRK.js → installer-8KDPYD7n.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-DTmBGW6Q.js → journeyDiagram-U35MCT3I-BDNGeVqH.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-C8WI_dOp.js → kanban-definition-NDS4AKOZ-S6WyCw-t.js} +1 -1
- package/out/renderer/assets/{layout-C3jbvT4l.js → layout-C8dSdqMl.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-BX1ObLve.js → legacy-agents-page-DlgZ5b8m.js} +1 -1
- package/out/renderer/assets/{library-page-qOfmNVcg.js → library-page-Cp4PnUA5.js} +3 -3
- package/out/renderer/assets/{mermaid.core-CdQ7E5mL.js → mermaid.core-ChUVqMVr.js} +5 -5
- package/out/renderer/assets/{mesh-page-DMkT_9A-.js → mesh-page-DZZfCNa2.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-DU0mo9p2.js → mindmap-definition-ALO5MXBD-BDgMRP17.js} +1 -1
- package/out/renderer/assets/{mini-aAsnKaGz.js → mini-BiSL5p9w.js} +1 -1
- package/out/renderer/assets/{notebook-pen-BP6ceuCH.js → notebook-pen-CDTqffOy.js} +1 -1
- package/out/renderer/assets/{notifications-page-DRMToDYt.js → notifications-page-Cmp-Mcnx.js} +1 -1
- package/out/renderer/assets/{org-access-Bs8eFlSp.js → org-access-CQLGDE7O.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-Cxo-hbUN.js → org-surface-gate-BRW-oc5F.js} +1 -1
- package/out/renderer/assets/{page-header-D5i9aRdF.js → page-header-51hz6cfp.js} +1 -1
- package/out/renderer/assets/{path-utils-CS-ZbmNv.js → path-utils-hqT2xf5k.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-Jdvz8VWw.js → pieDiagram-IB7DONF6-_o4TQRD4.js} +1 -1
- package/out/renderer/assets/{project-markdown-6v_v8CTi.js → project-markdown-DCyUXZT4.js} +1 -1
- package/out/renderer/assets/{projects-page-ClDZIyym.js → projects-page-DpKBnfKx.js} +1 -1
- package/out/renderer/assets/{publication-validation-fhBwU4Ct.js → publication-validation-DAtEW_km.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-DDWwjPpi.js → quadrantDiagram-7GDLP6J5-iGSUnWGg.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-Bph4zewY.js → radar-MK3ICKWK-WyU70_8J.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-DzozdIYt.js → radient-auth-buttons-CfQ8zffH.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-dCfjbetB.js → requirementDiagram-KVF5MWMF-D8UCvhk2.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-HVn73-Eh.js → sankeyDiagram-QLVOVGJD-Cu2Jst1E.js} +1 -1
- package/out/renderer/assets/{schedules-page-D7cUalTn.js → schedules-page-CBOwjsR3.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-DLk99tON.js → sequenceDiagram-X6HHIX6F-Cf1qv7nv.js} +1 -1
- package/out/renderer/assets/{settings-page-A_PbN5kj.js → settings-page-ri8T0hR6.js} +1 -1
- package/out/renderer/assets/{smartart-BXJB_IpV.js → smartart-BD3VY3T_.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-D4lTws7V.js → stateDiagram-DGXRK772-DygQ8odd.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-JmiS-OvQ.js +1 -0
- package/out/renderer/assets/team-bridge-page-CnL7zo0z.js +39 -0
- package/out/renderer/assets/{team-bridge-scope-preference-B_3LiR3U.js → team-bridge-scope-preference-amThPee8.js} +1 -1
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-_5CvFmhx.js → timeline-definition-BDJGKUSR-WnOC2syY.js} +1 -1
- package/out/renderer/assets/{use-download-agent-mutation-uNfQtsZW.js → use-download-agent-mutation-Boh-EKE8.js} +1 -1
- package/out/renderer/assets/{use-session-snapshot-Dd2mlTTk.js → use-session-snapshot-DPrglgqS.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-FE7vAowE.js → xychartDiagram-VJFVF3MP-BwdKR-i5.js} +1 -1
- package/out/renderer/console-capture.html +5 -5
- package/out/renderer/index.html +7 -7
- package/out/renderer/installer.html +4 -4
- package/out/renderer/mini.html +7 -7
- package/package.json +2 -2
- package/out/renderer/assets/browser-page-PqDhz6JH.js +0 -1
- package/out/renderer/assets/channel-Bayx-C4D.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-DIGzvb4h.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-DIGzvb4h.js +0 -1
- package/out/renderer/assets/clone-DSth8cxq.js +0 -1
- package/out/renderer/assets/infoDiagram-PH2N3AL5-CEGFxaq5.js +0 -2
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CLGdAi2z.js +0 -1
- package/out/renderer/assets/team-bridge-page-DOAIc8WR.js +0 -38
- /package/out/renderer/assets/{index-Cs4iHH2g.js → index-yTWbf43d.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-
|
|
2
|
-
import{r as $,b as K,h as zTe,j as f,c as E,u as iz,g as In,G as mse,i as ATe,H as ib,f as On,t as Xq}from"./index-Cs4iHH2g.js";import{aF as UTe,dK as SN,dL as WTe,dM as NTe,aC as YTe,dN as GTe,dO as QN,dP as ZTe,aD as gse,u as Zs,aL as ITe,dQ as DTe,dR as VTe,F as ui,dS as az,dT as MTe,dU as LTe,dV as FTe,o as gm,$ as $se,dW as BTe,dX as kN,dY as HTe,dZ as KTe,d_ as JTe,G as Ln,d$ as $n,ac as is,e0 as Ud,bz as oz,e1 as Rq,a7 as sz,b6 as yse,am as gu,e2 as e2e,h as wt,r as Ir,t as t2e,a4 as Xi,a9 as yO,e3 as n2e,w as Or,a as dr,c as Nn,m as mi,ab as r2e,d as qe,g as As,b1 as i2e,a0 as O$,e4 as vse,ba as bse,b8 as a2e,b9 as wse,dg as o2e,B as Xn,ai as s2e,e5 as l2e,e6 as c2e,cG as u2e,cR as O2e,e7 as d2e,e8 as f2e,e9 as h2e,ea as p2e,eb as m2e,dB as g2e,cJ as _N,cK as $2e,ec as AQ,ed as up,ee as lz,ef as y2e,eg as PN,C as Zn,cB as $r,eh as xse,ei as Sse,ak as Wa,b5 as Qse,ej as v2e,ek as b2e,el as w2e,em as x2e,en as S2e,eo as ex,ep as kse,eq as d$,er as Q2e,es as TN,at as Wd,et as k2e,eu as My,ev as _2e,ew as P2e,ex as T2e,ar as Yu,ey as X2e,ez as R2e,eA as E2e,bH as q2e,bF as j2e,eB as C2e,eC as Us,eD as Yc,eE as Mn,c_ as cz,by as _se,eF as z2e,eG as A2e,eH as Pse,eI as U2e,eJ as W2e,eK as N2e,eL as Y2e,eM as G2e,eN as Z2e,eO as iO,eP as uz,eQ as Tse,eR as Op,eS as I2e,eT as r1,eU as D2e,eV as V2e,eW as Eq,eX as M2e,eY as XN,eZ as L2e,e_ as F2e,e$ as B2e,f0 as tx,f1 as H2e,f2 as K2e,f3 as Xse,f4 as J2e,f5 as eXe,f6 as tXe,f7 as nXe,f8 as rXe,f9 as iXe,fa as aXe,fb as oXe,fc as sXe,fd as lXe,fe as cXe,ff as uXe,fg as OXe,fh as dXe,fi as fXe,f as UQ,fj as hXe,fk as Rse,fl as pXe,fm as mXe,fn as Ly,fo as Ese,fp as qse,fq as Oz,fr as gXe,fs as $Xe,ft as yXe,fu as vXe,fv as bXe,dG as WQ,dr as wXe,e as dz,fw as xXe,fx as SXe,D as QXe,az as kXe,v as _Xe,fy as PXe,fz as TXe,fA as XXe,fB as RXe,fC as f$,fD as EXe,fE as RN,fF as jse,fG as qXe,fH as EN,fI as jXe,fJ as CXe,fK as zXe,fL as Cse,fM as AXe,fN as ab,fO as qN,fP as UXe,fQ as jN,fR as WXe,aB as CN,fS as zN,fT as NXe,fU as YXe,fV as AN,fW as GXe,a8 as UN,ax as ZXe,bC as fz,bA as IXe,cM as zse,cL as Ase,a3 as h$,au as Use,fX as DXe,aw as Wse,fY as VXe,fZ as hz,f_ as qq,f$ as MXe,bU as LXe,g0 as FXe,av as BXe,g1 as HXe,g2 as KXe,g3 as JXe,b3 as eRe,g4 as tRe,g5 as nx,g6 as Nse,cx as nRe,g7 as Yse,g8 as rRe,g9 as iRe,ga as aRe,gb as oRe,q as sRe,gc as NQ,gd as pz,ge as lRe,gf as cRe,a_ as Gse,gg as Zse,gh as p$,gi as wc,gj as uRe,gk as ORe,gl as dRe,gm as fRe,cW as hRe,gn as rx,go as pRe,gp as mRe,gq as gRe,gr as $Re,gs as WN,gt as yRe,gu as vRe,gv as bRe,gw as wRe,gx as xRe,gy as SRe,S as QRe,aj as NN,gz as jq,gA as Cq}from"./path-utils-CS-ZbmNv.js";import{au as kRe,c as ze,aG as _Re,aH as Ise,aI as PRe,aJ as TRe,aK as XRe,aL as RRe,aM as ERe,aN as qRe,aO as og,aP as jRe,B as ke,n as mz,o as gz,y as CRe,p as $z,F as zRe,w as vt,h as Dse,i as js,a as ba,C as Vse,X as ni,j as ARe,u as Qe,g as Mse,k as ix,J as Lse,T as Nd,ak as zq,A as Tl,S as Qo,a6 as Fy,G as Fse,D as yz,b as vz,d as bz,e as ml,q as S0,x as Q0,Z as URe,ab as WRe,aB as wz,r as Yd,aQ as NRe,a7 as YRe,a8 as GRe,a9 as ZRe,af as IRe,ar as DRe,$ as VRe,N as MRe,O as LRe,P as FRe,K as Da,R as Bse,U as Hse,V as Kse,W as Jse,Y as Aq,_ as BRe,z as Uq,L as ele,aF as HRe,f as ho,a0 as KRe,a1 as JRe,a2 as YN,a3 as GN,a4 as e4e,a5 as ZN,aR as t4e,s as n4e,H as TP,I as IN,E as DN}from"./error-boundary-CD9E-FB_.js";import{c as $m,t as m,L as gd,d as r4e}from"./messages-C5Ff9CJ7.js";const VN=new Map,MN=new Map,LN=new Map;function xz(e){return e===void 0?"":JSON.stringify(e)}function Sz(e,t){const n=`${e}\0${xz(t)}`;let r=VN.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),VN.set(n,r)),r}function i4e(e,t){const n=`${e}\0${xz(t)}`;let r=MN.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),MN.set(n,r)),r}function YQ(e,t,n){return Sz(n??$m(),t).format(e)}function GQ(e,t,n){return Sz(n??$m(),t).format(e)}function tle(e,t,n){return Sz(n??$m(),t).format(e)}function Za(e,t,n){return i4e(n??$m(),t).format(e)}function Xin(e,t,n,r){const i=r??$m(),a=`${i}\0${xz(n)}`;let o=LN.get(a);return o===void 0&&(o=new Intl.RelativeTimeFormat(i,n),LN.set(a,o)),o.format(e,t)}const a4e=[{code:"en",native:"English",english:"English",dir:"ltr",status:"source"},{code:"fr",native:"Français",english:"French",dir:"ltr",status:"supported"},{code:"es",native:"Español",english:"Spanish",dir:"ltr",status:"supported"},{code:"zh-CN",native:"简体中文",english:"Chinese (Simplified)",dir:"ltr",status:"supported"},{code:"ru",native:"Русский",english:"Russian",dir:"ltr",status:"supported"},{code:"vi",native:"Tiếng Việt",english:"Vietnamese",dir:"ltr",status:"supported"},{code:"ur",native:"اردو",english:"Urdu",dir:"rtl",status:"supported"},{code:"hi",native:"हिन्दी",english:"Hindi",dir:"ltr",status:"supported"}],o4e={languages:a4e},FN=o4e.languages;function nle(e){const t=e.trim();if(t==="")return{lang:"en",dir:"ltr"};const n=t.toLowerCase(),r=FN.find(o=>o.code.toLowerCase()===n),i=n.split("-")[0],a=r??FN.find(o=>o.code.split("-")[0].toLowerCase()===i);return{lang:r?.code??t,dir:a?.dir==="rtl"?"rtl":"ltr"}}function s4e(e){return nle(e).dir}var l4e=class extends UTe{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:SN()})}getOptimisticResult(e){return e.behavior=SN(),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:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,l=n.fetchMeta?.fetchMore?.direction,c=o&&l==="forward",u=i&&l==="forward",O=o&&l==="backward",d=i&&l==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:NTe(t,n.data),hasPreviousPage:WTe(t,n.data),isFetchNextPageError:c,isFetchingNextPage:u,isFetchPreviousPageError:O,isFetchingPreviousPage:d,isRefetchError:s&&!c&&!O,isRefetching:a&&!u&&!d}}},c4e=class extends YTe{#n;#r=void 0;#e;#t;constructor(t,n){super(),this.#n=t,this.setOptions(n),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const n=this.options;this.options=this.#n.defaultMutationOptions(t),GTe(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#e,observer:this}),n?.mutationKey&&this.options.mutationKey&&QN(n.mutationKey)!==QN(this.options.mutationKey)?this.reset():this.#e?.state.status==="pending"&&this.#e.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#e?.removeObserver(this)}onMutationUpdate(t){this.#i(),this.#a(t)}getCurrentResult(){return this.#r}reset(){this.#e?.removeObserver(this),this.#e=void 0,this.#i(),this.#a()}mutate(t,n){return this.#t=n,this.#e?.removeObserver(this),this.#e=this.#n.getMutationCache().build(this.#n,this.options),this.#e.addObserver(this),this.#e.execute(t)}#i(){const t=this.#e?.state??ZTe();this.#r={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#a(t){gse.batch(()=>{if(this.#t&&this.hasListeners()){const n=this.#r.variables,r=this.#r.context;t?.type==="success"?(this.#t.onSuccess?.(t.data,n,r),this.#t.onSettled?.(t.data,null,n,r)):t?.type==="error"&&(this.#t.onError?.(t.error,n,r),this.#t.onSettled?.(void 0,t.error,n,r))}this.listeners.forEach(n=>{n(this.#r)})})}};function ax(e,t){const n=Zs(t),[r]=$.useState(()=>new c4e(n,e));$.useEffect(()=>{r.setOptions(e)},[r,e]);const i=$.useSyncExternalStore($.useCallback(o=>r.subscribe(gse.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=$.useCallback((o,s)=>{r.mutate(o,s).catch(ITe)},[r]);if(i.error&&DTe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function rle(e,t){return VTe(e,l4e,t)}const u4e=5e3;let ile=0;function O4e(e=u4e){ile=Date.now()+e}function Ein(e=Date.now()){return e<=ile}function d4e(e){O4e(),e.invalidateQueries({queryKey:ui.capabilities})}function f4e(e,t){if(!e||typeof e!="object")return null;const n=e,r=n.artifacts;if(!h4e(n)||!Array.isArray(r)||r.length===0||r.some(s=>!s||typeof s!="object"||typeof s.name!="string"))return null;const i=new Map,a=new Set(r.map(s=>s.name)),o=new Set;return r.map(s=>{const l=s,c=typeof l.name=="string"?l.name:"",u=(i.get(c)??0)+1;i.set(c,u);let O=u,d=u===1?c:`${c} (${O})`;for(;o.has(d)||d!==c&&a.has(d);)d=`${c} (${++O})`;o.add(d);const h=t.find(p=>p.kind==="audio"&&typeof l.digest=="string"&&p.attachment===l.digest)??null;return{id:JSON.stringify([l.request_id??null,c,u]),name:c,label:d,audio:h,costCaption:ale(l,!0),status:l.status==="cancelled"?"cancelled":l.status==="failed"||l.error?"failed":l.status==="completed"?"completed":"unknown",error:typeof l.error=="string"?l.error:null}})}function ale(e,t=!1){const n=e.cost&&typeof e.cost=="object"?e.cost:null;if(t&&(e.status==="failed"||e.error)&&e.cost_usd===0){if(n?.basis==="billed")return"No charge.";if(n?.basis==="estimated")return"Estimated cost $0; final charge not confirmed."}return az({...e,billing_basis:n?.basis??e.billing_basis})}function XP(e){const t=e,n=ale(t);if(!n)return"Total cost not yet known.";const r=t.cost_complete===!0;return`${r?"Total cost":"Known total cost"} ${n.slice(5)}${r?"":" Unknown or late charges are not included."}`}function h4e(e){return"cost_complete"in e||["completed","failed","cancelled"].some(t=>t in e)}function p4e(e,t){const n=e,r=s=>{const l=n[s];return typeof l=="number"&&Number.isInteger(l)&&l>=0?l:t.filter(c=>c.status===s).length},i=r("cancelled"),a=t.filter(s=>s.status==="unknown").length,o=t.filter(s=>s.status!=="completed");return`${r("completed")} completed · ${r("failed")} failed${i?` · ${i} cancelled/stopped`:""}${a?` · ${a} status unknown`:""}${o.length?`. Needs attention: ${o.map(s=>s.label).join("; ")}`:""}`}function m4e(e,t){const n=e;if(typeof n.error=="string"&&n.error)return n.error;const r=t?.split(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-Bw2_HcHz.js","./index-yTWbf43d.js","./messages-C5Ff9CJ7.js","./index-DY_OTUQR.css","./path-utils-hqT2xf5k.js","./error-boundary-CwJn067i.js","./index-Cbu_OqUM.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-ChUVqMVr.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as $,b as K,h as zTe,j as f,c as E,u as iz,g as In,G as mse,i as ATe,H as ib,f as On,t as Xq}from"./index-yTWbf43d.js";import{aF as UTe,dK as SN,dL as WTe,dM as NTe,aC as YTe,dN as GTe,dO as QN,dP as ZTe,aD as gse,u as Zs,aL as ITe,dQ as DTe,dR as VTe,F as ui,dS as az,dT as MTe,dU as LTe,dV as FTe,o as gm,$ as $se,dW as BTe,dX as kN,dY as HTe,dZ as KTe,d_ as JTe,G as Ln,d$ as $n,ac as is,e0 as Ud,bz as oz,e1 as Rq,a7 as sz,b6 as yse,am as gu,e2 as e2e,h as wt,r as Ir,t as t2e,a4 as Xi,a9 as yO,e3 as n2e,w as Or,a as dr,c as Nn,m as mi,ab as r2e,d as qe,g as As,b1 as i2e,a0 as O$,e4 as vse,ba as bse,b8 as a2e,b9 as wse,dg as o2e,B as Xn,ai as s2e,e5 as l2e,e6 as c2e,cG as u2e,cR as O2e,e7 as d2e,e8 as f2e,e9 as h2e,ea as p2e,eb as m2e,dB as g2e,cJ as _N,cK as $2e,ec as AQ,ed as up,ee as lz,ef as y2e,eg as PN,C as Zn,cB as $r,eh as xse,ei as Sse,ak as Wa,b5 as Qse,ej as v2e,ek as b2e,el as w2e,em as x2e,en as S2e,eo as ex,ep as kse,eq as d$,er as Q2e,es as TN,at as Wd,et as k2e,eu as My,ev as _2e,ew as P2e,ex as T2e,ar as Yu,ey as X2e,ez as R2e,eA as E2e,bH as q2e,bF as j2e,eB as C2e,eC as Us,eD as Yc,eE as Mn,c_ as cz,by as _se,eF as z2e,eG as A2e,eH as Pse,eI as U2e,eJ as W2e,eK as N2e,eL as Y2e,eM as G2e,eN as Z2e,eO as iO,eP as uz,eQ as Tse,eR as Op,eS as I2e,eT as r1,eU as D2e,eV as V2e,eW as Eq,eX as M2e,eY as XN,eZ as L2e,e_ as F2e,e$ as B2e,f0 as tx,f1 as H2e,f2 as K2e,f3 as Xse,f4 as J2e,f5 as eXe,f6 as tXe,f7 as nXe,f8 as rXe,f9 as iXe,fa as aXe,fb as oXe,fc as sXe,fd as lXe,fe as cXe,ff as uXe,fg as OXe,fh as dXe,fi as fXe,f as UQ,fj as hXe,fk as Rse,fl as pXe,fm as mXe,fn as Ly,fo as Ese,fp as qse,fq as Oz,fr as gXe,fs as $Xe,ft as yXe,fu as vXe,fv as bXe,dG as WQ,dr as wXe,e as dz,fw as xXe,fx as SXe,D as QXe,az as kXe,v as _Xe,fy as PXe,fz as TXe,fA as XXe,fB as RXe,fC as f$,fD as EXe,fE as RN,fF as jse,fG as qXe,fH as EN,fI as jXe,fJ as CXe,fK as zXe,fL as Cse,fM as AXe,fN as ab,fO as qN,fP as UXe,fQ as jN,fR as WXe,aB as CN,fS as zN,fT as NXe,fU as YXe,fV as AN,fW as GXe,a8 as UN,ax as ZXe,bC as fz,bA as IXe,cM as zse,cL as Ase,a3 as h$,au as Use,fX as DXe,aw as Wse,fY as VXe,fZ as hz,f_ as qq,f$ as MXe,bU as LXe,g0 as FXe,av as BXe,g1 as HXe,g2 as KXe,g3 as JXe,b3 as eRe,g4 as tRe,g5 as nx,g6 as Nse,cx as nRe,g7 as Yse,g8 as rRe,g9 as iRe,ga as aRe,gb as oRe,q as sRe,gc as NQ,gd as pz,ge as lRe,gf as cRe,a_ as Gse,gg as Zse,gh as p$,gi as wc,gj as uRe,gk as ORe,gl as dRe,gm as fRe,cW as hRe,gn as rx,go as pRe,gp as mRe,gq as gRe,gr as $Re,gs as WN,gt as yRe,gu as vRe,gv as bRe,gw as wRe,gx as xRe,gy as SRe,S as QRe,aj as NN,gz as jq,gA as Cq}from"./path-utils-hqT2xf5k.js";import{au as kRe,c as ze,aG as _Re,aH as Ise,aI as PRe,aJ as TRe,aK as XRe,aL as RRe,aM as ERe,aN as qRe,aO as og,aP as jRe,B as ke,n as mz,o as gz,y as CRe,p as $z,F as zRe,w as vt,h as Dse,i as js,a as ba,C as Vse,X as ni,j as ARe,u as Qe,g as Mse,k as ix,J as Lse,T as Nd,aj as zq,A as Tl,S as Qo,a6 as Fy,G as Fse,D as yz,b as vz,d as bz,e as ml,q as S0,x as Q0,Z as URe,ab as WRe,aB as wz,r as Yd,aQ as NRe,a7 as YRe,a8 as GRe,a9 as ZRe,af as IRe,ar as DRe,$ as VRe,N as MRe,O as LRe,P as FRe,K as Da,R as Bse,U as Hse,V as Kse,W as Jse,Y as Aq,_ as BRe,z as Uq,L as ele,aF as HRe,f as ho,a0 as KRe,a1 as JRe,a2 as YN,a3 as GN,a4 as e4e,a5 as ZN,aR as t4e,s as n4e,H as TP,I as IN,E as DN}from"./error-boundary-CwJn067i.js";import{c as $m,t as m,L as gd,d as r4e}from"./messages-C5Ff9CJ7.js";const VN=new Map,MN=new Map,LN=new Map;function xz(e){return e===void 0?"":JSON.stringify(e)}function Sz(e,t){const n=`${e}\0${xz(t)}`;let r=VN.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),VN.set(n,r)),r}function i4e(e,t){const n=`${e}\0${xz(t)}`;let r=MN.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),MN.set(n,r)),r}function YQ(e,t,n){return Sz(n??$m(),t).format(e)}function GQ(e,t,n){return Sz(n??$m(),t).format(e)}function tle(e,t,n){return Sz(n??$m(),t).format(e)}function Za(e,t,n){return i4e(n??$m(),t).format(e)}function Xin(e,t,n,r){const i=r??$m(),a=`${i}\0${xz(n)}`;let o=LN.get(a);return o===void 0&&(o=new Intl.RelativeTimeFormat(i,n),LN.set(a,o)),o.format(e,t)}const a4e=[{code:"en",native:"English",english:"English",dir:"ltr",status:"source"},{code:"fr",native:"Français",english:"French",dir:"ltr",status:"supported"},{code:"es",native:"Español",english:"Spanish",dir:"ltr",status:"supported"},{code:"zh-CN",native:"简体中文",english:"Chinese (Simplified)",dir:"ltr",status:"supported"},{code:"ru",native:"Русский",english:"Russian",dir:"ltr",status:"supported"},{code:"vi",native:"Tiếng Việt",english:"Vietnamese",dir:"ltr",status:"supported"},{code:"ur",native:"اردو",english:"Urdu",dir:"rtl",status:"supported"},{code:"hi",native:"हिन्दी",english:"Hindi",dir:"ltr",status:"supported"}],o4e={languages:a4e},FN=o4e.languages;function nle(e){const t=e.trim();if(t==="")return{lang:"en",dir:"ltr"};const n=t.toLowerCase(),r=FN.find(o=>o.code.toLowerCase()===n),i=n.split("-")[0],a=r??FN.find(o=>o.code.split("-")[0].toLowerCase()===i);return{lang:r?.code??t,dir:a?.dir==="rtl"?"rtl":"ltr"}}function s4e(e){return nle(e).dir}var l4e=class extends UTe{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:SN()})}getOptimisticResult(e){return e.behavior=SN(),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:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,l=n.fetchMeta?.fetchMore?.direction,c=o&&l==="forward",u=i&&l==="forward",O=o&&l==="backward",d=i&&l==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:NTe(t,n.data),hasPreviousPage:WTe(t,n.data),isFetchNextPageError:c,isFetchingNextPage:u,isFetchPreviousPageError:O,isFetchingPreviousPage:d,isRefetchError:s&&!c&&!O,isRefetching:a&&!u&&!d}}},c4e=class extends YTe{#n;#r=void 0;#e;#t;constructor(t,n){super(),this.#n=t,this.setOptions(n),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const n=this.options;this.options=this.#n.defaultMutationOptions(t),GTe(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#e,observer:this}),n?.mutationKey&&this.options.mutationKey&&QN(n.mutationKey)!==QN(this.options.mutationKey)?this.reset():this.#e?.state.status==="pending"&&this.#e.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#e?.removeObserver(this)}onMutationUpdate(t){this.#i(),this.#a(t)}getCurrentResult(){return this.#r}reset(){this.#e?.removeObserver(this),this.#e=void 0,this.#i(),this.#a()}mutate(t,n){return this.#t=n,this.#e?.removeObserver(this),this.#e=this.#n.getMutationCache().build(this.#n,this.options),this.#e.addObserver(this),this.#e.execute(t)}#i(){const t=this.#e?.state??ZTe();this.#r={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#a(t){gse.batch(()=>{if(this.#t&&this.hasListeners()){const n=this.#r.variables,r=this.#r.context;t?.type==="success"?(this.#t.onSuccess?.(t.data,n,r),this.#t.onSettled?.(t.data,null,n,r)):t?.type==="error"&&(this.#t.onError?.(t.error,n,r),this.#t.onSettled?.(void 0,t.error,n,r))}this.listeners.forEach(n=>{n(this.#r)})})}};function ax(e,t){const n=Zs(t),[r]=$.useState(()=>new c4e(n,e));$.useEffect(()=>{r.setOptions(e)},[r,e]);const i=$.useSyncExternalStore($.useCallback(o=>r.subscribe(gse.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=$.useCallback((o,s)=>{r.mutate(o,s).catch(ITe)},[r]);if(i.error&&DTe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function rle(e,t){return VTe(e,l4e,t)}const u4e=5e3;let ile=0;function O4e(e=u4e){ile=Date.now()+e}function Ein(e=Date.now()){return e<=ile}function d4e(e){O4e(),e.invalidateQueries({queryKey:ui.capabilities})}function f4e(e,t){if(!e||typeof e!="object")return null;const n=e,r=n.artifacts;if(!h4e(n)||!Array.isArray(r)||r.length===0||r.some(s=>!s||typeof s!="object"||typeof s.name!="string"))return null;const i=new Map,a=new Set(r.map(s=>s.name)),o=new Set;return r.map(s=>{const l=s,c=typeof l.name=="string"?l.name:"",u=(i.get(c)??0)+1;i.set(c,u);let O=u,d=u===1?c:`${c} (${O})`;for(;o.has(d)||d!==c&&a.has(d);)d=`${c} (${++O})`;o.add(d);const h=t.find(p=>p.kind==="audio"&&typeof l.digest=="string"&&p.attachment===l.digest)??null;return{id:JSON.stringify([l.request_id??null,c,u]),name:c,label:d,audio:h,costCaption:ale(l,!0),status:l.status==="cancelled"?"cancelled":l.status==="failed"||l.error?"failed":l.status==="completed"?"completed":"unknown",error:typeof l.error=="string"?l.error:null}})}function ale(e,t=!1){const n=e.cost&&typeof e.cost=="object"?e.cost:null;if(t&&(e.status==="failed"||e.error)&&e.cost_usd===0){if(n?.basis==="billed")return"No charge.";if(n?.basis==="estimated")return"Estimated cost $0; final charge not confirmed."}return az({...e,billing_basis:n?.basis??e.billing_basis})}function XP(e){const t=e,n=ale(t);if(!n)return"Total cost not yet known.";const r=t.cost_complete===!0;return`${r?"Total cost":"Known total cost"} ${n.slice(5)}${r?"":" Unknown or late charges are not included."}`}function h4e(e){return"cost_complete"in e||["completed","failed","cancelled"].some(t=>t in e)}function p4e(e,t){const n=e,r=s=>{const l=n[s];return typeof l=="number"&&Number.isInteger(l)&&l>=0?l:t.filter(c=>c.status===s).length},i=r("cancelled"),a=t.filter(s=>s.status==="unknown").length,o=t.filter(s=>s.status!=="completed");return`${r("completed")} completed · ${r("failed")} failed${i?` · ${i} cancelled/stopped`:""}${a?` · ${a} status unknown`:""}${o.length?`. Needs attention: ${o.map(s=>s.label).join("; ")}`:""}`}function m4e(e,t){const n=e;if(typeof n.error=="string"&&n.error)return n.error;const r=t?.split(`
|
|
3
3
|
`)[0];if(!r)return null;const i=r.indexOf("Batch ");return i>=0?r.slice(i):null}function g4e(e,t){const n=t&&typeof t=="object"?t:{},r=e&&typeof e=="object"?e.sounds:null,i=typeof n.total=="number"&&Number.isInteger(n.total)&&n.total>0?n.total:Array.isArray(r)&&r.length?r.length:null;if(i===null)return null;const a=n.item,o=typeof a=="number"&&Number.isInteger(a)&&a>=1&&a<=i&&typeof n.name=="string"?`Latest update: ${n.name} (item ${a} of ${i}).`:null;return{total:i,note:o}}const Qz="generate_video",kz="generate_voiceover",_z="generate_sound_effect",$4e=new Set(["generate_image",Qz,kz,_z]);function ole(e){return $4e.has(e)}function y4e(e){return e===Qz}function v4e(e){return e===kz||e===_z}function b4e(e){return e===Qz?"video":e===kz?"voiceover":e===_z?"sound-effect":"image"}const BN="Stopped before the provider was called; you will not be charged.",Wq="Stop requested. The provider has no cancellation endpoint; the generation continues and will be charged if it produces audio. Checking for settlement.",w4e="Audio generation is busy right now. Wait a moment and try again.";function Rh(e){switch(e){case"video":return"video";case"voiceover":return"voiceover";case"sound-effect":return"sound effect";default:return"image"}}function x4e(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=n.message;typeof r=="string"&&r&&t.push(r)}return t}function S4e(e){const t=e??{};return{stage:typeof t.stage=="string"?t.stage:null,fraction:typeof t.progress_fraction=="number"&&Number.isFinite(t.progress_fraction)?t.progress_fraction:null,logs:x4e(t.log_lines),queuePosition:typeof t.queue_position=="number"&&Number.isInteger(t.queue_position)?t.queue_position:null,error:typeof t.error=="string"&&t.error?t.error:null,errorType:typeof t.error_type=="string"&&t.error_type?t.error_type:null}}function HN(e){return e.fraction===null&&e.logs.length===0&&e.queuePosition===null?sle:{fraction:e.fraction,logs:e.logs,queuePosition:e.queuePosition}}const sle=Object.freeze({fraction:null,logs:[],queuePosition:null});function Q4e(e,{stopping:t=!1,settled:n=!1}={}){const r=S4e(e.details),i=b4e(e.toolName),a=i==="voiceover"||i==="sound-effect",o=a&&e.phase==="done"?f4e(e.details,e.images??[]):null,s=a?g4e(e.args,e.details):null,l=o?{batch:o,batchSummary:p4e(e.details,o),batchNote:m4e(e.details,e.output)}:{},c=a?P4e(e.details):null;if(e.stopped===!0)return{state:"cancelled",generating:e.startedAt!==null,message:r.error??e.output,...o?{...l,material:i,costCaption:XP(e.details)}:{},...c?{settlementCaption:c}:{},...c||n?{settled:!0}:{}};if(e.notRunKind==="skipped"||e.notRunKind==="aborted")return{state:"cancelled",generating:!1,message:e.output};if(e.notRunReason)return{state:"failed",material:i,message:e.notRunReason,errorType:a?RP(e.notRunKind,e.notRunReason):null};if(e.neverSent===!0)return{state:"cancelled",generating:!1,message:e.output};if(o&&e.isError)return{state:"failed",material:i,message:r.error??e.output,errorType:RP(r.errorType,r.error??e.output),...l,costCaption:XP(e.details)};if(e.isError===!0)return r.errorType==="media_already_completed"?{state:"done",images:e.images??[],material:i,durationS:e.durationS??null,receipt:"already-finished"}:r.stage==="cancelled"&&r.errorType===null?{state:"cancelled",generating:e.startedAt!==null,message:r.error??e.output,...c?{settlementCaption:c}:{},...c||n?{settled:!0}:{}}:{state:"failed",material:i,message:r.error??e.output??(r.errorType==="audio_rate_limited"?w4e:null),errorType:a?RP(r.errorType,r.error??e.output):null};switch(e.phase){case"composing":case"queued":return t?{state:"cancelling",generating:!1,material:i,startedAtMs:null,progress:sle}:{state:"queued",material:i,composing:e.phase==="composing",argumentBytes:e.argumentBytes??0,queuePosition:r.queuePosition};case"running":{const u=e.startedAt??null;return t?{state:"cancelling",generating:!0,material:i,startedAtMs:u,progress:HN(r)}:{state:"running",material:i,startedAtMs:u,progress:HN(r),note:r.error,...s?{batchProgress:s}:{}}}case"done":{const u=a?az(e.details,e.output):null;return{state:"done",images:e.images??[],material:i,durationS:e.durationS??null,receipt:"generated",batch:o,...l,costCaption:o?XP(e.details):u}}}}const k4e=/\s*Checking for settlement\.?\s*$/;function _4e(e){return e.replace(k4e,"").trimEnd()}function P4e(e){if(!e||typeof e!="object")return null;const t=e,n=t.cost;return t.settled===!0?az(e):t.settled===null&&t.cost_usd===null&&n?.basis==="quote"?"Settlement pending — the final charge will appear once the provider reports it.":null}function RP(e,t){if(!e)return null;const n=e.replace(/_/g," ");return t?.toLowerCase().startsWith(n.toLowerCase())?null:n.charAt(0).toUpperCase()+n.slice(1)}function T4e(e,t){const n=[],r=e.state==="queued"||e.state==="running"||e.state==="cancelling";t?.onCancel&&r&&n.push({kind:"cancel",disabled:e.state==="cancelling"});const i=e.state==="failed"||e.state==="cancelled";return t?.onRestart&&i&&n.push({kind:"restart",disabled:!1}),t?.onEditRestart&&i&&n.push({kind:"editRestart",disabled:!1}),n}function X4e(e,t){if(!y4e(e))return t?{onCancel:t}:void 0}function R4e(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const E4e=e=>{switch(e){case"success":return C4e;case"info":return A4e;case"warning":return z4e;case"error":return U4e;default:return null}},q4e=Array(12).fill(0),j4e=({visible:e,className:t})=>K.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},K.createElement("div",{className:"sonner-spinner"},q4e.map((n,r)=>K.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),C4e=K.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},K.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),z4e=K.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},K.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),A4e=K.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},K.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),U4e=K.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},K.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),W4e=K.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},K.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),K.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),N4e=()=>{const[e,t]=K.useState(document.hidden);return K.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let Nq=1;class Y4e{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:r,...i}=t,a=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:Nq++,o=this.toasts.find(l=>l.id===a),s=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),o?this.toasts=this.toasts.map(l=>l.id===a?(this.publish({...l,...t,id:a,title:r}),{...l,...t,id:a,dismissible:s,title:r}):l):this.addToast({title:r,...i,dismissible:s,id:a}),a},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const i=Promise.resolve(t instanceof Function?t():t);let a=r!==void 0,o;const s=i.then(async c=>{if(o=["resolve",c],K.isValidElement(c))a=!1,this.create({id:r,type:"default",message:c});else if(Z4e(c)&&!c.ok){a=!1;const O=typeof n.error=="function"?await n.error(`HTTP error! status: ${c.status}`):n.error,d=typeof n.description=="function"?await n.description(`HTTP error! status: ${c.status}`):n.description,p=typeof O=="object"&&!K.isValidElement(O)?O:{message:O};this.create({id:r,type:"error",description:d,...p})}else if(c instanceof Error){a=!1;const O=typeof n.error=="function"?await n.error(c):n.error,d=typeof n.description=="function"?await n.description(c):n.description,p=typeof O=="object"&&!K.isValidElement(O)?O:{message:O};this.create({id:r,type:"error",description:d,...p})}else if(n.success!==void 0){a=!1;const O=typeof n.success=="function"?await n.success(c):n.success,d=typeof n.description=="function"?await n.description(c):n.description,p=typeof O=="object"&&!K.isValidElement(O)?O:{message:O};this.create({id:r,type:"success",description:d,...p})}}).catch(async c=>{if(o=["reject",c],n.error!==void 0){a=!1;const u=typeof n.error=="function"?await n.error(c):n.error,O=typeof n.description=="function"?await n.description(c):n.description,h=typeof u=="object"&&!K.isValidElement(u)?u:{message:u};this.create({id:r,type:"error",description:O,...h})}}).finally(()=>{a&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),l=()=>new Promise((c,u)=>s.then(()=>o[0]==="reject"?u(o[1]):c(o[1])).catch(u));return typeof r!="string"&&typeof r!="number"?{unwrap:l}:Object.assign(r,{unwrap:l})},this.custom=(t,n)=>{const r=n?.id||Nq++;return this.create({jsx:t(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const Ca=new Y4e,G4e=(e,t)=>{const n=t?.id||Nq++;return Ca.addToast({title:e,...t,id:n}),n},Z4e=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",I4e=G4e,D4e=()=>Ca.toasts,V4e=()=>Ca.getActiveToasts(),hf=Object.assign(I4e,{success:Ca.success,info:Ca.info,warning:Ca.warning,error:Ca.error,custom:Ca.custom,message:Ca.message,promise:Ca.promise,dismiss:Ca.dismiss,loading:Ca.loading},{getHistory:D4e,getToasts:V4e});R4e("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}[data-sonner-toaster][data-lifted=true]{transform:translateY(-8px)}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function ob(e){return e.label!==void 0}const M4e=3,L4e="24px",F4e="16px",KN=4e3,B4e=356,H4e=14,K4e=45,J4e=200;function tl(...e){return e.filter(Boolean).join(" ")}function eEe(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const tEe=e=>{var t,n,r,i,a,o,s,l,c;const{invert:u,toast:O,unstyled:d,interacting:h,setHeights:p,visibleToasts:g,heights:y,index:v,toasts:b,expanded:x,removeToast:Q,defaultRichColors:w,closeButton:S,style:k,cancelButtonStyle:P,actionButtonStyle:R,className:T="",descriptionClassName:q="",duration:X,position:C,gap:N,expandByDefault:A,classNames:Y,icons:W,closeButtonAriaLabel:Z="Close toast"}=e,[D,z]=K.useState(null),[V,J]=K.useState(null),[G,ne]=K.useState(!1),[L,B]=K.useState(!1),[se,H]=K.useState(!1),[ee,re]=K.useState(!1),[fe,le]=K.useState(!1),[Pe,ce]=K.useState(0),[ve,xe]=K.useState(0),Te=K.useRef(O.duration||X||KN),de=K.useRef(null),we=K.useRef(null),Me=v===0,rt=v+1<=g,Ne=O.type,pt=O.dismissible!==!1,ht=O.className||"",at=O.descriptionClassName||"",te=K.useMemo(()=>y.findIndex(bt=>bt.toastId===O.id)||0,[y,O.id]),pe=K.useMemo(()=>{var bt;return(bt=O.closeButton)!=null?bt:S},[O.closeButton,S]),$e=K.useMemo(()=>O.duration||X||KN,[O.duration,X]),_e=K.useRef(0),He=K.useRef(0),We=K.useRef(0),Ut=K.useRef(null),[It,ye]=C.split("-"),it=K.useMemo(()=>y.reduce((bt,cn,tr)=>tr>=te?bt:bt+cn.height,0),[y,te]),lt=N4e(),Tt=O.invert||u,Ct=Ne==="loading";He.current=K.useMemo(()=>te*N+it,[te,it]),K.useEffect(()=>{Te.current=$e},[$e]),K.useEffect(()=>{ne(!0)},[]),K.useEffect(()=>{const bt=we.current;if(bt){const cn=bt.getBoundingClientRect().height;return xe(cn),p(tr=>[{toastId:O.id,height:cn,position:O.position},...tr]),()=>p(tr=>tr.filter(sr=>sr.toastId!==O.id))}},[p,O.id]),K.useLayoutEffect(()=>{if(!G)return;const bt=we.current,cn=bt.style.height;bt.style.height="auto";const tr=bt.getBoundingClientRect().height;bt.style.height=cn,xe(tr),p(sr=>sr.find(nr=>nr.toastId===O.id)?sr.map(nr=>nr.toastId===O.id?{...nr,height:tr}:nr):[{toastId:O.id,height:tr,position:O.position},...sr])},[G,O.title,O.description,p,O.id]);const pn=K.useCallback(()=>{B(!0),ce(He.current),p(bt=>bt.filter(cn=>cn.toastId!==O.id)),setTimeout(()=>{Q(O)},J4e)},[O,Q,p,He]);K.useEffect(()=>{if(O.promise&&Ne==="loading"||O.duration===1/0||O.type==="loading")return;let bt;return x||h||lt?(()=>{if(We.current<_e.current){const sr=new Date().getTime()-_e.current;Te.current=Te.current-sr}We.current=new Date().getTime()})():(()=>{Te.current!==1/0&&(_e.current=new Date().getTime(),bt=setTimeout(()=>{O.onAutoClose==null||O.onAutoClose.call(O,O),pn()},Te.current))})(),()=>clearTimeout(bt)},[x,h,O,Ne,lt,pn]),K.useEffect(()=>{O.delete&&pn()},[pn,O.delete]);function Ie(){var bt;if(W?.loading){var cn;return K.createElement("div",{className:tl(Y?.loader,O==null||(cn=O.classNames)==null?void 0:cn.loader,"sonner-loader"),"data-visible":Ne==="loading"},W.loading)}return K.createElement(j4e,{className:tl(Y?.loader,O==null||(bt=O.classNames)==null?void 0:bt.loader),visible:Ne==="loading"})}const ft=O.icon||W?.[Ne]||E4e(Ne);var ln,_n;return K.createElement("li",{tabIndex:0,ref:we,className:tl(T,ht,Y?.toast,O==null||(t=O.classNames)==null?void 0:t.toast,Y?.default,Y?.[Ne],O==null||(n=O.classNames)==null?void 0:n[Ne]),"data-sonner-toast":"","data-rich-colors":(ln=O.richColors)!=null?ln:w,"data-styled":!(O.jsx||O.unstyled||d),"data-mounted":G,"data-promise":!!O.promise,"data-swiped":fe,"data-removed":L,"data-visible":rt,"data-y-position":It,"data-x-position":ye,"data-index":v,"data-front":Me,"data-swiping":se,"data-dismissible":pt,"data-type":Ne,"data-invert":Tt,"data-swipe-out":ee,"data-swipe-direction":V,"data-expanded":!!(x||A&&G),style:{"--index":v,"--toasts-before":v,"--z-index":b.length-v,"--offset":`${L?Pe:He.current}px`,"--initial-height":A?"auto":`${ve}px`,...k,...O.style},onDragEnd:()=>{H(!1),z(null),Ut.current=null},onPointerDown:bt=>{Ct||!pt||(de.current=new Date,ce(He.current),bt.target.setPointerCapture(bt.pointerId),bt.target.tagName!=="BUTTON"&&(H(!0),Ut.current={x:bt.clientX,y:bt.clientY}))},onPointerUp:()=>{var bt,cn,tr;if(ee||!pt)return;Ut.current=null;const sr=Number(((bt=we.current)==null?void 0:bt.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ha=Number(((cn=we.current)==null?void 0:cn.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),nr=new Date().getTime()-((tr=de.current)==null?void 0:tr.getTime()),ai=D==="x"?sr:Ha,Ii=Math.abs(ai)/nr;if(Math.abs(ai)>=K4e||Ii>.11){ce(He.current),O.onDismiss==null||O.onDismiss.call(O,O),J(D==="x"?sr>0?"right":"left":Ha>0?"down":"up"),pn(),re(!0);return}else{var Qt,Gn;(Qt=we.current)==null||Qt.style.setProperty("--swipe-amount-x","0px"),(Gn=we.current)==null||Gn.style.setProperty("--swipe-amount-y","0px")}le(!1),H(!1),z(null)},onPointerMove:bt=>{var cn,tr,sr;if(!Ut.current||!pt||((cn=window.getSelection())==null?void 0:cn.toString().length)>0)return;const nr=bt.clientY-Ut.current.y,ai=bt.clientX-Ut.current.x;var Ii;const Qt=(Ii=e.swipeDirections)!=null?Ii:eEe(C);!D&&(Math.abs(ai)>1||Math.abs(nr)>1)&&z(Math.abs(ai)>Math.abs(nr)?"x":"y");let Gn={x:0,y:0};const Dr=Rr=>1/(1.5+Math.abs(Rr)/20);if(D==="y"){if(Qt.includes("top")||Qt.includes("bottom"))if(Qt.includes("top")&&nr<0||Qt.includes("bottom")&&nr>0)Gn.y=nr;else{const Rr=nr*Dr(nr);Gn.y=Math.abs(Rr)<Math.abs(nr)?Rr:nr}}else if(D==="x"&&(Qt.includes("left")||Qt.includes("right")))if(Qt.includes("left")&&ai<0||Qt.includes("right")&&ai>0)Gn.x=ai;else{const Rr=ai*Dr(ai);Gn.x=Math.abs(Rr)<Math.abs(ai)?Rr:ai}(Math.abs(Gn.x)>0||Math.abs(Gn.y)>0)&&le(!0),(tr=we.current)==null||tr.style.setProperty("--swipe-amount-x",`${Gn.x}px`),(sr=we.current)==null||sr.style.setProperty("--swipe-amount-y",`${Gn.y}px`)}},pe&&!O.jsx&&Ne!=="loading"?K.createElement("button",{"aria-label":Z,"data-disabled":Ct,"data-close-button":!0,onClick:Ct||!pt?()=>{}:()=>{pn(),O.onDismiss==null||O.onDismiss.call(O,O)},className:tl(Y?.closeButton,O==null||(r=O.classNames)==null?void 0:r.closeButton)},(_n=W?.close)!=null?_n:W4e):null,(Ne||O.icon||O.promise)&&O.icon!==null&&(W?.[Ne]!==null||O.icon)?K.createElement("div",{"data-icon":"",className:tl(Y?.icon,O==null||(i=O.classNames)==null?void 0:i.icon)},O.promise||O.type==="loading"&&!O.icon?O.icon||Ie():null,O.type!=="loading"?ft:null):null,K.createElement("div",{"data-content":"",className:tl(Y?.content,O==null||(a=O.classNames)==null?void 0:a.content)},K.createElement("div",{"data-title":"",className:tl(Y?.title,O==null||(o=O.classNames)==null?void 0:o.title)},O.jsx?O.jsx:typeof O.title=="function"?O.title():O.title),O.description?K.createElement("div",{"data-description":"",className:tl(q,at,Y?.description,O==null||(s=O.classNames)==null?void 0:s.description)},typeof O.description=="function"?O.description():O.description):null),K.isValidElement(O.cancel)?O.cancel:O.cancel&&ob(O.cancel)?K.createElement("button",{"data-button":!0,"data-cancel":!0,style:O.cancelButtonStyle||P,onClick:bt=>{ob(O.cancel)&&pt&&(O.cancel.onClick==null||O.cancel.onClick.call(O.cancel,bt),pn())},className:tl(Y?.cancelButton,O==null||(l=O.classNames)==null?void 0:l.cancelButton)},O.cancel.label):null,K.isValidElement(O.action)?O.action:O.action&&ob(O.action)?K.createElement("button",{"data-button":!0,"data-action":!0,style:O.actionButtonStyle||R,onClick:bt=>{ob(O.action)&&(O.action.onClick==null||O.action.onClick.call(O.action,bt),!bt.defaultPrevented&&pn())},className:tl(Y?.actionButton,O==null||(c=O.classNames)==null?void 0:c.actionButton)},O.action.label):null)};function JN(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function nEe(e,t){const n={};return[e,t].forEach((r,i)=>{const a=i===1,o=a?"--mobile-offset":"--offset",s=a?F4e:L4e;function l(c){["top","right","bottom","left"].forEach(u=>{n[`${o}-${u}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${o}-${c}`]=s:n[`${o}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(s)}),n}const rEe=K.forwardRef(function(t,n){const{invert:r,position:i="bottom-right",hotkey:a=["altKey","KeyT"],expand:o,closeButton:s,className:l,offset:c,mobileOffset:u,theme:O="light",richColors:d,duration:h,style:p,visibleToasts:g=M4e,toastOptions:y,dir:v=JN(),gap:b=H4e,icons:x,containerAriaLabel:Q="Notifications"}=t,[w,S]=K.useState([]),k=K.useMemo(()=>Array.from(new Set([i].concat(w.filter(V=>V.position).map(V=>V.position)))),[w,i]),[P,R]=K.useState([]),[T,q]=K.useState(!1),[X,C]=K.useState(!1),[N,A]=K.useState(O!=="system"?O:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),Y=K.useRef(null),W=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),Z=K.useRef(null),D=K.useRef(!1),z=K.useCallback(V=>{S(J=>{var G;return(G=J.find(ne=>ne.id===V.id))!=null&&G.delete||Ca.dismiss(V.id),J.filter(({id:ne})=>ne!==V.id)})},[]);return K.useEffect(()=>Ca.subscribe(V=>{if(V.dismiss){requestAnimationFrame(()=>{S(J=>J.map(G=>G.id===V.id?{...G,delete:!0}:G))});return}setTimeout(()=>{kRe.flushSync(()=>{S(J=>{const G=J.findIndex(ne=>ne.id===V.id);return G!==-1?[...J.slice(0,G),{...J[G],...V},...J.slice(G+1)]:[V,...J]})})})}),[w]),K.useEffect(()=>{if(O!=="system"){A(O);return}if(O==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?A("dark"):A("light")),typeof window>"u")return;const V=window.matchMedia("(prefers-color-scheme: dark)");try{V.addEventListener("change",({matches:J})=>{A(J?"dark":"light")})}catch{V.addListener(({matches:G})=>{try{A(G?"dark":"light")}catch(ne){console.error(ne)}})}},[O]),K.useEffect(()=>{w.length<=1&&q(!1)},[w]),K.useEffect(()=>{const V=J=>{var G;if(a.every(B=>J[B]||J.code===B)){var L;q(!0),(L=Y.current)==null||L.focus()}J.code==="Escape"&&(document.activeElement===Y.current||(G=Y.current)!=null&&G.contains(document.activeElement))&&q(!1)};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[a]),K.useEffect(()=>{if(Y.current)return()=>{Z.current&&(Z.current.focus({preventScroll:!0}),Z.current=null,D.current=!1)}},[Y.current]),K.createElement("section",{ref:n,"aria-label":`${Q} ${W}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},k.map((V,J)=>{var G;const[ne,L]=V.split("-");return w.length?K.createElement("ol",{key:V,dir:v==="auto"?JN():v,tabIndex:-1,ref:Y,className:l,"data-sonner-toaster":!0,"data-sonner-theme":N,"data-y-position":ne,"data-lifted":T&&w.length>1&&!o,"data-x-position":L,style:{"--front-toast-height":`${((G=P[0])==null?void 0:G.height)||0}px`,"--width":`${B4e}px`,"--gap":`${b}px`,...p,...nEe(c,u)},onBlur:B=>{D.current&&!B.currentTarget.contains(B.relatedTarget)&&(D.current=!1,Z.current&&(Z.current.focus({preventScroll:!0}),Z.current=null))},onFocus:B=>{B.target instanceof HTMLElement&&B.target.dataset.dismissible==="false"||D.current||(D.current=!0,Z.current=B.relatedTarget)},onMouseEnter:()=>q(!0),onMouseMove:()=>q(!0),onMouseLeave:()=>{X||q(!1)},onDragEnd:()=>q(!1),onPointerDown:B=>{B.target instanceof HTMLElement&&B.target.dataset.dismissible==="false"||C(!0)},onPointerUp:()=>C(!1)},w.filter(B=>!B.position&&J===0||B.position===V).map((B,se)=>{var H,ee;return K.createElement(tEe,{key:B.id,icons:x,index:se,toast:B,defaultRichColors:d,duration:(H=y?.duration)!=null?H:h,className:y?.className,descriptionClassName:y?.descriptionClassName,invert:r,visibleToasts:g,closeButton:(ee=y?.closeButton)!=null?ee:s,interacting:X,position:V,style:y?.style,unstyled:y?.unstyled,classNames:y?.classNames,cancelButtonStyle:y?.cancelButtonStyle,actionButtonStyle:y?.actionButtonStyle,closeButtonAriaLabel:y?.closeButtonAriaLabel,removeToast:z,toasts:w.filter(re=>re.position==B.position),heights:P.filter(re=>re.position==B.position),setHeights:R,expandByDefault:o,gap:b,expanded:T,swipeDirections:t.swipeDirections})})):null}))}),iEe=["ERR_INTERNET_DISCONNECTED","ERR_NETWORK_CHANGED","ERR_NAME_NOT_RESOLVED","ERR_TIMED_OUT","ERR_CONNECTION_RESET","ERR_CONNECTION_REFUSED","ERR_CONNECTION_CLOSED","ERR_CONNECTION_FAILED","ERR_CONNECTION_TIMED_OUT","ERR_ADDRESS_UNREACHABLE","ERR_NETWORK_IO_SUSPENDED","ERR_PROXY_CONNECTION_FAILED"],aEe=["ENOTFOUND","EAI_AGAIN","ETIMEDOUT","ECONNRESET","ECONNREFUSED","EHOSTUNREACH","ENETUNREACH","ENETDOWN","ENETRESET","ECONNABORTED","EPIPE"],oEe=["Failed to fetch","Load failed","NetworkError when attempting to fetch resource."],sEe=new Set(iEe),lEe=/[:\-\u2014\n]$/,cEe=/^[:\n]/,eY=/[:\uff1a\n\u2014]| - /g,uEe=/^(?:\s*Error:\s*)+/,OEe=/:\s+Error:\s+/g,dEe=/\b(?:net::)?(ERR_[A-Z0-9_]+)\b/g,fEe=aEe.map(e=>({code:e,pattern:new RegExp(`\\b${e}\\b`)}));function EP(e,t,n){const r=e.slice(0,t).trimEnd(),i=e.slice(t+n).trimStart(),a=r===""||lEe.test(r),o=i===""||cEe.test(i);return a&&o}function lle(e){const t=pEe(e);if(!t)return null;const n=cle(t);for(const r of n.matchAll(dEe)){const i=r[1];if(!sEe.has(i))continue;const a=r.index??0,o=a+r[0].length;return{code:`net::${i}`,start:a,end:o,clauseText:qP(n,a,o),clause:EP(n,a,o-a)}}for(const{code:r,pattern:i}of fEe){const a=i.exec(n);if(a){const o=a.index,s=o+a[0].length;return{code:r,start:o,end:s,clauseText:qP(n,o,s),clause:EP(n,o,s-o)}}}for(const r of oEe){const i=n.indexOf(r);if(i!==-1&&EP(n,i,r.length))return{code:r,start:i,end:i+r.length,clauseText:qP(n,i,i+r.length),clause:!0}}return null}function hEe(e){return lle(e)?.code??null}function qin(e){return hEe(e)!==null}function pEe(e){if(typeof e=="string")return e;if(e instanceof Error)return e.message||e.name||"";if(e&&typeof e=="object"&&"message"in e){const t=e.message;return typeof t=="string"?t:""}return""}function qP(e,t,n){let r=0;for(const a of e.slice(0,t).matchAll(eY))r=(a.index??0)+a[0].length;let i=e.length;for(const a of e.slice(n).matchAll(eY)){i=n+(a.index??0);break}return e.slice(r,i).trim()}function cle(e){return e.replace(uEe,"").replace(OEe,": ")}const sg=new Map,jP=new Map,CP=new Map,tY=5e3,mEe=1,gEe={CONNECTION:["Failed to fetch","Network error","ERR_CONNECTION_REFUSED","Server is offline","Connection failed"]},$Ee={"Failed to fetch":!0,"TypeError: Failed to fetch":!0,"Load failed":!0,"NetworkError when attempting to fetch resource.":!0,ERR_CONNECTION_REFUSED:!0,"net::ERR_CONNECTION_REFUSED":!0},zP=()=>m("ui.common.connection.transport_failure"),ule=e=>{const t=e.trim();if(Object.prototype.hasOwnProperty.call($Ee,t))return zP();const n=cle(t),r=lle(n);return r===null?e:r.clause?`${n.slice(0,r.start)}${zP()}${n.slice(r.end)}`:zP()},yEe=e=>{for(const[t,n]of Object.entries(gEe))if(n.some(r=>e.includes(r)))return t;return null},jin=(e,t)=>hf.loading(e,t),Tr=(e,t)=>{const n=Date.now(),i=yEe(e)||e,a=ule(e),o=jP.get(i);if(o&&n-o<tY)return null;const s=CP.get(i)||0;if(s>=mEe)return null;if(sg.has(i))return jP.set(i,n),sg.get(i);const l=hf.error(a,{...t,onDismiss:c=>{sg.delete(i),t?.onDismiss?.(c)},onAutoClose:c=>{sg.delete(i),t?.onAutoClose?.(c)}});return sg.set(i,l),jP.set(i,n),CP.set(i,s+1),setTimeout(()=>{CP.set(i,0)},tY),l},AP=(e,t)=>hf.error(ule(e),t),Jo=(e,t)=>hf.info(e,t),k0=e=>{hf.dismiss(e)},aO=(e,t)=>hf.success(e,t),Sh=(e,t)=>hf.warning(e,t),vEe={"under-window":{dark:{canvas:.59,surface:.67,elevated:.87},light:{canvas:.61,surface:.5,elevated:.45}},menu:{dark:{canvas:.73,surface:.79,elevated:.94},light:{canvas:.79,surface:.7,elevated:.65}},popover:{dark:{canvas:.79,surface:.85,elevated:.97},light:{canvas:.86,surface:.79,elevated:.75}}},bEe={dark:.09,light:.12},wEe={dark:{role:"sunken",scale:.73},light:{role:"surface",scale:.72}},xEe={dark:.91,light:.78},SEe={"under-window":{dark:.15,light:.2},menu:{dark:.15,light:.2},popover:{dark:.15,light:.15}},QEe={hover:.05,selected:.08,field:.05,work:.08},cl={alphaFloor:vEe,blockVeil:bEe,laneWash:wEe,bandFloor:xEe,controlMix:SEe,stateAlpha:QEe},Cin=["sidebars","full"],Ole=(e,t)=>e!=="vibrancy"?"popover":t==="menu"?"menu":t==="popover"?"popover":"under-window",kEe=.96,dle=e=>Math.round(e*100)/100;function _Ee(e,t,n){const r=cl.alphaFloor[Ole(e,t)][n];return{canvas:r.canvas,surface:r.surface,elevated:r.elevated}}function PEe(e){const t=Math.min(100,Math.max(0,e.intensity))/100,n=_Ee(e.mechanism,e.material,e.scheme),r=i=>{const a=Math.max(kEe,i);return dle(a-t*(a-i))};return{canvas:r(n.canvas),surface:r(n.surface),elevated:r(n.elevated)}}const TEe={sidebars:["sidebar"],full:["sidebar","canvas","pane"]};function XEe(e,t,n){return cl.controlMix[Ole(e,t)][n]}function REe(e){const t=PEe(e),n=i=>dle(Math.min(1,Math.max(0,1-(1-i)/(1-t.canvas)))),r={"--lo-glass-a-canvas":String(t.canvas),"--lo-glass-a-surface":String(t.surface),"--lo-glass-a-elevated":String(t.elevated),"--lo-glass-a-row-hover":String(cl.stateAlpha.hover),"--lo-glass-a-row-selected":String(cl.stateAlpha.selected),"--lo-glass-a-row-work":String(cl.stateAlpha.work),"--lo-glass-a-field":String(cl.stateAlpha.field),"--lo-glass-a-block-veil":String(cl.blockVeil[e.scheme]),"--lo-glass-a-band-floor":String(cl.bandFloor[e.scheme]),"--lo-glass-a-lane":String(Math.round(t.canvas*cl.laneWash[e.scheme].scale*100)/100),"--lo-glass-lane-tone":cl.laneWash[e.scheme].role==="sunken"?"var(--lo-sunken)":"var(--lo-surface)","--lo-glass-control-mix":String(XEe(e.mechanism,e.material,e.scheme)),"--lo-glass-in-surface":String(n(t.surface)),"--lo-glass-in-elevated":String(n(t.elevated))};return{kinds:TEe[e.coverage].join(" "),vars:r}}const fle=()=>document.documentElement,EEe=["--lo-glass-a-canvas","--lo-glass-a-surface","--lo-glass-a-elevated","--lo-glass-a-row-hover","--lo-glass-a-row-selected","--lo-glass-a-row-work","--lo-glass-a-block-veil","--lo-glass-a-band-floor","--lo-glass-a-lane","--lo-glass-lane-tone","--lo-glass-a-field","--lo-glass-control-mix","--lo-glass-in-surface","--lo-glass-in-elevated"];let i1=null;const ox=()=>fle().classList.contains("dark")?"dark":"light";function sx(e){i1=e;const t=fle();if(!e||!e.active){delete t.dataset.glass;for(const i of EEe)t.style.removeProperty(i);return}const{kinds:n,vars:r}=REe({coverage:e.settings.coverage,intensity:e.settings.intensity,mechanism:e.mechanism,material:e.settings.material,scheme:e.scheme});t.dataset.glass=n;for(const[i,a]of Object.entries(r))t.style.setProperty(i,a)}function zin(e){sx(e?{active:!0,scheme:e.scheme,mechanism:e.mechanism,settings:{coverage:e.coverage,intensity:e.intensity,material:e.material}}:null)}function Yq(e){if(!e||!e.active||e.capability.mechanism==="none"){sx(null);return}e.restartRequired&&e.active||sx({active:!0,scheme:ox(),mechanism:e.capability.mechanism,settings:{coverage:e.settings.coverage,intensity:e.settings.intensity,material:e.settings.material}})}function Ain(){!i1||!i1.active||(sx({...i1,scheme:ox()}),window.api?.windowGlass?.reportScheme?.(ox()))}function Uin(){const e=window.api?.windowGlass;if(!e)return()=>{};const t=e.onState(r=>Yq(r)),n=r=>{r&&Yq(r)};return typeof CSS<"u"&&e.reportRenderer?.({backdropFilter:CSS.supports("backdrop-filter: blur(1px)")}).then(n,()=>{}),e.get?.().then(n,()=>{}),t}function Win(){const[e,t]=$.useState(null);return $.useEffect(()=>{const r=window.api?.windowGlass;if(!r)return;let i=!1;r.get().then(o=>{i||t(o)});const a=r.onState(o=>t(o));return()=>{i=!0,a()}},[]),{state:e,set:async r=>{const i=await window.api?.windowGlass?.set(r);i&&(t(i),Yq(i),window.api?.windowGlass?.reportScheme?.(ox()))}}}const qEe=function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"}(),jEe=function(e,t){return new URL(e,t).href},nY={},be=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){const o=document.getElementsByTagName("link"),s=document.querySelector("meta[property=csp-nonce]"),l=s?.nonce||s?.getAttribute("nonce");i=Promise.allSettled(n.map(c=>{if(c=jEe(c,r),c in nY)return;nY[c]=!0;const u=c.endsWith(".css"),O=u?'[rel="stylesheet"]':"";if(!!r)for(let p=o.length-1;p>=0;p--){const g=o[p];if(g.href===c&&(!u||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${c}"]${O}`))return;const h=document.createElement("link");if(h.rel=u?"stylesheet":qEe,u||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),document.head.appendChild(h),u)return new Promise((p,g)=>{h.addEventListener("load",p),h.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function a(o){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=o,window.dispatchEvent(s),!s.defaultPrevented)throw o}return i.then(o=>{for(const s of o||[])s.status==="rejected"&&a(s.reason);return t().catch(a)})};/**
|
|
4
4
|
* React Router DOM v6.30.0
|
|
5
5
|
*
|
|
@@ -514,7 +514,7 @@ import{r as $,b as K,h as zTe,j as f,c as E,u as iz,g as In,G as mse,i as ATe,H
|
|
|
514
514
|
${t}`)}throw new Error(`Failed to load configuration: ${e instanceof Error?e.message:String(e)}`)}}const o1=H7e();let Yle=null;function yY(e){Yle=e}const mf={get baseUrl(){return Yle??o1.VITE_LOCAL_OPERATOR_API_URL},radientBaseUrl:o1.VITE_RADIENT_SERVER_BASE_URL,radientClientId:o1.VITE_RADIENT_CLIENT_ID};function K7e(e){return e.fromBridge!==!0?!1:e.projectKey.trim()!==""}const Din=K7e({fromBridge:typeof window>"u"?void 0:window.api?.telemetryEnabled,projectKey:o1.VITE_PUBLIC_POSTHOG_KEY}),J7e=["config"],e6e=()=>wt({enabled:!0,queryKey:J7e,queryFn:async()=>{const t=await Jy(mf.baseUrl).config.getConfig();if(t.status>=400)throw new Ln(t.status,t.message||m("ui.common.errors.configuration_fetch"));return t.result},refetchOnWindowFocus:!1,staleTime:5e3,retry:Ir}),vY=["server-health"],t6e=["internet-connectivity"],n6e=(e=5e3)=>{const t=Zs();return $.useEffect(()=>{const n=window.api?.backend?.onStatusChange;if(n)return n(r=>{yY(r.url),t.invalidateQueries({queryKey:vY})})},[t]),wt({queryKey:vY,queryFn:async()=>{const n=window.api?.backend;if(n){const r=await n.getStatus();return yY(r.url),{online:t2e(r.state),snapshot:r}}try{return await Ale.healthCheck(mf.baseUrl),{online:!0,snapshot:null}}catch{return{online:!1,snapshot:null}}},refetchInterval:e,refetchIntervalInBackground:!1,retry:!1,refetchOnWindowFocus:!0,placeholderData:n=>n})},r6e=(e=5e3)=>{const[t,n]=$.useState(navigator.onLine);return $.useEffect(()=>{const r=()=>{n(!0)},i=()=>{n(!1)};return window.addEventListener("online",r),window.addEventListener("offline",i),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",i)}},[]),wt({queryKey:t6e,queryFn:async()=>t&&navigator.onLine,refetchInterval:e,refetchIntervalInBackground:!1,retry:!1,refetchOnWindowFocus:!0,placeholderData:r=>r})},i6e=(e=5e3)=>{const{data:t,isLoading:n,refetch:r}=n6e(e),i=t?.online??!0,a=t?.snapshot??null,{data:o,isLoading:s}=e6e(),l=o?.values.hosting||"",c=l.toLowerCase()!=="ollama",{data:u=!0,isLoading:O,refetch:d}=r6e(e);return $.useEffect(()=>{const g=()=>{d()},y=()=>{d()};return window.addEventListener("online",g),window.addEventListener("offline",y),()=>{window.removeEventListener("online",g),window.removeEventListener("offline",y)}},[d]),{isServerOnline:i,serverSnapshot:a,isOnline:u,hostingProvider:l,shouldCheckInternet:c,hasConnectivityIssue:!i||c&&!u,connectivityIssue:i?c&&!u?"internet_offline":null:"server_offline",isLoading:n||c&&O||s,refetchServerStatus:r,refetchInternetStatus:d}},zz=()=>{const{isServerOnline:e,isOnline:t,hostingProvider:n,shouldCheckInternet:r,hasConnectivityIssue:i,connectivityIssue:a,isLoading:o,refetchInternetStatus:s}=i6e(),l=Zs();$.useEffect(()=>{const d=()=>{s(),l.invalidateQueries({refetchType:"all"})},h=()=>{s(),l.invalidateQueries({predicate:p=>{const g=p.queryKey[0];return g!=="server-health"&&g!=="internet-connectivity"&&g!=="config"},refetchType:"active"})};return window.addEventListener("online",d),window.addEventListener("offline",h),()=>{window.removeEventListener("online",d),window.removeEventListener("offline",h)}},[s,l]);const c=$.useRef(!1);return $.useEffect(()=>{if(!o){if(!e){c.current=!0;return}c.current&&(c.current=!1,l.invalidateQueries({predicate:d=>{const h=d.queryKey[0];return h!=="server-health"&&h!=="internet-connectivity"&&h!=="config"},refetchType:"active"}))}},[e,o,l]),{shouldEnableQuery:d=>!(o||!d?.bypassServerCheck&&!e),getConnectivityError:()=>o||e?null:new Error(m("ui.common.errors.server_offline")),isServerOnline:e,isOnline:t,hostingProvider:n,shouldCheckInternet:r,hasConnectivityIssue:i,connectivityIssue:a,isLoading:o}},Vin=Xi()(yO((e,t)=>({lastChatAgentId:null,lastAgentsPageAgentId:null,setLastChatAgentId:n=>{e({lastChatAgentId:n})},setLastAgentsPageAgentId:n=>{e({lastAgentsPageAgentId:n})},getLastAgentId:n=>n==="chat"?t().lastChatAgentId:t().lastAgentsPageAgentId,clearLastAgentId:n=>{e(n==="chat"?{lastChatAgentId:null}:{lastAgentsPageAgentId:null})},clearAgentFromAllPages:n=>{const r=t(),i={};r.lastChatAgentId===n&&(i.lastChatAgentId=null),r.lastAgentsPageAgentId===n&&(i.lastAgentsPageAgentId=null),Object.keys(i).length>0&&e(i)}}),{name:"agent-selection-storage"})),a6e={xs:"max-w-md",sm:"max-w-xl",md:"max-w-4xl",lg:"max-w-6xl",xl:"max-w-7xl"},g$=({open:e,onClose:t,title:n,children:r,actions:i,maxWidth:a="sm",fullWidth:o=!1,dialogProps:s={},dataTourTag:l})=>{const c=$.useRef(null);$.useEffect(()=>{if(e){c.current=document.activeElement instanceof HTMLElement?document.activeElement:null;return}const d=c.current;c.current=null,d&&document.contains(d)&&d.focus({preventScroll:!0})},[e]);const{className:u,...O}=s;return iz(e,"dialog"),f.jsx(mz,{open:e,onOpenChange:d=>{d||t()},children:f.jsxs(gz,{className:E("max-h-[calc(100vh-4rem)]",o?"w-full":"w-auto min-w-80",a===!1?"max-w-[calc(100vw-4rem)]":a6e[a],u),...O,children:[f.jsx(CRe,{className:"shrink-0",children:f.jsx($z,{className:"flex items-center gap-3",children:n})}),f.jsx("div",{className:"min-h-0 overflow-y-auto","data-tour-tag":l,children:r}),i&&f.jsx(zRe,{className:"shrink-0",children:i})]})})},FQ=$.forwardRef(({startIcon:e,children:t,className:n,...r},i)=>f.jsxs(ke,{ref:i,size:"lg",className:E("min-w-25",n),...r,children:[e,t]}));FQ.displayName="ActionButton";const Eh=$.forwardRef((e,t)=>f.jsx(FQ,{ref:t,variant:"primary",...e}));Eh.displayName="PrimaryButton";const dl=$.forwardRef((e,t)=>f.jsx(FQ,{ref:t,variant:"secondary",...e}));dl.displayName="SecondaryButton";const o6e=$.forwardRef((e,t)=>f.jsx(FQ,{ref:t,variant:"danger",...e}));o6e.displayName="DangerButton";const Az="data-chat-region",s6e="data-region-entry",l6e=`[${Az}]`,c6e=`[${s6e}]`,sd=["sidebar","header","transcript","composer"];function Gle(e){switch(e){case"sidebar":return m("ui.chat.sidebar.nav.chats");case"composer":return m("ui.chat.region.composer");case"header":case"transcript":return m("ui.chat.region.conversation")}}const u6e=e=>e.key==="F6"?e.metaKey||e.ctrlKey||e.altKey?null:e.shiftKey?-1:1:!e.altKey||!(e.metaKey||e.ctrlKey)||e.shiftKey?null:e.key==="ArrowDown"?1:e.key==="ArrowUp"?-1:null,Zle=e=>{const t=e;if(typeof t?.closest!="function")return null;const r=t.closest(l6e)?.getAttribute(Az);return r!=null&&O6e(r)?r:null},O6e=e=>sd.includes(e),d6e=(e,t,n)=>{const r=sd.filter(a=>e.querySelector(Ile(a))!==null);if(r.length===0)return null;if(t===null)return n===1?r[0]:r[r.length-1];const i=sd.indexOf(t);for(let a=1;a<=sd.length;a+=1){const o=sd[(i+n*a+4*sd.length)%sd.length];if(r.includes(o))return o}return r[0]},f6e=(e,t)=>{const n=e.querySelector(Ile(t));if(n===null)return null;const i=n.querySelector(c6e)??n;return i.focus(),i},Ile=e=>`[${Az}="${e}"]`,Min=e=>{if(!(e.metaKey||e.ctrlKey)||!e.shiftKey||e.altKey)return null;const t=e.key.toLowerCase();return t==="p"?"pin":t==="a"?"archive":null},h6e=(e,t)=>{const n=e==="pin"?"P":"A";return t?`⌘⇧${n}`:`Ctrl+Shift+${n}`},Lin=(e,t)=>t?`⌘+⇧+${e==="pin"?"P":"A"}`:h6e(e,t),Fin=e=>(e.metaKey||e.ctrlKey)&&e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="l",Bin=e=>e?"⌘+⇧+L":"Ctrl+Shift+L",Hin=e=>e?"⌘⇧L":"Ctrl+Shift+L",p6e={pin:"data-session-pin",archive:"data-session-archive"},Kin=(e,t)=>{const n=e;return typeof n?.closest!="function"?null:n.closest("[data-session-row]")?.querySelector(`[${p6e[t]}]`)??null},m6e=Xi(e=>({tab:null,setTab:t=>e({tab:t})})),Dq=Xi(e=>({count:0,backToTop:null,publish:(t,n)=>e({count:t,backToTop:n})})),g6e={queries:{staleTime:5*60*1e3,gcTime:10*60*1e3,retry:1,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!1,networkMode:"always"},mutations:{retry:1,networkMode:"always"}},Uz={refetchOnWindowFocus:!1},$6e=new n2e({defaultOptions:g6e}),Pd=new Map,Wz=new Map;function BQ(e,t){const n=new Blob([e],{type:t}),r=URL.createObjectURL(n);return Wz.set(r,n),r}function Dle(e){return Wz.get(e)??null}function ev(e){URL.revokeObjectURL(e),Wz.delete(e)}function $$(e){return Pd.get(e)?.url??null}function fp(e){const t=Pd.get(e);return t?(t.refs+=1,t.revoking=!1,t.url):null}function Nz(e,t){if(Pd.get(e)){ev(t);return}Pd.set(e,{url:t,refs:0,revoking:!1})}function hp(e){const t=Pd.get(e);t&&(t.refs-=1,!(t.refs>0)&&(t.revoking||(t.revoking=!0,queueMicrotask(()=>{!t.revoking||t.refs>0||(ev(t.url),Pd.get(e)===t&&Pd.delete(e))}))))}const Yz=/^[0-9a-f]{64}$/;function y6e(e,t){return`/v1/agents/${encodeURIComponent(e)}/avatar?v=${t}`}function Vle(e){if(e===null||typeof e!="object")return null;const t=e;return typeof t.sha256!="string"||!Yz.test(t.sha256)?null:{sha256:t.sha256,mime:typeof t.mime=="string"?t.mime:"image/png",bytes:typeof t.bytes=="number"?t.bytes:0,updated_at:typeof t.updated_at=="string"?t.updated_at:""}}function v6e(e){return e?.agent_id?e.locality!=="remote":!1}function Jin(e){const t=e?.agent_id??null,n=e?.avatar_sha256??null;if(!e||!t||!n)return null;const r=e.binding?.agent||null;return{agentId:t,agentName:r,sha256:n,owned:r!==null&&v6e(e)}}const b6e=10*1024*1024,Mle=["image/jpeg","image/png","image/webp","image/gif"],ean=Mle.join(","),w6e=4e7,x6e=/^data:image\/(?:webp|png|jpeg);base64,[A-Za-z0-9+/]+={0,2}$/;function tan(e){return Mle.includes(e.type)?e.size<=0?"decode":e.size>b6e?"size":null:"type"}function nan(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0||e*t>w6e?"decode":null}function S6e(e){if(e===null||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[n,r]of Object.entries(e))typeof n!="string"||n.length===0||n.length>200||typeof r=="string"&&x6e.test(r)&&(t[n]=r);return t}const HQ=["agents","avatars"],Q6e=500;let Lle=null;const tv=()=>Lle??$6e;let Fle=new Set;async function k6e(){const e=await $n({op:"legacy.agents.list",page:1,perPage:Q6e});if(!e.ok)throw new Error(`agents list ${e.status}`);const t=await e.json(),n={},r=new Set;for(const i of t.result?.agents??[]){r.add(i.id);const a=Vle(i.avatar);a&&(n[i.id]=a)}return Fle=r,n}function Ble(e=!0){Lle=Zs();const t=wt({queryKey:HQ,queryFn:k6e,enabled:e,staleTime:3e4,retry:1,refetchOnWindowFocus:!1}),n=t.data;return $.useEffect(()=>{n&&E6e(n)},[n]),t}function ran(){Ble(!0)}function ian(e,t){const n=t!==void 0,{data:r}=Ble(!!e&&!n),i=n?t&&Yz.test(t)?t:null:e?r?.[e]?.sha256??null:null;return _6e(e??null,i)}function _6e(e,t){const n=e&&t?y6e(e,t):null,[r,i]=$.useState(()=>({key:n,url:n?$$(n):null}));return $.useEffect(()=>{if(!n||!e||!t){i({key:n,url:null});return}const a=fp(n);if(a)return i({key:n,url:a}),()=>hp(n);i({key:n,url:null});let o=!1,s=!1;return is({op:"agent.avatar",agentId:e,sha256:t},null).then(l=>{if(o||l.kind!=="bytes")return;Nz(n,BQ(l.data,l.mimeType));const c=fp(n);s=c!==null,i({key:n,url:c})}).catch(()=>{}),()=>{o=!0,s&&hp(n)}},[n,e,t]),n?r.key===n?r.url:$$(n)??null:null}function Gz(){tv().invalidateQueries({queryKey:["agents"]}),Or.getState().fetchSessions()}async function P6e(e,t){const n=new Uint8Array(await t.arrayBuffer()),r=await is({op:"agent.avatar.put",agentId:e},n);if(r.status>=400||r.kind==="error")throw Ud(r);const i=r.kind==="json"?Vle(r.body?.avatar??r.body):null;return i&&tv().setQueryData(HQ,a=>({...a??{},[e]:i})),Gz(),i}async function aan(e){const t=await is({op:"agent.avatar.delete",agentId:e},null);if(t.status!==404&&(t.status>=400||t.kind==="error"))throw Ud(t);tv().setQueryData(HQ,n=>{if(!n)return n;const{[e]:r,...i}=n;return i}),Gz()}function T6e(e){typeof e?.agent_id!="string"||!e.agent_id||(tv().setQueryData(HQ,t=>{if(!t)return t;const{[e.agent_id]:n,...r}=t;return!e.sha256||!Yz.test(e.sha256)?r:{...r,[e.agent_id]:{...n??{mime:"image/png",bytes:0,updated_at:""},sha256:e.sha256}}}),Gz())}const Vq="agent-avatar-storage";let lb=null;function X6e(){try{const e=globalThis.localStorage?.getItem(Vq);if(!e)return{};const t=JSON.parse(e);return S6e(t?.state?.images)}catch{return{}}}function NP(e){try{if(Object.keys(e).length===0){globalThis.localStorage?.removeItem(Vq);return}globalThis.localStorage?.setItem(Vq,JSON.stringify({state:{images:e},version:0}))}catch{}}function R6e(e){const t=/^data:(image\/[a-z]+);base64,(.+)$/.exec(e);if(!t)return null;try{const n=atob(t[2]),r=new Uint8Array(n.length);for(let i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return new Blob([r],{type:t[1]})}catch{return null}}function E6e(e){return lb||(lb=(async()=>{const t=X6e(),n=Object.keys(t);if(n.length===0){NP({});return}const r=new Set(tv().getQueriesData({queryKey:["agents"]}).flatMap(([,a])=>Array.isArray(a?.agents)?a.agents:[]).map(a=>a.id));for(const a of Object.keys(e))r.add(a);for(const a of Fle)r.add(a);const i={...t};for(const a of n){if(e[a]){delete i[a];continue}if(r.size>0&&!r.has(a))continue;const o=R6e(t[a]);if(!o){delete i[a];continue}try{await P6e(a,o),delete i[a]}catch{}NP(i)}NP(i)})(),lb)}function q6e(){const e=new Set,t=new Set;let n=0,r=null,i=0;const a=new WeakMap,o=()=>{n+=1;for(const c of t)c()},s=()=>{i+=1,e.size!==0&&(e.clear(),o())},l=c=>{e.has(c)||(e.add(c),o())};return{note:l,noteFrame:(c,u)=>{const O=a.get(u);return O===void 0&&a.set(u,i),(O??i)!==i?!1:(c!==null&&l(c),!0)},has:c=>e.has(c),reset:()=>{r=null,s()},observeProcess:c=>{const u=r;r=c,u!==null&&u!==c&&s()},subscribe:c=>(t.add(c),()=>void t.delete(c)),version:()=>n}}const YP=q6e();let Mq=null,bY=null;const Lq=new Set;function j6e(e){const t=`${e.epoch}:${e.seq}`;if(Mq?.key!==t){Mq={key:t,revision:e.payload.revision,unreadCount:e.payload.unread_count,waitingCount:e.payload.waiting_count,waitingUnreadCount:e.payload.waiting_unread_count};for(const n of Lq)n()}}const GP={subscribe(e){return Lq.add(e),()=>{Lq.delete(e)}},snapshot:()=>Mq,serverSnapshot:()=>null};function Hle(){const e=dr(),t=globalThis.window?.api?.desktop?.feed,n=Nn(e.data,"desktop_feed")&&!!t,[r,i]=$.useState(!1),[a,o]=$.useState(!1),[s,l]=$.useState(null),[c,u]=$.useState(0),[O,d]=$.useState(null),[h,p]=$.useState(0),[g,y]=$.useState(null),[v,b]=$.useState(null),x=$.useRef(!1),Q=$.useRef(!1);return $.useEffect(()=>{if(!n||!t){x.current=!1,i(!1),o(!1),YP.reset();return}const w=Or.getState().applyAttention,S=Or.getState().applySessionStatus,k=t.watchState(({connected:R})=>{R&&(Q.current&&!x.current&&p(T=>T+1),Q.current=!0),R||YP.reset(),x.current=R,o(!0),i(R)}),P=t.subscribe(R=>{if(YP.observeProcess(R.epoch),R.type==="attention"){w(R.session_id,R.payload),R.payload.unseen===!0&&u(T=>T+1);return}if(R.type==="session_status"){S(R.session_id,{code:R.payload.code,label:R.payload.label},R.payload.revision,R.epoch),u(T=>T+1);return}if(R.type==="catalogue"){l(R.payload.revision);return}if(R.type==="authoring"&&d(R.payload.revision),R.type==="code_requests"){y({sessionId:R.session_id,revision:R.payload.revision});return}if(R.type==="notifications"){j6e(R);return}if(R.type==="agent.avatar.changed"){const T=`${R.epoch}:${R.seq}`;bY!==T&&(bY=T,T6e(R.payload));return}R.type==="config"&&b({changedKeys:R.payload.changed_keys,language:R.payload.language,epoch:R.epoch,seq:R.seq})});return()=>{P(),k()}},[n,t]),{available:n,connected:n&&r,reported:n&&a,catalogueRevision:s,activityRevision:c,authoringRevision:O,authoringReconnectRevision:h,codeRequestsRevision:g,configChange:v}}const oan={kind:"all",priority:"any",from:null},san=e=>e.kind!=="all"||e.priority!=="any"||e.from!==null,wY={high:3,normal:2,low:1},Gd=e=>e.source==="ask"&&(e.ask?.status===void 0||e.ask.status==="open");function C6e(e,t){return e.filter(n=>!(n.dismissed||t.kind==="asks"&&n.source!=="ask"||t.kind==="updates"&&n.source!=="notify"||t.priority==="high"&&n.priority!=="high"||t.priority==="normal_up"&&wY[n.priority]<wY.normal||t.from!==null&&n.session.id!==t.from))}const Fq=6e3,z6e=Number.POSITIVE_INFINITY,lan=e=>e?z6e:Fq,ZP=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()};function Kle(e,t){const n=ZP(t);if(e>=n)return"today";const r=ZP(n-1);if(e>=r)return"yesterday";const i=ZP(r-6*864e5+1);return e>=i?"week":"older"}const IP=(e,t)=>t.updated_at-e.updated_at||t.seq-e.seq;function can(e,t,n,r){const i=new Set(t.map(u=>u.id)),a=e.filter(u=>!i.has(u.id)&&!Gd(u)).sort(IP),o=[...t,...e.filter(u=>!i.has(u.id)&&Gd(u))].sort(IP),s=[];if(o.length>0&&s.push({kind:"waiting",key:"waiting",items:o}),n==="time"){const u=["today","yesterday","week","older"],O=new Map;for(const d of a){const h=Kle(d.updated_at,r),p=O.get(h)??[];p.push(d),O.set(h,p)}for(const d of u){const h=O.get(d);h&&h.length>0&&s.push({kind:"time",key:d,items:h})}return s}const l=new Map;for(const u of a){const O=l.get(u.session.id)??[];O.push(u),l.set(u.session.id,O)}const c=[...l.entries()].sort(([,u],[,O])=>IP(u[0],O[0]));for(const[u,O]of c)s.push({kind:"conversation",key:`session:${u}`,sessionId:u,title:O[0].session.title,items:O});return s}const uan=e=>e.flatMap(t=>t.items);function A6e(e){const t=e.filter(n=>!Gd(n));return{dismissable:t,asksStaying:e.length-t.length}}const Oan=(e,t)=>e.map(n=>{const r=t.get(n.id);return r!==void 0&&r>=n.revision?{...n,read:!0,read_via:"explicit"}:n}),dan=(e,t)=>new Set(t.filter(n=>e.has(n))),Zd=(e,t)=>e.revision>t.revision||e.revision===t.revision&&e.seq>=t.seq;function Jle(e,t,n){if(!t)return e?{...e,newerCount:0}:void 0;if(!e)return{...t,newerCount:0};const r=new Set([...t.items,...t.waiting??[]].map(s=>s.id)),i=[...e.items,...e.waiting??[]].filter(s=>!r.has(s.id)).length,a=new Map(e.items.map(s=>[s.id,s]));if(!n)return{...e,items:t.items.map(s=>{const l=a.get(s.id);return l&&Zd(l,s)?l:s}),reelWaiting:(e.waiting??[]).filter(s=>r.has(s.id)),next_cursor:t.next_cursor,newerCount:i};const o=new Map;for(const s of t.items)o.set(s.id,s);for(const s of e.items){const l=o.get(s.id);(!l||Zd(s,l))&&o.set(s.id,s)}return{...e,items:[...o.values()].sort((s,l)=>l.seq-s.seq),next_cursor:t.next_cursor,newerCount:0}}function U6e(e,t,n=!1){const[r,...i]=e;if(!r)return null;const a=new Set(e.flatMap(l=>l.items.map(c=>c.id))),o=t.filter(l=>!a.has(l.id));if(o.length===0)return null;if(n&&o.length===t.length)return"reset";const s=[...o].sort((l,c)=>c.seq-l.seq);return[{...r,items:[...s,...r.items]},...i]}function Zz(e,t,n){const r=new Set(t),i=a=>r.has(a.id)?n==="read"?{...a,read:!0,read_via:"explicit"}:n==="unread"?{...a,read:!1,read_via:null}:n==="dismiss"?{...a,dismissed:!0}:{...a,dismissed:!1}:a;return e.map(a=>({...a,items:a.items.map(i)}))}function W6e(e,t,n,r=0){if(!e||!Array.isArray(e.items))return e;const[i]=Zz([e],t,n);return{...i,unread_count:Math.max(0,e.unread_count+r)}}const fan=e=>e,han=(e,t)=>e.filter(n=>!t||n.session.id===t).map(n=>`${n.id}@${n.revision}:${n.read?1:0}${n.dismissed?"d":""}`).sort().join(","),pan=e=>e?`${e.high_water??0}:${e.waiting?.length??0}:${e.unread_count??0}`:"",man=(e,t)=>t||e==="conversation";function gan(e,t,n,r){const i=new Set(r),a=e.findIndex(c=>c.id===n),o=t?e.findIndex(c=>c.id===t):-1;if(a<0)return i;if(o<0)return i.add(n),i;const[s,l]=o<a?[o,a]:[a,o];for(let c=s;c<=l;c+=1)i.add(e[c].id);return i}const $an=e=>e?Math.max(0,e.unread_count)+Math.max(0,e.waiting_unread_count):0,ece=e=>e.read?e.read_via==="watching"?"live":e.read_via==="in_view"?"in_view":null:null;function tce(e,t){const n=Math.max(0,t-e);if(n<6e4)return{kind:"now"};const r=Kle(e,t);return r==="today"?n<36e5?{kind:"minutes",count:Math.floor(n/6e4)}:{kind:"hours",count:Math.floor(n/36e5)}:r==="yesterday"?{kind:"clock",at:e}:{kind:"date",at:e}}async function yan(e,t){const n=Object.freeze({...t.scope}),r=t.throughSeq,i=new Map;if(t.verb==="read"&&"all"in n)for(const s of t.waiting)i.set(s.id,Object.freeze({...s}));let a;const o=new Set;do{const s=await e({state:t.verb==="read"?"unread":"all",limit:100,throughSeq:r,source:"notify",..."sessionId"in n?{sessionId:n.sessionId}:{},...a?{cursor:a}:{}});for(const l of s.observed)!l.id.startsWith("ask:")&&!i.has(l.id)&&i.set(l.id,Object.freeze({...l}));if(a=s.next_cursor||void 0,a&&o.has(a))throw new Error("Notification cursor did not advance");a&&o.add(a)}while(a);return Object.freeze({scope:n,throughSeq:r,tokens:Object.freeze([...i.values()])})}const xY=e=>({changed:e.changed.length,skipped:e.skipped.length,pending:e.pending.length}),van=(e,t)=>e.changed.length===t&&e.skipped.length===0&&e.pending.length===0&&e.error===void 0,N6e=e=>e==="read"?"unread":e==="unread"?"read":e==="dismiss"?"undismiss":"dismiss";async function ban(e,t,n,r,i){const a=[...new Map(n.map(l=>[l.id,{...l}])).values()],o={changed:[],skipped:[],pending:a},s=new Set;i?.(xY(o));for(let l=0;l<a.length;l+=500){const c=a.slice(l,l+500),u=new Map(c.map(O=>[O.id,O]));try{const O=await e(t,r?{...r.scope,throughSeq:r.throughSeq,observed:c}:{items:c});for(const d of O.changed){const h=u.get(d);h&&!s.has(d)&&(o.changed.push(h),s.add(d))}for(const d of O.skipped)u.has(d.id)&&!s.has(d.id)&&(o.skipped.push(d),s.add(d.id))}catch(O){o.error=O}if(o.pending=a.filter(O=>!s.has(O.id)),i?.(xY(o)),o.error)break}return o}function Y6e(e,t){return t.excluded.has(e.id)?!1:Gd(e)?t.asks.some(n=>n.id===e.id):e.seq<=t.preview.through_seq&&(t.state==="all"||!e.read)&&C6e([e],t.filters).length===1}const Bq=e=>e.includeAskReads===!0&&e.preview.selection_version===2;function G6e(e){const t=[...e.excluded.values()],n=t.filter(Gd),r=t.filter(c=>!Gd(c)),i=e.preview,a=Math.max(0,(i.eligible_ask_count??i.skipped_ask_count)-n.length),o=Math.max(0,(i.eligible_update_count??i.eligible_count)-r.length),s=Math.max(0,(i.eligible_unread_update_count??i.eligible_unread_count)-r.filter(c=>!c.read).length),l=Math.max(0,(i.eligible_unread_ask_count??0)-n.filter(c=>!c.read).length);return{count:o+a,asks:a,eligible:o,updateUnread:s,askUnread:l,readable:o+(Bq(e)?a:0),unread:s+(Bq(e)?l:0)}}function Z6e(e,t){const n=G6e(e),r=(a,o)=>t==="unread"?a-o:-o,i={};for(const[a,o]of Object.entries(e.preview.session_counts)){const s=[...e.excluded.values()].filter(u=>u.source==="notify"&&u.session.id===a),l=Math.max(0,(o.eligible_update_count??o.eligible_count)-s.length),c=Math.max(0,(o.eligible_unread_update_count??o.eligible_unread_count)-s.filter(u=>!u.read).length);i[a]=r(l,c)}return{throughSeq:e.preview.through_seq,unreadDelta:r(n.eligible,n.updateUnread),waitingUnreadDelta:Bq(e)&&t!=="dismiss"?r(n.asks,n.askUnread):0,sessionUnreadDeltas:i}}const qt={all:["desktop","notifications"],list:e=>["desktop","notifications","list",e],session:e=>["desktop","notifications","session",e],detail:e=>["desktop","notifications","detail",e],count:["desktop","notifications","count"],facts:e=>["desktop","notifications","facts",e],sessionFacts:e=>["desktop","notifications","session-facts",e],sessionFactsAll:["desktop","notifications","session-facts"],listRoot:["desktop","notifications","list"],factsRoot:["desktop","notifications","facts"],sessionsRoot:["desktop","notifications","session"],sessionUnread:e=>["desktop","notifications","session-unread",e]};function I6e(){const e=dr();return Nn(e.data,"notifications",1)}function D6e(e,t){return nv(),wt({queryKey:qt.facts(e),enabled:t,queryFn:()=>qe({op:"notifications.list",state:e,limit:100}),retry:Ir,staleTime:5e3,refetchInterval:3e4,refetchIntervalInBackground:!1})}function V6e(e,t){return nv(),wt({queryKey:qt.sessionFacts(e??""),enabled:t&&!!e,queryFn:()=>qe({op:"notifications.list",state:"all",source:"notify",sessionId:e??"",limit:100}),retry:Ir,staleTime:5e3,refetchInterval:3e4,refetchIntervalInBackground:!1})}function nce(e,t,n,r){const i=JSON.stringify(t),a=n?.atTop===!0;$.useEffect(()=>{const o=r?.items;if(!e||!a||!o)return;const s=e.getQueryData(t);if(!s||!Array.isArray(s.pages))return;const l=U6e(s.pages,o,!!r.next_cursor),c=s.pages[0],u=c&&c.waiting!==r.waiting;if(l===null&&!u)return;if(l==="reset"){e.resetQueries({queryKey:t});return}const O=l??s.pages;e.setQueryData(t,{...s,pages:u?[{...c,...O[0],waiting:r.waiting},...O.slice(1)]:O})},[e,i,a,r])}function wan(e,t,n){nv();const{client:r}=mi(),i=D6e(e,t),[a,o]=$.useState(0),s=rle({queryKey:qt.list(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:c})=>qe({op:"notifications.list",state:e,limit:100,...c??{}}),getNextPageParam:c=>c.next_cursor?{cursor:c.next_cursor,throughSeq:c.high_water}:void 0,select:c=>{const u=c.pages[0],O=new Map;for(const d of c.pages)for(const h of d.items){const p=O.get(h.id);(!p||Zd(h,p))&&O.set(h.id,h)}return{...u,items:[...O.values()],next_cursor:c.pages.at(-1)?.next_cursor}},retry:Ir,staleTime:5e3,refetchInterval:!1,refetchIntervalInBackground:!1});nce(r,qt.list(e),n,i.data);const l=Jle(i.data,s.data,n?.atTop??!0);return{...s,data:l,dataUpdatedAt:Math.max(s.dataUpdatedAt,i.dataUpdatedAt),newerCount:l?.newerCount??0,refresh:i.refetch,windowResetAt:a,resetToTop:()=>(o(c=>c+1),r?.resetQueries({queryKey:qt.list(e)}),i.refetch())}}function Iz(e,t,n){nv();const{client:r}=mi(),i=V6e(e,t),a=rle({queryKey:qt.session(e??""),enabled:t&&!!e,initialPageParam:void 0,queryFn:({pageParam:s})=>qe({op:"notifications.list",state:"all",sessionId:e??"",source:"notify",limit:100,...s??{}}),getNextPageParam:s=>s.next_cursor?{cursor:s.next_cursor,throughSeq:s.high_water}:void 0,select:s=>{const l=s.pages[0],c=new Map;for(const u of s.pages)for(const O of u.items){const d=c.get(O.id);(!d||Zd(O,d))&&c.set(O.id,O)}return{...l,items:[...c.values()],next_cursor:s.pages.at(-1)?.next_cursor}},retry:Ir,staleTime:5e3,refetchInterval:!1,refetchIntervalInBackground:!1});nce(r,qt.session(e??""),n,i.data);const o=Jle(i.data,a.data,n?.atTop??!0);return{...a,data:o,dataUpdatedAt:Math.max(a.dataUpdatedAt,i.dataUpdatedAt),newerCount:o?.newerCount??0,resetToTop:()=>(r?.resetQueries({queryKey:qt.session(e??"")}),i.refetch())}}async function M6e(e,t=n=>qe({op:"notifications.list",...n})){let n,r=0;const i=new Set;for(;;){const a=await t({state:"unread",source:"notify",sessionId:e,limit:100,...n?{cursor:n}:{}});r+=a.items.filter(s=>!s.read&&!s.dismissed).length;const o=a.next_cursor??void 0;if(!o||i.has(o))return r;i.add(o),n=o}}function xan(e,t){return wt({queryKey:qt.detail(e??""),enabled:t&&!!e,queryFn:()=>qe({op:"notifications.get",id:e??""}),retry:Ir,staleTime:5e3})}function San(e){return nv(),wt({queryKey:qt.count,enabled:e,queryFn:()=>qe({op:"notifications.count"}),retry:Ir,staleTime:5e3,refetchInterval:3e4,refetchIntervalInBackground:!1})}const SY=new WeakMap,DP=new WeakMap,L6e=750;function F6e(e){if(!e)return Promise.resolve();const t=DP.get(e);t&&clearTimeout(t);const n=setTimeout(()=>{DP.delete(e),e.invalidateQueries({queryKey:qt.factsRoot}),e.invalidateQueries({queryKey:qt.sessionFactsAll})},L6e);return DP.set(e,n),Promise.resolve()}function nv(){const e=$.useSyncExternalStore(GP.subscribe,GP.snapshot,GP.serverSnapshot),{client:t,provided:n}=mi();$.useEffect(()=>{!n||!e||SY.get(t)!==e.key&&(SY.set(t,e.key),t.setQueryData(qt.count,{unread_count:e.unreadCount,waiting_count:e.waitingCount,waiting_unread_count:e.waitingUnreadCount,high_water:e.revision}),F6e(t))},[e,t,n])}const eO=e=>e.map(t=>({id:t.id,revision:t.revision}));function B6e(e,t){return e==="read"||e==="unread"?qe({op:"notifications.read",verb:e,target:t}):qe({op:"notifications.dismiss",verb:e,target:t})}function Dz(){const{client:e}=mi();return ax({onMutate:({verb:t,target:n})=>"items"in n?s1(e,t,n.items):void 0,onError:(t,n,r)=>r?.(),mutationFn:({verb:t,target:n})=>B6e(t,n),retry:r2e,onSuccess:(t,n,r)=>{r?(r.settle(t),e?.invalidateQueries({queryKey:qt.factsRoot}),e?.invalidateQueries({queryKey:qt.sessionFactsAll}),e?.invalidateQueries({queryKey:qt.count})):rce(e,n.verb,t.changed)}})}function Qan(){const e=Dz();return $.useMemo(()=>{const t=n=>r=>e.mutateAsync({verb:n,target:{items:eO(r)}});return{markRead:t("read"),markUnread:t("unread"),dismiss:t("dismiss"),restore:t("undismiss"),isPending:e.isPending}},[e.mutateAsync,e.isPending])}const QY=(e,t,n)=>W6e(e,t,n);function lx(e){const t=new Map,n=r=>{const i=t.get(r.id);(!i||Zd(r,i))&&t.set(r.id,r)};for(const r of[qt.factsRoot,qt.sessionFactsAll,qt.listRoot,qt.sessionsRoot])for(const[,i]of e.getQueriesData({queryKey:r})){for(const a of[...i?.items??[],...i?.waiting??[]])n(a);for(const a of i?.pages??[])for(const o of[...a?.items??[],...a?.waiting??[]])n(o)}return t}const Hq=new WeakMap,cx=e=>+(!e.read&&!e.dismissed);function P0(e,t){let n=t===void 0?e.base:[...e.history,e.base].filter(r=>r.seq<=t).at(-1)??e.history[0]??e.base;for(const r of e.operations)r.revision!==n.revision||t!==void 0&&(r.confirmedAt===void 0||r.confirmedAt>t)||r.confirmedAt!==void 0&&n.seq>=r.confirmedAt||(n=Zz([{items:[n]}],[n.id],r.verb)[0].items[0]);return n}function zu(e,t,n){return!e||n>=e.seq?{count:t,seq:n}:e}function kY(e,t,n){if(!n||t[0]!=="desktop"||t[1]!=="notifications")return;if(t[2]==="session-unread"&&typeof n=="number"){const i=String(t[3]);e.sessions.set(i,zu(e.sessions.get(i),n,Number(t[4])||0));return}const r=n;["facts","session-facts","count"].includes(String(t[2]))&&typeof r.unread_count=="number"&&(e.global=zu(e.global,r.unread_count,r.high_water??0)),["facts","session-facts","count"].includes(String(t[2]))&&typeof r.waiting_unread_count=="number"&&(e.waiting=zu(e.waiting,r.waiting_unread_count,r.high_water??0));for(const i of[...r.items??[],...(r.pages??[]).flatMap(a=>a.items)]){const a=e.rows.get(i.id);a&&(i.revision>a.base.revision||i.seq>a.base.seq)&&(a.history.push(a.base),a.base=i)}}function T0(e,t){if(!t.publishing){t.publishing=!0;try{const n=(a,o)=>{let s=0;for(const l of t.rows.values())o&&l.base.session.id!==o||(s+=cx(P0(l))-cx(P0(l,a.seq)));for(const l of t.scopes.values())s+=o?(l.sessionUnreadDeltas[o]??0)-(l.knownSessionDeltas.get(o)??0):l.unreadDelta-l.knownDelta;return Math.max(0,a.count+s)},r=t.waiting?Math.max(0,t.waiting.count+[...t.scopes.values()].reduce((a,o)=>a+(o.waitingUnreadDelta??0),0)):void 0,i=a=>a.filter(o=>o.seq>(t.absent.get(o.id)??-1)).map(o=>{const s=t.rows.get(o.id);if(!s)return o;const l=P0(s);return Zd(l,o)?{...o,read:l.read,read_via:l.read_via,dismissed:l.dismissed}:o});for(const a of[qt.listRoot,qt.sessionsRoot])e.setQueriesData({queryKey:a},o=>o?.pages?{...o,pages:o.pages.map(s=>({...s,items:i(s.items),...s.waiting?{waiting:i(s.waiting)}:{}}))}:o);for(const a of[qt.factsRoot,qt.sessionFactsAll])e.setQueriesData({queryKey:a},o=>o?.items?{...o,items:i(o.items),...o.waiting?{waiting:i(o.waiting)}:{},waiting_unread_count:r??o.waiting_unread_count,unread_count:t.global?n(t.global):o.unread_count}:o);e.setQueryData(qt.count,a=>a&&t.global?{...a,unread_count:n(t.global),waiting_unread_count:r??a.waiting_unread_count}:a);for(const[a,o]of t.sessions)e.setQueriesData({queryKey:qt.sessionUnread(a)},s=>typeof s=="number"?n(o,a):s)}finally{t.publishing=!1}}}function H6e(e){const t=Hq.get(e);if(t)return t;const n={rows:new Map,sessions:new Map,scopes:new Map,absent:new Map,publishing:!1};Hq.set(e,n);for(const[r,i]of e.getQueriesData({queryKey:qt.all}))kY(n,r,i);return e.getQueryCache().subscribe(r=>{n.publishing||r.type!=="updated"||r.action.type!=="success"||r.query.queryKey[0]!=="desktop"||r.query.queryKey[1]!=="notifications"||(kY(n,r.query.queryKey,r.query.state.data),T0(e,n))}),n}async function s1(e,t,n,r){if(!e||!n.length&&!r)return;await e.cancelQueries({queryKey:qt.all});const i=H6e(e),a=lx(e),o=Symbol("notification-write"),s=[];let l=0;const c=new Map;for(const d of n){const h=typeof d=="string"?d:d.id,p=a.get(h);if(!p||p.source!=="notify"||s.includes(h))continue;let g=i.rows.get(h);(!g||p.revision>g.base.revision||p.seq>g.base.seq)&&(g={base:p,history:g?[...g.history,g.base]:[],operations:g?.operations??[]},i.rows.set(h,g));const y=P0(g);g.operations.push({owner:o,verb:t,revision:typeof d=="string"?p.revision:d.revision});const v=cx(P0(g))-cx(y);l+=v,c.set(p.session.id,(c.get(p.session.id)??0)+v),s.push(h)}r&&i.scopes.set(o,{...r,sessionUnreadDeltas:{...r.sessionUnreadDeltas},knownDelta:l,knownSessionDeltas:c}),T0(e,i);let u=!1;const O=d=>{if(u)return;u=!0,i.scopes.delete(o);const h=new Set(d?.changed??[]);for(const p of s){const g=i.rows.get(p);g&&(g.operations=g.operations.flatMap(y=>y.owner!==o?[y]:h.has(p)?[{...y,confirmedAt:d?.high_water??Number.POSITIVE_INFINITY}]:[]))}d&&(i.global=zu(i.global,d.unread_count,d.high_water),i.waiting=zu(i.waiting,d.waiting_unread_count,d.high_water)),T0(e,i)};return Object.assign(()=>O(),{settle:d=>O(d),settleCompact:d=>{if(u)return;O(),i.global=zu(i.global,d.unread_count,d.high_water),i.waiting=zu(i.waiting,d.waiting_unread_count,d.high_water);for(const[p,g]of Object.entries(d.session_counts??{}))typeof d.counts_high_water=="number"&&typeof g.unread_count=="number"&&i.sessions.set(p,zu(i.sessions.get(p),g.unread_count,d.counts_high_water));const h=d.reconciliation;if(h){const p=lx(e),g=new Map(h.items.filter(b=>{const x=p.get(b.id);return!x||Zd(b,x)}).map(b=>[b.id,b])),y=new Set(h.absent_ids.filter(b=>(p.get(b)?.seq??0)<=h.high_water));for(const[b,x]of g){const Q=i.rows.get(b);Q&&(Q.history.push(Q.base),Q.base=x)}for(const b of y)i.rows.delete(b),i.absent.set(b,h.high_water);const v=b=>b.filter(x=>!y.has(x.id)).map(x=>g.get(x.id)??x);i.publishing=!0;try{for(const b of[qt.factsRoot,qt.sessionFactsAll])e.setQueriesData({queryKey:b},x=>x?.items?{...x,items:v(x.items),...x.waiting?{waiting:v(x.waiting)}:{}}:x);for(const b of[qt.listRoot,qt.sessionsRoot])e.setQueriesData({queryKey:b},x=>x?.pages?{...x,pages:x.pages.map(Q=>({...Q,items:v(Q.items),...Q.waiting?{waiting:v(Q.waiting)}:{}}))}:x)}finally{i.publishing=!1}}else e.refetchQueries({queryKey:qt.factsRoot,type:"active"}),e.refetchQueries({queryKey:qt.sessionFactsAll,type:"active"});h&&(d.counts_high_water===void 0||Object.values(d.session_counts??{}).some(p=>p.unread_count===void 0))&&e.refetchQueries({queryKey:qt.sessionFactsAll,type:"active"}),T0(e,i)}})}function rce(e,t,n){if(!e||n.length===0)return;const r=Hq.get(e);if(r){for(const a of n){const o=r.rows.get(a);if(o){const s=[...o.operations].reverse().find(l=>l.verb===t&&l.confirmedAt===void 0);s?s.confirmedAt=o.base.seq+1:o.operations.push({owner:Symbol("external-receipt"),verb:t,revision:o.base.revision,confirmedAt:o.base.seq+1})}}r.publishing=!0}const i=a=>!a||!Array.isArray(a.pages)?a:{...a,pages:Zz(a.pages,n,t)};e.setQueriesData({queryKey:qt.listRoot},i),e.setQueriesData({queryKey:qt.sessionsRoot},i),e.setQueriesData({queryKey:qt.factsRoot},a=>QY(a,n,t)),e.setQueriesData({queryKey:qt.sessionFactsAll},a=>QY(a,n,t)),r&&(r.publishing=!1,T0(e,r)),e.invalidateQueries({queryKey:qt.factsRoot}),e.invalidateQueries({queryKey:qt.sessionFactsAll}),e.invalidateQueries({queryKey:qt.count});for(const a of n)e.invalidateQueries({queryKey:qt.detail(a)})}function K6e(e){return qe({op:"notifications.seen",...e})}async function kan(e,t=n=>qe({op:"notifications.list",...n})){const n={};let r;const i=new Set;for(;;){const a=await t({state:"all",source:"notify",limit:100,throughSeq:e,...r?{cursor:r}:{}});for(const s of a.items)s.dismissed||s.source==="ask"||(n[s.session.id]=(n[s.session.id]??0)+1);const o=a.next_cursor??void 0;if(!o||i.has(o))return n;i.add(o),r=o}}async function _an(e,t,n=[],r=!1){return(await qe({op:"notifications.list",preview:!0,state:t,kind:e.kind,bulkPriority:e.priority,countSessionIds:n,...r?{includeAskReads:!0}:{},...e.from?{sessionId:e.from}:{}})).selection}function Pan(e){const{client:t}=mi(),n=$.useRef(new Map),r=$.useCallback(()=>t?t.getQueryCache().findAll({queryKey:qt.sessionUnread(null).slice(0,-1)}).filter(c=>c.isActive()).map(c=>String(c.queryKey[3])).slice(0,50):[],[t]),i=$.useCallback(c=>{const u=t?[...lx(t).keys()]:[];return[...new Set([...c,...u])].slice(0,500)},[t]),a=$.useCallback(()=>{t&&(e?e():t.resetQueries({queryKey:qt.listRoot}),t.resetQueries({queryKey:qt.sessionsRoot}))},[t,e]),o=$.useCallback(async(c,u,O=[])=>{n.current.clear();const d=t?[...lx(t).values()].filter(g=>Y6e(g,u)):[],h=await s1(t,c,eO(d),Z6e(u,c)),p=i(O);try{const g={selectionToken:u.preview.token,excludedIds:[...u.excluded.keys()],...u.preview.selection_version===2?{reconcileIds:p}:{}},y=await qe(c==="dismiss"?{op:"notifications.dismiss",verb:c,target:g}:{op:"notifications.read",verb:c,target:g});return h?.settleCompact(y),u.preview.selection_version!==2&&a(),n.current.set(y.operation_token,{verb:c,receipt:y,reconcileIds:p,canReconcile:u.preview.selection_version===2}),y}catch(g){throw h?.(),g}},[t,i,a]),s=$.useCallback(async(c,u,O,d=!1,h=[])=>{n.current.clear();const p=c==="dismiss"?A6e(u):null,g=p?.dismissable??u,y=p?.asksStaying??0,v=[],b=i(h);for(let x=0;x<g.length;x+=500){const Q=g.slice(x,x+500),w=await s1(t,c,eO(Q));try{const S={items:eO(Q),throughSeq:O,receipt:!0,...d?{reconcileIds:b}:{}},k=await qe(c==="dismiss"?{op:"notifications.dismiss",verb:c,target:S}:{op:"notifications.read",verb:c,target:S});w?.settleCompact(k),d||a(),n.current.set(k.operation_token,{verb:c,receipt:k,reconcileIds:b,canReconcile:d}),v.push(k)}catch(S){return w?.(),{receipts:v,pending:g.length-x,skippedAsks:y,error:S}}}return{receipts:v,pending:0,skippedAsks:y}},[t,i,a]),l=$.useCallback(async c=>{const u=n.current.get(c);if(!u)throw new Error("No retained notification operation");const{receipt:O}=u,d=Object.fromEntries(Object.entries(O.session_counts).map(([p,g])=>[p,-g.unread_delta])),h=await s1(t,N6e(u.verb),[],{throughSeq:O.counts_high_water??O.high_water,unreadDelta:O.counts_high_water===void 0?0:-O.unread_delta,waitingUnreadDelta:O.counts_high_water===void 0?0:-(O.waiting_unread_delta??0),sessionUnreadDeltas:O.counts_high_water===void 0?{}:d});try{const p=await qe({op:"notifications.read",verb:"undo",target:{operationToken:c,...u.canReconcile?{reconcileIds:u.reconcileIds}:{}}});return h?.settleCompact(p),u.canReconcile||a(),p}catch(p){throw h?.(),p}},[t,a]);return{apply:o,applyItems:s,undo:l,activeSessionIds:r}}const ice=["running","queued","paused"],J6e=e=>ice.some(t=>t===e),Vz=["pending","blocked"],ace={running:"running",queued:"queued",paused:"paused",interrupted:"interrupted",done:"done",cancelled:"cancelled",gone:"gone",failed:"failed"},_Y="cancelled before it started",PY={running:0,queued:0,failed:1,interrupted:2,paused:2,done:3,cancelled:3,gone:3,unknown:3},oce=6,TY=10,eCe=16,tCe=8,VP=" · ",MP=", ",nCe="Open run details",rCe="Close run details",wa=" — ",iCe="Todos",Tan=e=>{if(e.status!=="running")return null;const t=e.activity||"thinking";return{activity:t,phase:t==="thinking"?"thinking":t==="responding"?"responding":"running",clock:!1}},vO=new Set,gf=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Bt=e=>typeof e=="string"?e.trim():"",sce=e=>e.split(`
|
|
515
515
|
`)[0].trim(),ci=e=>typeof e!="number"||!Number.isFinite(e)?null:e,ux=e=>e.replace(/[\u0000-\u001f\u007f]+/g," ").replace(/\s+/g," ").trim(),aCe=e=>{const t=Math.max(0,Math.floor(e));if(t<60)return`${t}s`;if(t<3600){const i=Math.floor(t/60),a=t%60;return a===0?`${i}m`:`${i}m${a}s`}if(t<86400){const i=Math.floor(t/3600),a=Math.floor(t%3600/60);return a===0?`${i}h`:`${i}h${a}m`}const n=Math.floor(t/86400);if(n>99)return"100d+";const r=Math.floor(t%86400/3600);return r===0?`${n}d`:`${n}d${r}h`},oCe=(e,t)=>{if(e===null||e<=0||t===null||t<=0)return null;const n=e/t*100;return n<1?"<1%":`${Math.round(n)}%`},sCe=e=>e===null?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`,lce=(e,t)=>{const n=e.toLowerCase();if(t)return"queued";switch(n){case"running":return"running";case"pausing":return"running";case"queued":return"queued";case"starting":return"queued";case"paused":return"paused";case"failed":return"failed";case"cancelled":case"canceled":return"cancelled";case"interrupted":return"interrupted";case"completed":case"done":return"done";case"gone":return"gone";default:return"unknown"}},cce=e=>!J6e(e),Ox=e=>!cce(e.status);function lCe(e){const t=e.filter(Ox);for(const n of ice)if(t.some(r=>r.status===n))return n;return null}function dx(e){const t=e.filter(Ox),n=lCe(e);return n===null?null:{count:t.length,mark:n,markCount:t.filter(r=>r.status===n).length}}const cCe=e=>{const t=ux(sce(e));return t!==""&&lce(t,!1)==="unknown"?t:"unknown"},uCe=e=>typeof e=="string"?e:gf(e)?Bt(e.progress):"",OCe=e=>{const t=ci(e.start_time);if(t===null||t<=0)return{startSeconds:null,settledSeconds:null};const n=ci(e.settled_at);return{startSeconds:t,settledSeconds:n!==null&&n>0?n:null}},uce=(e,t)=>{if(e.startSeconds===null)return null;const n=e.settledSeconds??t;return aCe(Math.max(n-e.startSeconds,0))},dCe=e=>gf(e)?e:null,XY=(e,t)=>{const n=Bt(e.id),r=Bt(e.label)||n,i=Bt(e.agent_role),a=i===""||i==="task"?null:i,o=OCe(e),s=Bt(e.status)||"running",l=lce(s,e.queued===!0),c=dCe(e.usage),u=ci(c?.context_tokens)??ci(c?.input_tokens),O=ux(sce(Bt(e.error_text))),d=Bt(e.error_text).trim(),h=Bt(e.result_text).trim(),p=h===_Y,g=pCe(e.launch_prompts),y=Bt(e.launch_message_id),v=Bt(e.prompt).trim();return{id:n,label:r,role:a,jobType:Bt(e.type)||null,status:l,stateWord:p?_Y:l==="unknown"?cCe(s):ace[l],elapsedLabel:uce(o,t),startSeconds:o.startSeconds,settledSeconds:o.settledSeconds,contextLabel:oCe(u,ci(e.context_window)),costLabel:sCe(ci(e.direct_cost)),activity:cce(l)?null:ux(uCe(e.latest_details))||null,errorLine:l==="failed"&&O?O:null,errorText:d||null,resultText:p?null:h||null,childSessionId:Bt(e.session_id)||null,parentJobId:Bt(e.parent_job_id)||null,childCount:0,modelLabel:Bt(e.model_label)||null,brief:g[y]??(v||null),launchMessageId:y,launchPrompts:g}},fCe=e=>{const t=gf(e)?e:{},n=Bt(t.status).toLowerCase(),r=Vz.includes(n)||n==="done"||n==="dropped";return{text:Bt(t.text),status:r?n:"pending",reason:Bt(t.reason)||null}},hCe=e=>{const t=gf(e)?e:{},n=Array.isArray(t.items)?t.items:[];return{name:kCe(e)?Bt(t.name):null,items:n.map(fCe)}},pCe=e=>{if(!gf(e))return{};const t={};for(const[n,r]of Object.entries(e))n&&typeof r=="string"&&(t[n]=r);return t},Td=e=>Array.isArray(e)?e.filter(gf):[],LP=[["w",6048e5],["d",864e5],["h",36e5],["m",6e4],["s",1e3]],Oce=e=>{for(let t=0;t<LP.length;t++){const[n,r]=LP[t];if(e<r)continue;if(e%r===0)return`${e/r}${n}`;const i=Math.floor(e/r),a=e%r;for(const[o,s]of LP.slice(t+1)){if(a%s!==0)continue;const l=a/s,c=o==="s"?6e4/s:r/s;if(l<c)return`${i}${n}${l}${o}`}break}return`${e}ms`},mCe=(e,t)=>{const n=new Intl.DateTimeFormat(t,{timeZoneName:"short"}).formatToParts(e).find(o=>o.type==="timeZoneName")?.value;if(n)return n;const r=-e.getTimezoneOffset(),i=r<0?"-":"+",a=Math.abs(r);return`${i}${String(Math.floor(a/60)).padStart(2,"0")}${String(a%60).padStart(2,"0")}`},Kq=(e,t)=>{const n=new Date(e),r=new Date(t),i=$m(),a=n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate(),o=n.getFullYear()===r.getFullYear();return`${a?"":`${gCe(n,i,o)} `}${$Ce(n,i)} ${mCe(n,i)}`},gCe=(e,t,n)=>YQ(e,n?{month:"short",day:"2-digit"}:{month:"short",day:"2-digit",year:"numeric"},t).replace(/,/g,""),$Ce=(e,t)=>GQ(e,{hour:"numeric",minute:"2-digit"},t),yCe=(e,t)=>{if(e===null)return"once";const n=`every ${Oce(e)}`;return t===null?n:t===0?`${n} · no deliveries left`:`${n} · ${t} left`},dce=e=>e===1?"1 wake armed":`${e} wakes armed`,fce=e=>e===1?"1 monitor armed":`${e} monitors armed`,vCe=(e,t,n)=>{const r=ci(e.next_due_at),i=Bt(e.message);if(i===""&&r===null)return null;const a=ci(e.every_ms),o=a!==null&&a>0?a:null,s=ci(e.limit),l=ci(e.remaining)??(s===null?null:Math.max(s-(ci(e.fired_count)??0),0));return{id:Bt(e.id)||`wake-${t}`,createdAt:ci(e.created_at),message:i,nextDueAt:r,dueLabel:r===null||l===0?"":Kq(r,n),everyMs:o,remaining:l,cadence:yCe(o,l)}},bCe=(e,t)=>e.map((n,r)=>vCe(n,r,t)).filter(n=>n!==null).sort((n,r)=>(n.nextDueAt??Number.POSITIVE_INFINITY)-(r.nextDueAt??Number.POSITIVE_INFINITY)),Xan=(e,t=eCe)=>e.length<=t?{rows:[...e],hidden:0}:{rows:e.slice(0,t),hidden:e.length-t},wCe=(e,t,n)=>{const r=Bt(e.name),i=ci(e.next_due_at);if(r===""&&i===null)return null;const a=ci(e.every_ms),o=a!==null&&a>0?a:null,s=e.disabled===!0,l=ci(e.consecutive_failures),c=l!==null&&l>0?Math.floor(l):0,u=c>0,O=ci(e.last_check_at),d=O!==null&&O>0?O:null,h=ci(e.checks),p=h!==null&&h>0?Math.floor(h):0;return{id:Bt(e.id)||`monitor-${t}`,name:r,description:Bt(e.description),whenLabel:s?"disabled":i===null?"waiting":Kq(i,n),interval:o===null?"once":`every ${Oce(o)}`,lastCheckLabel:d===null?"":`last check ${Kq(d,n)}`,healthLabel:s?ux(Bt(e.disabled_reason)):u?`${c} failed`:"",alerting:s||u,nextDueAt:i,everyMs:o,lastCheckAt:d,checks:p,failures:c,disabled:s}},xCe=(e,t)=>e.map((n,r)=>wCe(n,r,t)).filter(n=>n!==null).sort((n,r)=>(n.nextDueAt??Number.POSITIVE_INFINITY)-(r.nextDueAt??Number.POSITIVE_INFINITY)),Ran=(e,t=tCe)=>e.length<=t?{rows:[...e],hidden:0}:{rows:e.slice(0,t),hidden:e.length-t};function Ean(e){const t=Td(e?.jobs),n=Array.isArray(e?.todos)?e.todos:[],r=e?.nowMs??Date.now(),i=r/1e3,a=[],o=[];for(const p of t){const g=Bt(p.type);if(g==="bash"||g==="video"){o.push(p);continue}(g===""||g==="task")&&a.push(p)}const s=a.map(p=>XY(p,i)),l=o.map(p=>XY(p,i)),c=new Map;for(const p of s)p.parentJobId&&c.set(p.parentJobId,(c.get(p.parentJobId)??0)+1);const u=s.map(p=>({...p,childCount:c.get(p.id)??0})),O=SCe(u),d=n.map(hCe),h=d.flatMap(p=>p.items);return{subagents:O,lineage:u,jobs:l,todos:d,wakes:bCe(Td(e?.wakes),r),monitors:xCe(Td(e?.monitors),r),openChildren:O.filter(Ox).length,openJobs:l.filter(Ox).length,failedChildIds:O.filter(p=>p.status==="failed").map(p=>p.id),openTodos:h.filter(p=>Vz.includes(p.status)).length,doneTodos:h.filter(p=>p.status==="done").length,droppedTodos:h.filter(p=>p.status==="dropped").length,totalTodos:h.length,measuredAtMs:r,measuredAtRealMs:Date.now()}}const SCe=e=>{const t=new Set(e.map(n=>n.id));return e.filter(n=>n.parentJobId===null||!t.has(n.parentJobId))};function qan(e,t){const n=FP(e.subagents,t),r=FP(e.lineage,t),i=FP(e.jobs,t);return n===e.subagents&&r===e.lineage&&i===e.jobs?e:{...e,subagents:n,lineage:r,jobs:i}}function QCe(e,t){if(e.startSeconds===null||e.settledSeconds!==null)return e;const n=uce(e,t/1e3);return n===e.elapsedLabel?e:{...e,elapsedLabel:n}}const FP=(e,t)=>{let n=!1;const r=e.map(i=>{const a=QCe(i,t);return a!==i&&(n=!0),a});return n?r:e},kCe=e=>{if(!gf(e))return!1;const t=Bt(e.name);return t!==""&&t!==iCe};function hce(e,t=vO){return e?e.failedChildIds.filter(n=>!t.has(n)):[]}function jan(e,t=vO){return pce(t,e)}function pce(e,t){if(t.every(r=>e.has(r)))return e;const n=new Set(e);for(const r of t)n.add(r);return n}function Can(e){return e.some(t=>t.startSeconds!==null&&t.settledSeconds===null)}function _Ce(e,t=vO){return hce(e,t).length>0}function zan(e,t=vO){return e?e.openChildren>0||e.openJobs>0||e.openTodos>0||_Ce(e,t):!1}function Aan(e,t){let n=!1;const r=e.map(i=>{if(i.kind!=="user")return i;const a=t[i.id];return a===void 0||a===i.text?i:(n=!0,{...i,text:a})});return n?r:e}function Uan(e,t){const n=RY(t);return n?e.some(r=>{if(r.kind!=="user")return!1;const i=RY(r.text);if(!i)return!1;if(i===n)return!0;const a=i.replace(TCe,"").trim();return a.length>=XCe&&n.startsWith(a)}):!1}const PCe=/\s+/g,TCe=/…+$/,RY=e=>(e??"").replace(PCe," ").trim(),XCe=32,RCe=6;function Wan(e,t=RCe){const n=(e??"").split(`
|
|
516
516
|
`);return n.length<=t?{lines:n,hidden:0}:{lines:n.slice(0,t),hidden:n.length-t}}const ECe=["connected","connecting","cold"],qCe={"auth-required":"Manage this server's credentials in Settings"},r0={grant:"Grant account access",key:"Enter API key",reconnect:"Reconnect",reload:"Reload"};function jCe(e,t={},n=[]){const r=UCe(n);return Td(e).map(i=>{const a=Bt(i.name);if(!a)return null;const o=Bt(i.status)||"cold",s=!ECe.includes(o),l=Bt(i.transport)||null,c=typeof i.transport_oauth_supported=="boolean"?i.transport_oauth_supported:null,u=(Array.isArray(i.secret_refs)?i.secret_refs:[]).map(O=>Bt(O&&typeof O=="object"&&"id"in O?O.id:null)).filter((O,d,h)=>O&&h.indexOf(O)===d);return{name:a,status:o,problem:s,toolCount:o==="connected"?ci(i.tool_count):null,keyNames:u,transport:l,oauthSupported:c,grant:r.get(a)&&(s||r.get(a)?.status==="running")?r.get(a):null,scope:Bt(i.owned_scope)||WCe(i.source)||null,remedy:s?zCe({status:o,transport:l,oauthSupported:c,keyNames:u}):null,errorText:s&&Bt(t[a])||null}}).filter(i=>i!==null).sort((i,a)=>i.name.localeCompare(a.name))}const CCe=/[\\/]/,zCe=e=>["disconnected","auth-required"].includes(e.status)&&e.keyNames.length>0&&(e.oauthSupported===!1||e.transport==="stdio")?{kind:"key"}:e.status==="disconnected"?{kind:"reconnect"}:e.status!=="auth-required"?null:e.transport==="stdio"||e.oauthSupported===!1?e.keyNames.length>0?{kind:"key"}:{kind:"words",label:qCe["auth-required"]}:{kind:"grant"},ACe=["running","complete","failed","cancelled"],UCe=e=>{const t=new Map;for(const r of Td(e)){const i=Bt(r.name),a=Bt(r.id),o=Bt(r.status);if(!i||!a||!ACe.includes(o))continue;const s=ci(r.created_at)??0,l=t.get(i);l&&l.createdAt>s||t.set(i,{id:a,action:Bt(r.action)||"reauth",status:o,credentialRemoved:r.credential_removed===!0,createdAt:s})}const n=new Map;for(const[r,{createdAt:i,...a}]of t)a.status!=="complete"&&n.set(r,a);return n},Jq=e=>Td(e).some(t=>Bt(t.status)==="running"),WCe=e=>{const t=Bt(e);if(!t)return"";const n=t.split(CCe);return n[n.length-1]??""};function NCe(e){return e.length>0&&e.every(t=>t.status==="cold")}function Nan(e){const t={};for(const n of Td(e)){const r=Bt(n.name),i=Bt(n.error);r&&i&&(t[r]=i)}return t}function Yan(e,t){if(NCe(e))return m(YCe);const n=e.filter(o=>o.status==="connected").length,r=e.filter(o=>o.problem).length,i=`${n} of ${e.length} connected`;if(r===0)return i;const a=`${i} · ${HCe(r)}`;return t!==void 0&&a.length>t?i:a}const YCe="ui.chat.run_details.mcp.cold_label";function GCe(e){return e.filter(t=>t.problem).map(t=>t.name)}function Gan(e,t=vO){const n=GCe(e),r=new Set(n.filter(a=>t.has(a))),i=pce(r,n);return i.size===t.size&&[...i].every(a=>t.has(a))?t:i}function ZCe(e,t=vO){return e.filter(n=>n.problem&&!t.has(n.name)).map(n=>n.name)}function Zan(e,t=vO){return ZCe(e,t).length>0}const mce=(e,t)=>{if(e.length===0)return"";if(t===void 0)return e.join(VP);let n=e.slice(0,1);for(const r of e.slice(1)){if([...n,r].join(VP).length>t)break;n=[...n,r]}return n.join(VP)},gce=32,$ce=66,yce=6,ICe=4,Ian=e=>(Number.isFinite(e)&&e>0?e:Mz)-gce-$ce>=ICe*yce,Mz=420,Dan=e=>{const t=Number.isFinite(e)&&e>0?e:Mz;return Math.max(1,Math.floor((t-gce-$ce)/yce))};function Van(e,t){const n=[];for(const r of["running","queued","failed","interrupted","paused","cancelled","done","gone","unknown"]){const i=e.filter(o=>o.status===r);if(i.length===0)continue;const a=new Map;for(const o of i)a.set(o.stateWord,(a.get(o.stateWord)??0)+1);for(const[o,s]of a)n.push(`${s} ${o}`)}return mce(n,t)}function Man(e,t){if(!e)return"";const n=[`${DCe(e)} of ${e.totalTodos} closed`,...e.droppedTodos>0?[`${e.droppedTodos} dropped`]:[]];return mce(n,t)}function DCe(e){return e.doneTodos+e.droppedTodos}const EY=e=>e.settledSeconds??e.startSeconds,VCe=(e,t)=>{const n=EY(e),r=EY(t);return n!==null&&r!==null?n===r?0:r-n:n===null&&r===null?0:n===null?1:-1},qY=(e,t)=>PY[e.status]-PY[t.status]||VCe(e,t);function MCe(e,t=oce){const n=[...e].sort(qY);if(n.length<=t)return{rows:n,hidden:0};const r=n.slice(0,t);for(const i of n.slice(t)){if(i.status!=="failed")continue;let a=-1;for(let o=r.length-1;o>=0;o--)if(r[o].status!=="failed"){a=o;break}if(a===-1)break;r[a]=i}return r.sort(qY),{rows:r,hidden:n.length-r.length}}function LCe(e,t=oce){return MCe([...e],t)}function FCe(e){return LCe(e).rows.filter(t=>t.status==="failed").map(t=>t.id)}function Lan(e){return FCe(e?.subagents??[])}function Fan(e){const t=e.reduce((c,u)=>c+u.items.length,0);if(t<=TY)return{phases:e.map(c=>({...c,hidden:0})),hidden:0};const n=c=>Vz.includes(c.status),r=e.reduce((c,u)=>c+u.items.filter(O=>!n(O)).length,0),i=t-r,a=Math.max(0,TY-i),o=Math.max(0,r-a);let s=0;const l=e.map(c=>{const u=[];let O=0;for(const d of c.items){if(n(d)){u.push(d);continue}s++<o?O+=1:u.push(d)}return{...c,items:u,hidden:O}});return{phases:l,hidden:l.reduce((c,u)=>c+u.hidden,0)}}const vce=(e,t)=>e===1?`1 ${t}`:`${e} ${t}s`,bce=e=>ace[e],wce=e=>e.markCount===e.count?bce(e.mark):"open",xce=e=>e.markCount===e.count?"":`, ${e.markCount} ${bce(e.mark)}`,Lz=e=>`${vce(e.count,"subagent")} ${wce(e)}`,Fz=e=>`${vce(e.count,"job")} ${wce(e)}`,Bz=e=>e.openTodos>0?m("ui.chat.run_details.chip.todos_open",{count:e.openTodos}):e.droppedTodos>0?m("ui.chat.run_details.chip.todos_closed"):m("ui.chat.run_details.chip.todos_resolved"),BCe=e=>m("ui.chat.run_details.chip.subagents_failed",{count:e}),HCe=e=>m("ui.chat.run_details.chip.attention",{count:e}),KCe=e=>m("ui.chat.run_details.chip.mcp_attention",{count:e});function Ban(e,t=vO,n={}){const r=n.cap??null,i=`${n.open?rCe:nCe}${r===null?"":` (${r})`}`;if(!e)return i;const a=[],o=[],s=hce(e,t).length;s>0&&a.push(BCe(s)),(n.mcpProblems??0)>0&&a.push(KCe(n.mcpProblems??0));const l=dx(e.subagents);l&&o.push(Lz(l));const c=dx(e.jobs);c&&o.push(Fz(c)),e.openTodos>0&&o.push(Bz(e));const u=[...a,...o];if(u.length===0)return i;if(n.maxChars!==void 0){const O=a.length>0?a:o.slice(0,1),d=a.length>0?o:o.slice(1);let h=[...O];for(const p of d){if((i+wa+[...h,p].join(MP)).length>n.maxChars)break;h=[...h,p]}return i+wa+h.join(MP)}return i+wa+u.join(MP)}function JCe(e){return e.stateWord}const Han=e=>e.childCount>0?`${e.childCount} child${e.childCount===1?"":"ren"}`:null,eze=54,tze=48,nze=12,rze=172,ize=92,Kan=e=>(Number.isFinite(e)&&e>0?e:Mz)-tze-rze-nze-eze>=ize,Jan=e=>e.childSessionId!==null;function eon(e,t){return e.filter(n=>n.parentJobId===t.id)}const Hz='textarea[aria-label="Message"]';let X0=null;function aze(e,t){return X0={give:e,field:t},()=>{X0?.give===e&&(X0=null)}}function oze(){return X0?.field()??null}function Kz(){X0?.give()}function ton({targetSessionId:e,displayedSessionId:t,activeElement:n,commandPaletteOpen:r}){if(e===t)return!0;if(r)return!1;const i=n;return!(i!==null&&(i.tagName==="INPUT"||i.tagName==="TEXTAREA"||i.isContentEditable===!0))}const Sce=e=>e==="open"||e==="answered"||e==="declined"||e==="timed_out"||e==="late"||e==="dismissed"||e==="expired"||e==="withdrawn",Qce=e=>{const t=e?.asks;return Array.isArray(t)?t:null},sze=e=>e!=null&&(Array.isArray(e.asks)||e.asks_open!=null),non=e=>bze(e)?null:e?.pending_gate??null,rv=e=>!e.truncated&&e.open<=e.waiting+e.movedOn,ron=e=>rv(e)?e.rows.filter(t=>t.canAnswer).length:e.open,jY=(e,t)=>{const n=Jz(e),r=fze(e,t);return r===null?n:`${n} · ${r}`},Jz=e=>rv(e)?e.waiting>0?e.waiting===1?"1 question waiting":`${e.waiting} questions waiting`:e.delivering>0?e.delivering===1?"1 answer not yet delivered — you can still change it":`${e.delivering} answers not yet delivered — you can still change them`:e.movedOn>0?e.movedOn===1?"1 question timed out":`${e.movedOn} questions timed out`:"All asks settled":`${e.open} outstanding`,ej=e=>e==="fleet"?"All conversations":"This conversation",lze="Reading the asks…",cze="Asks unavailable",uze="This runtime doesn't support queued asks.",Oze=e=>e.unread?"":e.published?rv(e)&&e.waiting===0&&e.delivering===0?"All asks settled":Jz(e):cze,dze=(e,t)=>{const n=Oze(t);return n===""?ej(e):`${ej(e)} · ${n}`},ion=e=>{const t=e.open?"Close":"Open",n=e.cap===null||e.cap===void 0?"":` (${e.cap})`,r=ej(e.scope);return e.count>0?`${t} asks${n} — ${r}, ${e.count} waiting`:`${t} asks${n} — ${r}`},kce=e=>!rv(e)||e.waiting===0?null:e.soonestExpiryMs,_ce=(e,t)=>{const n=kce(e);return n===null?null:zce(n,t)},Pce=e=>e.waiting>1?"soonest ask":"",fze=(e,t)=>{const n=_ce(e,t);if(n===null)return null;const r=Pce(e);return r===""?n:`${r} ${n}`},hze=(e,t)=>{const n=kce(e);return n===null?null:Tze(n,t)},pze=(e,t)=>rv(e)&&(e.waiting>0||e.delivering>0)&&e.movedOn>0?`${jY(e,t)} · ${e.movedOn} timed out`:jY(e,t),mze=(e,t,n)=>{const r=e.urgent?" · Urgent":"";return`${t?"Collapse":"Expand"} this conversation's asks${wa}${pze(e,n)}${r}`},aon=e=>{const t=e.head;if(t===null||!t.canAnswer)return!1;const n=t.ask.questions;return n.length>0&&n.every(r=>r.secret===!0)},gze=e=>{const t=e.questions,n=t.length===1&&t[0].secret===!0;return{key:`${e.ask_id}:${n?t[0].id:"*"}`,questionId:n?t[0].id:null}},oon=async(e,t,n,r)=>{if(e===null)return"stale";const i=gze(e.ask);if(i.key!==t)return"stale";if(i.questionId===null)return"multi";const a=await r(e.ask.ask_id,{[i.questionId]:[n.trim()]});return a===void 0?"unavailable":a.status==="sent"?"sent":a.status==="refused"||a.status==="failed"?"refused":a.status},$ze="[data-lo-ask-surfaces]",Tce="[data-lo-ask-item-toggle]",yze='[data-tour-tag="ask-pane-trigger"]',vze=e=>{const t=e;return typeof t?.closest!="function"?!0:t.closest($ze)!==null||t.closest(Tce)!==null||t.closest(Hz)!==null},son=e=>e.key!=="Escape"||e.isComposing===!0||e.defaultPrevented===!0||O$(e.target)?!1:vze(e.target),bze=e=>Qce(e)!==null&&e?.pending_gate?.kind==="ask",Xce=e=>e.questions.map(t=>({id:t.id,question:t.question,answers:(e.answers?.[t.id]??[]).slice()})),wze=e=>!Number.isFinite(e)||e<=0?"a while":e<60?`${Math.trunc(e)}s`:e<3600?`${Math.trunc(e/60)}m`:e<86400?`${Math.trunc(e/3600)}h`:`${Math.trunc(e/86400)}d`,tj=e=>{if(e.status==="dismissed"){const t=typeof e.by?.surface=="string"?e.by.surface:"",n=t==="remote"?"phone":t==="tui"?"terminal":t,r=n?` (${n})`:"",i=e.reason==="answered_in_chat"?"settled in chat":"no longer needed";return`Dismissed by you${r} — ${i} (ask ${e.askId})`}return e.status==="declined"?`Ask ${e.askId} declined — the agent was told`:e.status==="late"?`Answered late — the agent was told (ask ${e.askId})`:`Answered — delivering (ask ${e.askId})`},Rce=e=>`Timed out after ${wze(e.waitedS)} — the agent goes ahead without your answer (ask ${e.askId})`,xze="You can change this until the agent is handed your answer.",Sze=/[^A-Za-z0-9]+/,nj=(e,t)=>{const n=new Set(e.filter(i=>i.secret===!0).map(i=>i.id)),r={};for(const[i,a]of Object.entries(t)){if(!n.has(i)){r[i]=[...a];continue}const o=i.split(Sze).filter(Boolean).join("_").toUpperCase();r[i]=a.length===0?[]:[`[${o}]`]}return r},rj=(e,t,n)=>{const r=JSON.stringify([e.session_id??n??null,e.ask_id,e.created_at??null,e.questions]),i=o=>{const s=nj(e.questions,o??{});return Object.keys(s).sort().map(l=>[l,s[l]])},a=o=>JSON.stringify([r,e.status,e.answered_at??null,e.revised_at??null,e.delivered??null,e.answered_by??null,i(o)]);return{identity:r,before:a(e.answers),after:a(t),beforeAnswers:JSON.stringify(i(e.answers)),afterAnswers:JSON.stringify(i(t)),hasRevisionMarker:e.revised_at!=null}},ij=(e,t,n)=>{const r=t?.settled;if(r===void 0||e.delivered===!0)return e;if(r.revision){const i=rj(e,e.answers??{},n);if(i.identity!==r.revision.identity)return e;if(e.status==="answered"||e.status==="late"){const a=r.revision.acknowledged;if(a?.current===i.beforeAnswers)return e;const o=a?.unmarked===!0&&!i.hasRevisionMarker&&a.current!==i.beforeAnswers&&a.predecessors.includes(i.beforeAnswers);return r.answers&&(r.revision.superseded.includes(i.before)||o)?{...e,answers:r.answers}:e}}return fx.has(e.status)?r.status==="dismissed"?{...e,status:"dismissed",dismissed_at:r.at,...r.reason===void 0?{}:{dismissed_reason:r.reason}}:{...e,status:r.status,answered_at:r.at,answered_by:{surface:"desktop"},delivered:!1,...r.answers===void 0?{}:{answers:r.answers}}:e},fx=new Set(["open","timed_out"]),Ece=e=>{const t=Sce(e.status)?e.status:"unknown",n=fx.has(t),r=t==="timed_out";return{ask:e,status:t,open:n,waiting:t==="open",movedOn:r,lapsed:r,canAnswer:t==="open",canDecline:t==="open",delivering:(t==="answered"||t==="late")&&e.delivered!==!0}},KQ=(e,t,n)=>{const r=Qce(e),i=sze(e),a=e==null;if(r===null)return{asks:null,published:i,unread:a,rows:[],open:typeof e?.asks_open=="number"?e.asks_open:0,waiting:0,movedOn:0,total:0,truncated:e?.asks_truncated===!0,urgent:!1,delivering:0,soonestExpiryMs:null,head:null};const o=r.filter(h=>fx.has(h.status)&&!fx.has(ij(h,t?.[h.ask_id],n).status)).length,s=r.map(h=>Ece(ij(h,t?.[h.ask_id],n))).sort(Qze),l=s.filter(h=>h.open).length,c=s.filter(h=>h.waiting).length,u=s.filter(h=>h.movedOn).length,O=s.filter(h=>h.delivering&&t?.[h.ask.ask_id]?.refusedByOwner!==!0).length,d=s.filter(h=>h.waiting).map(h=>Number(h.ask.expires_at??0)).filter(h=>Number.isFinite(h)&&h>0);return{asks:r,published:i,unread:a,rows:s,open:typeof e?.asks_open=="number"?Math.max(0,e.asks_open-o):l,waiting:c,movedOn:u,delivering:O,total:s.length,truncated:e?.asks_truncated===!0,urgent:s.some(h=>h.waiting&&h.ask.urgent===!0),soonestExpiryMs:d.length>0?Math.min(...d):null,head:s.find(h=>h.canAnswer)??null}},Qze=(e,t)=>e.open!==t.open?e.open?-1:1:qce(e,t),qce=(e,t)=>{const n=Number(e.ask.created_at??0),r=Number(t.ask.created_at??0);return n!==r?n-r:e.ask.ask_id.localeCompare(t.ask.ask_id)},jce={open:"Queued — the agent is continuing",answered:"Answered — delivering",timed_out:"Timed out — the agent goes ahead without your answer",late:"Answered late — the agent was told",declined:"Declined — the agent was told",dismissed:"Dismissed — no reply was sent",expired:"Expired — this ask is too old to answer; ask the agent again",get withdrawn(){return m("ui.chat.asks.status.withdrawn")},unknown:"Waiting on an answer"},kze="Answered late — not yet delivered",e9=e=>{if(e==="withdrawn")return m("ui.chat.asks.status.withdrawn_label");const t=jce[e],n=t.indexOf(" — ");return n===-1?t:t.slice(0,n)},CY=(e,t=new Set)=>{const n=r=>r.canAnswer||r.lapsed&&t.has(r.ask.ask_id);return{pending:e.filter(n),settled:e.filter(r=>!n(r)).sort((r,i)=>qce(i,r))}},_ze=(e,t)=>{const n=Ece(e);if(n.status==="late"&&n.delivering)return kze;if(n.status==="answered"&&!n.delivering)return e9("answered");const r=jce[n.status];if(n.status!=="open")return r;const i=Pze(e,t);return i===null?r:`${r}; ${i}`},Pze=(e,t)=>zce(Number(e.expires_at??0),t),Cce=(e,t)=>{if(!Number.isFinite(e)||e<=0)return null;const n=e-t;if(n<=0)return{long:"expiring now",short:"now"};const r=Math.floor(n/6e4);if(r<1){const o=`${Math.floor(n/1e3)}s`;return{long:`expires in ${o}`,short:o}}if(r<60)return{long:`expires in ${r}m`,short:`${r}m`};const i=Math.floor(r/60);if(i<24)return{long:`expires in ${i}h`,short:`${i}h`};const a=Math.floor(i/24);return{long:`expires in ${a}d`,short:`${a}d`}},zce=(e,t)=>Cce(e,t)?.long??null,Tze=(e,t)=>Cce(e,t)?.short??null,Ace={},Xze={},Rze=()=>{},t9=(e,t)=>e[t]??[],Uce=e=>e==="",iv=e=>e.trim().length>0,Eze="<not provided>",Wce=(e,t)=>{if(t===void 0)return!0;const n=t[e.id];if(!Array.isArray(n))return!1;const r=n.filter(iv);return r.length===0||r[0]===Eze},qze="Leave empty to skip; what you type is never shown",jze="Required: type it again; it is never shown",Cze="Your answer (never shown again)",n9=(e,t)=>iv(t[e.id]??""),Nce=(e,t)=>!e.secret||t===void 0||n9(e,t),zze=(e,t,n)=>Wce(t,n)?e.questions.some(r=>r.id!==t.id&&Nce(r))?qze:Cze:jze,aj=(e,t,n={},r)=>{if(e.secret)return n9(e,n)||Wce(e,r);const i=t9(t,e.id);return i.some(iv)&&!i.some(Uce)},Aze=(e,t,n={},r)=>e.questions.every(i=>aj(i,t,n,r))&&e.questions.some(i=>Nce(i,n)),oj=32768,Uze=(e,t)=>e.filter(n=>iv(n)&&!t.includes(n)),Wze=(e,t)=>{const n=Uze(e,t);return{open:n.length>0||e.some(Uce),text:n.join(`
|
|
517
|
-
`)}},Nze=(e,t,n)=>{const r=e.filter(o=>t.includes(o)),i=n.open?n.text.trim():"";if(i===""||!t.includes(i))return r;const a=r.lastIndexOf(i);return r.filter((o,s)=>s!==a)},zY=(e,t,n)=>{if(!n.open)return t?[...e]:[];const r=n.text.trim();return t?[...e,r]:[r]},cb=(e,t,n={},r)=>{if(!Aze(e,t,n,r))return null;const i={};for(const a of e.questions)i[a.id]=a.secret?n9(a,n)?[(n[a.id]??"").trim()]:[]:[...new Set(t9(t,a.id).filter(iv))];return i},Yze=e=>{const t={};for(const n of e.questions){if(n.secret)continue;const r=e.answers?.[n.id];Array.isArray(r)&&r.length>0&&(t[n.id]=[...r])}return t},sj="That question was already settled, so your answer was not sent.",Gze="This ask is too old to answer — ask the agent again.",Yce=e=>{const t=typeof e?.status=="number"?e.status:null,n=typeof e?.code=="string"?e.code:"";return t===410||n==="expired"?Gze:t===409?sj:null},Zze=e=>{const t=typeof e=="object"&&e!==null?e.detail:void 0,n=e instanceof Error?e.message:"";return t!==void 0||e instanceof Ln&&n!==""&&n!==i2e},Ize=e=>{if(Zze(e))return As(e,sj);const t=Yce(e);return t!==null?t:As(e,e instanceof Error&&e.message?e.message:sj)},Gce=e=>Yce(e)!==null,Dze=e=>{if(Gce(e))return!1;const t=typeof e=="object"&&e!==null?e.code:void 0;return typeof t!="string"?!0:t===sz.transportFailed},Zce=e=>e==="moot"||e==="answered_in_chat"?e:null,lon=e=>e===1?"1 ask":`${e} asks`,Vze={high:3,normal:2,low:1},r9=({priority:e,className:t})=>{const n=Vze[e];return f.jsx("svg",{width:"14",height:"12",viewBox:"0 0 14 12","aria-hidden":"true","data-priority-bars":e,className:E("shrink-0",e==="high"?"text-warning":"text-ink-dim",t),children:[0,1,2].map(r=>f.jsx("rect",{x:1+r*4.5,y:8-r*3.5,width:"3",height:3+r*3.5,rx:"0.75",className:r<n?"fill-current":"fill-ink-disabled"},r))})},Ice=e=>{switch(e.kind){case"now":return m("ui.notifications.time.now");case"minutes":return m("ui.notifications.time.minutes",{count:Za(e.count)});case"hours":return m("ui.notifications.time.hours",{count:Za(e.count)});case"clock":return GQ(e.at,{hour:"2-digit",minute:"2-digit"});case"date":return YQ(e.at,{weekday:"short",day:"numeric"})}},Mze=e=>e.priority==="high"?m("ui.notifications.row.priority.high"):e.priority==="normal"?m("ui.notifications.row.priority.normal"):m("ui.notifications.row.priority.low"),BP="h-[calc(var(--text-body-sm)*var(--text-body-sm--line-height))] items-center",con=({item:e,nowMs:t,open:n,picked:r,selecting:i,focused:a,writesPaused:o,onOpen:s,onToggleSelect:l,onToggleRead:c,onDismiss:u,onAnswer:O,onFocusRow:d,hideSource:h=!1})=>{const p=Gd(e),g=!e.read,y=ece(e),v=Ice(tce(e.updated_at,t)),b=e.session.title||m("ui.notifications.group.untitled"),x=e.repeat_count>1?e.repeat_count:0,Q=m("ui.notifications.row.a11y",{read:g?"false":"true",priority:Mze(e),title:e.title,source:b,age:v,repeat:x}),w=(()=>{if(p){const k=[],P=e.ask?.question_count;typeof P=="number"&&P>0&&k.push(m("ui.notifications.row.ask_options",{options:P}));const R=e.ask?.deadline_at;if(typeof R=="number"&&R>t){const T=Math.max(1,Math.round((R-t)/6e4));k.push(m("ui.notifications.row.ask_expires",{time:T<60?m("ui.notifications.time.minutes",{count:Za(T)}):m("ui.notifications.time.hours",{count:Za(Math.round(T/60))})}))}return k.length>0?k.join(" · "):e.excerpt}return e.source==="ask"&&e.ask?.status?e9(Sce(e.ask.status)?e.ask.status:"unknown"):x>0?`${m("ui.notifications.row.updated_ago",{age:v})} · ${e.excerpt}`:e.excerpt})(),S=o?m("ui.notifications.writes_paused_tip"):null;return f.jsxs("div",{role:"row","aria-selected":r,"aria-label":Q,tabIndex:a?0:-1,"data-notification-row":e.id,"data-notification-revision":e.revision,"data-notification-unread":g?"":void 0,"data-notification-open":n?"":void 0,onClick:k=>{if(k.shiftKey||i){l(e,k.shiftKey);return}s(e)},onFocus:()=>d(e),className:E("group/row relative flex min-h-14 cursor-default items-start gap-3 px-3 py-2","outline-none focus-visible:outline-2 focus-visible:outline-accent focus-visible:-outline-offset-2","transition-colors duration-fast ease-out-quart",r?"bg-accent-wash":n?"bg-row-selected":"hover:bg-row-hover"),children:[f.jsxs("div",{role:"gridcell",tabIndex:-1,className:E("relative flex w-4 shrink-0 justify-center",BP),children:[f.jsx("span",{"aria-hidden":"true",className:E("size-1.5 rounded-full bg-accent forced-colors:bg-[CanvasText]",(!g||i)&&"invisible","group-hover/row:invisible group-focus-within/row:invisible")}),f.jsx("span",{"data-notification-select":"",className:E("absolute flex size-6 items-center justify-center",i||r?"visible":"invisible group-hover/row:visible group-focus-within/row:visible"),onClick:k=>k.stopPropagation(),onKeyDown:k=>{(k.key===" "||k.key==="Enter")&&k.stopPropagation()},children:f.jsx(Dse,{checked:r,tabIndex:-1,className:"size-6",onClick:k=>{k.stopPropagation(),l(e,k.shiftKey)},"aria-label":m("ui.notifications.row.select",{title:e.title})})})]}),f.jsx("div",{role:"gridcell",tabIndex:-1,className:E("flex w-5 shrink-0 justify-center",BP),children:e.source==="ask"?f.jsx(Pje,{size:16,"aria-hidden":"true",className:p?"text-info":"text-ink-dim"}):f.jsx(r9,{priority:e.priority})}),f.jsxs("div",{role:"gridcell",tabIndex:-1,className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[f.jsx("span",{"data-notification-title":"",className:E("min-w-0 truncate text-body-sm",g?"font-semibold text-ink":"text-ink-muted"),children:e.title}),e.priority==="high"&&e.source==="notify"&&f.jsx(js,{variant:"warning",size:"count",className:"h-4.5 px-1.5",children:m("ui.notifications.row.chip.high")}),x>0&&f.jsx(js,{variant:"neutral",size:"count",children:m("ui.notifications.row.chip.repeat",{count:ARe(x,99)})})]}),f.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-ink-dim text-meta",children:[!h&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"shrink-0 text-ink-muted",children:b}),f.jsx("span",{"aria-hidden":"true",children:"·"})]}),y&&f.jsx(vt,{content:y==="live"?m("ui.notifications.seen.live_hint"):m("ui.notifications.seen.in_view_hint"),children:f.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1","data-notification-seen":y,children:[f.jsx($le,{size:12,"aria-hidden":"true"}),y==="live"?m("ui.notifications.seen.live"):m("ui.notifications.seen.in_view")]})}),y&&f.jsx("span",{"aria-hidden":"true",children:"·"}),f.jsx("span",{className:"min-w-0 truncate",children:w})]})]}),f.jsxs("div",{role:"gridcell",tabIndex:-1,className:E("relative flex w-16 shrink-0 justify-end",BP),children:[f.jsx("span",{className:E("text-ink-dim text-meta tabular-nums","group-hover/row:invisible group-focus-within/row:invisible"),children:v}),f.jsxs("span",{className:E("absolute inset-e-0 flex items-center gap-0.5","invisible group-hover/row:visible group-focus-within/row:visible"),children:[f.jsx(R0,{label:S??(g?m("ui.notifications.row.mark_read"):m("ui.notifications.row.mark_unread")),disabled:o,onPress:()=>c(e),"data-row-action":"read",children:g?f.jsx(ba,{size:14}):f.jsx(Vse,{size:14})}),p?f.jsx(R0,{label:m("ui.notifications.row.answer"),onPress:()=>O(e),"data-row-action":"answer",children:f.jsx(Tle,{size:14})}):f.jsx(R0,{label:S??m("ui.notifications.row.dismiss"),disabled:o,onPress:()=>u(e),"data-row-action":"dismiss",children:f.jsx(ni,{size:14})})]})]})]})},R0=({label:e,disabled:t=!1,onPress:n,children:r,...i})=>f.jsx(vt,{content:e,children:f.jsx("button",{type:"button",tabIndex:-1,"aria-label":e,"aria-disabled":t||void 0,"data-row-action":i["data-row-action"],"data-row-visible":i["data-row-visible"],onClick:a=>{a.stopPropagation(),!t&&n()},className:E("flex size-7 items-center justify-center rounded-sm text-ink-muted","hover:bg-elevated hover:text-ink","focus-visible:outline-2 focus-visible:outline-accent",t&&"text-ink-disabled hover:bg-transparent hover:text-ink-disabled"),children:r})}),uon=(e,t)=>t>0?"asks":"updates",Lze=({tab:e,onTab:t,asks:n,unreadUpdates:r,sessionless:i})=>{Qe();const a=[{id:"asks",label:m("ui.notifications.drawer.tab.asks"),count:n},{id:"updates",label:m("ui.notifications.drawer.tab.updates"),count:r},{id:"all",label:m("ui.notifications.drawer.tab.all"),count:0}],o=i?a.filter(l=>l.id==="all"):a,s=l=>{const c=l.key==="ArrowRight"||l.key==="Tab"&&l.ctrlKey&&!l.shiftKey?1:l.key==="ArrowLeft"||l.key==="Tab"&&l.ctrlKey&&l.shiftKey?-1:0;if(c===0)return;l.preventDefault();const u=o.findIndex(d=>d.id===e),O=o[(u+c+o.length)%o.length];t(O.id),l.currentTarget.querySelector(`[data-drawer-tab="${O.id}"]`)?.focus()};return f.jsxs("div",{className:"flex shrink-0 flex-col gap-1 border-hairline border-b px-2 pb-1",onKeyDown:s,children:[f.jsx("button",{type:"button","aria-pressed":e==="all","data-drawer-tab":"all",onClick:()=>t("all"),className:E("min-h-8 w-full whitespace-normal rounded-sm px-2 py-1 text-start text-body-sm",e==="all"?"bg-row-selected text-ink":"text-ink-muted hover:bg-row-hover"),children:m("ui.notifications.drawer.tab.all")}),!i&&f.jsx("div",{role:"tablist","aria-label":m("ui.notifications.drawer.tabs_label"),className:"flex min-w-0 gap-1",children:a.filter(l=>l.id!=="all").map(l=>f.jsxs("button",{type:"button",role:"tab","aria-selected":e===l.id,tabIndex:e===l.id||e==="all"&&l.id==="asks"?0:-1,"data-drawer-tab":l.id,onClick:()=>t(l.id),className:E("flex min-h-8 min-w-0 flex-1 flex-wrap items-center justify-center gap-1 border-b-2 px-2 py-1 text-body-sm",e===l.id?"border-accent text-ink":"border-transparent text-ink-muted hover:text-ink"),children:[f.jsx("span",{className:"min-w-0 whitespace-normal break-words",children:l.label}),l.count>0&&f.jsx(js,{variant:"neutral",size:"count",className:"h-auto max-w-full whitespace-normal break-words text-center",children:l.id==="updates"?m("ui.notifications.drawer.unread_count",{count:Za(l.count)}):Za(l.count)})]},l.id))})]})},Oon=({tab:e})=>{Qe();const t=Dq(r=>r.count),n=Dq(r=>r.backToTop);return e!=="updates"||!n||t===0?null:f.jsxs(ke,{size:"sm",variant:"secondary",className:"shrink-0","data-drawer-back-to-top":"",onClick:n,children:[f.jsx(Mse,{"aria-hidden":"true"}),m("ui.notifications.new_pill",{count:Za(t)})]})};function Dce(e,t){const r=Iz(e,t).data?.high_water,i=wt({queryKey:[...qt.sessionUnread(e),r],enabled:t&&!!e&&r!==void 0,queryFn:()=>M6e(e),retry:Ir,staleTime:5e3,placeholderData:(a,o)=>t&&e&&o?.queryKey[3]===e?a:void 0});return t&&e?i.data??0:0}const HP="drawer-refusal",AY=e=>e==="dismiss"?m("ui.notifications.error.dismiss"):m("ui.notifications.error.mark"),don=({sessionId:e,nowMs:t,initialView:n="unread"})=>{Qe();const r=gm(),[i,a]=$.useState(n),o=Dce(e,!0),[s,l]=$.useState(!0),c=Iz(e,!0,{atTop:s}),u=Dz(),O=t??Date.now(),d=Dq(X=>X.publish),h=$.useRef(c.resetToTop);h.current=c.resetToTop;const p=$.useCallback(()=>{document.querySelector("[data-drawer-updates]")?.scrollTo({top:0,behavior:"smooth"}),l(!0),h.current()},[]);$.useEffect(()=>{d(c.newerCount,c.newerCount>0?p:null)},[c.newerCount,p,d]),$.useEffect(()=>()=>d(0,null),[d]);const g=$.useMemo(()=>(c.data?.items??[]).filter(X=>!X.dismissed).sort((X,C)=>C.updated_at-X.updated_at),[c.data]),y=g.filter(X=>!X.read),v=g.filter(X=>X.read),b=i==="unread"?y:v,x=$.useRef(null),Q=$.useRef(null),w=$.useRef(null),S=$.useRef("read"),k=$.useRef(null);$.useLayoutEffect(()=>{const X=document.activeElement,C=D=>x.current?.querySelector(D)??null,N=k.current;if(N){const D=C(`[data-drawer-update="${CSS.escape(N.id)}"] [data-row-action="${N.action}"]`);if(D&&(k.current=null,X===null||X===window.document.body||X.hasAttribute("data-drawer-empty"))){D.focus();return}}const A=Q.current;if(!A||b.some(D=>D.id===A.id))return;Q.current=null;const Y=w.current!==null&&!w.current.isConnected&&w.current===X;if(X!==document.body&&!Y)return;const W=b[Math.min(A.index,b.length-1)],Z=W?`[data-drawer-update="${CSS.escape(W.id)}"] [data-row-action="${S.current}"]`:"[data-drawer-empty], [data-drawer-load-more]";W||(k.current={id:A.id,action:S.current}),x.current?.querySelector(Z)?.focus()},[b]);const P=X=>{const C=document.querySelector(`[data-notification-flag="${CSS.escape(X.id)}"]`);C?.scrollIntoView({block:"center",behavior:"smooth"}),C?.animate?.([{backgroundColor:"var(--color-accent-wash)"},{backgroundColor:"transparent"}],{duration:900,easing:"ease-out"})};if(c.isLoading)return f.jsx("p",{"data-drawer-loading":"",className:"p-3 text-body-sm text-ink-muted",children:m("ui.notifications.page.loading")});if(c.isError&&!c.data)return f.jsxs("div",{"data-drawer-load-error":"",className:"p-3 text-body-sm text-ink-muted",children:[f.jsx("p",{children:m("ui.notifications.error.load.title")}),f.jsx(ke,{size:"sm",variant:"secondary",onClick:()=>void c.refetch(),children:m("ui.notifications.error.retry")})]});const R=(X,C)=>{const N=()=>u.mutate({verb:X,target:{items:C}},{onSuccess:A=>{A.changed?.length&&Jo(m("ui.notifications.toast.undone"))},onError:()=>AP(AY(X),{id:HP,action:{label:m("ui.notifications.error.retry"),onClick:N}})});N()},T=(X,C)=>{S.current=C==="dismiss"?"dismiss":"read";const N=C==="dismiss"?"undismiss":C==="read"?"unread":"read";u.mutate({verb:C,target:{items:eO([X])}},{onSuccess:A=>{A.changed.includes(X.id)&&Jo(C==="dismiss"?m("ui.notifications.toast.dismissed",{count:1}):C==="read"?m("ui.notifications.toast.marked_read",{count:Za(1)}):m("ui.notifications.toast.marked_unread",{count:Za(1)}),{duration:Fq,action:{label:m("ui.notifications.toast.undo"),onClick:()=>R(N,eO([X]))}})},onError:()=>AP(AY(C),{id:HP})})},q=()=>{document.activeElement?.hasAttribute("data-drawer-mark-all-read")&&(Q.current={id:"bulk-action",index:0});const X=eO(y);u.mutate({verb:"read",target:{items:X}},{onSuccess:C=>{const N=new Set(C.changed),A=X.filter(Y=>N.has(Y.id));A.length!==0&&Jo(m("ui.notifications.toast.marked_read",{count:Za(A.length)}),{duration:Fq,action:{label:m("ui.notifications.toast.undo"),onClick:()=>R("unread",A)}})},onError:()=>AP(m("ui.notifications.error.mark"),{id:HP})})};return f.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[f.jsx(Fze,{view:i,onView:a,unreadCount:o,action:i==="unread"&&y.length>0?f.jsx(ke,{variant:"ghost",size:"sm",className:"shrink-0","data-drawer-mark-all-read":"",disabled:c.isError,onClick:q,children:m("ui.notifications.drawer.mark_read")}):null}),f.jsxs("div",{"data-drawer-updates":"",ref:x,onFocusCapture:X=>{const C=X.target.closest("[data-drawer-update]");C&&!C.isConnected||(w.current=C?X.target:null,Q.current=C?.dataset.drawerUpdate?{id:C.dataset.drawerUpdate,index:b.findIndex(N=>N.id===C.dataset.drawerUpdate)}:null)},className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-1 py-2",onScroll:X=>{const C=X.currentTarget;l(C.scrollTop<=24),c.hasNextPage&&!c.isFetchingNextPage&&C.scrollHeight-C.scrollTop-C.clientHeight<160&&c.fetchNextPage()},onKeyDown:X=>{const N=X.target.closest("[data-drawer-update]");if(!N)return;const A=b.findIndex(W=>W.id===N.dataset.drawerUpdate),Y=b[A];if(Y)if(X.key==="ArrowDown"||X.key==="ArrowUp"){X.preventDefault();const W=b[Math.max(0,Math.min(b.length-1,A+(X.key==="ArrowDown"?1:-1)))];X.currentTarget.querySelector(`[data-drawer-update="${CSS.escape(W.id)}"] button`)?.focus()}else["r","u","e"].includes(X.key.toLowerCase())&&!c.isError&&(X.preventDefault(),T(Y,X.key.toLowerCase()==="e"?"dismiss":X.key.toLowerCase()==="u"?"unread":"read"))},children:[b.length===0&&!c.hasNextPage?f.jsx("h3",{tabIndex:-1,className:"px-3 py-8 text-center text-body-sm text-ink-muted","data-drawer-empty":i,children:g.length===0?m("ui.notifications.drawer.empty"):i==="unread"?m("ui.notifications.empty.caught_up.title"):m("ui.notifications.empty.filtered.title")}):f.jsx("ul",{className:"flex flex-col","data-drawer-view-list":i,children:b.map(X=>f.jsx(Bze,{item:X,nowMs:O,onShow:P,onToggleRead:()=>T(X,X.read?"unread":"read"),onDismiss:()=>T(X,"dismiss"),paused:c.isError},X.id))}),c.hasNextPage&&f.jsx(ke,{variant:"ghost",size:"sm","data-drawer-load-more":"",disabled:c.isFetchingNextPage,onClick:()=>void c.fetchNextPage(),children:c.isFetchingNextPage?m("ui.notifications.page.loading"):m("ui.common.forms.compact_pagination.next_page")})]}),f.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-hairline border-t px-3 py-2 text-meta",children:[f.jsx("span",{className:"min-w-0 text-ink-dim",children:m("ui.notifications.drawer.footer")}),f.jsxs(ke,{variant:"ghost",size:"sm",className:"shrink-0",onClick:()=>r(`/notifications?from=${encodeURIComponent(e)}`),children:[m("ui.notifications.drawer.open_notifications"),f.jsx(VQ,{"aria-hidden":"true",className:"rtl:-scale-x-100"})]})]})]})},Fze=({view:e,onView:t,unreadCount:n,action:r})=>f.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-between gap-1 px-2 pt-2",children:[f.jsx("div",{role:"radiogroup","aria-label":m("ui.notifications.filter.read_state"),className:"flex items-center gap-0.5 rounded-sm bg-sunken p-0.5",children:["unread","read"].map(i=>f.jsxs("button",{type:"button",role:"radio","aria-checked":e===i,tabIndex:e===i?0:-1,onKeyDown:a=>{if(!["ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(a.key))return;a.preventDefault();const o=a.key==="Home"?"unread":a.key==="End"?"read":i==="read"?"unread":"read";t(o),a.currentTarget.parentElement?.querySelector(`[data-drawer-read-view="${o}"]`)?.focus()},"data-drawer-read-view":i,onClick:()=>t(i),className:E("flex h-7 items-center gap-1.5 rounded-xs px-2.5 text-body-sm",e===i?"bg-elevated text-ink":"text-ink-muted hover:text-ink"),children:[i==="unread"?m("ui.notifications.drawer.group.unread"):m("ui.notifications.drawer.group.read"),i==="unread"&&n>0&&f.jsx(js,{variant:"neutral",size:"count",style:{minWidth:`calc(${Math.max(2,Za(n).length)}ch + 10px)`},children:Za(n)})]},i))}),r]}),Bze=({item:e,nowMs:t,onShow:n,onToggleRead:r,onDismiss:i,paused:a})=>{const o=ece(e);return f.jsxs("li",{className:"group/drawer-row flex h-12 items-center gap-2 rounded-sm px-2 hover:bg-row-hover","data-drawer-update":e.id,"data-unread":e.read?void 0:"",children:[f.jsx("span",{"aria-hidden":"true",className:E("size-1.5 shrink-0 rounded-full bg-accent forced-colors:bg-[CanvasText]",e.read&&"invisible")}),f.jsx(r9,{priority:e.priority}),f.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[f.jsx("span",{className:E("truncate text-body-sm",e.read?"text-ink-muted":"font-semibold text-ink"),children:e.title}),f.jsx("span",{className:"truncate text-ink-dim text-meta",children:o==="live"?m("ui.notifications.seen.live"):o==="in_view"?m("ui.notifications.seen.in_view"):Ice(tce(e.updated_at,t))})]}),f.jsxs("span",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-focus-within/drawer-row:opacity-100 group-hover/drawer-row:opacity-100",children:[f.jsx(R0,{label:e.read?m("ui.notifications.row.mark_unread"):m("ui.notifications.row.mark_read"),disabled:a,onPress:r,"data-row-action":"read",children:e.read?f.jsx(Vse,{size:14}):f.jsx(ba,{size:14})}),f.jsx(R0,{label:m("ui.notifications.row.dismiss"),disabled:a,onPress:i,"data-row-action":"dismiss",children:f.jsx(ni,{size:14})})]}),f.jsx(vt,{content:m("ui.notifications.drawer.show_in_conversation"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.notifications.drawer.show_in_conversation"),onClick:()=>n(e),children:f.jsx(sqe,{"aria-hidden":"true"})})})]})},Hze=16,Kze=64,lj=e=>e==="right"||e==="bottom"?1:-1,Jze=(e,t)=>t==="rtl"?-e:e,e9e=e=>e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e,t9e=(e,t,n)=>Math.max(t,Math.min(n,e)),i0=(e,t,n,r,i)=>t9e(e+t*lj(n),r,i),n9e=e=>e==="top"||e==="bottom",r9e=(e,{shiftKey:t,value:n,min:r,max:i,side:a,homeEnd:o="axis"})=>{const s=t?Kze:Hze,l=lj(a)===1?r:i,c=lj(a)===1?i:r,u=o==="value"?r:l,O=o==="value"?i:c;if(n9e(a)){if(e==="ArrowDown")return i0(n,s,a,r,i);if(e==="ArrowUp")return i0(n,-s,a,r,i)}else{if(e==="ArrowRight")return i0(n,s,a,r,i);if(e==="ArrowLeft")return i0(n,-s,a,r,i)}if(e==="Home")return u;if(e==="End")return O;if(e==="Enter")return null};var KP={exports:{}},JP,UY;function i9e(){if(UY)return JP;UY=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return JP=e,JP}var e5,WY;function a9e(){if(WY)return e5;WY=1;var e=i9e();function t(){}function n(){}return n.resetWarningCache=t,e5=function(){function r(o,s,l,c,u,O){if(O!==e){var d=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw d.name="Invariant Violation",d}}r.isRequired=r;function i(){return r}var a={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:i,element:r,elementType:r,instanceOf:i,node:r,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:t};return a.PropTypes=a,a},e5}var NY;function o9e(){return NY||(NY=1,KP.exports=a9e()()),KP.exports}var s9e=o9e();const zn=In(s9e),Vce=/^([1-9])\.?$/,cj=[{label:"Approve",description:"Run the action and continue the turn."},{label:"Deny",description:"Refuse the action; the turn continues."}],Mce=e=>e===cj[0]?.label?!0:e===cj[1]?.label?!1:null,Lce=e=>{const t=e.trim().toLowerCase();if(["y","yes","approve","ok","allow"].includes(t))return!0;if(["n","no","deny","reject","cancel"].includes(t))return!1;const n=Vce.exec(e.trim());if(!n)return null;const r=cj[Number.parseInt(n[1],10)-1];return r?Mce(r.label):null};function l9e(e,t){if(e.kind!=="ask"||e.options.length===0)return t;const n=Vce.exec(t.trim());if(!n)return t;const r=Number.parseInt(n[1],10)-1,i=e.options[r];return i?i.label:t}const fon=(e,t,n)=>l9e(e,t??n),c9e=e=>!!e?.secret,u9e=(e,t,n)=>{if(e.key!=="Tab"||e.shiftKey||e.altKey||e.ctrlKey||e.metaKey||t.value.trim().length===0)return!1;const{selectionStart:r,selectionEnd:i}=t;return r===null||i===null?!1:r===i&&i===t.value.length},O9e=(e,t,n)=>e!==null&&t===e&&e.value.length===0&&!n,d9e=()=>{let e=!1;return{get held(){return e},tryAcquire(){return e?!1:(e=!0,!0)},release(){e=!1}}},f9e=e=>e instanceof Error&&"code"in e&&typeof e.code=="string"?e.code:void 0,h9e="That question was already answered somewhere else, so your answer was not sent.",p9e="That question had already been settled or moved on, so your answer was not sent.",m9e="Your answer was not sent. The app reconnected to a new runtime instance, so the question was not answered here.",Fce="Whether your answer landed is not knowable.",g9e=e=>`${Fce} ${As(e,"The request could not be completed.")}`,$9e="Your answer isn't confirmed yet. The agent is busy.",y9e=`${Fce} The app could not reach this chat's session at all.`,Bce=e=>e instanceof Ln&&e.code===bse,v9e=e=>e instanceof Ln&&e.code===wse.runtimeUnreachable,b9e=e=>e instanceof Ln&&e.status===409&&e.code===void 0,w9e=e=>`Your answer was not sent. ${As(e,"The request could not be completed.")}`,x9e=new Set([a2e,sz.transportFailed,wse.runtimeUnreachable,bse]),i9=e=>!(e instanceof Ln)||e.status===null||e.code!==void 0&&x9e.has(e.code),hon=(e,t)=>{if(e.status==="refused")return{to:"refused"};if(e.status==="sent")return{to:"sent"};const n=Q9e(e.error,t),r=Bce(e.error);return t.cardOnScreen&&t.liveGateKey===t.pressedGateKey?{to:"card",refused:n,retryable:!i9(e.error),muted:r}:{to:"composer",message:n,code:k9e(e.error),muted:r,retry:!1}},S9e="answer_unconfirmed",Q9e=(e,t)=>{if(Bce(e))return $9e;if(v9e(e))return y9e;if(i9(e))return g9e(e);if(b9e(e)){if(t.liveEpoch!==t.sentEpoch)return m9e;if(t.liveGateKey===null)return h9e;if(t.liveGateKey!==t.pressedGateKey)return p9e}return w9e(e)},k9e=e=>i9(e)?S9e:f9e(e)??o2e,pon="Your answer was not sent — a secret request is answered in the field above the composer.",mon=async(e,t)=>{const{gate:n,sessionId:r,epoch:i,label:a,lock:o}=e,s=n.kind==="approval"?Mce(a):null;if(n.kind!=="ask"&&s===null||!r||!i)return{status:"refused"};if(!o.tryAcquire())return{status:"refused"};const l=n.kind==="approval"?{op:"sessions.answer",sessionId:r,epoch:i,requestId:n.request_id,approved:s===!0}:{op:"sessions.answer",sessionId:r,epoch:i,requestId:n.request_id,value:a,questionIndex:n.question_index};try{return await vse(()=>t(l)),{status:"sent"}}catch(c){return{status:"failed",request:l,error:c}}finally{o.release()}},gon=async(e,t)=>{const{gate:n,sessionId:r,epoch:i,value:a,lock:o}=e,s=a.trim();if(n.kind!=="ask"||!c9e(n))return{status:"refused"};if(!r||!i||s.length===0)return{status:"refused"};if(!o.tryAcquire())return{status:"refused"};const l={op:"sessions.answer",sessionId:r,epoch:i,requestId:n.request_id,value:s,questionIndex:n.question_index};try{return await vse(()=>t(l)),{status:"sent"}}catch(c){return{status:"failed",request:l,error:c}}finally{o.release()}},_9e=async(e,t)=>{const{taskId:n,answers:r,sessionId:i,lock:a}=e;if(!i||!n)return{status:"refused"};if(Object.keys(r).length===0)return{status:"refused"};if(!a.tryAcquire())return{status:"refused"};const o={op:"sessions.answer",sessionId:i,askId:n,answers:r};try{return await t(o),{status:"sent"}}catch(s){return{status:"failed",request:o,error:s}}finally{a.release()}},P9e=async(e,t)=>{const{taskId:n,answers:r,sessionId:i,lock:a}=e;if(!i||!n)return{status:"refused"};if(Object.keys(r).length===0)return{status:"refused"};if(!a.tryAcquire())return{status:"refused"};const o={op:"sessions.answer",sessionId:i,askId:n,answers:r,revise:!0};try{return await t(o),{status:"sent"}}catch(s){return{status:"failed",request:o,error:s}}finally{a.release()}},T9e=async(e,t)=>{const{taskId:n,sessionId:r,lock:i}=e;if(!r||!n)return{status:"refused"};if(!i.tryAcquire())return{status:"refused"};const a={op:"sessions.answer",sessionId:r,askId:n,decline:!0};try{return await t(a),{status:"sent"}}catch(o){return{status:"failed",request:a,error:o}}finally{i.release()}},X9e=async(e,t)=>{const{taskId:n,reason:r,sessionId:i,lock:a}=e;if(!i||!n)return{status:"refused"};if(!a.tryAcquire())return{status:"refused"};const o={op:"sessions.answer",sessionId:i,askId:n,dismiss:!0,reason:r};try{return await t(o),{status:"sent"}}catch(s){return{status:"failed",request:o,error:s}}finally{a.release()}},Hce=["desktop","asks"],YY=1e4;function R9e(e){const t=Array.isArray(e)?e:e?.asks??[];if(!Array.isArray(t))return[];const n=[];for(const r of t){if(r===null||typeof r!="object")continue;const i=r;if(typeof i.ask_id!="string"||i.ask_id.length===0)continue;const a=i.session_id;typeof a!="string"||a.length===0||n.push(i)}return n}const Kce=e=>KQ({asks:[...e]}).rows.filter(t=>t.canAnswer).length;function $on(e){const t=new Map;for(const n of KQ({asks:[...e]}).rows){if(!n.canAnswer)continue;const r=n.ask.session_id;typeof r!="string"||r.length===0||t.set(r,(t.get(r)??0)+1)}return t}const E9e=Object.freeze({asks:null,asks_open:null,asks_truncated:!1});function q9e(e,t){return e!==null?j9e(e):t?E9e:null}function j9e(e){return{asks:[...e],asks_open:Kce(e),asks_truncated:!1}}function C9e(e,t){const n=typeof e.session_id=="string"?e.session_id:"",r=t===void 0?null:t(n);if(typeof r=="string"&&r.trim().length>0)return r.trim();const a=(typeof e.cwd=="string"?e.cwd:"").replace(/[/\\]+$/,"");if(a.length>0){const o=a.split(/[/\\]/),s=o[o.length-1];if(s&&s.length>0)return s}return n.length===0?null:`conversation ${n.slice(-4)}`}function z9e(e,t){const n=e.map(a=>({ask:a,label:C9e(a,t)})),r=new Map;for(const a of n){if(a.label===null)continue;const o=a.ask.session_id,s=a.label.toLocaleLowerCase(),l=r.get(s)??new Set;typeof o=="string"&&o.length>0&&l.add(o),r.set(s,l)}const i=new Map;for(const a of n){if(a.label===null)continue;const o=a.ask.session_id,s=(r.get(a.label.toLocaleLowerCase())?.size??0)>1&&typeof o=="string"&&o.length>0;i.set(a.ask.ask_id,s?`${a.label} · ${o.slice(-4)}`:a.label)}return i}function ub(e,t){const n=e.find(i=>i.ask_id===t);if(!n)return null;const r=n.session_id;return typeof r=="string"&&r.length>0?r:null}function A9e(e,t){return e!==null?"live":t instanceof Ln&&t.status===404?"absent":"unknown"}function U9e(){const{client:e,provided:t}=mi(),n=wt({enabled:t,queryKey:Hce,queryFn:async()=>R9e(await qe({op:"asks.list"})),staleTime:YY,refetchOnMount:!1,retry:Ir,refetchInterval:YY},e),r=n.data??null,i=A9e(r,n.error);return{rows:r,outstanding:r===null?0:Kce(r),capability:i,frontend:q9e(r,i==="absent"),rowFor:a=>r===null?null:r.find(o=>o.ask_id===a)??null}}const W9e=({onAccepted:e,now:t=Date.now}={})=>{const n=$.useRef(d9e()).current,[r,i]=$.useState({}),[a,o]=$.useState(!1),s=$.useRef(e);s.current=e;const l=$.useCallback(c=>{n.held||(o(!0),i(u=>({...u,[c.askId]:{sending:!0,refused:null,...c.kind==="changed"&&u[c.askId]?.settled?{settled:u[c.askId]?.settled}:{}}})),(async()=>{let u;try{u=await c.send()}catch(O){u={status:"failed",request:{},error:O}}finally{o(!1)}if(u.status==="failed"){const O=Gce(u.error),d=Dze(u.error);i(h=>({...h,[c.askId]:{sending:!1,refused:Ize(u.error),...c.kind==="changed"&&h[c.askId]?.settled?{settled:h[c.askId]?.settled}:{},refusedByOwner:O,...d?{retry:()=>l(c)}:{}}}));return}if(u.status==="refused"){i(O=>({...O,[c.askId]:{sending:!1,refused:null,...c.kind==="changed"&&O[c.askId]?.settled?{settled:O[c.askId]?.settled}:{}}}));return}i(O=>{const d=O[c.askId]?.settled?.revision,h=c.decision,p=d?.acknowledged,g=h&&d?.identity===h.identity&&(d.accepted===h.before||d.superseded.includes(h.before)||!h.hasRevisionMarker&&p?.unmarked===!0&&(p.current===h.beforeAnswers||p.predecessors.includes(h.beforeAnswers))),y=h?{identity:h.identity,superseded:[...new Set([...g?d.superseded:[],h.before])],accepted:h.after,acknowledged:{current:h.afterAnswers,predecessors:g&&p?[...new Set([...p.predecessors,p.current])]:[],unmarked:!h.hasRevisionMarker&&(!g||p?.unmarked!==!1)}}:void 0;return{...O,[c.askId]:c.kind==="changed"?{sending:!1,refused:null,changed:!0,settled:{status:O[c.askId]?.settled?.status??"answered",at:t(),...y?{revision:y}:{},answers:nj(c.questions??[],c.answers??{})}}:{sending:!1,refused:null,...c.kind==="dismissed"&&c.reason!==void 0?{dismissed:c.reason}:{},settled:{status:c.kind,at:t(),...y?{revision:y}:{},...c.answers===void 0?{}:{answers:nj(c.questions??[],c.answers)},...c.reason===void 0?{}:{reason:c.reason}}}}}),s.current?.(c)})())},[n,t]);return{lock:n,outcomes:r,answering:a,run:l}},yon=(e,t,n)=>t===null||t===n||e!==null&&t===e,von=e=>e.viewMoved?e.caretUntouched?"composer":"leave":e.capturedUsable?"captured":e.caretUntouched?"trigger":"leave",N9e=()=>{const e=oze();return!e||e.disabled?!1:(Kz(),document.activeElement===e)},Y9e=3e4,Jce=(e,t)=>{const[n,r]=$.useState(()=>t??Date.now());return $.useEffect(()=>{if(t!==void 0||!e)return;r(Date.now());const i=window.setInterval(()=>r(Date.now()),Y9e);return()=>window.clearInterval(i)},[e,t]),t??n},eue="data-text-surface",t5=Object.freeze({[eue]:"true"}),a9=e=>{const t=$.useCallback(r=>{const i=window.matchMedia(e);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[e]),n=$.useCallback(()=>window.matchMedia(e).matches,[e]);return $.useSyncExternalStore(t,n,()=>!1)},tue="ms-5",nue="self-start mt-0.5",GY="flex min-h-6 w-full items-center gap-1.5 py-0.5 text-start",Ti=({summary:e,children:t,defaultOpen:n=!1,animate:r=!1,open:i,chevron:a="leading",className:o,triggerClassName:s,triggerData:l,chevronClassName:c,summaryAlign:u="center",rowClassName:O,disabled:d=!1,triggerLabel:h,triggerTooltip:p,tooltipClassName:g,trailing:y,onOpenChange:v})=>{const[b,x]=$.useState(n),Q=i!==void 0,w=Q?i:b,S=z=>{Q||x(z),v?.(z)},k=$.useId(),P=$.useRef(null),R=E("shrink-0",u==="firstLine"&&nue),T=u==="firstLine"?"items-start":null,q=$.useRef(!1),X=$.useRef(!1),C=$.useRef(null),N=z=>{for(let V=z instanceof Element?z:null;V&&V!==P.current;V=V.parentElement)if(V.hasAttribute(eue))return!0;return!1},A=z=>{if(q.current=N(z.target),X.current=!!window.getSelection()?.toString(),z.detail<=1){C.current=null;return}q.current&&C.current!==null&&(S(C.current),C.current=null)},Y=z=>{const V=z.detail===0,J=X.current||!!window.getSelection()?.toString();!V&&q.current&&(J||z.detail>1)||(C.current=w,S(!w))},W=z=>{if(z.key!=="Escape")return;const V=window.getSelection();!V||V.isCollapsed||P.current?.contains(V.anchorNode)&&V.removeAllRanges()};if(d)return f.jsx("div",{...l,className:o,children:f.jsxs("div",{className:E(GY,T,"text-ink-dim",O),children:[a==="leading"&&f.jsx("span",{className:E("size-3.5",R),"aria-hidden":!0}),f.jsx("span",{className:"min-w-0 flex-1",children:e})]})});const Z=w?f.jsx(ix,{className:"size-3.5","aria-hidden":!0}):f.jsx(Lse,{className:"size-3.5 rtl:-scale-x-100","aria-hidden":!0}),D=f.jsx(vt,{content:p,side:"top",className:g,children:f.jsxs("button",{type:"button",...l,"aria-expanded":w,"aria-controls":w&&t!=null?k:void 0,"aria-label":h,ref:P,onMouseDown:A,onClick:Y,onKeyDown:W,className:E(GY,T,"cursor-pointer select-none","text-ink-dim transition-colors duration-fast ease-out-quart hover:text-ink-muted",O,s),children:[a==="leading"&&f.jsx("span",{className:E("flex text-ink-disabled",R,c),children:Z}),f.jsx("span",{className:"min-w-0 flex-1",children:e}),a==="trailing"&&f.jsx("span",{className:E("flex text-ink-disabled",R,c),children:Z})]})});return f.jsxs("div",{className:o,children:[y?f.jsxs("div",{className:E("group flex items-center"),children:[D,y]}):D,r&&t!=null?f.jsx(G9e,{id:k,open:w,indent:a==="leading",children:t}):w&&t!=null?f.jsx("div",{id:k,className:E("mt-1 flex flex-col gap-2 pb-1",a==="leading"&&tue),children:t}):null]})},G9e=({id:e,open:t,indent:n,children:r})=>{const i=a9("(prefers-reduced-motion: reduce)"),[a,o]=$.useState(t),[s,l]=$.useState(t);return $.useLayoutEffect(()=>{if(!t||i){l(t);return}o(!0);let c=requestAnimationFrame(()=>{c=requestAnimationFrame(()=>l(!0))});return()=>cancelAnimationFrame(c)},[t,i]),$.useEffect(()=>{if(t||!a)return;if(i){o(!1);return}const c=setTimeout(()=>o(!1),240);return()=>clearTimeout(c)},[t,a,i]),f.jsx("div",{id:e,"data-disclosure-body":"animated","aria-hidden":!t,...t?{}:{inert:""},className:E("grid overflow-hidden transition-[grid-template-rows,opacity] duration-base ease-out-quart motion-reduce:transition-none",s?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0"),onTransitionEnd:c=>{!t&&c.target===c.currentTarget&&c.propertyName==="grid-template-rows"&&o(!1)},children:f.jsx("div",{className:E("min-h-0 overflow-hidden"),children:(t||a&&!i)&&f.jsx("div",{className:E("flex flex-col gap-2 pt-1 pb-1",n&&tue),children:r})})})};function Z9e(e,t){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<t?e:null}function I9e({className:e}){return Qe(),f.jsxs("span",{className:E("inline-flex shrink-0 items-baseline gap-0.5 font-medium text-ink-muted text-meta",e),children:[f.jsx("span",{"aria-hidden":"true",children:"▸"}),m("ui.chat.asks.recommended")]})}const ZY="Files and images can't be attached to an answer yet. Type your answer here, or send the file in the chat.",D9e=`Answers stop at ${oj.toLocaleString("en-US")} characters; anything past that is not kept.`,rue=e=>t=>{t.key!=="Enter"||t.shiftKey||t.nativeEvent.isComposing||(t.preventDefault(),!t.repeat&&e())},IY=({value:e,onChange:t,onEnter:n,disabled:r,ariaLabel:i,placeholder:a,questionId:o,fieldRef:s})=>{const[l,c]=$.useState(null);return f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx(Nd,{ref:s,"data-ask-other":o,value:e,disabled:r,"aria-label":i,placeholder:a,autoComplete:"off",maxLength:oj,onChange:u=>{c(null),t(u.target.value)},onKeyDown:rue(n),onPaste:u=>{const O=u.clipboardData;if(!O)return;const d=Array.from(O.files??[]);if(!(d.length>0||Array.from(O.items??[]).some(v=>v.kind==="file")))return;const p=O.getData("text/plain"),g=d.map(v=>v.name),y=g.length>0&&p.split(`
|
|
517
|
+
`)}},Nze=(e,t,n)=>{const r=e.filter(o=>t.includes(o)),i=n.open?n.text.trim():"";if(i===""||!t.includes(i))return r;const a=r.lastIndexOf(i);return r.filter((o,s)=>s!==a)},zY=(e,t,n)=>{if(!n.open)return t?[...e]:[];const r=n.text.trim();return t?[...e,r]:[r]},cb=(e,t,n={},r)=>{if(!Aze(e,t,n,r))return null;const i={};for(const a of e.questions)i[a.id]=a.secret?n9(a,n)?[(n[a.id]??"").trim()]:[]:[...new Set(t9(t,a.id).filter(iv))];return i},Yze=e=>{const t={};for(const n of e.questions){if(n.secret)continue;const r=e.answers?.[n.id];Array.isArray(r)&&r.length>0&&(t[n.id]=[...r])}return t},sj="That question was already settled, so your answer was not sent.",Gze="This ask is too old to answer — ask the agent again.",Yce=e=>{const t=typeof e?.status=="number"?e.status:null,n=typeof e?.code=="string"?e.code:"";return t===410||n==="expired"?Gze:t===409?sj:null},Zze=e=>{const t=typeof e=="object"&&e!==null?e.detail:void 0,n=e instanceof Error?e.message:"";return t!==void 0||e instanceof Ln&&n!==""&&n!==i2e},Ize=e=>{if(Zze(e))return As(e,sj);const t=Yce(e);return t!==null?t:As(e,e instanceof Error&&e.message?e.message:sj)},Gce=e=>Yce(e)!==null,Dze=e=>{if(Gce(e))return!1;const t=typeof e=="object"&&e!==null?e.code:void 0;return typeof t!="string"?!0:t===sz.transportFailed},Zce=e=>e==="moot"||e==="answered_in_chat"?e:null,lon=e=>e===1?"1 ask":`${e} asks`,Vze={high:3,normal:2,low:1},r9=({priority:e,className:t})=>{const n=Vze[e];return f.jsx("svg",{width:"14",height:"12",viewBox:"0 0 14 12","aria-hidden":"true","data-priority-bars":e,className:E("shrink-0",e==="high"?"text-warning":"text-ink-dim",t),children:[0,1,2].map(r=>f.jsx("rect",{x:1+r*4.5,y:8-r*3.5,width:"3",height:3+r*3.5,rx:"0.75",className:r<n?"fill-current":"fill-ink-disabled"},r))})},Ice=e=>{switch(e.kind){case"now":return m("ui.notifications.time.now");case"minutes":return m("ui.notifications.time.minutes",{count:Za(e.count)});case"hours":return m("ui.notifications.time.hours",{count:Za(e.count)});case"clock":return GQ(e.at,{hour:"2-digit",minute:"2-digit"});case"date":return YQ(e.at,{weekday:"short",day:"numeric"})}},Mze=e=>e.priority==="high"?m("ui.notifications.row.priority.high"):e.priority==="normal"?m("ui.notifications.row.priority.normal"):m("ui.notifications.row.priority.low"),BP="h-[calc(var(--text-body-sm)*var(--text-body-sm--line-height))] items-center",con=({item:e,nowMs:t,open:n,picked:r,selecting:i,focused:a,writesPaused:o,onOpen:s,onToggleSelect:l,onToggleRead:c,onDismiss:u,onAnswer:O,onFocusRow:d,hideSource:h=!1})=>{const p=Gd(e),g=!e.read,y=ece(e),v=Ice(tce(e.updated_at,t)),b=e.session.title||m("ui.notifications.group.untitled"),x=e.repeat_count>1?e.repeat_count:0,Q=m("ui.notifications.row.a11y",{read:g?"false":"true",priority:Mze(e),title:e.title,source:b,age:v,repeat:x}),w=(()=>{if(p){const k=[],P=e.ask?.question_count;typeof P=="number"&&P>0&&k.push(m("ui.notifications.row.ask_options",{options:P}));const R=e.ask?.deadline_at;if(typeof R=="number"&&R>t){const T=Math.max(1,Math.round((R-t)/6e4));k.push(m("ui.notifications.row.ask_expires",{time:T<60?m("ui.notifications.time.minutes",{count:Za(T)}):m("ui.notifications.time.hours",{count:Za(Math.round(T/60))})}))}return k.length>0?k.join(" · "):e.excerpt}return e.source==="ask"&&e.ask?.status?e9(Sce(e.ask.status)?e.ask.status:"unknown"):x>0?`${m("ui.notifications.row.updated_ago",{age:v})} · ${e.excerpt}`:e.excerpt})(),S=o?m("ui.notifications.writes_paused_tip"):null;return f.jsxs("div",{role:"row","aria-selected":r,"aria-label":Q,tabIndex:a?0:-1,"data-notification-row":e.id,"data-notification-revision":e.revision,"data-notification-unread":g?"":void 0,"data-notification-open":n?"":void 0,onClick:k=>{if(k.shiftKey||i){l(e,k.shiftKey);return}s(e)},onFocus:()=>d(e),className:E("group/row relative flex min-h-14 cursor-default items-start gap-3 px-3 py-2","outline-none focus-visible:outline-2 focus-visible:outline-accent focus-visible:-outline-offset-2","transition-colors duration-fast ease-out-quart",r?"bg-accent-wash":n?"bg-row-selected":"hover:bg-row-hover"),children:[f.jsxs("div",{role:"gridcell",tabIndex:-1,className:E("relative flex w-4 shrink-0 justify-center",BP),children:[f.jsx("span",{"aria-hidden":"true",className:E("size-1.5 rounded-full bg-accent forced-colors:bg-[CanvasText]",(!g||i)&&"invisible","group-hover/row:invisible group-focus-within/row:invisible")}),f.jsx("span",{"data-notification-select":"",className:E("absolute flex size-6 items-center justify-center",i||r?"visible":"invisible group-hover/row:visible group-focus-within/row:visible"),onClick:k=>k.stopPropagation(),onKeyDown:k=>{(k.key===" "||k.key==="Enter")&&k.stopPropagation()},children:f.jsx(Dse,{checked:r,tabIndex:-1,hitArea:"comfortable",onClick:k=>{k.stopPropagation(),l(e,k.shiftKey)},"aria-label":m("ui.notifications.row.select",{title:e.title})})})]}),f.jsx("div",{role:"gridcell",tabIndex:-1,className:E("flex w-5 shrink-0 justify-center",BP),children:e.source==="ask"?f.jsx(Pje,{size:16,"aria-hidden":"true",className:p?"text-info":"text-ink-dim"}):f.jsx(r9,{priority:e.priority})}),f.jsxs("div",{role:"gridcell",tabIndex:-1,className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[f.jsx("span",{"data-notification-title":"",className:E("min-w-0 truncate text-body-sm",g?"font-semibold text-ink":"text-ink-muted"),children:e.title}),e.priority==="high"&&e.source==="notify"&&f.jsx(js,{variant:"warning",size:"count",className:"h-4.5 px-1.5",children:m("ui.notifications.row.chip.high")}),x>0&&f.jsx(js,{variant:"neutral",size:"count",children:m("ui.notifications.row.chip.repeat",{count:ARe(x,99)})})]}),f.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-ink-dim text-meta",children:[!h&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"shrink-0 text-ink-muted",children:b}),f.jsx("span",{"aria-hidden":"true",children:"·"})]}),y&&f.jsx(vt,{content:y==="live"?m("ui.notifications.seen.live_hint"):m("ui.notifications.seen.in_view_hint"),children:f.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1","data-notification-seen":y,children:[f.jsx($le,{size:12,"aria-hidden":"true"}),y==="live"?m("ui.notifications.seen.live"):m("ui.notifications.seen.in_view")]})}),y&&f.jsx("span",{"aria-hidden":"true",children:"·"}),f.jsx("span",{className:"min-w-0 truncate",children:w})]})]}),f.jsxs("div",{role:"gridcell",tabIndex:-1,className:E("relative flex w-16 shrink-0 justify-end",BP),children:[f.jsx("span",{className:E("text-ink-dim text-meta tabular-nums","group-hover/row:invisible group-focus-within/row:invisible"),children:v}),f.jsxs("span",{className:E("absolute inset-e-0 flex items-center gap-0.5","invisible group-hover/row:visible group-focus-within/row:visible"),children:[f.jsx(R0,{label:S??(g?m("ui.notifications.row.mark_read"):m("ui.notifications.row.mark_unread")),disabled:o,onPress:()=>c(e),"data-row-action":"read",children:g?f.jsx(ba,{size:14}):f.jsx(Vse,{size:14})}),p?f.jsx(R0,{label:m("ui.notifications.row.answer"),onPress:()=>O(e),"data-row-action":"answer",children:f.jsx(Tle,{size:14})}):f.jsx(R0,{label:S??m("ui.notifications.row.dismiss"),disabled:o,onPress:()=>u(e),"data-row-action":"dismiss",children:f.jsx(ni,{size:14})})]})]})]})},R0=({label:e,disabled:t=!1,onPress:n,children:r,...i})=>f.jsx(vt,{content:e,children:f.jsx("button",{type:"button",tabIndex:-1,"aria-label":e,"aria-disabled":t||void 0,"data-row-action":i["data-row-action"],"data-row-visible":i["data-row-visible"],onClick:a=>{a.stopPropagation(),!t&&n()},className:E("flex size-7 items-center justify-center rounded-sm text-ink-muted","hover:bg-elevated hover:text-ink","focus-visible:outline-2 focus-visible:outline-accent",t&&"text-ink-disabled hover:bg-transparent hover:text-ink-disabled"),children:r})}),uon=(e,t)=>t>0?"asks":"updates",Lze=({tab:e,onTab:t,asks:n,unreadUpdates:r,sessionless:i})=>{Qe();const a=[{id:"asks",label:m("ui.notifications.drawer.tab.asks"),count:n},{id:"updates",label:m("ui.notifications.drawer.tab.updates"),count:r},{id:"all",label:m("ui.notifications.drawer.tab.all"),count:0}],o=i?a.filter(l=>l.id==="all"):a,s=l=>{const c=l.key==="ArrowRight"||l.key==="Tab"&&l.ctrlKey&&!l.shiftKey?1:l.key==="ArrowLeft"||l.key==="Tab"&&l.ctrlKey&&l.shiftKey?-1:0;if(c===0)return;l.preventDefault();const u=o.findIndex(d=>d.id===e),O=o[(u+c+o.length)%o.length];t(O.id),l.currentTarget.querySelector(`[data-drawer-tab="${O.id}"]`)?.focus()};return f.jsxs("div",{className:"flex shrink-0 flex-col gap-1 border-hairline border-b px-2 pb-1",onKeyDown:s,children:[f.jsx("button",{type:"button","aria-pressed":e==="all","data-drawer-tab":"all",onClick:()=>t("all"),className:E("min-h-8 w-full whitespace-normal rounded-sm px-2 py-1 text-start text-body-sm",e==="all"?"bg-row-selected text-ink":"text-ink-muted hover:bg-row-hover"),children:m("ui.notifications.drawer.tab.all")}),!i&&f.jsx("div",{role:"tablist","aria-label":m("ui.notifications.drawer.tabs_label"),className:"flex min-w-0 gap-1",children:a.filter(l=>l.id!=="all").map(l=>f.jsxs("button",{type:"button",role:"tab","aria-selected":e===l.id,tabIndex:e===l.id||e==="all"&&l.id==="asks"?0:-1,"data-drawer-tab":l.id,onClick:()=>t(l.id),className:E("flex min-h-8 min-w-0 flex-1 flex-wrap items-center justify-center gap-1 border-b-2 px-2 py-1 text-body-sm",e===l.id?"border-accent text-ink":"border-transparent text-ink-muted hover:text-ink"),children:[f.jsx("span",{className:"min-w-0 whitespace-normal break-words",children:l.label}),l.count>0&&f.jsx(js,{variant:"neutral",size:"count",className:"h-auto max-w-full whitespace-normal break-words text-center",children:l.id==="updates"?m("ui.notifications.drawer.unread_count",{count:Za(l.count)}):Za(l.count)})]},l.id))})]})},Oon=({tab:e})=>{Qe();const t=Dq(r=>r.count),n=Dq(r=>r.backToTop);return e!=="updates"||!n||t===0?null:f.jsxs(ke,{size:"sm",variant:"secondary",className:"shrink-0","data-drawer-back-to-top":"",onClick:n,children:[f.jsx(Mse,{"aria-hidden":"true"}),m("ui.notifications.new_pill",{count:Za(t)})]})};function Dce(e,t){const r=Iz(e,t).data?.high_water,i=wt({queryKey:[...qt.sessionUnread(e),r],enabled:t&&!!e&&r!==void 0,queryFn:()=>M6e(e),retry:Ir,staleTime:5e3,placeholderData:(a,o)=>t&&e&&o?.queryKey[3]===e?a:void 0});return t&&e?i.data??0:0}const HP="drawer-refusal",AY=e=>e==="dismiss"?m("ui.notifications.error.dismiss"):m("ui.notifications.error.mark"),don=({sessionId:e,nowMs:t,initialView:n="unread"})=>{Qe();const r=gm(),[i,a]=$.useState(n),o=Dce(e,!0),[s,l]=$.useState(!0),c=Iz(e,!0,{atTop:s}),u=Dz(),O=t??Date.now(),d=Dq(X=>X.publish),h=$.useRef(c.resetToTop);h.current=c.resetToTop;const p=$.useCallback(()=>{document.querySelector("[data-drawer-updates]")?.scrollTo({top:0,behavior:"smooth"}),l(!0),h.current()},[]);$.useEffect(()=>{d(c.newerCount,c.newerCount>0?p:null)},[c.newerCount,p,d]),$.useEffect(()=>()=>d(0,null),[d]);const g=$.useMemo(()=>(c.data?.items??[]).filter(X=>!X.dismissed).sort((X,C)=>C.updated_at-X.updated_at),[c.data]),y=g.filter(X=>!X.read),v=g.filter(X=>X.read),b=i==="unread"?y:v,x=$.useRef(null),Q=$.useRef(null),w=$.useRef(null),S=$.useRef("read"),k=$.useRef(null);$.useLayoutEffect(()=>{const X=document.activeElement,C=D=>x.current?.querySelector(D)??null,N=k.current;if(N){const D=C(`[data-drawer-update="${CSS.escape(N.id)}"] [data-row-action="${N.action}"]`);if(D&&(k.current=null,X===null||X===window.document.body||X.hasAttribute("data-drawer-empty"))){D.focus();return}}const A=Q.current;if(!A||b.some(D=>D.id===A.id))return;Q.current=null;const Y=w.current!==null&&!w.current.isConnected&&w.current===X;if(X!==document.body&&!Y)return;const W=b[Math.min(A.index,b.length-1)],Z=W?`[data-drawer-update="${CSS.escape(W.id)}"] [data-row-action="${S.current}"]`:"[data-drawer-empty], [data-drawer-load-more]";W||(k.current={id:A.id,action:S.current}),x.current?.querySelector(Z)?.focus()},[b]);const P=X=>{const C=document.querySelector(`[data-notification-flag="${CSS.escape(X.id)}"]`);C?.scrollIntoView({block:"center",behavior:"smooth"}),C?.animate?.([{backgroundColor:"var(--color-accent-wash)"},{backgroundColor:"transparent"}],{duration:900,easing:"ease-out"})};if(c.isLoading)return f.jsx("p",{"data-drawer-loading":"",className:"p-3 text-body-sm text-ink-muted",children:m("ui.notifications.page.loading")});if(c.isError&&!c.data)return f.jsxs("div",{"data-drawer-load-error":"",className:"p-3 text-body-sm text-ink-muted",children:[f.jsx("p",{children:m("ui.notifications.error.load.title")}),f.jsx(ke,{size:"sm",variant:"secondary",onClick:()=>void c.refetch(),children:m("ui.notifications.error.retry")})]});const R=(X,C)=>{const N=()=>u.mutate({verb:X,target:{items:C}},{onSuccess:A=>{A.changed?.length&&Jo(m("ui.notifications.toast.undone"))},onError:()=>AP(AY(X),{id:HP,action:{label:m("ui.notifications.error.retry"),onClick:N}})});N()},T=(X,C)=>{S.current=C==="dismiss"?"dismiss":"read";const N=C==="dismiss"?"undismiss":C==="read"?"unread":"read";u.mutate({verb:C,target:{items:eO([X])}},{onSuccess:A=>{A.changed.includes(X.id)&&Jo(C==="dismiss"?m("ui.notifications.toast.dismissed",{count:1}):C==="read"?m("ui.notifications.toast.marked_read",{count:Za(1)}):m("ui.notifications.toast.marked_unread",{count:Za(1)}),{duration:Fq,action:{label:m("ui.notifications.toast.undo"),onClick:()=>R(N,eO([X]))}})},onError:()=>AP(AY(C),{id:HP})})},q=()=>{document.activeElement?.hasAttribute("data-drawer-mark-all-read")&&(Q.current={id:"bulk-action",index:0});const X=eO(y);u.mutate({verb:"read",target:{items:X}},{onSuccess:C=>{const N=new Set(C.changed),A=X.filter(Y=>N.has(Y.id));A.length!==0&&Jo(m("ui.notifications.toast.marked_read",{count:Za(A.length)}),{duration:Fq,action:{label:m("ui.notifications.toast.undo"),onClick:()=>R("unread",A)}})},onError:()=>AP(m("ui.notifications.error.mark"),{id:HP})})};return f.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[f.jsx(Fze,{view:i,onView:a,unreadCount:o,action:i==="unread"&&y.length>0?f.jsx(ke,{variant:"ghost",size:"sm",className:"shrink-0","data-drawer-mark-all-read":"",disabled:c.isError,onClick:q,children:m("ui.notifications.drawer.mark_read")}):null}),f.jsxs("div",{"data-drawer-updates":"",ref:x,onFocusCapture:X=>{const C=X.target.closest("[data-drawer-update]");C&&!C.isConnected||(w.current=C?X.target:null,Q.current=C?.dataset.drawerUpdate?{id:C.dataset.drawerUpdate,index:b.findIndex(N=>N.id===C.dataset.drawerUpdate)}:null)},className:"flex min-h-0 flex-1 flex-col overflow-y-auto px-1 py-2",onScroll:X=>{const C=X.currentTarget;l(C.scrollTop<=24),c.hasNextPage&&!c.isFetchingNextPage&&C.scrollHeight-C.scrollTop-C.clientHeight<160&&c.fetchNextPage()},onKeyDown:X=>{const N=X.target.closest("[data-drawer-update]");if(!N)return;const A=b.findIndex(W=>W.id===N.dataset.drawerUpdate),Y=b[A];if(Y)if(X.key==="ArrowDown"||X.key==="ArrowUp"){X.preventDefault();const W=b[Math.max(0,Math.min(b.length-1,A+(X.key==="ArrowDown"?1:-1)))];X.currentTarget.querySelector(`[data-drawer-update="${CSS.escape(W.id)}"] button`)?.focus()}else["r","u","e"].includes(X.key.toLowerCase())&&!c.isError&&(X.preventDefault(),T(Y,X.key.toLowerCase()==="e"?"dismiss":X.key.toLowerCase()==="u"?"unread":"read"))},children:[b.length===0&&!c.hasNextPage?f.jsx("h3",{tabIndex:-1,className:"px-3 py-8 text-center text-body-sm text-ink-muted","data-drawer-empty":i,children:g.length===0?m("ui.notifications.drawer.empty"):i==="unread"?m("ui.notifications.empty.caught_up.title"):m("ui.notifications.empty.filtered.title")}):f.jsx("ul",{className:"flex flex-col","data-drawer-view-list":i,children:b.map(X=>f.jsx(Bze,{item:X,nowMs:O,onShow:P,onToggleRead:()=>T(X,X.read?"unread":"read"),onDismiss:()=>T(X,"dismiss"),paused:c.isError},X.id))}),c.hasNextPage&&f.jsx(ke,{variant:"ghost",size:"sm","data-drawer-load-more":"",disabled:c.isFetchingNextPage,onClick:()=>void c.fetchNextPage(),children:c.isFetchingNextPage?m("ui.notifications.page.loading"):m("ui.common.forms.compact_pagination.next_page")})]}),f.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-hairline border-t px-3 py-2 text-meta",children:[f.jsx("span",{className:"min-w-0 text-ink-dim",children:m("ui.notifications.drawer.footer")}),f.jsxs(ke,{variant:"ghost",size:"sm",className:"shrink-0",onClick:()=>r(`/notifications?from=${encodeURIComponent(e)}`),children:[m("ui.notifications.drawer.open_notifications"),f.jsx(VQ,{"aria-hidden":"true",className:"rtl:-scale-x-100"})]})]})]})},Fze=({view:e,onView:t,unreadCount:n,action:r})=>f.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-between gap-1 px-2 pt-2",children:[f.jsx("div",{role:"radiogroup","aria-label":m("ui.notifications.filter.read_state"),className:"flex items-center gap-0.5 rounded-sm bg-sunken p-0.5",children:["unread","read"].map(i=>f.jsxs("button",{type:"button",role:"radio","aria-checked":e===i,tabIndex:e===i?0:-1,onKeyDown:a=>{if(!["ArrowRight","ArrowLeft","ArrowDown","ArrowUp","Home","End"].includes(a.key))return;a.preventDefault();const o=a.key==="Home"?"unread":a.key==="End"?"read":i==="read"?"unread":"read";t(o),a.currentTarget.parentElement?.querySelector(`[data-drawer-read-view="${o}"]`)?.focus()},"data-drawer-read-view":i,onClick:()=>t(i),className:E("flex h-7 items-center gap-1.5 rounded-xs px-2.5 text-body-sm",e===i?"bg-elevated text-ink":"text-ink-muted hover:text-ink"),children:[i==="unread"?m("ui.notifications.drawer.group.unread"):m("ui.notifications.drawer.group.read"),i==="unread"&&n>0&&f.jsx(js,{variant:"neutral",size:"count",style:{minWidth:`calc(${Math.max(2,Za(n).length)}ch + 10px)`},children:Za(n)})]},i))}),r]}),Bze=({item:e,nowMs:t,onShow:n,onToggleRead:r,onDismiss:i,paused:a})=>{const o=ece(e);return f.jsxs("li",{className:"group/drawer-row flex h-12 items-center gap-2 rounded-sm px-2 hover:bg-row-hover","data-drawer-update":e.id,"data-unread":e.read?void 0:"",children:[f.jsx("span",{"aria-hidden":"true",className:E("size-1.5 shrink-0 rounded-full bg-accent forced-colors:bg-[CanvasText]",e.read&&"invisible")}),f.jsx(r9,{priority:e.priority}),f.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[f.jsx("span",{className:E("truncate text-body-sm",e.read?"text-ink-muted":"font-semibold text-ink"),children:e.title}),f.jsx("span",{className:"truncate text-ink-dim text-meta",children:o==="live"?m("ui.notifications.seen.live"):o==="in_view"?m("ui.notifications.seen.in_view"):Ice(tce(e.updated_at,t))})]}),f.jsxs("span",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-focus-within/drawer-row:opacity-100 group-hover/drawer-row:opacity-100",children:[f.jsx(R0,{label:e.read?m("ui.notifications.row.mark_unread"):m("ui.notifications.row.mark_read"),disabled:a,onPress:r,"data-row-action":"read",children:e.read?f.jsx(Vse,{size:14}):f.jsx(ba,{size:14})}),f.jsx(R0,{label:m("ui.notifications.row.dismiss"),disabled:a,onPress:i,"data-row-action":"dismiss",children:f.jsx(ni,{size:14})})]}),f.jsx(vt,{content:m("ui.notifications.drawer.show_in_conversation"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.notifications.drawer.show_in_conversation"),onClick:()=>n(e),children:f.jsx(sqe,{"aria-hidden":"true"})})})]})},Hze=16,Kze=64,lj=e=>e==="right"||e==="bottom"?1:-1,Jze=(e,t)=>t==="rtl"?-e:e,e9e=e=>e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e,t9e=(e,t,n)=>Math.max(t,Math.min(n,e)),i0=(e,t,n,r,i)=>t9e(e+t*lj(n),r,i),n9e=e=>e==="top"||e==="bottom",r9e=(e,{shiftKey:t,value:n,min:r,max:i,side:a,homeEnd:o="axis"})=>{const s=t?Kze:Hze,l=lj(a)===1?r:i,c=lj(a)===1?i:r,u=o==="value"?r:l,O=o==="value"?i:c;if(n9e(a)){if(e==="ArrowDown")return i0(n,s,a,r,i);if(e==="ArrowUp")return i0(n,-s,a,r,i)}else{if(e==="ArrowRight")return i0(n,s,a,r,i);if(e==="ArrowLeft")return i0(n,-s,a,r,i)}if(e==="Home")return u;if(e==="End")return O;if(e==="Enter")return null};var KP={exports:{}},JP,UY;function i9e(){if(UY)return JP;UY=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return JP=e,JP}var e5,WY;function a9e(){if(WY)return e5;WY=1;var e=i9e();function t(){}function n(){}return n.resetWarningCache=t,e5=function(){function r(o,s,l,c,u,O){if(O!==e){var d=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw d.name="Invariant Violation",d}}r.isRequired=r;function i(){return r}var a={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:i,element:r,elementType:r,instanceOf:i,node:r,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:t};return a.PropTypes=a,a},e5}var NY;function o9e(){return NY||(NY=1,KP.exports=a9e()()),KP.exports}var s9e=o9e();const zn=In(s9e),Vce=/^([1-9])\.?$/,cj=[{label:"Approve",description:"Run the action and continue the turn."},{label:"Deny",description:"Refuse the action; the turn continues."}],Mce=e=>e===cj[0]?.label?!0:e===cj[1]?.label?!1:null,Lce=e=>{const t=e.trim().toLowerCase();if(["y","yes","approve","ok","allow"].includes(t))return!0;if(["n","no","deny","reject","cancel"].includes(t))return!1;const n=Vce.exec(e.trim());if(!n)return null;const r=cj[Number.parseInt(n[1],10)-1];return r?Mce(r.label):null};function l9e(e,t){if(e.kind!=="ask"||e.options.length===0)return t;const n=Vce.exec(t.trim());if(!n)return t;const r=Number.parseInt(n[1],10)-1,i=e.options[r];return i?i.label:t}const fon=(e,t,n)=>l9e(e,t??n),c9e=e=>!!e?.secret,u9e=(e,t,n)=>{if(e.key!=="Tab"||e.shiftKey||e.altKey||e.ctrlKey||e.metaKey||t.value.trim().length===0)return!1;const{selectionStart:r,selectionEnd:i}=t;return r===null||i===null?!1:r===i&&i===t.value.length},O9e=(e,t,n)=>e!==null&&t===e&&e.value.length===0&&!n,d9e=()=>{let e=!1;return{get held(){return e},tryAcquire(){return e?!1:(e=!0,!0)},release(){e=!1}}},f9e=e=>e instanceof Error&&"code"in e&&typeof e.code=="string"?e.code:void 0,h9e="That question was already answered somewhere else, so your answer was not sent.",p9e="That question had already been settled or moved on, so your answer was not sent.",m9e="Your answer was not sent. The app reconnected to a new runtime instance, so the question was not answered here.",Fce="Whether your answer landed is not knowable.",g9e=e=>`${Fce} ${As(e,"The request could not be completed.")}`,$9e="Your answer isn't confirmed yet. The agent is busy.",y9e=`${Fce} The app could not reach this chat's session at all.`,Bce=e=>e instanceof Ln&&e.code===bse,v9e=e=>e instanceof Ln&&e.code===wse.runtimeUnreachable,b9e=e=>e instanceof Ln&&e.status===409&&e.code===void 0,w9e=e=>`Your answer was not sent. ${As(e,"The request could not be completed.")}`,x9e=new Set([a2e,sz.transportFailed,wse.runtimeUnreachable,bse]),i9=e=>!(e instanceof Ln)||e.status===null||e.code!==void 0&&x9e.has(e.code),hon=(e,t)=>{if(e.status==="refused")return{to:"refused"};if(e.status==="sent")return{to:"sent"};const n=Q9e(e.error,t),r=Bce(e.error);return t.cardOnScreen&&t.liveGateKey===t.pressedGateKey?{to:"card",refused:n,retryable:!i9(e.error),muted:r}:{to:"composer",message:n,code:k9e(e.error),muted:r,retry:!1}},S9e="answer_unconfirmed",Q9e=(e,t)=>{if(Bce(e))return $9e;if(v9e(e))return y9e;if(i9(e))return g9e(e);if(b9e(e)){if(t.liveEpoch!==t.sentEpoch)return m9e;if(t.liveGateKey===null)return h9e;if(t.liveGateKey!==t.pressedGateKey)return p9e}return w9e(e)},k9e=e=>i9(e)?S9e:f9e(e)??o2e,pon="Your answer was not sent — a secret request is answered in the field above the composer.",mon=async(e,t)=>{const{gate:n,sessionId:r,epoch:i,label:a,lock:o}=e,s=n.kind==="approval"?Mce(a):null;if(n.kind!=="ask"&&s===null||!r||!i)return{status:"refused"};if(!o.tryAcquire())return{status:"refused"};const l=n.kind==="approval"?{op:"sessions.answer",sessionId:r,epoch:i,requestId:n.request_id,approved:s===!0}:{op:"sessions.answer",sessionId:r,epoch:i,requestId:n.request_id,value:a,questionIndex:n.question_index};try{return await vse(()=>t(l)),{status:"sent"}}catch(c){return{status:"failed",request:l,error:c}}finally{o.release()}},gon=async(e,t)=>{const{gate:n,sessionId:r,epoch:i,value:a,lock:o}=e,s=a.trim();if(n.kind!=="ask"||!c9e(n))return{status:"refused"};if(!r||!i||s.length===0)return{status:"refused"};if(!o.tryAcquire())return{status:"refused"};const l={op:"sessions.answer",sessionId:r,epoch:i,requestId:n.request_id,value:s,questionIndex:n.question_index};try{return await vse(()=>t(l)),{status:"sent"}}catch(c){return{status:"failed",request:l,error:c}}finally{o.release()}},_9e=async(e,t)=>{const{taskId:n,answers:r,sessionId:i,lock:a}=e;if(!i||!n)return{status:"refused"};if(Object.keys(r).length===0)return{status:"refused"};if(!a.tryAcquire())return{status:"refused"};const o={op:"sessions.answer",sessionId:i,askId:n,answers:r};try{return await t(o),{status:"sent"}}catch(s){return{status:"failed",request:o,error:s}}finally{a.release()}},P9e=async(e,t)=>{const{taskId:n,answers:r,sessionId:i,lock:a}=e;if(!i||!n)return{status:"refused"};if(Object.keys(r).length===0)return{status:"refused"};if(!a.tryAcquire())return{status:"refused"};const o={op:"sessions.answer",sessionId:i,askId:n,answers:r,revise:!0};try{return await t(o),{status:"sent"}}catch(s){return{status:"failed",request:o,error:s}}finally{a.release()}},T9e=async(e,t)=>{const{taskId:n,sessionId:r,lock:i}=e;if(!r||!n)return{status:"refused"};if(!i.tryAcquire())return{status:"refused"};const a={op:"sessions.answer",sessionId:r,askId:n,decline:!0};try{return await t(a),{status:"sent"}}catch(o){return{status:"failed",request:a,error:o}}finally{i.release()}},X9e=async(e,t)=>{const{taskId:n,reason:r,sessionId:i,lock:a}=e;if(!i||!n)return{status:"refused"};if(!a.tryAcquire())return{status:"refused"};const o={op:"sessions.answer",sessionId:i,askId:n,dismiss:!0,reason:r};try{return await t(o),{status:"sent"}}catch(s){return{status:"failed",request:o,error:s}}finally{a.release()}},Hce=["desktop","asks"],YY=1e4;function R9e(e){const t=Array.isArray(e)?e:e?.asks??[];if(!Array.isArray(t))return[];const n=[];for(const r of t){if(r===null||typeof r!="object")continue;const i=r;if(typeof i.ask_id!="string"||i.ask_id.length===0)continue;const a=i.session_id;typeof a!="string"||a.length===0||n.push(i)}return n}const Kce=e=>KQ({asks:[...e]}).rows.filter(t=>t.canAnswer).length;function $on(e){const t=new Map;for(const n of KQ({asks:[...e]}).rows){if(!n.canAnswer)continue;const r=n.ask.session_id;typeof r!="string"||r.length===0||t.set(r,(t.get(r)??0)+1)}return t}const E9e=Object.freeze({asks:null,asks_open:null,asks_truncated:!1});function q9e(e,t){return e!==null?j9e(e):t?E9e:null}function j9e(e){return{asks:[...e],asks_open:Kce(e),asks_truncated:!1}}function C9e(e,t){const n=typeof e.session_id=="string"?e.session_id:"",r=t===void 0?null:t(n);if(typeof r=="string"&&r.trim().length>0)return r.trim();const a=(typeof e.cwd=="string"?e.cwd:"").replace(/[/\\]+$/,"");if(a.length>0){const o=a.split(/[/\\]/),s=o[o.length-1];if(s&&s.length>0)return s}return n.length===0?null:`conversation ${n.slice(-4)}`}function z9e(e,t){const n=e.map(a=>({ask:a,label:C9e(a,t)})),r=new Map;for(const a of n){if(a.label===null)continue;const o=a.ask.session_id,s=a.label.toLocaleLowerCase(),l=r.get(s)??new Set;typeof o=="string"&&o.length>0&&l.add(o),r.set(s,l)}const i=new Map;for(const a of n){if(a.label===null)continue;const o=a.ask.session_id,s=(r.get(a.label.toLocaleLowerCase())?.size??0)>1&&typeof o=="string"&&o.length>0;i.set(a.ask.ask_id,s?`${a.label} · ${o.slice(-4)}`:a.label)}return i}function ub(e,t){const n=e.find(i=>i.ask_id===t);if(!n)return null;const r=n.session_id;return typeof r=="string"&&r.length>0?r:null}function A9e(e,t){return e!==null?"live":t instanceof Ln&&t.status===404?"absent":"unknown"}function U9e(){const{client:e,provided:t}=mi(),n=wt({enabled:t,queryKey:Hce,queryFn:async()=>R9e(await qe({op:"asks.list"})),staleTime:YY,refetchOnMount:!1,retry:Ir,refetchInterval:YY},e),r=n.data??null,i=A9e(r,n.error);return{rows:r,outstanding:r===null?0:Kce(r),capability:i,frontend:q9e(r,i==="absent"),rowFor:a=>r===null?null:r.find(o=>o.ask_id===a)??null}}const W9e=({onAccepted:e,now:t=Date.now}={})=>{const n=$.useRef(d9e()).current,[r,i]=$.useState({}),[a,o]=$.useState(!1),s=$.useRef(e);s.current=e;const l=$.useCallback(c=>{n.held||(o(!0),i(u=>({...u,[c.askId]:{sending:!0,refused:null,...c.kind==="changed"&&u[c.askId]?.settled?{settled:u[c.askId]?.settled}:{}}})),(async()=>{let u;try{u=await c.send()}catch(O){u={status:"failed",request:{},error:O}}finally{o(!1)}if(u.status==="failed"){const O=Gce(u.error),d=Dze(u.error);i(h=>({...h,[c.askId]:{sending:!1,refused:Ize(u.error),...c.kind==="changed"&&h[c.askId]?.settled?{settled:h[c.askId]?.settled}:{},refusedByOwner:O,...d?{retry:()=>l(c)}:{}}}));return}if(u.status==="refused"){i(O=>({...O,[c.askId]:{sending:!1,refused:null,...c.kind==="changed"&&O[c.askId]?.settled?{settled:O[c.askId]?.settled}:{}}}));return}i(O=>{const d=O[c.askId]?.settled?.revision,h=c.decision,p=d?.acknowledged,g=h&&d?.identity===h.identity&&(d.accepted===h.before||d.superseded.includes(h.before)||!h.hasRevisionMarker&&p?.unmarked===!0&&(p.current===h.beforeAnswers||p.predecessors.includes(h.beforeAnswers))),y=h?{identity:h.identity,superseded:[...new Set([...g?d.superseded:[],h.before])],accepted:h.after,acknowledged:{current:h.afterAnswers,predecessors:g&&p?[...new Set([...p.predecessors,p.current])]:[],unmarked:!h.hasRevisionMarker&&(!g||p?.unmarked!==!1)}}:void 0;return{...O,[c.askId]:c.kind==="changed"?{sending:!1,refused:null,changed:!0,settled:{status:O[c.askId]?.settled?.status??"answered",at:t(),...y?{revision:y}:{},answers:nj(c.questions??[],c.answers??{})}}:{sending:!1,refused:null,...c.kind==="dismissed"&&c.reason!==void 0?{dismissed:c.reason}:{},settled:{status:c.kind,at:t(),...y?{revision:y}:{},...c.answers===void 0?{}:{answers:nj(c.questions??[],c.answers)},...c.reason===void 0?{}:{reason:c.reason}}}}}),s.current?.(c)})())},[n,t]);return{lock:n,outcomes:r,answering:a,run:l}},yon=(e,t,n)=>t===null||t===n||e!==null&&t===e,von=e=>e.viewMoved?e.caretUntouched?"composer":"leave":e.capturedUsable?"captured":e.caretUntouched?"trigger":"leave",N9e=()=>{const e=oze();return!e||e.disabled?!1:(Kz(),document.activeElement===e)},Y9e=3e4,Jce=(e,t)=>{const[n,r]=$.useState(()=>t??Date.now());return $.useEffect(()=>{if(t!==void 0||!e)return;r(Date.now());const i=window.setInterval(()=>r(Date.now()),Y9e);return()=>window.clearInterval(i)},[e,t]),t??n},eue="data-text-surface",t5=Object.freeze({[eue]:"true"}),a9=e=>{const t=$.useCallback(r=>{const i=window.matchMedia(e);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[e]),n=$.useCallback(()=>window.matchMedia(e).matches,[e]);return $.useSyncExternalStore(t,n,()=>!1)},tue="ms-5",nue="self-start mt-0.5",GY="flex min-h-6 w-full items-center gap-1.5 py-0.5 text-start",Ti=({summary:e,children:t,defaultOpen:n=!1,animate:r=!1,open:i,chevron:a="leading",className:o,triggerClassName:s,triggerData:l,chevronClassName:c,summaryAlign:u="center",rowClassName:O,disabled:d=!1,triggerLabel:h,triggerTooltip:p,tooltipClassName:g,trailing:y,onOpenChange:v})=>{const[b,x]=$.useState(n),Q=i!==void 0,w=Q?i:b,S=z=>{Q||x(z),v?.(z)},k=$.useId(),P=$.useRef(null),R=E("shrink-0",u==="firstLine"&&nue),T=u==="firstLine"?"items-start":null,q=$.useRef(!1),X=$.useRef(!1),C=$.useRef(null),N=z=>{for(let V=z instanceof Element?z:null;V&&V!==P.current;V=V.parentElement)if(V.hasAttribute(eue))return!0;return!1},A=z=>{if(q.current=N(z.target),X.current=!!window.getSelection()?.toString(),z.detail<=1){C.current=null;return}q.current&&C.current!==null&&(S(C.current),C.current=null)},Y=z=>{const V=z.detail===0,J=X.current||!!window.getSelection()?.toString();!V&&q.current&&(J||z.detail>1)||(C.current=w,S(!w))},W=z=>{if(z.key!=="Escape")return;const V=window.getSelection();!V||V.isCollapsed||P.current?.contains(V.anchorNode)&&V.removeAllRanges()};if(d)return f.jsx("div",{...l,className:o,children:f.jsxs("div",{className:E(GY,T,"text-ink-dim",O),children:[a==="leading"&&f.jsx("span",{className:E("size-3.5",R),"aria-hidden":!0}),f.jsx("span",{className:"min-w-0 flex-1",children:e})]})});const Z=w?f.jsx(ix,{className:"size-3.5","aria-hidden":!0}):f.jsx(Lse,{className:"size-3.5 rtl:-scale-x-100","aria-hidden":!0}),D=f.jsx(vt,{content:p,side:"top",className:g,children:f.jsxs("button",{type:"button",...l,"aria-expanded":w,"aria-controls":w&&t!=null?k:void 0,"aria-label":h,ref:P,onMouseDown:A,onClick:Y,onKeyDown:W,className:E(GY,T,"cursor-pointer select-none","text-ink-dim transition-colors duration-fast ease-out-quart hover:text-ink-muted",O,s),children:[a==="leading"&&f.jsx("span",{className:E("flex text-ink-disabled",R,c),children:Z}),f.jsx("span",{className:"min-w-0 flex-1",children:e}),a==="trailing"&&f.jsx("span",{className:E("flex text-ink-disabled",R,c),children:Z})]})});return f.jsxs("div",{className:o,children:[y?f.jsxs("div",{className:E("group flex items-center"),children:[D,y]}):D,r&&t!=null?f.jsx(G9e,{id:k,open:w,indent:a==="leading",children:t}):w&&t!=null?f.jsx("div",{id:k,className:E("mt-1 flex flex-col gap-2 pb-1",a==="leading"&&tue),children:t}):null]})},G9e=({id:e,open:t,indent:n,children:r})=>{const i=a9("(prefers-reduced-motion: reduce)"),[a,o]=$.useState(t),[s,l]=$.useState(t);return $.useLayoutEffect(()=>{if(!t||i){l(t);return}o(!0);let c=requestAnimationFrame(()=>{c=requestAnimationFrame(()=>l(!0))});return()=>cancelAnimationFrame(c)},[t,i]),$.useEffect(()=>{if(t||!a)return;if(i){o(!1);return}const c=setTimeout(()=>o(!1),240);return()=>clearTimeout(c)},[t,a,i]),f.jsx("div",{id:e,"data-disclosure-body":"animated","aria-hidden":!t,...t?{}:{inert:""},className:E("grid overflow-hidden transition-[grid-template-rows,opacity] duration-base ease-out-quart motion-reduce:transition-none",s?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0"),onTransitionEnd:c=>{!t&&c.target===c.currentTarget&&c.propertyName==="grid-template-rows"&&o(!1)},children:f.jsx("div",{className:E("min-h-0 overflow-hidden"),children:(t||a&&!i)&&f.jsx("div",{className:E("flex flex-col gap-2 pt-1 pb-1",n&&tue),children:r})})})};function Z9e(e,t){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<t?e:null}function I9e({className:e}){return Qe(),f.jsxs("span",{className:E("inline-flex shrink-0 items-baseline gap-0.5 font-medium text-ink-muted text-meta",e),children:[f.jsx("span",{"aria-hidden":"true",children:"▸"}),m("ui.chat.asks.recommended")]})}const ZY="Files and images can't be attached to an answer yet. Type your answer here, or send the file in the chat.",D9e=`Answers stop at ${oj.toLocaleString("en-US")} characters; anything past that is not kept.`,rue=e=>t=>{t.key!=="Enter"||t.shiftKey||t.nativeEvent.isComposing||(t.preventDefault(),!t.repeat&&e())},IY=({value:e,onChange:t,onEnter:n,disabled:r,ariaLabel:i,placeholder:a,questionId:o,fieldRef:s})=>{const[l,c]=$.useState(null);return f.jsxs("div",{className:"flex flex-col gap-1",children:[f.jsx(Nd,{ref:s,"data-ask-other":o,value:e,disabled:r,"aria-label":i,placeholder:a,autoComplete:"off",maxLength:oj,onChange:u=>{c(null),t(u.target.value)},onKeyDown:rue(n),onPaste:u=>{const O=u.clipboardData;if(!O)return;const d=Array.from(O.files??[]);if(!(d.length>0||Array.from(O.items??[]).some(v=>v.kind==="file")))return;const p=O.getData("text/plain"),g=d.map(v=>v.name),y=g.length>0&&p.split(`
|
|
518
518
|
`).every(v=>g.includes(v.trim()));p.trim()!==""&&!y||(u.preventDefault(),c(ZY))},onDragOver:u=>{u.dataTransfer?.types.includes("Files")&&(u.preventDefault(),u.dataTransfer.dropEffect="none")},onDrop:u=>{u.dataTransfer?.files?.length&&(u.preventDefault(),c(ZY))},className:E("field-sizing-content max-h-40 min-h-14 rounded-md px-2 py-1.5 text-sm")}),l===null&&e.length<oj?null:f.jsx("output",{className:"block text-ink-muted text-xs",children:l??D9e})]})},V9e=e=>e==="answered"?"success":e==="late"?"warning":"neutral",M9e=["moot","answered_in_chat"],L9e=e=>e==="moot"?m("ui.chat.asks.dismiss.moot.title"):m("ui.chat.asks.dismiss.answered_in_chat.title"),F9e=e=>e==="moot"?m("ui.chat.asks.dismiss.moot.note"):m("ui.chat.asks.dismiss.answered_in_chat.note"),uj=e=>e==="moot"?m("ui.chat.asks.dismiss.receipt.moot"):m("ui.chat.asks.dismiss.receipt.answered_in_chat"),B9e=e=>{switch(e){case"answered":case"late":return{Icon:ba,className:"text-success"};case"timed_out":return{Icon:IQ,className:"text-ink-muted"};case"declined":case"dismissed":case"expired":case"withdrawn":return{Icon:ni,className:"text-ink-muted"};default:return{Icon:ZQ,className:"text-accent"}}},DY=({chosen:e,multi:t})=>f.jsx("span",{"aria-hidden":"true",className:E("mt-1 h-3 w-3 shrink-0 border",t?"rounded-[2px]":"rounded-full",e?"border-accent bg-accent":"border-control")}),n5="button[data-ask-option]:not([disabled]), input[data-ask-secret]:not([disabled]), textarea[data-ask-other]:not([disabled])",r5="Type your answer",hx=e=>{if(e==null||(e.focus(),e.tagName!=="TEXTAREA"))return;const t=e,n=t.value.length;t.setSelectionRange(n,n)},H9e=({question:e,selected:t,secret:n,secretPlaceholder:r,disabled:i,onCell:a,onSecret:o,onAdvance:s,focusOtherRef:l})=>{const c=e.options??[],u=e.multi===!0,O=Z9e(e.recommended,c.length),d=c.map(b=>b.label),[h,p]=$.useState(()=>Wze(t,d)),g=Nze(t,d,h),y=$.useRef(null);$.useLayoutEffect(()=>{l.current===e.id&&(l.current=null,hx(y.current))},[h.open]);const v=b=>{p(b),a(zY(g,u,b))};return f.jsxs("div",{className:"flex flex-col gap-1.5","data-lo-ask-question":e.id,children:[f.jsx("p",{className:"text-ink text-sm",children:e.question}),e.secret?f.jsx("input",{"data-ask-secret":e.id,type:"password",autoComplete:"off",autoCorrect:"off",spellCheck:!1,disabled:i,value:n,onChange:b=>o(b.target.value),onKeyDown:rue(()=>s(e.id)),placeholder:r,"aria-label":`Your answer to: ${e.question}`,className:"w-full rounded-md border border-control bg-surface px-2 py-1.5 text-ink text-sm placeholder:text-ink-dim disabled:placeholder:text-ink-disabled"}):c.length>0?f.jsxs("div",{className:"flex flex-col",role:u?"group":"radiogroup",children:[c.map((b,x)=>{const Q=g.includes(b.label),w=O===x;return f.jsxs("button",{type:"button","data-ask-option":b.label,disabled:i,"aria-pressed":u?Q:void 0,"aria-checked":u?void 0:Q,role:u?"checkbox":"radio",onClick:()=>{if(!u){h.open&&p({...h,open:!1}),a([b.label]);return}a(zY(Q?g.filter(S=>S!==b.label):[...g,b.label],!0,h))},className:E("flex w-full items-baseline gap-2 rounded-sm px-2 py-1 text-start",Q?"bg-sunken":"hover:bg-sunken",i?"text-ink-dim":"text-ink"),children:[f.jsx(DY,{chosen:Q,multi:u}),f.jsxs("span",{className:"min-w-0 flex-1",children:[f.jsxs("span",{className:"flex items-baseline gap-x-2",children:[f.jsx("span",{className:E("min-w-0",w&&"font-semibold"),children:b.label}),w?f.jsx(I9e,{}):null]}),b.description?f.jsx("span",{className:"block text-ink-muted text-xs",children:b.description}):null]})]},b.label)}),f.jsxs("button",{type:"button","data-ask-option-other":"",disabled:i,"aria-pressed":u?h.open:void 0,"aria-checked":u?void 0:h.open,role:u?"checkbox":"radio",onClick:()=>{if(u&&h.open){v({...h,open:!1});return}l.current=e.id,h.open?hx(y.current):v({...h,open:!0})},className:E("flex w-full items-baseline gap-2 rounded-sm px-2 py-1 text-start",h.open?"bg-sunken":"hover:bg-sunken",i?"text-ink-dim":"text-ink"),children:[f.jsx(DY,{chosen:h.open,multi:u}),f.jsxs("span",{className:"min-w-0 flex-1",children:[f.jsx("span",{children:m("ui.chat.asks.other_label")})," ",h.open?null:f.jsx("span",{className:"ms-1.5 text-ink-muted text-xs",children:r5})]})]}),h.open?f.jsx("div",{className:"pt-1 pe-1 pb-1 ps-7",children:f.jsx(IY,{questionId:e.id,fieldRef:y,value:h.text,disabled:i,ariaLabel:`Your answer to: ${e.question}`,placeholder:r5,onChange:b=>v({open:!0,text:b}),onEnter:()=>s(e.id)})}):null]}):f.jsx(IY,{questionId:e.id,fieldRef:y,value:h.text,disabled:i,ariaLabel:`Your answer to: ${e.question}`,placeholder:r5,onChange:b=>v({open:!0,text:b}),onEnter:()=>s(e.id)})]})},K9e=({presentation:e,nowMs:t,answering:n,outcome:r,draft:i,onDraftChange:a,onAnswer:o,onDecline:s,onRevise:l,onDismiss:c,conversationOf:u})=>{const{ask:O,status:d,waiting:h,canAnswer:p,canDecline:g,delivering:y}=e,v=typeof O.user_messages_since=="number"&&Number.isFinite(O.user_messages_since)&&O.user_messages_since>0?O.user_messages_since:0,b=typeof O.last_user_message_at=="number"&&Number.isFinite(O.last_user_message_at)&&O.last_user_message_at>0?O.last_user_message_at:null,x=Qe(),Q=$.useMemo(()=>b===null?null:new Intl.DateTimeFormat(x,{timeStyle:"short"}).format(new Date(b)),[x,b]),w=u===void 0?null:u(e),S=$.useMemo(()=>ye=>a(O.ask_id,ye(i)),[O.ask_id,i,a]),[k,P]=$.useState({}),R=r?.settled!==void 0||d!=="open"&&d!=="timed_out";$.useEffect(()=>{R&&P(ye=>Object.keys(ye).length===0?ye:{})},[R]);const T=n||!!r?.sending,[q,X]=$.useState(0),C=$.useRef(null),N=r?.retry;N===void 0?C.current=null:C.current?.retry!==N&&(C.current={retry:N,revision:q});const A=N!==void 0&&C.current?.revision===q,Y=$.useRef(null),W=$.useRef(null);r?.refused&&(W.current=r),$.useLayoutEffect(()=>{const ye=W.current;if(!r?.refused||ye!==r||ye===null)return;W.current=null,(Y.current??Me.current?.querySelector(n5))?.focus({preventScroll:!0})},[r]);const Z=T||!p,D=$.useMemo(()=>cb(O,i,k)!==null,[O,i,k]),z=B9e(d),V=z.Icon,J=O.urgent===!0&&h,[G,ne]=$.useState(!1),[L,B]=$.useState(!1),[se,H]=$.useState(null),ee=$.useRef(null),re=$.useRef(null),fe=$.useRef(!1),le=r?.sending===!0;$.useEffect(()=>{L&&re.current?.focus()},[L]);const Pe=()=>{fe.current=!0,H(null),B(!1)};$.useLayoutEffect(()=>{L||!fe.current||(fe.current=!1,ee.current?.focus())},[L]),$.useEffect(()=>{r?.dismissed!==void 0&&(B(!1),H(null))},[r?.dismissed]);const[ce,ve]=$.useState(Ace),xe=r?.refusedByOwner===!0,Te=y&&!xe;$.useEffect(()=>{(r?.changed===!0||R&&r?.refusedByOwner===!0)&&(ne(!1),P(ye=>Object.keys(ye).length===0?ye:{}))},[r?.changed,r?.refusedByOwner,R]);const de=$.useMemo(()=>O.answers??{},[O.answers]),we=$.useMemo(()=>cb(O,ce,k,de)!==null,[O,ce,k,de]),Me=$.useRef(null),rt=$.useRef(!1);$.useLayoutEffect(()=>{if(!rt.current)return;rt.current=!1;const ye=Me.current,it=ye?.querySelector("textarea[data-ask-other]:not([disabled])");hx(it??ye?.querySelector(n5))},[G]);const Ne=G&&Te,pt=Ne?ce:i,ht=Ne?de:void 0,at=Ne?ye=>ve(ye):S,te=Ne?T:Z,pe=()=>{const ye=cb(O,i,k);ye!==null&&o(O,ye)},$e=()=>{if(l===void 0)return;const ye=cb(O,ce,k,de);ye!==null&&l(O,ye)},_e=ye=>{const it=O.questions.findIndex(lt=>lt.id===ye);if(!(it<0||te)&&aj(O.questions[it],pt,k,ht)){if(Ne){we&&l!==void 0?$e():He(it);return}D?pe():He(it)}},He=ye=>{const it=O.questions.length;for(let lt=1;lt<it;lt++){const Tt=O.questions[(ye+lt)%it];if(aj(Tt,pt,k,ht))continue;const Ct=[...Me.current?.querySelectorAll("[data-lo-ask-question]")??[]].find(pn=>pn.dataset.loAskQuestion===Tt.id);hx(Ct?.querySelector(n5));return}},We=$.useRef(null),Ut=d==="dismissed"?Zce(O.dismissed_reason):null,It=r?.refused!==void 0&&L&&se!==null?[m("ui.chat.asks.dismiss.refused"),r.refusedByOwner===!0?r.refused:null].filter(ye=>ye!==null&&ye!=="").join(" "):null;return f.jsxs("div",{ref:Me,"data-lo-ask-row":O.ask_id,"data-lo-ask-status":d,tabIndex:-1,onKeyDown:ye=>{!L||ye.key!=="Escape"||(ye.preventDefault(),ye.stopPropagation(),Pe())},"data-glass-block":"",className:"flex flex-col gap-2 rounded-md border border-hairline bg-surface p-3",children:[w===null?null:f.jsx("span",{"data-lo-ask-conversation":"",className:"truncate text-ink-dim text-meta",children:w}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(V,{"aria-hidden":"true",className:E("shrink-0",J?"text-warning":z.className),size:16}),f.jsxs("span",{className:"min-w-0 flex-1 text-ink text-xs",children:[J?f.jsxs("span",{className:"sr-only",children:[m("ui.chat.asks.urgent")," "]}):null,Ut===null?_ze(O,t):uj(Ut)]}),f.jsx("span",{className:"shrink-0 text-ink text-xs",title:O.ask_id,children:" "})]}),!p&&!Ne&&d!=="dismissed"?f.jsx("div",{className:"flex flex-col gap-1.5",children:Xce(O).map(ye=>{const it=O.questions.find(pn=>pn.id===ye.id),lt=(it?.options??[]).map(pn=>pn.label),Tt=it?.secret!==!0&<.length>0,Ct=ye.id===O.questions[0]?.id&&(d==="withdrawn"||d==="timed_out");return f.jsxs("div",{className:"flex flex-col gap-0.5",children:[Ct?null:f.jsx("span",{className:"text-ink-muted text-xs",children:ye.question}),ye.answers.length>0?ye.answers.map((pn,Ie)=>f.jsxs("span",{className:"whitespace-pre-wrap break-words text-ink text-sm",children:[pn,Tt&&!lt.includes(pn)?f.jsxs("span",{className:"text-ink-muted text-xs",children:[f.jsx("span",{"aria-hidden":"true",children:" · "}),m("ui.chat.asks.other_label")]}):null]},`${Ie}:${pn}`)):f.jsx("span",{className:"text-ink text-sm",children:m("ui.chat.asks.no_answer")})]},ye.id)})}):null,p||Ne?O.questions.map(ye=>f.jsx(H9e,{question:ye,selected:t9(pt,ye.id),secret:k[ye.id]??"",secretPlaceholder:zze(O,ye,ht),disabled:te,onCell:it=>{X(lt=>lt+1),at(lt=>({...lt,[ye.id]:it}))},onSecret:it=>{X(lt=>lt+1),P(lt=>({...lt,[ye.id]:it}))},onAdvance:_e,focusOtherRef:We},ye.id)):null,v>0&&Q!==null&&h?f.jsx("p",{"data-lo-ask-context":"",className:"text-ink-muted text-meta",children:m("ui.chat.asks.context.messages_since",{count:v,time:Q})}):null,r?.sending===!0&&!L?f.jsxs("output",{"data-lo-ask-sending":"",className:"flex items-center gap-1.5 text-ink-muted text-xs",children:[f.jsx(wle,{"aria-hidden":"true",size:14,className:"animate-spin"}),m("ui.agents.config.state.sending")]}):null,r?.refused?f.jsxs("output",{"data-lo-ask-refused":"",className:"flex flex-wrap items-center gap-2 text-body-sm text-danger",children:[f.jsx("span",{className:"min-w-0 break-words",children:It??r.refused}),A?f.jsx("button",{ref:Y,type:"button",disabled:T||!A,onClick:r.retry,className:"min-h-6 rounded-md border border-control px-2 py-1 text-ink text-xs hover:bg-sunken",children:m("ui.common.actions.retry")}):null]}):null,r?.changed===!0?f.jsxs("p",{className:"flex items-start gap-1.5 text-xs",children:[f.jsx(ba,{"aria-hidden":"true",size:14,className:"mt-0.5 shrink-0 text-success"}),f.jsx("span",{className:"text-ink",children:m("ui.chat.asks.changed_handoff")})]}):null,r?.dismissed!==void 0&&r.dismissed!==Ut?f.jsxs("p",{className:"flex items-start gap-1.5 text-xs",children:[f.jsx(ba,{"aria-hidden":"true",size:14,className:"mt-0.5 shrink-0 text-success"}),f.jsx("span",{className:"text-ink",children:uj(r.dismissed)})]}):null,(p||g)&&!L?f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{type:"button",disabled:Z||!D||A,onClick:pe,className:E("rounded-md px-3 py-1.5 text-sm",Z||!D||A?"border border-hairline bg-surface text-ink-dim":"border border-transparent bg-accent text-on-accent hover:bg-accent-hover"),children:m("ui.chat.asks.send_answer")}),g?f.jsx("button",{type:"button",disabled:T,onClick:()=>s(O),className:"rounded-md border border-transparent px-3 py-1.5 text-ink-muted text-sm hover:bg-sunken hover:text-ink",children:m("ui.chat.asks.decline")}):null]}):null,Te&&l!==void 0?f.jsx("div",{className:"flex flex-col gap-1.5",children:Ne?f.jsxs(f.Fragment,{children:[f.jsx("p",{className:"text-ink-dim text-meta",children:xze}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{type:"button",disabled:T||!we,onClick:$e,className:E("rounded-md px-3 py-1.5 text-sm",T||!we?"border border-hairline bg-surface text-ink-dim":"border border-transparent bg-accent text-on-accent hover:bg-accent-hover"),children:m("ui.chat.asks.update_answer")}),f.jsx("button",{type:"button",disabled:T,onClick:()=>ne(!1),className:"rounded-md border border-transparent px-3 py-1.5 text-ink-muted text-sm hover:bg-sunken hover:text-ink",children:m("ui.chat.asks.cancel")})]})]}):f.jsx("button",{type:"button",disabled:T,onClick:()=>{ve(Yze(O)),rt.current=!0,ne(!0)},className:"self-start rounded-md border border-control px-3 py-1.5 text-ink text-sm hover:bg-sunken",children:m("ui.chat.asks.change_answer")})}):null,c!==void 0&&p?f.jsx("div",{className:"flex flex-col gap-2",children:L?f.jsxs(f.Fragment,{children:[f.jsx("p",{className:"text-ink-muted text-meta",children:m("ui.chat.asks.dismiss.heading")}),M9e.map(ye=>f.jsxs("button",{ref:ye==="moot"?re:void 0,type:"button","aria-disabled":T?!0:void 0,onClick:()=>{T||(H(ye),c(O,ye))},"data-lo-ask-dismiss-reason":ye,className:E("flex w-full min-w-0 flex-col gap-0.5 rounded-md border border-control px-3 py-1.5 text-start hover:bg-sunken",T&&"text-ink-dim",se===ye&&"bg-sunken"),children:[f.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-ink text-sm",children:[se===ye?f.jsx(ba,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-ink-muted"}):null,f.jsx("span",{className:"min-w-0 break-words",children:L9e(ye)})]}),f.jsx("span",{className:"truncate text-ink-muted text-meta",children:le&&se===ye?m("ui.chat.asks.dismiss.in_flight"):F9e(ye)})]},ye)),f.jsx("button",{type:"button",onClick:Pe,className:"self-start rounded-md border border-transparent px-3 py-1.5 text-ink-muted text-sm hover:bg-sunken hover:text-ink",children:m("ui.chat.asks.dismiss.cancel")})]}):f.jsx("button",{ref:ee,type:"button",disabled:T,onClick:()=>B(!0),className:"self-start rounded-md border border-transparent px-3 py-1.5 text-ink-muted text-sm hover:bg-sunken hover:text-ink disabled:text-ink-dim",children:m("ui.chat.asks.dismiss.trigger")})}):null]})},VY="rounded-md border border-hairline",J9e=8e3,eAe=({view:e,onAnswer:t,onDecline:n,onRevise:r,onDismiss:i,answering:a=!1,outcomes:o,nowMs:s,drafts:l,onDraftChange:c,conversationOf:u,className:O})=>{if(!e.published)return null;const{pending:d,settled:h}=CY(e.rows),[p,g]=$.useState("all"),y=p!=="settled",v=p!=="outstanding",b=$.useRef(new Map);for(const ce of e.rows)ce.canAnswer&&!b.current.has(ce.ask.ask_id)&&b.current.set(ce.ask.ask_id,b.current.size);const x=new Set(e.rows.filter(ce=>b.current.has(ce.ask.ask_id)&&o?.[ce.ask.ask_id]?.settled?.status==="answered"&&(ce.status==="answered"||ce.status==="late")).map(ce=>ce.ask.ask_id)),Q=$.useRef(new Set),w=$.useRef(new Set);for(const ce of e.rows)ce.canAnswer&&w.current.add(ce.ask.ask_id);const S=$.useRef(new Map),[,k]=$.useState(0),P=()=>{b.current=new Map(e.rows.filter(ce=>ce.canAnswer).map((ce,ve)=>[ce.ask.ask_id,ve])),w.current=new Set(e.rows.filter(ce=>ce.canAnswer).map(ce=>ce.ask.ask_id)),L(ce=>({...ce,text:""})),k(ce=>ce+1)},R=CY(e.rows,w.current),T=p==="all"?[...R.pending,...R.settled.filter(ce=>x.has(ce.ask.ask_id))].sort((ce,ve)=>(b.current.get(ce.ask.ask_id)??Number.MAX_SAFE_INTEGER)-(b.current.get(ve.ask.ask_id)??Number.MAX_SAFE_INTEGER)):R.pending,q=(y?R.settled:h).filter(ce=>p!=="all"||!x.has(ce.ask.ask_id)),X=new Set(R.pending.filter(ce=>ce.lapsed).map(ce=>ce.ask.ask_id)),C=$.useRef(null),N=$.useRef(new Set),A=$.useRef(null),Y=(ce,ve)=>{const xe=e.rows.findIndex(Te=>Te.ask.ask_id===ce.ask_id);xe>=0&&(A.current={id:ce.ask_id,index:xe}),i?.(ce,ve)},W=$.useCallback(ce=>{const ve=C.current;if(ve===null)return;const xe=document.activeElement,Te=xe===null||xe===document.body||!xe.isConnected||ve.contains(xe);if(A.current=null,!Te)return;const de=[...ve.querySelectorAll("[data-lo-ask-row]")].filter(rt=>rt.dataset.loAskRow!==ce.id);(de[Math.min(ce.index,de.length-1)]?.querySelector("button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled])")??document.querySelector(Hz)??ve).focus({preventScroll:!0})},[]);$.useLayoutEffect(()=>{const ce=A.current;if(ce===null)return;const ve=o?.[ce.id];ve?.dismissed===void 0||ve.sending===!0||W(ce)},[o,W]),$.useLayoutEffect(()=>{const ce=A.current,ve=C.current;ce===null||ve===null||[...ve.querySelectorAll("[data-lo-ask-row]")].some(Te=>Te.dataset.loAskRow===ce.id)||W(ce)});const Z=typeof document>"u"?null:document.activeElement,D=Z!==null&&C.current?.contains(Z)?Z.closest("[data-lo-ask-row], [data-lo-ask-held]"):null,z=D?.getAttribute("data-lo-ask-held")??D?.getAttribute("data-lo-ask-row")??null,[V,J]=$.useState({seq:0,text:""}),G=$.useRef(l),[ne,L]=$.useState({seq:0,text:"",from:null}),B=ne.text,se=$.useRef(null),H=$.useRef(0);$.useEffect(()=>{if(V.text==="")return;const ce=setTimeout(()=>J(ve=>({seq:ve.seq,text:""})),J9e);return()=>clearTimeout(ce)},[V]),$.useLayoutEffect(()=>{if(ne.seq!==H.current){H.current=ne.seq;const Ne=document.activeElement;(Ne===null||Ne===document.body||!Ne.isConnected||ne.from!==null&&Ne.closest("[data-lo-ask-row]")?.getAttribute("data-lo-ask-row")===ne.from)&&se.current!==null&&se.current.focus({preventScroll:!0})}const ce=[...X].filter(Ne=>!N.current.has(Ne)),ve=N.current;N.current=X;const xe=new Map([...C.current?.querySelectorAll("[data-lo-ask-row]")??[]].map(Ne=>[Ne.getAttribute("data-lo-ask-row"),Ne])),Te=z!==null&&x.has(z)&&!Q.current.has(z);if(Q.current=x,Te){const Ne=document.activeElement;(!Ne||Ne===document.body||!Ne.isConnected)&&xe.get(z)?.focus({preventScroll:!0})}for(const Ne of e.rows){if(!Ne.canAnswer)continue;const pt=xe.get(Ne.ask.ask_id)?.getBoundingClientRect().height??0;pt>0&&S.current.set(Ne.ask.ask_id,pt)}const de=ce.filter(Ne=>Object.values(G.current[Ne]??l[Ne]??{}).some(pt=>pt.some(ht=>ht.trim()!==""))).length;G.current=l,de>0&&J(Ne=>({seq:Ne.seq+1,text:de===1?"That question timed out; your answer was not sent.":`${de} questions timed out; your answers were not sent.`}));const we=z;if(we===null||!X.has(we)||ve.has(we))return;const Me=document.activeElement;if(Me!==null&&Me!==document.body&&Me.isConnected)return;if(p==="outstanding"){L(Ne=>({seq:Ne.seq+1,text:ce.length===1?"Question timed out":`${ce.length} questions timed out`,from:we}));return}[...C.current?.querySelectorAll("[data-lo-ask-held]")??[]].find(Ne=>Ne.getAttribute("data-lo-ask-held")===we)?.querySelector("button[aria-expanded]")?.focus({preventScroll:!0})});const ee=ce=>f.jsx(K9e,{presentation:ce,nowMs:s,answering:a,outcome:o?.[ce.ask.ask_id],draft:l[ce.ask.ask_id]??Ace,onDraftChange:c,onAnswer:t,onDecline:n,onRevise:r,onDismiss:i===void 0?void 0:Y,conversationOf:u},ce.ask.ask_id),re=ce=>{const ve=Xce(ce.ask).filter(xe=>ce.ask.questions.find(Te=>Te.id===xe.id)?.secret!==!0).flatMap(xe=>xe.answers).filter(xe=>xe.trim()!=="");return ve.length===0?null:f.jsx("span",{"data-lo-ask-settled-answer":"",className:"line-clamp-2 min-w-0 whitespace-normal break-words text-ink-muted text-meta",children:ve.join(", ")})},fe=(ce,{held:ve=!1}={})=>{const xe=e9(ce.status),Te=ce.ask.questions[0]?.question??"No question text",de=o?.[ce.ask.ask_id]?.refused??null,we=o?.[ce.ask.ask_id]?.dismissed;return f.jsx(Ti,{triggerClassName:E("text-ink hover:bg-row-hover hover:text-ink",ve&&"rounded-t-[9px]"),chevronClassName:"text-ink-dim",rowClassName:"min-h-7 py-1",triggerLabel:`${xe} - ${Te}`,summary:f.jsxs("span",{className:"flex min-w-0 flex-col gap-0.5",children:[f.jsxs("span",{className:"flex min-w-0 items-start gap-1.5",children:[f.jsx(js,{variant:V9e(ce.status),shape:"pill",className:"mt-px shrink-0",children:xe}),f.jsxs("span",{className:"flex min-w-0 flex-col gap-0.5",children:[f.jsx("span",{className:"min-w-0 whitespace-normal break-words text-ink text-meta",children:Te}),re(ce)]})]}),de===null?null:f.jsx("span",{className:"min-w-0 text-danger text-meta",children:de}),we===void 0||Zce(ce.ask.dismissed_reason)!==null?null:f.jsx("span",{className:"min-w-0 text-ink-muted text-meta",children:uj(we)})]}),children:f.jsx("div",{className:"pt-1.5",children:ee(ce)})},ce.ask.ask_id)},le=f.jsx("fieldset",{"data-lo-ask-filter":p,"aria-label":m("ui.chat.asks.filter_label"),className:"m-0 flex items-center gap-1 border-0 p-0 px-1",children:[["all","All",e.rows.length],["outstanding","Pending",d.length],["settled","Settled",h.length]].map(([ce,ve,xe])=>f.jsx("button",{type:"button","aria-pressed":p===ce,onClick:()=>{P(),g(ce)},className:E("rounded-md px-2 py-0.5 text-meta transition-colors duration-fast ease-out-quart",p===ce?"bg-sunken text-ink":"text-ink-muted hover:bg-row-hover hover:text-ink"),children:`${ve} · ${xe}`},ce))}),Pe=e.rows.length===0?e.open>0?"The details for these asks could not be loaded.":"No asks outstanding. The agent is not waiting on anything.":p==="outstanding"&&d.length===0?"No asks are pending. They have all settled — see Settled.":p==="settled"&&h.length===0?"No asks have settled yet. They are all still pending.":null;return f.jsxs("div",{ref:C,"data-lo-ask-panel":"open",tabIndex:-1,className:E("flex w-full flex-col gap-2",O),children:[e.rows.length>0?le:null,f.jsx("div",{"data-lo-ask-lapse-note":"","aria-live":"polite",className:"sr-only",children:V.text===""?null:f.jsx("span",{children:V.text},V.seq)}),Pe===null?null:f.jsx("p",{"data-lo-ask-empty":"",className:"px-3 py-2 text-ink-muted text-body",children:Pe}),p==="outstanding"&&B!==""?f.jsx("div",{ref:se,"data-lo-ask-lapse-landing":"",tabIndex:-1,className:"sr-only",onKeyDown:ce=>{ce.target===ce.currentTarget&&ce.key===" "&&ce.preventDefault()},onBlur:()=>L(ce=>({...ce,text:""})),children:B}):null,y?T.map(ce=>{const ve=ce.ask.ask_id;if(!X.has(ve))return ee(ce);const xe=S.current.get(ve),Te=xe===void 0?void 0:{minHeight:`${xe}px`};return p==="outstanding"?f.jsx("div",{"data-lo-ask-spacer":ve,"aria-hidden":"true",className:VY,style:Te},ve):f.jsx("div",{"data-lo-ask-held":ve,className:VY,style:Te,children:fe(ce,{held:!0})},ve)}):null,v&&q.length>0?f.jsxs("div",{"data-lo-ask-settled":"",className:"flex flex-col gap-1 pb-1",children:[y&&R.pending.length>0?f.jsx("p",{className:"px-3 pt-1 text-ink-dim text-meta",children:m("ui.chat.asks.settled_heading")}):null,q.map(ce=>ce.delivering?ee(ce):fe(ce))]}):null]})},MY='a[href]:not([aria-disabled="true"]), button:not([disabled]):not([aria-disabled="true"]), [tabindex]:not([tabindex="-1"]):not([aria-disabled="true"]), input:not([disabled]):not([aria-disabled="true"]), select:not([disabled]):not([aria-disabled="true"]), textarea:not([disabled]):not([aria-disabled="true"])',tAe="[data-lo-ask-panel]",nAe="[data-lo-ask-row], [data-lo-ask-settled]",px="[data-conversation-actions]",LY=e=>e.matches(px)?e:document.querySelector(px),rAe=e=>e===document.body||e.matches(px),iAe=8,aAe=({frontend:e,scope:t,onClose:n,onAnswer:r,onDecline:i,onRevise:a,onDismiss:o,answering:s=!1,outcomes:l,drafts:c,onDraftChange:u,conversationOf:O,nowMs:d,tabs:h})=>{Qe();const p=KQ(e,l),g=Jce(p.open>0,d),y=$.useRef(null),v=p.unread,b=Xn(Y=>Y.askOpenIntent),x=Xn(Y=>Y.clearAskOpenIntent),Q=$.useRef(!1),w=$.useRef(null),S=$.useRef(!1);$.useEffect(()=>{if(h||S.current)return;if(p.rows.length>0||p.open>0){w.current=!0;return}if(v)return;const Y=w.current===!0;if(w.current=!1,Y){S.current=!0,n();return}Q.current||(S.current=!0,n())},[p.rows.length,p.open,v,n,h]);const k=$.useRef(!1),P=$.useRef(!1),R=$.useRef({attempts:0,handler:null,menu:null,menuGone:!1,beat:null,beatMaySettle:!1,observer:null}),T=$.useRef(!1),q=$.useRef(null),X=$.useCallback(()=>{const Y=R.current;Y.handler!==null&&(document.removeEventListener("focusin",Y.handler,!0),Y.handler=null),Y.beat!==null&&(clearTimeout(Y.beat),Y.beat=null),Y.observer?.disconnect(),Y.observer=null},[]),C=$.useCallback(()=>{const Y=R.current;if(Y.handler!==null||T.current)return;Y.attempts=0,Y.menu=document.querySelector('[role="menu"]'),Y.menuGone=Y.menu===null||!Y.menu.isConnected;const W=()=>{T.current=!0,X()},Z=()=>Y.menu===null||!Y.menu.isConnected,D=V=>{Y.beat!==null&&clearTimeout(Y.beat),Y.beatMaySettle=V,Y.beat=setTimeout(()=>{if(Y.beat=null,!T.current&&Z()&&y.current?.contains(document.activeElement)){if(!Y.beatMaySettle){D(!0);return}W()}},0)};if(Y.menu!==null&&!Y.menuGone&&typeof MutationObserver<"u"){const V=new MutationObserver(()=>{T.current||Y.menu!==null&&!Y.menu.isConnected&&(Y.menuGone=!0,V.disconnect(),Y.observer=null,D(!1))});V.observe(document.body,{childList:!0,subtree:!0}),Y.observer=V}const z=V=>{const J=V.target;if(J!==null){if(y.current?.contains(J)){D(!1);return}if(J.matches(px)){if(Y.attempts>=iAe){W();return}Y.attempts+=1;const G=q.current;(G?.isConnected?G:y.current)?.focus();return}J.closest('[role="menu"]')!==null||J.closest("[data-radix-popper-content-wrapper]")!==null||J.closest("[data-radix-focus-guard]")!==null||W()}};Y.handler=z,document.addEventListener("focusin",z,!0)},[X]),N=$.useRef(!1),A=$.useRef(null);return $.useLayoutEffect(()=>{if(k.current&&P.current&&C(),N.current)return;const Y=document.activeElement;if(Y===null||typeof Y.matches!="function")return;const W=Y.matches(Tce)||Y.matches(yze)?Y:null;b?.scope===t&&(x(t),k.current=!0,P.current=b.via==="menu",P.current&&(A.current=LY(Y),C()));const Z=W===null&&k.current;(W!==null||Z)&&(Q.current=!0);const D=y.current;if(D===null||(W!==null||Z)&&v||(N.current=!0,W===null&&!Z)||(W!==null&&(A.current=W),P.current&&(A.current??=LY(Y)),W===null&&!rAe(Y)))return;const z=D.querySelector(tAe),V=z?.querySelector(nAe),J=V?.querySelector(MY)??V??z?.querySelector(MY)??D;q.current=J,J.focus()}),$.useEffect(()=>()=>{X(),x(t),queueMicrotask(()=>{const Y=document.activeElement;if(Y!==null&&Y!==document.body)return;const W=A.current;if(W!==null){W.isConnected&&W.focus();return}N9e()})},[x,X,t]),f.jsxs("section",{ref:y,"aria-label":t==="fleet"?m("ui.chat.asks.all_asks"):m("ui.chat.asks.conversation_asks"),"data-lo-ask-surfaces":"","data-glass-region":"pane","data-ask-drawer":t,tabIndex:-1,className:E("panel-top-pad flex h-full flex-col bg-elevated"),onKeyDown:Y=>{Y.key==="Escape"&&(Y.preventDefault(),n())},children:[f.jsxs("div",{className:E("flex h-10 shrink-0 items-center justify-between gap-2 px-2","[padding-inline-end:max(0.5rem,var(--chrome-inset-end-pane,var(--chrome-inset-end)))]"),children:[f.jsx("span",{className:"truncate text-ink-muted text-xs","data-ask-scope":"",children:dze(t,p)}),h?.action,f.jsx(vt,{content:m("ui.chat.asks.close_asks"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.asks.close_asks"),onClick:()=>n({dismissSlot:!0}),"data-tour-tag":"close-asks-button",children:f.jsx(Bje,{"aria-hidden":"true",className:"rtl:-scale-x-100"})})})]}),h?.strip,h?.body??null,f.jsx("div",{className:E("min-h-0 flex-1 flex-col overflow-y-auto px-3 py-2",h?.body?"hidden":"flex"),children:f.jsx("div",{className:E("w-full max-w-[720px]"),children:p.published?f.jsx(eAe,{view:p,nowMs:g,answering:s,outcomes:l,drafts:c??Xze,onDraftChange:u??Rze,onAnswer:(Y,W)=>r?.(Y.ask_id,W),onDecline:Y=>i?.(Y.ask_id),onRevise:a===void 0?void 0:(Y,W)=>a(Y.ask_id,W),onDismiss:o===void 0?void 0:(Y,W)=>o(Y.ask_id,W),conversationOf:O}):f.jsx("p",{className:"text-ink-muted text-body",children:v?lze:uze})})})]})},FY={answered:{plain:"ui.notices.chat.ask_answered",named:"ui.notices.chat.ask_answered_named"},changed:{plain:"ui.notices.chat.ask_changed",named:"ui.notices.chat.ask_changed_named"},declined:{plain:"ui.notices.chat.ask_declined",named:"ui.notices.chat.ask_declined_named"},dismissed:{plain:"ui.notices.chat.ask_dismissed",named:"ui.notices.chat.ask_dismissed_named"}},oAe={},sAe=({onClose:e})=>{const{rows:t,frontend:n}=U9e(),r=Or(X=>X.activeSessionId)??null,i=Xn(X=>X.setAskDrawerOpen),a=m6e(X=>X.setTab),{client:o}=mi(),s=dr(),l=Nn(s.data,"ask_dismiss"),c=Nn(s.data,"notifications",1),u=Dce(r,c),[O,d]=$.useState(oAe),h=Or(X=>X.sessions),p=$.useMemo(()=>{const X=new Map;for(const C of h){const N=C.title;typeof N=="string"&&N.trim().length>0&&X.set(C.session_id,N)}return X},[h]),g=$.useMemo(()=>z9e(t??[],X=>p.get(X)),[t,p]),y=$.useCallback(X=>g.get(X.ask.ask_id)??null,[g]),v=$.useCallback(()=>{o.invalidateQueries({queryKey:Hce})},[o]);$.useEffect(()=>{const X=C=>{C.key!=="Escape"||C.isComposing===!0||C.defaultPrevented!==!0&&(O$(C.target)||(C.preventDefault(),e()))};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[e]);const b=$.useCallback((X,C)=>{const N=g.get(C);aO(N?m(FY[X].named,{name:N}):m(FY[X].plain))},[g]),{lock:x,outcomes:Q,answering:w,run:S}=W9e({onAccepted:X=>{b(X.kind,X.askId),v()}}),k=$.useCallback((X,C)=>{const N=ub(t??[],X),A=t?.find(Y=>Y.ask_id===X);!N||!A||S({askId:X,kind:"answered",answers:C,decision:rj(A,C,N),questions:A.questions,send:()=>_9e({taskId:X,answers:C,sessionId:N,lock:x},Y=>qe(Y))})},[x,t,S]),P=$.useCallback((X,C)=>{const N=ub(t??[],X),A=t?.find(W=>W.ask_id===X);if(!N||!A)return;const Y=ij(A,Q[X],N);S({askId:X,kind:"changed",answers:C,decision:rj(Y,C,N),questions:Y.questions,send:()=>P9e({taskId:X,answers:C,sessionId:N,lock:x},W=>qe(W))})},[x,t,S,Q]),R=$.useCallback(X=>{const C=ub(t??[],X);C&&S({askId:X,kind:"declined",send:()=>T9e({taskId:X,sessionId:C,lock:x},N=>qe(N))})},[x,t,S]),T=$.useCallback((X,C)=>{d(N=>({...N,[X]:C}))},[]),q=$.useCallback((X,C)=>{const N=ub(t??[],X);N&&S({askId:X,kind:"dismissed",reason:C,send:()=>X9e({taskId:X,reason:C,sessionId:N,lock:x},A=>qe(A))})},[x,t,S]);return f.jsx(aAe,{frontend:n,scope:"fleet",tabs:c?{strip:f.jsx(Lze,{tab:"all",asks:(t??[]).filter(X=>X.session_id===r&&X.status==="open").length,unreadUpdates:u,sessionless:!r,onTab:X=>{X==="all"||!r||(a(X),i(!0,"session"))}}),body:null}:void 0,onClose:X=>{a(null),e(X)},onAnswer:k,onDecline:R,onRevise:P,onDismiss:l?q:void 0,answering:w,outcomes:Q,drafts:O,onDraftChange:T,conversationOf:y})},lAe=48*60*60*1e3;var xc=(e=>(e.UI="ui",e.BACKEND="backend",e))(xc||{});const bon=Xi()(yO((e,t)=>({uiDeferredVersion:null,uiDeferredAt:null,backendDeferredVersion:null,backendDeferredAt:null,hydrated:!1,deferUpdate:(n,r)=>{e(n==="ui"?{uiDeferredVersion:r,uiDeferredAt:Date.now()}:{backendDeferredVersion:r,backendDeferredAt:Date.now()})},shouldShowUpdate:(n,r)=>{const{uiDeferredVersion:i,uiDeferredAt:a,backendDeferredVersion:o,backendDeferredAt:s}=t();let l,c;return n==="ui"?(l=i,c=a):(l=o,c=s),!l||!c||l!==r?!0:Date.now()-c>lAe},clearDeferredUpdate:n=>{if(n==="ui")e({uiDeferredVersion:null,uiDeferredAt:null});else if(n==="backend")e({backendDeferredVersion:null,backendDeferredAt:null});else throw new Error(`Invalid update type: ${n}`)}}),{name:"deferred-updates-storage",onRehydrateStorage:()=>e=>{e&&typeof e=="object"&&"setState"in e&&typeof e.setState=="function"&&e.setState({hydrated:!0})}})),cAe=["patch","minor","major"],BY="patch",uAe=/^v?(\d+)\.(\d+)\.(\d+)/,HY=e=>{if(typeof e!="string")return null;const t=uAe.exec(e.trim());return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null},OAe=(e,t)=>e[0]!==t[0]?e[0]>t[0]:e[1]!==t[1]?e[1]>t[1]:e[2]>t[2],dAe=(e,t)=>e[0]===0&&t[0]===0?e[1]!==t[1]:e[0]!==t[0],fAe=(e,t)=>e[0]!==t[0]||e[1]!==t[1],hAe=(e,t,n)=>{const r=HY(t),i=HY(n);return!r||!i||!OAe(i,r)?!1:e==="major"?dAe(r,i):e==="minor"?fAe(r,i):!0},pAe=e=>typeof e=="string"&&cAe.includes(e),mAe=[xc.UI,xc.BACKEND],To=e=>({[xc.UI]:e(xc.UI),[xc.BACKEND]:e(xc.BACKEND)}),gAe=(e,t)=>{const n=e.offers[t];return!n||e.detailOpen[t]?!1:hAe(e.followed[t],e.running[t],n.version)},ZO=Xi()(yO((e,t)=>({followed:To(()=>BY),running:To(()=>null),offers:To(()=>null),detailOpen:To(()=>!1),noticeOpen:!1,inflight:To(()=>!1),downloadPercent:To(()=>null),setFollowedSegment:(n,r)=>e(i=>({followed:{...i.followed,[n]:r}})),followedSegment:n=>t().followed[n],noteRunningVersion:(n,r)=>e(i=>({running:{...i.running,[n]:r}})),noteQuietOffer:(n,r)=>e(i=>({offers:{...i.offers,[n]:r}})),clearQuietOffer:n=>e(r=>{const i={...r.offers,[n]:null};return{offers:i,noticeOpen:Object.values(i).some(a=>a!==null)&&r.noticeOpen}}),openNotice:()=>e({noticeOpen:!0}),dismissNotice:()=>e({noticeOpen:!1}),noteInFlight:(n,r)=>e(i=>({inflight:{...i.inflight,[n]:r}})),noteDownloadPercent:(n,r)=>e(i=>({downloadPercent:{...i.downloadPercent,[n]:r}})),clearSurface:n=>e(r=>{const i={...r.offers,[n]:null};return{offers:i,detailOpen:{...r.detailOpen,[n]:!1},noticeOpen:Object.values(i).some(a=>a!==null)&&r.noticeOpen}}),openDetail:n=>e(()=>({detailOpen:To(r=>r===n)})),closeDetail:n=>e(r=>({detailOpen:{...r.detailOpen,[n]:!1}})),resetNotices:()=>e({offers:To(()=>null),detailOpen:To(()=>!1),noticeOpen:!1,inflight:To(()=>!1),downloadPercent:To(()=>null)})}),{name:"update-notice-storage",storage:s2e(()=>{if(typeof localStorage>"u"||localStorage===null)throw new Error("no localStorage in this environment");return localStorage}),partialize:e=>({followed:e.followed}),merge:(e,t)=>{const n=e??{},r=To(i=>{const a=n.followed?.[i];return pAe(a)?a:BY});return{...t,followed:r}}})),iue={get[xc.UI](){return m("ui.common.updates.update_quiet_indicator.application_update")},get[xc.BACKEND](){return m("ui.common.updates.update_quiet_indicator.server_update")}},$Ae=e=>`${iue[e.type]} ${e.version}`,won=e=>iue[e],KY=e=>m("ui.common.updates.update_quiet_indicator.available",{quietoffersubject:$Ae(e)}),yAe=({offers:e,onOpen:t,onDismiss:n,className:r})=>{Qe();const i=e.length===0;return f.jsxs("output",{"data-update-indicator":"","data-glass-region":"sidebar","data-update-indicator-count":e.length,onKeyDown:a=>{a.key==="Escape"&&(a.stopPropagation(),n())},className:i?void 0:E("flex h-7 shrink-0 items-center gap-1 border-t border-hairline bg-surface px-2",r),children:[e.map((a,o)=>f.jsxs($.Fragment,{children:[o>0&&f.jsx("span",{className:"sr-only",children:", "}),f.jsxs("button",{type:"button","data-update-indicator-open":a.type,"aria-label":m("ui.common.updates.update_quiet_indicator.open_release_details",{quietoffertext:KY(a)}),className:E("flex h-6 items-center gap-1.5 rounded-md px-1.5 text-meta text-accent","hover:bg-row-hover","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-0!"),onClick:()=>t(a.type),children:[f.jsx(cqe,{className:"size-3.5 shrink-0","aria-hidden":"true"}),f.jsx("span",{className:"whitespace-nowrap",children:KY(a)})]},a.type)]},a.type)),!i&&f.jsx("button",{type:"button","data-update-indicator-dismiss":"","aria-label":m("ui.common.updates.update_quiet_indicator.dismiss_update_notice"),onClick:n,className:E("flex h-6 items-center rounded-md px-1.5 text-ink-muted","hover:bg-row-hover hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-0!"),children:f.jsx(ni,{className:"size-3.5 shrink-0","aria-hidden":"true"})})]})},vAe=()=>{document.querySelector("[data-update-foot-icon]")?.focus()},bAe=()=>{const e=ZO(u=>u.followed),t=ZO(u=>u.running),n=ZO(u=>u.offers),r=ZO(u=>u.detailOpen),i=ZO(u=>u.openDetail),a=ZO(u=>u.noticeOpen),o=ZO(u=>u.dismissNotice),s=$.useCallback(()=>{o(),vAe()},[o]);$.useLayoutEffect(()=>{a&&document.querySelector("[data-update-indicator] button")?.focus()},[a]);const l=$.useMemo(()=>{const u={followed:e,running:t,offers:n,detailOpen:r};return mAe.filter(O=>gAe(u,O)).map(O=>({type:O,version:n[O]?.version??""}))},[e,t,n,r]),c=$.useCallback(u=>i(u),[i]);return f.jsx(yAe,{offers:a?l:[],onOpen:c,onDismiss:s})};function wAe(e,t){const{lang:n,dir:r}=nle(t);e.setAttribute("dir",r),e.setAttribute("lang",n)}function o9(){return s4e(Qe())}function xon(){const e=Qe();$.useLayoutEffect(()=>{wAe(document.documentElement,e)},[e])}const aue=$.createContext(null),Son=({children:e})=>{const t=$.useContext(aue);return t?zq.createPortal(e,t):null},mx=({side:e})=>f.jsx("div",{"aria-hidden":"true","data-panel-edge":e,className:E("pointer-events-none absolute inset-y-0 z-20 w-px bg-hairline/75",e==="start"?"start-0":"end-0")});mx.displayName="PanelEdge";const oue=$.forwardRef(({width:e,minWidth:t=0,tourTag:n,className:r,children:i,...a},o)=>f.jsxs("div",{ref:o,style:{minWidth:t,width:e},"data-tour-tag":n,className:E("relative h-full overflow-hidden transition-[width] duration-base ease-out-quart",r),...a,children:[i,f.jsx(mx,{side:"start"})]}));oue.displayName="PaneSlot";const xAe=200;let Au=null;const SAe=e=>{Au||(Au=document.createElement("div"),Object.assign(Au.style,{position:"fixed",top:"0",left:"0",width:"100vw",height:"100vh",zIndex:"9999"}),document.body.appendChild(Au)),Au.style.cursor=e},QAe=()=>{Au&&(document.body.removeChild(Au),Au=null)},JY=({sidebarWidth:e,onSidebarWidthChange:t,minWidth:n=180,maxWidth:r=600,orientation:i="vertical",side:a="right",onDoubleClick:o,label:s,homeEnd:l="axis"})=>{const c=i==="horizontal",[u,O]=$.useState(!1),[d,h]=$.useState(!1),p=$.useRef(!1),g=$.useRef(null),y=$.useRef(null);$.useEffect(()=>()=>{y.current&&clearTimeout(y.current),g.current?.()},[]);const v=Q=>{const S=!c&&getComputedStyle(Q.currentTarget).direction==="rtl"?e9e(Q.key):Q.key,k=r9e(S,{shiftKey:Q.shiftKey,value:e,min:n,max:r,side:a,homeEnd:l});if(k!==void 0&&!(k===null&&!o)){if(Q.preventDefault(),Q.stopPropagation(),k===null){o?.();return}t(k)}},b=Q=>{Q.preventDefault(),p.current=!0,h(!0);const w=Q.clientX,S=Q.clientY,k=e,P=!c&&getComputedStyle(Q.currentTarget).direction==="rtl";document.body.style.userSelect="none",SAe(c?"row-resize":"col-resize");const R=X=>{if(!p.current)return;const C=c?X.clientY-S:Jze(X.clientX-w,P?"rtl":"ltr");t(i0(k,C,a,n,r))},T=X=>{p.current&&(p.current=!1,X&&(h(!1),O(!1)),document.body.style.userSelect="",QAe(),window.removeEventListener("mousemove",R),window.removeEventListener("mouseup",q),window.removeEventListener("blur",q),document.documentElement.removeEventListener("mouseleave",q),g.current=null)},q=()=>T(!0);window.addEventListener("mousemove",R),window.addEventListener("mouseup",q),window.addEventListener("blur",q),document.documentElement.addEventListener("mouseleave",q),g.current=()=>T(!1)},x=u||d;return f.jsxs("div",{className:E("relative z-25 shrink-0",c?"h-0 w-full":"h-full w-0"),children:[f.jsx("div",{"aria-hidden":"true",className:E("pointer-events-none absolute z-12",c?"left-0 h-0.5 w-full":"top-0 h-full w-0.5","transition-[opacity,background-color] duration-fast ease-out-quart",c?a==="top"?"top-0":"bottom-0":a==="left"?"left-0":"right-0",d?"bg-accent":"bg-control",x?"opacity-100":"opacity-0")}),f.jsx("div",{role:"separator","aria-label":s,"aria-orientation":c?"horizontal":"vertical","aria-valuenow":Math.round(e),"aria-valuemin":n,"aria-valuemax":r,tabIndex:0,className:E("absolute z-11 touch-none",c?"left-0 h-2.5 w-full cursor-row-resize":"top-0 h-full w-3 cursor-col-resize",c?a==="top"?"-top-[5px]":"-bottom-[5px]":a==="left"?"-left-1.5":"-right-1.5"),onMouseEnter:()=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>O(!0),xAe)},onMouseLeave:()=>{y.current&&clearTimeout(y.current),p.current||O(!1)},onFocus:()=>O(!0),onBlur:()=>{p.current||O(!1)},onKeyDown:v,onMouseDown:b,onDoubleClick:o})]})};function kAe(e,t){const[n,r]=$.useState({width:0,left:0});return $.useLayoutEffect(()=>{const i=e.current;if(!i)return;const a=()=>{const s=i.getBoundingClientRect();r({width:s.width,left:s.left})};a();const o=new ResizeObserver(a);return o.observe(i),()=>o.disconnect()},[t,e]),n}const sue=$.createContext(null),Qon=()=>{const e=$.useContext(sue);if(!e)throw new Error("useSidebarFrame: the sidebar must be rendered inside ChatLayout (app.tsx)");return e},kon=({sidebar:e,content:t})=>{Qe();const n=o9(),r=Xn(A=>A.chatSidebarWidth),i=Xn(A=>A.setChatSidebarWidth),a=Xn(A=>A.restoreDefaultChatSidebarWidth),o=Xn(A=>A.isSidebarCollapsed),s=Xn(A=>A.toggleSidebar),[l,c]=$.useState(()=>typeof window>"u"?1380:window.innerWidth),u=$.useRef(null);$.useEffect(()=>{const A=()=>c(window.innerWidth);return window.addEventListener("resize",A),()=>window.removeEventListener("resize",A)},[]);const O=Xn(A=>A.isAskDrawerOpen),d=Xn(A=>A.askDrawerScope),h=Xn(A=>A.setAskDrawerOpen),p=Xn(A=>A.setRightSlotWidth),g=Xn(A=>A.restoreDefaultRightSlotWidth),y=O&&d==="fleet",v=Xn(l2e),x=Xn(A=>A.rightSlotRoute.mounted)?d2e:0,[Q,w]=$.useState(null),S=f2e(l,o,r,v,x),k=$.useCallback(A=>{c2e(A)&&(O$(A.target)||(A.preventDefault(),s()))},[s]);$.useEffect(()=>(document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)),[k]);const P=$.useCallback(A=>{const Y=u6e(A);if(Y===null||O$(A.target))return;const W=d6e(document,Zle(document.activeElement),Y);W!==null&&(A.preventDefault(),f6e(document,W))},[]);$.useEffect(()=>(document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)),[P]);const R=S.mode==="docked"?S.width:h2e,T=$.useRef(null),q=kAe(T,n),X=Xn(A=>u2e(q.width,A)),C=O2e(q.width||Number.MAX_SAFE_INTEGER)==="docked",N=q.width>0?(n==="rtl"?l-q.left:q.left+q.width)-X:0;return f.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col overflow-hidden",style:{"--panel-rail-w":`${x}px`,"--chrome-inset-end-pane":`max(0px, calc(var(--chrome-inset-end) - ${x}px))`},children:[f.jsx("div",{ref:u,"data-titlebar-lane":"","data-titlebar-drag":"","data-slot-edge":N,className:"absolute inset-x-0 top-0 z-30 h-[var(--chrome-strip-h)]"}),f.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[f.jsxs("div",{className:E("relative h-full shrink-0"),style:{width:R},children:[f.jsx(sue.Provider,{value:{expanded:S.mode==="docked",onCollapse:s},children:e}),f.jsx(mx,{side:"end"})]}),S.resizable&&f.jsx(JY,{sidebarWidth:S.width,onSidebarWidthChange:i,minWidth:m2e,maxWidth:p2e(l,x),onDoubleClick:a,label:m("ui.common.layout.chat_layout.resize_the_sidebar",{sidebartogglecap:g2e(PAe())})}),f.jsx("div",{ref:T,className:"flex h-full min-w-0 grow flex-col overflow-hidden",style:{"--panel-top-pad":"var(--chrome-strip-h)"},children:f.jsx(aue.Provider,{value:Q,children:f.jsxs("div",{className:"relative flex h-full min-h-0 w-full overflow-hidden",children:[t,y&&f.jsxs(f.Fragment,{children:[C&&f.jsx(JY,{sidebarWidth:X,onSidebarWidthChange:p,minWidth:_N,maxWidth:Math.max(_N,$2e(q.width)),side:"left",onDoubleClick:g,label:m("ui.common.layout.chat_layout.resize_asks_double_click_resets_the_shared_pane_width")}),f.jsx(oue,{width:C?X:void 0,className:C?void 0:"absolute inset-0",tourTag:"ask-fleet-slot","data-ask-mode":C?"docked":"overlay",children:f.jsx(sAe,{onClose:A=>h(!1,"fleet",A)})})]})]})})}),f.jsx("div",{ref:w,"data-panel-rail-host":"","data-glass-region":"sidebar",className:"panel-top-pad relative h-full shrink-0 bg-surface",style:{width:x},children:f.jsx(mx,{side:"start"})})]}),f.jsx(bAe,{})]})},_Ae="MAC",PAe=()=>typeof navigator<"u"&&navigator.platform.toUpperCase().indexOf(_Ae)>=0,TAe=({open:e,onClose:t,autoHideDuration:n,variant:r="info",role:i,action:a,children:o})=>{if(Qe(),$.useEffect(()=>{if(!e||n===void 0)return;const l=window.setTimeout(t,n);return()=>window.clearTimeout(l)},[e,n,t]),!e)return null;const s=i??(r==="danger"||r==="warning"?"alert":"status");return f.jsxs("div",{className:"fixed end-4 bottom-4 z-50 w-100 max-w-[calc(100vw-2rem)]",children:[f.jsxs(Tl,{variant:r,role:s,className:"relative pe-10 shadow-overlay",children:[o,a?f.jsx("div",{className:"flex justify-end gap-2 pt-1",children:a}):null]}),f.jsx(ke,{variant:"ghost",size:"icon-sm",onClick:t,"aria-label":m("ui.common.connection.floating_alert.dismiss"),className:"absolute top-1.5 end-1.5",children:f.jsx(ni,{})})]})};TAe.displayName="FloatingAlert";function l1(e){return e>=9995e5?`${(e/1e9).toFixed(1)} GB`:e>=999500?`${(e/1e6).toFixed(1)} MB`:`${Math.round(e/1e3)} KB`}const s9="000000000000",l9="00000000-0000-0000-0000-000000000000";function Oj(e,t){const n=lz({op:"sessions.message",sessionId:s9,requestId:l9,text:e,images:t,mode:"prompt"});return new TextEncoder().encode(JSON.stringify(n.body)).length}function y$(e,t){const n=l1(e);if(n!==l1(t))return[n,l1(t)];const r=n.endsWith("MB"),i=r?1e6:1e3,a=r?"MB":"KB";for(const o of[2,3]){const s=(e/i).toFixed(o),l=(t/i).toFixed(o);if(s!==l)return[`${s} ${a}`,`${l} ${a}`]}return[`${e.toLocaleString()} bytes`,`${t.toLocaleString()} bytes`]}function _on(e,t,n=AQ){if(t.length>up)return`This command is ${t.length.toLocaleString()} characters, more than the ${up.toLocaleString()} one command can carry. Shorten it, or put the text in a message instead.`;const r=lz({op:"sessions.command",sessionId:s9,requestId:l9,command:e,args:t}),i=new TextEncoder().encode(JSON.stringify(r.body)).length;if(i<=n)return null;const[a,o]=y$(i,n);return`This command is ${a}, more than the ${o} one command can carry. Shorten it, or put the text in a message instead.`}function Pon(e,t=y2e){if(e.length>PN)return`This system prompt is ${e.length.toLocaleString()} characters, more than the ${PN.toLocaleString()} one agent can carry. Shorten it.`;const n=new TextEncoder().encode(JSON.stringify({system_prompt:e})).length;if(n<=t)return null;const[r,i]=y$(n,t);return`This system prompt is ${r}, more than the ${i} one agent can carry. Shorten it.`}function XAe(e,t=AQ){if(e.length>up)return`This first message is ${e.length.toLocaleString()} characters, more than the ${up.toLocaleString()} one message can carry. Shorten it, or send it in the new conversation instead.`;const n=lz({op:"sessions.fork",sessionId:s9,requestId:l9,message:e,boundary:"next_safe"}),r=new TextEncoder().encode(JSON.stringify(n.body)).length;if(r<=t)return null;const[i,a]=y$(r,t);return`This first message is ${i}, more than the ${a} one message can carry. Shorten it, or send it in the new conversation instead.`}function Ton(e,t,n=AQ){if(e.length>up)return`This message is ${e.length.toLocaleString()} characters, more than the ${up.toLocaleString()} one message can carry. Split it across two messages.`;const r=Oj(e,t);if(r<=n)return null;const i=Oj(e,[]),a=r-i;if(t.length&&a>=i){const[l,c]=y$(a,n);return`These images total ${l}, more than the ${c} one message can carry. Remove an image, or send them in a second message.`}const[o,s]=y$(i,n);return`This message is ${o} of text, more than the ${s} one message can carry. Split it across two messages.`}var RAe=(e=>(e.CONNECT_PROVIDER="connect_provider",e.DEFAULT_MODEL="default_model",e.EXTRAS="extras",e))(RAe||{});const Xon=Xi()(yO((e,t)=>({isModalComplete:!1,isTourComplete:!1,currentStep:"connect_provider",isModalActive:!1,completeModalOnboarding:()=>{e({isModalComplete:!0,isModalActive:!1,isTourComplete:!0})},completeTourOnboarding:()=>{e({isTourComplete:!0})},setCurrentStep:n=>{e({currentStep:n})},activateModalOnboarding:()=>{e({isModalActive:!0})},deactivateModalOnboarding:()=>{e({isModalActive:!1})},resetOnboarding:()=>{e({isModalComplete:!1,isTourComplete:!1,currentStep:"connect_provider",isModalActive:!1})}}),{name:"onboarding-storage",partialize:e=>({isModalComplete:e.isModalComplete,isTourComplete:e.isTourComplete,currentStep:e.currentStep}),merge:(e,t)=>{const{isModalActive:n,...r}=e??{};return{...t,...r}},onRehydrateStorage:()=>(e,t)=>{t?console.error("Failed to rehydrate onboarding store:",t):e&&JSON.parse(localStorage.getItem("onboarding-storage")||"{}")?.state?.isComplete===!0&&!e.isModalComplete&&(console.log("Migrating old 'isComplete:true' state to 'isModalComplete:true'"),e.isModalComplete=!0)}}));function dj(e){return e.some(t=>!t.local&&!t.credential_optional&&(t.configured||t.has_credential))}function Ron(e){return e.onboardingComplete?"returning":e.census.status==="loading"||e.census.status==="failed"?"pending":e.census.status==="ready"?dj(e.census.providers)?"returning":"first_time":e.legacy.status!=="ready"?"pending":e.legacy.keys.length===0?"first_time":"returning"}const EAe=(e,t)=>e===t?!0:!e||!t?!e&&!t:e.length!==t.length?!1:e.every((n,r)=>n===t[r]),eG=(e,t)=>{const n=e.timestamp instanceof Date?e.timestamp.getTime():new Date(e.timestamp).getTime(),r=t.timestamp instanceof Date?t.timestamp.getTime():new Date(t.timestamp).getTime();return e.id===t.id&&e.role===t.role&&n===r&&e.message===t.message&&e.code===t.code&&e.stdout===t.stdout&&e.stderr===t.stderr&&e.logging===t.logging&&e.formatted_print===t.formatted_print&&e.status===t.status&&e.task_classification===t.task_classification&&e.action===t.action&&e.execution_type===t.execution_type&&e.is_streamable===t.is_streamable&&e.is_complete===t.is_complete&&e.conversation_id===t.conversation_id&&e.content===t.content&&e.file_path===t.file_path&&e.replacements===t.replacements&&e.agent===t.agent&&e.learnings===t.learnings&&e.thinking===t.thinking&&EAe(e.files,t.files)},Co=e=>e.timestamp instanceof Date?e.timestamp.getTime():new Date(e.timestamp).getTime(),tG=e=>{for(let t=1;t<e.length;t+=1)if(Co(e[t-1])>Co(e[t]))return!1;return!0},Eon=Xi((e,t)=>({messagesByConversation:{},paginationByConversation:{},lastUpdated:Date.now(),addMessages:(n,r,i=!1)=>{e(a=>{const o=a.messagesByConversation[n]||[],s=new Set(o.map(d=>d.id)),l=r.filter(d=>!s.has(d.id));if(l.length===0)return a;const c=tG(l)?l:[...l].sort((d,h)=>Co(d)-Co(h));let u=i?[...c,...o]:[...o,...c];return o.length===0||(i?Co(c[c.length-1])<=Co(o[0]):Co(c[0])>=Co(o[o.length-1]))||(u=[...u].sort((d,h)=>Co(d)-Co(h))),{messagesByConversation:{...a.messagesByConversation,[n]:u},lastUpdated:Date.now()}})},setMessages:(n,r)=>{e(i=>{const a=tG(r)?r:[...r].sort((s,l)=>Co(s)-Co(l)),o=i.messagesByConversation[n]||[];if(o.length===a.length){let s=!1;for(let l=0;l<o.length;l+=1)if(!eG(o[l],a[l])){s=!0;break}if(!s)return i}return{messagesByConversation:{...i.messagesByConversation,[n]:a},lastUpdated:Date.now()}})},addMessage:(n,r)=>{e(i=>{const a=i.messagesByConversation[n]||[];return a.some(o=>o.id===r.id)?i:{messagesByConversation:{...i.messagesByConversation,[n]:[...a,r]},lastUpdated:Date.now()}})},updateMessage:(n,r)=>{let i=!1;return e(a=>{const s=(a.messagesByConversation[n]||[]).map(l=>l.id===r.id?eG(l,r)?l:(i=!0,r):l);return i?{messagesByConversation:{...a.messagesByConversation,[n]:s},lastUpdated:Date.now()}:a}),i},clearConversation:n=>{e(r=>{const{[n]:i,...a}=r.messagesByConversation,{[n]:o,...s}=r.paginationByConversation;return{messagesByConversation:a,paginationByConversation:s,lastUpdated:Date.now()}})},getMessages:n=>t().messagesByConversation[n]||[],updatePagination:(n,r,i,a)=>{e(o=>{const s=o.paginationByConversation[n]||{currentPage:1,totalPages:1,hasMore:!1};return s.currentPage===r&&s.totalPages===i&&s.hasMore===a?o:{paginationByConversation:{...o.paginationByConversation,[n]:{...s,currentPage:r,totalPages:i,hasMore:a}},lastUpdated:Date.now()}})},getPagination:n=>t().paginationByConversation[n]||{currentPage:1,totalPages:1,hasMore:!1},updateScrollPosition:(n,r)=>{e(i=>{const a=i.paginationByConversation[n]||{currentPage:1,totalPages:1,hasMore:!1};return a.scrollPosition===r?i:{paginationByConversation:{...i.paginationByConversation,[n]:{...a,scrollPosition:r}}}})},getScrollPosition:n=>t().paginationByConversation[n]?.scrollPosition})),qon=Xi((e,t)=>({historyByConversation:{},setCurrentMessage:(n,r)=>{e(i=>{const a=i.historyByConversation[n]||{currentMessage:"",currentSequenceId:null};return{historyByConversation:{...i.historyByConversation,[n]:{...a,currentMessage:r}}}})},getCurrentMessage:n=>t().historyByConversation[n]?.currentMessage||"",setCurrentSequenceId:(n,r)=>{e(i=>{const a=i.historyByConversation[n]||{currentMessage:"",currentSequenceId:null};return{historyByConversation:{...i.historyByConversation,[n]:{...a,currentSequenceId:r}}}})},getCurrentSequenceId:n=>t().historyByConversation[n]?.currentSequenceId||null,resetHistory:n=>{e(r=>{const i=r.historyByConversation[n];return i?{historyByConversation:{...r.historyByConversation,[n]:{...i,currentSequenceId:null}}}:r})},clearConversationHistory:n=>{e(r=>{const{[n]:i,...a}=r.historyByConversation;return{historyByConversation:a}})}}));function qAe(e){return e.serverOnline?e.capabilitiesState==="pending"?"checking":e.capabilitiesState==="error"||e.accountUnavailable?"could-not-check":e.accountRead==="checking"?"checking":e.accountRead==="signed-out"||e.accountRead==="refused"?"sign-in":"could-not-check":"offline"}const jAe={recording:{checking:()=>m("ui.common.speech.control.checking"),"sign-in":()=>m("ui.common.speech.control.recording_sign_in"),"could-not-check":()=>m("ui.common.speech.control.recording_unknown"),offline:()=>m("ui.common.speech.control.recording_offline")},"speaking-aloud":{checking:()=>m("ui.common.speech.control.checking"),"sign-in":()=>m("ui.common.speech.control.speaking_sign_in"),"could-not-check":()=>m("ui.common.speech.control.speaking_unknown"),offline:()=>m("ui.common.speech.control.speaking_offline")}};function lue(e,t){return jAe[e][t]()}const CAe={checking:()=>m("ui.common.speech.settings.checking"),"sign-in":()=>m("ui.common.speech.settings.sign_in"),"could-not-check":()=>m("ui.common.speech.settings.unknown"),offline:()=>m("ui.common.speech.settings.offline")};function jon(e){return CAe[e]()}const zAe={name:"User",email:"user@example.com"},cue=Xi()(yO(e=>({profile:zAe,isSigningOut:!1,updateName:t=>{e(n=>({profile:{...n.profile,name:t}}))},updateEmail:t=>{e(n=>({profile:{...n.profile,email:t}}))},updateProfile:t=>{e(n=>({profile:{...n.profile,...t}}))},setIsSigningOut:t=>{e({isSigningOut:t})},clearProfile:()=>{e({profile:{name:"",email:""}})}}),{name:"user-profile-storage"}));function AAe(e){return{operation:e.operation,...e.tenantId?{tenant_id:e.tenantId}:{},...e.accountId?{account_id:e.accountId}:{},...e.agentId?{agent_id:e.agentId}:{},...e.commentId?{comment_id:e.commentId}:{},...e.teamId?{team_id:e.teamId}:{},...e.skillId?{skill_id:e.skillId}:{},...e.query?{query:e.query}:{},...e.payload?{payload:e.payload}:{},...e.requestId?{request_id:e.requestId}:{},...e.confirmed?{confirmed:!0}:{}}}async function UAe(e){return(await qe({op:"radient.request",control:AAe(e)})).data}async function c9(e){const t=await UAe(e);return t&&typeof t=="object"&&"result"in t?t.result:t}const Xc={all:["radient-user"],user:()=>["radient-user","user"]},Id=new WeakMap,fj=new WeakMap;function Con(e){const t=Id.get(e);if(!t)return e.getQueryState(Xc.user())?.status!=="success";if(t.signedOut)return!1;const n=e.getQueryData(Xc.user())?.account?.id;return t.pending||t.accountId!==n}function JQ(e){return Id.get(e)?.epoch??0}function u9(e){for(const t of fj.get(e)??[])t()}function WAe(e){Id.set(e,{epoch:JQ(e)+1,pending:!0}),u9(e)}function NAe(e){Id.set(e,{epoch:JQ(e)+1,pending:!1,signedOut:!0}),u9(e)}function nG(e,t,n){t===JQ(e)&&(Id.set(e,{epoch:t,pending:!1,accountId:n,signedOut:n===void 0?Id.get(e)?.signedOut:!1}),u9(e))}function v$(e){const t=Id.get(e),n=e.getQueryData(Xc.user())?.account?.id;return{epoch:t?.epoch??0,accountId:t?.signedOut||t?.pending||t&&t.accountId!==n?void 0:n}}function hj(e){const{epoch:t,accountId:n}=v$(e);return JSON.stringify([t,n??null])}function YAe(e,t){let n=fj.get(e);n||(n=new Set,fj.set(e,n)),n.add(t);const r=e.getQueryCache().subscribe(a=>{(a.type==="updated"||a.type==="removed")&&a.query.queryKey.length===2&&a.query.queryKey[0]==="radient-user"&&a.query.queryKey[1]==="user"&&t()}),i=n;return()=>{i.delete(t),r()}}function zon(){const e=Zs(),t=$.useCallback(i=>YAe(e,i),[e]),n=$.useCallback(()=>hj(e),[e]),r=$.useSyncExternalStore(t,n,n);return{...v$(e),token:r}}async function Aon(e,t,n){if(!t||v$(e).accountId!==t)throw new Error("Account authority unresolved");const r=hj(e),i=await n();if(hj(e)!==r||v$(e).accountId!==t)throw new Error("Account authority changed");return i}function Uon(e){return e==="refused"||e==="unavailable"||e==="unknown"}const GAe="radient_no_credential",ZAe="radient_credential_refused",IAe="radient_upstream_failed";function pj(e){if(e instanceof Ln){if(e.code===GAe)return"signed-out";if(e.code===ZAe)return"refused";if(e.code===IAe)return"unavailable";if(e.status===409&&/sign in to radient/i.test(e.message))return"signed-out"}return"unknown"}function rG(e){return pj(e)==="signed-out"}const O9=JSON.stringify(Xc.user()),d9=new Map,mj=new Set;function uue(){for(const e of mj)e()}function gj(){return d9.get(O9)??null}function DAe(e){return mj.add(e),()=>{mj.delete(e)}}function VAe(e){gj()!==e&&(d9.set(O9,e),uue())}let $j=0;function c1(){$j+=1,d9.delete(O9)&&uue()}async function Oue(e){WAe(e),c1(),await e.cancelQueries({queryKey:Xc.all}),await e.invalidateQueries({queryKey:Xc.all})}const due=({retryOnMount:e=!0,staleTime:t=30*1e3}={})=>{const n=Zs(),{setIsSigningOut:r}=cue(),i=dr(),a=Nn(i.data,"radient"),o=wt({queryKey:Xc.user(),queryFn:async()=>{const g=$j,y=JQ(n);try{const v=await c9({operation:"account"});return nG(n,y,v.account?.id),c1(),v}catch(v){if(rG(v))return nG(n,y),c1(),null;throw g===$j&&VAe(pj(v)),v}},enabled:a,staleTime:t,refetchOnWindowFocus:!0,retry:(g,y)=>!rG(y)&&g<2,retryOnMount:e}),s=!!o.data&&!o.isLoading,l=s,c=$.useSyncExternalStore(DAe,gj,gj),u=!!o.data,O=u?null:o.error?pj(o.error):c,d=O&&O!=="signed-out"?O:u?"ready":o.isLoading?"checking":"signed-out",h=ax({onMutate:()=>{NAe(n),r(!0)},mutationFn:async()=>{const y=(await qe({op:"accounts.list"})).accounts.filter(v=>v.provider==="radient");for(const v of y)await qe({op:"accounts.remove",accountId:v.id,confirmed:!0});return!0},onSuccess:()=>{n.removeQueries({queryKey:Xc.all}),c1(),n.invalidateQueries({queryKey:ui.accounts}),aO(m("ui.notices.sessions.signed_out")),r(!1)},onError:g=>{const y=g instanceof Error?g.message:String(g);Tr(m("ui.notices.sessions.sign_out_failed",{detail:y})),r(!1),Oue(n)}}),p=ax({mutationFn:async()=>(await n.invalidateQueries({queryKey:Xc.all}),!0)});return{user:o.data??void 0,isLoading:o.isLoading,isRefetching:o.isRefetching,isFetching:o.isFetching,isRefreshing:p.isPending,accountRead:d,error:o.error,hasLocalSession:l,isAuthenticated:s,unavailable:i.isSuccess&&!a,signOut:h.mutate,refreshUser:p.mutate,userQuery:o}},MAe=()=>{const e=cue(),{user:t,isLoading:n,isFetching:r,accountRead:i,error:a,isAuthenticated:o,hasLocalSession:s,unavailable:l,signOut:c,refreshUser:u}=due();let O;return n?O=s?"restoring":"loading":o?O="authenticated":O="unauthenticated",$.useEffect(()=>{if(!o||!t?.account)return;const{account:d}=t,h=d.profile?.display_name||d.name;if(!h&&!d.email)return;const{name:p,email:g}=e.profile;(h&&h!==p||d.email&&d.email!==g)&&e.updateProfile({name:h||p,email:d.email||g})},[o,t,e]),{authStatus:O,isAuthenticated:o,hasLocalSession:s,isLoading:n,isFetching:r,accountRead:i,error:a,user:o&&t?.account?{name:t.account.profile?.display_name||t.account.name,email:t.account.email,radientUser:t}:null,unavailable:l,refreshUser:u,signOut:c,updateProfile:e.updateProfile,updateName:e.updateName,updateEmail:e.updateEmail}},LAe=["credentials"],FAe=()=>{const{shouldEnableQuery:e,getConnectivityError:t}=zz(),n=t();return $.useEffect(()=>{n&&console.error("Credentials connectivity error:",n.message)},[n]),wt({enabled:e({bypassInternetCheck:!0}),queryKey:LAe,queryFn:async()=>{const i=await Jy(mf.baseUrl).credentials.listCredentials();if(i.status>=400)throw new Error(i.message||m("ui.common.errors.credentials_fetch"));return i.result},refetchOnWindowFocus:!1,staleTime:5e3})},fue=()=>{const{data:e,isError:t,isPending:n,fetchStatus:r,refetch:i}=FAe(),{isAuthenticated:a,accountRead:o,unavailable:s}=MAe(),{isServerOnline:l}=zz(),c=dr(),u=c.isPending?"pending":c.isError?"error":"answered",O=!!e?.keys?.includes("RADIENT_API_KEY"),d=a,h=t||n&&r==="idle",p=$.useRef(a);$.useEffect(()=>{p.current!==a&&(p.current=a,i())},[a,i]);const g=l&&(d||O&&!h),y=qAe({serverOnline:l,accountRead:o,accountUnavailable:s,capabilitiesState:u});return $.useMemo(()=>({hasRadientApiKey:O,hasRadientSession:d,isUnavailable:h,canUseRadientSpeech:g,speechBlock:y}),[O,d,h,g,y])};let i5=null;function BAe(){if(!i5){const e=window.api?.getHomeDirectory;i5=typeof e=="function"?e.call(window.api).catch(()=>null):Promise.resolve(null)}return i5}function HAe(){const[e,t]=$.useState(null);return $.useEffect(()=>{let n=!0;return BAe().then(r=>{n&&t(r)}),()=>{n=!1}},[]),e}const KAe=15*60*1e3,JAe=Xi()(yO((e,t)=>({providers:[],models:[],isLoading:!1,error:null,lastFetched:null,isInitialized:!1,fetchModels:async(n,r=!1)=>{const{lastFetched:i,isInitialized:a}=t(),o=Date.now();if(!(!r&&a&&i&&o-i<KAe)){e({isLoading:!0,error:null});try{const s=Jy(n),c=(await s.models.listProviders()).result?.providers||[],O=(await s.models.listModels("","recommended","descending")).result?.models||[];e({providers:c,models:O,isLoading:!1,lastFetched:o,isInitialized:!0})}catch(s){console.error("Failed to fetch models:",s),e({isLoading:!1,error:s instanceof Error?s.message:String(s)})}}},getModelsForProvider:n=>t().models.filter(r=>r.provider===n),reset:()=>{e({providers:[],models:[],isLoading:!1,error:null,lastFetched:null,isInitialized:!1})}}),{name:"local-operator-models",partialize:e=>({providers:e.providers,models:e.models,lastFetched:e.lastFetched,isInitialized:e.isInitialized})})),e8e=({autoFetch:e=!0}={})=>{const t=mf.baseUrl,n=$.useRef(null),{shouldEnableQuery:r,getConnectivityError:i,hasConnectivityIssue:a}=zz(),{providers:o,models:s,isLoading:l,error:c,lastFetched:u,isInitialized:O,fetchModels:d,getModelsForProvider:h}=JAe(),p=$.useRef(!0),g=$.useRef(!1),y=$.useRef(null);$.useEffect(()=>(n.current&&(clearInterval(n.current),n.current=null),y.current&&(clearTimeout(y.current),y.current=null),e&&r({bypassInternetCheck:!0})?(p.current?(p.current=!1,y.current=window.setTimeout(()=>{!g.current&&r({bypassInternetCheck:!0})&&(d(t),g.current=!0),y.current=null},1e3)):g.current||(d(t),g.current=!0),n.current=window.setInterval(()=>{r({bypassInternetCheck:!0})&&d(t)},15*60*1e3),()=>{n.current&&(clearInterval(n.current),n.current=null),y.current&&(clearTimeout(y.current),y.current=null)}):()=>{y.current&&(clearTimeout(y.current),y.current=null)}),[e,t,d,r]),$.useEffect(()=>{!a&&e&&O&&d(t)},[a,e,O,t,d]);const v=$.useCallback(async()=>{if(r({bypassInternetCheck:!0}))await d(t,!0);else{const x=i();if(x)throw x}},[t,d,r,i]);return{providers:o,models:s,isLoading:l,error:c,lastFetched:u,isInitialized:O,getModelsForProvider:h,getModelById:x=>s.find(Q=>Q.id===x),refreshModels:v}},t8e=()=>{const{isLoading:e,error:t,refreshModels:n}=e8e({autoFetch:!1}),r=$.useRef(!1);return $.useEffect(()=>{r.current||(r.current=!0)},[]),{isLoading:e,error:t,refreshModels:n}},n8e=(e,t,n)=>n&&e!==t,f9=e=>typeof e=="object"&&e!==null;function hue(e,t){e.offRecord.then(t,()=>{})}const r8e=e=>e!==!1&&!f9(e),i8e=(e,t)=>e===t?"":e,a8e=(e,t)=>e===""||e===t,o8e=e=>e==="",iG=(e,t)=>e?/\s$/.test(e)||/^\s/.test(t)?e+t:`${e} ${t}`:t,ws={unavailable:"ui.chat.composer.placeholder.unavailable",busy:"ui.chat.composer.placeholder.busy",answer:"ui.chat.composer.placeholder.answer",secretAnswer:"ui.chat.composer.placeholder.secret_answer",aside:"ui.chat.composer.placeholder.aside",sending:"ui.chat.composer.placeholder.sending",stopping:"ui.chat.composer.placeholder.stopping",recording:"ui.chat.composer.placeholder.recording",waiting:"ui.chat.composer.placeholder.waiting",noProvider:"ui.chat.composer.placeholder.no_provider",idle:"ui.chat.composer.placeholder.idle"},s8e=e=>e.unavailable?m(ws.unavailable):e.secretAnswer?m(ws.secretAnswer):e.hostLine&&(e.inputDisabled||e.sendingUnsettled||e.awaitingReply)?e.hostLine:e.inputDisabled?m(ws.busy):e.awaitingAnswer?m(ws.answer):e.asideAttached?m(ws.aside):e.stopping?m(ws.stopping):e.sendingUnsettled?m(ws.sending):e.awaitingReply?m(ws.waiting):e.noProvider?m(ws.noProvider):e.idle??m(ws.idle),l8e=[],c8e=[],u8e=e=>{const t=Zn.getState().inputByConversation[e];return{replies:t?.replies??l8e,attachments:t?.attachments??c8e}},O8e=(e,t)=>{const n=Zn.getState();for(const r of t.replies)n.removeReply(e,r.id);for(const r of t.attachments)n.removeAttachment(e,r.id)},d8e=()=>0,f8e=({conversationId:e,onSubmit:t,scrollToBottom:n,draftHeld:r=!1,draftUnredacted:i=d8e,transcriptless:a=!1})=>{const o=Zn(H=>H.getCurrentInput),s=Zn(H=>H.setCurrentInput),l=Zn(H=>H.addSubmittedMessage),c=Zn(H=>H.getSubmittedMessages),u=Zn(H=>H.getCurrentHistoryIndex),O=Zn(H=>H.setCurrentHistoryIndex),d=Zn(H=>H.resetCurrentHistoryIndex),h=Zn(H=>H.beginInFlight),p=Zn(H=>H.adoptReturnedText),[g,y]=$.useState(Zn.persist?.hasHydrated?.()??!1),v=$.useRef(void 0),b=$.useRef(void 0),[x,Q]=$.useState("");$.useEffect(()=>{const H=Zn.persist;let ee,re;return H&&typeof H.onHydrate=="function"&&typeof H.onFinishHydration=="function"?(ee=H.onHydrate(()=>y(!1)),re=H.onFinishHydration(()=>y(!0)),y(H.hasHydrated())):y(!0),()=>{ee?.(),re?.()}},[]);const w=$.useRef(null),S=$.useRef(""),k=Zn(H=>e?H.inputByConversation[e]?.currentInput??"":""),P=$.useRef(""),R=e?c(e):[],T=e?u(e):null;$.useEffect(()=>{if(n8e(b.current,e,g))if(b.current=e,e){const H=o(e);T!==null&&R.length>0?Q(R[T]||""):Q(H),v.current=e,S.current=""}else Q(""),v.current=void 0,S.current=""},[e,g,o,T,R]),$.useEffect(()=>{g&&e&&v.current!==e&&s(e,x)},[e,x,s,g]),$.useEffect(()=>{!g||!e||k!==P.current&&(P.current=k,k&&!x&&Q(k))},[k,g,e,x]);const q=Zn(H=>e?H.inputByConversation[e]?.pendingText:void 0),X=Zn(H=>e?H.inputByConversation[e]?.textRevision??0:0),C=Zn(H=>e?H.inputByConversation[e]?.currentInput:void 0),N=$.useRef(null);$.useEffect(()=>{if(!g||!e||v.current!==e)return;const H=N.current;N.current=X;const ee=H===null;if(q!==void 0){if(r)return;const fe=p(e);if(fe===null)return;P.current=fe,Q(fe);return}if(ee||X===H||r)return;const re=C??"";re!==x&&(P.current=re,Q(re))},[X,C,q,g,e,r,x,p]);const A=$.useCallback(H=>{if(Q(H),e){if(r)return;P.current=H,s(e,H,i(H)),d(e)}},[e,s,d,r,i]),Y=$.useRef(!1),W=$.useRef(""),Z=$.useRef(!1),D=$.useCallback(H=>{if(!(!e||!H)){if(r){Q(ee=>iG(ee,H));return}A(iG(o(e),H))}},[e,r,o,A]),z=$.useCallback(H=>{if(H){if(Z.current){W.current+=H;return}D(H)}},[D]),[V,J]=$.useState(!1),G=$.useCallback(async()=>{const H=e?u8e(e):void 0;if(!e||!x.trim()&&(H?.attachments.length??0)===0)return;const ee=Y.current;Y.current=!0,ee||(J(!0),Z.current=!0);const re=x;let fe=!1,le=!1,Pe;const ce=(xe=!1)=>{if(fe&&!xe)return;fe=!0;const Te=W.current;if(Te&&(W.current=""),Z.current=!1,!a&&v.current!==e){Te&&D(Te);return}Q(de=>i8e(de,re)),e&&h(e,{text:re,attachments:le?[]:H?.attachments??[],replies:le?[]:H?.replies??[],volatileText:r},xe),Te&&D(Te)},ve=()=>{e&&!a8e(o(e),re)||(P.current="",s(e,""),d(e),S.current="")};try{if(Pe=await t?.(re,()=>ce(!0)),Pe===!1){Z.current=!1;const xe=W.current;xe&&(W.current="",D(xe));return}}finally{ee||(Y.current=!1,J(!1))}f9(Pe)&&(le=!0,e&&H&&hue(Pe,()=>O8e(e,H))),ce(),r8e(Pe)&&l(e,re),ve(),n&&requestAnimationFrame(()=>{n()})},[x,e,t,l,s,d,n,h,r,D,o,a]),ne=$.useCallback(()=>{const H=w.current;if(!H)return{line:0,totalLines:1};const ee=H.value,re=H.selectionStart,le=(ee.substring(0,re).match(/\n/g)||[]).length+1,Pe=(ee.match(/\n/g)||[]).length+1;return{line:le,totalLines:Pe}},[]),L=$.useCallback(()=>ne().line===1,[ne]),B=$.useCallback(()=>{const{line:H,totalLines:ee}=ne();return H===ee},[ne]),se=$.useCallback(H=>{if(e){if(H.key==="Enter"&&!H.shiftKey){H.preventDefault(),G();return}if(R.length){if(H.key==="ArrowUp"){if(T===null){if(!o8e(x))return}else if(!L())return;if(H.preventDefault(),T===null)S.current=x,O(e,R.length-1),Q(R[R.length-1]||"");else if(T>0){const ee=T-1;O(e,ee),Q(R[ee]||"")}setTimeout(()=>{if(w.current){const ee=w.current.value.length;w.current.selectionStart=ee,w.current.selectionEnd=ee}},0)}if(H.key==="ArrowDown"&&B()){if(T===null)return;if(H.preventDefault(),T!==null){if(T<R.length-1){const ee=T+1;O(e,ee),Q(R[ee]||"")}else d(e),Q(S.current),S.current="";setTimeout(()=>{if(w.current){const ee=w.current.value.length;w.current.selectionStart=ee,w.current.selectionEnd=ee}},0)}}}}},[G,L,B,T,x,R,e,O,d]);return{inputValue:x,setInputValue:A,handleKeyDown:se,handleSubmit:G,textareaRef:w,appendTranscriptText:z,sendInFlight:V}},h8e=$.memo(()=>(t8e(),null));h8e.displayName="ModelsInitializer";const p8e={"--normal-bg":"var(--color-elevated)","--normal-text":"var(--color-ink)","--normal-border":"var(--color-control)","--border-radius":"var(--radius-md)","--gray12":"var(--color-ink)","--gray4":"var(--color-control)","--gray2":"var(--color-accent-wash)","--gray5":"var(--color-control)",background:"var(--color-elevated)",color:"var(--color-ink)",border:"1px solid var(--color-control)",boxShadow:"var(--shadow-overlay)",fontSize:"var(--text-meta)",padding:"12px 16px"},m8e=e=>({...p8e,"--toast-close-button-start":e==="rtl"?"0px":"auto","--toast-close-button-end":e==="rtl"?"auto":"0px","--toast-close-button-transform":e==="rtl"?"translate(-35%, -35%)":"translate(35%, -35%)"}),Won=({duration:e})=>{const t=o9();return f.jsx(rEe,{duration:e,position:t==="rtl"?"bottom-left":"bottom-right",dir:t,containerAriaLabel:m("ui.common.layout.toasts.notifications"),toastOptions:{style:m8e(t),closeButton:!0,closeButtonAriaLabel:m("ui.common.layout.toasts.dismiss")}})};var lg={},Bf={},Ob={},IO={},DO={},a5={},aG;function pue(){return aG||(aG=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Doctype=e.CDATA=e.Tag=e.Style=e.Script=e.Comment=e.Directive=e.Text=e.Root=e.isTag=e.ElementType=void 0;var t;(function(r){r.Root="root",r.Text="text",r.Directive="directive",r.Comment="comment",r.Script="script",r.Style="style",r.Tag="tag",r.CDATA="cdata",r.Doctype="doctype"})(t=e.ElementType||(e.ElementType={}));function n(r){return r.type===t.Tag||r.type===t.Script||r.type===t.Style}e.isTag=n,e.Root=t.Root,e.Text=t.Text,e.Directive=t.Directive,e.Comment=t.Comment,e.Script=t.Script,e.Style=t.Style,e.Tag=t.Tag,e.CDATA=t.CDATA,e.Doctype=t.Doctype}(a5)),a5}var Dt={},oG;function sG(){if(oG)return Dt;oG=1;var e=Dt&&Dt.__extends||function(){var w=function(S,k){return w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(P,R){P.__proto__=R}||function(P,R){for(var T in R)Object.prototype.hasOwnProperty.call(R,T)&&(P[T]=R[T])},w(S,k)};return function(S,k){if(typeof k!="function"&&k!==null)throw new TypeError("Class extends value "+String(k)+" is not a constructor or null");w(S,k);function P(){this.constructor=S}S.prototype=k===null?Object.create(k):(P.prototype=k.prototype,new P)}}(),t=Dt&&Dt.__assign||function(){return t=Object.assign||function(w){for(var S,k=1,P=arguments.length;k<P;k++){S=arguments[k];for(var R in S)Object.prototype.hasOwnProperty.call(S,R)&&(w[R]=S[R])}return w},t.apply(this,arguments)};Object.defineProperty(Dt,"__esModule",{value:!0}),Dt.cloneNode=Dt.hasChildren=Dt.isDocument=Dt.isDirective=Dt.isComment=Dt.isText=Dt.isCDATA=Dt.isTag=Dt.Element=Dt.Document=Dt.CDATA=Dt.NodeWithChildren=Dt.ProcessingInstruction=Dt.Comment=Dt.Text=Dt.DataNode=Dt.Node=void 0;var n=pue(),r=function(){function w(){this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty(w.prototype,"parentNode",{get:function(){return this.parent},set:function(S){this.parent=S},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"previousSibling",{get:function(){return this.prev},set:function(S){this.prev=S},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"nextSibling",{get:function(){return this.next},set:function(S){this.next=S},enumerable:!1,configurable:!0}),w.prototype.cloneNode=function(S){return S===void 0&&(S=!1),x(this,S)},w}();Dt.Node=r;var i=function(w){e(S,w);function S(k){var P=w.call(this)||this;return P.data=k,P}return Object.defineProperty(S.prototype,"nodeValue",{get:function(){return this.data},set:function(k){this.data=k},enumerable:!1,configurable:!0}),S}(r);Dt.DataNode=i;var a=function(w){e(S,w);function S(){var k=w!==null&&w.apply(this,arguments)||this;return k.type=n.ElementType.Text,k}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 3},enumerable:!1,configurable:!0}),S}(i);Dt.Text=a;var o=function(w){e(S,w);function S(){var k=w!==null&&w.apply(this,arguments)||this;return k.type=n.ElementType.Comment,k}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 8},enumerable:!1,configurable:!0}),S}(i);Dt.Comment=o;var s=function(w){e(S,w);function S(k,P){var R=w.call(this,P)||this;return R.name=k,R.type=n.ElementType.Directive,R}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),S}(i);Dt.ProcessingInstruction=s;var l=function(w){e(S,w);function S(k){var P=w.call(this)||this;return P.children=k,P}return Object.defineProperty(S.prototype,"firstChild",{get:function(){var k;return(k=this.children[0])!==null&&k!==void 0?k:null},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"lastChild",{get:function(){return this.children.length>0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"childNodes",{get:function(){return this.children},set:function(k){this.children=k},enumerable:!1,configurable:!0}),S}(r);Dt.NodeWithChildren=l;var c=function(w){e(S,w);function S(){var k=w!==null&&w.apply(this,arguments)||this;return k.type=n.ElementType.CDATA,k}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 4},enumerable:!1,configurable:!0}),S}(l);Dt.CDATA=c;var u=function(w){e(S,w);function S(){var k=w!==null&&w.apply(this,arguments)||this;return k.type=n.ElementType.Root,k}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 9},enumerable:!1,configurable:!0}),S}(l);Dt.Document=u;var O=function(w){e(S,w);function S(k,P,R,T){R===void 0&&(R=[]),T===void 0&&(T=k==="script"?n.ElementType.Script:k==="style"?n.ElementType.Style:n.ElementType.Tag);var q=w.call(this,R)||this;return q.name=k,q.attribs=P,q.type=T,q}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"tagName",{get:function(){return this.name},set:function(k){this.name=k},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"attributes",{get:function(){var k=this;return Object.keys(this.attribs).map(function(P){var R,T;return{name:P,value:k.attribs[P],namespace:(R=k["x-attribsNamespace"])===null||R===void 0?void 0:R[P],prefix:(T=k["x-attribsPrefix"])===null||T===void 0?void 0:T[P]}})},enumerable:!1,configurable:!0}),S}(l);Dt.Element=O;function d(w){return(0,n.isTag)(w)}Dt.isTag=d;function h(w){return w.type===n.ElementType.CDATA}Dt.isCDATA=h;function p(w){return w.type===n.ElementType.Text}Dt.isText=p;function g(w){return w.type===n.ElementType.Comment}Dt.isComment=g;function y(w){return w.type===n.ElementType.Directive}Dt.isDirective=y;function v(w){return w.type===n.ElementType.Root}Dt.isDocument=v;function b(w){return Object.prototype.hasOwnProperty.call(w,"children")}Dt.hasChildren=b;function x(w,S){S===void 0&&(S=!1);var k;if(p(w))k=new a(w.data);else if(g(w))k=new o(w.data);else if(d(w)){var P=S?Q(w.children):[],R=new O(w.name,t({},w.attribs),P);P.forEach(function(C){return C.parent=R}),w.namespace!=null&&(R.namespace=w.namespace),w["x-attribsNamespace"]&&(R["x-attribsNamespace"]=t({},w["x-attribsNamespace"])),w["x-attribsPrefix"]&&(R["x-attribsPrefix"]=t({},w["x-attribsPrefix"])),k=R}else if(h(w)){var P=S?Q(w.children):[],T=new c(P);P.forEach(function(N){return N.parent=T}),k=T}else if(v(w)){var P=S?Q(w.children):[],q=new u(P);P.forEach(function(N){return N.parent=q}),w["x-mode"]&&(q["x-mode"]=w["x-mode"]),k=q}else if(y(w)){var X=new s(w.name,w.data);w["x-name"]!=null&&(X["x-name"]=w["x-name"],X["x-publicId"]=w["x-publicId"],X["x-systemId"]=w["x-systemId"]),k=X}else throw new Error("Not implemented yet: ".concat(w.type));return k.startIndex=w.startIndex,k.endIndex=w.endIndex,w.sourceCodeLocation!=null&&(k.sourceCodeLocation=w.sourceCodeLocation),k}Dt.cloneNode=x;function Q(w){for(var S=w.map(function(P){return x(P,!0)}),k=1;k<S.length;k++)S[k].prev=S[k-1],S[k-1].next=S[k];return S}return Dt}var lG;function mue(){return lG||(lG=1,function(e){var t=DO&&DO.__createBinding||(Object.create?function(s,l,c,u){u===void 0&&(u=c);var O=Object.getOwnPropertyDescriptor(l,c);(!O||("get"in O?!l.__esModule:O.writable||O.configurable))&&(O={enumerable:!0,get:function(){return l[c]}}),Object.defineProperty(s,u,O)}:function(s,l,c,u){u===void 0&&(u=c),s[u]=l[c]}),n=DO&&DO.__exportStar||function(s,l){for(var c in s)c!=="default"&&!Object.prototype.hasOwnProperty.call(l,c)&&t(l,s,c)};Object.defineProperty(e,"__esModule",{value:!0}),e.DomHandler=void 0;var r=pue(),i=sG();n(sG(),e);var a={withStartIndices:!1,withEndIndices:!1,xmlMode:!1},o=function(){function s(l,c,u){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof c=="function"&&(u=c,c=a),typeof l=="object"&&(c=l,l=void 0),this.callback=l??null,this.options=c??a,this.elementCB=u??null}return s.prototype.onparserinit=function(l){this.parser=l},s.prototype.onreset=function(){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null},s.prototype.onend=function(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))},s.prototype.onerror=function(l){this.handleCallback(l)},s.prototype.onclosetag=function(){this.lastNode=null;var l=this.tagStack.pop();this.options.withEndIndices&&(l.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(l)},s.prototype.onopentag=function(l,c){var u=this.options.xmlMode?r.ElementType.Tag:void 0,O=new i.Element(l,c,void 0,u);this.addNode(O),this.tagStack.push(O)},s.prototype.ontext=function(l){var c=this.lastNode;if(c&&c.type===r.ElementType.Text)c.data+=l,this.options.withEndIndices&&(c.endIndex=this.parser.endIndex);else{var u=new i.Text(l);this.addNode(u),this.lastNode=u}},s.prototype.oncomment=function(l){if(this.lastNode&&this.lastNode.type===r.ElementType.Comment){this.lastNode.data+=l;return}var c=new i.Comment(l);this.addNode(c),this.lastNode=c},s.prototype.oncommentend=function(){this.lastNode=null},s.prototype.oncdatastart=function(){var l=new i.Text(""),c=new i.CDATA([l]);this.addNode(c),l.parent=c,this.lastNode=l},s.prototype.oncdataend=function(){this.lastNode=null},s.prototype.onprocessinginstruction=function(l,c){var u=new i.ProcessingInstruction(l,c);this.addNode(u)},s.prototype.handleCallback=function(l){if(typeof this.callback=="function")this.callback(l,this.dom);else if(l)throw l},s.prototype.addNode=function(l){var c=this.tagStack[this.tagStack.length-1],u=c.children[c.children.length-1];this.options.withStartIndices&&(l.startIndex=this.parser.startIndex),this.options.withEndIndices&&(l.endIndex=this.parser.endIndex),c.children.push(l),u&&(l.prev=u,u.next=l),l.parent=c,this.lastNode=null},s}();e.DomHandler=o,e.default=o}(DO)),DO}var o5={},cG;function g8e(){return cG||(cG=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CARRIAGE_RETURN_PLACEHOLDER_REGEX=e.CARRIAGE_RETURN_PLACEHOLDER=e.CARRIAGE_RETURN_REGEX=e.CARRIAGE_RETURN=e.CASE_SENSITIVE_TAG_NAMES_MAP=e.CASE_SENSITIVE_TAG_NAMES=void 0,e.CASE_SENSITIVE_TAG_NAMES=["animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"],e.CASE_SENSITIVE_TAG_NAMES_MAP=e.CASE_SENSITIVE_TAG_NAMES.reduce(function(t,n){return t[n.toLowerCase()]=n,t},{}),e.CARRIAGE_RETURN="\r",e.CARRIAGE_RETURN_REGEX=new RegExp(e.CARRIAGE_RETURN,"g"),e.CARRIAGE_RETURN_PLACEHOLDER="__HTML_DOM_PARSER_CARRIAGE_RETURN_PLACEHOLDER_".concat(Date.now(),"__"),e.CARRIAGE_RETURN_PLACEHOLDER_REGEX=new RegExp(e.CARRIAGE_RETURN_PLACEHOLDER,"g")}(o5)),o5}var uG;function gue(){if(uG)return IO;uG=1,Object.defineProperty(IO,"__esModule",{value:!0}),IO.formatAttributes=r,IO.escapeSpecialCharacters=a,IO.revertEscapedCharacters=o,IO.formatDOM=s;var e=mue(),t=g8e();function n(l){return t.CASE_SENSITIVE_TAG_NAMES_MAP[l]}function r(l){for(var c={},u=0,O=l.length;u<O;u++){var d=l[u];c[d.name]=d.value}return c}function i(l){l=l.toLowerCase();var c=n(l);return c||l}function a(l){return l.replace(t.CARRIAGE_RETURN_REGEX,t.CARRIAGE_RETURN_PLACEHOLDER)}function o(l){return l.replace(t.CARRIAGE_RETURN_PLACEHOLDER_REGEX,t.CARRIAGE_RETURN)}function s(l,c,u){c===void 0&&(c=null);for(var O=[],d,h=0,p=l.length;h<p;h++){var g=l[h];switch(g.nodeType){case 1:{var y=i(g.nodeName);d=new e.Element(y,r(g.attributes)),d.children=s(y==="template"?g.content.childNodes:g.childNodes,d);break}case 3:d=new e.Text(o(g.nodeValue));break;case 8:d=new e.Comment(g.nodeValue);break;default:continue}var v=O[h-1]||null;v&&(v.next=d),d.parent=c,d.prev=v,d.next=null,O.push(d)}return u&&(d=new e.ProcessingInstruction(u.substring(0,u.indexOf(" ")).toLowerCase(),u),d.next=O[0]||null,d.parent=c,O.unshift(d),O[1]&&(O[1].prev=O[0])),O}return IO}var OG;function $8e(){if(OG)return Ob;OG=1,Object.defineProperty(Ob,"__esModule",{value:!0}),Ob.default=g;var e=gue(),t="html",n="head",r="body",i=/<([a-zA-Z]+[0-9]?)/,a=/<head[^]*>/i,o=/<body[^]*>/i,s=function(y,v){throw new Error("This browser does not support `document.implementation.createHTMLDocument`")},l=function(y,v){throw new Error("This browser does not support `DOMParser.prototype.parseFromString`")},c=typeof window=="object"&&window.DOMParser;if(typeof c=="function"){var u=new c,O="text/html";l=function(y,v){return v&&(y="<".concat(v,">").concat(y,"</").concat(v,">")),u.parseFromString(y,O)},s=l}if(typeof document=="object"&&document.implementation){var d=document.implementation.createHTMLDocument();s=function(y,v){if(v){var b=d.documentElement.querySelector(v);return b&&(b.innerHTML=y),d}return d.documentElement.innerHTML=y,d}}var h=typeof document=="object"&&document.createElement("template"),p;h&&h.content&&(p=function(y){return h.innerHTML=y,h.content.childNodes});function g(y){var v,b;y=(0,e.escapeSpecialCharacters)(y);var x=y.match(i),Q=x&&x[1]?x[1].toLowerCase():"";switch(Q){case t:{var w=l(y);if(!a.test(y)){var S=w.querySelector(n);(v=S?.parentNode)===null||v===void 0||v.removeChild(S)}if(!o.test(y)){var S=w.querySelector(r);(b=S?.parentNode)===null||b===void 0||b.removeChild(S)}return w.querySelectorAll(t)}case n:case r:{var k=s(y).querySelectorAll(Q);return o.test(y)&&a.test(y)?k[0].parentNode.childNodes:k}default:{if(p)return p(y);var S=s(y,r).querySelector(r);return S.childNodes}}}return Ob}var dG;function y8e(){if(dG)return Bf;dG=1;var e=Bf&&Bf.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(Bf,"__esModule",{value:!0}),Bf.default=i;var t=e($8e()),n=gue(),r=/<(![a-zA-Z\s]+)>/;function i(a){if(typeof a!="string")throw new TypeError("First argument must be a string");if(!a)return[];var o=a.match(r),s=o?o[1]:void 0;return(0,n.formatDOM)((0,t.default)(a),null,s)}return Bf}var db={},Xo={},cg={},fG;function v8e(){if(fG)return cg;fG=1;var e=0;cg.SAME=e;var t=1;return cg.CAMELCASE=t,cg.possibleStandardNames={accept:0,acceptCharset:1,"accept-charset":"acceptCharset",accessKey:1,action:0,allowFullScreen:1,alt:0,as:0,async:0,autoCapitalize:1,autoComplete:1,autoCorrect:1,autoFocus:1,autoPlay:1,autoSave:1,capture:0,cellPadding:1,cellSpacing:1,challenge:0,charSet:1,checked:0,children:0,cite:0,class:"className",classID:1,className:1,cols:0,colSpan:1,content:0,contentEditable:1,contextMenu:1,controls:0,controlsList:1,coords:0,crossOrigin:1,dangerouslySetInnerHTML:1,data:0,dateTime:1,default:0,defaultChecked:1,defaultValue:1,defer:0,dir:0,disabled:0,disablePictureInPicture:1,disableRemotePlayback:1,download:0,draggable:0,encType:1,enterKeyHint:1,for:"htmlFor",form:0,formMethod:1,formAction:1,formEncType:1,formNoValidate:1,formTarget:1,frameBorder:1,headers:0,height:0,hidden:0,high:0,href:0,hrefLang:1,htmlFor:1,httpEquiv:1,"http-equiv":"httpEquiv",icon:0,id:0,innerHTML:1,inputMode:1,integrity:0,is:0,itemID:1,itemProp:1,itemRef:1,itemScope:1,itemType:1,keyParams:1,keyType:1,kind:0,label:0,lang:0,list:0,loop:0,low:0,manifest:0,marginWidth:1,marginHeight:1,max:0,maxLength:1,media:0,mediaGroup:1,method:0,min:0,minLength:1,multiple:0,muted:0,name:0,noModule:1,nonce:0,noValidate:1,open:0,optimum:0,pattern:0,placeholder:0,playsInline:1,poster:0,preload:0,profile:0,radioGroup:1,readOnly:1,referrerPolicy:1,rel:0,required:0,reversed:0,role:0,rows:0,rowSpan:1,sandbox:0,scope:0,scoped:0,scrolling:0,seamless:0,selected:0,shape:0,size:0,sizes:0,span:0,spellCheck:1,src:0,srcDoc:1,srcLang:1,srcSet:1,start:0,step:0,style:0,summary:0,tabIndex:1,target:0,title:0,type:0,useMap:1,value:0,width:0,wmode:0,wrap:0,about:0,accentHeight:1,"accent-height":"accentHeight",accumulate:0,additive:0,alignmentBaseline:1,"alignment-baseline":"alignmentBaseline",allowReorder:1,alphabetic:0,amplitude:0,arabicForm:1,"arabic-form":"arabicForm",ascent:0,attributeName:1,attributeType:1,autoReverse:1,azimuth:0,baseFrequency:1,baselineShift:1,"baseline-shift":"baselineShift",baseProfile:1,bbox:0,begin:0,bias:0,by:0,calcMode:1,capHeight:1,"cap-height":"capHeight",clip:0,clipPath:1,"clip-path":"clipPath",clipPathUnits:1,clipRule:1,"clip-rule":"clipRule",color:0,colorInterpolation:1,"color-interpolation":"colorInterpolation",colorInterpolationFilters:1,"color-interpolation-filters":"colorInterpolationFilters",colorProfile:1,"color-profile":"colorProfile",colorRendering:1,"color-rendering":"colorRendering",contentScriptType:1,contentStyleType:1,cursor:0,cx:0,cy:0,d:0,datatype:0,decelerate:0,descent:0,diffuseConstant:1,direction:0,display:0,divisor:0,dominantBaseline:1,"dominant-baseline":"dominantBaseline",dur:0,dx:0,dy:0,edgeMode:1,elevation:0,enableBackground:1,"enable-background":"enableBackground",end:0,exponent:0,externalResourcesRequired:1,fill:0,fillOpacity:1,"fill-opacity":"fillOpacity",fillRule:1,"fill-rule":"fillRule",filter:0,filterRes:1,filterUnits:1,floodOpacity:1,"flood-opacity":"floodOpacity",floodColor:1,"flood-color":"floodColor",focusable:0,fontFamily:1,"font-family":"fontFamily",fontSize:1,"font-size":"fontSize",fontSizeAdjust:1,"font-size-adjust":"fontSizeAdjust",fontStretch:1,"font-stretch":"fontStretch",fontStyle:1,"font-style":"fontStyle",fontVariant:1,"font-variant":"fontVariant",fontWeight:1,"font-weight":"fontWeight",format:0,from:0,fx:0,fy:0,g1:0,g2:0,glyphName:1,"glyph-name":"glyphName",glyphOrientationHorizontal:1,"glyph-orientation-horizontal":"glyphOrientationHorizontal",glyphOrientationVertical:1,"glyph-orientation-vertical":"glyphOrientationVertical",glyphRef:1,gradientTransform:1,gradientUnits:1,hanging:0,horizAdvX:1,"horiz-adv-x":"horizAdvX",horizOriginX:1,"horiz-origin-x":"horizOriginX",ideographic:0,imageRendering:1,"image-rendering":"imageRendering",in2:0,in:0,inlist:0,intercept:0,k1:0,k2:0,k3:0,k4:0,k:0,kernelMatrix:1,kernelUnitLength:1,kerning:0,keyPoints:1,keySplines:1,keyTimes:1,lengthAdjust:1,letterSpacing:1,"letter-spacing":"letterSpacing",lightingColor:1,"lighting-color":"lightingColor",limitingConeAngle:1,local:0,markerEnd:1,"marker-end":"markerEnd",markerHeight:1,markerMid:1,"marker-mid":"markerMid",markerStart:1,"marker-start":"markerStart",markerUnits:1,markerWidth:1,mask:0,maskContentUnits:1,maskUnits:1,mathematical:0,mode:0,numOctaves:1,offset:0,opacity:0,operator:0,order:0,orient:0,orientation:0,origin:0,overflow:0,overlinePosition:1,"overline-position":"overlinePosition",overlineThickness:1,"overline-thickness":"overlineThickness",paintOrder:1,"paint-order":"paintOrder",panose1:0,"panose-1":"panose1",pathLength:1,patternContentUnits:1,patternTransform:1,patternUnits:1,pointerEvents:1,"pointer-events":"pointerEvents",points:0,pointsAtX:1,pointsAtY:1,pointsAtZ:1,prefix:0,preserveAlpha:1,preserveAspectRatio:1,primitiveUnits:1,property:0,r:0,radius:0,refX:1,refY:1,renderingIntent:1,"rendering-intent":"renderingIntent",repeatCount:1,repeatDur:1,requiredExtensions:1,requiredFeatures:1,resource:0,restart:0,result:0,results:0,rotate:0,rx:0,ry:0,scale:0,security:0,seed:0,shapeRendering:1,"shape-rendering":"shapeRendering",slope:0,spacing:0,specularConstant:1,specularExponent:1,speed:0,spreadMethod:1,startOffset:1,stdDeviation:1,stemh:0,stemv:0,stitchTiles:1,stopColor:1,"stop-color":"stopColor",stopOpacity:1,"stop-opacity":"stopOpacity",strikethroughPosition:1,"strikethrough-position":"strikethroughPosition",strikethroughThickness:1,"strikethrough-thickness":"strikethroughThickness",string:0,stroke:0,strokeDasharray:1,"stroke-dasharray":"strokeDasharray",strokeDashoffset:1,"stroke-dashoffset":"strokeDashoffset",strokeLinecap:1,"stroke-linecap":"strokeLinecap",strokeLinejoin:1,"stroke-linejoin":"strokeLinejoin",strokeMiterlimit:1,"stroke-miterlimit":"strokeMiterlimit",strokeWidth:1,"stroke-width":"strokeWidth",strokeOpacity:1,"stroke-opacity":"strokeOpacity",suppressContentEditableWarning:1,suppressHydrationWarning:1,surfaceScale:1,systemLanguage:1,tableValues:1,targetX:1,targetY:1,textAnchor:1,"text-anchor":"textAnchor",textDecoration:1,"text-decoration":"textDecoration",textLength:1,textRendering:1,"text-rendering":"textRendering",to:0,transform:0,typeof:0,u1:0,u2:0,underlinePosition:1,"underline-position":"underlinePosition",underlineThickness:1,"underline-thickness":"underlineThickness",unicode:0,unicodeBidi:1,"unicode-bidi":"unicodeBidi",unicodeRange:1,"unicode-range":"unicodeRange",unitsPerEm:1,"units-per-em":"unitsPerEm",unselectable:0,vAlphabetic:1,"v-alphabetic":"vAlphabetic",values:0,vectorEffect:1,"vector-effect":"vectorEffect",version:0,vertAdvY:1,"vert-adv-y":"vertAdvY",vertOriginX:1,"vert-origin-x":"vertOriginX",vertOriginY:1,"vert-origin-y":"vertOriginY",vHanging:1,"v-hanging":"vHanging",vIdeographic:1,"v-ideographic":"vIdeographic",viewBox:1,viewTarget:1,visibility:0,vMathematical:1,"v-mathematical":"vMathematical",vocab:0,widths:0,wordSpacing:1,"word-spacing":"wordSpacing",writingMode:1,"writing-mode":"writingMode",x1:0,x2:0,x:0,xChannelSelector:1,xHeight:1,"x-height":"xHeight",xlinkActuate:1,"xlink:actuate":"xlinkActuate",xlinkArcrole:1,"xlink:arcrole":"xlinkArcrole",xlinkHref:1,"xlink:href":"xlinkHref",xlinkRole:1,"xlink:role":"xlinkRole",xlinkShow:1,"xlink:show":"xlinkShow",xlinkTitle:1,"xlink:title":"xlinkTitle",xlinkType:1,"xlink:type":"xlinkType",xmlBase:1,"xml:base":"xmlBase",xmlLang:1,"xml:lang":"xmlLang",xmlns:0,"xml:space":"xmlSpace",xmlnsXlink:1,"xmlns:xlink":"xmlnsXlink",xmlSpace:1,y1:0,y2:0,y:0,yChannelSelector:1,z:0,zoomAndPan:1},cg}var hG;function b8e(){if(hG)return Xo;hG=1;const e=0,t=1,n=2,r=3,i=4,a=5,o=6;function s(w){return c.hasOwnProperty(w)?c[w]:null}function l(w,S,k,P,R,T,q){this.acceptsBooleans=S===n||S===r||S===i,this.attributeName=P,this.attributeNamespace=R,this.mustUseProperty=k,this.propertyName=w,this.type=S,this.sanitizeURL=T,this.removeEmptyString=q}const c={};["children","dangerouslySetInnerHTML","defaultValue","defaultChecked","innerHTML","suppressContentEditableWarning","suppressHydrationWarning","style"].forEach(w=>{c[w]=new l(w,e,!1,w,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(([w,S])=>{c[w]=new l(w,t,!1,S,null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(w=>{c[w]=new l(w,n,!1,w.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(w=>{c[w]=new l(w,n,!1,w,null,!1,!1)}),["allowFullScreen","async","autoFocus","autoPlay","controls","default","defer","disabled","disablePictureInPicture","disableRemotePlayback","formNoValidate","hidden","loop","noModule","noValidate","open","playsInline","readOnly","required","reversed","scoped","seamless","itemScope"].forEach(w=>{c[w]=new l(w,r,!1,w.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(w=>{c[w]=new l(w,r,!0,w,null,!1,!1)}),["capture","download"].forEach(w=>{c[w]=new l(w,i,!1,w,null,!1,!1)}),["cols","rows","size","span"].forEach(w=>{c[w]=new l(w,o,!1,w,null,!1,!1)}),["rowSpan","start"].forEach(w=>{c[w]=new l(w,a,!1,w.toLowerCase(),null,!1,!1)});const O=/[\-\:]([a-z])/g,d=w=>w[1].toUpperCase();["accent-height","alignment-baseline","arabic-form","baseline-shift","cap-height","clip-path","clip-rule","color-interpolation","color-interpolation-filters","color-profile","color-rendering","dominant-baseline","enable-background","fill-opacity","fill-rule","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-name","glyph-orientation-horizontal","glyph-orientation-vertical","horiz-adv-x","horiz-origin-x","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","overline-position","overline-thickness","paint-order","panose-1","pointer-events","rendering-intent","shape-rendering","stop-color","stop-opacity","strikethrough-position","strikethrough-thickness","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-rendering","underline-position","underline-thickness","unicode-bidi","unicode-range","units-per-em","v-alphabetic","v-hanging","v-ideographic","v-mathematical","vector-effect","vert-adv-y","vert-origin-x","vert-origin-y","word-spacing","writing-mode","xmlns:xlink","x-height"].forEach(w=>{const S=w.replace(O,d);c[S]=new l(S,t,!1,w,null,!1,!1)}),["xlink:actuate","xlink:arcrole","xlink:role","xlink:show","xlink:title","xlink:type"].forEach(w=>{const S=w.replace(O,d);c[S]=new l(S,t,!1,w,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(w=>{const S=w.replace(O,d);c[S]=new l(S,t,!1,w,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(w=>{c[w]=new l(w,t,!1,w.toLowerCase(),null,!1,!1)});const h="xlinkHref";c[h]=new l("xlinkHref",t,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(w=>{c[w]=new l(w,t,!1,w.toLowerCase(),null,!0,!0)});const{CAMELCASE:p,SAME:g,possibleStandardNames:y}=v8e(),b=":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD"+"\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",x=RegExp.prototype.test.bind(new RegExp("^(data|aria)-["+b+"]*$")),Q=Object.keys(y).reduce((w,S)=>{const k=y[S];return k===g?w[S]=S:k===p?w[S.toLowerCase()]=S:w[S]=k,w},{});return Xo.BOOLEAN=r,Xo.BOOLEANISH_STRING=n,Xo.NUMERIC=a,Xo.OVERLOADED_BOOLEAN=i,Xo.POSITIVE_NUMERIC=o,Xo.RESERVED=e,Xo.STRING=t,Xo.getPropertyInfo=s,Xo.isCustomAttribute=x,Xo.possibleStandardNames=Q,Xo}var ug={},Hf={},s5,pG;function w8e(){if(pG)return s5;pG=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,s=/^\s+|\s+$/g,l=`
|
|
519
519
|
`,c="/",u="*",O="",d="comment",h="declaration";s5=function(g,y){if(typeof g!="string")throw new TypeError("First argument must be a string");if(!g)return[];y=y||{};var v=1,b=1;function x(C){var N=C.match(t);N&&(v+=N.length);var A=C.lastIndexOf(l);b=~A?C.length-A:b+C.length}function Q(){var C={line:v,column:b};return function(N){return N.position=new w(C),P(),N}}function w(C){this.start=C,this.end={line:v,column:b},this.source=y.source}w.prototype.content=g;function S(C){var N=new Error(y.source+":"+v+":"+b+": "+C);if(N.reason=C,N.filename=y.source,N.line=v,N.column=b,N.source=g,!y.silent)throw N}function k(C){var N=C.exec(g);if(N){var A=N[0];return x(A),g=g.slice(A.length),N}}function P(){k(n)}function R(C){var N;for(C=C||[];N=T();)N!==!1&&C.push(N);return C}function T(){var C=Q();if(!(c!=g.charAt(0)||u!=g.charAt(1))){for(var N=2;O!=g.charAt(N)&&(u!=g.charAt(N)||c!=g.charAt(N+1));)++N;if(N+=2,O===g.charAt(N-1))return S("End of comment missing");var A=g.slice(2,N-2);return b+=2,x(A),g=g.slice(N),b+=2,C({type:d,comment:A})}}function q(){var C=Q(),N=k(r);if(N){if(T(),!k(i))return S("property missing ':'");var A=k(a),Y=C({type:h,property:p(N[0].replace(e,O)),value:A?p(A[0].replace(e,O)):O});return k(o),Y}}function X(){var C=[];R(C);for(var N;N=q();)N!==!1&&(C.push(N),R(C));return C}return P(),X()};function p(g){return g?g.replace(s,O):O}return s5}var mG;function x8e(){if(mG)return Hf;mG=1;var e=Hf&&Hf.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Hf,"__esModule",{value:!0}),Hf.default=n;var t=e(w8e());function n(r,i){var a=null;if(!r||typeof r!="string")return a;var o=(0,t.default)(r),s=typeof i=="function";return o.forEach(function(l){if(l.type==="declaration"){var c=l.property,u=l.value;s?i(c,u,l):u&&(a=a||{},a[c]=u)}}),a}return Hf}var Og={},gG;function S8e(){if(gG)return Og;gG=1,Object.defineProperty(Og,"__esModule",{value:!0}),Og.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,a=function(c){return!c||n.test(c)||e.test(c)},o=function(c,u){return u.toUpperCase()},s=function(c,u){return"".concat(u,"-")},l=function(c,u){return u===void 0&&(u={}),a(c)?c:(c=c.toLowerCase(),u.reactCompat?c=c.replace(i,s):c=c.replace(r,s),c.replace(t,o))};return Og.camelCase=l,Og}var dg,$G;function $ue(){if($G)return dg;$G=1;var e=dg&&dg.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(x8e()),n=S8e();function r(i,a){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(s,l){s&&l&&(o[(0,n.camelCase)(s,a)]=l)}),o}return r.default=r,dg=r,dg}var yG;function yue(){return yG||(yG=1,function(e){var t=ug&&ug.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(e,"__esModule",{value:!0}),e.returnFirstArg=e.canTextBeChildOfNode=e.ELEMENTS_WITH_NO_TEXT_CHILDREN=e.PRESERVE_CUSTOM_ATTRIBUTES=void 0,e.isCustomComponent=a,e.setStyleProp=s;var n=mse(),r=t($ue()),i=new Set(["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"]);function a(u,O){return u.includes("-")?!i.has(u):!!(O&&typeof O.is=="string")}var o={reactCompat:!0};function s(u,O){if(typeof u=="string"){if(!u.trim()){O.style={};return}try{O.style=(0,r.default)(u,o)}catch{O.style={}}}}e.PRESERVE_CUSTOM_ATTRIBUTES=Number(n.version.split(".")[0])>=16,e.ELEMENTS_WITH_NO_TEXT_CHILDREN=new Set(["tr","tbody","thead","tfoot","colgroup","table","head","html","frameset"]);var l=function(u){return!e.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(u.name)};e.canTextBeChildOfNode=l;var c=function(u){return u};e.returnFirstArg=c}(ug)),ug}var vG;function vue(){if(vG)return db;vG=1,Object.defineProperty(db,"__esModule",{value:!0}),db.default=a;var e=b8e(),t=yue(),n=["checked","value"],r=["input","select","textarea"],i={reset:!0,submit:!0};function a(s,l){s===void 0&&(s={});var c={},u=!!(s.type&&i[s.type]);for(var O in s){var d=s[O];if((0,e.isCustomAttribute)(O)){c[O]=d;continue}var h=O.toLowerCase(),p=o(h);if(p){var g=(0,e.getPropertyInfo)(p);switch(n.includes(p)&&r.includes(l)&&!u&&(p=o("default"+h)),c[p]=d,g&&g.type){case e.BOOLEAN:c[p]=!0;break;case e.OVERLOADED_BOOLEAN:d===""&&(c[p]=!0);break}continue}t.PRESERVE_CUSTOM_ATTRIBUTES&&(c[O]=d)}return(0,t.setStyleProp)(s.style,c),c}function o(s){return e.possibleStandardNames[s]}return db}var Kf={},bG;function Q8e(){if(bG)return Kf;bG=1;var e=Kf&&Kf.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Kf,"__esModule",{value:!0}),Kf.default=a;var t=mse(),n=e(vue()),r=yue(),i={cloneElement:t.cloneElement,createElement:t.createElement,isValidElement:t.isValidElement};function a(s,l){l===void 0&&(l={});for(var c=[],u=typeof l.replace=="function",O=l.transform||r.returnFirstArg,d=l.library||i,h=d.cloneElement,p=d.createElement,g=d.isValidElement,y=s.length,v=0;v<y;v++){var b=s[v];if(u){var x=l.replace(b,v);if(g(x)){y>1&&(x=h(x,{key:x.key||v})),c.push(O(x,b,v));continue}}if(b.type==="text"){var Q=!b.data.trim().length;if(Q&&b.parent&&!(0,r.canTextBeChildOfNode)(b.parent)||l.trim&&Q)continue;c.push(O(b.data,b,v));continue}var w=b,S={};o(w)?((0,r.setStyleProp)(w.attribs.style,w.attribs),S=w.attribs):w.attribs&&(S=(0,n.default)(w.attribs,w.name));var k=void 0;switch(b.type){case"script":case"style":b.children[0]&&(S.dangerouslySetInnerHTML={__html:b.children[0].data});break;case"tag":b.name==="textarea"&&b.children[0]?S.defaultValue=b.children[0].data:b.children&&b.children.length&&(k=a(b.children,l));break;default:continue}y>1&&(S.key=v),c.push(O(p(b.name,S,k),b,v))}return c.length===1?c[0]:c}function o(s){return r.PRESERVE_CUSTOM_ATTRIBUTES&&s.type==="tag"&&(0,r.isCustomComponent)(s.name,s.attribs)}return Kf}var wG;function k8e(){return wG||(wG=1,function(e){var t=lg&&lg.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(e,"__esModule",{value:!0}),e.htmlToDOM=e.domToReact=e.attributesToProps=e.Text=e.ProcessingInstruction=e.Element=e.Comment=void 0,e.default=s;var n=t(y8e());e.htmlToDOM=n.default;var r=t(vue());e.attributesToProps=r.default;var i=t(Q8e());e.domToReact=i.default;var a=mue();Object.defineProperty(e,"Comment",{enumerable:!0,get:function(){return a.Comment}}),Object.defineProperty(e,"Element",{enumerable:!0,get:function(){return a.Element}}),Object.defineProperty(e,"ProcessingInstruction",{enumerable:!0,get:function(){return a.ProcessingInstruction}}),Object.defineProperty(e,"Text",{enumerable:!0,get:function(){return a.Text}});var o={lowerCaseAttributeNames:!1};function s(l,c){if(typeof l!="string")throw new TypeError("First argument must be a string");return l?(0,i.default)((0,n.default)(l,c?.htmlparser2||o),c):[]}}(lg)),lg}var _8e=k8e();const xG=In(_8e),Non=xG.default||xG,P8e=e=>e.includes("loopback or private")?m("ui.notices.links.open_local_blocked"):m("ui.notices.links.open_failed"),bue=e=>{Tr(P8e(e))};function Yon(){const e=window.api?.onExternalOpenRefused;return typeof e!="function"?()=>{}:e(t=>{bue(t.reason)})}const wue=2200,Gon=120,Zon=180,Ion=.45,Don="cubic-bezier(0.4, 0, 0.6, 1)",fg="data-lo-scrollbar",l5="active",SG="idle",T8e="data-undo-scope",X8e={now:()=>Date.now(),setTimer:(e,t)=>setTimeout(e,t),clearTimer:e=>clearTimeout(e)},QG=/^(auto|scroll)$/,R8e=e=>{const t=getComputedStyle(e);return QG.test(t.overflowX)||QG.test(t.overflowY)},E8e="contenteditable",c5=e=>{let t=e;for(;t!==null;){if(t.isContentEditable===!0||t.getAttribute(E8e)!==null||t.getAttribute(T8e)!==null)return!0;t=t.parentElement}return!1},u5=e=>e!==null&&e.nodeType===1?e:null,q8e=":focus-visible";function Von(e={}){const t=e.doc??document,n=e.clock??X8e,r=e.holdMs??wue,i=new Map,a=new WeakMap,o=new WeakMap;let s=null;const l=b=>{const x=a.get(b);if(x!==void 0)return x;const Q=(e.isScroller??R8e)(b);return Q&&a.set(b,Q),Q},c=b=>{const x=u5(b);if(x===null)return null;const Q=o.get(x);if(Q!==void 0)return Q;if(c5(x))return null;let w=null,S=x;for(;S!==null;){if(l(S)){w=S;break}S=S.parentElement}return w!==null&&o.set(x,w),w},u=b=>{if(b===null||b.isConnected!==!0)return;const x=b.getAttribute(fg);x!==l5&&(x===null&&b.setAttribute(fg,SG),b.setAttribute(fg,l5)),i.set(b,n.now()+r),d()};function O(){s=null;const b=n.now();for(const[x,Q]of[...i]){if(x.isConnected!==!0){i.delete(x);continue}Q<=b&&(i.delete(x),x.getAttribute(fg)===l5&&x.setAttribute(fg,SG))}d()}function d(){if(s!==null||i.size===0)return;let b=Number.POSITIVE_INFINITY;for(const x of i.values())x<b&&(b=x);s=n.setTimer(O,Math.max(b-n.now(),0))}const h=b=>{const x=u5(b.target);x!==null&&l(x)&&(c5(x)||u(x))},p=b=>{u(c(b.target))},g=b=>{u(c(b.target))},y=b=>{const x=u5(b.target);x===null||c5(x)||!(typeof x.matches!="function"||x.matches(q8e))||u(c(x))},v={capture:!0,passive:!0};return t.addEventListener("scroll",h,v),t.addEventListener("pointerover",p,v),t.addEventListener("pointerdown",g,v),t.addEventListener("focusin",y,v),()=>{t.removeEventListener("scroll",h,v),t.removeEventListener("pointerover",p,v),t.removeEventListener("pointerdown",g,v),t.removeEventListener("focusin",y,v),s!==null&&(n.clearTimer(s),s=null),i.clear()}}function h9(e){return e.label?.trim()||e.name}function Mon(e,t){return ek("profiles"),wt({queryKey:["desktop","profile",e],enabled:t&&!!e,queryFn:()=>qe({op:"profiles.get",name:e??""}),retry:!1})}function Lon(e,t){return ek("teams"),wt({queryKey:["desktop","team",e],enabled:t&&!!e,queryFn:()=>qe({op:"teams.get",name:e??""}),retry:!1})}function Fon(e,t){return wt({queryKey:["desktop","team",e,"effective"],enabled:t&&!!e,queryFn:()=>qe({op:"teams.effective",name:e??""}),retry:!1})}function Bon(e){for(const t of[["desktop","profiles"],["desktop","teams"],["desktop","profile"],["desktop","team"],["desktop","skills","library"],["desktop","hub-links"]])e.invalidateQueries({queryKey:[...t]})}function j8e(e){return ek("profiles"),wt({queryKey:["desktop","profiles"],enabled:e,queryFn:()=>qe({op:"profiles.list"}).then(t=>t.profiles),retry:Ir,staleTime:1e4})}function ek(e){const{authoringRevision:t,authoringReconnectRevision:n}=Hle(),r=Zs(),i=$.useRef(t),a=$.useRef(n);$.useEffect(()=>{if(t!==null&&t!==i.current){i.current=t,a.current=n,r.invalidateQueries({queryKey:["desktop",e]}),r.invalidateQueries({queryKey:["desktop",e==="profiles"?"profile":"team"]});return}n!==a.current&&(a.current=n,r.invalidateQueries({queryKey:["desktop",e]}),r.invalidateQueries({queryKey:["desktop",e==="profiles"?"profile":"team"]}))},[t,n,e,r])}function xue(e){return ek("teams"),wt({queryKey:["desktop","teams"],enabled:e,queryFn:()=>qe({op:"teams.list"}).then(t=>t.teams),retry:Ir,staleTime:1e4})}function C8e(e){const t=xue(e);return $.useMemo(()=>{const n=new Map((t.data??[]).map(r=>[r.name,h9(r)]));return r=>n.get(r)??r},[t.data])}const z8e=/\s+/g,A8e=/(?<=[.!?])\s/,U8e="The aside was not answered.";function Sue(e){return As(e,U8e)}const W8e=new Set(["aside_unanswered","aside_empty_answer"]);function Que(e){return e instanceof Ln&&e.code!==void 0&&W8e.has(e.code)}const N8e="This aside can't continue. Press Esc to close it, which discards this exchange, then start a new one with /btw.",Y8e="Ask again here to keep this exchange, or press Esc to close the aside and discard it.",G8e=/\s+[Aa]sk again\.$/;function Z8e(e,t){const n=Sue(e);return t?Que(e)?`${n.replace(G8e,"")} ${Y8e}`:`${n} ${N8e}`:n}const kG=60;function I8e(e){const t=e.trim().replace(z8e," ");return t.length>kG?`“${t.slice(0,kG-1)}…”`:`“${t}”`}function D8e(e,t){return`Your aside ${I8e(e)} got no answer: ${V8e(t)}`}function V8e(e){return Que(e)?"The model didn't reply in text. Ask again.":Sue(e)}const M8e="The aside is still answering. Press Enter again once the answer is in.",L8e="This aside is queued to join the conversation. Ask again once it has been added.";function Hon(e,t){return e.attached[t]?.queued?L8e:w2e(e,t)?.streaming?M8e:null}function Kon(e,t,n){const r=x2e($r.getState(),t);e.catch(i=>{const a=$r.getState();r&&S2e(a,r.asideId)||n(D8e(r?.question??"",i))})}const F8e="The request has invalid fields.";function B8e(e,t){return t&&e instanceof Ln&&e.status===422&&e.message===F8e}const a0=new Set,H8e=64;function K8e(e){for(a0.add(e);a0.size>H8e;){const t=a0.values().next().value;if(t===void 0)return;a0.delete(t)}}function Jon(e){$r.getState().attachAside(e)}async function esn(e,t,n){const r=Wa(),i=$r.getState(),a=xse(i,e);i.beginAsk(e,r,t);const o=l=>qe({op:"sessions.aside",sessionId:e,requestId:r,text:t,asideId:a,subscriptionId:l?n:void 0}),s=!!n&&!a0.has(e);try{let l;try{l=await o(s)}catch(c){if(!B8e(c,s))throw c;K8e(e),l=await o(!1)}return $r.getState().settleAside(r,l.data.text),r}catch(l){throw $r.getState().failAside(r,Z8e(l,a!==void 0)),l}}async function kue(e){const t=$r.getState(),n=Sse(t,e);if(!n)return;let r;try{r=await qe({op:"sessions.adopt",sessionId:e,requestId:Wa(),asideId:n,confirmed:!0})}catch(i){throw t.setAsideNotice(e,tUe(i)),i}if(J8e(r)==="queued"){$r.getState().queueAdoption(e,n,[]),nUe(e,n).then(i=>{const a=$r.getState().attached[e]?.queued;i.length>0&&a?.asideId===n&&$r.getState().queueAdoption(e,n,i)});return}Qse(e),$r.getState().detachAside(e)}function J8e(e){return e?.data?.status==="queued"?"queued":"adopted"}const _G="Queued — this aside joins the conversation when the current turn finishes.",eUe={session_closed:"The aside was not added: this conversation has closed, so there is nothing to add it to.",open_tool_batch:"The conversation stopped in the middle of a tool call, so the aside was not added. Send a message to continue the conversation, then add the aside.",turn_running:"This conversation is busy, and the version it's running can't queue an aside. Add it when the reply finishes."};function tUe(e){if(e instanceof Ln&&e.code===v2e){const t=b2e(e.detail);if(t)return eUe[t]}return As(e,"The aside was not added to the conversation.")}async function nUe(e,t){try{return((await qe({op:"sessions.aside.get",sessionId:e,asideId:t}))?.data?.turns??[]).map(r=>r?.id).filter(r=>typeof r=="string"&&r!=="")}catch{return[]}}const PG=1500,rUe="The aside was not added to the conversation. Add it again to try once more.",iUe="The aside could not be confirmed in the conversation. If it is not there, add it again.";function aUe(e){return e.messageIds.length>0&&e.messageIds.every(t=>e.hasRecord(t))?"landed":e.turnAlive?"wait":"resync"}const hd=new Map;function TG(e){const t=hd.get(e);t!==void 0&&clearTimeout(t),hd.delete(e)}function tsn(e,t,n){const r=$r.getState().attached[e]?.queued;if(!r)return;const{asideId:i}=r,a=aUe({messageIds:r.messageIds,hasRecord:t,turnAlive:n});if(a==="landed"){TG(i),$r.getState().detachAside(e);return}if(a==="wait"){TG(i);return}if(hd.has(i))return;const o=()=>$r.getState().attached[e]?.queued?.asideId===i;hd.set(i,setTimeout(()=>{if(!o()){hd.delete(i);return}Qse(e),hd.set(i,setTimeout(()=>{if(hd.delete(i),!o())return;const s=$r.getState().attached[e]?.queued?.messageIds.length??0;$r.getState().unqueueAdoption(e,i,s>0?rUe:iUe)},PG))},PG))}function yj(e){const t=$r.getState(),n=xse(t,e)??Sse(t,e);n&&qe({op:"sessions.aside.close",sessionId:e,asideId:n}).catch(()=>{}),$r.getState().detachAside(e)}function oUe(e){return e.defaultPrevented||e.repeat||e.isComposing||e.shiftKey||e.altKey||e.key.toLowerCase()!=="f"?!1:e.metaKey||e.ctrlKey}const _ue=e=>e?"⌘+F":"Ctrl+F",XG=e=>`Press ${_ue(e)} again to add the aside to the conversation. Once added, it stays there.`,sUe=400;function lUe(e,t,n){return e?.turnId!==t?"arm":n-e.at<sUe?"ignore":"adopt"}function Pue(e,t,n=!1){return!!e?.settled&&(n||!t)}function cUe(e,t,n=!1){return e?e.error!==null?"Nothing to add.":t&&!n?"This conversation is working. Adding the aside while it runs would splice a message into a live turn.":e.streaming?"The exchange is still settling — a moment before it can be added.":null:"Nothing to add yet."}function Tue(e){return e.scrollTop+(e.turnTop-e.regionTop)}function uUe(e){const t=Math.max(0,e.scrollHeight-e.clientHeight);return Math.min(t,Math.max(0,Tue(e)))}function OUe(e,t){return e===t}function dUe(e){return e.scrollTop<e.offset&&e.maxScroll<e.offset&&e.clientHeight>e.writtenClientHeight&&Math.abs(e.scrollTop-e.maxScroll)<=1}function fUe(e){return e?`${e.error!==null?"refused":e.settled?"settled":"live"}:${e.text.length}`:"none"}const RG=140,hUe=[[/!?\[([^\]]*)\]\([^)]*\)/g,"$1"],[/`(?=\S)([^`]*?\S)`/g,"$1"],[/\*\*(?=\S)([\s\S]*?\S)\*\*/g,"$1"],[/__(?=\S)([\s\S]*?\S)__/g,"$1"],[/~~(?=\S)([^~]*?\S)~~/g,"$1"],[/\*(?=\S)([^*]*?\S)\*/g,"$1"],[/(?<![A-Za-z0-9_])_(?=\S)([^_]*?\S)_(?!\w)/g,"$1"]];function pUe(e){return hUe.reduce((t,[n,r])=>t.replace(n,r),e)}function mUe(e){if(!e)return null;if(e.error!==null)return"The aside was not answered";if(e.streaming)return"Asking the aside";const t=pUe(e.text.trim()).split(A8e)[0]??"";return t.length===0?"The aside answered":t.length>RG?`The aside answered: ${t.slice(0,RG)}…`:`The aside answered: ${t}`}const gUe=new Set(["job_result","hub_message","team_bridge_message","monitor_prompt"]),$Ue="no_reply";function bl(e){return e.kind==="tool"&&e.toolName===$Ue}function oO(e){return!(!bl(e)||e.phase!=="done"||e.isError===!0||e.stopped===!0||e.neverSent===!0||e.notRunReason!==null&&e.notRunReason!==void 0||ex(e.notRunKind))}function pp(e){switch(e.kind){case"user":return"user";case"peer":return"peer";case"wake":return"wake";case"custom":return e.customType==="team_bridge_message"?"peer":gUe.has(e.customType)?e.customType:null;default:return null}}function gx(e){return e.kind==="assistant"&&!e.streaming&&e.stopReason==="stop"}function vj(e){return e.kind==="assistant"&&!e.streaming&&e.callsTools!==!0&&e.text.length>0}function Xue(e){return e.kind==="notice"&&e.complete===!0}function p9(e){switch(e.kind){case"compaction":return"compaction";case"notice":return Xue(e)?"terminal":null;case"custom":return e.level==="error"?"terminal":null;default:return null}}function tk(e){return p9(e)==="terminal"}function Rue(e,t){const n=e.length,r=new Array(n).fill(!1);let i=!1;for(let l=n-1;l>=0;l-=1){const c=e[l];pp(c)!==null?i=!1:c.kind==="tool"?(oO(c)&&(r[l]=!0),i=!0):c.kind==="assistant"&&!c.streaming&&t(c)&&!i&&(r[l]=!0)}const a=[];let o=0,s=!1;for(let l=0;l<n;l+=1){const c=e[l];if(tk(c)&&(s=!0),!r[l])continue;let u=-1;const O=[];for(let g=o;g<l;g+=1){const y=pp(e[g]);u===-1&&e[g].kind==="tool"&&(u=g),y!==null&&(u===-1||y==="user")&&O.push(y)}const d=a.at(-1)??null;let h,p;d===null?(h="response",p=O.includes("user")?"user":"head-cut"):O.includes("user")?(h="response",p="user"):O.some(g=>g==="wake"||g==="peer")&&s?(h="commentary",p="post-terminal"):(h=d.class,p="continuation"),a.push({start:o,closeIndex:l,class:h,why:p,initiators:O}),o=l+1,s=!1}return a}function Eue(e,t,n){const r=t.length>0?t[t.length-1].closeIndex:-1;let i=!1;for(let a=e.length-1;a>r;a-=1)tk(e[a])&&(i=!0);for(let a=e.length-1;a>=0;a-=1){const o=e[a];if(!(o.kind==="user"||!n.paints(o))&&!n.isStatement(o)){if(o.kind==="assistant"&&!o.streaming||o.kind!=="assistant"&&i)break;return null}}for(let a=t.length-1;a>=0;a-=1)if(t[a].class==="response")return oO(e[t[a].closeIndex])?null:t[a];return null}function yUe(e,t){const n=Rue(e,t.paints),r=Eue(e,n,t),i=new Set;if(e.forEach((u,O)=>{O>=t.from&&t.pinned(u)&&i.add(O)}),r!==null){i.add(r.closeIndex);const u=n[n.length-1].closeIndex;for(let O=e.length-1;O>u;O-=1){const d=e[O];if(!t.isStatement(d))break;i.add(O)}}for(const u of n)u.class==="response"&&!oO(e[u.closeIndex])&&i.add(u.closeIndex);if(n.length>0){const u=n[n.length-1];oO(e[u.closeIndex])||i.add(u.closeIndex)}const a=new Set;for(const u of n)if(u.class==="response")for(let O=u.start;O<=u.closeIndex;O+=1)a.add(O);const o=n.at(-1),s=o===void 0?0:o.class==="response"?o.closeIndex+1:e.length;for(let u=s;u<e.length;u+=1)a.add(u);e.forEach((u,O)=>{O<t.from||(u.kind==="user"||t.paints(u)&&(gx(u)||vj(u)&&a.has(O)))&&i.add(O)}),(t.mode??kse)==="by-response"&&e.forEach((u,O)=>{O<t.from||u.kind!=="assistant"||u.streaming||t.paints(u)&&i.add(O)});const l=[];let c=null;for(let u=t.from;u<e.length;u+=1)i.has(u)?(c!==null&&l.push({from:c,to:u-1}),c=null):c===null&&(c=u);return c!==null&&l.push({from:c,to:e.length-1}),{cycles:n,answer:r,segments:l,visible:i}}function vUe(e){switch(e){case"peer":return"Peer messages";case"wake":return"Wake messages";case"monitor":return"Monitor messages";case"job":return"Job results";default:return"Messages"}}function bUe(e,t,n,r){for(let o=n.from;o<=n.to;o+=1)if(e[o].kind==="user")return{kind:"steered"};if(r!=null)return{kind:"group",family:r.family};const i=t.find(o=>o.start<=n.to&&n.to<=o.closeIndex);let a=i?.initiators.at(-1)??null;if(i===void 0){const o=t.filter(s=>s.closeIndex<n.from);for(let s=(o.at(-1)?.closeIndex??-1)+1;s<=n.to&&e[s].kind!=="tool";s+=1)a=pp(e[s])??a}switch(a){case"wake":case"monitor_prompt":return{kind:"wake"};case"peer":case"hub_message":return{kind:"peer"};case"job_result":return{kind:"job"};default:for(let o=n.from;o<=n.to;o+=1){const s=e[o].kind;if(s==="ask_response"||s==="ask_timeout")return{kind:"ask"}}return null}}function wUe(e){switch(e?.kind){case"steered":return"Steered";case"wake":return"Wake";case"peer":return"Peer message";case"job":return"Job result";case"ask":return"Ask";case"group":return vUe(e.family);default:return null}}function xUe(e,t,n,r,i,a=null){const o=r??a;if(o===null||!(n.from>o)&&!i&&r!==null||!t.some(O=>O.start<=n.to&&n.to<=O.closeIndex))return!1;const l=e[n.to];if(!(l.kind==="assistant"?!l.streaming:l.kind==="tool"?l.phase==="done":!1))return!1;const u=n.to+1<e.length?e[n.to+1]:null;return u===null||p9(u)!=="terminal"}const SUe=e=>{const t=e.split(`
|
|
520
520
|
`),n=t.findIndex(i=>i.trim().length>0);if(n<0)return{headline:e.trim(),rest:null};const r=t.slice(n+1).join(`
|
|
@@ -834,7 +834,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
834
834
|
`))};if(c.from==this.from&&a<this.from?c.from=a:c.to==this.to&&a>this.to&&(c.to=a),c.from==c.to&&!c.insert.length){let u=Ge.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));u.main.eq(i)||t.dispatch({selection:u,userEvent:"select"});return}if((ct.mac||ct.android)&&c.from==o-1&&/^\. ?$/.test(r.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:s,to:l,insert:Wn.of([r.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);RA(t,c,Ge.single(this.toEditorPos(r.selectionStart,u),this.toEditorPos(r.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state))},this.handlers.characterboundsupdate=r=>{let i=[],a=null;for(let o=this.toEditorPos(r.rangeStart),s=this.toEditorPos(r.rangeEnd);o<s;o++){let l=t.coordsForChar(o);a=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||a||new DOMRect,i.push(a)}n.updateCharacterBounds(r.rangeStart,i)},this.handlers.textformatupdate=r=>{let i=[];for(let a of r.getTextFormats()){let o=a.underlineStyle,s=a.underlineThickness;if(o!="None"&&s!="None"){let l=this.toEditorPos(a.rangeStart),c=this.toEditorPos(a.rangeEnd);if(l<c){let u=`text-decoration: underline ${o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${s=="Thin"?1:2}px`;i.push(nn.mark({attributes:{style:u}}).range(l,c))}}}t.dispatch({effects:mpe.of(nn.set(i))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(t.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{this.editContext.updateControlBounds(r.contentDOM.getBoundingClientRect());let i=C$(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let n=0,r=!1,i=this.pendingContextChange;return t.changes.iterChanges((a,o,s,l,c)=>{if(r)return;let u=c.length-(o-a);if(i&&o>=i.to)if(i.from==a&&i.to==o&&i.insert.eq(c)){i=this.pendingContextChange=null,n+=u,this.to+=u;return}else i=null,this.revertPending(t.state);if(a+=n,o+=n,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+c.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(o),c.toString()),this.to+=u}n+=u}),i&&!r&&this.revertPending(t.state),!r}update(t){let n=this.pendingContextChange,r=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(r.from,r.to)&&t.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||n)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:n}=t.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(t.doc.length,n+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),t.doc.sliceString(n.from,n.to))}setSelection(t){let{main:n}=t.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),i=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(t){let{head:n}=t.selection.main;return!(this.from>0&&n-this.from<500||this.to<t.doc.length&&this.to-n<500||this.to-this.from>1e4*3)}toEditorPos(t,n=this.to-this.from){t=Math.min(t,n);let r=this.composing;return r&&r.drifted?r.editorBase+(t-r.contextBase):t+this.from}toContextPos(t){let n=this.composing;return n&&n.drifted?n.contextBase+(t-n.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class xt{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 n;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&&(i=>i.forEach(a=>r(a,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=t.root||vKe(t.parent)||document,this.viewState=new PD(t.state||Rn.create(t)),t.scrollTo&&t.scrollTo.is(jb)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(jh).map(i=>new rT(i));for(let i of this.plugins)i.update(this);this.observer=new UJe(this),this.inputState=new sJe(this),this.inputState.ensureHandlers(this.plugins),this.docView=new cD(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...t){let n=t.length==1&&t[0]instanceof Gi?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(n,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,i,a=this.state;for(let d of t){if(d.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=d.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,l=null;t.some(d=>d.annotation(Tpe))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=Xpe(a,o),l||(s=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(Rn.phrases)!=this.state.facet(Rn.phrases))return this.setState(a);i=zx.create(this,a,t),i.flags|=s;let O=this.viewState.scrollTarget;try{this.updateState=2;for(let d of t){if(O&&(O=O.map(d.changes)),d.scrollIntoView){let{main:h}=d.state.selection;O=new Bh(h.empty?h:Ge.cursor(h.head,h.head>h.anchor?-1:1))}for(let h of d.effects)h.is(jb)&&(O=h.value.clip(this.state))}this.viewState.update(i,O),this.bidiCache=Ux.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(s0)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(d=>d.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(Nb)!=i.state.facet(Nb)&&(this.viewState.mustMeasureContent=!0),(n||r||O||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let d of this.state.facet(S3))try{d(i)}catch(h){Ya(this.state,h,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!xpe(this,u)&&c.force&&Fh(this.contentDOM,c.key,c.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 n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new PD(t),this.plugins=t.facet(jh).map(r=>new rT(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new cD(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(t){let n=t.startState.facet(jh),r=t.state.facet(jh);if(n!=r){let i=[];for(let a of r){let o=n.indexOf(a);if(o<0)i.push(new rT(a));else{let s=this.plugins[o];s.mustUpdate=t,i.push(s)}}for(let a of this.plugins)a.mustUpdate!=t&&a.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=t;for(let i=0;i<this.plugins.length;i++)this.plugins[i].update(this);n!=r&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let n=t.value;if(n&&n.docViewUpdate)try{n.docViewUpdate(this)}catch(r){Ya(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 n=null,r=this.scrollDOM,i=r.scrollTop*this.scaleY,{scrollAnchorPos:a,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let s=0;;s++){if(o<0)if(Ihe(r))a=-1,o=this.viewState.heightMap.height;else{let h=this.viewState.scrollAnchorAt(i);a=h.from,o=h.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(s>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(h=>{try{return h.read(this)}catch(p){return Ya(this.state,p),ED}}),O=zx.create(this,this.state,[]),d=!1;O.flags|=l,n?n.flags|=l:n=O,this.updateState=2,O.empty||(this.updatePlugins(O),this.inputState.update(O),this.updateAttrs(),d=this.docView.update(O),d&&this.docViewUpdate());for(let h=0;h<c.length;h++)if(u[h]!=ED)try{let p=c[h];p.write&&p.write(u[h],this)}catch(p){Ya(this.state,p)}if(d&&this.docView.updateSelection(!0),!O.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let p=(a<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(a).top)-o;if(p>1||p<-1){i=i+p,r.scrollTop=i/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let s of this.state.facet(S3))s(n)}get themeClasses(){return T3+" "+(this.state.facet(P3)?jpe:qpe)+" "+this.state.facet(Nb)}updateAttrs(){let t=qD(this,gpe,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(vc)?"true":"false",class:"cm-content",style:`${ct.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),qD(this,PA,n);let r=this.observer.ignore(()=>{let i=y3(this.contentDOM,this.contentAttrs,n),a=y3(this.dom,this.editorAttrs,t);return i||a});return this.editorAttrs=t,this.contentAttrs=n,r}showAnnouncements(t){let n=!0;for(let r of t)for(let i of r.effects)if(i.is(xt.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(s0);let t=this.state.facet(xt.cspNonce);fO.mount(this.root,this.styleModules.concat(zJe).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 n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===t.key){this.measureRequests[n]=t;return}}this.measureRequests.push(t)}}plugin(t){let n=this.pluginMap.get(t);return(n===void 0||n&&n.plugin!=t)&&this.pluginMap.set(t,n=this.plugins.find(r=>r.plugin==t)||null),n&&n.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,n,r){return aT(this,t,hD(this,t,n,r))}moveByGroup(t,n){return aT(this,t,hD(this,t,n,r=>KKe(this,t.head,r)))}visualLineSide(t,n){let r=this.bidiSpans(t),i=this.textDirectionAt(t.from),a=r[n?r.length-1:0];return Ge.cursor(a.side(n,i)+t.from,a.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return HKe(this,t,n,r)}moveVertically(t,n,r){return aT(this,t,JKe(this,t,n,r))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,n=0){return this.docView.posFromDOM(t,n)}posAtCoords(t,n=!0){return this.readMeasured(),wpe(this,t,n)}coordsAtPos(t,n=1){this.readMeasured();let r=this.docView.coordsAt(t,n);if(!r||r.left==r.right)return r;let i=this.state.doc.lineAt(t),a=this.bidiSpans(i),o=a[Du.find(a,t-i.from,-1,n)];return dv(r,o.dir==yr.LTR==n>0)}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(fpe)||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>YJe)return ape(t.length);let n=this.textDirectionAt(t.from),r;for(let a of this.bidiCache)if(a.from==t.from&&a.dir==n&&(a.fresh||ipe(a.isolates,r=lD(this,t))))return a.order;r||(r=lD(this,t));let i=CKe(t.text,n,r);return this.bidiCache.push(new Ux(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||ct.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Ghe(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,n={}){return jb.of(new Bh(typeof t=="number"?Ge.cursor(t):t,n.y,n.x,n.yMargin,n.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(t);return jb.of(new Bh(Ge.cursor(r.from),"start","start",r.top-t,n,!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 pi.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return pi.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=fO.newName(),i=[Nb.of(r),s0.of(X3(`.${r}`,t))];return n&&n.dark&&i.push(P3.of(!0)),i}static baseTheme(t){return QO.lowest(s0.of(X3("."+T3,t,Cpe)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&Hn.get(r)||Hn.get(t);return((n=i?.rootView)===null||n===void 0?void 0:n.view)||null}}xt.styleModule=s0;xt.inputHandler=Ope;xt.clipboardInputFilter=kA;xt.clipboardOutputFilter=_A;xt.scrollHandler=ppe;xt.focusChangeEffect=dpe;xt.perLineTextDirection=fpe;xt.exceptionSink=upe;xt.updateListener=S3;xt.editable=vc;xt.mouseSelectionStyle=cpe;xt.dragMovesSelection=lpe;xt.clickAddsSelectionRange=spe;xt.decorations=z$;xt.outerDecorations=$pe;xt.atomicRanges=TA;xt.bidiIsolatedRanges=ype;xt.scrollMargins=vpe;xt.darkTheme=P3;xt.cspNonce=dt.define({combine:e=>e.length?e[0]:""});xt.contentAttributes=PA;xt.editorAttributes=gpe;xt.lineWrapping=xt.contentAttributes.of({class:"cm-lineWrapping"});xt.announce=vn.define();const YJe=4096,ED={};class Ux{constructor(t,n,r,i,a,o){this.from=t,this.to=n,this.dir=r,this.isolates=i,this.fresh=a,this.order=o}static update(t,n){if(n.empty&&!t.some(a=>a.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:yr.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let o=t[a];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new Ux(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}}function qD(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let a=r[i],o=typeof a=="function"?a(e):a;o&&$3(o,n)}return n}const GJe=ct.mac?"mac":ct.windows?"win":ct.linux?"linux":"key";function ZJe(e,t){const n=e.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,a,o,s;for(let l=0;l<n.length-1;++l){const c=n[l];if(/^(cmd|meta|m)$/i.test(c))s=!0;else if(/^a(lt)?$/i.test(c))i=!0;else if(/^(c|ctrl|control)$/i.test(c))a=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))t=="mac"?s=!0:a=!0;else throw new Error("Unrecognized modifier name: "+c)}return i&&(r="Alt-"+r),a&&(r="Ctrl-"+r),s&&(r="Meta-"+r),o&&(r="Shift-"+r),r}function Yb(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n!==!1&&t.shiftKey&&(e="Shift-"+e),e}const IJe=QO.default(xt.domEventHandlers({keydown(e,t){return Ape(zpe(t.state),e,t,"editor")}})),_k=dt.define({enables:IJe}),jD=new WeakMap;function zpe(e){let t=e.facet(_k),n=jD.get(t);return n||jD.set(t,n=VJe(t.reduce((r,i)=>r.concat(i),[]))),n}function Esn(e,t,n){return Ape(zpe(e.state),t,e,n)}let Wu=null;const DJe=4e3;function VJe(e,t=GJe){let n=Object.create(null),r=Object.create(null),i=(o,s)=>{let l=r[o];if(l==null)r[o]=s;else if(l!=s)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},a=(o,s,l,c,u)=>{var O,d;let h=n[o]||(n[o]=Object.create(null)),p=s.split(/ (?!$)/).map(v=>ZJe(v,t));for(let v=1;v<p.length;v++){let b=p.slice(0,v).join(" ");i(b,!0),h[b]||(h[b]={preventDefault:!0,stopPropagation:!1,run:[x=>{let Q=Wu={view:x,prefix:b,scope:o};return setTimeout(()=>{Wu==Q&&(Wu=null)},DJe),!0}]})}let g=p.join(" ");i(g,!1);let y=h[g]||(h[g]={preventDefault:!1,stopPropagation:!1,run:((d=(O=h._any)===null||O===void 0?void 0:O.run)===null||d===void 0?void 0:d.slice())||[]});l&&y.run.push(l),c&&(y.preventDefault=!0),u&&(y.stopPropagation=!0)};for(let o of e){let s=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of s){let u=n[c]||(n[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:O}=o;for(let d in u)u[d].run.push(h=>O(h,R3))}let l=o[t]||o.key;if(l)for(let c of s)a(c,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&a(c,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return n}let R3=null;function Ape(e,t,n,r){R3=t;let i=pKe(t),a=mo(i,0),o=yc(a)==i.length&&i!=" ",s="",l=!1,c=!1,u=!1;Wu&&Wu.view==n&&Wu.scope==r&&(s=Wu.prefix+" ",Qpe.indexOf(t.keyCode)<0&&(c=!0,Wu=null));let O=new Set,d=y=>{if(y){for(let v of y.run)if(!O.has(v)&&(O.add(v),v(n)))return y.stopPropagation&&(u=!0),!0;y.preventDefault&&(y.stopPropagation&&(u=!0),c=!0)}return!1},h=e[r],p,g;return h&&(d(h[s+Yb(i,t,!o)])?l=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(ct.windows&&t.ctrlKey&&t.altKey)&&(p=hO[t.keyCode])&&p!=i?(d(h[s+Yb(p,t,!0)])||t.shiftKey&&(g=j$[t.keyCode])!=i&&g!=p&&d(h[s+Yb(g,t,!1)]))&&(l=!0):o&&t.shiftKey&&d(h[s+Yb(i,t,!0)])&&(l=!0),!l&&d(h._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),R3=null,l}class pv{constructor(t,n,r,i,a){this.className=t,this.left=n,this.top=r,this.width=i,this.height=a}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,n){return n.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,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let a=Upe(t);return[new pv(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return MJe(t,n,r)}}function Upe(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==yr.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function CD(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let a=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,s=e.posAtCoords({x:a.left+1,y:o}),l=e.posAtCoords({x:a.right-1,y:o});return s==null||l==null?r:{from:Math.max(r.from,Math.min(s,l)),to:Math.min(r.to,Math.max(s,l))}}function MJe(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),a=e.textDirection==yr.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),l=Upe(e),c=o.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),O=s.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),d=s.right-(u?parseInt(u.paddingRight):0),h=k3(e,r,1),p=k3(e,i,-1),g=h.type==xa.Text?h:null,y=p.type==xa.Text?p:null;if(g&&(e.lineWrapping||h.widgetLineBreaks)&&(g=CD(e,r,1,g)),y&&(e.lineWrapping||p.widgetLineBreaks)&&(y=CD(e,i,-1,y)),g&&y&&g.from==y.from&&g.to==y.to)return b(x(n.from,n.to,g));{let w=g?x(n.from,null,g):Q(h,!1),S=y?x(null,n.to,y):Q(p,!0),k=[];return(g||h).to<(y||p).from-(g&&y?1:0)||h.widgetLineBreaks>1&&w.bottom+e.defaultLineHeight/2<S.top?k.push(v(O,w.bottom,d,S.top)):w.bottom<S.top&&e.elementAtHeight((w.bottom+S.top)/2).type==xa.Text&&(w.bottom=S.top=(w.bottom+S.top)/2),b(w).concat(k).concat(b(S))}function v(w,S,k,P){return new pv(t,w-l.left,S-l.top,k-w,P-S)}function b({top:w,bottom:S,horizontal:k}){let P=[];for(let R=0;R<k.length;R+=2)P.push(v(k[R],w,k[R+1],S));return P}function x(w,S,k){let P=1e9,R=-1e9,T=[];function q(N,A,Y,W,Z){let D=e.coordsAtPos(N,N==k.to?-2:2),z=e.coordsAtPos(Y,Y==k.from?2:-2);!D||!z||(P=Math.min(D.top,z.top,P),R=Math.max(D.bottom,z.bottom,R),Z==yr.LTR?T.push(a&&A?O:D.left,a&&W?d:z.right):T.push(!a&&W?O:z.left,!a&&A?d:D.right))}let X=w??k.from,C=S??k.to;for(let N of e.visibleRanges)if(N.to>X&&N.from<C)for(let A=Math.max(N.from,X),Y=Math.min(N.to,C);;){let W=e.state.doc.lineAt(A);for(let Z of e.bidiSpans(W)){let D=Z.from+W.from,z=Z.to+W.from;if(D>=Y)break;z>A&&q(Math.max(D,A),w==null&&D<=X,Math.min(z,Y),S==null&&z>=C,Z.dir)}if(A=W.to+1,A>=Y)break}return T.length==0&&q(X,w==null,C,S==null,e.textDirection),{top:P,bottom:R,horizontal:T}}function Q(w,S){let k=s.top+(S?w.top:w.bottom);return{top:k,bottom:k,horizontal:[]}}}function LJe(e,t){return e.constructor==t.constructor&&e.eq(t)}class FJe{constructor(t,n){this.view=t,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,t)}update(t){t.startState.facet(b1)!=t.state.facet(b1)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){this.layer.updateOnDocViewUpdate!==!1&&t.requestMeasure(this.measureReq)}setOrder(t){let n=0,r=t.facet(b1);for(;n<r.length&&r[n]!=this.layer;)n++;this.dom.style.zIndex=String((this.layer.above?150:-1)-n)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:n}=this.view;(t!=this.scaleX||n!=this.scaleY)&&(this.scaleX=t,this.scaleY=n,this.dom.style.transform=`scale(${1/t}, ${1/n})`)}draw(t){if(t.length!=this.drawn.length||t.some((n,r)=>!LJe(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let i of t)i.update&&n&&i.constructor&&this.drawn[r].constructor&&i.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(i.draw(),n);for(;n;){let i=n.nextSibling;n.remove(),n=i}this.drawn=t}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const b1=dt.define();function Wpe(e){return[pi.define(t=>new FJe(t,e)),b1.of(e)]}const A$=dt.define({combine(e){return km(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function qsn(e={}){return[A$.of(e),BJe,HJe,KJe,hpe.of(!0)]}function Npe(e){return e.startState.facet(A$)!=e.state.facet(A$)}const BJe=Wpe({above:!0,markers(e){let{state:t}=e,n=t.facet(A$),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor){let o=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",s=i.empty?i:Ge.cursor(i.head,i.head>i.anchor?-1:1);for(let l of pv.forRange(e,o,s))r.push(l)}}return r},update(e,t){e.transactions.some(r=>r.selection)&&(t.style.animationName=t.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Npe(e);return n&&zD(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){zD(t.state,e)},class:"cm-cursorLayer"});function zD(e,t){t.style.animationDuration=e.facet(A$).cursorBlinkRate+"ms"}const HJe=Wpe({above:!1,markers(e){return e.state.selection.ranges.map(t=>t.empty?[]:pv.forRange(e,"cm-selectionBackground",t)).reduce((t,n)=>t.concat(n))},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||Npe(e)},class:"cm-selectionLayer"}),KJe=QO.highest(xt.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Ype=vn.define({map(e,t){return e==null?null:t.mapPos(e)}}),u0=La.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(Ype)?r.value:n,e)}}),JJe=pi.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 n=e.state.field(u0);n==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(u0)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(u0),n=t!=null&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(u0)!=e&&this.view.dispatch({effects:Ype.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 jsn(){return[u0,JJe]}function AD(e,t,n,r,i){t.lastIndex=0;for(let a=e.iterRange(n,r),o=n,s;!a.next().done;o+=a.value.length)if(!a.lineBreak)for(;s=t.exec(a.value);)i(o+s.index,s)}function eet(e,t){let n=e.visibleRanges;if(n.length==1&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let r=[];for(let{from:i,to:a}of n)i=Math.max(e.state.doc.lineAt(i).from,i-t),a=Math.min(e.state.doc.lineAt(a).to,a+t),r.length&&r[r.length-1].to>=i?r[r.length-1].to=a:r.push({from:i,to:a});return r}class tet{constructor(t){const{regexp:n,decoration:r,decorate:i,boundary:a,maxLength:o=1e3}=t;if(!n.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=n,i)this.addMatch=(s,l,c,u)=>i(u,c,c+s[0].length,s,l);else if(typeof r=="function")this.addMatch=(s,l,c,u)=>{let O=r(s,l,c);O&&u(c,c+s[0].length,O)};else if(r)this.addMatch=(s,l,c,u)=>u(c,c+s[0].length,r);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=a,this.maxLength=o}createDeco(t){let n=new Md,r=n.add.bind(n);for(let{from:i,to:a}of eet(t,this.maxLength))AD(t.state.doc,this.regexp,i,a,(o,s)=>this.addMatch(s,t,o,r));return n.finish()}updateDeco(t,n){let r=1e9,i=-1;return t.docChanged&&t.changes.iterChanges((a,o,s,l)=>{l>=t.view.viewport.from&&s<=t.view.viewport.to&&(r=Math.min(s,r),i=Math.max(l,i))}),t.viewportMoved||i-r>1e3?this.createDeco(t.view):i>-1?this.updateRange(t.view,n.map(t.changes),r,i):n}updateRange(t,n,r,i){for(let a of t.visibleRanges){let o=Math.max(a.from,r),s=Math.min(a.to,i);if(s>=o){let l=t.state.doc.lineAt(o),c=l.to<s?t.state.doc.lineAt(s):l,u=Math.max(a.from,l.from),O=Math.min(a.to,c.to);if(this.boundary){for(;o>l.from;o--)if(this.boundary.test(l.text[o-1-l.from])){u=o;break}for(;s<c.to;s++)if(this.boundary.test(c.text[s-c.from])){O=s;break}}let d=[],h,p=(g,y,v)=>d.push(v.range(g,y));if(l==c)for(this.regexp.lastIndex=u-l.from;(h=this.regexp.exec(l.text))&&h.index<O-l.from;)this.addMatch(h,t,h.index+l.from,p);else AD(t.state.doc,this.regexp,u,O,(g,y)=>this.addMatch(y,t,g,p));n=n.update({filterFrom:u,filterTo:O,filter:(g,y)=>g<u||y>O,add:d})}}return n}}const E3=/x/.unicode!=null?"gu":"g",net=new RegExp(`[\0-\b
|
|
835
835
|
--\u2028\u2029\uFEFF-]`,E3),ret={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"};let lT=null;function iet(){var e;if(lT==null&&typeof document<"u"&&document.body){let t=document.body.style;lT=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return lT||!1}const w1=dt.define({combine(e){let t=km(e,{render:null,specialChars:net,addSpecialChars:null});return(t.replaceTabs=!iet())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,E3)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,E3)),t}});function Csn(e={}){return[w1.of(e),aet()]}let UD=null;function aet(){return UD||(UD=pi.fromClass(class{constructor(e){this.view=e,this.decorations=nn.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(w1)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new tet({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,a=mo(t[0],0);if(a==9){let o=i.lineAt(r),s=n.state.tabSize,l=dO(o.text,s,r-o.from);return nn.replace({widget:new uet((s-l%s)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=nn.replace({widget:new cet(e,a)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(w1);e.startState.facet(w1)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))}const oet="•";function set(e){return e>=32?oet:e==10?"":String.fromCharCode(9216+e)}class cet extends au{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=set(this.code),r=t.state.phrase("Control character")+" "+(ret[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,r,n);if(i)return i;let a=document.createElement("span");return a.textContent=n,a.title=r,a.setAttribute("aria-label",r),a.className="cm-specialChar",a}ignoreEvent(){return!1}}class uet extends au{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent=" ",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}function zsn(){return det}const Oet=nn.line({class:"cm-activeLine"}),det=pi.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,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(Oet.range(i.from)),t=i.from)}return nn.set(n)}},{decorations:e=>e.decorations});class fet extends au{constructor(t){super(),this.content=t}toDOM(t){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(t):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(t){let n=t.firstChild?Sp(t.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(t.parentNode),i=dv(n[0],r.direction!="rtl"),a=parseInt(r.lineHeight);return i.bottom-i.top>a*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+a}:i}ignoreEvent(){return!1}}function Asn(e){let t=pi.fromClass(class{constructor(n){this.view=n,this.placeholder=e?nn.set([nn.widget({widget:new fet(e),side:1}).range(0)]):nn.none}get decorations(){return this.view.state.doc.length?nn.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,xt.contentAttributes.of({"aria-placeholder":e})]:t}const q3=2e3;function het(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>q3||n.off>q3||t.col<0||n.col<0){let o=Math.min(t.off,n.off),s=Math.max(t.off,n.off);for(let l=r;l<=i;l++){let c=e.doc.line(l);c.length<=s&&a.push(Ge.range(c.from+o,c.to+s))}}else{let o=Math.min(t.col,n.col),s=Math.max(t.col,n.col);for(let l=r;l<=i;l++){let c=e.doc.line(l),u=O3(c.text,o,e.tabSize,!0);if(u<0)a.push(Ge.cursor(c.to));else{let O=O3(c.text,s,e.tabSize);a.push(Ge.range(c.from+u,c.from+O))}}}return a}function pet(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function WD(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,a=i>q3?-1:i==r.length?pet(e,t.clientX):dO(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function met(e,t){let n=WD(e,t),r=e.state.selection;return n?{update(i){if(i.docChanged){let a=i.changes.mapPos(i.startState.doc.line(n.line).from),o=i.state.doc.lineAt(a);n={line:o.number,col:n.col,off:Math.min(n.off,o.length)},r=r.map(i.changes)}},get(i,a,o){let s=WD(e,i);if(!s)return r;let l=het(e.state,n,s);return l.length?o?Ge.create(l.concat(r.ranges)):Ge.create(l):r}}:null}function Usn(e){let t=n=>n.altKey&&n.button==0;return xt.mouseSelectionStyle.of((n,r)=>t(r)?met(n,r):null)}const get={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},$et={style:"cursor: crosshair"};function Wsn(e={}){let[t,n]=get[e.key||"Alt"],r=pi.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventObservers:{keydown(i){this.set(i.keyCode==t||n(i))},keyup(i){(i.keyCode==t||!n(i))&&this.set(!1)},mousemove(i){this.set(n(i))}}});return[r,xt.contentAttributes.of(i=>{var a;return!((a=i.plugin(r))===null||a===void 0)&&a.isDown?$et:null})]}const yg="-10000px";class Gpe{constructor(t,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=t.state.facet(n),this.tooltips=this.input.filter(o=>o);let a=null;this.tooltipViews=this.tooltips.map(o=>a=r(o,a))}update(t,n){var r;let i=t.state.facet(this.facet),a=i.filter(l=>l);if(i===this.input){for(let l of this.tooltipViews)l.update&&l.update(t);return!1}let o=[],s=n?[]:null;for(let l=0;l<a.length;l++){let c=a[l],u=-1;if(c){for(let O=0;O<this.tooltips.length;O++){let d=this.tooltips[O];d&&d.create==c.create&&(u=O)}if(u<0)o[l]=this.createTooltipView(c,l?o[l-1]:null),s&&(s[l]=!!c.above);else{let O=o[l]=this.tooltipViews[u];s&&(s[l]=n[u]),O.update&&O.update(t)}}}for(let l of this.tooltipViews)o.indexOf(l)<0&&(this.removeTooltipView(l),(r=l.destroy)===null||r===void 0||r.call(l));return n&&(s.forEach((l,c)=>n[c]=l),n.length=s.length),this.input=i,this.tooltips=a,this.tooltipViews=o,!0}}function yet(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const cT=dt.define({combine:e=>{var t,n,r;return{position:ct.ios?"absolute":((t=e.find(i=>i.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((n=e.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=e.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||yet}}}),ND=new WeakMap,jA=pi.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(cT);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 Gpe(e,CA,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.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 n=t||e.geometryChanged,r=e.state.facet(cT);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=yg,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;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(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:a}=this.manager.tooltipViews[0];if(ct.gecko)n=a.offsetParent!=this.container.ownerDocument.body;else if(a.style.top==yg&&a.style.left=="0px"){let o=a.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}}if(n||this.position=="absolute")if(this.parent){let a=this.parent.getBoundingClientRect();a.width&&a.height&&(e=a.width/this.parent.offsetWidth,t=a.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=XA(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((a,o)=>{let s=this.manager.tooltipViews[o];return s.getCoords?s.getCoords(a.pos):this.view.coordsAtPos(a.pos)}),size:this.manager.tooltipViews.map(({dom:a})=>a.getBoundingClientRect()),space:this.view.state.facet(cT).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let s of this.manager.tooltipViews)s.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:a}=e,o=[];for(let s=0;s<this.manager.tooltips.length;s++){let l=this.manager.tooltips[s],c=this.manager.tooltipViews[s],{dom:u}=c,O=e.pos[s],d=e.size[s];if(!O||l.clip!==!1&&(O.bottom<=Math.max(n.top,r.top)||O.top>=Math.min(n.bottom,r.bottom)||O.right<Math.max(n.left,r.left)-.1||O.left>Math.min(n.right,r.right)+.1)){u.style.top=yg;continue}let h=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=h?7:0,g=d.right-d.left,y=(t=ND.get(c))!==null&&t!==void 0?t:d.bottom-d.top,v=c.offset||bet,b=this.view.textDirection==yr.LTR,x=d.width>r.right-r.left?b?r.left:r.right-d.width:b?Math.max(r.left,Math.min(O.left-(h?14:0)+v.x,r.right-g)):Math.min(Math.max(r.left,O.left-g+(h?14:0)-v.x),r.right-g),Q=this.above[s];!l.strictSide&&(Q?O.top-y-p-v.y<r.top:O.bottom+y+p+v.y>r.bottom)&&Q==r.bottom-O.bottom>O.top-r.top&&(Q=this.above[s]=!Q);let w=(Q?O.top-r.top:r.bottom-O.bottom)-p;if(w<y&&c.resize!==!1){if(w<this.view.defaultLineHeight){u.style.top=yg;continue}ND.set(c,y),u.style.height=(y=w)/a+"px"}else u.style.height&&(u.style.height="");let S=Q?O.top-y-p-v.y:O.bottom+p+v.y,k=x+g;if(c.overlap!==!0)for(let P of o)P.left<k&&P.right>x&&P.top<S+y&&P.bottom>S&&(S=Q?P.top-y-2-p:P.bottom+p+2);if(this.position=="absolute"?(u.style.top=(S-e.parent.top)/a+"px",YD(u,(x-e.parent.left)/i)):(u.style.top=S/a+"px",YD(u,x/i)),h){let P=O.left+(b?v.x:-v.x)-(x+14-7);h.style.left=P/i+"px"}c.overlap!==!0&&o.push({left:x,top:S,right:k,bottom:S+y}),u.classList.toggle("cm-tooltip-above",Q),u.classList.toggle("cm-tooltip-below",!Q),c.positioned&&c.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=yg}},{eventObservers:{scroll(){this.maybeMeasure()}}});function YD(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const vet=xt.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:`${7*2}px`,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"}}}),bet={x:0,y:0},CA=dt.define({enables:[jA,vet]}),Wx=dt.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class Pk{static create(t){return new Pk(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Gpe(t,Wx,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(t,n){let r=t.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(t){for(let n of this.manager.tooltipViews)n.mount&&n.mount(t);this.mounted=!0}positioned(t){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let n of this.manager.tooltipViews)(t=n.destroy)===null||t===void 0||t.call(n)}passProp(t){let n;for(let r of this.manager.tooltipViews){let i=r[t];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const wet=CA.compute([Wx],e=>{let t=e.facet(Wx);return t.length===0?null:{pos:Math.min(...t.map(n=>n.pos)),end:Math.max(...t.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:Pk.create,above:t[0].above,arrow:t.some(n=>n.arrow)}});class xet{constructor(t,n,r,i,a){this.view=t,this.source=n,this.field=r,this.setHover=i,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){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 t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:n}=this,r=t.docView.nearest(n.target);if(!r)return;let i,a=1;if(r instanceof Iu)i=r.posAtStart;else{if(i=t.posAtCoords(n),i==null)return;let s=t.coordsAtPos(i);if(!s||n.y<s.top||n.y>s.bottom||n.x<s.left-t.defaultCharacterWidth||n.x>s.right+t.defaultCharacterWidth)return;let l=t.bidiSpans(t.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),c=l&&l.dir==yr.RTL?-1:1;a=n.x<s.left?-c:c}let o=this.source(t,i,a);if(o?.then){let s=this.pending={pos:i};o.then(l=>{this.pending==s&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>Ya(t.state,l,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let t=this.view.plugin(jA),n=t?t.manager.tooltips.findIndex(r=>r.create==Pk.create):-1;return n>-1?t.manager.tooltipViews[n]:null}mousemove(t){var n,r;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:a}=this;if(i.length&&a&&!Qet(a.dom,t)||this.pending){let{pos:o}=i[0]||this.pending,s=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:o;(o==s?this.view.posAtCoords(this.lastMove)!=o:!ket(this.view,o,s,t.clientX,t.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length){let{tooltip:r}=this;r&&r.dom.contains(t.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let n=r=>{t.removeEventListener("mouseleave",n),this.active.length&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Gb=4;function Qet(e,t){let{left:n,right:r,top:i,bottom:a}=e.getBoundingClientRect(),o;if(o=e.querySelector(".cm-tooltip-arrow")){let s=o.getBoundingClientRect();i=Math.min(s.top,i),a=Math.max(s.bottom,a)}return t.clientX>=n-Gb&&t.clientX<=r+Gb&&t.clientY>=i-Gb&&t.clientY<=a+Gb}function ket(e,t,n,r,i,a){let o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>r||o.right<r||o.top>i||Math.min(o.bottom,s)<i)return!1;let l=e.posAtCoords({x:r,y:i},!1);return l>=t&&l<=n}function Nsn(e,t={}){let n=vn.define(),r=La.define({create(){return[]},update(i,a){if(i.length&&(t.hideOnChange&&(a.docChanged||a.selection)?i=[]:t.hideOn&&(i=i.filter(o=>!t.hideOn(a,o))),a.docChanged)){let o=[];for(let s of i){let l=a.changes.mapPos(s.pos,-1,Yi.TrackDel);if(l!=null){let c=Object.assign(Object.create(null),s);c.pos=l,c.end!=null&&(c.end=a.changes.mapPos(c.end)),o.push(c)}}i=o}for(let o of a.effects)o.is(n)&&(i=o.value),o.is(_et)&&(i=[]);return i},provide:i=>Wx.from(i)});return{active:r,extension:[r,pi.define(i=>new xet(i,e,r,n,t.hoverTime||300)),wet]}}function Zpe(e,t){let n=e.plugin(jA);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const _et=vn.define(),GD=dt.define({combine(e){let t,n;for(let r of e)t=t||r.topContainer,n=n||r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function Ysn(e,t){let n=e.plugin(Ipe),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const Ipe=pi.fromClass(class{constructor(e){this.input=e.state.facet(ID),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(GD);this.top=new Zb(e,!0,t.topContainer),this.bottom=new Zb(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(e){let t=e.state.facet(GD);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Zb(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Zb(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(ID);if(n!=this.input){let r=n.filter(l=>l),i=[],a=[],o=[],s=[];for(let l of r){let c=this.specs.indexOf(l),u;c<0?(u=l(e.view),s.push(u)):(u=this.panels[c],u.update&&u.update(e)),i.push(u),(u.top?a:o).push(u)}this.specs=r,this.panels=i,this.top.sync(a),this.bottom.sync(o);for(let l of s)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let r of this.panels)r.update&&r.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>xt.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class Zb{constructor(t,n,r){this.view=t,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let n of this.panels)n.destroy&&t.indexOf(n)<0&&n.destroy();this.panels=t,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",this.dom.style[this.top?"top":"bottom"]="0";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let t=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;t!=n.dom;)t=ZD(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=ZD(t)}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 t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function ZD(e){let t=e.nextSibling;return e.remove(),t}const ID=dt.define({enables:Ipe});class Vc extends Vd{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Vc.prototype.elementClass="";Vc.prototype.toDOM=void 0;Vc.prototype.mapMode=Yi.TrackBefore;Vc.prototype.startSide=Vc.prototype.endSide=-1;Vc.prototype.point=!0;const x1=dt.define(),Pet=dt.define(),Tet={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>yn.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},G0=dt.define();function Xet(e){return[Dpe(),G0.of({...Tet,...e})]}const DD=dt.define({combine:e=>e.some(t=>t)});function Dpe(e){return[Ret]}const Ret=pi.fromClass(class{constructor(e){this.view=e,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(G0).map(t=>new MD(e,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!e.state.facet(DD),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}e.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(DD)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&this.dom.remove();let n=yn.iter(this.view.state.facet(x1),this.view.viewport.from),r=[],i=this.gutters.map(a=>new Eet(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let o=!0;for(let s of a.type)if(s.type==xa.Text&&o){j3(n,r,s.from);for(let l of i)l.line(this.view,s,r);o=!1}else if(s.widget)for(let l of i)l.widget(this.view,s)}else if(a.type==xa.Text){j3(n,r,a.from);for(let o of i)o.line(this.view,a,r)}else if(a.widget)for(let o of i)o.widget(this.view,a);for(let a of i)a.finish();e&&this.view.scrollDOM.insertBefore(this.dom,t)}updateGutters(e){let t=e.startState.facet(G0),n=e.state.facet(G0),r=e.docChanged||e.heightChanged||e.viewportChanged||!yn.eq(e.startState.facet(x1),e.state.facet(x1),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let i of this.gutters)i.update(e)&&(r=!0);else{r=!0;let i=[];for(let a of n){let o=t.indexOf(a);o<0?i.push(new MD(this.view,a)):(this.gutters[o].update(e),i.push(this.gutters[o]))}for(let a of this.gutters)a.dom.remove(),i.indexOf(a)<0&&a.destroy();for(let a of i)this.dom.appendChild(a.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove()}},{provide:e=>xt.scrollMargins.of(t=>{let n=t.plugin(e);return!n||n.gutters.length==0||!n.fixed?null:t.textDirection==yr.LTR?{left:n.dom.offsetWidth*t.scaleX}:{right:n.dom.offsetWidth*t.scaleX}})});function VD(e){return Array.isArray(e)?e:[e]}function j3(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class Eet{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=yn.iter(t.markers,n.from)}addElement(t,n,r){let{gutter:i}=this,a=(n.top-this.height)/t.scaleY,o=n.height/t.scaleY;if(this.i==i.elements.length){let s=new Vpe(t,o,a,r);i.elements.push(s),i.dom.appendChild(s.dom)}else i.elements[this.i].update(t,o,a,r);this.height=n.bottom,this.i++}line(t,n,r){let i=[];j3(this.cursor,i,n.from),r.length&&(i=i.concat(r));let a=this.gutter.config.lineMarker(t,n,i);a&&i.unshift(a);let o=this.gutter;i.length==0&&!o.config.renderEmptyElements||this.addElement(t,n,i)}widget(t,n){let r=this.gutter.config.widgetMarker(t,n.widget,n),i=r?[r]:null;for(let a of t.state.facet(Pet)){let o=a(t,n.widget,n);o&&(i||(i=[])).push(o)}i&&this.addElement(t,n,i)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let n=t.elements.pop();t.dom.removeChild(n.dom),n.destroy()}}}class MD{constructor(t,n){this.view=t,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,i=>{let a=i.target,o;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let l=a.getBoundingClientRect();o=(l.top+l.bottom)/2}else o=i.clientY;let s=t.lineBlockAtHeight(o-t.documentTop);n.domEventHandlers[r](t,s,i)&&i.preventDefault()});this.markers=VD(n.markers(t)),n.initialSpacer&&(this.spacer=new Vpe(t,0,0,[n.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let n=this.markers;if(this.markers=VD(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let i=this.config.updateSpacer(this.spacer.markers[0],t);i!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[i])}let r=t.view.viewport;return!yn.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(t):!1)}destroy(){for(let t of this.elements)t.destroy()}}class Vpe{constructor(t,n,r,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,n,r,i)}update(t,n,r,i){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),qet(this.markers,i)||this.setMarkers(t,i)}setMarkers(t,n){let r="cm-gutterElement",i=this.dom.firstChild;for(let a=0,o=0;;){let s=o,l=a<n.length?n[a++]:null,c=!1;if(l){let u=l.elementClass;u&&(r+=" "+u);for(let O=o;O<this.markers.length;O++)if(this.markers[O].compare(l)){s=O,c=!0;break}}else s=this.markers.length;for(;o<s;){let u=this.markers[o++];if(u.toDOM){u.destroy(i);let O=i.nextSibling;i.remove(),i=O}}if(!l)break;l.toDOM&&(c?i=i.nextSibling:this.dom.insertBefore(l.toDOM(t),i)),c&&o++}this.dom.className=r,this.markers=n}destroy(){this.setMarkers(null,[])}}function qet(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}const jet=dt.define(),Cet=dt.define(),Ch=dt.define({combine(e){return km(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,n){let r=Object.assign({},t);for(let i in n){let a=r[i],o=n[i];r[i]=a?(s,l,c)=>a(s,l,c)||o(s,l,c):o}return r}})}});class uT extends Vc{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function OT(e,t){return e.state.facet(Ch).formatNumber(t,e.state)}const zet=G0.compute([Ch],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(jet)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new uT(OT(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(Cet)){let a=i(t,n,r);if(a)return a}return null},lineMarkerChange:t=>t.startState.facet(Ch)!=t.state.facet(Ch),initialSpacer(t){return new uT(OT(t,LD(t.state.doc.lines)))},updateSpacer(t,n){let r=OT(n.view,LD(n.view.state.doc.lines));return r==t.number?t:new uT(r)},domEventHandlers:e.facet(Ch).domEventHandlers}));function Gsn(e={}){return[Ch.of(e),Dpe(),zet]}function LD(e){let t=9;for(;t<e;)t=t*10+9;return t}const Aet=new class extends Vc{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Uet=x1.compute(["selection"],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(Aet.range(i)))}return yn.of(t)});function Zsn(){return Uet}let Wet=0;class tt{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=Wet++}toString(){let{name:t}=this;for(let n of this.modified)n.name&&(t=`${n.name}(${t})`);return t}static define(t,n){let r=typeof t=="string"?t:"?";if(t instanceof tt&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new tt(r,[],null,[]);if(i.set.push(i),n)for(let a of n.set)i.set.push(a);return i}static defineModifier(t){let n=new Nx(t);return r=>r.modified.indexOf(n)>-1?r:Nx.get(r.base||r,r.modified.concat(n).sort((i,a)=>i.id-a.id))}}let Net=0;class Nx{constructor(t){this.name=t,this.instances=[],this.id=Net++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(s=>s.base==t&&Yet(n,s.modified));if(r)return r;let i=[],a=new tt(t.name,i,t,n);for(let s of n)s.instances.push(a);let o=Get(n);for(let s of t.set)if(!s.modified.length)for(let l of o)i.push(Nx.get(s,l));return a}}function Yet(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function Get(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((n,r)=>r.length-n.length)}function kn(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let a=[],o=2,s=i;for(let O=0;;){if(s=="..."&&O>0&&O+3==i.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!d)throw new RangeError("Invalid path: "+i);if(a.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),O+=d[0].length,O==i.length)break;let h=i[O++];if(O==i.length&&h=="!"){o=0;break}if(h!="/")throw new RangeError("Invalid path: "+i);s=i.slice(O)}let l=a.length-1,c=a[l];if(!c)throw new RangeError("Invalid path: "+i);let u=new Yx(r,o,l>0?a.slice(0,l):null);t[c]=u.sort(t[c])}}return Mpe.add(t)}const Mpe=new jt;let Yx=class{constructor(t,n,r,i){this.tags=t,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}};Yx.empty=new Yx([],2,null);function Lpe(e,t){let n=Object.create(null);for(let a of e)if(!Array.isArray(a.tag))n[a.tag.id]=a.class;else for(let o of a.tag)n[o.id]=a.class;let{scope:r,all:i=null}=t||{};return{style:a=>{let o=i;for(let s of a)for(let l of s.set){let c=n[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:r}}function Zet(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function Iet(e,t,n,r=0,i=e.length){let a=new Det(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,"",a.highlighters),a.flush(i)}class Det{constructor(t,n,r){this.at=t,this.highlighters=n,this.span=r,this.class=""}startSpan(t,n){n!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=n)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,n,r,i,a){let{type:o,from:s,to:l}=t;if(s>=r||l<=n)return;o.isTop&&(a=this.highlighters.filter(h=>!h.scope||h.scope(o)));let c=i,u=Vet(t)||Yx.empty,O=Zet(a,u.tags);if(O&&(c&&(c+=" "),c+=O,u.mode==1&&(i+=(i?" ":"")+O)),this.startSpan(Math.max(n,s),c),u.opaque)return;let d=t.tree&&t.tree.prop(jt.mounted);if(d&&d.overlay){let h=t.node.enter(d.overlay[0].from+s,1),p=this.highlighters.filter(y=>!y.scope||y.scope(d.tree.type)),g=t.firstChild();for(let y=0,v=s;;y++){let b=y<d.overlay.length?d.overlay[y]:null,x=b?b.from+s:l,Q=Math.max(n,v),w=Math.min(r,x);if(Q<w&&g)for(;t.from<w&&(this.highlightRange(t,Q,w,i,a),this.startSpan(Math.min(w,t.to),c),!(t.to>=x||!t.nextSibling())););if(!b||x>r)break;v=b.to+s,v>n&&(this.highlightRange(h.cursor(),Math.max(n,b.from+s),Math.min(r,v),"",p),this.startSpan(Math.min(r,v),c))}g&&t.parent()}else if(t.firstChild()){d&&(i="");do if(!(t.to<=n)){if(t.from>=r)break;this.highlightRange(t,n,r,i,a),this.startSpan(Math.min(r,t.to),c)}while(t.nextSibling());t.parent()}}}function Vet(e){let t=e.type.prop(Mpe);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const Je=tt.define,Ib=Je(),Ru=Je(),FD=Je(Ru),BD=Je(Ru),Eu=Je(),Db=Je(Eu),dT=Je(Eu),ll=Je(),KO=Je(ll),rl=Je(),il=Je(),C3=Je(),vg=Je(C3),Vb=Je(),_={comment:Ib,lineComment:Je(Ib),blockComment:Je(Ib),docComment:Je(Ib),name:Ru,variableName:Je(Ru),typeName:FD,tagName:Je(FD),propertyName:BD,attributeName:Je(BD),className:Je(Ru),labelName:Je(Ru),namespace:Je(Ru),macroName:Je(Ru),literal:Eu,string:Db,docString:Je(Db),character:Je(Db),attributeValue:Je(Db),number:dT,integer:Je(dT),float:Je(dT),bool:Je(Eu),regexp:Je(Eu),escape:Je(Eu),color:Je(Eu),url:Je(Eu),keyword:rl,self:Je(rl),null:Je(rl),atom:Je(rl),unit:Je(rl),modifier:Je(rl),operatorKeyword:Je(rl),controlKeyword:Je(rl),definitionKeyword:Je(rl),moduleKeyword:Je(rl),operator:il,derefOperator:Je(il),arithmeticOperator:Je(il),logicOperator:Je(il),bitwiseOperator:Je(il),compareOperator:Je(il),updateOperator:Je(il),definitionOperator:Je(il),typeOperator:Je(il),controlOperator:Je(il),punctuation:C3,separator:Je(C3),bracket:vg,angleBracket:Je(vg),squareBracket:Je(vg),paren:Je(vg),brace:Je(vg),content:ll,heading:KO,heading1:Je(KO),heading2:Je(KO),heading3:Je(KO),heading4:Je(KO),heading5:Je(KO),heading6:Je(KO),contentSeparator:Je(ll),list:Je(ll),quote:Je(ll),emphasis:Je(ll),strong:Je(ll),link:Je(ll),monospace:Je(ll),strikethrough:Je(ll),inserted:Je(),deleted:Je(),changed:Je(),invalid:Je(),meta:Vb,documentMeta:Je(Vb),annotation:Je(Vb),processingInstruction:Je(Vb),definition:tt.defineModifier("definition"),constant:tt.defineModifier("constant"),function:tt.defineModifier("function"),standard:tt.defineModifier("standard"),local:tt.defineModifier("local"),special:tt.defineModifier("special")};for(let e in _){let t=_[e];t instanceof tt&&(t.name=e)}Lpe([{tag:_.link,class:"tok-link"},{tag:_.heading,class:"tok-heading"},{tag:_.emphasis,class:"tok-emphasis"},{tag:_.strong,class:"tok-strong"},{tag:_.keyword,class:"tok-keyword"},{tag:_.atom,class:"tok-atom"},{tag:_.bool,class:"tok-bool"},{tag:_.url,class:"tok-url"},{tag:_.labelName,class:"tok-labelName"},{tag:_.inserted,class:"tok-inserted"},{tag:_.deleted,class:"tok-deleted"},{tag:_.literal,class:"tok-literal"},{tag:_.string,class:"tok-string"},{tag:_.number,class:"tok-number"},{tag:[_.regexp,_.escape,_.special(_.string)],class:"tok-string2"},{tag:_.variableName,class:"tok-variableName"},{tag:_.local(_.variableName),class:"tok-variableName tok-local"},{tag:_.definition(_.variableName),class:"tok-variableName tok-definition"},{tag:_.special(_.variableName),class:"tok-variableName2"},{tag:_.definition(_.propertyName),class:"tok-propertyName tok-definition"},{tag:_.typeName,class:"tok-typeName"},{tag:_.namespace,class:"tok-namespace"},{tag:_.className,class:"tok-className"},{tag:_.macroName,class:"tok-macroName"},{tag:_.propertyName,class:"tok-propertyName"},{tag:_.operator,class:"tok-operator"},{tag:_.comment,class:"tok-comment"},{tag:_.meta,class:"tok-meta"},{tag:_.invalid,class:"tok-invalid"},{tag:_.punctuation,class:"tok-punctuation"}]);var fT;const Vu=new jt;function Tk(e){return dt.define({combine:e?t=>t.concat(e):void 0})}const zA=new jt;class bo{constructor(t,n,r=[],i=""){this.data=t,this.name=i,Rn.prototype.hasOwnProperty("tree")||Object.defineProperty(Rn.prototype,"tree",{get(){return Yn(this)}}),this.parser=n,this.extension=[mO.of(this),Rn.languageData.of((a,o,s)=>{let l=HD(a,o,s),c=l.type.prop(Vu);if(!c)return[];let u=a.facet(c),O=l.type.prop(zA);if(O){let d=l.resolve(o-l.from,s);for(let h of O)if(h.test(d,a)){let p=a.facet(h.facet);return h.type=="replace"?p:p.concat(u)}}return u})].concat(r)}isActiveAt(t,n,r=-1){return HD(t,n,r).type.prop(Vu)==this.data}findRegions(t){let n=t.facet(mO);if(n?.data==this.data)return[{from:0,to:t.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(a,o)=>{if(a.prop(Vu)==this.data){r.push({from:o,to:o+a.length});return}let s=a.prop(jt.mounted);if(s){if(s.tree.prop(Vu)==this.data){if(s.overlay)for(let l of s.overlay)r.push({from:l.from+o,to:l.to+o});else r.push({from:o,to:o+a.length});return}else if(s.overlay){let l=r.length;if(i(s.tree,s.overlay[0].from+o),r.length>l)return}}for(let l=0;l<a.children.length;l++){let c=a.children[l];c instanceof sn&&i(c,a.positions[l]+o)}};return i(Yn(t),0),r}get allowsNesting(){return!0}}bo.setState=vn.define();function HD(e,t,n){let r=e.facet(mO),i=Yn(e).topNode;if(!r||r.allowsNesting)for(let a=i;a;a=a.enter(t,n,Bn.ExcludeBuffers))a.type.isTop&&(i=a);return i}class wn extends bo{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=Tk(t.languageData);return new wn(n,t.parser.configure({props:[Vu.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new wn(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Yn(e){let t=e.field(bo.state,!1);return t?t.tree:sn.empty}class Met{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,n){let r=this.cursorPos-this.string.length;return t<r||n>=this.cursorPos?this.doc.sliceString(t,n):this.string.slice(t-r,n-r)}}let bg=null;class Hd{constructor(t,n,r=[],i,a,o,s,l){this.parser=t,this.state=n,this.fragments=r,this.tree=i,this.treeLen=a,this.viewport=o,this.skipped=s,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new Hd(t,n,[],sn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Met(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=sn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof t=="number"){let i=Date.now()+t;t=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped(jc.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,n;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=t,this.tree=n,this.fragments=this.withoutTempSkipped(jc.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=bg;bg=this;try{return t()}finally{bg=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=KD(t,n.from,n.to);return t}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let l=[];if(t.iterChangedRanges((c,u,O,d)=>l.push({fromA:c,toA:u,fromB:O,toB:d})),r=jc.applyChanges(r,l),i=sn.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let c of this.skipped){let u=t.mapPos(c.from,1),O=t.mapPos(c.to,-1);u<O&&s.push({from:u,to:O})}}}return new Hd(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let n=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:i,to:a}=this.skipped[r];i<t.to&&a>t.from&&(this.fragments=KD(this.fragments,i,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,n){this.skipped.push({from:t,to:n})}static getSkippingParser(t){return new class extends xk{createParse(n,r,i){let a=i[0].from,o=i[i.length-1].to;return{parsedPos:a,advance(){let l=bg;if(l){for(let c of i)l.tempSkipped.push(c);t&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,t]):t)}return this.parsedPos=o,new sn(ri.none,[],[],o-a)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let n=this.fragments;return this.treeLen>=t&&n.length&&n[0].from==0&&n[0].to>=t}static get(){return bg}}function KD(e,t,n){return jc.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class Pp{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=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),n.viewport.to);return n.work(20,r)||n.takeTree(),new Pp(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=Hd.create(t.facet(mO).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new Pp(r)}}bo.state=La.define({create:Pp.init,update(e,t){for(let n of t.effects)if(n.is(bo.setState))return n.value;return t.startState.facet(mO)!=t.state.facet(mO)?Pp.init(t.state):e.apply(t)}});let Fpe=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Fpe=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const hT=typeof navigator<"u"&&(!((fT=navigator.scheduling)===null||fT===void 0)&&fT.isInputPending)?()=>navigator.scheduling.isInputPending():null,Let=pi.fromClass(class{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 n=this.view.state.field(bo.state).context;(n.updateViewport(t.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:t}=this.view,n=t.field(bo.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=Fpe(this.work))}work(t){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:i}}=this.view,a=r.field(bo.state);if(a.tree==a.context.tree&&a.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!hT?Math.max(25,t.timeRemaining()-5):1e9),s=a.context.treeLen<i&&r.doc.length>i+1e3,l=a.context.work(()=>hT&&hT()||Date.now()>o,i+(s?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:bo.setState.of(new Pp(a.context))})),this.chunkBudget>0&&!(l&&!s)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Ya(this.view.state,n)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),mO=dt.define({combine(e){return e.length?e[0]:null},enables:e=>[bo.state,Let,xt.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class hn{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}class ge{constructor(t,n,r,i,a,o=void 0){this.name=t,this.alias=n,this.extensions=r,this.filename=i,this.loadFunc=a,this.support=o,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:n,support:r}=t;if(!n){if(!r)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");n=()=>Promise.resolve(r)}return new ge(t.name,(t.alias||[]).concat(t.name).map(i=>i.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(t,n){for(let i of t)if(i.filename&&i.filename.test(n))return i;let r=/\.([^.]+)$/.exec(n);if(r){for(let i of t)if(i.extensions.indexOf(r[1])>-1)return i}return null}static matchLanguageName(t,n,r=!0){n=n.toLowerCase();for(let i of t)if(i.alias.some(a=>a==n))return i;if(r)for(let i of t)for(let a of i.alias){let o=n.indexOf(a);if(o>-1&&(a.length>2||!/\w/.test(n[o-1])&&!/\w/.test(n[o+a.length])))return i}return null}}const Fet=dt.define(),Xk=dt.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(n=>n!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function Gx(e){let t=e.facet(Xk);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Bet(e,t){let n="",r=e.tabSize,i=e.facet(Xk)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let a=0;a<t;a++)n+=i;return n}function Het(e,t){e instanceof Rn&&(e=new Bpe(e));for(let r of e.state.facet(Fet)){let i=r(e,t);if(i!==void 0)return i}let n=Yn(e.state);return n.length>=t?Ket(e,n,t):null}class Bpe{constructor(t,n={}){this.state=t,this.options=n,this.unit=Gx(t)}lineAt(t,n=1){let r=this.state.doc.lineAt(t),{simulateBreak:i,simulateDoubleBreak:a}=this.options;return i!=null&&i>=r.from&&i<=r.to?a&&i==t?{text:"",from:t}:(n<0?i<t:i<=t)?{text:r.text.slice(i-r.from),from:i}:{text:r.text.slice(0,i-r.from),from:r.from}:r}textAfterPos(t,n=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:r,from:i}=this.lineAt(t,n);return r.slice(t-i,Math.min(r.length,t+100-i))}column(t,n=1){let{text:r,from:i}=this.lineAt(t,n),a=this.countColumn(r,t-i),o=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return o>-1&&(a+=o-this.countColumn(r,r.search(/\S|$/))),a}countColumn(t,n=t.length){return dO(t,this.state.tabSize,n)}lineIndent(t,n=1){let{text:r,from:i}=this.lineAt(t,n),a=this.options.overrideIndentation;if(a){let o=a(i);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Xr=new jt;function Ket(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let a=[];for(let o=i;o&&!(o.from<r.node.from||o.to>r.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)a.push(o);for(let o=a.length-1;o>=0;o--)r={node:a[o],next:r}}return Hpe(r,e,n)}function Hpe(e,t,n){for(let r=e;r;r=r.next){let i=ett(r.node);if(i)return i(AA.create(t,n,r))}return 0}function Jet(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function ett(e){let t=e.type.prop(Xr);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(jt.closedBy))){let i=e.lastChild,a=i&&r.indexOf(i.name)>-1;return o=>Kpe(o,!0,1,void 0,a&&!Jet(o)?i.from:void 0)}return e.parent==null?ttt:null}function ttt(){return 0}class AA extends Bpe{constructor(t,n,r){super(t.state,t.options),this.base=t,this.pos=n,this.context=r}get node(){return this.context.node}static create(t,n,r){return new AA(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let n=this.state.doc.lineAt(t.from);for(;;){let r=t.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(ntt(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Hpe(this.context.next,this.base,this.pos)}}function ntt(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function rtt(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let s=n.to;;){let l=t.childAfter(s);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let c=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+c}}s=l.to}}function ts({closing:e,align:t=!0,units:n=1}){return r=>Kpe(r,t,n,e)}function Kpe(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,l=t?rtt(e):null;return l?s?e.column(l.from):e.column(l.to):e.baseIndent+(s?0:e.unit*n)}const UA=e=>e.baseIndent;function Ar({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const itt=200;function Vsn(){return Rn.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 n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+itt)return e;let a=n.sliceString(i.from,r);if(!t.some(c=>c.test(a)))return e;let{state:o}=e,s=-1,l=[];for(let{head:c}of o.selection.ranges){let u=o.doc.lineAt(c);if(u.from==s)continue;s=u.from;let O=Het(o,u.from);if(O==null)continue;let d=/^\s*/.exec(u.text)[0],h=Bet(o,O);d!=h&&l.push({from:u.from,to:u.from+d.length,insert:h})}return l.length?[e,{changes:l,sequential:!0}]:e})}const Jpe=dt.define(),xr=new jt;function sa(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}function att(e,t,n){let r=Yn(e);if(r.length<n)return null;let i=r.resolveStack(n,1),a=null;for(let o=i;o;o=o.next){let s=o.node;if(s.to<=n||s.from>n)continue;if(a&&s.from<t)break;let l=s.type.prop(xr);if(l&&(s.to<r.length-50||r.length==e.doc.length||!ott(s))){let c=l(s,e);c&&c.from<=n&&c.from>=t&&c.to>n&&(a=c)}}return a}function ott(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function Zx(e,t,n){for(let r of e.facet(Jpe)){let i=r(e,t,n);if(i)return i}return att(e,t,n)}function eme(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}const Rk=vn.define({map:eme}),mv=vn.define({map:eme});function tme(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(r=>r.from<=n&&r.to>=n)||t.push(e.lineBlockAt(n));return t}const Kd=La.define({create(){return nn.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(Rk)&&!stt(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(ime),i=r?nn.replace({widget:new ftt(r(t.state,n.value))}):JD;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(mv)&&(e=e.update({filter:(r,i)=>n.value.from!=r||n.value.to!=i,filterFrom:n.value.from,filterTo:n.value.to}));if(t.selection){let n=!1,{head:r}=t.selection.main;e.between(r,r,(i,a)=>{i<r&&a>r&&(n=!0)}),n&&(e=e.update({filterFrom:r,filterTo:r,filter:(i,a)=>a<=r||i>=r}))}return e},provide:e=>xt.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(r,i)=>{n.push(r,i)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");t.push(JD.range(r,i))}return nn.set(t,!0)}});function Ix(e,t,n){var r;let i=null;return(r=e.field(Kd,!1))===null||r===void 0||r.between(t,n,(a,o)=>{(!i||i.from>a)&&(i={from:a,to:o})}),i}function stt(e,t,n){let r=!1;return e.between(t,t,(i,a)=>{i==t&&a==n&&(r=!0)}),r}function nme(e,t){return e.field(Kd,!1)?t:t.concat(vn.appendConfig.of(ame()))}const ltt=e=>{for(let t of tme(e)){let n=Zx(e.state,t.from,t.to);if(n)return e.dispatch({effects:nme(e.state,[Rk.of(n),rme(e,n)])}),!0}return!1},ctt=e=>{if(!e.state.field(Kd,!1))return!1;let t=[];for(let n of tme(e)){let r=Ix(e.state,n.from,n.to);r&&t.push(mv.of(r),rme(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function rme(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return xt.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const utt=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=Zx(t,i.from,i.to);a&&n.push(Rk.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:nme(e.state,n)}),!!n.length},Ott=e=>{let t=e.state.field(Kd,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(mv.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},Msn=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:ltt},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:ctt},{key:"Ctrl-Alt-[",run:utt},{key:"Ctrl-Alt-]",run:Ott}],dtt={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},ime=dt.define({combine(e){return km(e,dtt)}});function ame(e){return[Kd,ptt]}function ome(e,t){let{state:n}=e,r=n.facet(ime),i=o=>{let s=e.lineBlockAt(e.posAtDOM(o.target)),l=Ix(e.state,s.from,s.to);l&&e.dispatch({effects:mv.of(l)}),o.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let a=document.createElement("span");return a.textContent=r.placeholderText,a.setAttribute("aria-label",n.phrase("folded code")),a.title=n.phrase("unfold"),a.className="cm-foldPlaceholder",a.onclick=i,a}const JD=nn.replace({widget:new class extends au{toDOM(e){return ome(e,null)}}});class ftt extends au{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return ome(t,this.value)}}const htt={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class pT extends Vc{constructor(t,n){super(),this.config=t,this.open=n}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=t.state.phrase(this.open?"Fold line":"Unfold line"),n}}function Lsn(e={}){let t={...htt,...e},n=new pT(t,!0),r=new pT(t,!1),i=pi.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(mO)!=o.state.facet(mO)||o.startState.field(Kd,!1)!=o.state.field(Kd,!1)||Yn(o.startState)!=Yn(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let s=new Md;for(let l of o.viewportLineBlocks){let c=Ix(o.state,l.from,l.to)?r:Zx(o.state,l.from,l.to)?n:null;c&&s.add(l.from,l.from,c)}return s.finish()}}),{domEventHandlers:a}=t;return[i,Xet({class:"cm-foldGutter",markers(o){var s;return((s=o.plugin(i))===null||s===void 0?void 0:s.markers)||yn.empty},initialSpacer(){return new pT(t,!1)},domEventHandlers:{...a,click:(o,s,l)=>{if(a.click&&a.click(o,s,l))return!0;let c=Ix(o.state,s.from,s.to);if(c)return o.dispatch({effects:mv.of(c)}),!0;let u=Zx(o.state,s.from,s.to);return u?(o.dispatch({effects:Rk.of(u)}),!0):!1}}}),ame()]}const ptt=xt.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"}});class Ek{constructor(t,n){this.specs=t;let r;function i(s){let l=fO.newName();return(r||(r=Object.create(null)))["."+l]=s,l}const a=typeof n.all=="string"?n.all:n.all?i(n.all):void 0,o=n.scope;this.scope=o instanceof bo?s=>s.prop(Vu)==o.data:o?s=>s==o:void 0,this.style=Lpe(t.map(s=>({tag:s.tag,class:s.class||i(Object.assign({},s,{tag:null}))})),{all:a}).style,this.module=r?new fO(r):null,this.themeType=n.themeType}static define(t,n){return new Ek(t,n||{})}}const z3=dt.define(),sme=dt.define({combine(e){return e.length?[e[0]]:null}});function mT(e){let t=e.facet(z3);return t.length?t:e.facet(sme)}function Fsn(e,t){let n=[gtt],r;return e instanceof Ek&&(e.module&&n.push(xt.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(sme.of(e)):r?n.push(z3.computeN([xt.darkTheme],i=>i.facet(xt.darkTheme)==(r=="dark")?[e]:[])):n.push(z3.of(e)),n}class mtt{constructor(t){this.markCache=Object.create(null),this.tree=Yn(t.state),this.decorations=this.buildDeco(t,mT(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=Yn(t.state),r=mT(t.state),i=r!=mT(t.startState),{viewport:a}=t.view,o=t.changes.mapPos(this.decoratedTo,1);n.length<a.to&&!i&&n.type==this.tree.type&&o>=a.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(n!=this.tree||t.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(t.view,r),this.decoratedTo=a.to)}buildDeco(t,n){if(!n||!this.tree.length)return nn.none;let r=new Md;for(let{from:i,to:a}of t.visibleRanges)Iet(this.tree,n,(o,s,l)=>{r.add(o,s,this.markCache[l]||(this.markCache[l]=nn.mark({class:l})))},i,a);return r.finish()}}const gtt=QO.high(pi.fromClass(mtt,{decorations:e=>e.decorations})),Bsn=Ek.define([{tag:_.meta,color:"#404740"},{tag:_.link,textDecoration:"underline"},{tag:_.heading,textDecoration:"underline",fontWeight:"bold"},{tag:_.emphasis,fontStyle:"italic"},{tag:_.strong,fontWeight:"bold"},{tag:_.strikethrough,textDecoration:"line-through"},{tag:_.keyword,color:"#708"},{tag:[_.atom,_.bool,_.url,_.contentSeparator,_.labelName],color:"#219"},{tag:[_.literal,_.inserted],color:"#164"},{tag:[_.string,_.deleted],color:"#a11"},{tag:[_.regexp,_.escape,_.special(_.string)],color:"#e40"},{tag:_.definition(_.variableName),color:"#00f"},{tag:_.local(_.variableName),color:"#30a"},{tag:[_.typeName,_.namespace],color:"#085"},{tag:_.className,color:"#167"},{tag:[_.special(_.variableName),_.macroName],color:"#256"},{tag:_.definition(_.propertyName),color:"#00c"},{tag:_.comment,color:"#940"},{tag:_.invalid,color:"#f00"}]),$tt=xt.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),lme=1e4,cme="()[]{}",ume=dt.define({combine(e){return km(e,{afterCursor:!0,brackets:cme,maxScanDistance:lme,renderMatch:btt})}}),ytt=nn.mark({class:"cm-matchingBracket"}),vtt=nn.mark({class:"cm-nonmatchingBracket"});function btt(e){let t=[],n=e.matched?ytt:vtt;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}const wtt=La.define({create(){return nn.none},update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(ume);for(let i of t.state.selection.ranges){if(!i.empty)continue;let a=Mb(t.state,i.head,-1,r)||i.head>0&&Mb(t.state,i.head-1,1,r)||r.afterCursor&&(Mb(t.state,i.head,1,r)||i.head<t.state.doc.length&&Mb(t.state,i.head+1,-1,r));a&&(n=n.concat(r.renderMatch(a,t.state)))}return nn.set(n,!0)},provide:e=>xt.decorations.from(e)}),xtt=[wtt,$tt];function Hsn(e={}){return[ume.of(e),xtt]}const WA=new jt;function A3(e,t,n){let r=e.prop(t<0?jt.openedBy:jt.closedBy);if(r)return r;if(e.name.length==1){let i=n.indexOf(e.name);if(i>-1&&i%2==(t<0?1:0))return[n[i+t]]}return null}function U3(e){let t=e.type.prop(WA);return t?t(e.node):e}function Mb(e,t,n,r={}){let i=r.maxScanDistance||lme,a=r.brackets||cme,o=Yn(e),s=o.resolveInner(t,n);for(let l=s;l;l=l.parent){let c=A3(l.type,n,a);if(c&&l.from<l.to){let u=U3(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return Stt(e,t,n,l,u,c,a)}}return Qtt(e,t,n,o,s.type,i,a)}function Stt(e,t,n,r,i,a,o){let s=r.parent,l={from:i.from,to:i.to},c=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(c==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let O=U3(u);return{start:l,end:O?{from:O.from,to:O.to}:void 0,matched:!0}}else if(A3(u.type,n,o))c++;else if(A3(u.type,-n,o)){if(c==0){let O=U3(u);return{start:l,end:O&&O.from<O.to?{from:O.from,to:O.to}:void 0,matched:!1}}c--}}while(n<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function Qtt(e,t,n,r,i,a,o){let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=o.indexOf(s);if(l<0||l%2==0!=n>0)return null;let c={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),O=0;for(let d=0;!u.next().done&&d<=a;){let h=u.value;n<0&&(d+=h.length);let p=t+d*n;for(let g=n>0?0:h.length-1,y=n>0?h.length:-1;g!=y;g+=n){let v=o.indexOf(h[g]);if(!(v<0||r.resolveInner(p+g,1).type!=i))if(v%2==0==n>0)O++;else{if(O==1)return{start:c,end:{from:p+g,to:p+g+1},matched:v>>1==l>>1};O--}}n>0&&(d+=h.length)}return u.done?{start:c,matched:!1}:null}function eV(e,t,n,r=0,i=0){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let a=i;for(let o=r;o<t;o++)e.charCodeAt(o)==9?a+=n-a%n:a++;return a}class Ome{constructor(t,n,r,i){this.string=t,this.tabSize=n,this.indentUnit=r,this.overrideIndent=i,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(t){let n=this.string.charAt(this.pos),r;if(typeof t=="string"?r=n==t:r=n&&(t instanceof RegExp?t.test(n):t(n)),r)return++this.pos,n}eatWhile(t){let n=this.pos;for(;this.eat(t););return this.pos>n}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let n=this.string.indexOf(t,this.pos);if(n>-1)return this.pos=n,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=eV(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return(t=this.overrideIndent)!==null&&t!==void 0?t:eV(this.string,null,this.tabSize)}match(t,n,r){if(typeof t=="string"){let i=o=>r?o.toLowerCase():o,a=this.string.substr(this.pos,t.length);return i(a)==i(t)?(n!==!1&&(this.pos+=t.length),!0):null}else{let i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&n!==!1&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function ktt(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||_tt,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||YA,mergeTokens:e.mergeTokens!==!1}}function _tt(e){if(typeof e!="object")return e;let t={};for(let n in e){let r=e[n];t[n]=r instanceof Array?r.slice():r}return t}const tV=new WeakMap;class Ce extends bo{constructor(t){let n=Tk(t.languageData),r=ktt(t),i,a=new class extends xk{createParse(o,s,l){return new Ttt(i,o,s,l)}};super(n,a,[],t.name),this.topNode=Ett(n,this),i=this,this.streamParser=r,this.stateAfter=new jt({perNode:!0}),this.tokenTable=t.tokenTable?new pme(r.tokenTable):Rtt}static define(t){return new Ce(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=tV.get(t.state),n!=null&&n<t.pos-1e4&&(n=void 0));let i=NA(this,t.node.tree,t.node.from,t.node.from,n??t.pos),a,o;if(i?(o=i.state,a=i.pos+1):(o=this.streamParser.startState(t.unit),a=t.node.from),t.pos-a>1e4)return null;for(;a<t.pos;){let l=t.state.doc.lineAt(a),c=Math.min(t.pos,l.to);if(l.length){let u=r?r(l.from):-1,O=new Ome(l.text,t.state.tabSize,t.unit,u<0?void 0:u);for(;O.pos<c-l.from;)fme(this.streamParser.token,O,o)}else this.streamParser.blankLine(o,t.unit);if(c==t.pos)break;a=l.to+1}let s=t.lineAt(t.pos);return r&&n==null&&tV.set(t.state,s.from),this.streamParser.indent(o,/^\s*(.*)/.exec(s.text)[1],t)}get allowsNesting(){return!1}}function NA(e,t,n,r,i){let a=n>=r&&n+t.length<=i&&t.prop(e.stateAfter);if(a)return{state:e.streamParser.copyState(a),pos:n+t.length};for(let o=t.children.length-1;o>=0;o--){let s=t.children[o],l=n+t.positions[o],c=s instanceof sn&&l<i&&NA(e,s,l,r,i);if(c)return c}return null}function dme(e,t,n,r,i){if(i&&n<=0&&r>=t.length)return t;!i&&n==0&&t.type==e.topNode&&(i=!0);for(let a=t.children.length-1;a>=0;a--){let o=t.positions[a],s=t.children[a],l;if(o<r&&s instanceof sn){if(!(l=dme(e,s,n-o,r-o,i)))break;return i?new sn(t.type,t.children.slice(0,a).concat(l),t.positions.slice(0,a+1),o+l.length):l}}return null}function Ptt(e,t,n,r,i){for(let a of t){let o=a.from+(a.openStart?25:0),s=a.to-(a.openEnd?25:0),l=o<=n&&s>n&&NA(e,a.tree,0-a.offset,n,s),c;if(l&&l.pos<=r&&(c=dme(e,a.tree,n+a.offset,l.pos+a.offset,!1)))return{state:l.state,tree:c}}return{state:e.streamParser.startState(i?Gx(i):4),tree:sn.empty}}let Ttt=class{constructor(t,n,r,i){this.lang=t,this.input=n,this.fragments=r,this.ranges=i,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=i[i.length-1].to;let a=Hd.get(),o=i[0].from,{state:s,tree:l}=Ptt(t,r,o,this.to,a?.state);this.state=s,this.parsedPos=this.chunkStart=o+l.length;for(let c=0;c<l.children.length;c++)this.chunks.push(l.children[c]),this.chunkPos.push(l.positions[c]);a&&this.parsedPos<a.viewport.from-1e5&&i.some(c=>c.from<=a.viewport.from&&c.to>=a.viewport.from)&&(this.state=this.lang.streamParser.startState(Gx(a.state)),a.skipUntilInView(this.parsedPos,a.viewport.from),this.parsedPos=a.viewport.from),this.moveRangeIndex()}advance(){let t=Hd.get(),n=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),r=Math.min(n,this.chunkStart+2048);for(t&&(r=Math.min(r,t.viewport.to));this.parsedPos<r;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=n?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,n),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let n=this.input.chunk(t);if(this.input.lineChunks)n==`
|
|
836
836
|
`&&(n="");else{let r=n.indexOf(`
|
|
837
|
-
`);r>-1&&(n=n.slice(0,r))}return t+n.length<=this.to?n:n.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,n=this.lineAfter(t),r=t+n.length;for(let i=this.rangeIndex;;){let a=this.ranges[i].to;if(a>=r||(n=n.slice(0,a-(r-n.length)),i++,i==this.ranges.length))break;let o=this.ranges[i].from,s=this.lineAfter(o);n+=s,r=o+s.length}return{line:n,end:r}}skipGapsTo(t,n,r){for(;;){let i=this.ranges[this.rangeIndex].to,a=t+n;if(r>0?i>a:i>=a)break;let o=this.ranges[++this.rangeIndex].from;n+=o-i}return n}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,n,r,i){let a=4;if(this.ranges.length>1){i=this.skipGapsTo(n,i,1),n+=i;let s=this.chunk.length;i=this.skipGapsTo(r,i,-1),r+=i,a+=this.chunk.length-s}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&a==4&&o>=0&&this.chunk[o]==t&&this.chunk[o+2]==n?this.chunk[o+2]=r:this.chunk.push(t,n,r,a),i}parseLine(t){let{line:n,end:r}=this.nextLine(),i=0,{streamParser:a}=this.lang,o=new Ome(n,t?t.state.tabSize:4,t?Gx(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=fme(a.token,o,this.state);if(s&&(i=this.emitToken(this.lang.tokenTable.resolve(s),this.parsedPos+o.start,this.parsedPos+o.pos,i)),o.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=sn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Xtt,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new sn(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new sn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function fme(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let i=e(t,n);if(t.pos>t.start)return i}throw new Error("Stream parser failed to advance stream.")}const YA=Object.create(null),U$=[ri.none],Xtt=new Qm(U$),nV=[],rV=Object.create(null),hme=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"]])hme[e]=mme(YA,t);class pme{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),hme)}resolve(t){return t?this.table[t]||(this.table[t]=mme(this.extra,t)):0}}const Rtt=new pme(YA);function gT(e,t){nV.indexOf(e)>-1||(nV.push(e),console.warn(t))}function mme(e,t){let n=[];for(let s of t.split(" ")){let l=[];for(let c of s.split(".")){let u=e[c]||_[c];u?typeof u=="function"?l.length?l=l.map(u):gT(c,`Modifier ${c} used at start of tag`):l.length?gT(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:gT(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(s=>s.id),a=rV[i];if(a)return a.id;let o=rV[i]=ri.define({id:U$.length,name:r,props:[kn({[r]:n})]});return U$.push(o),o.id}function Ett(e,t){let n=ri.define({id:U$.length,name:"Document",props:[Vu.add(()=>e),Xr.add(()=>r=>t.getIndent(r))],top:!0});return U$.push(n),n}yr.RTL,yr.LTR;function Ee(e){return new hn(Ce.define(e))}function bu(e){return be(()=>Promise.resolve().then(()=>nOt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const qtt=[ge.of({name:"C",extensions:["c","h","ino"],load(){return be(()=>Promise.resolve().then(()=>LM),void 0,import.meta.url).then(e=>e.cpp())}}),ge.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return be(()=>Promise.resolve().then(()=>LM),void 0,import.meta.url).then(e=>e.cpp())}}),ge.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return bu("Cassandra")}}),ge.of({name:"CSS",extensions:["css"],load(){return be(()=>Promise.resolve().then(()=>git),void 0,import.meta.url).then(e=>e.css())}}),ge.of({name:"Go",extensions:["go"],load(){return be(()=>import("./index-BiI-eK_K.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(e=>e.go())}}),ge.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return be(()=>Promise.resolve().then(()=>lat),void 0,import.meta.url).then(e=>e.html())}}),ge.of({name:"Java",extensions:["java"],load(){return be(()=>Promise.resolve().then(()=>oOt),void 0,import.meta.url).then(e=>e.java())}}),ge.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return be(()=>Promise.resolve().then(()=>Hb),void 0,import.meta.url).then(e=>e.javascript())}}),ge.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return be(()=>Promise.resolve().then(()=>fot),void 0,import.meta.url).then(e=>e.json())}}),ge.of({name:"JSX",extensions:["jsx"],load(){return be(()=>Promise.resolve().then(()=>Hb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),ge.of({name:"LESS",extensions:["less"],load(){return be(()=>Promise.resolve().then(()=>Tat),void 0,import.meta.url).then(e=>e.less())}}),ge.of({name:"Liquid",extensions:["liquid"],load(){return be(()=>Promise.resolve().then(()=>Dft),void 0,import.meta.url).then(e=>e.liquid())}}),ge.of({name:"MariaDB SQL",load(){return bu("MariaSQL")}}),ge.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return be(()=>Promise.resolve().then(()=>$at),void 0,import.meta.url).then(e=>e.markdown())}}),ge.of({name:"MS SQL",load(){return bu("MSSQL")}}),ge.of({name:"MySQL",load(){return bu("MySQL")}}),ge.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return be(()=>Promise.resolve().then(()=>wft),void 0,import.meta.url).then(e=>e.php())}}),ge.of({name:"PLSQL",extensions:["pls"],load(){return bu("PLSQL")}}),ge.of({name:"PostgreSQL",load(){return bu("PostgreSQL")}}),ge.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return be(()=>Promise.resolve().then(()=>Dct),void 0,import.meta.url).then(e=>e.python())}}),ge.of({name:"Rust",extensions:["rs"],load(){return be(()=>Promise.resolve().then(()=>kOt),void 0,import.meta.url).then(e=>e.rust())}}),ge.of({name:"Sass",extensions:["sass"],load(){return be(()=>Promise.resolve().then(()=>cM),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),ge.of({name:"SCSS",extensions:["scss"],load(){return be(()=>Promise.resolve().then(()=>cM),void 0,import.meta.url).then(e=>e.sass())}}),ge.of({name:"SQL",extensions:["sql"],load(){return bu("StandardSQL")}}),ge.of({name:"SQLite",load(){return bu("SQLite")}}),ge.of({name:"TSX",extensions:["tsx"],load(){return be(()=>Promise.resolve().then(()=>Hb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),ge.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return be(()=>Promise.resolve().then(()=>Hb),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),ge.of({name:"WebAssembly",extensions:["wat","wast"],load(){return be(()=>Promise.resolve().then(()=>Lft),void 0,import.meta.url).then(e=>e.wast())}}),ge.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return be(()=>Promise.resolve().then(()=>fut),void 0,import.meta.url).then(e=>e.xml())}}),ge.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return be(()=>import("./index-G0fTK0HE.js"),__vite__mapDeps([6,1,2,3,4,5]),import.meta.url).then(e=>e.yaml())}}),ge.of({name:"APL",extensions:["dyalog","apl"],load(){return be(()=>Promise.resolve().then(()=>xmt),void 0,import.meta.url).then(e=>Ee(e.apl))}}),ge.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return be(()=>Promise.resolve().then(()=>Smt),void 0,import.meta.url).then(e=>Ee(e.asciiArmor))}}),ge.of({name:"ASN.1",extensions:["asn","asn1"],load(){return be(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>Ee(e.asn1({})))}}),ge.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return be(()=>Promise.resolve().then(()=>Tmt),void 0,import.meta.url).then(e=>Ee(e.asterisk))}}),ge.of({name:"Brainfuck",extensions:["b","bf"],load(){return be(()=>Promise.resolve().then(()=>Rmt),void 0,import.meta.url).then(e=>Ee(e.brainfuck))}}),ge.of({name:"Cobol",extensions:["cob","cpy"],load(){return be(()=>Promise.resolve().then(()=>agt),void 0,import.meta.url).then(e=>Ee(e.cobol))}}),ge.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return be(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Ee(e.csharp))}}),ge.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return be(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Ee(e.clojure))}}),ge.of({name:"ClojureScript",extensions:["cljs"],load(){return be(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Ee(e.clojure))}}),ge.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return be(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>Ee(e.gss))}}),ge.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return be(()=>Promise.resolve().then(()=>Bmt),void 0,import.meta.url).then(e=>Ee(e.cmake))}}),ge.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return be(()=>Promise.resolve().then(()=>$gt),void 0,import.meta.url).then(e=>Ee(e.coffeeScript))}}),ge.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return be(()=>Promise.resolve().then(()=>Sgt),void 0,import.meta.url).then(e=>Ee(e.commonLisp))}}),ge.of({name:"Cypher",extensions:["cyp","cypher"],load(){return be(()=>Promise.resolve().then(()=>Ggt),void 0,import.meta.url).then(e=>Ee(e.cypher))}}),ge.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return be(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>Ee(e.cython))}}),ge.of({name:"Crystal",extensions:["cr"],load(){return be(()=>Promise.resolve().then(()=>zgt),void 0,import.meta.url).then(e=>Ee(e.crystal))}}),ge.of({name:"D",extensions:["d"],load(){return be(()=>Promise.resolve().then(()=>Fgt),void 0,import.meta.url).then(e=>Ee(e.d))}}),ge.of({name:"Dart",extensions:["dart"],load(){return be(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Ee(e.dart))}}),ge.of({name:"diff",extensions:["diff","patch"],load(){return be(()=>Promise.resolve().then(()=>Bgt),void 0,import.meta.url).then(e=>Ee(e.diff))}}),ge.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return be(()=>Promise.resolve().then(()=>c0t),void 0,import.meta.url).then(e=>Ee(e.dockerFile))}}),ge.of({name:"DTD",extensions:["dtd"],load(){return be(()=>Promise.resolve().then(()=>d0t),void 0,import.meta.url).then(e=>Ee(e.dtd))}}),ge.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return be(()=>Promise.resolve().then(()=>g0t),void 0,import.meta.url).then(e=>Ee(e.dylan))}}),ge.of({name:"EBNF",load(){return be(()=>Promise.resolve().then(()=>$0t),void 0,import.meta.url).then(e=>Ee(e.ebnf))}}),ge.of({name:"ECL",extensions:["ecl"],load(){return be(()=>Promise.resolve().then(()=>k0t),void 0,import.meta.url).then(e=>Ee(e.ecl))}}),ge.of({name:"edn",extensions:["edn"],load(){return be(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Ee(e.clojure))}}),ge.of({name:"Eiffel",extensions:["e"],load(){return be(()=>Promise.resolve().then(()=>E0t),void 0,import.meta.url).then(e=>Ee(e.eiffel))}}),ge.of({name:"Elm",extensions:["elm"],load(){return be(()=>Promise.resolve().then(()=>Z0t),void 0,import.meta.url).then(e=>Ee(e.elm))}}),ge.of({name:"Erlang",extensions:["erl"],load(){return be(()=>Promise.resolve().then(()=>f$t),void 0,import.meta.url).then(e=>Ee(e.erlang))}}),ge.of({name:"Esper",load(){return be(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>Ee(e.esper))}}),ge.of({name:"Factor",extensions:["factor"],load(){return be(()=>Promise.resolve().then(()=>h$t),void 0,import.meta.url).then(e=>Ee(e.factor))}}),ge.of({name:"FCL",load(){return be(()=>Promise.resolve().then(()=>y$t),void 0,import.meta.url).then(e=>Ee(e.fcl))}}),ge.of({name:"Forth",extensions:["forth","fth","4th"],load(){return be(()=>Promise.resolve().then(()=>w$t),void 0,import.meta.url).then(e=>Ee(e.forth))}}),ge.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return be(()=>Promise.resolve().then(()=>T$t),void 0,import.meta.url).then(e=>Ee(e.fortran))}}),ge.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return be(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Ee(e.fSharp))}}),ge.of({name:"Gas",extensions:["s"],load(){return be(()=>Promise.resolve().then(()=>R$t),void 0,import.meta.url).then(e=>Ee(e.gas))}}),ge.of({name:"Gherkin",extensions:["feature"],load(){return be(()=>Promise.resolve().then(()=>E$t),void 0,import.meta.url).then(e=>Ee(e.gherkin))}}),ge.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return be(()=>Promise.resolve().then(()=>Z$t),void 0,import.meta.url).then(e=>Ee(e.groovy))}}),ge.of({name:"Haskell",extensions:["hs"],load(){return be(()=>Promise.resolve().then(()=>B$t),void 0,import.meta.url).then(e=>Ee(e.haskell))}}),ge.of({name:"Haxe",extensions:["hx"],load(){return be(()=>Promise.resolve().then(()=>gF),void 0,import.meta.url).then(e=>Ee(e.haxe))}}),ge.of({name:"HXML",extensions:["hxml"],load(){return be(()=>Promise.resolve().then(()=>gF),void 0,import.meta.url).then(e=>Ee(e.hxml))}}),ge.of({name:"HTTP",load(){return be(()=>Promise.resolve().then(()=>yyt),void 0,import.meta.url).then(e=>Ee(e.http))}}),ge.of({name:"IDL",extensions:["pro"],load(){return be(()=>Promise.resolve().then(()=>kyt),void 0,import.meta.url).then(e=>Ee(e.idl))}}),ge.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return be(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>Ee(e.jsonld))}}),ge.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return be(()=>Promise.resolve().then(()=>Xyt),void 0,import.meta.url).then(e=>Ee(e.jinja2))}}),ge.of({name:"Julia",extensions:["jl"],load(){return be(()=>Promise.resolve().then(()=>tvt),void 0,import.meta.url).then(e=>Ee(e.julia))}}),ge.of({name:"Kotlin",extensions:["kt","kts"],load(){return be(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Ee(e.kotlin))}}),ge.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return be(()=>Promise.resolve().then(()=>avt),void 0,import.meta.url).then(e=>Ee(e.liveScript))}}),ge.of({name:"Lua",extensions:["lua"],load(){return be(()=>Promise.resolve().then(()=>fvt),void 0,import.meta.url).then(e=>Ee(e.lua))}}),ge.of({name:"mIRC",extensions:["mrc"],load(){return be(()=>Promise.resolve().then(()=>zvt),void 0,import.meta.url).then(e=>Ee(e.mirc))}}),ge.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return be(()=>Promise.resolve().then(()=>bvt),void 0,import.meta.url).then(e=>Ee(e.mathematica))}}),ge.of({name:"Modelica",extensions:["mo"],load(){return be(()=>Promise.resolve().then(()=>Vvt),void 0,import.meta.url).then(e=>Ee(e.modelica))}}),ge.of({name:"MUMPS",extensions:["mps"],load(){return be(()=>Promise.resolve().then(()=>lbt),void 0,import.meta.url).then(e=>Ee(e.mumps))}}),ge.of({name:"Mbox",extensions:["mbox"],load(){return be(()=>Promise.resolve().then(()=>qvt),void 0,import.meta.url).then(e=>Ee(e.mbox))}}),ge.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return be(()=>Promise.resolve().then(()=>fbt),void 0,import.meta.url).then(e=>Ee(e.nginx))}}),ge.of({name:"NSIS",extensions:["nsh","nsi"],load(){return be(()=>Promise.resolve().then(()=>hbt),void 0,import.meta.url).then(e=>Ee(e.nsis))}}),ge.of({name:"NTriples",extensions:["nt","nq"],load(){return be(()=>Promise.resolve().then(()=>pbt),void 0,import.meta.url).then(e=>Ee(e.ntriples))}}),ge.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return be(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Ee(e.objectiveC))}}),ge.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return be(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Ee(e.objectiveCpp))}}),ge.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return be(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Ee(e.oCaml))}}),ge.of({name:"Octave",extensions:["m"],load(){return be(()=>Promise.resolve().then(()=>kbt),void 0,import.meta.url).then(e=>Ee(e.octave))}}),ge.of({name:"Oz",extensions:["oz"],load(){return be(()=>Promise.resolve().then(()=>Ubt),void 0,import.meta.url).then(e=>Ee(e.oz))}}),ge.of({name:"Pascal",extensions:["p","pas"],load(){return be(()=>Promise.resolve().then(()=>Ibt),void 0,import.meta.url).then(e=>Ee(e.pascal))}}),ge.of({name:"Perl",extensions:["pl","pm"],load(){return be(()=>Promise.resolve().then(()=>Dbt),void 0,import.meta.url).then(e=>Ee(e.perl))}}),ge.of({name:"Pig",extensions:["pig"],load(){return be(()=>Promise.resolve().then(()=>Lbt),void 0,import.meta.url).then(e=>Ee(e.pig))}}),ge.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return be(()=>Promise.resolve().then(()=>uwt),void 0,import.meta.url).then(e=>Ee(e.powerShell))}}),ge.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return be(()=>Promise.resolve().then(()=>Owt),void 0,import.meta.url).then(e=>Ee(e.properties))}}),ge.of({name:"ProtoBuf",extensions:["proto"],load(){return be(()=>Promise.resolve().then(()=>mwt),void 0,import.meta.url).then(e=>Ee(e.protobuf))}}),ge.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return be(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([7,8]),import.meta.url).then(e=>Ee(e.pug))}}),ge.of({name:"Puppet",extensions:["pp"],load(){return be(()=>Promise.resolve().then(()=>ywt),void 0,import.meta.url).then(e=>Ee(e.puppet))}}),ge.of({name:"Q",extensions:["q"],load(){return be(()=>Promise.resolve().then(()=>_wt),void 0,import.meta.url).then(e=>Ee(e.q))}}),ge.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return be(()=>Promise.resolve().then(()=>jwt),void 0,import.meta.url).then(e=>Ee(e.r))}}),ge.of({name:"RPM Changes",load(){return be(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Ee(e.rpmChanges))}}),ge.of({name:"RPM Spec",extensions:["spec"],load(){return be(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Ee(e.rpmSpec))}}),ge.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return be(()=>Promise.resolve().then(()=>Zwt),void 0,import.meta.url).then(e=>Ee(e.ruby))}}),ge.of({name:"SAS",extensions:["sas"],load(){return be(()=>Promise.resolve().then(()=>Mwt),void 0,import.meta.url).then(e=>Ee(e.sas))}}),ge.of({name:"Scala",extensions:["scala"],load(){return be(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Ee(e.scala))}}),ge.of({name:"Scheme",extensions:["scm","ss"],load(){return be(()=>Promise.resolve().then(()=>o1t),void 0,import.meta.url).then(e=>Ee(e.scheme))}}),ge.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return be(()=>Promise.resolve().then(()=>u1t),void 0,import.meta.url).then(e=>Ee(e.shell))}}),ge.of({name:"Sieve",extensions:["siv","sieve"],load(){return be(()=>Promise.resolve().then(()=>p1t),void 0,import.meta.url).then(e=>Ee(e.sieve))}}),ge.of({name:"Smalltalk",extensions:["st"],load(){return be(()=>Promise.resolve().then(()=>$1t),void 0,import.meta.url).then(e=>Ee(e.smalltalk))}}),ge.of({name:"Solr",load(){return be(()=>Promise.resolve().then(()=>Q1t),void 0,import.meta.url).then(e=>Ee(e.solr))}}),ge.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return be(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Ee(e.sml))}}),ge.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return be(()=>Promise.resolve().then(()=>E1t),void 0,import.meta.url).then(e=>Ee(e.sparql))}}),ge.of({name:"Spreadsheet",alias:["excel","formula"],load(){return be(()=>Promise.resolve().then(()=>q1t),void 0,import.meta.url).then(e=>Ee(e.spreadsheet))}}),ge.of({name:"Squirrel",extensions:["nut"],load(){return be(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Ee(e.squirrel))}}),ge.of({name:"Stylus",extensions:["styl"],load(){return be(()=>Promise.resolve().then(()=>txt),void 0,import.meta.url).then(e=>Ee(e.stylus))}}),ge.of({name:"Swift",extensions:["swift"],load(){return be(()=>Promise.resolve().then(()=>bxt),void 0,import.meta.url).then(e=>Ee(e.swift))}}),ge.of({name:"sTeX",load(){return be(()=>Promise.resolve().then(()=>lB),void 0,import.meta.url).then(e=>Ee(e.stex))}}),ge.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return be(()=>Promise.resolve().then(()=>lB),void 0,import.meta.url).then(e=>Ee(e.stex))}}),ge.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return be(()=>Promise.resolve().then(()=>PB),void 0,import.meta.url).then(e=>Ee(e.verilog))}}),ge.of({name:"Tcl",extensions:["tcl"],load(){return be(()=>Promise.resolve().then(()=>Qxt),void 0,import.meta.url).then(e=>Ee(e.tcl))}}),ge.of({name:"Textile",extensions:["textile"],load(){return be(()=>Promise.resolve().then(()=>Txt),void 0,import.meta.url).then(e=>Ee(e.textile))}}),ge.of({name:"TiddlyWiki",load(){return be(()=>Promise.resolve().then(()=>Bxt),void 0,import.meta.url).then(e=>Ee(e.tiddlyWiki))}}),ge.of({name:"Tiki wiki",load(){return be(()=>Promise.resolve().then(()=>rSt),void 0,import.meta.url).then(e=>Ee(e.tiki))}}),ge.of({name:"TOML",extensions:["toml"],load(){return be(()=>Promise.resolve().then(()=>iSt),void 0,import.meta.url).then(e=>Ee(e.toml))}}),ge.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return be(()=>Promise.resolve().then(()=>sSt),void 0,import.meta.url).then(e=>Ee(e.troff))}}),ge.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return be(()=>Promise.resolve().then(()=>QSt),void 0,import.meta.url).then(e=>Ee(e.ttcn))}}),ge.of({name:"TTCN_CFG",extensions:["cfg"],load(){return be(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>Ee(e.ttcnCfg))}}),ge.of({name:"Turtle",extensions:["ttl"],load(){return be(()=>Promise.resolve().then(()=>PSt),void 0,import.meta.url).then(e=>Ee(e.turtle))}}),ge.of({name:"Web IDL",extensions:["webidl"],load(){return be(()=>Promise.resolve().then(()=>bQt),void 0,import.meta.url).then(e=>Ee(e.webIDL))}}),ge.of({name:"VB.NET",extensions:["vb"],load(){return be(()=>Promise.resolve().then(()=>ZSt),void 0,import.meta.url).then(e=>Ee(e.vb))}}),ge.of({name:"VBScript",extensions:["vbs"],load(){return be(()=>Promise.resolve().then(()=>DSt),void 0,import.meta.url).then(e=>Ee(e.vbScript))}}),ge.of({name:"Velocity",extensions:["vtl"],load(){return be(()=>Promise.resolve().then(()=>LSt),void 0,import.meta.url).then(e=>Ee(e.velocity))}}),ge.of({name:"Verilog",extensions:["v"],load(){return be(()=>Promise.resolve().then(()=>PB),void 0,import.meta.url).then(e=>Ee(e.verilog))}}),ge.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return be(()=>Promise.resolve().then(()=>rQt),void 0,import.meta.url).then(e=>Ee(e.vhdl))}}),ge.of({name:"XQuery",extensions:["xy","xquery"],load(){return be(()=>Promise.resolve().then(()=>RQt),void 0,import.meta.url).then(e=>Ee(e.xQuery))}}),ge.of({name:"Yacas",extensions:["ys"],load(){return be(()=>Promise.resolve().then(()=>YQt),void 0,import.meta.url).then(e=>Ee(e.yacas))}}),ge.of({name:"Z80",extensions:["z80"],load(){return be(()=>Promise.resolve().then(()=>VQt),void 0,import.meta.url).then(e=>Ee(e.z80))}}),ge.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return be(()=>Promise.resolve().then(()=>x2),void 0,import.meta.url).then(e=>Ee(e.mscgen))}}),ge.of({name:"Xù",extensions:["xu"],load(){return be(()=>Promise.resolve().then(()=>x2),void 0,import.meta.url).then(e=>Ee(e.xu))}}),ge.of({name:"MsGenny",extensions:["msgenny"],load(){return be(()=>Promise.resolve().then(()=>x2),void 0,import.meta.url).then(e=>Ee(e.msgenny))}}),ge.of({name:"Vue",extensions:["vue"],load(){return be(()=>Promise.resolve().then(()=>nht),void 0,import.meta.url).then(e=>e.vue())}}),ge.of({name:"Angular Template",load(){return be(()=>Promise.resolve().then(()=>bht),void 0,import.meta.url).then(e=>e.angular())}})];class GA{constructor(t,n,r,i){this.state=t,this.pos=n,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let n=Yn(this.state).resolveInner(this.pos,-1);for(;n&&t.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(t){let n=this.state.doc.lineAt(this.pos),r=Math.max(n.from,this.pos-250),i=n.text.slice(r-n.from,this.pos-n.from),a=i.search(gme(t,!1));return a<0?null:{from:r+a,to:this.pos,text:i.slice(a)}}get aborted(){return this.abortListeners==null}addEventListener(t,n,r){t=="abort"&&this.abortListeners&&(this.abortListeners.push(n),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function iV(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function jtt(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let a=1;a<i.length;a++)n[i[a]]=!0}let r=iV(t)+iV(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function gv(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:jtt(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function qk(e,t){return n=>{for(let r=Yn(n.state).resolveInner(n.pos,-1);r;r=r.parent){if(e.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return t(n)}}class aV{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function Rd(e){return e.selection.main.from}function gme(e,t){var n;let{source:r}=e,i=t&&r[0]!="^",a=r[r.length-1]!="$";return!i&&!a?e:new RegExp(`${i?"^":""}(?:${r})${a?"$":""}`,(n=e.flags)!==null&&n!==void 0?n:e.ignoreCase?"i":"")}const ZA=bf.define();function Ctt(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return Object.assign(Object.assign({},e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let l=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:l},range:Ge.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const oV=new WeakMap;function ztt(e){if(!Array.isArray(e))return e;let t=oV.get(e);return t||oV.set(e,t=gv(e)),t}const Dx=vn.define(),W$=vn.define();class Att{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<t.length;){let r=mo(t,n),i=yc(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(mo(o==a?a.toLowerCase():o,0)),n+=i}this.astral=t.length!=this.chars.length}ret(t,n){return this.score=t,this.matched=n,this}match(t){if(this.pattern.length==0)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:n,folded:r,any:i,precise:a,byWord:o}=this;if(n.length==1){let b=mo(t,0),x=yc(b),Q=x==t.length?0:-100;if(b!=n[0])if(b==r[0])Q+=-200;else return null;return this.ret(Q,[0,x])}let s=t.indexOf(this.pattern);if(s==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(s<0){for(let b=0,x=Math.min(t.length,200);b<x&&c<l;){let Q=mo(t,b);(Q==n[c]||Q==r[c])&&(i[c++]=b),b+=yc(Q)}if(c<l)return null}let u=0,O=0,d=!1,h=0,p=-1,g=-1,y=/[a-z]/.test(t),v=!0;for(let b=0,x=Math.min(t.length,200),Q=0;b<x&&O<l;){let w=mo(t,b);s<0&&(u<l&&w==n[u]&&(a[u++]=b),h<l&&(w==n[h]||w==r[h]?(h==0&&(p=b),g=b+1,h++):h=0));let S,k=w<255?w>=48&&w<=57||w>=97&&w<=122?2:w>=65&&w<=90?1:0:(S=Phe(w))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!b||k==1&&y||Q==0&&k!=0)&&(n[O]==w||r[O]==w&&(d=!0)?o[O++]=b:o.length&&(v=!1)),Q=k,b+=yc(w)}return O==l&&o[0]==0&&v?this.result(-100+(d?-200:0),o,t):h==l&&p==0?this.ret(-200-t.length+(g==t.length?0:-100),[0,g]):s>-1?this.ret(-700-t.length,[s,s+this.pattern.length]):h==l?this.ret(-900-t.length,[p,g]):O==l?this.result(-100+(d?-200:0)+-700+(v?0:-1100),o,t):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,t)}result(t,n,r){let i=[],a=0;for(let o of n){let s=o+(this.astral?yc(mo(r,o)):1);a&&i[a-1]==o?i[a-1]=s:(i[a++]=o,i[a++]=s)}return this.ret(t-r.length,i)}}class Utt{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let n=t.slice(0,this.pattern.length),r=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,n.length],this.score=r+(t.length==this.pattern.length?0:-100),this)}}const Pi=dt.define({combine(e){return km(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Wtt,filterStrict:!1,compareCompletions:(t,n)=>t.label.localeCompare(n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,n)=>t&&n,closeOnBlur:(t,n)=>t&&n,icons:(t,n)=>t&&n,tooltipClass:(t,n)=>r=>sV(t(r),n(r)),optionClass:(t,n)=>r=>sV(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function sV(e,t){return e?t?e+" "+t:e:t}function Wtt(e,t,n,r,i,a){let o=e.textDirection==yr.RTL,s=o,l=!1,c="top",u,O,d=t.left-i.left,h=i.right-t.right,p=r.right-r.left,g=r.bottom-r.top;if(s&&d<Math.min(p,h)?s=!1:!s&&h<Math.min(p,d)&&(s=!0),p<=(s?d:h))u=Math.max(i.top,Math.min(n.top,i.bottom-g))-t.top,O=Math.min(400,s?d:h);else{l=!0,O=Math.min(400,(o?t.right:i.right-t.left)-30);let b=i.bottom-t.bottom;b>=g||b>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let y=(t.bottom-t.top)/a.offsetHeight,v=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/y}px; max-width: ${O/v}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function Ntt(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),t.push({render(n,r,i,a){let o=document.createElement("span");o.className="cm-completionLabel";let s=n.displayLabel||n.label,l=0;for(let c=0;c<a.length;){let u=a[c++],O=a[c++];u>l&&o.appendChild(document.createTextNode(s.slice(l,u)));let d=o.appendChild(document.createElement("span"));d.appendChild(document.createTextNode(s.slice(u,O))),d.className="cm-completionMatchedText",l=O}return l<s.length&&o.appendChild(document.createTextNode(s.slice(l))),o},position:50},{render(n){if(!n.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=n.detail,r},position:80}),t.sort((n,r)=>n.position-r.position).map(n=>n.render)}function $T(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let i=Math.floor(t/n);return{from:i*n,to:(i+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class Ytt{constructor(t,n,r){this.view=t,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=t.state.field(n),{options:a,selected:o}=i.open,s=t.state.facet(Pi);this.optionContent=Ntt(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=$T(a.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=t.state.field(n).open;for(let u=l.target,O;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(O=/-(\d+)$/.exec(u.id))&&+O[1]<c.length){this.applyCompletion(t,c[+O[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=t.state.field(this.stateField,!1);c&&c.tooltip&&t.state.facet(Pi).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:W$.of(null)})}),this.showOptions(a,i.id)}mount(){this.updateSel()}showOptions(t,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var n;let r=t.state.field(this.stateField),i=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),r!=i){let{options:a,selected:o,disabled:s}=r.open;(!i.open||i.open.options!=a)&&(this.range=$T(a.length,o,t.state.facet(Pi).maxRenderedOptions),this.showOptions(a,r.id)),this.updateSel(),s!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(t){let n=this.tooltipClass(t);if(n!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of n.split(" "))r&&this.dom.classList.add(r);this.currentClass=n}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),n=t.open;if((n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=$T(n.options.length,n.selected,this.view.state.facet(Pi).maxRenderedOptions),this.showOptions(n.options,t.id)),this.updateSelectedOption(n.selected)){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:i}=r;if(!i)return;let a=typeof i=="string"?document.createTextNode(i):i(r);if(!a)return;"then"in a?a.then(o=>{o&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(o,r)}).catch(o=>Ya(this.view.state,o,"completion info")):this.addInfoPane(a,r)}}addInfoPane(t,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",t.nodeType!=null)r.appendChild(t),this.infoDestroy=null;else{let{dom:i,destroy:a}=t;r.appendChild(i),this.infoDestroy=a||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let n=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==t?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&r.removeAttribute("aria-selected");return n&&Ztt(this.list,n),n}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let n=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=t.getBoundingClientRect(),a=this.space;if(!a){let o=this.dom.ownerDocument.documentElement;a={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return i.top>Math.min(a.bottom,n.bottom)-10||i.bottom<Math.max(a.top,n.top)+10?null:this.view.state.facet(Pi).positionInfo(this.view,n,i,r,a,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,n,r){const i=document.createElement("ul");i.id=n,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",o=>{o.target==i&&o.preventDefault()});let a=null;for(let o=r.from;o<r.to;o++){let{completion:s,match:l}=t[o],{section:c}=s;if(c){let d=typeof c=="string"?c:c.name;if(d!=a&&(o>r.from||r.from==0))if(a=d,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let h=i.appendChild(document.createElement("completion-section"));h.textContent=d}}const u=i.appendChild(document.createElement("li"));u.id=n+"-"+o,u.setAttribute("role","option");let O=this.optionClass(s);O&&(u.className=O);for(let d of this.optionContent){let h=d(s,this.view.state,this.view,l);h&&u.appendChild(h)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<t.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Gtt(e,t){return n=>new Ytt(n,e,t)}function Ztt(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function lV(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Itt(e,t){let n=[],r=null,i=c=>{n.push(c);let{section:u}=c.completion;if(u){r||(r=[]);let O=typeof u=="string"?u:u.name;r.some(d=>d.name==O)||r.push(typeof u=="string"?{name:O}:u)}},a=t.facet(Pi);for(let c of e)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let O of c.result.options)i(new aV(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,h=a.filterStrict?new Utt(O):new Att(O);for(let p of c.result.options)if(d=h.match(p.label)){let g=p.displayLabel?u?u(p,d.matched):[]:d.matched;i(new aV(p,c.source,g,d.score+(p.boost||0)))}}}if(r){let c=Object.create(null),u=0,O=(d,h)=>{var p,g;return((p=d.rank)!==null&&p!==void 0?p:1e9)-((g=h.rank)!==null&&g!==void 0?g:1e9)||(d.name<h.name?-1:1)};for(let d of r.sort(O))u-=1e5,c[d.name]=u;for(let d of n){let{section:h}=d.completion;h&&(d.score+=c[typeof h=="string"?h:h.name])}}let o=[],s=null,l=a.compareCompletions;for(let c of n.sort((u,O)=>O.score-u.score||l(u.completion,O.completion))){let u=c.completion;!s||s.label!=u.label||s.detail!=u.detail||s.type!=null&&u.type!=null&&s.type!=u.type||s.apply!=u.apply||s.boost!=u.boost?o.push(c):lV(c.completion)>lV(s)&&(o[o.length-1]=c),s=c.completion}return o}class zh{constructor(t,n,r,i,a,o){this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=a,this.disabled=o}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new zh(this.options,cV(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(c=>c.isPending))return i.setDisabled();let s=Itt(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Pi).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let u=0;u<s.length;u++)if(s[u].completion==c){l=u;break}}return new zh(s,cV(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:Btt,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new zh(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new zh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Vx{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new Vx(Ltt,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Pi),a=(r.override||n.languageDataAt("autocomplete",Rd(n)).map(ztt)).map(l=>(this.active.find(u=>u.source==l)||new Bo(l,this.active.some(u=>u.state!=0)?1:0)).update(t,r));a.length==this.active.length&&a.every((l,c)=>l==this.active[c])&&(a=this.active);let o=this.open,s=t.effects.some(l=>l.is(IA));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Dtt(a,this.active)||s?o=zh.build(a,n,this.id,o,r,s):o&&o.disabled&&!a.some(l=>l.isPending)&&(o=null),!o&&a.every(l=>!l.isPending)&&a.some(l=>l.hasResult())&&(a=a.map(l=>l.hasResult()?new Bo(l.source,0):l));for(let l of t.effects)l.is(yme)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new Vx(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Vtt:Mtt}}function Dtt(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}const Vtt={"aria-autocomplete":"list"},Mtt={};function cV(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Ltt=[];function $me(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(ZA);if(r&&t.activateOnCompletion(r))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class Bo{constructor(t,n,r=!1){this.source=t,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=$me(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new Bo(i.source,0)),r&4&&i.state==0&&(i=new Bo(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(Dx))i=new Bo(i.source,1,a.value);else if(a.is(W$))i=new Bo(i.source,0);else if(a.is(IA))for(let o of a.value)o.source==i.source&&(i=o);return i}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(Rd(t.state))}}class Hh extends Bo{constructor(t,n,r,i,a,o){super(t,3,n),this.limit=r,this.result=i,this.from=a,this.to=o}hasResult(){return!0}updateFor(t,n){var r;if(!(n&3))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let a=t.changes.mapPos(this.from),o=t.changes.mapPos(this.to,1),s=Rd(t.state);if(s>o||!i||n&2&&(Rd(t.startState)==this.from||s<this.limit))return new Bo(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return Ftt(i.validFor,t.state,a,o)?new Hh(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new GA(t.state,s,!1)))?new Hh(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:Rd(t.state)):new Bo(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new Hh(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new Bo(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Ftt(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):gme(e,!0).test(i)}const IA=vn.define({map(e,t){return e.map(n=>n.map(t))}}),yme=vn.define(),Aa=La.define({create(){return Vx.start()},update(e,t){return e.update(t)},provide:e=>[CA.from(e,t=>t.tooltip),xt.contentAttributes.from(e,t=>t.attrs)]});function DA(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Aa).active.find(i=>i.source==t.source);return r instanceof Hh?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},Ctt(e.state,n,r.from,r.to)),{annotations:ZA.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const Btt=Gtt(Aa,DA);function Lb(e,t="option"){return n=>{let r=n.state.field(Aa,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Pi).interactionDelay)return!1;let i=1,a;t=="page"&&(a=Zpe(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector("li").offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t=="page"?0:o-1:s>=o&&(s=t=="page"?o-1:0),n.dispatch({effects:yme.of(s)}),!0}}const Htt=e=>{let t=e.state.field(Aa,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Pi).interactionDelay?!1:DA(e,t.open.options[t.open.selected])},uV=e=>e.state.field(Aa,!1)?(e.dispatch({effects:Dx.of(!0)}),!0):!1,Ktt=e=>{let t=e.state.field(Aa,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:W$.of(null)}),!0)};class Jtt{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const ent=50,tnt=1e3,nnt=pi.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(Aa).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Aa),n=e.state.facet(Pi);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Aa)==t)return;let r=e.transactions.some(a=>{let o=$me(a,n);return o&8||(a.selection||a.docChanged)&&!(o&3)});for(let a=0;a<this.running.length;a++){let o=this.running[a];if(r||o.context.abortOnDocChange&&e.docChanged||o.updates.length+e.transactions.length>ent&&Date.now()-o.time>tnt){for(let s of o.context.abortListeners)try{s()}catch(l){Ya(this.view.state,l)}o.context.abortListeners=null,this.running.splice(a--,1)}else o.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(a=>a.effects.some(o=>o.is(Dx)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(a=>a.isPending&&!this.running.some(o=>o.active.source==a.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let a of e.transactions)a.isUserEvent("input.type")?this.composing=2:this.composing==2&&a.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(Aa);for(let n of t.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Pi).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=Rd(t),r=new GA(t,n,e.explicit,this.view),i=new Jtt(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(a=>{i.context.aborted||(i.done=a||null,this.scheduleAccept())},a=>{this.view.dispatch({effects:W$.of(null)}),Ya(this.view.state,a)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Pi).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Pi),r=this.view.state.field(Aa);for(let i=0;i<this.running.length;i++){let a=this.running[i];if(a.done===void 0)continue;if(this.running.splice(i--,1),a.done){let s=Rd(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new Hh(a.active.source,a.active.explicit,l,a.done,a.done.from,(e=a.done.to)!==null&&e!==void 0?e:s);for(let u of a.updates)c=c.update(u,n);if(c.hasResult()){t.push(c);continue}}let o=r.active.find(s=>s.source==a.active.source);if(o&&o.isPending)if(a.done==null){let s=new Bo(a.active.source,0);for(let l of a.updates)s=s.update(l,n);s.isPending||t.push(s)}else this.startQuery(o)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:IA.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Aa,!1);if(t&&t.tooltip&&this.view.state.facet(Pi).closeOnBlur){let n=t.open&&Zpe(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:W$.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Dx.of(!1)}),20),this.composing=0}}}),rnt=typeof navigator=="object"&&/Win/.test(navigator.platform),int=QO.highest(xt.domEventHandlers({keydown(e,t){let n=t.state.field(Aa,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(rnt&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(o=>o.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&DA(t,r),!1}})),vme=xt.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"}}});class ant{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class VA{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Yi.TrackDel),r=t.mapPos(this.to,1,Yi.TrackDel);return n==null||r==null?null:new VA(this.field,n,r)}}class MA{constructor(t,n){this.lines=t,this.fieldPositions=n}instantiate(t,n){let r=[],i=[n],a=t.doc.lineAt(n),o=/^\s*/.exec(a.text)[0];for(let l of this.lines){if(r.length){let c=o,u=/^\t*/.exec(l)[0].length;for(let O=0;O<u;O++)c+=t.facet(Xk);i.push(n+c.length-u),l=c+l.slice(u)}r.push(l),n+=l.length+1}let s=this.fieldPositions.map(l=>new VA(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:s}}static parse(t){let n=[],r=[],i=[],a;for(let o of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(o);){let s=a[1]?+a[1]:null,l=a[2]||a[3]||"",c=-1,u=l.replace(/\\[{}]/g,O=>O[1]);for(let O=0;O<n.length;O++)(s!=null?n[O].seq==s:u&&n[O].name==u)&&(c=O);if(c<0){let O=0;for(;O<n.length&&(s==null||n[O].seq!=null&&n[O].seq<s);)O++;n.splice(O,0,{seq:s,name:u}),c=O;for(let d of i)d.field>=c&&d.field++}i.push(new ant(c,r.length,a.index,a.index+u.length)),o=o.slice(0,a.index)+l+o.slice(a.index+a[0].length)}o=o.replace(/\\([{}])/g,(s,l,c)=>{for(let u of i)u.line==r.length&&u.from>c&&(u.from--,u.to--);return l}),r.push(o)}return new MA(r,i)}}let ont=nn.widget({widget:new class extends au{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),snt=nn.mark({class:"cm-snippetField"});class _m{constructor(t,n){this.ranges=t,this.active=n,this.deco=nn.set(t.map(r=>(r.from==r.to?ont:snt).range(r.from,r.to)))}map(t){let n=[];for(let r of this.ranges){let i=r.map(t);if(!i)return null;n.push(i)}return new _m(n,this.active)}selectionInsideField(t){return t.ranges.every(n=>this.ranges.some(r=>r.field==this.active&&r.from<=n.from&&r.to>=n.to))}}const $v=vn.define({map(e,t){return e&&e.map(t)}}),lnt=vn.define(),N$=La.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is($v))return n.value;if(n.is(lnt)&&e)return new _m(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>xt.decorations.from(e,t=>t?t.deco:nn.none)});function LA(e,t){return Ge.create(e.filter(n=>n.field==t).map(n=>Ge.range(n.from,n.to)))}function cnt(e){let t=MA.parse(e);return(n,r,i,a)=>{let{text:o,ranges:s}=t.instantiate(n.state,i),{main:l}=n.state.selection,c={changes:{from:i,to:a==l.from?l.to:a,insert:Wn.of(o)},scrollIntoView:!0,annotations:r?[ZA.of(r),Gi.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=LA(s,0)),s.some(u=>u.field>0)){let u=new _m(s,0),O=c.effects=[$v.of(u)];n.state.field(N$,!1)===void 0&&O.push(vn.appendConfig.of([N$,hnt,pnt,vme]))}n.dispatch(n.state.update(c))}}function bme(e){return({state:t,dispatch:n})=>{let r=t.field(N$,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(o=>o.field==i+e);return n(t.update({selection:LA(r.ranges,i),effects:$v.of(a?null:new _m(r.ranges,i)),scrollIntoView:!0})),!0}}const unt=({state:e,dispatch:t})=>e.field(N$,!1)?(t(e.update({effects:$v.of(null)})),!0):!1,Ont=bme(1),dnt=bme(-1),fnt=[{key:"Tab",run:Ont,shift:dnt},{key:"Escape",run:unt}],OV=dt.define({combine(e){return e.length?e[0]:fnt}}),hnt=QO.highest(_k.compute([OV],e=>e.facet(OV)));function cr(e,t){return Object.assign(Object.assign({},t),{apply:cnt(e)})}const pnt=xt.domEventHandlers({mousedown(e,t){let n=t.state.field(N$,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(a=>a.from<=r&&a.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:LA(n.ranges,i.field),effects:$v.of(n.ranges.some(a=>a.field>i.field)?new _m(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),Y$={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},bd=vn.define({map(e,t){let n=t.mapPos(e,-1,Yi.TrackAfter);return n??void 0}}),FA=new class extends Vd{};FA.startSide=1;FA.endSide=-1;const wme=La.define({create(){return yn.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of t.effects)n.is(bd)&&(e=e.update({add:[FA.range(n.value,n.value+1)]}));return e}});function Jsn(){return[gnt,wme]}const yT="()[]{}<>«»»«[]{}";function xme(e){for(let t=0;t<yT.length;t+=2)if(yT.charCodeAt(t)==e)return yT.charAt(t+1);return Phe(e<128?e:e+1)}function Sme(e,t){return e.languageDataAt("closeBrackets",t)[0]||Y$}const mnt=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),gnt=xt.inputHandler.of((e,t,n,r)=>{if((mnt?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&yc(mo(r,0))==1||t!=i.from||n!=i.to)return!1;let a=ynt(e.state,r);return a?(e.dispatch(a),!0):!1}),$nt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Sme(e,e.selection.main.head).brackets||Y$.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=vnt(e.doc,o.head);for(let l of r)if(l==s&&jk(e.doc,o.head)==xme(mo(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Ge.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},eln=[{key:"Backspace",run:$nt}];function ynt(e,t){let n=Sme(e,e.selection.main.head),r=n.brackets||Y$.brackets;for(let i of r){let a=xme(mo(i,0));if(t==i)return a==i?xnt(e,i,r.indexOf(i+i+i)>-1,n):bnt(e,i,a,n.before||Y$.before);if(t==a&&Qme(e,e.selection.main.from))return wnt(e,i,a)}return null}function Qme(e,t){let n=!1;return e.field(wme).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function jk(e,t){let n=e.sliceString(t,t+2);return n.slice(0,yc(mo(n,0)))}function vnt(e,t){let n=e.sliceString(t-2,t);return yc(mo(n,0))==n.length?n:n.slice(1)}function bnt(e,t,n,r){let i=null,a=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:n,from:o.to}],effects:bd.of(o.to+t.length),range:Ge.range(o.anchor+t.length,o.head+t.length)};let s=jk(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:bd.of(o.head+t.length),range:Ge.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function wnt(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&jk(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Ge.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function xnt(e,t,n,r){let i=r.stringPrefixes||Y$.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:bd.of(s.to+t.length),range:Ge.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=jk(e.doc,l),u;if(c==t){if(dV(e,l))return{changes:{insert:t+t,from:l},effects:bd.of(l+t.length),range:Ge.cursor(l+t.length)};if(Qme(e,l)){let d=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+d.length,insert:d},range:Ge.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=fV(e,l-2*t.length,i))>-1&&dV(e,u))return{changes:{insert:t+t+t+t,from:l},effects:bd.of(l+t.length),range:Ge.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=Fo.Word&&fV(e,l,i)>-1&&!Snt(e,l,t,i))return{changes:{insert:t+t,from:l},effects:bd.of(l+t.length),range:Ge.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function dV(e,t){let n=Yn(e).resolveInner(t+1);return n.parent&&n.from==t}function Snt(e,t,n,r){let i=Yn(e).resolveInner(t,-1),a=r.reduce((o,s)=>Math.max(o,s.length),0);for(let o=0;o<5;o++){let s=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),l=s.indexOf(n);if(!l||l>-1&&r.indexOf(s.slice(0,l))>-1){let u=i.firstChild;for(;u&&u.from==i.from&&u.to-u.from>n.length+l;){if(e.sliceDoc(u.to-n.length,u.to)==n)return!1;u=u.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function fV(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=Fo.Word)return t;for(let i of n){let a=t-i.length;if(e.sliceDoc(a,t)==i&&r(e.sliceDoc(a-1,a))!=Fo.Word)return a}return-1}function tln(e={}){return[int,Aa,Pi.of(e),nnt,knt,vme]}const Qnt=[{key:"Ctrl-Space",run:uV},{mac:"Alt-`",run:uV},{key:"Escape",run:Ktt},{key:"ArrowDown",run:Lb(!0)},{key:"ArrowUp",run:Lb(!1)},{key:"PageDown",run:Lb(!0,"page")},{key:"PageUp",run:Lb(!1,"page")},{key:"Enter",run:Htt}],knt=QO.highest(_k.computeN([Pi],e=>e.facet(Pi).defaultKeymap?[Qnt]:[]));class Mx{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new Mx(t,n,r,o,a,[],[])}constructor(t,n,r,i,a,o,s){this.type=t,this.value=n,this.from=r,this.hash=i,this.end=a,this.children=o,this.positions=s,this.hashProp=[[jt.contextHash,i]]}addChild(t,n){t.prop(jt.contextHash)!=this.hash&&(t=new sn(t.type,t.children,t.positions,t.length,this.hashProp)),this.children.push(t),this.positions.push(n)}toTree(t,n=this.end){let r=this.children.length-1;return r>=0&&(n=Math.max(n,this.positions[r]+this.children[r].length+this.from)),new sn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new sn(ri.none,i,a,o,this.hashProp)})}}var De;(function(e){e[e.Document=1]="Document",e[e.CodeBlock=2]="CodeBlock",e[e.FencedCode=3]="FencedCode",e[e.Blockquote=4]="Blockquote",e[e.HorizontalRule=5]="HorizontalRule",e[e.BulletList=6]="BulletList",e[e.OrderedList=7]="OrderedList",e[e.ListItem=8]="ListItem",e[e.ATXHeading1=9]="ATXHeading1",e[e.ATXHeading2=10]="ATXHeading2",e[e.ATXHeading3=11]="ATXHeading3",e[e.ATXHeading4=12]="ATXHeading4",e[e.ATXHeading5=13]="ATXHeading5",e[e.ATXHeading6=14]="ATXHeading6",e[e.SetextHeading1=15]="SetextHeading1",e[e.SetextHeading2=16]="SetextHeading2",e[e.HTMLBlock=17]="HTMLBlock",e[e.LinkReference=18]="LinkReference",e[e.Paragraph=19]="Paragraph",e[e.CommentBlock=20]="CommentBlock",e[e.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",e[e.Escape=22]="Escape",e[e.Entity=23]="Entity",e[e.HardBreak=24]="HardBreak",e[e.Emphasis=25]="Emphasis",e[e.StrongEmphasis=26]="StrongEmphasis",e[e.Link=27]="Link",e[e.Image=28]="Image",e[e.InlineCode=29]="InlineCode",e[e.HTMLTag=30]="HTMLTag",e[e.Comment=31]="Comment",e[e.ProcessingInstruction=32]="ProcessingInstruction",e[e.Autolink=33]="Autolink",e[e.HeaderMark=34]="HeaderMark",e[e.QuoteMark=35]="QuoteMark",e[e.ListMark=36]="ListMark",e[e.LinkMark=37]="LinkMark",e[e.EmphasisMark=38]="EmphasisMark",e[e.CodeMark=39]="CodeMark",e[e.CodeText=40]="CodeText",e[e.CodeInfo=41]="CodeInfo",e[e.LinkTitle=42]="LinkTitle",e[e.LinkLabel=43]="LinkLabel",e[e.URL=44]="URL"})(De||(De={}));class _nt{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let Pnt=class{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let t=this.skipSpace(this.basePos);this.indent=this.countIndent(t,this.pos,this.indent),this.pos=t,this.next=t==this.text.length?-1:this.text.charCodeAt(t)}skipSpace(t){return Z0(this.text,t)}reset(t){for(this.text=t,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(t){this.basePos=t,this.baseIndent=this.countIndent(t,this.pos,this.indent)}moveBaseColumn(t){this.baseIndent=t,this.basePos=this.findColumn(t)}addMarker(t){this.markers.push(t)}countIndent(t,n=0,r=0){for(let i=n;i<t;i++)r+=this.text.charCodeAt(i)==9?4-r%4:1;return r}findColumn(t){let n=0;for(let r=0;n<this.text.length&&r<t;n++)r+=this.text.charCodeAt(n)==9?4-r%4:1;return n}scrub(){if(!this.baseIndent)return this.text;let t="";for(let n=0;n<this.basePos;n++)t+=" ";return t+this.text.slice(this.basePos)}};function hV(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==De.OrderedList?KA:HA)(n,t,!1);return r>0&&(e.type!=De.BulletList||BA(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const kme={[De.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(fn(De.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(Os(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[De.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[De.OrderedList]:hV,[De.BulletList]:hV,[De.Document](){return!0}};function Os(e){return e==32||e==9||e==10||e==13}function Z0(e,t=0){for(;t<e.length&&Os(e.charCodeAt(t));)t++;return t}function pV(e,t,n){for(;t>n&&Os(e.charCodeAt(t-1));)t--;return t}function _me(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function Pme(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function BA(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let i=e.pos+1;i<e.text.length;i++){let a=e.text.charCodeAt(i);if(a==e.next)r++;else if(!Os(a))return-1}return n&&e.next==45&&Rme(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(Cme.SetextHeading)>-1||r<3?-1:1}function Tme(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function HA(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||Os(e.text.charCodeAt(e.pos+1)))&&(!n||Tme(t,De.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function KA(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){r++;if(r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!Os(e.text.charCodeAt(r+1))||n&&!Tme(t,De.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function Xme(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function Rme(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&Os(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const W3=/^[ \t]*$/,Eme=/-->/,qme=/\?>/,N3=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Eme],[/^\s*<\?/,qme],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,W3],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,W3]];function jme(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=N3.length-(n?1:0);i<a;i++)if(N3[i][0].test(r))return i;return-1}function mV(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function JO(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==De.CodeText?e[r].to=n:e.push(fn(De.CodeText,t,n))}const Fb={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(JO(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){JO(s,e.lineStart-1,e.lineStart);for(let l of t.markers)s.push(l)}else{if(t.indent<n)break;{if(s.length){for(let c of s)c.type==De.CodeText?JO(o,c.from,c.to):o.push(c);s=[]}JO(o,e.lineStart-1,e.lineStart);for(let c of t.markers)o.push(c);a=e.lineStart+t.text.length;let l=e.lineStart+t.findColumn(t.baseIndent+4);l<a&&JO(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=De.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(De.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=_me(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=pV(t.text,t.text.length,o),l=[fn(De.CodeMark,r,r+a)];o<s&&l.push(fn(De.CodeInfo,e.lineStart+o,e.lineStart+s));for(let c=!0;e.nextLine()&&t.depth>=e.stack.length;c=!1){let u=t.pos;if(t.indent-t.baseIndent<4)for(;u<t.text.length&&t.text.charCodeAt(u)==i;)u++;if(u-t.pos>=a&&t.skipSpace(u)==t.text.length){for(let O of t.markers)l.push(O);l.push(fn(De.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||JO(l,e.lineStart-1,e.lineStart);for(let h of t.markers)l.push(h);let O=e.lineStart+t.basePos,d=e.lineStart+t.text.length;O<d&&JO(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(De.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=Pme(t);return n<0?!1:(e.startContext(De.Blockquote,t.pos),e.addNode(De.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(BA(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(De.HorizontalRule,n),!0},BulletList(e,t){let n=HA(t,e,!1);if(n<0)return!1;e.block.type!=De.BulletList&&e.startContext(De.BulletList,t.basePos,t.next);let r=mV(t,t.pos+1);return e.startContext(De.ListItem,t.basePos,r-t.baseIndent),e.addNode(De.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=KA(t,e,!1);if(n<0)return!1;e.block.type!=De.OrderedList&&e.startContext(De.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=mV(t,t.pos+n);return e.startContext(De.ListItem,t.basePos,r-t.baseIndent),e.addNode(De.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=Xme(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=pV(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!Os(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(De.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(De.HeaderMark,o-r,a-r);let l=s.finish(De.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=jme(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=N3[n][1],a=[],o=i!=W3;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let c of t.markers)a.push(c)}o&&e.nextLine();let s=i==Eme?De.CommentBlock:i==qme?De.ProcessingInstructionBlock:De.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class Tnt{constructor(t){this.stage=0,this.elts=[],this.pos=0,this.start=t.start,this.advance(t.content)}nextLine(t,n,r){if(this.stage==-1)return!1;let i=r.content+`
|
|
837
|
+
`);r>-1&&(n=n.slice(0,r))}return t+n.length<=this.to?n:n.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,n=this.lineAfter(t),r=t+n.length;for(let i=this.rangeIndex;;){let a=this.ranges[i].to;if(a>=r||(n=n.slice(0,a-(r-n.length)),i++,i==this.ranges.length))break;let o=this.ranges[i].from,s=this.lineAfter(o);n+=s,r=o+s.length}return{line:n,end:r}}skipGapsTo(t,n,r){for(;;){let i=this.ranges[this.rangeIndex].to,a=t+n;if(r>0?i>a:i>=a)break;let o=this.ranges[++this.rangeIndex].from;n+=o-i}return n}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,n,r,i){let a=4;if(this.ranges.length>1){i=this.skipGapsTo(n,i,1),n+=i;let s=this.chunk.length;i=this.skipGapsTo(r,i,-1),r+=i,a+=this.chunk.length-s}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&a==4&&o>=0&&this.chunk[o]==t&&this.chunk[o+2]==n?this.chunk[o+2]=r:this.chunk.push(t,n,r,a),i}parseLine(t){let{line:n,end:r}=this.nextLine(),i=0,{streamParser:a}=this.lang,o=new Ome(n,t?t.state.tabSize:4,t?Gx(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=fme(a.token,o,this.state);if(s&&(i=this.emitToken(this.lang.tokenTable.resolve(s),this.parsedPos+o.start,this.parsedPos+o.pos,i)),o.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=sn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Xtt,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new sn(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new sn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function fme(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let i=e(t,n);if(t.pos>t.start)return i}throw new Error("Stream parser failed to advance stream.")}const YA=Object.create(null),U$=[ri.none],Xtt=new Qm(U$),nV=[],rV=Object.create(null),hme=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"]])hme[e]=mme(YA,t);class pme{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),hme)}resolve(t){return t?this.table[t]||(this.table[t]=mme(this.extra,t)):0}}const Rtt=new pme(YA);function gT(e,t){nV.indexOf(e)>-1||(nV.push(e),console.warn(t))}function mme(e,t){let n=[];for(let s of t.split(" ")){let l=[];for(let c of s.split(".")){let u=e[c]||_[c];u?typeof u=="function"?l.length?l=l.map(u):gT(c,`Modifier ${c} used at start of tag`):l.length?gT(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:gT(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(s=>s.id),a=rV[i];if(a)return a.id;let o=rV[i]=ri.define({id:U$.length,name:r,props:[kn({[r]:n})]});return U$.push(o),o.id}function Ett(e,t){let n=ri.define({id:U$.length,name:"Document",props:[Vu.add(()=>e),Xr.add(()=>r=>t.getIndent(r))],top:!0});return U$.push(n),n}yr.RTL,yr.LTR;function Ee(e){return new hn(Ce.define(e))}function bu(e){return be(()=>Promise.resolve().then(()=>nOt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const qtt=[ge.of({name:"C",extensions:["c","h","ino"],load(){return be(()=>Promise.resolve().then(()=>LM),void 0,import.meta.url).then(e=>e.cpp())}}),ge.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return be(()=>Promise.resolve().then(()=>LM),void 0,import.meta.url).then(e=>e.cpp())}}),ge.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return bu("Cassandra")}}),ge.of({name:"CSS",extensions:["css"],load(){return be(()=>Promise.resolve().then(()=>git),void 0,import.meta.url).then(e=>e.css())}}),ge.of({name:"Go",extensions:["go"],load(){return be(()=>import("./index-Bw2_HcHz.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(e=>e.go())}}),ge.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return be(()=>Promise.resolve().then(()=>lat),void 0,import.meta.url).then(e=>e.html())}}),ge.of({name:"Java",extensions:["java"],load(){return be(()=>Promise.resolve().then(()=>oOt),void 0,import.meta.url).then(e=>e.java())}}),ge.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return be(()=>Promise.resolve().then(()=>Hb),void 0,import.meta.url).then(e=>e.javascript())}}),ge.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return be(()=>Promise.resolve().then(()=>fot),void 0,import.meta.url).then(e=>e.json())}}),ge.of({name:"JSX",extensions:["jsx"],load(){return be(()=>Promise.resolve().then(()=>Hb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),ge.of({name:"LESS",extensions:["less"],load(){return be(()=>Promise.resolve().then(()=>Tat),void 0,import.meta.url).then(e=>e.less())}}),ge.of({name:"Liquid",extensions:["liquid"],load(){return be(()=>Promise.resolve().then(()=>Dft),void 0,import.meta.url).then(e=>e.liquid())}}),ge.of({name:"MariaDB SQL",load(){return bu("MariaSQL")}}),ge.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return be(()=>Promise.resolve().then(()=>$at),void 0,import.meta.url).then(e=>e.markdown())}}),ge.of({name:"MS SQL",load(){return bu("MSSQL")}}),ge.of({name:"MySQL",load(){return bu("MySQL")}}),ge.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return be(()=>Promise.resolve().then(()=>wft),void 0,import.meta.url).then(e=>e.php())}}),ge.of({name:"PLSQL",extensions:["pls"],load(){return bu("PLSQL")}}),ge.of({name:"PostgreSQL",load(){return bu("PostgreSQL")}}),ge.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return be(()=>Promise.resolve().then(()=>Dct),void 0,import.meta.url).then(e=>e.python())}}),ge.of({name:"Rust",extensions:["rs"],load(){return be(()=>Promise.resolve().then(()=>kOt),void 0,import.meta.url).then(e=>e.rust())}}),ge.of({name:"Sass",extensions:["sass"],load(){return be(()=>Promise.resolve().then(()=>cM),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),ge.of({name:"SCSS",extensions:["scss"],load(){return be(()=>Promise.resolve().then(()=>cM),void 0,import.meta.url).then(e=>e.sass())}}),ge.of({name:"SQL",extensions:["sql"],load(){return bu("StandardSQL")}}),ge.of({name:"SQLite",load(){return bu("SQLite")}}),ge.of({name:"TSX",extensions:["tsx"],load(){return be(()=>Promise.resolve().then(()=>Hb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),ge.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return be(()=>Promise.resolve().then(()=>Hb),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),ge.of({name:"WebAssembly",extensions:["wat","wast"],load(){return be(()=>Promise.resolve().then(()=>Lft),void 0,import.meta.url).then(e=>e.wast())}}),ge.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return be(()=>Promise.resolve().then(()=>fut),void 0,import.meta.url).then(e=>e.xml())}}),ge.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return be(()=>import("./index-Cbu_OqUM.js"),__vite__mapDeps([6,1,2,3,4,5]),import.meta.url).then(e=>e.yaml())}}),ge.of({name:"APL",extensions:["dyalog","apl"],load(){return be(()=>Promise.resolve().then(()=>xmt),void 0,import.meta.url).then(e=>Ee(e.apl))}}),ge.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return be(()=>Promise.resolve().then(()=>Smt),void 0,import.meta.url).then(e=>Ee(e.asciiArmor))}}),ge.of({name:"ASN.1",extensions:["asn","asn1"],load(){return be(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>Ee(e.asn1({})))}}),ge.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return be(()=>Promise.resolve().then(()=>Tmt),void 0,import.meta.url).then(e=>Ee(e.asterisk))}}),ge.of({name:"Brainfuck",extensions:["b","bf"],load(){return be(()=>Promise.resolve().then(()=>Rmt),void 0,import.meta.url).then(e=>Ee(e.brainfuck))}}),ge.of({name:"Cobol",extensions:["cob","cpy"],load(){return be(()=>Promise.resolve().then(()=>agt),void 0,import.meta.url).then(e=>Ee(e.cobol))}}),ge.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return be(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Ee(e.csharp))}}),ge.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return be(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Ee(e.clojure))}}),ge.of({name:"ClojureScript",extensions:["cljs"],load(){return be(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Ee(e.clojure))}}),ge.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return be(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>Ee(e.gss))}}),ge.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return be(()=>Promise.resolve().then(()=>Bmt),void 0,import.meta.url).then(e=>Ee(e.cmake))}}),ge.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return be(()=>Promise.resolve().then(()=>$gt),void 0,import.meta.url).then(e=>Ee(e.coffeeScript))}}),ge.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return be(()=>Promise.resolve().then(()=>Sgt),void 0,import.meta.url).then(e=>Ee(e.commonLisp))}}),ge.of({name:"Cypher",extensions:["cyp","cypher"],load(){return be(()=>Promise.resolve().then(()=>Ggt),void 0,import.meta.url).then(e=>Ee(e.cypher))}}),ge.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return be(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>Ee(e.cython))}}),ge.of({name:"Crystal",extensions:["cr"],load(){return be(()=>Promise.resolve().then(()=>zgt),void 0,import.meta.url).then(e=>Ee(e.crystal))}}),ge.of({name:"D",extensions:["d"],load(){return be(()=>Promise.resolve().then(()=>Fgt),void 0,import.meta.url).then(e=>Ee(e.d))}}),ge.of({name:"Dart",extensions:["dart"],load(){return be(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Ee(e.dart))}}),ge.of({name:"diff",extensions:["diff","patch"],load(){return be(()=>Promise.resolve().then(()=>Bgt),void 0,import.meta.url).then(e=>Ee(e.diff))}}),ge.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return be(()=>Promise.resolve().then(()=>c0t),void 0,import.meta.url).then(e=>Ee(e.dockerFile))}}),ge.of({name:"DTD",extensions:["dtd"],load(){return be(()=>Promise.resolve().then(()=>d0t),void 0,import.meta.url).then(e=>Ee(e.dtd))}}),ge.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return be(()=>Promise.resolve().then(()=>g0t),void 0,import.meta.url).then(e=>Ee(e.dylan))}}),ge.of({name:"EBNF",load(){return be(()=>Promise.resolve().then(()=>$0t),void 0,import.meta.url).then(e=>Ee(e.ebnf))}}),ge.of({name:"ECL",extensions:["ecl"],load(){return be(()=>Promise.resolve().then(()=>k0t),void 0,import.meta.url).then(e=>Ee(e.ecl))}}),ge.of({name:"edn",extensions:["edn"],load(){return be(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Ee(e.clojure))}}),ge.of({name:"Eiffel",extensions:["e"],load(){return be(()=>Promise.resolve().then(()=>E0t),void 0,import.meta.url).then(e=>Ee(e.eiffel))}}),ge.of({name:"Elm",extensions:["elm"],load(){return be(()=>Promise.resolve().then(()=>Z0t),void 0,import.meta.url).then(e=>Ee(e.elm))}}),ge.of({name:"Erlang",extensions:["erl"],load(){return be(()=>Promise.resolve().then(()=>f$t),void 0,import.meta.url).then(e=>Ee(e.erlang))}}),ge.of({name:"Esper",load(){return be(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>Ee(e.esper))}}),ge.of({name:"Factor",extensions:["factor"],load(){return be(()=>Promise.resolve().then(()=>h$t),void 0,import.meta.url).then(e=>Ee(e.factor))}}),ge.of({name:"FCL",load(){return be(()=>Promise.resolve().then(()=>y$t),void 0,import.meta.url).then(e=>Ee(e.fcl))}}),ge.of({name:"Forth",extensions:["forth","fth","4th"],load(){return be(()=>Promise.resolve().then(()=>w$t),void 0,import.meta.url).then(e=>Ee(e.forth))}}),ge.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return be(()=>Promise.resolve().then(()=>T$t),void 0,import.meta.url).then(e=>Ee(e.fortran))}}),ge.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return be(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Ee(e.fSharp))}}),ge.of({name:"Gas",extensions:["s"],load(){return be(()=>Promise.resolve().then(()=>R$t),void 0,import.meta.url).then(e=>Ee(e.gas))}}),ge.of({name:"Gherkin",extensions:["feature"],load(){return be(()=>Promise.resolve().then(()=>E$t),void 0,import.meta.url).then(e=>Ee(e.gherkin))}}),ge.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return be(()=>Promise.resolve().then(()=>Z$t),void 0,import.meta.url).then(e=>Ee(e.groovy))}}),ge.of({name:"Haskell",extensions:["hs"],load(){return be(()=>Promise.resolve().then(()=>B$t),void 0,import.meta.url).then(e=>Ee(e.haskell))}}),ge.of({name:"Haxe",extensions:["hx"],load(){return be(()=>Promise.resolve().then(()=>gF),void 0,import.meta.url).then(e=>Ee(e.haxe))}}),ge.of({name:"HXML",extensions:["hxml"],load(){return be(()=>Promise.resolve().then(()=>gF),void 0,import.meta.url).then(e=>Ee(e.hxml))}}),ge.of({name:"HTTP",load(){return be(()=>Promise.resolve().then(()=>yyt),void 0,import.meta.url).then(e=>Ee(e.http))}}),ge.of({name:"IDL",extensions:["pro"],load(){return be(()=>Promise.resolve().then(()=>kyt),void 0,import.meta.url).then(e=>Ee(e.idl))}}),ge.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return be(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>Ee(e.jsonld))}}),ge.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return be(()=>Promise.resolve().then(()=>Xyt),void 0,import.meta.url).then(e=>Ee(e.jinja2))}}),ge.of({name:"Julia",extensions:["jl"],load(){return be(()=>Promise.resolve().then(()=>tvt),void 0,import.meta.url).then(e=>Ee(e.julia))}}),ge.of({name:"Kotlin",extensions:["kt","kts"],load(){return be(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Ee(e.kotlin))}}),ge.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return be(()=>Promise.resolve().then(()=>avt),void 0,import.meta.url).then(e=>Ee(e.liveScript))}}),ge.of({name:"Lua",extensions:["lua"],load(){return be(()=>Promise.resolve().then(()=>fvt),void 0,import.meta.url).then(e=>Ee(e.lua))}}),ge.of({name:"mIRC",extensions:["mrc"],load(){return be(()=>Promise.resolve().then(()=>zvt),void 0,import.meta.url).then(e=>Ee(e.mirc))}}),ge.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return be(()=>Promise.resolve().then(()=>bvt),void 0,import.meta.url).then(e=>Ee(e.mathematica))}}),ge.of({name:"Modelica",extensions:["mo"],load(){return be(()=>Promise.resolve().then(()=>Vvt),void 0,import.meta.url).then(e=>Ee(e.modelica))}}),ge.of({name:"MUMPS",extensions:["mps"],load(){return be(()=>Promise.resolve().then(()=>lbt),void 0,import.meta.url).then(e=>Ee(e.mumps))}}),ge.of({name:"Mbox",extensions:["mbox"],load(){return be(()=>Promise.resolve().then(()=>qvt),void 0,import.meta.url).then(e=>Ee(e.mbox))}}),ge.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return be(()=>Promise.resolve().then(()=>fbt),void 0,import.meta.url).then(e=>Ee(e.nginx))}}),ge.of({name:"NSIS",extensions:["nsh","nsi"],load(){return be(()=>Promise.resolve().then(()=>hbt),void 0,import.meta.url).then(e=>Ee(e.nsis))}}),ge.of({name:"NTriples",extensions:["nt","nq"],load(){return be(()=>Promise.resolve().then(()=>pbt),void 0,import.meta.url).then(e=>Ee(e.ntriples))}}),ge.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return be(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Ee(e.objectiveC))}}),ge.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return be(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Ee(e.objectiveCpp))}}),ge.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return be(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Ee(e.oCaml))}}),ge.of({name:"Octave",extensions:["m"],load(){return be(()=>Promise.resolve().then(()=>kbt),void 0,import.meta.url).then(e=>Ee(e.octave))}}),ge.of({name:"Oz",extensions:["oz"],load(){return be(()=>Promise.resolve().then(()=>Ubt),void 0,import.meta.url).then(e=>Ee(e.oz))}}),ge.of({name:"Pascal",extensions:["p","pas"],load(){return be(()=>Promise.resolve().then(()=>Ibt),void 0,import.meta.url).then(e=>Ee(e.pascal))}}),ge.of({name:"Perl",extensions:["pl","pm"],load(){return be(()=>Promise.resolve().then(()=>Dbt),void 0,import.meta.url).then(e=>Ee(e.perl))}}),ge.of({name:"Pig",extensions:["pig"],load(){return be(()=>Promise.resolve().then(()=>Lbt),void 0,import.meta.url).then(e=>Ee(e.pig))}}),ge.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return be(()=>Promise.resolve().then(()=>uwt),void 0,import.meta.url).then(e=>Ee(e.powerShell))}}),ge.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return be(()=>Promise.resolve().then(()=>Owt),void 0,import.meta.url).then(e=>Ee(e.properties))}}),ge.of({name:"ProtoBuf",extensions:["proto"],load(){return be(()=>Promise.resolve().then(()=>mwt),void 0,import.meta.url).then(e=>Ee(e.protobuf))}}),ge.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return be(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([7,8]),import.meta.url).then(e=>Ee(e.pug))}}),ge.of({name:"Puppet",extensions:["pp"],load(){return be(()=>Promise.resolve().then(()=>ywt),void 0,import.meta.url).then(e=>Ee(e.puppet))}}),ge.of({name:"Q",extensions:["q"],load(){return be(()=>Promise.resolve().then(()=>_wt),void 0,import.meta.url).then(e=>Ee(e.q))}}),ge.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return be(()=>Promise.resolve().then(()=>jwt),void 0,import.meta.url).then(e=>Ee(e.r))}}),ge.of({name:"RPM Changes",load(){return be(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Ee(e.rpmChanges))}}),ge.of({name:"RPM Spec",extensions:["spec"],load(){return be(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Ee(e.rpmSpec))}}),ge.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return be(()=>Promise.resolve().then(()=>Zwt),void 0,import.meta.url).then(e=>Ee(e.ruby))}}),ge.of({name:"SAS",extensions:["sas"],load(){return be(()=>Promise.resolve().then(()=>Mwt),void 0,import.meta.url).then(e=>Ee(e.sas))}}),ge.of({name:"Scala",extensions:["scala"],load(){return be(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Ee(e.scala))}}),ge.of({name:"Scheme",extensions:["scm","ss"],load(){return be(()=>Promise.resolve().then(()=>o1t),void 0,import.meta.url).then(e=>Ee(e.scheme))}}),ge.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return be(()=>Promise.resolve().then(()=>u1t),void 0,import.meta.url).then(e=>Ee(e.shell))}}),ge.of({name:"Sieve",extensions:["siv","sieve"],load(){return be(()=>Promise.resolve().then(()=>p1t),void 0,import.meta.url).then(e=>Ee(e.sieve))}}),ge.of({name:"Smalltalk",extensions:["st"],load(){return be(()=>Promise.resolve().then(()=>$1t),void 0,import.meta.url).then(e=>Ee(e.smalltalk))}}),ge.of({name:"Solr",load(){return be(()=>Promise.resolve().then(()=>Q1t),void 0,import.meta.url).then(e=>Ee(e.solr))}}),ge.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return be(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Ee(e.sml))}}),ge.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return be(()=>Promise.resolve().then(()=>E1t),void 0,import.meta.url).then(e=>Ee(e.sparql))}}),ge.of({name:"Spreadsheet",alias:["excel","formula"],load(){return be(()=>Promise.resolve().then(()=>q1t),void 0,import.meta.url).then(e=>Ee(e.spreadsheet))}}),ge.of({name:"Squirrel",extensions:["nut"],load(){return be(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Ee(e.squirrel))}}),ge.of({name:"Stylus",extensions:["styl"],load(){return be(()=>Promise.resolve().then(()=>txt),void 0,import.meta.url).then(e=>Ee(e.stylus))}}),ge.of({name:"Swift",extensions:["swift"],load(){return be(()=>Promise.resolve().then(()=>bxt),void 0,import.meta.url).then(e=>Ee(e.swift))}}),ge.of({name:"sTeX",load(){return be(()=>Promise.resolve().then(()=>lB),void 0,import.meta.url).then(e=>Ee(e.stex))}}),ge.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return be(()=>Promise.resolve().then(()=>lB),void 0,import.meta.url).then(e=>Ee(e.stex))}}),ge.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return be(()=>Promise.resolve().then(()=>PB),void 0,import.meta.url).then(e=>Ee(e.verilog))}}),ge.of({name:"Tcl",extensions:["tcl"],load(){return be(()=>Promise.resolve().then(()=>Qxt),void 0,import.meta.url).then(e=>Ee(e.tcl))}}),ge.of({name:"Textile",extensions:["textile"],load(){return be(()=>Promise.resolve().then(()=>Txt),void 0,import.meta.url).then(e=>Ee(e.textile))}}),ge.of({name:"TiddlyWiki",load(){return be(()=>Promise.resolve().then(()=>Bxt),void 0,import.meta.url).then(e=>Ee(e.tiddlyWiki))}}),ge.of({name:"Tiki wiki",load(){return be(()=>Promise.resolve().then(()=>rSt),void 0,import.meta.url).then(e=>Ee(e.tiki))}}),ge.of({name:"TOML",extensions:["toml"],load(){return be(()=>Promise.resolve().then(()=>iSt),void 0,import.meta.url).then(e=>Ee(e.toml))}}),ge.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return be(()=>Promise.resolve().then(()=>sSt),void 0,import.meta.url).then(e=>Ee(e.troff))}}),ge.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return be(()=>Promise.resolve().then(()=>QSt),void 0,import.meta.url).then(e=>Ee(e.ttcn))}}),ge.of({name:"TTCN_CFG",extensions:["cfg"],load(){return be(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>Ee(e.ttcnCfg))}}),ge.of({name:"Turtle",extensions:["ttl"],load(){return be(()=>Promise.resolve().then(()=>PSt),void 0,import.meta.url).then(e=>Ee(e.turtle))}}),ge.of({name:"Web IDL",extensions:["webidl"],load(){return be(()=>Promise.resolve().then(()=>bQt),void 0,import.meta.url).then(e=>Ee(e.webIDL))}}),ge.of({name:"VB.NET",extensions:["vb"],load(){return be(()=>Promise.resolve().then(()=>ZSt),void 0,import.meta.url).then(e=>Ee(e.vb))}}),ge.of({name:"VBScript",extensions:["vbs"],load(){return be(()=>Promise.resolve().then(()=>DSt),void 0,import.meta.url).then(e=>Ee(e.vbScript))}}),ge.of({name:"Velocity",extensions:["vtl"],load(){return be(()=>Promise.resolve().then(()=>LSt),void 0,import.meta.url).then(e=>Ee(e.velocity))}}),ge.of({name:"Verilog",extensions:["v"],load(){return be(()=>Promise.resolve().then(()=>PB),void 0,import.meta.url).then(e=>Ee(e.verilog))}}),ge.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return be(()=>Promise.resolve().then(()=>rQt),void 0,import.meta.url).then(e=>Ee(e.vhdl))}}),ge.of({name:"XQuery",extensions:["xy","xquery"],load(){return be(()=>Promise.resolve().then(()=>RQt),void 0,import.meta.url).then(e=>Ee(e.xQuery))}}),ge.of({name:"Yacas",extensions:["ys"],load(){return be(()=>Promise.resolve().then(()=>YQt),void 0,import.meta.url).then(e=>Ee(e.yacas))}}),ge.of({name:"Z80",extensions:["z80"],load(){return be(()=>Promise.resolve().then(()=>VQt),void 0,import.meta.url).then(e=>Ee(e.z80))}}),ge.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return be(()=>Promise.resolve().then(()=>x2),void 0,import.meta.url).then(e=>Ee(e.mscgen))}}),ge.of({name:"Xù",extensions:["xu"],load(){return be(()=>Promise.resolve().then(()=>x2),void 0,import.meta.url).then(e=>Ee(e.xu))}}),ge.of({name:"MsGenny",extensions:["msgenny"],load(){return be(()=>Promise.resolve().then(()=>x2),void 0,import.meta.url).then(e=>Ee(e.msgenny))}}),ge.of({name:"Vue",extensions:["vue"],load(){return be(()=>Promise.resolve().then(()=>nht),void 0,import.meta.url).then(e=>e.vue())}}),ge.of({name:"Angular Template",load(){return be(()=>Promise.resolve().then(()=>bht),void 0,import.meta.url).then(e=>e.angular())}})];class GA{constructor(t,n,r,i){this.state=t,this.pos=n,this.explicit=r,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let n=Yn(this.state).resolveInner(this.pos,-1);for(;n&&t.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(t){let n=this.state.doc.lineAt(this.pos),r=Math.max(n.from,this.pos-250),i=n.text.slice(r-n.from,this.pos-n.from),a=i.search(gme(t,!1));return a<0?null:{from:r+a,to:this.pos,text:i.slice(a)}}get aborted(){return this.abortListeners==null}addEventListener(t,n,r){t=="abort"&&this.abortListeners&&(this.abortListeners.push(n),r&&r.onDocChange&&(this.abortOnDocChange=!0))}}function iV(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function jtt(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let a=1;a<i.length;a++)n[i[a]]=!0}let r=iV(t)+iV(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function gv(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:jtt(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function qk(e,t){return n=>{for(let r=Yn(n.state).resolveInner(n.pos,-1);r;r=r.parent){if(e.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return t(n)}}class aV{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function Rd(e){return e.selection.main.from}function gme(e,t){var n;let{source:r}=e,i=t&&r[0]!="^",a=r[r.length-1]!="$";return!i&&!a?e:new RegExp(`${i?"^":""}(?:${r})${a?"$":""}`,(n=e.flags)!==null&&n!==void 0?n:e.ignoreCase?"i":"")}const ZA=bf.define();function Ctt(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return Object.assign(Object.assign({},e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let l=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:l},range:Ge.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const oV=new WeakMap;function ztt(e){if(!Array.isArray(e))return e;let t=oV.get(e);return t||oV.set(e,t=gv(e)),t}const Dx=vn.define(),W$=vn.define();class Att{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<t.length;){let r=mo(t,n),i=yc(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(mo(o==a?a.toLowerCase():o,0)),n+=i}this.astral=t.length!=this.chars.length}ret(t,n){return this.score=t,this.matched=n,this}match(t){if(this.pattern.length==0)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:n,folded:r,any:i,precise:a,byWord:o}=this;if(n.length==1){let b=mo(t,0),x=yc(b),Q=x==t.length?0:-100;if(b!=n[0])if(b==r[0])Q+=-200;else return null;return this.ret(Q,[0,x])}let s=t.indexOf(this.pattern);if(s==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(s<0){for(let b=0,x=Math.min(t.length,200);b<x&&c<l;){let Q=mo(t,b);(Q==n[c]||Q==r[c])&&(i[c++]=b),b+=yc(Q)}if(c<l)return null}let u=0,O=0,d=!1,h=0,p=-1,g=-1,y=/[a-z]/.test(t),v=!0;for(let b=0,x=Math.min(t.length,200),Q=0;b<x&&O<l;){let w=mo(t,b);s<0&&(u<l&&w==n[u]&&(a[u++]=b),h<l&&(w==n[h]||w==r[h]?(h==0&&(p=b),g=b+1,h++):h=0));let S,k=w<255?w>=48&&w<=57||w>=97&&w<=122?2:w>=65&&w<=90?1:0:(S=Phe(w))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!b||k==1&&y||Q==0&&k!=0)&&(n[O]==w||r[O]==w&&(d=!0)?o[O++]=b:o.length&&(v=!1)),Q=k,b+=yc(w)}return O==l&&o[0]==0&&v?this.result(-100+(d?-200:0),o,t):h==l&&p==0?this.ret(-200-t.length+(g==t.length?0:-100),[0,g]):s>-1?this.ret(-700-t.length,[s,s+this.pattern.length]):h==l?this.ret(-900-t.length,[p,g]):O==l?this.result(-100+(d?-200:0)+-700+(v?0:-1100),o,t):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,t)}result(t,n,r){let i=[],a=0;for(let o of n){let s=o+(this.astral?yc(mo(r,o)):1);a&&i[a-1]==o?i[a-1]=s:(i[a++]=o,i[a++]=s)}return this.ret(t-r.length,i)}}class Utt{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let n=t.slice(0,this.pattern.length),r=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return r==null?null:(this.matched=[0,n.length],this.score=r+(t.length==this.pattern.length?0:-100),this)}}const Pi=dt.define({combine(e){return km(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Wtt,filterStrict:!1,compareCompletions:(t,n)=>t.label.localeCompare(n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,n)=>t&&n,closeOnBlur:(t,n)=>t&&n,icons:(t,n)=>t&&n,tooltipClass:(t,n)=>r=>sV(t(r),n(r)),optionClass:(t,n)=>r=>sV(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function sV(e,t){return e?t?e+" "+t:e:t}function Wtt(e,t,n,r,i,a){let o=e.textDirection==yr.RTL,s=o,l=!1,c="top",u,O,d=t.left-i.left,h=i.right-t.right,p=r.right-r.left,g=r.bottom-r.top;if(s&&d<Math.min(p,h)?s=!1:!s&&h<Math.min(p,d)&&(s=!0),p<=(s?d:h))u=Math.max(i.top,Math.min(n.top,i.bottom-g))-t.top,O=Math.min(400,s?d:h);else{l=!0,O=Math.min(400,(o?t.right:i.right-t.left)-30);let b=i.bottom-t.bottom;b>=g||b>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let y=(t.bottom-t.top)/a.offsetHeight,v=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/y}px; max-width: ${O/v}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function Ntt(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),t.push({render(n,r,i,a){let o=document.createElement("span");o.className="cm-completionLabel";let s=n.displayLabel||n.label,l=0;for(let c=0;c<a.length;){let u=a[c++],O=a[c++];u>l&&o.appendChild(document.createTextNode(s.slice(l,u)));let d=o.appendChild(document.createElement("span"));d.appendChild(document.createTextNode(s.slice(u,O))),d.className="cm-completionMatchedText",l=O}return l<s.length&&o.appendChild(document.createTextNode(s.slice(l))),o},position:50},{render(n){if(!n.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=n.detail,r},position:80}),t.sort((n,r)=>n.position-r.position).map(n=>n.render)}function $T(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let i=Math.floor(t/n);return{from:i*n,to:(i+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}class Ytt{constructor(t,n,r){this.view=t,this.stateField=n,this.applyCompletion=r,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let i=t.state.field(n),{options:a,selected:o}=i.open,s=t.state.facet(Pi);this.optionContent=Ntt(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=$T(a.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=t.state.field(n).open;for(let u=l.target,O;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(O=/-(\d+)$/.exec(u.id))&&+O[1]<c.length){this.applyCompletion(t,c[+O[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=t.state.field(this.stateField,!1);c&&c.tooltip&&t.state.facet(Pi).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:W$.of(null)})}),this.showOptions(a,i.id)}mount(){this.updateSel()}showOptions(t,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(t){var n;let r=t.state.field(this.stateField),i=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),r!=i){let{options:a,selected:o,disabled:s}=r.open;(!i.open||i.open.options!=a)&&(this.range=$T(a.length,o,t.state.facet(Pi).maxRenderedOptions),this.showOptions(a,r.id)),this.updateSel(),s!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(t){let n=this.tooltipClass(t);if(n!=this.currentClass){for(let r of this.currentClass.split(" "))r&&this.dom.classList.remove(r);for(let r of n.split(" "))r&&this.dom.classList.add(r);this.currentClass=n}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),n=t.open;if((n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=$T(n.options.length,n.selected,this.view.state.facet(Pi).maxRenderedOptions),this.showOptions(n.options,t.id)),this.updateSelectedOption(n.selected)){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:i}=r;if(!i)return;let a=typeof i=="string"?document.createTextNode(i):i(r);if(!a)return;"then"in a?a.then(o=>{o&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(o,r)}).catch(o=>Ya(this.view.state,o,"completion info")):this.addInfoPane(a,r)}}addInfoPane(t,n){this.destroyInfo();let r=this.info=document.createElement("div");if(r.className="cm-tooltip cm-completionInfo",t.nodeType!=null)r.appendChild(t),this.infoDestroy=null;else{let{dom:i,destroy:a}=t;r.appendChild(i),this.infoDestroy=a||null}this.dom.appendChild(r),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let n=null;for(let r=this.list.firstChild,i=this.range.from;r;r=r.nextSibling,i++)r.nodeName!="LI"||!r.id?i--:i==t?r.hasAttribute("aria-selected")||(r.setAttribute("aria-selected","true"),n=r):r.hasAttribute("aria-selected")&&r.removeAttribute("aria-selected");return n&&Ztt(this.list,n),n}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let n=this.dom.getBoundingClientRect(),r=this.info.getBoundingClientRect(),i=t.getBoundingClientRect(),a=this.space;if(!a){let o=this.dom.ownerDocument.documentElement;a={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return i.top>Math.min(a.bottom,n.bottom)-10||i.bottom<Math.max(a.top,n.top)+10?null:this.view.state.facet(Pi).positionInfo(this.view,n,i,r,a,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,n,r){const i=document.createElement("ul");i.id=n,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",o=>{o.target==i&&o.preventDefault()});let a=null;for(let o=r.from;o<r.to;o++){let{completion:s,match:l}=t[o],{section:c}=s;if(c){let d=typeof c=="string"?c:c.name;if(d!=a&&(o>r.from||r.from==0))if(a=d,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let h=i.appendChild(document.createElement("completion-section"));h.textContent=d}}const u=i.appendChild(document.createElement("li"));u.id=n+"-"+o,u.setAttribute("role","option");let O=this.optionClass(s);O&&(u.className=O);for(let d of this.optionContent){let h=d(s,this.view.state,this.view,l);h&&u.appendChild(h)}}return r.from&&i.classList.add("cm-completionListIncompleteTop"),r.to<t.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Gtt(e,t){return n=>new Ytt(n,e,t)}function Ztt(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function lV(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Itt(e,t){let n=[],r=null,i=c=>{n.push(c);let{section:u}=c.completion;if(u){r||(r=[]);let O=typeof u=="string"?u:u.name;r.some(d=>d.name==O)||r.push(typeof u=="string"?{name:O}:u)}},a=t.facet(Pi);for(let c of e)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let O of c.result.options)i(new aV(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,h=a.filterStrict?new Utt(O):new Att(O);for(let p of c.result.options)if(d=h.match(p.label)){let g=p.displayLabel?u?u(p,d.matched):[]:d.matched;i(new aV(p,c.source,g,d.score+(p.boost||0)))}}}if(r){let c=Object.create(null),u=0,O=(d,h)=>{var p,g;return((p=d.rank)!==null&&p!==void 0?p:1e9)-((g=h.rank)!==null&&g!==void 0?g:1e9)||(d.name<h.name?-1:1)};for(let d of r.sort(O))u-=1e5,c[d.name]=u;for(let d of n){let{section:h}=d.completion;h&&(d.score+=c[typeof h=="string"?h:h.name])}}let o=[],s=null,l=a.compareCompletions;for(let c of n.sort((u,O)=>O.score-u.score||l(u.completion,O.completion))){let u=c.completion;!s||s.label!=u.label||s.detail!=u.detail||s.type!=null&&u.type!=null&&s.type!=u.type||s.apply!=u.apply||s.boost!=u.boost?o.push(c):lV(c.completion)>lV(s)&&(o[o.length-1]=c),s=c.completion}return o}class zh{constructor(t,n,r,i,a,o){this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=a,this.disabled=o}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new zh(this.options,cV(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(c=>c.isPending))return i.setDisabled();let s=Itt(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Pi).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let u=0;u<s.length;u++)if(s[u].completion==c){l=u;break}}return new zh(s,cV(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:Btt,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new zh(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new zh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Vx{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new Vx(Ltt,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Pi),a=(r.override||n.languageDataAt("autocomplete",Rd(n)).map(ztt)).map(l=>(this.active.find(u=>u.source==l)||new Bo(l,this.active.some(u=>u.state!=0)?1:0)).update(t,r));a.length==this.active.length&&a.every((l,c)=>l==this.active[c])&&(a=this.active);let o=this.open,s=t.effects.some(l=>l.is(IA));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Dtt(a,this.active)||s?o=zh.build(a,n,this.id,o,r,s):o&&o.disabled&&!a.some(l=>l.isPending)&&(o=null),!o&&a.every(l=>!l.isPending)&&a.some(l=>l.hasResult())&&(a=a.map(l=>l.hasResult()?new Bo(l.source,0):l));for(let l of t.effects)l.is(yme)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new Vx(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Vtt:Mtt}}function Dtt(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}const Vtt={"aria-autocomplete":"list"},Mtt={};function cV(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Ltt=[];function $me(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(ZA);if(r&&t.activateOnCompletion(r))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class Bo{constructor(t,n,r=!1){this.source=t,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=$me(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new Bo(i.source,0)),r&4&&i.state==0&&(i=new Bo(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(Dx))i=new Bo(i.source,1,a.value);else if(a.is(W$))i=new Bo(i.source,0);else if(a.is(IA))for(let o of a.value)o.source==i.source&&(i=o);return i}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(Rd(t.state))}}class Hh extends Bo{constructor(t,n,r,i,a,o){super(t,3,n),this.limit=r,this.result=i,this.from=a,this.to=o}hasResult(){return!0}updateFor(t,n){var r;if(!(n&3))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let a=t.changes.mapPos(this.from),o=t.changes.mapPos(this.to,1),s=Rd(t.state);if(s>o||!i||n&2&&(Rd(t.startState)==this.from||s<this.limit))return new Bo(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return Ftt(i.validFor,t.state,a,o)?new Hh(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new GA(t.state,s,!1)))?new Hh(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:Rd(t.state)):new Bo(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new Hh(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new Bo(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Ftt(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):gme(e,!0).test(i)}const IA=vn.define({map(e,t){return e.map(n=>n.map(t))}}),yme=vn.define(),Aa=La.define({create(){return Vx.start()},update(e,t){return e.update(t)},provide:e=>[CA.from(e,t=>t.tooltip),xt.contentAttributes.from(e,t=>t.attrs)]});function DA(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Aa).active.find(i=>i.source==t.source);return r instanceof Hh?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},Ctt(e.state,n,r.from,r.to)),{annotations:ZA.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const Btt=Gtt(Aa,DA);function Lb(e,t="option"){return n=>{let r=n.state.field(Aa,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Pi).interactionDelay)return!1;let i=1,a;t=="page"&&(a=Zpe(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector("li").offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t=="page"?0:o-1:s>=o&&(s=t=="page"?o-1:0),n.dispatch({effects:yme.of(s)}),!0}}const Htt=e=>{let t=e.state.field(Aa,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Pi).interactionDelay?!1:DA(e,t.open.options[t.open.selected])},uV=e=>e.state.field(Aa,!1)?(e.dispatch({effects:Dx.of(!0)}),!0):!1,Ktt=e=>{let t=e.state.field(Aa,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:W$.of(null)}),!0)};class Jtt{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const ent=50,tnt=1e3,nnt=pi.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(Aa).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Aa),n=e.state.facet(Pi);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Aa)==t)return;let r=e.transactions.some(a=>{let o=$me(a,n);return o&8||(a.selection||a.docChanged)&&!(o&3)});for(let a=0;a<this.running.length;a++){let o=this.running[a];if(r||o.context.abortOnDocChange&&e.docChanged||o.updates.length+e.transactions.length>ent&&Date.now()-o.time>tnt){for(let s of o.context.abortListeners)try{s()}catch(l){Ya(this.view.state,l)}o.context.abortListeners=null,this.running.splice(a--,1)}else o.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(a=>a.effects.some(o=>o.is(Dx)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(a=>a.isPending&&!this.running.some(o=>o.active.source==a.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let a of e.transactions)a.isUserEvent("input.type")?this.composing=2:this.composing==2&&a.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(Aa);for(let n of t.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Pi).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=Rd(t),r=new GA(t,n,e.explicit,this.view),i=new Jtt(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(a=>{i.context.aborted||(i.done=a||null,this.scheduleAccept())},a=>{this.view.dispatch({effects:W$.of(null)}),Ya(this.view.state,a)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Pi).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Pi),r=this.view.state.field(Aa);for(let i=0;i<this.running.length;i++){let a=this.running[i];if(a.done===void 0)continue;if(this.running.splice(i--,1),a.done){let s=Rd(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new Hh(a.active.source,a.active.explicit,l,a.done,a.done.from,(e=a.done.to)!==null&&e!==void 0?e:s);for(let u of a.updates)c=c.update(u,n);if(c.hasResult()){t.push(c);continue}}let o=r.active.find(s=>s.source==a.active.source);if(o&&o.isPending)if(a.done==null){let s=new Bo(a.active.source,0);for(let l of a.updates)s=s.update(l,n);s.isPending||t.push(s)}else this.startQuery(o)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:IA.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Aa,!1);if(t&&t.tooltip&&this.view.state.facet(Pi).closeOnBlur){let n=t.open&&Zpe(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:W$.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Dx.of(!1)}),20),this.composing=0}}}),rnt=typeof navigator=="object"&&/Win/.test(navigator.platform),int=QO.highest(xt.domEventHandlers({keydown(e,t){let n=t.state.field(Aa,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(rnt&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(o=>o.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&DA(t,r),!1}})),vme=xt.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"}}});class ant{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class VA{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Yi.TrackDel),r=t.mapPos(this.to,1,Yi.TrackDel);return n==null||r==null?null:new VA(this.field,n,r)}}class MA{constructor(t,n){this.lines=t,this.fieldPositions=n}instantiate(t,n){let r=[],i=[n],a=t.doc.lineAt(n),o=/^\s*/.exec(a.text)[0];for(let l of this.lines){if(r.length){let c=o,u=/^\t*/.exec(l)[0].length;for(let O=0;O<u;O++)c+=t.facet(Xk);i.push(n+c.length-u),l=c+l.slice(u)}r.push(l),n+=l.length+1}let s=this.fieldPositions.map(l=>new VA(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:s}}static parse(t){let n=[],r=[],i=[],a;for(let o of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(o);){let s=a[1]?+a[1]:null,l=a[2]||a[3]||"",c=-1,u=l.replace(/\\[{}]/g,O=>O[1]);for(let O=0;O<n.length;O++)(s!=null?n[O].seq==s:u&&n[O].name==u)&&(c=O);if(c<0){let O=0;for(;O<n.length&&(s==null||n[O].seq!=null&&n[O].seq<s);)O++;n.splice(O,0,{seq:s,name:u}),c=O;for(let d of i)d.field>=c&&d.field++}i.push(new ant(c,r.length,a.index,a.index+u.length)),o=o.slice(0,a.index)+l+o.slice(a.index+a[0].length)}o=o.replace(/\\([{}])/g,(s,l,c)=>{for(let u of i)u.line==r.length&&u.from>c&&(u.from--,u.to--);return l}),r.push(o)}return new MA(r,i)}}let ont=nn.widget({widget:new class extends au{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),snt=nn.mark({class:"cm-snippetField"});class _m{constructor(t,n){this.ranges=t,this.active=n,this.deco=nn.set(t.map(r=>(r.from==r.to?ont:snt).range(r.from,r.to)))}map(t){let n=[];for(let r of this.ranges){let i=r.map(t);if(!i)return null;n.push(i)}return new _m(n,this.active)}selectionInsideField(t){return t.ranges.every(n=>this.ranges.some(r=>r.field==this.active&&r.from<=n.from&&r.to>=n.to))}}const $v=vn.define({map(e,t){return e&&e.map(t)}}),lnt=vn.define(),N$=La.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is($v))return n.value;if(n.is(lnt)&&e)return new _m(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>xt.decorations.from(e,t=>t?t.deco:nn.none)});function LA(e,t){return Ge.create(e.filter(n=>n.field==t).map(n=>Ge.range(n.from,n.to)))}function cnt(e){let t=MA.parse(e);return(n,r,i,a)=>{let{text:o,ranges:s}=t.instantiate(n.state,i),{main:l}=n.state.selection,c={changes:{from:i,to:a==l.from?l.to:a,insert:Wn.of(o)},scrollIntoView:!0,annotations:r?[ZA.of(r),Gi.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=LA(s,0)),s.some(u=>u.field>0)){let u=new _m(s,0),O=c.effects=[$v.of(u)];n.state.field(N$,!1)===void 0&&O.push(vn.appendConfig.of([N$,hnt,pnt,vme]))}n.dispatch(n.state.update(c))}}function bme(e){return({state:t,dispatch:n})=>{let r=t.field(N$,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(o=>o.field==i+e);return n(t.update({selection:LA(r.ranges,i),effects:$v.of(a?null:new _m(r.ranges,i)),scrollIntoView:!0})),!0}}const unt=({state:e,dispatch:t})=>e.field(N$,!1)?(t(e.update({effects:$v.of(null)})),!0):!1,Ont=bme(1),dnt=bme(-1),fnt=[{key:"Tab",run:Ont,shift:dnt},{key:"Escape",run:unt}],OV=dt.define({combine(e){return e.length?e[0]:fnt}}),hnt=QO.highest(_k.compute([OV],e=>e.facet(OV)));function cr(e,t){return Object.assign(Object.assign({},t),{apply:cnt(e)})}const pnt=xt.domEventHandlers({mousedown(e,t){let n=t.state.field(N$,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(a=>a.from<=r&&a.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:LA(n.ranges,i.field),effects:$v.of(n.ranges.some(a=>a.field>i.field)?new _m(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),Y$={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},bd=vn.define({map(e,t){let n=t.mapPos(e,-1,Yi.TrackAfter);return n??void 0}}),FA=new class extends Vd{};FA.startSide=1;FA.endSide=-1;const wme=La.define({create(){return yn.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of t.effects)n.is(bd)&&(e=e.update({add:[FA.range(n.value,n.value+1)]}));return e}});function Jsn(){return[gnt,wme]}const yT="()[]{}<>«»»«[]{}";function xme(e){for(let t=0;t<yT.length;t+=2)if(yT.charCodeAt(t)==e)return yT.charAt(t+1);return Phe(e<128?e:e+1)}function Sme(e,t){return e.languageDataAt("closeBrackets",t)[0]||Y$}const mnt=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),gnt=xt.inputHandler.of((e,t,n,r)=>{if((mnt?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&yc(mo(r,0))==1||t!=i.from||n!=i.to)return!1;let a=ynt(e.state,r);return a?(e.dispatch(a),!0):!1}),$nt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Sme(e,e.selection.main.head).brackets||Y$.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=vnt(e.doc,o.head);for(let l of r)if(l==s&&jk(e.doc,o.head)==xme(mo(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Ge.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},eln=[{key:"Backspace",run:$nt}];function ynt(e,t){let n=Sme(e,e.selection.main.head),r=n.brackets||Y$.brackets;for(let i of r){let a=xme(mo(i,0));if(t==i)return a==i?xnt(e,i,r.indexOf(i+i+i)>-1,n):bnt(e,i,a,n.before||Y$.before);if(t==a&&Qme(e,e.selection.main.from))return wnt(e,i,a)}return null}function Qme(e,t){let n=!1;return e.field(wme).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function jk(e,t){let n=e.sliceString(t,t+2);return n.slice(0,yc(mo(n,0)))}function vnt(e,t){let n=e.sliceString(t-2,t);return yc(mo(n,0))==n.length?n:n.slice(1)}function bnt(e,t,n,r){let i=null,a=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:n,from:o.to}],effects:bd.of(o.to+t.length),range:Ge.range(o.anchor+t.length,o.head+t.length)};let s=jk(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:bd.of(o.head+t.length),range:Ge.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function wnt(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&jk(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Ge.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function xnt(e,t,n,r){let i=r.stringPrefixes||Y$.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:bd.of(s.to+t.length),range:Ge.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=jk(e.doc,l),u;if(c==t){if(dV(e,l))return{changes:{insert:t+t,from:l},effects:bd.of(l+t.length),range:Ge.cursor(l+t.length)};if(Qme(e,l)){let d=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+d.length,insert:d},range:Ge.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=fV(e,l-2*t.length,i))>-1&&dV(e,u))return{changes:{insert:t+t+t+t,from:l},effects:bd.of(l+t.length),range:Ge.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=Fo.Word&&fV(e,l,i)>-1&&!Snt(e,l,t,i))return{changes:{insert:t+t,from:l},effects:bd.of(l+t.length),range:Ge.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function dV(e,t){let n=Yn(e).resolveInner(t+1);return n.parent&&n.from==t}function Snt(e,t,n,r){let i=Yn(e).resolveInner(t,-1),a=r.reduce((o,s)=>Math.max(o,s.length),0);for(let o=0;o<5;o++){let s=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),l=s.indexOf(n);if(!l||l>-1&&r.indexOf(s.slice(0,l))>-1){let u=i.firstChild;for(;u&&u.from==i.from&&u.to-u.from>n.length+l;){if(e.sliceDoc(u.to-n.length,u.to)==n)return!1;u=u.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function fV(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=Fo.Word)return t;for(let i of n){let a=t-i.length;if(e.sliceDoc(a,t)==i&&r(e.sliceDoc(a-1,a))!=Fo.Word)return a}return-1}function tln(e={}){return[int,Aa,Pi.of(e),nnt,knt,vme]}const Qnt=[{key:"Ctrl-Space",run:uV},{mac:"Alt-`",run:uV},{key:"Escape",run:Ktt},{key:"ArrowDown",run:Lb(!0)},{key:"ArrowUp",run:Lb(!1)},{key:"PageDown",run:Lb(!0,"page")},{key:"PageUp",run:Lb(!1,"page")},{key:"Enter",run:Htt}],knt=QO.highest(_k.computeN([Pi],e=>e.facet(Pi).defaultKeymap?[Qnt]:[]));class Mx{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new Mx(t,n,r,o,a,[],[])}constructor(t,n,r,i,a,o,s){this.type=t,this.value=n,this.from=r,this.hash=i,this.end=a,this.children=o,this.positions=s,this.hashProp=[[jt.contextHash,i]]}addChild(t,n){t.prop(jt.contextHash)!=this.hash&&(t=new sn(t.type,t.children,t.positions,t.length,this.hashProp)),this.children.push(t),this.positions.push(n)}toTree(t,n=this.end){let r=this.children.length-1;return r>=0&&(n=Math.max(n,this.positions[r]+this.children[r].length+this.from)),new sn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new sn(ri.none,i,a,o,this.hashProp)})}}var De;(function(e){e[e.Document=1]="Document",e[e.CodeBlock=2]="CodeBlock",e[e.FencedCode=3]="FencedCode",e[e.Blockquote=4]="Blockquote",e[e.HorizontalRule=5]="HorizontalRule",e[e.BulletList=6]="BulletList",e[e.OrderedList=7]="OrderedList",e[e.ListItem=8]="ListItem",e[e.ATXHeading1=9]="ATXHeading1",e[e.ATXHeading2=10]="ATXHeading2",e[e.ATXHeading3=11]="ATXHeading3",e[e.ATXHeading4=12]="ATXHeading4",e[e.ATXHeading5=13]="ATXHeading5",e[e.ATXHeading6=14]="ATXHeading6",e[e.SetextHeading1=15]="SetextHeading1",e[e.SetextHeading2=16]="SetextHeading2",e[e.HTMLBlock=17]="HTMLBlock",e[e.LinkReference=18]="LinkReference",e[e.Paragraph=19]="Paragraph",e[e.CommentBlock=20]="CommentBlock",e[e.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",e[e.Escape=22]="Escape",e[e.Entity=23]="Entity",e[e.HardBreak=24]="HardBreak",e[e.Emphasis=25]="Emphasis",e[e.StrongEmphasis=26]="StrongEmphasis",e[e.Link=27]="Link",e[e.Image=28]="Image",e[e.InlineCode=29]="InlineCode",e[e.HTMLTag=30]="HTMLTag",e[e.Comment=31]="Comment",e[e.ProcessingInstruction=32]="ProcessingInstruction",e[e.Autolink=33]="Autolink",e[e.HeaderMark=34]="HeaderMark",e[e.QuoteMark=35]="QuoteMark",e[e.ListMark=36]="ListMark",e[e.LinkMark=37]="LinkMark",e[e.EmphasisMark=38]="EmphasisMark",e[e.CodeMark=39]="CodeMark",e[e.CodeText=40]="CodeText",e[e.CodeInfo=41]="CodeInfo",e[e.LinkTitle=42]="LinkTitle",e[e.LinkLabel=43]="LinkLabel",e[e.URL=44]="URL"})(De||(De={}));class _nt{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let Pnt=class{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let t=this.skipSpace(this.basePos);this.indent=this.countIndent(t,this.pos,this.indent),this.pos=t,this.next=t==this.text.length?-1:this.text.charCodeAt(t)}skipSpace(t){return Z0(this.text,t)}reset(t){for(this.text=t,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(t){this.basePos=t,this.baseIndent=this.countIndent(t,this.pos,this.indent)}moveBaseColumn(t){this.baseIndent=t,this.basePos=this.findColumn(t)}addMarker(t){this.markers.push(t)}countIndent(t,n=0,r=0){for(let i=n;i<t;i++)r+=this.text.charCodeAt(i)==9?4-r%4:1;return r}findColumn(t){let n=0;for(let r=0;n<this.text.length&&r<t;n++)r+=this.text.charCodeAt(n)==9?4-r%4:1;return n}scrub(){if(!this.baseIndent)return this.text;let t="";for(let n=0;n<this.basePos;n++)t+=" ";return t+this.text.slice(this.basePos)}};function hV(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==De.OrderedList?KA:HA)(n,t,!1);return r>0&&(e.type!=De.BulletList||BA(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const kme={[De.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(fn(De.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(Os(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[De.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[De.OrderedList]:hV,[De.BulletList]:hV,[De.Document](){return!0}};function Os(e){return e==32||e==9||e==10||e==13}function Z0(e,t=0){for(;t<e.length&&Os(e.charCodeAt(t));)t++;return t}function pV(e,t,n){for(;t>n&&Os(e.charCodeAt(t-1));)t--;return t}function _me(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function Pme(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function BA(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let i=e.pos+1;i<e.text.length;i++){let a=e.text.charCodeAt(i);if(a==e.next)r++;else if(!Os(a))return-1}return n&&e.next==45&&Rme(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(Cme.SetextHeading)>-1||r<3?-1:1}function Tme(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function HA(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||Os(e.text.charCodeAt(e.pos+1)))&&(!n||Tme(t,De.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function KA(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){r++;if(r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!Os(e.text.charCodeAt(r+1))||n&&!Tme(t,De.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function Xme(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function Rme(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&Os(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const W3=/^[ \t]*$/,Eme=/-->/,qme=/\?>/,N3=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Eme],[/^\s*<\?/,qme],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,W3],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,W3]];function jme(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=N3.length-(n?1:0);i<a;i++)if(N3[i][0].test(r))return i;return-1}function mV(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function JO(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==De.CodeText?e[r].to=n:e.push(fn(De.CodeText,t,n))}const Fb={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(JO(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){JO(s,e.lineStart-1,e.lineStart);for(let l of t.markers)s.push(l)}else{if(t.indent<n)break;{if(s.length){for(let c of s)c.type==De.CodeText?JO(o,c.from,c.to):o.push(c);s=[]}JO(o,e.lineStart-1,e.lineStart);for(let c of t.markers)o.push(c);a=e.lineStart+t.text.length;let l=e.lineStart+t.findColumn(t.baseIndent+4);l<a&&JO(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=De.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(De.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=_me(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=pV(t.text,t.text.length,o),l=[fn(De.CodeMark,r,r+a)];o<s&&l.push(fn(De.CodeInfo,e.lineStart+o,e.lineStart+s));for(let c=!0;e.nextLine()&&t.depth>=e.stack.length;c=!1){let u=t.pos;if(t.indent-t.baseIndent<4)for(;u<t.text.length&&t.text.charCodeAt(u)==i;)u++;if(u-t.pos>=a&&t.skipSpace(u)==t.text.length){for(let O of t.markers)l.push(O);l.push(fn(De.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||JO(l,e.lineStart-1,e.lineStart);for(let h of t.markers)l.push(h);let O=e.lineStart+t.basePos,d=e.lineStart+t.text.length;O<d&&JO(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(De.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=Pme(t);return n<0?!1:(e.startContext(De.Blockquote,t.pos),e.addNode(De.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(BA(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(De.HorizontalRule,n),!0},BulletList(e,t){let n=HA(t,e,!1);if(n<0)return!1;e.block.type!=De.BulletList&&e.startContext(De.BulletList,t.basePos,t.next);let r=mV(t,t.pos+1);return e.startContext(De.ListItem,t.basePos,r-t.baseIndent),e.addNode(De.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=KA(t,e,!1);if(n<0)return!1;e.block.type!=De.OrderedList&&e.startContext(De.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=mV(t,t.pos+n);return e.startContext(De.ListItem,t.basePos,r-t.baseIndent),e.addNode(De.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=Xme(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=pV(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!Os(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(De.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(De.HeaderMark,o-r,a-r);let l=s.finish(De.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=jme(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=N3[n][1],a=[],o=i!=W3;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let c of t.markers)a.push(c)}o&&e.nextLine();let s=i==Eme?De.CommentBlock:i==qme?De.ProcessingInstructionBlock:De.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class Tnt{constructor(t){this.stage=0,this.elts=[],this.pos=0,this.start=t.start,this.advance(t.content)}nextLine(t,n,r){if(this.stage==-1)return!1;let i=r.content+`
|
|
838
838
|
`+n.scrub(),a=this.advance(i);return a>-1&&a<i.length?this.complete(t,r,a):!1}finish(t,n){return(this.stage==2||this.stage==3)&&Z0(n.content,this.pos)==n.content.length?this.complete(t,n,n.content.length):!1}complete(t,n,r){return t.addLeafElement(n,fn(De.LinkReference,this.start,this.start+r,this.elts)),!0}nextStage(t){return t?(this.pos=t.to-this.start,this.elts.push(t),this.stage++,!0):(t===!1&&(this.stage=-1),!1)}advance(t){for(;;){if(this.stage==-1)return-1;if(this.stage==0){if(!this.nextStage(Ime(t,this.pos,this.start,!0)))return-1;if(t.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(fn(De.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(Gme(t,Z0(t,this.pos),this.start)))return-1}else if(this.stage==2){let n=Z0(t,this.pos),r=0;if(n>this.pos){let i=Zme(t,n,this.start);if(i){let a=vT(t,i.to-this.start);a>0&&(this.nextStage(i),r=a)}}return r||(r=vT(t,this.pos)),r>0&&r<t.length?r:-1}else return vT(t,this.pos)}}}function vT(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!Os(n))return-1}return t}class Xnt{nextLine(t,n,r){let i=n.depth<t.stack.length?-1:Rme(n),a=n.next;if(i<0)return!1;let o=fn(De.HeaderMark,t.lineStart+n.pos,t.lineStart+i);return t.nextLine(),t.addLeafElement(r,fn(a==61?De.SetextHeading1:De.SetextHeading2,r.start,t.prevLineEnd(),[...t.parser.parseInline(r.content,r.start),o])),!0}finish(){return!1}}const Cme={LinkReference(e,t){return t.content.charCodeAt(0)==91?new Tnt(t):null},SetextHeading(){return new Xnt}},Rnt=[(e,t)=>Xme(t)>=0,(e,t)=>_me(t)>=0,(e,t)=>Pme(t)>=0,(e,t)=>HA(t,e,!0)>=0,(e,t)=>KA(t,e,!0)>=0,(e,t)=>BA(t,e,!0)>=0,(e,t)=>jme(t,e,!0)>=0],Ent={text:"",end:0};class qnt{constructor(t,n,r,i){this.parser=t,this.input=n,this.ranges=i,this.line=new Pnt,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=i[i.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=i[0].from,this.block=Mx.create(De.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new Ant(r,n):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:t}=this;for(;;){for(let r=0;;){let i=t.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;r<t.markers.length&&(!i||t.markers[r].from<i.end);){let a=t.markers[r++];this.addNode(a.type,a.from,a.to)}if(!i)break;this.finishContext()}if(t.pos<t.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(t.basePos))return null;e:for(;;){for(let r of this.parser.blockParsers)if(r){let i=r(this,t);if(i!=!1){if(i==!0)return null;t.forward();continue e}}break}let n=new _nt(this.lineStart+t.pos,t.text.slice(t.pos));for(let r of this.parser.leafBlockParsers)if(r){let i=r(this,n);i&&n.parsers.push(i)}e:for(;this.nextLine()&&t.pos!=t.text.length;){if(t.indent<t.baseIndent+4){for(let r of this.parser.endLeafBlock)if(r(this,t,n))break e}for(let r of n.parsers)if(r.nextLine(this,t,n))return null;n.content+=`
|
|
839
839
|
`+t.scrub();for(let r of t.markers)n.marks.push(r)}return this.finishLeaf(n),null}stopAt(t){if(this.stoppedAt!=null&&this.stoppedAt<t)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=t}reuseFragment(t){if(!this.fragments.moveTo(this.absoluteLineStart+t,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let n=this.fragments.takeNodes(this);return n?(this.absoluteLineStart+=n,this.lineStart=Dme(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(t=this.depth-1){return this.parser.nodeSet.types[this.stack[t].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(t){let n=Ent;if(n.end=t,t>=this.to)n.text="";else if(n.text=this.lineChunkAt(t),n.end+=n.text.length,this.ranges.length>1){let r=this.absoluteLineStart,i=this.rangeI;for(;this.ranges[i].to<n.end;){i++;let a=this.ranges[i].from,o=this.lineChunkAt(a);n.end=a+o.length,n.text=n.text.slice(0,this.ranges[i-1].to-r)+o,r=n.end-n.text.length}}return n}readLine(){let{line:t}=this,{text:n,end:r}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=r,t.reset(n);t.depth<this.stack.length;t.depth++){let i=this.stack[t.depth],a=this.parser.skipContextMarkup[i.type];if(!a)throw new Error("Unhandled block context "+De[i.type]);if(!a(i,this,t))break;t.forward()}}lineChunkAt(t){let n=this.input.chunk(t),r;if(this.input.lineChunks)r=n==`
|
|
840
840
|
`?"":n;else{let i=n.indexOf(`
|
|
@@ -869,7 +869,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
869
869
|
`,o.end),l=t.slice(o.end,s===-1?t.length:s);if(a_t.test(l))return Ua;const c=l.length-l.replace(o_t,"").length,u={start:o.start,end:o.end+c},O=e.typingAt;if(O!==null){const d=O+Np(e.value).length;return n<O||n>d?{arm:u,typingAt:null,value:""}:{arm:u,typingAt:O,value:e.value}}return a&&n===u.end&&t[n-1]===d_?{arm:u,typingAt:n,value:""}:{arm:u,typingAt:null,value:""}}const Yo=e=>e.typingAt!==null,f_t=e=>e.arm!==null;function Xf(e){return e.typingAt===null?null:{start:e.typingAt,end:e.typingAt+Np(e.value).length}}function tU(e,t,n,r){const i=Xf(e);if(i===null)return null;const{top:a,bottom:o,inserted:s}=r;if(a>i.end||o<i.start)return null;const l=Np(e.value),c=Z7(a-i.start,0,l.length),u=Z7(o-i.start,0,l.length),O=Np(s),d=[...l.slice(0,c),...O,...l.slice(u)].join(""),h=a+O.length,p=t.slice(0,a)+k1e.repeat(O.length)+t.slice(h),g=O.length-s.length,y=n>=h?n+g:n;return{buffer:p,caret:y,capture:{...e,value:d}}}function ZB(e,t,n,r){const i={capture:e,buffer:t.slice(0,n.start)+r+t.slice(n.end),caret:n.start+r.length},a=Yo(e)&&e.value===""&&r.startsWith("-");if(Yo(e)&&(a||r.includes(`
|
|
870
870
|
`))){const o=wS(e);return r.includes(`
|
|
871
871
|
`)?{...i,capture:o}:{...i,capture:Wh(o,i.buffer,i.caret,"typing")}}return tU(e,i.buffer,i.caret,{top:n.start,bottom:n.end,inserted:r})??i}function wS(e){return Yo(e)?{arm:e.arm,typingAt:null,value:""}:e}function h_t(e,t){let n=0;const r=Math.min(e.length,t.length);for(;n<r&&e[n]===t[n];)n++;let i=e.length,a=t.length;for(;i>n&&a>n&&e[i-1]===t[a-1];)i--,a--;return{top:n,bottom:i,inserted:t.slice(n,a)}}function p_t(e,t,n,r,i){const a=h_t(t,n),o=Xf(e);let s={capture:e,buffer:n,caret:r};if(a.inserted!==""&&o!==null&&a.top<=o.end&&a.bottom>=o.start)s={capture:wS(e),buffer:n,caret:r};else{const l=tU(e,n,r,a);l?s=l:Yo(e)&&a.inserted.includes(`
|
|
872
|
-
`)&&(s={capture:wS(e),buffer:n,caret:r})}return{...s,capture:Wh(s.capture,s.buffer,s.caret,i)}}function m_t(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=Xf(t);if(o===null||t.value==="")return{minted:!1,capture:t,buffer:n,caret:r,payload:null};const s=t.arm===null?o.start:t.arm.start,l=C1e(i,t.value),c=l+d_,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:Ua,buffer:u,caret:s+c.length,payload:{index:i,key:z1e(a,e.draw),value:t.value,marker:l}}}const g_t=e=>Yo(e)&&e.value!=="";function $_t(e,t){const n=Xf(e);if(n===null)return{cancelled:!1,capture:e,buffer:t,caret:0,token:null};const r=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:Ua,buffer:t.slice(0,n.start)+t.slice(n.end),caret:n.start,token:{span:{start:r,end:n.start},text:t.slice(r,n.start)}}}function y_t(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function v_t(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=Xf(e);return o===null?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:n.start<=o.start?{kind:"passthrough",capture:{...e,typingAt:o.start+r.length},buffer:i,caret:a,payload:null}:n.start>=o.end?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:{kind:"passthrough",capture:wS(e),buffer:i,caret:a,payload:null}}function b_t(e){const{capture:t,buffer:n,caret:r,pasted:i}=e;if(t.arm===null)return null;if(t.typingAt!==null&&t.value!==""){if(i==="")return null;const u=tU(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=Mn(i);if(!a)return i===""?null:v_t(t,n,e.selection,i);const o=t.arm,s=C1e(e.index,a),l=s+d_,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:Ua,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:z1e(e.taken,e.draw),value:a,marker:s}}}const j1e=e=>`${l_t(e)} chars`,C1e=(e,t)=>`[Credential #${e}, ${j1e(t)}]`;function w_t(e){kl.lastIndex=0;const t=kl.exec(e);return kl.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function x_t(e){kl.lastIndex=0;const t=kl.exec(e);if(kl.lastIndex=0,t===null||t[0]!==e)return null;const n=Number.parseInt(t[1],10);return{index:n,label:`#${n}`,chars:Number.parseInt(t[2],10)}}function Rv(e,t){if(w_t(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const W2=/\[credential ([A-Za-z_][A-Za-z0-9_]*) \((\d+) chars\) \u2014 available to bash and eval as \$([A-Za-z_][A-Za-z0-9_]*); its value cannot be read\]/y,N2=/\[credential NOT stored \u2014 [^\]\n]*\]/y,Y2=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,S_t=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&G7.test(t[1])?t[1]:""};function Q_t(e,t){if(e.charCodeAt(t)!==91)return null;W2.lastIndex=t;const n=W2.exec(e);if(W2.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};N2.lastIndex=t;const r=N2.exec(e);if(N2.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};Y2.lastIndex=t;const i=Y2.exec(e);return Y2.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:S_t(i[0])}:null}function f_(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=Q_t(e,r);if(i===null){r++;continue}r>n&&t.push({kind:"text",text:e.slice(n,r)}),t.push(i),r+=i.text.length,n=r}return n<e.length&&t.push({kind:"text",text:e.slice(n)}),t}function IB(e,t){const n=[];for(const r of t){const i=Rv(e,r);i!==null&&n.push({at:i.start,payload:r})}return n.sort((r,i)=>r.at-i.at).map(r=>r.payload)}function k_t(e,t=""){return e==="unconfirmed"?t?`[credential unconfirmed — it may be held as $${t}, so check list_variables before assuming it is missing]`:"[credential unconfirmed — the session may hold it, so check list_variables before assuming it is missing]":e==="unreachable"?"[credential NOT stored — the session could not be reached; try again]":e==="rejected-key"?"[credential NOT stored — the store rejected its name]":"[credential NOT stored — its value did not survive; ask the operator to paste it again]"}const __t=e=>`[credential ${e.key} (${j1e(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function P_t(e,t,n=new Map){const r=[...t],i=[];for(const o of r){const s=Rv(e,o);s!==null&&i.push({span:s,payload:o})}for(const o of X1e(e,r))i.push({span:o,payload:null});let a=e;for(const{span:o,payload:s}of i.sort((l,c)=>c.span.start-l.span.start)){const l=s===null?"lost":n.get(s.index),c=s===null||l!==void 0?k_t(l??"lost",s?.key):__t(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const T_t=(e,t,n)=>`Removed ${e} (credential #${t}) from this message. Its value is gone — press ${n} to put it back, or paste it again after /credential to reuse it.`,X_t=e=>`Remove credential #${e}`,R_t=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,E_t=(e,t,n)=>T_t(e,t,n),q_t="Undo",j_t=e=>m("ui.notices.credentials.removed",{index:e}),C_t=e=>e.unredacted!==null?e.unredacted:e.armed?Z_t:e.cleared!==null?E_t(e.cleared.key,e.cleared.index,e.undoCap):null;function z_t(e){const{buffer:t,payload:n}=e,r=Rv(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===d_?r.end+1:r.end;return{cleared:!0,buffer:t.slice(0,r.start)+t.slice(i),caret:r.start,removed:t.slice(r.start,i)}}function A_t(e){const{buffer:t,cleared:n}=e;return n.removed===""||t!==n.buffer?null:{buffer:t.slice(0,n.caret)+n.removed+t.slice(n.caret),caret:n.caret+n.removed.length}}const DB=e=>m("ui.notices.credentials.stored",{keys:e.join(", ")});function VB(e){return m("ui.notices.credentials.unstored",{count:e.length,keys:[...e].sort().join(", ")})}const U_t="store unconfirmed",W_t="Credential store unconfirmed",N_t=e=>e===""?W_t:`${e} · ${U_t}`,Y_t="Paste the value again after /credential to store it again.",G_t=e=>`${e} ${Y_t}`;function MB(e){return m("ui.notices.credentials.unconfirmed",{count:e.length,keys:[...e].sort().join(", ")})}const Z_t="armed — add a space, then type or paste the secret",I_t="masked as you type — Enter makes a pill, Esc twice discards",D_t="masked — Enter opens the credential picker; type or paste the secret into this span",V_t="Esc again discards it — still masked, Enter makes a pill",M_t="credential discarded — nothing was stored or sent",L_t="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",F_t=e=>`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`;function B_t(e,t){const n=Xf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const LB=(e,t)=>e&&e.over===t?e.chars:null,H_t=e=>{const t=Math.floor(4294967296/e)*e,n=new Uint32Array(1);for(;;)if(globalThis.crypto.getRandomValues(n),n[0]<t)return n[0]%e},K_t=16,J_t=16;function z1e(e=[],t=H_t){const n=new Set(e);for(let r=0;r<K_t;r++){const i=GB+FB(8,t);if(!n.has(i))return i}return GB+FB(J_t,t)}const FB=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=YB[t(YB.length)];return n},ePt=8,tPt=256,nPt=/^[/@$#]/,rPt=/^\w+:\/\//,iPt=/^[A-Za-z]+$/,aPt=/^\d+$/,oPt=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/],sPt=3,lPt=20,cPt=/^[A-Za-z0-9_\-+/=.]+$/,uPt=new RegExp(`^[^${Yc}@]+@[^${Yc}@]+\\.[A-Za-z]{2,}$`),OPt=/^[\w.-]+(?:\/[\w.-]+)+$/,dPt=/\.[A-Za-z][A-Za-z0-9]{0,7}$/,fPt=/^v?\d+(?:\.\d+)+(?:[-+][0-9A-Za-z.-]+)?$/,hPt=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,pPt=/^[\w.-]+:\d{2,5}$/,mPt=/^(?:[0-9a-f]{7,12}|[0-9a-f]{40})$/i,gPt=/^[a-z]+(?:_[a-z]+)+$/,$Pt=/^[a-z]+(?:-[a-z]+)+$/,yPt=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$/,vPt=/^[a-z0-9]+(?:-[a-z0-9]+)+$/,bPt=/\d{4,}/,wPt=e=>{const t=e.trim();return t.length<ePt||t.length>tPt||Us.test(t)||nPt.test(t)||rPt.test(t)||Lce(t)!==null||uPt.test(t)||OPt.test(t)||dPt.test(t)||fPt.test(t)||hPt.test(t)||pPt.test(t)||mPt.test(t)||gPt.test(t)||$Pt.test(t)||yPt.test(t)||vPt.test(t)&&bPt.test(t)||iPt.test(t)||aPt.test(t)?!1:oPt.filter(r=>r.test(t)).length>=sPt?!0:t.length>=lPt&&cPt.test(t)},A1e=E("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),U1e=E("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),W1e=({label:e,chars:t=null,tone:n="live",title:r,onClear:i,clearLabel:a,className:o,style:s,small:l=!1})=>f.jsxs("span",{className:E("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?U1e:A1e,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?f.jsx(Fse,{"aria-hidden":"true",className:"size-3 shrink-0"}):f.jsx(hje,{"aria-hidden":"true",className:"size-3 shrink-0"}),f.jsx("span",{className:"min-w-0 truncate",children:e}),t!==null&&f.jsx("span",{className:"shrink-0",children:`· ${t} chars`}),i&&f.jsx("button",{type:"button","aria-label":a,onClick:i,className:"pointer-events-auto -mr-1 flex shrink-0 cursor-pointer items-center rounded-xs p-0.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-offset-1! active:bg-sunken",children:f.jsx(ni,{"aria-hidden":"true",className:"size-3"})}),r&&f.jsx("span",{className:"sr-only",children:r})]}),ty="#lo-credential/",xPt=`${ty}unstored`,BB=`${ty}unconfirmed`,SPt=/^\d+$/,N1e=e=>e.kind==="stored"?`${ty}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${BB}/${e.key}`:BB:xPt;function QPt(e){if(!e||!e.startsWith(ty))return null;const t=e.slice(ty.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return G7.test(a)?{kind:"unconfirmed",key:a}:null}const n=t.lastIndexOf("/");if(n===-1)return null;const r=t.slice(0,n),i=t.slice(n+1);return!G7.test(r)||!SPt.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function HB(e,t){const n=QPt(e);if(n===null)return null;const r=f_(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return N1e(i)!==e?null:n}const h_=()=>e=>{const t=n=>{if(!n.children)return;const r=[];let i=!1;for(const a of n.children){if(a.type!=="text"||typeof a.value!="string"){t(a),r.push(a);continue}const o=f_(a.value);if(o.length===1&&o[0].kind==="text"){r.push(a);continue}i=!0;for(const s of o){if(s.kind==="text"){r.push({type:"text",value:s.text});continue}r.push({type:"link",url:N1e(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},kPt=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?N_t(e.key):"Credential not stored",_Pt=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?G_t(t):t,PPt=({citation:e,title:t})=>f.jsx(W1e,{tone:e.kind==="stored"?"live":"warning",label:kPt(e),chars:e.kind==="stored"?e.chars:null,title:_Pt(e,t),className:"align-middle"}),TPt=(e,t)=>typeof t=="string"?HB(e,t):t==null?HB(e,""):null,XPt=e=>({href:t,title:n,children:r})=>{const i=TPt(t,r);if(i===null){const a=e;return f.jsx(a,{href:t,title:n,children:r})}return f.jsx(PPt,{citation:i,title:n})},Y1e=e=>DBe(e)?"artifact":e.startsWith("data:")?"data":e.startsWith("blob:")?"blob":e.startsWith("http://")||e.startsWith("https://")?"http":e.startsWith("file://")||e.startsWith("/")||e.startsWith("~")?"path":"other",nU=e=>{const t=Y1e(e);return t==="other"?"path":t},G2={id:"open-file",get label(){return m("ui.common.file_actions.open_file")}},RPt={id:"show-in-canvas",get label(){return m("ui.common.file_actions.show_in_canvas")}},EPt={id:"save-as",get label(){return m("ui.chat.image_actions.save_as")}},Z2={id:"open-folder",get label(){return m("ui.common.file_actions.open_folder")}},I2={id:"copy-file-path",get label(){return m("ui.common.file_actions.copy_file_path")}},Oh={id:"copy-image",get label(){return m("ui.chat.image_actions.copy_image")}},qPt={id:"copy-image-url",get label(){return m("ui.chat.image_actions.copy_image_url")}},jPt={id:"open-in-browser",get label(){return m("ui.chat.image_actions.open_in_browser")}};function G1e(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const o=[...t?[RPt]:[],...a?[{id:"expand-image",get label(){return m("ui.chat.image_actions.expand_image")}}]:[]];switch(e){case"artifact":return[...o,...i?[G2,Z2,I2]:[],EPt,...r==="video"||r==="audio"?[]:[Oh]];case"path":return[...o,G2,Z2,I2,...r==="video"||r==="audio"?[]:[Oh]];case"data":return[...o,Oh];case"blob":return i?[...o,G2,Z2,I2,Oh]:[Oh];case"http":return[...CPt(n)?[Oh]:[],qPt,jPt];case"other":return[]}}const Z1e=(e,t)=>G1e(e,t).length>0;function CPt(e){try{const t=new URL(e),n=t.hostname==="localhost"||t.hostname==="127.0.0.1";return t.protocol==="http:"&&n&&(t.port==="1111"||t.port==="8080")}catch{return!1}}const rU=e=>e.startsWith("file://")?e.slice(7):e;function I1e(e){const t=e.indexOf(",");if(t===-1)throw new Error("Malformed data URL");const n=e.slice(5,t),r=e.slice(t+1),i=n.split(";")[0]||"application/octet-stream";if(n.endsWith(";base64")){const s=atob(r),l=new Uint8Array(s.length);for(let c=0;c<s.length;c+=1)l[c]=s.charCodeAt(c);return new Blob([l],{type:i})}const a=decodeURIComponent(r),o=new Uint8Array(a.length);for(let s=0;s<a.length;s+=1)o[s]=a.charCodeAt(s);return new Blob([o],{type:i})}async function KB(e,t,n){if(e==="data")return I1e(t);if(e==="blob"){const o=Dle(n??t);if(o===null)throw new Error("These image bytes are not available in this window");return o}if(e==="http"){const o=await fetch(n??t);if(!o.ok)throw new Error(`The image server answered ${o.status}`);return o.blob()}const r=window.api?.readFileBytes;if(typeof r!="function")throw new Error("This window cannot read local files");const i=rU(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:b$(i)})}const zPt=e=>e.trim().toLowerCase()!=="image/png";async function APt(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!zPt(e.type))return e;const t=URL.createObjectURL(e);try{const n=await UPt(t);if(n.naturalWidth===0||n.naturalHeight===0)throw new Error("This image could not be decoded for the clipboard");const r=document.createElement("canvas");r.width=n.naturalWidth,r.height=n.naturalHeight;const i=r.getContext("2d");if(i===null)throw new Error("This window cannot re-encode the image for the clipboard");i.drawImage(n,0,0);const a=await new Promise(o=>{r.toBlob(o,"image/png")});if(a===null)throw new Error("This image could not be re-encoded for the clipboard");return a}finally{URL.revokeObjectURL(t)}}function UPt(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>t(r),r.onerror=()=>n(new Error("This image could not be decoded for the clipboard")),r.src=e})}const WPt=6e4;function NPt(e,t){const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.setTimeout(()=>URL.revokeObjectURL(n),WPt)}const N1=new Map;function YPt(e,t){const n=N1.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await is(e.childId?{op:"subagents.attachment",sessionId:e.sessionId,childId:e.childId,digest:t}:{op:"sessions.attachment",sessionId:e.sessionId,digest:t},null);if(i.kind!=="bytes")return null;const a=BQ(i.data,i.mimeType);return r.holders<=0?(ev(a),null):(Nz(t,a),a)}catch{return null}finally{N1.delete(t)}})(),N1.set(t,r),r.promise}class iU extends Error{constructor(){super("This item is no longer in the session"),this.name="AttachmentGoneError"}}async function D1e(e,t){const n=$$(t),r=n?Dle(n):null;if(r)return r;const i=await is(e.childId?{op:"subagents.attachment",sessionId:e.sessionId,childId:e.childId,digest:t}:{op:"sessions.attachment",sessionId:e.sessionId,digest:t},null);if(i.kind!=="bytes")throw i.status===404?new iU:new Error("These bytes are not available right now");return new Blob([i.data],{type:i.mimeType})}function GPt(e){const t=N1.get(e);t&&(t.holders-=1)}function Ev(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=$.useState(()=>e.attachment?$$(e.attachment):null),[a,o]=$.useState(!1),s=t?.sessionId??null,l=t?.childId??null;$.useEffect(()=>{const u=e.attachment;if(n||!u||!s)return;let O=!0;const d=fp(u);if(d)return i(d),o(!1),()=>{O=!1,hp(u)};i(null),o(!1);let h=!0;return YPt({sessionId:s,childId:l},u).then(p=>{if(h=!1,!!O){if(!p){o(!0);return}i(fp(u))}}),()=>{O=!1,h&&GPt(u),hp(u)}},[e.attachment,n,s,l]);const c=n??r;return c?{state:"ready",url:c}:e.attachment&&s&&!a?{state:"resolving"}:{state:"missing"}}function aU(e,t){return Ev(e,t)}const cln=Object.freeze(Object.defineProperty({__proto__:null,AttachmentGoneError:iU,fetchAttachmentBlob:D1e,useAttachmentSource:Ev,useAttachmentUrl:aU},Symbol.toStringTag,{value:"Module"})),ZPt={"expand-image":f.jsx(xle,{"aria-hidden":"true"}),"open-file":f.jsx(By,{"aria-hidden":"true"}),"show-in-canvas":f.jsx(ble,{"aria-hidden":"true"}),"save-as":f.jsx(DQ,{"aria-hidden":"true"}),"open-folder":f.jsx(dp,{"aria-hidden":"true"}),"copy-file-path":f.jsx(Tz,{"aria-hidden":"true"}),"copy-image":f.jsx(pf,{"aria-hidden":"true"}),"copy-image-url":f.jsx($je,{"aria-hidden":"true"}),"open-in-browser":f.jsx(VQ,{"aria-hidden":"true"})},JB=(e,t,n)=>n instanceof iU?t:e;function IPt({file:e,src:t,resolvePath:n,missing:r,onShowInCanvas:i,mediaKind:a,onExpand:o,saveName:s}){return G1e(nU(e),{canShowInCanvas:!!i,source:t??e,mediaKind:a,artifactPathActions:!!n,canExpand:!!o}).filter(l=>(l.id!=="save-as"||!!s)&&(!r||l.id==="copy-file-path"))}const V1e=({file:e,src:t,label:n,open:r,onOpenChange:i,onCloseAutoFocus:a,triggerTabIndex:o,resolvePath:s,missing:l,onShowInCanvas:c,mediaKind:u,onExpand:O,saveName:d,resolveBytes:h,tooltip:p="Image actions","aria-label":g})=>{const y=nU(e),v=IPt({file:e,src:t,resolvePath:s,missing:l,onShowInCanvas:c,mediaKind:u,onExpand:O,saveName:d});if(v.length===0)return null;const b=async(k,P,R)=>{try{await navigator.clipboard.writeText(k),aO(P)}catch(T){console.error(`${R}: `,T),Tr(R)}},x=async()=>{try{if(typeof ClipboardItem>"u")throw new Error("this window cannot write an image to the clipboard");const k=h?await h():await KB(y,e,t),P=await APt(k);await navigator.clipboard.write([new ClipboardItem({[P.type]:P})]),aO(m("ui.notices.files.image_copied"))}catch(k){console.error("Failed to copy image: ",k),Tr(JB(m("ui.notices.files.image_copy_failed"),m("ui.notices.files.image_copy_failed_gone"),k))}},Q=async()=>{try{const k=h?await h():await KB(y,e,t);NPt(k,d??"download")}catch(k){console.error("Failed to save file: ",k),Tr(JB(m("ui.notices.files.save_failed"),m("ui.notices.files.save_failed_gone"),k))}},w=async k=>{let P=rU(e);if(s&&["open-file","open-folder","copy-file-path"].includes(k.id))try{P=await s()}catch{Tr(m("ui.canvas.files.prepareError"));return}switch(k.id){case"expand-image":O?.();return;case"open-file":gO(P);return;case"open-folder":H8(P);return;case"show-in-canvas":c?.();return;case"copy-file-path":b(P,"File path copied to clipboard","Failed to copy file path");return;case"copy-image":x();return;case"save-as":Q();return;case"copy-image-url":b(t??e,"Image URL copied to clipboard","Failed to copy image URL");return;case"open-in-browser":K8(t??e);return}},S=g??`Actions for ${n??"this image"}`;return f.jsxs(yz,{open:r,onOpenChange:i,children:[f.jsx(vt,{content:p,children:f.jsx(vz,{asChild:!0,children:f.jsx(ke,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":S,tabIndex:o,onClick:k=>k.stopPropagation(),children:f.jsx(Iq,{"aria-hidden":"true"})})})}),f.jsxs(bz,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:k=>k.stopPropagation(),children:[s&&f.jsx("div",{role:"note",className:E("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:m("ui.canvas.files.pathCopyNote")}),v.map(k=>f.jsxs(ml,{onSelect:()=>w(k),children:[ZPt[k.id],f.jsx("span",{children:k.label})]},k.id))]})]})},DPt=({src:e,alt:t,title:n,className:r})=>{const i=Tv(),a=e??"",o=Y1e(a);if(o==="other")return f.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=Z1e(o,{canShowInCanvas:s,source:a});return f.jsxs("span",{className:E("group/mdimg relative inline-block max-w-full"),children:[f.jsx("img",{src:e,alt:t,title:n,className:r}),l&&f.jsx("span",{"data-markdown-image":"",className:E("pointer-events-none absolute top-1 right-1 z-[2] opacity-0","transition-opacity duration-fast ease-out-quart","group-hover/mdimg:pointer-events-auto group-hover/mdimg:opacity-100","group-focus-within/mdimg:pointer-events-auto group-focus-within/mdimg:opacity-100","has-[[aria-expanded=true]]:pointer-events-auto has-[[aria-expanded=true]]:opacity-100"),children:f.jsx(V1e,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||gO(rU(a))})}:void 0})})]})};function VPt(){return{enter:{mathFlow:e,mathFlowFenceMeta:t,mathText:a},exit:{mathFlow:i,mathFlowFence:r,mathFlowFenceMeta:n,mathFlowValue:s,mathText:o,mathTextData:s}};function e(l){const c={type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]};this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[c]}},l)}function t(){this.buffer()}function n(){const l=this.resume(),c=this.stack[this.stack.length-1];c.type,c.meta=l}function r(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)}function i(l){const c=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),u=this.stack[this.stack.length-1];u.type,this.exit(l),u.value=c;const O=u.data.hChildren[0];O.type,O.tagName,O.children.push({type:"text",value:c}),this.data.mathFlowInside=void 0}function a(l){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-inline"]},hChildren:[]}},l),this.buffer()}function o(l){const c=this.resume(),u=this.stack[this.stack.length-1];u.type,this.exit(l),u.value=c,u.data.hChildren.push({type:"text",value:c})}function s(l){this.config.enter.data.call(this,l),this.config.exit.data.call(this,l)}}const MPt={tokenize:LPt,concrete:!0,name:"mathFlow"},eH={tokenize:FPt,partial:!0};function LPt(e,t,n){const r=this,i=r.events[r.events.length-1],a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0;let o=0;return s;function s(b){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),l(b)}function l(b){return b===36?(e.consume(b),o++,l):o<2?n(b):(e.exit("mathFlowFenceSequence"),tn(e,c,"whitespace")(b))}function c(b){return b===null||yt(b)?O(b):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(b))}function u(b){return b===null||yt(b)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),O(b)):b===36?n(b):(e.consume(b),u)}function O(b){return e.exit("mathFlowFence"),r.interrupt?t(b):e.attempt(eH,d,y)(b)}function d(b){return e.attempt({tokenize:v,partial:!0},y,h)(b)}function h(b){return(a?tn(e,p,"linePrefix",a+1):p)(b)}function p(b){return b===null?y(b):yt(b)?e.attempt(eH,d,y)(b):(e.enter("mathFlowValue"),g(b))}function g(b){return b===null||yt(b)?(e.exit("mathFlowValue"),p(b)):(e.consume(b),g)}function y(b){return e.exit("mathFlow"),t(b)}function v(b,x,Q){let w=0;return tn(b,S,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function S(R){return b.enter("mathFlowFence"),b.enter("mathFlowFenceSequence"),k(R)}function k(R){return R===36?(w++,b.consume(R),k):w<o?Q(R):(b.exit("mathFlowFenceSequence"),tn(b,P,"whitespace")(R))}function P(R){return R===null||yt(R)?(b.exit("mathFlowFence"),x(R)):Q(R)}}}function FPt(e,t,n){const r=this;return i;function i(o){return o===null?t(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function BPt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:HPt,previous:KPt,name:"mathText"};function r(i,a,o){let s=0,l,c;return u;function u(g){return i.enter("mathText"),i.enter("mathTextSequence"),O(g)}function O(g){return g===36?(i.consume(g),s++,O):s<2&&!n?o(g):(i.exit("mathTextSequence"),d(g))}function d(g){return g===null?o(g):g===36?(c=i.enter("mathTextSequence"),l=0,p(g)):g===32?(i.enter("space"),i.consume(g),i.exit("space"),d):yt(g)?(i.enter("lineEnding"),i.consume(g),i.exit("lineEnding"),d):(i.enter("mathTextData"),h(g))}function h(g){return g===null||g===32||g===36||yt(g)?(i.exit("mathTextData"),d(g)):(i.consume(g),h)}function p(g){return g===36?(i.consume(g),l++,p):l===s?(i.exit("mathTextSequence"),i.exit("mathText"),a(g)):(c.type="mathTextData",h(g))}}}function HPt(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function KPt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function JPt(e){return{flow:{36:MPt},text:{36:BPt()}}}const Nh=36,tH=e=>e!==null&&e<-2,nH=e=>e===null||e===32||e<0,rH=e=>e!==null&&e>=48&&e<=57,M1e=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:e5t,previous:t5t,name:"mathText"};function n(r,i,a){const o=this;let s=0,l=null,c,u;return O;function O(y){return r.enter("mathText"),r.enter("mathTextSequence"),d(y)}function d(y){return y===Nh?(r.consume(y),s++,d):s<2&&!t||s===1&&(nH(y)||rH(y))?a(y):(r.exit("mathTextSequence"),h(y))}function h(y){return y===null?a(y):y===Nh?(u=r.enter("mathTextSequence"),c=0,l=o.previous,g(y)):y===32?(r.enter("space"),r.consume(y),r.exit("space"),h):tH(y)?(r.enter("lineEnding"),r.consume(y),r.exit("lineEnding"),h):(r.enter("mathTextData"),p(y))}function p(y){return y===null||y===32||y===Nh||tH(y)?(r.exit("mathTextData"),h(y)):(r.consume(y),p)}function g(y){return y===Nh?(r.consume(y),c++,g):c===s?s===1&&(nH(l)||rH(y))?a(y):(r.exit("mathTextSequence"),r.exit("mathText"),i(y)):(u.type="mathTextData",p(y))}}};function e5t(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function t5t(e){return e!==Nh||this.events[this.events.length-1][1].type==="characterEscape"}const n5t=JPt().flow,r5t=M1e();function p_(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?r5t:M1e(e);n.push({flow:n5t,text:{[Nh]:i}}),r.push(VPt())}const L1e=({node:e,...t})=>f.jsx("div",{className:"lo-md-table-scroll",children:f.jsx("table",{...t})}),i5t=/\$(?!\d)(.+?)\$/,a5t=/\$\$([\s\S]+?)\$\$/,o5t=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,s5t=/\\[a-zA-Z]+(\{[^}]*\})?/,iH=e=>i5t.test(e)||a5t.test(e)||o5t.test(e)?!0:s5t.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),l5t=e=>{const t=f_(e);if(t.length===1&&t[0].kind==="text")return null;let n="",r=!1;for(const i of t){if(i.kind==="text"){n+=i.text;continue}r=!0,n+="x".repeat(i.text.length)}return r?n:null},c5t=e=>f_(e).filter(t=>t.kind!=="text").length,u5t=e=>{if(!iH(e))return!1;const t=l5t(e);return t===null?!0:iH(t)||t.includes("$")?!1:c5t(e)<2},Vt="var(--color-ink)",ec="var(--color-ink-muted)",sl="var(--color-surface)",Qu="var(--color-elevated)",tc="var(--color-sunken)",Vi="var(--color-hairline)",ku="var(--color-control)",dh="var(--color-accent)",m0="var(--color-accent-wash)",O5t="var(--color-accent-alt-wash)",d5t="var(--color-on-accent)",f5t="var(--color-info)",F1e="var(--color-info-wash)",h5t="var(--color-success)",B1e="var(--color-success-wash)",p5t="var(--color-warning)",I7="var(--color-warning-wash)",m5t="var(--color-warning-border)",D2="var(--color-danger)",D7="var(--color-danger-wash)",aH=[m0,O5t,F1e,B1e,I7,D7],_u=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),g5t=()=>{const e={primaryColor:_u("--color-accent"),secondaryColor:_u("--color-success"),tertiaryColor:_u("--color-info"),mainBkg:_u("--color-elevated"),clusterBkg:_u("--color-sunken"),clusterBorder:_u("--color-hairline"),edgeLabelBackground:_u("--color-surface"),quadrant1Fill:_u("--color-accent-wash")};for(const[n,r]of Object.entries(e))r===""&&delete e[n];const t={darkMode:getComputedStyle(document.documentElement).colorScheme.includes("dark"),background:sl,primaryTextColor:Vt,primaryBorderColor:ku,secondaryTextColor:Vt,secondaryBorderColor:Vi,tertiaryTextColor:Vt,tertiaryBorderColor:Vi,lineColor:ec,arrowheadColor:ec,textColor:Vt,secondBkg:tc,border1:ku,border2:Vi,labelColor:Vt,nodeBkg:Qu,nodeBorder:ku,nodeTextColor:Vt,defaultLinkColor:ec,titleColor:Vt,noteBkgColor:I7,noteBorderColor:m5t,noteTextColor:Vt,actorBkg:Qu,actorBorder:ku,actorTextColor:Vt,actorLineColor:Vi,signalColor:ec,signalTextColor:Vt,labelBoxBkgColor:Qu,labelBoxBorderColor:Vi,labelTextColor:Vt,loopTextColor:Vt,activationBkgColor:m0,activationBorderColor:dh,sequenceNumberColor:sl,sectionBkgColor:tc,sectionBkgColor2:sl,altSectionBkgColor:tc,excludeBkgColor:tc,taskBkgColor:m0,taskBorderColor:ku,taskTextColor:Vt,taskTextLightColor:Vt,taskTextDarkColor:Vt,taskTextOutsideColor:Vt,taskTextClickableColor:dh,activeTaskBkgColor:m0,activeTaskBorderColor:dh,gridColor:Vi,doneTaskBkgColor:tc,doneTaskBorderColor:Vi,critBkgColor:D7,critBorderColor:D2,todayLineColor:dh,transitionColor:ec,transitionLabelColor:Vt,stateLabelColor:Vt,stateBkg:Qu,labelBackgroundColor:sl,compositeBackground:tc,altBackground:tc,compositeTitleBackground:Qu,compositeBorder:Vi,innerEndBackground:Vt,specialStateColor:Vt,classText:Vt,attributeBackgroundColorOdd:sl,attributeBackgroundColorEven:tc,rowOdd:sl,rowEven:tc,errorBkgColor:D7,errorTextColor:D2,pieTitleTextColor:Vt,pieSectionTextColor:Vt,pieLegendTextColor:Vt,pieStrokeColor:sl,pieOuterStrokeColor:Vi,requirementBackground:Qu,requirementBorderColor:ku,requirementTextColor:Vt,relationColor:ec,relationLabelBackground:sl,relationLabelColor:Vt,branchLabelColor:d5t,commitLabelColor:Vt,commitLabelBackground:sl,tagLabelColor:Vt,tagLabelBackground:m0,tagLabelBorder:ku,quadrant2Fill:F1e,quadrant3Fill:B1e,quadrant4Fill:I7,quadrant2TextFill:Vt,quadrant3TextFill:Vt,quadrant4TextFill:Vt,quadrantPointFill:dh,archEdgeColor:ec,archEdgeArrowColor:ec,archGroupBorderColor:Vi,scaleLabelColor:Vt,packet:{startByteColor:Vt,endByteColor:Vt,labelColor:Vt,titleColor:Vt,blockStrokeColor:ku,blockFillColor:Qu},radar:{axisColor:ec,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:Vi,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:sl,titleColor:Vt,xAxisTitleColor:Vt,xAxisLabelColor:Vt,xAxisTickColor:Vi,xAxisLineColor:Vi,yAxisTitleColor:Vt,yAxisLabelColor:Vt,yAxisTickColor:Vi,yAxisLineColor:Vi,plotColorPalette:[dh,f5t,h5t,p5t,D2].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Qu,t[`surfacePeer${n}`]=Vi;for(let n=0;n<8;n++)t[`fillType${n}`]=aH[n%aH.length];return{...t,...e}};let V2=null,oH=null;const $5t=async e=>{V2||(V2=be(async()=>{const{default:n}=await import("./mermaid.core-CdQ7E5mL.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([9,1,2,3]),import.meta.url).then(({default:n})=>n));const t=await V2;return oH!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:g5t()}),oH=e),t},sH=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>f.jsxs("div",{className:E("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[f.jsx(vt,{content:m("ui.chat.mermaid.zoom_in"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.zoom_in"),onClick:n,children:f.jsx(Rle,{})})}),f.jsx(vt,{content:m("ui.chat.mermaid.zoom_out"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.zoom_out"),onClick:r,children:f.jsx(Ele,{})})}),f.jsx(vt,{content:m("ui.chat.mermaid.pan_hint"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.pan"),children:f.jsx(Nje,{})})}),f.jsx(vt,{content:m("ui.chat.mermaid.reset_view"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.reset_view"),onClick:i,children:f.jsx(MQ,{})})}),f.jsx(vt,{content:m("ui.chat.mermaid.save_svg"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.save_svg"),onClick:a,children:f.jsx(DQ,{})})}),f.jsx(vt,{content:t?m("ui.chat.mermaid.copied"):m("ui.chat.mermaid.copy_text"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":t?m("ui.chat.mermaid.copied"):m("ui.chat.mermaid.copy_text"),onClick:o,children:f.jsx(pf,{className:E(t&&"text-success")})})}),s]}),V7=({title:e,children:t})=>f.jsxs(Tl,{variant:"danger",role:"alert",className:"my-4",children:[f.jsx(S0,{children:e}),f.jsx(Q0,{children:t})]});class y5t extends $.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("Mermaid Error Boundary caught an error:",t,n)}render(){return this.state.hasError?this.props.fallback||f.jsxs(V7,{title:m("ui.chat.mermaid.error_title"),children:[this.state.error?.message||m("ui.chat.mermaid.unexpected_error")," ",m("ui.chat.mermaid.error_contained")]}):this.props.children}}const v5t=$.memo(({chart:e,id:t})=>{Qe();const n=$.useRef(null),r=$.useRef(null),[i,a]=$.useState(null),[o,s]=$.useState(!0),[l,c]=$.useState(""),[u,O]=$.useState(!1),[d,h]=$.useState({scale:1,x:0,y:0}),[p,g]=$.useState({scale:1,x:0,y:0}),[y,v]=$.useState(!1),[b,x]=$.useState({x:0,y:0}),[Q,w]=$.useState("idle"),[S,k]=$.useState("idle"),P=Xn(G=>G.themeName),R=$.useCallback(async()=>{try{if(s(!0),a(null),c(""),!e||typeof e!="string"||e.trim().length===0)throw new Error("Invalid or empty chart content");const G=await $5t(P),ne=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:L}=await G.render(ne,e);if(!L||typeof L!="string"||L.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(L)}catch(G){console.error("Mermaid rendering error:",G);const ne=G instanceof Error?G.message:"Failed to render mermaid diagram";a(ne),c("")}finally{s(!1)}},[e,t,P]);$.useEffect(()=>{R().catch(G=>{console.error("Error in renderDiagram effect:",G),a("Failed to initialize diagram rendering"),s(!1)})},[R]);const T=$.useCallback(()=>{try{if(!l||!r.current)return 1;const ne=r.current.getBoundingClientRect(),L=document.createElement("div");L.innerHTML=l;const B=L.querySelector("svg");if(!B)return 1;const se=B.getBoundingClientRect?.()?.width||Number.parseFloat(B.getAttribute("width")||"0")||B.viewBox?.baseVal?.width||800,H=B.getBoundingClientRect?.()?.height||Number.parseFloat(B.getAttribute("height")||"0")||B.viewBox?.baseVal?.height||600,ee=ne.width*.9/se,re=ne.height*.9/H;return Math.min(ee,re,1)}catch(G){return console.error("Error calculating fullscreen scale:",G),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const G=T();g({scale:G,x:0,y:0})}catch(G){console.error("Error setting fullscreen transform:",G)}},100)},[u,l,T]);const q=$.useCallback((G=!1)=>{try{(G?g:h)(L=>({...L,scale:Math.min(L.scale*1.2,10)}))}catch(ne){console.error("Error in zoom in:",ne)}},[]),X=$.useCallback((G=!1)=>{try{(G?g:h)(L=>({...L,scale:Math.max(L.scale/1.2,.1)}))}catch(ne){console.error("Error in zoom out:",ne)}},[]),C=$.useCallback((G=!1)=>{try{const ne=G?g:h;if(G){const L=T();ne({scale:L,x:0,y:0})}else ne({scale:1,x:0,y:0})}catch(ne){console.error("Error in reset:",ne)}},[T]),N=$.useCallback(()=>{if(l)try{const G=new Blob([l],{type:"image/svg+xml"}),ne=URL.createObjectURL(G),L=document.createElement("a");L.href=ne,L.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(L),L.click(),document.body.removeChild(L),URL.revokeObjectURL(ne)}catch(G){console.error("Failed to save SVG:",G)}},[l]),A=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),w("copied"),setTimeout(()=>w("idle"),1200)}catch(G){console.error("Failed to copy Mermaid chart text:",G)}},[e]),Y=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),k("copied"),setTimeout(()=>k("idle"),1200)}catch(G){console.error("Failed to copy Mermaid chart text:",G)}},[e]),W=$.useCallback(G=>{try{v(!0),x({x:G.clientX,y:G.clientY}),G.preventDefault()}catch(ne){console.error("Error in mouse down:",ne)}},[]),Z=$.useCallback((G,ne=!1)=>{try{if(!y)return;const L=G.clientX-b.x,B=G.clientY-b.y;(ne?g:h)(H=>({...H,x:H.x+L,y:H.y+B})),x({x:G.clientX,y:G.clientY})}catch(L){console.error("Error in mouse move:",L)}},[y,b]),D=$.useCallback(()=>{try{v(!1)}catch(G){console.error("Error in mouse up:",G)}},[]),z=$.useCallback((G,ne=!1)=>{try{G.preventDefault();const L=G.deltaY>0?.9:1.1;(ne?g:h)(se=>({...se,scale:Math.min(Math.max(se.scale*L,.1),5)}))}catch(L){console.error("Error in wheel:",L)}},[]),V=$.useCallback(G=>{try{O(G)}catch(ne){console.error("Error toggling fullscreen:",ne)}},[]);if(i)return f.jsxs(V7,{title:m("ui.chat.mermaid.error_title"),children:[i,f.jsx("span",{className:E("mt-2 block text-ink-muted"),children:m("ui.chat.mermaid.chart_label")}),f.jsx("span",{className:E("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const J=(G=!1)=>{try{const ne=G?r:n,L=G?p:d;return f.jsx("div",{ref:ne,className:E("mermaid flex w-full items-center justify-center",G?"h-full min-h-full":"h-auto min-h-50",y?"cursor-grabbing":"cursor-grab"),onMouseDown:W,onMouseMove:B=>Z(B,G),onMouseUp:D,onMouseLeave:D,onWheel:B=>z(B,G),children:o?f.jsx("div",{className:E("p-4 text-body-sm text-ink-muted"),children:m("ui.chat.mermaid.loading")}):l?f.jsx("div",{className:E("flex h-full w-full items-center justify-center"),style:{transform:`translate(${L.x}px, ${L.y}px) scale(${L.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(ne){return console.error("Error rendering diagram content:",ne),f.jsx(V7,{title:m("ui.chat.mermaid.rendering_error"),children:m("ui.chat.mermaid.render_failed")})}};return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:E("relative flex items-center justify-center overflow-hidden rounded-md bg-surface","[&_svg]:h-auto [&_svg]:min-h-100 [&_svg]:max-w-none [&_svg]:bg-transparent"),children:[J(!1),f.jsx(sH,{className:"top-2 right-2",copied:Q==="copied",onZoomIn:()=>q(!1),onZoomOut:()=>X(!1),onReset:()=>C(!1),onSave:N,onCopy:A,children:f.jsx(vt,{content:m("ui.chat.mermaid.fullscreen"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.open_fullscreen"),onClick:()=>V(!0),children:f.jsx(xle,{})})})})]}),f.jsx(g$,{open:u,onClose:()=>V(!1),title:m("ui.chat.mermaid.diagram_title"),maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:f.jsxs("div",{className:E("relative flex h-[80vh] w-full items-center justify-center overflow-hidden","[&_svg]:h-auto [&_svg]:max-h-full [&_svg]:w-auto [&_svg]:max-w-full [&_svg]:bg-transparent"),children:[J(!0),f.jsx(sH,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>q(!0),onZoomOut:()=>X(!0),onReset:()=>C(!0),onSave:N,onCopy:Y,children:f.jsx(vt,{content:m("ui.chat.mermaid.close_fullscreen"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.close_fullscreen"),onClick:()=>V(!1),children:f.jsx(ni,{})})})})]})})]})}),b5t=$.memo(e=>f.jsx(y5t,{children:f.jsx(v5t,{...e})}));let H1e=!1,M2=null;const w5t=()=>(M2||(M2=be(()=>Promise.resolve({}),__vite__mapDeps([10]),import.meta.url).then(e=>(H1e=!0,e))),M2),x5t=/language-(\w+)/,S5t=cz,Q5t=new RegExp(`^[^${Yc}\\d*+-]`),k5t=/\n$/,K1e=({href:e,children:t})=>{const n=i1e(e),r=Tv();return!n||n.kind==="other"?f.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}):f.jsx("a",{href:n.target,"data-lo-kind":n.kind,"data-lo-target":n.target,draggable:!1,target:n.kind==="url"?"_blank":void 0,rel:n.kind==="url"?"noopener noreferrer":void 0,onClick:n.kind==="file"?i=>T5t(i,r):void 0,children:t})},_5t=e=>i1e(e)?.kind==="file",P5t=l1e,T5t=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(s1e)??"file",i=n.getAttribute(P5t),a=ekt({kind:r,hasHighlight:$kt(n),canOpenInCanvas:B8(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||gO(i)});return}gO(i)}},M7=(e,t)=>t==="href"&&_5t(e)?e:bde(e),ny={a:K1e,table:L1e,img:DPt,code:({node:e,className:t,children:n,...r})=>x5t.exec(t??"")?.[1]==="mermaid"?f.jsx(b5t,{chart:String(n).replace(k5t,"")}):f.jsx("code",{dir:"ltr",className:t,...r,children:n})},X5t={...ny,a:XPt(K1e)},R5t=[Ws],E5t=[Ws,p_],q5t=[Ws,u_],j5t=[Ws,p_,u_],C5t=[Ws,h_,O_],z5t=[Ws,p_,h_,O_],A5t=[Ws,u_,h_,O_],U5t=[Ws,p_,u_,h_,O_],W5t={"000":R5t,"001":C5t,"010":q5t,"011":A5t,100:E5t,101:z5t,110:j5t,111:U5t},N5t=[],Y5t=[qLe],J1e=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),exe=(e,t,n)=>{const r=$.useMemo(()=>u5t(e),[e]),[i,a]=$.useState(H1e),o=r&&i;return $.useEffect(()=>{if(!r||i)return;let s=!1;return w5t().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:W5t[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?Y5t:N5t}},txe=(e,t,n)=>{const[,r]=$.useState(0);$.useEffect(()=>{if(!t)return;const i=OHe(e);if(i.length===0)return;let a=!0;const o=new Set(i),s=ikt(l=>{a&&l.some(c=>o.has(c))&&r(c=>c+1)});return F8(i,window.api?.probeFiles,_se,nkt(n===void 0?e:`${n}\0${e}`)).then(()=>{a&&i.some(l=>o1e(l)!=="unknown")&&r(l=>l+1)}),()=>{a=!1,s()}},[e,t,n])},ry=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1,documentId:a})=>{const o=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:s,rehypePlugins:l}=exe(o,r,i),c=J1e(t);return txe(o,r,a),f.jsx("div",{className:E("lo-markdown",n),style:c,children:f.jsx(wx,{remarkPlugins:s,rehypePlugins:l,urlTransform:M7,components:i?X5t:ny,children:o})})});ry.displayName="MarkdownRenderer";const lH={...ny,a:({children:e})=>f.jsx(f.Fragment,{children:e})},nxe=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:UB(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=b1e(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=exe(n,t,!1);if(txe(e,t),r!==null){const o=UB(r.before);return f.jsxs(f.Fragment,{children:[o.trim()!==""&&f.jsx(wx,{remarkPlugins:i,rehypePlugins:a,urlTransform:M7,components:t?ny:lH,children:o}),f.jsx(G5t,{info:r.info,body:r.body})]})}return f.jsx(wx,{remarkPlugins:i,rehypePlugins:a,urlTransform:M7,components:t?ny:lH,children:n})});nxe.displayName="ParsedBlock";const G5t=({info:e,body:t})=>{const n=e.split(S5t)[0];return f.jsx("pre",{children:f.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
|
|
872
|
+
`)&&(s={capture:wS(e),buffer:n,caret:r})}return{...s,capture:Wh(s.capture,s.buffer,s.caret,i)}}function m_t(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=Xf(t);if(o===null||t.value==="")return{minted:!1,capture:t,buffer:n,caret:r,payload:null};const s=t.arm===null?o.start:t.arm.start,l=C1e(i,t.value),c=l+d_,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:Ua,buffer:u,caret:s+c.length,payload:{index:i,key:z1e(a,e.draw),value:t.value,marker:l}}}const g_t=e=>Yo(e)&&e.value!=="";function $_t(e,t){const n=Xf(e);if(n===null)return{cancelled:!1,capture:e,buffer:t,caret:0,token:null};const r=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:Ua,buffer:t.slice(0,n.start)+t.slice(n.end),caret:n.start,token:{span:{start:r,end:n.start},text:t.slice(r,n.start)}}}function y_t(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function v_t(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=Xf(e);return o===null?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:n.start<=o.start?{kind:"passthrough",capture:{...e,typingAt:o.start+r.length},buffer:i,caret:a,payload:null}:n.start>=o.end?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:{kind:"passthrough",capture:wS(e),buffer:i,caret:a,payload:null}}function b_t(e){const{capture:t,buffer:n,caret:r,pasted:i}=e;if(t.arm===null)return null;if(t.typingAt!==null&&t.value!==""){if(i==="")return null;const u=tU(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=Mn(i);if(!a)return i===""?null:v_t(t,n,e.selection,i);const o=t.arm,s=C1e(e.index,a),l=s+d_,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:Ua,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:z1e(e.taken,e.draw),value:a,marker:s}}}const j1e=e=>`${l_t(e)} chars`,C1e=(e,t)=>`[Credential #${e}, ${j1e(t)}]`;function w_t(e){kl.lastIndex=0;const t=kl.exec(e);return kl.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function x_t(e){kl.lastIndex=0;const t=kl.exec(e);if(kl.lastIndex=0,t===null||t[0]!==e)return null;const n=Number.parseInt(t[1],10);return{index:n,label:`#${n}`,chars:Number.parseInt(t[2],10)}}function Rv(e,t){if(w_t(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const W2=/\[credential ([A-Za-z_][A-Za-z0-9_]*) \((\d+) chars\) \u2014 available to bash and eval as \$([A-Za-z_][A-Za-z0-9_]*); its value cannot be read\]/y,N2=/\[credential NOT stored \u2014 [^\]\n]*\]/y,Y2=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,S_t=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&G7.test(t[1])?t[1]:""};function Q_t(e,t){if(e.charCodeAt(t)!==91)return null;W2.lastIndex=t;const n=W2.exec(e);if(W2.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};N2.lastIndex=t;const r=N2.exec(e);if(N2.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};Y2.lastIndex=t;const i=Y2.exec(e);return Y2.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:S_t(i[0])}:null}function f_(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=Q_t(e,r);if(i===null){r++;continue}r>n&&t.push({kind:"text",text:e.slice(n,r)}),t.push(i),r+=i.text.length,n=r}return n<e.length&&t.push({kind:"text",text:e.slice(n)}),t}function IB(e,t){const n=[];for(const r of t){const i=Rv(e,r);i!==null&&n.push({at:i.start,payload:r})}return n.sort((r,i)=>r.at-i.at).map(r=>r.payload)}function k_t(e,t=""){return e==="unconfirmed"?t?`[credential unconfirmed — it may be held as $${t}, so check list_variables before assuming it is missing]`:"[credential unconfirmed — the session may hold it, so check list_variables before assuming it is missing]":e==="unreachable"?"[credential NOT stored — the session could not be reached; try again]":e==="rejected-key"?"[credential NOT stored — the store rejected its name]":"[credential NOT stored — its value did not survive; ask the operator to paste it again]"}const __t=e=>`[credential ${e.key} (${j1e(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function P_t(e,t,n=new Map){const r=[...t],i=[];for(const o of r){const s=Rv(e,o);s!==null&&i.push({span:s,payload:o})}for(const o of X1e(e,r))i.push({span:o,payload:null});let a=e;for(const{span:o,payload:s}of i.sort((l,c)=>c.span.start-l.span.start)){const l=s===null?"lost":n.get(s.index),c=s===null||l!==void 0?k_t(l??"lost",s?.key):__t(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const T_t=(e,t,n)=>`Removed ${e} (credential #${t}) from this message. Its value is gone — press ${n} to put it back, or paste it again after /credential to reuse it.`,X_t=e=>`Remove credential #${e}`,R_t=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,E_t=(e,t,n)=>T_t(e,t,n),q_t="Undo",j_t=e=>m("ui.notices.credentials.removed",{index:e}),C_t=e=>e.unredacted!==null?e.unredacted:e.armed?Z_t:e.cleared!==null?E_t(e.cleared.key,e.cleared.index,e.undoCap):null;function z_t(e){const{buffer:t,payload:n}=e,r=Rv(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===d_?r.end+1:r.end;return{cleared:!0,buffer:t.slice(0,r.start)+t.slice(i),caret:r.start,removed:t.slice(r.start,i)}}function A_t(e){const{buffer:t,cleared:n}=e;return n.removed===""||t!==n.buffer?null:{buffer:t.slice(0,n.caret)+n.removed+t.slice(n.caret),caret:n.caret+n.removed.length}}const DB=e=>m("ui.notices.credentials.stored",{keys:e.join(", ")});function VB(e){return m("ui.notices.credentials.unstored",{count:e.length,keys:[...e].sort().join(", ")})}const U_t="store unconfirmed",W_t="Credential store unconfirmed",N_t=e=>e===""?W_t:`${e} · ${U_t}`,Y_t="Paste the value again after /credential to store it again.",G_t=e=>`${e} ${Y_t}`;function MB(e){return m("ui.notices.credentials.unconfirmed",{count:e.length,keys:[...e].sort().join(", ")})}const Z_t="armed — add a space, then type or paste the secret",I_t="masked as you type — Enter makes a pill, Esc twice discards",D_t="masked — Enter opens the credential picker; type or paste the secret into this span",V_t="Esc again discards it — still masked, Enter makes a pill",M_t="credential discarded — nothing was stored or sent",L_t="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",F_t=e=>`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`;function B_t(e,t){const n=Xf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const LB=(e,t)=>e&&e.over===t?e.chars:null,H_t=e=>{const t=Math.floor(4294967296/e)*e,n=new Uint32Array(1);for(;;)if(globalThis.crypto.getRandomValues(n),n[0]<t)return n[0]%e},K_t=16,J_t=16;function z1e(e=[],t=H_t){const n=new Set(e);for(let r=0;r<K_t;r++){const i=GB+FB(8,t);if(!n.has(i))return i}return GB+FB(J_t,t)}const FB=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=YB[t(YB.length)];return n},ePt=8,tPt=256,nPt=/^[/@$#]/,rPt=/^\w+:\/\//,iPt=/^[A-Za-z]+$/,aPt=/^\d+$/,oPt=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/],sPt=3,lPt=20,cPt=/^[A-Za-z0-9_\-+/=.]+$/,uPt=new RegExp(`^[^${Yc}@]+@[^${Yc}@]+\\.[A-Za-z]{2,}$`),OPt=/^[\w.-]+(?:\/[\w.-]+)+$/,dPt=/\.[A-Za-z][A-Za-z0-9]{0,7}$/,fPt=/^v?\d+(?:\.\d+)+(?:[-+][0-9A-Za-z.-]+)?$/,hPt=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,pPt=/^[\w.-]+:\d{2,5}$/,mPt=/^(?:[0-9a-f]{7,12}|[0-9a-f]{40})$/i,gPt=/^[a-z]+(?:_[a-z]+)+$/,$Pt=/^[a-z]+(?:-[a-z]+)+$/,yPt=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$/,vPt=/^[a-z0-9]+(?:-[a-z0-9]+)+$/,bPt=/\d{4,}/,wPt=e=>{const t=e.trim();return t.length<ePt||t.length>tPt||Us.test(t)||nPt.test(t)||rPt.test(t)||Lce(t)!==null||uPt.test(t)||OPt.test(t)||dPt.test(t)||fPt.test(t)||hPt.test(t)||pPt.test(t)||mPt.test(t)||gPt.test(t)||$Pt.test(t)||yPt.test(t)||vPt.test(t)&&bPt.test(t)||iPt.test(t)||aPt.test(t)?!1:oPt.filter(r=>r.test(t)).length>=sPt?!0:t.length>=lPt&&cPt.test(t)},A1e=E("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),U1e=E("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),W1e=({label:e,chars:t=null,tone:n="live",title:r,onClear:i,clearLabel:a,className:o,style:s,small:l=!1})=>f.jsxs("span",{className:E("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?U1e:A1e,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?f.jsx(Fse,{"aria-hidden":"true",className:"size-3 shrink-0"}):f.jsx(hje,{"aria-hidden":"true",className:"size-3 shrink-0"}),f.jsx("span",{className:"min-w-0 truncate",children:e}),t!==null&&f.jsx("span",{className:"shrink-0",children:`· ${t} chars`}),i&&f.jsx("button",{type:"button","aria-label":a,onClick:i,className:"pointer-events-auto -mr-1 flex shrink-0 cursor-pointer items-center rounded-xs p-0.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-offset-1! active:bg-sunken",children:f.jsx(ni,{"aria-hidden":"true",className:"size-3"})}),r&&f.jsx("span",{className:"sr-only",children:r})]}),ty="#lo-credential/",xPt=`${ty}unstored`,BB=`${ty}unconfirmed`,SPt=/^\d+$/,N1e=e=>e.kind==="stored"?`${ty}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${BB}/${e.key}`:BB:xPt;function QPt(e){if(!e||!e.startsWith(ty))return null;const t=e.slice(ty.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return G7.test(a)?{kind:"unconfirmed",key:a}:null}const n=t.lastIndexOf("/");if(n===-1)return null;const r=t.slice(0,n),i=t.slice(n+1);return!G7.test(r)||!SPt.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function HB(e,t){const n=QPt(e);if(n===null)return null;const r=f_(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return N1e(i)!==e?null:n}const h_=()=>e=>{const t=n=>{if(!n.children)return;const r=[];let i=!1;for(const a of n.children){if(a.type!=="text"||typeof a.value!="string"){t(a),r.push(a);continue}const o=f_(a.value);if(o.length===1&&o[0].kind==="text"){r.push(a);continue}i=!0;for(const s of o){if(s.kind==="text"){r.push({type:"text",value:s.text});continue}r.push({type:"link",url:N1e(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},kPt=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?N_t(e.key):"Credential not stored",_Pt=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?G_t(t):t,PPt=({citation:e,title:t})=>f.jsx(W1e,{tone:e.kind==="stored"?"live":"warning",label:kPt(e),chars:e.kind==="stored"?e.chars:null,title:_Pt(e,t),className:"align-middle"}),TPt=(e,t)=>typeof t=="string"?HB(e,t):t==null?HB(e,""):null,XPt=e=>({href:t,title:n,children:r})=>{const i=TPt(t,r);if(i===null){const a=e;return f.jsx(a,{href:t,title:n,children:r})}return f.jsx(PPt,{citation:i,title:n})},Y1e=e=>DBe(e)?"artifact":e.startsWith("data:")?"data":e.startsWith("blob:")?"blob":e.startsWith("http://")||e.startsWith("https://")?"http":e.startsWith("file://")||e.startsWith("/")||e.startsWith("~")?"path":"other",nU=e=>{const t=Y1e(e);return t==="other"?"path":t},G2={id:"open-file",get label(){return m("ui.common.file_actions.open_file")}},RPt={id:"show-in-canvas",get label(){return m("ui.common.file_actions.show_in_canvas")}},EPt={id:"save-as",get label(){return m("ui.chat.image_actions.save_as")}},Z2={id:"open-folder",get label(){return m("ui.common.file_actions.open_folder")}},I2={id:"copy-file-path",get label(){return m("ui.common.file_actions.copy_file_path")}},Oh={id:"copy-image",get label(){return m("ui.chat.image_actions.copy_image")}},qPt={id:"copy-image-url",get label(){return m("ui.chat.image_actions.copy_image_url")}},jPt={id:"open-in-browser",get label(){return m("ui.chat.image_actions.open_in_browser")}};function G1e(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const o=[...t?[RPt]:[],...a?[{id:"expand-image",get label(){return m("ui.chat.image_actions.expand_image")}}]:[]];switch(e){case"artifact":return[...o,...i?[G2,Z2,I2]:[],EPt,...r==="video"||r==="audio"?[]:[Oh]];case"path":return[...o,G2,Z2,I2,...r==="video"||r==="audio"?[]:[Oh]];case"data":return[...o,Oh];case"blob":return i?[...o,G2,Z2,I2,Oh]:[Oh];case"http":return[...CPt(n)?[Oh]:[],qPt,jPt];case"other":return[]}}const Z1e=(e,t)=>G1e(e,t).length>0;function CPt(e){try{const t=new URL(e),n=t.hostname==="localhost"||t.hostname==="127.0.0.1";return t.protocol==="http:"&&n&&(t.port==="1111"||t.port==="8080")}catch{return!1}}const rU=e=>e.startsWith("file://")?e.slice(7):e;function I1e(e){const t=e.indexOf(",");if(t===-1)throw new Error("Malformed data URL");const n=e.slice(5,t),r=e.slice(t+1),i=n.split(";")[0]||"application/octet-stream";if(n.endsWith(";base64")){const s=atob(r),l=new Uint8Array(s.length);for(let c=0;c<s.length;c+=1)l[c]=s.charCodeAt(c);return new Blob([l],{type:i})}const a=decodeURIComponent(r),o=new Uint8Array(a.length);for(let s=0;s<a.length;s+=1)o[s]=a.charCodeAt(s);return new Blob([o],{type:i})}async function KB(e,t,n){if(e==="data")return I1e(t);if(e==="blob"){const o=Dle(n??t);if(o===null)throw new Error("These image bytes are not available in this window");return o}if(e==="http"){const o=await fetch(n??t);if(!o.ok)throw new Error(`The image server answered ${o.status}`);return o.blob()}const r=window.api?.readFileBytes;if(typeof r!="function")throw new Error("This window cannot read local files");const i=rU(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:b$(i)})}const zPt=e=>e.trim().toLowerCase()!=="image/png";async function APt(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!zPt(e.type))return e;const t=URL.createObjectURL(e);try{const n=await UPt(t);if(n.naturalWidth===0||n.naturalHeight===0)throw new Error("This image could not be decoded for the clipboard");const r=document.createElement("canvas");r.width=n.naturalWidth,r.height=n.naturalHeight;const i=r.getContext("2d");if(i===null)throw new Error("This window cannot re-encode the image for the clipboard");i.drawImage(n,0,0);const a=await new Promise(o=>{r.toBlob(o,"image/png")});if(a===null)throw new Error("This image could not be re-encoded for the clipboard");return a}finally{URL.revokeObjectURL(t)}}function UPt(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>t(r),r.onerror=()=>n(new Error("This image could not be decoded for the clipboard")),r.src=e})}const WPt=6e4;function NPt(e,t){const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.setTimeout(()=>URL.revokeObjectURL(n),WPt)}const N1=new Map;function YPt(e,t){const n=N1.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await is(e.childId?{op:"subagents.attachment",sessionId:e.sessionId,childId:e.childId,digest:t}:{op:"sessions.attachment",sessionId:e.sessionId,digest:t},null);if(i.kind!=="bytes")return null;const a=BQ(i.data,i.mimeType);return r.holders<=0?(ev(a),null):(Nz(t,a),a)}catch{return null}finally{N1.delete(t)}})(),N1.set(t,r),r.promise}class iU extends Error{constructor(){super("This item is no longer in the session"),this.name="AttachmentGoneError"}}async function D1e(e,t){const n=$$(t),r=n?Dle(n):null;if(r)return r;const i=await is(e.childId?{op:"subagents.attachment",sessionId:e.sessionId,childId:e.childId,digest:t}:{op:"sessions.attachment",sessionId:e.sessionId,digest:t},null);if(i.kind!=="bytes")throw i.status===404?new iU:new Error("These bytes are not available right now");return new Blob([i.data],{type:i.mimeType})}function GPt(e){const t=N1.get(e);t&&(t.holders-=1)}function Ev(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=$.useState(()=>e.attachment?$$(e.attachment):null),[a,o]=$.useState(!1),s=t?.sessionId??null,l=t?.childId??null;$.useEffect(()=>{const u=e.attachment;if(n||!u||!s)return;let O=!0;const d=fp(u);if(d)return i(d),o(!1),()=>{O=!1,hp(u)};i(null),o(!1);let h=!0;return YPt({sessionId:s,childId:l},u).then(p=>{if(h=!1,!!O){if(!p){o(!0);return}i(fp(u))}}),()=>{O=!1,h&&GPt(u),hp(u)}},[e.attachment,n,s,l]);const c=n??r;return c?{state:"ready",url:c}:e.attachment&&s&&!a?{state:"resolving"}:{state:"missing"}}function aU(e,t){return Ev(e,t)}const cln=Object.freeze(Object.defineProperty({__proto__:null,AttachmentGoneError:iU,fetchAttachmentBlob:D1e,useAttachmentSource:Ev,useAttachmentUrl:aU},Symbol.toStringTag,{value:"Module"})),ZPt={"expand-image":f.jsx(xle,{"aria-hidden":"true"}),"open-file":f.jsx(By,{"aria-hidden":"true"}),"show-in-canvas":f.jsx(ble,{"aria-hidden":"true"}),"save-as":f.jsx(DQ,{"aria-hidden":"true"}),"open-folder":f.jsx(dp,{"aria-hidden":"true"}),"copy-file-path":f.jsx(Tz,{"aria-hidden":"true"}),"copy-image":f.jsx(pf,{"aria-hidden":"true"}),"copy-image-url":f.jsx($je,{"aria-hidden":"true"}),"open-in-browser":f.jsx(VQ,{"aria-hidden":"true"})},JB=(e,t,n)=>n instanceof iU?t:e;function IPt({file:e,src:t,resolvePath:n,missing:r,onShowInCanvas:i,mediaKind:a,onExpand:o,saveName:s}){return G1e(nU(e),{canShowInCanvas:!!i,source:t??e,mediaKind:a,artifactPathActions:!!n,canExpand:!!o}).filter(l=>(l.id!=="save-as"||!!s)&&(!r||l.id==="copy-file-path"))}const V1e=({file:e,src:t,label:n,open:r,onOpenChange:i,onCloseAutoFocus:a,triggerTabIndex:o,resolvePath:s,missing:l,onShowInCanvas:c,mediaKind:u,onExpand:O,saveName:d,resolveBytes:h,tooltip:p="Image actions","aria-label":g})=>{const y=nU(e),v=IPt({file:e,src:t,resolvePath:s,missing:l,onShowInCanvas:c,mediaKind:u,onExpand:O,saveName:d});if(v.length===0)return null;const b=async(k,P,R)=>{try{await navigator.clipboard.writeText(k),aO(P)}catch(T){console.error(`${R}: `,T),Tr(R)}},x=async()=>{try{if(typeof ClipboardItem>"u")throw new Error("this window cannot write an image to the clipboard");const k=h?await h():await KB(y,e,t),P=await APt(k);await navigator.clipboard.write([new ClipboardItem({[P.type]:P})]),aO(m("ui.notices.files.image_copied"))}catch(k){console.error("Failed to copy image: ",k),Tr(JB(m("ui.notices.files.image_copy_failed"),m("ui.notices.files.image_copy_failed_gone"),k))}},Q=async()=>{try{const k=h?await h():await KB(y,e,t);NPt(k,d??"download")}catch(k){console.error("Failed to save file: ",k),Tr(JB(m("ui.notices.files.save_failed"),m("ui.notices.files.save_failed_gone"),k))}},w=async k=>{let P=rU(e);if(s&&["open-file","open-folder","copy-file-path"].includes(k.id))try{P=await s()}catch{Tr(m("ui.canvas.files.prepareError"));return}switch(k.id){case"expand-image":O?.();return;case"open-file":gO(P);return;case"open-folder":H8(P);return;case"show-in-canvas":c?.();return;case"copy-file-path":b(P,"File path copied to clipboard","Failed to copy file path");return;case"copy-image":x();return;case"save-as":Q();return;case"copy-image-url":b(t??e,"Image URL copied to clipboard","Failed to copy image URL");return;case"open-in-browser":K8(t??e);return}},S=g??`Actions for ${n??"this image"}`;return f.jsxs(yz,{open:r,onOpenChange:i,children:[f.jsx(vt,{content:p,children:f.jsx(vz,{asChild:!0,children:f.jsx(ke,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":S,tabIndex:o,onClick:k=>k.stopPropagation(),children:f.jsx(Iq,{"aria-hidden":"true"})})})}),f.jsxs(bz,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:k=>k.stopPropagation(),children:[s&&f.jsx("div",{role:"note",className:E("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:m("ui.canvas.files.pathCopyNote")}),v.map(k=>f.jsxs(ml,{onSelect:()=>w(k),children:[ZPt[k.id],f.jsx("span",{children:k.label})]},k.id))]})]})},DPt=({src:e,alt:t,title:n,className:r})=>{const i=Tv(),a=e??"",o=Y1e(a);if(o==="other")return f.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=Z1e(o,{canShowInCanvas:s,source:a});return f.jsxs("span",{className:E("group/mdimg relative inline-block max-w-full"),children:[f.jsx("img",{src:e,alt:t,title:n,className:r}),l&&f.jsx("span",{"data-markdown-image":"",className:E("pointer-events-none absolute top-1 right-1 z-[2] opacity-0","transition-opacity duration-fast ease-out-quart","group-hover/mdimg:pointer-events-auto group-hover/mdimg:opacity-100","group-focus-within/mdimg:pointer-events-auto group-focus-within/mdimg:opacity-100","has-[[aria-expanded=true]]:pointer-events-auto has-[[aria-expanded=true]]:opacity-100"),children:f.jsx(V1e,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||gO(rU(a))})}:void 0})})]})};function VPt(){return{enter:{mathFlow:e,mathFlowFenceMeta:t,mathText:a},exit:{mathFlow:i,mathFlowFence:r,mathFlowFenceMeta:n,mathFlowValue:s,mathText:o,mathTextData:s}};function e(l){const c={type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]};this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[c]}},l)}function t(){this.buffer()}function n(){const l=this.resume(),c=this.stack[this.stack.length-1];c.type,c.meta=l}function r(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)}function i(l){const c=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),u=this.stack[this.stack.length-1];u.type,this.exit(l),u.value=c;const O=u.data.hChildren[0];O.type,O.tagName,O.children.push({type:"text",value:c}),this.data.mathFlowInside=void 0}function a(l){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-inline"]},hChildren:[]}},l),this.buffer()}function o(l){const c=this.resume(),u=this.stack[this.stack.length-1];u.type,this.exit(l),u.value=c,u.data.hChildren.push({type:"text",value:c})}function s(l){this.config.enter.data.call(this,l),this.config.exit.data.call(this,l)}}const MPt={tokenize:LPt,concrete:!0,name:"mathFlow"},eH={tokenize:FPt,partial:!0};function LPt(e,t,n){const r=this,i=r.events[r.events.length-1],a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0;let o=0;return s;function s(b){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),l(b)}function l(b){return b===36?(e.consume(b),o++,l):o<2?n(b):(e.exit("mathFlowFenceSequence"),tn(e,c,"whitespace")(b))}function c(b){return b===null||yt(b)?O(b):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(b))}function u(b){return b===null||yt(b)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),O(b)):b===36?n(b):(e.consume(b),u)}function O(b){return e.exit("mathFlowFence"),r.interrupt?t(b):e.attempt(eH,d,y)(b)}function d(b){return e.attempt({tokenize:v,partial:!0},y,h)(b)}function h(b){return(a?tn(e,p,"linePrefix",a+1):p)(b)}function p(b){return b===null?y(b):yt(b)?e.attempt(eH,d,y)(b):(e.enter("mathFlowValue"),g(b))}function g(b){return b===null||yt(b)?(e.exit("mathFlowValue"),p(b)):(e.consume(b),g)}function y(b){return e.exit("mathFlow"),t(b)}function v(b,x,Q){let w=0;return tn(b,S,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function S(R){return b.enter("mathFlowFence"),b.enter("mathFlowFenceSequence"),k(R)}function k(R){return R===36?(w++,b.consume(R),k):w<o?Q(R):(b.exit("mathFlowFenceSequence"),tn(b,P,"whitespace")(R))}function P(R){return R===null||yt(R)?(b.exit("mathFlowFence"),x(R)):Q(R)}}}function FPt(e,t,n){const r=this;return i;function i(o){return o===null?t(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function BPt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:HPt,previous:KPt,name:"mathText"};function r(i,a,o){let s=0,l,c;return u;function u(g){return i.enter("mathText"),i.enter("mathTextSequence"),O(g)}function O(g){return g===36?(i.consume(g),s++,O):s<2&&!n?o(g):(i.exit("mathTextSequence"),d(g))}function d(g){return g===null?o(g):g===36?(c=i.enter("mathTextSequence"),l=0,p(g)):g===32?(i.enter("space"),i.consume(g),i.exit("space"),d):yt(g)?(i.enter("lineEnding"),i.consume(g),i.exit("lineEnding"),d):(i.enter("mathTextData"),h(g))}function h(g){return g===null||g===32||g===36||yt(g)?(i.exit("mathTextData"),d(g)):(i.consume(g),h)}function p(g){return g===36?(i.consume(g),l++,p):l===s?(i.exit("mathTextSequence"),i.exit("mathText"),a(g)):(c.type="mathTextData",h(g))}}}function HPt(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function KPt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function JPt(e){return{flow:{36:MPt},text:{36:BPt()}}}const Nh=36,tH=e=>e!==null&&e<-2,nH=e=>e===null||e===32||e<0,rH=e=>e!==null&&e>=48&&e<=57,M1e=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:e5t,previous:t5t,name:"mathText"};function n(r,i,a){const o=this;let s=0,l=null,c,u;return O;function O(y){return r.enter("mathText"),r.enter("mathTextSequence"),d(y)}function d(y){return y===Nh?(r.consume(y),s++,d):s<2&&!t||s===1&&(nH(y)||rH(y))?a(y):(r.exit("mathTextSequence"),h(y))}function h(y){return y===null?a(y):y===Nh?(u=r.enter("mathTextSequence"),c=0,l=o.previous,g(y)):y===32?(r.enter("space"),r.consume(y),r.exit("space"),h):tH(y)?(r.enter("lineEnding"),r.consume(y),r.exit("lineEnding"),h):(r.enter("mathTextData"),p(y))}function p(y){return y===null||y===32||y===Nh||tH(y)?(r.exit("mathTextData"),h(y)):(r.consume(y),p)}function g(y){return y===Nh?(r.consume(y),c++,g):c===s?s===1&&(nH(l)||rH(y))?a(y):(r.exit("mathTextSequence"),r.exit("mathText"),i(y)):(u.type="mathTextData",p(y))}}};function e5t(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="mathTextData"){e[t][1].type="mathTextPadding",e[n][1].type="mathTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="mathTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function t5t(e){return e!==Nh||this.events[this.events.length-1][1].type==="characterEscape"}const n5t=JPt().flow,r5t=M1e();function p_(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?r5t:M1e(e);n.push({flow:n5t,text:{[Nh]:i}}),r.push(VPt())}const L1e=({node:e,...t})=>f.jsx("div",{className:"lo-md-table-scroll",children:f.jsx("table",{...t})}),i5t=/\$(?!\d)(.+?)\$/,a5t=/\$\$([\s\S]+?)\$\$/,o5t=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,s5t=/\\[a-zA-Z]+(\{[^}]*\})?/,iH=e=>i5t.test(e)||a5t.test(e)||o5t.test(e)?!0:s5t.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),l5t=e=>{const t=f_(e);if(t.length===1&&t[0].kind==="text")return null;let n="",r=!1;for(const i of t){if(i.kind==="text"){n+=i.text;continue}r=!0,n+="x".repeat(i.text.length)}return r?n:null},c5t=e=>f_(e).filter(t=>t.kind!=="text").length,u5t=e=>{if(!iH(e))return!1;const t=l5t(e);return t===null?!0:iH(t)||t.includes("$")?!1:c5t(e)<2},Vt="var(--color-ink)",ec="var(--color-ink-muted)",sl="var(--color-surface)",Qu="var(--color-elevated)",tc="var(--color-sunken)",Vi="var(--color-hairline)",ku="var(--color-control)",dh="var(--color-accent)",m0="var(--color-accent-wash)",O5t="var(--color-accent-alt-wash)",d5t="var(--color-on-accent)",f5t="var(--color-info)",F1e="var(--color-info-wash)",h5t="var(--color-success)",B1e="var(--color-success-wash)",p5t="var(--color-warning)",I7="var(--color-warning-wash)",m5t="var(--color-warning-border)",D2="var(--color-danger)",D7="var(--color-danger-wash)",aH=[m0,O5t,F1e,B1e,I7,D7],_u=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),g5t=()=>{const e={primaryColor:_u("--color-accent"),secondaryColor:_u("--color-success"),tertiaryColor:_u("--color-info"),mainBkg:_u("--color-elevated"),clusterBkg:_u("--color-sunken"),clusterBorder:_u("--color-hairline"),edgeLabelBackground:_u("--color-surface"),quadrant1Fill:_u("--color-accent-wash")};for(const[n,r]of Object.entries(e))r===""&&delete e[n];const t={darkMode:getComputedStyle(document.documentElement).colorScheme.includes("dark"),background:sl,primaryTextColor:Vt,primaryBorderColor:ku,secondaryTextColor:Vt,secondaryBorderColor:Vi,tertiaryTextColor:Vt,tertiaryBorderColor:Vi,lineColor:ec,arrowheadColor:ec,textColor:Vt,secondBkg:tc,border1:ku,border2:Vi,labelColor:Vt,nodeBkg:Qu,nodeBorder:ku,nodeTextColor:Vt,defaultLinkColor:ec,titleColor:Vt,noteBkgColor:I7,noteBorderColor:m5t,noteTextColor:Vt,actorBkg:Qu,actorBorder:ku,actorTextColor:Vt,actorLineColor:Vi,signalColor:ec,signalTextColor:Vt,labelBoxBkgColor:Qu,labelBoxBorderColor:Vi,labelTextColor:Vt,loopTextColor:Vt,activationBkgColor:m0,activationBorderColor:dh,sequenceNumberColor:sl,sectionBkgColor:tc,sectionBkgColor2:sl,altSectionBkgColor:tc,excludeBkgColor:tc,taskBkgColor:m0,taskBorderColor:ku,taskTextColor:Vt,taskTextLightColor:Vt,taskTextDarkColor:Vt,taskTextOutsideColor:Vt,taskTextClickableColor:dh,activeTaskBkgColor:m0,activeTaskBorderColor:dh,gridColor:Vi,doneTaskBkgColor:tc,doneTaskBorderColor:Vi,critBkgColor:D7,critBorderColor:D2,todayLineColor:dh,transitionColor:ec,transitionLabelColor:Vt,stateLabelColor:Vt,stateBkg:Qu,labelBackgroundColor:sl,compositeBackground:tc,altBackground:tc,compositeTitleBackground:Qu,compositeBorder:Vi,innerEndBackground:Vt,specialStateColor:Vt,classText:Vt,attributeBackgroundColorOdd:sl,attributeBackgroundColorEven:tc,rowOdd:sl,rowEven:tc,errorBkgColor:D7,errorTextColor:D2,pieTitleTextColor:Vt,pieSectionTextColor:Vt,pieLegendTextColor:Vt,pieStrokeColor:sl,pieOuterStrokeColor:Vi,requirementBackground:Qu,requirementBorderColor:ku,requirementTextColor:Vt,relationColor:ec,relationLabelBackground:sl,relationLabelColor:Vt,branchLabelColor:d5t,commitLabelColor:Vt,commitLabelBackground:sl,tagLabelColor:Vt,tagLabelBackground:m0,tagLabelBorder:ku,quadrant2Fill:F1e,quadrant3Fill:B1e,quadrant4Fill:I7,quadrant2TextFill:Vt,quadrant3TextFill:Vt,quadrant4TextFill:Vt,quadrantPointFill:dh,archEdgeColor:ec,archEdgeArrowColor:ec,archGroupBorderColor:Vi,scaleLabelColor:Vt,packet:{startByteColor:Vt,endByteColor:Vt,labelColor:Vt,titleColor:Vt,blockStrokeColor:ku,blockFillColor:Qu},radar:{axisColor:ec,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:Vi,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:sl,titleColor:Vt,xAxisTitleColor:Vt,xAxisLabelColor:Vt,xAxisTickColor:Vi,xAxisLineColor:Vi,yAxisTitleColor:Vt,yAxisLabelColor:Vt,yAxisTickColor:Vi,yAxisLineColor:Vi,plotColorPalette:[dh,f5t,h5t,p5t,D2].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Qu,t[`surfacePeer${n}`]=Vi;for(let n=0;n<8;n++)t[`fillType${n}`]=aH[n%aH.length];return{...t,...e}};let V2=null,oH=null;const $5t=async e=>{V2||(V2=be(async()=>{const{default:n}=await import("./mermaid.core-ChUVqMVr.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([9,1,2,3]),import.meta.url).then(({default:n})=>n));const t=await V2;return oH!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:g5t()}),oH=e),t},sH=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>f.jsxs("div",{className:E("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[f.jsx(vt,{content:m("ui.chat.mermaid.zoom_in"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.zoom_in"),onClick:n,children:f.jsx(Rle,{})})}),f.jsx(vt,{content:m("ui.chat.mermaid.zoom_out"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.zoom_out"),onClick:r,children:f.jsx(Ele,{})})}),f.jsx(vt,{content:m("ui.chat.mermaid.pan_hint"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.pan"),children:f.jsx(Nje,{})})}),f.jsx(vt,{content:m("ui.chat.mermaid.reset_view"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.reset_view"),onClick:i,children:f.jsx(MQ,{})})}),f.jsx(vt,{content:m("ui.chat.mermaid.save_svg"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.save_svg"),onClick:a,children:f.jsx(DQ,{})})}),f.jsx(vt,{content:t?m("ui.chat.mermaid.copied"):m("ui.chat.mermaid.copy_text"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":t?m("ui.chat.mermaid.copied"):m("ui.chat.mermaid.copy_text"),onClick:o,children:f.jsx(pf,{className:E(t&&"text-success")})})}),s]}),V7=({title:e,children:t})=>f.jsxs(Tl,{variant:"danger",role:"alert",className:"my-4",children:[f.jsx(S0,{children:e}),f.jsx(Q0,{children:t})]});class y5t extends $.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("Mermaid Error Boundary caught an error:",t,n)}render(){return this.state.hasError?this.props.fallback||f.jsxs(V7,{title:m("ui.chat.mermaid.error_title"),children:[this.state.error?.message||m("ui.chat.mermaid.unexpected_error")," ",m("ui.chat.mermaid.error_contained")]}):this.props.children}}const v5t=$.memo(({chart:e,id:t})=>{Qe();const n=$.useRef(null),r=$.useRef(null),[i,a]=$.useState(null),[o,s]=$.useState(!0),[l,c]=$.useState(""),[u,O]=$.useState(!1),[d,h]=$.useState({scale:1,x:0,y:0}),[p,g]=$.useState({scale:1,x:0,y:0}),[y,v]=$.useState(!1),[b,x]=$.useState({x:0,y:0}),[Q,w]=$.useState("idle"),[S,k]=$.useState("idle"),P=Xn(G=>G.themeName),R=$.useCallback(async()=>{try{if(s(!0),a(null),c(""),!e||typeof e!="string"||e.trim().length===0)throw new Error("Invalid or empty chart content");const G=await $5t(P),ne=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:L}=await G.render(ne,e);if(!L||typeof L!="string"||L.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(L)}catch(G){console.error("Mermaid rendering error:",G);const ne=G instanceof Error?G.message:"Failed to render mermaid diagram";a(ne),c("")}finally{s(!1)}},[e,t,P]);$.useEffect(()=>{R().catch(G=>{console.error("Error in renderDiagram effect:",G),a("Failed to initialize diagram rendering"),s(!1)})},[R]);const T=$.useCallback(()=>{try{if(!l||!r.current)return 1;const ne=r.current.getBoundingClientRect(),L=document.createElement("div");L.innerHTML=l;const B=L.querySelector("svg");if(!B)return 1;const se=B.getBoundingClientRect?.()?.width||Number.parseFloat(B.getAttribute("width")||"0")||B.viewBox?.baseVal?.width||800,H=B.getBoundingClientRect?.()?.height||Number.parseFloat(B.getAttribute("height")||"0")||B.viewBox?.baseVal?.height||600,ee=ne.width*.9/se,re=ne.height*.9/H;return Math.min(ee,re,1)}catch(G){return console.error("Error calculating fullscreen scale:",G),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const G=T();g({scale:G,x:0,y:0})}catch(G){console.error("Error setting fullscreen transform:",G)}},100)},[u,l,T]);const q=$.useCallback((G=!1)=>{try{(G?g:h)(L=>({...L,scale:Math.min(L.scale*1.2,10)}))}catch(ne){console.error("Error in zoom in:",ne)}},[]),X=$.useCallback((G=!1)=>{try{(G?g:h)(L=>({...L,scale:Math.max(L.scale/1.2,.1)}))}catch(ne){console.error("Error in zoom out:",ne)}},[]),C=$.useCallback((G=!1)=>{try{const ne=G?g:h;if(G){const L=T();ne({scale:L,x:0,y:0})}else ne({scale:1,x:0,y:0})}catch(ne){console.error("Error in reset:",ne)}},[T]),N=$.useCallback(()=>{if(l)try{const G=new Blob([l],{type:"image/svg+xml"}),ne=URL.createObjectURL(G),L=document.createElement("a");L.href=ne,L.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(L),L.click(),document.body.removeChild(L),URL.revokeObjectURL(ne)}catch(G){console.error("Failed to save SVG:",G)}},[l]),A=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),w("copied"),setTimeout(()=>w("idle"),1200)}catch(G){console.error("Failed to copy Mermaid chart text:",G)}},[e]),Y=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),k("copied"),setTimeout(()=>k("idle"),1200)}catch(G){console.error("Failed to copy Mermaid chart text:",G)}},[e]),W=$.useCallback(G=>{try{v(!0),x({x:G.clientX,y:G.clientY}),G.preventDefault()}catch(ne){console.error("Error in mouse down:",ne)}},[]),Z=$.useCallback((G,ne=!1)=>{try{if(!y)return;const L=G.clientX-b.x,B=G.clientY-b.y;(ne?g:h)(H=>({...H,x:H.x+L,y:H.y+B})),x({x:G.clientX,y:G.clientY})}catch(L){console.error("Error in mouse move:",L)}},[y,b]),D=$.useCallback(()=>{try{v(!1)}catch(G){console.error("Error in mouse up:",G)}},[]),z=$.useCallback((G,ne=!1)=>{try{G.preventDefault();const L=G.deltaY>0?.9:1.1;(ne?g:h)(se=>({...se,scale:Math.min(Math.max(se.scale*L,.1),5)}))}catch(L){console.error("Error in wheel:",L)}},[]),V=$.useCallback(G=>{try{O(G)}catch(ne){console.error("Error toggling fullscreen:",ne)}},[]);if(i)return f.jsxs(V7,{title:m("ui.chat.mermaid.error_title"),children:[i,f.jsx("span",{className:E("mt-2 block text-ink-muted"),children:m("ui.chat.mermaid.chart_label")}),f.jsx("span",{className:E("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const J=(G=!1)=>{try{const ne=G?r:n,L=G?p:d;return f.jsx("div",{ref:ne,className:E("mermaid flex w-full items-center justify-center",G?"h-full min-h-full":"h-auto min-h-50",y?"cursor-grabbing":"cursor-grab"),onMouseDown:W,onMouseMove:B=>Z(B,G),onMouseUp:D,onMouseLeave:D,onWheel:B=>z(B,G),children:o?f.jsx("div",{className:E("p-4 text-body-sm text-ink-muted"),children:m("ui.chat.mermaid.loading")}):l?f.jsx("div",{className:E("flex h-full w-full items-center justify-center"),style:{transform:`translate(${L.x}px, ${L.y}px) scale(${L.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(ne){return console.error("Error rendering diagram content:",ne),f.jsx(V7,{title:m("ui.chat.mermaid.rendering_error"),children:m("ui.chat.mermaid.render_failed")})}};return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:E("relative flex items-center justify-center overflow-hidden rounded-md bg-surface","[&_svg]:h-auto [&_svg]:min-h-100 [&_svg]:max-w-none [&_svg]:bg-transparent"),children:[J(!1),f.jsx(sH,{className:"top-2 right-2",copied:Q==="copied",onZoomIn:()=>q(!1),onZoomOut:()=>X(!1),onReset:()=>C(!1),onSave:N,onCopy:A,children:f.jsx(vt,{content:m("ui.chat.mermaid.fullscreen"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.open_fullscreen"),onClick:()=>V(!0),children:f.jsx(xle,{})})})})]}),f.jsx(g$,{open:u,onClose:()=>V(!1),title:m("ui.chat.mermaid.diagram_title"),maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:f.jsxs("div",{className:E("relative flex h-[80vh] w-full items-center justify-center overflow-hidden","[&_svg]:h-auto [&_svg]:max-h-full [&_svg]:w-auto [&_svg]:max-w-full [&_svg]:bg-transparent"),children:[J(!0),f.jsx(sH,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>q(!0),onZoomOut:()=>X(!0),onReset:()=>C(!0),onSave:N,onCopy:Y,children:f.jsx(vt,{content:m("ui.chat.mermaid.close_fullscreen"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.close_fullscreen"),onClick:()=>V(!1),children:f.jsx(ni,{})})})})]})})]})}),b5t=$.memo(e=>f.jsx(y5t,{children:f.jsx(v5t,{...e})}));let H1e=!1,M2=null;const w5t=()=>(M2||(M2=be(()=>Promise.resolve({}),__vite__mapDeps([10]),import.meta.url).then(e=>(H1e=!0,e))),M2),x5t=/language-(\w+)/,S5t=cz,Q5t=new RegExp(`^[^${Yc}\\d*+-]`),k5t=/\n$/,K1e=({href:e,children:t})=>{const n=i1e(e),r=Tv();return!n||n.kind==="other"?f.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}):f.jsx("a",{href:n.target,"data-lo-kind":n.kind,"data-lo-target":n.target,draggable:!1,target:n.kind==="url"?"_blank":void 0,rel:n.kind==="url"?"noopener noreferrer":void 0,onClick:n.kind==="file"?i=>T5t(i,r):void 0,children:t})},_5t=e=>i1e(e)?.kind==="file",P5t=l1e,T5t=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(s1e)??"file",i=n.getAttribute(P5t),a=ekt({kind:r,hasHighlight:$kt(n),canOpenInCanvas:B8(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||gO(i)});return}gO(i)}},M7=(e,t)=>t==="href"&&_5t(e)?e:bde(e),ny={a:K1e,table:L1e,img:DPt,code:({node:e,className:t,children:n,...r})=>x5t.exec(t??"")?.[1]==="mermaid"?f.jsx(b5t,{chart:String(n).replace(k5t,"")}):f.jsx("code",{dir:"ltr",className:t,...r,children:n})},X5t={...ny,a:XPt(K1e)},R5t=[Ws],E5t=[Ws,p_],q5t=[Ws,u_],j5t=[Ws,p_,u_],C5t=[Ws,h_,O_],z5t=[Ws,p_,h_,O_],A5t=[Ws,u_,h_,O_],U5t=[Ws,p_,u_,h_,O_],W5t={"000":R5t,"001":C5t,"010":q5t,"011":A5t,100:E5t,101:z5t,110:j5t,111:U5t},N5t=[],Y5t=[qLe],J1e=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),exe=(e,t,n)=>{const r=$.useMemo(()=>u5t(e),[e]),[i,a]=$.useState(H1e),o=r&&i;return $.useEffect(()=>{if(!r||i)return;let s=!1;return w5t().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:W5t[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?Y5t:N5t}},txe=(e,t,n)=>{const[,r]=$.useState(0);$.useEffect(()=>{if(!t)return;const i=OHe(e);if(i.length===0)return;let a=!0;const o=new Set(i),s=ikt(l=>{a&&l.some(c=>o.has(c))&&r(c=>c+1)});return F8(i,window.api?.probeFiles,_se,nkt(n===void 0?e:`${n}\0${e}`)).then(()=>{a&&i.some(l=>o1e(l)!=="unknown")&&r(l=>l+1)}),()=>{a=!1,s()}},[e,t,n])},ry=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1,documentId:a})=>{const o=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:s,rehypePlugins:l}=exe(o,r,i),c=J1e(t);return txe(o,r,a),f.jsx("div",{className:E("lo-markdown",n),style:c,children:f.jsx(wx,{remarkPlugins:s,rehypePlugins:l,urlTransform:M7,components:i?X5t:ny,children:o})})});ry.displayName="MarkdownRenderer";const lH={...ny,a:({children:e})=>f.jsx(f.Fragment,{children:e})},nxe=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:UB(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=b1e(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=exe(n,t,!1);if(txe(e,t),r!==null){const o=UB(r.before);return f.jsxs(f.Fragment,{children:[o.trim()!==""&&f.jsx(wx,{remarkPlugins:i,rehypePlugins:a,urlTransform:M7,components:t?ny:lH,children:o}),f.jsx(G5t,{info:r.info,body:r.body})]})}return f.jsx(wx,{remarkPlugins:i,rehypePlugins:a,urlTransform:M7,components:t?ny:lH,children:n})});nxe.displayName="ParsedBlock";const G5t=({info:e,body:t})=>{const n=e.split(S5t)[0];return f.jsx("pre",{children:f.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
|
|
873
873
|
`)?"":`
|
|
874
874
|
`}`})})},rxe=({content:e,styleProps:t,className:n})=>{const r=$.useRef(null);r.current===null&&(r.current=wkt());const i=r.current;kkt(i,e);const{blockStart:a}=i,o=a+_kt(e.slice(a));let s=null,l=a;(i.kind==="other"||(i.kind==="list"||i.kind==="indented-code")&&Q5t.test(e.slice(i.cursor)))&&i.fence===null&&i.blankRunStart>=a&&i.cursor<o&&e.slice(i.cursor,o).trim().length>0&&(s=e.slice(a,i.blankRunStart),l=i.cursor);const c=e.slice(l,o),u=i.blocks.map((d,h)=>({key:h,source:d,closed:!0}));s!==null&&u.push({key:i.blocks.length,source:s,closed:!0}),c!==""&&u.push({key:u.length,source:c,closed:!1});const O=J1e(t);return f.jsx("div",{className:E("lo-markdown",n),style:O,children:u.map(d=>f.jsx(nxe,{source:d.source,closed:d.closed},d.key))})};rxe.displayName="StreamingMarkdown";const L7=({src:e,name:t,className:n})=>f.jsx(URe,{className:E("mb-1 size-5",n),children:f.jsx(WRe,{src:e,alt:t??"",loading:"eager"})}),Qa=({isUser:e,children:t,className:n})=>e?f.jsx("div",{className:E("flex w-full justify-end",n),children:t}):f.jsx("div",{className:E("group relative w-full",n),children:t}),oU=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},Z5t=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()+1),Math.max(1,t.getTime()-e)};let sU=oU(Date.now()),$c=null,cH=0,uH=0,OH=0;const Y1=new Set,I5t=1e3,D5t=()=>typeof performance>"u"?Date.now():performance.now(),ixe=()=>{const e=Date.now(),t=e+Z5t(e),n=D5t();$c!==null&&t===cH&&Math.abs(e-uH-(n-OH))<=I5t||($c!==null&&clearTimeout($c),cH=t,uH=e,OH=n,$c=setTimeout(()=>{$c=null,sU=oU(Date.now());for(const r of Y1)r();ixe()},t-e),$c.unref?.())},V5t=e=>(Y1.add(e),sU=oU(Date.now()),ixe(),()=>{Y1.delete(e),Y1.size===0&&$c!==null&&(clearTimeout($c),$c=null)}),dH=()=>sU,M5t=()=>$.useSyncExternalStore(V5t,dH,dH),L5t=e=>new Date(e+1e3),F5t=()=>L5t(M5t()),uln=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":YQ(t,{year:"numeric",month:"long",day:"numeric"})}catch(t){return console.error("Error formatting calendar date:",t),""}},B5t=(e,t=new Date)=>{if(e==null)return"";try{const n=e instanceof Date?e:new Date(e);if(Number.isNaN(n.getTime()))return"";const r=GQ(n,{hour:"numeric",minute:"2-digit",hour12:!0});if(n.toDateString()===t.toDateString())return r;const i=new Date(t);if(i.setDate(t.getDate()-1),n.toDateString()===i.toDateString())return m("ui.common.time.yesterday_at",{time:r});const a=YQ(n,{month:"short",day:"numeric"});return n.getFullYear()===t.getFullYear()?`${a}, ${r}`:`${a}, ${n.getFullYear()}, ${r}`}catch(n){return console.error("Error formatting turn timestamp:",n),""}},H5t=(e,t)=>{if(!e)return"";try{const n=e instanceof Date?e:new Date(e);return Number.isNaN(n.getTime())?"":tle(n,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit",...t})}catch(n){return console.error("Error formatting calendar date-time:",n),""}},K5t={turn:"Sent",answer:"Answered",tool:"Ran"},xS=({timestamp:e,scope:t,className:n})=>{const r=e instanceof Date?e:new Date(e),i=F5t();if(Number.isNaN(r.getTime()))return null;const a=H5t(r,{hour12:!0});return f.jsx(vt,{content:a,side:"bottom",delayDuration:1200,children:f.jsx("time",{dateTime:r.toISOString(),"data-stamp":t,"aria-label":`${K5t[t]} ${a}`,className:E("shrink-0 select-none whitespace-nowrap text-ink-dim text-meta",n),children:f.jsx("bdi",{children:B5t(r,i)})})})},lU=({replies:e,onRemoveReply:t})=>(Qe(),f.jsxs("div",{className:"mb-2 flex flex-col gap-1.5 rounded-sm bg-sunken p-2",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-ink-dim",children:[f.jsx(Sle,{size:12,"aria-hidden":"true"}),f.jsx("span",{className:"text-meta",children:m("ui.chat.reply.replying_to")})]}),e.map(n=>f.jsxs("div",{className:"flex items-center gap-2 border-hairline border-s-2 py-0.5 ps-2",children:[f.jsx("span",{className:"flex-1 truncate text-body-sm text-ink-muted",title:n.text,children:n.text}),t&&f.jsx(ke,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-ink-dim hover:bg-elevated hover:text-ink",onClick:()=>t(n.id),"aria-label":m("ui.chat.reply.remove"),children:f.jsx(ni,{"aria-hidden":"true"})})]},n.id))]})),J5t=({children:e,className:t})=>f.jsx("span",{"aria-hidden":!0,className:E("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),eTt={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},tTt=({line:e})=>f.jsx("span",{className:E(eTt[e.kind],"block"),children:e.text}),nTt=({diff:e,className:t})=>{const n=z2e(e);return f.jsxs("div",{className:E("max-h-[740px] overflow-y-auto overflow-x-hidden rounded-md bg-sunken p-3 font-mono text-ink text-mono-sm whitespace-pre-wrap break-words",t),children:[n.lines.map((r,i)=>f.jsx(tTt,{line:r},i)),n.hidden>0&&f.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:A2e(n.hidden)})]})},rTt=(e,t=72)=>{let i=e.replace(/```[\s\S]*?```/g," ").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/\s+/g," ").trim();if(i.length>t){const a=i.slice(0,t),o=a.lastIndexOf(" ");i=`${a.slice(0,o>32?o:t).trimEnd()}…`}return i.replace(/[.!?…]+$/g,"").trimEnd()},fH=e=>e.startsWith("file://")?e.slice(7):e,iTt={READ:{verb:"Read",runningVerb:"Reading",icon:ple},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:kle},EDIT:{verb:"Edited",runningVerb:"Editing",icon:n3e},CODE:{verb:"Ran code",runningVerb:"Running code",icon:gle},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:y3e},DONE:{verb:"Finished",runningVerb:"Finishing",icon:wz},ASK:{verb:"Asked",runningVerb:"Asking",icon:ZQ},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:Tqe}},aTt={verb:"Worked on the request",runningVerb:"Working on the request",icon:gle},oTt=(e,t,n,r)=>{const i=e?iTt[e]:aTt;let a;if(t)a=fH(t);else if(n&&n.length>0){const s=n.filter(l=>!l.startsWith("data:"));s.length===1?a=fH(s[0]):s.length>1&&(a=`${s.length} files`)}const o=!a&&r?rTt(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:a,narration:o||void 0,icon:i.icon}},hH="min-h-5 py-0",sTt=({icon:e,verb:t,object:n,narration:r,running:i,failed:a,wrap:o})=>f.jsxs("span",{className:E("flex min-w-0 gap-2",o?"items-start":"items-center"),"aria-busy":i||void 0,children:[f.jsx(J5t,{className:E(a?"text-danger":"text-ink-dim",o&&nue),children:e}),f.jsxs("span",{className:E(o?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[f.jsxs("span",{...t5,className:E("select-text font-mono text-mono-sm",a?"text-danger":"text-ink-muted"),children:[t,r?":":null]}),n?f.jsxs("span",{...t5,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?f.jsxs("span",{...t5,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),pH=({action:e,filePath:t,files:n,narration:r,running:i=!1,failed:a=!1,defaultOpen:o=!1,details:s,className:l,verbOverride:c,object:u,glyph:O,wrap:d,dense:h=!1})=>{const p=oTt(e,t,n,r),g=c??(i?p.runningVerb:p.verb),y=a?Yd:p.icon,v=a||!c||!O?f.jsx(y,{}):O,b=f.jsx(sTt,{icon:v,verb:g,object:c?u:p.object,narration:c?r:p.narration,running:i,failed:a,wrap:d}),x=d?"firstLine":"center";return s?f.jsx(Ti,{summary:b,chevron:"leading",summaryAlign:x,defaultOpen:o,className:l,rowClassName:h?hH:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:s}):f.jsx(Ti,{disabled:!0,summary:b,summaryAlign:x,className:l,rowClassName:h?hH:void 0})},lTt=["channel","here","everyone"];function Oln(e){const{body:t,candidates:n,self:r}=e;if(!t||!t.includes("@"))return null;const i=r?[...n,{kind:"human",accountId:r.accountId,label:r.label}]:n,a=s=>r!==null&&s===r.accountId;if(Array.isArray(e.mentions)){const s=[];for(const l of e.mentions){if(!l||typeof l!="object")continue;if(l.kind==="channel"){const u=lTt.find(O=>axe(t,[{label:O,viewer:!1}],!0).some(d=>d.kind==="mention"));u&&s.push({label:u,viewer:!1});continue}const c=i.find(u=>u.kind===l.kind&&u.accountId===l.account_id);c&&s.push({label:c.label,viewer:a(l.account_id)})}return s.length>0?{source:"message",runs:s,caseSensitive:!0}:null}const o=i.filter(s=>s.label!==""&&t.includes(`@${s.label}`)).map(s=>({label:s.label,viewer:!1}));return o.length>0?{source:"fallback",runs:o,caseSensitive:!0}:null}const mH=/[\p{L}\p{N}_]/u;function axe(e,t,n=!0){const r=(l,c)=>n?l===c:l.toLocaleLowerCase()===c.toLocaleLowerCase(),i=[...t].sort((l,c)=>c.label.length-l.label.length),a=[];let o="",s=0;for(;s<e.length;){const l=s===0?"":e.charAt(s-1),c=e.charAt(s)==="@"&&!mH.test(l)&&l!=="."?i.find(O=>{const d=s+1+O.label.length;return r(e.slice(s+1,d),O.label)&&!mH.test(e.charAt(d))}):void 0;if(!c){o+=e.charAt(s),s+=1;continue}o&&a.push({kind:"text",text:o}),o="";const u=s+1+c.label.length;a.push({kind:"mention",text:e.slice(s,u),viewer:c.viewer}),s=u}return o&&a.push({kind:"text",text:o}),a}const cTt="team-bridge-mention rounded-sm px-0.5 font-medium bg-accent-wash text-accent",uTt="team-bridge-mention rounded-sm px-0.5 font-medium bg-warning-wash text-warning";function OTt(e){return()=>t=>{hk(t,"text",(n,r,i)=>{if(!i||r===void 0||!n.value.includes("@"))return;const a=axe(n.value,e);if(a.some(o=>o.kind==="mention"))return i.children.splice(r,1,...a.map(o=>o.kind==="text"?{type:"text",value:o.text}:{type:"mention",data:{hName:"span",hProperties:{className:o.viewer?uTt:cTt,"data-mention":o.viewer?"viewer":"other"}},children:[{type:"text",value:o.text}]})),r+a.length})}}const dTt=/^(https?:|mailto:)/i,fTt={a:({href:e,children:t})=>typeof e=="string"&&dTt.test(e)?f.jsx("a",{href:e,target:"_blank",rel:"noreferrer",children:t}):f.jsx("span",{className:"font-mono text-mono-sm",children:t}),img:({alt:e,src:t})=>f.jsx("span",{className:"text-ink-muted",children:e||(typeof t=="string"?t:"")}),table:L1e},oxe=$.memo(({children:e,className:t,mentions:n,style:r})=>{const i=$.useMemo(()=>n?.length?[Ws,OTt(n)]:[Ws],[n]);return f.jsx("div",{className:E("lo-markdown",t),style:r,children:f.jsx(wx,{remarkPlugins:i,components:fTt,children:e})})});oxe.displayName="TeamBridgeMarkdown";const sxe=8,hTt="… deeper values not shown",pTt="(empty)";function mTt(e){return`… ${e} more line${e===1?"":"s"}`}const gH=.5;function gTt(e,t,n,r){if(!Number.isFinite(t)||t<=0)return 0;let i=0;for(const a of e){if(a.height<=0)continue;const o=Math.max(1,Math.round(a.height/t));for(let s=1;s<=o;s++)a.top+s*t>n+r&&i++}return i}function lxe(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function cU(e){return typeof e=="object"&&e!==null}function cxe(e,t,n,r){if(n>sxe){r.push({key:t,value:hTt,depth:n});return}if(cU(e)){for(const[a,o]of Object.entries(e))cxe(o,t?`${t}.${a}`:a,n+1,r);return}const i=lxe(e);i!==null&&r.push({key:t,value:i,depth:n})}function uxe(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))cxe(r,n,1,t);return t}const $Tt=512;function yTt(e,t){if(t)return!0;if(!e)return!1;let n=$Tt;const r=(i,a)=>{if(n--<=0||a>sxe)return!0;if(!cU(i))return lxe(i)!==null;for(const o of Object.values(i))if(r(o,a+1))return!0;return!1};for(const i of Object.values(e))if(r(i,1))return!0;return!1}function vTt(e){if(!e)return null;const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return null;let n;try{n=JSON.parse(t)}catch{return null}if(!cU(n))return null;const r=uxe(n);return r.length>0?r:[{key:"",value:pTt,depth:1}]}const bTt=8,iy="max-h-[min(320px,40vh)]",Oxe=iy,dxe=({line:e})=>f.jsxs("div",{className:E("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*bTt},children:[e.key?f.jsxs("span",{className:E("text-ink-muted"),children:[e.key,": "]}):null,f.jsx("span",{className:E("text-ink-dim"),children:e.value})]}),$H=({lines:e,label:t})=>f.jsx("div",{className:E("flex flex-col gap-1"),"data-detail-lines":t,children:e.map((n,r)=>f.jsx(dxe,{line:n},r))});function yH(e){const[t,n]=$.useState(0),[r,i]=$.useState(!1);return $.useLayoutEffect(()=>{const a=e.current;if(!a)return;const o=a.firstElementChild,s=()=>{const c=o??a,u=Number.parseFloat(getComputedStyle(c).lineHeight);if(!Number.isFinite(u)||u<=0){n(0),i(!1);return}const O=a.getBoundingClientRect(),d=c.getBoundingClientRect();i(d.height>O.height+gH);const h=c.children.length>0?Array.from(c.children):[c];n(gTt(h.map(p=>{const g=p.getBoundingClientRect();return{top:g.top,height:g.height}}),u,O.bottom,gH))};s(),a.addEventListener("scroll",s,{passive:!0});const l=new ResizeObserver(s);return l.observe(o??a),()=>{a.removeEventListener("scroll",s),l.disconnect()}}),{lines:t,overflowing:r}}const vH=({lines:e,overflowing:t})=>t?f.jsx("span",{className:E("mt-1 block text-ink-dim"),children:e>0?mTt(e):" "}):null,wTt=({args:e,output:t,isError:n,interrupted:r=!1,note:i=null})=>{const a=uxe(e),o=vTt(t),s=$.useRef(null),l=$.useRef(null),c=yH(s),u=yH(l);return a.length===0&&!t&&!i?null:f.jsxs("div",{className:E("w-full rounded-md bg-sunken p-3 font-mono text-mono-sm"),children:[a.length>0&&f.jsxs("div",{"data-detail-section":"input",children:[f.jsx("div",{ref:s,className:E(iy,"overflow-auto"),children:f.jsx($H,{lines:a,label:"input"})}),f.jsx(vH,{lines:c.lines,overflowing:c.overflowing})]}),i&&f.jsx("div",{className:E("whitespace-normal font-sans text-body-sm text-ink-muted",a.length>0&&"mt-3"),"data-detail-section":"note",children:i}),t&&f.jsxs("div",{className:E(a.length>0&&"mt-3"),"data-detail-section":"output",children:[f.jsx("span",{className:E("mb-1 block text-meta",n&&!r?"text-danger":"text-ink-dim"),children:r?"Interrupted":n?"Error":"Output"}),f.jsx("div",{ref:l,className:E(iy,"overflow-auto"),children:o?f.jsx($H,{lines:o,label:"result-json"}):f.jsx("pre",{className:E("whitespace-pre font-mono",n&&!r?"text-danger":"text-ink"),children:t})}),f.jsx(vH,{lines:u.lines,overflowing:u.overflowing})]})]})},fxe=({view:e,isError:t,note:n=null,children:r})=>{const i=n??e.outcome,a=e.internals.length>0||!!e.raw;return f.jsxs("div",{className:E("flex w-full flex-col gap-2 rounded-md bg-sunken p-3 font-sans text-body-sm"),"data-bridge-detail":"",children:[e.headline?f.jsx("div",{className:E("font-medium text-ink"),"data-detail-section":"bridge-target",children:e.headline}):null,e.body?f.jsx("div",{className:E(iy,"overflow-auto text-ink"),"data-detail-section":"bridge-body",children:f.jsx(oxe,{children:e.body})}):null,i?f.jsx("div",{className:E("whitespace-normal",t?"text-danger":"text-ink-muted"),"data-detail-section":"bridge-outcome",children:i}):null,r,a?f.jsx(Ti,{chevron:"trailing",chevronClassName:"text-ink-dim",summary:f.jsx("span",{className:E("text-ink-dim text-meta"),children:m("ui.chat.canonical.tool_row.bridge.detail.details")}),triggerData:{"data-detail-section":"bridge-details"},children:f.jsxs("div",{className:E(iy,"overflow-auto pt-1 font-mono text-mono-sm"),children:[e.internals.map(o=>f.jsx(dxe,{line:{key:o.key,value:o.value,depth:1}},o.key)),e.raw?f.jsx("pre",{className:E("mt-2 whitespace-pre-wrap break-words font-mono text-ink-dim"),children:e.raw}):null]})}):null]})},xTt="mcp__",STt={bash:Q3e,read:m$,write:lY,edit:lY,glob:dp,grep:Hy,todo:vje,wake:IQ,list_variables:fY,read_variable:fY,browser:cY,console:Qle,project:xqe,project_delete:_3e,web_search:cY,web_fetch:DQ,task:_0,agent:_0,send:Xle,peer:dje,sessions:a3e,bridge:Cje};function QTt(e){const t=e.trim().toLowerCase(),n=STt[t];return n||(t.startsWith(xTt)?_le:z3e)}const kTt=Pz,_Tt=Qje,PTt=xje,TTt=Xje,XTt=aje,bH="min-h-5 py-0",wH={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent-alt",plain:"text-ink-muted"},RTt=(e,t)=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":e==="receipt"?wH.plain:wH[U2e(t)],ETt=e=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":"text-ink-muted",qTt=({added:e,removed:t})=>e<=0&&t<=0?null:f.jsxs("span",{className:E("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&f.jsxs("span",{className:E("text-success"),children:["+",e]}),t>0&&f.jsxs("span",{className:E("text-danger"),children:["-",t]})]}),jTt={running:"",success:"ui.chat.canonical.tool_row.outcome.succeeded",error:"ui.chat.canonical.tool_row.outcome.failed",interrupted:"ui.chat.canonical.tool_row.outcome.interrupted","not-run":"ui.chat.canonical.tool_row.outcome.never_ran",partial:"",receipt:""},L2=e=>{const t=jTt[e];return t===""?"":m(t)},CTt=1e3;function zTt(e){const[t,n]=$.useState(()=>e===null?null:Math.max(0,(Date.now()-e)/1e3));return $.useEffect(()=>{if(e===null){n(null);return}const r=()=>n(Math.max(0,(Date.now()-e)/1e3));r();const i=window.setInterval(r,CTt);return()=>window.clearInterval(i)},[e]),t}const ATt=({toolName:e="",outcome:t,deliveryState:n=null,failureWord:r=null,durationS:i,startedAt:a})=>{const o=t==="running",s=zTt(o?a??null:null),l=t==="error"||t==="not-run",c=t==="partial",u=N2e(n,e),O=c?u:l?u??r??L2(t):null,d=c?"text-warning":"text-danger",h=c?Y2e(n,e):null,p=E("font-medium text-meta",d,c&&(h?"hidden @[40rem]/toolrow:inline":"hidden @[19rem]/toolrow:inline")),g=E("font-medium text-meta",d,"hidden @[20rem]/toolrow:inline @[40rem]/toolrow:hidden"),y=c?G2e(n,e):null,v=c?Z2e(n,e):void 0,b=c?n==="mailbox"?_Tt:n==="unconfirmed"?PTt:n==="inbox_only"?TTt:n==="awaiting_acceptance"?XTt:null:t==="interrupted"?kTt:null,x=b&&c?"text-warning":"text-ink-dim",Q=o?a==null?"":iO(s??0):uz(i);return f.jsxs("span",{className:E("flex shrink-0 items-center gap-1.5"),children:[O?f.jsx("span",{className:p,title:v,"aria-hidden":y?!0:void 0,children:O}):null,O&&h?f.jsx("span",{className:g,title:v,"aria-hidden":y?!0:void 0,"data-status-word":"short",children:h}):null,f.jsxs("span",{className:E("flex shrink-0 [&_svg]:size-3.5",b&&"size-3.5",x),children:[b?f.jsx(b,{"aria-hidden":!0}):null,!l&&L2(t)?f.jsx("span",{className:E("sr-only"),children:L2(t)}):null,y?f.jsx("span",{className:E("sr-only"),children:y}):null]}),f.jsx("span",{className:E("hidden w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums @[19rem]/toolrow:inline"),children:Q})]})},Ac=({toolName:e,op:t="",verbless:n=!1,summary:r,summaryFallback:i=null,summaryHold:a=!1,summaryWrap:o=!1,outcome:s,deliveryState:l=null,settledVerb:c=null,failureWord:u=null,durationS:O,startedAt:d=null,added:h=0,removed:p=0,details:g,defaultOpen:y=!1,className:v,media:b})=>{Qe();const x=s==="running",Q=s==="error",w=QTt(e),S=d$(e),{verb:k,object:P}=Pse(e,r,i,x,t,c??W2e(l)),R=f.jsxs("span",{className:E("flex min-w-0 flex-1 items-center gap-2"),children:[f.jsx("span",{"aria-hidden":!0,className:E("flex size-3.5 shrink-0 [&_svg]:size-3.5",RTt(s,e)),children:f.jsx(w,{})}),n?null:f.jsx("span",{"data-trace-verb":"",className:E("shrink-0 whitespace-nowrap text-body-sm",ETt(s)),title:S,children:k}),f.jsx("span",{className:E(o?"min-w-0 flex-1 break-words whitespace-normal font-mono text-ink-muted text-mono-sm":"min-w-0 flex-1 truncate font-mono text-ink-muted text-mono-sm"),title:a?void 0:P,children:a?f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"text-ink-dim","data-label-hold":"true","aria-hidden":!0,children:"…"}),f.jsx("span",{className:E("sr-only"),children:m("ui.chat.canonical.tool_row.pending")})]}):f.jsx("bdi",{dir:"ltr",children:P})}),f.jsx(qTt,{added:h,removed:p}),f.jsx(ATt,{toolName:e,outcome:s,deliveryState:l,failureWord:u,durationS:O,startedAt:d})]}),T=x?{"data-glass-state":"running"}:void 0,q=x?"bg-elevated":Q?"bg-danger-wash":"hover:bg-row-hover",X=g?f.jsx(Ti,{summary:R,chevron:"leading",defaultOpen:y,className:E("@container/toolrow",v),triggerData:T,rowClassName:bH,triggerClassName:E("-mx-2 rounded-sm px-2",q),children:g}):f.jsx(Ti,{disabled:!0,summary:R,triggerData:T,rowClassName:bH,className:E("@container/toolrow",(x||Q)&&E("-mx-2 rounded-sm px-2",q),v)});return b?f.jsxs("div",{className:E("flex flex-col"),children:[X,b]}):X},UTt=3,WTt=2;function NTt(e){const t={incoming:0,job_result:0,wake:0,monitor_prompt:0};let n=!1,r=!1;for(const{record:o}of e){const s=Tse(o);s&&(t[s]+=1),o.kind==="custom"&&(o.receipt?.expectsReply===!0&&(n=!0),o.receipt?.steer===!0&&(r=!0))}const i=[],a=(o,s,l)=>{o>0&&i.push(`${o} ${o===1?s:l}`)};return a(t.incoming,"incoming message","incoming messages"),a(t.job_result,"job result","job results"),a(t.wake,"wake receipt","wake receipts"),a(t.monitor_prompt,"monitor prompt","monitor prompts"),a(e.length-t.incoming-t.job_result-t.wake-t.monitor_prompt,"other receipt","other receipts"),n&&i.push("Reply requested"),r&&i.push("Steered"),i}const hxe=e=>{const t=e.toLowerCase();return t==="read"||t==="grep"||t==="glob"||t==="ls"||t==="list"?"files":t==="search_the_web"||t==="web_search"||t==="search"?"web":t==="bash"||t==="exec"||t==="shell"||t==="run"?"commands":t==="edit"||t==="write"||t==="multiedit"?"edits":t==="task"||t==="delegate"?"delegated":t==="fetch"||t==="web_fetch"||t==="fetch_url"?"searches":null},pxe=e=>{const t=new Map;let n=0;for(const o of e){const s=hxe(o.name);s===null?n+=1:t.set(s,(t.get(s)??0)+1)}const r=uU(e);if(n>0||t.size>2){const o=mxe(r);return{units:o.length===0?[`${e.length} actions`]:o,prose:!1,countUnits:r}}const i=["files","searches","web","commands","edits","delegated"],a=[];for(const o of i){const s=t.get(o)??0;s!==0&&(o==="files"&&a.push(`Explored ${s} file${s===1?"":"s"}`),o==="searches"&&a.push(`${s} search${s===1?"":"es"}`),o==="web"&&a.push(`Searched the web ${s} time${s===1?"":"s"}`),o==="commands"&&a.push(`Ran ${s} command${s===1?"":"s"}`),o==="edits"&&a.push(`Edited ${s} file${s===1?"":"s"}`),o==="delegated"&&a.push(`Delegated ${s} task${s===1?"":"s"}`))}return a.length===0?{units:[`${e.length} actions`],prose:!0,countUnits:r}:{units:[a.length===1?a[0]:`${a[0]}, ${a[1].charAt(0).toLowerCase()}${a[1].slice(1)}`],prose:!0,countUnits:r}},YTt=e=>pxe(e).units;function GTt(e){return YTt(e).join(" · ")}const F2={agent:{noun:"agent",plural:"agents"},team:{noun:"team",plural:"teams"},team_delete:{noun:"team deletion",plural:"team deletions"},hub:{noun:"subagent",plural:"subagents"},secret:{noun:"secret",plural:"secrets"},project:{noun:"project",plural:"projects"},project_delete:{noun:"project deletion",plural:"project deletions"},wake:{noun:"wake",plural:"wakes"},jobs:{noun:"job check",plural:"job checks"},console:{noun:"console",plural:"consoles"},network:{noun:"network call",plural:"network calls"},browser:{noun:"browser action",plural:"browser actions"},todo:{noun:"todo update",plural:"todo updates"},send:{noun:"message",plural:"messages"},ask:{noun:"question",plural:"questions"},wait:{noun:"wait",plural:"waits"},lsp:{noun:"code lookup",plural:"code lookups"},web_read:{noun:"page",plural:"pages"},list_variables:{noun:"variable lookup",plural:"variable lookups"},read_variable:{noun:"variable read",plural:"variable reads"},sessions:{noun:"session",plural:"sessions"}},B2=5,mxe=e=>{if(e.length<=B2)return e.map(r=>r.label);const t=e.slice(0,B2),n=e.slice(B2).reduce((r,i)=>r+i.count,0);return[...t.map(r=>r.label),`and ${n} other action${n===1?"":"s"}`]},uU=e=>{const t=new Map,n=(s,l)=>{const c=t.get(s);c?c.count+=1:t.set(s,{kind:l,count:1})};for(const s of e){const l=s.name.toLowerCase();if(l==="bash"||l==="exec"||l==="shell"||l==="run"){n("kind:shell",{noun:"shell",plural:null});continue}if(l==="eval"){n("kind:python",{noun:"python",plural:null});continue}const c=hxe(s.name);if(c==="files")n("class:files",{noun:"file",plural:"files"});else if(c==="searches")n("class:searches",{noun:"search",plural:"searches"});else if(c==="web")n("class:web",{noun:"web search",plural:"web searches"});else if(c==="edits")n("class:edits",{noun:"edit",plural:"edits"});else if(c==="delegated")n("class:delegated",{noun:"task",plural:"tasks"});else if(l==="todo")(s.op??"").toLowerCase()==="view"?n("kind:todo:view",{noun:"todo read",plural:"todo reads"}):n("kind:todo",F2.todo);else if(l==="jobs")(s.op??"").toLowerCase()==="cancel"?n("kind:jobs:cancel",{noun:"job cancellation",plural:"job cancellations"}):n("kind:jobs",F2.jobs);else if(l==="bridge")I2e.has((s.op??"").toLowerCase())?n("kind:bridge:post",{noun:m("ui.chat.canonical.fold.bridge_post.one"),plural:m("ui.chat.canonical.fold.bridge_post.other")}):n("kind:bridge",{noun:m("ui.chat.canonical.fold.bridge.one"),plural:m("ui.chat.canonical.fold.bridge.other")});else{const u=F2[l];if(u)n(`kind:${l}`,u);else{const O=d$(s.name);n(`name:${O}`,{noun:O,plural:null})}}}const r=["class:files","class:searches","class:web","kind:shell","kind:python","class:edits","class:delegated","kind:agent","kind:team","kind:hub"],i=[],a=(s,l)=>`${s} ${s===1||l.plural===null?l.noun:l.plural}`;for(const s of r){const l=t.get(s);l&&i.push({key:s,label:a(l.count,l.kind),count:l.count})}const o=[...t.entries()].filter(([s])=>!r.includes(s)).sort(([,s],[,l])=>l.count-s.count||s.kind.noun.localeCompare(l.kind.noun));for(const[s,l]of o)i.push({key:s,label:a(l.count,l.kind),count:l.count});return i};function ZTt(e){return e.running===!0?typeof e.startedAtMs!="number"?null:{startMs:e.startedAtMs,endMs:null}:typeof e.endedAtMs!="number"||typeof e.durationS!="number"?null:{startMs:e.endedAtMs-e.durationS*1e3,endMs:e.endedAtMs}}function ITt(e){let t=null,n=null,r=!1;for(const i of e){i.running===!0&&(r=!0);const a=ZTt(i);a&&(t=t===null?a.startMs:Math.min(t,a.startMs),a.endMs!==null&&(n=n===null?a.endMs:Math.max(n,a.endMs)))}return t===null||n===null&&!r?null:{startedAtMs:t,endedAtMs:n,running:r}}function DTt(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.executing===!0)return Pse(n.name,n.summary??"",null,!0,n.op)}return null}function VTt(e,t){let n=0;for(let r=e.length-1;r>=0&&t(e[r]);r-=1)n+=1;return n}function MTt(e,t){const n=[];let r=[];const i=()=>{if(r.length===0)return;const a=r.filter(O=>t.isReceipt?.(O)),o=r.filter(O=>t.isFoldable(O)).map(O=>{const d={name:t.nameOf(O),failed:t.failedOf(O),durationS:t.durationOf?t.durationOf(O):null,startedAtMs:t.startedAtOf?t.startedAtOf(O):null,endedAtMs:t.endedAtOf?t.endedAtOf(O):null};return t.summaryOf&&(d.summary=t.summaryOf(O)),t.opOf&&(d.op=t.opOf(O)),t.runningOf&&(d.running=t.runningOf(O)),t.executingOf&&(d.executing=t.executingOf(O)),d}),s=a.length?t.receiptSummaryOf?.(a)??[]:[],l=s.length>0?s:a.length>0?[`${a.length} receipt${a.length===1?"":"s"}`]:[],c=t.isReceipt?VTt(r,t.isReceipt):0,u=t.liveTurn===!0&&t.latchedFoldIds!==void 0&&r.some(O=>t.latchedFoldIds?.has(O.record.id)===!0);if(o.length>=UTt||c>=WTt||u){const O=(()=>{if(o.length===0)return{units:[],prose:!1,countUnits:[]};const d=uU(o);return l.length>0?{units:mxe(d),prose:!1,countUnits:d}:pxe(o)})();n.push({kind:"run",id:r[0].record.id,gap:r[0].gap,rows:r,actions:o,summary:{units:[...O.units,...l],prose:O.prose,countUnits:O.countUnits},failedCount:o.filter(d=>d.failed).length,span:ITt(o),live:DTt(o)})}else for(const O of r)n.push({kind:"row",row:O});r=[]};for(const a of e){if((a.gap==="turn"||a.gap==="first")&&i(),t.isFoldable(a)||t.isReceipt?.(a)){r.push(a);continue}i(),n.push({kind:"row",row:a})}return i(),n}function LTt(e,t,n){const r=new Set;for(const i of e)t.has(i)&&r.add(i);for(const i of n)if(i.kind==="run")for(const a of i.rows)r.add(a.record.id);return r}const xH=e=>{const t=[];for(const n of e)if(!(n.record.kind!=="tool"&&!(n.record.kind==="custom"&&Tse(n.record)==="incoming")))for(const r of n.record.images??[])Op(r)&&t.push(r);return t},G1=5,FTt=(e,{uncapped:t=!1}={})=>t?{shown:Math.max(e,0),more:0}:e<G1?{shown:Math.max(e,0),more:0}:{shown:G1-1,more:e-(G1-1)},BTt=e=>{const t=G1-1;if(e<=0)return[];if(e<=t)return[e];const n=Array.from({length:Math.floor(e/t)},()=>t),r=e%t;return r===1?(n[n.length-1]=t-1,n.push(2)):r>1&&n.push(r),n},SS=e=>e<=0?null:`${e} image${e===1?"":"s"}`;function QS(e){return e.record.kind==="tool"?e.record.durationS:null}function gxe(e){let t=null;for(const n of e){const r=QS(n);typeof r=="number"&&(t=(t??0)+r)}return t}function HTt(e,t){const n=new Map,r=t.opensRun??(l=>l.gap==="turn"||l.gap==="first");let i=0,a=0,o=null,s=null;for(const l of e){if(r(l)&&(i=0,a=0,o=null,s=null),t.isAction(l)){i+=1,t.failedOf(l)&&(a+=1,s??=l.record.id);const c=t.durationOf?t.durationOf(l):null;typeof c=="number"&&(o=(o??0)+c)}l.closesTurn&&n.set(l.record.id,{actions:i,failed:a,durationS:o,firstFailedId:s})}return n}const KTt="min-h-5 py-0",JTt=1e3;function e2t(e){const[t,n]=$.useState(()=>Date.now());return $.useEffect(()=>{if(!e)return;const r=()=>n(Date.now());r();const i=window.setInterval(r,JTt);return()=>window.clearInterval(i)},[e]),t}const t2t=({summary:e,span:t,live:n,open:r,onOpenChange:i,className:a,condensedMedia:o,mediaCount:s=0,recordIds:l,children:c})=>{const u=e2t(t?.running===!0),O=t===null?null:Math.max(0,((t.running?u:t.endedAtMs??u)-t.startedAtMs)/1e3),d=O===null?"":uz(O),h=$.useRef(null),p=()=>{h.current?.querySelector("button[aria-expanded]")?.focus(),i(!0)};return f.jsxs("div",{ref:h,className:a,"data-fold-ids":l.join(" "),children:[f.jsx(Ti,{animate:r||!o,open:r,onOpenChange:i,rowClassName:KTt,triggerClassName:E("-mx-2 rounded-sm px-2","hover:bg-row-hover"),summary:f.jsxs("span",{className:E("flex min-w-0 flex-1 items-center gap-2"),children:[n!==null&&!r&&f.jsxs(f.Fragment,{children:[f.jsxs("span",{"data-fold-live":"",className:E("min-w-0 shrink-[100000] truncate"),title:`${n.verb} ${n.object}`,children:[f.jsx("span",{className:E("text-accent"),children:n.verb})," ",f.jsx("span",{className:E("font-mono text-mono-sm text-ink-muted"),children:n.object})]}),f.jsx("span",{"aria-hidden":!0,className:E("text-ink-dim text-meta"),children:"·"})]}),f.jsx("span",{className:E("min-w-0 break-words text-body-sm text-ink-muted"),title:e.units.join(" · "),"data-fold-summary":"",children:e.units.map((g,y)=>f.jsxs($.Fragment,{children:[y>0&&f.jsx("span",{"aria-hidden":"true",children:" · "}),f.jsx("span",{className:E(e.prose?"whitespace-normal":"whitespace-nowrap"),children:g})]},g))}),SS(s)!==null&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":!0,className:E("text-ink-dim text-meta"),children:"·"}),f.jsx("span",{className:E("shrink-0 text-ink-muted text-meta"),children:SS(s)})]}),d!==""&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":!0,className:E("text-ink-dim text-meta"),children:"·"}),f.jsx("span",{"data-fold-span":"",className:E("shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:d})]})]}),children:f.jsx("div",{className:E("flex flex-col"),children:c})}),!r&&o&&o(p)]})},SH=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],n2t=80,r2t=1e3,$xe=({activity:e,phase:t,startedAt:n,clock:r,className:i})=>{const[a,o]=$.useState(0),[s,l]=$.useState(()=>n===void 0?0:Math.floor((Date.now()-n)/1e3)),[c,u]=$.useState(!1),O=r!==!1&&!c,d=a9("(prefers-reduced-motion: reduce)"),h=$.useRef(n??Date.now()),p=$.useRef(t),g=$.useRef(n);if(p.current!==t)p.current=t,g.current=n,h.current=n??Date.now(),c&&u(!1),l(0);else if(g.current!==n){const b=g.current!==void 0&&n===void 0;g.current=n,u(b),b||(h.current=n,l(Math.floor((Date.now()-n)/1e3)))}const y=$.useRef(r!==!1),v=$.useRef(t);return $.useEffect(()=>{const b=r!==!1,x=y.current,Q=v.current===t;y.current=b,v.current=t,!x&&b&&Q&&l(Math.floor((Date.now()-h.current)/1e3))},[r,t]),$.useEffect(()=>{const b=O?window.setInterval(()=>l(Math.floor((Date.now()-h.current)/1e3)),r2t):null;if(d)return o(0),()=>{b!==null&&window.clearInterval(b)};const x=window.setInterval(()=>o(Q=>(Q+1)%SH.length),n2t);return()=>{window.clearInterval(x),b!==null&&window.clearInterval(b)}},[d,O]),f.jsxs("div",{className:E("flex items-center gap-2",i),"data-lo-working-line":!0,"aria-live":"polite",children:[f.jsx("span",{"aria-hidden":!0,className:E("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:SH[a]}),f.jsx("span",{className:E("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),f.jsx("span",{"aria-hidden":!0,className:E("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:O?iO(s):""})]})},i2t="min-h-5 py-0",Pu=()=>f.jsx("span",{"aria-hidden":!0,className:E("text-ink-dim text-meta"),children:"·"}),a2t=({recordIds:e,segmentIds:t,anchorRecordId:n,className:r,durationS:i,actionCount:a,partial:o=!1,title:s,stampTs:l,label:c=null,completed:u=!1,open:O,onOpenChange:d,children:h,condensedMedia:p,mediaCount:g=0,group:y=null,episode:v=null})=>{Qe();const b=o?`${a}+ actions`:a===1?"1 action":`${a} actions`,x=`At least ${a===1?"1 action":`${a} actions`} — earlier rows of this turn are not loaded`,Q=v?.receipts??y?.count,w=Q===void 0?null:`At least ${Q} messages — earlier rows are not loaded`,S=$.useRef(null),k=()=>{S.current?.querySelector("button[aria-expanded]")?.focus(),d(!0)};return c===null&&i===null&&a===0&&y===null&&v===null&&g===0?null:f.jsxs("div",{ref:S,className:E("border-b border-hairline pb-3",r),"data-turn-summary":"","data-run-ids":e.join(" "),"data-segment-ids":t?.join(" "),"data-segment-complete":u&&!v?.active?"true":void 0,"data-segment-active":v?.active?"true":void 0,"data-record-id":n,children:[f.jsx(Ti,{open:O,onOpenChange:d,chevron:"trailing",rowClassName:i2t,triggerClassName:E("-ms-2 -me-2 w-[calc(100%+1rem)] rounded-sm ps-2 pe-6","hover:bg-row-hover"),chevronClassName:E("-mr-6","text-ink-muted"),summary:f.jsxs("span",{className:E("flex min-w-0 flex-1 items-center gap-2"),title:s??void 0,children:[c!==null&&f.jsx("span",{className:E("shrink-0 text-body-sm text-ink-muted"),"data-segment-label":"",children:c}),u&&!v?.active&&f.jsx(f.Fragment,{children:f.jsx(wz,{"aria-hidden":!0,className:E("size-3.5 shrink-0 text-success")})}),v?.active?f.jsxs(f.Fragment,{children:[c!==null&&f.jsx(Pu,{}),f.jsx("span",{className:"shrink-0 text-body-sm text-ink-muted",title:o?w??void 0:void 0,"aria-label":o?w??void 0:void 0,children:o?`${v.receipts}+`:v.receipts}),a>0&&f.jsxs(f.Fragment,{children:[f.jsx(Pu,{}),f.jsx("span",{className:"shrink-0 text-body-sm text-ink-muted",title:o?x:void 0,children:f.jsx("bdi",{children:b})})]}),v.phaseLine!==null&&f.jsxs(f.Fragment,{children:[f.jsx(Pu,{}),f.jsx($xe,{activity:v.phaseLine.activity,phase:v.phaseLine.phase,startedAt:v.phaseLine.startedAt,clock:v.phaseLine.clock,className:"min-w-0"})]})]}):y!==null?f.jsxs(f.Fragment,{children:[c!==null&&f.jsx(Pu,{}),f.jsx("span",{className:E("shrink-0 text-body-sm text-ink-muted"),title:o?w??void 0:void 0,"aria-label":o?w??void 0:void 0,children:o?`${v?.receipts??y.count}+`:`${v?.receipts??y.count}`}),y.spanS!==null&&f.jsxs(f.Fragment,{children:[f.jsx(Pu,{}),f.jsx("span",{className:E("shrink-0 text-body-sm text-ink-muted"),children:iO(y.spanS)})]})]}):f.jsxs(f.Fragment,{children:[c!==null&&(i!==null||a>0)&&f.jsx(Pu,{}),i!==null&&f.jsx("span",{className:E("shrink-0 text-body-sm text-ink-muted"),children:m("ui.chat.canonical.turn_summary.took",{duration:iO(i)})}),i!==null&&a>0&&f.jsx(Pu,{}),a>0&&f.jsx("span",{className:E("shrink-0 text-body-sm text-ink-muted"),title:o?x:void 0,"aria-label":o?x:void 0,children:f.jsx("bdi",{children:b})})]}),SS(g)!==null&&f.jsxs(f.Fragment,{children:[f.jsx(Pu,{}),f.jsx("span",{className:E("shrink-0 text-body-sm text-ink-muted"),children:SS(g)})]}),u&&!v?.active&&f.jsx("span",{className:E("sr-only"),children:m("ui.chat.canonical.turn_summary.completed")}),l!==null&&f.jsx("span",{className:E("ms-auto"),children:f.jsx(xS,{timestamp:l,scope:"answer"})})]}),children:f.jsx("div",{className:E("flex flex-col"),children:h})}),!O&&p&&f.jsx("div",{className:E("pb-2"),children:p(k)})]})},yxe="lo-missing-session-notice",$O=({children:e,className:t,boundary:n="hairline",...r})=>f.jsx("div",{className:E("flex max-w-full items-center justify-center overflow-hidden","min-h-16 min-w-16 rounded-sm",n==="control"?["bg-media-surface","border border-transparent","transition-colors duration-fast ease-out-quart","group-hover/tile:border-control group-focus-visible/tile:border-control"]:["border border-hairline","bg-sunken"],t),...r,children:e}),o2t="could not be displayed. It may have been moved, renamed, or deleted.",OU="could not be displayed. Its stored copy is not available to this reader.",vxe="could not be played. Its stored copy is not available to this reader.",bxe=vxe,af=({name:e,detail:t=o2t,className:n,compact:r=!1})=>r?f.jsx("div",{className:E("flex h-[78px] w-[117px] items-center justify-center rounded-sm border border-control bg-sunken",n),role:"img","aria-label":`${e} ${t}`,title:`${e} ${t}`,children:f.jsx(OY,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0})}):f.jsxs("div",{className:E("flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2",n),children:[f.jsx(OY,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),f.jsxs("span",{className:"min-w-0 text-body-sm text-ink-muted",children:[f.jsx("span",{className:"truncate font-mono text-ink text-mono-sm",children:e}),` ${t}`]})]}),kS=4,wxe=2,s2t=2,xxe=4,Sxe=kS+wxe,l2t=.8,c2t=24,QH=.3,kH=1;function u2t(e){return!Number.isFinite(e)||e<=0?1:Math.max(1,Math.floor((e+wxe)/Sxe))}function O2t(e,t){const n=Math.min(e,t-e);return Number.isFinite(n)?Math.max(0,Math.min(1,n/c2t)):0}function d2t(e,t){if(t<=0)return[];if(e.length===0)return new Array(t).fill(0);const n=new Array(t),r=e.length/t;for(let i=0;i<t;i+=1){const a=Math.floor(i*r),o=Math.max(a+1,Math.floor((i+1)*r));let s=0;for(let l=a;l<o&&l<e.length;l+=1){const c=e[l];Number.isFinite(c)&&c>s&&(s=c)}n[i]=Math.max(0,Math.min(1,s))}return n}function Qxe(e,t,n){const r=u2t(t),i=e===null?null:d2t(e,r),a=[],o=Math.max(1,r-1);for(let s=0;s<r;s+=1){const l=s*Sxe,c=l+kS/2,O=(i===null?0:i[s])*n*l2t,d=Math.max(xxe,Math.round(O)),h=QH+(kH-QH)*(s/o);a.push({x:l,width:kS,height:d,alpha:Math.min(kH,h)*O2t(c,t)})}return a}function e$(e){if(!Number.isFinite(e)||e<=0)return"0:00";const t=Math.floor(e),n=Math.floor(t/60),r=t%60;return`${n}:${r.toString().padStart(2,"0")}`}function f2t(e,t,n){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=0)return 0;const r=Math.max(0,Math.min(1,e/t));return!Number.isFinite(n)||n<=0?0:r*n}function h2t(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?0:Math.max(0,Math.min(1,e/t))}function _H(e,t){return`${e$(e)} of ${e$(t)}`}const p2t=4,PH=1,m2t="flex min-h-11 min-w-11 shrink-0 items-center justify-center text-ink-muted transition-colors duration-fast ease-out-quart hover:text-ink disabled:pointer-events-none disabled:text-ink-disabled",kxe=({ownerId:e,src:t,label:n,peaks:r,durationHint:i=null,variant:a="full",className:o})=>{Qe();const s=Ui(ne=>ne.ownerId===e),l=Ui(ne=>ne.ownerId===e?ne.status:"idle"),c=Ui(ne=>ne.ownerId===e?ne.duration:0),[u,O]=$.useState(!1),[d,h]=$.useState(!1);$.useEffect(()=>{(l==="loading"||l==="playing")&&h(!1)},[l]);const p=c>0?c:i??0,g=s&&l==="playing",y=s&&l==="loading",v=d||s&&l==="error",b=$.useRef(null),x=$.useRef(null),Q=$.useRef(null),w=$.useRef(null),S=$.useRef(null),[k,P]=$.useState({width:0,height:0,dpr:1});$.useEffect(()=>{const ne=b.current;if(!ne)return;const L=()=>{const se=ne.getBoundingClientRect();P({width:se.width,height:se.height,dpr:window.devicePixelRatio||1})};L();const B=new ResizeObserver(L);return B.observe(ne),()=>B.disconnect()},[]);const R=$.useCallback(ne=>{if(!ne||k.width<=0)return;const L=ne.getContext("2d");if(!L)return;ne.width=Math.max(1,Math.round(k.width*k.dpr)),ne.height=Math.max(1,Math.round(k.height*k.dpr)),L.setTransform(k.dpr,0,0,k.dpr,0,0),L.clearRect(0,0,k.width,k.height);const B=getComputedStyle(ne).color,se=Qxe(r,k.width,k.height);L.fillStyle=B;for(const H of se)L.globalAlpha=H.alpha,L.beginPath(),L.roundRect(H.x,(k.height-H.height)/2,H.width,H.height,s2t),L.fill();L.globalAlpha=1},[k.width,k.height,k.dpr,r]);$.useEffect(()=>{R(x.current),R(Q.current)},[R]);const T=$.useRef(null),q=$.useCallback(ne=>{const L=h2t(ne,p),B=Q.current;b.current?.style.setProperty("--sound-progress",`${L*100}%`),B&&(B.style.clipPath=`inset(0 ${(1-L)*100}% 0 0)`);const se=e$(ne);S.current&&S.current.textContent!==se&&(S.current.textContent=se);const H=w.current;H&&(H.setAttribute("aria-valuenow",String(Math.floor(ne))),H.setAttribute("aria-valuetext",_H(ne,p)))},[p]);$.useEffect(()=>{const ne=g||u,L=()=>q(s?y5()?.currentTime??0:A.current);if(!ne){L();return}let B=0;const se=()=>{const H=T.current??y5()?.currentTime??0;q(H),B=requestAnimationFrame(se)};return B=requestAnimationFrame(se),()=>cancelAnimationFrame(B)},[g,u,s,q]);const X=$.useCallback(async()=>(h(!1),Ui.getState().play(e,t,{onError:()=>h(!0)})),[e,t]),C=$.useCallback(ne=>{const L=Ui.getState();if(g){L.seek(e,ne),q(ne);return}X().then(B=>{B!==!1&&(Ui.getState().seek(e,ne),q(ne))})},[e,g,X,q]),N=$.useCallback(async()=>{if(g){Ui.getState().pause(e);return}h(!1),await Ui.getState().toggle(e,t,{onError:()=>h(!0)})},[e,t,g]),A=$.useRef(0),Y=$.useRef(null),W=$.useCallback(ne=>{const L=b.current;if(!L)return 0;const B=L.getBoundingClientRect();return f2t(ne-B.left,B.width,p)},[p]),Z=ne=>{if(y)return;ne.currentTarget.setPointerCapture?.(ne.pointerId),Y.current={pointerId:ne.pointerId,startX:ne.clientX,moved:!1,pendingX:ne.clientX,raf:0}},D=ne=>{const L=Y.current;!L||L.pointerId!==ne.pointerId||(Math.abs(ne.clientX-L.startX)>p2t&&(L.moved||O(!0),L.moved=!0),L.pendingX=ne.clientX,L.moved&&L.raf===0&&(L.raf=requestAnimationFrame(()=>{const B=Y.current;if(!B)return;B.raf=0;const se=W(B.pendingX);T.current=se,Ui.getState().scrub(e,se),q(se)})))},z=ne=>{const L=Y.current;if(!L||L.pointerId!==ne.pointerId)return;L.raf!==0&&cancelAnimationFrame(L.raf),Y.current=null,T.current=null,ne.currentTarget.releasePointerCapture?.(ne.pointerId);const B=W(ne.clientX);if(L.moved){A.current=B,O(!1),Ui.getState().seek(e,B),q(B);return}C(B)},V=ne=>{const L=y5(),B=s&&L?L.currentTime:0;if(ne.key===" "||ne.key==="Enter"){ne.preventDefault(),N();return}let se=null;if(ne.key==="ArrowLeft"?se=B-PH:ne.key==="ArrowRight"?se=B+PH:ne.key==="Home"?se=0:ne.key==="End"&&(se=p),se===null)return;ne.preventDefault();const H=Math.max(0,Math.min(p,se));C(H)},J=a==="compact",G=`${n} position`;return f.jsxs("div",{"data-sound-player":a,"data-sound-peaks":r?"stored":"flat","data-sound-status":v?"error":u?"scrubbing":s?l:"idle",className:E("flex w-full min-w-0 items-center gap-2",J?"gap-1.5":"gap-2",o),children:[f.jsx("button",{type:"button",className:m2t,disabled:y,onClick:()=>void N(),"aria-label":g?m("ui.chat.audio.pause_label",{label:n}):m("ui.chat.audio.play_label",{label:n}),children:y?f.jsx(Qo,{size:"sm"}):g?f.jsx(mle,{size:22,"aria-hidden":"true"}):f.jsx(gqe,{size:22,"aria-hidden":"true"})}),f.jsx("div",{ref:w,role:"slider",tabIndex:0,"aria-label":G,"aria-valuemin":0,"aria-valuemax":Math.max(0,Math.round(p)),"aria-valuenow":0,"aria-valuetext":_H(0,p),"data-sound-slider":"",className:E("group relative min-h-11 min-w-0 flex-1 cursor-pointer touch-none select-none","rounded-sm outline-offset-2 focus-visible:outline-2 focus-visible:outline-accent",v&&"cursor-default"),onPointerDown:Z,onPointerMove:D,onPointerUp:z,onPointerCancel:z,onKeyDown:V,children:f.jsxs("div",{ref:b,className:"absolute inset-0",children:[f.jsx("canvas",{ref:x,className:"absolute inset-0 h-full w-full text-ink-dim"}),f.jsx("canvas",{ref:Q,style:{clipPath:"inset(0 100% 0 0)"},className:"absolute inset-0 h-full w-full text-ink-muted"}),f.jsx("span",{"data-sound-thumb":"",className:E("pointer-events-none absolute top-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-ink-muted group-hover:bg-ink group-focus-visible:bg-accent",u&&"bg-accent"),style:{left:"var(--sound-progress, 0%)"}})]})}),f.jsx("span",{ref:S,"data-sound-time":"",className:E("min-w-10 shrink-0 text-center text-meta text-ink-muted tabular-nums"),children:e$(0)}),f.jsx("span",{className:E("min-w-10 shrink-0 text-center text-meta text-ink-dim tabular-nums"),children:e$(p)}),v?f.jsx("span",{"data-sound-error":"",className:E("shrink-0 text-meta text-ink-muted"),children:m("ui.chat.canonical.sound.player_failed")}):null]})};function TH(e){const t=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.peaks)?e.peaks:null;if(!t||t.length===0)return null;const n=[];for(const r of t){if(typeof r!="number"||!Number.isFinite(r))return null;n.push(Math.max(0,Math.min(1,r)))}return n}const XH=new Map;async function g2t(e,t){try{const n=await is({op:"sessions.attachment.waveform",sessionId:e.sessionId,digest:t},null);if(n.kind==="json")return TH(n.body);if(n.kind==="bytes"){const r=new TextDecoder().decode(n.data);try{return TH(JSON.parse(r))}catch{return null}}return null}catch{return null}}function _xe(e,t){const n=t?.sessionId??null,r=t?.childId??null,[i,a]=$.useState(()=>e?$2t(e):null);return $.useEffect(()=>{if(!e||!n){a(null);return}let o=!0;return y2t({sessionId:n,childId:r},e).then(s=>{o&&a(s)}),()=>{o=!1}},[e,n,r]),i}function $2t(e){return F7.get(e)??null}const F7=new Map;function y2t(e,t){const n=XH.get(t);if(n)return n;const r=g2t(e,t).then(i=>(F7.set(t,i),i)).catch(()=>(F7.set(t,null),null));return XH.set(t,r),r}function Pxe(e){return`sound:${e.attachment??e.id}`}const dU=({audio:e,scope:t,label:n,ownerId:r})=>{const i=Ev(e,t),a=_xe(e.attachment,t);return i.state==="missing"?f.jsx(af,{name:n,detail:bxe}):i.state==="resolving"?f.jsx("div",{className:E("inline-block max-w-full self-start"),"aria-hidden":!0,children:f.jsx($O,{"data-attachment-reserved":""})}):f.jsx("div",{className:E("w-full max-w-[560px] self-start"),children:f.jsx(kxe,{ownerId:r??Pxe(e),src:i.url,label:n,peaks:a,durationHint:e.durationS??null})})},ud=1,Txe=4,RH=(e,t)=>Math.min(Txe,Math.max(ud,e+t)),Wg=Object.freeze({x:0,y:0}),H2=(e,t)=>t<=0?0:Math.min(t-1,Math.max(0,Math.trunc(e))),K2=(e,t,n)=>t<=0?0:((e+n)%t+t)%t,v2t=(e,t)=>m("ui.common.viewer.position",{kind:"image",index:e+1,count:t}),EH=(e,t,n)=>{const r=Math.max(0,n-1)/2,i=t.width*r||0,a=t.height*r||0;return{x:Math.min(i,Math.max(-i,e.x)),y:Math.min(a,Math.max(-a,e.y))}},b2t="max-h-[min(90vh,calc(100vh-104px))] max-w-[min(90vw,calc(100vw-104px))]",w2t="max-h-[min(90vh,calc(100vh-208px))] max-w-[min(90vw,calc(100vw-104px))]",qH=e=>E(e,"flex min-h-16 min-w-64 items-center justify-center p-6"),x2t="opacity-85",fh="bg-surface/85 disabled:bg-surface/85",fU=({src:e,label:t,open:n,onOpenChange:r,restoreFocusTo:i,fallback:a,pending:o=!1,group:s,layerRef:l,mediaKind:c="image",mediaLabel:u="image",layerAttributes:O})=>{Qe();const d=c==="video",h=(H,ee)=>u==="asset"?m("ui.common.viewer.position",{kind:"asset",index:H+1,count:ee}):v2t(H,ee),[p,g]=$.useState(null),y=e!==void 0&&p===e,[v,b]=$.useState(ud),[x,Q]=$.useState(Wg),w=$.useRef(e);$.useLayoutEffect(()=>{w.current!==e&&(w.current=e,b(ud),Q(Wg))},[e]);const[S,k]=$.useState(!0),P=$.useRef(null);$.useEffect(()=>{if(!n)return;let H;const ee=()=>{clearTimeout(H),H=setTimeout(()=>{const fe=P.current;if(fe&&(fe.matches(":hover")||fe.contains(document.activeElement))){ee();return}k(!1)},wue)},re=()=>{k(!0),ee()};return k(!0),ee(),document.addEventListener("pointermove",re,{passive:!0}),document.addEventListener("pointerdown",re,{passive:!0}),document.addEventListener("keydown",re),document.addEventListener("focusin",re),()=>{clearTimeout(H),document.removeEventListener("pointermove",re),document.removeEventListener("pointerdown",re),document.removeEventListener("keydown",re),document.removeEventListener("focusin",re)}},[n]);const R=s?.onPrev,T=s?.onNext,q=s!==void 0&&s.count>1,X=q?w2t:b2t,C=$.useRef(null),N=l??C;$.useEffect(()=>{if(!n||!q)return;const H=ee=>{ee.defaultPrevented||ee.metaKey||ee.ctrlKey||ee.altKey||(ee.key==="ArrowLeft"?(ee.preventDefault(),R?.()):ee.key==="ArrowRight"&&(ee.preventDefault(),T?.()))};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[n,q,R,T]),iz(n,"lightbox");const A=$.useRef(null),Y=!d&&e!==void 0&&!y,W=v===ud&&x.x===Wg.x&&x.y===Wg.y,Z=H=>{if(!Y)return;b(H);const ee=A.current;ee&&Q(re=>EH(re,{width:ee.clientWidth,height:ee.clientHeight},H))},D=()=>{Y&&(b(ud),Q(Wg))},z=$.useRef(null),[V,J]=$.useState(!1),G=Y&&v>ud,ne=H=>{!G||H.button!==0||(H.currentTarget.setPointerCapture(H.pointerId),z.current={pointerId:H.pointerId,startX:H.clientX,startY:H.clientY,pan:x},J(!0))},L=H=>{const ee=z.current,re=A.current;!ee||ee.pointerId!==H.pointerId||!re||Q(EH({x:ee.pan.x+(H.clientX-ee.startX),y:ee.pan.y+(H.clientY-ee.startY)},{width:re.clientWidth,height:re.clientHeight},v))},B=H=>{z.current?.pointerId===H.pointerId&&(z.current=null,J(!1))},se=e!==void 0&&!y?f.jsx("div",{ref:A,"data-image-viewport":"",tabIndex:-1,className:E(X,"relative h-fit w-fit overflow-hidden leading-none outline-none",G&&(V?"cursor-grabbing":"cursor-grab"),G&&"touch-none"),onPointerDown:ne,onPointerMove:L,onPointerUp:B,onPointerCancel:B,children:d?f.jsx("video",{src:e,controls:!0,autoPlay:!0,className:E(X,"block object-contain"),"data-lightbox-video":"",onError:()=>g(e),children:t}):f.jsx("img",{src:e,alt:t,draggable:!1,className:E(X,"block select-none object-contain"),style:W?void 0:{transform:`translate(${x.x}px, ${x.y}px) scale(${v})`},onError:()=>g(e)})}):e===void 0&&o?f.jsx("div",{className:qH(X),"aria-hidden":"true"}):f.jsx("div",{className:qH(X),children:a});return f.jsx(mz,{open:n,onOpenChange:r,children:f.jsxs(gz,{ref:N,tabIndex:-1,onOpenAutoFocus:H=>{H.preventDefault(),(A.current??N.current)?.focus()},showClose:!1,"aria-describedby":void 0,onCloseAutoFocus:H=>{const ee=i?.current;ee&&(H.preventDefault(),ee.focus())},className:E("inset-0 top-0 left-0 m-auto h-fit w-fit translate-none outline-none",X,"gap-0 rounded-none border-0 border-transparent bg-transparent p-0 shadow-none"),...O,children:[f.jsx($z,{className:"sr-only",children:t}),q&&s?f.jsx("div",{"aria-live":"polite",className:"sr-only",children:h(s.index,s.count)}):null,se,f.jsxs("div",{ref:P,"data-image-viewer-controls":"",className:E("pointer-events-none fixed inset-0 transition-opacity ease-out-quart",S?"opacity-100 duration-fast":`${x2t} duration-base`),children:[q&&s?.filmstrip?f.jsx("div",{className:"pointer-events-auto fixed inset-x-0 bottom-4 mx-auto w-fit max-w-[calc(100vw-256px)]",children:s.filmstrip}):null,q?f.jsxs(f.Fragment,{children:[f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.common.viewer.previous",{kind:u}),title:m("ui.common.viewer.previous",{kind:u}),onClick:s?.onPrev,className:E("pointer-events-auto fixed top-0 bottom-0 left-4 my-auto",fh),"data-image-viewer-prev":"",children:f.jsx(rqe,{"aria-hidden":"true"})}),f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.common.viewer.next",{kind:u}),title:m("ui.common.viewer.next",{kind:u}),onClick:s?.onNext,className:E("pointer-events-auto fixed top-0 right-4 bottom-0 my-auto",fh),"data-image-viewer-next":"",children:f.jsx(Lse,{"aria-hidden":"true"})})]}):null,!d&&f.jsxs("div",{className:"pointer-events-auto fixed right-4 bottom-4 flex items-center gap-1",children:[f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.common.viewer.zoom_out"),title:m("ui.common.viewer.zoom_out"),disabled:!Y||v===ud,onClick:()=>Z(RH(v,-1)),className:fh,children:f.jsx(Ele,{"aria-hidden":"true"})}),f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.common.viewer.zoom_in"),title:m("ui.common.viewer.zoom_in"),disabled:!Y||v===Txe,onClick:()=>Z(RH(v,1)),className:fh,children:f.jsx(Rle,{"aria-hidden":"true"})}),f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.common.viewer.reset_view"),title:m("ui.common.viewer.reset_view"),disabled:!Y||W,onClick:D,className:fh,children:f.jsx(MQ,{"aria-hidden":"true"})})]}),f.jsx(NRe,{asChild:!0,children:f.jsx(ke,{variant:"ghost",size:"icon-sm",className:E("pointer-events-auto fixed top-4 right-4",fh),"aria-label":m("ui.common.viewer.close",{kind:u}),title:m("ui.common.viewer.close",{kind:u}),children:f.jsx(ni,{"aria-hidden":"true"})})})]})]})})};fU.displayName="ImageLightbox";const S2t={full:"max-h-[240px] max-w-full object-contain",thumbnail:["h-[76px] w-[115px] object-contain","motion-safe:transition-transform motion-safe:duration-fast motion-safe:ease-out-quart","motion-safe:group-hover/tile:scale-[1.04]"].join(" ")},Q2t=/[/\\]/,jH=e=>{const t=e.split(Q2t);return t[t.length-1]},Xxe=$.memo(({file:e,src:t,conversationId:n,label:r,size:i="full",overlay:a,press:o,pathActions:s})=>{const[l,c]=$.useState(!1),[u,O]=$.useState(!1),[d,h]=$.useState(!1),p=$.useRef(null),g=Xn(T=>T.setCanvasOpen),{setViewMode:y}=yd(),v=$.useCallback(async()=>{const T=jH(e),q=A=>{A&&console.error("Error processing file:",A);const Y=e.startsWith("file://")?e.substring(7):e;window.api.openFile(Y).catch(W=>{console.error("Error opening file:",W)})},{setFiles:X,setOpenTabs:C,setSelectedTab:N}=yd.getState();if(e.startsWith("data:"))if(U7(T)){const A=e,Y={id:A,title:T,path:A,content:e,type:Tx(e)},Z=yd.getState().conversations?.[n],D=Z?.files??[],z=Z?.openTabs??[],V=(()=>{const ne=D.findIndex(L=>L.id===A);return ne!==-1?[...D.slice(0,ne),Y,...D.slice(ne+1)]:[...D,Y]})();X(n,V);const G=z.some(ne=>ne.id===A)?z:[...z,{id:A,title:T}];C(n,G),N(n,A),g(!0),y(n,"documents")}else g(!0),y(n,"files");else{const A=e.startsWith("file://")?e.substring(7):e;try{const Y=await window.api.readFile(A);if(Y.success&&U7(T)){const W=A,Z={id:W,title:T,path:A,content:Y.data,type:Tx(e)},z=yd.getState().conversations?.[n],V=z?.files??[],J=z?.openTabs??[],G=(()=>{const B=V.findIndex(se=>se.id===W);return B!==-1?[...V.slice(0,B),Z,...V.slice(B+1)]:[...V,Z]})();X(n,G);const L=J.some(B=>B.id===W)?J:[...J,{id:W,title:T}];C(n,L),N(n,W),g(!0),y(n,"documents");return}g(!0),y(n,"files")}catch(Y){const W=Y instanceof Error?Y.message:String(Y??"Unknown error reading file");return q(W)}}},[e,g,y,n]),b=()=>{c(!0)},x=nU(e),w=(x==="path"||x==="data")&&n!==""||!!s?.onShowInCanvas,S=Z1e(x,{canShowInCanvas:w,source:t,artifactPathActions:!!s}),k=x==="path",P=r??jH(e);if(l)return f.jsx(af,{name:P,compact:i==="thumbnail"});const R=f.jsx($O,{boundary:i==="thumbnail"?"control":"hairline",children:f.jsx("img",{className:E(S2t[i],u?"opacity-100":"opacity-0"),src:t,alt:P,loading:"lazy",decoding:"async",onLoad:()=>O(!0),onError:b})});return f.jsxs("div",{className:"group relative inline-block",children:[f.jsx("button",{ref:p,type:"button",className:E("block max-w-full cursor-pointer",i==="thumbnail"&&"group/tile rounded-sm"),onClick:o?o.onPress:()=>h(!0),"aria-label":o?o.label:`Expand ${P}`,title:o?o.title:`Click to expand ${P}`,"aria-current":o?.current?"true":void 0,children:R}),S&&f.jsx("div",{className:"file-actions-menu pointer-events-none absolute top-1 end-1 z-[2] opacity-0 transition-opacity duration-fast ease-out-quart group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 has-[[aria-expanded=true]]:pointer-events-auto has-[[aria-expanded=true]]:opacity-100",onClick:T=>{T.stopPropagation()},onKeyDown:T=>T.stopPropagation(),children:f.jsx(V1e,{file:e,src:t,label:P,onShowInCanvas:s?.onShowInCanvas??(w?v:void 0),resolvePath:s?.resolvePath})}),o?null:a?a({open:d,onOpenChange:h,restoreFocusTo:p}):f.jsx(fU,{src:t,label:P,open:d,onOpenChange:h,restoreFocusTo:p,fallback:f.jsx(af,{name:P,detail:k?void 0:OU})})]})});Xxe.displayName="ImageAttachment";const k2t=(e,t,n)=>e.name??(n===1?"Image":`Image ${t+1}`),_2t={id:"image-group:empty",data:null,attachment:null,mimeType:"image/png"},P2t=({cold:e,children:t})=>e?f.jsx("div",{className:"flex h-[79px] w-[117px] items-start leading-none",children:t}):t,T2t=({images:e,index:t,scope:n,open:r,onOpenChange:i,restoreFocusTo:a,labelFor:o=k2t})=>{const s=e.length,[l,c]=$.useState(()=>H2(t,s)),[u,O]=$.useState(r);u!==r&&(O(r),r&&c(H2(t,s)));const d=H2(l,s),h=e[d]??_2t,p=o(h,d,s),g=aU(h,n),y=$.useRef(null),v=$.useRef(null),[b,x]=$.useState(!1),Q=$.useCallback(W=>{y.current=W,x(W!==null)},[]),w=W=>{const Z=y.current?.querySelector(`button[aria-label="Show image ${W+1} of ${s}"]`);Z?Z.focus():v.current?.focus()},S=W=>{const Z=K2(d,s,W),D=y.current?.contains(document.activeElement)??!1;c(Z),D&&w(Z)},k=()=>S(-1),P=()=>S(1),R=JSON.stringify([n?.sessionId,n?.childId,e.map(W=>[W.id,W.attachment,W.mimeType])]),[T,q]=$.useState(()=>({identity:R,open:r,indices:new Set}));(T.identity!==R||T.open!==r)&&q({identity:R,open:r,indices:new Set});const X=$.useCallback(W=>{q(Z=>{if(!r||Z.identity!==R||!Z.open||W.every(z=>Z.indices.has(z)))return Z;const D=new Set(Z.indices);for(const z of W)D.add(z);return{...Z,indices:D}})},[R,r]),C=K2(d,s,-1),N=K2(d,s,1);$.useEffect(()=>{r&&X([d,C,N])},[r,d,C,N,X]),$.useEffect(()=>{const W=y.current;if(!r||!b||!W||typeof IntersectionObserver>"u")return;let Z=!0;const D=new IntersectionObserver(z=>{Z&&X(z.filter(V=>V.isIntersecting).map(V=>Number(V.target.dataset.imageSlot)-1))},{root:W});for(const z of W.querySelectorAll("[data-image-slot]"))D.observe(z);return()=>{Z=!1,D.disconnect()}},[r,b,X]);const A=(W,Z)=>!!W.data||!W.attachment||Z===d||Z===C||Z===N||T.identity===R&&T.open&&T.indices.has(Z);$.useEffect(()=>{(y.current?.querySelector(`[data-image-slot="${d+1}"]`)??y.current)?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[b,d]);const Y=s>1?f.jsx("ul",{role:"list",ref:Q,"aria-label":`${s} images`,"data-image-filmstrip":"",className:"flex max-w-full items-center gap-2 overflow-x-auto px-2 py-1 leading-none",children:e.map((W,Z)=>f.jsx("li",{"data-image-slot":Z+1,className:E("flex shrink-0 scroll-mx-px rounded-sm leading-none",Z===d&&"ring-1 ring-ink"),children:f.jsx(P2t,{cold:!!W.attachment&&!W.data,children:A(W,Z)?f.jsx(Rf,{image:W,scope:n,size:"thumbnail",label:o(W,Z,s),press:{onPress:()=>c(Z),label:`Show image ${Z+1} of ${s}`,title:`Show image ${Z+1} of ${s}`,current:Z===d}}):f.jsx("button",{type:"button","aria-label":`Show image ${Z+1} of ${s}`,title:`Show image ${Z+1} of ${s}`,className:"group/tile inline-block max-w-full cursor-zoom-in rounded-sm leading-none",onClick:()=>{X([Z]),c(Z)},children:f.jsx($O,{boundary:"control",className:"h-[78px] w-[117px]","data-attachment-reserved":"","data-attachment-deferred":""})})})},W.id))}):void 0;return f.jsx(fU,{src:g.state==="ready"?g.url:void 0,pending:g.state==="resolving",label:p,open:r,onOpenChange:i,restoreFocusTo:a,fallback:f.jsx(af,{name:p,detail:OU}),layerRef:v,group:{index:d,count:s,onPrev:k,onNext:P,filmstrip:Y}})},Rf=({image:e,scope:t,label:n,size:r,group:i,press:a,pathActions:o})=>{const s=aU(e,t);if(s.state==="resolving"){const c=f.jsx($O,{boundary:r==="thumbnail"?"control":"hairline",className:r==="thumbnail"?"h-[78px] w-[117px]":void 0,"data-attachment-reserved":""});return a?f.jsx("button",{type:"button","aria-label":a.label,title:a.title,"aria-current":a.current||void 0,className:"group/tile inline-block max-w-full cursor-zoom-in rounded-sm leading-none",onClick:a.onPress,children:c}):f.jsx("div",{className:E("inline-block max-w-full"),"aria-hidden":!0,children:c})}if(s.state==="missing")return f.jsx(af,{name:n,compact:r==="thumbnail",detail:OU});const l=s.url;return f.jsx("div",{className:E("inline-block max-w-full"),children:f.jsx(Xxe,{file:l,src:l,label:n,size:r,conversationId:t?.sessionId??"",press:a,pathActions:o,overlay:i?c=>f.jsx(T2t,{images:i.images,index:i.index,labelFor:i.labelFor,scope:t,open:c.open,onOpenChange:c.onOpenChange,restoreFocusTo:c.restoreFocusTo}):void 0})})};function X2t(){return m("ui.chat.checkpoint.generating_name")}const R2t={rest:"scale-x-60 bg-ink-dim",preview:"scale-x-90 bg-ink-muted",active:"scale-x-100 bg-ink",unloaded:"scale-x-40 bg-ink-dim opacity-75"};function E2t(e){return e.id===e.activeId?"active":e.id===e.previewId?"preview":e.loaded===!1?"unloaded":"rest"}function Rxe(e,t){return m("ui.chat.checkpoint.turn",{turn:e,total:t})}function q2t(e,t){const n=Rxe(e.turn,t),r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`${n} · ${r}`:n}function j2t(e){return e.kind==="completion"&&e.naming?.state==="pending"}function C2t(e){const t=e.naming?.state==="ready"?e.naming.summary:null;return t?.trim()?t:null}function z2t(e){let t=0;for(const n of e)n.turn>t&&(t=n.turn);return t}const A2t={complete:"Complete",error:"Error",interrupted:"Interrupted",open:"Open"};function U2t(e){if(!Number.isFinite(e)||e<=0)return"";const t=new Date(e*1e3);return Number.isNaN(t.getTime())?"":GQ(t,{hour:"numeric",minute:"2-digit"})}function W2t(e,t){if(e.kind==="user"){const r=U2t(e.ts);return r?m("ui.chat.checkpoint.jump_user",{turn:e.turn,total:t,clock:r}):m("ui.chat.checkpoint.jump_user_no_clock",{turn:e.turn,total:t})}const n=e.naming?.state==="ready"?e.naming.name?.trim():"";return n?m("ui.chat.checkpoint.jump_agent",{turn:e.turn,total:t,name:n}):m("ui.chat.checkpoint.jump_agent_unnamed",{turn:e.turn,total:t})}function N2t(e,t){const n=e.checkpoints.find(i=>i.id===t);return n?n.kind==="completion"?n.naming?.state??null:e.checkpoints.find(i=>i.kind==="completion"&&i.turn===n.turn)?.naming?.state??null:null}function J2(e,t){const n=[];for(const r of t)N2t(e,r)==="pending"&&n.push(r);return n}const Y2t=120,CH=80,kc=10,_S=24,G2t=2,B7=420,Exe=32;function m_(e,t){return(t?G2t:0)+_S+e*kc}function zH(e,t){return m_(e,t)+_S}function Z2t(e,t,n){if(t<=0)return{start:0,end:0};const r=Exe*kc,i=Math.floor(Math.max(0,e)/r),a=i*r-B7,o=(i+1)*r+2*B7,s=m_(0,n),l=Math.max(0,Math.floor((a-s)/kc)),c=Math.min(t,Math.ceil((o-s)/kc));return{start:Math.min(l,c),end:c}}function I2t(e,t,n,r,i=24){const a=m_(e,t),o=a+kc;return a<n+i?Math.max(0,a-i):o>n+r-i?o-r+i:null}const D2t="Turn checkpoints",V2t={complete:ba,error:Yd,interrupted:Pz,open:fqe},M2t={complete:"text-success",error:"text-danger",interrupted:"text-warning",open:"text-ink-dim"},L2t=({checkpoint:e,turnCount:t})=>{const n=e.outcome,r=n?V2t[n]:null,i=C2t(e),a=e.naming?.state==="ready"?e.naming.name?.trim():"";return f.jsxs(f.Fragment,{children:[f.jsxs("p",{className:E("text-body-sm font-medium text-ink"),children:[Rxe(e.turn,t),a&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",children:" · "}),f.jsx("span",{className:E("font-normal text-ink-muted"),children:a})]})]}),j2t(e)&&f.jsx("p",{className:E("text-ink-dim text-meta"),children:X2t()}),i&&f.jsx("p",{className:E("line-clamp-2 break-words text-body-sm text-ink-muted"),children:i}),n&&r&&f.jsx("div",{className:E("flex items-center gap-1.5 text-ink-dim text-meta"),children:f.jsxs("span",{className:E("flex items-center gap-1",M2t[n]),children:[f.jsx(r,{"aria-hidden":"true",className:E("size-3.5 shrink-0")}),A2t[n]]})})]})},F2t=$.memo(function({checkpoint:t,state:n,label:r,top:i,roving:a,registerTick:o,onPreview:s,onPreviewEnd:l,onFocusMark:c,onBlurMark:u,onActivate:O,onKeyMark:d,describedBy:h}){const p=g=>{g.pointerType!=="touch"&&s(t.id)};return f.jsx("button",{ref:g=>o(t.id,g),type:"button","data-checkpoint-id":t.id,"data-mark-state":n,"aria-label":r,"aria-describedby":h,tabIndex:a?0:-1,className:E("group pointer-events-auto absolute start-0 block h-2.5 w-7"),style:{top:i},onPointerMove:p,onPointerLeave:l,onFocus:()=>c(t.id),onBlur:u,onClick:()=>O(t.id),onKeyDown:g=>d(g,t.id),children:f.jsx("span",{"aria-hidden":"true",className:E("ms-auto me-1.5 block h-0.5 w-5 origin-right rtl:origin-left rounded-full","transition-[transform,background-color] duration-fast ease-out-quart","motion-reduce:transition-none",R2t[n])})})}),B2t=({sessionId:e,checkpoints:t,onJump:n,onHover:r,building:i=!1,loadedIds:a,activeId:o=null})=>{Qe();const s=$.useId(),[l,c]=$.useState(null),[u,O]=$.useState(null),[d,h]=$.useState(null),p=$.useRef(t);p.current=t;const g=$.useRef(new Map),y=$.useRef(null),v=$.useMemo(()=>new Map(t.map((de,we)=>[de.id,we])),[t]),b=$.useRef(v);b.current=v;const x=$.useRef(i);x.current=i;const[Q,w]=$.useState({sessionId:"",top:0}),S=Exe*kc,k=$.useCallback(de=>{const we=Math.floor(Math.max(0,de)/S)*S;w(Me=>Me.sessionId===e&&Me.top===we?Me:{sessionId:e,top:we})},[S,e]),P=Q.sessionId===e?Q.top:Math.max(0,zH(t.length,i)-B7),R=$.useRef(null),T=$.useRef(null),q=$.useCallback(()=>{R.current!==null&&(clearTimeout(R.current),R.current=null),T.current!==null&&(clearTimeout(T.current),T.current=null)},[]),X=$.useCallback((de,we)=>{q();const Me=()=>{O(de),h(p.current.find(rt=>rt.id===de)??null)};if(we<=0){Me();return}R.current=setTimeout(()=>{R.current=null,Me()},we)},[q]),C=$.useCallback(de=>{if(q(),de<=0){O(null);return}T.current=setTimeout(()=>{T.current=null,O(null)},de)},[q]),N=$.useRef(e);$.useEffect(()=>{N.current!==e&&(N.current=e,q(),ee.current=null,c(null),O(null),h(null))},[e,q]);const A=$.useRef(null);$.useLayoutEffect(()=>{const de=y.current;if(!(t.length===0||de===null)){if(o!==null&&Y.current===e){A.current=e,k(de.scrollTop);return}A.current!==e&&(A.current=e,de.scrollTop=zH(t.length,i),k(de.scrollTop))}},[o,i,t.length,e,k]);const Y=$.useRef(null);$.useLayoutEffect(()=>{if(o===null)return;const de=y.current,we=b.current.get(o);if(de===null||we===void 0)return;Y.current=e;const Me=I2t(we,x.current,de.scrollTop,de.clientHeight);Me!==null&&(de.scrollTop=Me),k(de.scrollTop)},[o,e,k]),$.useEffect(()=>()=>q(),[q]);const W=$.useRef(r);$.useEffect(()=>{W.current=r});const Z=$.useMemo(()=>z2t(t),[t]),D=u&&d?.id===u?d:null,z=u&&g.current.get(u)||null,V=$.useMemo(()=>({current:z}),[z]),J=D!==null&&z!==null;$.useEffect(()=>{W.current(J&&u?u:null)},[J,u]);const G=$.useCallback((de,we)=>{we?g.current.set(de,we):g.current.delete(de)},[]),[ne,L]=$.useState(null),B=ne&&v.has(ne)?ne:t[0]?.id??null,se=$.useRef(null),H=$.useCallback(de=>{const we=Math.max(0,Math.min(t.length-1,de)),Me=t[we];if(!Me)return;L(Me.id);const rt=g.current.get(Me.id);if(rt){rt.focus();return}const Ne=y.current;Ne!==null&&(Ne.scrollTop=Math.max(0,m_(we,i)+kc/2-Ne.clientHeight/2),k(Ne.scrollTop)),se.current=Me.id},[i,t,k]);$.useLayoutEffect(()=>{const de=se.current;if(de===null)return;const we=g.current.get(de);we&&(se.current=null,we.focus())});const ee=$.useRef(null),re=$.useCallback(de=>{ee.current!==de&&(ee.current=de,c(de),X(de,Y2t))},[X]),fe=$.useCallback(()=>{ee.current=null,c(de=>de===null?de:null),C(CH)},[C]),le=$.useCallback(de=>{ee.current=de,L(de),c(we=>we===de?we:de),X(de,0)},[X]),Pe=$.useCallback(()=>{ee.current=null,c(de=>de===null?de:null),C(CH)},[C]),ce=$.useCallback(de=>{C(0),ee.current=null,c(null),n(de)},[C,n]),ve=$.useCallback((de,we)=>{if(de.key==="Escape"){C(0);return}const Me=v.get(we);if(Me!==void 0){if(de.key==="ArrowDown"){de.preventDefault(),de.stopPropagation(),H(Me+1);return}if(de.key==="ArrowUp"){de.preventDefault(),de.stopPropagation(),H(Me-1);return}if(de.key==="Home"){de.preventDefault(),de.stopPropagation(),H(0);return}de.key==="End"&&(de.preventDefault(),de.stopPropagation(),H(t.length-1))}},[t.length,C,H,v]),xe=Z2t(P,t.length,i),Te=[];for(let de=xe.start;de<xe.end;de+=1)Te.push(de);for(const de of[B,u,l]){const we=de===null?void 0:v.get(de);we!==void 0&&(we<xe.start||we>=xe.end)&&!Te.includes(we)&&Te.push(we)}return Te.sort((de,we)=>de-we),t.length===0&&!i?null:f.jsxs("div",{"data-lo-checkpoint-rail":"",role:"toolbar","aria-orientation":"vertical","aria-label":D2t,className:E("pointer-events-none absolute inset-y-0 end-3 z-10 hidden w-7 select-none","flex-col justify-center","@[900px]/chatcol:flex"),children:[f.jsxs("div",{"data-rail-frame":"","data-checkpoint-count":t.length,ref:y,onScroll:de=>k(de.currentTarget.scrollTop),className:E("max-h-[min(calc(100%-4rem),420px)] w-7 overflow-y-auto overscroll-contain","[&::-webkit-scrollbar]:hidden","[mask-image:linear-gradient(to_bottom,transparent_0,#000_24px,#000_calc(100%-24px),transparent_100%)]"),children:[i&&f.jsx("span",{"aria-hidden":"true","data-rail-building":"",className:E("ms-auto me-1.5 block h-0.5 w-5 animate-pulse-visible rounded-full bg-ink-dim")}),f.jsx("div",{"data-rail-track":"",className:"relative py-6",style:{height:t.length*kc+2*_S},children:Te.map(de=>{const we=t[de];return f.jsx(F2t,{checkpoint:we,top:_S+de*kc,state:E2t({id:we.id,previewId:l,activeId:o,loaded:a?a.has(we.id):!0}),label:W2t(we,Z),roving:we.id===B,registerTick:G,onPreview:re,onPreviewEnd:fe,onFocusMark:le,onBlurMark:Pe,onActivate:ce,onKeyMark:ve,describedBy:J&&u===we.id?s:void 0},we.id)})})]}),f.jsxs(YRe,{open:J,onOpenChange:de=>{de||C(0)},children:[f.jsx(GRe,{virtualRef:V}),D&&f.jsx(ZRe,{id:s,"data-checkpoint-card":"",side:"left",align:"center",sideOffset:10,collisionPadding:8,role:"tooltip","aria-label":D.kind==="user"?"Your message":q2t(D,Z),onOpenAutoFocus:de=>de.preventDefault(),onCloseAutoFocus:de=>de.preventDefault(),onFocusOutside:de=>{const we=de.detail?.originalEvent?.target;we instanceof Element&&we.closest("[data-lo-checkpoint-rail]")&&de.preventDefault()},className:E("pointer-events-none max-h-[176px] w-[300px] max-w-[300px] overflow-hidden","flex flex-col gap-2"),children:D.kind==="user"?f.jsx("div",{"data-checkpoint-card-text":"",className:E("line-clamp-3 break-words whitespace-pre-wrap","text-body-sm text-ink"),children:D.text}):f.jsx(L2t,{checkpoint:D,turnCount:Z})})]})]})},H2t=$.memo(B2t);function K2t(e,t){if(!t)return e;let n=!1;const r=[];for(const i of e){if(i.kind==="peer"||i.kind==="tool"&&i.toolName==="send"){n=!0;continue}r.push(i)}return n?r:e}const J2t=(e,t,n)=>(e.getAttribute(t)??"").split(" ").includes(n);function eXt(e,t){return e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`)!==null}function qxe(e,t){const n=[["[data-turn-summary]","data-run-ids"],["[data-fold-ids]","data-fold-ids"]];for(const[r,i]of n)for(const a of e.querySelectorAll(r)){const o=a.getAttribute("data-segment-ids");if(o!==null?!o.split(" ").includes(t):!J2t(a,i,t))continue;if(a.querySelector("button[aria-expanded]")?.getAttribute("aria-expanded")==="false")return a}return null}function tXt(e,t){return eXt(e,t)||qxe(e,t)!==null}const nXt=3;function rXt(e,t,n){const r=i=>{if(n.isCurrent&&!n.isCurrent()){n.onMissing();return}const a=e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`);if(a){const l=a.querySelector("button[aria-expanded]");l?.getAttribute("aria-expanded")==="false"&&l.click(),n.onRevealed(a);return}if(i>=nXt){n.onMissing();return}const s=qxe(e,t)?.querySelector("button[aria-expanded]");if(!s){n.onMissing();return}s.click(),window.requestAnimationFrame(()=>{r(i+1)})};r(0)}const AH=(e,t,n)=>n===1?"Image":`Image ${t+1}`,UH=({images:e,scope:t,onRevealMore:n,uncapped:r=!1,indent:i="content"})=>{const{shown:a,more:o}=FTt(e.length,{uncapped:r}),s=BTt(a),l=s.length>1,c=new Set;for(let O=0,d=0;d<s.length;d+=1)c.add(O),O+=s[d];const u=e.slice(0,a).map((O,d)=>f.jsx("li",{className:E("flex leading-none",l&&c.has(d)&&"col-start-1"),children:f.jsx(Rf,{image:O,scope:t,size:"thumbnail",label:AH(O,d,e.length),group:{images:e,index:d,labelFor:AH}})},O.id));return f.jsxs("ul",{role:"list","aria-label":e.length===1?"1 image from this run":`${e.length} images from this run`,"data-fold-media":"",className:E("mt-2 gap-2",l?"grid grid-cols-[repeat(4,max-content)] items-start":"flex flex-wrap items-center",i==="content"?"ms-5":"ms-0"),children:[u,o>0&&f.jsx("li",{className:E("flex h-[78px] items-center leading-none"),children:f.jsx(ke,{variant:"outline",size:"sm",onClick:n,"aria-label":`+${o} more image${o===1?"":"s"}`,title:`+${o} more image${o===1?"":"s"}`,children:`+${o}`})},"fold-media-more")]})};function WH(e,t){if(t.length===0)return!1;const n=e.find(i=>i.ids[0]===t[0]);return n?n.open:e.find(i=>i.ids.some(a=>t.includes(a)))?.open??!1}function iXt(e,t,n,r){if(t.length===0)return[...e];const i=t[0],a=[];let o=!1;for(const s of e){if(!(s.ids[0]===i||s.ids.some(c=>t.includes(c)))){a.push(s);continue}o||(a.push({ids:[...t],open:n}),o=!0)}return o||a.push({ids:[...t],open:n}),a.filter(s=>s.ids.some(l=>r.has(l)))}const aXt=({video:e,scope:t,label:n})=>{const r=Ev(e,t),[i,a]=$.useState(!1);return r.state==="missing"||i?f.jsx(af,{name:n,detail:vxe}):r.state==="resolving"?f.jsx("div",{className:E("inline-block max-w-full self-start"),"aria-hidden":!0,children:f.jsx($O,{"data-attachment-reserved":""})}):f.jsx("div",{className:E("inline-block max-w-full self-start"),children:f.jsx($O,{children:f.jsx("video",{controls:!0,preload:"metadata",src:r.url,"aria-label":n,className:E("max-h-[240px] max-w-full object-contain"),onError:()=>a(!0)})})})};function oXt({items:e,summary:t,scope:n}){return Qe(),f.jsxs("div",{"data-sound-batch":"",className:E("flex w-full min-w-0 max-w-[560px] flex-col gap-4"),children:[f.jsx("p",{className:E("text-meta text-ink-muted break-words [overflow-wrap:anywhere]"),children:t}),f.jsx("ul",{className:"flex min-w-0 flex-col gap-4",children:e.map(r=>f.jsxs("li",{"data-sound-batch-item":"",className:E("min-w-0"),children:[f.jsxs("p",{className:E("text-body text-ink break-words [overflow-wrap:anywhere]"),children:[r.label,r.status!=="completed"?` · ${r.status==="unknown"?"Status unknown":r.status==="cancelled"?"Stopped":"Failed"}`:""]}),r.error?f.jsx("p",{className:E("text-body-sm text-ink break-words [overflow-wrap:anywhere]"),children:r.error}):r.audio?f.jsx(dU,{audio:r.audio,ownerId:`${Pxe(r.audio)}:batch:${r.audio.id}:${r.id}`,scope:n,label:r.label}):f.jsx("p",{className:E("text-meta text-ink-muted"),children:m("ui.chat.canonical.sound.batch_attachment_unavailable")}),f.jsx("p",{className:E("text-meta text-ink-dim"),children:r.costCaption??"Cost not yet known."})]},r.id))})]})}function dln({sessionId:e,runningSound:t,available:n,onInterrupt:r,onRestoreFocus:i}){const[a,o]=$.useState(!1),s=$.useRef(null),l=$.useRef(e);$.useEffect(()=>{const h=l.current!==e;l.current=e,!(!h&&t)&&a&&(o(!1),i())},[e,t,a,i]);const c=$.useCallback(()=>{o(!1),i()},[i]),u=$.useCallback(()=>{if(!e||!n)return;const h=s.current?.querySelector("[data-sound-stop-confirmation] button");if(h){h.focus();return}if(t){o(!0);return}r()},[e,n,t,r]),O=$.useCallback(()=>{o(!1),i(),r()},[r,i]),d=$.useMemo(()=>a&&t?f.jsx(jxe,{onKeepWaiting:c,onRequestStop:O}):null,[a,t,c,O]);return{paneRef:s,stop:u,confirmation:d}}function jxe({onKeepWaiting:e,onRequestStop:t}){Qe();const n=$.useRef(null),r=$.useId();return $.useEffect(()=>{n.current?.focus();const i=a=>{a.key!=="Escape"||a.isComposing||a.defaultPrevented||(a.preventDefault(),a.stopPropagation(),e())};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[e]),f.jsxs("fieldset",{"data-sound-stop-confirmation":"","aria-label":m("ui.chat.canonical.sound.stop.confirm_label"),className:"flex flex-col items-start gap-2",children:[f.jsx("p",{className:"text-meta text-ink","aria-live":"polite",children:m("ui.chat.canonical.sound.stop.question")}),f.jsx("p",{id:r,className:"text-body-sm text-ink-dim",children:m("ui.chat.canonical.sound.stop.warning")}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsx(ke,{ref:n,"aria-describedby":r,variant:"ghost",size:"sm",onClick:e,children:m("ui.chat.canonical.sound.stop.keep_waiting")}),f.jsx(ke,{variant:"secondary",size:"sm",onClick:t,children:m("ui.chat.canonical.sound.stop.request_stop")})]})]})}const sXt=1e3;function lXt(e){const[t,n]=$.useState(()=>e===null?null:Math.max(0,(Date.now()-e)/1e3));return $.useEffect(()=>{if(e===null){n(null);return}const r=()=>n(Math.max(0,(Date.now()-e)/1e3));r();const i=window.setInterval(r,sXt);return()=>window.clearInterval(i)},[e]),t}function cXt(){return f.jsx("div",{"aria-hidden":!0,"data-imagegen-tile":"",className:E("relative aspect-[3/2] w-[240px] max-w-full overflow-hidden rounded-sm bg-sunken"),children:f.jsx("span",{className:E("absolute inset-0","animate-shimmer","bg-gradient-to-r from-transparent via-elevated to-transparent","bg-[length:200%_100%]","bg-[position:-200%_50%]","bg-no-repeat")})})}const NH=44,uXt=240,eX=12,OXt=Array.from({length:240},(e,t)=>Math.min(1,.18+Math.abs(Math.sin(t/7)*Math.cos(t/17))*.72));function dXt({state:e}){const t=Qxe(OXt,uXt-eX*2,NH);return f.jsx("div",{"aria-hidden":!0,"data-sound-loading-tile":"","data-sound-loading":e,className:E("relative flex w-[240px] max-w-full items-center overflow-hidden rounded-sm bg-sunken"),style:{height:NH},children:f.jsx("div",{className:E("flex w-full items-center"),style:{paddingLeft:eX,paddingRight:eX},children:t.map((n,r)=>f.jsx("span",{"data-sound-loading-bar":"",className:E("shrink-0 rounded-[2px]",e==="running"?"animate-pulse-visible bg-ink-muted":e==="queued"?"bg-ink-disabled":e==="stopped"?"bg-ink-dim":"bg-ink-muted"),style:{width:kS,height:e==="failed"?xxe:n.height,marginRight:n===t.at(-1)?0:2,animationDelay:e==="running"?`${r%12*90}ms`:void 0}},n.x))})})}function fXt({view:e,elapsed:t}){let n,r=null,i=!1;switch(e.state){case"queued":n=e.composing?"Writing the request…":"Queued",r=e.queuePosition!==null?`${e.queuePosition} ahead`:e.argumentBytes>0?r1(e.argumentBytes):null;break;case"running":n=e.batchProgress?`Generating ${e.batchProgress.total} ${Rh(e.material)}${e.batchProgress.total===1?"":"s"}…`:`Generating ${Rh(e.material)}…`,r=t===null?null:iO(t);break;case"cancelling":n=e.generating?Wq:BN;break;case"done":n=e.receipt==="already-finished"?"Already finished.":e.batch?`${tX(e.material)} batch`:`Generated ${Rh(e.material)}`,r=e.receipt==="already-finished"||e.durationS===null?null:uz(e.durationS);break;case"failed":n=e.batch?`${tX(e.material)} batch failed.`:e.message??`The ${Rh(e.material)} could not be generated.`,i=!0;break;case"cancelled":{const a=e.message??(e.generating?Wq:BN);n=e.batch?`${tX(e.material??"sound-effect")} batch stopped.`:e.settlementCaption||e.settled?_4e(a):a;break}}return f.jsxs("p",{className:E("flex min-w-0 items-baseline gap-1.5 text-body-sm"),children:[f.jsx("span",{className:E("min-w-0",i?"text-ink":"text-ink-muted"),children:n}),r===null?null:f.jsxs("span",{className:E("shrink-0 text-meta text-ink-dim"),children:["· ",r]})]})}function hXt({line:e}){return f.jsx("p",{"data-imagegen-log":"",title:e,className:E("min-w-0 truncate font-mono text-mono-sm text-ink-dim"),children:e})}function tX(e){const t=Rh(e);return t.charAt(0).toUpperCase()+t.slice(1)}function hh({line:e,prominent:t=!1}){return f.jsx("p",{"data-imagegen-note":"",className:E("min-w-0 text-body-sm",t?"text-ink-muted":"text-ink-dim"),children:e})}function pXt(e,t){return e==="cancel"?m("ui.chat.canonical.image_gen.control.stop"):e==="restart"?t==="failed"?m("ui.common.actions.retry"):m("ui.chat.canonical.image_gen.control.restart"):m("ui.chat.canonical.image_gen.control.edit_and_restart")}const mXt=({view:e,scope:t,actions:n})=>{Qe();const[r,i]=$.useState(!1),a=$.useCallback(()=>i(!1),[]),o=$.useRef(null),s=$.useRef(!1);$.useLayoutEffect(()=>{s.current&&!r&&(o.current?.querySelector("[data-imagegen-controls] button")??o.current)?.focus(),s.current=r},[r]),$.useLayoutEffect(()=>{const Q=o.current;return()=>{Q?.contains(document.activeElement)&&Q.closest("[data-chat-pane]")?.querySelector("textarea")?.focus()}},[]);const l=e.state==="running"&&(e.material==="voiceover"||e.material==="sound-effect");$.useEffect(()=>{l||i(!1)},[l]);const c=e.state==="running"||e.state==="cancelling"?e.startedAtMs:null,u=lXt(c),O=T4e(e,n),d={cancel:n?.onCancel,restart:n?.onRestart,editRestart:n?.onEditRestart},h=e.state==="running"||e.state==="cancelling",p=h&&(e.state==="running"||e.generating),g="material"in e?e.material:void 0,y=g==="voiceover"||g==="sound-effect",v=y?e.state==="queued"?"queued":e.state==="cancelling"?e.generating?"stopped":null:p?"running":e.state==="failed"?"failed":e.state==="cancelled"?"stopped":null:null,b=y&&(e.state==="failed"?e.batch?.some(Q=>Q.status==="cancelled"):e.state==="cancelled"&&(e.batch?.some(Q=>Q.status==="cancelled")||e.message))?Wq:null,x=h&&e.progress.logs.length>0?e.progress.logs[e.progress.logs.length-1]:null;return f.jsxs("div",{ref:o,tabIndex:-1,"data-imagegen-card":e.state,className:E("flex w-full flex-col gap-2"),children:[v?f.jsx(dXt,{state:v}):p?f.jsx(cXt,{}):null,e.state==="failed"&&(e.material==="voiceover"||e.material==="sound-effect")&&e.errorType?f.jsx("p",{className:E("text-meta text-ink-dim"),children:e.errorType}):null,f.jsx(fXt,{view:e,elapsed:u}),(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.costCaption?f.jsx(hh,{line:e.costCaption,prominent:!!e.batch}):null,(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.batchNote?f.jsx(hh,{line:e.batchNote,prominent:!0}):null,e.state==="running"&&e.batchProgress?.note?f.jsx(hh,{line:e.batchProgress.note}):null,e.state==="cancelled"&&e.settlementCaption?f.jsx(hh,{line:e.settlementCaption}):null,b?f.jsx(hh,{line:b}):null,l&&r?f.jsx(jxe,{onKeepWaiting:a,onRequestStop:()=>{i(!1),n?.onCancel?.()}}):null,e.state==="running"&&typeof e.note=="string"?f.jsx(hh,{line:e.note}):null,p&&e.progress.fraction!==null?f.jsx(IRe,{"aria-label":m("ui.chat.canonical.image_gen.progress"),className:E("max-w-[240px]"),value:Math.round(Math.min(1,Math.max(0,e.progress.fraction))*100)}):null,x===null?null:f.jsx(hXt,{line:x}),(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.batch?f.jsx(oXt,{items:e.batch,summary:e.batchSummary??`${e.batch.length} items`,scope:t}):e.state==="done"&&e.images.length>0?f.jsx("div",{className:E("flex flex-col gap-2"),children:e.images.map((Q,w)=>{const S=`Generated ${Rh(Q.kind==="audio"?e.material:Q.kind??"image")}`,k=e.images.length===1?S:`${S} ${w+1}`;return Q.kind==="video"?f.jsx(aXt,{video:Q,scope:t,label:k},Q.id):Q.kind==="audio"?f.jsx(dU,{audio:Q,scope:t,label:k},Q.id):f.jsx(Rf,{image:Q,scope:t,label:k},Q.id)})}):null,O.length>0&&!(l&&r)?f.jsx("div",{"data-imagegen-controls":"",className:E("flex items-center gap-2"),children:O.map(Q=>f.jsx(ke,{variant:"secondary",size:"sm",disabled:Q.disabled,title:Q.kind==="cancel"?e.state==="queued"||e.state==="cancelling"&&!e.generating?"Stops before the provider is called.":"Requests a stop; the provider may finish anyway.":void 0,onClick:Q.kind==="cancel"&&l?()=>{const w=o.current?.closest("[data-chat-pane]")?.querySelector("[data-sound-stop-confirmation] button");if(w){w.focus();return}i(!0)}:d[Q.kind],children:pXt(Q.kind,e.state)},Q.kind))}):null]})},Rm="data-lo-quote-toolkit";function H7(e,t){return e.kind!=="user"&&e.kind!=="assistant"||t.trim().length===0?!1:e.kind!=="assistant"?!0:!e.streaming}const YH=e=>(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(`[${Rm}]`)??null,gXt=e=>e.nodeType===Node.ELEMENT_NODE,$Xt=e=>{const t=Array.from(e.childNodes),n=t.findIndex(r=>gXt(r)&&r.hasAttribute(Rm));return n===-1?t.length:n},yXt=(e,t)=>Math.abs(e.top-t.top)<.5&&Math.abs(e.left-t.left)<.5&&Math.abs(e.right-t.right)<.5&&Math.abs(e.bottom-t.bottom)<.5,vXt=e=>{const t=Array.from(document.querySelectorAll(`[${Rm}]`),n=>n.getBoundingClientRect());return Array.from(e.getClientRects()).filter(n=>!t.some(r=>yXt(r,n))).map(n=>({top:n.top,left:n.left,right:n.right,bottom:n.bottom}))};function tp(e){if(!e)return null;const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;const n=t.getRangeAt(0);if(YH(n.startContainer)||YH(n.endContainer)||!e.contains(n.startContainer))return null;const r=n.cloneRange();e.contains(n.endContainer)||r.setEnd(e,$Xt(e));const i=r.toString().trim();return i.length===0?null:{text:i,lines:vXt(n)}}const GH="[data-lo-canonical-transcript]",bXt="[data-lo-transcript-content]",ZH=e=>({top:e.top,left:e.left,right:e.right,bottom:e.bottom}),wXt=()=>({top:0,left:0,right:window.innerWidth,bottom:window.innerHeight});function Cxe(e){const{turnRef:t,visible:n,lines:r,measureKey:i,belowWhenOffFirstLine:a}=e,o=$.useRef(null),[s,l]=$.useState(null),c=$.useRef(r);c.current=r;const u=$.useCallback(()=>{const O=t.current,d=o.current;if(!O||!d){l(null);return}const h=c.current();if(!h||h.length===0){l(null);return}const p=YYe({lines:h,container:ZH((O.closest(GH)??O).getBoundingClientRect()),viewport:wXt(),size:{width:d.offsetWidth,height:d.offsetHeight},row:ZH(O.getBoundingClientRect()),belowWhenOffFirstLine:a}),g=O.getBoundingClientRect(),y=p?{top:p.top-g.top,left:p.left-g.left,placement:p.placement}:null;l(v=>v===y||v&&y&&v.top===y.top&&v.left===y.left&&v.placement===y.placement?v:y)},[t,a]);return $.useLayoutEffect(()=>{if(!n){l(null);return}u();let O=0;const d=()=>{O||(O=requestAnimationFrame(()=>{O=0,u()}))};document.addEventListener("scroll",d,!0),document.addEventListener("selectionchange",d),window.addEventListener("resize",d);const h=t.current?.closest(GH),p=h?.querySelector(bXt),g=new ResizeObserver(d);return h&&g.observe(h),p&&g.observe(p),()=>{O&&cancelAnimationFrame(O),document.removeEventListener("scroll",d,!0),document.removeEventListener("selectionchange",d),window.removeEventListener("resize",d),g.disconnect()}},[n,u,t,i]),{controlRef:o,placement:s}}function zxe(e){const[t,n]=$.useState(null);$.useEffect(()=>{const i=()=>n(tp(e.current)?.text??null);return i(),document.addEventListener("selectionchange",i),()=>document.removeEventListener("selectionchange",i)},[e]);const r=$.useCallback(()=>n(null),[]);return{text:t,clear:r}}const Th="data-lo-link-toolbar",xXt=120,SXt=2;function Axe(e){const[t,n]=$.useState(null),[r,i]=$.useState(!1),a=$.useRef(null);a.current=t;const o=$.useRef(null),s=$.useRef(null),l=$.useCallback(()=>{const u=e.current;if(!u){o.current=null,n(h=>h===null?h:null),i(h=>h===!1?h:!1);return}const O=ckt(u);if(O){n(h=>h===O?h:O),i(h=>h===!0?h:!0);return}if(i(h=>h===!1?h:!1),u1e()){n(h=>h===null?h:null);return}const d=o.current&&u.contains(o.current)?o.current:null;n(h=>h===d?h:d)},[e]);$.useEffect(()=>{const u=e.current;if(!u)return;let O=0;const d=k=>{O&&(clearTimeout(O),O=0),o.current=k,l()},h=k=>{if(O&&clearTimeout(O),!k){O=0,o.current=null,l();return}o.current!==k&&(s.current=null,O=setTimeout(()=>{O=0,o.current=k,l()},xXt))},p=(k,P)=>{const R=o.current;if(!R||!u.contains(R))return!1;const T=u.querySelector(`[${Th}]`),q=Q9+SXt;for(const X of[R,T]){if(!X)continue;const C=X.getBoundingClientRect();if(!(C.width<=0||C.height<=0)&&k>=C.left-q&&k<=C.right+q&&P>=C.top-q&&P<=C.bottom+q)return!0}return!1},g=k=>{const P=k.target;if(P?.closest(`[${Rm}]`))return;const R=P?.closest(Ph)??null;!R&&p(k.clientX,k.clientY)||h(R)},y=k=>{const P=k.relatedTarget;P&&u.contains(P)||p(k.clientX,k.clientY)||d(null)},v=k=>{const P=k.target?.closest(Ph);if(P){if(P===s.current){s.current=null;return}d(P)}},b=k=>{const P=k.relatedTarget;P&&u.contains(P)||d(null)},x=()=>Array.from(u.querySelectorAll(`[${Th}] button:not([disabled])`)),Q=k=>{const P=k.target;if(!P)return!1;if(P.closest(`[${Th}]`)){const X=x(),C=X.indexOf(P);if(C===-1)return!1;if(k.shiftKey&&C===0){const N=o.current;return N instanceof HTMLElement?(N.focus(),!0):!1}if(!k.shiftKey&&C===X.length-1){const N=Array.from(u.querySelectorAll(Ph)),A=o.current,Y=A?N.indexOf(A)+1:-1,W=Y>0?N[Y]:void 0;return W?(W.focus(),!0):!1}return!1}if(k.shiftKey)return!1;const T=P.closest(Ph);if(!T||!u.contains(T))return!1;o.current!==T&&d(T);const[q]=x();return q?(q.focus(),!0):!1},w=k=>{if(k.key==="Tab"&&Q(k)){k.preventDefault();return}if(!(k.key==="ContextMenu"||k.shiftKey&&k.key==="F10"))return;const R=k.target?.closest(Ph);!R||!u.contains(R)||(k.preventDefault(),d(R),requestAnimationFrame(()=>{u.querySelector(`[${Th}] button`)?.focus()}))},S=k=>{const P=k.target;P&&u.contains(P)||d(null)};return u.addEventListener("pointerover",g),u.addEventListener("pointerout",y),u.addEventListener("focusin",v),u.addEventListener("focusout",b),u.addEventListener("keydown",w),document.addEventListener("pointerdown",S,!0),document.addEventListener("selectionchange",l),l(),()=>{O&&clearTimeout(O),u.removeEventListener("pointerover",g),u.removeEventListener("pointerout",y),u.removeEventListener("focusin",v),u.removeEventListener("focusout",b),u.removeEventListener("keydown",w),document.removeEventListener("pointerdown",S,!0),document.removeEventListener("selectionchange",l)}},[e,l]);const c=$.useCallback(()=>{s.current=a.current,o.current=null,l()},[l]);return $.useEffect(()=>{if(!t)return;const u=O=>{if(O.key!=="Escape"||O.target?.closest(`[${Th}]`))return;const h=window.getSelection();h&&!h.isCollapsed&&h.removeAllRanges(),c()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[t,c]),{subject:t,quoteAvailable:r,dismiss:c}}function Uxe(e,t,n){const r=Zn(i=>i.addReply);return $.useCallback(()=>{const a=tp(t.current)?.text??(u1e()?null:n?.()??null);a&&(r(e,{id:Wa(),text:a}),window.getSelection()?.removeAllRanges(),Kz())},[r,e,t,n])}const Wxe=({conversationId:e,turnRef:t,subject:n,quoteAvailable:r,onDismiss:i})=>{const a=n.getAttribute(l1e)??"",o=n.getAttribute("data-lo-kind")??"file",s=Tv(),l=$.useCallback(()=>(n.textContent??"").trim()||null,[n]),c=Uxe(e,t,l),{text:u}=zxe(t),{speak:O}=vm(),d=ak(e),h=u??l(),p=h===null?null:vp(e,ik(h).text);EOe(p);const g=sk({key:p,getText:()=>tp(t.current)?.text??l(),play:({text:A})=>O(vp(e,A),ok(d,A))}),[y,v]=$.useState(!1),[b,x]=$.useState(()=>W1(a)??null),{controlRef:Q,placement:w}=Cxe({turnRef:t,visible:!0,lines:()=>{const A=n.getClientRects();return Array.from(A,Y=>({top:Y.top,left:Y.left,right:Y.right,bottom:Y.bottom}))},measureKey:n,belowWhenOffFirstLine:!0});$.useEffect(()=>{const A=W1(a);if(x(A??null),v(!1),A!==void 0)return;let Y=!0;return rkt(a,window.api?.probeFiles).then(()=>{Y&&x(W1(a)??null)}),()=>{Y=!1}},[a]);const S=o==="file"&&B8(s,a),k=f1e({target:a,isDirectory:b?.exists===!0&&!b.isFile,probe:b,canOpenInCanvas:S}),P=dkt({kind:o,target:a,probe:b,quotable:r,canOpenInCanvas:S});if(!P||!a)return null;const R=async()=>{await Xv(a)&&v(!0)},T=async()=>{if(o==="url"){await CB(o,a);return}s&&k&&await s.openInCanvas(a)||await CB(o,a)||x(null)},q=async()=>{await gO(a)||x(null)},X=async()=>{await H8(a)||x(null)},C={quote:f.jsx(Ple,{}),copy:y?f.jsx(ba,{}):f.jsx(pf,{}),open:k?f.jsx(Kje,{}):o==="url"?f.jsx(VQ,{}):f.jsx(By,{}),"open-default":f.jsx(LEe,{}),"open-folder":f.jsx(dp,{})},N={quote:c,copy:()=>{R()},open:()=>{T()},"open-default":()=>{q()},"open-folder":()=>{X()}};return f.jsxs(k9,{[Rm]:"",[Th]:"",ref:Q,label:P.label,className:E("absolute z-20",!w&&"invisible"),style:w?{top:w.top,left:w.left}:void 0,onKeyDown:A=>{if(A.key!=="Escape")return;window.getSelection()?.removeAllRanges();const Y=n;A.preventDefault(),i(),Y.focus?.()},children:[P.actions.map(A=>f.jsxs($.Fragment,{children:[f.jsx(vt,{content:A.id==="copy"&&y?"Copied":A.label,side:w?.placement==="below"?"bottom":"top",children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":A.id==="copy"&&y?"Copied":A.label,className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:N[A.id],children:C[A.id]})}),A.id==="quote"&&f.jsx(lk,{control:g,side:w?.placement==="below"?"bottom":"top"})]},A.id)),P.note&&f.jsx("span",{className:"max-w-56 truncate ps-1 text-ink-dim text-meta",title:P.noteTitle??P.note,children:P.note})]})};function QXt({role:e="answer",forkable:t=!1}={}){const n=t?["fork"]:[];return e==="user"?["copy",...n]:e==="commentary"?["copy"]:e==="response"?["copy","speak",...n]:["copy","speak",...n]}function K7(e){return e.kind!=="user"&&e.kind!=="assistant"||e.kind==="assistant"&&e.streaming?null:e.id||null}const IH=96;function kXt(e){const t=e.replace(/\s+/g," ").trim();return t.length<=IH?t:`${t.slice(0,IH-1).trimEnd()}…`}function _Xt(){return m("ui.chat.response_actions.answer_label")}function PXt(){return m("ui.chat.response_actions.yours_label")}const TXt="pointer-events-none opacity-0 transition-opacity duration-fast ease-out-quart group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 [@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100";function DH(e){return e?"opacity-100":TXt}const Nxe=2e3,XXt=1e4;function fln(e){const{request:t}=e;return t?e.now-t.requestedAt>XXt?"retire":e.presentable?e.claimed?"hold":"present":"yield":null}let VH=0,Tw=0;const RXt=Xi(e=>({request:null,requestPanel:(t,n,r,i)=>{VH+=1,e({request:{destination:t,nonce:VH,requestedAt:Date.now(),invoker:n??null,...r?{sessionId:r}:{},...i?.id?{entryId:i.id}:{},...i?.id&&i.excerpt?{entryExcerpt:i.excerpt}:{},...r&&i?.subjectName?{subjectName:i.subjectName}:{}}})},consumePanel:t=>e(n=>n.request?.nonce===t?{request:null}:n),presenterClaimed:!1,claimPresenter:()=>{Tw+=1,e({presenterClaimed:!0});let t=!1;return()=>{t||(t=!0,Tw=Math.max(0,Tw-1),Tw===0&&e({presenterClaimed:!1}))}}})),EXt=(e,t)=>{let n=e;for(;n!==null;){if(n.matches(":hover"))return!0;if(n===t)break;n=n.parentElement}const r=e.ownerDocument.activeElement;return r!==null&&t.contains(r)},qXt=9e4,MH=new Set,jXt=2600,Z1=$.memo(function({bodyText:t,kind:n="answer",agentId:r,speechId:i,revealId:a,revealAt:o,conversationId:s,entryId:l,overlay:c=!1,overlayClassName:u}){const[O,d]=$.useState(!1),[h,p]=$.useState(!1),g=$.useRef(null),y=$.useRef(null),v=$.useRef(null),b=$.useRef(null),{playSpeech:x}=vm(),Q=ak(r??null),w=sk({key:i?XOe(i):null,getText:()=>t,play:({text:C})=>{i&&x(i,Q,C)}}),S=RXt(C=>C.requestPanel),k=!!(s&&l);Qe();const P=QXt({role:n,forkable:k}),R=O||w.active;$.useEffect(()=>()=>{g.current!==null&&clearTimeout(g.current)},[]),$.useEffect(()=>{if(!a||o===void 0||MH.has(a)||(MH.add(a),Date.now()-o>qXt))return;const C=y.current;if(C===null)return;const N=C.closest(".group")??C;if(EXt(C,N))return;p(!0);const A=()=>{p(!1),N.removeEventListener("pointerenter",A),N.removeEventListener("focusin",A)};return N.addEventListener("pointerenter",A),N.addEventListener("focusin",A),()=>{N.removeEventListener("pointerenter",A),N.removeEventListener("focusin",A)}},[a,o]),$.useEffect(()=>{if(h)return b.current=setTimeout(()=>{b.current=null,p(!1)},jXt),()=>{b.current!==null&&clearTimeout(b.current)}},[h]);const T=async()=>{await Xv(t)&&(d(!0),g.current!==null&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,d(!1)},Nxe))},q=()=>{!s||!l||S("session.fork",v.current,s,{id:l,excerpt:kXt(t)})},X={copy:f.jsx(vt,{content:O?m("ui.chat.response_actions.copied"):m("ui.chat.response_actions.copy"),side:"bottom",children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":O?m("ui.chat.response_actions.copied"):m("ui.chat.response_actions.copy"),className:E("text-ink-dim hover:bg-transparent hover:text-ink"),onClick:T,children:O?f.jsx(ba,{"aria-hidden":"true"}):f.jsx(pf,{"aria-hidden":"true"})})}),speak:f.jsx(lk,{control:w,side:"bottom",className:E("text-ink-dim hover:bg-transparent hover:text-ink")}),fork:f.jsx(vt,{content:m("ui.chat.pickers.destination_pickers.fork_from_this_message"),side:"bottom",children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.pickers.destination_pickers.fork_from_this_message"),ref:v,className:E("text-ink-dim hover:bg-transparent hover:text-ink"),onClick:q,children:f.jsx(Jqe,{"aria-hidden":"true"})})})};return f.jsx("div",{role:"toolbar","aria-label":n==="user"?PXt():n==="commentary"?m("ui.chat.commentary_actions.label"):n==="response"?m("ui.chat.response_actions.label"):_Xt(),ref:y,onAnimationEnd:C=>{C.target===C.currentTarget&&p(!1)},...h?{"data-lo-arrive":""}:{},...n==="user"?{"data-lo-user-actions":""}:n==="commentary"?{"data-lo-gutter-actions":""}:n==="response"?{"data-lo-response-actions":""}:{"data-lo-answer-actions":""},className:E(c?E("absolute z-10 flex h-8 items-center gap-1","-top-2 end-0",DH(R),u):E("flex h-8 shrink-0 items-center gap-1",DH(R))),children:P.map(C=>f.jsx($.Fragment,{children:X[C]},C))})}),CXt="@container/olderhistory mb-4 flex h-7 min-w-0 items-center gap-2",Xw="@min-[260px]/olderhistory:hidden",Rw="@max-[260px]/olderhistory:hidden",Yxe="lo-older-history-hint",zXt=({state:e,transportDown:t=!1,onLoadOlder:n,onRetryHydration:r})=>{Qe();const i=e==="loading"?m("ui.chat.canonical.older_history.loading"):e==="failed"?t?m("ui.chat.canonical.older_history.transport.long"):m("ui.chat.canonical.older_history.failed.long"):e==="unproven"?m("ui.chat.canonical.older_history.unproven.long"):null,a=e==="loading";return f.jsxs("div",{className:CXt,children:[f.jsx("output",{className:"sr-only","aria-live":"polite",children:i}),e==="failed"&&t?f.jsxs("span",{className:"min-w-0 truncate text-ink-dim text-meta",children:[f.jsx("span",{className:Xw,children:m("ui.chat.canonical.older_history.transport.short")}),f.jsx("span",{className:Rw,children:m("ui.chat.canonical.older_history.transport.long")})]}):e==="failed"?f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"min-w-0 truncate text-danger text-meta",title:m("ui.chat.canonical.older_history.failed.long"),children:[f.jsx("span",{className:Xw,children:m("ui.chat.canonical.older_history.failed.short")}),f.jsx("span",{className:Rw,children:m("ui.chat.canonical.older_history.failed.long")})]}),f.jsx(ke,{variant:"ghost",size:"sm",className:"shrink-0",onClick:n,children:m("ui.chat.canonical.older_history.try_again")})]}):a?f.jsxs(ke,{variant:"ghost",size:"sm","aria-disabled":!0,onClick:o=>{o.preventDefault()},className:"text-ink-muted",children:[f.jsx(Qo,{size:"sm"}),m("ui.chat.canonical.older_history.loading")]}):e==="idle"?f.jsx(ke,{variant:"ghost",size:"sm",onClick:n,children:m("ui.chat.canonical.older_history.load")}):e==="windowed"?f.jsxs("span",{id:Yxe,className:"min-w-0 truncate text-ink-dim text-meta",title:t?m("ui.chat.canonical.older_history.windowed.title"):m("ui.chat.canonical.older_history.windowed.title_gesture"),children:[f.jsx("span",{className:Xw,children:t?m("ui.chat.canonical.older_history.windowed.title"):m("ui.chat.canonical.older_history.windowed.short_gesture")}),f.jsx("span",{className:Rw,children:t?m("ui.chat.canonical.older_history.windowed.title"):m("ui.chat.canonical.older_history.windowed.title_gesture")})]}):e==="unproven"?f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"min-w-0 truncate text-ink-dim text-meta",title:m("ui.chat.canonical.older_history.unproven.long"),children:[f.jsx("span",{className:Xw,children:m("ui.chat.canonical.older_history.unproven.short")}),f.jsx("span",{className:Rw,children:m("ui.chat.canonical.older_history.unproven.long")})]}),!t&&r&&f.jsx(ke,{variant:"ghost",size:"sm",className:"shrink-0",onClick:r,children:m("ui.chat.canonical.older_history.try_again")})]}):f.jsx("span",{className:"min-w-0 truncate text-ink-dim text-meta",children:m("ui.chat.canonical.older_history.conversation_start")})]})},AXt="/settings?section=providers",LH="/settings?section=providers&provider=radient",UXt="/settings?section=radient",FH=/sign in to radient/i,WXt=[/insufficient credits/i,/credit balance is too low/i],NXt=[/rate limit or quota/i],YXt=[/insufficient credits/i,/\bHTTP 402\b/i];function Gxe(e){return(e??"").split("/")[0]?.trim().toLowerCase()==="radient"}function hU(e){return Gxe(e.provider)?e.category==="billing"?!0:(e.category==null||e.category==="unknown"||e.category==="rate-limit")&&YXt.some(n=>n.test(e.text)):!1}function GXt(e){if(!hU(e))return null;const t=/rate limit or quota( exceeded)?\s*/i;if(!t.test(e.headline))return{label:"billing",headline:e.headline};const n=e.headline.replace(t,"").trim(),r=/^\((HTTP \d{3})\):?\s*(.*)$/i.exec(n),i=(r?r[2]:n.replace(/^:\s*/,"")).trim(),a=r?` (${r[1]})`:"";return{label:"billing",headline:i?m("ui.chat.provider_error.headline.out_of_credits",{status:a,body:i}):m("ui.chat.provider_error.headline.out_of_credits_refused",{status:a})}}function ZXt(e){return e==="auth"?"sign-in":e==="billing"?"billing":e==="rate-limit"?"quota":null}function BH(e){const t=Gxe(e.provider)||FH.test(e.text);let n=ZXt(e.category);return hU(e)&&(n="billing"),n===null&&(e.category==null||e.category==="unknown")&&(FH.test(e.text)?n="sign-in":WXt.some(r=>r.test(e.text))?n="billing":NXt.some(r=>r.test(e.text))&&(n="quota")),n===null?null:n==="sign-in"&&t?{label:m("ui.chat.provider_error.action.sign_in_radient"),to:LH}:n==="billing"&&t?{label:m("ui.chat.provider_error.action.open_radient_account"),to:UXt}:{label:m("ui.chat.provider_error.action.open_provider_settings"),to:t?LH:AXt}}const Zxe=({conversationId:e,turnRef:t,allowQuote:n=!0})=>{Qe();const{text:r,clear:i}=zxe(t),a=r!==null,o=Uxe(e,t);$.useEffect(()=>{const v=t.current;if(!v||!a)return;const b=v.closest("[data-record-id]")??v,x=[...b.querySelectorAll("[data-lo-gutter-actions], [data-lo-user-actions], [data-lo-answer-actions], [data-lo-response-actions]")];b.setAttribute("data-lo-selection-active","");for(const Q of x)Q.setAttribute("inert",""),Q.setAttribute("aria-hidden","true");return()=>{b.removeAttribute("data-lo-selection-active");for(const Q of x)Q.removeAttribute("inert"),Q.removeAttribute("aria-hidden")}},[a,t]);const[s,l]=$.useState(!1),c=$.useRef(null);$.useEffect(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);const u=$.useCallback(async()=>{const v=tp(t.current)?.text??r;v&&await Xv(v)&&(l(!0),c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,l(!1)},Nxe))},[r,t]),{controlRef:O,placement:d}=Cxe({turnRef:t,visible:a,lines:()=>tp(t.current)?.lines??null}),{speak:h}=vm(),p=ak(e),g=r===null?null:vp(e,ik(r).text);EOe(g);const y=sk({key:g,getText:()=>tp(t.current)?.text??null,play:({text:v})=>h(vp(e,v),ok(p,v))});return $.useEffect(()=>{if(!a)return;const v=b=>{b.key!=="Escape"||b.defaultPrevented||(window.getSelection()?.removeAllRanges(),i())};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[a,i]),a?f.jsxs(k9,{[Rm]:"",ref:O,label:m("ui.chat.transcript_copy.selection.toolbar"),className:E("absolute z-20",!d&&"invisible"),style:d?{top:d.top,left:d.left}:void 0,children:[n&&f.jsx(vt,{content:"Quote",side:d?.placement==="below"?"bottom":"top",children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.transcript_copy.selection.quote"),className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:o,children:f.jsx(Ple,{})})}),f.jsx(vt,{content:s?m("ui.chat.transcript_copy.toast.copied_selection"):m("ui.chat.transcript_copy.selection.copy"),side:d?.placement==="below"?"bottom":"top",children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":s?m("ui.chat.transcript_copy.toast.copied_selection"):m("ui.chat.transcript_copy.selection.copy"),className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:()=>{u()},children:s?f.jsx(ba,{}):f.jsx(pf,{})})}),f.jsx(lk,{control:y,side:d?.placement==="below"?"bottom":"top"})]}):null},Ixe={all:["radient-prices"],prices:()=>[...Ixe.all,"prices"]},IXt=()=>{const e=wt({queryKey:Ixe.prices(),queryFn:()=>c9({operation:"prices"}),staleTime:36e5,refetchOnWindowFocus:!1,refetchOnMount:!0,refetchInterval:!1,retry:3});return{prices:e.data,isLoading:e.isLoading,isFetching:e.isFetching,error:e.error,pricesQuery:e}},HH="https://console.radienthq.com/dashboard/verification",KH="https://console.radienthq.com/dashboard/billing",JH=()=>m("ui.common.account.top_up");function DXt(e){return!e.email_verified&&e.signup_grant!=="claimed"}const hln=e=>typeof e!="number"||!Number.isFinite(e)?m("ui.common.account.free_credits_unknown"):m("ui.common.account.free_credits",{amount:`$${e.toFixed(2)}`}),J7=e=>Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`,VXt=e=>typeof e!="number"||!Number.isFinite(e)?m("ui.common.account.free_credits_unknown"):m("ui.common.account.free_credits",{amount:J7(e)});function eK(e,t){if(!e)return t;try{const{protocol:n}=new URL(e);return n==="https:"||n==="http:"?e:t}catch{return t}}function MXt(e){window.api?.openExternal?window.api.openExternal(e):window.open(e,"_blank")}const LXt=(e,t)=>e==="pending"?{sentence:m("ui.common.account.verify_pending",{amount:t}),action:m("ui.common.account.open_verification")}:e==="expired"?{sentence:m("ui.common.account.verify_expired",{amount:t}),action:m("ui.common.account.request_new_link")}:{sentence:m("ui.common.account.verify_none"),action:m("ui.common.account.open_verification")};function FXt(e,t){if(e===void 0)return{state:"unknown",lines:[m("ui.common.account.out_unknown_verify"),m("ui.common.account.out_unknown_top_up")],links:[{label:m("ui.common.account.open_verification"),url:HH},{label:JH(),url:KH}]};if(DXt(e)){const i=eK(e.claim_url,HH),{action:a}=LXt(e.signup_grant,"");if(e.signup_grant==="none")return{state:"unverified",lines:[m("ui.common.account.out_unverified_none")],links:[{label:a,url:i}]};const o=VXt(e.grant_amount??t);return{state:"unverified",lines:[m("ui.common.account.out_unverified_claim",{amount:o}),e.signup_grant==="expired"?m("ui.common.account.out_unverified_expired"):m("ui.common.account.out_unverified_inbox")],links:[{label:a,url:i}]}}const n=e.first_topup,r=[m("ui.common.account.out_verified")];return n!==void 0&&n.bonus_received===!1&&Number.isFinite(n.bonus_amount)&&Number.isFinite(n.minimum_purchase)&&r.push(m("ui.common.account.first_top_up_bonus",{bonus:J7(n.bonus_amount),minimum:J7(n.minimum_purchase)})),{state:"verified",lines:r,links:[{label:JH(),url:eK(n?.topup_url,KH)}]}}const BXt=5*1e3,HXt=({action:e})=>{const{user:t,accountRead:n}=due({staleTime:BXt,retryOnMount:!1}),r=dr(),{prices:i}=IXt(),o=r.isPending||n==="checking"?null:FXt(n==="ready"?t?.verification:void 0,i?.default_new_credits);return f.jsxs("div",{className:"mt-1 flex flex-col items-start gap-2 ps-6",children:[o?f.jsxs("div",{"data-radient-credits-state":o.state,className:"flex max-w-[60ch] items-start gap-3 rounded-sm border border-hairline bg-surface p-3",children:[f.jsx(Fy,{className:"mt-0.5 size-4 shrink-0 text-ink-muted","aria-hidden":"true"}),f.jsx("div",{className:"min-w-0 text-body-sm text-ink",children:o.lines.map(s=>f.jsx("p",{className:"[&:not(:first-child)]:mt-1",children:s},s))})]}):null,f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o?.links.map(s=>f.jsx(ke,{variant:"secondary",size:"sm",onClick:()=>MXt(s.url),children:s.label},s.url)),f.jsx(ke,{variant:"ghost",size:"sm",asChild:!0,children:f.jsx(hle,{to:e.to,children:e.label})})]})]})},g0="data-jump-highlight",KXt=1400,nX=new WeakMap;function e6(e){const t=nX.get(e);t!==void 0&&window.clearTimeout(t);const n=e.hasAttribute(g0);e.removeAttribute(g0),n&&e.offsetHeight,e.setAttribute(g0,""),nX.set(e,window.setTimeout(()=>{nX.delete(e),e.removeAttribute(g0)},KXt))}const rX=(e,t,n="normal",r=0)=>{const a=e.scrollTop+t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-r;e.scrollTop=n==="reversed"?Math.min(0,a):Math.max(0,a)},I1=24,Dxe=6,t6=()=>new Promise(e=>{window.requestAnimationFrame(()=>{e()})}),tK=async e=>{for(let t=0;t<Dxe;t+=1){if(e())return;await t6()}},Vxe=e=>{let t=null;return()=>(t!==null||(t=e().finally(()=>{t=null})),t)},JXt=e=>{const t=Vxe(e.loadOlder),n=()=>tK(()=>e.reachable()||e.rowDistance()!==null);return{loadOne:t,loadThrough:async i=>{const a=e.hasHeadroom??(()=>!0);let o=0;for(;;){if(e.reachable())return"landed";const s=e.rowDistance();if(s!==null){if(i.maxRows!==void 0&&s>i.maxRows)return"over-budget";if(!a()&&o<i.maxPages&&(o+=1,await t())){await n();continue}return e.mount(s),await tK(()=>e.reachable()),e.reachable()?"landed":"exhausted"}if(o>=i.maxPages||(o+=1,!await t()))return"exhausted";await n()}}}},eRt=12,tRt=1200,nRt=Dxe,rRt=nRt+2,iRt=2,aRt=30,nK=1,Ng=I1;let ph=0;async function oRt(e){const{isReachable:t,rowDistance:n,mount:r,loadOlder:i}=e,a=e.hasHeadroom??(()=>!0);return await JXt({reachable:t,rowDistance:n,mount:r,loadOlder:i,hasHeadroom:a}).loadThrough({maxPages:eRt,maxRows:tRt})==="landed"}async function sRt(e,t,n){if(!n()||!t.isConnected)return;ph+=1;const r=ph;rX(e,t,"reversed",Ng);const i=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);let a=!1;const o=()=>{a=!0},s=l=>{i.has(l.key)&&(a=!0)};e.addEventListener("wheel",o,{passive:!0,once:!0}),e.addEventListener("pointerdown",o,{passive:!0,once:!0}),e.addEventListener("touchstart",o,{passive:!0,once:!0}),window.addEventListener("keydown",s);try{let l=0,c=!1;for(let u=0;u<rRt&&(await t6(),!(!n()||!t.isConnected||a||r!==ph));u+=1){const O=t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-Ng;if(Math.abs(O)<=nK){if(l+=1,l>=iRt){c=!0;break}continue}l=0,rX(e,t,"reversed",Ng)}if(c&&!a&&r===ph){const u=e,O=t,d=()=>{a=!0};u.addEventListener("wheel",d,{passive:!0,once:!0}),u.addEventListener("pointerdown",d,{passive:!0,once:!0}),u.addEventListener("touchstart",d,{passive:!0,once:!0}),window.addEventListener("keydown",s),(async()=>{try{for(let h=0;h<aRt;h+=1){if(await t6(),!n()||a||r!==ph||!u.isConnected||!O.isConnected)return;const p=O.getBoundingClientRect().top-u.getBoundingClientRect().top-u.clientTop-Ng;if(Math.abs(p)<=nK)continue;rX(u,O,"reversed",Ng);const g=u.ownerDocument?.defaultView;g!=null&&u.dispatchEvent(new g.Event("scroll"))}}finally{u.removeEventListener("wheel",d),u.removeEventListener("pointerdown",d),u.removeEventListener("touchstart",d),window.removeEventListener("keydown",s)}})()}}finally{e.removeEventListener("wheel",o),e.removeEventListener("pointerdown",o),e.removeEventListener("touchstart",o),window.removeEventListener("keydown",s)}if(n()&&!a&&r===ph){const l=e.ownerDocument?.defaultView;l!=null&&e.dispatchEvent(new l.Event("scroll"))}}function Mxe(e,t,n,r=()=>!0){return r()?new Promise(i=>{rXt(e,n,{isCurrent:r,onRevealed:a=>{if(!r()){i("missing");return}e6(a),sRt(t,a,r).then(()=>{r()&&a.isConnected&&!a.hasAttribute(g0)&&e6(a),i(r()?"landed":"missing")})},onMissing:()=>{i("missing")}})}):Promise.resolve("missing")}const Fu=120,Ew=400,lRt=.5,cRt=320,uRt=900,qw=64,g_=2,iX=24,aX=3,ORt=4,ay=12,n6=ay,dRt=120,fRt=.35,rK=12,hRt=8,pRt=ay,mRt=.5,iK=()=>({armed:!1,deliberate:!1,retained:!1,busy:!1,continuation:!1,clampLatched:!1,actFetchSpent:!1,travelledSinceLatch:!1,actTravelled:!1,pressDemand:!1,pageWidenOwed:!1,turnedAround:!1,lastInputAt:Number.NEGATIVE_INFINITY,failures:0,chainFetch:0,chainWiden:0,chainInvisible:0,actAsks:0,revealsThisAct:0}),Lxe=e=>Math.min(uRt,Math.max(cRt,Math.round(e*lRt))),gRt=(e,t)=>{if(t.direction==="down")return{...e,armed:!1,deliberate:!1,retained:!1,actFetchSpent:t.at-e.lastInputAt>=Ew?!1:e.actFetchSpent,actAsks:t.at-e.lastInputAt>=Ew?0:e.actAsks,revealsThisAct:t.at-e.lastInputAt>=Ew?0:e.revealsThisAct,continuation:!1,clampLatched:!1,travelledSinceLatch:!1,actTravelled:e.actTravelled||t.travelledPx>=qw,pageWidenOwed:!1,turnedAround:e.busy,chainFetch:0,chainWiden:0,chainInvisible:0,lastInputAt:t.at};const n=t.at-e.lastInputAt>=Ew,r={...e,actFetchSpent:n?!1:e.actFetchSpent,actAsks:n?0:e.actAsks,revealsThisAct:n?0:e.revealsThisAct,travelledSinceLatch:n?!1:e.travelledSinceLatch,actTravelled:n?t.travelledPx>=qw:e.actTravelled||t.travelledPx>=qw,continuation:!1,turnedAround:!1,chainFetch:0,chainInvisible:0,chainWiden:0,lastInputAt:t.at};return t.deliberate?{...r,clampLatched:!1,failures:0,deliberate:!0,actFetchSpent:!1,actAsks:0,revealsThisAct:0,actTravelled:!1,pressDemand:!1,...e.busy?{retained:!0}:{armed:!0}}:t.atHardTop&&t.continuous&&e.clampLatched&&!n?t.travelledPx>=qw&&!e.travelledSinceLatch?{...r,armed:!0,pressDemand:!1,clampLatched:!1,travelledSinceLatch:!0}:!e.armed&&e.clampLatched&&!e.actTravelled?{...e,armed:!0,pressDemand:!0,lastInputAt:t.at}:{...e,lastInputAt:t.at}:e.busy?{...r,retained:!0,pressDemand:!1}:{...r,armed:!0,pressDemand:!1}},Yg=(e,t,n)=>({action:t,state:{...e,armed:!1,deliberate:!1,busy:!0,continuation:!1,clampLatched:e.clampLatched||e.armed&&n.distanceFromTopPx<=g_,pageWidenOwed:e.pageWidenOwed&&t!=="widen",actFetchSpent:t==="fetch"?!0:e.actFetchSpent,chainWiden:t==="widen"?e.chainWiden+1:e.chainWiden,chainFetch:t==="fetch"?e.chainFetch+1:e.chainFetch,actAsks:t==="fetch"?e.actAsks+1:e.actAsks,revealsThisAct:e.revealsThisAct+1,chainInvisible:e.chainInvisible}}),$Rt=(e,t,n)=>e.busy||e.pageWidenOwed?!0:!e.armed||!Fxe(t).inZone?!1:t.distanceFromTopPx<=g_?!e.pressDemand||!e.clampLatched||e.actTravelled||e.actAsks>=n6?!1:n-e.lastInputAt>=Fu:!0;function Fxe(e,t=Lxe(e.clientHeight)){return{inZone:e.distanceFromTopPx<=t}}const yRt=(e,t,n)=>{if(e.busy)return{action:"none",state:e};const r=t.hiddenRows>0?"widen":t.hasMore?"fetch":"none";if(r==="none")return{action:"none",state:e.armed||e.continuation?{...e,armed:!1,deliberate:!1,continuation:!1}:e};if(t.followingTail&&t.scrollable)return e.armed?{action:"none",state:{...e,armed:!1}}:{action:"none",state:e};const i=Lxe(t.clientHeight),{inZone:a}=Fxe(t,i),o=n-e.lastInputAt>=Fu||t.distanceFromTopPx<=g_,s=e.revealsThisAct<pRt;if(e.pageWidenOwed&&r==="widen"&&e.chainWiden<rK&&s)return o?Yg({...e,pageWidenOwed:!1,continuation:!1,armed:!1,retained:!1,deliberate:!1},r,t):{action:"none",state:e};if(e.armed){if(e.deliberate)return Yg(e,r,t);if(r==="fetch"&&e.failures>=aX)return{action:"none",state:{...e,armed:!1}};if(!o)return{action:"none",state:e};if(!a)return{action:"none",state:{...e,armed:!1}};if(r==="fetch"&&e.actFetchSpent){const l=n-e.lastInputAt>=Fu;return l&&e.clampLatched&&!e.actTravelled&&e.pressDemand&&e.actAsks<n6?Yg(e,r,t):l?{action:"none",state:{...e,armed:!1}}:{action:"none",state:e}}return Yg(e,r,t)}if(e.continuation){const l=e.actAsks<n6,c=l&&e.chainInvisible>0&&e.chainInvisible<ay;return t.scrollable&&!(e.pageWidenOwed&&r==="widen")&&!c?{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}:s&&(r==="widen"?e.chainWiden<rK:(c||l&&e.chainFetch<ORt)&&e.failures<aX)?Yg({...e,pageWidenOwed:!1,continuation:!1},r,t):{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}}return{action:"none",state:e}},aK=(e,{network:t=!0,hiddenRowsAfter:n=0,paintedDelta:r=null,growthPx:i=null,clientHeight:a=0,newRecords:o=null}={})=>{const s=r!==null&&r<hRt,l=r===null&&t&&i!==null&&i<Math.max(dRt,fRt*a),c=s||t&&o===0||l;return{...e,busy:!1,failures:t?0:e.failures,armed:e.retained,pressDemand:e.retained&&e.pressDemand,deliberate:e.retained?e.deliberate:!1,retained:!1,turnedAround:!1,pageWidenOwed:t&&n>0,actFetchSpent:c?!1:e.actFetchSpent,chainInvisible:c?Math.min(e.chainInvisible+1,ay):0,continuation:t&&n>0||c&&e.chainInvisible+1<ay||!e.retained&&!e.turnedAround}},vRt=e=>({...e,busy:!1,pressDemand:!1,failures:e.failures+1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),bRt=e=>({...e,busy:!1,pressDemand:!1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),wRt=(e,t,n,r)=>n===r?Bxe(e,t):null,Bxe=(e,t)=>{if(!e||!t||e.id!==t.id||e.extent===t.extent)return 0;const n=t.viewportOffset-e.viewportOffset;return Math.abs(n)<mRt?0:n};function Hxe({path:e}){switch(g9(e)){case"image":return f.jsx(yle,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"spreadsheet":return f.jsx(vle,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"markdown":case"text":case"document":return f.jsx(m$,{"aria-hidden":"true",className:"size-3.5 shrink-0"});default:return f.jsx(By,{"aria-hidden":"true",className:"size-3.5 shrink-0"})}}function xRt(e,t){try{return B8(e,t)}catch{return!1}}function pU(e,t,n,r){const i=$.useCallback(async s=>{try{const l=r?await r():e,[c]=await window.api.probeFiles([l],t??void 0);if(!c?.resolved.startsWith("/"))throw new Error("File path has no session working directory");await s(c.resolved)}catch{Tr(m("ui.chat.highlights.file_resolution_failed"))}},[e,t,r]),a=xRt(n??null,e),o=$.useCallback(()=>{i(async s=>{a&&n&&await n.openInCanvas(s)||await gO(s)})},[i,a,n]);return{canOpenInCanvas:a,press:o,withTarget:i}}const mU=$.memo(function({actionPath:t,label:n,cwd:r,pane:i,overlay:a=!1,resolveActionPath:o,missing:s=!1}){Qe();const{canOpenInCanvas:l,withTarget:c}=pU(t,r,i,o),[u,O]=$.useState(!1),d=`Actions for ${n||"this file"}`;return f.jsxs(yz,{children:[f.jsx(vt,{content:"File actions",children:f.jsx(vz,{asChild:!0,children:a?f.jsx(ke,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":d,children:f.jsx(Iq,{"aria-hidden":"true"})}):f.jsx("button",{type:"button",className:"flex size-6 shrink-0 items-center justify-center text-ink-dim opacity-0 group-hover:opacity-100 focus-visible:opacity-100","aria-label":d,children:f.jsx(Iq,{"aria-hidden":"true",className:"size-3.5"})})})}),f.jsxs(bz,{align:"end",className:"min-w-45",children:[l&&!s&&f.jsxs(ml,{onSelect:()=>{c(h=>i?.openInCanvas(h))},children:[f.jsx(ble,{"aria-hidden":"true"}),f.jsx("span",{children:m("ui.chat.canonical.supplement.file_actions.open_in_canvas")})]}),!s&&f.jsxs(ml,{onSelect:()=>{c(gO)},children:[f.jsx(By,{"aria-hidden":"true"}),f.jsx("span",{children:m("ui.chat.canonical.supplement.file_actions.open_in_default_app")})]}),!s&&f.jsxs(ml,{onSelect:()=>{c(H8)},children:[f.jsx(dp,{"aria-hidden":"true"}),f.jsx("span",{children:m("ui.chat.canonical.supplement.file_actions.reveal_in_finder")})]}),f.jsxs(ml,{onSelect:()=>{(o&&!s?o():Promise.resolve(t)).then(h=>navigator.clipboard.writeText(h)).then(()=>O(!0)).catch(()=>Tr(m("ui.notices.files.copy_path_failed")))},children:[f.jsx(Tz,{"aria-hidden":"true"}),f.jsx("span",{children:u?"Copied":"Copy file path"})]})]})]})});function SRt(e){return e.materialisable===!1&&!e.stored?"gone":e.exists===!0?"present":e.exists===!1?e.stored?"retained":"gone":e.stored?"present":"gone"}const gU=(e,t,n)=>`${e}:${t??`#${n}`}`;function QRt(e){if(!e||typeof e.message_id!="string"||!e.message_id||e.kind!=="document"&&e.kind!=="image")return null;const t=typeof e.attachment=="string"&&e.attachment?e.attachment:null;return{key:gU(e.message_id,t,e.index??0),messageId:e.message_id,ts:Math.round((typeof e.ts=="number"?e.ts:0)*1e3),kind:e.kind,digest:t,data:null,filename:e.filename??null,mimeType:e.mime_type??(e.kind==="image"?"image/png":"application/octet-stream"),bytes:typeof e.bytes=="number"?e.bytes:null,path:e.path??null,storedPath:e.stored_path??null,availability:SRt(e),index:typeof e.index=="number"?e.index:0,materialisable:typeof e.materialisable=="boolean"?e.materialisable:null,originExists:typeof e.exists=="boolean"?e.exists:null}}function kRt(e,t,n){return{key:gU(e.id,t.attachment,n),messageId:e.id,ts:e.ts,kind:"document",digest:t.attachment,data:null,filename:t.filename,mimeType:t.mimeType,bytes:t.bytes>0?t.bytes:null,path:t.path,storedPath:t.storedPath,availability:"unknown",materialisable:null}}function _Rt(e,t,n){return{key:gU(e.id,t.attachment,n),messageId:e.id,ts:e.ts,kind:"image",digest:t.attachment,data:t.data,filename:t.name??null,mimeType:t.mimeType,bytes:t.sizeBytes??null,path:null,storedPath:null,availability:"unknown",materialisable:null}}function Kxe(e){const t=[];for(const n of e??[])n.kind==="user"&&((n.documents??[]).forEach((r,i)=>{t.push(kRt(n,r,i))}),n.images.forEach((r,i)=>{r.kind!==void 0&&r.kind!=="image"||t.push(_Rt(n,r,i))}));return t}function PRt(e,t,n=!1){const r=e?.state==="ready",i=r?(e?.items??[]).map(QRt).filter(p=>p!==null):[],a=!n||e?.state==="unsupported"?"none":r?i.length>0&&i.every(p=>p.materialisable===null)?"none":"ready":"pending",o=new Map(i.map(p=>[p.key,p])),s=new Map;for(const p of i){const g=`${p.messageId}:${p.kind}`;s.set(g,(s.get(g)??0)+1)}const l=Kxe(t),c=new Map,u=XRt({items:i,verdicts:a}),O=new Map;for(const p of l){const g=`${p.messageId}:${p.kind}`;O.set(g,(O.get(g)??0)+1)}const d=new Map,h=[...i];for(const p of l){const g=`${p.messageId}:${p.kind}`,y=d.get(g)??0;if(d.set(g,y+1),o.has(p.key))continue;const v=r6(u,{messageId:p.messageId,kind:p.kind,position:y,count:O.get(g)??0,digest:p.digest,path:p.path}),b=v===null?p:{...p,materialisable:v};if(b.digest===null){const x=`${b.messageId}:${b.kind}`,Q=c.get(x)??0;if(c.set(x,Q+1),Q<(s.get(x)??0))continue}o.set(b.key,b),h.push(b)}return h.sort((p,g)=>g.ts-p.ts),{items:h,complete:r,truncated:!!e?.truncated,verdicts:a}}const qv={digests:new Set,slots:new Map,paths:new Set,verdicts:"none",judged:new Map},TRt={...qv,verdicts:"pending"};function XRt(e){const t=e.verdicts??"none";if(t==="pending")return TRt;const n=new Set,r=new Set,i=new Map,a=new Map;for(const s of e.items){if(typeof s.materialisable!="boolean"||s.index===void 0)continue;const l=`${s.messageId}:${s.kind}`;i.set(l,(i.get(l)??0)+1);const c=s.materialisable===!1;c&&s.digest&&n.add(s.digest),c&&s.path&&r.add(s.path);const u=a.get(l)??[];u.push({index:s.index,refused:c}),a.set(l,u)}const o=new Map;for(const[s,l]of a)l.some(c=>c.refused)&&(l.sort((c,u)=>c.index-u.index),o.set(s,l.map(c=>c.refused)));return!o.size&&t==="none"?qv:{digests:n,slots:o,paths:r,verdicts:t,judged:i}}function r6(e,t){if(t.digest&&e.digests.has(t.digest)||t.path&&e.paths.has(t.path))return!1;if(e.verdicts==="pending")return"pending";const n=`${t.messageId}:${t.kind}`,r=e.slots.get(n);return r&&(r.length!==t.count||r[t.position])?!1:e.verdicts==="ready"&&(e.judged.get(n)??0)<t.count?"pending":null}function oK(e,t){return e&&t!==!1&&t!=="pending"}function pln(e){return new Set(e.items.map(t=>t.digest).filter(t=>t!==null))}function mln(e,t,n=0,r=!0){const i=dr(),a=i.data!==void 0,o=Nn(i.data,"session_attachments"),s=$.useMemo(()=>Kxe(t),[t]),l=s.map(R=>`${R.key}:${R.digest??""}`).join("|"),[c,u]=$.useState({key:"",value:null,state:"loading"}),O=`${e??"draft"}:${o}`,[d,h]=$.useState(0),{echoIds:p,durableIds:g}=$.useMemo(()=>{const R=new Set(s.map(X=>X.messageId)),T=[],q=[];for(const X of t??[])X.kind!=="user"||!R.has(X.id)||(X.local||X.provisional?T:q).push(X.id);return{echoIds:T.join(`
|
|
875
875
|
`),durableIds:q.join(`
|