local-operator-ui 0.45.2 → 0.45.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/out/main/index.js +150 -18
  2. package/out/preload/index.js +4 -0
  3. package/out/renderer/assets/{_basePickBy-DfW_EmXG.js → _basePickBy-D2mJrcmc.js} +1 -1
  4. package/out/renderer/assets/{_baseUniq-ayYN_oUd.js → _baseUniq-CxwrVbCU.js} +1 -1
  5. package/out/renderer/assets/{agent-details-page-DYNg_8WE.js → agent-details-page-DW2BcdCd.js} +1 -1
  6. package/out/renderer/assets/{agent-hub-page-Fl9o5tVX.js → agent-hub-page-DtelG6Z1.js} +1 -1
  7. package/out/renderer/assets/agents-page-BEpaWqiq.js +14 -0
  8. package/out/renderer/assets/{approvalsOverlay-C0at70px.js → approvalsOverlay-eLrF8rTc.js} +1 -1
  9. package/out/renderer/assets/{arc-CAgcm6f2.js → arc-Bm2OoQ4-.js} +1 -1
  10. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-B_AU_9Ol.js → architectureDiagram-IEHRJDOE-BoPMn2Mo.js} +1 -1
  11. package/out/renderer/assets/{blockDiagram-JOT3LUYC-Cx1mTsWR.js → blockDiagram-JOT3LUYC-DxKZonYG.js} +1 -1
  12. package/out/renderer/assets/{book-open-CezObvQD.js → book-open-ByRqB3UN.js} +1 -1
  13. package/out/renderer/assets/browser-page-CUGb_34H.js +1 -0
  14. package/out/renderer/assets/{browser-webauthn-prompt-CbRckWAd.js → browser-webauthn-prompt-DwGQwTu8.js} +1 -1
  15. package/out/renderer/assets/{building-2-9EZMFKGw.js → building-2-Dy6C7045.js} +1 -1
  16. package/out/renderer/assets/{c4Diagram-VJAJSXHY-D-u6J_VF.js → c4Diagram-VJAJSXHY-DgSuLDm0.js} +1 -1
  17. package/out/renderer/assets/channel-WrJnktqu.js +1 -0
  18. package/out/renderer/assets/{chunk-4BMEZGHF-Dr3TIH8M.js → chunk-4BMEZGHF-Bb4vaZIp.js} +1 -1
  19. package/out/renderer/assets/{chunk-A2AXSNBT-7KeNbzkc.js → chunk-A2AXSNBT-p7_pHJVS.js} +1 -1
  20. package/out/renderer/assets/{chunk-AEK57VVT-ClkwOxB5.js → chunk-AEK57VVT-ClZWEudC.js} +1 -1
  21. package/out/renderer/assets/{chunk-D6G4REZN-DKlbiDds.js → chunk-D6G4REZN-BtRUAAer.js} +1 -1
  22. package/out/renderer/assets/{chunk-RZ5BOZE2-DdcfCvZ6.js → chunk-RZ5BOZE2-B6FiCA8P.js} +1 -1
  23. package/out/renderer/assets/{chunk-XZIHB7SX-BslwBEYg.js → chunk-XZIHB7SX-iubhBv37.js} +1 -1
  24. package/out/renderer/assets/classDiagram-GIVACNV2-kOcXvj0Y.js +1 -0
  25. package/out/renderer/assets/classDiagram-v2-COTLJTTW-kOcXvj0Y.js +1 -0
  26. package/out/renderer/assets/clone-BxCrdsII.js +1 -0
  27. package/out/renderer/assets/{console-mirror-DJmf7Skj.js → console-mirror-DtPKRnoQ.js} +1 -1
  28. package/out/renderer/assets/{consoleCapture-C3BYnks6.js → consoleCapture-C497gKx7.js} +1 -1
  29. package/out/renderer/assets/{conversation-input-sync-DzEaiT19.js → conversation-input-sync-CczYmRpD.js} +4 -4
  30. package/out/renderer/assets/{dagre-OKDRZEBW-D_xZ0YPD.js → dagre-OKDRZEBW-CMCYOxv5.js} +1 -1
  31. package/out/renderer/assets/{diagram-SSKATNLV-rYZUf0IN.js → diagram-SSKATNLV-GbrQ1DgQ.js} +1 -1
  32. package/out/renderer/assets/{diagram-VNBRO52H-CXhsoZrw.js → diagram-VNBRO52H-fTF3Mw0c.js} +1 -1
  33. package/out/renderer/assets/{erDiagram-Q7BY3M3F-1JJNePdt.js → erDiagram-Q7BY3M3F-vp92kU8p.js} +1 -1
  34. package/out/renderer/assets/error-boundary-BgUrwH7u.js +126 -0
  35. package/out/renderer/assets/{flowDiagram-4HSFHLVR-D0pvhpjZ.js → flowDiagram-4HSFHLVR-DQDsWb6f.js} +1 -1
  36. package/out/renderer/assets/{ganttDiagram-APWFNJXF-Chzblo33.js → ganttDiagram-APWFNJXF-BvG5lCVD.js} +1 -1
  37. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-D8mYAr4t.js → gitGraphDiagram-7IBYFJ6S-BtRj6YUh.js} +1 -1
  38. package/out/renderer/assets/{graph-Cw0lwTt0.js → graph-D5b7-Ozr.js} +1 -1
  39. package/out/renderer/assets/{hash-DTOKDpBn.js → hash-CrEjZX-2.js} +1 -1
  40. package/out/renderer/assets/{heart-BOf2F-L2.js → heart-8rDtUc1Z.js} +1 -1
  41. package/out/renderer/assets/{index-LdCy3uKw.js → index-BQ-anM-O.js} +1 -1
  42. package/out/renderer/assets/{index-BTzCVYFd.js → index-BVf3_vkI.js} +1 -1
  43. package/out/renderer/assets/{index-8oTW2A2L.js → index-D-WE-3AE.js} +181 -181
  44. package/out/renderer/assets/{index-C_VKtNXE.js → index-DEnBt0Qi.js} +1 -1
  45. package/out/renderer/assets/index-N87yPCeX.css +1 -0
  46. package/out/renderer/assets/infoDiagram-PH2N3AL5-QGroqdpX.js +2 -0
  47. package/out/renderer/assets/{installer-Bl9ZlNPa.js → installer-CDeSFlYF.js} +1 -1
  48. package/out/renderer/assets/{journeyDiagram-U35MCT3I-wXp-XzIA.js → journeyDiagram-U35MCT3I-DVqe6k_G.js} +1 -1
  49. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-Dx-4ogJ1.js → kanban-definition-NDS4AKOZ-xs0tGUWm.js} +1 -1
  50. package/out/renderer/assets/{layout-CbkXDKl2.js → layout-BXhptE7W.js} +1 -1
  51. package/out/renderer/assets/{legacy-agents-page-zUkXzn9i.js → legacy-agents-page-CAu2ymNc.js} +1 -1
  52. package/out/renderer/assets/{library-page-Co1m65Bo.js → library-page-Z3gULDyp.js} +3 -3
  53. package/out/renderer/assets/{mermaid.core-B10H6Sj9.js → mermaid.core-Dkk1pdj8.js} +5 -5
  54. package/out/renderer/assets/{mesh-page-wXYYLB7-.js → mesh-page-DPKNd40g.js} +1 -1
  55. package/out/renderer/assets/{messages-CHMqznYC.js → messages-CSKtFcP6.js} +8 -8
  56. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-DknOLkdd.js → mindmap-definition-ALO5MXBD-CFGVlmoc.js} +1 -1
  57. package/out/renderer/assets/{mini-Bwcr1Ehq.js → mini-AvkMQUn7.js} +1 -1
  58. package/out/renderer/assets/{notebook-pen-DchCI5ov.js → notebook-pen-LANPWMJy.js} +1 -1
  59. package/out/renderer/assets/{notifications-page-NOQ-sP7O.js → notifications-page-CylLvSdk.js} +1 -1
  60. package/out/renderer/assets/{org-access-B9w3NCte.js → org-access-MX0xjFWR.js} +1 -1
  61. package/out/renderer/assets/{org-surface-gate-CLSu0eKs.js → org-surface-gate-BtvmKKbu.js} +1 -1
  62. package/out/renderer/assets/{page-header-yOGfpoQT.js → page-header-FV16p5uV.js} +1 -1
  63. package/out/renderer/assets/{path-utils-qAYSdhvu.js → path-utils-CyEhREK0.js} +1 -1
  64. package/out/renderer/assets/{pieDiagram-IB7DONF6-BChSPutf.js → pieDiagram-IB7DONF6-BSjrs9cA.js} +1 -1
  65. package/out/renderer/assets/{project-markdown-DQL1UPcc.js → project-markdown-DMOUmU9x.js} +1 -1
  66. package/out/renderer/assets/{projects-page-msVCbtiR.js → projects-page-BR99VLsd.js} +1 -1
  67. package/out/renderer/assets/{publication-validation-D7ewtWTx.js → publication-validation-BRAIkrkM.js} +1 -1
  68. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-CuwarOKF.js → quadrantDiagram-7GDLP6J5-CImVcS_C.js} +1 -1
  69. package/out/renderer/assets/{radar-MK3ICKWK-Dt9DGim3.js → radar-MK3ICKWK-DoLVtIkR.js} +1 -1
  70. package/out/renderer/assets/{radient-auth-buttons-CjpEThBx.js → radient-auth-buttons-DNj7RTGb.js} +1 -1
  71. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-CuqF9L9e.js → requirementDiagram-KVF5MWMF-CTGcN8fW.js} +1 -1
  72. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-CWHiGUqH.js → sankeyDiagram-QLVOVGJD-BW8957-i.js} +1 -1
  73. package/out/renderer/assets/{schedules-page-CrRFo5_v.js → schedules-page-CUdpU-8C.js} +1 -1
  74. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-VLHRJlos.js → sequenceDiagram-X6HHIX6F-DrVKNinq.js} +1 -1
  75. package/out/renderer/assets/{settings-page-Bmz6Rduj.js → settings-page-BMHScWEQ.js} +1 -1
  76. package/out/renderer/assets/{smartart-BhYR330C.js → smartart-mqgXLYJa.js} +1 -1
  77. package/out/renderer/assets/{stateDiagram-DGXRK772-BbMDjtoq.js → stateDiagram-DGXRK772-DSx047Sl.js} +1 -1
  78. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-BVcdQug2.js +1 -0
  79. package/out/renderer/assets/{team-bridge-page-BVmUDKly.js → team-bridge-page-_zokvRE7.js} +5 -5
  80. package/out/renderer/assets/{timeline-definition-BDJGKUSR-B933H8Mc.js → timeline-definition-BDJGKUSR-Crl7bGz-.js} +1 -1
  81. package/out/renderer/assets/{use-default-on-banner-D7q-pE2P.js → use-default-on-banner-5Do2jUFB.js} +1 -1
  82. package/out/renderer/assets/{use-download-agent-mutation-CRQMrclD.js → use-download-agent-mutation-BuozrL1A.js} +1 -1
  83. package/out/renderer/assets/{use-session-snapshot-DsORSDZa.js → use-session-snapshot-BKrw3TC-.js} +1 -1
  84. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-DfbaIoJC.js → xychartDiagram-VJFVF3MP-DS7OvQRJ.js} +1 -1
  85. package/out/renderer/browser-approvals-overlay.html +2 -2
  86. package/out/renderer/console-capture.html +6 -6
  87. package/out/renderer/index.html +8 -8
  88. package/out/renderer/installer.html +5 -5
  89. package/out/renderer/mini.html +8 -8
  90. package/package.json +2 -2
  91. package/out/renderer/assets/agents-page-CjRqlFDm.js +0 -14
  92. package/out/renderer/assets/browser-page-wS2--hNN.js +0 -1
  93. package/out/renderer/assets/channel-f8JO-5hx.js +0 -1
  94. package/out/renderer/assets/classDiagram-GIVACNV2-BJuCZKRI.js +0 -1
  95. package/out/renderer/assets/classDiagram-v2-COTLJTTW-BJuCZKRI.js +0 -1
  96. package/out/renderer/assets/clone-XTwsRjwN.js +0 -1
  97. package/out/renderer/assets/error-boundary-B7P_UC5N.js +0 -126
  98. package/out/renderer/assets/index-C5esWud7.css +0 -1
  99. package/out/renderer/assets/infoDiagram-PH2N3AL5-DU3xDGzm.js +0 -2
  100. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-B6wHUE5l.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-BTzCVYFd.js","./index-C_VKtNXE.js","./messages-CHMqznYC.js","./index-C5esWud7.css","./path-utils-qAYSdhvu.js","./error-boundary-B7P_UC5N.js","./index-LdCy3uKw.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-B10H6Sj9.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
2
- import{r as $,b as K,h as DPe,j as f,c as R,u as iC,g as Zn,G as Mae,i as VPe,H as jv,f as cn,t as ZE}from"./index-C_VKtNXE.js";import{aC as MPe,dC as lW,dD as LPe,dE as FPe,az as BPe,dF as HPe,dG as cW,dH as KPe,aA as Lae,u as Tl,aI as JPe,dI as e5e,dJ as t5e,F as hi,dK as aC,dL as n5e,dM as r5e,dN as i5e,B as Jp,$ as Fae,dO as a5e,dP as uW,dQ as o5e,dR as s5e,dS as l5e,G as Mn,dT as yn,ac as Rc,dU as G0,bx as c5e,dV as IE,b0 as Bae,b4 as Hae,aa as cu,dW as u5e,i as vt,r as Zr,n as O5e,a4 as Zi,a7 as uO,a as kr,c as Vn,q as fr,E as Ti,ab as d5e,d as qe,dX as Kae,h as _s,b8 as Jae,b6 as f5e,b7 as eoe,dd as h5e,a_ as p5e,a0 as Z0,x as kn,dY as m5e,dZ as g5e,d_ as $5e,cC as y5e,cN as v5e,d$ as b5e,e0 as w5e,e1 as x5e,e2 as S5e,e3 as Q5e,dt as k5e,cF as OW,cG as _5e,e4 as lQ,e5 as Mh,e6 as oC,e7 as P5e,e8 as dW,y as Gn,cy as pr,e9 as toe,ea as noe,cP as Aa,b3 as roe,eb as T5e,ec as X5e,ed as R5e,ee as E5e,ef as q5e,eg as P1,eh as ioe,ei as I0,ej as j5e,ek as fW,am as Xd,el as C5e,em as by,en as z5e,eo as A5e,ep as U5e,ak as Eu,eq as W5e,er as Y5e,es as N5e,bG as G5e,bE as Z5e,et as I5e,eu as Ps,ev as Ec,ew as vn,cX as cQ,bw as aoe,ex as D5e,ey as V5e,ez as ooe,eA as M5e,eB as L5e,eC as Fu,eD as sC,eE as F5e,eF as B5e,eG as H5e,eH as D0,eI as K5e,eJ as Ew,eK as J5e,eL as eTe,eM as DE,eN as tTe,eO as hW,eP as nTe,eQ as rTe,eR as iTe,eS as T1,eT as aTe,eU as oTe,eV as soe,eW as sTe,eX as lTe,eY as cTe,eZ as uTe,e_ as OTe,e$ as dTe,f0 as fTe,f1 as hTe,f2 as pTe,f3 as mTe,f4 as gTe,f5 as $Te,f6 as yTe,f7 as vTe,f8 as bTe,g as uQ,f9 as wTe,fa as loe,fb as xTe,fc as STe,fd as wy,fe as coe,ff as uoe,fg as QTe,fh as kTe,fi as _Te,fj as PTe,dn as TTe,e as lC,fk as XTe,dy as cC,fl as RTe,D as ETe,aw as qTe,o as jTe,fm as CTe,fn as zTe,fo as ATe,fp as UTe,fq as VE,fr as Ooe,fs as pW,ft as doe,fu as WTe,fv as mW,fw as YTe,fx as NTe,fy as GTe,fz as ZTe,fA as Cv,fB as gW,fC as ITe,fD as $W,fE as DTe,ay as yW,fF as vW,fG as VTe,fH as MTe,fI as bW,fJ as LTe,fK as wW,fL as FTe,au as BTe,bB as uC,bz as HTe,cI as foe,cH as hoe,a3 as V0,an as poe,fM as KTe,ap as moe,fN as JTe,fO as OC,fP as ME,fQ as e2e,bT as t2e,fR as n2e,ao as r2e,fS as i2e,fT as a2e,fU as o2e,b1 as s2e,fV as l2e,fW as OQ,cu as c2e,fX as u2e,C as O2e,fY as dQ,fZ as dC,f_ as d2e,aX as goe,f$ as M0,g0 as dc,g1 as f2e,g2 as h2e,g3 as p2e,cT as m2e,g4 as g2e,g5 as $2e,g6 as xW,g7 as y2e,g8 as tP,g9 as v2e,ga as b2e,gb as w2e,gc as x2e,gd as S2e,ge as Q2e,S as k2e,gf as _2e,by as SW,gg as LE,gh as FE}from"./path-utils-qAYSdhvu.js";import{al as P2e,c as Ae,az as T2e,aA as $oe,aB as X2e,aC as R2e,aD as E2e,aE as q2e,aF as j2e,aG as C2e,aH as Um,aI as z2e,B as ke,o as fC,p as hC,y as A2e,q as pC,F as U2e,v as $t,i as yoe,j as hl,C as va,b as voe,X as ti,k as W2e,u as Re,h as boe,l as X1,J as woe,T as Rd,am as BE,A as pl,S as yo,a5 as xy,G as xoe,D as mC,d as gC,e as $C,f as nl,a as r0,w as i0,au as yC,x as Ed,aJ as Y2e,a6 as N2e,a7 as G2e,a8 as Z2e,ah as I2e,aK as D2e,Z as V2e,M as M2e,N as L2e,O as F2e,K as Za,Q as Soe,R as Qoe,U as koe,V as _oe,W as HE,Y as B2e,z as KE,L as Poe,ay as H2e,g as so,$ as K2e,a0 as J2e,a1 as QW,a2 as kW,a3 as eXe,a4 as _W,aL as tXe,r as nXe,H as nP,I as PW,E as TW}from"./error-boundary-B7P_UC5N.js";import{c as em,t as m,L as cd}from"./messages-CHMqznYC.js";const XW=new Map,RW=new Map,EW=new Map;function vC(e){return e===void 0?"":JSON.stringify(e)}function bC(e,t){const n=`${e}\0${vC(t)}`;let r=XW.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),XW.set(n,r)),r}function rXe(e,t){const n=`${e}\0${vC(t)}`;let r=RW.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),RW.set(n,r)),r}function fQ(e,t,n){return bC(n??em(),t).format(e)}function hQ(e,t,n){return bC(n??em(),t).format(e)}function iXe(e,t,n){return bC(n??em(),t).format(e)}function Ts(e,t,n){return rXe(n??em(),t).format(e)}function Rtn(e,t,n,r){const i=r??em(),a=`${i}\0${vC(n)}`;let o=EW.get(a);return o===void 0&&(o=new Intl.RelativeTimeFormat(i,n),EW.set(a,o)),o.format(e,t)}const aXe=[{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"}],oXe={languages:aXe},qW=oXe.languages;function Toe(e){const t=e.trim();if(t==="")return{lang:"en",dir:"ltr"};const n=t.toLowerCase(),r=qW.find(o=>o.code.toLowerCase()===n),i=n.split("-")[0],a=r??qW.find(o=>o.code.split("-")[0].toLowerCase()===i);return{lang:r?.code??t,dir:a?.dir==="rtl"?"rtl":"ltr"}}function sXe(e){return Toe(e).dir}var lXe=class extends MPe{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:lW()})}getOptimisticResult(e){return e.behavior=lW(),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:FPe(t,n.data),hasPreviousPage:LPe(t,n.data),isFetchNextPageError:c,isFetchingNextPage:u,isFetchPreviousPageError:O,isFetchingPreviousPage:d,isRefetchError:s&&!c&&!O,isRefetching:a&&!u&&!d}}},cXe=class extends BPe{#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),HPe(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#e,observer:this}),n?.mutationKey&&this.options.mutationKey&&cW(n.mutationKey)!==cW(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??KPe();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){Lae.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 R1(e,t){const n=Tl(t),[r]=$.useState(()=>new cXe(n,e));$.useEffect(()=>{r.setOptions(e)},[r,e]);const i=$.useSyncExternalStore($.useCallback(o=>r.subscribe(Lae.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=$.useCallback((o,s)=>{r.mutate(o,s).catch(JPe)},[r]);if(i.error&&e5e(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function Xoe(e,t){return t5e(e,lXe,t)}const uXe=5e3;let Roe=0;function OXe(e=uXe){Roe=Date.now()+e}function qtn(e=Date.now()){return e<=Roe}function dXe(e){OXe(),e.invalidateQueries({queryKey:hi.capabilities})}function fXe(e,t){if(!e||typeof e!="object")return null;const n=e,r=n.artifacts;if(!hXe(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:Eoe(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 Eoe(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 aC({...e,billing_basis:n?.basis??e.billing_basis})}function rP(e){const t=e,n=Eoe(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 hXe(e){return"cost_complete"in e||["completed","failed","cancelled"].some(t=>t in e)}function pXe(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 mXe(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-BVf3_vkI.js","./index-DEnBt0Qi.js","./messages-CSKtFcP6.js","./index-N87yPCeX.css","./path-utils-CyEhREK0.js","./error-boundary-BgUrwH7u.js","./index-BQ-anM-O.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-Dkk1pdj8.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
2
+ import{r as $,b as K,h as DPe,j as f,c as R,u as iC,g as Zn,G as Mae,i as VPe,H as jv,f as cn,t as ZE}from"./index-DEnBt0Qi.js";import{aC as MPe,dC as lW,dD as LPe,dE as FPe,az as BPe,dF as HPe,dG as cW,dH as KPe,aA as Lae,u as Tl,aI as JPe,dI as e5e,dJ as t5e,F as hi,dK as aC,dL as n5e,dM as r5e,dN as i5e,B as Jp,$ as Fae,dO as a5e,dP as uW,dQ as o5e,dR as s5e,dS as l5e,G as Mn,dT as yn,ac as Rc,dU as G0,bx as c5e,dV as IE,b0 as Bae,b4 as Hae,aa as cu,dW as u5e,i as vt,r as Zr,n as O5e,a4 as Zi,a7 as uO,a as kr,c as Vn,q as fr,E as Ti,ab as d5e,d as qe,dX as Kae,h as _s,b8 as Jae,b6 as f5e,b7 as eoe,dd as h5e,a_ as p5e,a0 as Z0,x as kn,dY as m5e,dZ as g5e,d_ as $5e,cC as y5e,cN as v5e,d$ as b5e,e0 as w5e,e1 as x5e,e2 as S5e,e3 as Q5e,dt as k5e,cF as OW,cG as _5e,e4 as lQ,e5 as Mh,e6 as oC,e7 as P5e,e8 as dW,y as Gn,cy as pr,e9 as toe,ea as noe,cP as Aa,b3 as roe,eb as T5e,ec as X5e,ed as R5e,ee as E5e,ef as q5e,eg as P1,eh as ioe,ei as I0,ej as j5e,ek as fW,am as Xd,el as C5e,em as by,en as z5e,eo as A5e,ep as U5e,ak as Eu,eq as W5e,er as Y5e,es as N5e,bG as G5e,bE as Z5e,et as I5e,eu as Ps,ev as Ec,ew as vn,cX as cQ,bw as aoe,ex as D5e,ey as V5e,ez as ooe,eA as M5e,eB as L5e,eC as Fu,eD as sC,eE as F5e,eF as B5e,eG as H5e,eH as D0,eI as K5e,eJ as Ew,eK as J5e,eL as eTe,eM as DE,eN as tTe,eO as hW,eP as nTe,eQ as rTe,eR as iTe,eS as T1,eT as aTe,eU as oTe,eV as soe,eW as sTe,eX as lTe,eY as cTe,eZ as uTe,e_ as OTe,e$ as dTe,f0 as fTe,f1 as hTe,f2 as pTe,f3 as mTe,f4 as gTe,f5 as $Te,f6 as yTe,f7 as vTe,f8 as bTe,g as uQ,f9 as wTe,fa as loe,fb as xTe,fc as STe,fd as wy,fe as coe,ff as uoe,fg as QTe,fh as kTe,fi as _Te,fj as PTe,dn as TTe,e as lC,fk as XTe,dy as cC,fl as RTe,D as ETe,aw as qTe,o as jTe,fm as CTe,fn as zTe,fo as ATe,fp as UTe,fq as VE,fr as Ooe,fs as pW,ft as doe,fu as WTe,fv as mW,fw as YTe,fx as NTe,fy as GTe,fz as ZTe,fA as Cv,fB as gW,fC as ITe,fD as $W,fE as DTe,ay as yW,fF as vW,fG as VTe,fH as MTe,fI as bW,fJ as LTe,fK as wW,fL as FTe,au as BTe,bB as uC,bz as HTe,cI as foe,cH as hoe,a3 as V0,an as poe,fM as KTe,ap as moe,fN as JTe,fO as OC,fP as ME,fQ as e2e,bT as t2e,fR as n2e,ao as r2e,fS as i2e,fT as a2e,fU as o2e,b1 as s2e,fV as l2e,fW as OQ,cu as c2e,fX as u2e,C as O2e,fY as dQ,fZ as dC,f_ as d2e,aX as goe,f$ as M0,g0 as dc,g1 as f2e,g2 as h2e,g3 as p2e,cT as m2e,g4 as g2e,g5 as $2e,g6 as xW,g7 as y2e,g8 as tP,g9 as v2e,ga as b2e,gb as w2e,gc as x2e,gd as S2e,ge as Q2e,S as k2e,gf as _2e,by as SW,gg as LE,gh as FE}from"./path-utils-CyEhREK0.js";import{am as P2e,c as Ae,aA as T2e,aB as $oe,aC as X2e,aD as R2e,aE as E2e,aF as q2e,aG as j2e,aH as C2e,aI as Um,aJ as z2e,B as ke,o as fC,p as hC,y as A2e,q as pC,F as U2e,v as $t,i as yoe,j as hl,C as va,b as voe,X as ti,k as W2e,u as Re,h as boe,l as X1,J as woe,T as Rd,an as BE,A as pl,S as yo,a5 as xy,G as xoe,D as mC,d as gC,e as $C,f as nl,a as r0,w as i0,av as yC,x as Ed,aK as Y2e,a6 as N2e,a7 as G2e,a8 as Z2e,ai as I2e,aL as D2e,Z as V2e,M as M2e,N as L2e,O as F2e,K as Za,Q as Soe,R as Qoe,U as koe,V as _oe,W as HE,Y as B2e,z as KE,L as Poe,az as H2e,g as so,$ as K2e,a0 as J2e,a1 as QW,a2 as kW,a3 as eXe,a4 as _W,aM as tXe,r as nXe,H as nP,I as PW,E as TW}from"./error-boundary-BgUrwH7u.js";import{c as em,t as m,L as cd}from"./messages-CSKtFcP6.js";const XW=new Map,RW=new Map,EW=new Map;function vC(e){return e===void 0?"":JSON.stringify(e)}function bC(e,t){const n=`${e}\0${vC(t)}`;let r=XW.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),XW.set(n,r)),r}function rXe(e,t){const n=`${e}\0${vC(t)}`;let r=RW.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),RW.set(n,r)),r}function fQ(e,t,n){return bC(n??em(),t).format(e)}function hQ(e,t,n){return bC(n??em(),t).format(e)}function iXe(e,t,n){return bC(n??em(),t).format(e)}function Ts(e,t,n){return rXe(n??em(),t).format(e)}function Rtn(e,t,n,r){const i=r??em(),a=`${i}\0${vC(n)}`;let o=EW.get(a);return o===void 0&&(o=new Intl.RelativeTimeFormat(i,n),EW.set(a,o)),o.format(e,t)}const aXe=[{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"}],oXe={languages:aXe},qW=oXe.languages;function Toe(e){const t=e.trim();if(t==="")return{lang:"en",dir:"ltr"};const n=t.toLowerCase(),r=qW.find(o=>o.code.toLowerCase()===n),i=n.split("-")[0],a=r??qW.find(o=>o.code.split("-")[0].toLowerCase()===i);return{lang:r?.code??t,dir:a?.dir==="rtl"?"rtl":"ltr"}}function sXe(e){return Toe(e).dir}var lXe=class extends MPe{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:lW()})}getOptimisticResult(e){return e.behavior=lW(),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:FPe(t,n.data),hasPreviousPage:LPe(t,n.data),isFetchNextPageError:c,isFetchingNextPage:u,isFetchPreviousPageError:O,isFetchingPreviousPage:d,isRefetchError:s&&!c&&!O,isRefetching:a&&!u&&!d}}},cXe=class extends BPe{#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),HPe(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#e,observer:this}),n?.mutationKey&&this.options.mutationKey&&cW(n.mutationKey)!==cW(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??KPe();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){Lae.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 R1(e,t){const n=Tl(t),[r]=$.useState(()=>new cXe(n,e));$.useEffect(()=>{r.setOptions(e)},[r,e]);const i=$.useSyncExternalStore($.useCallback(o=>r.subscribe(Lae.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=$.useCallback((o,s)=>{r.mutate(o,s).catch(JPe)},[r]);if(i.error&&e5e(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function Xoe(e,t){return t5e(e,lXe,t)}const uXe=5e3;let Roe=0;function OXe(e=uXe){Roe=Date.now()+e}function qtn(e=Date.now()){return e<=Roe}function dXe(e){OXe(),e.invalidateQueries({queryKey:hi.capabilities})}function fXe(e,t){if(!e||typeof e!="object")return null;const n=e,r=n.artifacts;if(!hXe(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:Eoe(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 Eoe(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 aC({...e,billing_basis:n?.basis??e.billing_basis})}function rP(e){const t=e,n=Eoe(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 hXe(e){return"cost_complete"in e||["completed","failed","cancelled"].some(t=>t in e)}function pXe(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 mXe(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 gXe(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 wC="generate_video",xC="generate_voiceover",SC="generate_sound_effect",$Xe=new Set(["generate_image",wC,xC,SC]);function qoe(e){return $Xe.has(e)}function yXe(e){return e===wC}function vXe(e){return e===xC||e===SC}function bXe(e){return e===wC?"video":e===xC?"voiceover":e===SC?"sound-effect":"image"}const jW="Stopped before the provider was called; you will not be charged.",JE="Stop requested. The provider has no cancellation endpoint; the generation continues and will be charged if it produces audio. Checking for settlement.",wXe="Audio generation is busy right now. Wait a moment and try again.";function hh(e){switch(e){case"video":return"video";case"voiceover":return"voiceover";case"sound-effect":return"sound effect";default:return"image"}}function xXe(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 SXe(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:xXe(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 CW(e){return e.fraction===null&&e.logs.length===0&&e.queuePosition===null?joe:{fraction:e.fraction,logs:e.logs,queuePosition:e.queuePosition}}const joe=Object.freeze({fraction:null,logs:[],queuePosition:null});function QXe(e,{stopping:t=!1,settled:n=!1}={}){const r=SXe(e.details),i=bXe(e.toolName),a=i==="voiceover"||i==="sound-effect",o=a&&e.phase==="done"?fXe(e.details,e.images??[]):null,s=a?gXe(e.args,e.details):null,l=o?{batch:o,batchSummary:pXe(e.details,o),batchNote:mXe(e.details,e.output)}:{},c=a?PXe(e.details):null;if(e.stopped===!0)return{state:"cancelled",generating:e.startedAt!==null,message:r.error??e.output,...o?{...l,material:i,costCaption:rP(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?iP(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:iP(r.errorType,r.error??e.output),...l,costCaption:rP(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"?wXe:null),errorType:a?iP(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:joe}:{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:CW(r)}:{state:"running",material:i,startedAtMs:u,progress:CW(r),note:r.error,...s?{batchProgress:s}:{}}}case"done":{const u=a?aC(e.details,e.output):null;return{state:"done",images:e.images??[],material:i,durationS:e.durationS??null,receipt:"generated",batch:o,...l,costCaption:o?rP(e.details):u}}}}const kXe=/\s*Checking for settlement\.?\s*$/;function _Xe(e){return e.replace(kXe,"").trimEnd()}function PXe(e){if(!e||typeof e!="object")return null;const t=e,n=t.cost;return t.settled===!0?aC(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 iP(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 TXe(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 XXe(e,t){if(!yXe(e))return t?{onCancel:t}:void 0}function RXe(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 EXe=e=>{switch(e){case"success":return CXe;case"info":return AXe;case"warning":return zXe;case"error":return UXe;default:return null}},qXe=Array(12).fill(0),jXe=({visible:e,className:t})=>K.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},K.createElement("div",{className:"sonner-spinner"},qXe.map((n,r)=>K.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),CXe=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"})),zXe=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"})),AXe=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"})),UXe=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"})),WXe=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"})),YXe=()=>{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 eq=1;class NXe{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:eq++,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(ZXe(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||eq++;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 qa=new NXe,GXe=(e,t)=>{const n=t?.id||eq++;return qa.addToast({title:e,...t,id:n}),n},ZXe=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",IXe=GXe,DXe=()=>qa.toasts,VXe=()=>qa.getActiveToasts(),nf=Object.assign(IXe,{success:qa.success,info:qa.info,warning:qa.warning,error:qa.error,custom:qa.custom,message:qa.message,promise:qa.promise,dismiss:qa.dismiss,loading:qa.loading},{getHistory:DXe,getToasts:VXe});RXe("[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 zv(e){return e.label!==void 0}const MXe=3,LXe="24px",FXe="16px",zW=4e3,BXe=356,HXe=14,KXe=45,JXe=200;function Ns(...e){return e.filter(Boolean).join(" ")}function eRe(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const tRe=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:T,className:X="",descriptionClassName:E="",duration:j,position:U,gap:C,expandByDefault:G,classNames:Y,icons:W,closeButtonAriaLabel:Z="Close toast"}=e,[V,A]=K.useState(null),[I,J]=K.useState(null),[N,te]=K.useState(!1),[B,ee]=K.useState(!1),[le,F]=K.useState(!1),[L,ne]=K.useState(!1),[ue,oe]=K.useState(!1),[ve,ye]=K.useState(0),[Qe,Ee]=K.useState(0),ze=K.useRef(O.duration||j||zW),he=K.useRef(null),_e=K.useRef(null),Ke=v===0,rt=v+1<=g,dt=O.type,de=O.dismissible!==!1,Pe=O.className||"",xe=O.descriptionClassName||"",ie=K.useMemo(()=>y.findIndex(St=>St.toastId===O.id)||0,[y,O.id]),pe=K.useMemo(()=>{var St;return(St=O.closeButton)!=null?St:S},[O.closeButton,S]),we=K.useMemo(()=>O.duration||j||zW,[O.duration,j]),et=K.useRef(0),Ye=K.useRef(0),It=K.useRef(0),yt=K.useRef(null),[Ht,Me]=U.split("-"),Rt=K.useMemo(()=>y.reduce((St,In,Un)=>Un>=ie?St:St+In.height,0),[y,ie]),xt=YXe(),jt=O.invert||u,er=dt==="loading";Ye.current=K.useMemo(()=>ie*C+Rt,[ie,Rt]),K.useEffect(()=>{ze.current=we},[we]),K.useEffect(()=>{te(!0)},[]),K.useEffect(()=>{const St=_e.current;if(St){const In=St.getBoundingClientRect().height;return Ee(In),p(Un=>[{toastId:O.id,height:In,position:O.position},...Un]),()=>p(Un=>Un.filter(br=>br.toastId!==O.id))}},[p,O.id]),K.useLayoutEffect(()=>{if(!N)return;const St=_e.current,In=St.style.height;St.style.height="auto";const Un=St.getBoundingClientRect().height;St.style.height=In,Ee(Un),p(br=>br.find(cr=>cr.toastId===O.id)?br.map(cr=>cr.toastId===O.id?{...cr,height:Un}:cr):[{toastId:O.id,height:Un,position:O.position},...br])},[N,O.title,O.description,p,O.id]);const Rn=K.useCallback(()=>{ee(!0),ye(Ye.current),p(St=>St.filter(In=>In.toastId!==O.id)),setTimeout(()=>{Q(O)},JXe)},[O,Q,p,Ye]);K.useEffect(()=>{if(O.promise&&dt==="loading"||O.duration===1/0||O.type==="loading")return;let St;return x||h||xt?(()=>{if(It.current<et.current){const br=new Date().getTime()-et.current;ze.current=ze.current-br}It.current=new Date().getTime()})():(()=>{ze.current!==1/0&&(et.current=new Date().getTime(),St=setTimeout(()=>{O.onAutoClose==null||O.onAutoClose.call(O,O),Rn()},ze.current))})(),()=>clearTimeout(St)},[x,h,O,dt,xt,Rn]),K.useEffect(()=>{O.delete&&Rn()},[Rn,O.delete]);function Le(){var St;if(W?.loading){var In;return K.createElement("div",{className:Ns(Y?.loader,O==null||(In=O.classNames)==null?void 0:In.loader,"sonner-loader"),"data-visible":dt==="loading"},W.loading)}return K.createElement(jXe,{className:Ns(Y?.loader,O==null||(St=O.classNames)==null?void 0:St.loader),visible:dt==="loading"})}const ht=O.icon||W?.[dt]||EXe(dt);var Lt,ii;return K.createElement("li",{tabIndex:0,ref:_e,className:Ns(X,Pe,Y?.toast,O==null||(t=O.classNames)==null?void 0:t.toast,Y?.default,Y?.[dt],O==null||(n=O.classNames)==null?void 0:n[dt]),"data-sonner-toast":"","data-rich-colors":(Lt=O.richColors)!=null?Lt:w,"data-styled":!(O.jsx||O.unstyled||d),"data-mounted":N,"data-promise":!!O.promise,"data-swiped":ue,"data-removed":B,"data-visible":rt,"data-y-position":Ht,"data-x-position":Me,"data-index":v,"data-front":Ke,"data-swiping":le,"data-dismissible":de,"data-type":dt,"data-invert":jt,"data-swipe-out":L,"data-swipe-direction":I,"data-expanded":!!(x||G&&N),style:{"--index":v,"--toasts-before":v,"--z-index":b.length-v,"--offset":`${B?ve:Ye.current}px`,"--initial-height":G?"auto":`${Qe}px`,...k,...O.style},onDragEnd:()=>{F(!1),A(null),yt.current=null},onPointerDown:St=>{er||!de||(he.current=new Date,ye(Ye.current),St.target.setPointerCapture(St.pointerId),St.target.tagName!=="BUTTON"&&(F(!0),yt.current={x:St.clientX,y:St.clientY}))},onPointerUp:()=>{var St,In,Un;if(L||!de)return;yt.current=null;const br=Number(((St=_e.current)==null?void 0:St.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),wo=Number(((In=_e.current)==null?void 0:In.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),cr=new Date().getTime()-((Un=he.current)==null?void 0:Un.getTime()),jr=V==="x"?br:wo,la=Math.abs(jr)/cr;if(Math.abs(jr)>=KXe||la>.11){ye(Ye.current),O.onDismiss==null||O.onDismiss.call(O,O),J(V==="x"?br>0?"right":"left":wo>0?"down":"up"),Rn(),ne(!0);return}else{var Qt,Ft;(Qt=_e.current)==null||Qt.style.setProperty("--swipe-amount-x","0px"),(Ft=_e.current)==null||Ft.style.setProperty("--swipe-amount-y","0px")}oe(!1),F(!1),A(null)},onPointerMove:St=>{var In,Un,br;if(!yt.current||!de||((In=window.getSelection())==null?void 0:In.toString().length)>0)return;const cr=St.clientY-yt.current.y,jr=St.clientX-yt.current.x;var la;const Qt=(la=e.swipeDirections)!=null?la:eRe(U);!V&&(Math.abs(jr)>1||Math.abs(cr)>1)&&A(Math.abs(jr)>Math.abs(cr)?"x":"y");let Ft={x:0,y:0};const Ei=En=>1/(1.5+Math.abs(En)/20);if(V==="y"){if(Qt.includes("top")||Qt.includes("bottom"))if(Qt.includes("top")&&cr<0||Qt.includes("bottom")&&cr>0)Ft.y=cr;else{const En=cr*Ei(cr);Ft.y=Math.abs(En)<Math.abs(cr)?En:cr}}else if(V==="x"&&(Qt.includes("left")||Qt.includes("right")))if(Qt.includes("left")&&jr<0||Qt.includes("right")&&jr>0)Ft.x=jr;else{const En=jr*Ei(jr);Ft.x=Math.abs(En)<Math.abs(jr)?En:jr}(Math.abs(Ft.x)>0||Math.abs(Ft.y)>0)&&oe(!0),(Un=_e.current)==null||Un.style.setProperty("--swipe-amount-x",`${Ft.x}px`),(br=_e.current)==null||br.style.setProperty("--swipe-amount-y",`${Ft.y}px`)}},pe&&!O.jsx&&dt!=="loading"?K.createElement("button",{"aria-label":Z,"data-disabled":er,"data-close-button":!0,onClick:er||!de?()=>{}:()=>{Rn(),O.onDismiss==null||O.onDismiss.call(O,O)},className:Ns(Y?.closeButton,O==null||(r=O.classNames)==null?void 0:r.closeButton)},(ii=W?.close)!=null?ii:WXe):null,(dt||O.icon||O.promise)&&O.icon!==null&&(W?.[dt]!==null||O.icon)?K.createElement("div",{"data-icon":"",className:Ns(Y?.icon,O==null||(i=O.classNames)==null?void 0:i.icon)},O.promise||O.type==="loading"&&!O.icon?O.icon||Le():null,O.type!=="loading"?ht:null):null,K.createElement("div",{"data-content":"",className:Ns(Y?.content,O==null||(a=O.classNames)==null?void 0:a.content)},K.createElement("div",{"data-title":"",className:Ns(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:Ns(E,xe,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&&zv(O.cancel)?K.createElement("button",{"data-button":!0,"data-cancel":!0,style:O.cancelButtonStyle||P,onClick:St=>{zv(O.cancel)&&de&&(O.cancel.onClick==null||O.cancel.onClick.call(O.cancel,St),Rn())},className:Ns(Y?.cancelButton,O==null||(l=O.classNames)==null?void 0:l.cancelButton)},O.cancel.label):null,K.isValidElement(O.action)?O.action:O.action&&zv(O.action)?K.createElement("button",{"data-button":!0,"data-action":!0,style:O.actionButtonStyle||T,onClick:St=>{zv(O.action)&&(O.action.onClick==null||O.action.onClick.call(O.action,St),!St.defaultPrevented&&Rn())},className:Ns(Y?.actionButton,O==null||(c=O.classNames)==null?void 0:c.actionButton)},O.action.label):null)};function AW(){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 nRe(e,t){const n={};return[e,t].forEach((r,i)=>{const a=i===1,o=a?"--mobile-offset":"--offset",s=a?FXe:LXe;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 rRe=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=MXe,toastOptions:y,dir:v=AW(),gap:b=HXe,icons:x,containerAriaLabel:Q="Notifications"}=t,[w,S]=K.useState([]),k=K.useMemo(()=>Array.from(new Set([i].concat(w.filter(I=>I.position).map(I=>I.position)))),[w,i]),[P,T]=K.useState([]),[X,E]=K.useState(!1),[j,U]=K.useState(!1),[C,G]=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),V=K.useRef(!1),A=K.useCallback(I=>{S(J=>{var N;return(N=J.find(te=>te.id===I.id))!=null&&N.delete||qa.dismiss(I.id),J.filter(({id:te})=>te!==I.id)})},[]);return K.useEffect(()=>qa.subscribe(I=>{if(I.dismiss){requestAnimationFrame(()=>{S(J=>J.map(N=>N.id===I.id?{...N,delete:!0}:N))});return}setTimeout(()=>{P2e.flushSync(()=>{S(J=>{const N=J.findIndex(te=>te.id===I.id);return N!==-1?[...J.slice(0,N),{...J[N],...I},...J.slice(N+1)]:[I,...J]})})})}),[w]),K.useEffect(()=>{if(O!=="system"){G(O);return}if(O==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?G("dark"):G("light")),typeof window>"u")return;const I=window.matchMedia("(prefers-color-scheme: dark)");try{I.addEventListener("change",({matches:J})=>{G(J?"dark":"light")})}catch{I.addListener(({matches:N})=>{try{G(N?"dark":"light")}catch(te){console.error(te)}})}},[O]),K.useEffect(()=>{w.length<=1&&E(!1)},[w]),K.useEffect(()=>{const I=J=>{var N;if(a.every(ee=>J[ee]||J.code===ee)){var B;E(!0),(B=Y.current)==null||B.focus()}J.code==="Escape"&&(document.activeElement===Y.current||(N=Y.current)!=null&&N.contains(document.activeElement))&&E(!1)};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[a]),K.useEffect(()=>{if(Y.current)return()=>{Z.current&&(Z.current.focus({preventScroll:!0}),Z.current=null,V.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((I,J)=>{var N;const[te,B]=I.split("-");return w.length?K.createElement("ol",{key:I,dir:v==="auto"?AW():v,tabIndex:-1,ref:Y,className:l,"data-sonner-toaster":!0,"data-sonner-theme":C,"data-y-position":te,"data-lifted":X&&w.length>1&&!o,"data-x-position":B,style:{"--front-toast-height":`${((N=P[0])==null?void 0:N.height)||0}px`,"--width":`${BXe}px`,"--gap":`${b}px`,...p,...nRe(c,u)},onBlur:ee=>{V.current&&!ee.currentTarget.contains(ee.relatedTarget)&&(V.current=!1,Z.current&&(Z.current.focus({preventScroll:!0}),Z.current=null))},onFocus:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||V.current||(V.current=!0,Z.current=ee.relatedTarget)},onMouseEnter:()=>E(!0),onMouseMove:()=>E(!0),onMouseLeave:()=>{j||E(!1)},onDragEnd:()=>E(!1),onPointerDown:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||U(!0)},onPointerUp:()=>U(!1)},w.filter(ee=>!ee.position&&J===0||ee.position===I).map((ee,le)=>{var F,L;return K.createElement(tRe,{key:ee.id,icons:x,index:le,toast:ee,defaultRichColors:d,duration:(F=y?.duration)!=null?F:h,className:y?.className,descriptionClassName:y?.descriptionClassName,invert:r,visibleToasts:g,closeButton:(L=y?.closeButton)!=null?L:s,interacting:j,position:I,style:y?.style,unstyled:y?.unstyled,classNames:y?.classNames,cancelButtonStyle:y?.cancelButtonStyle,actionButtonStyle:y?.actionButtonStyle,closeButtonAriaLabel:y?.closeButtonAriaLabel,removeToast:A,toasts:w.filter(ne=>ne.position==ee.position),heights:P.filter(ne=>ne.position==ee.position),setHeights:T,expandByDefault:o,gap:b,expanded:X,swipeDirections:t.swipeDirections})})):null}))}),iRe=["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"],aRe=["ENOTFOUND","EAI_AGAIN","ETIMEDOUT","ECONNRESET","ECONNREFUSED","EHOSTUNREACH","ENETUNREACH","ENETDOWN","ENETRESET","ECONNABORTED","EPIPE"],oRe=["Failed to fetch","Load failed","NetworkError when attempting to fetch resource."],sRe=new Set(iRe),lRe=/[:\-\u2014\n]$/,cRe=/^[:\n]/,UW=/[:\uff1a\n\u2014]| - /g,uRe=/^(?:\s*Error:\s*)+/,ORe=/:\s+Error:\s+/g,dRe=/\b(?:net::)?(ERR_[A-Z0-9_]+)\b/g,fRe=aRe.map(e=>({code:e,pattern:new RegExp(`\\b${e}\\b`)}));function aP(e,t,n){const r=e.slice(0,t).trimEnd(),i=e.slice(t+n).trimStart(),a=r===""||lRe.test(r),o=i===""||cRe.test(i);return a&&o}function Coe(e){const t=pRe(e);if(!t)return null;const n=zoe(t);for(const r of n.matchAll(dRe)){const i=r[1];if(!sRe.has(i))continue;const a=r.index??0,o=a+r[0].length;return{code:`net::${i}`,start:a,end:o,clauseText:oP(n,a,o),clause:aP(n,a,o-a)}}for(const{code:r,pattern:i}of fRe){const a=i.exec(n);if(a){const o=a.index,s=o+a[0].length;return{code:r,start:o,end:s,clauseText:oP(n,o,s),clause:aP(n,o,s-o)}}}for(const r of oRe){const i=n.indexOf(r);if(i!==-1&&aP(n,i,r.length))return{code:r,start:i,end:i+r.length,clauseText:oP(n,i,i+r.length),clause:!0}}return null}function hRe(e){return Coe(e)?.code??null}function jtn(e){return hRe(e)!==null}function pRe(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 oP(e,t,n){let r=0;for(const a of e.slice(0,t).matchAll(UW))r=(a.index??0)+a[0].length;let i=e.length;for(const a of e.slice(n).matchAll(UW)){i=n+(a.index??0);break}return e.slice(r,i).trim()}function zoe(e){return e.replace(uRe,"").replace(ORe,": ")}const Wm=new Map,sP=new Map,lP=new Map,WW=5e3,mRe=1,gRe={CONNECTION:["Failed to fetch","Network error","ERR_CONNECTION_REFUSED","Server is offline","Connection failed"]},$Re={"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},cP=()=>m("ui.common.connection.transport_failure"),Aoe=e=>{const t=e.trim();if(Object.prototype.hasOwnProperty.call($Re,t))return cP();const n=zoe(t),r=Coe(n);return r===null?e:r.clause?`${n.slice(0,r.start)}${cP()}${n.slice(r.end)}`:cP()},yRe=e=>{for(const[t,n]of Object.entries(gRe))if(n.some(r=>e.includes(r)))return t;return null},Ctn=(e,t)=>nf.loading(e,t),Er=(e,t)=>{const n=Date.now(),i=yRe(e)||e,a=Aoe(e),o=sP.get(i);if(o&&n-o<WW)return null;const s=lP.get(i)||0;if(s>=mRe)return null;if(Wm.has(i))return sP.set(i,n),Wm.get(i);const l=nf.error(a,{...t,onDismiss:c=>{Wm.delete(i),t?.onDismiss?.(c)},onAutoClose:c=>{Wm.delete(i),t?.onAutoClose?.(c)}});return Wm.set(i,l),sP.set(i,n),lP.set(i,s+1),setTimeout(()=>{lP.set(i,0)},WW),l},ztn=(e,t)=>nf.error(Aoe(e),t),ml=(e,t)=>nf.info(e,t),a0=e=>{nf.dismiss(e)},Bu=(e,t)=>nf.success(e,t),sh=(e,t)=>nf.warning(e,t),vRe={"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}}},bRe={dark:.09,light:.12},wRe={dark:{role:"sunken",scale:.73},light:{role:"surface",scale:.72}},xRe={dark:.91,light:.78},SRe={"under-window":{dark:.15,light:.2},menu:{dark:.15,light:.2},popover:{dark:.15,light:.15}},QRe={hover:.05,selected:.08,field:.05,work:.08},Fs={alphaFloor:vRe,blockVeil:bRe,laneWash:wRe,bandFloor:xRe,controlMix:SRe,stateAlpha:QRe},Atn=["sidebars","full"],Uoe=(e,t)=>e!=="vibrancy"?"popover":t==="menu"?"menu":t==="popover"?"popover":"under-window",kRe=.96,Woe=e=>Math.round(e*100)/100;function _Re(e,t,n){const r=Fs.alphaFloor[Uoe(e,t)][n];return{canvas:r.canvas,surface:r.surface,elevated:r.elevated}}function PRe(e){const t=Math.min(100,Math.max(0,e.intensity))/100,n=_Re(e.mechanism,e.material,e.scheme),r=i=>{const a=Math.max(kRe,i);return Woe(a-t*(a-i))};return{canvas:r(n.canvas),surface:r(n.surface),elevated:r(n.elevated)}}const TRe={sidebars:["sidebar"],full:["sidebar","canvas","pane"]};function XRe(e,t,n){return Fs.controlMix[Uoe(e,t)][n]}function RRe(e){const t=PRe(e),n=i=>Woe(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(Fs.stateAlpha.hover),"--lo-glass-a-row-selected":String(Fs.stateAlpha.selected),"--lo-glass-a-row-work":String(Fs.stateAlpha.work),"--lo-glass-a-field":String(Fs.stateAlpha.field),"--lo-glass-a-block-veil":String(Fs.blockVeil[e.scheme]),"--lo-glass-a-band-floor":String(Fs.bandFloor[e.scheme]),"--lo-glass-a-lane":String(Math.round(t.canvas*Fs.laneWash[e.scheme].scale*100)/100),"--lo-glass-lane-tone":Fs.laneWash[e.scheme].role==="sunken"?"var(--lo-sunken)":"var(--lo-surface)","--lo-glass-control-mix":String(XRe(e.mechanism,e.material,e.scheme)),"--lo-glass-in-surface":String(n(t.surface)),"--lo-glass-in-elevated":String(n(t.elevated))};return{kinds:TRe[e.coverage].join(" "),vars:r}}const Yoe=()=>document.documentElement,ERe=["--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 qw=null;const E1=()=>Yoe().classList.contains("dark")?"dark":"light";function q1(e){qw=e;const t=Yoe();if(!e||!e.active){delete t.dataset.glass;for(const i of ERe)t.style.removeProperty(i);return}const{kinds:n,vars:r}=RRe({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 Utn(e){q1(e?{active:!0,scheme:e.scheme,mechanism:e.mechanism,settings:{coverage:e.coverage,intensity:e.intensity,material:e.material}}:null)}function tq(e){if(!e||!e.active||e.capability.mechanism==="none"){q1(null);return}e.restartRequired&&e.active||q1({active:!0,scheme:E1(),mechanism:e.capability.mechanism,settings:{coverage:e.settings.coverage,intensity:e.settings.intensity,material:e.settings.material}})}function Wtn(){!qw||!qw.active||(q1({...qw,scheme:E1()}),window.api?.windowGlass?.reportScheme?.(E1()))}function Ytn(){const e=window.api?.windowGlass;if(!e)return()=>{};const t=e.onState(r=>tq(r)),n=r=>{r&&tq(r)};return typeof CSS<"u"&&e.reportRenderer?.({backdropFilter:CSS.supports("backdrop-filter: blur(1px)")}).then(n,()=>{}),e.get?.().then(n,()=>{}),t}function Ntn(){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),tq(i),window.api?.windowGlass?.reportScheme?.(E1()))}}}const qRe=function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"}(),jRe=function(e,t){return new URL(e,t).href},YW={},$e=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=jRe(c,r),c in YW)return;YW[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":qRe,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
  *
@@ -819,7 +819,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
819
819
  `))};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=Ze.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));u.main.eq(i)||t.dispatch({selection:u,userEvent:"select"});return}if((st.mac||st.android)&&c.from==o-1&&/^\. ?$/.test(r.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:s,to:l,insert:zn.of([r.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);Q9(t,c,Ze.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(en.mark({attributes:{style:u}}).range(l,c))}}}t.dispatch({effects:Cfe.of(en.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=O$(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 bt{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||IFe(t.parent)||document,this.viewState=new uI(t.state||_n.create(t)),t.scrollTo&&t.scrollTo.is(cb)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(gh).map(i=>new S5(i));for(let i of this.plugins)i.update(this);this.observer=new lHe(this),this.inputState=new RBe(this),this.inputState.ensureHandlers(this.plugins),this.docView=new DZ(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 Ni?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(Lfe))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=Ffe(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(_n.phrases)!=this.state.facet(_n.phrases))return this.setState(a);i=sx.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 qh(h.empty?h:Ze.cursor(h.head,h.head>h.anchor?-1:1))}for(let h of d.effects)h.is(cb)&&(O=h.value.clip(this.state))}this.viewState.update(i,O),this.bidiCache=cx.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Yg)!=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(pb)!=i.state.facet(pb)&&(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(E3))try{d(i)}catch(h){Wa(this.state,h,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!Gfe(this,u)&&c.force&&Eh(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 uI(t),this.plugins=t.facet(gh).map(r=>new S5(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new DZ(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(gh),r=t.state.facet(gh);if(n!=r){let i=[];for(let a of r){let o=n.indexOf(a);if(o<0)i.push(new S5(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){Wa(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(cfe(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 Wa(this.state,p),hI}}),O=sx.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]!=hI)try{let p=c[h];p.write&&p.write(u[h],this)}catch(p){Wa(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(E3))s(n)}get themeClasses(){return A3+" "+(this.state.facet(z3)?Jfe:Kfe)+" "+this.state.facet(pb)}updateAttrs(){let t=pI(this,zfe,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(uc)?"true":"false",class:"cm-content",style:`${st.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),pI(this,w9,n);let r=this.observer.ignore(()=>{let i=_3(this.contentDOM,this.contentAttrs,n),a=_3(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(bt.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(Yg);let t=this.state.facet(bt.cspNonce);iO.mount(this.root,this.styleModules.concat(oHe).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 k5(this,t,BZ(this,t,n,r))}moveByGroup(t,n){return k5(this,t,BZ(this,t,n,r=>wBe(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 Ze.cursor(a.side(n,i)+t.from,a.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return bBe(this,t,n,r)}moveVertically(t,n,r){return k5(this,t,xBe(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(),Nfe(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[zu.find(a,t-i.from,-1,n)];return Wy(r,o.dir==mr.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(Efe)||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>OHe)return Sfe(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||xfe(a.isolates,r=IZ(this,t))))return a.order;r||(r=IZ(this,t));let i=aBe(t.text,n,r);return this.bidiCache.push(new cx(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||st.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{sfe(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 cb.of(new qh(typeof t=="number"?Ze.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 cb.of(new qh(Ze.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 yi.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return yi.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=iO.newName(),i=[pb.of(r),Yg.of(U3(`.${r}`,t))];return n&&n.dark&&i.push(z3.of(!0)),i}static baseTheme(t){return mO.lowest(Yg.of(U3("."+A3,t,ehe)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&Bn.get(r)||Bn.get(t);return((n=i?.rootView)===null||n===void 0?void 0:n.view)||null}}bt.styleModule=Yg;bt.inputHandler=Xfe;bt.clipboardInputFilter=v9;bt.clipboardOutputFilter=b9;bt.scrollHandler=jfe;bt.focusChangeEffect=Rfe;bt.perLineTextDirection=Efe;bt.exceptionSink=Tfe;bt.updateListener=E3;bt.editable=uc;bt.mouseSelectionStyle=Pfe;bt.dragMovesSelection=_fe;bt.clickAddsSelectionRange=kfe;bt.decorations=d$;bt.outerDecorations=Afe;bt.atomicRanges=x9;bt.bidiIsolatedRanges=Ufe;bt.scrollMargins=Wfe;bt.darkTheme=z3;bt.cspNonce=Ot.define({combine:e=>e.length?e[0]:""});bt.contentAttributes=w9;bt.editorAttributes=zfe;bt.lineWrapping=bt.contentAttributes.of({class:"cm-lineWrapping"});bt.announce=pn.define();const OHe=4096,hI={};class cx{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:mr.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 cx(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}}function pI(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&&k3(o,n)}return n}const dHe=st.mac?"mac":st.windows?"win":st.linux?"linux":"key";function fHe(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 mb(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 hHe=mO.default(bt.domEventHandlers({keydown(e,t){return nhe(the(t.state),e,t,"editor")}})),FQ=Ot.define({enables:hHe}),mI=new WeakMap;function the(e){let t=e.facet(FQ),n=mI.get(t);return n||mI.set(t,n=mHe(t.reduce((r,i)=>r.concat(i),[]))),n}function win(e,t,n){return nhe(the(e.state),t,e,n)}let Xu=null;const pHe=4e3;function mHe(e,t=dHe){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=>fHe(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=Xu={view:x,prefix:b,scope:o};return setTimeout(()=>{Xu==Q&&(Xu=null)},pHe),!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,W3))}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 W3=null;function nhe(e,t,n,r){W3=t;let i=WFe(t),a=co(i,0),o=cc(a)==i.length&&i!=" ",s="",l=!1,c=!1,u=!1;Xu&&Xu.view==n&&Xu.scope==r&&(s=Xu.prefix+" ",Ife.indexOf(t.keyCode)<0&&(c=!0,Xu=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+mb(i,t,!o)])?l=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(st.windows&&t.ctrlKey&&t.altKey)&&(p=aO[t.keyCode])&&p!=i?(d(h[s+mb(p,t,!0)])||t.shiftKey&&(g=u$[t.keyCode])!=i&&g!=p&&d(h[s+mb(g,t,!1)]))&&(l=!0):o&&t.shiftKey&&d(h[s+mb(i,t,!0)])&&(l=!0),!l&&d(h._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),W3=null,l}class Gy{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=rhe(t);return[new Gy(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return gHe(t,n,r)}}function rhe(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==mr.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function gI(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 gHe(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==mr.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),l=rhe(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=j3(e,r,1),p=j3(e,i,-1),g=h.type==wa.Text?h:null,y=p.type==wa.Text?p:null;if(g&&(e.lineWrapping||h.widgetLineBreaks)&&(g=gI(e,r,1,g)),y&&(e.lineWrapping||p.widgetLineBreaks)&&(y=gI(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==wa.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 Gy(t,w-l.left,S-l.top,k-w,P-S)}function b({top:w,bottom:S,horizontal:k}){let P=[];for(let T=0;T<k.length;T+=2)P.push(v(k[T],w,k[T+1],S));return P}function x(w,S,k){let P=1e9,T=-1e9,X=[];function E(C,G,Y,W,Z){let V=e.coordsAtPos(C,C==k.to?-2:2),A=e.coordsAtPos(Y,Y==k.from?2:-2);!V||!A||(P=Math.min(V.top,A.top,P),T=Math.max(V.bottom,A.bottom,T),Z==mr.LTR?X.push(a&&G?O:V.left,a&&W?d:A.right):X.push(!a&&W?O:A.left,!a&&G?d:V.right))}let j=w??k.from,U=S??k.to;for(let C of e.visibleRanges)if(C.to>j&&C.from<U)for(let G=Math.max(C.from,j),Y=Math.min(C.to,U);;){let W=e.state.doc.lineAt(G);for(let Z of e.bidiSpans(W)){let V=Z.from+W.from,A=Z.to+W.from;if(V>=Y)break;A>G&&E(Math.max(V,G),w==null&&V<=j,Math.min(A,Y),S==null&&A>=U,Z.dir)}if(G=W.to+1,G>=Y)break}return X.length==0&&E(j,w==null,U,S==null,e.textDirection),{top:P,bottom:T,horizontal:X}}function Q(w,S){let k=s.top+(S?w.top:w.bottom);return{top:k,bottom:k,horizontal:[]}}}function $He(e,t){return e.constructor==t.constructor&&e.eq(t)}class yHe{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(Bw)!=t.state.facet(Bw)&&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(Bw);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)=>!$He(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 Bw=Ot.define();function ihe(e){return[yi.define(t=>new yHe(t,e)),Bw.of(e)]}const f$=Ot.define({combine(e){return lm(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function xin(e={}){return[f$.of(e),vHe,bHe,wHe,qfe.of(!0)]}function ahe(e){return e.startState.facet(f$)!=e.state.facet(f$)}const vHe=ihe({above:!0,markers(e){let{state:t}=e,n=t.facet(f$),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:Ze.cursor(i.head,i.head>i.anchor?-1:1);for(let l of Gy.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=ahe(e);return n&&$I(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){$I(t.state,e)},class:"cm-cursorLayer"});function $I(e,t){t.style.animationDuration=e.facet(f$).cursorBlinkRate+"ms"}const bHe=ihe({above:!1,markers(e){return e.state.selection.ranges.map(t=>t.empty?[]:Gy.forRange(e,"cm-selectionBackground",t)).reduce((t,n)=>t.concat(n))},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||ahe(e)},class:"cm-selectionLayer"}),wHe=mO.highest(bt.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"}}}})),ohe=pn.define({map(e,t){return e==null?null:t.mapPos(e)}}),Zg=Va.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(ohe)?r.value:n,e)}}),xHe=yi.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(Zg);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(Zg)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(Zg),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(Zg)!=e&&this.view.dispatch({effects:ohe.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 Sin(){return[Zg,xHe]}function yI(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 SHe(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 QHe{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 zd,r=n.add.bind(n);for(let{from:i,to:a}of SHe(t,this.maxLength))yI(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 yI(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 Y3=/x/.unicode!=null?"gu":"g",kHe=new RegExp(`[\0-\b
820
820
  --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,Y3),_He={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 T5=null;function PHe(){var e;if(T5==null&&typeof document<"u"&&document.body){let t=document.body.style;T5=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return T5||!1}const Hw=Ot.define({combine(e){let t=lm(e,{render:null,specialChars:kHe,addSpecialChars:null});return(t.replaceTabs=!PHe())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,Y3)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,Y3)),t}});function Qin(e={}){return[Hw.of(e),THe()]}let vI=null;function THe(){return vI||(vI=yi.fromClass(class{constructor(e){this.view=e,this.decorations=en.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(Hw)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new QHe({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,a=co(t[0],0);if(a==9){let o=i.lineAt(r),s=n.state.tabSize,l=rO(o.text,s,r-o.from);return en.replace({widget:new qHe((s-l%s)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=en.replace({widget:new EHe(e,a)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(Hw);e.startState.facet(Hw)!=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 XHe="•";function RHe(e){return e>=32?XHe:e==10?"␤":String.fromCharCode(9216+e)}class EHe extends Hc{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=RHe(this.code),r=t.state.phrase("Control character")+" "+(_He[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 qHe extends Hc{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 kin(){return CHe}const jHe=en.line({class:"cm-activeLine"}),CHe=yi.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(jHe.range(i.from)),t=i.from)}return en.set(n)}},{decorations:e=>e.decorations});class zHe extends Hc{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?ip(t.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(t.parentNode),i=Wy(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 _in(e){let t=yi.fromClass(class{constructor(n){this.view=n,this.placeholder=e?en.set([en.widget({widget:new zHe(e),side:1}).range(0)]):en.none}get decorations(){return this.view.state.doc.length?en.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,bt.contentAttributes.of({"aria-placeholder":e})]:t}const N3=2e3;function AHe(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>N3||n.off>N3||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(Ze.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=y3(c.text,o,e.tabSize,!0);if(u<0)a.push(Ze.cursor(c.to));else{let O=y3(c.text,s,e.tabSize);a.push(Ze.range(c.from+u,c.from+O))}}}return a}function UHe(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function bI(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>N3?-1:i==r.length?UHe(e,t.clientX):rO(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function WHe(e,t){let n=bI(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=bI(e,i);if(!s)return r;let l=AHe(e.state,n,s);return l.length?o?Ze.create(l.concat(r.ranges)):Ze.create(l):r}}:null}function Pin(e){let t=n=>n.altKey&&n.button==0;return bt.mouseSelectionStyle.of((n,r)=>t(r)?WHe(n,r):null)}const YHe={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},NHe={style:"cursor: crosshair"};function Tin(e={}){let[t,n]=YHe[e.key||"Alt"],r=yi.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,bt.contentAttributes.of(i=>{var a;return!((a=i.plugin(r))===null||a===void 0)&&a.isDown?NHe:null})]}const Hm="-10000px";class she{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 GHe(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const X5=Ot.define({combine:e=>{var t,n,r;return{position:st.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)||GHe}}}),wI=new WeakMap,P9=yi.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(X5);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 she(e,T9,(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(X5);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=Hm,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(st.gecko)n=a.offsetParent!=this.container.ownerDocument.body;else if(a.style.top==Hm&&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=S9(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(X5).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=Hm;continue}let h=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=h?7:0,g=d.right-d.left,y=(t=wI.get(c))!==null&&t!==void 0?t:d.bottom-d.top,v=c.offset||IHe,b=this.view.textDirection==mr.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=Hm;continue}wI.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",xI(u,(x-e.parent.left)/i)):(u.style.top=S/a+"px",xI(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=Hm}},{eventObservers:{scroll(){this.maybeMeasure()}}});function xI(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const ZHe=bt.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"}}}),IHe={x:0,y:0},T9=Ot.define({enables:[P9,ZHe]}),ux=Ot.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class BQ{static create(t){return new BQ(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new she(t,ux,(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 DHe=T9.compute([ux],e=>{let t=e.facet(ux);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:BQ.create,above:t[0].above,arrow:t.some(n=>n.arrow)}});class VHe{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 Cu)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==mr.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=>Wa(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(P9),n=t?t.manager.tooltips.findIndex(r=>r.create==BQ.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&&!MHe(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:!LHe(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 MHe(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 LHe(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 Xin(e,t={}){let n=pn.define(),r=Va.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,Wi.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(FHe)&&(i=[]);return i},provide:i=>ux.from(i)});return{active:r,extension:[r,yi.define(i=>new VHe(i,e,r,n,t.hoverTime||300)),DHe]}}function lhe(e,t){let n=e.plugin(P9);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const FHe=pn.define(),SI=Ot.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 Rin(e,t){let n=e.plugin(che),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const che=yi.fromClass(class{constructor(e){this.input=e.state.facet(kI),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(SI);this.top=new $b(e,!0,t.topContainer),this.bottom=new $b(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(SI);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new $b(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new $b(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(kI);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=>bt.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class $b{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=QI(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=QI(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 QI(e){let t=e.nextSibling;return e.remove(),t}const kI=Ot.define({enables:che});class Ac extends Cd{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Ac.prototype.elementClass="";Ac.prototype.toDOM=void 0;Ac.prototype.mapMode=Wi.TrackBefore;Ac.prototype.startSide=Ac.prototype.endSide=-1;Ac.prototype.point=!0;const Kw=Ot.define(),BHe=Ot.define(),HHe={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>hn.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},y0=Ot.define();function KHe(e){return[uhe(),y0.of({...HHe,...e})]}const _I=Ot.define({combine:e=>e.some(t=>t)});function uhe(e){return[JHe]}const JHe=yi.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(y0).map(t=>new TI(e,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!e.state.facet(_I),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(_I)!=!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=hn.iter(this.view.state.facet(Kw),this.view.viewport.from),r=[],i=this.gutters.map(a=>new eKe(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==wa.Text&&o){G3(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==wa.Text){G3(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(y0),n=e.state.facet(y0),r=e.docChanged||e.heightChanged||e.viewportChanged||!hn.eq(e.startState.facet(Kw),e.state.facet(Kw),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 TI(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=>bt.scrollMargins.of(t=>{let n=t.plugin(e);return!n||n.gutters.length==0||!n.fixed?null:t.textDirection==mr.LTR?{left:n.dom.offsetWidth*t.scaleX}:{right:n.dom.offsetWidth*t.scaleX}})});function PI(e){return Array.isArray(e)?e:[e]}function G3(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class eKe{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=hn.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 Ohe(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=[];G3(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(BHe)){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 TI{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=PI(n.markers(t)),n.initialSpacer&&(this.spacer=new Ohe(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=PI(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!hn.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 Ohe{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":""),tKe(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 tKe(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 nKe=Ot.define(),rKe=Ot.define(),$h=Ot.define({combine(e){return lm(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 R5 extends Ac{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function E5(e,t){return e.state.facet($h).formatNumber(t,e.state)}const iKe=y0.compute([$h],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(nKe)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new R5(E5(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(rKe)){let a=i(t,n,r);if(a)return a}return null},lineMarkerChange:t=>t.startState.facet($h)!=t.state.facet($h),initialSpacer(t){return new R5(E5(t,XI(t.state.doc.lines)))},updateSpacer(t,n){let r=E5(n.view,XI(n.view.state.doc.lines));return r==t.number?t:new R5(r)},domEventHandlers:e.facet($h).domEventHandlers}));function Ein(e={}){return[$h.of(e),uhe(),iKe]}function XI(e){let t=9;for(;t<e;)t=t*10+9;return t}const aKe=new class extends Ac{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},oKe=Kw.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(aKe.range(i)))}return hn.of(t)});function qin(){return oKe}let sKe=0;class tt{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=sKe++}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 Ox(t);return r=>r.modified.indexOf(n)>-1?r:Ox.get(r.base||r,r.modified.concat(n).sort((i,a)=>i.id-a.id))}}let lKe=0;class Ox{constructor(t){this.name=t,this.instances=[],this.id=lKe++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(s=>s.base==t&&cKe(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=uKe(n);for(let s of t.set)if(!s.modified.length)for(let l of o)i.push(Ox.get(s,l));return a}}function cKe(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function uKe(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 wn(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 dx(r,o,l>0?a.slice(0,l):null);t[c]=u.sort(t[c])}}return dhe.add(t)}const dhe=new qt;let dx=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}};dx.empty=new dx([],2,null);function fhe(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 OKe(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function dKe(e,t,n,r=0,i=e.length){let a=new fKe(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,"",a.highlighters),a.flush(i)}class fKe{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=hKe(t)||dx.empty,O=OKe(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(qt.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 hKe(e){let t=e.type.prop(dhe);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const Je=tt.define,yb=Je(),xu=Je(),RI=Je(xu),EI=Je(xu),Su=Je(),vb=Je(Su),q5=Je(Su),Ls=Je(),IO=Je(Ls),Zs=Je(),Is=Je(),Z3=Je(),Km=Je(Z3),bb=Je(),_={comment:yb,lineComment:Je(yb),blockComment:Je(yb),docComment:Je(yb),name:xu,variableName:Je(xu),typeName:RI,tagName:Je(RI),propertyName:EI,attributeName:Je(EI),className:Je(xu),labelName:Je(xu),namespace:Je(xu),macroName:Je(xu),literal:Su,string:vb,docString:Je(vb),character:Je(vb),attributeValue:Je(vb),number:q5,integer:Je(q5),float:Je(q5),bool:Je(Su),regexp:Je(Su),escape:Je(Su),color:Je(Su),url:Je(Su),keyword:Zs,self:Je(Zs),null:Je(Zs),atom:Je(Zs),unit:Je(Zs),modifier:Je(Zs),operatorKeyword:Je(Zs),controlKeyword:Je(Zs),definitionKeyword:Je(Zs),moduleKeyword:Je(Zs),operator:Is,derefOperator:Je(Is),arithmeticOperator:Je(Is),logicOperator:Je(Is),bitwiseOperator:Je(Is),compareOperator:Je(Is),updateOperator:Je(Is),definitionOperator:Je(Is),typeOperator:Je(Is),controlOperator:Je(Is),punctuation:Z3,separator:Je(Z3),bracket:Km,angleBracket:Je(Km),squareBracket:Je(Km),paren:Je(Km),brace:Je(Km),content:Ls,heading:IO,heading1:Je(IO),heading2:Je(IO),heading3:Je(IO),heading4:Je(IO),heading5:Je(IO),heading6:Je(IO),contentSeparator:Je(Ls),list:Je(Ls),quote:Je(Ls),emphasis:Je(Ls),strong:Je(Ls),link:Je(Ls),monospace:Je(Ls),strikethrough:Je(Ls),inserted:Je(),deleted:Je(),changed:Je(),invalid:Je(),meta:bb,documentMeta:Je(bb),annotation:Je(bb),processingInstruction:Je(bb),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)}fhe([{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 j5;const Au=new qt;function HQ(e){return Ot.define({combine:e?t=>t.concat(e):void 0})}const X9=new qt;class po{constructor(t,n,r=[],i=""){this.data=t,this.name=i,_n.prototype.hasOwnProperty("tree")||Object.defineProperty(_n.prototype,"tree",{get(){return An(this)}}),this.parser=n,this.extension=[sO.of(this),_n.languageData.of((a,o,s)=>{let l=qI(a,o,s),c=l.type.prop(Au);if(!c)return[];let u=a.facet(c),O=l.type.prop(X9);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 qI(t,n,r).type.prop(Au)==this.data}findRegions(t){let n=t.facet(sO);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(Au)==this.data){r.push({from:o,to:o+a.length});return}let s=a.prop(qt.mounted);if(s){if(s.tree.prop(Au)==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 an&&i(c,a.positions[l]+o)}};return i(An(t),0),r}get allowsNesting(){return!0}}po.setState=pn.define();function qI(e,t,n){let r=e.facet(sO),i=An(e).topNode;if(!r||r.allowsNesting)for(let a=i;a;a=a.enter(t,n,Fn.ExcludeBuffers))a.type.isTop&&(i=a);return i}class gn extends po{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=HQ(t.languageData);return new gn(n,t.parser.configure({props:[Au.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new gn(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function An(e){let t=e.field(po.state,!1);return t?t.tree:an.empty}class pKe{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 Jm=null;class Yd{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 Yd(t,n,[],an.empty,0,r,[],null)}startParse(){return this.parser.startParse(new pKe(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=an.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(Qc.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(Qc.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=Jm;Jm=this;try{return t()}finally{Jm=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=jI(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=Qc.applyChanges(r,l),i=an.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 Yd(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=jI(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 DQ{createParse(n,r,i){let a=i[0].from,o=i[i.length-1].to;return{parsedPos:a,advance(){let l=Jm;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 an(ni.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 Jm}}function jI(e,t,n){return Qc.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class lp{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 lp(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=Yd.create(t.facet(sO).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new lp(r)}}po.state=Va.define({create:lp.init,update(e,t){for(let n of t.effects)if(n.is(po.setState))return n.value;return t.startState.facet(sO)!=t.state.facet(sO)?lp.init(t.state):e.apply(t)}});let hhe=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(hhe=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const C5=typeof navigator<"u"&&(!((j5=navigator.scheduling)===null||j5===void 0)&&j5.isInputPending)?()=>navigator.scheduling.isInputPending():null,mKe=yi.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(po.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(po.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=hhe(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(po.state);if(a.tree==a.context.tree&&a.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!C5?Math.max(25,t.timeRemaining()-5):1e9),s=a.context.treeLen<i&&r.doc.length>i+1e3,l=a.context.work(()=>C5&&C5()||Date.now()>o,i+(s?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:po.setState.of(new lp(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=>Wa(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()}}}),sO=Ot.define({combine(e){return e.length?e[0]:null},enables:e=>[po.state,mKe,bt.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class On{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 gKe=Ot.define(),KQ=Ot.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 fx(e){let t=e.facet(KQ);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function $Ke(e,t){let n="",r=e.tabSize,i=e.facet(KQ)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let a=0;a<t;a++)n+=i;return n}function yKe(e,t){e instanceof _n&&(e=new phe(e));for(let r of e.state.facet(gKe)){let i=r(e,t);if(i!==void 0)return i}let n=An(e.state);return n.length>=t?vKe(e,n,t):null}class phe{constructor(t,n={}){this.state=t,this.options=n,this.unit=fx(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 rO(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 _r=new qt;function vKe(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 mhe(r,e,n)}function mhe(e,t,n){for(let r=e;r;r=r.next){let i=wKe(r.node);if(i)return i(R9.create(t,n,r))}return 0}function bKe(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function wKe(e){let t=e.type.prop(_r);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(qt.closedBy))){let i=e.lastChild,a=i&&r.indexOf(i.name)>-1;return o=>ghe(o,!0,1,void 0,a&&!bKe(o)?i.from:void 0)}return e.parent==null?xKe:null}function xKe(){return 0}class R9 extends phe{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 R9(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(SKe(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return mhe(this.context.next,this.base,this.pos)}}function SKe(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function QKe(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 Lo({closing:e,align:t=!0,units:n=1}){return r=>ghe(r,t,n,e)}function ghe(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?QKe(e):null;return l?s?e.column(l.from):e.column(l.to):e.baseIndent+(s?0:e.unit*n)}const E9=e=>e.baseIndent;function qr({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const kKe=200;function zin(){return _n.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+kKe)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=yKe(o,u.from);if(O==null)continue;let d=/^\s*/.exec(u.text)[0],h=$Ke(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 $he=Ot.define(),vr=new qt;function oa(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 _Ke(e,t,n){let r=An(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(vr);if(l&&(s.to<r.length-50||r.length==e.doc.length||!PKe(s))){let c=l(s,e);c&&c.from<=n&&c.from>=t&&c.to>n&&(a=c)}}return a}function PKe(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function hx(e,t,n){for(let r of e.facet($he)){let i=r(e,t,n);if(i)return i}return _Ke(e,t,n)}function yhe(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 JQ=pn.define({map:yhe}),Zy=pn.define({map:yhe});function vhe(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 Nd=Va.define({create(){return en.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(JQ)&&!TKe(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(xhe),i=r?en.replace({widget:new CKe(r(t.state,n.value))}):CI;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(Zy)&&(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=>bt.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(CI.range(r,i))}return en.set(t,!0)}});function px(e,t,n){var r;let i=null;return(r=e.field(Nd,!1))===null||r===void 0||r.between(t,n,(a,o)=>{(!i||i.from>a)&&(i={from:a,to:o})}),i}function TKe(e,t,n){let r=!1;return e.between(t,t,(i,a)=>{i==t&&a==n&&(r=!0)}),r}function bhe(e,t){return e.field(Nd,!1)?t:t.concat(pn.appendConfig.of(She()))}const XKe=e=>{for(let t of vhe(e)){let n=hx(e.state,t.from,t.to);if(n)return e.dispatch({effects:bhe(e.state,[JQ.of(n),whe(e,n)])}),!0}return!1},RKe=e=>{if(!e.state.field(Nd,!1))return!1;let t=[];for(let n of vhe(e)){let r=px(e.state,n.from,n.to);r&&t.push(Zy.of(r),whe(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function whe(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return bt.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const EKe=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=hx(t,i.from,i.to);a&&n.push(JQ.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:bhe(e.state,n)}),!!n.length},qKe=e=>{let t=e.state.field(Nd,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(Zy.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},Ain=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:XKe},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:RKe},{key:"Ctrl-Alt-[",run:EKe},{key:"Ctrl-Alt-]",run:qKe}],jKe={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},xhe=Ot.define({combine(e){return lm(e,jKe)}});function She(e){return[Nd,AKe]}function Qhe(e,t){let{state:n}=e,r=n.facet(xhe),i=o=>{let s=e.lineBlockAt(e.posAtDOM(o.target)),l=px(e.state,s.from,s.to);l&&e.dispatch({effects:Zy.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 CI=en.replace({widget:new class extends Hc{toDOM(e){return Qhe(e,null)}}});class CKe extends Hc{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Qhe(t,this.value)}}const zKe={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class z5 extends Ac{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 Uin(e={}){let t={...zKe,...e},n=new z5(t,!0),r=new z5(t,!1),i=yi.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(sO)!=o.state.facet(sO)||o.startState.field(Nd,!1)!=o.state.field(Nd,!1)||An(o.startState)!=An(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let s=new zd;for(let l of o.viewportLineBlocks){let c=px(o.state,l.from,l.to)?r:hx(o.state,l.from,l.to)?n:null;c&&s.add(l.from,l.from,c)}return s.finish()}}),{domEventHandlers:a}=t;return[i,KHe({class:"cm-foldGutter",markers(o){var s;return((s=o.plugin(i))===null||s===void 0?void 0:s.markers)||hn.empty},initialSpacer(){return new z5(t,!1)},domEventHandlers:{...a,click:(o,s,l)=>{if(a.click&&a.click(o,s,l))return!0;let c=px(o.state,s.from,s.to);if(c)return o.dispatch({effects:Zy.of(c)}),!0;let u=hx(o.state,s.from,s.to);return u?(o.dispatch({effects:JQ.of(u)}),!0):!1}}}),She()]}const AKe=bt.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=iO.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 po?s=>s.prop(Au)==o.data:o?s=>s==o:void 0,this.style=fhe(t.map(s=>({tag:s.tag,class:s.class||i(Object.assign({},s,{tag:null}))})),{all:a}).style,this.module=r?new iO(r):null,this.themeType=n.themeType}static define(t,n){return new ek(t,n||{})}}const I3=Ot.define(),khe=Ot.define({combine(e){return e.length?[e[0]]:null}});function A5(e){let t=e.facet(I3);return t.length?t:e.facet(khe)}function Win(e,t){let n=[WKe],r;return e instanceof ek&&(e.module&&n.push(bt.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(khe.of(e)):r?n.push(I3.computeN([bt.darkTheme],i=>i.facet(bt.darkTheme)==(r=="dark")?[e]:[])):n.push(I3.of(e)),n}class UKe{constructor(t){this.markCache=Object.create(null),this.tree=An(t.state),this.decorations=this.buildDeco(t,A5(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=An(t.state),r=A5(t.state),i=r!=A5(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 en.none;let r=new zd;for(let{from:i,to:a}of t.visibleRanges)dKe(this.tree,n,(o,s,l)=>{r.add(o,s,this.markCache[l]||(this.markCache[l]=en.mark({class:l})))},i,a);return r.finish()}}const WKe=mO.high(yi.fromClass(UKe,{decorations:e=>e.decorations})),Yin=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"}]),YKe=bt.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),_he=1e4,Phe="()[]{}",The=Ot.define({combine(e){return lm(e,{afterCursor:!0,brackets:Phe,maxScanDistance:_he,renderMatch:ZKe})}}),NKe=en.mark({class:"cm-matchingBracket"}),GKe=en.mark({class:"cm-nonmatchingBracket"});function ZKe(e){let t=[],n=e.matched?NKe:GKe;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 IKe=Va.define({create(){return en.none},update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(The);for(let i of t.state.selection.ranges){if(!i.empty)continue;let a=wb(t.state,i.head,-1,r)||i.head>0&&wb(t.state,i.head-1,1,r)||r.afterCursor&&(wb(t.state,i.head,1,r)||i.head<t.state.doc.length&&wb(t.state,i.head+1,-1,r));a&&(n=n.concat(r.renderMatch(a,t.state)))}return en.set(n,!0)},provide:e=>bt.decorations.from(e)}),DKe=[IKe,YKe];function Nin(e={}){return[The.of(e),DKe]}const q9=new qt;function D3(e,t,n){let r=e.prop(t<0?qt.openedBy:qt.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 V3(e){let t=e.type.prop(q9);return t?t(e.node):e}function wb(e,t,n,r={}){let i=r.maxScanDistance||_he,a=r.brackets||Phe,o=An(e),s=o.resolveInner(t,n);for(let l=s;l;l=l.parent){let c=D3(l.type,n,a);if(c&&l.from<l.to){let u=V3(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return VKe(e,t,n,l,u,c,a)}}return MKe(e,t,n,o,s.type,i,a)}function VKe(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=V3(u);return{start:l,end:O?{from:O.from,to:O.to}:void 0,matched:!0}}else if(D3(u.type,n,o))c++;else if(D3(u.type,-n,o)){if(c==0){let O=V3(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 MKe(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 zI(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 Xhe{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=zI(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:zI(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 LKe(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||FKe,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||C9,mergeTokens:e.mergeTokens!==!1}}function FKe(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 AI=new WeakMap;class Ce extends po{constructor(t){let n=HQ(t.languageData),r=LKe(t),i,a=new class extends DQ{createParse(o,s,l){return new HKe(i,o,s,l)}};super(n,a,[],t.name),this.topNode=eJe(n,this),i=this,this.streamParser=r,this.stateAfter=new qt({perNode:!0}),this.tokenTable=t.tokenTable?new jhe(r.tokenTable):JKe}static define(t){return new Ce(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=AI.get(t.state),n!=null&&n<t.pos-1e4&&(n=void 0));let i=j9(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 Xhe(l.text,t.state.tabSize,t.unit,u<0?void 0:u);for(;O.pos<c-l.from;)Ehe(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&&AI.set(t.state,s.from),this.streamParser.indent(o,/^\s*(.*)/.exec(s.text)[1],t)}get allowsNesting(){return!1}}function j9(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 an&&l<i&&j9(e,s,l,r,i);if(c)return c}return null}function Rhe(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 an){if(!(l=Rhe(e,s,n-o,r-o,i)))break;return i?new an(t.type,t.children.slice(0,a).concat(l),t.positions.slice(0,a+1),o+l.length):l}}return null}function BKe(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&&j9(e,a.tree,0-a.offset,n,s),c;if(l&&l.pos<=r&&(c=Rhe(e,a.tree,n+a.offset,l.pos+a.offset,!1)))return{state:l.state,tree:c}}return{state:e.streamParser.startState(i?fx(i):4),tree:an.empty}}let HKe=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=Yd.get(),o=i[0].from,{state:s,tree:l}=BKe(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(fx(a.state)),a.skipUntilInView(this.parsedPos,a.viewport.from),this.parsedPos=a.viewport.from),this.moveRangeIndex()}advance(){let t=Yd.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==`
821
821
  `&&(n="");else{let r=n.indexOf(`
822
- `);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 Xhe(n,t?t.state.tabSize:4,t?fx(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=Ehe(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=an.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:KKe,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new an(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 an(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Ehe(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 C9=Object.create(null),h$=[ni.none],KKe=new sm(h$),UI=[],WI=Object.create(null),qhe=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"]])qhe[e]=Che(C9,t);class jhe{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),qhe)}resolve(t){return t?this.table[t]||(this.table[t]=Che(this.extra,t)):0}}const JKe=new jhe(C9);function U5(e,t){UI.indexOf(e)>-1||(UI.push(e),console.warn(t))}function Che(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):U5(c,`Modifier ${c} used at start of tag`):l.length?U5(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:U5(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=WI[i];if(a)return a.id;let o=WI[i]=ni.define({id:h$.length,name:r,props:[wn({[r]:n})]});return h$.push(o),o.id}function eJe(e,t){let n=ni.define({id:h$.length,name:"Document",props:[Au.add(()=>e),_r.add(()=>r=>t.getIndent(r))],top:!0});return h$.push(n),n}mr.RTL,mr.LTR;function Xe(e){return new On(Ce.define(e))}function fu(e){return $e(()=>Promise.resolve().then(()=>klt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const tJe=[ge.of({name:"C",extensions:["c","h","ino"],load(){return $e(()=>Promise.resolve().then(()=>XV),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 $e(()=>Promise.resolve().then(()=>XV),void 0,import.meta.url).then(e=>e.cpp())}}),ge.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return fu("Cassandra")}}),ge.of({name:"CSS",extensions:["css"],load(){return $e(()=>Promise.resolve().then(()=>Ntt),void 0,import.meta.url).then(e=>e.css())}}),ge.of({name:"Go",extensions:["go"],load(){return $e(()=>import("./index-BTzCVYFd.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 $e(()=>Promise.resolve().then(()=>Ent),void 0,import.meta.url).then(e=>e.html())}}),ge.of({name:"Java",extensions:["java"],load(){return $e(()=>Promise.resolve().then(()=>Xlt),void 0,import.meta.url).then(e=>e.java())}}),ge.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return $e(()=>Promise.resolve().then(()=>kb),void 0,import.meta.url).then(e=>e.javascript())}}),ge.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return $e(()=>Promise.resolve().then(()=>Art),void 0,import.meta.url).then(e=>e.json())}}),ge.of({name:"JSX",extensions:["jsx"],load(){return $e(()=>Promise.resolve().then(()=>kb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),ge.of({name:"LESS",extensions:["less"],load(){return $e(()=>Promise.resolve().then(()=>Jnt),void 0,import.meta.url).then(e=>e.less())}}),ge.of({name:"Liquid",extensions:["liquid"],load(){return $e(()=>Promise.resolve().then(()=>pOt),void 0,import.meta.url).then(e=>e.liquid())}}),ge.of({name:"MariaDB SQL",load(){return fu("MariaSQL")}}),ge.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return $e(()=>Promise.resolve().then(()=>Gnt),void 0,import.meta.url).then(e=>e.markdown())}}),ge.of({name:"MS SQL",load(){return fu("MSSQL")}}),ge.of({name:"MySQL",load(){return fu("MySQL")}}),ge.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return $e(()=>Promise.resolve().then(()=>Vut),void 0,import.meta.url).then(e=>e.php())}}),ge.of({name:"PLSQL",extensions:["pls"],load(){return fu("PLSQL")}}),ge.of({name:"PostgreSQL",load(){return fu("PostgreSQL")}}),ge.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return $e(()=>Promise.resolve().then(()=>pst),void 0,import.meta.url).then(e=>e.python())}}),ge.of({name:"Rust",extensions:["rs"],load(){return $e(()=>Promise.resolve().then(()=>Blt),void 0,import.meta.url).then(e=>e.rust())}}),ge.of({name:"Sass",extensions:["sass"],load(){return $e(()=>Promise.resolve().then(()=>DD),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),ge.of({name:"SCSS",extensions:["scss"],load(){return $e(()=>Promise.resolve().then(()=>DD),void 0,import.meta.url).then(e=>e.sass())}}),ge.of({name:"SQL",extensions:["sql"],load(){return fu("StandardSQL")}}),ge.of({name:"SQLite",load(){return fu("SQLite")}}),ge.of({name:"TSX",extensions:["tsx"],load(){return $e(()=>Promise.resolve().then(()=>kb),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 $e(()=>Promise.resolve().then(()=>kb),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),ge.of({name:"WebAssembly",extensions:["wat","wast"],load(){return $e(()=>Promise.resolve().then(()=>$Ot),void 0,import.meta.url).then(e=>e.wast())}}),ge.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return $e(()=>Promise.resolve().then(()=>Ast),void 0,import.meta.url).then(e=>e.xml())}}),ge.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return $e(()=>import("./index-LdCy3uKw.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 $e(()=>Promise.resolve().then(()=>Mft),void 0,import.meta.url).then(e=>Xe(e.apl))}}),ge.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return $e(()=>Promise.resolve().then(()=>Lft),void 0,import.meta.url).then(e=>Xe(e.asciiArmor))}}),ge.of({name:"ASN.1",extensions:["asn","asn1"],load(){return $e(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>Xe(e.asn1({})))}}),ge.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return $e(()=>Promise.resolve().then(()=>Jft),void 0,import.meta.url).then(e=>Xe(e.asterisk))}}),ge.of({name:"Brainfuck",extensions:["b","bf"],load(){return $e(()=>Promise.resolve().then(()=>tht),void 0,import.meta.url).then(e=>Xe(e.brainfuck))}}),ge.of({name:"Cobol",extensions:["cob","cpy"],load(){return $e(()=>Promise.resolve().then(()=>Tht),void 0,import.meta.url).then(e=>Xe(e.cobol))}}),ge.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return $e(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>Xe(e.csharp))}}),ge.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return $e(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Xe(e.clojure))}}),ge.of({name:"ClojureScript",extensions:["cljs"],load(){return $e(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Xe(e.clojure))}}),ge.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return $e(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>Xe(e.gss))}}),ge.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return $e(()=>Promise.resolve().then(()=>vht),void 0,import.meta.url).then(e=>Xe(e.cmake))}}),ge.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return $e(()=>Promise.resolve().then(()=>Ght),void 0,import.meta.url).then(e=>Xe(e.coffeeScript))}}),ge.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return $e(()=>Promise.resolve().then(()=>Lht),void 0,import.meta.url).then(e=>Xe(e.commonLisp))}}),ge.of({name:"Cypher",extensions:["cyp","cypher"],load(){return $e(()=>Promise.resolve().then(()=>dpt),void 0,import.meta.url).then(e=>Xe(e.cypher))}}),ge.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return $e(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>Xe(e.cython))}}),ge.of({name:"Crystal",extensions:["cr"],load(){return $e(()=>Promise.resolve().then(()=>opt),void 0,import.meta.url).then(e=>Xe(e.crystal))}}),ge.of({name:"D",extensions:["d"],load(){return $e(()=>Promise.resolve().then(()=>ypt),void 0,import.meta.url).then(e=>Xe(e.d))}}),ge.of({name:"Dart",extensions:["dart"],load(){return $e(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>Xe(e.dart))}}),ge.of({name:"diff",extensions:["diff","patch"],load(){return $e(()=>Promise.resolve().then(()=>vpt),void 0,import.meta.url).then(e=>Xe(e.diff))}}),ge.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return $e(()=>Promise.resolve().then(()=>qpt),void 0,import.meta.url).then(e=>Xe(e.dockerFile))}}),ge.of({name:"DTD",extensions:["dtd"],load(){return $e(()=>Promise.resolve().then(()=>zpt),void 0,import.meta.url).then(e=>Xe(e.dtd))}}),ge.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return $e(()=>Promise.resolve().then(()=>Npt),void 0,import.meta.url).then(e=>Xe(e.dylan))}}),ge.of({name:"EBNF",load(){return $e(()=>Promise.resolve().then(()=>Gpt),void 0,import.meta.url).then(e=>Xe(e.ebnf))}}),ge.of({name:"ECL",extensions:["ecl"],load(){return $e(()=>Promise.resolve().then(()=>Bpt),void 0,import.meta.url).then(e=>Xe(e.ecl))}}),ge.of({name:"edn",extensions:["edn"],load(){return $e(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Xe(e.clojure))}}),ge.of({name:"Eiffel",extensions:["e"],load(){return $e(()=>Promise.resolve().then(()=>nmt),void 0,import.meta.url).then(e=>Xe(e.eiffel))}}),ge.of({name:"Elm",extensions:["elm"],load(){return $e(()=>Promise.resolve().then(()=>fmt),void 0,import.meta.url).then(e=>Xe(e.elm))}}),ge.of({name:"Erlang",extensions:["erl"],load(){return $e(()=>Promise.resolve().then(()=>Amt),void 0,import.meta.url).then(e=>Xe(e.erlang))}}),ge.of({name:"Esper",load(){return $e(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>Xe(e.esper))}}),ge.of({name:"Factor",extensions:["factor"],load(){return $e(()=>Promise.resolve().then(()=>Umt),void 0,import.meta.url).then(e=>Xe(e.factor))}}),ge.of({name:"FCL",load(){return $e(()=>Promise.resolve().then(()=>Zmt),void 0,import.meta.url).then(e=>Xe(e.fcl))}}),ge.of({name:"Forth",extensions:["forth","fth","4th"],load(){return $e(()=>Promise.resolve().then(()=>Vmt),void 0,import.meta.url).then(e=>Xe(e.forth))}}),ge.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return $e(()=>Promise.resolve().then(()=>Jmt),void 0,import.meta.url).then(e=>Xe(e.fortran))}}),ge.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return $e(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Xe(e.fSharp))}}),ge.of({name:"Gas",extensions:["s"],load(){return $e(()=>Promise.resolve().then(()=>tgt),void 0,import.meta.url).then(e=>Xe(e.gas))}}),ge.of({name:"Gherkin",extensions:["feature"],load(){return $e(()=>Promise.resolve().then(()=>ngt),void 0,import.meta.url).then(e=>Xe(e.gherkin))}}),ge.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return $e(()=>Promise.resolve().then(()=>fgt),void 0,import.meta.url).then(e=>Xe(e.groovy))}}),ge.of({name:"Haskell",extensions:["hs"],load(){return $e(()=>Promise.resolve().then(()=>vgt),void 0,import.meta.url).then(e=>Xe(e.haskell))}}),ge.of({name:"Haxe",extensions:["hx"],load(){return $e(()=>Promise.resolve().then(()=>JM),void 0,import.meta.url).then(e=>Xe(e.haxe))}}),ge.of({name:"HXML",extensions:["hxml"],load(){return $e(()=>Promise.resolve().then(()=>JM),void 0,import.meta.url).then(e=>Xe(e.hxml))}}),ge.of({name:"HTTP",load(){return $e(()=>Promise.resolve().then(()=>Zgt),void 0,import.meta.url).then(e=>Xe(e.http))}}),ge.of({name:"IDL",extensions:["pro"],load(){return $e(()=>Promise.resolve().then(()=>Bgt),void 0,import.meta.url).then(e=>Xe(e.idl))}}),ge.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return $e(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>Xe(e.jsonld))}}),ge.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return $e(()=>Promise.resolve().then(()=>e0t),void 0,import.meta.url).then(e=>Xe(e.jinja2))}}),ge.of({name:"Julia",extensions:["jl"],load(){return $e(()=>Promise.resolve().then(()=>Q0t),void 0,import.meta.url).then(e=>Xe(e.julia))}}),ge.of({name:"Kotlin",extensions:["kt","kts"],load(){return $e(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>Xe(e.kotlin))}}),ge.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return $e(()=>Promise.resolve().then(()=>T0t),void 0,import.meta.url).then(e=>Xe(e.liveScript))}}),ge.of({name:"Lua",extensions:["lua"],load(){return $e(()=>Promise.resolve().then(()=>A0t),void 0,import.meta.url).then(e=>Xe(e.lua))}}),ge.of({name:"mIRC",extensions:["mrc"],load(){return $e(()=>Promise.resolve().then(()=>o$t),void 0,import.meta.url).then(e=>Xe(e.mirc))}}),ge.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return $e(()=>Promise.resolve().then(()=>D0t),void 0,import.meta.url).then(e=>Xe(e.mathematica))}}),ge.of({name:"Modelica",extensions:["mo"],load(){return $e(()=>Promise.resolve().then(()=>m$t),void 0,import.meta.url).then(e=>Xe(e.modelica))}}),ge.of({name:"MUMPS",extensions:["mps"],load(){return $e(()=>Promise.resolve().then(()=>E$t),void 0,import.meta.url).then(e=>Xe(e.mumps))}}),ge.of({name:"Mbox",extensions:["mbox"],load(){return $e(()=>Promise.resolve().then(()=>r$t),void 0,import.meta.url).then(e=>Xe(e.mbox))}}),ge.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return $e(()=>Promise.resolve().then(()=>A$t),void 0,import.meta.url).then(e=>Xe(e.nginx))}}),ge.of({name:"NSIS",extensions:["nsh","nsi"],load(){return $e(()=>Promise.resolve().then(()=>U$t),void 0,import.meta.url).then(e=>Xe(e.nsis))}}),ge.of({name:"NTriples",extensions:["nt","nq"],load(){return $e(()=>Promise.resolve().then(()=>W$t),void 0,import.meta.url).then(e=>Xe(e.ntriples))}}),ge.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return $e(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>Xe(e.objectiveC))}}),ge.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return $e(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>Xe(e.objectiveCpp))}}),ge.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return $e(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Xe(e.oCaml))}}),ge.of({name:"Octave",extensions:["m"],load(){return $e(()=>Promise.resolve().then(()=>B$t),void 0,import.meta.url).then(e=>Xe(e.octave))}}),ge.of({name:"Oz",extensions:["oz"],load(){return $e(()=>Promise.resolve().then(()=>lyt),void 0,import.meta.url).then(e=>Xe(e.oz))}}),ge.of({name:"Pascal",extensions:["p","pas"],load(){return $e(()=>Promise.resolve().then(()=>hyt),void 0,import.meta.url).then(e=>Xe(e.pascal))}}),ge.of({name:"Perl",extensions:["pl","pm"],load(){return $e(()=>Promise.resolve().then(()=>pyt),void 0,import.meta.url).then(e=>Xe(e.perl))}}),ge.of({name:"Pig",extensions:["pig"],load(){return $e(()=>Promise.resolve().then(()=>$yt),void 0,import.meta.url).then(e=>Xe(e.pig))}}),ge.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return $e(()=>Promise.resolve().then(()=>jyt),void 0,import.meta.url).then(e=>Xe(e.powerShell))}}),ge.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return $e(()=>Promise.resolve().then(()=>Cyt),void 0,import.meta.url).then(e=>Xe(e.properties))}}),ge.of({name:"ProtoBuf",extensions:["proto"],load(){return $e(()=>Promise.resolve().then(()=>Yyt),void 0,import.meta.url).then(e=>Xe(e.protobuf))}}),ge.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return $e(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([7,8]),import.meta.url).then(e=>Xe(e.pug))}}),ge.of({name:"Puppet",extensions:["pp"],load(){return $e(()=>Promise.resolve().then(()=>Zyt),void 0,import.meta.url).then(e=>Xe(e.puppet))}}),ge.of({name:"Q",extensions:["q"],load(){return $e(()=>Promise.resolve().then(()=>Hyt),void 0,import.meta.url).then(e=>Xe(e.q))}}),ge.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return $e(()=>Promise.resolve().then(()=>ivt),void 0,import.meta.url).then(e=>Xe(e.r))}}),ge.of({name:"RPM Changes",load(){return $e(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Xe(e.rpmChanges))}}),ge.of({name:"RPM Spec",extensions:["spec"],load(){return $e(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Xe(e.rpmSpec))}}),ge.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return $e(()=>Promise.resolve().then(()=>fvt),void 0,import.meta.url).then(e=>Xe(e.ruby))}}),ge.of({name:"SAS",extensions:["sas"],load(){return $e(()=>Promise.resolve().then(()=>gvt),void 0,import.meta.url).then(e=>Xe(e.sas))}}),ge.of({name:"Scala",extensions:["scala"],load(){return $e(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>Xe(e.scala))}}),ge.of({name:"Scheme",extensions:["scm","ss"],load(){return $e(()=>Promise.resolve().then(()=>Xvt),void 0,import.meta.url).then(e=>Xe(e.scheme))}}),ge.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return $e(()=>Promise.resolve().then(()=>jvt),void 0,import.meta.url).then(e=>Xe(e.shell))}}),ge.of({name:"Sieve",extensions:["siv","sieve"],load(){return $e(()=>Promise.resolve().then(()=>Wvt),void 0,import.meta.url).then(e=>Xe(e.sieve))}}),ge.of({name:"Smalltalk",extensions:["st"],load(){return $e(()=>Promise.resolve().then(()=>Gvt),void 0,import.meta.url).then(e=>Xe(e.smalltalk))}}),ge.of({name:"Solr",load(){return $e(()=>Promise.resolve().then(()=>Fvt),void 0,import.meta.url).then(e=>Xe(e.solr))}}),ge.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return $e(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Xe(e.sml))}}),ge.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return $e(()=>Promise.resolve().then(()=>nbt),void 0,import.meta.url).then(e=>Xe(e.sparql))}}),ge.of({name:"Spreadsheet",alias:["excel","formula"],load(){return $e(()=>Promise.resolve().then(()=>rbt),void 0,import.meta.url).then(e=>Xe(e.spreadsheet))}}),ge.of({name:"Squirrel",extensions:["nut"],load(){return $e(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>Xe(e.squirrel))}}),ge.of({name:"Stylus",extensions:["styl"],load(){return $e(()=>Promise.resolve().then(()=>Qbt),void 0,import.meta.url).then(e=>Xe(e.stylus))}}),ge.of({name:"Swift",extensions:["swift"],load(){return $e(()=>Promise.resolve().then(()=>Dbt),void 0,import.meta.url).then(e=>Xe(e.swift))}}),ge.of({name:"sTeX",load(){return $e(()=>Promise.resolve().then(()=>IL),void 0,import.meta.url).then(e=>Xe(e.stex))}}),ge.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return $e(()=>Promise.resolve().then(()=>IL),void 0,import.meta.url).then(e=>Xe(e.stex))}}),ge.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return $e(()=>Promise.resolve().then(()=>uF),void 0,import.meta.url).then(e=>Xe(e.verilog))}}),ge.of({name:"Tcl",extensions:["tcl"],load(){return $e(()=>Promise.resolve().then(()=>Fbt),void 0,import.meta.url).then(e=>Xe(e.tcl))}}),ge.of({name:"Textile",extensions:["textile"],load(){return $e(()=>Promise.resolve().then(()=>Jbt),void 0,import.meta.url).then(e=>Xe(e.textile))}}),ge.of({name:"TiddlyWiki",load(){return $e(()=>Promise.resolve().then(()=>vwt),void 0,import.meta.url).then(e=>Xe(e.tiddlyWiki))}}),ge.of({name:"Tiki wiki",load(){return $e(()=>Promise.resolve().then(()=>_wt),void 0,import.meta.url).then(e=>Xe(e.tiki))}}),ge.of({name:"TOML",extensions:["toml"],load(){return $e(()=>Promise.resolve().then(()=>Pwt),void 0,import.meta.url).then(e=>Xe(e.toml))}}),ge.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return $e(()=>Promise.resolve().then(()=>Rwt),void 0,import.meta.url).then(e=>Xe(e.troff))}}),ge.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return $e(()=>Promise.resolve().then(()=>Fwt),void 0,import.meta.url).then(e=>Xe(e.ttcn))}}),ge.of({name:"TTCN_CFG",extensions:["cfg"],load(){return $e(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>Xe(e.ttcnCfg))}}),ge.of({name:"Turtle",extensions:["ttl"],load(){return $e(()=>Promise.resolve().then(()=>Kwt),void 0,import.meta.url).then(e=>Xe(e.turtle))}}),ge.of({name:"Web IDL",extensions:["webidl"],load(){return $e(()=>Promise.resolve().then(()=>D1t),void 0,import.meta.url).then(e=>Xe(e.webIDL))}}),ge.of({name:"VB.NET",extensions:["vb"],load(){return $e(()=>Promise.resolve().then(()=>f1t),void 0,import.meta.url).then(e=>Xe(e.vb))}}),ge.of({name:"VBScript",extensions:["vbs"],load(){return $e(()=>Promise.resolve().then(()=>p1t),void 0,import.meta.url).then(e=>Xe(e.vbScript))}}),ge.of({name:"Velocity",extensions:["vtl"],load(){return $e(()=>Promise.resolve().then(()=>$1t),void 0,import.meta.url).then(e=>Xe(e.velocity))}}),ge.of({name:"Verilog",extensions:["v"],load(){return $e(()=>Promise.resolve().then(()=>uF),void 0,import.meta.url).then(e=>Xe(e.verilog))}}),ge.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return $e(()=>Promise.resolve().then(()=>_1t),void 0,import.meta.url).then(e=>Xe(e.vhdl))}}),ge.of({name:"XQuery",extensions:["xy","xquery"],load(){return $e(()=>Promise.resolve().then(()=>txt),void 0,import.meta.url).then(e=>Xe(e.xQuery))}}),ge.of({name:"Yacas",extensions:["ys"],load(){return $e(()=>Promise.resolve().then(()=>Oxt),void 0,import.meta.url).then(e=>Xe(e.yacas))}}),ge.of({name:"Z80",extensions:["z80"],load(){return $e(()=>Promise.resolve().then(()=>mxt),void 0,import.meta.url).then(e=>Xe(e.z80))}}),ge.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return $e(()=>Promise.resolve().then(()=>IT),void 0,import.meta.url).then(e=>Xe(e.mscgen))}}),ge.of({name:"Xù",extensions:["xu"],load(){return $e(()=>Promise.resolve().then(()=>IT),void 0,import.meta.url).then(e=>Xe(e.xu))}}),ge.of({name:"MsGenny",extensions:["msgenny"],load(){return $e(()=>Promise.resolve().then(()=>IT),void 0,import.meta.url).then(e=>Xe(e.msgenny))}}),ge.of({name:"Vue",extensions:["vue"],load(){return $e(()=>Promise.resolve().then(()=>kOt),void 0,import.meta.url).then(e=>e.vue())}}),ge.of({name:"Angular Template",load(){return $e(()=>Promise.resolve().then(()=>DOt),void 0,import.meta.url).then(e=>e.angular())}})];class z9{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=An(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(zhe(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 YI(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 nJe(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=YI(t)+YI(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Iy(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:nJe(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function tk(e,t){return n=>{for(let r=An(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 NI{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function xd(e){return e.selection.main.from}function zhe(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 A9=uf.define();function rJe(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:Ze.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const GI=new WeakMap;function iJe(e){if(!Array.isArray(e))return e;let t=GI.get(e);return t||GI.set(e,t=Iy(e)),t}const mx=pn.define(),p$=pn.define();class aJe{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=co(t,n),i=cc(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(co(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=co(t,0),x=cc(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=co(t,b);(Q==n[c]||Q==r[c])&&(i[c++]=b),b+=cc(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=co(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=Mde(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+=cc(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?cc(co(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 oJe{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=Ot.define({combine(e){return lm(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:sJe,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=>ZI(t(r),n(r)),optionClass:(t,n)=>r=>ZI(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function ZI(e,t){return e?t?e+" "+t:e:t}function sJe(e,t,n,r,i,a){let o=e.textDirection==mr.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 lJe(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 W5(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 cJe{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=lJe(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=W5(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:p$.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=W5(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=W5(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=>Wa(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&&OJe(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 uJe(e,t){return n=>new cJe(n,e,t)}function OJe(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 II(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function dJe(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 NI(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,h=a.filterStrict?new oJe(O):new aJe(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 NI(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):II(c.completion)>II(s)&&(o[o.length-1]=c),s=c.completion}return o}class yh{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 yh(this.options,DI(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=dJe(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 yh(s,DI(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:$Je,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new yh(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 yh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class gx{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new gx(mJe,"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",xd(n)).map(iJe)).map(l=>(this.active.find(u=>u.source==l)||new Io(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(U9));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!fJe(a,this.active)||s?o=yh.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 Io(l.source,0):l));for(let l of t.effects)l.is(Uhe)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new gx(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?hJe:pJe}}function fJe(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 hJe={"aria-autocomplete":"list"},pJe={};function DI(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const mJe=[];function Ahe(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(A9);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 Io{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=Ahe(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new Io(i.source,0)),r&4&&i.state==0&&(i=new Io(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(mx))i=new Io(i.source,1,a.value);else if(a.is(p$))i=new Io(i.source,0);else if(a.is(U9))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(xd(t.state))}}class jh extends Io{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=xd(t.state);if(s>o||!i||n&2&&(xd(t.startState)==this.from||s<this.limit))return new Io(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return gJe(i.validFor,t.state,a,o)?new jh(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new z9(t.state,s,!1)))?new jh(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:xd(t.state)):new Io(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new jh(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new Io(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function gJe(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):zhe(e,!0).test(i)}const U9=pn.define({map(e,t){return e.map(n=>n.map(t))}}),Uhe=pn.define(),Ca=Va.define({create(){return gx.start()},update(e,t){return e.update(t)},provide:e=>[T9.from(e,t=>t.tooltip),bt.contentAttributes.from(e,t=>t.attrs)]});function W9(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ca).active.find(i=>i.source==t.source);return r instanceof jh?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},rJe(e.state,n,r.from,r.to)),{annotations:A9.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const $Je=uJe(Ca,W9);function xb(e,t="option"){return n=>{let r=n.state.field(Ca,!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=lhe(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:Uhe.of(s)}),!0}}const yJe=e=>{let t=e.state.field(Ca,!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:W9(e,t.open.options[t.open.selected])},VI=e=>e.state.field(Ca,!1)?(e.dispatch({effects:mx.of(!0)}),!0):!1,vJe=e=>{let t=e.state.field(Ca,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:p$.of(null)}),!0)};class bJe{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const wJe=50,xJe=1e3,SJe=yi.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(Ca).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ca),n=e.state.facet(Pi);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ca)==t)return;let r=e.transactions.some(a=>{let o=Ahe(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>wJe&&Date.now()-o.time>xJe){for(let s of o.context.abortListeners)try{s()}catch(l){Wa(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(mx)))&&(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(Ca);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=xd(t),r=new z9(t,n,e.explicit,this.view),i=new bJe(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:p$.of(null)}),Wa(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(Ca);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=xd(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new jh(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 Io(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:U9.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ca,!1);if(t&&t.tooltip&&this.view.state.facet(Pi).closeOnBlur){let n=t.open&&lhe(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:p$.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:mx.of(!1)}),20),this.composing=0}}}),QJe=typeof navigator=="object"&&/Win/.test(navigator.platform),kJe=mO.highest(bt.domEventHandlers({keydown(e,t){let n=t.state.field(Ca,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(QJe&&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&&W9(t,r),!1}})),Whe=bt.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 _Je{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class Y9{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Wi.TrackDel),r=t.mapPos(this.to,1,Wi.TrackDel);return n==null||r==null?null:new Y9(this.field,n,r)}}class N9{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(KQ);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 Y9(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 _Je(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 N9(r,i)}}let PJe=en.widget({widget:new class extends Hc{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),TJe=en.mark({class:"cm-snippetField"});class cm{constructor(t,n){this.ranges=t,this.active=n,this.deco=en.set(t.map(r=>(r.from==r.to?PJe:TJe).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 cm(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 Dy=pn.define({map(e,t){return e&&e.map(t)}}),XJe=pn.define(),m$=Va.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(Dy))return n.value;if(n.is(XJe)&&e)return new cm(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=>bt.decorations.from(e,t=>t?t.deco:en.none)});function G9(e,t){return Ze.create(e.filter(n=>n.field==t).map(n=>Ze.range(n.from,n.to)))}function RJe(e){let t=N9.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:zn.of(o)},scrollIntoView:!0,annotations:r?[A9.of(r),Ni.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=G9(s,0)),s.some(u=>u.field>0)){let u=new cm(s,0),O=c.effects=[Dy.of(u)];n.state.field(m$,!1)===void 0&&O.push(pn.appendConfig.of([m$,zJe,AJe,Whe]))}n.dispatch(n.state.update(c))}}function Yhe(e){return({state:t,dispatch:n})=>{let r=t.field(m$,!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:G9(r.ranges,i),effects:Dy.of(a?null:new cm(r.ranges,i)),scrollIntoView:!0})),!0}}const EJe=({state:e,dispatch:t})=>e.field(m$,!1)?(t(e.update({effects:Dy.of(null)})),!0):!1,qJe=Yhe(1),jJe=Yhe(-1),CJe=[{key:"Tab",run:qJe,shift:jJe},{key:"Escape",run:EJe}],MI=Ot.define({combine(e){return e.length?e[0]:CJe}}),zJe=mO.highest(FQ.compute([MI],e=>e.facet(MI)));function sr(e,t){return Object.assign(Object.assign({},t),{apply:RJe(e)})}const AJe=bt.domEventHandlers({mousedown(e,t){let n=t.state.field(m$,!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:G9(n.ranges,i.field),effects:Dy.of(n.ranges.some(a=>a.field>i.field)?new cm(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),g$={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},fd=pn.define({map(e,t){let n=t.mapPos(e,-1,Wi.TrackAfter);return n??void 0}}),Z9=new class extends Cd{};Z9.startSide=1;Z9.endSide=-1;const Nhe=Va.define({create(){return hn.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(fd)&&(e=e.update({add:[Z9.range(n.value,n.value+1)]}));return e}});function Zin(){return[WJe,Nhe]}const Y5="()[]{}<>«»»«[]{}";function Ghe(e){for(let t=0;t<Y5.length;t+=2)if(Y5.charCodeAt(t)==e)return Y5.charAt(t+1);return Mde(e<128?e:e+1)}function Zhe(e,t){return e.languageDataAt("closeBrackets",t)[0]||g$}const UJe=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),WJe=bt.inputHandler.of((e,t,n,r)=>{if((UJe?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&cc(co(r,0))==1||t!=i.from||n!=i.to)return!1;let a=NJe(e.state,r);return a?(e.dispatch(a),!0):!1}),YJe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Zhe(e,e.selection.main.head).brackets||g$.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=GJe(e.doc,o.head);for(let l of r)if(l==s&&nk(e.doc,o.head)==Ghe(co(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Ze.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},Iin=[{key:"Backspace",run:YJe}];function NJe(e,t){let n=Zhe(e,e.selection.main.head),r=n.brackets||g$.brackets;for(let i of r){let a=Ghe(co(i,0));if(t==i)return a==i?DJe(e,i,r.indexOf(i+i+i)>-1,n):ZJe(e,i,a,n.before||g$.before);if(t==a&&Ihe(e,e.selection.main.from))return IJe(e,i,a)}return null}function Ihe(e,t){let n=!1;return e.field(Nhe).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function nk(e,t){let n=e.sliceString(t,t+2);return n.slice(0,cc(co(n,0)))}function GJe(e,t){let n=e.sliceString(t-2,t);return cc(co(n,0))==n.length?n:n.slice(1)}function ZJe(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:fd.of(o.to+t.length),range:Ze.range(o.anchor+t.length,o.head+t.length)};let s=nk(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:fd.of(o.head+t.length),range:Ze.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function IJe(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&nk(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Ze.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function DJe(e,t,n,r){let i=r.stringPrefixes||g$.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:fd.of(s.to+t.length),range:Ze.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=nk(e.doc,l),u;if(c==t){if(LI(e,l))return{changes:{insert:t+t,from:l},effects:fd.of(l+t.length),range:Ze.cursor(l+t.length)};if(Ihe(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:Ze.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=FI(e,l-2*t.length,i))>-1&&LI(e,u))return{changes:{insert:t+t+t+t,from:l},effects:fd.of(l+t.length),range:Ze.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=Zo.Word&&FI(e,l,i)>-1&&!VJe(e,l,t,i))return{changes:{insert:t+t,from:l},effects:fd.of(l+t.length),range:Ze.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function LI(e,t){let n=An(e).resolveInner(t+1);return n.parent&&n.from==t}function VJe(e,t,n,r){let i=An(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 FI(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=Zo.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))!=Zo.Word)return a}return-1}function Din(e={}){return[kJe,Ca,Pi.of(e),SJe,LJe,Whe]}const MJe=[{key:"Ctrl-Space",run:VI},{mac:"Alt-`",run:VI},{key:"Escape",run:vJe},{key:"ArrowDown",run:xb(!0)},{key:"ArrowUp",run:xb(!1)},{key:"PageDown",run:xb(!0,"page")},{key:"PageUp",run:xb(!1,"page")},{key:"Enter",run:yJe}],LJe=mO.highest(FQ.computeN([Pi],e=>e.facet(Pi).defaultKeymap?[MJe]:[]));class $x{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new $x(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=[[qt.contextHash,i]]}addChild(t,n){t.prop(qt.contextHash)!=this.hash&&(t=new an(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 an(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new an(ni.none,i,a,o,this.hashProp)})}}var Ie;(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"})(Ie||(Ie={}));class FJe{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let BJe=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 v0(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 BI(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==Ie.OrderedList?V9:D9)(n,t,!1);return r>0&&(e.type!=Ie.BulletList||I9(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const Dhe={[Ie.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(un(Ie.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(rs(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[Ie.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Ie.OrderedList]:BI,[Ie.BulletList]:BI,[Ie.Document](){return!0}};function rs(e){return e==32||e==9||e==10||e==13}function v0(e,t=0){for(;t<e.length&&rs(e.charCodeAt(t));)t++;return t}function HI(e,t,n){for(;t>n&&rs(e.charCodeAt(t-1));)t--;return t}function Vhe(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 Mhe(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function I9(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(!rs(a))return-1}return n&&e.next==45&&Bhe(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(epe.SetextHeading)>-1||r<3?-1:1}function Lhe(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function D9(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||rs(e.text.charCodeAt(e.pos+1)))&&(!n||Lhe(t,Ie.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function V9(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&&!rs(e.text.charCodeAt(r+1))||n&&!Lhe(t,Ie.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function Fhe(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 Bhe(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&&rs(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const M3=/^[ \t]*$/,Hhe=/-->/,Khe=/\?>/,L3=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Hhe],[/^\s*<\?/,Khe],[/^\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,M3],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,M3]];function Jhe(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=L3.length-(n?1:0);i<a;i++)if(L3[i][0].test(r))return i;return-1}function KI(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 DO(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Ie.CodeText?e[r].to=n:e.push(un(Ie.CodeText,t,n))}const Sb={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(DO(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){DO(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==Ie.CodeText?DO(o,c.from,c.to):o.push(c);s=[]}DO(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&&DO(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=Ie.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Ie.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=Vhe(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=HI(t.text,t.text.length,o),l=[un(Ie.CodeMark,r,r+a)];o<s&&l.push(un(Ie.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(un(Ie.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||DO(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&&DO(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Ie.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=Mhe(t);return n<0?!1:(e.startContext(Ie.Blockquote,t.pos),e.addNode(Ie.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(I9(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Ie.HorizontalRule,n),!0},BulletList(e,t){let n=D9(t,e,!1);if(n<0)return!1;e.block.type!=Ie.BulletList&&e.startContext(Ie.BulletList,t.basePos,t.next);let r=KI(t,t.pos+1);return e.startContext(Ie.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ie.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=V9(t,e,!1);if(n<0)return!1;e.block.type!=Ie.OrderedList&&e.startContext(Ie.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=KI(t,t.pos+n);return e.startContext(Ie.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ie.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=Fhe(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=HI(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!rs(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(Ie.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Ie.HeaderMark,o-r,a-r);let l=s.finish(Ie.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=Jhe(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=L3[n][1],a=[],o=i!=M3;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==Hhe?Ie.CommentBlock:i==Khe?Ie.ProcessingInstructionBlock:Ie.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class HJe{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+`
822
+ `);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 Xhe(n,t?t.state.tabSize:4,t?fx(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=Ehe(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=an.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:KKe,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new an(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 an(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Ehe(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 C9=Object.create(null),h$=[ni.none],KKe=new sm(h$),UI=[],WI=Object.create(null),qhe=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"]])qhe[e]=Che(C9,t);class jhe{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),qhe)}resolve(t){return t?this.table[t]||(this.table[t]=Che(this.extra,t)):0}}const JKe=new jhe(C9);function U5(e,t){UI.indexOf(e)>-1||(UI.push(e),console.warn(t))}function Che(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):U5(c,`Modifier ${c} used at start of tag`):l.length?U5(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:U5(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=WI[i];if(a)return a.id;let o=WI[i]=ni.define({id:h$.length,name:r,props:[wn({[r]:n})]});return h$.push(o),o.id}function eJe(e,t){let n=ni.define({id:h$.length,name:"Document",props:[Au.add(()=>e),_r.add(()=>r=>t.getIndent(r))],top:!0});return h$.push(n),n}mr.RTL,mr.LTR;function Xe(e){return new On(Ce.define(e))}function fu(e){return $e(()=>Promise.resolve().then(()=>klt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const tJe=[ge.of({name:"C",extensions:["c","h","ino"],load(){return $e(()=>Promise.resolve().then(()=>XV),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 $e(()=>Promise.resolve().then(()=>XV),void 0,import.meta.url).then(e=>e.cpp())}}),ge.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return fu("Cassandra")}}),ge.of({name:"CSS",extensions:["css"],load(){return $e(()=>Promise.resolve().then(()=>Ntt),void 0,import.meta.url).then(e=>e.css())}}),ge.of({name:"Go",extensions:["go"],load(){return $e(()=>import("./index-BVf3_vkI.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 $e(()=>Promise.resolve().then(()=>Ent),void 0,import.meta.url).then(e=>e.html())}}),ge.of({name:"Java",extensions:["java"],load(){return $e(()=>Promise.resolve().then(()=>Xlt),void 0,import.meta.url).then(e=>e.java())}}),ge.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return $e(()=>Promise.resolve().then(()=>kb),void 0,import.meta.url).then(e=>e.javascript())}}),ge.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return $e(()=>Promise.resolve().then(()=>Art),void 0,import.meta.url).then(e=>e.json())}}),ge.of({name:"JSX",extensions:["jsx"],load(){return $e(()=>Promise.resolve().then(()=>kb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),ge.of({name:"LESS",extensions:["less"],load(){return $e(()=>Promise.resolve().then(()=>Jnt),void 0,import.meta.url).then(e=>e.less())}}),ge.of({name:"Liquid",extensions:["liquid"],load(){return $e(()=>Promise.resolve().then(()=>pOt),void 0,import.meta.url).then(e=>e.liquid())}}),ge.of({name:"MariaDB SQL",load(){return fu("MariaSQL")}}),ge.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return $e(()=>Promise.resolve().then(()=>Gnt),void 0,import.meta.url).then(e=>e.markdown())}}),ge.of({name:"MS SQL",load(){return fu("MSSQL")}}),ge.of({name:"MySQL",load(){return fu("MySQL")}}),ge.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return $e(()=>Promise.resolve().then(()=>Vut),void 0,import.meta.url).then(e=>e.php())}}),ge.of({name:"PLSQL",extensions:["pls"],load(){return fu("PLSQL")}}),ge.of({name:"PostgreSQL",load(){return fu("PostgreSQL")}}),ge.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return $e(()=>Promise.resolve().then(()=>pst),void 0,import.meta.url).then(e=>e.python())}}),ge.of({name:"Rust",extensions:["rs"],load(){return $e(()=>Promise.resolve().then(()=>Blt),void 0,import.meta.url).then(e=>e.rust())}}),ge.of({name:"Sass",extensions:["sass"],load(){return $e(()=>Promise.resolve().then(()=>DD),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),ge.of({name:"SCSS",extensions:["scss"],load(){return $e(()=>Promise.resolve().then(()=>DD),void 0,import.meta.url).then(e=>e.sass())}}),ge.of({name:"SQL",extensions:["sql"],load(){return fu("StandardSQL")}}),ge.of({name:"SQLite",load(){return fu("SQLite")}}),ge.of({name:"TSX",extensions:["tsx"],load(){return $e(()=>Promise.resolve().then(()=>kb),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 $e(()=>Promise.resolve().then(()=>kb),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),ge.of({name:"WebAssembly",extensions:["wat","wast"],load(){return $e(()=>Promise.resolve().then(()=>$Ot),void 0,import.meta.url).then(e=>e.wast())}}),ge.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return $e(()=>Promise.resolve().then(()=>Ast),void 0,import.meta.url).then(e=>e.xml())}}),ge.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return $e(()=>import("./index-BQ-anM-O.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 $e(()=>Promise.resolve().then(()=>Mft),void 0,import.meta.url).then(e=>Xe(e.apl))}}),ge.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return $e(()=>Promise.resolve().then(()=>Lft),void 0,import.meta.url).then(e=>Xe(e.asciiArmor))}}),ge.of({name:"ASN.1",extensions:["asn","asn1"],load(){return $e(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>Xe(e.asn1({})))}}),ge.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return $e(()=>Promise.resolve().then(()=>Jft),void 0,import.meta.url).then(e=>Xe(e.asterisk))}}),ge.of({name:"Brainfuck",extensions:["b","bf"],load(){return $e(()=>Promise.resolve().then(()=>tht),void 0,import.meta.url).then(e=>Xe(e.brainfuck))}}),ge.of({name:"Cobol",extensions:["cob","cpy"],load(){return $e(()=>Promise.resolve().then(()=>Tht),void 0,import.meta.url).then(e=>Xe(e.cobol))}}),ge.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return $e(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>Xe(e.csharp))}}),ge.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return $e(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Xe(e.clojure))}}),ge.of({name:"ClojureScript",extensions:["cljs"],load(){return $e(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Xe(e.clojure))}}),ge.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return $e(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>Xe(e.gss))}}),ge.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return $e(()=>Promise.resolve().then(()=>vht),void 0,import.meta.url).then(e=>Xe(e.cmake))}}),ge.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return $e(()=>Promise.resolve().then(()=>Ght),void 0,import.meta.url).then(e=>Xe(e.coffeeScript))}}),ge.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return $e(()=>Promise.resolve().then(()=>Lht),void 0,import.meta.url).then(e=>Xe(e.commonLisp))}}),ge.of({name:"Cypher",extensions:["cyp","cypher"],load(){return $e(()=>Promise.resolve().then(()=>dpt),void 0,import.meta.url).then(e=>Xe(e.cypher))}}),ge.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return $e(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>Xe(e.cython))}}),ge.of({name:"Crystal",extensions:["cr"],load(){return $e(()=>Promise.resolve().then(()=>opt),void 0,import.meta.url).then(e=>Xe(e.crystal))}}),ge.of({name:"D",extensions:["d"],load(){return $e(()=>Promise.resolve().then(()=>ypt),void 0,import.meta.url).then(e=>Xe(e.d))}}),ge.of({name:"Dart",extensions:["dart"],load(){return $e(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>Xe(e.dart))}}),ge.of({name:"diff",extensions:["diff","patch"],load(){return $e(()=>Promise.resolve().then(()=>vpt),void 0,import.meta.url).then(e=>Xe(e.diff))}}),ge.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return $e(()=>Promise.resolve().then(()=>qpt),void 0,import.meta.url).then(e=>Xe(e.dockerFile))}}),ge.of({name:"DTD",extensions:["dtd"],load(){return $e(()=>Promise.resolve().then(()=>zpt),void 0,import.meta.url).then(e=>Xe(e.dtd))}}),ge.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return $e(()=>Promise.resolve().then(()=>Npt),void 0,import.meta.url).then(e=>Xe(e.dylan))}}),ge.of({name:"EBNF",load(){return $e(()=>Promise.resolve().then(()=>Gpt),void 0,import.meta.url).then(e=>Xe(e.ebnf))}}),ge.of({name:"ECL",extensions:["ecl"],load(){return $e(()=>Promise.resolve().then(()=>Bpt),void 0,import.meta.url).then(e=>Xe(e.ecl))}}),ge.of({name:"edn",extensions:["edn"],load(){return $e(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Xe(e.clojure))}}),ge.of({name:"Eiffel",extensions:["e"],load(){return $e(()=>Promise.resolve().then(()=>nmt),void 0,import.meta.url).then(e=>Xe(e.eiffel))}}),ge.of({name:"Elm",extensions:["elm"],load(){return $e(()=>Promise.resolve().then(()=>fmt),void 0,import.meta.url).then(e=>Xe(e.elm))}}),ge.of({name:"Erlang",extensions:["erl"],load(){return $e(()=>Promise.resolve().then(()=>Amt),void 0,import.meta.url).then(e=>Xe(e.erlang))}}),ge.of({name:"Esper",load(){return $e(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>Xe(e.esper))}}),ge.of({name:"Factor",extensions:["factor"],load(){return $e(()=>Promise.resolve().then(()=>Umt),void 0,import.meta.url).then(e=>Xe(e.factor))}}),ge.of({name:"FCL",load(){return $e(()=>Promise.resolve().then(()=>Zmt),void 0,import.meta.url).then(e=>Xe(e.fcl))}}),ge.of({name:"Forth",extensions:["forth","fth","4th"],load(){return $e(()=>Promise.resolve().then(()=>Vmt),void 0,import.meta.url).then(e=>Xe(e.forth))}}),ge.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return $e(()=>Promise.resolve().then(()=>Jmt),void 0,import.meta.url).then(e=>Xe(e.fortran))}}),ge.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return $e(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Xe(e.fSharp))}}),ge.of({name:"Gas",extensions:["s"],load(){return $e(()=>Promise.resolve().then(()=>tgt),void 0,import.meta.url).then(e=>Xe(e.gas))}}),ge.of({name:"Gherkin",extensions:["feature"],load(){return $e(()=>Promise.resolve().then(()=>ngt),void 0,import.meta.url).then(e=>Xe(e.gherkin))}}),ge.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return $e(()=>Promise.resolve().then(()=>fgt),void 0,import.meta.url).then(e=>Xe(e.groovy))}}),ge.of({name:"Haskell",extensions:["hs"],load(){return $e(()=>Promise.resolve().then(()=>vgt),void 0,import.meta.url).then(e=>Xe(e.haskell))}}),ge.of({name:"Haxe",extensions:["hx"],load(){return $e(()=>Promise.resolve().then(()=>JM),void 0,import.meta.url).then(e=>Xe(e.haxe))}}),ge.of({name:"HXML",extensions:["hxml"],load(){return $e(()=>Promise.resolve().then(()=>JM),void 0,import.meta.url).then(e=>Xe(e.hxml))}}),ge.of({name:"HTTP",load(){return $e(()=>Promise.resolve().then(()=>Zgt),void 0,import.meta.url).then(e=>Xe(e.http))}}),ge.of({name:"IDL",extensions:["pro"],load(){return $e(()=>Promise.resolve().then(()=>Bgt),void 0,import.meta.url).then(e=>Xe(e.idl))}}),ge.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return $e(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>Xe(e.jsonld))}}),ge.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return $e(()=>Promise.resolve().then(()=>e0t),void 0,import.meta.url).then(e=>Xe(e.jinja2))}}),ge.of({name:"Julia",extensions:["jl"],load(){return $e(()=>Promise.resolve().then(()=>Q0t),void 0,import.meta.url).then(e=>Xe(e.julia))}}),ge.of({name:"Kotlin",extensions:["kt","kts"],load(){return $e(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>Xe(e.kotlin))}}),ge.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return $e(()=>Promise.resolve().then(()=>T0t),void 0,import.meta.url).then(e=>Xe(e.liveScript))}}),ge.of({name:"Lua",extensions:["lua"],load(){return $e(()=>Promise.resolve().then(()=>A0t),void 0,import.meta.url).then(e=>Xe(e.lua))}}),ge.of({name:"mIRC",extensions:["mrc"],load(){return $e(()=>Promise.resolve().then(()=>o$t),void 0,import.meta.url).then(e=>Xe(e.mirc))}}),ge.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return $e(()=>Promise.resolve().then(()=>D0t),void 0,import.meta.url).then(e=>Xe(e.mathematica))}}),ge.of({name:"Modelica",extensions:["mo"],load(){return $e(()=>Promise.resolve().then(()=>m$t),void 0,import.meta.url).then(e=>Xe(e.modelica))}}),ge.of({name:"MUMPS",extensions:["mps"],load(){return $e(()=>Promise.resolve().then(()=>E$t),void 0,import.meta.url).then(e=>Xe(e.mumps))}}),ge.of({name:"Mbox",extensions:["mbox"],load(){return $e(()=>Promise.resolve().then(()=>r$t),void 0,import.meta.url).then(e=>Xe(e.mbox))}}),ge.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return $e(()=>Promise.resolve().then(()=>A$t),void 0,import.meta.url).then(e=>Xe(e.nginx))}}),ge.of({name:"NSIS",extensions:["nsh","nsi"],load(){return $e(()=>Promise.resolve().then(()=>U$t),void 0,import.meta.url).then(e=>Xe(e.nsis))}}),ge.of({name:"NTriples",extensions:["nt","nq"],load(){return $e(()=>Promise.resolve().then(()=>W$t),void 0,import.meta.url).then(e=>Xe(e.ntriples))}}),ge.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return $e(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>Xe(e.objectiveC))}}),ge.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return $e(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>Xe(e.objectiveCpp))}}),ge.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return $e(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Xe(e.oCaml))}}),ge.of({name:"Octave",extensions:["m"],load(){return $e(()=>Promise.resolve().then(()=>B$t),void 0,import.meta.url).then(e=>Xe(e.octave))}}),ge.of({name:"Oz",extensions:["oz"],load(){return $e(()=>Promise.resolve().then(()=>lyt),void 0,import.meta.url).then(e=>Xe(e.oz))}}),ge.of({name:"Pascal",extensions:["p","pas"],load(){return $e(()=>Promise.resolve().then(()=>hyt),void 0,import.meta.url).then(e=>Xe(e.pascal))}}),ge.of({name:"Perl",extensions:["pl","pm"],load(){return $e(()=>Promise.resolve().then(()=>pyt),void 0,import.meta.url).then(e=>Xe(e.perl))}}),ge.of({name:"Pig",extensions:["pig"],load(){return $e(()=>Promise.resolve().then(()=>$yt),void 0,import.meta.url).then(e=>Xe(e.pig))}}),ge.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return $e(()=>Promise.resolve().then(()=>jyt),void 0,import.meta.url).then(e=>Xe(e.powerShell))}}),ge.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return $e(()=>Promise.resolve().then(()=>Cyt),void 0,import.meta.url).then(e=>Xe(e.properties))}}),ge.of({name:"ProtoBuf",extensions:["proto"],load(){return $e(()=>Promise.resolve().then(()=>Yyt),void 0,import.meta.url).then(e=>Xe(e.protobuf))}}),ge.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return $e(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([7,8]),import.meta.url).then(e=>Xe(e.pug))}}),ge.of({name:"Puppet",extensions:["pp"],load(){return $e(()=>Promise.resolve().then(()=>Zyt),void 0,import.meta.url).then(e=>Xe(e.puppet))}}),ge.of({name:"Q",extensions:["q"],load(){return $e(()=>Promise.resolve().then(()=>Hyt),void 0,import.meta.url).then(e=>Xe(e.q))}}),ge.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return $e(()=>Promise.resolve().then(()=>ivt),void 0,import.meta.url).then(e=>Xe(e.r))}}),ge.of({name:"RPM Changes",load(){return $e(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Xe(e.rpmChanges))}}),ge.of({name:"RPM Spec",extensions:["spec"],load(){return $e(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Xe(e.rpmSpec))}}),ge.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return $e(()=>Promise.resolve().then(()=>fvt),void 0,import.meta.url).then(e=>Xe(e.ruby))}}),ge.of({name:"SAS",extensions:["sas"],load(){return $e(()=>Promise.resolve().then(()=>gvt),void 0,import.meta.url).then(e=>Xe(e.sas))}}),ge.of({name:"Scala",extensions:["scala"],load(){return $e(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>Xe(e.scala))}}),ge.of({name:"Scheme",extensions:["scm","ss"],load(){return $e(()=>Promise.resolve().then(()=>Xvt),void 0,import.meta.url).then(e=>Xe(e.scheme))}}),ge.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return $e(()=>Promise.resolve().then(()=>jvt),void 0,import.meta.url).then(e=>Xe(e.shell))}}),ge.of({name:"Sieve",extensions:["siv","sieve"],load(){return $e(()=>Promise.resolve().then(()=>Wvt),void 0,import.meta.url).then(e=>Xe(e.sieve))}}),ge.of({name:"Smalltalk",extensions:["st"],load(){return $e(()=>Promise.resolve().then(()=>Gvt),void 0,import.meta.url).then(e=>Xe(e.smalltalk))}}),ge.of({name:"Solr",load(){return $e(()=>Promise.resolve().then(()=>Fvt),void 0,import.meta.url).then(e=>Xe(e.solr))}}),ge.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return $e(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Xe(e.sml))}}),ge.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return $e(()=>Promise.resolve().then(()=>nbt),void 0,import.meta.url).then(e=>Xe(e.sparql))}}),ge.of({name:"Spreadsheet",alias:["excel","formula"],load(){return $e(()=>Promise.resolve().then(()=>rbt),void 0,import.meta.url).then(e=>Xe(e.spreadsheet))}}),ge.of({name:"Squirrel",extensions:["nut"],load(){return $e(()=>Promise.resolve().then(()=>LO),void 0,import.meta.url).then(e=>Xe(e.squirrel))}}),ge.of({name:"Stylus",extensions:["styl"],load(){return $e(()=>Promise.resolve().then(()=>Qbt),void 0,import.meta.url).then(e=>Xe(e.stylus))}}),ge.of({name:"Swift",extensions:["swift"],load(){return $e(()=>Promise.resolve().then(()=>Dbt),void 0,import.meta.url).then(e=>Xe(e.swift))}}),ge.of({name:"sTeX",load(){return $e(()=>Promise.resolve().then(()=>IL),void 0,import.meta.url).then(e=>Xe(e.stex))}}),ge.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return $e(()=>Promise.resolve().then(()=>IL),void 0,import.meta.url).then(e=>Xe(e.stex))}}),ge.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return $e(()=>Promise.resolve().then(()=>uF),void 0,import.meta.url).then(e=>Xe(e.verilog))}}),ge.of({name:"Tcl",extensions:["tcl"],load(){return $e(()=>Promise.resolve().then(()=>Fbt),void 0,import.meta.url).then(e=>Xe(e.tcl))}}),ge.of({name:"Textile",extensions:["textile"],load(){return $e(()=>Promise.resolve().then(()=>Jbt),void 0,import.meta.url).then(e=>Xe(e.textile))}}),ge.of({name:"TiddlyWiki",load(){return $e(()=>Promise.resolve().then(()=>vwt),void 0,import.meta.url).then(e=>Xe(e.tiddlyWiki))}}),ge.of({name:"Tiki wiki",load(){return $e(()=>Promise.resolve().then(()=>_wt),void 0,import.meta.url).then(e=>Xe(e.tiki))}}),ge.of({name:"TOML",extensions:["toml"],load(){return $e(()=>Promise.resolve().then(()=>Pwt),void 0,import.meta.url).then(e=>Xe(e.toml))}}),ge.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return $e(()=>Promise.resolve().then(()=>Rwt),void 0,import.meta.url).then(e=>Xe(e.troff))}}),ge.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return $e(()=>Promise.resolve().then(()=>Fwt),void 0,import.meta.url).then(e=>Xe(e.ttcn))}}),ge.of({name:"TTCN_CFG",extensions:["cfg"],load(){return $e(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>Xe(e.ttcnCfg))}}),ge.of({name:"Turtle",extensions:["ttl"],load(){return $e(()=>Promise.resolve().then(()=>Kwt),void 0,import.meta.url).then(e=>Xe(e.turtle))}}),ge.of({name:"Web IDL",extensions:["webidl"],load(){return $e(()=>Promise.resolve().then(()=>D1t),void 0,import.meta.url).then(e=>Xe(e.webIDL))}}),ge.of({name:"VB.NET",extensions:["vb"],load(){return $e(()=>Promise.resolve().then(()=>f1t),void 0,import.meta.url).then(e=>Xe(e.vb))}}),ge.of({name:"VBScript",extensions:["vbs"],load(){return $e(()=>Promise.resolve().then(()=>p1t),void 0,import.meta.url).then(e=>Xe(e.vbScript))}}),ge.of({name:"Velocity",extensions:["vtl"],load(){return $e(()=>Promise.resolve().then(()=>$1t),void 0,import.meta.url).then(e=>Xe(e.velocity))}}),ge.of({name:"Verilog",extensions:["v"],load(){return $e(()=>Promise.resolve().then(()=>uF),void 0,import.meta.url).then(e=>Xe(e.verilog))}}),ge.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return $e(()=>Promise.resolve().then(()=>_1t),void 0,import.meta.url).then(e=>Xe(e.vhdl))}}),ge.of({name:"XQuery",extensions:["xy","xquery"],load(){return $e(()=>Promise.resolve().then(()=>txt),void 0,import.meta.url).then(e=>Xe(e.xQuery))}}),ge.of({name:"Yacas",extensions:["ys"],load(){return $e(()=>Promise.resolve().then(()=>Oxt),void 0,import.meta.url).then(e=>Xe(e.yacas))}}),ge.of({name:"Z80",extensions:["z80"],load(){return $e(()=>Promise.resolve().then(()=>mxt),void 0,import.meta.url).then(e=>Xe(e.z80))}}),ge.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return $e(()=>Promise.resolve().then(()=>IT),void 0,import.meta.url).then(e=>Xe(e.mscgen))}}),ge.of({name:"Xù",extensions:["xu"],load(){return $e(()=>Promise.resolve().then(()=>IT),void 0,import.meta.url).then(e=>Xe(e.xu))}}),ge.of({name:"MsGenny",extensions:["msgenny"],load(){return $e(()=>Promise.resolve().then(()=>IT),void 0,import.meta.url).then(e=>Xe(e.msgenny))}}),ge.of({name:"Vue",extensions:["vue"],load(){return $e(()=>Promise.resolve().then(()=>kOt),void 0,import.meta.url).then(e=>e.vue())}}),ge.of({name:"Angular Template",load(){return $e(()=>Promise.resolve().then(()=>DOt),void 0,import.meta.url).then(e=>e.angular())}})];class z9{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=An(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(zhe(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 YI(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 nJe(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=YI(t)+YI(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Iy(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:nJe(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function tk(e,t){return n=>{for(let r=An(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 NI{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function xd(e){return e.selection.main.from}function zhe(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 A9=uf.define();function rJe(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:Ze.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const GI=new WeakMap;function iJe(e){if(!Array.isArray(e))return e;let t=GI.get(e);return t||GI.set(e,t=Iy(e)),t}const mx=pn.define(),p$=pn.define();class aJe{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=co(t,n),i=cc(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(co(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=co(t,0),x=cc(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=co(t,b);(Q==n[c]||Q==r[c])&&(i[c++]=b),b+=cc(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=co(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=Mde(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+=cc(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?cc(co(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 oJe{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=Ot.define({combine(e){return lm(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:sJe,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=>ZI(t(r),n(r)),optionClass:(t,n)=>r=>ZI(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function ZI(e,t){return e?t?e+" "+t:e:t}function sJe(e,t,n,r,i,a){let o=e.textDirection==mr.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 lJe(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 W5(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 cJe{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=lJe(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=W5(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:p$.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=W5(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=W5(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=>Wa(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&&OJe(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 uJe(e,t){return n=>new cJe(n,e,t)}function OJe(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 II(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function dJe(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 NI(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,h=a.filterStrict?new oJe(O):new aJe(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 NI(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):II(c.completion)>II(s)&&(o[o.length-1]=c),s=c.completion}return o}class yh{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 yh(this.options,DI(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=dJe(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 yh(s,DI(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:$Je,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new yh(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 yh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class gx{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new gx(mJe,"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",xd(n)).map(iJe)).map(l=>(this.active.find(u=>u.source==l)||new Io(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(U9));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!fJe(a,this.active)||s?o=yh.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 Io(l.source,0):l));for(let l of t.effects)l.is(Uhe)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new gx(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?hJe:pJe}}function fJe(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 hJe={"aria-autocomplete":"list"},pJe={};function DI(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const mJe=[];function Ahe(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(A9);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 Io{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=Ahe(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new Io(i.source,0)),r&4&&i.state==0&&(i=new Io(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(mx))i=new Io(i.source,1,a.value);else if(a.is(p$))i=new Io(i.source,0);else if(a.is(U9))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(xd(t.state))}}class jh extends Io{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=xd(t.state);if(s>o||!i||n&2&&(xd(t.startState)==this.from||s<this.limit))return new Io(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return gJe(i.validFor,t.state,a,o)?new jh(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new z9(t.state,s,!1)))?new jh(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:xd(t.state)):new Io(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new jh(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new Io(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function gJe(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):zhe(e,!0).test(i)}const U9=pn.define({map(e,t){return e.map(n=>n.map(t))}}),Uhe=pn.define(),Ca=Va.define({create(){return gx.start()},update(e,t){return e.update(t)},provide:e=>[T9.from(e,t=>t.tooltip),bt.contentAttributes.from(e,t=>t.attrs)]});function W9(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ca).active.find(i=>i.source==t.source);return r instanceof jh?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},rJe(e.state,n,r.from,r.to)),{annotations:A9.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const $Je=uJe(Ca,W9);function xb(e,t="option"){return n=>{let r=n.state.field(Ca,!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=lhe(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:Uhe.of(s)}),!0}}const yJe=e=>{let t=e.state.field(Ca,!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:W9(e,t.open.options[t.open.selected])},VI=e=>e.state.field(Ca,!1)?(e.dispatch({effects:mx.of(!0)}),!0):!1,vJe=e=>{let t=e.state.field(Ca,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:p$.of(null)}),!0)};class bJe{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const wJe=50,xJe=1e3,SJe=yi.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(Ca).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ca),n=e.state.facet(Pi);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ca)==t)return;let r=e.transactions.some(a=>{let o=Ahe(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>wJe&&Date.now()-o.time>xJe){for(let s of o.context.abortListeners)try{s()}catch(l){Wa(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(mx)))&&(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(Ca);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=xd(t),r=new z9(t,n,e.explicit,this.view),i=new bJe(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:p$.of(null)}),Wa(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(Ca);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=xd(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new jh(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 Io(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:U9.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ca,!1);if(t&&t.tooltip&&this.view.state.facet(Pi).closeOnBlur){let n=t.open&&lhe(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:p$.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:mx.of(!1)}),20),this.composing=0}}}),QJe=typeof navigator=="object"&&/Win/.test(navigator.platform),kJe=mO.highest(bt.domEventHandlers({keydown(e,t){let n=t.state.field(Ca,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(QJe&&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&&W9(t,r),!1}})),Whe=bt.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 _Je{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class Y9{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Wi.TrackDel),r=t.mapPos(this.to,1,Wi.TrackDel);return n==null||r==null?null:new Y9(this.field,n,r)}}class N9{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(KQ);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 Y9(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 _Je(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 N9(r,i)}}let PJe=en.widget({widget:new class extends Hc{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),TJe=en.mark({class:"cm-snippetField"});class cm{constructor(t,n){this.ranges=t,this.active=n,this.deco=en.set(t.map(r=>(r.from==r.to?PJe:TJe).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 cm(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 Dy=pn.define({map(e,t){return e&&e.map(t)}}),XJe=pn.define(),m$=Va.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(Dy))return n.value;if(n.is(XJe)&&e)return new cm(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=>bt.decorations.from(e,t=>t?t.deco:en.none)});function G9(e,t){return Ze.create(e.filter(n=>n.field==t).map(n=>Ze.range(n.from,n.to)))}function RJe(e){let t=N9.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:zn.of(o)},scrollIntoView:!0,annotations:r?[A9.of(r),Ni.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=G9(s,0)),s.some(u=>u.field>0)){let u=new cm(s,0),O=c.effects=[Dy.of(u)];n.state.field(m$,!1)===void 0&&O.push(pn.appendConfig.of([m$,zJe,AJe,Whe]))}n.dispatch(n.state.update(c))}}function Yhe(e){return({state:t,dispatch:n})=>{let r=t.field(m$,!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:G9(r.ranges,i),effects:Dy.of(a?null:new cm(r.ranges,i)),scrollIntoView:!0})),!0}}const EJe=({state:e,dispatch:t})=>e.field(m$,!1)?(t(e.update({effects:Dy.of(null)})),!0):!1,qJe=Yhe(1),jJe=Yhe(-1),CJe=[{key:"Tab",run:qJe,shift:jJe},{key:"Escape",run:EJe}],MI=Ot.define({combine(e){return e.length?e[0]:CJe}}),zJe=mO.highest(FQ.compute([MI],e=>e.facet(MI)));function sr(e,t){return Object.assign(Object.assign({},t),{apply:RJe(e)})}const AJe=bt.domEventHandlers({mousedown(e,t){let n=t.state.field(m$,!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:G9(n.ranges,i.field),effects:Dy.of(n.ranges.some(a=>a.field>i.field)?new cm(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),g$={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},fd=pn.define({map(e,t){let n=t.mapPos(e,-1,Wi.TrackAfter);return n??void 0}}),Z9=new class extends Cd{};Z9.startSide=1;Z9.endSide=-1;const Nhe=Va.define({create(){return hn.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(fd)&&(e=e.update({add:[Z9.range(n.value,n.value+1)]}));return e}});function Zin(){return[WJe,Nhe]}const Y5="()[]{}<>«»»«[]{}";function Ghe(e){for(let t=0;t<Y5.length;t+=2)if(Y5.charCodeAt(t)==e)return Y5.charAt(t+1);return Mde(e<128?e:e+1)}function Zhe(e,t){return e.languageDataAt("closeBrackets",t)[0]||g$}const UJe=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),WJe=bt.inputHandler.of((e,t,n,r)=>{if((UJe?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&cc(co(r,0))==1||t!=i.from||n!=i.to)return!1;let a=NJe(e.state,r);return a?(e.dispatch(a),!0):!1}),YJe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Zhe(e,e.selection.main.head).brackets||g$.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=GJe(e.doc,o.head);for(let l of r)if(l==s&&nk(e.doc,o.head)==Ghe(co(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Ze.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},Iin=[{key:"Backspace",run:YJe}];function NJe(e,t){let n=Zhe(e,e.selection.main.head),r=n.brackets||g$.brackets;for(let i of r){let a=Ghe(co(i,0));if(t==i)return a==i?DJe(e,i,r.indexOf(i+i+i)>-1,n):ZJe(e,i,a,n.before||g$.before);if(t==a&&Ihe(e,e.selection.main.from))return IJe(e,i,a)}return null}function Ihe(e,t){let n=!1;return e.field(Nhe).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function nk(e,t){let n=e.sliceString(t,t+2);return n.slice(0,cc(co(n,0)))}function GJe(e,t){let n=e.sliceString(t-2,t);return cc(co(n,0))==n.length?n:n.slice(1)}function ZJe(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:fd.of(o.to+t.length),range:Ze.range(o.anchor+t.length,o.head+t.length)};let s=nk(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:fd.of(o.head+t.length),range:Ze.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function IJe(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&nk(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Ze.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function DJe(e,t,n,r){let i=r.stringPrefixes||g$.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:fd.of(s.to+t.length),range:Ze.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=nk(e.doc,l),u;if(c==t){if(LI(e,l))return{changes:{insert:t+t,from:l},effects:fd.of(l+t.length),range:Ze.cursor(l+t.length)};if(Ihe(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:Ze.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=FI(e,l-2*t.length,i))>-1&&LI(e,u))return{changes:{insert:t+t+t+t,from:l},effects:fd.of(l+t.length),range:Ze.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=Zo.Word&&FI(e,l,i)>-1&&!VJe(e,l,t,i))return{changes:{insert:t+t,from:l},effects:fd.of(l+t.length),range:Ze.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function LI(e,t){let n=An(e).resolveInner(t+1);return n.parent&&n.from==t}function VJe(e,t,n,r){let i=An(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 FI(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=Zo.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))!=Zo.Word)return a}return-1}function Din(e={}){return[kJe,Ca,Pi.of(e),SJe,LJe,Whe]}const MJe=[{key:"Ctrl-Space",run:VI},{mac:"Alt-`",run:VI},{key:"Escape",run:vJe},{key:"ArrowDown",run:xb(!0)},{key:"ArrowUp",run:xb(!1)},{key:"PageDown",run:xb(!0,"page")},{key:"PageUp",run:xb(!1,"page")},{key:"Enter",run:yJe}],LJe=mO.highest(FQ.computeN([Pi],e=>e.facet(Pi).defaultKeymap?[MJe]:[]));class $x{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new $x(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=[[qt.contextHash,i]]}addChild(t,n){t.prop(qt.contextHash)!=this.hash&&(t=new an(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 an(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new an(ni.none,i,a,o,this.hashProp)})}}var Ie;(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"})(Ie||(Ie={}));class FJe{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let BJe=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 v0(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 BI(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==Ie.OrderedList?V9:D9)(n,t,!1);return r>0&&(e.type!=Ie.BulletList||I9(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const Dhe={[Ie.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(un(Ie.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(rs(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[Ie.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Ie.OrderedList]:BI,[Ie.BulletList]:BI,[Ie.Document](){return!0}};function rs(e){return e==32||e==9||e==10||e==13}function v0(e,t=0){for(;t<e.length&&rs(e.charCodeAt(t));)t++;return t}function HI(e,t,n){for(;t>n&&rs(e.charCodeAt(t-1));)t--;return t}function Vhe(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 Mhe(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function I9(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(!rs(a))return-1}return n&&e.next==45&&Bhe(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(epe.SetextHeading)>-1||r<3?-1:1}function Lhe(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function D9(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||rs(e.text.charCodeAt(e.pos+1)))&&(!n||Lhe(t,Ie.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function V9(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&&!rs(e.text.charCodeAt(r+1))||n&&!Lhe(t,Ie.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function Fhe(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 Bhe(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&&rs(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const M3=/^[ \t]*$/,Hhe=/-->/,Khe=/\?>/,L3=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Hhe],[/^\s*<\?/,Khe],[/^\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,M3],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,M3]];function Jhe(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=L3.length-(n?1:0);i<a;i++)if(L3[i][0].test(r))return i;return-1}function KI(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 DO(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Ie.CodeText?e[r].to=n:e.push(un(Ie.CodeText,t,n))}const Sb={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(DO(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){DO(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==Ie.CodeText?DO(o,c.from,c.to):o.push(c);s=[]}DO(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&&DO(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=Ie.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Ie.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=Vhe(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=HI(t.text,t.text.length,o),l=[un(Ie.CodeMark,r,r+a)];o<s&&l.push(un(Ie.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(un(Ie.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||DO(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&&DO(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Ie.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=Mhe(t);return n<0?!1:(e.startContext(Ie.Blockquote,t.pos),e.addNode(Ie.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(I9(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Ie.HorizontalRule,n),!0},BulletList(e,t){let n=D9(t,e,!1);if(n<0)return!1;e.block.type!=Ie.BulletList&&e.startContext(Ie.BulletList,t.basePos,t.next);let r=KI(t,t.pos+1);return e.startContext(Ie.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ie.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=V9(t,e,!1);if(n<0)return!1;e.block.type!=Ie.OrderedList&&e.startContext(Ie.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=KI(t,t.pos+n);return e.startContext(Ie.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ie.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=Fhe(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=HI(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!rs(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(Ie.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Ie.HeaderMark,o-r,a-r);let l=s.finish(Ie.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=Jhe(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=L3[n][1],a=[],o=i!=M3;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==Hhe?Ie.CommentBlock:i==Khe?Ie.ProcessingInstructionBlock:Ie.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class HJe{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+`
823
823
  `+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)&&v0(n.content,this.pos)==n.content.length?this.complete(t,n,n.content.length):!1}complete(t,n,r){return t.addLeafElement(n,un(Ie.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(cpe(t,this.pos,this.start,!0)))return-1;if(t.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(un(Ie.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(spe(t,v0(t,this.pos),this.start)))return-1}else if(this.stage==2){let n=v0(t,this.pos),r=0;if(n>this.pos){let i=lpe(t,n,this.start);if(i){let a=N5(t,i.to-this.start);a>0&&(this.nextStage(i),r=a)}}return r||(r=N5(t,this.pos)),r>0&&r<t.length?r:-1}else return N5(t,this.pos)}}}function N5(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!rs(n))return-1}return t}class KJe{nextLine(t,n,r){let i=n.depth<t.stack.length?-1:Bhe(n),a=n.next;if(i<0)return!1;let o=un(Ie.HeaderMark,t.lineStart+n.pos,t.lineStart+i);return t.nextLine(),t.addLeafElement(r,un(a==61?Ie.SetextHeading1:Ie.SetextHeading2,r.start,t.prevLineEnd(),[...t.parser.parseInline(r.content,r.start),o])),!0}finish(){return!1}}const epe={LinkReference(e,t){return t.content.charCodeAt(0)==91?new HJe(t):null},SetextHeading(){return new KJe}},JJe=[(e,t)=>Fhe(t)>=0,(e,t)=>Vhe(t)>=0,(e,t)=>Mhe(t)>=0,(e,t)=>D9(t,e,!0)>=0,(e,t)=>V9(t,e,!0)>=0,(e,t)=>I9(t,e,!0)>=0,(e,t)=>Jhe(t,e,!0)>=0],eet={text:"",end:0};class tet{constructor(t,n,r,i){this.parser=t,this.input=n,this.ranges=i,this.line=new BJe,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=$x.create(Ie.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new aet(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 FJe(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+=`
824
824
  `+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=upe(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=eet;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 "+Ie[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==`
825
825
  `?"":n;else{let i=n.indexOf(`
@@ -854,7 +854,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
854
854
  `,o.end),l=t.slice(o.end,s===-1?t.length:s);if(XSt.test(l))return za;const c=l.length-l.replace(RSt,"").length,u={start:o.start,end:o.end+c},O=e.typingAt;if(O!==null){const d=O+vp(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]===Ck?{arm:u,typingAt:n,value:""}:{arm:u,typingAt:null,value:""}}const Co=e=>e.typingAt!==null,USt=e=>e.arm!==null;function yf(e){return e.typingAt===null?null:{start:e.typingAt,end:e.typingAt+vp(e.value).length}}function FA(e,t,n,r){const i=yf(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=vp(e.value),c=Hj(a-i.start,0,l.length),u=Hj(o-i.start,0,l.length),O=vp(s),d=[...l.slice(0,c),...O,...l.slice(u)].join(""),h=a+O.length,p=t.slice(0,a)+Ibe.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 QF(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=Co(e)&&e.value===""&&r.startsWith("-");if(Co(e)&&(a||r.includes(`
855
855
  `))){const o=Mx(e);return r.includes(`
856
856
  `)?{...i,capture:o}:{...i,capture:wh(o,i.buffer,i.caret,"typing")}}return FA(e,i.buffer,i.caret,{top:n.start,bottom:n.end,inserted:r})??i}function Mx(e){return Co(e)?{arm:e.arm,typingAt:null,value:""}:e}function WSt(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 YSt(e,t,n,r,i){const a=WSt(t,n),o=yf(e);let s={capture:e,buffer:n,caret:r};if(a.inserted!==""&&o!==null&&a.top<=o.end&&a.bottom>=o.start)s={capture:Mx(e),buffer:n,caret:r};else{const l=FA(e,n,r,a);l?s=l:Co(e)&&a.inserted.includes(`
857
- `)&&(s={capture:Mx(e),buffer:n,caret:r})}return{...s,capture:wh(s.capture,s.buffer,s.caret,i)}}function NSt(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=yf(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=Jbe(i,t.value),c=l+Ck,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:za,buffer:u,caret:s+c.length,payload:{index:i,key:ewe(a,e.draw),value:t.value,marker:l}}}const GSt=e=>Co(e)&&e.value!=="";function ZSt(e,t){const n=yf(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:za,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 ISt(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function DSt(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=yf(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:Mx(e),buffer:i,caret:a,payload:null}}function VSt(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=FA(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=vn(i);if(!a)return i===""?null:DSt(t,n,e.selection,i);const o=t.arm,s=Jbe(e.index,a),l=s+Ck,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:za,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:ewe(e.taken,e.draw),value:a,marker:s}}}const Kbe=e=>`${qSt(e)} chars`,Jbe=(e,t)=>`[Credential #${e}, ${Kbe(t)}]`;function MSt(e){Ol.lastIndex=0;const t=Ol.exec(e);return Ol.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function LSt(e){Ol.lastIndex=0;const t=Ol.exec(e);if(Ol.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(MSt(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const o2=/\[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,s2=/\[credential NOT stored \u2014 [^\]\n]*\]/y,l2=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,FSt=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&Bj.test(t[1])?t[1]:""};function BSt(e,t){if(e.charCodeAt(t)!==91)return null;o2.lastIndex=t;const n=o2.exec(e);if(o2.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};s2.lastIndex=t;const r=s2.exec(e);if(s2.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};l2.lastIndex=t;const i=l2.exec(e);return l2.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:FSt(i[0])}:null}function zk(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=BSt(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 kF(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 HSt(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 KSt=e=>`[credential ${e.key} (${Kbe(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function JSt(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 Lbe(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?HSt(l??"lost",s?.key):KSt(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const eQt=(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.`,tQt=e=>`Remove credential #${e}`,nQt=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,rQt=(e,t,n)=>eQt(e,t,n),iQt="Undo",aQt=e=>m("ui.notices.credentials.removed",{index:e}),oQt=e=>e.unredacted!==null?e.unredacted:e.armed?hQt:e.cleared!==null?rQt(e.cleared.key,e.cleared.index,e.undoCap):null;function sQt(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]===Ck?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 lQt(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 _F=e=>m("ui.notices.credentials.stored",{keys:e.join(", ")});function PF(e){return m("ui.notices.credentials.unstored",{count:e.length,keys:[...e].sort().join(", ")})}const cQt="store unconfirmed",uQt="Credential store unconfirmed",OQt=e=>e===""?uQt:`${e} · ${cQt}`,dQt="Paste the value again after /credential to store it again.",fQt=e=>`${e} ${dQt}`;function TF(e){return m("ui.notices.credentials.unconfirmed",{count:e.length,keys:[...e].sort().join(", ")})}const hQt="armed — add a space, then type or paste the secret",pQt="masked as you type — Enter makes a pill, Esc twice discards",mQt="masked — Enter opens the credential picker; type or paste the secret into this span",gQt="Esc again discards it — still masked, Enter makes a pill",$Qt="credential discarded — nothing was stored or sent",yQt="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",vQt=e=>`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`;function bQt(e,t){const n=yf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const XF=(e,t)=>e&&e.over===t?e.chars:null,wQt=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},xQt=16,SQt=16;function ewe(e=[],t=wQt){const n=new Set(e);for(let r=0;r<xQt;r++){const i=SF+RF(8,t);if(!n.has(i))return i}return SF+RF(SQt,t)}const RF=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=xF[t(xF.length)];return n},QQt=8,kQt=256,_Qt=/^[/@$#]/,PQt=/^\w+:\/\//,TQt=/^[A-Za-z]+$/,XQt=/^\d+$/,RQt=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/],EQt=3,qQt=20,jQt=/^[A-Za-z0-9_\-+/=.]+$/,CQt=new RegExp(`^[^${Ec}@]+@[^${Ec}@]+\\.[A-Za-z]{2,}$`),zQt=/^[\w.-]+(?:\/[\w.-]+)+$/,AQt=/\.[A-Za-z][A-Za-z0-9]{0,7}$/,UQt=/^v?\d+(?:\.\d+)+(?:[-+][0-9A-Za-z.-]+)?$/,WQt=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,YQt=/^[\w.-]+:\d{2,5}$/,NQt=/^(?:[0-9a-f]{7,12}|[0-9a-f]{40})$/i,GQt=/^[a-z]+(?:_[a-z]+)+$/,ZQt=/^[a-z]+(?:-[a-z]+)+$/,IQt=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$/,DQt=/^[a-z0-9]+(?:-[a-z0-9]+)+$/,VQt=/\d{4,}/,MQt=e=>{const t=e.trim();return t.length<QQt||t.length>kQt||Ps.test(t)||_Qt.test(t)||PQt.test(t)||Pse(t)!==null||CQt.test(t)||zQt.test(t)||AQt.test(t)||UQt.test(t)||WQt.test(t)||YQt.test(t)||NQt.test(t)||GQt.test(t)||ZQt.test(t)||IQt.test(t)||DQt.test(t)&&VQt.test(t)||TQt.test(t)||XQt.test(t)?!1:RQt.filter(r=>r.test(t)).length>=EQt?!0:t.length>=qQt&&jQt.test(t)},twe=R("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),nwe=R("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),rwe=({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:R("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?nwe:twe,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?f.jsx(xoe,{"aria-hidden":"true",className:"size-3 shrink-0"}):f.jsx(dEe,{"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(ti,{"aria-hidden":"true",className:"size-3"})}),r&&f.jsx("span",{className:"sr-only",children:r})]}),R$="#lo-credential/",LQt=`${R$}unstored`,EF=`${R$}unconfirmed`,FQt=/^\d+$/,iwe=e=>e.kind==="stored"?`${R$}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${EF}/${e.key}`:EF:LQt;function BQt(e){if(!e||!e.startsWith(R$))return null;const t=e.slice(R$.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return Bj.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!Bj.test(r)||!FQt.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function qF(e,t){const n=BQt(e);if(n===null)return null;const r=zk(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return iwe(i)!==e?null:n}const Ak=()=>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=zk(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:iwe(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},HQt=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?OQt(e.key):"Credential not stored",KQt=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?fQt(t):t,JQt=({citation:e,title:t})=>f.jsx(rwe,{tone:e.kind==="stored"?"live":"warning",label:HQt(e),chars:e.kind==="stored"?e.chars:null,title:KQt(e,t),className:"align-middle"}),ekt=(e,t)=>typeof t=="string"?qF(e,t):t==null?qF(e,""):null,tkt=e=>({href:t,title:n,children:r})=>{const i=ekt(t,r);if(i===null){const a=e;return f.jsx(a,{href:t,title:n,children:r})}return f.jsx(JQt,{citation:i,title:n})},awe=e=>pLe(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",owe=e=>{const t=awe(e);return t==="other"?"path":t},jF={id:"open-file",label:"Open file"},nkt={id:"show-in-canvas",label:"Show in canvas"},rkt={id:"save-as",label:"Save as…"},CF={id:"open-folder",label:"Open folder"},zF={id:"copy-file-path",label:"Copy file path"},gg={id:"copy-image",label:"Copy image"},ikt={id:"copy-image-url",label:"Copy image URL"},akt={id:"open-in-browser",label:"Open in browser"};function swe(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const o=[...t?[nkt]:[],...a?[{id:"expand-image",label:"Expand image"}]:[]];switch(e){case"artifact":return[...o,...i?[jF,CF,zF]:[],rkt,...r==="video"||r==="audio"?[]:[gg]];case"path":return[...o,jF,CF,zF,...r==="video"||r==="audio"?[]:[gg]];case"data":return[...o,gg];case"blob":return[gg];case"http":return[...okt(n)?[gg]:[],ikt,akt];case"other":return[]}}const lwe=(e,t)=>swe(e,t).length>0;function okt(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 BA=e=>e.startsWith("file://")?e.slice(7):e;function skt(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 AF(e,t,n){if(e==="data")return skt(t);if(e==="blob"){const o=bce(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=BA(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:H0(i)})}const lkt=e=>e.trim().toLowerCase()!=="image/png";async function ckt(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!lkt(e.type))return e;const t=URL.createObjectURL(e);try{const n=await ukt(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 ukt(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 Okt=6e4;function dkt(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),Okt)}const p1=new Map;function fkt(e,t){const n=p1.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await Rc(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=cz(i.data,i.mimeType);return r.holders<=0?(Ry(a),null):(wce(t,a),a)}catch{return null}finally{p1.delete(t)}})(),p1.set(t,r),r.promise}class HA extends Error{constructor(){super("This item is no longer in the session"),this.name="AttachmentGoneError"}}async function cwe(e,t){const n=uz(t),r=n?bce(n):null;if(r)return r;const i=await Rc(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 HA:new Error("These bytes are not available right now");return new Blob([i.data],{type:i.mimeType})}function hkt(e){const t=p1.get(e);t&&(t.holders-=1)}function iv(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=$.useState(()=>e.attachment?uz(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=G1(u);if(d)return i(d),o(!1),()=>{O=!1,Z1(u)};i(null),o(!1);let h=!0;return fkt({sessionId:s,childId:l},u).then(p=>{if(h=!1,!!O){if(!p){o(!0);return}i(G1(u))}}),()=>{O=!1,h&&hkt(u),Z1(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 KA(e,t){return iv(e,t)}const Jin=Object.freeze(Object.defineProperty({__proto__:null,AttachmentGoneError:HA,fetchAttachmentBlob:cwe,useAttachmentSource:iv,useAttachmentUrl:KA},Symbol.toStringTag,{value:"Module"})),pkt={"expand-image":f.jsx(Foe,{"aria-hidden":"true"}),"open-file":f.jsx(Sy,{"aria-hidden":"true"}),"show-in-canvas":f.jsx(Loe,{"aria-hidden":"true"}),"save-as":f.jsx(gQ,{"aria-hidden":"true"}),"open-folder":f.jsx(Lh,{"aria-hidden":"true"}),"copy-file-path":f.jsx(kC,{"aria-hidden":"true"}),"copy-image":f.jsx(rf,{"aria-hidden":"true"}),"copy-image-url":f.jsx(mEe,{"aria-hidden":"true"}),"open-in-browser":f.jsx($Q,{"aria-hidden":"true"})},UF=(e,t,n)=>n instanceof HA?t:e,uwe=({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=owe(e),v=swe(y,{canShowInCanvas:!!c,source:t??e,mediaKind:u,artifactPathActions:!!s,canExpand:!!O}).filter(k=>(k.id!=="save-as"||!!d)&&(!l||k.id==="copy-file-path"));if(v.length===0)return null;const b=async(k,P,T)=>{try{await navigator.clipboard.writeText(k),Bu(P)}catch(X){console.error(`${T}: `,X),Er(T)}},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 AF(y,e,t),P=await ckt(k);await navigator.clipboard.write([new ClipboardItem({[P.type]:P})]),Bu(m("ui.notices.files.image_copied"))}catch(k){console.error("Failed to copy image: ",k),Er(UF(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 AF(y,e,t);dkt(k,d??"download")}catch(k){console.error("Failed to save file: ",k),Er(UF(m("ui.notices.files.save_failed"),m("ui.notices.files.save_failed_gone"),k))}},w=async k=>{let P=BA(e);if(s&&["open-file","open-folder","copy-file-path"].includes(k.id))try{P=await s()}catch{Er(m("ui.canvas.files.prepareError"));return}switch(k.id){case"expand-image":O?.();return;case"open-file":lO(P);return;case"open-folder":DA(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":VA(t??e);return}},S=g??`Actions for ${n??"this image"}`;return f.jsxs(mC,{open:r,onOpenChange:i,children:[f.jsx($t,{content:p,children:f.jsx(gC,{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($C,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:k=>k.stopPropagation(),children:[s&&f.jsx("div",{role:"note",className:R("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:m("ui.canvas.files.pathCopyNote")}),v.map(k=>f.jsxs(nl,{onSelect:()=>w(k),children:[pkt[k.id],f.jsx("span",{children:k.label})]},k.id))]})]})},mkt=({src:e,alt:t,title:n,className:r})=>{const i=Ek(),a=e??"",o=awe(a);if(o==="other")return f.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=lwe(o,{canShowInCanvas:s,source:a});return f.jsxs("span",{className:R("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:R("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(uwe,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||lO(BA(a))})}:void 0})})]})};function gkt(){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 $kt={tokenize:ykt,concrete:!0,name:"mathFlow"},WF={tokenize:vkt,partial:!0};function ykt(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"),Jt(e,c,"whitespace")(b))}function c(b){return b===null||gt(b)?O(b):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(b))}function u(b){return b===null||gt(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(WF,d,y)(b)}function d(b){return e.attempt({tokenize:v,partial:!0},y,h)(b)}function h(b){return(a?Jt(e,p,"linePrefix",a+1):p)(b)}function p(b){return b===null?y(b):gt(b)?e.attempt(WF,d,y)(b):(e.enter("mathFlowValue"),g(b))}function g(b){return b===null||gt(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 Jt(b,S,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function S(T){return b.enter("mathFlowFence"),b.enter("mathFlowFenceSequence"),k(T)}function k(T){return T===36?(w++,b.consume(T),k):w<o?Q(T):(b.exit("mathFlowFenceSequence"),Jt(b,P,"whitespace")(T))}function P(T){return T===null||gt(T)?(b.exit("mathFlowFence"),x(T)):Q(T)}}}function vkt(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 bkt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:wkt,previous:xkt,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):gt(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||gt(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 wkt(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 xkt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function Skt(e){return{flow:{36:$kt},text:{36:bkt()}}}const xh=36,YF=e=>e!==null&&e<-2,NF=e=>e===null||e===32||e<0,GF=e=>e!==null&&e>=48&&e<=57,Owe=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:Qkt,previous:kkt,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===xh?(r.consume(y),s++,d):s<2&&!t||s===1&&(NF(y)||GF(y))?a(y):(r.exit("mathTextSequence"),h(y))}function h(y){return y===null?a(y):y===xh?(u=r.enter("mathTextSequence"),c=0,l=o.previous,g(y)):y===32?(r.enter("space"),r.consume(y),r.exit("space"),h):YF(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===xh||YF(y)?(r.exit("mathTextData"),h(y)):(r.consume(y),p)}function g(y){return y===xh?(r.consume(y),c++,g):c===s?s===1&&(NF(l)||GF(y))?a(y):(r.exit("mathTextSequence"),r.exit("mathText"),i(y)):(u.type="mathTextData",p(y))}}};function Qkt(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 kkt(e){return e!==xh||this.events[this.events.length-1][1].type==="characterEscape"}const _kt=Skt().flow,Pkt=Owe();function Uk(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?Pkt:Owe(e);n.push({flow:_kt,text:{[xh]:i}}),r.push(gkt())}const Tkt=({node:e,...t})=>f.jsx("div",{className:"lo-md-table-scroll",children:f.jsx("table",{...t})}),Xkt=/\$(?!\d)(.+?)\$/,Rkt=/\$\$([\s\S]+?)\$\$/,Ekt=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,qkt=/\\[a-zA-Z]+(\{[^}]*\})?/,ZF=e=>Xkt.test(e)||Rkt.test(e)||Ekt.test(e)?!0:qkt.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),jkt=e=>{const t=zk(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},Ckt=e=>zk(e).filter(t=>t.kind!=="text").length,zkt=e=>{if(!ZF(e))return!1;const t=jkt(e);return t===null?!0:ZF(t)||t.includes("$")?!1:Ckt(e)<2},Gt="var(--color-ink)",Il="var(--color-ink-muted)",Ms="var(--color-surface)",gu="var(--color-elevated)",Dl="var(--color-sunken)",Vi="var(--color-hairline)",$u="var(--color-control)",Bf="var(--color-accent)",Fg="var(--color-accent-wash)",Akt="var(--color-accent-alt-wash)",Ukt="var(--color-on-accent)",Wkt="var(--color-info)",dwe="var(--color-info-wash)",Ykt="var(--color-success)",fwe="var(--color-success-wash)",Nkt="var(--color-warning)",Kj="var(--color-warning-wash)",Gkt="var(--color-warning-border)",c2="var(--color-danger)",Jj="var(--color-danger-wash)",IF=[Fg,Akt,dwe,fwe,Kj,Jj],yu=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),Zkt=()=>{const e={primaryColor:yu("--color-accent"),secondaryColor:yu("--color-success"),tertiaryColor:yu("--color-info"),mainBkg:yu("--color-elevated"),clusterBkg:yu("--color-sunken"),clusterBorder:yu("--color-hairline"),edgeLabelBackground:yu("--color-surface"),quadrant1Fill:yu("--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:Ms,primaryTextColor:Gt,primaryBorderColor:$u,secondaryTextColor:Gt,secondaryBorderColor:Vi,tertiaryTextColor:Gt,tertiaryBorderColor:Vi,lineColor:Il,arrowheadColor:Il,textColor:Gt,secondBkg:Dl,border1:$u,border2:Vi,labelColor:Gt,nodeBkg:gu,nodeBorder:$u,nodeTextColor:Gt,defaultLinkColor:Il,titleColor:Gt,noteBkgColor:Kj,noteBorderColor:Gkt,noteTextColor:Gt,actorBkg:gu,actorBorder:$u,actorTextColor:Gt,actorLineColor:Vi,signalColor:Il,signalTextColor:Gt,labelBoxBkgColor:gu,labelBoxBorderColor:Vi,labelTextColor:Gt,loopTextColor:Gt,activationBkgColor:Fg,activationBorderColor:Bf,sequenceNumberColor:Ms,sectionBkgColor:Dl,sectionBkgColor2:Ms,altSectionBkgColor:Dl,excludeBkgColor:Dl,taskBkgColor:Fg,taskBorderColor:$u,taskTextColor:Gt,taskTextLightColor:Gt,taskTextDarkColor:Gt,taskTextOutsideColor:Gt,taskTextClickableColor:Bf,activeTaskBkgColor:Fg,activeTaskBorderColor:Bf,gridColor:Vi,doneTaskBkgColor:Dl,doneTaskBorderColor:Vi,critBkgColor:Jj,critBorderColor:c2,todayLineColor:Bf,transitionColor:Il,transitionLabelColor:Gt,stateLabelColor:Gt,stateBkg:gu,labelBackgroundColor:Ms,compositeBackground:Dl,altBackground:Dl,compositeTitleBackground:gu,compositeBorder:Vi,innerEndBackground:Gt,specialStateColor:Gt,classText:Gt,attributeBackgroundColorOdd:Ms,attributeBackgroundColorEven:Dl,rowOdd:Ms,rowEven:Dl,errorBkgColor:Jj,errorTextColor:c2,pieTitleTextColor:Gt,pieSectionTextColor:Gt,pieLegendTextColor:Gt,pieStrokeColor:Ms,pieOuterStrokeColor:Vi,requirementBackground:gu,requirementBorderColor:$u,requirementTextColor:Gt,relationColor:Il,relationLabelBackground:Ms,relationLabelColor:Gt,branchLabelColor:Ukt,commitLabelColor:Gt,commitLabelBackground:Ms,tagLabelColor:Gt,tagLabelBackground:Fg,tagLabelBorder:$u,quadrant2Fill:dwe,quadrant3Fill:fwe,quadrant4Fill:Kj,quadrant2TextFill:Gt,quadrant3TextFill:Gt,quadrant4TextFill:Gt,quadrantPointFill:Bf,archEdgeColor:Il,archEdgeArrowColor:Il,archGroupBorderColor:Vi,scaleLabelColor:Gt,packet:{startByteColor:Gt,endByteColor:Gt,labelColor:Gt,titleColor:Gt,blockStrokeColor:$u,blockFillColor:gu},radar:{axisColor:Il,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:Vi,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:Ms,titleColor:Gt,xAxisTitleColor:Gt,xAxisLabelColor:Gt,xAxisTickColor:Vi,xAxisLineColor:Vi,yAxisTitleColor:Gt,yAxisLabelColor:Gt,yAxisTickColor:Vi,yAxisLineColor:Vi,plotColorPalette:[Bf,Wkt,Ykt,Nkt,c2].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=gu,t[`surfacePeer${n}`]=Vi;for(let n=0;n<8;n++)t[`fillType${n}`]=IF[n%IF.length];return{...t,...e}};let u2=null,DF=null;const Ikt=async e=>{u2||(u2=$e(async()=>{const{default:n}=await import("./mermaid.core-B10H6Sj9.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([9,1,2,3]),import.meta.url).then(({default:n})=>n));const t=await u2;return DF!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:Zkt()}),DF=e),t},VF=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>f.jsxs("div",{className:R("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[f.jsx($t,{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(rse,{})})}),f.jsx($t,{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(ise,{})})}),f.jsx($t,{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(CEe,{})})}),f.jsx($t,{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(yQ,{})})}),f.jsx($t,{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(gQ,{})})}),f.jsx($t,{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(rf,{className:R(t&&"text-success")})})}),s]}),e7=({title:e,children:t})=>f.jsxs(pl,{variant:"danger",role:"alert",className:"my-4",children:[f.jsx(r0,{children:e}),f.jsx(i0,{children:t})]});class Dkt 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(e7,{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 Vkt=$.memo(({chart:e,id:t})=>{Re();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=kn(N=>N.themeName),T=$.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 N=await Ikt(P),te=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:B}=await N.render(te,e);if(!B||typeof B!="string"||B.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(B)}catch(N){console.error("Mermaid rendering error:",N);const te=N instanceof Error?N.message:"Failed to render mermaid diagram";a(te),c("")}finally{s(!1)}},[e,t,P]);$.useEffect(()=>{T().catch(N=>{console.error("Error in renderDiagram effect:",N),a("Failed to initialize diagram rendering"),s(!1)})},[T]);const X=$.useCallback(()=>{try{if(!l||!r.current)return 1;const te=r.current.getBoundingClientRect(),B=document.createElement("div");B.innerHTML=l;const ee=B.querySelector("svg");if(!ee)return 1;const le=ee.getBoundingClientRect?.()?.width||Number.parseFloat(ee.getAttribute("width")||"0")||ee.viewBox?.baseVal?.width||800,F=ee.getBoundingClientRect?.()?.height||Number.parseFloat(ee.getAttribute("height")||"0")||ee.viewBox?.baseVal?.height||600,L=te.width*.9/le,ne=te.height*.9/F;return Math.min(L,ne,1)}catch(N){return console.error("Error calculating fullscreen scale:",N),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const N=X();g({scale:N,x:0,y:0})}catch(N){console.error("Error setting fullscreen transform:",N)}},100)},[u,l,X]);const E=$.useCallback((N=!1)=>{try{(N?g:h)(B=>({...B,scale:Math.min(B.scale*1.2,10)}))}catch(te){console.error("Error in zoom in:",te)}},[]),j=$.useCallback((N=!1)=>{try{(N?g:h)(B=>({...B,scale:Math.max(B.scale/1.2,.1)}))}catch(te){console.error("Error in zoom out:",te)}},[]),U=$.useCallback((N=!1)=>{try{const te=N?g:h;if(N){const B=X();te({scale:B,x:0,y:0})}else te({scale:1,x:0,y:0})}catch(te){console.error("Error in reset:",te)}},[X]),C=$.useCallback(()=>{if(l)try{const N=new Blob([l],{type:"image/svg+xml"}),te=URL.createObjectURL(N),B=document.createElement("a");B.href=te,B.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(B),B.click(),document.body.removeChild(B),URL.revokeObjectURL(te)}catch(N){console.error("Failed to save SVG:",N)}},[l]),G=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),w("copied"),setTimeout(()=>w("idle"),1200)}catch(N){console.error("Failed to copy Mermaid chart text:",N)}},[e]),Y=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),k("copied"),setTimeout(()=>k("idle"),1200)}catch(N){console.error("Failed to copy Mermaid chart text:",N)}},[e]),W=$.useCallback(N=>{try{v(!0),x({x:N.clientX,y:N.clientY}),N.preventDefault()}catch(te){console.error("Error in mouse down:",te)}},[]),Z=$.useCallback((N,te=!1)=>{try{if(!y)return;const B=N.clientX-b.x,ee=N.clientY-b.y;(te?g:h)(F=>({...F,x:F.x+B,y:F.y+ee})),x({x:N.clientX,y:N.clientY})}catch(B){console.error("Error in mouse move:",B)}},[y,b]),V=$.useCallback(()=>{try{v(!1)}catch(N){console.error("Error in mouse up:",N)}},[]),A=$.useCallback((N,te=!1)=>{try{N.preventDefault();const B=N.deltaY>0?.9:1.1;(te?g:h)(le=>({...le,scale:Math.min(Math.max(le.scale*B,.1),5)}))}catch(B){console.error("Error in wheel:",B)}},[]),I=$.useCallback(N=>{try{O(N)}catch(te){console.error("Error toggling fullscreen:",te)}},[]);if(i)return f.jsxs(e7,{title:m("ui.chat.mermaid.error_title"),children:[i,f.jsx("span",{className:R("mt-2 block text-ink-muted"),children:m("ui.chat.mermaid.chart_label")}),f.jsx("span",{className:R("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const J=(N=!1)=>{try{const te=N?r:n,B=N?p:d;return f.jsx("div",{ref:te,className:R("mermaid flex w-full items-center justify-center",N?"h-full min-h-full":"h-auto min-h-50",y?"cursor-grabbing":"cursor-grab"),onMouseDown:W,onMouseMove:ee=>Z(ee,N),onMouseUp:V,onMouseLeave:V,onWheel:ee=>A(ee,N),children:o?f.jsx("div",{className:R("p-4 text-body-sm text-ink-muted"),children:m("ui.chat.mermaid.loading")}):l?f.jsx("div",{className:R("flex h-full w-full items-center justify-center"),style:{transform:`translate(${B.x}px, ${B.y}px) scale(${B.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(te){return console.error("Error rendering diagram content:",te),f.jsx(e7,{title:m("ui.chat.mermaid.rendering_error"),children:m("ui.chat.mermaid.render_failed")})}};return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:R("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(VF,{className:"top-2 right-2",copied:Q==="copied",onZoomIn:()=>E(!1),onZoomOut:()=>j(!1),onReset:()=>U(!1),onSave:C,onCopy:G,children:f.jsx($t,{content:m("ui.chat.mermaid.fullscreen"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.open_fullscreen"),onClick:()=>I(!0),children:f.jsx(Foe,{})})})})]}),f.jsx(F0,{open:u,onClose:()=>I(!1),title:m("ui.chat.mermaid.diagram_title"),maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:f.jsxs("div",{className:R("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(VF,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>E(!0),onZoomOut:()=>j(!0),onReset:()=>U(!0),onSave:C,onCopy:Y,children:f.jsx($t,{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:()=>I(!1),children:f.jsx(ti,{})})})})]})})]})}),Mkt=$.memo(e=>f.jsx(Dkt,{children:f.jsx(Vkt,{...e})}));let hwe=!1,O2=null;const Lkt=()=>(O2||(O2=$e(()=>Promise.resolve({}),__vite__mapDeps([10]),import.meta.url).then(e=>(hwe=!0,e))),O2),Fkt=/language-(\w+)/,Bkt=cQ,Hkt=new RegExp(`^[^${Ec}\\d*+-]`),Kkt=/\n$/,pwe=({href:e,children:t})=>{const n=xbe(e),r=Ek();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=>t_t(i,r):void 0,children:t})},Jkt=e=>xbe(e)?.kind==="file",e_t=_be,t_t=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(kbe)??"file",i=n.getAttribute(e_t),a=Sxt({kind:r,hasHighlight:Zxt(n),canOpenInCanvas:IA(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||lO(i)});return}lO(i)}},t7=(e,t)=>t==="href"&&Jkt(e)?e:Yue(e),E$={a:pwe,table:Tkt,img:mkt,code:({node:e,className:t,children:n,...r})=>Fkt.exec(t??"")?.[1]==="mermaid"?f.jsx(Mkt,{chart:String(n).replace(Kkt,"")}):f.jsx("code",{dir:"ltr",className:t,...r,children:n})},n_t={...E$,a:tkt(pwe)},r_t=[Bc],i_t=[Bc,Uk],a_t=[Bc,qk],o_t=[Bc,Uk,qk],s_t=[Bc,Ak,jk],l_t=[Bc,Uk,Ak,jk],c_t=[Bc,qk,Ak,jk],u_t=[Bc,Uk,qk,Ak,jk],O_t={"000":r_t,"001":s_t,"010":a_t,"011":c_t,100:i_t,101:l_t,110:o_t,111:u_t},d_t=[],f_t=[rVe],mwe=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),gwe=(e,t,n)=>{const r=$.useMemo(()=>zkt(e),[e]),[i,a]=$.useState(hwe),o=r&&i;return $.useEffect(()=>{if(!r||i)return;let s=!1;return Lkt().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:O_t[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?f_t:d_t}},$we=(e,t,n)=>{const[,r]=$.useState(0);$.useEffect(()=>{if(!t)return;const i=CLe(e);if(i.length===0)return;let a=!0;const o=new Set(i),s=Pxt(l=>{a&&l.some(c=>o.has(c))&&r(c=>c+1)});return ZA(i,window.api?.probeFiles,aoe,kxt(n===void 0?e:`${n}\0${e}`)).then(()=>{a&&i.some(l=>Qbe(l)!=="unknown")&&r(l=>l+1)}),()=>{a=!1,s()}},[e,t,n])},q$=$.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}=gwe(o,r,i),c=mwe(t);return $we(o,r,a),f.jsx("div",{className:R("lo-markdown",n),style:c,children:f.jsx(Gq,{remarkPlugins:s,rehypePlugins:l,urlTransform:t7,components:i?n_t:E$,children:o})})});q$.displayName="MarkdownRenderer";const MF={...E$,a:({children:e})=>f.jsx(f.Fragment,{children:e})},ywe=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:vF(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=Wbe(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=gwe(n,t,!1);if($we(e,t),r!==null){const o=vF(r.before);return f.jsxs(f.Fragment,{children:[o.trim()!==""&&f.jsx(Gq,{remarkPlugins:i,rehypePlugins:a,urlTransform:t7,components:t?E$:MF,children:o}),f.jsx(h_t,{info:r.info,body:r.body})]})}return f.jsx(Gq,{remarkPlugins:i,rehypePlugins:a,urlTransform:t7,components:t?E$:MF,children:n})});ywe.displayName="ParsedBlock";const h_t=({info:e,body:t})=>{const n=e.split(Bkt)[0];return f.jsx("pre",{children:f.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
857
+ `)&&(s={capture:Mx(e),buffer:n,caret:r})}return{...s,capture:wh(s.capture,s.buffer,s.caret,i)}}function NSt(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=yf(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=Jbe(i,t.value),c=l+Ck,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:za,buffer:u,caret:s+c.length,payload:{index:i,key:ewe(a,e.draw),value:t.value,marker:l}}}const GSt=e=>Co(e)&&e.value!=="";function ZSt(e,t){const n=yf(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:za,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 ISt(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function DSt(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=yf(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:Mx(e),buffer:i,caret:a,payload:null}}function VSt(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=FA(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=vn(i);if(!a)return i===""?null:DSt(t,n,e.selection,i);const o=t.arm,s=Jbe(e.index,a),l=s+Ck,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:za,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:ewe(e.taken,e.draw),value:a,marker:s}}}const Kbe=e=>`${qSt(e)} chars`,Jbe=(e,t)=>`[Credential #${e}, ${Kbe(t)}]`;function MSt(e){Ol.lastIndex=0;const t=Ol.exec(e);return Ol.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function LSt(e){Ol.lastIndex=0;const t=Ol.exec(e);if(Ol.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(MSt(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const o2=/\[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,s2=/\[credential NOT stored \u2014 [^\]\n]*\]/y,l2=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,FSt=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&Bj.test(t[1])?t[1]:""};function BSt(e,t){if(e.charCodeAt(t)!==91)return null;o2.lastIndex=t;const n=o2.exec(e);if(o2.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};s2.lastIndex=t;const r=s2.exec(e);if(s2.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};l2.lastIndex=t;const i=l2.exec(e);return l2.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:FSt(i[0])}:null}function zk(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=BSt(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 kF(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 HSt(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 KSt=e=>`[credential ${e.key} (${Kbe(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function JSt(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 Lbe(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?HSt(l??"lost",s?.key):KSt(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const eQt=(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.`,tQt=e=>`Remove credential #${e}`,nQt=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,rQt=(e,t,n)=>eQt(e,t,n),iQt="Undo",aQt=e=>m("ui.notices.credentials.removed",{index:e}),oQt=e=>e.unredacted!==null?e.unredacted:e.armed?hQt:e.cleared!==null?rQt(e.cleared.key,e.cleared.index,e.undoCap):null;function sQt(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]===Ck?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 lQt(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 _F=e=>m("ui.notices.credentials.stored",{keys:e.join(", ")});function PF(e){return m("ui.notices.credentials.unstored",{count:e.length,keys:[...e].sort().join(", ")})}const cQt="store unconfirmed",uQt="Credential store unconfirmed",OQt=e=>e===""?uQt:`${e} · ${cQt}`,dQt="Paste the value again after /credential to store it again.",fQt=e=>`${e} ${dQt}`;function TF(e){return m("ui.notices.credentials.unconfirmed",{count:e.length,keys:[...e].sort().join(", ")})}const hQt="armed — add a space, then type or paste the secret",pQt="masked as you type — Enter makes a pill, Esc twice discards",mQt="masked — Enter opens the credential picker; type or paste the secret into this span",gQt="Esc again discards it — still masked, Enter makes a pill",$Qt="credential discarded — nothing was stored or sent",yQt="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",vQt=e=>`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`;function bQt(e,t){const n=yf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const XF=(e,t)=>e&&e.over===t?e.chars:null,wQt=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},xQt=16,SQt=16;function ewe(e=[],t=wQt){const n=new Set(e);for(let r=0;r<xQt;r++){const i=SF+RF(8,t);if(!n.has(i))return i}return SF+RF(SQt,t)}const RF=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=xF[t(xF.length)];return n},QQt=8,kQt=256,_Qt=/^[/@$#]/,PQt=/^\w+:\/\//,TQt=/^[A-Za-z]+$/,XQt=/^\d+$/,RQt=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/],EQt=3,qQt=20,jQt=/^[A-Za-z0-9_\-+/=.]+$/,CQt=new RegExp(`^[^${Ec}@]+@[^${Ec}@]+\\.[A-Za-z]{2,}$`),zQt=/^[\w.-]+(?:\/[\w.-]+)+$/,AQt=/\.[A-Za-z][A-Za-z0-9]{0,7}$/,UQt=/^v?\d+(?:\.\d+)+(?:[-+][0-9A-Za-z.-]+)?$/,WQt=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,YQt=/^[\w.-]+:\d{2,5}$/,NQt=/^(?:[0-9a-f]{7,12}|[0-9a-f]{40})$/i,GQt=/^[a-z]+(?:_[a-z]+)+$/,ZQt=/^[a-z]+(?:-[a-z]+)+$/,IQt=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$/,DQt=/^[a-z0-9]+(?:-[a-z0-9]+)+$/,VQt=/\d{4,}/,MQt=e=>{const t=e.trim();return t.length<QQt||t.length>kQt||Ps.test(t)||_Qt.test(t)||PQt.test(t)||Pse(t)!==null||CQt.test(t)||zQt.test(t)||AQt.test(t)||UQt.test(t)||WQt.test(t)||YQt.test(t)||NQt.test(t)||GQt.test(t)||ZQt.test(t)||IQt.test(t)||DQt.test(t)&&VQt.test(t)||TQt.test(t)||XQt.test(t)?!1:RQt.filter(r=>r.test(t)).length>=EQt?!0:t.length>=qQt&&jQt.test(t)},twe=R("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),nwe=R("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),rwe=({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:R("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?nwe:twe,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?f.jsx(xoe,{"aria-hidden":"true",className:"size-3 shrink-0"}):f.jsx(dEe,{"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(ti,{"aria-hidden":"true",className:"size-3"})}),r&&f.jsx("span",{className:"sr-only",children:r})]}),R$="#lo-credential/",LQt=`${R$}unstored`,EF=`${R$}unconfirmed`,FQt=/^\d+$/,iwe=e=>e.kind==="stored"?`${R$}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${EF}/${e.key}`:EF:LQt;function BQt(e){if(!e||!e.startsWith(R$))return null;const t=e.slice(R$.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return Bj.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!Bj.test(r)||!FQt.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function qF(e,t){const n=BQt(e);if(n===null)return null;const r=zk(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return iwe(i)!==e?null:n}const Ak=()=>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=zk(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:iwe(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},HQt=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?OQt(e.key):"Credential not stored",KQt=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?fQt(t):t,JQt=({citation:e,title:t})=>f.jsx(rwe,{tone:e.kind==="stored"?"live":"warning",label:HQt(e),chars:e.kind==="stored"?e.chars:null,title:KQt(e,t),className:"align-middle"}),ekt=(e,t)=>typeof t=="string"?qF(e,t):t==null?qF(e,""):null,tkt=e=>({href:t,title:n,children:r})=>{const i=ekt(t,r);if(i===null){const a=e;return f.jsx(a,{href:t,title:n,children:r})}return f.jsx(JQt,{citation:i,title:n})},awe=e=>pLe(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",owe=e=>{const t=awe(e);return t==="other"?"path":t},jF={id:"open-file",label:"Open file"},nkt={id:"show-in-canvas",label:"Show in canvas"},rkt={id:"save-as",label:"Save as…"},CF={id:"open-folder",label:"Open folder"},zF={id:"copy-file-path",label:"Copy file path"},gg={id:"copy-image",label:"Copy image"},ikt={id:"copy-image-url",label:"Copy image URL"},akt={id:"open-in-browser",label:"Open in browser"};function swe(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const o=[...t?[nkt]:[],...a?[{id:"expand-image",label:"Expand image"}]:[]];switch(e){case"artifact":return[...o,...i?[jF,CF,zF]:[],rkt,...r==="video"||r==="audio"?[]:[gg]];case"path":return[...o,jF,CF,zF,...r==="video"||r==="audio"?[]:[gg]];case"data":return[...o,gg];case"blob":return[gg];case"http":return[...okt(n)?[gg]:[],ikt,akt];case"other":return[]}}const lwe=(e,t)=>swe(e,t).length>0;function okt(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 BA=e=>e.startsWith("file://")?e.slice(7):e;function skt(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 AF(e,t,n){if(e==="data")return skt(t);if(e==="blob"){const o=bce(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=BA(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:H0(i)})}const lkt=e=>e.trim().toLowerCase()!=="image/png";async function ckt(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!lkt(e.type))return e;const t=URL.createObjectURL(e);try{const n=await ukt(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 ukt(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 Okt=6e4;function dkt(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),Okt)}const p1=new Map;function fkt(e,t){const n=p1.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await Rc(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=cz(i.data,i.mimeType);return r.holders<=0?(Ry(a),null):(wce(t,a),a)}catch{return null}finally{p1.delete(t)}})(),p1.set(t,r),r.promise}class HA extends Error{constructor(){super("This item is no longer in the session"),this.name="AttachmentGoneError"}}async function cwe(e,t){const n=uz(t),r=n?bce(n):null;if(r)return r;const i=await Rc(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 HA:new Error("These bytes are not available right now");return new Blob([i.data],{type:i.mimeType})}function hkt(e){const t=p1.get(e);t&&(t.holders-=1)}function iv(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=$.useState(()=>e.attachment?uz(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=G1(u);if(d)return i(d),o(!1),()=>{O=!1,Z1(u)};i(null),o(!1);let h=!0;return fkt({sessionId:s,childId:l},u).then(p=>{if(h=!1,!!O){if(!p){o(!0);return}i(G1(u))}}),()=>{O=!1,h&&hkt(u),Z1(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 KA(e,t){return iv(e,t)}const Jin=Object.freeze(Object.defineProperty({__proto__:null,AttachmentGoneError:HA,fetchAttachmentBlob:cwe,useAttachmentSource:iv,useAttachmentUrl:KA},Symbol.toStringTag,{value:"Module"})),pkt={"expand-image":f.jsx(Foe,{"aria-hidden":"true"}),"open-file":f.jsx(Sy,{"aria-hidden":"true"}),"show-in-canvas":f.jsx(Loe,{"aria-hidden":"true"}),"save-as":f.jsx(gQ,{"aria-hidden":"true"}),"open-folder":f.jsx(Lh,{"aria-hidden":"true"}),"copy-file-path":f.jsx(kC,{"aria-hidden":"true"}),"copy-image":f.jsx(rf,{"aria-hidden":"true"}),"copy-image-url":f.jsx(mEe,{"aria-hidden":"true"}),"open-in-browser":f.jsx($Q,{"aria-hidden":"true"})},UF=(e,t,n)=>n instanceof HA?t:e,uwe=({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=owe(e),v=swe(y,{canShowInCanvas:!!c,source:t??e,mediaKind:u,artifactPathActions:!!s,canExpand:!!O}).filter(k=>(k.id!=="save-as"||!!d)&&(!l||k.id==="copy-file-path"));if(v.length===0)return null;const b=async(k,P,T)=>{try{await navigator.clipboard.writeText(k),Bu(P)}catch(X){console.error(`${T}: `,X),Er(T)}},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 AF(y,e,t),P=await ckt(k);await navigator.clipboard.write([new ClipboardItem({[P.type]:P})]),Bu(m("ui.notices.files.image_copied"))}catch(k){console.error("Failed to copy image: ",k),Er(UF(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 AF(y,e,t);dkt(k,d??"download")}catch(k){console.error("Failed to save file: ",k),Er(UF(m("ui.notices.files.save_failed"),m("ui.notices.files.save_failed_gone"),k))}},w=async k=>{let P=BA(e);if(s&&["open-file","open-folder","copy-file-path"].includes(k.id))try{P=await s()}catch{Er(m("ui.canvas.files.prepareError"));return}switch(k.id){case"expand-image":O?.();return;case"open-file":lO(P);return;case"open-folder":DA(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":VA(t??e);return}},S=g??`Actions for ${n??"this image"}`;return f.jsxs(mC,{open:r,onOpenChange:i,children:[f.jsx($t,{content:p,children:f.jsx(gC,{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($C,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:k=>k.stopPropagation(),children:[s&&f.jsx("div",{role:"note",className:R("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:m("ui.canvas.files.pathCopyNote")}),v.map(k=>f.jsxs(nl,{onSelect:()=>w(k),children:[pkt[k.id],f.jsx("span",{children:k.label})]},k.id))]})]})},mkt=({src:e,alt:t,title:n,className:r})=>{const i=Ek(),a=e??"",o=awe(a);if(o==="other")return f.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=lwe(o,{canShowInCanvas:s,source:a});return f.jsxs("span",{className:R("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:R("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(uwe,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||lO(BA(a))})}:void 0})})]})};function gkt(){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 $kt={tokenize:ykt,concrete:!0,name:"mathFlow"},WF={tokenize:vkt,partial:!0};function ykt(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"),Jt(e,c,"whitespace")(b))}function c(b){return b===null||gt(b)?O(b):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(b))}function u(b){return b===null||gt(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(WF,d,y)(b)}function d(b){return e.attempt({tokenize:v,partial:!0},y,h)(b)}function h(b){return(a?Jt(e,p,"linePrefix",a+1):p)(b)}function p(b){return b===null?y(b):gt(b)?e.attempt(WF,d,y)(b):(e.enter("mathFlowValue"),g(b))}function g(b){return b===null||gt(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 Jt(b,S,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function S(T){return b.enter("mathFlowFence"),b.enter("mathFlowFenceSequence"),k(T)}function k(T){return T===36?(w++,b.consume(T),k):w<o?Q(T):(b.exit("mathFlowFenceSequence"),Jt(b,P,"whitespace")(T))}function P(T){return T===null||gt(T)?(b.exit("mathFlowFence"),x(T)):Q(T)}}}function vkt(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 bkt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:wkt,previous:xkt,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):gt(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||gt(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 wkt(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 xkt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function Skt(e){return{flow:{36:$kt},text:{36:bkt()}}}const xh=36,YF=e=>e!==null&&e<-2,NF=e=>e===null||e===32||e<0,GF=e=>e!==null&&e>=48&&e<=57,Owe=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:Qkt,previous:kkt,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===xh?(r.consume(y),s++,d):s<2&&!t||s===1&&(NF(y)||GF(y))?a(y):(r.exit("mathTextSequence"),h(y))}function h(y){return y===null?a(y):y===xh?(u=r.enter("mathTextSequence"),c=0,l=o.previous,g(y)):y===32?(r.enter("space"),r.consume(y),r.exit("space"),h):YF(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===xh||YF(y)?(r.exit("mathTextData"),h(y)):(r.consume(y),p)}function g(y){return y===xh?(r.consume(y),c++,g):c===s?s===1&&(NF(l)||GF(y))?a(y):(r.exit("mathTextSequence"),r.exit("mathText"),i(y)):(u.type="mathTextData",p(y))}}};function Qkt(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 kkt(e){return e!==xh||this.events[this.events.length-1][1].type==="characterEscape"}const _kt=Skt().flow,Pkt=Owe();function Uk(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?Pkt:Owe(e);n.push({flow:_kt,text:{[xh]:i}}),r.push(gkt())}const Tkt=({node:e,...t})=>f.jsx("div",{className:"lo-md-table-scroll",children:f.jsx("table",{...t})}),Xkt=/\$(?!\d)(.+?)\$/,Rkt=/\$\$([\s\S]+?)\$\$/,Ekt=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,qkt=/\\[a-zA-Z]+(\{[^}]*\})?/,ZF=e=>Xkt.test(e)||Rkt.test(e)||Ekt.test(e)?!0:qkt.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),jkt=e=>{const t=zk(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},Ckt=e=>zk(e).filter(t=>t.kind!=="text").length,zkt=e=>{if(!ZF(e))return!1;const t=jkt(e);return t===null?!0:ZF(t)||t.includes("$")?!1:Ckt(e)<2},Gt="var(--color-ink)",Il="var(--color-ink-muted)",Ms="var(--color-surface)",gu="var(--color-elevated)",Dl="var(--color-sunken)",Vi="var(--color-hairline)",$u="var(--color-control)",Bf="var(--color-accent)",Fg="var(--color-accent-wash)",Akt="var(--color-accent-alt-wash)",Ukt="var(--color-on-accent)",Wkt="var(--color-info)",dwe="var(--color-info-wash)",Ykt="var(--color-success)",fwe="var(--color-success-wash)",Nkt="var(--color-warning)",Kj="var(--color-warning-wash)",Gkt="var(--color-warning-border)",c2="var(--color-danger)",Jj="var(--color-danger-wash)",IF=[Fg,Akt,dwe,fwe,Kj,Jj],yu=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),Zkt=()=>{const e={primaryColor:yu("--color-accent"),secondaryColor:yu("--color-success"),tertiaryColor:yu("--color-info"),mainBkg:yu("--color-elevated"),clusterBkg:yu("--color-sunken"),clusterBorder:yu("--color-hairline"),edgeLabelBackground:yu("--color-surface"),quadrant1Fill:yu("--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:Ms,primaryTextColor:Gt,primaryBorderColor:$u,secondaryTextColor:Gt,secondaryBorderColor:Vi,tertiaryTextColor:Gt,tertiaryBorderColor:Vi,lineColor:Il,arrowheadColor:Il,textColor:Gt,secondBkg:Dl,border1:$u,border2:Vi,labelColor:Gt,nodeBkg:gu,nodeBorder:$u,nodeTextColor:Gt,defaultLinkColor:Il,titleColor:Gt,noteBkgColor:Kj,noteBorderColor:Gkt,noteTextColor:Gt,actorBkg:gu,actorBorder:$u,actorTextColor:Gt,actorLineColor:Vi,signalColor:Il,signalTextColor:Gt,labelBoxBkgColor:gu,labelBoxBorderColor:Vi,labelTextColor:Gt,loopTextColor:Gt,activationBkgColor:Fg,activationBorderColor:Bf,sequenceNumberColor:Ms,sectionBkgColor:Dl,sectionBkgColor2:Ms,altSectionBkgColor:Dl,excludeBkgColor:Dl,taskBkgColor:Fg,taskBorderColor:$u,taskTextColor:Gt,taskTextLightColor:Gt,taskTextDarkColor:Gt,taskTextOutsideColor:Gt,taskTextClickableColor:Bf,activeTaskBkgColor:Fg,activeTaskBorderColor:Bf,gridColor:Vi,doneTaskBkgColor:Dl,doneTaskBorderColor:Vi,critBkgColor:Jj,critBorderColor:c2,todayLineColor:Bf,transitionColor:Il,transitionLabelColor:Gt,stateLabelColor:Gt,stateBkg:gu,labelBackgroundColor:Ms,compositeBackground:Dl,altBackground:Dl,compositeTitleBackground:gu,compositeBorder:Vi,innerEndBackground:Gt,specialStateColor:Gt,classText:Gt,attributeBackgroundColorOdd:Ms,attributeBackgroundColorEven:Dl,rowOdd:Ms,rowEven:Dl,errorBkgColor:Jj,errorTextColor:c2,pieTitleTextColor:Gt,pieSectionTextColor:Gt,pieLegendTextColor:Gt,pieStrokeColor:Ms,pieOuterStrokeColor:Vi,requirementBackground:gu,requirementBorderColor:$u,requirementTextColor:Gt,relationColor:Il,relationLabelBackground:Ms,relationLabelColor:Gt,branchLabelColor:Ukt,commitLabelColor:Gt,commitLabelBackground:Ms,tagLabelColor:Gt,tagLabelBackground:Fg,tagLabelBorder:$u,quadrant2Fill:dwe,quadrant3Fill:fwe,quadrant4Fill:Kj,quadrant2TextFill:Gt,quadrant3TextFill:Gt,quadrant4TextFill:Gt,quadrantPointFill:Bf,archEdgeColor:Il,archEdgeArrowColor:Il,archGroupBorderColor:Vi,scaleLabelColor:Gt,packet:{startByteColor:Gt,endByteColor:Gt,labelColor:Gt,titleColor:Gt,blockStrokeColor:$u,blockFillColor:gu},radar:{axisColor:Il,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:Vi,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:Ms,titleColor:Gt,xAxisTitleColor:Gt,xAxisLabelColor:Gt,xAxisTickColor:Vi,xAxisLineColor:Vi,yAxisTitleColor:Gt,yAxisLabelColor:Gt,yAxisTickColor:Vi,yAxisLineColor:Vi,plotColorPalette:[Bf,Wkt,Ykt,Nkt,c2].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=gu,t[`surfacePeer${n}`]=Vi;for(let n=0;n<8;n++)t[`fillType${n}`]=IF[n%IF.length];return{...t,...e}};let u2=null,DF=null;const Ikt=async e=>{u2||(u2=$e(async()=>{const{default:n}=await import("./mermaid.core-Dkk1pdj8.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([9,1,2,3]),import.meta.url).then(({default:n})=>n));const t=await u2;return DF!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:Zkt()}),DF=e),t},VF=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>f.jsxs("div",{className:R("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[f.jsx($t,{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(rse,{})})}),f.jsx($t,{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(ise,{})})}),f.jsx($t,{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(CEe,{})})}),f.jsx($t,{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(yQ,{})})}),f.jsx($t,{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(gQ,{})})}),f.jsx($t,{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(rf,{className:R(t&&"text-success")})})}),s]}),e7=({title:e,children:t})=>f.jsxs(pl,{variant:"danger",role:"alert",className:"my-4",children:[f.jsx(r0,{children:e}),f.jsx(i0,{children:t})]});class Dkt 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(e7,{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 Vkt=$.memo(({chart:e,id:t})=>{Re();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=kn(N=>N.themeName),T=$.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 N=await Ikt(P),te=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:B}=await N.render(te,e);if(!B||typeof B!="string"||B.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(B)}catch(N){console.error("Mermaid rendering error:",N);const te=N instanceof Error?N.message:"Failed to render mermaid diagram";a(te),c("")}finally{s(!1)}},[e,t,P]);$.useEffect(()=>{T().catch(N=>{console.error("Error in renderDiagram effect:",N),a("Failed to initialize diagram rendering"),s(!1)})},[T]);const X=$.useCallback(()=>{try{if(!l||!r.current)return 1;const te=r.current.getBoundingClientRect(),B=document.createElement("div");B.innerHTML=l;const ee=B.querySelector("svg");if(!ee)return 1;const le=ee.getBoundingClientRect?.()?.width||Number.parseFloat(ee.getAttribute("width")||"0")||ee.viewBox?.baseVal?.width||800,F=ee.getBoundingClientRect?.()?.height||Number.parseFloat(ee.getAttribute("height")||"0")||ee.viewBox?.baseVal?.height||600,L=te.width*.9/le,ne=te.height*.9/F;return Math.min(L,ne,1)}catch(N){return console.error("Error calculating fullscreen scale:",N),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const N=X();g({scale:N,x:0,y:0})}catch(N){console.error("Error setting fullscreen transform:",N)}},100)},[u,l,X]);const E=$.useCallback((N=!1)=>{try{(N?g:h)(B=>({...B,scale:Math.min(B.scale*1.2,10)}))}catch(te){console.error("Error in zoom in:",te)}},[]),j=$.useCallback((N=!1)=>{try{(N?g:h)(B=>({...B,scale:Math.max(B.scale/1.2,.1)}))}catch(te){console.error("Error in zoom out:",te)}},[]),U=$.useCallback((N=!1)=>{try{const te=N?g:h;if(N){const B=X();te({scale:B,x:0,y:0})}else te({scale:1,x:0,y:0})}catch(te){console.error("Error in reset:",te)}},[X]),C=$.useCallback(()=>{if(l)try{const N=new Blob([l],{type:"image/svg+xml"}),te=URL.createObjectURL(N),B=document.createElement("a");B.href=te,B.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(B),B.click(),document.body.removeChild(B),URL.revokeObjectURL(te)}catch(N){console.error("Failed to save SVG:",N)}},[l]),G=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),w("copied"),setTimeout(()=>w("idle"),1200)}catch(N){console.error("Failed to copy Mermaid chart text:",N)}},[e]),Y=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),k("copied"),setTimeout(()=>k("idle"),1200)}catch(N){console.error("Failed to copy Mermaid chart text:",N)}},[e]),W=$.useCallback(N=>{try{v(!0),x({x:N.clientX,y:N.clientY}),N.preventDefault()}catch(te){console.error("Error in mouse down:",te)}},[]),Z=$.useCallback((N,te=!1)=>{try{if(!y)return;const B=N.clientX-b.x,ee=N.clientY-b.y;(te?g:h)(F=>({...F,x:F.x+B,y:F.y+ee})),x({x:N.clientX,y:N.clientY})}catch(B){console.error("Error in mouse move:",B)}},[y,b]),V=$.useCallback(()=>{try{v(!1)}catch(N){console.error("Error in mouse up:",N)}},[]),A=$.useCallback((N,te=!1)=>{try{N.preventDefault();const B=N.deltaY>0?.9:1.1;(te?g:h)(le=>({...le,scale:Math.min(Math.max(le.scale*B,.1),5)}))}catch(B){console.error("Error in wheel:",B)}},[]),I=$.useCallback(N=>{try{O(N)}catch(te){console.error("Error toggling fullscreen:",te)}},[]);if(i)return f.jsxs(e7,{title:m("ui.chat.mermaid.error_title"),children:[i,f.jsx("span",{className:R("mt-2 block text-ink-muted"),children:m("ui.chat.mermaid.chart_label")}),f.jsx("span",{className:R("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const J=(N=!1)=>{try{const te=N?r:n,B=N?p:d;return f.jsx("div",{ref:te,className:R("mermaid flex w-full items-center justify-center",N?"h-full min-h-full":"h-auto min-h-50",y?"cursor-grabbing":"cursor-grab"),onMouseDown:W,onMouseMove:ee=>Z(ee,N),onMouseUp:V,onMouseLeave:V,onWheel:ee=>A(ee,N),children:o?f.jsx("div",{className:R("p-4 text-body-sm text-ink-muted"),children:m("ui.chat.mermaid.loading")}):l?f.jsx("div",{className:R("flex h-full w-full items-center justify-center"),style:{transform:`translate(${B.x}px, ${B.y}px) scale(${B.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(te){return console.error("Error rendering diagram content:",te),f.jsx(e7,{title:m("ui.chat.mermaid.rendering_error"),children:m("ui.chat.mermaid.render_failed")})}};return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:R("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(VF,{className:"top-2 right-2",copied:Q==="copied",onZoomIn:()=>E(!1),onZoomOut:()=>j(!1),onReset:()=>U(!1),onSave:C,onCopy:G,children:f.jsx($t,{content:m("ui.chat.mermaid.fullscreen"),children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.open_fullscreen"),onClick:()=>I(!0),children:f.jsx(Foe,{})})})})]}),f.jsx(F0,{open:u,onClose:()=>I(!1),title:m("ui.chat.mermaid.diagram_title"),maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:f.jsxs("div",{className:R("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(VF,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>E(!0),onZoomOut:()=>j(!0),onReset:()=>U(!0),onSave:C,onCopy:Y,children:f.jsx($t,{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:()=>I(!1),children:f.jsx(ti,{})})})})]})})]})}),Mkt=$.memo(e=>f.jsx(Dkt,{children:f.jsx(Vkt,{...e})}));let hwe=!1,O2=null;const Lkt=()=>(O2||(O2=$e(()=>Promise.resolve({}),__vite__mapDeps([10]),import.meta.url).then(e=>(hwe=!0,e))),O2),Fkt=/language-(\w+)/,Bkt=cQ,Hkt=new RegExp(`^[^${Ec}\\d*+-]`),Kkt=/\n$/,pwe=({href:e,children:t})=>{const n=xbe(e),r=Ek();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=>t_t(i,r):void 0,children:t})},Jkt=e=>xbe(e)?.kind==="file",e_t=_be,t_t=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(kbe)??"file",i=n.getAttribute(e_t),a=Sxt({kind:r,hasHighlight:Zxt(n),canOpenInCanvas:IA(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||lO(i)});return}lO(i)}},t7=(e,t)=>t==="href"&&Jkt(e)?e:Yue(e),E$={a:pwe,table:Tkt,img:mkt,code:({node:e,className:t,children:n,...r})=>Fkt.exec(t??"")?.[1]==="mermaid"?f.jsx(Mkt,{chart:String(n).replace(Kkt,"")}):f.jsx("code",{dir:"ltr",className:t,...r,children:n})},n_t={...E$,a:tkt(pwe)},r_t=[Bc],i_t=[Bc,Uk],a_t=[Bc,qk],o_t=[Bc,Uk,qk],s_t=[Bc,Ak,jk],l_t=[Bc,Uk,Ak,jk],c_t=[Bc,qk,Ak,jk],u_t=[Bc,Uk,qk,Ak,jk],O_t={"000":r_t,"001":s_t,"010":a_t,"011":c_t,100:i_t,101:l_t,110:o_t,111:u_t},d_t=[],f_t=[rVe],mwe=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),gwe=(e,t,n)=>{const r=$.useMemo(()=>zkt(e),[e]),[i,a]=$.useState(hwe),o=r&&i;return $.useEffect(()=>{if(!r||i)return;let s=!1;return Lkt().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:O_t[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?f_t:d_t}},$we=(e,t,n)=>{const[,r]=$.useState(0);$.useEffect(()=>{if(!t)return;const i=CLe(e);if(i.length===0)return;let a=!0;const o=new Set(i),s=Pxt(l=>{a&&l.some(c=>o.has(c))&&r(c=>c+1)});return ZA(i,window.api?.probeFiles,aoe,kxt(n===void 0?e:`${n}\0${e}`)).then(()=>{a&&i.some(l=>Qbe(l)!=="unknown")&&r(l=>l+1)}),()=>{a=!1,s()}},[e,t,n])},q$=$.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}=gwe(o,r,i),c=mwe(t);return $we(o,r,a),f.jsx("div",{className:R("lo-markdown",n),style:c,children:f.jsx(Gq,{remarkPlugins:s,rehypePlugins:l,urlTransform:t7,components:i?n_t:E$,children:o})})});q$.displayName="MarkdownRenderer";const MF={...E$,a:({children:e})=>f.jsx(f.Fragment,{children:e})},ywe=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:vF(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=Wbe(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=gwe(n,t,!1);if($we(e,t),r!==null){const o=vF(r.before);return f.jsxs(f.Fragment,{children:[o.trim()!==""&&f.jsx(Gq,{remarkPlugins:i,rehypePlugins:a,urlTransform:t7,components:t?E$:MF,children:o}),f.jsx(h_t,{info:r.info,body:r.body})]})}return f.jsx(Gq,{remarkPlugins:i,rehypePlugins:a,urlTransform:t7,components:t?E$:MF,children:n})});ywe.displayName="ParsedBlock";const h_t=({info:e,body:t})=>{const n=e.split(Bkt)[0];return f.jsx("pre",{children:f.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
858
858
  `)?"":`
859
859
  `}`})})},vwe=({content:e,styleProps:t,className:n})=>{const r=$.useRef(null);r.current===null&&(r.current=Mxt());const i=r.current;Hxt(i,e);const{blockStart:a}=i,o=a+Kxt(e.slice(a));let s=null,l=a;(i.kind==="other"||(i.kind==="list"||i.kind==="indented-code")&&Hkt.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=mwe(t);return f.jsx("div",{className:R("lo-markdown",n),style:O,children:u.map(d=>f.jsx(ywe,{source:d.source,closed:d.closed},d.key))})};vwe.displayName="StreamingMarkdown";const Na=({isUser:e,children:t,className:n})=>e?f.jsx("div",{className:R("flex w-full justify-end",n),children:t}):f.jsx("div",{className:R("group relative w-full",n),children:t}),JA=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},p_t=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 e8=JA(Date.now()),lc=null,LF=0,FF=0,BF=0;const m1=new Set,m_t=1e3,g_t=()=>typeof performance>"u"?Date.now():performance.now(),bwe=()=>{const e=Date.now(),t=e+p_t(e),n=g_t();lc!==null&&t===LF&&Math.abs(e-FF-(n-BF))<=m_t||(lc!==null&&clearTimeout(lc),LF=t,FF=e,BF=n,lc=setTimeout(()=>{lc=null,e8=JA(Date.now());for(const r of m1)r();bwe()},t-e),lc.unref?.())},$_t=e=>(m1.add(e),e8=JA(Date.now()),bwe(),()=>{m1.delete(e),m1.size===0&&lc!==null&&(clearTimeout(lc),lc=null)}),HF=()=>e8,y_t=()=>$.useSyncExternalStore($_t,HF,HF),v_t=e=>new Date(e+1e3),b_t=()=>v_t(y_t()),ean=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":fQ(t,{year:"numeric",month:"long",day:"numeric"})}catch(t){return console.error("Error formatting calendar date:",t),""}},w_t=(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=hQ(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=fQ(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),""}},x_t=(e,t)=>{if(!e)return"";try{const n=e instanceof Date?e:new Date(e);return Number.isNaN(n.getTime())?"":iXe(n,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit",...t})}catch(n){return console.error("Error formatting calendar date-time:",n),""}},S_t={turn:"Sent",answer:"Answered",tool:"Ran"},Lx=({timestamp:e,scope:t,className:n})=>{const r=e instanceof Date?e:new Date(e),i=b_t();if(Number.isNaN(r.getTime()))return null;const a=x_t(r,{hour12:!0});return f.jsx($t,{content:a,side:"bottom",delayDuration:1200,children:f.jsx("time",{dateTime:r.toISOString(),"data-stamp":t,"aria-label":`${S_t[t]} ${a}`,className:R("shrink-0 select-none whitespace-nowrap text-ink-dim text-meta",n),children:f.jsx("bdi",{children:w_t(r,i)})})})},t8=({replies:e,onRemoveReply:t})=>(Re(),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(Boe,{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(ti,{"aria-hidden":"true"})})]},n.id))]})),Q_t=({children:e,className:t})=>f.jsx("span",{"aria-hidden":!0,className:R("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),k_t={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},__t=({line:e})=>f.jsx("span",{className:R(k_t[e.kind],"block"),children:e.text}),P_t=({diff:e,className:t})=>{const n=D5e(e);return f.jsxs("div",{className:R("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(__t,{line:r},i)),n.hidden>0&&f.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:V5e(n.hidden)})]})},T_t=(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()},KF=e=>e.startsWith("file://")?e.slice(7):e,X_t={READ:{verb:"Read",runningVerb:"Reading",icon:Goe},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:Koe},EDIT:{verb:"Edited",runningVerb:"Editing",icon:HEe},CODE:{verb:"Ran code",runningVerb:"Running code",icon:Ioe},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:hqe},DONE:{verb:"Finished",runningVerb:"Finishing",icon:yC},ASK:{verb:"Asked",runningVerb:"Asking",icon:pQ},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:T4e}},R_t={verb:"Worked on the request",runningVerb:"Working on the request",icon:Ioe},E_t=(e,t,n,r)=>{const i=e?X_t[e]:R_t;let a;if(t)a=KF(t);else if(n&&n.length>0){const s=n.filter(l=>!l.startsWith("data:"));s.length===1?a=KF(s[0]):s.length>1&&(a=`${s.length} files`)}const o=!a&&r?T_t(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:a,narration:o||void 0,icon:i.icon}},JF="min-h-5 py-0",q_t=({icon:e,verb:t,object:n,narration:r,running:i,failed:a,wrap:o})=>f.jsxs("span",{className:R("flex min-w-0 gap-2",o?"items-start":"items-center"),"aria-busy":i||void 0,children:[f.jsx(Q_t,{className:R(a?"text-danger":"text-ink-dim",o&&yle),children:e}),f.jsxs("span",{className:R(o?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[f.jsxs("span",{...SP,className:R("select-text font-mono text-mono-sm",a?"text-danger":"text-ink-muted"),children:[t,r?":":null]}),n?f.jsxs("span",{...SP,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?f.jsxs("span",{...SP,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),eB=({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=E_t(e,t,n,r),g=c??(i?p.runningVerb:p.verb),y=a?Ed:p.icon,v=a||!c||!O?f.jsx(y,{}):O,b=f.jsx(q_t,{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(Yi,{summary:b,chevron:"leading",summaryAlign:x,defaultOpen:o,className:l,rowClassName:h?JF:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:s}):f.jsx(Yi,{disabled:!0,summary:b,summaryAlign:x,className:l,rowClassName:h?JF:void 0})},wwe=8,j_t="… deeper values not shown",C_t="(empty)";function z_t(e){return`… ${e} more line${e===1?"":"s"}`}const tB=.5;function A_t(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 xwe(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function n8(e){return typeof e=="object"&&e!==null}function Swe(e,t,n,r){if(n>wwe){r.push({key:t,value:j_t,depth:n});return}if(n8(e)){for(const[a,o]of Object.entries(e))Swe(o,t?`${t}.${a}`:a,n+1,r);return}const i=xwe(e);i!==null&&r.push({key:t,value:i,depth:n})}function Qwe(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))Swe(r,n,1,t);return t}const U_t=512;function W_t(e,t){if(t)return!0;if(!e)return!1;let n=U_t;const r=(i,a)=>{if(n--<=0||a>wwe)return!0;if(!n8(i))return xwe(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 Y_t(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(!n8(n))return null;const r=Qwe(n);return r.length>0?r:[{key:"",value:C_t,depth:1}]}const N_t=8,n7="max-h-[min(320px,40vh)]",kwe=n7,G_t=({line:e})=>f.jsxs("div",{className:R("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*N_t},children:[e.key?f.jsxs("span",{className:R("text-ink-muted"),children:[e.key,": "]}):null,f.jsx("span",{className:R("text-ink-dim"),children:e.value})]}),nB=({lines:e,label:t})=>f.jsx("div",{className:R("flex flex-col gap-1"),"data-detail-lines":t,children:e.map((n,r)=>f.jsx(G_t,{line:n},r))});function rB(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+tB);const h=c.children.length>0?Array.from(c.children):[c];n(A_t(h.map(p=>{const g=p.getBoundingClientRect();return{top:g.top,height:g.height}}),u,O.bottom,tB))};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 iB=({lines:e,overflowing:t})=>t?f.jsx("span",{className:R("mt-1 block text-ink-dim"),children:e>0?z_t(e):" "}):null,Z_t=({args:e,output:t,isError:n,interrupted:r=!1,note:i=null})=>{const a=Qwe(e),o=Y_t(t),s=$.useRef(null),l=$.useRef(null),c=rB(s),u=rB(l);return a.length===0&&!t&&!i?null:f.jsxs("div",{className:R("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:R(n7,"overflow-auto"),children:f.jsx(nB,{lines:a,label:"input"})}),f.jsx(iB,{lines:c.lines,overflowing:c.overflowing})]}),i&&f.jsx("div",{className:R("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:R(a.length>0&&"mt-3"),"data-detail-section":"output",children:[f.jsx("span",{className:R("mb-1 block text-meta",n&&!r?"text-danger":"text-ink-dim"),children:r?"Interrupted":n?"Error":"Output"}),f.jsx("div",{ref:l,className:R(n7,"overflow-auto"),children:o?f.jsx(nB,{lines:o,label:"result-json"}):f.jsx("pre",{className:R("whitespace-pre font-mono",n&&!r?"text-danger":"text-ink"),children:t})}),f.jsx(iB,{lines:u.lines,overflowing:u.overflowing})]})]})},I_t="mcp__",D_t={bash:vqe,read:L0,write:VW,edit:VW,glob:Lh,grep:Qy,todo:$Ee,wake:mQ,list_variables:HW,read_variable:HW,browser:MW,console:Hoe,project:x4e,project_delete:wqe,web_search:MW,web_fetch:gQ,task:o0,agent:o0,send:nse,peer:uEe,sessions:eqe};function V_t(e){const t=e.trim().toLowerCase(),n=D_t[t];return n||(t.startsWith(I_t)?Joe:Rqe)}const M_t=QC,L_t=SEe,F_t=wEe,aB="min-h-5 py-0",oB={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent-alt",plain:"text-ink-muted"},B_t=(e,t)=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":e==="receipt"?oB.plain:oB[M5e(t)],H_t=e=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":"text-ink-muted",K_t=({added:e,removed:t})=>e<=0&&t<=0?null:f.jsxs("span",{className:R("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&f.jsxs("span",{className:R("text-success"),children:["+",e]}),t>0&&f.jsxs("span",{className:R("text-danger"),children:["-",t]})]}),J_t={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:""},d2=e=>{const t=J_t[e];return t===""?"":m(t)},ePt=1e3;function tPt(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,ePt);return()=>window.clearInterval(i)},[e]),t}const nPt=({outcome:e,deliveryState:t=null,durationS:n,startedAt:r})=>{const i=e==="running",a=tPt(i?r??null:null),o=e==="error"||e==="not-run",s=e==="partial",l=t?F5e[t]:void 0,c=s?l??null:o?l??d2(e):null,O=R("font-medium text-meta",s?"text-warning":"text-danger",s&&"hidden @[19rem]/toolrow:inline"),d=s&&t?H5e[t]??null:null,h=s&&t?B5e[t]:void 0,p=s?t==="mailbox"?L_t:t==="unconfirmed"?F_t:null:e==="interrupted"?M_t:null,g=p&&s?"text-warning":"text-ink-dim",y=i?r==null?"":Fu(a??0):sC(n);return f.jsxs("span",{className:R("flex shrink-0 items-center gap-1.5"),children:[c?f.jsx("span",{className:O,title:h,"aria-hidden":d?!0:void 0,children:c}):null,f.jsxs("span",{className:R("flex shrink-0 [&_svg]:size-3.5",p&&"size-3.5",g),children:[p?f.jsx(p,{"aria-hidden":!0}):null,!o&&d2(e)?f.jsx("span",{className:R("sr-only"),children:d2(e)}):null,d?f.jsx("span",{className:R("sr-only"),children:d}):null]}),f.jsx("span",{className:R("hidden w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums @[19rem]/toolrow:inline"),children:y})]})},Vu=({toolName:e,op:t="",verbless:n=!1,summary:r,summaryFallback:i=null,summaryHold:a=!1,summaryWrap:o=!1,outcome:s,deliveryState:l=null,durationS:c,startedAt:u=null,added:O=0,removed:d=0,details:h,defaultOpen:p=!1,className:g,media:y})=>{Re();const v=s==="running",b=s==="error",x=V_t(e),Q=I0(e),{verb:w,object:S}=ooe(e,r,i,v,t,L5e(l)),k=f.jsxs("span",{className:R("flex min-w-0 flex-1 items-center gap-2"),children:[f.jsx("span",{"aria-hidden":!0,className:R("flex size-3.5 shrink-0 [&_svg]:size-3.5",B_t(s,e)),children:f.jsx(x,{})}),n?null:f.jsx("span",{"data-trace-verb":"",className:R("shrink-0 whitespace-nowrap text-body-sm",H_t(s)),title:Q,children:w}),f.jsx("span",{className:R(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:S,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:R("sr-only"),children:"pending"})]}):f.jsx("bdi",{dir:"ltr",children:S})}),f.jsx(K_t,{added:O,removed:d}),f.jsx(nPt,{outcome:s,deliveryState:l,durationS:c,startedAt:u})]}),P=v?{"data-glass-state":"running"}:void 0,T=v?"bg-elevated":b?"bg-danger-wash":"hover:bg-row-hover",X=h?f.jsx(Yi,{summary:k,chevron:"leading",defaultOpen:p,className:R("@container/toolrow",g),triggerData:P,rowClassName:aB,triggerClassName:R("-mx-2 rounded-sm px-2",T),children:h}):f.jsx(Yi,{disabled:!0,summary:k,triggerData:P,rowClassName:aB,className:R("@container/toolrow",(v||b)&&R("-mx-2 rounded-sm px-2",T),g)});return y?f.jsxs("div",{className:R("flex flex-col"),children:[X,y]}):X},rPt=3,iPt=2;function aPt(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=K5e(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 _we=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},Pwe=e=>{const t=new Map;let n=0;for(const o of e){const s=_we(o.name);s===null?n+=1:t.set(s,(t.get(s)??0)+1)}const r=r8(e);if(n>0||t.size>2){const o=Twe(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}},oPt=e=>Pwe(e).units;function sPt(e){return oPt(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"}},h2=5,Twe=e=>{if(e.length<=h2)return e.map(r=>r.label);const t=e.slice(0,h2),n=e.slice(h2).reduce((r,i)=>r+i.count,0);return[...t.map(r=>r.label),`and ${n} other action${n===1?"":"s"}`]},r8=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=_we(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{const u=f2[l];if(u)n(`kind:${l}`,u);else{const O=I0(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 lPt(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 cPt(e){let t=null,n=null,r=!1;for(const i of e){i.running===!0&&(r=!0);const a=lPt(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 uPt(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.executing===!0)return ooe(n.name,n.summary??"",null,!0,n.op)}return null}function OPt(e,t){let n=0;for(let r=e.length-1;r>=0&&t(e[r]);r-=1)n+=1;return n}function dPt(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?OPt(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>=rPt||c>=iPt||u){const O=(()=>{if(o.length===0)return{units:[],prose:!1,countUnits:[]};const d=r8(o);return l.length>0?{units:Twe(d),prose:!1,countUnits:d}:Pwe(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:cPt(o),live:uPt(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 fPt(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 sB=e=>{const t=[];for(const n of e)if(!(n.record.kind!=="tool"&&!(n.record.kind==="custom"&&n.record.customType==="hub_message")))for(const r of n.record.images??[])D0(r)&&t.push(r);return t},g1=5,hPt=(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)},pPt=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},Fx=e=>e<=0?null:`${e} image${e===1?"":"s"}`;function Bx(e){return e.record.kind==="tool"?e.record.durationS:null}function Xwe(e){let t=null;for(const n of e){const r=Bx(n);typeof r=="number"&&(t=(t??0)+r)}return t}function mPt(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 gPt="min-h-5 py-0",$Pt=1e3;function yPt(e){const[t,n]=$.useState(()=>Date.now());return $.useEffect(()=>{if(!e)return;const r=()=>n(Date.now());r();const i=window.setInterval(r,$Pt);return()=>window.clearInterval(i)},[e]),t}const vPt=({summary:e,span:t,live:n,open:r,onOpenChange:i,className:a,condensedMedia:o,mediaCount:s=0,recordIds:l,children:c})=>{const u=yPt(t?.running===!0),O=t===null?null:Math.max(0,((t.running?u:t.endedAtMs??u)-t.startedAtMs)/1e3),d=O===null?"":sC(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(Yi,{animate:r||!o,open:r,onOpenChange:i,rowClassName:gPt,triggerClassName:R("-mx-2 rounded-sm px-2","hover:bg-row-hover"),summary:f.jsxs("span",{className:R("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:R("min-w-0 shrink-[100000] truncate"),title:`${n.verb} ${n.object}`,children:[f.jsx("span",{className:R("text-accent"),children:n.verb})," ",f.jsx("span",{className:R("font-mono text-mono-sm text-ink-muted"),children:n.object})]}),f.jsx("span",{"aria-hidden":!0,className:R("text-ink-dim text-meta"),children:"·"})]}),f.jsx("span",{className:R("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:R(e.prose?"whitespace-normal":"whitespace-nowrap"),children:g})]},g))}),Fx(s)!==null&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":!0,className:R("text-ink-dim text-meta"),children:"·"}),f.jsx("span",{className:R("shrink-0 text-ink-muted text-meta"),children:Fx(s)})]}),d!==""&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":!0,className:R("text-ink-dim text-meta"),children:"·"}),f.jsx("span",{"data-fold-span":"",className:R("shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:d})]})]}),children:f.jsx("div",{className:R("flex flex-col"),children:c})}),!r&&o&&o(p)]})},lB=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],bPt=80,wPt=1e3,Rwe=({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=LC("(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)),wPt):null;if(d)return o(0),()=>{b!==null&&window.clearInterval(b)};const x=window.setInterval(()=>o(Q=>(Q+1)%lB.length),bPt);return()=>{window.clearInterval(x),b!==null&&window.clearInterval(b)}},[d,O]),f.jsxs("div",{className:R("flex items-center gap-2",i),"data-lo-working-line":!0,"aria-live":"polite",children:[f.jsx("span",{"aria-hidden":!0,className:R("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:lB[a]}),f.jsx("span",{className:R("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),f.jsx("span",{"aria-hidden":!0,className:R("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:O?Fu(s):""})]})},xPt="min-h-5 py-0",vu=()=>f.jsx("span",{"aria-hidden":!0,className:R("text-ink-dim text-meta"),children:"·"}),SPt=({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})=>{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:R("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(Yi,{open:O,onOpenChange:d,chevron:"trailing",rowClassName:xPt,triggerClassName:R("-ms-2 -me-2 w-[calc(100%+1rem)] rounded-sm ps-2 pe-6","hover:bg-row-hover"),chevronClassName:R("-mr-6","text-ink-muted"),summary:f.jsxs("span",{className:R("flex min-w-0 flex-1 items-center gap-2"),title:s??void 0,children:[c!==null&&f.jsx("span",{className:R("shrink-0 text-body-sm text-ink-muted"),"data-segment-label":"",children:c}),u&&!v?.active&&f.jsx(f.Fragment,{children:f.jsx(yC,{"aria-hidden":!0,className:R("size-3.5 shrink-0 text-success")})}),v?.active?f.jsxs(f.Fragment,{children:[c!==null&&f.jsx(vu,{}),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(vu,{}),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(vu,{}),f.jsx(Rwe,{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(vu,{}),f.jsx("span",{className:R("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(vu,{}),f.jsx("span",{className:R("shrink-0 text-body-sm text-ink-muted"),children:Fu(y.spanS)})]})]}):f.jsxs(f.Fragment,{children:[c!==null&&(i!==null||a>0)&&f.jsx(vu,{}),i!==null&&f.jsxs("span",{className:R("shrink-0 text-body-sm text-ink-muted"),children:["Took ",Fu(i)]}),i!==null&&a>0&&f.jsx(vu,{}),a>0&&f.jsx("span",{className:R("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})})]}),Fx(g)!==null&&f.jsxs(f.Fragment,{children:[f.jsx(vu,{}),f.jsx("span",{className:R("shrink-0 text-body-sm text-ink-muted"),children:Fx(g)})]}),u&&!v?.active&&f.jsx("span",{className:R("sr-only"),children:"completed"}),l!==null&&f.jsx("span",{className:R("ms-auto"),children:f.jsx(Lx,{timestamp:l,scope:"answer"})})]}),children:f.jsx("div",{className:R("flex flex-col"),children:h})}),!O&&p&&f.jsx("div",{className:R("pb-2"),children:p(k)})]})},Ewe="lo-missing-session-notice",cO=({children:e,className:t,boundary:n="hairline",...r})=>f.jsx("div",{className:R("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}),QPt="could not be displayed. It may have been moved, renamed, or deleted.",i8="could not be displayed. Its stored copy is not available to this reader.",qwe="could not be played. Its stored copy is not available to this reader.",jwe=qwe,Md=({name:e,detail:t=QPt,className:n,compact:r=!1})=>r?f.jsx("div",{className:R("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(FW,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0})}):f.jsxs("div",{className:R("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(FW,{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}`]})]}),Hx=4,Cwe=2,kPt=2,zwe=4,Awe=Hx+Cwe,_Pt=.8,PPt=24,cB=.3,uB=1;function TPt(e){return!Number.isFinite(e)||e<=0?1:Math.max(1,Math.floor((e+Cwe)/Awe))}function XPt(e,t){const n=Math.min(e,t-e);return Number.isFinite(n)?Math.max(0,Math.min(1,n/PPt)):0}function RPt(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 Uwe(e,t,n){const r=TPt(t),i=e===null?null:RPt(e,r),a=[],o=Math.max(1,r-1);for(let s=0;s<r;s+=1){const l=s*Awe,c=l+Hx/2,O=(i===null?0:i[s])*n*_Pt,d=Math.max(zwe,Math.round(O)),h=cB+(uB-cB)*(s/o);a.push({x:l,width:Hx,height:d,alpha:Math.min(uB,h)*XPt(c,t)})}return a}function R0(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 EPt(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 qPt(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?0:Math.max(0,Math.min(1,e/t))}function OB(e,t){return`${R0(e)} of ${R0(t)}`}const jPt=4,dB=1,CPt="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",Wwe=({ownerId:e,src:t,label:n,peaks:r,durationHint:i=null,variant:a="full",className:o})=>{Re();const s=zi(te=>te.ownerId===e),l=zi(te=>te.ownerId===e?te.status:"idle"),c=zi(te=>te.ownerId===e?te.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 te=b.current;if(!te)return;const B=()=>{const le=te.getBoundingClientRect();P({width:le.width,height:le.height,dpr:window.devicePixelRatio||1})};B();const ee=new ResizeObserver(B);return ee.observe(te),()=>ee.disconnect()},[]);const T=$.useCallback(te=>{if(!te||k.width<=0)return;const B=te.getContext("2d");if(!B)return;te.width=Math.max(1,Math.round(k.width*k.dpr)),te.height=Math.max(1,Math.round(k.height*k.dpr)),B.setTransform(k.dpr,0,0,k.dpr,0,0),B.clearRect(0,0,k.width,k.height);const ee=getComputedStyle(te).color,le=Uwe(r,k.width,k.height);B.fillStyle=ee;for(const F of le)B.globalAlpha=F.alpha,B.beginPath(),B.roundRect(F.x,(k.height-F.height)/2,F.width,F.height,kPt),B.fill();B.globalAlpha=1},[k.width,k.height,k.dpr,r]);$.useEffect(()=>{T(x.current),T(Q.current)},[T]);const X=$.useRef(null),E=$.useCallback(te=>{const B=qPt(te,p),ee=Q.current;b.current?.style.setProperty("--sound-progress",`${B*100}%`),ee&&(ee.style.clipPath=`inset(0 ${(1-B)*100}% 0 0)`);const le=R0(te);S.current&&S.current.textContent!==le&&(S.current.textContent=le);const F=w.current;F&&(F.setAttribute("aria-valuenow",String(Math.floor(te))),F.setAttribute("aria-valuetext",OB(te,p)))},[p]);$.useEffect(()=>{const te=g||u,B=()=>E(s?YP()?.currentTime??0:G.current);if(!te){B();return}let ee=0;const le=()=>{const F=X.current??YP()?.currentTime??0;E(F),ee=requestAnimationFrame(le)};return ee=requestAnimationFrame(le),()=>cancelAnimationFrame(ee)},[g,u,s,E]);const j=$.useCallback(async()=>(h(!1),zi.getState().play(e,t,{onError:()=>h(!0)})),[e,t]),U=$.useCallback(te=>{const B=zi.getState();if(g){B.seek(e,te),E(te);return}j().then(ee=>{ee!==!1&&(zi.getState().seek(e,te),E(te))})},[e,g,j,E]),C=$.useCallback(async()=>{if(g){zi.getState().pause(e);return}h(!1),await zi.getState().toggle(e,t,{onError:()=>h(!0)})},[e,t,g]),G=$.useRef(0),Y=$.useRef(null),W=$.useCallback(te=>{const B=b.current;if(!B)return 0;const ee=B.getBoundingClientRect();return EPt(te-ee.left,ee.width,p)},[p]),Z=te=>{if(y)return;te.currentTarget.setPointerCapture?.(te.pointerId),Y.current={pointerId:te.pointerId,startX:te.clientX,moved:!1,pendingX:te.clientX,raf:0}},V=te=>{const B=Y.current;!B||B.pointerId!==te.pointerId||(Math.abs(te.clientX-B.startX)>jPt&&(B.moved||O(!0),B.moved=!0),B.pendingX=te.clientX,B.moved&&B.raf===0&&(B.raf=requestAnimationFrame(()=>{const ee=Y.current;if(!ee)return;ee.raf=0;const le=W(ee.pendingX);X.current=le,zi.getState().scrub(e,le),E(le)})))},A=te=>{const B=Y.current;if(!B||B.pointerId!==te.pointerId)return;B.raf!==0&&cancelAnimationFrame(B.raf),Y.current=null,X.current=null,te.currentTarget.releasePointerCapture?.(te.pointerId);const ee=W(te.clientX);if(B.moved){G.current=ee,O(!1),zi.getState().seek(e,ee),E(ee);return}U(ee)},I=te=>{const B=YP(),ee=s&&B?B.currentTime:0;if(te.key===" "||te.key==="Enter"){te.preventDefault(),C();return}let le=null;if(te.key==="ArrowLeft"?le=ee-dB:te.key==="ArrowRight"?le=ee+dB:te.key==="Home"?le=0:te.key==="End"&&(le=p),le===null)return;te.preventDefault();const F=Math.max(0,Math.min(p,le));U(F)},J=a==="compact",N=`${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:R("flex w-full min-w-0 items-center gap-2",J?"gap-1.5":"gap-2",o),children:[f.jsx("button",{type:"button",className:CPt,disabled:y,onClick:()=>void C(),"aria-label":`${g?"Pause":"Play"} ${n}`,children:y?f.jsx(yo,{size:"sm"}):g?f.jsx(Zoe,{size:22,"aria-hidden":"true"}):f.jsx(g4e,{size:22,"aria-hidden":"true"})}),f.jsx("div",{ref:w,role:"slider",tabIndex:0,"aria-label":N,"aria-valuemin":0,"aria-valuemax":Math.max(0,Math.round(p)),"aria-valuenow":0,"aria-valuetext":OB(0,p),"data-sound-slider":"",className:R("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:V,onPointerUp:A,onPointerCancel:A,onKeyDown:I,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:R("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:R("min-w-10 shrink-0 text-center text-meta text-ink-muted tabular-nums"),children:R0(0)}),f.jsx("span",{className:R("min-w-10 shrink-0 text-center text-meta text-ink-dim tabular-nums"),children:R0(p)}),v?f.jsx("span",{"data-sound-error":"",className:R("shrink-0 text-meta text-ink-muted"),children:m("ui.chat.canonical.sound.player_failed")}):null]})};function fB(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 hB=new Map;async function zPt(e,t){try{const n=await Rc({op:"sessions.attachment.waveform",sessionId:e.sessionId,digest:t},null);if(n.kind==="json")return fB(n.body);if(n.kind==="bytes"){const r=new TextDecoder().decode(n.data);try{return fB(JSON.parse(r))}catch{return null}}return null}catch{return null}}function Ywe(e,t){const n=t?.sessionId??null,r=t?.childId??null,[i,a]=$.useState(()=>e?APt(e):null);return $.useEffect(()=>{if(!e||!n){a(null);return}let o=!0;return UPt({sessionId:n,childId:r},e).then(s=>{o&&a(s)}),()=>{o=!1}},[e,n,r]),i}function APt(e){return r7.get(e)??null}const r7=new Map;function UPt(e,t){const n=hB.get(t);if(n)return n;const r=zPt(e,t).then(i=>(r7.set(t,i),i)).catch(()=>(r7.set(t,null),null));return hB.set(t,r),r}function Nwe(e){return`sound:${e.attachment??e.id}`}const a8=({audio:e,scope:t,label:n,ownerId:r})=>{const i=iv(e,t),a=Ywe(e.attachment,t);return i.state==="missing"?f.jsx(Md,{name:n,detail:jwe}):i.state==="resolving"?f.jsx("div",{className:R("inline-block max-w-full self-start"),"aria-hidden":!0,children:f.jsx(cO,{"data-attachment-reserved":""})}):f.jsx("div",{className:R("w-full max-w-[560px] self-start"),children:f.jsx(Wwe,{ownerId:r??Nwe(e),src:i.url,label:n,peaks:a,durationHint:e.durationS??null})})},nd=1,Gwe=4,pB=(e,t)=>Math.min(Gwe,Math.max(nd,e+t)),$g=Object.freeze({x:0,y:0}),p2=(e,t)=>t<=0?0:Math.min(t-1,Math.max(0,Math.trunc(e))),m2=(e,t,n)=>t<=0?0:((e+n)%t+t)%t,WPt=(e,t)=>m("ui.common.viewer.position",{kind:"image",index:e+1,count:t}),mB=(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))}},YPt="max-h-[min(90vh,calc(100vh-104px))] max-w-[min(90vw,calc(100vw-104px))]",NPt="max-h-[min(90vh,calc(100vh-208px))] max-w-[min(90vw,calc(100vw-104px))]",gB=e=>R(e,"flex min-h-16 min-w-64 items-center justify-center p-6"),GPt="opacity-85",Hf="bg-surface/85 disabled:bg-surface/85",o8=({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})=>{Re();const d=c==="video",h=(F,L)=>u==="asset"?m("ui.common.viewer.position",{kind:"asset",index:F+1,count:L}):WPt(F,L),[p,g]=$.useState(null),y=e!==void 0&&p===e,[v,b]=$.useState(nd),[x,Q]=$.useState($g),w=$.useRef(e);$.useLayoutEffect(()=>{w.current!==e&&(w.current=e,b(nd),Q($g))},[e]);const[S,k]=$.useState(!0),P=$.useRef(null);$.useEffect(()=>{if(!n)return;let F;const L=()=>{clearTimeout(F),F=setTimeout(()=>{const ue=P.current;if(ue&&(ue.matches(":hover")||ue.contains(document.activeElement))){L();return}k(!1)},Wle)},ne=()=>{k(!0),L()};return k(!0),L(),document.addEventListener("pointermove",ne,{passive:!0}),document.addEventListener("pointerdown",ne,{passive:!0}),document.addEventListener("keydown",ne),document.addEventListener("focusin",ne),()=>{clearTimeout(F),document.removeEventListener("pointermove",ne),document.removeEventListener("pointerdown",ne),document.removeEventListener("keydown",ne),document.removeEventListener("focusin",ne)}},[n]);const T=s?.onPrev,X=s?.onNext,E=s!==void 0&&s.count>1,j=E?NPt:YPt,U=$.useRef(null),C=l??U;$.useEffect(()=>{if(!n||!E)return;const F=L=>{L.defaultPrevented||L.metaKey||L.ctrlKey||L.altKey||(L.key==="ArrowLeft"?(L.preventDefault(),T?.()):L.key==="ArrowRight"&&(L.preventDefault(),X?.()))};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[n,E,T,X]),iC(n,"lightbox");const G=$.useRef(null),Y=!d&&e!==void 0&&!y,W=v===nd&&x.x===$g.x&&x.y===$g.y,Z=F=>{if(!Y)return;b(F);const L=G.current;L&&Q(ne=>mB(ne,{width:L.clientWidth,height:L.clientHeight},F))},V=()=>{Y&&(b(nd),Q($g))},A=$.useRef(null),[I,J]=$.useState(!1),N=Y&&v>nd,te=F=>{!N||F.button!==0||(F.currentTarget.setPointerCapture(F.pointerId),A.current={pointerId:F.pointerId,startX:F.clientX,startY:F.clientY,pan:x},J(!0))},B=F=>{const L=A.current,ne=G.current;!L||L.pointerId!==F.pointerId||!ne||Q(mB({x:L.pan.x+(F.clientX-L.startX),y:L.pan.y+(F.clientY-L.startY)},{width:ne.clientWidth,height:ne.clientHeight},v))},ee=F=>{A.current?.pointerId===F.pointerId&&(A.current=null,J(!1))},le=e!==void 0&&!y?f.jsx("div",{ref:G,"data-image-viewport":"",tabIndex:-1,className:R(j,"relative h-fit w-fit overflow-hidden leading-none outline-none",N&&(I?"cursor-grabbing":"cursor-grab"),N&&"touch-none"),onPointerDown:te,onPointerMove:B,onPointerUp:ee,onPointerCancel:ee,children:d?f.jsx("video",{src:e,controls:!0,autoPlay:!0,className:R(j,"block object-contain"),"data-lightbox-video":"",onError:()=>g(e),children:t}):f.jsx("img",{src:e,alt:t,draggable:!1,className:R(j,"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:gB(j),"aria-hidden":"true"}):f.jsx("div",{className:gB(j),children:a});return f.jsx(fC,{open:n,onOpenChange:r,children:f.jsxs(hC,{ref:C,tabIndex:-1,onOpenAutoFocus:F=>{F.preventDefault(),(G.current??C.current)?.focus()},showClose:!1,"aria-describedby":void 0,onCloseAutoFocus:F=>{const L=i?.current;L&&(F.preventDefault(),L.focus())},className:R("inset-0 top-0 left-0 m-auto h-fit w-fit translate-none outline-none",j,"gap-0 rounded-none border-0 border-transparent bg-transparent p-0 shadow-none"),...O,children:[f.jsx(pC,{className:"sr-only",children:t}),E&&s?f.jsx("div",{"aria-live":"polite",className:"sr-only",children:h(s.index,s.count)}):null,le,f.jsxs("div",{ref:P,"data-image-viewer-controls":"",className:R("pointer-events-none fixed inset-0 transition-opacity ease-out-quart",S?"opacity-100 duration-fast":`${GPt} duration-base`),children:[E&&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,E?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:R("pointer-events-auto fixed top-0 bottom-0 left-4 my-auto",Hf),"data-image-viewer-prev":"",children:f.jsx(r4e,{"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:R("pointer-events-auto fixed top-0 right-4 bottom-0 my-auto",Hf),"data-image-viewer-next":"",children:f.jsx(woe,{"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===nd,onClick:()=>Z(pB(v,-1)),className:Hf,children:f.jsx(ise,{"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===Gwe,onClick:()=>Z(pB(v,1)),className:Hf,children:f.jsx(rse,{"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:V,className:Hf,children:f.jsx(yQ,{"aria-hidden":"true"})})]}),f.jsx(Y2e,{asChild:!0,children:f.jsx(ke,{variant:"ghost",size:"icon-sm",className:R("pointer-events-auto fixed top-4 right-4",Hf),"aria-label":m("ui.common.viewer.close",{kind:u}),title:m("ui.common.viewer.close",{kind:u}),children:f.jsx(ti,{"aria-hidden":"true"})})})]})]})})};o8.displayName="ImageLightbox";const ZPt={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(" ")},IPt=/[/\\]/,$B=e=>{const t=e.split(IPt);return t[t.length-1]},Zwe=$.memo(({file:e,src:t,conversationId:n,label:r,size:i="full",overlay:a,press:o})=>{const[s,l]=$.useState(!1),[c,u]=$.useState(!1),[O,d]=$.useState(!1),h=$.useRef(null),p=kn(T=>T.setCanvasOpen),{setViewMode:g}=Od(),y=$.useCallback(async()=>{const T=$B(e),X=C=>{C&&console.error("Error processing file:",C);const G=e.startsWith("file://")?e.substring(7):e;window.api.openFile(G).catch(Y=>{console.error("Error opening file:",Y)})},{setFiles:E,setOpenTabs:j,setSelectedTab:U}=Od.getState();if(e.startsWith("data:"))if(Vj(T)){const C=e,G={id:C,title:T,path:C,content:e,type:ex(e)},W=Od.getState().conversations?.[n],Z=W?.files??[],V=W?.openTabs??[],A=(()=>{const N=Z.findIndex(te=>te.id===C);return N!==-1?[...Z.slice(0,N),G,...Z.slice(N+1)]:[...Z,G]})();E(n,A);const J=V.some(N=>N.id===C)?V:[...V,{id:C,title:T}];j(n,J),U(n,C),p(!0),g(n,"documents")}else p(!0),g(n,"files");else{const C=e.startsWith("file://")?e.substring(7):e;try{const G=await window.api.readFile(C);if(G.success&&Vj(T)){const Y=C,W={id:Y,title:T,path:C,content:G.data,type:ex(e)},V=Od.getState().conversations?.[n],A=V?.files??[],I=V?.openTabs??[],J=(()=>{const B=A.findIndex(ee=>ee.id===Y);return B!==-1?[...A.slice(0,B),W,...A.slice(B+1)]:[...A,W]})();E(n,J);const te=I.some(B=>B.id===Y)?I:[...I,{id:Y,title:T}];j(n,te),U(n,Y),p(!0),g(n,"documents");return}p(!0),g(n,"files")}catch(G){const Y=G instanceof Error?G.message:String(G??"Unknown error reading file");return X(Y)}}},[e,p,g,n]),v=()=>{l(!0)},b=owe(e),Q=(b==="path"||b==="data")&&n!=="",w=lwe(b,{canShowInCanvas:Q,source:t}),S=b==="path",k=r??$B(e);if(s)return f.jsx(Md,{name:k,compact:i==="thumbnail"});const P=f.jsx(cO,{boundary:i==="thumbnail"?"control":"hairline",children:f.jsx("img",{className:R(ZPt[i],c?"opacity-100":"opacity-0"),src:t,alt:k,loading:"lazy",decoding:"async",onLoad:()=>u(!0),onError:v})});return f.jsxs("div",{className:"group relative inline-block",children:[f.jsx("button",{ref:h,type:"button",className:R("block max-w-full cursor-pointer",i==="thumbnail"&&"group/tile rounded-sm"),onClick:o?o.onPress:()=>d(!0),"aria-label":o?o.label:`Expand ${k}`,title:o?o.title:`Click to expand ${k}`,"aria-current":o?.current?"true":void 0,children:P}),w&&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(uwe,{file:e,src:t,label:k,onShowInCanvas:Q?y:void 0})}),o?null:a?a({open:O,onOpenChange:d,restoreFocusTo:h}):f.jsx(o8,{src:t,label:k,open:O,onOpenChange:d,restoreFocusTo:h,fallback:f.jsx(Md,{name:k,detail:S?void 0:i8})})]})});Zwe.displayName="ImageAttachment";const DPt=(e,t,n)=>e.name??(n===1?"Image":`Image ${t+1}`),VPt={id:"image-group:empty",data:null,attachment:null,mimeType:"image/png"},MPt=({cold:e,children:t})=>e?f.jsx("div",{className:"flex h-[79px] w-[117px] items-start leading-none",children:t}):t,LPt=({images:e,index:t,scope:n,open:r,onOpenChange:i,restoreFocusTo:a,labelFor:o=DPt})=>{const s=e.length,[l,c]=$.useState(()=>p2(t,s)),[u,O]=$.useState(r);u!==r&&(O(r),r&&c(p2(t,s)));const d=p2(l,s),h=e[d]??VPt,p=o(h,d,s),g=KA(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=m2(d,s,W),V=y.current?.contains(document.activeElement)??!1;c(Z),V&&w(Z)},k=()=>S(-1),P=()=>S(1),T=JSON.stringify([n?.sessionId,n?.childId,e.map(W=>[W.id,W.attachment,W.mimeType])]),[X,E]=$.useState(()=>({identity:T,open:r,indices:new Set}));(X.identity!==T||X.open!==r)&&E({identity:T,open:r,indices:new Set});const j=$.useCallback(W=>{E(Z=>{if(!r||Z.identity!==T||!Z.open||W.every(A=>Z.indices.has(A)))return Z;const V=new Set(Z.indices);for(const A of W)V.add(A);return{...Z,indices:V}})},[T,r]),U=m2(d,s,-1),C=m2(d,s,1);$.useEffect(()=>{r&&j([d,U,C])},[r,d,U,C,j]),$.useEffect(()=>{const W=y.current;if(!r||!b||!W||typeof IntersectionObserver>"u")return;let Z=!0;const V=new IntersectionObserver(A=>{Z&&j(A.filter(I=>I.isIntersecting).map(I=>Number(I.target.dataset.imageSlot)-1))},{root:W});for(const A of W.querySelectorAll("[data-image-slot]"))V.observe(A);return()=>{Z=!1,V.disconnect()}},[r,b,j]);const G=(W,Z)=>!!W.data||!W.attachment||Z===d||Z===U||Z===C||X.identity===T&&X.open&&X.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:R("flex shrink-0 scroll-mx-px rounded-sm leading-none",Z===d&&"ring-1 ring-ink"),children:f.jsx(MPt,{cold:!!W.attachment&&!W.data,children:G(W,Z)?f.jsx(fm,{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:()=>{j([Z]),c(Z)},children:f.jsx(cO,{boundary:"control",className:"h-[78px] w-[117px]","data-attachment-reserved":"","data-attachment-deferred":""})})})},W.id))}):void 0;return f.jsx(o8,{src:g.state==="ready"?g.url:void 0,pending:g.state==="resolving",label:p,open:r,onOpenChange:i,restoreFocusTo:a,fallback:f.jsx(Md,{name:p,detail:i8}),layerRef:v,group:{index:d,count:s,onPrev:k,onNext:P,filmstrip:Y}})},fm=({image:e,scope:t,label:n,size:r,group:i,press:a})=>{const o=KA(e,t);if(o.state==="resolving"){const l=f.jsx(cO,{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:l}):f.jsx("div",{className:R("inline-block max-w-full"),"aria-hidden":!0,children:l})}if(o.state==="missing")return f.jsx(Md,{name:n,compact:r==="thumbnail",detail:i8});const s=o.url;return f.jsx("div",{className:R("inline-block max-w-full"),children:f.jsx(Zwe,{file:s,src:s,label:n,size:r,conversationId:t?.sessionId??"",press:a,overlay:i?l=>f.jsx(LPt,{images:i.images,index:i.index,labelFor:i.labelFor,scope:t,open:l.open,onOpenChange:l.onOpenChange,restoreFocusTo:l.restoreFocusTo}):void 0})})};function FPt(){return m("ui.chat.checkpoint.generating_name")}const BPt={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 HPt(e){return e.id===e.activeId?"active":e.id===e.previewId?"preview":e.loaded===!1?"unloaded":"rest"}function Iwe(e,t){return m("ui.chat.checkpoint.turn",{turn:e,total:t})}function KPt(e,t){const n=Iwe(e.turn,t),r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`${n} · ${r}`:n}function JPt(e){return e.kind==="completion"&&e.naming?.state==="pending"}function e5t(e){const t=e.naming?.state==="ready"?e.naming.summary:null;return t?.trim()?t:null}function t5t(e){let t=0;for(const n of e)n.turn>t&&(t=n.turn);return t}const n5t={complete:"Complete",error:"Error",interrupted:"Interrupted",open:"Open"};function r5t(e){if(!Number.isFinite(e)||e<=0)return"";const t=new Date(e*1e3);return Number.isNaN(t.getTime())?"":hQ(t,{hour:"numeric",minute:"2-digit"})}function i5t(e,t){if(e.kind==="user"){const r=r5t(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 a5t(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 g2(e,t){const n=[];for(const r of t)a5t(e,r)==="pending"&&n.push(r);return n}const o5t=120,yB=80,gc=10,Kx=24,s5t=2,i7=420,Dwe=32;function Wk(e,t){return(t?s5t:0)+Kx+e*gc}function vB(e,t){return Wk(e,t)+Kx}function l5t(e,t,n){if(t<=0)return{start:0,end:0};const r=Dwe*gc,i=Math.floor(Math.max(0,e)/r),a=i*r-i7,o=(i+1)*r+2*i7,s=Wk(0,n),l=Math.max(0,Math.floor((a-s)/gc)),c=Math.min(t,Math.ceil((o-s)/gc));return{start:Math.min(l,c),end:c}}function c5t(e,t,n,r,i=24){const a=Wk(e,t),o=a+gc;return a<n+i?Math.max(0,a-i):o>n+r-i?o-r+i:null}const u5t="Turn checkpoints",O5t={complete:va,error:Ed,interrupted:QC,open:f4e},d5t={complete:"text-success",error:"text-danger",interrupted:"text-warning",open:"text-ink-dim"},f5t=({checkpoint:e,turnCount:t})=>{const n=e.outcome,r=n?O5t[n]:null,i=e5t(e),a=e.naming?.state==="ready"?e.naming.name?.trim():"";return f.jsxs(f.Fragment,{children:[f.jsxs("p",{className:R("text-body-sm font-medium text-ink"),children:[Iwe(e.turn,t),a&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",children:" · "}),f.jsx("span",{className:R("font-normal text-ink-muted"),children:a})]})]}),JPt(e)&&f.jsx("p",{className:R("text-ink-dim text-meta"),children:FPt()}),i&&f.jsx("p",{className:R("line-clamp-2 break-words text-body-sm text-ink-muted"),children:i}),n&&r&&f.jsx("div",{className:R("flex items-center gap-1.5 text-ink-dim text-meta"),children:f.jsxs("span",{className:R("flex items-center gap-1",d5t[n]),children:[f.jsx(r,{"aria-hidden":"true",className:R("size-3.5 shrink-0")}),n5t[n]]})})]})},h5t=$.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:R("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:R("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",BPt[n])})})}),p5t=({sessionId:e,checkpoints:t,onJump:n,onHover:r,building:i=!1,loadedIds:a,activeId:o=null})=>{Re();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((he,_e)=>[he.id,_e])),[t]),b=$.useRef(v);b.current=v;const x=$.useRef(i);x.current=i;const[Q,w]=$.useState({sessionId:"",top:0}),S=Dwe*gc,k=$.useCallback(he=>{const _e=Math.floor(Math.max(0,he)/S)*S;w(Ke=>Ke.sessionId===e&&Ke.top===_e?Ke:{sessionId:e,top:_e})},[S,e]),P=Q.sessionId===e?Q.top:Math.max(0,vB(t.length,i)-i7),T=$.useRef(null),X=$.useRef(null),E=$.useCallback(()=>{T.current!==null&&(clearTimeout(T.current),T.current=null),X.current!==null&&(clearTimeout(X.current),X.current=null)},[]),j=$.useCallback((he,_e)=>{E();const Ke=()=>{O(he),h(p.current.find(rt=>rt.id===he)??null)};if(_e<=0){Ke();return}T.current=setTimeout(()=>{T.current=null,Ke()},_e)},[E]),U=$.useCallback(he=>{if(E(),he<=0){O(null);return}X.current=setTimeout(()=>{X.current=null,O(null)},he)},[E]),C=$.useRef(e);$.useEffect(()=>{C.current!==e&&(C.current=e,E(),L.current=null,c(null),O(null),h(null))},[e,E]);const G=$.useRef(null);$.useLayoutEffect(()=>{const he=y.current;if(!(t.length===0||he===null)){if(o!==null&&Y.current===e){G.current=e,k(he.scrollTop);return}G.current!==e&&(G.current=e,he.scrollTop=vB(t.length,i),k(he.scrollTop))}},[o,i,t.length,e,k]);const Y=$.useRef(null);$.useLayoutEffect(()=>{if(o===null)return;const he=y.current,_e=b.current.get(o);if(he===null||_e===void 0)return;Y.current=e;const Ke=c5t(_e,x.current,he.scrollTop,he.clientHeight);Ke!==null&&(he.scrollTop=Ke),k(he.scrollTop)},[o,e,k]),$.useEffect(()=>()=>E(),[E]);const W=$.useRef(r);$.useEffect(()=>{W.current=r});const Z=$.useMemo(()=>t5t(t),[t]),V=u&&d?.id===u?d:null,A=u&&g.current.get(u)||null,I=$.useMemo(()=>({current:A}),[A]),J=V!==null&&A!==null;$.useEffect(()=>{W.current(J&&u?u:null)},[J,u]);const N=$.useCallback((he,_e)=>{_e?g.current.set(he,_e):g.current.delete(he)},[]),[te,B]=$.useState(null),ee=te&&v.has(te)?te:t[0]?.id??null,le=$.useRef(null),F=$.useCallback(he=>{const _e=Math.max(0,Math.min(t.length-1,he)),Ke=t[_e];if(!Ke)return;B(Ke.id);const rt=g.current.get(Ke.id);if(rt){rt.focus();return}const dt=y.current;dt!==null&&(dt.scrollTop=Math.max(0,Wk(_e,i)+gc/2-dt.clientHeight/2),k(dt.scrollTop)),le.current=Ke.id},[i,t,k]);$.useLayoutEffect(()=>{const he=le.current;if(he===null)return;const _e=g.current.get(he);_e&&(le.current=null,_e.focus())});const L=$.useRef(null),ne=$.useCallback(he=>{L.current!==he&&(L.current=he,c(he),j(he,o5t))},[j]),ue=$.useCallback(()=>{L.current=null,c(he=>he===null?he:null),U(yB)},[U]),oe=$.useCallback(he=>{L.current=he,B(he),c(_e=>_e===he?_e:he),j(he,0)},[j]),ve=$.useCallback(()=>{L.current=null,c(he=>he===null?he:null),U(yB)},[U]),ye=$.useCallback(he=>{U(0),L.current=null,c(null),n(he)},[U,n]),Qe=$.useCallback((he,_e)=>{if(he.key==="Escape"){U(0);return}const Ke=v.get(_e);if(Ke!==void 0){if(he.key==="ArrowDown"){he.preventDefault(),he.stopPropagation(),F(Ke+1);return}if(he.key==="ArrowUp"){he.preventDefault(),he.stopPropagation(),F(Ke-1);return}if(he.key==="Home"){he.preventDefault(),he.stopPropagation(),F(0);return}he.key==="End"&&(he.preventDefault(),he.stopPropagation(),F(t.length-1))}},[t.length,U,F,v]),Ee=l5t(P,t.length,i),ze=[];for(let he=Ee.start;he<Ee.end;he+=1)ze.push(he);for(const he of[ee,u,l]){const _e=he===null?void 0:v.get(he);_e!==void 0&&(_e<Ee.start||_e>=Ee.end)&&!ze.includes(_e)&&ze.push(_e)}return ze.sort((he,_e)=>he-_e),t.length===0&&!i?null:f.jsxs("div",{"data-lo-checkpoint-rail":"",role:"toolbar","aria-orientation":"vertical","aria-label":u5t,className:R("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:he=>k(he.currentTarget.scrollTop),className:R("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:R("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*gc+2*Kx},children:ze.map(he=>{const _e=t[he];return f.jsx(h5t,{checkpoint:_e,top:Kx+he*gc,state:HPt({id:_e.id,previewId:l,activeId:o,loaded:a?a.has(_e.id):!0}),label:i5t(_e,Z),roving:_e.id===ee,registerTick:N,onPreview:ne,onPreviewEnd:ue,onFocusMark:oe,onBlurMark:ve,onActivate:ye,onKeyMark:Qe,describedBy:J&&u===_e.id?s:void 0},_e.id)})})]}),f.jsxs(N2e,{open:J,onOpenChange:he=>{he||U(0)},children:[f.jsx(G2e,{virtualRef:I}),V&&f.jsx(Z2e,{id:s,"data-checkpoint-card":"",side:"left",align:"center",sideOffset:10,collisionPadding:8,role:"tooltip","aria-label":V.kind==="user"?"Your message":KPt(V,Z),onOpenAutoFocus:he=>he.preventDefault(),onCloseAutoFocus:he=>he.preventDefault(),onFocusOutside:he=>{const _e=he.detail?.originalEvent?.target;_e instanceof Element&&_e.closest("[data-lo-checkpoint-rail]")&&he.preventDefault()},className:R("pointer-events-none max-h-[176px] w-[300px] max-w-[300px] overflow-hidden","flex flex-col gap-2"),children:V.kind==="user"?f.jsx("div",{"data-checkpoint-card-text":"",className:R("line-clamp-3 break-words whitespace-pre-wrap","text-body-sm text-ink"),children:V.text}):f.jsx(f5t,{checkpoint:V,turnCount:Z})})]})]})},m5t=$.memo(p5t);function g5t(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 $5t=(e,t,n)=>(e.getAttribute(t)??"").split(" ").includes(n);function y5t(e,t){return e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`)!==null}function Vwe(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):!$5t(a,i,t))continue;if(a.querySelector("button[aria-expanded]")?.getAttribute("aria-expanded")==="false")return a}return null}function v5t(e,t){return y5t(e,t)||Vwe(e,t)!==null}const b5t=3;function w5t(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>=b5t){n.onMissing();return}const s=Vwe(e,t)?.querySelector("button[aria-expanded]");if(!s){n.onMissing();return}s.click(),window.requestAnimationFrame(()=>{r(i+1)})};r(0)}const bB=(e,t,n)=>n===1?"Image":`Image ${t+1}`,wB=({images:e,scope:t,onRevealMore:n,uncapped:r=!1,indent:i="content"})=>{const{shown:a,more:o}=hPt(e.length,{uncapped:r}),s=pPt(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:R("flex leading-none",l&&c.has(d)&&"col-start-1"),children:f.jsx(fm,{image:O,scope:t,size:"thumbnail",label:bB(O,d,e.length),group:{images:e,index:d,labelFor:bB}})},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:R("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:R("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 xB(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 x5t(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 S5t=({video:e,scope:t,label:n})=>{const r=iv(e,t),[i,a]=$.useState(!1);return r.state==="missing"||i?f.jsx(Md,{name:n,detail:qwe}):r.state==="resolving"?f.jsx("div",{className:R("inline-block max-w-full self-start"),"aria-hidden":!0,children:f.jsx(cO,{"data-attachment-reserved":""})}):f.jsx("div",{className:R("inline-block max-w-full self-start"),children:f.jsx(cO,{children:f.jsx("video",{controls:!0,preload:"metadata",src:r.url,"aria-label":n,className:R("max-h-[240px] max-w-full object-contain"),onError:()=>a(!0)})})})};function Q5t({items:e,summary:t,scope:n}){return Re(),f.jsxs("div",{"data-sound-batch":"",className:R("flex w-full min-w-0 max-w-[560px] flex-col gap-4"),children:[f.jsx("p",{className:R("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:R("min-w-0"),children:[f.jsxs("p",{className:R("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:R("text-body-sm text-ink break-words [overflow-wrap:anywhere]"),children:r.error}):r.audio?f.jsx(a8,{audio:r.audio,ownerId:`${Nwe(r.audio)}:batch:${r.audio.id}:${r.id}`,scope:n,label:r.label}):f.jsx("p",{className:R("text-meta text-ink-muted"),children:m("ui.chat.canonical.sound.batch_attachment_unavailable")}),f.jsx("p",{className:R("text-meta text-ink-dim"),children:r.costCaption??"Cost not yet known."})]},r.id))})]})}function tan({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(Mwe,{onKeepWaiting:c,onRequestStop:O}):null,[a,t,c,O]);return{paneRef:s,stop:u,confirmation:d}}function Mwe({onKeepWaiting:e,onRequestStop:t}){Re();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 k5t=1e3;function _5t(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,k5t);return()=>window.clearInterval(i)},[e]),t}function P5t(){return f.jsx("div",{"aria-hidden":!0,"data-imagegen-tile":"",className:R("relative aspect-[3/2] w-[240px] max-w-full overflow-hidden rounded-sm bg-sunken"),children:f.jsx("span",{className:R("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 SB=44,T5t=240,$2=12,X5t=Array.from({length:240},(e,t)=>Math.min(1,.18+Math.abs(Math.sin(t/7)*Math.cos(t/17))*.72));function R5t({state:e}){const t=Uwe(X5t,T5t-$2*2,SB);return f.jsx("div",{"aria-hidden":!0,"data-sound-loading-tile":"","data-sound-loading":e,className:R("relative flex w-[240px] max-w-full items-center overflow-hidden rounded-sm bg-sunken"),style:{height:SB},children:f.jsx("div",{className:R("flex w-full items-center"),style:{paddingLeft:$2,paddingRight:$2},children:t.map((n,r)=>f.jsx("span",{"data-sound-loading-bar":"",className:R("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:Hx,height:e==="failed"?zwe:n.height,marginRight:n===t.at(-1)?0:2,animationDelay:e==="running"?`${r%12*90}ms`:void 0}},n.x))})})}function E5t({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?Ew(e.argumentBytes):null;break;case"running":n=e.batchProgress?`Generating ${e.batchProgress.total} ${hh(e.material)}${e.batchProgress.total===1?"":"s"}…`:`Generating ${hh(e.material)}…`,r=t===null?null:Fu(t);break;case"cancelling":n=e.generating?JE:jW;break;case"done":n=e.receipt==="already-finished"?"Already finished.":e.batch?`${y2(e.material)} batch`:`Generated ${hh(e.material)}`,r=e.receipt==="already-finished"||e.durationS===null?null:sC(e.durationS);break;case"failed":n=e.batch?`${y2(e.material)} batch failed.`:e.message??`The ${hh(e.material)} could not be generated.`,i=!0;break;case"cancelled":{const a=e.message??(e.generating?JE:jW);n=e.batch?`${y2(e.material??"sound-effect")} batch stopped.`:e.settlementCaption||e.settled?_Xe(a):a;break}}return f.jsxs("p",{className:R("flex min-w-0 items-baseline gap-1.5 text-body-sm"),children:[f.jsx("span",{className:R("min-w-0",i?"text-ink":"text-ink-muted"),children:n}),r===null?null:f.jsxs("span",{className:R("shrink-0 text-meta text-ink-dim"),children:["· ",r]})]})}function q5t({line:e}){return f.jsx("p",{"data-imagegen-log":"",title:e,className:R("min-w-0 truncate font-mono text-mono-sm text-ink-dim"),children:e})}function y2(e){const t=hh(e);return t.charAt(0).toUpperCase()+t.slice(1)}function Kf({line:e,prominent:t=!1}){return f.jsx("p",{"data-imagegen-note":"",className:R("min-w-0 text-body-sm",t?"text-ink-muted":"text-ink-dim"),children:e})}function j5t(e,t){return e==="cancel"?"Stop":e==="restart"?t==="failed"?"Retry":"Restart":"Edit and restart"}const C5t=({view:e,scope:t,actions:n})=>{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=_5t(c),O=TXe(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))?JE: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:R("flex w-full flex-col gap-2"),children:[v?f.jsx(R5t,{state:v}):p?f.jsx(P5t,{}):null,e.state==="failed"&&(e.material==="voiceover"||e.material==="sound-effect")&&e.errorType?f.jsx("p",{className:R("text-meta text-ink-dim"),children:e.errorType}):null,f.jsx(E5t,{view:e,elapsed:u}),(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.costCaption?f.jsx(Kf,{line:e.costCaption,prominent:!!e.batch}):null,(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.batchNote?f.jsx(Kf,{line:e.batchNote,prominent:!0}):null,e.state==="running"&&e.batchProgress?.note?f.jsx(Kf,{line:e.batchProgress.note}):null,e.state==="cancelled"&&e.settlementCaption?f.jsx(Kf,{line:e.settlementCaption}):null,b?f.jsx(Kf,{line:b}):null,l&&r?f.jsx(Mwe,{onKeepWaiting:a,onRequestStop:()=>{i(!1),n?.onCancel?.()}}):null,e.state==="running"&&typeof e.note=="string"?f.jsx(Kf,{line:e.note}):null,p&&e.progress.fraction!==null?f.jsx(I2e,{"aria-label":"Image generation progress",className:R("max-w-[240px]"),value:Math.round(Math.min(1,Math.max(0,e.progress.fraction))*100)}):null,x===null?null:f.jsx(q5t,{line:x}),(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.batch?f.jsx(Q5t,{items:e.batch,summary:e.batchSummary??`${e.batch.length} items`,scope:t}):e.state==="done"&&e.images.length>0?f.jsx("div",{className:R("flex flex-col gap-2"),children:e.images.map((Q,w)=>{const S=`Generated ${hh(Q.kind==="audio"?e.material:Q.kind??"image")}`,k=e.images.length===1?S:`${S} ${w+1}`;return Q.kind==="video"?f.jsx(S5t,{video:Q,scope:t,label:k},Q.id):Q.kind==="audio"?f.jsx(a8,{audio:Q,scope:t,label:k},Q.id):f.jsx(fm,{image:Q,scope:t,label:k},Q.id)})}):null,O.length>0&&!(l&&r)?f.jsx("div",{"data-imagegen-controls":"",className:R("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:j5t(Q.kind,e.state)},Q.kind))}):null]})},hm="data-lo-quote-toolkit";function a7(e,t){return e.kind!=="user"&&e.kind!=="assistant"||t.trim().length===0?!1:e.kind!=="assistant"?!0:!e.streaming}const QB=e=>(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(`[${hm}]`)??null,z5t=e=>e.nodeType===Node.ELEMENT_NODE,A5t=e=>{const t=Array.from(e.childNodes),n=t.findIndex(r=>z5t(r)&&r.hasAttribute(hm));return n===-1?t.length:n},U5t=(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,W5t=e=>{const t=Array.from(document.querySelectorAll(`[${hm}]`),n=>n.getBoundingClientRect());return Array.from(e.getClientRects()).filter(n=>!t.some(r=>U5t(r,n))).map(n=>({top:n.top,left:n.left,right:n.right,bottom:n.bottom}))};function Uh(e){if(!e)return null;const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;const n=t.getRangeAt(0);if(QB(n.startContainer)||QB(n.endContainer)||!e.contains(n.startContainer))return null;const r=n.cloneRange();e.contains(n.endContainer)||r.setEnd(e,A5t(e));const i=r.toString().trim();return i.length===0?null:{text:i,lines:W5t(n)}}const kB="[data-lo-canonical-transcript]",Y5t="[data-lo-transcript-content]",_B=e=>({top:e.top,left:e.left,right:e.right,bottom:e.bottom}),N5t=()=>({top:0,left:0,right:window.innerWidth,bottom:window.innerHeight});function Lwe(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=OWe({lines:h,container:_B((O.closest(kB)??O).getBoundingClientRect()),viewport:N5t(),size:{width:d.offsetWidth,height:d.offsetHeight},row:_B(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(kB),p=h?.querySelector(Y5t),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 Fwe(e){const[t,n]=$.useState(null);$.useEffect(()=>{const i=()=>n(Uh(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 dh="data-lo-link-toolbar",G5t=120,Z5t=2;function Bwe(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=qxt(u);if(O){n(h=>h===O?h:O),i(h=>h===!0?h:!0);return}if(i(h=>h===!1?h:!1),Tbe()){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()},G5t))},p=(k,P)=>{const T=o.current;if(!T||!u.contains(T))return!1;const X=u.querySelector(`[${dh}]`),E=$z+Z5t;for(const j of[T,X]){if(!j)continue;const U=j.getBoundingClientRect();if(!(U.width<=0||U.height<=0)&&k>=U.left-E&&k<=U.right+E&&P>=U.top-E&&P<=U.bottom+E)return!0}return!1},g=k=>{const P=k.target;if(P?.closest(`[${hm}]`))return;const T=P?.closest(Oh)??null;!T&&p(k.clientX,k.clientY)||h(T)},y=k=>{const P=k.relatedTarget;P&&u.contains(P)||p(k.clientX,k.clientY)||d(null)},v=k=>{const P=k.target?.closest(Oh);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(`[${dh}] button:not([disabled])`)),Q=k=>{const P=k.target;if(!P)return!1;if(P.closest(`[${dh}]`)){const j=x(),U=j.indexOf(P);if(U===-1)return!1;if(k.shiftKey&&U===0){const C=o.current;return C instanceof HTMLElement?(C.focus(),!0):!1}if(!k.shiftKey&&U===j.length-1){const C=Array.from(u.querySelectorAll(Oh)),G=o.current,Y=G?C.indexOf(G)+1:-1,W=Y>0?C[Y]:void 0;return W?(W.focus(),!0):!1}return!1}if(k.shiftKey)return!1;const X=P.closest(Oh);if(!X||!u.contains(X))return!1;o.current!==X&&d(X);const[E]=x();return E?(E.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 T=k.target?.closest(Oh);!T||!u.contains(T)||(k.preventDefault(),d(T),requestAnimationFrame(()=>{u.querySelector(`[${dh}] 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(`[${dh}]`))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 Hwe(e,t,n){const r=Gn(i=>i.addReply);return $.useCallback(()=>{const a=Uh(t.current)?.text??(Tbe()?null:n?.()??null);a&&(r(e,{id:Aa(),text:a}),window.getSelection()?.removeAllRanges(),IC())},[r,e,t,n])}const Kwe=({conversationId:e,turnRef:t,subject:n,quoteAvailable:r,onDismiss:i})=>{const a=n.getAttribute(_be)??"",o=n.getAttribute("data-lo-kind")??"file",s=Ek(),l=$.useCallback(()=>(n.textContent??"").trim()||null,[n]),c=Hwe(e,t,l),{text:u}=Fwe(t),{speak:O}=nm(),d=PQ(e),h=u??l(),p=h===null?null:ep(e,_Q(h).text);Hce(p);const g=XQ({key:p,getText:()=>Uh(t.current)?.text??l(),play:({text:G})=>O(ep(e,G),TQ(d,G))}),[y,v]=$.useState(!1),[b,x]=$.useState(()=>h1(a)??null),{controlRef:Q,placement:w}=Lwe({turnRef:t,visible:!0,lines:()=>{const G=n.getClientRects();return Array.from(G,Y=>({top:Y.top,left:Y.left,right:Y.right,bottom:Y.bottom}))},measureKey:n,belowWhenOffFirstLine:!0});$.useEffect(()=>{const G=h1(a);if(x(G??null),v(!1),G!==void 0)return;let Y=!0;return _xt(a,window.api?.probeFiles).then(()=>{Y&&x(h1(a)??null)}),()=>{Y=!1}},[a]);const S=o==="file"&&IA(s,a),k=Ebe({target:a,isDirectory:b?.exists===!0&&!b.isFile,probe:b,canOpenInCanvas:S}),P=zxt({kind:o,target:a,probe:b,quotable:r,canOpenInCanvas:S});if(!P||!a)return null;const T=async()=>{await nv(a)&&v(!0)},X=async()=>{if(o==="url"){await gF(o,a);return}s&&k&&await s.openInCanvas(a)||await gF(o,a)||x(null)},E=async()=>{await lO(a)||x(null)},j=async()=>{await DA(a)||x(null)},U={quote:f.jsx(ese,{}),copy:y?f.jsx(va,{}):f.jsx(rf,{}),open:k?f.jsx(MEe,{}):o==="url"?f.jsx($Q,{}):f.jsx(Sy,{}),"open-default":f.jsx(LRe,{}),"open-folder":f.jsx(Lh,{})},C={quote:c,copy:()=>{T()},open:()=>{X()},"open-default":()=>{E()},"open-folder":()=>{j()}};return f.jsxs(yz,{[hm]:"",[dh]:"",ref:Q,label:P.label,className:R("absolute z-20",!w&&"invisible"),style:w?{top:w.top,left:w.left}:void 0,onKeyDown:G=>{if(G.key!=="Escape")return;window.getSelection()?.removeAllRanges();const Y=n;G.preventDefault(),i(),Y.focus?.()},children:[P.actions.map(G=>f.jsxs($.Fragment,{children:[f.jsx($t,{content:G.id==="copy"&&y?"Copied":G.label,side:w?.placement==="below"?"bottom":"top",children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":G.id==="copy"&&y?"Copied":G.label,className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:C[G.id],children:U[G.id]})}),G.id==="quote"&&f.jsx(RQ,{control:g,side:w?.placement==="below"?"bottom":"top"})]},G.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 I5t({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 o7(e){return e.kind!=="user"&&e.kind!=="assistant"||e.kind==="assistant"&&e.streaming?null:e.id||null}const PB=96;function D5t(e){const t=e.replace(/\s+/g," ").trim();return t.length<=PB?t:`${t.slice(0,PB-1).trimEnd()}…`}function V5t(){return m("ui.chat.response_actions.answer_label")}function M5t(){return m("ui.chat.response_actions.yours_label")}const L5t="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 TB(e){return e?"opacity-100":L5t}const Jwe=2e3,F5t=1e4;function nan(e){const{request:t}=e;return t?e.now-t.requestedAt>F5t?"retire":e.presentable?e.claimed?"hold":"present":"yield":null}let XB=0,iw=0;const B5t=Zi(e=>({request:null,requestPanel:(t,n,r,i)=>{XB+=1,e({request:{destination:t,nonce:XB,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:()=>{iw+=1,e({presenterClaimed:!0});let t=!1;return()=>{t||(t=!0,iw=Math.max(0,iw-1),iw===0&&e({presenterClaimed:!1}))}}})),H5t=(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)},K5t=9e4,RB=new Set,J5t=2600,$1=$.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}=nm(),Q=PQ(r??null),w=XQ({key:i?Fce(i):null,getText:()=>t,play:({text:U})=>{i&&x(i,Q,U)}}),S=B5t(U=>U.requestPanel),k=!!(s&&l);Re();const P=I5t({role:n,forkable:k}),T=O||w.active;$.useEffect(()=>()=>{g.current!==null&&clearTimeout(g.current)},[]),$.useEffect(()=>{if(!a||o===void 0||RB.has(a)||(RB.add(a),Date.now()-o>K5t))return;const U=y.current;if(U===null)return;const C=U.closest(".group")??U;if(H5t(U,C))return;p(!0);const G=()=>{p(!1),C.removeEventListener("pointerenter",G),C.removeEventListener("focusin",G)};return C.addEventListener("pointerenter",G),C.addEventListener("focusin",G),()=>{C.removeEventListener("pointerenter",G),C.removeEventListener("focusin",G)}},[a,o]),$.useEffect(()=>{if(h)return b.current=setTimeout(()=>{b.current=null,p(!1)},J5t),()=>{b.current!==null&&clearTimeout(b.current)}},[h]);const X=async()=>{await nv(t)&&(d(!0),g.current!==null&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,d(!1)},Jwe))},E=()=>{!s||!l||S("session.fork",v.current,s,{id:l,excerpt:D5t(t)})},j={copy:f.jsx($t,{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:R("text-ink-dim hover:bg-transparent hover:text-ink"),onClick:X,children:O?f.jsx(va,{"aria-hidden":"true"}):f.jsx(rf,{"aria-hidden":"true"})})}),speak:f.jsx(RQ,{control:w,side:"bottom",className:R("text-ink-dim hover:bg-transparent hover:text-ink")}),fork:f.jsx($t,{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:R("text-ink-dim hover:bg-transparent hover:text-ink"),onClick:E,children:f.jsx(J4e,{"aria-hidden":"true"})})})};return f.jsx("div",{role:"toolbar","aria-label":n==="user"?M5t():n==="commentary"?m("ui.chat.commentary_actions.label"):n==="response"?m("ui.chat.response_actions.label"):V5t(),ref:y,onAnimationEnd:U=>{U.target===U.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:R(c?R("absolute z-10 flex h-8 items-center gap-1","-top-2 end-0",TB(T),u):R("flex h-8 shrink-0 items-center gap-1",TB(T))),children:P.map(U=>f.jsx($.Fragment,{children:j[U]},U))})}),eTt="@container/olderhistory mb-4 flex h-7 min-w-0 items-center gap-2",aw="@min-[260px]/olderhistory:hidden",ow="@max-[260px]/olderhistory:hidden",e1e="lo-older-history-hint",tTt=({state:e,transportDown:t=!1,onLoadOlder:n,onRetryHydration:r})=>{Re();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:eTt,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:aw,children:m("ui.chat.canonical.older_history.transport.short")}),f.jsx("span",{className:ow,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:aw,children:m("ui.chat.canonical.older_history.failed.short")}),f.jsx("span",{className:ow,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(yo,{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:e1e,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:aw,children:t?m("ui.chat.canonical.older_history.windowed.title"):m("ui.chat.canonical.older_history.windowed.short_gesture")}),f.jsx("span",{className:ow,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:aw,children:m("ui.chat.canonical.older_history.unproven.short")}),f.jsx("span",{className:ow,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")})]})},nTt="/settings?section=providers",EB="/settings?section=providers&provider=radient",rTt="/settings?section=radient",qB=/sign in to radient/i,iTt=[/insufficient credits/i,/credit balance is too low/i],aTt=[/rate limit or quota/i],oTt=[/insufficient credits/i,/\bHTTP 402\b/i];function t1e(e){return(e??"").split("/")[0]?.trim().toLowerCase()==="radient"}function s8(e){return t1e(e.provider)?e.category==="billing"?!0:(e.category==null||e.category==="unknown"||e.category==="rate-limit")&&oTt.some(n=>n.test(e.text)):!1}function sTt(e){if(!s8(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 lTt(e){return e==="auth"?"sign-in":e==="billing"?"billing":e==="rate-limit"?"quota":null}function jB(e){const t=t1e(e.provider)||qB.test(e.text);let n=lTt(e.category);return s8(e)&&(n="billing"),n===null&&(e.category==null||e.category==="unknown")&&(qB.test(e.text)?n="sign-in":iTt.some(r=>r.test(e.text))?n="billing":aTt.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:EB}:n==="billing"&&t?{label:m("ui.chat.provider_error.action.open_radient_account"),to:rTt}:{label:m("ui.chat.provider_error.action.open_provider_settings"),to:t?EB:nTt}}const n1e=({conversationId:e,turnRef:t,allowQuote:n=!0})=>{Re();const{text:r,clear:i}=Fwe(t),a=r!==null,o=Hwe(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=Uh(t.current)?.text??r;v&&await nv(v)&&(l(!0),c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,l(!1)},Jwe))},[r,t]),{controlRef:O,placement:d}=Lwe({turnRef:t,visible:a,lines:()=>Uh(t.current)?.lines??null}),{speak:h}=nm(),p=PQ(e),g=r===null?null:ep(e,_Q(r).text);Hce(g);const y=XQ({key:g,getText:()=>Uh(t.current)?.text??null,play:({text:v})=>h(ep(e,v),TQ(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(yz,{[hm]:"",ref:O,label:m("ui.chat.transcript_copy.selection.toolbar"),className:R("absolute z-20",!d&&"invisible"),style:d?{top:d.top,left:d.left}:void 0,children:[n&&f.jsx($t,{content:"Quote",side:d?.placement==="below"?"bottom":"top",children:f.jsx(ke,{variant:"ghost",size:"icon-sm","aria-label":"Quote",className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:o,children:f.jsx(ese,{})})}),f.jsx($t,{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(va,{}):f.jsx(rf,{})})}),f.jsx(RQ,{control:y,side:d?.placement==="below"?"bottom":"top"})]}):null},r1e={all:["radient-prices"],prices:()=>[...r1e.all,"prices"]},cTt=()=>{const e=vt({queryKey:r1e.prices(),queryFn:()=>KC({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}},CB="https://console.radienthq.com/dashboard/verification",zB="https://console.radienthq.com/dashboard/billing",AB=()=>m("ui.common.account.top_up");function uTt(e){return!e.email_verified&&e.signup_grant!=="claimed"}const ran=e=>typeof e!="number"||!Number.isFinite(e)?m("ui.common.account.free_credits_unknown"):m("ui.common.account.free_credits",{amount:`$${e.toFixed(2)}`}),s7=e=>Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`,OTt=e=>typeof e!="number"||!Number.isFinite(e)?m("ui.common.account.free_credits_unknown"):m("ui.common.account.free_credits",{amount:s7(e)});function UB(e,t){if(!e)return t;try{const{protocol:n}=new URL(e);return n==="https:"||n==="http:"?e:t}catch{return t}}function dTt(e){window.api?.openExternal?window.api.openExternal(e):window.open(e,"_blank")}const fTt=(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 hTt(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:CB},{label:AB(),url:zB}]};if(uTt(e)){const i=UB(e.claim_url,CB),{action:a}=fTt(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=OTt(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:s7(n.bonus_amount),minimum:s7(n.minimum_purchase)})),{state:"verified",lines:r,links:[{label:AB(),url:UB(n?.topup_url,zB)}]}}const pTt=5*1e3,mTt=({action:e})=>{const{user:t,accountRead:n}=Tle({staleTime:pTt,retryOnMount:!1}),r=kr(),{prices:i}=cTt(),o=r.isPending||n==="checking"?null:hTt(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(xy,{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:()=>dTt(s.url),children:s.label},s.url)),f.jsx(ke,{variant:"ghost",size:"sm",asChild:!0,children:f.jsx(Noe,{to:e.to,children:e.label})})]})]})},v2=(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)},y1=24,i1e=6,l7=()=>new Promise(e=>{window.requestAnimationFrame(()=>{e()})}),WB=async e=>{for(let t=0;t<i1e;t+=1){if(e())return;await l7()}},a1e=e=>{let t=null;return()=>(t!==null||(t=e().finally(()=>{t=null})),t)},gTt=e=>{const t=a1e(e.loadOlder),n=()=>WB(()=>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 WB(()=>e.reachable()),e.reachable()?"landed":"exhausted"}if(o>=i.maxPages||(o+=1,!await t()))return"exhausted";await n()}}}},Bg="data-jump-highlight",$Tt=1400,yTt=12,vTt=1200,bTt=i1e,wTt=bTt+2,xTt=2,STt=30,YB=1,yg=y1;let Jf=0;async function QTt(e){const{isReachable:t,rowDistance:n,mount:r,loadOlder:i}=e,a=e.hasHeadroom??(()=>!0);return await gTt({reachable:t,rowDistance:n,mount:r,loadOlder:i,hasHeadroom:a}).loadThrough({maxPages:yTt,maxRows:vTt})==="landed"}async function kTt(e,t,n){if(!n()||!t.isConnected)return;Jf+=1;const r=Jf;v2(e,t,"reversed",yg);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<wTt&&(await l7(),!(!n()||!t.isConnected||a||r!==Jf));u+=1){const O=t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-yg;if(Math.abs(O)<=YB){if(l+=1,l>=xTt){c=!0;break}continue}l=0,v2(e,t,"reversed",yg)}if(c&&!a&&r===Jf){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<STt;h+=1){if(await l7(),!n()||a||r!==Jf||!u.isConnected||!O.isConnected)return;const p=O.getBoundingClientRect().top-u.getBoundingClientRect().top-u.clientTop-yg;if(Math.abs(p)<=YB)continue;v2(u,O,"reversed",yg);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===Jf){const l=e.ownerDocument?.defaultView;l!=null&&e.dispatchEvent(new l.Event("scroll"))}}function o1e(e,t,n,r=()=>!0){return r()?new Promise(i=>{w5t(e,n,{isCurrent:r,onRevealed:a=>{if(!r()){i("missing");return}NB(a),kTt(t,a,r).then(()=>{r()&&a.isConnected&&!a.hasAttribute(Bg)&&NB(a),i(r()?"landed":"missing")})},onMissing:()=>{i("missing")}})}):Promise.resolve("missing")}const b2=new WeakMap;function NB(e){const t=b2.get(e);t!==void 0&&window.clearTimeout(t);const n=e.hasAttribute(Bg);e.removeAttribute(Bg),n&&e.offsetHeight,e.setAttribute(Bg,""),b2.set(e,window.setTimeout(()=>{b2.delete(e),e.removeAttribute(Bg)},$Tt))}const Yu=120,sw=400,_Tt=.5,PTt=320,TTt=900,lw=64,Yk=2,w2=24,x2=3,XTt=4,j$=12,c7=j$,RTt=120,ETt=.35,GB=12,qTt=8,jTt=j$,CTt=.5,ZB=()=>({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}),s1e=e=>Math.min(TTt,Math.max(PTt,Math.round(e*_Tt))),zTt=(e,t)=>{if(t.direction==="down")return{...e,armed:!1,deliberate:!1,retained:!1,actFetchSpent:t.at-e.lastInputAt>=sw?!1:e.actFetchSpent,actAsks:t.at-e.lastInputAt>=sw?0:e.actAsks,revealsThisAct:t.at-e.lastInputAt>=sw?0:e.revealsThisAct,continuation:!1,clampLatched:!1,travelledSinceLatch:!1,actTravelled:e.actTravelled||t.travelledPx>=lw,pageWidenOwed:!1,turnedAround:e.busy,chainFetch:0,chainWiden:0,chainInvisible:0,lastInputAt:t.at};const n=t.at-e.lastInputAt>=sw,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>=lw:e.actTravelled||t.travelledPx>=lw,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>=lw&&!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}},vg=(e,t,n)=>({action:t,state:{...e,armed:!1,deliberate:!1,busy:!0,continuation:!1,clampLatched:e.clampLatched||e.armed&&n.distanceFromTopPx<=Yk,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}}),ATt=(e,t,n)=>e.busy||e.pageWidenOwed?!0:!e.armed||!l1e(t).inZone?!1:t.distanceFromTopPx<=Yk?!e.pressDemand||!e.clampLatched||e.actTravelled||e.actAsks>=c7?!1:n-e.lastInputAt>=Yu:!0;function l1e(e,t=s1e(e.clientHeight)){return{inZone:e.distanceFromTopPx<=t}}const UTt=(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=s1e(t.clientHeight),{inZone:a}=l1e(t,i),o=n-e.lastInputAt>=Yu||t.distanceFromTopPx<=Yk,s=e.revealsThisAct<jTt;if(e.pageWidenOwed&&r==="widen"&&e.chainWiden<GB&&s)return o?vg({...e,pageWidenOwed:!1,continuation:!1,armed:!1,retained:!1,deliberate:!1},r,t):{action:"none",state:e};if(e.armed){if(e.deliberate)return vg(e,r,t);if(r==="fetch"&&e.failures>=x2)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>=Yu;return l&&e.clampLatched&&!e.actTravelled&&e.pressDemand&&e.actAsks<c7?vg(e,r,t):l?{action:"none",state:{...e,armed:!1}}:{action:"none",state:e}}return vg(e,r,t)}if(e.continuation){const l=e.actAsks<c7,c=l&&e.chainInvisible>0&&e.chainInvisible<j$;return t.scrollable&&!(e.pageWidenOwed&&r==="widen")&&!c?{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}:s&&(r==="widen"?e.chainWiden<GB:(c||l&&e.chainFetch<XTt)&&e.failures<x2)?vg({...e,pageWidenOwed:!1,continuation:!1},r,t):{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}}return{action:"none",state:e}},IB=(e,{network:t=!0,hiddenRowsAfter:n=0,paintedDelta:r=null,growthPx:i=null,clientHeight:a=0,newRecords:o=null}={})=>{const s=r!==null&&r<qTt,l=r===null&&t&&i!==null&&i<Math.max(RTt,ETt*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,j$):0,continuation:t&&n>0||c&&e.chainInvisible+1<j$||!e.retained&&!e.turnedAround}},WTt=e=>({...e,busy:!1,pressDemand:!1,failures:e.failures+1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),YTt=e=>({...e,busy:!1,pressDemand:!1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),NTt=(e,t,n,r)=>n===r?c1e(e,t):null,c1e=(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)<CTt?0:n};function DB(e,t=56){if(e.length<=t)return e;const n=Math.floor((t-1)/2);return`${e.slice(0,n)}…${e.slice(-n)}`}const VB=({label:e,copied:t,onCopy:n})=>f.jsxs(f.Fragment,{children:[f.jsx("button",{type:"button",onClick:n,"aria-label":e,title:e,className:R("shrink-0 rounded-sm p-0.5 text-ink-dim hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-1"),children:t?f.jsx(va,{"aria-hidden":"true",className:R("size-3.5")}):f.jsx(rf,{"aria-hidden":"true",className:R("size-3.5")})}),f.jsx("output",{className:R("sr-only"),"aria-live":"polite",children:t?e:""})]});function GTt(e,t){const[n,r]=$.useState(null);return $.useEffect(()=>{if(!t||!e){r(null);return}const i=window.api?.probeFiles;if(!i)return;let a=!1;return i([e]).then(o=>{if(a)return;const s=o[0];if(!s||s.error){r(null);return}r(s.exists)}),()=>{a=!0}},[e,t]),n}const ZTt=({document:e,remote:t=!1,placementKnown:n=!0,existence:r})=>{Re();const i=e.filename||m("ui.chat.attachments.file_unnamed"),a=GTt(r===void 0?e.path:null,!t&&n),s=(r===void 0?a:r)===!1,[l,c]=$.useState(!1),u=s?e.storedPath:e.path,O=h=>s?m(h?"ui.chat.attachments.saved_path_copied":"ui.chat.attachments.copy_saved_path"):m(h?"ui.chat.attachments.path_copied":"ui.chat.attachments.copy_path"),d=$.useCallback(async()=>{if(u)try{await navigator.clipboard.writeText(u),c(!0),window.setTimeout(()=>c(!1),2e3)}catch{c(!1)}},[u]);return f.jsxs("div",{className:R("flex max-w-[32rem] items-start gap-2.5 py-1"),"data-document-id":e.id,children:[f.jsx(Oz,{name:i,mimeType:e.mimeType,className:R("mt-0.5 size-4.5 shrink-0 text-ink-muted")}),f.jsxs("div",{className:R("flex min-w-0 flex-col gap-0.5"),children:[f.jsx("span",{className:R("break-all text-body-sm text-ink"),children:i}),f.jsx("span",{className:R("text-ink-muted text-meta"),children:xce(i,e.mimeType,e.bytes)}),e.path&&f.jsxs("span",{className:R("flex min-w-0 items-center gap-1"),children:[f.jsx("span",{className:R("select-all truncate font-mono text-meta",s?"text-ink-dim":"text-ink-muted"),title:e.path,children:DB(e.path)}),!s&&u&&f.jsx(VB,{label:O(l),copied:l,onCopy:d})]}),s&&f.jsxs("span",{className:R("flex flex-col gap-0.5 text-ink-muted text-meta"),children:[f.jsx("span",{className:R("font-medium text-danger"),children:m("ui.chat.attachments.file_missing")}),!e.storedPath&&f.jsx("span",{children:m("ui.chat.attachments.file_missing_recovery")})]}),s&&e.storedPath&&f.jsxs("span",{className:R("flex min-w-0 items-center gap-1 text-meta"),children:[f.jsx("span",{className:R("shrink-0 text-ink-muted"),title:e.attachment?m("ui.chat.attachments.file_retained",{digest:e.attachment}):void 0,children:m("ui.chat.attachments.saved_copy_label")}),f.jsx("span",{className:R("select-all truncate font-mono text-ink-muted text-meta"),title:e.storedPath,children:DB(e.storedPath,40)}),f.jsx(VB,{label:O(l),copied:l,onCopy:d})]})]})]})};function u1e({path:e}){switch(sz(e)){case"image":return f.jsx(Voe,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"spreadsheet":return f.jsx(Moe,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"markdown":case"text":case"document":return f.jsx(L0,{"aria-hidden":"true",className:"size-3.5 shrink-0"});default:return f.jsx(Sy,{"aria-hidden":"true",className:"size-3.5 shrink-0"})}}function ITt(e,t){try{return IA(e,t)}catch{return!1}}function l8(e,t,n){const r=$.useCallback(async o=>{try{const[s]=await window.api.probeFiles([e],t??void 0);if(!s?.resolved.startsWith("/"))throw new Error("File path has no session working directory");await o(s.resolved)}catch{Er(m("ui.chat.highlights.file_resolution_failed"))}},[e,t]),i=ITt(n??null,e),a=$.useCallback(()=>{r(async o=>{i&&n&&await n.openInCanvas(o)||await lO(o)})},[r,i,n]);return{canOpenInCanvas:i,press:a,withTarget:r}}const O1e=$.memo(function({actionPath:t,label:n,cwd:r,pane:i,overlay:a=!1}){Re();const{canOpenInCanvas:o,withTarget:s}=l8(t,r,i),[l,c]=$.useState(!1),u=`Actions for ${n||"this file"}`;return f.jsxs(mC,{children:[f.jsx($t,{content:"File actions",children:f.jsx(gC,{asChild:!0,children:a?f.jsx(ke,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":u,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":u,children:f.jsx(iq,{"aria-hidden":"true",className:"size-3.5"})})})}),f.jsxs($C,{align:"end",className:"min-w-45",children:[o&&f.jsxs(nl,{onSelect:()=>{s(O=>i?.openInCanvas(O))},children:[f.jsx(Loe,{"aria-hidden":"true"}),f.jsx("span",{children:m("ui.chat.canonical.supplement.file_actions.open_in_canvas")})]}),f.jsxs(nl,{onSelect:()=>{s(lO)},children:[f.jsx(Sy,{"aria-hidden":"true"}),f.jsx("span",{children:m("ui.chat.canonical.supplement.file_actions.open_in_default_app")})]}),f.jsxs(nl,{onSelect:()=>{s(DA)},children:[f.jsx(Lh,{"aria-hidden":"true"}),f.jsx("span",{children:m("ui.chat.canonical.supplement.file_actions.reveal_in_finder")})]}),f.jsxs(nl,{onSelect:()=>{navigator.clipboard.writeText(t).then(()=>c(!0)).catch(()=>Er(m("ui.notices.files.copy_path_failed")))},children:[f.jsx(kC,{"aria-hidden":"true"}),f.jsx("span",{children:l?"Copied":"Copy file path"})]})]})]})}),DTt="lo-supplement",VTt="s";function MTt(e,t){return`${DTt}://${VTt}/${e}/${t}`}const LTt="[supplement] frame torn down after a second load (hostile navigation or a blocked attempt)";function FTt(e){let t=e.parentElement;for(;t;){const n=window.getComputedStyle(t);if((n.overflowY==="auto"||n.overflowY==="scroll")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function BTt({component:e,sessionId:t,documentHtml:n,documentFailed:r=!1,onRetry:i,onHeightChange:a,className:o}){Re();const s=J5e(e),[l,c]=$.useState(s),[u,O]=$.useState(!1),[d,h]=$.useState(!0),p=$.useRef(null),g=$.useRef(null),y=$.useRef(""),v=$.useRef(!1),b=$.useRef(""),x=$.useRef(()=>{}),Q=$.useRef(0),w=$.useRef(s),S=$.useRef(null),k=$.useRef(()=>{}),P=$.useRef(a),T=$.useRef(()=>{}),X=$.useCallback(E=>{v.current||(v.current=!0,b.current=E,O(!0))},[]);return $.useEffect(()=>{if(n===null)return;const E=g.current;if(!E)return;y.current=eTe();const j=window.api?.desktop?.armSupplementFrame,U=t!==null&&DE(e.attachment);let C;if(j===void 0)C=tTe(n);else if(U)C=MTt(t,e.attachment);else{X("no-address");return}let G=!1,Y=!1,W=null,Z=null,V=null;const A={resize:null,error:!1},I=window.setTimeout(()=>{G||X("no-ready")},hW),J=ne=>{E.contentWindow?.postMessage(ne,"*")},N=()=>{v.current||Z===null&&(J({lo:"supplement-host",t:"ping"}),Z=window.setTimeout(()=>{Z=null,X("no-pong")},hW))};x.current=()=>{Y||v.current||(Y=!0,N(),W=window.setInterval(N,nTe))};const te=ne=>{const ue=p.current;if(ue){const oe=FTt(ue);if(oe&&ue.getBoundingClientRect().top<oe.getBoundingClientRect().top){S.current=ne,P.current?.(ne);return}}S.current=null,P.current?.(ne),ne!==w.current&&(w.current=ne,c(ne))},B=()=>{V===null&&(V=window.requestAnimationFrame(()=>{V=null;const{resize:ne,error:ue}=A;if(A.resize=null,A.error=!1,ue){X("frame-error");return}ne!==null&&te(ne)}))},ee=ne=>{if(v.current||ne.source!==E.contentWindow||ne.origin!=="null")return;const ue=aTe(ne.data,y.current);if(ue){if(ue.t==="ready"){G||(G=!0,window.clearTimeout(I));return}if(ue.t==="pong"){Z!==null&&(window.clearTimeout(Z),Z=null);return}if(ue.t==="resize"){A.resize=oTe(ue.h),h(!1),B();return}A.error=!0,B()}},le=()=>{const ne=S.current;ne!==null&&te(ne)};window.addEventListener("message",ee),window.addEventListener("scroll",le,!0);let F=!1;return(async()=>{if(j)try{await j(C)}catch{}F||(E.src=C)})(),()=>{F=!0,window.clearTimeout(I),W!==null&&window.clearInterval(W),Z!==null&&window.clearTimeout(Z),V!==null&&window.cancelAnimationFrame(V),window.removeEventListener("message",ee),window.removeEventListener("scroll",le,!0),x.current=()=>{}}},[n,X,t,e.attachment]),P.current=a,T.current=E=>{v.current||Q.current!==1||g.current?.contentWindow?.postMessage({lo:"supplement-host",t:"theme",mode:E.mode,vars:E.vars,nonce:y.current},"*")},$.useEffect(()=>rTe(E=>T.current(E)),[]),k.current=()=>{const E=Q.current+1;if(Q.current=E,E>1){console.debug(LTt),X("second-load");return}T.current(iTe()),x.current()},u||r?f.jsxs("div",{className:"text-ink-dim text-meta","data-supplement-frame-fallback":r?"document":b.current,children:[m("ui.chat.canonical.supplement.frame.failed"),i&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",className:"px-1 text-ink-dim",children:"·"}),f.jsx("button",{type:"button",className:"text-ink-dim","data-supplement-frame-retry":"",onClick:()=>i(),children:m("ui.common.actions.retry")})]})]}):f.jsxs("div",{className:o,"data-supplement-frame-box":"",children:[f.jsxs("div",{ref:p,"data-supplement-frame":"",className:"relative overflow-hidden",style:{height:l,width:"100%"},children:[n!==null&&f.jsx("iframe",{ref:g,title:e.title,sandbox:"allow-scripts",onLoad:()=>k.current(),className:"block h-full w-full border-0"}),d&&f.jsxs(f.Fragment,{children:[f.jsx("output",{className:"sr-only",children:m("ui.chat.canonical.supplement.frame.loading")}),f.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 animate-shimmer bg-elevated/40 bg-gradient-to-r from-transparent via-elevated/60 to-transparent bg-[length:200%_100%] bg-[position:-200%_50%] bg-no-repeat"})]})]}),f.jsx("span",{className:"block truncate text-ink-muted text-meta",title:m("ui.chat.canonical.supplement.frame.source",{name:e.source}),"data-supplement-source":"",children:m("ui.chat.canonical.supplement.frame.source",{name:T1(e.source)})})]})}function HTt(e="200px"){const[t,n]=$.useState(()=>typeof IntersectionObserver>"u"),[r,i]=$.useState(null),a=$.useCallback(o=>i(o),[]);return $.useEffect(()=>{if(r===null||t||typeof IntersectionObserver>"u")return;const o=new IntersectionObserver(s=>{s.some(l=>l.isIntersecting)&&(n(!0),o.disconnect())},{rootMargin:e});return o.observe(r),()=>o.disconnect()},[r,e,t]),[a,t]}const KTt=150,u7=16*1024*1024,ws=new Map,Wh=[];let Hg=0,d1e=0,f1e=0,O7=0;const ian=()=>({entries:ws.size,queued:Wh.length,active:Hg,reads:d1e,decodes:f1e,peakActive:O7}),JTt=e=>e.artifact?`finder:${e.artifact.sessionId}:${e.artifact.childId??"self"}:${e.artifact.digest}`:`finder:${e.path}:${e.lastAgentModified??0}:${e.sizeBytes??0}`;async function e2t(e){if(e.artifact)return cwe({sessionId:e.artifact.sessionId,childId:e.artifact.childId??null},e.artifact.digest);const t=await window.api.readFileBytes(e.path,u7);if(!t.success)throw new Error(t.error??"Could not be read");return new Blob([t.data],{type:H0(e.path)})}function h1e(){for(const[e,t]of ws){if(ws.size<=KTt)return;t.listeners.size||t.started||(t.state.url&&Ry(t.state.url),ws.delete(e))}}function MB(e,t){e.state=t;for(const n of e.listeners)n(t)}function p1e(){for(;Hg<4&&Wh.length;){const e=Wh.shift();if(!e||!e.listeners.size){e&&ws.delete(e.key);continue}e.started=!0,Hg++,d1e++,O7=Math.max(O7,Hg),(async()=>{try{if((e.document.sizeBytes??0)>u7)throw new Error("Too large to preview");const t=await e2t(e.document);if(t.size>u7)throw new Error("Too large to preview");const n=e.document.artifact?.width,r=e.document.artifact?.height,i=n&&r?Math.min(1,640/Math.max(n,r)):null,a=i&&n&&r?{resizeWidth:Math.max(1,Math.round(n*i)),resizeHeight:Math.max(1,Math.round(r*i)),resizeQuality:"high"}:{resizeWidth:640,resizeQuality:"high"};let o,s=null;if(t.type==="image/svg+xml"||e.document.path.toLowerCase().endsWith(".svg")){s=URL.createObjectURL(t);const l=new Image;l.src=s;try{await l.decode()}catch(u){throw URL.revokeObjectURL(s),u}const c=Math.min(1,640/Math.max(l.naturalWidth,l.naturalHeight));l.width=Math.max(1,Math.round(l.naturalWidth*c)),l.height=Math.max(1,Math.round(l.naturalHeight*c)),o=l}else o=await createImageBitmap(t,a);f1e++;try{const l=Math.min(1,640/Math.max(o.width,o.height)),c=new OffscreenCanvas(Math.max(1,Math.round(o.width*l)),Math.max(1,Math.round(o.height*l))),u=c.getContext("2d");if(!u)throw new Error("Can't preview this image");u.drawImage(o,0,0,c.width,c.height);const O=await c.convertToBlob({type:"image/png"});MB(e,{state:"ready",url:cz(await O.arrayBuffer(),"image/png")})}finally{"close"in o&&o.close(),s&&URL.revokeObjectURL(s)}}catch(t){MB(e,{state:"unavailable",reason:t instanceof Error?t.message:m("ui.canvas.finder_thumbnails.could_not_be_read")})}finally{e.started=!1,Hg--,h1e(),p1e()}})()}}function t2t(e,t){const n=JTt(e),[r,i]=$.useState({state:"loading"});return $.useEffect(()=>{if(!t)return;let a=ws.get(n);a?.state.state==="unavailable"&&!a.listeners.size&&(ws.delete(n),a=void 0),a?(ws.delete(n),ws.set(n,a)):(a={key:n,document:e,state:{state:"loading"},listeners:new Set,started:!1},ws.set(n,a),Wh.push(a)),a.listeners.add(i),i(a.state),p1e();const o=a;return()=>{if(o.listeners.delete(i),!o.started&&o.state.state==="loading"&&!o.listeners.size){const s=Wh.indexOf(o);s>=0&&Wh.splice(s,1),ws.delete(n)}h1e()}},[n,t,e]),r}const n2t="pointer-events-none absolute top-1 end-1 flex 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",r2t=$.memo(function({file:t,cwd:n,pane:r}){const{name:i,path:a}=soe(t),o=i||a||t.path,[s,l]=HTt(),[c,u]=$.useState(null),[O,d]=$.useState(!1);$.useEffect(()=>{let x=!1;const Q=window.api?.probeFiles;if(typeof Q!="function"){u(null),d(!0);return}return u(null),d(!1),(async()=>{try{const[w]=await Q([t.path],n??void 0),S=w?.resolved??"";x||u(S.startsWith("/")?S:null)}catch{x||u(null)}finally{x||d(!0)}})(),()=>{x=!0}},[t.path,n]);const h=$.useMemo(()=>({id:`supplement:${t.path}`,title:o,path:c??t.path,content:"",type:"image",sizeBytes:t.sizeBytes,lastAgentModified:t.mtime?t.mtime*1e3:void 0}),[t.path,o,t.sizeBytes,t.mtime,c]),p=t2t(h,l&&c!==null),{press:g}=l8(t.path,n,r),y=p.state==="ready"&&typeof p.url=="string",b=!(!O||c!==null&&p.state==="loading")&&(c===null||p.state==="unavailable");return f.jsx("li",{className:"flex leading-none","data-supplement-image-tile":"",children:f.jsxs("div",{className:"group relative",ref:s,children:[f.jsx("button",{type:"button",className:"group/tile block cursor-pointer rounded-sm","aria-label":`Open ${o}`,title:t.path,onClick:()=>void g(),children:y?f.jsx(cO,{boundary:"control",className:"h-[78px] w-[117px]",children:f.jsx("img",{alt:"",className:"h-[76px] w-[115px] object-contain",src:p.url})}):b?f.jsx("span",{className:"flex h-[78px] w-[117px] items-center justify-center rounded-sm border border-control bg-sunken text-ink-dim","data-supplement-image-fallback":"",children:f.jsx(u1e,{path:t.path})}):f.jsx(cO,{boundary:"control",className:"h-[78px] w-[117px]"})}),f.jsx("div",{className:n2t,children:f.jsx(O1e,{overlay:!0,actionPath:t.path,label:o,cwd:n,pane:r})})]})})}),i2t=({files:e,cwd:t,pane:n,className:r})=>f.jsx("ul",{role:"list","aria-label":e.length===1?"1 image from this run":`${e.length} images from this run`,"data-supplement-images":"",className:R("grid grid-cols-[repeat(4,max-content)] gap-2",r),children:e.map(i=>f.jsx(r2t,{file:i,cwd:t,pane:n},i.path))}),a2t=2*1024*1024,Sh=new Map,S2=new Map,o2t=64,LB={html:null,failed:!1};async function s2t(e,t){const n=`${e}:${t}`,r=S2.get(n);if(r)return r;const i=(async()=>{try{const a=await Rc({op:"sessions.supplementDocument",sessionId:e,digest:t},null);if(a.kind!=="json")return null;const o=a.body,s=o&&typeof o.html=="string"?o.html:null;if(s===null||s.length>a2t)return null;for(Sh.set(n,s);Sh.size>o2t;){const l=Sh.keys().next().value;if(l===void 0)break;Sh.delete(l)}return s}catch{return null}finally{S2.delete(n)}})();return S2.set(n,i),i}function l2t(e,t,n){const[r,i]=$.useState(()=>{if(!e||!DE(t))return LB;const a=Sh.get(`${e}:${t}`);return a!==void 0?{html:a,failed:!1}:LB});return $.useEffect(()=>{if(!n||!e||!DE(t))return;const a=Sh.get(`${e}:${t}`);if(a!==void 0){i({html:a,failed:!1});return}let o=!1;return s2t(e,t).then(s=>{o||i(s!==null?{html:s,failed:!1}:{html:null,failed:!0})}),()=>{o=!0}},[n,e,t]),r}const FB=$.memo(function({actionPath:t,cwd:n,label:r,suffix:i,size:a,pane:o}){const{press:s}=l8(t,n,o);return f.jsxs("div",{className:"group flex w-full items-center gap-2 text-meta",children:[f.jsx(u1e,{path:t}),f.jsxs("button",{type:"button",className:"min-w-0 flex-1 truncate text-start text-ink hover:text-ink-dim","data-supplement-file":"",title:t,onClick:()=>{s()},children:[T1(r),i&&i!==r&&f.jsx("span",{className:"ms-2 text-ink-muted",children:T1(i)})]}),a&&f.jsx("span",{className:"shrink-0 text-ink-dim",children:a}),f.jsx(O1e,{actionPath:t,label:r,cwd:n,pane:o})]})}),c2t=$.memo(function({sound:t,sessionId:n}){const r=$.useMemo(()=>n?{sessionId:n,childId:null}:null,[n]),i=iv({data:null,attachment:t.attachment,mimeType:t.mime},r),a=Ywe(t.attachment,r),o=t.title||"Generated sound";return f.jsxs("div",{"data-supplement-sound":"",className:"flex min-w-0 flex-col gap-0.5",children:[t.title&&f.jsx("span",{"data-supplement-sound-title":"",title:t.title,className:"truncate text-meta text-ink-muted",children:T1(t.title)}),i.state==="missing"?f.jsx(Md,{name:o,detail:jwe}):i.state==="resolving"?f.jsx("div",{"data-supplement-sound-placeholder":"",className:"h-11","aria-hidden":!0}):f.jsx(Wwe,{variant:"compact",ownerId:`sound:${t.attachment}`,src:i.url,label:o,peaks:a,durationHint:t.durationS})]})}),BB=$.memo(function({component:t,sessionId:n,onRetry:r,onHeight:i}){const a=$.useRef(null),[o,s]=$.useState(!1);$.useEffect(()=>{const u=a.current;if(u===null)return;if(typeof IntersectionObserver>"u"){s(!0);return}const O=new IntersectionObserver(d=>{for(const h of d)h.isIntersecting&&s(!0)},{rootMargin:"200px 0px"});return O.observe(u),()=>O.disconnect()},[]);const l=l2t(n,t.attachment,o),c=$.useCallback(u=>{i?.(t.attachment,u)},[i,t.attachment]);return f.jsx("div",{ref:a,"data-supplement-slot":"",children:f.jsx(BTt,{component:t,sessionId:n,documentHtml:l.html,documentFailed:l.failed,onRetry:r,onHeightChange:i?c:void 0})})}),u2t=$.memo(function({record:t,sessionId:n,cwd:r,condensed:i=!1}){Re();const a=Ek(),[o,s]=$.useState(!1),[l,c]=$.useState(!1),[u,O]=$.useState(!1),d=JSON.stringify([n,t.anchor,t.job]),[h,p]=$.useState({identity:d,open:!0}),g=h.identity===d&&h.open;h.identity!==d&&(p({identity:d,open:!0}),O(!1));const[y,v]=$.useState(!1),[b,x]=$.useState(""),[Q,w]=$.useState(!1),[S,k]=$.useState(()=>new Map),[P,T]=$.useState(0),X=sTe(t,t.live),E=lTe(t.cause),j=t.files,U=t.filesMore,C=t.components,G=t.sounds??[],Y=j.length+U,W=async oe=>{if(n){w(!0);try{await qe({...oe,sessionId:n,job:t.job,anchor:t.anchor})}catch(ve){Er(uQ(m("ui.notices.files.highlights_update_failed"),ve))}finally{w(!1)}}},Z=()=>{W({op:"supplements.cancel"})},V=()=>{W({op:"supplements.restart"})},A=()=>{const oe=b.trim();oe&&(v(!1),x(""),W({op:"supplements.steer",text:oe}))},I=$.useCallback((oe,ve)=>{k(ye=>{if(ye.get(oe)===ve)return ye;const Qe=new Map(ye);return Qe.set(oe,ve),Qe})},[]),J=wTe(typeof window>"u"?900:window.innerHeight),{visible:N}=cTe(C,J,S);$.useEffect(()=>{T(oe=>Math.max(oe,N.length))},[N.length]);const te=Math.min(C.length,Math.max(P,N.length)),B=C.slice(0,te),ee=C.slice(te),le=()=>X==="preparing"||X==="files_preparing"||X==="cancelled_retry"||X==="files_cancelled_retry"||X==="failed_retry"||X==="files_failed_retry"?f.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-meta","data-supplement-line":"",children:[(X==="preparing"||X==="files_preparing")&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",className:"relative inline-block size-3 overflow-hidden rounded-full bg-sunken",children:f.jsx("span",{className:"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"})}),f.jsx("span",{className:"text-ink-muted",children:mTe})]}),(X==="cancelled_retry"||X==="files_cancelled_retry")&&f.jsx("span",{className:"text-ink-muted",children:gTe}),(X==="failed_retry"||X==="files_failed_retry")&&f.jsxs("span",{className:"text-ink-muted",children:[$Te,E?` — ${E}`:""]}),(X==="preparing"||X==="files_preparing")&&n&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",className:"text-ink-dim",children:"·"}),!y&&f.jsx("button",{type:"button",className:"text-ink-dim","data-supplement-adjust":"",onClick:()=>v(!0),children:yTe}),f.jsx("button",{type:"button",className:"text-ink-dim disabled:text-ink-dim/60","data-supplement-cancel":"",disabled:Q||t.state==="cancelling",onClick:Z,children:vTe})]}),(X==="cancelled_retry"||X==="files_cancelled_retry"||X==="failed_retry"||X==="files_failed_retry")&&n&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",className:"text-ink-dim",children:"·"}),f.jsx("button",{type:"button",className:"text-ink-dim","data-supplement-retry":"",onClick:V,children:bTe})]})]}):null,F=y?f.jsxs("div",{className:"flex items-center gap-2 text-meta","data-supplement-adjust-form":"",children:[f.jsx("input",{autoFocus:!0,className:"min-w-0 flex-1 rounded-sm border border-control bg-canvas px-1.5 py-0.5 text-ink text-meta",maxLength:uTe,placeholder:m("ui.chat.canonical.supplement.adjust_placeholder"),value:b,onChange:oe=>x(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&A(),oe.key==="Escape"&&(v(!1),x(""))}}),f.jsx("button",{type:"button",className:"text-ink-dim disabled:text-ink-dim/60",disabled:Q||!b.trim(),onClick:A,children:m("ui.chat.canonical.supplement.send")})]}):null;if(X==="nothing")return null;let L=null;if(j.length>0||U>0){const oe=[],ve=[];for(const Qe of j)sz(Qe.path)==="image"?oe.push(Qe):ve.push(Qe);const ye=Y<=2&&C.length===0&&U===0;L=f.jsxs("div",{className:"flex flex-col gap-1","data-supplement-files-summary":ye?"":void 0,"data-supplement-files":ye?void 0:"",children:[oe.length>0&&f.jsx(i2t,{files:oe,cwd:r,pane:a,className:ve.length>0||U>0?"mb-1":void 0}),ve.map(Qe=>{const{name:Ee,path:ze,size:he}=soe(Qe);return f.jsx(FB,{actionPath:Qe.path,cwd:r,label:Ee||ze,suffix:ze,size:he,pane:a},`${Qe.path}:${Qe.name}`)}),U>0&&f.jsx(Yi,{chevronClassName:"text-ink-dim",open:o,onOpenChange:s,rowClassName:"min-h-0 py-0",summary:f.jsx("span",{"data-supplement-more":"",children:o?"Show fewer":OTe(U)}),children:t.more.slice(0,20).map(Qe=>f.jsx(FB,{actionPath:Qe,cwd:r,label:Qe,suffix:"",size:"",pane:a},Qe))})]})}const ne=G.length>0?f.jsx("div",{"data-supplement-sounds":"",className:G.length>1?"grid grid-cols-[repeat(auto-fit,minmax(15rem,1fr))] gap-1":"flex flex-col gap-1",children:G.map(oe=>f.jsx(c2t,{sound:oe,sessionId:n},oe.attachment))}):null,ue=f.jsxs("div",{className:"flex flex-col gap-2","data-supplement-components":"",children:[B.map(oe=>f.jsx(BB,{component:oe,sessionId:n,onRetry:n?V:void 0,onHeight:I},oe.attachment)),ee.length>0&&f.jsx(Yi,{chevronClassName:"text-ink-dim",open:u,onOpenChange:O,rowClassName:"min-h-0 py-0",summary:f.jsx("span",{"data-supplement-show-all":"",children:u?"Show fewer":dTe(ee.length)}),children:ee.map(oe=>f.jsx(BB,{component:oe,sessionId:n,onRetry:n?V:void 0,onHeight:I},oe.attachment))})]});return f.jsxs("div",{className:"flex flex-col gap-2","data-supplement-record":t.anchor,"data-supplement-condensed":i?"":void 0,children:[L,ne,le(),!i&&t.detail?.includes("prepared:unsupported")&&f.jsx("p",{className:"text-meta text-ink-muted","data-supplement-refusal":"",children:m("ui.chat.canonical.supplement.preview_unavailable")}),!i&&(X==="failed_retry"||X==="files_failed_retry")&&f.jsxs("div",{className:"flex flex-col gap-1 text-meta text-ink-muted","data-supplement-diagnostic":"",children:[f.jsx("p",{children:fTe(t)}),((t.attempts?.length??0)>0||(t.detail?.length??0)>0)&&f.jsx(Yi,{open:l,onOpenChange:c,rowClassName:"min-h-6 py-0",chevronClassName:"text-ink-dim",summary:"Details",children:f.jsxs("div",{className:"max-h-[min(320px,40vh)] overflow-auto break-words font-mono text-ink-dim",children:[t.model&&f.jsx("p",{children:m("ui.chat.canonical.supplement.details.model",{name:t.model})}),f.jsx("p",{children:m("ui.chat.canonical.supplement.details.attempts",{count:t.attempts?.length??0})}),t.detail?.map(oe=>f.jsx("p",{children:hTe(oe)},oe))]})})]}),(X==="preparing"||X==="files_preparing")&&F,X==="block"&&C.length>0&&(i?f.jsx(Yi,{open:g,onOpenChange:oe=>{oe||O(!1),p({identity:d,open:oe})},chevronClassName:"text-ink-dim",rowClassName:"min-h-0 py-0",summary:f.jsx("span",{"data-supplement-graphics-reveal":"",children:pTe(C.length,g,B.length)}),children:f.jsx("div",{className:"-ml-5 w-[calc(100%+1.25rem)]",children:ue})}):ue)]})});function O2t(e){return e.shiftKey||e.altKey||!(e.metaKey||e.ctrlKey)?!1:e.key.toLowerCase()==="f"}const d2t=e=>e?"⌘F":"Ctrl+F";function f2t(e){switch(e){case"ready":case"building":case"unsupported":case"error":return e;default:return"error"}}function h2t(e,t,n){return n<=0?-1:(((e<0||e>=n?t>0?-1:0:e)+t)%n+n)%n}function p2t(e,t){return t>=0&&t<e.length?e[t]:null}function m2t(e,t){const n=[];let r=0;for(const[i,a]of t){const o=Math.max(r,Math.min(e.length,i)),s=Math.max(o,Math.min(e.length,a));s<=o||(o>r&&n.push({text:e.slice(r,o),matched:!1}),n.push({text:e.slice(o,s),matched:!0}),r=s)}return r<e.length&&n.push({text:e.slice(r),matched:!1}),n}const g2t={user:"You",agent:"Agent"},$2t="related match",HB="Search this conversation",y2t="Search results",v2t="Close search";function b2t(e){const t=e.filter(r=>r.tier==="exact").length,n=e.length-t;return n===0?e.length===1?"1 match":`${e.length} matches`:t===0?n===1?"1 related match":`${n} related matches`:`${t} exact · ${n} related`}const w2t="No messages match this search.",x2t="Still indexing this conversation.",S2t="Results appear as the index catches up.",Q2t="Newer messages may be missing while the index catches up.",k2t="This conversation lives on another device, so it cannot be searched here.",_2t="This conversation could not be searched.",P2t="Try again",T2t="Check again",X2t="Could not reach that message. It is further back than the loaded history — scroll up in the transcript to load more.",R2t="Updating — the list below is the previous search's.",E2t="Going to that message…";function q2t(e){return e===1?"(the first match shown)":`(first ${e} shown)`}function j2t(e){return e.state==="building"}async function C2t(e,t){if(e===null)return"not-mounted";const n=e.querySelector("[data-lo-transcript-content]")??e;return await o1e(n,e,t)==="landed"?"revealed":"not-mounted"}async function z2t(e){const t=e.query.trim().slice(0,loe);if(t.length===0)return{query:"",state:"ready",partial:!1,hits:[],truncated:!1};const n=Math.min(Math.max(e.limit??xTe,1),STe);return qe({op:"sessions.find",sessionId:e.sessionId,q:t,limit:n})}const A2t=200,U2t=1500;function W2t({sessionId:e,enabled:t}){const[n,r]=$.useState(""),[i,a]=$.useState("idle"),[o,s]=$.useState([]),[l,c]=$.useState(!1),[u,O]=$.useState(!1),[d,h]=$.useState(-1),p=$.useRef(0),g=$.useRef(0),y=$.useRef(0),v=$.useRef(""),b=$.useRef(null),x=$.useRef(null),Q=$.useRef(new Set),w=$.useRef(e);w.current=e;const S=$.useCallback(()=>{x.current!==null&&(clearTimeout(x.current),x.current=null)},[]),k=$.useCallback((C,G)=>{Q.current.has(C)||(Q.current.add(C),console.warn(C,G))},[]),P=$.useCallback(()=>{p.current+=1,S(),b.current=null,y.current=0,a("idle"),s(C=>C.length===0?C:[]),c(!1),O(!1),h(-1)},[S]),T=$.useRef(()=>{}),X=$.useCallback((C,G)=>{const Y=f2t(G.state);a(Y);const W=Y==="ready"||Y==="building",Z=W?G.hits:[];if(y.current=Z.length,s(Z),c(W&&G.truncated),O(Y==="building"&&G.partial),h(Z.length>0?0:-1),Y==="building"&&j2t(G)){if(b.current!==C){b.current=C;const V=p.current;x.current=setTimeout(()=>{x.current=null,p.current===V&&T.current(C,"follow-up")},U2t)}}else S()},[S]),E=$.useCallback((C,G)=>{const Y=w.current;if(!Y)return;const W=p.current,Z=++g.current;G==="fresh"&&(S(),b.current=null,a("loading")),z2t({sessionId:Y,query:C}).then(V=>{Z!==g.current||p.current!==W||X(C,V)}).catch(V=>{Z!==g.current||p.current!==W||(k("thread search could not be answered:",V),S(),b.current=null,y.current=0,s([]),c(!1),O(!1),h(-1),a("error"))})},[X,S,k]);T.current=E,$.useEffect(()=>{const C=`${t?"1":"0"}:${e??""}`;if(v.current!==C&&(v.current=C,Q.current=new Set,P(),r(Z=>Z===""?Z:""),!t||!e))return;if(!t||!e){P();return}const G=n.trim();if(G.length===0){P();return}const Y=p.current,W=setTimeout(()=>{p.current===Y&&T.current(G,"fresh")},A2t);return()=>clearTimeout(W)},[n,t,e,P]),$.useEffect(()=>()=>S(),[S]);const j=$.useCallback(C=>{h(G=>h2t(G,C,y.current))},[]),U=$.useCallback(()=>{const C=n.trim();!t||!e||C.length===0||T.current(C,"fresh")},[t,e,n]);return{query:n,setQuery:r,state:i,hits:o,truncated:l,partial:u,cursor:d,moveCursor:j,activeHit:p2t(o,d),refresh:U}}const Y2t=R("bg-accent-wash","before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent"),N2t="bg-accent-wash font-medium text-ink underline decoration-accent decoration-2 underline-offset-2",G2t=()=>navigator.platform.toUpperCase().indexOf("MAC")>=0,Z2t=({hit:e,active:t,optionId:n,onNavigate:r})=>{const i=m2t(e.snippet,e.ranges);return f.jsxs("li",{id:n,role:"option","aria-selected":t,onMouseDown:a=>a.preventDefault(),onClick:()=>r(e),className:R("relative flex cursor-pointer flex-col gap-0.5 px-3 py-2",t?Y2t:"hover:bg-accent-wash"),children:[f.jsxs("span",{className:"flex items-center gap-1.5 text-ink-muted text-meta",children:[f.jsx("span",{children:g2t[e.role]}),e.tier==="soft"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",children:"·"}),f.jsx("span",{className:"text-ink-dim",children:$2t})]})]}),f.jsx("span",{className:"line-clamp-2 text-body-sm text-ink",children:i.map((a,o)=>a.matched?f.jsx("mark",{className:N2t,children:a.text},o):f.jsx("span",{children:a.text},o))})]})},I2t=({query:e,onQueryChange:t,state:n,hits:r,cursor:i,truncated:a,partial:o,onMoveCursor:s,onNavigate:l,onRetry:c,onClose:u,isMac:O,jumping:d=!1})=>{const h=$.useId(),p=`${h}-list`,g=$.useCallback(w=>`${h}-opt-${w}`,[h]),y=$.useRef(null),v=i>=0&&i<r.length?r[i]:null,b=r.length>0,x=n==="error"||n==="building";$.useEffect(()=>{y.current?.focus(),y.current?.select()},[]),$.useEffect(()=>{i<0||document.getElementById(g(i))?.scrollIntoView({block:"nearest"})},[i,g]);const Q=w=>{if(w.key==="ArrowDown"){w.preventDefault(),s(1);return}if(w.key==="ArrowUp"){w.preventDefault(),s(-1);return}if(w.key==="Enter"){w.preventDefault(),v!==null?l(v):x&&c();return}};return f.jsxs("div",{"data-lo-thread-search":"",role:"presentation",onKeyDown:w=>{w.defaultPrevented||w.key==="Escape"&&(w.preventDefault(),u())},className:"pointer-events-auto w-[26rem] max-w-full rounded-md border border-hairline bg-elevated text-body-sm text-ink shadow-overlay",children:[f.jsx("div",{className:"p-2",children:f.jsxs("div",{className:R("flex items-center gap-2 rounded-sm border border-control bg-surface px-2","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[f.jsx(Qy,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-ink-dim"}),f.jsx("input",{ref:y,type:"text",value:e,onChange:w=>t(w.target.value),onKeyDown:Q,maxLength:loe,placeholder:HB,"aria-label":HB,role:"combobox","aria-expanded":b,"aria-controls":b?p:void 0,"aria-activedescendant":v!==null?g(i):void 0,"aria-autocomplete":"list",autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 border-0 bg-transparent text-body-sm text-ink outline-none placeholder:text-ink-dim"}),f.jsx(ke,{type:"button",variant:"ghost",size:"icon-sm","aria-label":v2t,onClick:u,children:f.jsx(ti,{"aria-hidden":"true"})})]})}),f.jsxs("div",{className:"flex items-start gap-2 px-3 pb-2",children:[f.jsxs("p",{className:"min-w-0 flex-1 text-ink-muted text-meta",children:[n==="loading"&&(b?R2t:"Searching…"),n==="ready"&&(r.length>0?b2t(r):w2t),n==="building"&&(o?Q2t:x2t),n==="unsupported"&&k2t,n==="error"&&_2t,n==="ready"&&a&&b&&f.jsxs("span",{className:"text-ink-dim",children:[" ",q2t(r.length)]}),n==="building"&&!o&&f.jsxs("span",{className:"text-ink-dim",children:[" ",S2t]})]}),x&&f.jsx(ke,{type:"button",variant:"ghost",size:"sm",onClick:c,className:"shrink-0",children:n==="building"?T2t:P2t})]}),b&&f.jsx("ul",{id:p,role:"listbox","aria-label":y2t,"aria-busy":n==="loading",className:R("max-h-80 overflow-y-auto border-t border-hairline py-1",n==="loading"&&"opacity-60"),children:r.map((w,S)=>f.jsx(Z2t,{hit:w,active:S===i,optionId:g(S),onNavigate:l},w.id))}),d&&f.jsx("output",{className:"block border-t border-hairline px-3 py-1.5 text-ink-muted text-meta",children:E2t}),f.jsxs("div",{className:"flex items-center gap-3 border-t border-hairline px-3 py-1.5",children:[f.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[f.jsx(ud,{shortcut:"↑"}),f.jsx(ud,{shortcut:"↓"}),f.jsx("span",{children:"browse"})]}),f.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[f.jsx(ud,{shortcut:"↵"}),f.jsx("span",{children:"jump"})]}),f.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[f.jsx(ud,{shortcut:"esc"}),f.jsx("span",{children:"close"})]}),f.jsx("span",{className:"ms-auto text-ink-dim text-meta",children:d2t(O)})]})]})},D2t=({sessionId:e,containerRef:t,onReveal:n})=>{const[r,i]=$.useState(!1),[a,o]=$.useState(!1),s=$.useRef(null),l=$.useRef(null),c=W2t({sessionId:e,enabled:r}),u=$.useCallback(()=>{const h=document.activeElement;l.current=h instanceof HTMLElement?h:null,i(!0)},[]),O=$.useCallback(()=>{i(!1);const h=l.current;l.current=null,h?.isConnected&&h.focus()},[]);$.useEffect(()=>{const h=p=>{if(p.defaultPrevented||!O2t(p))return;const g=p.target;if(!(!(s.current!==null&&g!==null&&s.current.contains(g))&&(Z0(p.target)||pse(p.target)===null))){if(p.preventDefault(),r){const v=s.current?.querySelector("input");v?.focus(),v?.select();return}u()}};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[r,u]);const d=$.useCallback(async h=>{o(!0);try{if(n){await n(h.id);return}await C2t(t.current,h.id)}finally{o(!1)}},[t,n]);return r?f.jsx("div",{ref:s,className:"pointer-events-none absolute top-3 end-6 z-20 max-w-[calc(100%-1.5rem)]",children:f.jsx(I2t,{query:c.query,onQueryChange:c.setQuery,state:c.state,hits:c.hits,cursor:c.cursor,truncated:c.truncated,partial:c.partial,onMoveCursor:c.moveCursor,onNavigate:d,onRetry:c.refresh,onClose:O,isMac:G2t(),jumping:a})}):null},V2t=/\s+$/;function M2t(e){return e.kind==="user"||e.kind==="assistant"}function m1e(e){return e.kind!=="user"&&e.kind!=="assistant"?"":coe(e.text)?.text??e.text}const L2t=Wue().use(Xue).use(Bc);function c8(e){switch(e.type){case"text":case"inlineCode":case"html":return e.value??"";case"image":return e.alt??"";case"break":return`
860
860
  `;default:return(e.children??[]).map(c8).join("")}}function F2t(e){return(e.children??[]).map(t=>(t.children??[]).map(n=>c8(n)).join(" | ")).join(`