local-operator-ui 0.52.2 → 0.52.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 (99) hide show
  1. package/out/main/index.js +283 -17
  2. package/out/renderer/assets/{_basePickBy-CumswRl9.js → _basePickBy-iT9286AT.js} +1 -1
  3. package/out/renderer/assets/{_baseUniq-B4HhVWVa.js → _baseUniq-DD0ttvBE.js} +1 -1
  4. package/out/renderer/assets/{agent-details-page-D4Cwc37_.js → agent-details-page-8Unp8bfu.js} +1 -1
  5. package/out/renderer/assets/{agent-hub-page-BhED6eF-.js → agent-hub-page-DVY6ubtZ.js} +1 -1
  6. package/out/renderer/assets/{agents-page-CJEjCPx2.js → agents-page-CjrCc-ti.js} +3 -3
  7. package/out/renderer/assets/{appearance-BGSQVKcf.js → appearance-CglKqGvj.js} +33 -33
  8. package/out/renderer/assets/{approvalsOverlay-BYxKL-Bm.js → approvalsOverlay-DKgqhhTD.js} +1 -1
  9. package/out/renderer/assets/{arc-BTgPMeV2.js → arc-CK9vvg2A.js} +1 -1
  10. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-D21lhqBn.js → architectureDiagram-IEHRJDOE-CdKP12BE.js} +1 -1
  11. package/out/renderer/assets/{avatar-cropper-BzE0Zgtx.js → avatar-cropper-0dGCTZU0.js} +1 -1
  12. package/out/renderer/assets/{blockDiagram-JOT3LUYC-H7qzGt48.js → blockDiagram-JOT3LUYC-B2801lZE.js} +1 -1
  13. package/out/renderer/assets/{book-open-mVr_JhpC.js → book-open-JdzmqKBN.js} +1 -1
  14. package/out/renderer/assets/browser-page-DOBOuzyt.js +1 -0
  15. package/out/renderer/assets/{browser-webauthn-prompt-C2DQr5xk.js → browser-webauthn-prompt-CJLZ5Tqt.js} +1 -1
  16. package/out/renderer/assets/{building-2-BakK5eDM.js → building-2-D33MQvHb.js} +1 -1
  17. package/out/renderer/assets/{c4Diagram-VJAJSXHY-BQXh-myf.js → c4Diagram-VJAJSXHY-D2t0xX4h.js} +1 -1
  18. package/out/renderer/assets/channel-CeooNOqV.js +1 -0
  19. package/out/renderer/assets/{chunk-4BMEZGHF-CS2jZ-TN.js → chunk-4BMEZGHF-Cba_jbxB.js} +1 -1
  20. package/out/renderer/assets/{chunk-A2AXSNBT-1ZFvPyRU.js → chunk-A2AXSNBT-C92MmnqI.js} +1 -1
  21. package/out/renderer/assets/{chunk-AEK57VVT-W3CzFN81.js → chunk-AEK57VVT-UcFfPLa4.js} +1 -1
  22. package/out/renderer/assets/{chunk-D6G4REZN-lG86fQds.js → chunk-D6G4REZN-CvE3nkMR.js} +1 -1
  23. package/out/renderer/assets/{chunk-RZ5BOZE2-CIjO6EjZ.js → chunk-RZ5BOZE2-CcF3POOp.js} +1 -1
  24. package/out/renderer/assets/{chunk-XZIHB7SX-BnKWJ7iN.js → chunk-XZIHB7SX-DS_H9K1d.js} +1 -1
  25. package/out/renderer/assets/classDiagram-GIVACNV2-DqKNu0jH.js +1 -0
  26. package/out/renderer/assets/classDiagram-v2-COTLJTTW-DqKNu0jH.js +1 -0
  27. package/out/renderer/assets/clone-kpV5KmdR.js +1 -0
  28. package/out/renderer/assets/{console-mirror-Cn2ywGkk.js → console-mirror-BzKlbMRA.js} +1 -1
  29. package/out/renderer/assets/{consoleCapture-BJf4yixq.js → consoleCapture-CoxfMrTn.js} +1 -1
  30. package/out/renderer/assets/{conversation-input-sync-DovjnW2l.js → conversation-input-sync-D93dFUgE.js} +5 -5
  31. package/out/renderer/assets/{dagre-OKDRZEBW-BoNQF-t4.js → dagre-OKDRZEBW-WbYNfeZA.js} +1 -1
  32. package/out/renderer/assets/{diagram-SSKATNLV-DDq7yxPF.js → diagram-SSKATNLV-Cw5VjWu9.js} +1 -1
  33. package/out/renderer/assets/{diagram-VNBRO52H-B2alAWMr.js → diagram-VNBRO52H-IlUwcdmi.js} +1 -1
  34. package/out/renderer/assets/{erDiagram-Q7BY3M3F-Dy0lcUxx.js → erDiagram-Q7BY3M3F-F78O2eGP.js} +1 -1
  35. package/out/renderer/assets/{error-boundary-B_K7Ygu0.js → error-boundary-5lWaVpLN.js} +1 -1
  36. package/out/renderer/assets/{flowDiagram-4HSFHLVR-0tA9oWeg.js → flowDiagram-4HSFHLVR-rhCbqXbY.js} +1 -1
  37. package/out/renderer/assets/{ganttDiagram-APWFNJXF-DHIhTFPL.js → ganttDiagram-APWFNJXF-XZFptWtl.js} +1 -1
  38. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-DMzYX57y.js → gitGraphDiagram-7IBYFJ6S-BZwNmAJI.js} +1 -1
  39. package/out/renderer/assets/{graph-DL8EGYPv.js → graph-Ckdro8w3.js} +1 -1
  40. package/out/renderer/assets/{heart-CHrvPJDz.js → heart-B5l0IpLW.js} +1 -1
  41. package/out/renderer/assets/index-B2rgX9Dg.js +794 -0
  42. package/out/renderer/assets/{index-CrX6UPbZ.js → index-BmvRznQC.js} +1 -1
  43. package/out/renderer/assets/{index-GsdqL7En.js → index-CuD9ABIl.js} +1 -1
  44. package/out/renderer/assets/{index-CGr1O9qR.js → index-DfUaW0_X.js} +1 -1
  45. package/out/renderer/assets/index-zOGxsTLz.css +1 -0
  46. package/out/renderer/assets/infoDiagram-PH2N3AL5-BmPQ7IQT.js +2 -0
  47. package/out/renderer/assets/{installer-C2z2EYgE.js → installer-UyNPdVrT.js} +1 -1
  48. package/out/renderer/assets/{journeyDiagram-U35MCT3I-B78kdq9m.js → journeyDiagram-U35MCT3I-BIhrG8aC.js} +1 -1
  49. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-BophBODb.js → kanban-definition-NDS4AKOZ-WOxfEnS9.js} +1 -1
  50. package/out/renderer/assets/{layout-BvjyMys3.js → layout-dANLA-tA.js} +1 -1
  51. package/out/renderer/assets/{legacy-agents-page-BeOVjy6n.js → legacy-agents-page-BaQuBK_q.js} +1 -1
  52. package/out/renderer/assets/{library-page-DdT_BsGT.js → library-page-C4x8iQGv.js} +3 -3
  53. package/out/renderer/assets/{log-in-BFUGdS5K.js → log-in-DBei2mwq.js} +1 -1
  54. package/out/renderer/assets/{mermaid.core-C3_jDZhe.js → mermaid.core-CfTVsgje.js} +5 -5
  55. package/out/renderer/assets/{mesh-page-BLZj78Uz.js → mesh-page-O6Ds04IH.js} +1 -1
  56. package/out/renderer/assets/{messages-BbxDSLHR.js → messages-DvlMQPU7.js} +8 -8
  57. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-Dahn0o74.js → mindmap-definition-ALO5MXBD-9SVtYz6V.js} +1 -1
  58. package/out/renderer/assets/{mini-DBxaVn-Z.js → mini-Bn_Tp8-d.js} +1 -1
  59. package/out/renderer/assets/{notebook-pen-BE72w4To.js → notebook-pen-8CWpVrT6.js} +1 -1
  60. package/out/renderer/assets/{notifications-page-DGzq-DD4.js → notifications-page-DSysSuA4.js} +1 -1
  61. package/out/renderer/assets/{org-access-Fxre140y.js → org-access-zWiHDD3G.js} +1 -1
  62. package/out/renderer/assets/{org-surface-gate-BDRn0nVG.js → org-surface-gate-ihrYN8vU.js} +1 -1
  63. package/out/renderer/assets/{page-header-CTA5Xu8F.js → page-header-BQKBmX15.js} +1 -1
  64. package/out/renderer/assets/{pieDiagram-IB7DONF6-DwRNR4pI.js → pieDiagram-IB7DONF6-ByfLgCmO.js} +1 -1
  65. package/out/renderer/assets/{project-markdown-DjXid2UO.js → project-markdown-DuwBnykC.js} +1 -1
  66. package/out/renderer/assets/{projects-page-CPaw0Up6.js → projects-page-CbEZSowB.js} +1 -1
  67. package/out/renderer/assets/{publication-validation-Czsb07hy.js → publication-validation-CwL9aRWw.js} +1 -1
  68. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-5eifcc6v.js → quadrantDiagram-7GDLP6J5-B3d2Hv3w.js} +1 -1
  69. package/out/renderer/assets/{radar-MK3ICKWK-CrV6t877.js → radar-MK3ICKWK-D8xp2R3e.js} +1 -1
  70. package/out/renderer/assets/{radient-auth-buttons-D0dsjqx3.js → radient-auth-buttons-DFD7TopW.js} +1 -1
  71. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-BLvCJZRO.js → requirementDiagram-KVF5MWMF-CTsiF5ma.js} +1 -1
  72. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-ODO3Gvbc.js → sankeyDiagram-QLVOVGJD-BIqE7-l7.js} +1 -1
  73. package/out/renderer/assets/{schedules-page-BNQSuywo.js → schedules-page-B1PsQw2c.js} +1 -1
  74. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-gKEwnuuI.js → sequenceDiagram-X6HHIX6F-B7EJrleR.js} +1 -1
  75. package/out/renderer/assets/{settings-page-ByHnVTTc.js → settings-page-Bn08QATQ.js} +1 -1
  76. package/out/renderer/assets/{smartart-BNgfXC7J.js → smartart-D4dvveBy.js} +1 -1
  77. package/out/renderer/assets/{stateDiagram-DGXRK772-D6xpTcWP.js → stateDiagram-DGXRK772-gK_EsZNQ.js} +1 -1
  78. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-D8AVGtcM.js +1 -0
  79. package/out/renderer/assets/{team-bridge-page-DYFoMJCT.js → team-bridge-page-CQaF5KkB.js} +1 -1
  80. package/out/renderer/assets/{team-bridge-scope-preference-CB17d5U6.js → team-bridge-scope-preference-CuwGV0hc.js} +1 -1
  81. package/out/renderer/assets/{timeline-definition-BDJGKUSR-vEmvbuvw.js → timeline-definition-BDJGKUSR-fz4NGWuu.js} +1 -1
  82. package/out/renderer/assets/{use-download-agent-mutation-BWqgdo9E.js → use-download-agent-mutation-CON_9AtM.js} +1 -1
  83. package/out/renderer/assets/{use-session-snapshot-DrX9xnah.js → use-session-snapshot-BJnMBOP9.js} +1 -1
  84. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-BTzn_AOJ.js → xychartDiagram-VJFVF3MP-B0w1zi01.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 +1 -1
  91. package/out/renderer/assets/browser-page-otZ82fBG.js +0 -1
  92. package/out/renderer/assets/channel-BCoUfRr5.js +0 -1
  93. package/out/renderer/assets/classDiagram-GIVACNV2-C9PA3btW.js +0 -1
  94. package/out/renderer/assets/classDiagram-v2-COTLJTTW-C9PA3btW.js +0 -1
  95. package/out/renderer/assets/clone-DJ4z5fkU.js +0 -1
  96. package/out/renderer/assets/index-C-dwN1b1.css +0 -1
  97. package/out/renderer/assets/index-DBKZjyX8.js +0 -794
  98. package/out/renderer/assets/infoDiagram-PH2N3AL5-Yo-97F6g.js +0 -2
  99. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CLu3wWvB.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-GsdqL7En.js","./index-CGr1O9qR.js","./messages-BbxDSLHR.js","./index-C-dwN1b1.css","./appearance-BGSQVKcf.js","./roles-D1pcbxAx.js","./error-boundary-B_K7Ygu0.js","./index-CrX6UPbZ.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-C3_jDZhe.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
2
- import{r as $,b as J,m as UXe,j as f,c as T,u as r9,g as Ln,J as Nle,i as Yle,f as i9,n as WXe,K as kb,l as hn,t as Gle}from"./index-CGr1O9qR.js";import{bh as NXe,es as WY,et as YXe,eu as GXe,be as ZXe,ev as IXe,ew as NY,ex as DXe,bf as Zle,u as ko,bn as VXe,ey as MXe,ez as LXe,K as Wr,eA as a9,eB as FXe,aU as BXe,eC as HXe,eD as KXe,eE as JXe,o as gf,a4 as Ile,eF as eRe,eG as YY,eH as tRe,eI as nRe,eJ as rRe,L as Zn,eK as vn,al as is,eL as Gd,cb as o9,eM as xj,ag as s9,bK as Dle,J as vu,eN as iRe,h as bt,r as Fr,t as aRe,ad as gi,ai as QO,eO as oRe,c as Un,w as fr,a as hr,m as $i,ak as sRe,d as je,bO as Vle,g as Ns,bF as lRe,a5 as S$,eP as fk,bM as cRe,bN as Mle,dW as uRe,E as Yt,ar as ORe,eQ as dRe,eR as fRe,dj as hRe,di as pRe,dn as f5,dk as mRe,bH as Lle,eS as gRe,eT as $Re,eU as yRe,eV as vRe,eW as bRe,eh as wRe,dp as xRe,eX as hk,eY as xp,eZ as l9,e_ as SRe,e$ as GY,F as Mn,dd as vr,f0 as Fle,f1 as Ble,at as Za,bJ as c9,f2 as QRe,f3 as kRe,f4 as _Re,f5 as PRe,f6 as TRe,f7 as Qx,f8 as Hle,f9 as Q$,fa as XRe,fb as ZY,aG as Zd,fc as RRe,fd as sv,fe as ERe,ff as qRe,fg as jRe,aE as Iu,fh as CRe,fi as zRe,fj as ARe,cj as URe,ch as WRe,fk as NRe,fl as YRe,fm as GRe,fn as Ys,fo as Gc,fp as Bn,fq as ZRe,fr as kx,fs as IRe,aP as DRe,ba as h5,ft as VRe,fu as MRe,fv as LRe,fw as FRe,fx as BRe,fy as u9,fz as HRe,I as KRe,dE as O9,ca as Kle,aK as Jle,aO as JRe,aN as e4e,fA as t4e,fB as n4e,fC as ece,fD as r4e,fE as i4e,fF as a4e,fG as o4e,fH as s4e,fI as l4e,fJ as lO,fK as d9,fL as tce,fM as Sp,fN as c4e,fO as k1,fP as u4e,fQ as O4e,fR as Sj,fS as d4e,fT as IY,fU as f4e,fV as h4e,fW as p4e,fX as cO,fY as m4e,fZ as g4e,f_ as f9,f$ as $4e,g0 as y4e,g1 as v4e,g2 as b4e,g3 as w4e,g4 as x4e,g5 as S4e,g6 as Q4e,g7 as k4e,g8 as _4e,g9 as P4e,ga as T4e,gb as X4e,gc as R4e,gd as E4e,f as pk,ge as q4e,gf as nce,gg as j4e,gh as C4e,gi as lv,gj as rce,gk as ice,gl as h9,gm as z4e,gn as A4e,go as U4e,gp as W4e,gq as N4e,eo as mk,e4 as Y4e,e as p9,gr as G4e,gs as Z4e,D as I4e,b7 as D4e,gt as V4e,v as M4e,gu as L4e,gv as F4e,gw as B4e,gx as H4e,gy as k$,gz as K4e,gA as DY,gB as ace,gC as J4e,gD as VY,gE as eEe,gF as tEe,gG as nEe,gH as oce,gI as rEe,gJ as iEe,gK as _b,gL as MY,gM as aEe,gN as LY,gO as oEe,bd as FY,gP as BY,gQ as sEe,gR as lEe,gS as HY,gT as cEe,ah as KY,cS as uEe,bu as OEe,cR as dEe,aV as fEe,b5 as hEe,ce as m9,cc as pEe,gU as mEe,dr as sce,dq as lce,ac as _$,aH as cce,gV as gEe,aJ as uce,gW as $Ee,gX as g9,gY as _1,gZ as yEe,g_ as vEe,cu as bEe,g$ as wEe,aI as xEe,h0 as SEe,h1 as QEe,h2 as kEe,h3 as JY,h4 as _Ee,h5 as _x,h6 as Oce,d9 as PEe,h7 as dce,h8 as TEe,h9 as XEe,ha as REe,hb as EEe,q as qEe,hc as gk,hd as $9,he as jEe,hf as CEe,bC as fce,hg as hce,hh as P$,hi as xc,hj as zEe,hk as AEe,hl as UEe,hm as WEe,dA as NEe,hn as Px,ho as YEe,hp as GEe,hq as ZEe,hr as IEe,hs as eG,ht as DEe,hu as VEe,hv as MEe,hw as LEe,hx as FEe,hy as BEe,S as HEe,as as tG,hz as Qj,hA as kj}from"./appearance-BGSQVKcf.js";import{aA as KEe,c as Ce,aJ as JEe,aK as pce,aL as eqe,aM as tqe,aN as nqe,aO as rqe,aP as iqe,aQ as aqe,aR as mg,aS as oqe,B as Qe,n as y9,o as v9,y as sqe,p as b9,F as lqe,w as vt,h as mce,i as As,a as sa,C as Tx,X as oi,j as cqe,u as we,g as gce,k as Xx,J as $ce,T as Id,aj as T$,A as Xl,Z as p5,ab as uqe,v as Oqe,S as Sa,a6 as cv,G as yce,D as w9,b as x9,d as S9,e as gl,q as A0,x as U0,au as Q9,r as uO,aT as dqe,a7 as fqe,a8 as hqe,a9 as pqe,af as mqe,at as gqe,$ as $qe,N as yqe,O as vqe,P as bqe,K as Fa,R as vce,U as bce,V as wce,W as xce,Y as _j,_ as wqe,z as Pj,L as Sce,aI as xqe,f as ho,a0 as Sqe,a1 as Qqe,a2 as nG,a3 as rG,a4 as kqe,a5 as iG,an as _qe,s as Pqe,H as m5,I as aG,E as oG}from"./error-boundary-B_K7Ygu0.js";import{c as $f,t as m,L as bd,d as Tqe}from"./messages-BbxDSLHR.js";import{P as k9}from"./roles-D1pcbxAx.js";const sG=new Map,lG=new Map,cG=new Map;function _9(e){return e===void 0?"":JSON.stringify(e)}function P9(e,t){const n=`${e}\0${_9(t)}`;let r=sG.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),sG.set(n,r)),r}function Xqe(e,t){const n=`${e}\0${_9(t)}`;let r=lG.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),lG.set(n,r)),r}function $k(e,t,n){return P9(n??$f(),t).format(e)}function yk(e,t,n){return P9(n??$f(),t).format(e)}function Qce(e,t,n){return P9(n??$f(),t).format(e)}function Ma(e,t,n){return Xqe(n??$f(),t).format(e)}function Kln(e,t,n,r){const i=r??$f(),a=`${i}\0${_9(n)}`;let o=cG.get(a);return o===void 0&&(o=new Intl.RelativeTimeFormat(i,n),cG.set(a,o)),o.format(e,t)}const Rqe=[{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"}],Eqe={languages:Rqe},uG=Eqe.languages;function kce(e){const t=e.trim();if(t==="")return{lang:"en",dir:"ltr"};const n=t.toLowerCase(),r=uG.find(o=>o.code.toLowerCase()===n),i=n.split("-")[0],a=r??uG.find(o=>o.code.split("-")[0].toLowerCase()===i);return{lang:r?.code??t,dir:a?.dir==="rtl"?"rtl":"ltr"}}function _ce(e){return kce(e).dir}var qqe=class extends NXe{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:WY()})}getOptimisticResult(e){return e.behavior=WY(),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:GXe(t,n.data),hasPreviousPage:YXe(t,n.data),isFetchNextPageError:c,isFetchingNextPage:u,isFetchPreviousPageError:O,isFetchingPreviousPage:d,isRefetchError:s&&!c&&!O,isRefetching:a&&!u&&!d}}},jqe=class extends ZXe{#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),IXe(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#e,observer:this}),n?.mutationKey&&this.options.mutationKey&&NY(n.mutationKey)!==NY(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??DXe();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){Zle.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 Rx(e,t){const n=ko(t),[r]=$.useState(()=>new jqe(n,e));$.useEffect(()=>{r.setOptions(e)},[r,e]);const i=$.useSyncExternalStore($.useCallback(o=>r.subscribe(Zle.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=$.useCallback((o,s)=>{r.mutate(o,s).catch(VXe)},[r]);if(i.error&&MXe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function Pce(e,t){return LXe(e,qqe,t)}const Cqe=5e3;let Tce=0;function zqe(e=Cqe){Tce=Date.now()+e}function ecn(e=Date.now()){return e<=Tce}function Aqe(e){zqe(),e.invalidateQueries({queryKey:Wr.capabilities})}const Uqe=e=>e!==""&&_ce($f())==="rtl"?`⁦${e}⁩`:e;function Wqe(e,t){if(!e||typeof e!="object")return null;const n=e,r=n.artifacts;if(!Nqe(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:Xce(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 Xce(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 a9({...e,billing_basis:n?.basis??e.billing_basis})}function g5(e){const t=e,n=Xce(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 Nqe(e){return"cost_complete"in e||["completed","failed","cancelled"].some(t=>t in e)}function Yqe(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 Gqe(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-CuD9ABIl.js","./index-DfUaW0_X.js","./messages-DvlMQPU7.js","./index-zOGxsTLz.css","./appearance-CglKqGvj.js","./roles-D1pcbxAx.js","./error-boundary-5lWaVpLN.js","./index-BmvRznQC.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-CfTVsgje.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
2
+ import{r as $,b as J,m as UXe,j as f,c as T,u as r9,g as Ln,J as Nle,i as Yle,f as i9,n as WXe,K as kb,l as hn,t as Gle}from"./index-DfUaW0_X.js";import{bh as NXe,ev as WY,ew as YXe,ex as GXe,be as ZXe,ey as IXe,ez as NY,eA as DXe,bf as Zle,u as ko,bn as VXe,eB as MXe,eC as LXe,K as Wr,eD as a9,eE as FXe,aU as BXe,eF as HXe,eG as KXe,eH as JXe,o as gf,a4 as Ile,eI as eRe,eJ as YY,eK as tRe,eL as nRe,eM as rRe,L as Zn,eN as vn,al as is,eO as Gd,cb as o9,eP as xj,ag as s9,bK as Dle,J as vu,eQ as iRe,h as bt,r as Fr,t as aRe,ad as gi,ai as QO,eR as oRe,c as Un,w as fr,a as hr,m as $i,ak as sRe,d as je,bO as Vle,g as Ns,bF as lRe,a5 as S$,eS as fk,bM as cRe,bN as Mle,dZ as uRe,E as Yt,ar as ORe,eT as dRe,eU as fRe,dm as hRe,dl as pRe,dr as f5,dn as mRe,bH as Lle,eV as gRe,eW as $Re,eX as yRe,eY as vRe,eZ as bRe,ek as wRe,ds as xRe,e_ as hk,e$ as xp,f0 as l9,f1 as SRe,f2 as GY,F as Mn,dg as vr,f3 as Fle,f4 as Ble,at as Za,bJ as c9,f5 as QRe,f6 as kRe,f7 as _Re,f8 as PRe,f9 as TRe,fa as Qx,fb as Hle,fc as Q$,fd as XRe,fe as ZY,aG as Zd,ff as RRe,fg as sv,fh as ERe,fi as qRe,fj as jRe,aE as Iu,fk as CRe,fl as zRe,fm as ARe,cj as URe,ch as WRe,fn as NRe,fo as YRe,fp as GRe,fq as Ys,fr as Gc,fs as Bn,ft as ZRe,fu as kx,fv as IRe,aP as DRe,ba as h5,fw as VRe,fx as MRe,fy as LRe,fz as FRe,fA as BRe,fB as u9,fC as HRe,I as KRe,dH as O9,ca as Kle,aK as Jle,aO as JRe,aN as e4e,fD as t4e,fE as n4e,fF as ece,fG as r4e,fH as i4e,fI as a4e,fJ as o4e,fK as s4e,fL as l4e,fM as lO,fN as d9,fO as tce,fP as Sp,fQ as c4e,fR as k1,fS as u4e,fT as O4e,fU as Sj,fV as d4e,fW as IY,fX as f4e,fY as h4e,fZ as p4e,f_ as cO,f$ as m4e,g0 as g4e,g1 as f9,g2 as $4e,g3 as y4e,g4 as v4e,g5 as b4e,g6 as w4e,g7 as x4e,g8 as S4e,g9 as Q4e,ga as k4e,gb as _4e,gc as P4e,gd as T4e,ge as X4e,gf as R4e,gg as E4e,f as pk,gh as q4e,gi as nce,gj as j4e,gk as C4e,gl as lv,gm as rce,gn as ice,go as h9,gp as z4e,gq as A4e,gr as U4e,gs as W4e,gt as N4e,er as mk,e7 as Y4e,e as p9,gu as G4e,gv as Z4e,D as I4e,b7 as D4e,gw as V4e,v as M4e,gx as L4e,gy as F4e,gz as B4e,gA as H4e,gB as k$,gC as K4e,gD as DY,gE as ace,gF as J4e,gG as VY,gH as eEe,gI as tEe,gJ as nEe,gK as oce,gL as rEe,gM as iEe,gN as _b,gO as MY,gP as aEe,gQ as LY,gR as oEe,bd as FY,gS as BY,gT as sEe,gU as lEe,gV as HY,gW as cEe,ah as KY,cS as uEe,bu as OEe,cR as dEe,aV as fEe,b5 as hEe,ce as m9,cc as pEe,gX as mEe,du as sce,dt as lce,ac as _$,aH as cce,gY as gEe,aJ as uce,gZ as $Ee,g_ as g9,g$ as _1,h0 as yEe,h1 as vEe,cu as bEe,h2 as wEe,aI as xEe,h3 as SEe,h4 as QEe,h5 as kEe,h6 as JY,h7 as _Ee,h8 as _x,h9 as Oce,dc as PEe,ha as dce,hb as TEe,hc as XEe,hd as REe,he as EEe,q as qEe,hf as gk,hg as $9,hh as jEe,hi as CEe,bC as fce,hj as hce,hk as P$,hl as xc,hm as zEe,hn as AEe,ho as UEe,hp as WEe,dD as NEe,hq as Px,hr as YEe,hs as GEe,ht as ZEe,hu as IEe,hv as eG,hw as DEe,hx as VEe,hy as MEe,hz as LEe,hA as FEe,hB as BEe,S as HEe,as as tG,hC as Qj,hD as kj}from"./appearance-CglKqGvj.js";import{aA as KEe,c as Ce,aJ as JEe,aK as pce,aL as eqe,aM as tqe,aN as nqe,aO as rqe,aP as iqe,aQ as aqe,aR as mg,aS as oqe,B as Qe,n as y9,o as v9,y as sqe,p as b9,F as lqe,w as vt,h as mce,i as As,a as sa,C as Tx,X as oi,j as cqe,u as we,g as gce,k as Xx,J as $ce,T as Id,aj as T$,A as Xl,Z as p5,ab as uqe,v as Oqe,S as Sa,a6 as cv,G as yce,D as w9,b as x9,d as S9,e as gl,q as A0,x as U0,au as Q9,r as uO,aT as dqe,a7 as fqe,a8 as hqe,a9 as pqe,af as mqe,at as gqe,$ as $qe,N as yqe,O as vqe,P as bqe,K as Fa,R as vce,U as bce,V as wce,W as xce,Y as _j,_ as wqe,z as Pj,L as Sce,aI as xqe,f as ho,a0 as Sqe,a1 as Qqe,a2 as nG,a3 as rG,a4 as kqe,a5 as iG,an as _qe,s as Pqe,H as m5,I as aG,E as oG}from"./error-boundary-5lWaVpLN.js";import{c as $f,t as m,L as bd,d as Tqe}from"./messages-DvlMQPU7.js";import{P as k9}from"./roles-D1pcbxAx.js";const sG=new Map,lG=new Map,cG=new Map;function _9(e){return e===void 0?"":JSON.stringify(e)}function P9(e,t){const n=`${e}\0${_9(t)}`;let r=sG.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),sG.set(n,r)),r}function Xqe(e,t){const n=`${e}\0${_9(t)}`;let r=lG.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),lG.set(n,r)),r}function $k(e,t,n){return P9(n??$f(),t).format(e)}function yk(e,t,n){return P9(n??$f(),t).format(e)}function Qce(e,t,n){return P9(n??$f(),t).format(e)}function Ma(e,t,n){return Xqe(n??$f(),t).format(e)}function Kln(e,t,n,r){const i=r??$f(),a=`${i}\0${_9(n)}`;let o=cG.get(a);return o===void 0&&(o=new Intl.RelativeTimeFormat(i,n),cG.set(a,o)),o.format(e,t)}const Rqe=[{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"}],Eqe={languages:Rqe},uG=Eqe.languages;function kce(e){const t=e.trim();if(t==="")return{lang:"en",dir:"ltr"};const n=t.toLowerCase(),r=uG.find(o=>o.code.toLowerCase()===n),i=n.split("-")[0],a=r??uG.find(o=>o.code.split("-")[0].toLowerCase()===i);return{lang:r?.code??t,dir:a?.dir==="rtl"?"rtl":"ltr"}}function _ce(e){return kce(e).dir}var qqe=class extends NXe{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:WY()})}getOptimisticResult(e){return e.behavior=WY(),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:GXe(t,n.data),hasPreviousPage:YXe(t,n.data),isFetchNextPageError:c,isFetchingNextPage:u,isFetchPreviousPageError:O,isFetchingPreviousPage:d,isRefetchError:s&&!c&&!O,isRefetching:a&&!u&&!d}}},jqe=class extends ZXe{#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),IXe(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#e,observer:this}),n?.mutationKey&&this.options.mutationKey&&NY(n.mutationKey)!==NY(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??DXe();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){Zle.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 Rx(e,t){const n=ko(t),[r]=$.useState(()=>new jqe(n,e));$.useEffect(()=>{r.setOptions(e)},[r,e]);const i=$.useSyncExternalStore($.useCallback(o=>r.subscribe(Zle.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=$.useCallback((o,s)=>{r.mutate(o,s).catch(VXe)},[r]);if(i.error&&MXe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function Pce(e,t){return LXe(e,qqe,t)}const Cqe=5e3;let Tce=0;function zqe(e=Cqe){Tce=Date.now()+e}function ecn(e=Date.now()){return e<=Tce}function Aqe(e){zqe(),e.invalidateQueries({queryKey:Wr.capabilities})}const Uqe=e=>e!==""&&_ce($f())==="rtl"?`⁦${e}⁩`:e;function Wqe(e,t){if(!e||typeof e!="object")return null;const n=e,r=n.artifacts;if(!Nqe(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:Xce(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 Xce(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 a9({...e,billing_basis:n?.basis??e.billing_basis})}function g5(e){const t=e,n=Xce(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 Nqe(e){return"cost_complete"in e||["completed","failed","cancelled"].some(t=>t in e)}function Yqe(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 Gqe(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 Zqe(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 T9="generate_video",X9="generate_voiceover",R9="generate_sound_effect",Iqe=new Set(["generate_image",T9,X9,R9]);function Rce(e){return Iqe.has(e)}function Dqe(e){return e===T9}function Vqe(e){return e===X9||e===R9}function Mqe(e){return e===T9?"video":e===X9?"voiceover":e===R9?"sound-effect":"image"}const OG="Stopped before the provider was called; you will not be charged.",Tj="Stop requested. The provider has no cancellation endpoint; the generation continues and will be charged if it produces audio. Checking for settlement.",Lqe="Audio generation is busy right now. Wait a moment and try again.";function Yh(e){switch(e){case"video":return"video";case"voiceover":return"voiceover";case"sound-effect":return"sound effect";default:return"image"}}function Fqe(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 Bqe(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:Fqe(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 dG(e){return e.fraction===null&&e.logs.length===0&&e.queuePosition===null?Ece:{fraction:e.fraction,logs:e.logs,queuePosition:e.queuePosition}}const Ece=Object.freeze({fraction:null,logs:[],queuePosition:null});function Hqe(e,{stopping:t=!1,settled:n=!1}={}){const r=Bqe(e.details),i=Mqe(e.toolName),a=i==="voiceover"||i==="sound-effect",o=a&&e.phase==="done"?Wqe(e.details,e.images??[]):null,s=a?Zqe(e.args,e.details):null,l=o?{batch:o,batchSummary:Yqe(e.details,o),batchNote:Gqe(e.details,e.output)}:{},c=a?eje(e.details):null;if(e.stopped===!0)return{state:"cancelled",generating:e.startedAt!==null,message:r.error??e.output,...o?{...l,material:i,costCaption:g5(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?$5(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:$5(r.errorType,r.error??e.output),...l,costCaption:g5(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"?Lqe:null),errorType:a?$5(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:Ece}:{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:dG(r)}:{state:"running",material:i,startedAtMs:u,progress:dG(r),note:r.error,...s?{batchProgress:s}:{}}}case"done":{const u=a?a9(e.details,e.output):null;return{state:"done",images:e.images??[],material:i,durationS:e.durationS??null,receipt:"generated",batch:o,...l,costCaption:o?g5(e.details):u}}}}const Kqe=/\s*Checking for settlement\.?\s*$/;function Jqe(e){return e.replace(Kqe,"").trimEnd()}function eje(e){if(!e||typeof e!="object")return null;const t=e,n=t.cost;return t.settled===!0?a9(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 $5(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 tje(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 nje(e,t){if(!Dqe(e))return t?{onCancel:t}:void 0}function rje(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 ije=e=>{switch(e){case"success":return sje;case"info":return cje;case"warning":return lje;case"error":return uje;default:return null}},aje=Array(12).fill(0),oje=({visible:e,className:t})=>J.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},J.createElement("div",{className:"sonner-spinner"},aje.map((n,r)=>J.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),sje=J.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},J.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"})),lje=J.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},J.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"})),cje=J.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},J.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"})),uje=J.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},J.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"})),Oje=J.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"},J.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),J.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),dje=()=>{const[e,t]=J.useState(document.hidden);return J.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let Xj=1;class fje{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:Xj++,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],J.isValidElement(c))a=!1,this.create({id:r,type:"default",message:c});else if(pje(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"&&!J.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"&&!J.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"&&!J.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"&&!J.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||Xj++;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 Ua=new fje,hje=(e,t)=>{const n=t?.id||Xj++;return Ua.addToast({title:e,...t,id:n}),n},pje=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",mje=hje,gje=()=>Ua.toasts,$je=()=>Ua.getActiveToasts(),yf=Object.assign(mje,{success:Ua.success,info:Ua.info,warning:Ua.warning,error:Ua.error,custom:Ua.custom,message:Ua.message,promise:Ua.promise,dismiss:Ua.dismiss,loading:Ua.loading},{getHistory:gje,getToasts:$je});rje("[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 Pb(e){return e.label!==void 0}const yje=3,vje="24px",bje="16px",fG=4e3,wje=356,xje=14,Sje=45,Qje=200;function rl(...e){return e.filter(Boolean).join(" ")}function kje(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const _je=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:X,className:E="",descriptionClassName:R="",duration:q,position:C,gap:z,expandByDefault:W,classNames:G,icons:A,closeButtonAriaLabel:I="Close toast"}=e,[Z,U]=J.useState(null),[D,K]=J.useState(null),[Y,le]=J.useState(!1),[F,H]=J.useState(!1),[se,ee]=J.useState(!1),[L,ne]=J.useState(!1),[Oe,he]=J.useState(!1),[_e,te]=J.useState(0),[be,xe]=J.useState(0),Xe=J.useRef(O.duration||q||fG),ue=J.useRef(null),ge=J.useRef(null),Ke=v===0,dt=v+1<=g,Ee=O.type,Xt=O.dismissible!==!1,ht=O.className||"",tn=O.descriptionClassName||"",pe=J.useMemo(()=>y.findIndex(pt=>pt.toastId===O.id)||0,[y,O.id]),ie=J.useMemo(()=>{var pt;return(pt=O.closeButton)!=null?pt:S},[O.closeButton,S]),$e=J.useMemo(()=>O.duration||q||fG,[O.duration,q]),Re=J.useRef(0),Se=J.useRef(0),Me=J.useRef(0),Je=J.useRef(null),[St,Ae]=C.split("-"),Ne=J.useMemo(()=>y.reduce((pt,On,Nt)=>Nt>=pe?pt:pt+On.height,0),[y,pe]),Be=dje(),Bt=O.invert||u,_t=Ee==="loading";Se.current=J.useMemo(()=>pe*z+Ne,[pe,Ne]),J.useEffect(()=>{Xe.current=$e},[$e]),J.useEffect(()=>{le(!0)},[]),J.useEffect(()=>{const pt=ge.current;if(pt){const On=pt.getBoundingClientRect().height;return xe(On),p(Nt=>[{toastId:O.id,height:On,position:O.position},...Nt]),()=>p(Nt=>Nt.filter(kn=>kn.toastId!==O.id))}},[p,O.id]),J.useLayoutEffect(()=>{if(!Y)return;const pt=ge.current,On=pt.style.height;pt.style.height="auto";const Nt=pt.getBoundingClientRect().height;pt.style.height=On,xe(Nt),p(kn=>kn.find(Xn=>Xn.toastId===O.id)?kn.map(Xn=>Xn.toastId===O.id?{...Xn,height:Nt}:Xn):[{toastId:O.id,height:Nt,position:O.position},...kn])},[Y,O.title,O.description,p,O.id]);const Ut=J.useCallback(()=>{H(!0),te(Se.current),p(pt=>pt.filter(On=>On.toastId!==O.id)),setTimeout(()=>{Q(O)},Qje)},[O,Q,p,Se]);J.useEffect(()=>{if(O.promise&&Ee==="loading"||O.duration===1/0||O.type==="loading")return;let pt;return x||h||Be?(()=>{if(Me.current<Re.current){const kn=new Date().getTime()-Re.current;Xe.current=Xe.current-kn}Me.current=new Date().getTime()})():(()=>{Xe.current!==1/0&&(Re.current=new Date().getTime(),pt=setTimeout(()=>{O.onAutoClose==null||O.onAutoClose.call(O,O),Ut()},Xe.current))})(),()=>clearTimeout(pt)},[x,h,O,Ee,Be,Ut]),J.useEffect(()=>{O.delete&&Ut()},[Ut,O.delete]);function Hn(){var pt;if(A?.loading){var On;return J.createElement("div",{className:rl(G?.loader,O==null||(On=O.classNames)==null?void 0:On.loader,"sonner-loader"),"data-visible":Ee==="loading"},A.loading)}return J.createElement(oje,{className:rl(G?.loader,O==null||(pt=O.classNames)==null?void 0:pt.loader),visible:Ee==="loading"})}const ze=O.icon||A?.[Ee]||ije(Ee);var rt,Pt;return J.createElement("li",{tabIndex:0,ref:ge,className:rl(E,ht,G?.toast,O==null||(t=O.classNames)==null?void 0:t.toast,G?.default,G?.[Ee],O==null||(n=O.classNames)==null?void 0:n[Ee]),"data-sonner-toast":"","data-rich-colors":(rt=O.richColors)!=null?rt:w,"data-styled":!(O.jsx||O.unstyled||d),"data-mounted":Y,"data-promise":!!O.promise,"data-swiped":Oe,"data-removed":F,"data-visible":dt,"data-y-position":St,"data-x-position":Ae,"data-index":v,"data-front":Ke,"data-swiping":se,"data-dismissible":Xt,"data-type":Ee,"data-invert":Bt,"data-swipe-out":L,"data-swipe-direction":D,"data-expanded":!!(x||W&&Y),style:{"--index":v,"--toasts-before":v,"--z-index":b.length-v,"--offset":`${F?_e:Se.current}px`,"--initial-height":W?"auto":`${be}px`,...k,...O.style},onDragEnd:()=>{ee(!1),U(null),Je.current=null},onPointerDown:pt=>{_t||!Xt||(ue.current=new Date,te(Se.current),pt.target.setPointerCapture(pt.pointerId),pt.target.tagName!=="BUTTON"&&(ee(!0),Je.current={x:pt.clientX,y:pt.clientY}))},onPointerUp:()=>{var pt,On,Nt;if(L||!Xt)return;Je.current=null;const kn=Number(((pt=ge.current)==null?void 0:pt.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Br=Number(((On=ge.current)==null?void 0:On.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Xn=new Date().getTime()-((Nt=ue.current)==null?void 0:Nt.getTime()),Yr=Z==="x"?kn:Br,da=Math.abs(Yr)/Xn;if(Math.abs(Yr)>=Sje||da>.11){te(Se.current),O.onDismiss==null||O.onDismiss.call(O,O),K(Z==="x"?kn>0?"right":"left":Br>0?"down":"up"),Ut(),ne(!0);return}else{var Tt,Rn;(Tt=ge.current)==null||Tt.style.setProperty("--swipe-amount-x","0px"),(Rn=ge.current)==null||Rn.style.setProperty("--swipe-amount-y","0px")}he(!1),ee(!1),U(null)},onPointerMove:pt=>{var On,Nt,kn;if(!Je.current||!Xt||((On=window.getSelection())==null?void 0:On.toString().length)>0)return;const Xn=pt.clientY-Je.current.y,Yr=pt.clientX-Je.current.x;var da;const Tt=(da=e.swipeDirections)!=null?da:kje(C);!Z&&(Math.abs(Yr)>1||Math.abs(Xn)>1)&&U(Math.abs(Yr)>Math.abs(Xn)?"x":"y");let Rn={x:0,y:0};const bi=qr=>1/(1.5+Math.abs(qr)/20);if(Z==="y"){if(Tt.includes("top")||Tt.includes("bottom"))if(Tt.includes("top")&&Xn<0||Tt.includes("bottom")&&Xn>0)Rn.y=Xn;else{const qr=Xn*bi(Xn);Rn.y=Math.abs(qr)<Math.abs(Xn)?qr:Xn}}else if(Z==="x"&&(Tt.includes("left")||Tt.includes("right")))if(Tt.includes("left")&&Yr<0||Tt.includes("right")&&Yr>0)Rn.x=Yr;else{const qr=Yr*bi(Yr);Rn.x=Math.abs(qr)<Math.abs(Yr)?qr:Yr}(Math.abs(Rn.x)>0||Math.abs(Rn.y)>0)&&he(!0),(Nt=ge.current)==null||Nt.style.setProperty("--swipe-amount-x",`${Rn.x}px`),(kn=ge.current)==null||kn.style.setProperty("--swipe-amount-y",`${Rn.y}px`)}},ie&&!O.jsx&&Ee!=="loading"?J.createElement("button",{"aria-label":I,"data-disabled":_t,"data-close-button":!0,onClick:_t||!Xt?()=>{}:()=>{Ut(),O.onDismiss==null||O.onDismiss.call(O,O)},className:rl(G?.closeButton,O==null||(r=O.classNames)==null?void 0:r.closeButton)},(Pt=A?.close)!=null?Pt:Oje):null,(Ee||O.icon||O.promise)&&O.icon!==null&&(A?.[Ee]!==null||O.icon)?J.createElement("div",{"data-icon":"",className:rl(G?.icon,O==null||(i=O.classNames)==null?void 0:i.icon)},O.promise||O.type==="loading"&&!O.icon?O.icon||Hn():null,O.type!=="loading"?ze:null):null,J.createElement("div",{"data-content":"",className:rl(G?.content,O==null||(a=O.classNames)==null?void 0:a.content)},J.createElement("div",{"data-title":"",className:rl(G?.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?J.createElement("div",{"data-description":"",className:rl(R,tn,G?.description,O==null||(s=O.classNames)==null?void 0:s.description)},typeof O.description=="function"?O.description():O.description):null),J.isValidElement(O.cancel)?O.cancel:O.cancel&&Pb(O.cancel)?J.createElement("button",{"data-button":!0,"data-cancel":!0,style:O.cancelButtonStyle||P,onClick:pt=>{Pb(O.cancel)&&Xt&&(O.cancel.onClick==null||O.cancel.onClick.call(O.cancel,pt),Ut())},className:rl(G?.cancelButton,O==null||(l=O.classNames)==null?void 0:l.cancelButton)},O.cancel.label):null,J.isValidElement(O.action)?O.action:O.action&&Pb(O.action)?J.createElement("button",{"data-button":!0,"data-action":!0,style:O.actionButtonStyle||X,onClick:pt=>{Pb(O.action)&&(O.action.onClick==null||O.action.onClick.call(O.action,pt),!pt.defaultPrevented&&Ut())},className:rl(G?.actionButton,O==null||(c=O.classNames)==null?void 0:c.actionButton)},O.action.label):null)};function hG(){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 Pje(e,t){const n={};return[e,t].forEach((r,i)=>{const a=i===1,o=a?"--mobile-offset":"--offset",s=a?bje:vje;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 Tje=J.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=yje,toastOptions:y,dir:v=hG(),gap:b=xje,icons:x,containerAriaLabel:Q="Notifications"}=t,[w,S]=J.useState([]),k=J.useMemo(()=>Array.from(new Set([i].concat(w.filter(D=>D.position).map(D=>D.position)))),[w,i]),[P,X]=J.useState([]),[E,R]=J.useState(!1),[q,C]=J.useState(!1),[z,W]=J.useState(O!=="system"?O:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),G=J.useRef(null),A=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=J.useRef(null),Z=J.useRef(!1),U=J.useCallback(D=>{S(K=>{var Y;return(Y=K.find(le=>le.id===D.id))!=null&&Y.delete||Ua.dismiss(D.id),K.filter(({id:le})=>le!==D.id)})},[]);return J.useEffect(()=>Ua.subscribe(D=>{if(D.dismiss){requestAnimationFrame(()=>{S(K=>K.map(Y=>Y.id===D.id?{...Y,delete:!0}:Y))});return}setTimeout(()=>{KEe.flushSync(()=>{S(K=>{const Y=K.findIndex(le=>le.id===D.id);return Y!==-1?[...K.slice(0,Y),{...K[Y],...D},...K.slice(Y+1)]:[D,...K]})})})}),[w]),J.useEffect(()=>{if(O!=="system"){W(O);return}if(O==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?W("dark"):W("light")),typeof window>"u")return;const D=window.matchMedia("(prefers-color-scheme: dark)");try{D.addEventListener("change",({matches:K})=>{W(K?"dark":"light")})}catch{D.addListener(({matches:Y})=>{try{W(Y?"dark":"light")}catch(le){console.error(le)}})}},[O]),J.useEffect(()=>{w.length<=1&&R(!1)},[w]),J.useEffect(()=>{const D=K=>{var Y;if(a.every(H=>K[H]||K.code===H)){var F;R(!0),(F=G.current)==null||F.focus()}K.code==="Escape"&&(document.activeElement===G.current||(Y=G.current)!=null&&Y.contains(document.activeElement))&&R(!1)};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[a]),J.useEffect(()=>{if(G.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,Z.current=!1)}},[G.current]),J.createElement("section",{ref:n,"aria-label":`${Q} ${A}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},k.map((D,K)=>{var Y;const[le,F]=D.split("-");return w.length?J.createElement("ol",{key:D,dir:v==="auto"?hG():v,tabIndex:-1,ref:G,className:l,"data-sonner-toaster":!0,"data-sonner-theme":z,"data-y-position":le,"data-lifted":E&&w.length>1&&!o,"data-x-position":F,style:{"--front-toast-height":`${((Y=P[0])==null?void 0:Y.height)||0}px`,"--width":`${wje}px`,"--gap":`${b}px`,...p,...Pje(c,u)},onBlur:H=>{Z.current&&!H.currentTarget.contains(H.relatedTarget)&&(Z.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:H=>{H.target instanceof HTMLElement&&H.target.dataset.dismissible==="false"||Z.current||(Z.current=!0,I.current=H.relatedTarget)},onMouseEnter:()=>R(!0),onMouseMove:()=>R(!0),onMouseLeave:()=>{q||R(!1)},onDragEnd:()=>R(!1),onPointerDown:H=>{H.target instanceof HTMLElement&&H.target.dataset.dismissible==="false"||C(!0)},onPointerUp:()=>C(!1)},w.filter(H=>!H.position&&K===0||H.position===D).map((H,se)=>{var ee,L;return J.createElement(_je,{key:H.id,icons:x,index:se,toast:H,defaultRichColors:d,duration:(ee=y?.duration)!=null?ee:h,className:y?.className,descriptionClassName:y?.descriptionClassName,invert:r,visibleToasts:g,closeButton:(L=y?.closeButton)!=null?L:s,interacting:q,position:D,style:y?.style,unstyled:y?.unstyled,classNames:y?.classNames,cancelButtonStyle:y?.cancelButtonStyle,actionButtonStyle:y?.actionButtonStyle,closeButtonAriaLabel:y?.closeButtonAriaLabel,removeToast:U,toasts:w.filter(ne=>ne.position==H.position),heights:P.filter(ne=>ne.position==H.position),setHeights:X,expandByDefault:o,gap:b,expanded:E,swipeDirections:t.swipeDirections})})):null}))}),Xje=["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"],Rje=["ENOTFOUND","EAI_AGAIN","ETIMEDOUT","ECONNRESET","ECONNREFUSED","EHOSTUNREACH","ENETUNREACH","ENETDOWN","ENETRESET","ECONNABORTED","EPIPE"],Eje=["Failed to fetch","Load failed","NetworkError when attempting to fetch resource."],qje=new Set(Xje),jje=/[:\-\u2014\n]$/,Cje=/^[:\n]/,pG=/[:\uff1a\n\u2014]| - /g,zje=/^(?:\s*Error:\s*)+/,Aje=/:\s+Error:\s+/g,Uje=/\b(?:net::)?(ERR_[A-Z0-9_]+)\b/g,Wje=Rje.map(e=>({code:e,pattern:new RegExp(`\\b${e}\\b`)}));function y5(e,t,n){const r=e.slice(0,t).trimEnd(),i=e.slice(t+n).trimStart(),a=r===""||jje.test(r),o=i===""||Cje.test(i);return a&&o}function qce(e){const t=Yje(e);if(!t)return null;const n=jce(t);for(const r of n.matchAll(Uje)){const i=r[1];if(!qje.has(i))continue;const a=r.index??0,o=a+r[0].length;return{code:`net::${i}`,start:a,end:o,clauseText:v5(n,a,o),clause:y5(n,a,o-a)}}for(const{code:r,pattern:i}of Wje){const a=i.exec(n);if(a){const o=a.index,s=o+a[0].length;return{code:r,start:o,end:s,clauseText:v5(n,o,s),clause:y5(n,o,s-o)}}}for(const r of Eje){const i=n.indexOf(r);if(i!==-1&&y5(n,i,r.length))return{code:r,start:i,end:i+r.length,clauseText:v5(n,i,i+r.length),clause:!0}}return null}function Nje(e){return qce(e)?.code??null}function tcn(e){return Nje(e)!==null}function Yje(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 v5(e,t,n){let r=0;for(const a of e.slice(0,t).matchAll(pG))r=(a.index??0)+a[0].length;let i=e.length;for(const a of e.slice(n).matchAll(pG)){i=n+(a.index??0);break}return e.slice(r,i).trim()}function jce(e){return e.replace(zje,"").replace(Aje,": ")}const gg=new Map,b5=new Map,w5=new Map,mG=5e3,Gje=1,Zje={CONNECTION:["Failed to fetch","Network error","ERR_CONNECTION_REFUSED","Server is offline","Connection failed"]},Ije={"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},x5=()=>m("ui.common.connection.transport_failure"),Cce=e=>{const t=e.trim();if(Object.prototype.hasOwnProperty.call(Ije,t))return x5();const n=jce(t),r=qce(n);return r===null?e:r.clause?`${n.slice(0,r.start)}${x5()}${n.slice(r.end)}`:x5()},Dje=e=>{for(const[t,n]of Object.entries(Zje))if(n.some(r=>e.includes(r)))return t;return null},ncn=(e,t)=>yf.loading(e,t),Rr=(e,t)=>{const n=Date.now(),i=Dje(e)||e,a=Cce(e),o=b5.get(i);if(o&&n-o<mG)return null;const s=w5.get(i)||0;if(s>=Gje)return null;if(gg.has(i))return b5.set(i,n),gg.get(i);const l=yf.error(a,{...t,onDismiss:c=>{gg.delete(i),t?.onDismiss?.(c)},onAutoClose:c=>{gg.delete(i),t?.onAutoClose?.(c)}});return gg.set(i,l),b5.set(i,n),w5.set(i,s+1),setTimeout(()=>{w5.set(i,0)},mG),l},S5=(e,t)=>yf.error(Cce(e),t),Jo=(e,t)=>yf.info(e,t),W0=e=>{yf.dismiss(e)},OO=(e,t)=>yf.success(e,t),jh=(e,t)=>yf.warning(e,t),Vje={"under-window":{dark:{canvas:.53,surface:.59,elevated:.68},light:{canvas:.61,surface:.5,elevated:.45}},menu:{dark:{canvas:.67,surface:.72,elevated:.8},light:{canvas:.79,surface:.7,elevated:.65}},popover:{dark:{canvas:.75,surface:.78,elevated:.86},light:{canvas:.86,surface:.79,elevated:.75}}},Mje={dark:.09,light:.12},Lje={dark:{role:"sunken",scale:.68},light:{role:"surface",scale:.72}},Fje={"under-window":{dark:.15,light:.2},menu:{dark:.1,light:.2},popover:{dark:.1,light:.15}},Bje={dark:.88,light:.78},Hje={dark:.7,light:.5},Kje={dark:.65,light:.6},Jje={dark:.3,light:.4},e3e={hover:.05,selected:.08,field:.05,work:.08},t3e="Minimum ground alphas, the minimum ink and edge mixes the floating overlay carries, the state/field overlay alphas and the edge mix the window-glass feature paints, derived by scripts/derive-glass-floors.mjs (AA ink over the worst measured backdrop WITH the state overlay stacked; the 3:1 structural edge via a border->ink mix; the overlay floor against the least opaque column the app can present, plus the two mixes that carry the semantic inks and the panel's own boundary on it). Asserted by scripts/contrast-contract.mjs. Never hand-lower or hand-pick a value: re-derive.",E9={alphaFloor:Vje,blockVeil:Mje,laneWash:Lje,controlMix:Fje,bandFloor:Bje,overlayFloor:Hje,overlayInkMix:Kje,overlayEdgeMix:Jje,stateAlpha:e3e,_why:t3e},rcn=["sidebars","full"],zce=(e,t)=>e!=="vibrancy"?"popover":t==="menu"?"menu":t==="popover"?"popover":"under-window",Ace=.96,q9=e=>Math.round(e*100)/100;function n3e(e,t,n,r=E9){const i=r.alphaFloor[zce(e,t)][n];return{canvas:i.canvas,surface:i.surface,elevated:i.elevated}}function r3e(e){const t=Math.min(100,Math.max(0,e.intensity))/100,n=n3e(e.mechanism,e.material,e.scheme,e.floors),r=i=>{const a=Math.max(Ace,i);return q9(a-t*(a-i))};return{canvas:r(n.canvas),surface:r(n.surface),elevated:r(n.elevated)}}function i3e(e){const t=Math.min(100,Math.max(0,e.intensity))/100,n=E9.overlayFloor[e.scheme],r=Math.max(Ace,n);return q9(r-t*(r-n))}const a3e={sidebars:["sidebar"],full:["sidebar","canvas","pane"]};function o3e(e){const t=e.floors??E9,n=r3e(e),r=a=>n.canvas===1?0:q9(Math.min(1,Math.max(0,1-(1-a)/(1-n.canvas)))),i={"--lo-glass-a-canvas":String(n.canvas),"--lo-glass-a-surface":String(n.surface),"--lo-glass-a-elevated":String(n.elevated),"--lo-glass-a-row-hover":String(t.stateAlpha.hover),"--lo-glass-a-row-selected":String(t.stateAlpha.selected),"--lo-glass-a-row-work":String(t.stateAlpha.work),"--lo-glass-a-field":String(t.stateAlpha.field),"--lo-glass-a-block-veil":String(t.blockVeil[e.scheme]),"--lo-glass-a-band-floor":String(t.bandFloor[e.scheme]),"--lo-glass-a-overlay":String(i3e({intensity:e.intensity,scheme:e.scheme})),"--lo-glass-overlay-ink-mix":String(t.overlayInkMix[e.scheme]),"--lo-glass-overlay-edge-mix":String(t.overlayEdgeMix[e.scheme]),"--lo-glass-a-lane":String(Math.round(n.canvas*t.laneWash[e.scheme].scale*100)/100),"--lo-glass-lane-tone":t.laneWash[e.scheme].role==="sunken"?"var(--lo-sunken)":"var(--lo-surface)","--lo-glass-control-mix":String(t.controlMix[zce(e.mechanism,e.material)][e.scheme]),"--lo-glass-in-surface":String(r(n.surface)),"--lo-glass-in-elevated":String(r(n.elevated))};return{kinds:a3e[e.coverage].join(" "),vars:i}}const Uce=()=>document.documentElement,s3e=["--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-overlay","--lo-glass-overlay-ink-mix","--lo-glass-overlay-edge-mix","--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 P1=null;const Ex=()=>Uce().classList.contains("dark")?"dark":"light";function qx(e){P1=e;const t=Uce();if(!e||!e.active){delete t.dataset.glass;for(const a of s3e)t.style.removeProperty(a);return}const n=FXe(document),{kinds:r,vars:i}=o3e({floors:n?BXe(n):void 0,coverage:e.settings.coverage,intensity:e.settings.intensity,mechanism:e.mechanism,material:e.settings.material,scheme:e.scheme});t.dataset.glass=r;for(const[a,o]of Object.entries(i))t.style.setProperty(a,o)}function icn(e){qx(e?{active:!0,scheme:e.scheme,mechanism:e.mechanism,settings:{coverage:e.coverage,intensity:e.intensity,material:e.material}}:null)}function Rj(e){if(!e||!e.active||e.capability.mechanism==="none"){qx(null);return}e.restartRequired&&e.active||qx({active:!0,scheme:Ex(),mechanism:e.capability.mechanism,settings:{coverage:e.settings.coverage,intensity:e.settings.intensity,material:e.settings.material}})}function acn(){!P1||!P1.active||(qx({...P1,scheme:Ex()}),window.api?.windowGlass?.reportScheme?.(Ex()))}function ocn(){const e=window.api?.windowGlass;if(!e)return()=>{};const t=e.onState(r=>Rj(r)),n=r=>{r&&Rj(r)};return typeof CSS<"u"&&e.reportRenderer?.({backdropFilter:CSS.supports("backdrop-filter: blur(1px)")}).then(n,()=>{}),e.get?.().then(n,()=>{}),t}function scn(){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),Rj(i),window.api?.windowGlass?.reportScheme?.(Ex()))}}}const l3e=function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"}(),c3e=function(e,t){return new URL(e,t).href},gG={},ve=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=c3e(c,r),c in gG)return;gG[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":l3e,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
  *
@@ -874,7 +874,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
874
874
  `))};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=De.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));u.main.eq(i)||t.dispatch({selection:u,userEvent:"select"});return}if((ct.mac||ct.android)&&c.from==o-1&&/^\. ?$/.test(r.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:s,to:l,insert:Gn.of([r.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);Y8(t,c,De.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(on.mark({attributes:{style:u}}).range(l,c))}}}t.dispatch({effects:Dme.of(on.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=L$(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let n=0,r=!1,i=this.pendingContextChange;return t.changes.iterChanges((a,o,s,l,c)=>{if(r)return;let u=c.length-(o-a);if(i&&o>=i.to)if(i.from==a&&i.to==o&&i.insert.eq(c)){i=this.pendingContextChange=null,n+=u,this.to+=u;return}else i=null,this.revertPending(t.state);if(a+=n,o+=n,o<=this.from)this.from+=u,this.to+=u;else if(a<this.to){if(a<this.from||o>this.to||this.to-this.from+c.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(o),c.toString()),this.to+=u}n+=u}),i&&!r&&this.revertPending(t.state),!r}update(t){let n=this.pendingContextChange,r=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(r.from,r.to)&&t.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):!this.applyEdits(t)||!this.rangeIsValid(t.state)?(this.pendingContextChange=null,this.reset(t.state)):(t.docChanged||t.selectionSet||n)&&this.setSelection(t.state),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:n}=t.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(t.doc.length,n+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),t.doc.sliceString(n.from,n.to))}setSelection(t){let{main:n}=t.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),i=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(t){let{head:n}=t.selection.main;return!(this.from>0&&n-this.from<500||this.to<t.doc.length&&this.to-n<500||this.to-this.from>1e4*3)}toEditorPos(t,n=this.to-this.from){t=Math.min(t,n);let r=this.composing;return r&&r.drifted?r.editorBase+(t-r.contextBase):t+this.from}toContextPos(t){let n=this.composing;return n&&n.drifted?n.contextBase+(t-n.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class xt{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:r}=t;this.dispatchTransactions=t.dispatchTransactions||r&&(i=>i.forEach(a=>r(a,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=t.root||Qtt(t.parent)||document,this.viewState=new DV(t.state||jn.create(t)),t.scrollTo&&t.scrollTo.is(tw)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Dh).map(i=>new IT(i));for(let i of this.plugins)i.update(this);this.observer=new Znt(this),this.inputState=new dnt(this),this.inputState.ensureHandlers(this.plugins),this.docView=new kV(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 Di?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(ige))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=age(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(jn.phrases)!=this.state.facet(jn.phrases))return this.setState(a);i=cS.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 lp(h.empty?h:De.cursor(h.head,h.head>h.anchor?-1:1))}for(let h of d.effects)h.is(tw)&&(O=h.value.clip(this.state))}this.viewState.update(i,O),this.bidiCache=OS.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(v0)!=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(sw)!=i.state.facet(sw)&&(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(y7))try{d(i)}catch(h){Da(this.state,h,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!Kme(this,u)&&c.force&&sp(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 DV(t),this.plugins=t.facet(Dh).map(r=>new IT(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new kV(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(Dh),r=t.state.facet(Dh);if(n!=r){let i=[];for(let a of r){let o=n.indexOf(a);if(o<0)i.push(new IT(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){Da(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(yme(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 Da(this.state,p),FV}}),O=cS.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]!=FV)try{let p=c[h];p.write&&p.write(u[h],this)}catch(p){Da(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(y7))s(n)}get themeClasses(){return S7+" "+(this.state.facet(x7)?cge:lge)+" "+this.state.facet(sw)}updateAttrs(){let t=BV(this,Vme,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(bc)?"true":"false",class:"cm-content",style:`${ct.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),BV(this,U8,n);let r=this.observer.ignore(()=>{let i=h7(this.contentDOM,this.contentAttrs,n),a=h7(this.dom,this.editorAttrs,t);return i||a});return this.editorAttrs=t,this.contentAttrs=n,r}showAnnouncements(t){let n=!0;for(let r of t)for(let i of r.effects)if(i.is(xt.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(v0);let t=this.state.facet(xt.cspNonce);yO.mount(this.root,this.styleModules.concat(Ynt).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 VT(this,t,RV(this,t,n,r))}moveByGroup(t,n){return VT(this,t,RV(this,t,n,r=>rnt(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 De.cursor(a.side(n,i)+t.from,a.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return nnt(this,t,n,r)}moveVertically(t,n,r){return VT(this,t,int(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(),Hme(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[Fu.find(a,t-i.from,-1,n)];return _v(r,o.dir==br.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(Gme)||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>Vnt)return jme(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||qme(a.isolates,r=QV(this,t))))return a.order;r||(r=QV(this,t));let i=Ntt(t.text,n,r);return this.bidiCache.push(new OS(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||ct.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{gme(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 tw.of(new lp(typeof t=="number"?De.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 tw.of(new lp(De.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 mi.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return mi.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=yO.newName(),i=[sw.of(r),v0.of(Q7(`.${r}`,t))];return n&&n.dark&&i.push(x7.of(!0)),i}static baseTheme(t){return RO.lowest(v0.of(Q7("."+S7,t,uge)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&er.get(r)||er.get(t);return((n=i?.rootView)===null||n===void 0?void 0:n.view)||null}}xt.styleModule=v0;xt.inputHandler=Nme;xt.clipboardInputFilter=z8;xt.clipboardOutputFilter=A8;xt.scrollHandler=Ime;xt.focusChangeEffect=Yme;xt.perLineTextDirection=Gme;xt.exceptionSink=Wme;xt.updateListener=y7;xt.editable=bc;xt.mouseSelectionStyle=Ume;xt.dragMovesSelection=Ame;xt.clickAddsSelectionRange=zme;xt.decorations=F$;xt.outerDecorations=Mme;xt.atomicRanges=W8;xt.bidiIsolatedRanges=Lme;xt.scrollMargins=Fme;xt.darkTheme=x7;xt.cspNonce=ft.define({combine:e=>e.length?e[0]:""});xt.contentAttributes=U8;xt.editorAttributes=Vme;xt.lineWrapping=xt.contentAttributes.of({class:"cm-lineWrapping"});xt.announce=wn.define();const Vnt=4096,FV={};class OS{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:br.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 OS(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}}function BV(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&&f7(o,n)}return n}const Mnt=ct.mac?"mac":ct.windows?"win":ct.linux?"linux":"key";function Lnt(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 lw(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 Fnt=RO.default(xt.domEventHandlers({keydown(e,t){return dge(Oge(t.state),e,t,"editor")}})),i_=ft.define({enables:Fnt}),HV=new WeakMap;function Oge(e){let t=e.facet(i_),n=HV.get(t);return n||HV.set(t,n=Hnt(t.reduce((r,i)=>r.concat(i),[]))),n}function idn(e,t,n){return dge(Oge(e.state),t,e,n)}let Gu=null;const Bnt=4e3;function Hnt(e,t=Mnt){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=>Lnt(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=Gu={view:x,prefix:b,scope:o};return setTimeout(()=>{Gu==Q&&(Gu=null)},Bnt),!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,k7))}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 k7=null;function dge(e,t,n,r){k7=t;let i=vtt(t),a=mo(i,0),o=vc(a)==i.length&&i!=" ",s="",l=!1,c=!1,u=!1;Gu&&Gu.view==n&&Gu.scope==r&&(s=Gu.prefix+" ",ege.indexOf(t.keyCode)<0&&(c=!0,Gu=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+lw(i,t,!o)])?l=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(ct.windows&&t.ctrlKey&&t.altKey)&&(p=vO[t.keyCode])&&p!=i?(d(h[s+lw(p,t,!0)])||t.shiftKey&&(g=M$[t.keyCode])!=i&&g!=p&&d(h[s+lw(g,t,!1)]))&&(l=!0):o&&t.shiftKey&&d(h[s+lw(i,t,!0)])&&(l=!0),!l&&d(h._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),k7=null,l}class Xv{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=fge(t);return[new Xv(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return Knt(t,n,r)}}function fge(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==br.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function KV(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 Knt(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==br.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),l=fge(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=b7(e,r,1),p=b7(e,i,-1),g=h.type==ka.Text?h:null,y=p.type==ka.Text?p:null;if(g&&(e.lineWrapping||h.widgetLineBreaks)&&(g=KV(e,r,1,g)),y&&(e.lineWrapping||p.widgetLineBreaks)&&(y=KV(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==ka.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 Xv(t,w-l.left,S-l.top,k-w,P-S)}function b({top:w,bottom:S,horizontal:k}){let P=[];for(let X=0;X<k.length;X+=2)P.push(v(k[X],w,k[X+1],S));return P}function x(w,S,k){let P=1e9,X=-1e9,E=[];function R(z,W,G,A,I){let Z=e.coordsAtPos(z,z==k.to?-2:2),U=e.coordsAtPos(G,G==k.from?2:-2);!Z||!U||(P=Math.min(Z.top,U.top,P),X=Math.max(Z.bottom,U.bottom,X),I==br.LTR?E.push(a&&W?O:Z.left,a&&A?d:U.right):E.push(!a&&A?O:U.left,!a&&W?d:Z.right))}let q=w??k.from,C=S??k.to;for(let z of e.visibleRanges)if(z.to>q&&z.from<C)for(let W=Math.max(z.from,q),G=Math.min(z.to,C);;){let A=e.state.doc.lineAt(W);for(let I of e.bidiSpans(A)){let Z=I.from+A.from,U=I.to+A.from;if(Z>=G)break;U>W&&R(Math.max(Z,W),w==null&&Z<=q,Math.min(U,G),S==null&&U>=C,I.dir)}if(W=A.to+1,W>=G)break}return E.length==0&&R(q,w==null,C,S==null,e.textDirection),{top:P,bottom:X,horizontal:E}}function Q(w,S){let k=s.top+(S?w.top:w.bottom);return{top:k,bottom:k,horizontal:[]}}}function Jnt(e,t){return e.constructor==t.constructor&&e.eq(t)}class ert{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(D1)!=t.state.facet(D1)&&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(D1);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)=>!Jnt(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 D1=ft.define();function hge(e){return[mi.define(t=>new ert(t,e)),D1.of(e)]}const B$=ft.define({combine(e){return Wm(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function adn(e={}){return[B$.of(e),trt,nrt,rrt,Zme.of(!0)]}function pge(e){return e.startState.facet(B$)!=e.state.facet(B$)}const trt=hge({above:!0,markers(e){let{state:t}=e,n=t.facet(B$),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:De.cursor(i.head,i.head>i.anchor?-1:1);for(let l of Xv.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=pge(e);return n&&JV(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){JV(t.state,e)},class:"cm-cursorLayer"});function JV(e,t){t.style.animationDuration=e.facet(B$).cursorBlinkRate+"ms"}const nrt=hge({above:!1,markers(e){return e.state.selection.ranges.map(t=>t.empty?[]:Xv.forRange(e,"cm-selectionBackground",t)).reduce((t,n)=>t.concat(n))},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||pge(e)},class:"cm-selectionLayer"}),rrt=RO.highest(xt.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),mge=wn.define({map(e,t){return e==null?null:t.mapPos(e)}}),x0=Ka.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(mge)?r.value:n,e)}}),irt=mi.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(x0);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(x0)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(x0),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(x0)!=e&&this.view.dispatch({effects:mge.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 odn(){return[x0,irt]}function eM(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 art(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 ort{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 Bd,r=n.add.bind(n);for(let{from:i,to:a}of art(t,this.maxLength))eM(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 eM(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 _7=/x/.unicode!=null?"gu":"g",srt=new RegExp(`[\0-\b
875
875
  --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,_7),lrt={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 FT=null;function crt(){var e;if(FT==null&&typeof document<"u"&&document.body){let t=document.body.style;FT=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return FT||!1}const V1=ft.define({combine(e){let t=Wm(e,{render:null,specialChars:srt,addSpecialChars:null});return(t.replaceTabs=!crt())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,_7)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,_7)),t}});function sdn(e={}){return[V1.of(e),urt()]}let tM=null;function urt(){return tM||(tM=mi.fromClass(class{constructor(e){this.view=e,this.decorations=on.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(V1)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new ort({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,a=mo(t[0],0);if(a==9){let o=i.lineAt(r),s=n.state.tabSize,l=$O(o.text,s,r-o.from);return on.replace({widget:new hrt((s-l%s)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=on.replace({widget:new frt(e,a)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(V1);e.startState.facet(V1)!=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 Ort="•";function drt(e){return e>=32?Ort:e==10?"␤":String.fromCharCode(9216+e)}class frt extends su{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=drt(this.code),r=t.state.phrase("Control character")+" "+(lrt[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 hrt extends su{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 ldn(){return mrt}const prt=on.line({class:"cm-activeLine"}),mrt=mi.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(prt.range(i.from)),t=i.from)}return on.set(n)}},{decorations:e=>e.decorations});class grt extends su{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?Wp(t.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(t.parentNode),i=_v(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 cdn(e){let t=mi.fromClass(class{constructor(n){this.view=n,this.placeholder=e?on.set([on.widget({widget:new grt(e),side:1}).range(0)]):on.none}get decorations(){return this.view.state.doc.length?on.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,xt.contentAttributes.of({"aria-placeholder":e})]:t}const P7=2e3;function $rt(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>P7||n.off>P7||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(De.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=o7(c.text,o,e.tabSize,!0);if(u<0)a.push(De.cursor(c.to));else{let O=o7(c.text,s,e.tabSize);a.push(De.range(c.from+u,c.from+O))}}}return a}function yrt(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function nM(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>P7?-1:i==r.length?yrt(e,t.clientX):$O(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function vrt(e,t){let n=nM(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=nM(e,i);if(!s)return r;let l=$rt(e.state,n,s);return l.length?o?De.create(l.concat(r.ranges)):De.create(l):r}}:null}function udn(e){let t=n=>n.altKey&&n.button==0;return xt.mouseSelectionStyle.of((n,r)=>t(r)?vrt(n,r):null)}const brt={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},wrt={style:"cursor: crosshair"};function Odn(e={}){let[t,n]=brt[e.key||"Alt"],r=mi.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventObservers:{keydown(i){this.set(i.keyCode==t||n(i))},keyup(i){(i.keyCode==t||!n(i))&&this.set(!1)},mousemove(i){this.set(n(i))}}});return[r,xt.contentAttributes.of(i=>{var a;return!((a=i.plugin(r))===null||a===void 0)&&a.isDown?wrt:null})]}const Xg="-10000px";class gge{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 xrt(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const BT=ft.define({combine:e=>{var t,n,r;return{position:ct.ios?"absolute":((t=e.find(i=>i.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((n=e.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=e.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||xrt}}}),rM=new WeakMap,I8=mi.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(BT);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 gge(e,D8,(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(BT);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=Xg,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(e=r.destroy)===null||e===void 0||e.call(r);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:a}=this.manager.tooltipViews[0];if(ct.gecko)n=a.offsetParent!=this.container.ownerDocument.body;else if(a.style.top==Xg&&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=N8(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(BT).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=Xg;continue}let h=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=h?7:0,g=d.right-d.left,y=(t=rM.get(c))!==null&&t!==void 0?t:d.bottom-d.top,v=c.offset||Qrt,b=this.view.textDirection==br.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=Xg;continue}rM.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",iM(u,(x-e.parent.left)/i)):(u.style.top=S/a+"px",iM(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=Xg}},{eventObservers:{scroll(){this.maybeMeasure()}}});function iM(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const Srt=xt.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Qrt={x:0,y:0},D8=ft.define({enables:[I8,Srt]}),dS=ft.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class a_{static create(t){return new a_(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new gge(t,dS,(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 krt=D8.compute([dS],e=>{let t=e.facet(dS);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:a_.create,above:t[0].above,arrow:t.some(n=>n.arrow)}});class _rt{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 Lu)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==br.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=>Da(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(I8),n=t?t.manager.tooltips.findIndex(r=>r.create==a_.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&&!Prt(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:!Trt(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 cw=4;function Prt(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-cw&&t.clientX<=r+cw&&t.clientY>=i-cw&&t.clientY<=a+cw}function Trt(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 ddn(e,t={}){let n=wn.define(),r=Ka.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,Ii.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(Xrt)&&(i=[]);return i},provide:i=>dS.from(i)});return{active:r,extension:[r,mi.define(i=>new _rt(i,e,r,n,t.hoverTime||300)),krt]}}function $ge(e,t){let n=e.plugin(I8);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const Xrt=wn.define(),aM=ft.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 fdn(e,t){let n=e.plugin(yge),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const yge=mi.fromClass(class{constructor(e){this.input=e.state.facet(sM),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(aM);this.top=new uw(e,!0,t.topContainer),this.bottom=new uw(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(aM);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new uw(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new uw(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(sM);if(n!=this.input){let r=n.filter(l=>l),i=[],a=[],o=[],s=[];for(let l of r){let c=this.specs.indexOf(l),u;c<0?(u=l(e.view),s.push(u)):(u=this.panels[c],u.update&&u.update(e)),i.push(u),(u.top?a:o).push(u)}this.specs=r,this.panels=i,this.top.sync(a),this.bottom.sync(o);for(let l of s)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let r of this.panels)r.update&&r.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>xt.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class uw{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=oM(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=oM(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 oM(e){let t=e.nextSibling;return e.remove(),t}const sM=ft.define({enables:yge});class Mc extends Fd{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Mc.prototype.elementClass="";Mc.prototype.toDOM=void 0;Mc.prototype.mapMode=Ii.TrackBefore;Mc.prototype.startSide=Mc.prototype.endSide=-1;Mc.prototype.point=!0;const M1=ft.define(),Rrt=ft.define(),Ert={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>bn.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},t$=ft.define();function qrt(e){return[vge(),t$.of({...Ert,...e})]}const lM=ft.define({combine:e=>e.some(t=>t)});function vge(e){return[jrt]}const jrt=mi.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(t$).map(t=>new uM(e,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!e.state.facet(lM),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(lM)!=!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=bn.iter(this.view.state.facet(M1),this.view.viewport.from),r=[],i=this.gutters.map(a=>new Crt(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==ka.Text&&o){T7(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==ka.Text){T7(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(t$),n=e.state.facet(t$),r=e.docChanged||e.heightChanged||e.viewportChanged||!bn.eq(e.startState.facet(M1),e.state.facet(M1),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 uM(this.view,a)):(this.gutters[o].update(e),i.push(this.gutters[o]))}for(let a of this.gutters)a.dom.remove(),i.indexOf(a)<0&&a.destroy();for(let a of i)this.dom.appendChild(a.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove()}},{provide:e=>xt.scrollMargins.of(t=>{let n=t.plugin(e);return!n||n.gutters.length==0||!n.fixed?null:t.textDirection==br.LTR?{left:n.dom.offsetWidth*t.scaleX}:{right:n.dom.offsetWidth*t.scaleX}})});function cM(e){return Array.isArray(e)?e:[e]}function T7(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class Crt{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=bn.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 bge(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=[];T7(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(Rrt)){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 uM{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=cM(n.markers(t)),n.initialSpacer&&(this.spacer=new bge(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=cM(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!bn.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 bge{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":""),zrt(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 zrt(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 Art=ft.define(),Urt=ft.define(),Vh=ft.define({combine(e){return Wm(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 HT extends Mc{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function KT(e,t){return e.state.facet(Vh).formatNumber(t,e.state)}const Wrt=t$.compute([Vh],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(Art)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new HT(KT(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(Urt)){let a=i(t,n,r);if(a)return a}return null},lineMarkerChange:t=>t.startState.facet(Vh)!=t.state.facet(Vh),initialSpacer(t){return new HT(KT(t,OM(t.state.doc.lines)))},updateSpacer(t,n){let r=KT(n.view,OM(n.view.state.doc.lines));return r==t.number?t:new HT(r)},domEventHandlers:e.facet(Vh).domEventHandlers}));function hdn(e={}){return[Vh.of(e),vge(),Wrt]}function OM(e){let t=9;for(;t<e;)t=t*10+9;return t}const Nrt=new class extends Mc{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Yrt=M1.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(Nrt.range(i)))}return bn.of(t)});function pdn(){return Yrt}let Grt=0;class it{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=Grt++}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 it&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new it(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 fS(t);return r=>r.modified.indexOf(n)>-1?r:fS.get(r.base||r,r.modified.concat(n).sort((i,a)=>i.id-a.id))}}let Zrt=0;class fS{constructor(t){this.name=t,this.instances=[],this.id=Zrt++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(s=>s.base==t&&Irt(n,s.modified));if(r)return r;let i=[],a=new it(t.name,i,t,n);for(let s of n)s.instances.push(a);let o=Drt(n);for(let s of t.set)if(!s.modified.length)for(let l of o)i.push(fS.get(s,l));return a}}function Irt(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function Drt(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 Tn(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 hS(r,o,l>0?a.slice(0,l):null);t[c]=u.sort(t[c])}}return wge.add(t)}const wge=new Wt;let hS=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}};hS.empty=new hS([],2,null);function xge(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 Vrt(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function Mrt(e,t,n,r=0,i=e.length){let a=new Lrt(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,"",a.highlighters),a.flush(i)}class Lrt{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=Frt(t)||hS.empty,O=Vrt(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(Wt.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 Frt(e){let t=e.type.prop(wge);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const nt=it.define,Ow=nt(),ju=nt(),dM=nt(ju),fM=nt(ju),Cu=nt(),dw=nt(Cu),JT=nt(Cu),ul=nt(),nd=nt(ul),al=nt(),ol=nt(),X7=nt(),Rg=nt(X7),fw=nt(),_={comment:Ow,lineComment:nt(Ow),blockComment:nt(Ow),docComment:nt(Ow),name:ju,variableName:nt(ju),typeName:dM,tagName:nt(dM),propertyName:fM,attributeName:nt(fM),className:nt(ju),labelName:nt(ju),namespace:nt(ju),macroName:nt(ju),literal:Cu,string:dw,docString:nt(dw),character:nt(dw),attributeValue:nt(dw),number:JT,integer:nt(JT),float:nt(JT),bool:nt(Cu),regexp:nt(Cu),escape:nt(Cu),color:nt(Cu),url:nt(Cu),keyword:al,self:nt(al),null:nt(al),atom:nt(al),unit:nt(al),modifier:nt(al),operatorKeyword:nt(al),controlKeyword:nt(al),definitionKeyword:nt(al),moduleKeyword:nt(al),operator:ol,derefOperator:nt(ol),arithmeticOperator:nt(ol),logicOperator:nt(ol),bitwiseOperator:nt(ol),compareOperator:nt(ol),updateOperator:nt(ol),definitionOperator:nt(ol),typeOperator:nt(ol),controlOperator:nt(ol),punctuation:X7,separator:nt(X7),bracket:Rg,angleBracket:nt(Rg),squareBracket:nt(Rg),paren:nt(Rg),brace:nt(Rg),content:ul,heading:nd,heading1:nt(nd),heading2:nt(nd),heading3:nt(nd),heading4:nt(nd),heading5:nt(nd),heading6:nt(nd),contentSeparator:nt(ul),list:nt(ul),quote:nt(ul),emphasis:nt(ul),strong:nt(ul),link:nt(ul),monospace:nt(ul),strikethrough:nt(ul),inserted:nt(),deleted:nt(),changed:nt(),invalid:nt(),meta:fw,documentMeta:nt(fw),annotation:nt(fw),processingInstruction:nt(fw),definition:it.defineModifier("definition"),constant:it.defineModifier("constant"),function:it.defineModifier("function"),standard:it.defineModifier("standard"),local:it.defineModifier("local"),special:it.defineModifier("special")};for(let e in _){let t=_[e];t instanceof it&&(t.name=e)}xge([{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 e2;const Bu=new Wt;function o_(e){return ft.define({combine:e?t=>t.concat(e):void 0})}const V8=new Wt;class bo{constructor(t,n,r=[],i=""){this.data=t,this.name=i,jn.prototype.hasOwnProperty("tree")||Object.defineProperty(jn.prototype,"tree",{get(){return In(this)}}),this.parser=n,this.extension=[wO.of(this),jn.languageData.of((a,o,s)=>{let l=hM(a,o,s),c=l.type.prop(Bu);if(!c)return[];let u=a.facet(c),O=l.type.prop(V8);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 hM(t,n,r).type.prop(Bu)==this.data}findRegions(t){let n=t.facet(wO);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(Bu)==this.data){r.push({from:o,to:o+a.length});return}let s=a.prop(Wt.mounted);if(s){if(s.tree.prop(Bu)==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 un&&i(c,a.positions[l]+o)}};return i(In(t),0),r}get allowsNesting(){return!0}}bo.setState=wn.define();function hM(e,t,n){let r=e.facet(wO),i=In(e).topNode;if(!r||r.allowsNesting)for(let a=i;a;a=a.enter(t,n,Jn.ExcludeBuffers))a.type.isTop&&(i=a);return i}class Sn extends bo{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=o_(t.languageData);return new Sn(n,t.parser.configure({props:[Bu.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new Sn(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function In(e){let t=e.field(bo.state,!1);return t?t.tree:un.empty}class Brt{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 Eg=null;class ef{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 ef(t,n,[],un.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Brt(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=un.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(Cc.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(Cc.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=Eg;Eg=this;try{return t()}finally{Eg=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=pM(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=Cc.applyChanges(r,l),i=un.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 ef(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=pM(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 e_{createParse(n,r,i){let a=i[0].from,o=i[i.length-1].to;return{parsedPos:a,advance(){let l=Eg;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 un(si.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 Eg}}function pM(e,t,n){return Cc.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class Zp{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 Zp(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=ef.create(t.facet(wO).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new Zp(r)}}bo.state=Ka.define({create:Zp.init,update(e,t){for(let n of t.effects)if(n.is(bo.setState))return n.value;return t.startState.facet(wO)!=t.state.facet(wO)?Zp.init(t.state):e.apply(t)}});let Sge=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Sge=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const t2=typeof navigator<"u"&&(!((e2=navigator.scheduling)===null||e2===void 0)&&e2.isInputPending)?()=>navigator.scheduling.isInputPending():null,Hrt=mi.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let n=this.view.state.field(bo.state).context;(n.updateViewport(t.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:t}=this.view,n=t.field(bo.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=Sge(this.work))}work(t){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:i}}=this.view,a=r.field(bo.state);if(a.tree==a.context.tree&&a.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!t2?Math.max(25,t.timeRemaining()-5):1e9),s=a.context.treeLen<i&&r.doc.length>i+1e3,l=a.context.work(()=>t2&&t2()||Date.now()>o,i+(s?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:bo.setState.of(new Zp(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=>Da(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()}}}),wO=ft.define({combine(e){return e.length?e[0]:null},enables:e=>[bo.state,Hrt,xt.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class mn{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}class ye{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 ye(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 Krt=ft.define(),s_=ft.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 pS(e){let t=e.facet(s_);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Jrt(e,t){let n="",r=e.tabSize,i=e.facet(s_)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let a=0;a<t;a++)n+=i;return n}function eit(e,t){e instanceof jn&&(e=new Qge(e));for(let r of e.state.facet(Krt)){let i=r(e,t);if(i!==void 0)return i}let n=In(e.state);return n.length>=t?tit(e,n,t):null}class Qge{constructor(t,n={}){this.state=t,this.options=n,this.unit=pS(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 $O(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 Er=new Wt;function tit(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 kge(r,e,n)}function kge(e,t,n){for(let r=e;r;r=r.next){let i=rit(r.node);if(i)return i(M8.create(t,n,r))}return 0}function nit(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function rit(e){let t=e.type.prop(Er);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Wt.closedBy))){let i=e.lastChild,a=i&&r.indexOf(i.name)>-1;return o=>_ge(o,!0,1,void 0,a&&!nit(o)?i.from:void 0)}return e.parent==null?iit:null}function iit(){return 0}class M8 extends Qge{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 M8(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(ait(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return kge(this.context.next,this.base,this.pos)}}function ait(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function oit(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let s=n.to;;){let l=t.childAfter(s);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=o)return null;let c=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+c}}s=l.to}}function ts({closing:e,align:t=!0,units:n=1}){return r=>_ge(r,t,n,e)}function _ge(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?oit(e):null;return l?s?e.column(l.from):e.column(l.to):e.baseIndent+(s?0:e.unit*n)}const L8=e=>e.baseIndent;function Nr({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const sit=200;function $dn(){return jn.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+sit)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=eit(o,u.from);if(O==null)continue;let d=/^\s*/.exec(u.text)[0],h=Jrt(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 Pge=ft.define(),Sr=new Wt;function ua(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 lit(e,t,n){let r=In(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(Sr);if(l&&(s.to<r.length-50||r.length==e.doc.length||!cit(s))){let c=l(s,e);c&&c.from<=n&&c.from>=t&&c.to>n&&(a=c)}}return a}function cit(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function mS(e,t,n){for(let r of e.facet(Pge)){let i=r(e,t,n);if(i)return i}return lit(e,t,n)}function Tge(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 l_=wn.define({map:Tge}),Rv=wn.define({map:Tge});function Xge(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 tf=Ka.define({create(){return on.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(l_)&&!uit(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(qge),i=r?on.replace({widget:new mit(r(t.state,n.value))}):mM;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(Rv)&&(e=e.update({filter:(r,i)=>n.value.from!=r||n.value.to!=i,filterFrom:n.value.from,filterTo:n.value.to}));if(t.selection){let n=!1,{head:r}=t.selection.main;e.between(r,r,(i,a)=>{i<r&&a>r&&(n=!0)}),n&&(e=e.update({filterFrom:r,filterTo:r,filter:(i,a)=>a<=r||i>=r}))}return e},provide:e=>xt.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(r,i)=>{n.push(r,i)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");t.push(mM.range(r,i))}return on.set(t,!0)}});function gS(e,t,n){var r;let i=null;return(r=e.field(tf,!1))===null||r===void 0||r.between(t,n,(a,o)=>{(!i||i.from>a)&&(i={from:a,to:o})}),i}function uit(e,t,n){let r=!1;return e.between(t,t,(i,a)=>{i==t&&a==n&&(r=!0)}),r}function Rge(e,t){return e.field(tf,!1)?t:t.concat(wn.appendConfig.of(jge()))}const Oit=e=>{for(let t of Xge(e)){let n=mS(e.state,t.from,t.to);if(n)return e.dispatch({effects:Rge(e.state,[l_.of(n),Ege(e,n)])}),!0}return!1},dit=e=>{if(!e.state.field(tf,!1))return!1;let t=[];for(let n of Xge(e)){let r=gS(e.state,n.from,n.to);r&&t.push(Rv.of(r),Ege(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function Ege(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return xt.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const fit=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=mS(t,i.from,i.to);a&&n.push(l_.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:Rge(e.state,n)}),!!n.length},hit=e=>{let t=e.state.field(tf,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(Rv.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},ydn=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Oit},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:dit},{key:"Ctrl-Alt-[",run:fit},{key:"Ctrl-Alt-]",run:hit}],pit={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},qge=ft.define({combine(e){return Wm(e,pit)}});function jge(e){return[tf,$it]}function Cge(e,t){let{state:n}=e,r=n.facet(qge),i=o=>{let s=e.lineBlockAt(e.posAtDOM(o.target)),l=gS(e.state,s.from,s.to);l&&e.dispatch({effects:Rv.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 mM=on.replace({widget:new class extends su{toDOM(e){return Cge(e,null)}}});class mit extends su{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Cge(t,this.value)}}const git={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class n2 extends Mc{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 vdn(e={}){let t={...git,...e},n=new n2(t,!0),r=new n2(t,!1),i=mi.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(wO)!=o.state.facet(wO)||o.startState.field(tf,!1)!=o.state.field(tf,!1)||In(o.startState)!=In(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let s=new Bd;for(let l of o.viewportLineBlocks){let c=gS(o.state,l.from,l.to)?r:mS(o.state,l.from,l.to)?n:null;c&&s.add(l.from,l.from,c)}return s.finish()}}),{domEventHandlers:a}=t;return[i,qrt({class:"cm-foldGutter",markers(o){var s;return((s=o.plugin(i))===null||s===void 0?void 0:s.markers)||bn.empty},initialSpacer(){return new n2(t,!1)},domEventHandlers:{...a,click:(o,s,l)=>{if(a.click&&a.click(o,s,l))return!0;let c=gS(o.state,s.from,s.to);if(c)return o.dispatch({effects:Rv.of(c)}),!0;let u=mS(o.state,s.from,s.to);return u?(o.dispatch({effects:l_.of(u)}),!0):!1}}}),jge()]}const $it=xt.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class c_{constructor(t,n){this.specs=t;let r;function i(s){let l=yO.newName();return(r||(r=Object.create(null)))["."+l]=s,l}const a=typeof n.all=="string"?n.all:n.all?i(n.all):void 0,o=n.scope;this.scope=o instanceof bo?s=>s.prop(Bu)==o.data:o?s=>s==o:void 0,this.style=xge(t.map(s=>({tag:s.tag,class:s.class||i(Object.assign({},s,{tag:null}))})),{all:a}).style,this.module=r?new yO(r):null,this.themeType=n.themeType}static define(t,n){return new c_(t,n||{})}}const R7=ft.define(),zge=ft.define({combine(e){return e.length?[e[0]]:null}});function r2(e){let t=e.facet(R7);return t.length?t:e.facet(zge)}function bdn(e,t){let n=[vit],r;return e instanceof c_&&(e.module&&n.push(xt.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(zge.of(e)):r?n.push(R7.computeN([xt.darkTheme],i=>i.facet(xt.darkTheme)==(r=="dark")?[e]:[])):n.push(R7.of(e)),n}class yit{constructor(t){this.markCache=Object.create(null),this.tree=In(t.state),this.decorations=this.buildDeco(t,r2(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=In(t.state),r=r2(t.state),i=r!=r2(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 on.none;let r=new Bd;for(let{from:i,to:a}of t.visibleRanges)Mrt(this.tree,n,(o,s,l)=>{r.add(o,s,this.markCache[l]||(this.markCache[l]=on.mark({class:l})))},i,a);return r.finish()}}const vit=RO.high(mi.fromClass(yit,{decorations:e=>e.decorations})),wdn=c_.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"}]),bit=xt.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Age=1e4,Uge="()[]{}",Wge=ft.define({combine(e){return Wm(e,{afterCursor:!0,brackets:Uge,maxScanDistance:Age,renderMatch:Sit})}}),wit=on.mark({class:"cm-matchingBracket"}),xit=on.mark({class:"cm-nonmatchingBracket"});function Sit(e){let t=[],n=e.matched?wit:xit;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 Qit=Ka.define({create(){return on.none},update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(Wge);for(let i of t.state.selection.ranges){if(!i.empty)continue;let a=hw(t.state,i.head,-1,r)||i.head>0&&hw(t.state,i.head-1,1,r)||r.afterCursor&&(hw(t.state,i.head,1,r)||i.head<t.state.doc.length&&hw(t.state,i.head+1,-1,r));a&&(n=n.concat(r.renderMatch(a,t.state)))}return on.set(n,!0)},provide:e=>xt.decorations.from(e)}),kit=[Qit,bit];function xdn(e={}){return[Wge.of(e),kit]}const F8=new Wt;function E7(e,t,n){let r=e.prop(t<0?Wt.openedBy:Wt.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 q7(e){let t=e.type.prop(F8);return t?t(e.node):e}function hw(e,t,n,r={}){let i=r.maxScanDistance||Age,a=r.brackets||Uge,o=In(e),s=o.resolveInner(t,n);for(let l=s;l;l=l.parent){let c=E7(l.type,n,a);if(c&&l.from<l.to){let u=q7(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return _it(e,t,n,l,u,c,a)}}return Pit(e,t,n,o,s.type,i,a)}function _it(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=q7(u);return{start:l,end:O?{from:O.from,to:O.to}:void 0,matched:!0}}else if(E7(u.type,n,o))c++;else if(E7(u.type,-n,o)){if(c==0){let O=q7(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 Pit(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 gM(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 Nge{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=gM(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:gM(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 Tit(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||Xit,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||H8,mergeTokens:e.mergeTokens!==!1}}function Xit(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 $M=new WeakMap;class We extends bo{constructor(t){let n=o_(t.languageData),r=Tit(t),i,a=new class extends e_{createParse(o,s,l){return new Eit(i,o,s,l)}};super(n,a,[],t.name),this.topNode=Cit(n,this),i=this,this.streamParser=r,this.stateAfter=new Wt({perNode:!0}),this.tokenTable=t.tokenTable?new Ige(r.tokenTable):jit}static define(t){return new We(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=$M.get(t.state),n!=null&&n<t.pos-1e4&&(n=void 0));let i=B8(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 Nge(l.text,t.state.tabSize,t.unit,u<0?void 0:u);for(;O.pos<c-l.from;)Gge(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&&$M.set(t.state,s.from),this.streamParser.indent(o,/^\s*(.*)/.exec(s.text)[1],t)}get allowsNesting(){return!1}}function B8(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 un&&l<i&&B8(e,s,l,r,i);if(c)return c}return null}function Yge(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 un){if(!(l=Yge(e,s,n-o,r-o,i)))break;return i?new un(t.type,t.children.slice(0,a).concat(l),t.positions.slice(0,a+1),o+l.length):l}}return null}function Rit(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&&B8(e,a.tree,0-a.offset,n,s),c;if(l&&l.pos<=r&&(c=Yge(e,a.tree,n+a.offset,l.pos+a.offset,!1)))return{state:l.state,tree:c}}return{state:e.streamParser.startState(i?pS(i):4),tree:un.empty}}let Eit=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=ef.get(),o=i[0].from,{state:s,tree:l}=Rit(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(pS(a.state)),a.skipUntilInView(this.parsedPos,a.viewport.from),this.parsedPos=a.viewport.from),this.moveRangeIndex()}advance(){let t=ef.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==`
876
876
  `&&(n="");else{let r=n.indexOf(`
877
- `);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 Nge(n,t?t.state.tabSize:4,t?pS(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=Gge(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=un.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:qit,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new un(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 un(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Gge(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 H8=Object.create(null),H$=[si.none],qit=new Um(H$),yM=[],vM=Object.create(null),Zge=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"]])Zge[e]=Dge(H8,t);class Ige{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Zge)}resolve(t){return t?this.table[t]||(this.table[t]=Dge(this.extra,t)):0}}const jit=new Ige(H8);function i2(e,t){yM.indexOf(e)>-1||(yM.push(e),console.warn(t))}function Dge(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):i2(c,`Modifier ${c} used at start of tag`):l.length?i2(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:i2(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=vM[i];if(a)return a.id;let o=vM[i]=si.define({id:H$.length,name:r,props:[Tn({[r]:n})]});return H$.push(o),o.id}function Cit(e,t){let n=si.define({id:H$.length,name:"Document",props:[Bu.add(()=>e),Er.add(()=>r=>t.getIndent(r))],top:!0});return H$.push(n),n}br.RTL,br.LTR;function qe(e){return new mn(We.define(e))}function Su(e){return ve(()=>Promise.resolve().then(()=>aht),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const zit=[ye.of({name:"C",extensions:["c","h","ino"],load(){return ve(()=>Promise.resolve().then(()=>OF),void 0,import.meta.url).then(e=>e.cpp())}}),ye.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return ve(()=>Promise.resolve().then(()=>OF),void 0,import.meta.url).then(e=>e.cpp())}}),ye.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Su("Cassandra")}}),ye.of({name:"CSS",extensions:["css"],load(){return ve(()=>Promise.resolve().then(()=>vst),void 0,import.meta.url).then(e=>e.css())}}),ye.of({name:"Go",extensions:["go"],load(){return ve(()=>import("./index-GsdqL7En.js"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url).then(e=>e.go())}}),ye.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return ve(()=>Promise.resolve().then(()=>Olt),void 0,import.meta.url).then(e=>e.html())}}),ye.of({name:"Java",extensions:["java"],load(){return ve(()=>Promise.resolve().then(()=>cht),void 0,import.meta.url).then(e=>e.java())}}),ye.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return ve(()=>Promise.resolve().then(()=>$w),void 0,import.meta.url).then(e=>e.javascript())}}),ye.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return ve(()=>Promise.resolve().then(()=>mct),void 0,import.meta.url).then(e=>e.json())}}),ye.of({name:"JSX",extensions:["jsx"],load(){return ve(()=>Promise.resolve().then(()=>$w),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),ye.of({name:"LESS",extensions:["less"],load(){return ve(()=>Promise.resolve().then(()=>Elt),void 0,import.meta.url).then(e=>e.less())}}),ye.of({name:"Liquid",extensions:["liquid"],load(){return ve(()=>Promise.resolve().then(()=>Lmt),void 0,import.meta.url).then(e=>e.liquid())}}),ye.of({name:"MariaDB SQL",load(){return Su("MariaSQL")}}),ye.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return ve(()=>Promise.resolve().then(()=>blt),void 0,import.meta.url).then(e=>e.markdown())}}),ye.of({name:"MS SQL",load(){return Su("MSSQL")}}),ye.of({name:"MySQL",load(){return Su("MySQL")}}),ye.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return ve(()=>Promise.resolve().then(()=>Qmt),void 0,import.meta.url).then(e=>e.php())}}),ye.of({name:"PLSQL",extensions:["pls"],load(){return Su("PLSQL")}}),ye.of({name:"PostgreSQL",load(){return Su("PostgreSQL")}}),ye.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return ve(()=>Promise.resolve().then(()=>Ldt),void 0,import.meta.url).then(e=>e.python())}}),ye.of({name:"Rust",extensions:["rs"],load(){return ve(()=>Promise.resolve().then(()=>Tht),void 0,import.meta.url).then(e=>e.rust())}}),ye.of({name:"Sass",extensions:["sass"],load(){return ve(()=>Promise.resolve().then(()=>kL),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),ye.of({name:"SCSS",extensions:["scss"],load(){return ve(()=>Promise.resolve().then(()=>kL),void 0,import.meta.url).then(e=>e.sass())}}),ye.of({name:"SQL",extensions:["sql"],load(){return Su("StandardSQL")}}),ye.of({name:"SQLite",load(){return Su("SQLite")}}),ye.of({name:"TSX",extensions:["tsx"],load(){return ve(()=>Promise.resolve().then(()=>$w),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),ye.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return ve(()=>Promise.resolve().then(()=>$w),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),ye.of({name:"WebAssembly",extensions:["wat","wast"],load(){return ve(()=>Promise.resolve().then(()=>Hmt),void 0,import.meta.url).then(e=>e.wast())}}),ye.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return ve(()=>Promise.resolve().then(()=>mft),void 0,import.meta.url).then(e=>e.xml())}}),ye.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return ve(()=>import("./index-CrX6UPbZ.js"),__vite__mapDeps([7,1,2,3,4,5,6]),import.meta.url).then(e=>e.yaml())}}),ye.of({name:"APL",extensions:["dyalog","apl"],load(){return ve(()=>Promise.resolve().then(()=>k$t),void 0,import.meta.url).then(e=>qe(e.apl))}}),ye.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return ve(()=>Promise.resolve().then(()=>_$t),void 0,import.meta.url).then(e=>qe(e.asciiArmor))}}),ye.of({name:"ASN.1",extensions:["asn","asn1"],load(){return ve(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>qe(e.asn1({})))}}),ye.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return ve(()=>Promise.resolve().then(()=>E$t),void 0,import.meta.url).then(e=>qe(e.asterisk))}}),ye.of({name:"Brainfuck",extensions:["b","bf"],load(){return ve(()=>Promise.resolve().then(()=>j$t),void 0,import.meta.url).then(e=>qe(e.brainfuck))}}),ye.of({name:"Cobol",extensions:["cob","cpy"],load(){return ve(()=>Promise.resolve().then(()=>lyt),void 0,import.meta.url).then(e=>qe(e.cobol))}}),ye.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return ve(()=>Promise.resolve().then(()=>od),void 0,import.meta.url).then(e=>qe(e.csharp))}}),ye.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>qe(e.clojure))}}),ye.of({name:"ClojureScript",extensions:["cljs"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>qe(e.clojure))}}),ye.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return ve(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>qe(e.gss))}}),ye.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return ve(()=>Promise.resolve().then(()=>J$t),void 0,import.meta.url).then(e=>qe(e.cmake))}}),ye.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return ve(()=>Promise.resolve().then(()=>byt),void 0,import.meta.url).then(e=>qe(e.coffeeScript))}}),ye.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return ve(()=>Promise.resolve().then(()=>_yt),void 0,import.meta.url).then(e=>qe(e.commonLisp))}}),ye.of({name:"Cypher",extensions:["cyp","cypher"],load(){return ve(()=>Promise.resolve().then(()=>Dyt),void 0,import.meta.url).then(e=>qe(e.cypher))}}),ye.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return ve(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>qe(e.cython))}}),ye.of({name:"Crystal",extensions:["cr"],load(){return ve(()=>Promise.resolve().then(()=>Wyt),void 0,import.meta.url).then(e=>qe(e.crystal))}}),ye.of({name:"D",extensions:["d"],load(){return ve(()=>Promise.resolve().then(()=>Kyt),void 0,import.meta.url).then(e=>qe(e.d))}}),ye.of({name:"Dart",extensions:["dart"],load(){return ve(()=>Promise.resolve().then(()=>od),void 0,import.meta.url).then(e=>qe(e.dart))}}),ye.of({name:"diff",extensions:["diff","patch"],load(){return ve(()=>Promise.resolve().then(()=>Jyt),void 0,import.meta.url).then(e=>qe(e.diff))}}),ye.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return ve(()=>Promise.resolve().then(()=>dvt),void 0,import.meta.url).then(e=>qe(e.dockerFile))}}),ye.of({name:"DTD",extensions:["dtd"],load(){return ve(()=>Promise.resolve().then(()=>pvt),void 0,import.meta.url).then(e=>qe(e.dtd))}}),ye.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return ve(()=>Promise.resolve().then(()=>vvt),void 0,import.meta.url).then(e=>qe(e.dylan))}}),ye.of({name:"EBNF",load(){return ve(()=>Promise.resolve().then(()=>bvt),void 0,import.meta.url).then(e=>qe(e.ebnf))}}),ye.of({name:"ECL",extensions:["ecl"],load(){return ve(()=>Promise.resolve().then(()=>Tvt),void 0,import.meta.url).then(e=>qe(e.ecl))}}),ye.of({name:"edn",extensions:["edn"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>qe(e.clojure))}}),ye.of({name:"Eiffel",extensions:["e"],load(){return ve(()=>Promise.resolve().then(()=>Cvt),void 0,import.meta.url).then(e=>qe(e.eiffel))}}),ye.of({name:"Elm",extensions:["elm"],load(){return ve(()=>Promise.resolve().then(()=>Vvt),void 0,import.meta.url).then(e=>qe(e.elm))}}),ye.of({name:"Erlang",extensions:["erl"],load(){return ve(()=>Promise.resolve().then(()=>mbt),void 0,import.meta.url).then(e=>qe(e.erlang))}}),ye.of({name:"Esper",load(){return ve(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>qe(e.esper))}}),ye.of({name:"Factor",extensions:["factor"],load(){return ve(()=>Promise.resolve().then(()=>gbt),void 0,import.meta.url).then(e=>qe(e.factor))}}),ye.of({name:"FCL",load(){return ve(()=>Promise.resolve().then(()=>wbt),void 0,import.meta.url).then(e=>qe(e.fcl))}}),ye.of({name:"Forth",extensions:["forth","fth","4th"],load(){return ve(()=>Promise.resolve().then(()=>Qbt),void 0,import.meta.url).then(e=>qe(e.forth))}}),ye.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return ve(()=>Promise.resolve().then(()=>Ebt),void 0,import.meta.url).then(e=>qe(e.fortran))}}),ye.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>qe(e.fSharp))}}),ye.of({name:"Gas",extensions:["s"],load(){return ve(()=>Promise.resolve().then(()=>jbt),void 0,import.meta.url).then(e=>qe(e.gas))}}),ye.of({name:"Gherkin",extensions:["feature"],load(){return ve(()=>Promise.resolve().then(()=>Cbt),void 0,import.meta.url).then(e=>qe(e.gherkin))}}),ye.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return ve(()=>Promise.resolve().then(()=>Vbt),void 0,import.meta.url).then(e=>qe(e.groovy))}}),ye.of({name:"Haskell",extensions:["hs"],load(){return ve(()=>Promise.resolve().then(()=>Jbt),void 0,import.meta.url).then(e=>qe(e.haskell))}}),ye.of({name:"Haxe",extensions:["hx"],load(){return ve(()=>Promise.resolve().then(()=>jB),void 0,import.meta.url).then(e=>qe(e.haxe))}}),ye.of({name:"HXML",extensions:["hxml"],load(){return ve(()=>Promise.resolve().then(()=>jB),void 0,import.meta.url).then(e=>qe(e.hxml))}}),ye.of({name:"HTTP",load(){return ve(()=>Promise.resolve().then(()=>wwt),void 0,import.meta.url).then(e=>qe(e.http))}}),ye.of({name:"IDL",extensions:["pro"],load(){return ve(()=>Promise.resolve().then(()=>Twt),void 0,import.meta.url).then(e=>qe(e.idl))}}),ye.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return ve(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>qe(e.jsonld))}}),ye.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return ve(()=>Promise.resolve().then(()=>qwt),void 0,import.meta.url).then(e=>qe(e.jinja2))}}),ye.of({name:"Julia",extensions:["jl"],load(){return ve(()=>Promise.resolve().then(()=>i1t),void 0,import.meta.url).then(e=>qe(e.julia))}}),ye.of({name:"Kotlin",extensions:["kt","kts"],load(){return ve(()=>Promise.resolve().then(()=>od),void 0,import.meta.url).then(e=>qe(e.kotlin))}}),ye.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return ve(()=>Promise.resolve().then(()=>l1t),void 0,import.meta.url).then(e=>qe(e.liveScript))}}),ye.of({name:"Lua",extensions:["lua"],load(){return ve(()=>Promise.resolve().then(()=>m1t),void 0,import.meta.url).then(e=>qe(e.lua))}}),ye.of({name:"mIRC",extensions:["mrc"],load(){return ve(()=>Promise.resolve().then(()=>W1t),void 0,import.meta.url).then(e=>qe(e.mirc))}}),ye.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return ve(()=>Promise.resolve().then(()=>S1t),void 0,import.meta.url).then(e=>qe(e.mathematica))}}),ye.of({name:"Modelica",extensions:["mo"],load(){return ve(()=>Promise.resolve().then(()=>F1t),void 0,import.meta.url).then(e=>qe(e.modelica))}}),ye.of({name:"MUMPS",extensions:["mps"],load(){return ve(()=>Promise.resolve().then(()=>Oxt),void 0,import.meta.url).then(e=>qe(e.mumps))}}),ye.of({name:"Mbox",extensions:["mbox"],load(){return ve(()=>Promise.resolve().then(()=>z1t),void 0,import.meta.url).then(e=>qe(e.mbox))}}),ye.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return ve(()=>Promise.resolve().then(()=>mxt),void 0,import.meta.url).then(e=>qe(e.nginx))}}),ye.of({name:"NSIS",extensions:["nsh","nsi"],load(){return ve(()=>Promise.resolve().then(()=>gxt),void 0,import.meta.url).then(e=>qe(e.nsis))}}),ye.of({name:"NTriples",extensions:["nt","nq"],load(){return ve(()=>Promise.resolve().then(()=>$xt),void 0,import.meta.url).then(e=>qe(e.ntriples))}}),ye.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return ve(()=>Promise.resolve().then(()=>od),void 0,import.meta.url).then(e=>qe(e.objectiveC))}}),ye.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return ve(()=>Promise.resolve().then(()=>od),void 0,import.meta.url).then(e=>qe(e.objectiveCpp))}}),ye.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>qe(e.oCaml))}}),ye.of({name:"Octave",extensions:["m"],load(){return ve(()=>Promise.resolve().then(()=>Txt),void 0,import.meta.url).then(e=>qe(e.octave))}}),ye.of({name:"Oz",extensions:["oz"],load(){return ve(()=>Promise.resolve().then(()=>Yxt),void 0,import.meta.url).then(e=>qe(e.oz))}}),ye.of({name:"Pascal",extensions:["p","pas"],load(){return ve(()=>Promise.resolve().then(()=>Mxt),void 0,import.meta.url).then(e=>qe(e.pascal))}}),ye.of({name:"Perl",extensions:["pl","pm"],load(){return ve(()=>Promise.resolve().then(()=>Lxt),void 0,import.meta.url).then(e=>qe(e.perl))}}),ye.of({name:"Pig",extensions:["pig"],load(){return ve(()=>Promise.resolve().then(()=>Hxt),void 0,import.meta.url).then(e=>qe(e.pig))}}),ye.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return ve(()=>Promise.resolve().then(()=>fSt),void 0,import.meta.url).then(e=>qe(e.powerShell))}}),ye.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return ve(()=>Promise.resolve().then(()=>hSt),void 0,import.meta.url).then(e=>qe(e.properties))}}),ye.of({name:"ProtoBuf",extensions:["proto"],load(){return ve(()=>Promise.resolve().then(()=>ySt),void 0,import.meta.url).then(e=>qe(e.protobuf))}}),ye.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return ve(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([8,9]),import.meta.url).then(e=>qe(e.pug))}}),ye.of({name:"Puppet",extensions:["pp"],load(){return ve(()=>Promise.resolve().then(()=>wSt),void 0,import.meta.url).then(e=>qe(e.puppet))}}),ye.of({name:"Q",extensions:["q"],load(){return ve(()=>Promise.resolve().then(()=>XSt),void 0,import.meta.url).then(e=>qe(e.q))}}),ye.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return ve(()=>Promise.resolve().then(()=>ASt),void 0,import.meta.url).then(e=>qe(e.r))}}),ye.of({name:"RPM Changes",load(){return ve(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>qe(e.rpmChanges))}}),ye.of({name:"RPM Spec",extensions:["spec"],load(){return ve(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>qe(e.rpmSpec))}}),ye.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return ve(()=>Promise.resolve().then(()=>VSt),void 0,import.meta.url).then(e=>qe(e.ruby))}}),ye.of({name:"SAS",extensions:["sas"],load(){return ve(()=>Promise.resolve().then(()=>BSt),void 0,import.meta.url).then(e=>qe(e.sas))}}),ye.of({name:"Scala",extensions:["scala"],load(){return ve(()=>Promise.resolve().then(()=>od),void 0,import.meta.url).then(e=>qe(e.scala))}}),ye.of({name:"Scheme",extensions:["scm","ss"],load(){return ve(()=>Promise.resolve().then(()=>cQt),void 0,import.meta.url).then(e=>qe(e.scheme))}}),ye.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return ve(()=>Promise.resolve().then(()=>fQt),void 0,import.meta.url).then(e=>qe(e.shell))}}),ye.of({name:"Sieve",extensions:["siv","sieve"],load(){return ve(()=>Promise.resolve().then(()=>$Qt),void 0,import.meta.url).then(e=>qe(e.sieve))}}),ye.of({name:"Smalltalk",extensions:["st"],load(){return ve(()=>Promise.resolve().then(()=>bQt),void 0,import.meta.url).then(e=>qe(e.smalltalk))}}),ye.of({name:"Solr",load(){return ve(()=>Promise.resolve().then(()=>PQt),void 0,import.meta.url).then(e=>qe(e.solr))}}),ye.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>qe(e.sml))}}),ye.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return ve(()=>Promise.resolve().then(()=>CQt),void 0,import.meta.url).then(e=>qe(e.sparql))}}),ye.of({name:"Spreadsheet",alias:["excel","formula"],load(){return ve(()=>Promise.resolve().then(()=>zQt),void 0,import.meta.url).then(e=>qe(e.spreadsheet))}}),ye.of({name:"Squirrel",extensions:["nut"],load(){return ve(()=>Promise.resolve().then(()=>od),void 0,import.meta.url).then(e=>qe(e.squirrel))}}),ye.of({name:"Stylus",extensions:["styl"],load(){return ve(()=>Promise.resolve().then(()=>ikt),void 0,import.meta.url).then(e=>qe(e.stylus))}}),ye.of({name:"Swift",extensions:["swift"],load(){return ve(()=>Promise.resolve().then(()=>Skt),void 0,import.meta.url).then(e=>qe(e.swift))}}),ye.of({name:"sTeX",load(){return ve(()=>Promise.resolve().then(()=>QH),void 0,import.meta.url).then(e=>qe(e.stex))}}),ye.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return ve(()=>Promise.resolve().then(()=>QH),void 0,import.meta.url).then(e=>qe(e.stex))}}),ye.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return ve(()=>Promise.resolve().then(()=>DH),void 0,import.meta.url).then(e=>qe(e.verilog))}}),ye.of({name:"Tcl",extensions:["tcl"],load(){return ve(()=>Promise.resolve().then(()=>Pkt),void 0,import.meta.url).then(e=>qe(e.tcl))}}),ye.of({name:"Textile",extensions:["textile"],load(){return ve(()=>Promise.resolve().then(()=>Ekt),void 0,import.meta.url).then(e=>qe(e.textile))}}),ye.of({name:"TiddlyWiki",load(){return ve(()=>Promise.resolve().then(()=>Jkt),void 0,import.meta.url).then(e=>qe(e.tiddlyWiki))}}),ye.of({name:"Tiki wiki",load(){return ve(()=>Promise.resolve().then(()=>o_t),void 0,import.meta.url).then(e=>qe(e.tiki))}}),ye.of({name:"TOML",extensions:["toml"],load(){return ve(()=>Promise.resolve().then(()=>s_t),void 0,import.meta.url).then(e=>qe(e.toml))}}),ye.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return ve(()=>Promise.resolve().then(()=>u_t),void 0,import.meta.url).then(e=>qe(e.troff))}}),ye.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return ve(()=>Promise.resolve().then(()=>P_t),void 0,import.meta.url).then(e=>qe(e.ttcn))}}),ye.of({name:"TTCN_CFG",extensions:["cfg"],load(){return ve(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>qe(e.ttcnCfg))}}),ye.of({name:"Turtle",extensions:["ttl"],load(){return ve(()=>Promise.resolve().then(()=>R_t),void 0,import.meta.url).then(e=>qe(e.turtle))}}),ye.of({name:"Web IDL",extensions:["webidl"],load(){return ve(()=>Promise.resolve().then(()=>SPt),void 0,import.meta.url).then(e=>qe(e.webIDL))}}),ye.of({name:"VB.NET",extensions:["vb"],load(){return ve(()=>Promise.resolve().then(()=>V_t),void 0,import.meta.url).then(e=>qe(e.vb))}}),ye.of({name:"VBScript",extensions:["vbs"],load(){return ve(()=>Promise.resolve().then(()=>L_t),void 0,import.meta.url).then(e=>qe(e.vbScript))}}),ye.of({name:"Velocity",extensions:["vtl"],load(){return ve(()=>Promise.resolve().then(()=>H_t),void 0,import.meta.url).then(e=>qe(e.velocity))}}),ye.of({name:"Verilog",extensions:["v"],load(){return ve(()=>Promise.resolve().then(()=>DH),void 0,import.meta.url).then(e=>qe(e.verilog))}}),ye.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return ve(()=>Promise.resolve().then(()=>oPt),void 0,import.meta.url).then(e=>qe(e.vhdl))}}),ye.of({name:"XQuery",extensions:["xy","xquery"],load(){return ve(()=>Promise.resolve().then(()=>jPt),void 0,import.meta.url).then(e=>qe(e.xQuery))}}),ye.of({name:"Yacas",extensions:["ys"],load(){return ve(()=>Promise.resolve().then(()=>IPt),void 0,import.meta.url).then(e=>qe(e.yacas))}}),ye.of({name:"Z80",extensions:["z80"],load(){return ve(()=>Promise.resolve().then(()=>FPt),void 0,import.meta.url).then(e=>qe(e.z80))}}),ye.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return ve(()=>Promise.resolve().then(()=>uX),void 0,import.meta.url).then(e=>qe(e.mscgen))}}),ye.of({name:"Xù",extensions:["xu"],load(){return ve(()=>Promise.resolve().then(()=>uX),void 0,import.meta.url).then(e=>qe(e.xu))}}),ye.of({name:"MsGenny",extensions:["msgenny"],load(){return ve(()=>Promise.resolve().then(()=>uX),void 0,import.meta.url).then(e=>qe(e.msgenny))}}),ye.of({name:"Vue",extensions:["vue"],load(){return ve(()=>Promise.resolve().then(()=>agt),void 0,import.meta.url).then(e=>e.vue())}}),ye.of({name:"Angular Template",load(){return ve(()=>Promise.resolve().then(()=>Sgt),void 0,import.meta.url).then(e=>e.angular())}})];class K8{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=In(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(Vge(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 bM(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 Ait(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=bM(t)+bM(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Ev(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:Ait(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function u_(e,t){return n=>{for(let r=In(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 wM{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function Cd(e){return e.selection.main.from}function Vge(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 J8=kf.define();function Uit(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:De.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const xM=new WeakMap;function Wit(e){if(!Array.isArray(e))return e;let t=xM.get(e);return t||xM.set(e,t=Ev(e)),t}const $S=wn.define(),K$=wn.define();class Nit{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<t.length;){let r=mo(t,n),i=vc(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(mo(o==a?a.toLowerCase():o,0)),n+=i}this.astral=t.length!=this.chars.length}ret(t,n){return this.score=t,this.matched=n,this}match(t){if(this.pattern.length==0)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:n,folded:r,any:i,precise:a,byWord:o}=this;if(n.length==1){let b=mo(t,0),x=vc(b),Q=x==t.length?0:-100;if(b!=n[0])if(b==r[0])Q+=-200;else return null;return this.ret(Q,[0,x])}let s=t.indexOf(this.pattern);if(s==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(s<0){for(let b=0,x=Math.min(t.length,200);b<x&&c<l;){let Q=mo(t,b);(Q==n[c]||Q==r[c])&&(i[c++]=b),b+=vc(Q)}if(c<l)return null}let u=0,O=0,d=!1,h=0,p=-1,g=-1,y=/[a-z]/.test(t),v=!0;for(let b=0,x=Math.min(t.length,200),Q=0;b<x&&O<l;){let w=mo(t,b);s<0&&(u<l&&w==n[u]&&(a[u++]=b),h<l&&(w==n[h]||w==r[h]?(h==0&&(p=b),g=b+1,h++):h=0));let S,k=w<255?w>=48&&w<=57||w>=97&&w<=122?2:w>=65&&w<=90?1:0:(S=rme(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+=vc(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?vc(mo(r,o)):1);a&&i[a-1]==o?i[a-1]=s:(i[a++]=o,i[a++]=s)}return this.ret(t-r.length,i)}}class Yit{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 Ei=ft.define({combine(e){return Wm(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:Git,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=>SM(t(r),n(r)),optionClass:(t,n)=>r=>SM(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function SM(e,t){return e?t?e+" "+t:e:t}function Git(e,t,n,r,i,a){let o=e.textDirection==br.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 Zit(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 a2(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 Iit{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(Ei);this.optionContent=Zit(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=a2(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(Ei).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:K$.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=a2(a.length,o,t.state.facet(Ei).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=a2(n.options.length,n.selected,this.view.state.facet(Ei).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=>Da(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&&Vit(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(Ei).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 Dit(e,t){return n=>new Iit(n,e,t)}function Vit(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 QM(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Mit(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(Ei);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 wM(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,h=a.filterStrict?new Yit(O):new Nit(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 wM(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):QM(c.completion)>QM(s)&&(o[o.length-1]=c),s=c.completion}return o}class Mh{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 Mh(this.options,kM(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=Mit(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Ei).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 Mh(s,kM(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:Jit,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new Mh(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 Mh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class yS{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new yS(Hit,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Ei),a=(r.override||n.languageDataAt("autocomplete",Cd(n)).map(Wit)).map(l=>(this.active.find(u=>u.source==l)||new Bo(l,this.active.some(u=>u.state!=0)?1:0)).update(t,r));a.length==this.active.length&&a.every((l,c)=>l==this.active[c])&&(a=this.active);let o=this.open,s=t.effects.some(l=>l.is(eU));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Lit(a,this.active)||s?o=Mh.build(a,n,this.id,o,r,s):o&&o.disabled&&!a.some(l=>l.isPending)&&(o=null),!o&&a.every(l=>!l.isPending)&&a.some(l=>l.hasResult())&&(a=a.map(l=>l.hasResult()?new Bo(l.source,0):l));for(let l of t.effects)l.is(Lge)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new yS(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Fit:Bit}}function Lit(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 Fit={"aria-autocomplete":"list"},Bit={};function kM(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Hit=[];function Mge(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(J8);if(r&&t.activateOnCompletion(r))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class Bo{constructor(t,n,r=!1){this.source=t,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=Mge(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new Bo(i.source,0)),r&4&&i.state==0&&(i=new Bo(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is($S))i=new Bo(i.source,1,a.value);else if(a.is(K$))i=new Bo(i.source,0);else if(a.is(eU))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(Cd(t.state))}}class cp extends Bo{constructor(t,n,r,i,a,o){super(t,3,n),this.limit=r,this.result=i,this.from=a,this.to=o}hasResult(){return!0}updateFor(t,n){var r;if(!(n&3))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let a=t.changes.mapPos(this.from),o=t.changes.mapPos(this.to,1),s=Cd(t.state);if(s>o||!i||n&2&&(Cd(t.startState)==this.from||s<this.limit))return new Bo(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return Kit(i.validFor,t.state,a,o)?new cp(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new K8(t.state,s,!1)))?new cp(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:Cd(t.state)):new Bo(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new cp(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new Bo(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Kit(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Vge(e,!0).test(i)}const eU=wn.define({map(e,t){return e.map(n=>n.map(t))}}),Lge=wn.define(),Ya=Ka.define({create(){return yS.start()},update(e,t){return e.update(t)},provide:e=>[D8.from(e,t=>t.tooltip),xt.contentAttributes.from(e,t=>t.attrs)]});function tU(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ya).active.find(i=>i.source==t.source);return r instanceof cp?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},Uit(e.state,n,r.from,r.to)),{annotations:J8.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const Jit=Dit(Ya,tU);function pw(e,t="option"){return n=>{let r=n.state.field(Ya,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ei).interactionDelay)return!1;let i=1,a;t=="page"&&(a=$ge(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:Lge.of(s)}),!0}}const eat=e=>{let t=e.state.field(Ya,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ei).interactionDelay?!1:tU(e,t.open.options[t.open.selected])},_M=e=>e.state.field(Ya,!1)?(e.dispatch({effects:$S.of(!0)}),!0):!1,tat=e=>{let t=e.state.field(Ya,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:K$.of(null)}),!0)};class nat{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const rat=50,iat=1e3,aat=mi.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(Ya).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ya),n=e.state.facet(Ei);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ya)==t)return;let r=e.transactions.some(a=>{let o=Mge(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>rat&&Date.now()-o.time>iat){for(let s of o.context.abortListeners)try{s()}catch(l){Da(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($S)))&&(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(Ya);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(Ei).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=Cd(t),r=new K8(t,n,e.explicit,this.view),i=new nat(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:K$.of(null)}),Da(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(Ei).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Ei),r=this.view.state.field(Ya);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=Cd(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new cp(a.active.source,a.active.explicit,l,a.done,a.done.from,(e=a.done.to)!==null&&e!==void 0?e:s);for(let u of a.updates)c=c.update(u,n);if(c.hasResult()){t.push(c);continue}}let o=r.active.find(s=>s.source==a.active.source);if(o&&o.isPending)if(a.done==null){let s=new Bo(a.active.source,0);for(let l of a.updates)s=s.update(l,n);s.isPending||t.push(s)}else this.startQuery(o)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:eU.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ya,!1);if(t&&t.tooltip&&this.view.state.facet(Ei).closeOnBlur){let n=t.open&&$ge(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:K$.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:$S.of(!1)}),20),this.composing=0}}}),oat=typeof navigator=="object"&&/Win/.test(navigator.platform),sat=RO.highest(xt.domEventHandlers({keydown(e,t){let n=t.state.field(Ya,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(oat&&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&&tU(t,r),!1}})),Fge=xt.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class lat{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class nU{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Ii.TrackDel),r=t.mapPos(this.to,1,Ii.TrackDel);return n==null||r==null?null:new nU(this.field,n,r)}}class rU{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(s_);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 nU(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 lat(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 rU(r,i)}}let cat=on.widget({widget:new class extends su{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),uat=on.mark({class:"cm-snippetField"});class Nm{constructor(t,n){this.ranges=t,this.active=n,this.deco=on.set(t.map(r=>(r.from==r.to?cat:uat).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 Nm(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 qv=wn.define({map(e,t){return e&&e.map(t)}}),Oat=wn.define(),J$=Ka.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(qv))return n.value;if(n.is(Oat)&&e)return new Nm(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>xt.decorations.from(e,t=>t?t.deco:on.none)});function iU(e,t){return De.create(e.filter(n=>n.field==t).map(n=>De.range(n.from,n.to)))}function dat(e){let t=rU.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:Gn.of(o)},scrollIntoView:!0,annotations:r?[J8.of(r),Di.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=iU(s,0)),s.some(u=>u.field>0)){let u=new Nm(s,0),O=c.effects=[qv.of(u)];n.state.field(J$,!1)===void 0&&O.push(wn.appendConfig.of([J$,gat,$at,Fge]))}n.dispatch(n.state.update(c))}}function Bge(e){return({state:t,dispatch:n})=>{let r=t.field(J$,!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:iU(r.ranges,i),effects:qv.of(a?null:new Nm(r.ranges,i)),scrollIntoView:!0})),!0}}const fat=({state:e,dispatch:t})=>e.field(J$,!1)?(t(e.update({effects:qv.of(null)})),!0):!1,hat=Bge(1),pat=Bge(-1),mat=[{key:"Tab",run:hat,shift:pat},{key:"Escape",run:fat}],PM=ft.define({combine(e){return e.length?e[0]:mat}}),gat=RO.highest(i_.compute([PM],e=>e.facet(PM)));function Or(e,t){return Object.assign(Object.assign({},t),{apply:dat(e)})}const $at=xt.domEventHandlers({mousedown(e,t){let n=t.state.field(J$,!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:iU(n.ranges,i.field),effects:qv.of(n.ranges.some(a=>a.field>i.field)?new Nm(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),ey={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Qd=wn.define({map(e,t){let n=t.mapPos(e,-1,Ii.TrackAfter);return n??void 0}}),aU=new class extends Fd{};aU.startSide=1;aU.endSide=-1;const Hge=Ka.define({create(){return bn.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(Qd)&&(e=e.update({add:[aU.range(n.value,n.value+1)]}));return e}});function Qdn(){return[vat,Hge]}const o2="()[]{}<>«»»«[]{}";function Kge(e){for(let t=0;t<o2.length;t+=2)if(o2.charCodeAt(t)==e)return o2.charAt(t+1);return rme(e<128?e:e+1)}function Jge(e,t){return e.languageDataAt("closeBrackets",t)[0]||ey}const yat=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),vat=xt.inputHandler.of((e,t,n,r)=>{if((yat?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&vc(mo(r,0))==1||t!=i.from||n!=i.to)return!1;let a=wat(e.state,r);return a?(e.dispatch(a),!0):!1}),bat=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Jge(e,e.selection.main.head).brackets||ey.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=xat(e.doc,o.head);for(let l of r)if(l==s&&O_(e.doc,o.head)==Kge(mo(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:De.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},kdn=[{key:"Backspace",run:bat}];function wat(e,t){let n=Jge(e,e.selection.main.head),r=n.brackets||ey.brackets;for(let i of r){let a=Kge(mo(i,0));if(t==i)return a==i?kat(e,i,r.indexOf(i+i+i)>-1,n):Sat(e,i,a,n.before||ey.before);if(t==a&&e0e(e,e.selection.main.from))return Qat(e,i,a)}return null}function e0e(e,t){let n=!1;return e.field(Hge).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function O_(e,t){let n=e.sliceString(t,t+2);return n.slice(0,vc(mo(n,0)))}function xat(e,t){let n=e.sliceString(t-2,t);return vc(mo(n,0))==n.length?n:n.slice(1)}function Sat(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:Qd.of(o.to+t.length),range:De.range(o.anchor+t.length,o.head+t.length)};let s=O_(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:Qd.of(o.head+t.length),range:De.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function Qat(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&O_(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:De.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function kat(e,t,n,r){let i=r.stringPrefixes||ey.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:Qd.of(s.to+t.length),range:De.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=O_(e.doc,l),u;if(c==t){if(TM(e,l))return{changes:{insert:t+t,from:l},effects:Qd.of(l+t.length),range:De.cursor(l+t.length)};if(e0e(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:De.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=XM(e,l-2*t.length,i))>-1&&TM(e,u))return{changes:{insert:t+t+t+t,from:l},effects:Qd.of(l+t.length),range:De.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=Fo.Word&&XM(e,l,i)>-1&&!_at(e,l,t,i))return{changes:{insert:t+t,from:l},effects:Qd.of(l+t.length),range:De.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function TM(e,t){let n=In(e).resolveInner(t+1);return n.parent&&n.from==t}function _at(e,t,n,r){let i=In(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 XM(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=Fo.Word)return t;for(let i of n){let a=t-i.length;if(e.sliceDoc(a,t)==i&&r(e.sliceDoc(a-1,a))!=Fo.Word)return a}return-1}function _dn(e={}){return[sat,Ya,Ei.of(e),aat,Tat,Fge]}const Pat=[{key:"Ctrl-Space",run:_M},{mac:"Alt-`",run:_M},{key:"Escape",run:tat},{key:"ArrowDown",run:pw(!0)},{key:"ArrowUp",run:pw(!1)},{key:"PageDown",run:pw(!0,"page")},{key:"PageUp",run:pw(!1,"page")},{key:"Enter",run:eat}],Tat=RO.highest(i_.computeN([Ei],e=>e.facet(Ei).defaultKeymap?[Pat]:[]));class vS{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new vS(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=[[Wt.contextHash,i]]}addChild(t,n){t.prop(Wt.contextHash)!=this.hash&&(t=new un(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 un(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new un(si.none,i,a,o,this.hashProp)})}}var Ve;(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"})(Ve||(Ve={}));class Xat{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let Rat=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 n$(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 RM(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==Ve.OrderedList?lU:sU)(n,t,!1);return r>0&&(e.type!=Ve.BulletList||oU(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const t0e={[Ve.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(pn(Ve.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(Os(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[Ve.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Ve.OrderedList]:RM,[Ve.BulletList]:RM,[Ve.Document](){return!0}};function Os(e){return e==32||e==9||e==10||e==13}function n$(e,t=0){for(;t<e.length&&Os(e.charCodeAt(t));)t++;return t}function EM(e,t,n){for(;t>n&&Os(e.charCodeAt(t-1));)t--;return t}function n0e(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 r0e(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function oU(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let i=e.pos+1;i<e.text.length;i++){let a=e.text.charCodeAt(i);if(a==e.next)r++;else if(!Os(a))return-1}return n&&e.next==45&&o0e(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(u0e.SetextHeading)>-1||r<3?-1:1}function i0e(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function sU(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||Os(e.text.charCodeAt(e.pos+1)))&&(!n||i0e(t,Ve.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function lU(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){r++;if(r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!Os(e.text.charCodeAt(r+1))||n&&!i0e(t,Ve.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function a0e(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 o0e(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&Os(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const j7=/^[ \t]*$/,s0e=/-->/,l0e=/\?>/,C7=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,s0e],[/^\s*<\?/,l0e],[/^\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,j7],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,j7]];function c0e(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=C7.length-(n?1:0);i<a;i++)if(C7[i][0].test(r))return i;return-1}function qM(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 rd(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Ve.CodeText?e[r].to=n:e.push(pn(Ve.CodeText,t,n))}const mw={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(rd(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){rd(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==Ve.CodeText?rd(o,c.from,c.to):o.push(c);s=[]}rd(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&&rd(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=Ve.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Ve.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=n0e(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=EM(t.text,t.text.length,o),l=[pn(Ve.CodeMark,r,r+a)];o<s&&l.push(pn(Ve.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(pn(Ve.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||rd(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&&rd(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Ve.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=r0e(t);return n<0?!1:(e.startContext(Ve.Blockquote,t.pos),e.addNode(Ve.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(oU(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Ve.HorizontalRule,n),!0},BulletList(e,t){let n=sU(t,e,!1);if(n<0)return!1;e.block.type!=Ve.BulletList&&e.startContext(Ve.BulletList,t.basePos,t.next);let r=qM(t,t.pos+1);return e.startContext(Ve.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ve.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=lU(t,e,!1);if(n<0)return!1;e.block.type!=Ve.OrderedList&&e.startContext(Ve.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=qM(t,t.pos+n);return e.startContext(Ve.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ve.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=a0e(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=EM(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!Os(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(Ve.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Ve.HeaderMark,o-r,a-r);let l=s.finish(Ve.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=c0e(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=C7[n][1],a=[],o=i!=j7;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==s0e?Ve.CommentBlock:i==l0e?Ve.ProcessingInstructionBlock:Ve.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class Eat{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+`
877
+ `);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 Nge(n,t?t.state.tabSize:4,t?pS(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=Gge(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=un.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:qit,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new un(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 un(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Gge(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 H8=Object.create(null),H$=[si.none],qit=new Um(H$),yM=[],vM=Object.create(null),Zge=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"]])Zge[e]=Dge(H8,t);class Ige{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Zge)}resolve(t){return t?this.table[t]||(this.table[t]=Dge(this.extra,t)):0}}const jit=new Ige(H8);function i2(e,t){yM.indexOf(e)>-1||(yM.push(e),console.warn(t))}function Dge(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):i2(c,`Modifier ${c} used at start of tag`):l.length?i2(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:i2(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=vM[i];if(a)return a.id;let o=vM[i]=si.define({id:H$.length,name:r,props:[Tn({[r]:n})]});return H$.push(o),o.id}function Cit(e,t){let n=si.define({id:H$.length,name:"Document",props:[Bu.add(()=>e),Er.add(()=>r=>t.getIndent(r))],top:!0});return H$.push(n),n}br.RTL,br.LTR;function qe(e){return new mn(We.define(e))}function Su(e){return ve(()=>Promise.resolve().then(()=>aht),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const zit=[ye.of({name:"C",extensions:["c","h","ino"],load(){return ve(()=>Promise.resolve().then(()=>OF),void 0,import.meta.url).then(e=>e.cpp())}}),ye.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return ve(()=>Promise.resolve().then(()=>OF),void 0,import.meta.url).then(e=>e.cpp())}}),ye.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Su("Cassandra")}}),ye.of({name:"CSS",extensions:["css"],load(){return ve(()=>Promise.resolve().then(()=>vst),void 0,import.meta.url).then(e=>e.css())}}),ye.of({name:"Go",extensions:["go"],load(){return ve(()=>import("./index-CuD9ABIl.js"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url).then(e=>e.go())}}),ye.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return ve(()=>Promise.resolve().then(()=>Olt),void 0,import.meta.url).then(e=>e.html())}}),ye.of({name:"Java",extensions:["java"],load(){return ve(()=>Promise.resolve().then(()=>cht),void 0,import.meta.url).then(e=>e.java())}}),ye.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return ve(()=>Promise.resolve().then(()=>$w),void 0,import.meta.url).then(e=>e.javascript())}}),ye.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return ve(()=>Promise.resolve().then(()=>mct),void 0,import.meta.url).then(e=>e.json())}}),ye.of({name:"JSX",extensions:["jsx"],load(){return ve(()=>Promise.resolve().then(()=>$w),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),ye.of({name:"LESS",extensions:["less"],load(){return ve(()=>Promise.resolve().then(()=>Elt),void 0,import.meta.url).then(e=>e.less())}}),ye.of({name:"Liquid",extensions:["liquid"],load(){return ve(()=>Promise.resolve().then(()=>Lmt),void 0,import.meta.url).then(e=>e.liquid())}}),ye.of({name:"MariaDB SQL",load(){return Su("MariaSQL")}}),ye.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return ve(()=>Promise.resolve().then(()=>blt),void 0,import.meta.url).then(e=>e.markdown())}}),ye.of({name:"MS SQL",load(){return Su("MSSQL")}}),ye.of({name:"MySQL",load(){return Su("MySQL")}}),ye.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return ve(()=>Promise.resolve().then(()=>Qmt),void 0,import.meta.url).then(e=>e.php())}}),ye.of({name:"PLSQL",extensions:["pls"],load(){return Su("PLSQL")}}),ye.of({name:"PostgreSQL",load(){return Su("PostgreSQL")}}),ye.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return ve(()=>Promise.resolve().then(()=>Ldt),void 0,import.meta.url).then(e=>e.python())}}),ye.of({name:"Rust",extensions:["rs"],load(){return ve(()=>Promise.resolve().then(()=>Tht),void 0,import.meta.url).then(e=>e.rust())}}),ye.of({name:"Sass",extensions:["sass"],load(){return ve(()=>Promise.resolve().then(()=>kL),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),ye.of({name:"SCSS",extensions:["scss"],load(){return ve(()=>Promise.resolve().then(()=>kL),void 0,import.meta.url).then(e=>e.sass())}}),ye.of({name:"SQL",extensions:["sql"],load(){return Su("StandardSQL")}}),ye.of({name:"SQLite",load(){return Su("SQLite")}}),ye.of({name:"TSX",extensions:["tsx"],load(){return ve(()=>Promise.resolve().then(()=>$w),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),ye.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return ve(()=>Promise.resolve().then(()=>$w),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),ye.of({name:"WebAssembly",extensions:["wat","wast"],load(){return ve(()=>Promise.resolve().then(()=>Hmt),void 0,import.meta.url).then(e=>e.wast())}}),ye.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return ve(()=>Promise.resolve().then(()=>mft),void 0,import.meta.url).then(e=>e.xml())}}),ye.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return ve(()=>import("./index-BmvRznQC.js"),__vite__mapDeps([7,1,2,3,4,5,6]),import.meta.url).then(e=>e.yaml())}}),ye.of({name:"APL",extensions:["dyalog","apl"],load(){return ve(()=>Promise.resolve().then(()=>k$t),void 0,import.meta.url).then(e=>qe(e.apl))}}),ye.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return ve(()=>Promise.resolve().then(()=>_$t),void 0,import.meta.url).then(e=>qe(e.asciiArmor))}}),ye.of({name:"ASN.1",extensions:["asn","asn1"],load(){return ve(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>qe(e.asn1({})))}}),ye.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return ve(()=>Promise.resolve().then(()=>E$t),void 0,import.meta.url).then(e=>qe(e.asterisk))}}),ye.of({name:"Brainfuck",extensions:["b","bf"],load(){return ve(()=>Promise.resolve().then(()=>j$t),void 0,import.meta.url).then(e=>qe(e.brainfuck))}}),ye.of({name:"Cobol",extensions:["cob","cpy"],load(){return ve(()=>Promise.resolve().then(()=>lyt),void 0,import.meta.url).then(e=>qe(e.cobol))}}),ye.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return ve(()=>Promise.resolve().then(()=>od),void 0,import.meta.url).then(e=>qe(e.csharp))}}),ye.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>qe(e.clojure))}}),ye.of({name:"ClojureScript",extensions:["cljs"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>qe(e.clojure))}}),ye.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return ve(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>qe(e.gss))}}),ye.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return ve(()=>Promise.resolve().then(()=>J$t),void 0,import.meta.url).then(e=>qe(e.cmake))}}),ye.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return ve(()=>Promise.resolve().then(()=>byt),void 0,import.meta.url).then(e=>qe(e.coffeeScript))}}),ye.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return ve(()=>Promise.resolve().then(()=>_yt),void 0,import.meta.url).then(e=>qe(e.commonLisp))}}),ye.of({name:"Cypher",extensions:["cyp","cypher"],load(){return ve(()=>Promise.resolve().then(()=>Dyt),void 0,import.meta.url).then(e=>qe(e.cypher))}}),ye.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return ve(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>qe(e.cython))}}),ye.of({name:"Crystal",extensions:["cr"],load(){return ve(()=>Promise.resolve().then(()=>Wyt),void 0,import.meta.url).then(e=>qe(e.crystal))}}),ye.of({name:"D",extensions:["d"],load(){return ve(()=>Promise.resolve().then(()=>Kyt),void 0,import.meta.url).then(e=>qe(e.d))}}),ye.of({name:"Dart",extensions:["dart"],load(){return ve(()=>Promise.resolve().then(()=>od),void 0,import.meta.url).then(e=>qe(e.dart))}}),ye.of({name:"diff",extensions:["diff","patch"],load(){return ve(()=>Promise.resolve().then(()=>Jyt),void 0,import.meta.url).then(e=>qe(e.diff))}}),ye.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return ve(()=>Promise.resolve().then(()=>dvt),void 0,import.meta.url).then(e=>qe(e.dockerFile))}}),ye.of({name:"DTD",extensions:["dtd"],load(){return ve(()=>Promise.resolve().then(()=>pvt),void 0,import.meta.url).then(e=>qe(e.dtd))}}),ye.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return ve(()=>Promise.resolve().then(()=>vvt),void 0,import.meta.url).then(e=>qe(e.dylan))}}),ye.of({name:"EBNF",load(){return ve(()=>Promise.resolve().then(()=>bvt),void 0,import.meta.url).then(e=>qe(e.ebnf))}}),ye.of({name:"ECL",extensions:["ecl"],load(){return ve(()=>Promise.resolve().then(()=>Tvt),void 0,import.meta.url).then(e=>qe(e.ecl))}}),ye.of({name:"edn",extensions:["edn"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>qe(e.clojure))}}),ye.of({name:"Eiffel",extensions:["e"],load(){return ve(()=>Promise.resolve().then(()=>Cvt),void 0,import.meta.url).then(e=>qe(e.eiffel))}}),ye.of({name:"Elm",extensions:["elm"],load(){return ve(()=>Promise.resolve().then(()=>Vvt),void 0,import.meta.url).then(e=>qe(e.elm))}}),ye.of({name:"Erlang",extensions:["erl"],load(){return ve(()=>Promise.resolve().then(()=>mbt),void 0,import.meta.url).then(e=>qe(e.erlang))}}),ye.of({name:"Esper",load(){return ve(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>qe(e.esper))}}),ye.of({name:"Factor",extensions:["factor"],load(){return ve(()=>Promise.resolve().then(()=>gbt),void 0,import.meta.url).then(e=>qe(e.factor))}}),ye.of({name:"FCL",load(){return ve(()=>Promise.resolve().then(()=>wbt),void 0,import.meta.url).then(e=>qe(e.fcl))}}),ye.of({name:"Forth",extensions:["forth","fth","4th"],load(){return ve(()=>Promise.resolve().then(()=>Qbt),void 0,import.meta.url).then(e=>qe(e.forth))}}),ye.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return ve(()=>Promise.resolve().then(()=>Ebt),void 0,import.meta.url).then(e=>qe(e.fortran))}}),ye.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>qe(e.fSharp))}}),ye.of({name:"Gas",extensions:["s"],load(){return ve(()=>Promise.resolve().then(()=>jbt),void 0,import.meta.url).then(e=>qe(e.gas))}}),ye.of({name:"Gherkin",extensions:["feature"],load(){return ve(()=>Promise.resolve().then(()=>Cbt),void 0,import.meta.url).then(e=>qe(e.gherkin))}}),ye.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return ve(()=>Promise.resolve().then(()=>Vbt),void 0,import.meta.url).then(e=>qe(e.groovy))}}),ye.of({name:"Haskell",extensions:["hs"],load(){return ve(()=>Promise.resolve().then(()=>Jbt),void 0,import.meta.url).then(e=>qe(e.haskell))}}),ye.of({name:"Haxe",extensions:["hx"],load(){return ve(()=>Promise.resolve().then(()=>jB),void 0,import.meta.url).then(e=>qe(e.haxe))}}),ye.of({name:"HXML",extensions:["hxml"],load(){return ve(()=>Promise.resolve().then(()=>jB),void 0,import.meta.url).then(e=>qe(e.hxml))}}),ye.of({name:"HTTP",load(){return ve(()=>Promise.resolve().then(()=>wwt),void 0,import.meta.url).then(e=>qe(e.http))}}),ye.of({name:"IDL",extensions:["pro"],load(){return ve(()=>Promise.resolve().then(()=>Twt),void 0,import.meta.url).then(e=>qe(e.idl))}}),ye.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return ve(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>qe(e.jsonld))}}),ye.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return ve(()=>Promise.resolve().then(()=>qwt),void 0,import.meta.url).then(e=>qe(e.jinja2))}}),ye.of({name:"Julia",extensions:["jl"],load(){return ve(()=>Promise.resolve().then(()=>i1t),void 0,import.meta.url).then(e=>qe(e.julia))}}),ye.of({name:"Kotlin",extensions:["kt","kts"],load(){return ve(()=>Promise.resolve().then(()=>od),void 0,import.meta.url).then(e=>qe(e.kotlin))}}),ye.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return ve(()=>Promise.resolve().then(()=>l1t),void 0,import.meta.url).then(e=>qe(e.liveScript))}}),ye.of({name:"Lua",extensions:["lua"],load(){return ve(()=>Promise.resolve().then(()=>m1t),void 0,import.meta.url).then(e=>qe(e.lua))}}),ye.of({name:"mIRC",extensions:["mrc"],load(){return ve(()=>Promise.resolve().then(()=>W1t),void 0,import.meta.url).then(e=>qe(e.mirc))}}),ye.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return ve(()=>Promise.resolve().then(()=>S1t),void 0,import.meta.url).then(e=>qe(e.mathematica))}}),ye.of({name:"Modelica",extensions:["mo"],load(){return ve(()=>Promise.resolve().then(()=>F1t),void 0,import.meta.url).then(e=>qe(e.modelica))}}),ye.of({name:"MUMPS",extensions:["mps"],load(){return ve(()=>Promise.resolve().then(()=>Oxt),void 0,import.meta.url).then(e=>qe(e.mumps))}}),ye.of({name:"Mbox",extensions:["mbox"],load(){return ve(()=>Promise.resolve().then(()=>z1t),void 0,import.meta.url).then(e=>qe(e.mbox))}}),ye.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return ve(()=>Promise.resolve().then(()=>mxt),void 0,import.meta.url).then(e=>qe(e.nginx))}}),ye.of({name:"NSIS",extensions:["nsh","nsi"],load(){return ve(()=>Promise.resolve().then(()=>gxt),void 0,import.meta.url).then(e=>qe(e.nsis))}}),ye.of({name:"NTriples",extensions:["nt","nq"],load(){return ve(()=>Promise.resolve().then(()=>$xt),void 0,import.meta.url).then(e=>qe(e.ntriples))}}),ye.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return ve(()=>Promise.resolve().then(()=>od),void 0,import.meta.url).then(e=>qe(e.objectiveC))}}),ye.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return ve(()=>Promise.resolve().then(()=>od),void 0,import.meta.url).then(e=>qe(e.objectiveCpp))}}),ye.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>qe(e.oCaml))}}),ye.of({name:"Octave",extensions:["m"],load(){return ve(()=>Promise.resolve().then(()=>Txt),void 0,import.meta.url).then(e=>qe(e.octave))}}),ye.of({name:"Oz",extensions:["oz"],load(){return ve(()=>Promise.resolve().then(()=>Yxt),void 0,import.meta.url).then(e=>qe(e.oz))}}),ye.of({name:"Pascal",extensions:["p","pas"],load(){return ve(()=>Promise.resolve().then(()=>Mxt),void 0,import.meta.url).then(e=>qe(e.pascal))}}),ye.of({name:"Perl",extensions:["pl","pm"],load(){return ve(()=>Promise.resolve().then(()=>Lxt),void 0,import.meta.url).then(e=>qe(e.perl))}}),ye.of({name:"Pig",extensions:["pig"],load(){return ve(()=>Promise.resolve().then(()=>Hxt),void 0,import.meta.url).then(e=>qe(e.pig))}}),ye.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return ve(()=>Promise.resolve().then(()=>fSt),void 0,import.meta.url).then(e=>qe(e.powerShell))}}),ye.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return ve(()=>Promise.resolve().then(()=>hSt),void 0,import.meta.url).then(e=>qe(e.properties))}}),ye.of({name:"ProtoBuf",extensions:["proto"],load(){return ve(()=>Promise.resolve().then(()=>ySt),void 0,import.meta.url).then(e=>qe(e.protobuf))}}),ye.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return ve(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([8,9]),import.meta.url).then(e=>qe(e.pug))}}),ye.of({name:"Puppet",extensions:["pp"],load(){return ve(()=>Promise.resolve().then(()=>wSt),void 0,import.meta.url).then(e=>qe(e.puppet))}}),ye.of({name:"Q",extensions:["q"],load(){return ve(()=>Promise.resolve().then(()=>XSt),void 0,import.meta.url).then(e=>qe(e.q))}}),ye.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return ve(()=>Promise.resolve().then(()=>ASt),void 0,import.meta.url).then(e=>qe(e.r))}}),ye.of({name:"RPM Changes",load(){return ve(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>qe(e.rpmChanges))}}),ye.of({name:"RPM Spec",extensions:["spec"],load(){return ve(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>qe(e.rpmSpec))}}),ye.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return ve(()=>Promise.resolve().then(()=>VSt),void 0,import.meta.url).then(e=>qe(e.ruby))}}),ye.of({name:"SAS",extensions:["sas"],load(){return ve(()=>Promise.resolve().then(()=>BSt),void 0,import.meta.url).then(e=>qe(e.sas))}}),ye.of({name:"Scala",extensions:["scala"],load(){return ve(()=>Promise.resolve().then(()=>od),void 0,import.meta.url).then(e=>qe(e.scala))}}),ye.of({name:"Scheme",extensions:["scm","ss"],load(){return ve(()=>Promise.resolve().then(()=>cQt),void 0,import.meta.url).then(e=>qe(e.scheme))}}),ye.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return ve(()=>Promise.resolve().then(()=>fQt),void 0,import.meta.url).then(e=>qe(e.shell))}}),ye.of({name:"Sieve",extensions:["siv","sieve"],load(){return ve(()=>Promise.resolve().then(()=>$Qt),void 0,import.meta.url).then(e=>qe(e.sieve))}}),ye.of({name:"Smalltalk",extensions:["st"],load(){return ve(()=>Promise.resolve().then(()=>bQt),void 0,import.meta.url).then(e=>qe(e.smalltalk))}}),ye.of({name:"Solr",load(){return ve(()=>Promise.resolve().then(()=>PQt),void 0,import.meta.url).then(e=>qe(e.solr))}}),ye.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>qe(e.sml))}}),ye.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return ve(()=>Promise.resolve().then(()=>CQt),void 0,import.meta.url).then(e=>qe(e.sparql))}}),ye.of({name:"Spreadsheet",alias:["excel","formula"],load(){return ve(()=>Promise.resolve().then(()=>zQt),void 0,import.meta.url).then(e=>qe(e.spreadsheet))}}),ye.of({name:"Squirrel",extensions:["nut"],load(){return ve(()=>Promise.resolve().then(()=>od),void 0,import.meta.url).then(e=>qe(e.squirrel))}}),ye.of({name:"Stylus",extensions:["styl"],load(){return ve(()=>Promise.resolve().then(()=>ikt),void 0,import.meta.url).then(e=>qe(e.stylus))}}),ye.of({name:"Swift",extensions:["swift"],load(){return ve(()=>Promise.resolve().then(()=>Skt),void 0,import.meta.url).then(e=>qe(e.swift))}}),ye.of({name:"sTeX",load(){return ve(()=>Promise.resolve().then(()=>QH),void 0,import.meta.url).then(e=>qe(e.stex))}}),ye.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return ve(()=>Promise.resolve().then(()=>QH),void 0,import.meta.url).then(e=>qe(e.stex))}}),ye.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return ve(()=>Promise.resolve().then(()=>DH),void 0,import.meta.url).then(e=>qe(e.verilog))}}),ye.of({name:"Tcl",extensions:["tcl"],load(){return ve(()=>Promise.resolve().then(()=>Pkt),void 0,import.meta.url).then(e=>qe(e.tcl))}}),ye.of({name:"Textile",extensions:["textile"],load(){return ve(()=>Promise.resolve().then(()=>Ekt),void 0,import.meta.url).then(e=>qe(e.textile))}}),ye.of({name:"TiddlyWiki",load(){return ve(()=>Promise.resolve().then(()=>Jkt),void 0,import.meta.url).then(e=>qe(e.tiddlyWiki))}}),ye.of({name:"Tiki wiki",load(){return ve(()=>Promise.resolve().then(()=>o_t),void 0,import.meta.url).then(e=>qe(e.tiki))}}),ye.of({name:"TOML",extensions:["toml"],load(){return ve(()=>Promise.resolve().then(()=>s_t),void 0,import.meta.url).then(e=>qe(e.toml))}}),ye.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return ve(()=>Promise.resolve().then(()=>u_t),void 0,import.meta.url).then(e=>qe(e.troff))}}),ye.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return ve(()=>Promise.resolve().then(()=>P_t),void 0,import.meta.url).then(e=>qe(e.ttcn))}}),ye.of({name:"TTCN_CFG",extensions:["cfg"],load(){return ve(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>qe(e.ttcnCfg))}}),ye.of({name:"Turtle",extensions:["ttl"],load(){return ve(()=>Promise.resolve().then(()=>R_t),void 0,import.meta.url).then(e=>qe(e.turtle))}}),ye.of({name:"Web IDL",extensions:["webidl"],load(){return ve(()=>Promise.resolve().then(()=>SPt),void 0,import.meta.url).then(e=>qe(e.webIDL))}}),ye.of({name:"VB.NET",extensions:["vb"],load(){return ve(()=>Promise.resolve().then(()=>V_t),void 0,import.meta.url).then(e=>qe(e.vb))}}),ye.of({name:"VBScript",extensions:["vbs"],load(){return ve(()=>Promise.resolve().then(()=>L_t),void 0,import.meta.url).then(e=>qe(e.vbScript))}}),ye.of({name:"Velocity",extensions:["vtl"],load(){return ve(()=>Promise.resolve().then(()=>H_t),void 0,import.meta.url).then(e=>qe(e.velocity))}}),ye.of({name:"Verilog",extensions:["v"],load(){return ve(()=>Promise.resolve().then(()=>DH),void 0,import.meta.url).then(e=>qe(e.verilog))}}),ye.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return ve(()=>Promise.resolve().then(()=>oPt),void 0,import.meta.url).then(e=>qe(e.vhdl))}}),ye.of({name:"XQuery",extensions:["xy","xquery"],load(){return ve(()=>Promise.resolve().then(()=>jPt),void 0,import.meta.url).then(e=>qe(e.xQuery))}}),ye.of({name:"Yacas",extensions:["ys"],load(){return ve(()=>Promise.resolve().then(()=>IPt),void 0,import.meta.url).then(e=>qe(e.yacas))}}),ye.of({name:"Z80",extensions:["z80"],load(){return ve(()=>Promise.resolve().then(()=>FPt),void 0,import.meta.url).then(e=>qe(e.z80))}}),ye.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return ve(()=>Promise.resolve().then(()=>uX),void 0,import.meta.url).then(e=>qe(e.mscgen))}}),ye.of({name:"Xù",extensions:["xu"],load(){return ve(()=>Promise.resolve().then(()=>uX),void 0,import.meta.url).then(e=>qe(e.xu))}}),ye.of({name:"MsGenny",extensions:["msgenny"],load(){return ve(()=>Promise.resolve().then(()=>uX),void 0,import.meta.url).then(e=>qe(e.msgenny))}}),ye.of({name:"Vue",extensions:["vue"],load(){return ve(()=>Promise.resolve().then(()=>agt),void 0,import.meta.url).then(e=>e.vue())}}),ye.of({name:"Angular Template",load(){return ve(()=>Promise.resolve().then(()=>Sgt),void 0,import.meta.url).then(e=>e.angular())}})];class K8{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=In(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(Vge(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 bM(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 Ait(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=bM(t)+bM(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Ev(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:Ait(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function u_(e,t){return n=>{for(let r=In(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 wM{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function Cd(e){return e.selection.main.from}function Vge(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 J8=kf.define();function Uit(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:De.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const xM=new WeakMap;function Wit(e){if(!Array.isArray(e))return e;let t=xM.get(e);return t||xM.set(e,t=Ev(e)),t}const $S=wn.define(),K$=wn.define();class Nit{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<t.length;){let r=mo(t,n),i=vc(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(mo(o==a?a.toLowerCase():o,0)),n+=i}this.astral=t.length!=this.chars.length}ret(t,n){return this.score=t,this.matched=n,this}match(t){if(this.pattern.length==0)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:n,folded:r,any:i,precise:a,byWord:o}=this;if(n.length==1){let b=mo(t,0),x=vc(b),Q=x==t.length?0:-100;if(b!=n[0])if(b==r[0])Q+=-200;else return null;return this.ret(Q,[0,x])}let s=t.indexOf(this.pattern);if(s==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(s<0){for(let b=0,x=Math.min(t.length,200);b<x&&c<l;){let Q=mo(t,b);(Q==n[c]||Q==r[c])&&(i[c++]=b),b+=vc(Q)}if(c<l)return null}let u=0,O=0,d=!1,h=0,p=-1,g=-1,y=/[a-z]/.test(t),v=!0;for(let b=0,x=Math.min(t.length,200),Q=0;b<x&&O<l;){let w=mo(t,b);s<0&&(u<l&&w==n[u]&&(a[u++]=b),h<l&&(w==n[h]||w==r[h]?(h==0&&(p=b),g=b+1,h++):h=0));let S,k=w<255?w>=48&&w<=57||w>=97&&w<=122?2:w>=65&&w<=90?1:0:(S=rme(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+=vc(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?vc(mo(r,o)):1);a&&i[a-1]==o?i[a-1]=s:(i[a++]=o,i[a++]=s)}return this.ret(t-r.length,i)}}class Yit{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 Ei=ft.define({combine(e){return Wm(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:Git,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=>SM(t(r),n(r)),optionClass:(t,n)=>r=>SM(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function SM(e,t){return e?t?e+" "+t:e:t}function Git(e,t,n,r,i,a){let o=e.textDirection==br.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 Zit(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 a2(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 Iit{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(Ei);this.optionContent=Zit(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=a2(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(Ei).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:K$.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=a2(a.length,o,t.state.facet(Ei).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=a2(n.options.length,n.selected,this.view.state.facet(Ei).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=>Da(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&&Vit(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(Ei).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 Dit(e,t){return n=>new Iit(n,e,t)}function Vit(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 QM(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Mit(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(Ei);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 wM(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,h=a.filterStrict?new Yit(O):new Nit(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 wM(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):QM(c.completion)>QM(s)&&(o[o.length-1]=c),s=c.completion}return o}class Mh{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 Mh(this.options,kM(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=Mit(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Ei).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 Mh(s,kM(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:Jit,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new Mh(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 Mh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class yS{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new yS(Hit,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Ei),a=(r.override||n.languageDataAt("autocomplete",Cd(n)).map(Wit)).map(l=>(this.active.find(u=>u.source==l)||new Bo(l,this.active.some(u=>u.state!=0)?1:0)).update(t,r));a.length==this.active.length&&a.every((l,c)=>l==this.active[c])&&(a=this.active);let o=this.open,s=t.effects.some(l=>l.is(eU));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Lit(a,this.active)||s?o=Mh.build(a,n,this.id,o,r,s):o&&o.disabled&&!a.some(l=>l.isPending)&&(o=null),!o&&a.every(l=>!l.isPending)&&a.some(l=>l.hasResult())&&(a=a.map(l=>l.hasResult()?new Bo(l.source,0):l));for(let l of t.effects)l.is(Lge)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new yS(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Fit:Bit}}function Lit(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 Fit={"aria-autocomplete":"list"},Bit={};function kM(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Hit=[];function Mge(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(J8);if(r&&t.activateOnCompletion(r))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}class Bo{constructor(t,n,r=!1){this.source=t,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=Mge(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new Bo(i.source,0)),r&4&&i.state==0&&(i=new Bo(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is($S))i=new Bo(i.source,1,a.value);else if(a.is(K$))i=new Bo(i.source,0);else if(a.is(eU))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(Cd(t.state))}}class cp extends Bo{constructor(t,n,r,i,a,o){super(t,3,n),this.limit=r,this.result=i,this.from=a,this.to=o}hasResult(){return!0}updateFor(t,n){var r;if(!(n&3))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let a=t.changes.mapPos(this.from),o=t.changes.mapPos(this.to,1),s=Cd(t.state);if(s>o||!i||n&2&&(Cd(t.startState)==this.from||s<this.limit))return new Bo(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return Kit(i.validFor,t.state,a,o)?new cp(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new K8(t.state,s,!1)))?new cp(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:Cd(t.state)):new Bo(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new cp(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new Bo(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Kit(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Vge(e,!0).test(i)}const eU=wn.define({map(e,t){return e.map(n=>n.map(t))}}),Lge=wn.define(),Ya=Ka.define({create(){return yS.start()},update(e,t){return e.update(t)},provide:e=>[D8.from(e,t=>t.tooltip),xt.contentAttributes.from(e,t=>t.attrs)]});function tU(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ya).active.find(i=>i.source==t.source);return r instanceof cp?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},Uit(e.state,n,r.from,r.to)),{annotations:J8.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const Jit=Dit(Ya,tU);function pw(e,t="option"){return n=>{let r=n.state.field(Ya,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ei).interactionDelay)return!1;let i=1,a;t=="page"&&(a=$ge(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:Lge.of(s)}),!0}}const eat=e=>{let t=e.state.field(Ya,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ei).interactionDelay?!1:tU(e,t.open.options[t.open.selected])},_M=e=>e.state.field(Ya,!1)?(e.dispatch({effects:$S.of(!0)}),!0):!1,tat=e=>{let t=e.state.field(Ya,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:K$.of(null)}),!0)};class nat{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const rat=50,iat=1e3,aat=mi.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(Ya).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ya),n=e.state.facet(Ei);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ya)==t)return;let r=e.transactions.some(a=>{let o=Mge(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>rat&&Date.now()-o.time>iat){for(let s of o.context.abortListeners)try{s()}catch(l){Da(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($S)))&&(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(Ya);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(Ei).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=Cd(t),r=new K8(t,n,e.explicit,this.view),i=new nat(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:K$.of(null)}),Da(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(Ei).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Ei),r=this.view.state.field(Ya);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=Cd(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new cp(a.active.source,a.active.explicit,l,a.done,a.done.from,(e=a.done.to)!==null&&e!==void 0?e:s);for(let u of a.updates)c=c.update(u,n);if(c.hasResult()){t.push(c);continue}}let o=r.active.find(s=>s.source==a.active.source);if(o&&o.isPending)if(a.done==null){let s=new Bo(a.active.source,0);for(let l of a.updates)s=s.update(l,n);s.isPending||t.push(s)}else this.startQuery(o)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:eU.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ya,!1);if(t&&t.tooltip&&this.view.state.facet(Ei).closeOnBlur){let n=t.open&&$ge(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:K$.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:$S.of(!1)}),20),this.composing=0}}}),oat=typeof navigator=="object"&&/Win/.test(navigator.platform),sat=RO.highest(xt.domEventHandlers({keydown(e,t){let n=t.state.field(Ya,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(oat&&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&&tU(t,r),!1}})),Fge=xt.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class lat{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class nU{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Ii.TrackDel),r=t.mapPos(this.to,1,Ii.TrackDel);return n==null||r==null?null:new nU(this.field,n,r)}}class rU{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(s_);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 nU(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 lat(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 rU(r,i)}}let cat=on.widget({widget:new class extends su{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),uat=on.mark({class:"cm-snippetField"});class Nm{constructor(t,n){this.ranges=t,this.active=n,this.deco=on.set(t.map(r=>(r.from==r.to?cat:uat).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 Nm(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 qv=wn.define({map(e,t){return e&&e.map(t)}}),Oat=wn.define(),J$=Ka.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(qv))return n.value;if(n.is(Oat)&&e)return new Nm(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>xt.decorations.from(e,t=>t?t.deco:on.none)});function iU(e,t){return De.create(e.filter(n=>n.field==t).map(n=>De.range(n.from,n.to)))}function dat(e){let t=rU.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:Gn.of(o)},scrollIntoView:!0,annotations:r?[J8.of(r),Di.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=iU(s,0)),s.some(u=>u.field>0)){let u=new Nm(s,0),O=c.effects=[qv.of(u)];n.state.field(J$,!1)===void 0&&O.push(wn.appendConfig.of([J$,gat,$at,Fge]))}n.dispatch(n.state.update(c))}}function Bge(e){return({state:t,dispatch:n})=>{let r=t.field(J$,!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:iU(r.ranges,i),effects:qv.of(a?null:new Nm(r.ranges,i)),scrollIntoView:!0})),!0}}const fat=({state:e,dispatch:t})=>e.field(J$,!1)?(t(e.update({effects:qv.of(null)})),!0):!1,hat=Bge(1),pat=Bge(-1),mat=[{key:"Tab",run:hat,shift:pat},{key:"Escape",run:fat}],PM=ft.define({combine(e){return e.length?e[0]:mat}}),gat=RO.highest(i_.compute([PM],e=>e.facet(PM)));function Or(e,t){return Object.assign(Object.assign({},t),{apply:dat(e)})}const $at=xt.domEventHandlers({mousedown(e,t){let n=t.state.field(J$,!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:iU(n.ranges,i.field),effects:qv.of(n.ranges.some(a=>a.field>i.field)?new Nm(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),ey={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Qd=wn.define({map(e,t){let n=t.mapPos(e,-1,Ii.TrackAfter);return n??void 0}}),aU=new class extends Fd{};aU.startSide=1;aU.endSide=-1;const Hge=Ka.define({create(){return bn.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(Qd)&&(e=e.update({add:[aU.range(n.value,n.value+1)]}));return e}});function Qdn(){return[vat,Hge]}const o2="()[]{}<>«»»«[]{}";function Kge(e){for(let t=0;t<o2.length;t+=2)if(o2.charCodeAt(t)==e)return o2.charAt(t+1);return rme(e<128?e:e+1)}function Jge(e,t){return e.languageDataAt("closeBrackets",t)[0]||ey}const yat=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),vat=xt.inputHandler.of((e,t,n,r)=>{if((yat?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&vc(mo(r,0))==1||t!=i.from||n!=i.to)return!1;let a=wat(e.state,r);return a?(e.dispatch(a),!0):!1}),bat=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Jge(e,e.selection.main.head).brackets||ey.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=xat(e.doc,o.head);for(let l of r)if(l==s&&O_(e.doc,o.head)==Kge(mo(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:De.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},kdn=[{key:"Backspace",run:bat}];function wat(e,t){let n=Jge(e,e.selection.main.head),r=n.brackets||ey.brackets;for(let i of r){let a=Kge(mo(i,0));if(t==i)return a==i?kat(e,i,r.indexOf(i+i+i)>-1,n):Sat(e,i,a,n.before||ey.before);if(t==a&&e0e(e,e.selection.main.from))return Qat(e,i,a)}return null}function e0e(e,t){let n=!1;return e.field(Hge).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function O_(e,t){let n=e.sliceString(t,t+2);return n.slice(0,vc(mo(n,0)))}function xat(e,t){let n=e.sliceString(t-2,t);return vc(mo(n,0))==n.length?n:n.slice(1)}function Sat(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:Qd.of(o.to+t.length),range:De.range(o.anchor+t.length,o.head+t.length)};let s=O_(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:Qd.of(o.head+t.length),range:De.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function Qat(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&O_(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:De.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function kat(e,t,n,r){let i=r.stringPrefixes||ey.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:Qd.of(s.to+t.length),range:De.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=O_(e.doc,l),u;if(c==t){if(TM(e,l))return{changes:{insert:t+t,from:l},effects:Qd.of(l+t.length),range:De.cursor(l+t.length)};if(e0e(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:De.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=XM(e,l-2*t.length,i))>-1&&TM(e,u))return{changes:{insert:t+t+t+t,from:l},effects:Qd.of(l+t.length),range:De.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=Fo.Word&&XM(e,l,i)>-1&&!_at(e,l,t,i))return{changes:{insert:t+t,from:l},effects:Qd.of(l+t.length),range:De.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function TM(e,t){let n=In(e).resolveInner(t+1);return n.parent&&n.from==t}function _at(e,t,n,r){let i=In(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 XM(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=Fo.Word)return t;for(let i of n){let a=t-i.length;if(e.sliceDoc(a,t)==i&&r(e.sliceDoc(a-1,a))!=Fo.Word)return a}return-1}function _dn(e={}){return[sat,Ya,Ei.of(e),aat,Tat,Fge]}const Pat=[{key:"Ctrl-Space",run:_M},{mac:"Alt-`",run:_M},{key:"Escape",run:tat},{key:"ArrowDown",run:pw(!0)},{key:"ArrowUp",run:pw(!1)},{key:"PageDown",run:pw(!0,"page")},{key:"PageUp",run:pw(!1,"page")},{key:"Enter",run:eat}],Tat=RO.highest(i_.computeN([Ei],e=>e.facet(Ei).defaultKeymap?[Pat]:[]));class vS{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new vS(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=[[Wt.contextHash,i]]}addChild(t,n){t.prop(Wt.contextHash)!=this.hash&&(t=new un(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 un(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new un(si.none,i,a,o,this.hashProp)})}}var Ve;(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"})(Ve||(Ve={}));class Xat{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let Rat=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 n$(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 RM(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==Ve.OrderedList?lU:sU)(n,t,!1);return r>0&&(e.type!=Ve.BulletList||oU(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const t0e={[Ve.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(pn(Ve.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(Os(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[Ve.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Ve.OrderedList]:RM,[Ve.BulletList]:RM,[Ve.Document](){return!0}};function Os(e){return e==32||e==9||e==10||e==13}function n$(e,t=0){for(;t<e.length&&Os(e.charCodeAt(t));)t++;return t}function EM(e,t,n){for(;t>n&&Os(e.charCodeAt(t-1));)t--;return t}function n0e(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 r0e(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function oU(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let i=e.pos+1;i<e.text.length;i++){let a=e.text.charCodeAt(i);if(a==e.next)r++;else if(!Os(a))return-1}return n&&e.next==45&&o0e(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(u0e.SetextHeading)>-1||r<3?-1:1}function i0e(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function sU(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||Os(e.text.charCodeAt(e.pos+1)))&&(!n||i0e(t,Ve.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function lU(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){r++;if(r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!Os(e.text.charCodeAt(r+1))||n&&!i0e(t,Ve.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function a0e(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 o0e(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&Os(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const j7=/^[ \t]*$/,s0e=/-->/,l0e=/\?>/,C7=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,s0e],[/^\s*<\?/,l0e],[/^\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,j7],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,j7]];function c0e(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=C7.length-(n?1:0);i<a;i++)if(C7[i][0].test(r))return i;return-1}function qM(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 rd(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Ve.CodeText?e[r].to=n:e.push(pn(Ve.CodeText,t,n))}const mw={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(rd(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){rd(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==Ve.CodeText?rd(o,c.from,c.to):o.push(c);s=[]}rd(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&&rd(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=Ve.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Ve.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=n0e(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=EM(t.text,t.text.length,o),l=[pn(Ve.CodeMark,r,r+a)];o<s&&l.push(pn(Ve.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(pn(Ve.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||rd(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&&rd(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Ve.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=r0e(t);return n<0?!1:(e.startContext(Ve.Blockquote,t.pos),e.addNode(Ve.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(oU(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Ve.HorizontalRule,n),!0},BulletList(e,t){let n=sU(t,e,!1);if(n<0)return!1;e.block.type!=Ve.BulletList&&e.startContext(Ve.BulletList,t.basePos,t.next);let r=qM(t,t.pos+1);return e.startContext(Ve.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ve.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=lU(t,e,!1);if(n<0)return!1;e.block.type!=Ve.OrderedList&&e.startContext(Ve.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=qM(t,t.pos+n);return e.startContext(Ve.ListItem,t.basePos,r-t.baseIndent),e.addNode(Ve.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=a0e(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=EM(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!Os(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(Ve.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Ve.HeaderMark,o-r,a-r);let l=s.finish(Ve.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=c0e(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=C7[n][1],a=[],o=i!=j7;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==s0e?Ve.CommentBlock:i==l0e?Ve.ProcessingInstructionBlock:Ve.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class Eat{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+`
878
878
  `+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)&&n$(n.content,this.pos)==n.content.length?this.complete(t,n,n.content.length):!1}complete(t,n,r){return t.addLeafElement(n,pn(Ve.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(y0e(t,this.pos,this.start,!0)))return-1;if(t.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(pn(Ve.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(g0e(t,n$(t,this.pos),this.start)))return-1}else if(this.stage==2){let n=n$(t,this.pos),r=0;if(n>this.pos){let i=$0e(t,n,this.start);if(i){let a=s2(t,i.to-this.start);a>0&&(this.nextStage(i),r=a)}}return r||(r=s2(t,this.pos)),r>0&&r<t.length?r:-1}else return s2(t,this.pos)}}}function s2(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!Os(n))return-1}return t}class qat{nextLine(t,n,r){let i=n.depth<t.stack.length?-1:o0e(n),a=n.next;if(i<0)return!1;let o=pn(Ve.HeaderMark,t.lineStart+n.pos,t.lineStart+i);return t.nextLine(),t.addLeafElement(r,pn(a==61?Ve.SetextHeading1:Ve.SetextHeading2,r.start,t.prevLineEnd(),[...t.parser.parseInline(r.content,r.start),o])),!0}finish(){return!1}}const u0e={LinkReference(e,t){return t.content.charCodeAt(0)==91?new Eat(t):null},SetextHeading(){return new qat}},jat=[(e,t)=>a0e(t)>=0,(e,t)=>n0e(t)>=0,(e,t)=>r0e(t)>=0,(e,t)=>sU(t,e,!0)>=0,(e,t)=>lU(t,e,!0)>=0,(e,t)=>oU(t,e,!0)>=0,(e,t)=>c0e(t,e,!0)>=0],Cat={text:"",end:0};class zat{constructor(t,n,r,i){this.parser=t,this.input=n,this.ranges=i,this.line=new Rat,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=vS.create(Ve.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new Nat(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 Xat(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+=`
879
879
  `+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=v0e(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=Cat;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 "+Ve[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==`
880
880
  `?"":n;else{let i=n.indexOf(`
@@ -910,7 +910,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
910
910
  `,o.end),l=t.slice(o.end,s===-1?t.length:s);if($Tt.test(l))return Ga;const c=l.length-l.replace(yTt,"").length,u={start:o.start,end:o.end+c},O=e.typingAt;if(O!==null){const d=O+tm(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]===Z_?{arm:u,typingAt:n,value:""}:{arm:u,typingAt:null,value:""}}const Wa=e=>e.typingAt!==null,kTt=e=>e.arm!==null;function Cf(e){return e.typingAt===null?null:{start:e.typingAt,end:e.typingAt+tm(e.value).length}}function OW(e,t,n,r){const i=Cf(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=tm(e.value),c=U6(a-i.start,0,l.length),u=U6(o-i.start,0,l.length),O=tm(s),d=[...l.slice(0,c),...O,...l.slice(u)].join(""),h=a+O.length,p=t.slice(0,a)+rSe.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 sK(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=Wa(e)&&e.value===""&&r.startsWith("-");if(Wa(e)&&(a||r.includes(`
911
911
  `))){const o=BS(e);return r.includes(`
912
912
  `)?{...i,capture:o}:{...i,capture:Bh(o,i.buffer,i.caret,"typing")}}return OW(e,i.buffer,i.caret,{top:n.start,bottom:n.end,inserted:r})??i}function BS(e){return Wa(e)?{arm:e.arm,typingAt:null,value:""}:e}function _Tt(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 PTt(e,t,n,r,i){const a=_Tt(t,n),o=Cf(e);let s={capture:e,buffer:n,caret:r};if(a.inserted!==""&&o!==null&&a.top<=o.end&&a.bottom>=o.start)s={capture:BS(e),buffer:n,caret:r};else{const l=OW(e,n,r,a);l?s=l:Wa(e)&&a.inserted.includes(`
913
- `)&&(s={capture:BS(e),buffer:n,caret:r})}return{...s,capture:Bh(s.capture,s.buffer,s.caret,i)}}function TTt(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=Cf(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=dSe(i,t.value),c=l+Z_,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:Ga,buffer:u,caret:s+c.length,payload:{index:i,key:fSe(a,e.draw),value:t.value,marker:l}}}const XTt=e=>Wa(e)&&e.value!=="";function RTt(e,t){const n=Cf(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:Ga,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 ETt(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function qTt(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=Cf(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:BS(e),buffer:i,caret:a,payload:null}}function jTt(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=OW(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=Bn(i);if(!a)return i===""?null:qTt(t,n,e.selection,i);const o=t.arm,s=dSe(e.index,a),l=s+Z_,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:Ga,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:fSe(e.taken,e.draw),value:a,marker:s}}}const OSe=e=>`${bTt(e)} chars`,dSe=(e,t)=>`[Credential #${e}, ${OSe(t)}]`;function CTt(e){_l.lastIndex=0;const t=_l.exec(e);return _l.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function zTt(e){_l.lastIndex=0;const t=_l.exec(e);if(_l.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 Vv(e,t){if(CTt(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const _X=/\[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,PX=/\[credential NOT stored \u2014 [^\]\n]*\]/y,TX=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,ATt=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&A6.test(t[1])?t[1]:""};function UTt(e,t){if(e.charCodeAt(t)!==91)return null;_X.lastIndex=t;const n=_X.exec(e);if(_X.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};PX.lastIndex=t;const r=PX.exec(e);if(PX.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};TX.lastIndex=t;const i=TX.exec(e);return TX.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:ATt(i[0])}:null}function I_(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=UTt(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 lK(e,t){const n=[];for(const r of t){const i=Vv(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 WTt(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 NTt=e=>`[credential ${e.key} (${OSe(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function YTt(e,t,n=new Map){const r=[...t],i=[];for(const o of r){const s=Vv(e,o);s!==null&&i.push({span:s,payload:o})}for(const o of sSe(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?WTt(l??"lost",s?.key):NTt(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const GTt=(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.`,ZTt=e=>`Remove credential #${e}`,ITt=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,DTt=(e,t,n)=>GTt(e,t,n),VTt="Undo",MTt=e=>m("ui.notices.credentials.removed",{index:e}),LTt=e=>e.unredacted!==null?e.unredacted:e.armed?n2t:e.cleared!==null?DTt(e.cleared.key,e.cleared.index,e.undoCap):null;function FTt(e){const{buffer:t,payload:n}=e,r=Vv(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===Z_?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 BTt(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 cK=e=>m("ui.notices.credentials.stored",{keys:e.join(", ")});function uK(e){return m("ui.notices.credentials.unstored",{count:e.length,keys:[...e].sort().join(", ")})}const HTt="store unconfirmed",KTt="Credential store unconfirmed",JTt=e=>e===""?KTt:`${e} · ${HTt}`,e2t="Paste the value again after /credential to store it again.",t2t=e=>`${e} ${e2t}`;function OK(e){return m("ui.notices.credentials.unconfirmed",{count:e.length,keys:[...e].sort().join(", ")})}const n2t="armed — add a space, then type or paste the secret",r2t="masked as you type — Enter makes a pill, Esc twice discards",i2t="masked — Enter opens the credential picker; type or paste the secret into this span",a2t="Esc again discards it — still masked, Enter makes a pill",o2t="credential discarded — nothing was stored or sent",s2t="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",l2t=e=>`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`;function c2t(e,t){const n=Cf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const dK=(e,t)=>e&&e.over===t?e.chars:null,u2t=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},O2t=16,d2t=16;function fSe(e=[],t=u2t){const n=new Set(e);for(let r=0;r<O2t;r++){const i=oK+fK(8,t);if(!n.has(i))return i}return oK+fK(d2t,t)}const fK=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=aK[t(aK.length)];return n},f2t=8,h2t=256,p2t=/^[/@$#]/,m2t=/^\w+:\/\//,g2t=/^[A-Za-z]+$/,$2t=/^\d+$/,y2t=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/],v2t=3,b2t=20,w2t=/^[A-Za-z0-9_\-+/=.]+$/,x2t=new RegExp(`^[^${Gc}@]+@[^${Gc}@]+\\.[A-Za-z]{2,}$`),S2t=/^[\w.-]+(?:\/[\w.-]+)+$/,Q2t=/\.[A-Za-z][A-Za-z0-9]{0,7}$/,k2t=/^v?\d+(?:\.\d+)+(?:[-+][0-9A-Za-z.-]+)?$/,_2t=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,P2t=/^[\w.-]+:\d{2,5}$/,T2t=/^(?:[0-9a-f]{7,12}|[0-9a-f]{40})$/i,X2t=/^[a-z]+(?:_[a-z]+)+$/,R2t=/^[a-z]+(?:-[a-z]+)+$/,E2t=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$/,q2t=/^[a-z0-9]+(?:-[a-z0-9]+)+$/,j2t=/\d{4,}/,hK=e=>{const t=e.trim();return t.length<f2t||t.length>h2t||Ys.test(t)||p2t.test(t)||m2t.test(t)||dA(t)!==null||x2t.test(t)||S2t.test(t)||Q2t.test(t)||k2t.test(t)||_2t.test(t)||P2t.test(t)||T2t.test(t)||X2t.test(t)||R2t.test(t)||E2t.test(t)||q2t.test(t)&&j2t.test(t)||g2t.test(t)||$2t.test(t)?!1:y2t.filter(r=>r.test(t)).length>=v2t?!0:t.length>=b2t&&w2t.test(t)},hSe=T("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),pSe=T("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),mSe=({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:T("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?pSe:hSe,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?f.jsx(yce,{"aria-hidden":"true",className:"size-3 shrink-0"}):f.jsx(V7e,{"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(oi,{"aria-hidden":"true",className:"size-3"})}),r&&f.jsx("span",{className:"sr-only",children:r})]}),hy="#lo-credential/",C2t=`${hy}unstored`,pK=`${hy}unconfirmed`,z2t=/^\d+$/,gSe=e=>e.kind==="stored"?`${hy}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${pK}/${e.key}`:pK:C2t;function A2t(e){if(!e||!e.startsWith(hy))return null;const t=e.slice(hy.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return A6.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!A6.test(r)||!z2t.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function mK(e,t){const n=A2t(e);if(n===null)return null;const r=I_(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return gSe(i)!==e?null:n}const D_=()=>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=I_(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:gSe(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},U2t=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?JTt(e.key):"Credential not stored",W2t=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?t2t(t):t,N2t=({citation:e,title:t})=>f.jsx(mSe,{tone:e.kind==="stored"?"live":"warning",label:U2t(e),chars:e.kind==="stored"?e.chars:null,title:W2t(e,t),className:"align-middle"}),Y2t=(e,t)=>typeof t=="string"?mK(e,t):t==null?mK(e,""):null,G2t=e=>({href:t,title:n,children:r})=>{const i=Y2t(t,r);if(i===null){const a=e;return f.jsx(a,{href:t,title:n,children:r})}return f.jsx(N2t,{citation:i,title:n})},$Se=e=>LJe(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",dW=e=>{const t=$Se(e);return t==="other"?"path":t},XX={id:"open-file",get label(){return m("ui.common.file_actions.open_file")}},Z2t={id:"show-in-canvas",get label(){return m("ui.common.file_actions.show_in_canvas")}},I2t={id:"save-as",get label(){return m("ui.chat.image_actions.save_as")}},RX={id:"open-folder",get label(){return m("ui.common.file_actions.open_folder")}},EX={id:"copy-file-path",get label(){return m("ui.common.file_actions.copy_file_path")}},vh={id:"copy-image",get label(){return m("ui.chat.image_actions.copy_image")}},D2t={id:"copy-image-url",get label(){return m("ui.chat.image_actions.copy_image_url")}},V2t={id:"open-in-browser",get label(){return m("ui.chat.image_actions.open_in_browser")}};function ySe(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const o=[...t?[Z2t]:[],...a?[{id:"expand-image",get label(){return m("ui.chat.image_actions.expand_image")}}]:[]];switch(e){case"artifact":return[...o,...i?[XX,RX,EX]:[],I2t,...r==="video"||r==="audio"?[]:[vh]];case"path":return[...o,XX,RX,EX,...r==="video"||r==="audio"?[]:[vh]];case"data":return[...o,vh];case"blob":return i?[...o,XX,RX,EX,vh]:[vh];case"http":return[...M2t(n)?[vh]:[],D2t,V2t];case"other":return[]}}const vSe=(e,t)=>ySe(e,t).length>0;function M2t(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 fW=e=>e.startsWith("file://")?e.slice(7):e;function bSe(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 gK(e,t,n){if(e==="data")return bSe(t);if(e==="blob"){const o=gue(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=fW(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:Xp(i)})}const L2t=e=>e.trim().toLowerCase()!=="image/png";async function F2t(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!L2t(e.type))return e;const t=URL.createObjectURL(e);try{const n=await B2t(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 B2t(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 H2t=6e4;function K2t(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),H2t)}const ux=new Map;function J2t(e,t){const n=ux.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await is(e.childId?{op:"subagents.attachment",sessionId:e.sessionId,childId:e.childId,digest:t}:{op:"sessions.attachment",sessionId:e.sessionId,digest:t},null);if(i.kind!=="bytes")return null;const a=kk(i.data,i.mimeType);return r.holders<=0?(pv(a),null):(L9(t,a),a)}catch{return null}finally{ux.delete(t)}})(),ux.set(t,r),r.promise}class hW extends Error{constructor(){super("This item is no longer in the session"),this.name="AttachmentGoneError"}}async function wSe(e,t){const n=E$(t),r=n?gue(n):null;if(r)return r;const i=await is(e.childId?{op:"subagents.attachment",sessionId:e.sessionId,childId:e.childId,digest:t}:{op:"sessions.attachment",sessionId:e.sessionId,digest:t},null);if(i.kind!=="bytes")throw i.status===404?new hW:new Error("These bytes are not available right now");return new Blob([i.data],{type:i.mimeType})}function eXt(e){const t=ux.get(e);t&&(t.holders-=1)}function Mv(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=$.useState(()=>e.attachment?E$(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=_p(u);if(d)return i(d),o(!1),()=>{O=!1,Pp(u)};i(null),o(!1);let h=!0;return J2t({sessionId:s,childId:l},u).then(p=>{if(h=!1,!!O){if(!p){o(!0);return}i(_p(u))}}),()=>{O=!1,h&&eXt(u),Pp(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 pW(e,t){return Mv(e,t)}const Cdn=Object.freeze(Object.defineProperty({__proto__:null,AttachmentGoneError:hW,fetchAttachmentBlob:wSe,useAttachmentSource:Mv,useAttachmentUrl:pW},Symbol.toStringTag,{value:"Module"})),tXt={"expand-image":f.jsx(Lce,{"aria-hidden":"true"}),"open-file":f.jsx(Ov,{"aria-hidden":"true"}),"show-in-canvas":f.jsx(Mce,{"aria-hidden":"true"}),"save-as":f.jsx(vk,{"aria-hidden":"true"}),"open-folder":f.jsx(kp,{"aria-hidden":"true"}),"copy-file-path":f.jsx(C9,{"aria-hidden":"true"}),"copy-image":f.jsx(vf,{"aria-hidden":"true"}),"copy-image-url":f.jsx(B7e,{"aria-hidden":"true"}),"open-in-browser":f.jsx(bk,{"aria-hidden":"true"})},$K=(e,t,n)=>n instanceof hW?t:e;function nXt({file:e,src:t,resolvePath:n,missing:r,onShowInCanvas:i,mediaKind:a,onExpand:o,saveName:s}){return ySe(dW(e),{canShowInCanvas:!!i,source:t??e,mediaKind:a,artifactPathActions:!!n,canExpand:!!o}).filter(l=>(l.id!=="save-as"||!!s)&&(!r||l.id==="copy-file-path"))}const xSe=({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=dW(e),v=nXt({file:e,src:t,resolvePath:s,missing:l,onShowInCanvas:c,mediaKind:u,onExpand:O,saveName:d});if(v.length===0)return null;const b=async(k,P,X)=>{try{await navigator.clipboard.writeText(k),OO(P)}catch(E){console.error(`${X}: `,E),Rr(X)}},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 gK(y,e,t),P=await F2t(k);await navigator.clipboard.write([new ClipboardItem({[P.type]:P})]),OO(m("ui.notices.files.image_copied"))}catch(k){console.error("Failed to copy image: ",k),Rr($K(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 gK(y,e,t);K2t(k,d??"download")}catch(k){console.error("Failed to save file: ",k),Rr($K(m("ui.notices.files.save_failed"),m("ui.notices.files.save_failed_gone"),k))}},w=async k=>{let P=fW(e);if(s&&["open-file","open-folder","copy-file-path"].includes(k.id))try{P=await s()}catch{Rr(m("ui.canvas.files.prepareError"));return}switch(k.id){case"expand-image":O?.();return;case"open-file":xO(P);return;case"open-folder":sW(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":lW(t??e);return}},S=g??`Actions for ${n??"this image"}`;return f.jsxs(w9,{open:r,onOpenChange:i,children:[f.jsx(vt,{content:p,children:f.jsx(x9,{asChild:!0,children:f.jsx(Qe,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":S,tabIndex:o,onClick:k=>k.stopPropagation(),children:f.jsx(jj,{"aria-hidden":"true"})})})}),f.jsxs(S9,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:k=>k.stopPropagation(),children:[s&&f.jsx("div",{role:"note",className:T("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:m("ui.canvas.files.pathCopyNote")}),v.map(k=>f.jsxs(gl,{onSelect:()=>w(k),children:[tXt[k.id],f.jsx("span",{children:k.label})]},k.id))]})]})},rXt=({src:e,alt:t,title:n,className:r})=>{const i=Iv(),a=e??"",o=$Se(a);if(o==="other")return f.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=vSe(o,{canShowInCanvas:s,source:a});return f.jsxs("span",{className:T("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:T("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(xSe,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||xO(fW(a))})}:void 0})})]})};function iXt(){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 aXt={tokenize:oXt,concrete:!0,name:"mathFlow"},yK={tokenize:sXt,partial:!0};function oXt(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"),an(e,c,"whitespace")(b))}function c(b){return b===null||yt(b)?O(b):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(b))}function u(b){return b===null||yt(b)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),O(b)):b===36?n(b):(e.consume(b),u)}function O(b){return e.exit("mathFlowFence"),r.interrupt?t(b):e.attempt(yK,d,y)(b)}function d(b){return e.attempt({tokenize:v,partial:!0},y,h)(b)}function h(b){return(a?an(e,p,"linePrefix",a+1):p)(b)}function p(b){return b===null?y(b):yt(b)?e.attempt(yK,d,y)(b):(e.enter("mathFlowValue"),g(b))}function g(b){return b===null||yt(b)?(e.exit("mathFlowValue"),p(b)):(e.consume(b),g)}function y(b){return e.exit("mathFlow"),t(b)}function v(b,x,Q){let w=0;return an(b,S,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function S(X){return b.enter("mathFlowFence"),b.enter("mathFlowFenceSequence"),k(X)}function k(X){return X===36?(w++,b.consume(X),k):w<o?Q(X):(b.exit("mathFlowFenceSequence"),an(b,P,"whitespace")(X))}function P(X){return X===null||yt(X)?(b.exit("mathFlowFence"),x(X)):Q(X)}}}function sXt(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 lXt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:cXt,previous:uXt,name:"mathText"};function r(i,a,o){let s=0,l,c;return u;function u(g){return i.enter("mathText"),i.enter("mathTextSequence"),O(g)}function O(g){return g===36?(i.consume(g),s++,O):s<2&&!n?o(g):(i.exit("mathTextSequence"),d(g))}function d(g){return g===null?o(g):g===36?(c=i.enter("mathTextSequence"),l=0,p(g)):g===32?(i.enter("space"),i.consume(g),i.exit("space"),d):yt(g)?(i.enter("lineEnding"),i.consume(g),i.exit("lineEnding"),d):(i.enter("mathTextData"),h(g))}function h(g){return g===null||g===32||g===36||yt(g)?(i.exit("mathTextData"),d(g)):(i.consume(g),h)}function p(g){return g===36?(i.consume(g),l++,p):l===s?(i.exit("mathTextSequence"),i.exit("mathText"),a(g)):(c.type="mathTextData",h(g))}}}function cXt(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 uXt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function OXt(e){return{flow:{36:aXt},text:{36:lXt()}}}const Hh=36,vK=e=>e!==null&&e<-2,bK=e=>e===null||e===32||e<0,wK=e=>e!==null&&e>=48&&e<=57,SSe=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:dXt,previous:fXt,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===Hh?(r.consume(y),s++,d):s<2&&!t||s===1&&(bK(y)||wK(y))?a(y):(r.exit("mathTextSequence"),h(y))}function h(y){return y===null?a(y):y===Hh?(u=r.enter("mathTextSequence"),c=0,l=o.previous,g(y)):y===32?(r.enter("space"),r.consume(y),r.exit("space"),h):vK(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===Hh||vK(y)?(r.exit("mathTextData"),h(y)):(r.consume(y),p)}function g(y){return y===Hh?(r.consume(y),c++,g):c===s?s===1&&(bK(l)||wK(y))?a(y):(r.exit("mathTextSequence"),r.exit("mathText"),i(y)):(u.type="mathTextData",p(y))}}};function dXt(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 fXt(e){return e!==Hh||this.events[this.events.length-1][1].type==="characterEscape"}const hXt=OXt().flow,pXt=SSe();function V_(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?pXt:SSe(e);n.push({flow:hXt,text:{[Hh]:i}}),r.push(iXt())}const QSe=({node:e,...t})=>f.jsx("div",{className:"lo-md-table-scroll",children:f.jsx("table",{...t})}),mXt=/\$(?!\d)(.+?)\$/,gXt=/\$\$([\s\S]+?)\$\$/,$Xt=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,yXt=/\\[a-zA-Z]+(\{[^}]*\})?/,xK=e=>mXt.test(e)||gXt.test(e)||$Xt.test(e)?!0:yXt.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),vXt=e=>{const t=I_(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},bXt=e=>I_(e).filter(t=>t.kind!=="text").length,wXt=e=>{if(!xK(e))return!1;const t=vXt(e);return t===null?!0:xK(t)||t.includes("$")?!1:bXt(e)<2},kSe=Object.freeze(["canvas","surface","ink","inkMuted","accent","borderControl"]),_Se=Object.freeze(k9.filter(e=>!["overlayShadow","scrim"].includes(e))),PSe=65536,TSe=/^#[0-9a-fA-F]{6}$/,xXt=(e,t)=>Object.hasOwn(e,t),SK=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&[Object.prototype,null].includes(Object.getPrototypeOf(e)),pa=e=>{throw new Error(e)},SXt={canvas:["surface","elevated","sunken","messageSurface","mediaSurface","rowHover","rowSelected","accentWash","accentAltWash","successWash","warningWash","dangerWash","infoWash"],surface:["elevated","rowHover","rowSelected"],ink:["inkMuted","inkDim","inkDisabled"],inkMuted:["inkDim"],accent:["accentHover","accentActive","accentWash","chartBarHover"],borderControl:["hairline","hairlineStrong"]},py=(e,t)=>{const n={...e};for(const r of kSe){const i=DRe(t.seeds?.[r]);if(!i)continue;const a=h5(e[r]),o=h5(i);n[r]=i;for(const s of SXt[r]){const l=h5(e[s]);n[s]=VRe({l:o.l+l.l-a.l,c:a.c>.01?o.c*l.c/a.c:l.c,h:o.h+l.h-a.h})}}n.accent.toUpperCase()!==e.accent.toUpperCase()&&(n.onAccent=MRe(n.accent,[e.onAccent,n.ink,n.canvas,"#000000","#FFFFFF"]));for(const r of _Se)TSe.test(t.overrides?.[r]??"")&&(n[r]=t.overrides[r]);for(const r of["overlayShadow","scrim"]){const i=t.overrides?.[r];typeof i=="string"&&/^(0(?:\.\d{1,3})?|1(?:\.0{1,3})?)$/.test(i)&&(n[r]=e[r].replace(/\/\s*[\d.]+\)/,`/ ${i})`))}return n},mW=(e,t)=>ZRe(e,t),zdn=(e,t)=>{const n=py(e,t),r=BRe(n,t.base,e,{pinned:Object.keys(t.overrides??{}),maxEvaluations:320,lightnessOnly:!0}).palette;if(!r||Object.keys(t.overrides??{}).some(s=>r[s]!==n[s]))return null;const a={...t.overrides};for(const s of _Se)r[s]!==n[s]&&(a[s]=r[s]);const o={...t,overrides:a};return mW(py(e,o),t.base).length?null:o},XSe=(e,t,{id:n="custom-import",now:r=Date.now()}={})=>{(typeof e!="string"||new TextEncoder().encode(e).length>PSe)&&pa("import_size");let i;try{i=JSON.parse(e)}catch{pa("import_invalid_json")}SK(i)||pa("import_format");const a=new Set(["format","version","name","base","seeds","overrides","id","updatedAt"]);Object.keys(i).some(s=>!a.has(s))&&pa("import_unsafe"),i.format!=="local-operator-theme"&&pa("import_format"),i.version!==1&&pa("import_version"),(typeof i.base!="string"||!t(i.base))&&pa("import_base"),(typeof i.name!="string"||!i.name.trim()||i.name.trim().length>60)&&pa("import_name");const o={};for(const s of["seeds","overrides"]){(!xXt(i,s)||!SK(i[s]))&&pa("import_roles");const l={};for(const[c,u]of Object.entries(i[s]))(!(s==="seeds"?kSe:k9).includes(c)||typeof u!="string")&&pa("import_roles"),["overlayShadow","scrim"].includes(c)?(/^(0(?:\.\d{1,3})?|1(?:\.0{1,3})?)$/.test(u)||pa("import_roles"),l[c]=u):(TSe.test(u)||pa("import_roles"),l[c]=u.toUpperCase());o[s]=l}return{format:"local-operator-theme",version:1,id:n,name:i.name.trim(),base:i.base,...o,updatedAt:r}},QXt=(e,t)=>{if(e==null)return[];(typeof e!="string"||e.length>PSe*kx)&&pa("load_error");let n;try{n=JSON.parse(e)}catch{pa("load_error")}const r=Array.isArray(n)?n:n?.version===1?n.themes:null;Array.isArray(r)||pa("load_error");const i=[],a=new Set;for(const o of r.slice(0,kx))try{const s=IRe(o,{isThemeName:t,isRole:c=>k9.includes(c)});if(!s||a.has(s.id))continue;const l=XSe(JSON.stringify(o),t,{id:s.id,now:s.updatedAt});i.push(l),a.add(l.id)}catch{}return i},kXt=e=>JSON.stringify({format:"local-operator-theme",version:1,name:e.name,base:e.base,seeds:e.seeds,overrides:e.overrides},null,2),Adn=(e,t)=>{const n=new Set(t.map(r=>r.name));if(!n.has(e))return e;for(let r=2;r<=kx+1;r++){const i=`${e.slice(0,54)} (${r})`;if(!n.has(i))return i}return e},Udn=(e,t)=>{const n=LRe({composed:!0,capturePairs:!0});return FRe(n,{id:t,palette:e}),{findings:n.log,readings:n.readings}};let SO={themes:[],error:!1,loading:!1};const W6=new Set,RSe=()=>{for(const e of W6)e()},QK=()=>SO,_Xt=e=>(W6.add(e),()=>{W6.delete(e)}),kK=()=>{try{SO={themes:QXt(localStorage.getItem(u9),Yle).filter(t=>{const n=i9(t.base)?.palette;return n&&mW(py(n,t),t.base).length===0}),error:!1,loading:!1}}catch{SO={themes:[],error:!0,loading:!1}}RSe()},gW=()=>$.useSyncExternalStore(_Xt,QK,QK),PXt=e=>SO.themes.find(t=>t.id===e),ESe=e=>{localStorage.setItem(u9,JSON.stringify({version:1,themes:e})),SO={themes:e,error:!1,loading:!1},RSe()},Wdn=e=>{const t=HRe(e.id);if(!t)throw new Error("invalid custom theme id");const n=XSe(kXt(e),Yle,{id:t,now:e.updatedAt}),r=i9(n.base)?.palette;if(!r||mW(py(r,n),n.base).length)throw new Error("contrast");if(!PXt(n.id)&&SO.themes.length>=kx)throw new Error("limit");ESe([n,...SO.themes.filter(i=>i.id!==n.id)])},Ndn=e=>ESe(SO.themes.filter(t=>t.id!==e));typeof window<"u"&&(kK(),window.addEventListener("storage",e=>{(e.key===u9||e.key===null)&&kK()}));const TXt=()=>{const e=Yt(i=>i.themeName),t=Yt(i=>i.contrast),n=Yt(i=>i.accent),r=Yt(i=>i.customThemeId);return $.useMemo(()=>({themeName:e,contrast:t,accent:n,customThemeId:r}),[e,t,n,r])},XXt=e=>{const t=e?i9(e.base)?.palette:void 0;return t&&e?py(t,e):void 0},RXt=()=>{const e=TXt(),t=gW();return $.useMemo(()=>{const n=t.themes.find(a=>a.id===e.customThemeId),r=XXt(n),i=n?.base;return{appearance:e,savedPalette:r,savedBase:i,resolved:KRe(e,r,i)}},[e,t])},M_=()=>RXt().resolved,Ydn=()=>M_().palette.mode==="dark",Lt="var(--color-ink)",tc="var(--color-ink-muted)",cl="var(--color-surface)",Pu="var(--color-elevated)",nc="var(--color-sunken)",Fi="var(--color-hairline)",Tu="var(--color-control)",bh="var(--color-accent)",T0="var(--color-accent-wash)",EXt="var(--color-accent-alt-wash)",qXt="var(--color-on-accent)",jXt="var(--color-info)",qSe="var(--color-info-wash)",CXt="var(--color-success)",jSe="var(--color-success-wash)",zXt="var(--color-warning)",N6="var(--color-warning-wash)",AXt="var(--color-warning-border)",qX="var(--color-danger)",Y6="var(--color-danger-wash)",_K=[T0,EXt,qSe,jSe,N6,Y6],Xu=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),UXt=()=>{const e={primaryColor:Xu("--color-accent"),secondaryColor:Xu("--color-success"),tertiaryColor:Xu("--color-info"),mainBkg:Xu("--color-elevated"),clusterBkg:Xu("--color-sunken"),clusterBorder:Xu("--color-hairline"),edgeLabelBackground:Xu("--color-surface"),quadrant1Fill:Xu("--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:cl,primaryTextColor:Lt,primaryBorderColor:Tu,secondaryTextColor:Lt,secondaryBorderColor:Fi,tertiaryTextColor:Lt,tertiaryBorderColor:Fi,lineColor:tc,arrowheadColor:tc,textColor:Lt,secondBkg:nc,border1:Tu,border2:Fi,labelColor:Lt,nodeBkg:Pu,nodeBorder:Tu,nodeTextColor:Lt,defaultLinkColor:tc,titleColor:Lt,noteBkgColor:N6,noteBorderColor:AXt,noteTextColor:Lt,actorBkg:Pu,actorBorder:Tu,actorTextColor:Lt,actorLineColor:Fi,signalColor:tc,signalTextColor:Lt,labelBoxBkgColor:Pu,labelBoxBorderColor:Fi,labelTextColor:Lt,loopTextColor:Lt,activationBkgColor:T0,activationBorderColor:bh,sequenceNumberColor:cl,sectionBkgColor:nc,sectionBkgColor2:cl,altSectionBkgColor:nc,excludeBkgColor:nc,taskBkgColor:T0,taskBorderColor:Tu,taskTextColor:Lt,taskTextLightColor:Lt,taskTextDarkColor:Lt,taskTextOutsideColor:Lt,taskTextClickableColor:bh,activeTaskBkgColor:T0,activeTaskBorderColor:bh,gridColor:Fi,doneTaskBkgColor:nc,doneTaskBorderColor:Fi,critBkgColor:Y6,critBorderColor:qX,todayLineColor:bh,transitionColor:tc,transitionLabelColor:Lt,stateLabelColor:Lt,stateBkg:Pu,labelBackgroundColor:cl,compositeBackground:nc,altBackground:nc,compositeTitleBackground:Pu,compositeBorder:Fi,innerEndBackground:Lt,specialStateColor:Lt,classText:Lt,attributeBackgroundColorOdd:cl,attributeBackgroundColorEven:nc,rowOdd:cl,rowEven:nc,errorBkgColor:Y6,errorTextColor:qX,pieTitleTextColor:Lt,pieSectionTextColor:Lt,pieLegendTextColor:Lt,pieStrokeColor:cl,pieOuterStrokeColor:Fi,requirementBackground:Pu,requirementBorderColor:Tu,requirementTextColor:Lt,relationColor:tc,relationLabelBackground:cl,relationLabelColor:Lt,branchLabelColor:qXt,commitLabelColor:Lt,commitLabelBackground:cl,tagLabelColor:Lt,tagLabelBackground:T0,tagLabelBorder:Tu,quadrant2Fill:qSe,quadrant3Fill:jSe,quadrant4Fill:N6,quadrant2TextFill:Lt,quadrant3TextFill:Lt,quadrant4TextFill:Lt,quadrantPointFill:bh,archEdgeColor:tc,archEdgeArrowColor:tc,archGroupBorderColor:Fi,scaleLabelColor:Lt,packet:{startByteColor:Lt,endByteColor:Lt,labelColor:Lt,titleColor:Lt,blockStrokeColor:Tu,blockFillColor:Pu},radar:{axisColor:tc,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:Fi,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:cl,titleColor:Lt,xAxisTitleColor:Lt,xAxisLabelColor:Lt,xAxisTickColor:Fi,xAxisLineColor:Fi,yAxisTitleColor:Lt,yAxisLabelColor:Lt,yAxisTickColor:Fi,yAxisLineColor:Fi,plotColorPalette:[bh,jXt,CXt,zXt,qX].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Pu,t[`surfacePeer${n}`]=Fi;for(let n=0;n<8;n++)t[`fillType${n}`]=_K[n%_K.length];return{...t,...e}};let jX=null,PK=null;const WXt=async e=>{jX||(jX=ve(async()=>{const{default:n}=await import("./mermaid.core-C3_jDZhe.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([10,1,2,3]),import.meta.url).then(({default:n})=>n));const t=await jX;return PK!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:UXt()}),PK=e),t},TK=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>f.jsxs("div",{"data-lo-floating":"",className:T("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[f.jsx(vt,{content:m("ui.chat.mermaid.zoom_in"),children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.zoom_in"),onClick:n,children:f.jsx(tue,{})})}),f.jsx(vt,{content:m("ui.chat.mermaid.zoom_out"),children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.zoom_out"),onClick:r,children:f.jsx(nue,{})})}),f.jsx(vt,{content:m("ui.chat.mermaid.pan_hint"),children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.pan"),children:f.jsx(y6e,{})})}),f.jsx(vt,{content:m("ui.chat.mermaid.reset_view"),children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.reset_view"),onClick:i,children:f.jsx(xk,{})})}),f.jsx(vt,{content:m("ui.chat.mermaid.save_svg"),children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.save_svg"),onClick:a,children:f.jsx(vk,{})})}),f.jsx(vt,{content:t?m("ui.chat.mermaid.copied"):m("ui.chat.mermaid.copy_text"),children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":t?m("ui.chat.mermaid.copied"):m("ui.chat.mermaid.copy_text"),onClick:o,children:f.jsx(vf,{className:T(t&&"text-success")})})}),s]}),G6=({title:e,children:t})=>f.jsxs(Xl,{variant:"danger",role:"alert",className:"my-4",children:[f.jsx(A0,{children:e}),f.jsx(U0,{children:t})]});class NXt 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(G6,{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 YXt=$.memo(({chart:e,id:t})=>{we();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=M_().id,X=$.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 Y=await WXt(P),le=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:F}=await Y.render(le,e);if(!F||typeof F!="string"||F.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(F)}catch(Y){console.error("Mermaid rendering error:",Y);const le=Y instanceof Error?Y.message:"Failed to render mermaid diagram";a(le),c("")}finally{s(!1)}},[e,t,P]);$.useEffect(()=>{X().catch(Y=>{console.error("Error in renderDiagram effect:",Y),a("Failed to initialize diagram rendering"),s(!1)})},[X]);const E=$.useCallback(()=>{try{if(!l||!r.current)return 1;const le=r.current.getBoundingClientRect(),F=document.createElement("div");F.innerHTML=l;const H=F.querySelector("svg");if(!H)return 1;const se=H.getBoundingClientRect?.()?.width||Number.parseFloat(H.getAttribute("width")||"0")||H.viewBox?.baseVal?.width||800,ee=H.getBoundingClientRect?.()?.height||Number.parseFloat(H.getAttribute("height")||"0")||H.viewBox?.baseVal?.height||600,L=le.width*.9/se,ne=le.height*.9/ee;return Math.min(L,ne,1)}catch(Y){return console.error("Error calculating fullscreen scale:",Y),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const Y=E();g({scale:Y,x:0,y:0})}catch(Y){console.error("Error setting fullscreen transform:",Y)}},100)},[u,l,E]);const R=$.useCallback((Y=!1)=>{try{(Y?g:h)(F=>({...F,scale:Math.min(F.scale*1.2,10)}))}catch(le){console.error("Error in zoom in:",le)}},[]),q=$.useCallback((Y=!1)=>{try{(Y?g:h)(F=>({...F,scale:Math.max(F.scale/1.2,.1)}))}catch(le){console.error("Error in zoom out:",le)}},[]),C=$.useCallback((Y=!1)=>{try{const le=Y?g:h;if(Y){const F=E();le({scale:F,x:0,y:0})}else le({scale:1,x:0,y:0})}catch(le){console.error("Error in reset:",le)}},[E]),z=$.useCallback(()=>{if(l)try{const Y=new Blob([l],{type:"image/svg+xml"}),le=URL.createObjectURL(Y),F=document.createElement("a");F.href=le,F.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(le)}catch(Y){console.error("Failed to save SVG:",Y)}},[l]),W=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),w("copied"),setTimeout(()=>w("idle"),1200)}catch(Y){console.error("Failed to copy Mermaid chart text:",Y)}},[e]),G=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),k("copied"),setTimeout(()=>k("idle"),1200)}catch(Y){console.error("Failed to copy Mermaid chart text:",Y)}},[e]),A=$.useCallback(Y=>{try{v(!0),x({x:Y.clientX,y:Y.clientY}),Y.preventDefault()}catch(le){console.error("Error in mouse down:",le)}},[]),I=$.useCallback((Y,le=!1)=>{try{if(!y)return;const F=Y.clientX-b.x,H=Y.clientY-b.y;(le?g:h)(ee=>({...ee,x:ee.x+F,y:ee.y+H})),x({x:Y.clientX,y:Y.clientY})}catch(F){console.error("Error in mouse move:",F)}},[y,b]),Z=$.useCallback(()=>{try{v(!1)}catch(Y){console.error("Error in mouse up:",Y)}},[]),U=$.useCallback((Y,le=!1)=>{try{Y.preventDefault();const F=Y.deltaY>0?.9:1.1;(le?g:h)(se=>({...se,scale:Math.min(Math.max(se.scale*F,.1),5)}))}catch(F){console.error("Error in wheel:",F)}},[]),D=$.useCallback(Y=>{try{O(Y)}catch(le){console.error("Error toggling fullscreen:",le)}},[]);if(i)return f.jsxs(G6,{title:m("ui.chat.mermaid.error_title"),children:[i,f.jsx("span",{className:T("mt-2 block text-ink-muted"),children:m("ui.chat.mermaid.chart_label")}),f.jsx("span",{className:T("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const K=(Y=!1)=>{try{const le=Y?r:n,F=Y?p:d;return f.jsx("div",{ref:le,className:T("mermaid flex w-full items-center justify-center",Y?"h-full min-h-full":"h-auto min-h-50",y?"cursor-grabbing":"cursor-grab"),onMouseDown:A,onMouseMove:H=>I(H,Y),onMouseUp:Z,onMouseLeave:Z,onWheel:H=>U(H,Y),children:o?f.jsx("div",{className:T("p-4 text-body-sm text-ink-muted"),children:m("ui.chat.mermaid.loading")}):l?f.jsx("div",{className:T("flex h-full w-full items-center justify-center"),style:{transform:`translate(${F.x}px, ${F.y}px) scale(${F.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(le){return console.error("Error rendering diagram content:",le),f.jsx(G6,{title:m("ui.chat.mermaid.rendering_error"),children:m("ui.chat.mermaid.render_failed")})}};return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:T("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:[K(!1),f.jsx(TK,{className:"top-2 right-2",copied:Q==="copied",onZoomIn:()=>R(!1),onZoomOut:()=>q(!1),onReset:()=>C(!1),onSave:z,onCopy:W,children:f.jsx(vt,{content:m("ui.chat.mermaid.fullscreen"),children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.open_fullscreen"),onClick:()=>D(!0),children:f.jsx(Lce,{})})})})]}),f.jsx(R$,{open:u,onClose:()=>D(!1),title:m("ui.chat.mermaid.diagram_title"),maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:f.jsxs("div",{className:T("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:[K(!0),f.jsx(TK,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>R(!0),onZoomOut:()=>q(!0),onReset:()=>C(!0),onSave:z,onCopy:G,children:f.jsx(vt,{content:m("ui.chat.mermaid.close_fullscreen"),children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.close_fullscreen"),onClick:()=>D(!1),children:f.jsx(oi,{})})})})]})})]})}),GXt=$.memo(e=>f.jsx(NXt,{children:f.jsx(YXt,{...e})}));let CSe=!1,CX=null;const ZXt=()=>(CX||(CX=ve(()=>Promise.resolve({}),__vite__mapDeps([11]),import.meta.url).then(e=>(CSe=!0,e))),CX),IXt=/language-(\w+)/,DXt=O9,VXt=new RegExp(`^[^${Gc}\\d*+-]`),MXt=/\n$/,zSe=({href:e,children:t})=>{const n=qxe(e),r=Iv();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=>BXt(i,r):void 0,children:t})},LXt=e=>qxe(e)?.kind==="file",FXt=Axe,BXt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(zxe)??"file",i=n.getAttribute(FXt),a=r5t({kind:r,hasHighlight:b5t(n),canOpenInCanvas:oW(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||xO(i)});return}xO(i)}},Z6=(e,t)=>t==="href"&&LXt(e)?e:Bfe(e),my={a:zSe,table:QSe,img:rXt,code:({node:e,className:t,children:n,...r})=>IXt.exec(t??"")?.[1]==="mermaid"?f.jsx(GXt,{chart:String(n).replace(MXt,"")}):f.jsx("code",{dir:"ltr",className:t,...r,children:n})},HXt={...my,a:G2t(zSe)},KXt=[Gs],JXt=[Gs,V_],eRt=[Gs,Y_],tRt=[Gs,V_,Y_],nRt=[Gs,D_,G_],rRt=[Gs,V_,D_,G_],iRt=[Gs,Y_,D_,G_],aRt=[Gs,V_,Y_,D_,G_],oRt={"000":KXt,"001":nRt,"010":eRt,"011":iRt,100:JXt,101:rRt,110:tRt,111:aRt},sRt=[],lRt=[zHe],ASe=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),USe=(e,t,n,r)=>{const i=$.useMemo(()=>wXt(e),[e]),[a,o]=$.useState(CSe),s=i&&a;$.useEffect(()=>{if(!i||a)return;let O=!1;return ZXt().then(()=>{O||o(!0)}),()=>{O=!0}},[i,a]);const l=oRt[`${s?1:0}${t?1:0}${n?1:0}`],c=n&&r?r.join("\0"):"";return{remarkPlugins:$.useMemo(()=>c===""?l:[[uTt,{names:c.split("\0")}],...l],[l,c]),rehypePlugins:s?lRt:sRt}},WSe=(e,t,n)=>{const[,r]=$.useState(0);$.useEffect(()=>{if(!t)return;const i=pet(e);if(i.length===0)return;let a=!0;const o=new Set(i),s=s5t(l=>{a&&l.some(c=>o.has(c))&&r(c=>c+1)});return aW(i,window.api?.probeFiles,Kle,a5t(n===void 0?e:`${n}\0${e}`)).then(()=>{a&&i.some(l=>Cxe(l)!=="unknown")&&r(l=>l+1)}),()=>{a=!1,s()}},[e,t,n])},gy=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1,skillNames:a,documentId:o})=>{const s=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:l,rehypePlugins:c}=USe(s,r,i,a),u=ASe(t);return WSe(s,r,o),f.jsx("div",{className:T("lo-markdown",n),style:u,children:f.jsx(Fx,{remarkPlugins:l,rehypePlugins:c,urlTransform:Z6,components:i?HXt:my,children:s})})});gy.displayName="MarkdownRenderer";const XK={...my,a:({children:e})=>f.jsx(f.Fragment,{children:e})},NSe=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:tK(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=Bxe(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=USe(n,t,!1);if(WSe(e,t),r!==null){const o=tK(r.before);return f.jsxs(f.Fragment,{children:[o.trim()!==""&&f.jsx(Fx,{remarkPlugins:i,rehypePlugins:a,urlTransform:Z6,components:t?my:XK,children:o}),f.jsx(cRt,{info:r.info,body:r.body})]})}return f.jsx(Fx,{remarkPlugins:i,rehypePlugins:a,urlTransform:Z6,components:t?my:XK,children:n})});NSe.displayName="ParsedBlock";const cRt=({info:e,body:t})=>{const n=e.split(DXt)[0];return f.jsx("pre",{children:f.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
913
+ `)&&(s={capture:BS(e),buffer:n,caret:r})}return{...s,capture:Bh(s.capture,s.buffer,s.caret,i)}}function TTt(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=Cf(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=dSe(i,t.value),c=l+Z_,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:Ga,buffer:u,caret:s+c.length,payload:{index:i,key:fSe(a,e.draw),value:t.value,marker:l}}}const XTt=e=>Wa(e)&&e.value!=="";function RTt(e,t){const n=Cf(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:Ga,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 ETt(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function qTt(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=Cf(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:BS(e),buffer:i,caret:a,payload:null}}function jTt(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=OW(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=Bn(i);if(!a)return i===""?null:qTt(t,n,e.selection,i);const o=t.arm,s=dSe(e.index,a),l=s+Z_,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:Ga,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:fSe(e.taken,e.draw),value:a,marker:s}}}const OSe=e=>`${bTt(e)} chars`,dSe=(e,t)=>`[Credential #${e}, ${OSe(t)}]`;function CTt(e){_l.lastIndex=0;const t=_l.exec(e);return _l.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function zTt(e){_l.lastIndex=0;const t=_l.exec(e);if(_l.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 Vv(e,t){if(CTt(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const _X=/\[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,PX=/\[credential NOT stored \u2014 [^\]\n]*\]/y,TX=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,ATt=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&A6.test(t[1])?t[1]:""};function UTt(e,t){if(e.charCodeAt(t)!==91)return null;_X.lastIndex=t;const n=_X.exec(e);if(_X.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};PX.lastIndex=t;const r=PX.exec(e);if(PX.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};TX.lastIndex=t;const i=TX.exec(e);return TX.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:ATt(i[0])}:null}function I_(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=UTt(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 lK(e,t){const n=[];for(const r of t){const i=Vv(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 WTt(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 NTt=e=>`[credential ${e.key} (${OSe(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function YTt(e,t,n=new Map){const r=[...t],i=[];for(const o of r){const s=Vv(e,o);s!==null&&i.push({span:s,payload:o})}for(const o of sSe(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?WTt(l??"lost",s?.key):NTt(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const GTt=(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.`,ZTt=e=>`Remove credential #${e}`,ITt=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,DTt=(e,t,n)=>GTt(e,t,n),VTt="Undo",MTt=e=>m("ui.notices.credentials.removed",{index:e}),LTt=e=>e.unredacted!==null?e.unredacted:e.armed?n2t:e.cleared!==null?DTt(e.cleared.key,e.cleared.index,e.undoCap):null;function FTt(e){const{buffer:t,payload:n}=e,r=Vv(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===Z_?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 BTt(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 cK=e=>m("ui.notices.credentials.stored",{keys:e.join(", ")});function uK(e){return m("ui.notices.credentials.unstored",{count:e.length,keys:[...e].sort().join(", ")})}const HTt="store unconfirmed",KTt="Credential store unconfirmed",JTt=e=>e===""?KTt:`${e} · ${HTt}`,e2t="Paste the value again after /credential to store it again.",t2t=e=>`${e} ${e2t}`;function OK(e){return m("ui.notices.credentials.unconfirmed",{count:e.length,keys:[...e].sort().join(", ")})}const n2t="armed — add a space, then type or paste the secret",r2t="masked as you type — Enter makes a pill, Esc twice discards",i2t="masked — Enter opens the credential picker; type or paste the secret into this span",a2t="Esc again discards it — still masked, Enter makes a pill",o2t="credential discarded — nothing was stored or sent",s2t="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",l2t=e=>`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`;function c2t(e,t){const n=Cf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const dK=(e,t)=>e&&e.over===t?e.chars:null,u2t=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},O2t=16,d2t=16;function fSe(e=[],t=u2t){const n=new Set(e);for(let r=0;r<O2t;r++){const i=oK+fK(8,t);if(!n.has(i))return i}return oK+fK(d2t,t)}const fK=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=aK[t(aK.length)];return n},f2t=8,h2t=256,p2t=/^[/@$#]/,m2t=/^\w+:\/\//,g2t=/^[A-Za-z]+$/,$2t=/^\d+$/,y2t=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/],v2t=3,b2t=20,w2t=/^[A-Za-z0-9_\-+/=.]+$/,x2t=new RegExp(`^[^${Gc}@]+@[^${Gc}@]+\\.[A-Za-z]{2,}$`),S2t=/^[\w.-]+(?:\/[\w.-]+)+$/,Q2t=/\.[A-Za-z][A-Za-z0-9]{0,7}$/,k2t=/^v?\d+(?:\.\d+)+(?:[-+][0-9A-Za-z.-]+)?$/,_2t=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,P2t=/^[\w.-]+:\d{2,5}$/,T2t=/^(?:[0-9a-f]{7,12}|[0-9a-f]{40})$/i,X2t=/^[a-z]+(?:_[a-z]+)+$/,R2t=/^[a-z]+(?:-[a-z]+)+$/,E2t=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$/,q2t=/^[a-z0-9]+(?:-[a-z0-9]+)+$/,j2t=/\d{4,}/,hK=e=>{const t=e.trim();return t.length<f2t||t.length>h2t||Ys.test(t)||p2t.test(t)||m2t.test(t)||dA(t)!==null||x2t.test(t)||S2t.test(t)||Q2t.test(t)||k2t.test(t)||_2t.test(t)||P2t.test(t)||T2t.test(t)||X2t.test(t)||R2t.test(t)||E2t.test(t)||q2t.test(t)&&j2t.test(t)||g2t.test(t)||$2t.test(t)?!1:y2t.filter(r=>r.test(t)).length>=v2t?!0:t.length>=b2t&&w2t.test(t)},hSe=T("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),pSe=T("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),mSe=({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:T("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?pSe:hSe,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?f.jsx(yce,{"aria-hidden":"true",className:"size-3 shrink-0"}):f.jsx(V7e,{"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(oi,{"aria-hidden":"true",className:"size-3"})}),r&&f.jsx("span",{className:"sr-only",children:r})]}),hy="#lo-credential/",C2t=`${hy}unstored`,pK=`${hy}unconfirmed`,z2t=/^\d+$/,gSe=e=>e.kind==="stored"?`${hy}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${pK}/${e.key}`:pK:C2t;function A2t(e){if(!e||!e.startsWith(hy))return null;const t=e.slice(hy.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return A6.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!A6.test(r)||!z2t.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function mK(e,t){const n=A2t(e);if(n===null)return null;const r=I_(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return gSe(i)!==e?null:n}const D_=()=>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=I_(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:gSe(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},U2t=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?JTt(e.key):"Credential not stored",W2t=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?t2t(t):t,N2t=({citation:e,title:t})=>f.jsx(mSe,{tone:e.kind==="stored"?"live":"warning",label:U2t(e),chars:e.kind==="stored"?e.chars:null,title:W2t(e,t),className:"align-middle"}),Y2t=(e,t)=>typeof t=="string"?mK(e,t):t==null?mK(e,""):null,G2t=e=>({href:t,title:n,children:r})=>{const i=Y2t(t,r);if(i===null){const a=e;return f.jsx(a,{href:t,title:n,children:r})}return f.jsx(N2t,{citation:i,title:n})},$Se=e=>LJe(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",dW=e=>{const t=$Se(e);return t==="other"?"path":t},XX={id:"open-file",get label(){return m("ui.common.file_actions.open_file")}},Z2t={id:"show-in-canvas",get label(){return m("ui.common.file_actions.show_in_canvas")}},I2t={id:"save-as",get label(){return m("ui.chat.image_actions.save_as")}},RX={id:"open-folder",get label(){return m("ui.common.file_actions.open_folder")}},EX={id:"copy-file-path",get label(){return m("ui.common.file_actions.copy_file_path")}},vh={id:"copy-image",get label(){return m("ui.chat.image_actions.copy_image")}},D2t={id:"copy-image-url",get label(){return m("ui.chat.image_actions.copy_image_url")}},V2t={id:"open-in-browser",get label(){return m("ui.chat.image_actions.open_in_browser")}};function ySe(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const o=[...t?[Z2t]:[],...a?[{id:"expand-image",get label(){return m("ui.chat.image_actions.expand_image")}}]:[]];switch(e){case"artifact":return[...o,...i?[XX,RX,EX]:[],I2t,...r==="video"||r==="audio"?[]:[vh]];case"path":return[...o,XX,RX,EX,...r==="video"||r==="audio"?[]:[vh]];case"data":return[...o,vh];case"blob":return i?[...o,XX,RX,EX,vh]:[vh];case"http":return[...M2t(n)?[vh]:[],D2t,V2t];case"other":return[]}}const vSe=(e,t)=>ySe(e,t).length>0;function M2t(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 fW=e=>e.startsWith("file://")?e.slice(7):e;function bSe(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 gK(e,t,n){if(e==="data")return bSe(t);if(e==="blob"){const o=gue(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=fW(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:Xp(i)})}const L2t=e=>e.trim().toLowerCase()!=="image/png";async function F2t(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!L2t(e.type))return e;const t=URL.createObjectURL(e);try{const n=await B2t(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 B2t(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 H2t=6e4;function K2t(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),H2t)}const ux=new Map;function J2t(e,t){const n=ux.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await is(e.childId?{op:"subagents.attachment",sessionId:e.sessionId,childId:e.childId,digest:t}:{op:"sessions.attachment",sessionId:e.sessionId,digest:t},null);if(i.kind!=="bytes")return null;const a=kk(i.data,i.mimeType);return r.holders<=0?(pv(a),null):(L9(t,a),a)}catch{return null}finally{ux.delete(t)}})(),ux.set(t,r),r.promise}class hW extends Error{constructor(){super("This item is no longer in the session"),this.name="AttachmentGoneError"}}async function wSe(e,t){const n=E$(t),r=n?gue(n):null;if(r)return r;const i=await is(e.childId?{op:"subagents.attachment",sessionId:e.sessionId,childId:e.childId,digest:t}:{op:"sessions.attachment",sessionId:e.sessionId,digest:t},null);if(i.kind!=="bytes")throw i.status===404?new hW:new Error("These bytes are not available right now");return new Blob([i.data],{type:i.mimeType})}function eXt(e){const t=ux.get(e);t&&(t.holders-=1)}function Mv(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=$.useState(()=>e.attachment?E$(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=_p(u);if(d)return i(d),o(!1),()=>{O=!1,Pp(u)};i(null),o(!1);let h=!0;return J2t({sessionId:s,childId:l},u).then(p=>{if(h=!1,!!O){if(!p){o(!0);return}i(_p(u))}}),()=>{O=!1,h&&eXt(u),Pp(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 pW(e,t){return Mv(e,t)}const Cdn=Object.freeze(Object.defineProperty({__proto__:null,AttachmentGoneError:hW,fetchAttachmentBlob:wSe,useAttachmentSource:Mv,useAttachmentUrl:pW},Symbol.toStringTag,{value:"Module"})),tXt={"expand-image":f.jsx(Lce,{"aria-hidden":"true"}),"open-file":f.jsx(Ov,{"aria-hidden":"true"}),"show-in-canvas":f.jsx(Mce,{"aria-hidden":"true"}),"save-as":f.jsx(vk,{"aria-hidden":"true"}),"open-folder":f.jsx(kp,{"aria-hidden":"true"}),"copy-file-path":f.jsx(C9,{"aria-hidden":"true"}),"copy-image":f.jsx(vf,{"aria-hidden":"true"}),"copy-image-url":f.jsx(B7e,{"aria-hidden":"true"}),"open-in-browser":f.jsx(bk,{"aria-hidden":"true"})},$K=(e,t,n)=>n instanceof hW?t:e;function nXt({file:e,src:t,resolvePath:n,missing:r,onShowInCanvas:i,mediaKind:a,onExpand:o,saveName:s}){return ySe(dW(e),{canShowInCanvas:!!i,source:t??e,mediaKind:a,artifactPathActions:!!n,canExpand:!!o}).filter(l=>(l.id!=="save-as"||!!s)&&(!r||l.id==="copy-file-path"))}const xSe=({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=dW(e),v=nXt({file:e,src:t,resolvePath:s,missing:l,onShowInCanvas:c,mediaKind:u,onExpand:O,saveName:d});if(v.length===0)return null;const b=async(k,P,X)=>{try{await navigator.clipboard.writeText(k),OO(P)}catch(E){console.error(`${X}: `,E),Rr(X)}},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 gK(y,e,t),P=await F2t(k);await navigator.clipboard.write([new ClipboardItem({[P.type]:P})]),OO(m("ui.notices.files.image_copied"))}catch(k){console.error("Failed to copy image: ",k),Rr($K(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 gK(y,e,t);K2t(k,d??"download")}catch(k){console.error("Failed to save file: ",k),Rr($K(m("ui.notices.files.save_failed"),m("ui.notices.files.save_failed_gone"),k))}},w=async k=>{let P=fW(e);if(s&&["open-file","open-folder","copy-file-path"].includes(k.id))try{P=await s()}catch{Rr(m("ui.canvas.files.prepareError"));return}switch(k.id){case"expand-image":O?.();return;case"open-file":xO(P);return;case"open-folder":sW(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":lW(t??e);return}},S=g??`Actions for ${n??"this image"}`;return f.jsxs(w9,{open:r,onOpenChange:i,children:[f.jsx(vt,{content:p,children:f.jsx(x9,{asChild:!0,children:f.jsx(Qe,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":S,tabIndex:o,onClick:k=>k.stopPropagation(),children:f.jsx(jj,{"aria-hidden":"true"})})})}),f.jsxs(S9,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:k=>k.stopPropagation(),children:[s&&f.jsx("div",{role:"note",className:T("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:m("ui.canvas.files.pathCopyNote")}),v.map(k=>f.jsxs(gl,{onSelect:()=>w(k),children:[tXt[k.id],f.jsx("span",{children:k.label})]},k.id))]})]})},rXt=({src:e,alt:t,title:n,className:r})=>{const i=Iv(),a=e??"",o=$Se(a);if(o==="other")return f.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=vSe(o,{canShowInCanvas:s,source:a});return f.jsxs("span",{className:T("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:T("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(xSe,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||xO(fW(a))})}:void 0})})]})};function iXt(){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 aXt={tokenize:oXt,concrete:!0,name:"mathFlow"},yK={tokenize:sXt,partial:!0};function oXt(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"),an(e,c,"whitespace")(b))}function c(b){return b===null||yt(b)?O(b):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(b))}function u(b){return b===null||yt(b)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),O(b)):b===36?n(b):(e.consume(b),u)}function O(b){return e.exit("mathFlowFence"),r.interrupt?t(b):e.attempt(yK,d,y)(b)}function d(b){return e.attempt({tokenize:v,partial:!0},y,h)(b)}function h(b){return(a?an(e,p,"linePrefix",a+1):p)(b)}function p(b){return b===null?y(b):yt(b)?e.attempt(yK,d,y)(b):(e.enter("mathFlowValue"),g(b))}function g(b){return b===null||yt(b)?(e.exit("mathFlowValue"),p(b)):(e.consume(b),g)}function y(b){return e.exit("mathFlow"),t(b)}function v(b,x,Q){let w=0;return an(b,S,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function S(X){return b.enter("mathFlowFence"),b.enter("mathFlowFenceSequence"),k(X)}function k(X){return X===36?(w++,b.consume(X),k):w<o?Q(X):(b.exit("mathFlowFenceSequence"),an(b,P,"whitespace")(X))}function P(X){return X===null||yt(X)?(b.exit("mathFlowFence"),x(X)):Q(X)}}}function sXt(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 lXt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:cXt,previous:uXt,name:"mathText"};function r(i,a,o){let s=0,l,c;return u;function u(g){return i.enter("mathText"),i.enter("mathTextSequence"),O(g)}function O(g){return g===36?(i.consume(g),s++,O):s<2&&!n?o(g):(i.exit("mathTextSequence"),d(g))}function d(g){return g===null?o(g):g===36?(c=i.enter("mathTextSequence"),l=0,p(g)):g===32?(i.enter("space"),i.consume(g),i.exit("space"),d):yt(g)?(i.enter("lineEnding"),i.consume(g),i.exit("lineEnding"),d):(i.enter("mathTextData"),h(g))}function h(g){return g===null||g===32||g===36||yt(g)?(i.exit("mathTextData"),d(g)):(i.consume(g),h)}function p(g){return g===36?(i.consume(g),l++,p):l===s?(i.exit("mathTextSequence"),i.exit("mathText"),a(g)):(c.type="mathTextData",h(g))}}}function cXt(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 uXt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function OXt(e){return{flow:{36:aXt},text:{36:lXt()}}}const Hh=36,vK=e=>e!==null&&e<-2,bK=e=>e===null||e===32||e<0,wK=e=>e!==null&&e>=48&&e<=57,SSe=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:dXt,previous:fXt,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===Hh?(r.consume(y),s++,d):s<2&&!t||s===1&&(bK(y)||wK(y))?a(y):(r.exit("mathTextSequence"),h(y))}function h(y){return y===null?a(y):y===Hh?(u=r.enter("mathTextSequence"),c=0,l=o.previous,g(y)):y===32?(r.enter("space"),r.consume(y),r.exit("space"),h):vK(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===Hh||vK(y)?(r.exit("mathTextData"),h(y)):(r.consume(y),p)}function g(y){return y===Hh?(r.consume(y),c++,g):c===s?s===1&&(bK(l)||wK(y))?a(y):(r.exit("mathTextSequence"),r.exit("mathText"),i(y)):(u.type="mathTextData",p(y))}}};function dXt(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 fXt(e){return e!==Hh||this.events[this.events.length-1][1].type==="characterEscape"}const hXt=OXt().flow,pXt=SSe();function V_(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?pXt:SSe(e);n.push({flow:hXt,text:{[Hh]:i}}),r.push(iXt())}const QSe=({node:e,...t})=>f.jsx("div",{className:"lo-md-table-scroll",children:f.jsx("table",{...t})}),mXt=/\$(?!\d)(.+?)\$/,gXt=/\$\$([\s\S]+?)\$\$/,$Xt=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,yXt=/\\[a-zA-Z]+(\{[^}]*\})?/,xK=e=>mXt.test(e)||gXt.test(e)||$Xt.test(e)?!0:yXt.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),vXt=e=>{const t=I_(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},bXt=e=>I_(e).filter(t=>t.kind!=="text").length,wXt=e=>{if(!xK(e))return!1;const t=vXt(e);return t===null?!0:xK(t)||t.includes("$")?!1:bXt(e)<2},kSe=Object.freeze(["canvas","surface","ink","inkMuted","accent","borderControl"]),_Se=Object.freeze(k9.filter(e=>!["overlayShadow","scrim"].includes(e))),PSe=65536,TSe=/^#[0-9a-fA-F]{6}$/,xXt=(e,t)=>Object.hasOwn(e,t),SK=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&[Object.prototype,null].includes(Object.getPrototypeOf(e)),pa=e=>{throw new Error(e)},SXt={canvas:["surface","elevated","sunken","messageSurface","mediaSurface","rowHover","rowSelected","accentWash","accentAltWash","successWash","warningWash","dangerWash","infoWash"],surface:["elevated","rowHover","rowSelected"],ink:["inkMuted","inkDim","inkDisabled"],inkMuted:["inkDim"],accent:["accentHover","accentActive","accentWash","chartBarHover"],borderControl:["hairline","hairlineStrong"]},py=(e,t)=>{const n={...e};for(const r of kSe){const i=DRe(t.seeds?.[r]);if(!i)continue;const a=h5(e[r]),o=h5(i);n[r]=i;for(const s of SXt[r]){const l=h5(e[s]);n[s]=VRe({l:o.l+l.l-a.l,c:a.c>.01?o.c*l.c/a.c:l.c,h:o.h+l.h-a.h})}}n.accent.toUpperCase()!==e.accent.toUpperCase()&&(n.onAccent=MRe(n.accent,[e.onAccent,n.ink,n.canvas,"#000000","#FFFFFF"]));for(const r of _Se)TSe.test(t.overrides?.[r]??"")&&(n[r]=t.overrides[r]);for(const r of["overlayShadow","scrim"]){const i=t.overrides?.[r];typeof i=="string"&&/^(0(?:\.\d{1,3})?|1(?:\.0{1,3})?)$/.test(i)&&(n[r]=e[r].replace(/\/\s*[\d.]+\)/,`/ ${i})`))}return n},mW=(e,t)=>ZRe(e,t),zdn=(e,t)=>{const n=py(e,t),r=BRe(n,t.base,e,{pinned:Object.keys(t.overrides??{}),maxEvaluations:320,lightnessOnly:!0}).palette;if(!r||Object.keys(t.overrides??{}).some(s=>r[s]!==n[s]))return null;const a={...t.overrides};for(const s of _Se)r[s]!==n[s]&&(a[s]=r[s]);const o={...t,overrides:a};return mW(py(e,o),t.base).length?null:o},XSe=(e,t,{id:n="custom-import",now:r=Date.now()}={})=>{(typeof e!="string"||new TextEncoder().encode(e).length>PSe)&&pa("import_size");let i;try{i=JSON.parse(e)}catch{pa("import_invalid_json")}SK(i)||pa("import_format");const a=new Set(["format","version","name","base","seeds","overrides","id","updatedAt"]);Object.keys(i).some(s=>!a.has(s))&&pa("import_unsafe"),i.format!=="local-operator-theme"&&pa("import_format"),i.version!==1&&pa("import_version"),(typeof i.base!="string"||!t(i.base))&&pa("import_base"),(typeof i.name!="string"||!i.name.trim()||i.name.trim().length>60)&&pa("import_name");const o={};for(const s of["seeds","overrides"]){(!xXt(i,s)||!SK(i[s]))&&pa("import_roles");const l={};for(const[c,u]of Object.entries(i[s]))(!(s==="seeds"?kSe:k9).includes(c)||typeof u!="string")&&pa("import_roles"),["overlayShadow","scrim"].includes(c)?(/^(0(?:\.\d{1,3})?|1(?:\.0{1,3})?)$/.test(u)||pa("import_roles"),l[c]=u):(TSe.test(u)||pa("import_roles"),l[c]=u.toUpperCase());o[s]=l}return{format:"local-operator-theme",version:1,id:n,name:i.name.trim(),base:i.base,...o,updatedAt:r}},QXt=(e,t)=>{if(e==null)return[];(typeof e!="string"||e.length>PSe*kx)&&pa("load_error");let n;try{n=JSON.parse(e)}catch{pa("load_error")}const r=Array.isArray(n)?n:n?.version===1?n.themes:null;Array.isArray(r)||pa("load_error");const i=[],a=new Set;for(const o of r.slice(0,kx))try{const s=IRe(o,{isThemeName:t,isRole:c=>k9.includes(c)});if(!s||a.has(s.id))continue;const l=XSe(JSON.stringify(o),t,{id:s.id,now:s.updatedAt});i.push(l),a.add(l.id)}catch{}return i},kXt=e=>JSON.stringify({format:"local-operator-theme",version:1,name:e.name,base:e.base,seeds:e.seeds,overrides:e.overrides},null,2),Adn=(e,t)=>{const n=new Set(t.map(r=>r.name));if(!n.has(e))return e;for(let r=2;r<=kx+1;r++){const i=`${e.slice(0,54)} (${r})`;if(!n.has(i))return i}return e},Udn=(e,t)=>{const n=LRe({composed:!0,capturePairs:!0});return FRe(n,{id:t,palette:e}),{findings:n.log,readings:n.readings}};let SO={themes:[],error:!1,loading:!1};const W6=new Set,RSe=()=>{for(const e of W6)e()},QK=()=>SO,_Xt=e=>(W6.add(e),()=>{W6.delete(e)}),kK=()=>{try{SO={themes:QXt(localStorage.getItem(u9),Yle).filter(t=>{const n=i9(t.base)?.palette;return n&&mW(py(n,t),t.base).length===0}),error:!1,loading:!1}}catch{SO={themes:[],error:!0,loading:!1}}RSe()},gW=()=>$.useSyncExternalStore(_Xt,QK,QK),PXt=e=>SO.themes.find(t=>t.id===e),ESe=e=>{localStorage.setItem(u9,JSON.stringify({version:1,themes:e})),SO={themes:e,error:!1,loading:!1},RSe()},Wdn=e=>{const t=HRe(e.id);if(!t)throw new Error("invalid custom theme id");const n=XSe(kXt(e),Yle,{id:t,now:e.updatedAt}),r=i9(n.base)?.palette;if(!r||mW(py(r,n),n.base).length)throw new Error("contrast");if(!PXt(n.id)&&SO.themes.length>=kx)throw new Error("limit");ESe([n,...SO.themes.filter(i=>i.id!==n.id)])},Ndn=e=>ESe(SO.themes.filter(t=>t.id!==e));typeof window<"u"&&(kK(),window.addEventListener("storage",e=>{(e.key===u9||e.key===null)&&kK()}));const TXt=()=>{const e=Yt(i=>i.themeName),t=Yt(i=>i.contrast),n=Yt(i=>i.accent),r=Yt(i=>i.customThemeId);return $.useMemo(()=>({themeName:e,contrast:t,accent:n,customThemeId:r}),[e,t,n,r])},XXt=e=>{const t=e?i9(e.base)?.palette:void 0;return t&&e?py(t,e):void 0},RXt=()=>{const e=TXt(),t=gW();return $.useMemo(()=>{const n=t.themes.find(a=>a.id===e.customThemeId),r=XXt(n),i=n?.base;return{appearance:e,savedPalette:r,savedBase:i,resolved:KRe(e,r,i)}},[e,t])},M_=()=>RXt().resolved,Ydn=()=>M_().palette.mode==="dark",Lt="var(--color-ink)",tc="var(--color-ink-muted)",cl="var(--color-surface)",Pu="var(--color-elevated)",nc="var(--color-sunken)",Fi="var(--color-hairline)",Tu="var(--color-control)",bh="var(--color-accent)",T0="var(--color-accent-wash)",EXt="var(--color-accent-alt-wash)",qXt="var(--color-on-accent)",jXt="var(--color-info)",qSe="var(--color-info-wash)",CXt="var(--color-success)",jSe="var(--color-success-wash)",zXt="var(--color-warning)",N6="var(--color-warning-wash)",AXt="var(--color-warning-border)",qX="var(--color-danger)",Y6="var(--color-danger-wash)",_K=[T0,EXt,qSe,jSe,N6,Y6],Xu=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),UXt=()=>{const e={primaryColor:Xu("--color-accent"),secondaryColor:Xu("--color-success"),tertiaryColor:Xu("--color-info"),mainBkg:Xu("--color-elevated"),clusterBkg:Xu("--color-sunken"),clusterBorder:Xu("--color-hairline"),edgeLabelBackground:Xu("--color-surface"),quadrant1Fill:Xu("--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:cl,primaryTextColor:Lt,primaryBorderColor:Tu,secondaryTextColor:Lt,secondaryBorderColor:Fi,tertiaryTextColor:Lt,tertiaryBorderColor:Fi,lineColor:tc,arrowheadColor:tc,textColor:Lt,secondBkg:nc,border1:Tu,border2:Fi,labelColor:Lt,nodeBkg:Pu,nodeBorder:Tu,nodeTextColor:Lt,defaultLinkColor:tc,titleColor:Lt,noteBkgColor:N6,noteBorderColor:AXt,noteTextColor:Lt,actorBkg:Pu,actorBorder:Tu,actorTextColor:Lt,actorLineColor:Fi,signalColor:tc,signalTextColor:Lt,labelBoxBkgColor:Pu,labelBoxBorderColor:Fi,labelTextColor:Lt,loopTextColor:Lt,activationBkgColor:T0,activationBorderColor:bh,sequenceNumberColor:cl,sectionBkgColor:nc,sectionBkgColor2:cl,altSectionBkgColor:nc,excludeBkgColor:nc,taskBkgColor:T0,taskBorderColor:Tu,taskTextColor:Lt,taskTextLightColor:Lt,taskTextDarkColor:Lt,taskTextOutsideColor:Lt,taskTextClickableColor:bh,activeTaskBkgColor:T0,activeTaskBorderColor:bh,gridColor:Fi,doneTaskBkgColor:nc,doneTaskBorderColor:Fi,critBkgColor:Y6,critBorderColor:qX,todayLineColor:bh,transitionColor:tc,transitionLabelColor:Lt,stateLabelColor:Lt,stateBkg:Pu,labelBackgroundColor:cl,compositeBackground:nc,altBackground:nc,compositeTitleBackground:Pu,compositeBorder:Fi,innerEndBackground:Lt,specialStateColor:Lt,classText:Lt,attributeBackgroundColorOdd:cl,attributeBackgroundColorEven:nc,rowOdd:cl,rowEven:nc,errorBkgColor:Y6,errorTextColor:qX,pieTitleTextColor:Lt,pieSectionTextColor:Lt,pieLegendTextColor:Lt,pieStrokeColor:cl,pieOuterStrokeColor:Fi,requirementBackground:Pu,requirementBorderColor:Tu,requirementTextColor:Lt,relationColor:tc,relationLabelBackground:cl,relationLabelColor:Lt,branchLabelColor:qXt,commitLabelColor:Lt,commitLabelBackground:cl,tagLabelColor:Lt,tagLabelBackground:T0,tagLabelBorder:Tu,quadrant2Fill:qSe,quadrant3Fill:jSe,quadrant4Fill:N6,quadrant2TextFill:Lt,quadrant3TextFill:Lt,quadrant4TextFill:Lt,quadrantPointFill:bh,archEdgeColor:tc,archEdgeArrowColor:tc,archGroupBorderColor:Fi,scaleLabelColor:Lt,packet:{startByteColor:Lt,endByteColor:Lt,labelColor:Lt,titleColor:Lt,blockStrokeColor:Tu,blockFillColor:Pu},radar:{axisColor:tc,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:Fi,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:cl,titleColor:Lt,xAxisTitleColor:Lt,xAxisLabelColor:Lt,xAxisTickColor:Fi,xAxisLineColor:Fi,yAxisTitleColor:Lt,yAxisLabelColor:Lt,yAxisTickColor:Fi,yAxisLineColor:Fi,plotColorPalette:[bh,jXt,CXt,zXt,qX].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Pu,t[`surfacePeer${n}`]=Fi;for(let n=0;n<8;n++)t[`fillType${n}`]=_K[n%_K.length];return{...t,...e}};let jX=null,PK=null;const WXt=async e=>{jX||(jX=ve(async()=>{const{default:n}=await import("./mermaid.core-CfTVsgje.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([10,1,2,3]),import.meta.url).then(({default:n})=>n));const t=await jX;return PK!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:UXt()}),PK=e),t},TK=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>f.jsxs("div",{"data-lo-floating":"",className:T("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[f.jsx(vt,{content:m("ui.chat.mermaid.zoom_in"),children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.zoom_in"),onClick:n,children:f.jsx(tue,{})})}),f.jsx(vt,{content:m("ui.chat.mermaid.zoom_out"),children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.zoom_out"),onClick:r,children:f.jsx(nue,{})})}),f.jsx(vt,{content:m("ui.chat.mermaid.pan_hint"),children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.pan"),children:f.jsx(y6e,{})})}),f.jsx(vt,{content:m("ui.chat.mermaid.reset_view"),children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.reset_view"),onClick:i,children:f.jsx(xk,{})})}),f.jsx(vt,{content:m("ui.chat.mermaid.save_svg"),children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.save_svg"),onClick:a,children:f.jsx(vk,{})})}),f.jsx(vt,{content:t?m("ui.chat.mermaid.copied"):m("ui.chat.mermaid.copy_text"),children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":t?m("ui.chat.mermaid.copied"):m("ui.chat.mermaid.copy_text"),onClick:o,children:f.jsx(vf,{className:T(t&&"text-success")})})}),s]}),G6=({title:e,children:t})=>f.jsxs(Xl,{variant:"danger",role:"alert",className:"my-4",children:[f.jsx(A0,{children:e}),f.jsx(U0,{children:t})]});class NXt 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(G6,{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 YXt=$.memo(({chart:e,id:t})=>{we();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=M_().id,X=$.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 Y=await WXt(P),le=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:F}=await Y.render(le,e);if(!F||typeof F!="string"||F.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(F)}catch(Y){console.error("Mermaid rendering error:",Y);const le=Y instanceof Error?Y.message:"Failed to render mermaid diagram";a(le),c("")}finally{s(!1)}},[e,t,P]);$.useEffect(()=>{X().catch(Y=>{console.error("Error in renderDiagram effect:",Y),a("Failed to initialize diagram rendering"),s(!1)})},[X]);const E=$.useCallback(()=>{try{if(!l||!r.current)return 1;const le=r.current.getBoundingClientRect(),F=document.createElement("div");F.innerHTML=l;const H=F.querySelector("svg");if(!H)return 1;const se=H.getBoundingClientRect?.()?.width||Number.parseFloat(H.getAttribute("width")||"0")||H.viewBox?.baseVal?.width||800,ee=H.getBoundingClientRect?.()?.height||Number.parseFloat(H.getAttribute("height")||"0")||H.viewBox?.baseVal?.height||600,L=le.width*.9/se,ne=le.height*.9/ee;return Math.min(L,ne,1)}catch(Y){return console.error("Error calculating fullscreen scale:",Y),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const Y=E();g({scale:Y,x:0,y:0})}catch(Y){console.error("Error setting fullscreen transform:",Y)}},100)},[u,l,E]);const R=$.useCallback((Y=!1)=>{try{(Y?g:h)(F=>({...F,scale:Math.min(F.scale*1.2,10)}))}catch(le){console.error("Error in zoom in:",le)}},[]),q=$.useCallback((Y=!1)=>{try{(Y?g:h)(F=>({...F,scale:Math.max(F.scale/1.2,.1)}))}catch(le){console.error("Error in zoom out:",le)}},[]),C=$.useCallback((Y=!1)=>{try{const le=Y?g:h;if(Y){const F=E();le({scale:F,x:0,y:0})}else le({scale:1,x:0,y:0})}catch(le){console.error("Error in reset:",le)}},[E]),z=$.useCallback(()=>{if(l)try{const Y=new Blob([l],{type:"image/svg+xml"}),le=URL.createObjectURL(Y),F=document.createElement("a");F.href=le,F.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(le)}catch(Y){console.error("Failed to save SVG:",Y)}},[l]),W=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),w("copied"),setTimeout(()=>w("idle"),1200)}catch(Y){console.error("Failed to copy Mermaid chart text:",Y)}},[e]),G=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),k("copied"),setTimeout(()=>k("idle"),1200)}catch(Y){console.error("Failed to copy Mermaid chart text:",Y)}},[e]),A=$.useCallback(Y=>{try{v(!0),x({x:Y.clientX,y:Y.clientY}),Y.preventDefault()}catch(le){console.error("Error in mouse down:",le)}},[]),I=$.useCallback((Y,le=!1)=>{try{if(!y)return;const F=Y.clientX-b.x,H=Y.clientY-b.y;(le?g:h)(ee=>({...ee,x:ee.x+F,y:ee.y+H})),x({x:Y.clientX,y:Y.clientY})}catch(F){console.error("Error in mouse move:",F)}},[y,b]),Z=$.useCallback(()=>{try{v(!1)}catch(Y){console.error("Error in mouse up:",Y)}},[]),U=$.useCallback((Y,le=!1)=>{try{Y.preventDefault();const F=Y.deltaY>0?.9:1.1;(le?g:h)(se=>({...se,scale:Math.min(Math.max(se.scale*F,.1),5)}))}catch(F){console.error("Error in wheel:",F)}},[]),D=$.useCallback(Y=>{try{O(Y)}catch(le){console.error("Error toggling fullscreen:",le)}},[]);if(i)return f.jsxs(G6,{title:m("ui.chat.mermaid.error_title"),children:[i,f.jsx("span",{className:T("mt-2 block text-ink-muted"),children:m("ui.chat.mermaid.chart_label")}),f.jsx("span",{className:T("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const K=(Y=!1)=>{try{const le=Y?r:n,F=Y?p:d;return f.jsx("div",{ref:le,className:T("mermaid flex w-full items-center justify-center",Y?"h-full min-h-full":"h-auto min-h-50",y?"cursor-grabbing":"cursor-grab"),onMouseDown:A,onMouseMove:H=>I(H,Y),onMouseUp:Z,onMouseLeave:Z,onWheel:H=>U(H,Y),children:o?f.jsx("div",{className:T("p-4 text-body-sm text-ink-muted"),children:m("ui.chat.mermaid.loading")}):l?f.jsx("div",{className:T("flex h-full w-full items-center justify-center"),style:{transform:`translate(${F.x}px, ${F.y}px) scale(${F.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(le){return console.error("Error rendering diagram content:",le),f.jsx(G6,{title:m("ui.chat.mermaid.rendering_error"),children:m("ui.chat.mermaid.render_failed")})}};return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:T("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:[K(!1),f.jsx(TK,{className:"top-2 right-2",copied:Q==="copied",onZoomIn:()=>R(!1),onZoomOut:()=>q(!1),onReset:()=>C(!1),onSave:z,onCopy:W,children:f.jsx(vt,{content:m("ui.chat.mermaid.fullscreen"),children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.open_fullscreen"),onClick:()=>D(!0),children:f.jsx(Lce,{})})})})]}),f.jsx(R$,{open:u,onClose:()=>D(!1),title:m("ui.chat.mermaid.diagram_title"),maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:f.jsxs("div",{className:T("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:[K(!0),f.jsx(TK,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>R(!0),onZoomOut:()=>q(!0),onReset:()=>C(!0),onSave:z,onCopy:G,children:f.jsx(vt,{content:m("ui.chat.mermaid.close_fullscreen"),children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.mermaid.close_fullscreen"),onClick:()=>D(!1),children:f.jsx(oi,{})})})})]})})]})}),GXt=$.memo(e=>f.jsx(NXt,{children:f.jsx(YXt,{...e})}));let CSe=!1,CX=null;const ZXt=()=>(CX||(CX=ve(()=>Promise.resolve({}),__vite__mapDeps([11]),import.meta.url).then(e=>(CSe=!0,e))),CX),IXt=/language-(\w+)/,DXt=O9,VXt=new RegExp(`^[^${Gc}\\d*+-]`),MXt=/\n$/,zSe=({href:e,children:t})=>{const n=qxe(e),r=Iv();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=>BXt(i,r):void 0,children:t})},LXt=e=>qxe(e)?.kind==="file",FXt=Axe,BXt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(zxe)??"file",i=n.getAttribute(FXt),a=r5t({kind:r,hasHighlight:b5t(n),canOpenInCanvas:oW(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||xO(i)});return}xO(i)}},Z6=(e,t)=>t==="href"&&LXt(e)?e:Bfe(e),my={a:zSe,table:QSe,img:rXt,code:({node:e,className:t,children:n,...r})=>IXt.exec(t??"")?.[1]==="mermaid"?f.jsx(GXt,{chart:String(n).replace(MXt,"")}):f.jsx("code",{dir:"ltr",className:t,...r,children:n})},HXt={...my,a:G2t(zSe)},KXt=[Gs],JXt=[Gs,V_],eRt=[Gs,Y_],tRt=[Gs,V_,Y_],nRt=[Gs,D_,G_],rRt=[Gs,V_,D_,G_],iRt=[Gs,Y_,D_,G_],aRt=[Gs,V_,Y_,D_,G_],oRt={"000":KXt,"001":nRt,"010":eRt,"011":iRt,100:JXt,101:rRt,110:tRt,111:aRt},sRt=[],lRt=[zHe],ASe=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),USe=(e,t,n,r)=>{const i=$.useMemo(()=>wXt(e),[e]),[a,o]=$.useState(CSe),s=i&&a;$.useEffect(()=>{if(!i||a)return;let O=!1;return ZXt().then(()=>{O||o(!0)}),()=>{O=!0}},[i,a]);const l=oRt[`${s?1:0}${t?1:0}${n?1:0}`],c=n&&r?r.join("\0"):"";return{remarkPlugins:$.useMemo(()=>c===""?l:[[uTt,{names:c.split("\0")}],...l],[l,c]),rehypePlugins:s?lRt:sRt}},WSe=(e,t,n)=>{const[,r]=$.useState(0);$.useEffect(()=>{if(!t)return;const i=pet(e);if(i.length===0)return;let a=!0;const o=new Set(i),s=s5t(l=>{a&&l.some(c=>o.has(c))&&r(c=>c+1)});return aW(i,window.api?.probeFiles,Kle,a5t(n===void 0?e:`${n}\0${e}`)).then(()=>{a&&i.some(l=>Cxe(l)!=="unknown")&&r(l=>l+1)}),()=>{a=!1,s()}},[e,t,n])},gy=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1,skillNames:a,documentId:o})=>{const s=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:l,rehypePlugins:c}=USe(s,r,i,a),u=ASe(t);return WSe(s,r,o),f.jsx("div",{className:T("lo-markdown",n),style:u,children:f.jsx(Fx,{remarkPlugins:l,rehypePlugins:c,urlTransform:Z6,components:i?HXt:my,children:s})})});gy.displayName="MarkdownRenderer";const XK={...my,a:({children:e})=>f.jsx(f.Fragment,{children:e})},NSe=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:tK(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=Bxe(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=USe(n,t,!1);if(WSe(e,t),r!==null){const o=tK(r.before);return f.jsxs(f.Fragment,{children:[o.trim()!==""&&f.jsx(Fx,{remarkPlugins:i,rehypePlugins:a,urlTransform:Z6,components:t?my:XK,children:o}),f.jsx(cRt,{info:r.info,body:r.body})]})}return f.jsx(Fx,{remarkPlugins:i,rehypePlugins:a,urlTransform:Z6,components:t?my:XK,children:n})});NSe.displayName="ParsedBlock";const cRt=({info:e,body:t})=>{const n=e.split(DXt)[0];return f.jsx("pre",{children:f.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
914
914
  `)?"":`
915
915
  `}`})})},YSe=({content:e,styleProps:t,className:n})=>{const r=$.useRef(null);r.current===null&&(r.current=Q5t());const i=r.current;T5t(i,e);const{blockStart:a}=i,o=a+X5t(e.slice(a));let s=null,l=a;(i.kind==="other"||(i.kind==="list"||i.kind==="indented-code")&&VXt.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=ASe(t);return f.jsx("div",{className:T("lo-markdown",n),style:O,children:u.map(d=>f.jsx(NSe,{source:d.source,closed:d.closed},d.key))})};YSe.displayName="StreamingMarkdown";const I6=({mark:e,name:t,className:n})=>{const r=Jle(Yt(o=>o.agentAvatarSize)),i=e4e[r],a=JRe[r];return f.jsx("div",{className:T("flex",a.className,n),"data-turn-avatar-gap":a.px,children:f.jsx(UNe,{mark:e,boxClassName:i.className,glyphClassName:i.glyphClassName,hitClassName:i.hitClassName,alt:t??"",agentName:t})})},Pa=({isUser:e,children:t,className:n})=>e?f.jsx("div",{className:T("flex w-full justify-end",n),children:t}):f.jsx("div",{className:T("group relative w-full",n),children:t}),$W=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},uRt=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 yW=$W(Date.now()),yc=null,RK=0,EK=0,qK=0;const Ox=new Set,ORt=1e3,dRt=()=>typeof performance>"u"?Date.now():performance.now(),GSe=()=>{const e=Date.now(),t=e+uRt(e),n=dRt();yc!==null&&t===RK&&Math.abs(e-EK-(n-qK))<=ORt||(yc!==null&&clearTimeout(yc),RK=t,EK=e,qK=n,yc=setTimeout(()=>{yc=null,yW=$W(Date.now());for(const r of Ox)r();GSe()},t-e),yc.unref?.())},fRt=e=>(Ox.add(e),yW=$W(Date.now()),GSe(),()=>{Ox.delete(e),Ox.size===0&&yc!==null&&(clearTimeout(yc),yc=null)}),jK=()=>yW,hRt=()=>$.useSyncExternalStore(fRt,jK,jK),pRt=e=>new Date(e+1e3),mRt=()=>pRt(hRt()),Gdn=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":$k(t,{year:"numeric",month:"long",day:"numeric"})}catch(t){return console.error("Error formatting calendar date:",t),""}},gRt=(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=yk(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=$k(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),""}},$Rt=(e,t)=>{if(!e)return"";try{const n=e instanceof Date?e:new Date(e);return Number.isNaN(n.getTime())?"":Qce(n,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit",...t})}catch(n){return console.error("Error formatting calendar date-time:",n),""}},yRt={turn:"Sent",answer:"Answered",tool:"Ran"},HS=({timestamp:e,scope:t,className:n})=>{const r=e instanceof Date?e:new Date(e),i=mRt();if(Number.isNaN(r.getTime()))return null;const a=$Rt(r,{hour12:!0});return f.jsx(vt,{content:a,side:"bottom",delayDuration:1200,children:f.jsx("time",{dateTime:r.toISOString(),"data-stamp":t,"aria-label":`${yRt[t]} ${a}`,className:T("shrink-0 select-none whitespace-nowrap text-ink-dim text-meta",n),children:f.jsx("bdi",{children:gRt(r,i)})})})},vW=({replies:e,onRemoveReply:t})=>(we(),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(Fce,{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(Qe,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-ink-dim hover:bg-elevated hover:text-ink",onClick:()=>t(n.id),"data-reply-chip-remove":!0,"aria-label":m("ui.chat.reply.remove"),children:f.jsx(oi,{"aria-hidden":"true"})})]},n.id))]})),vRt=({children:e,className:t})=>f.jsx("span",{"aria-hidden":!0,className:T("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),bRt={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},wRt=({line:e})=>f.jsx("span",{className:T(bRt[e.kind],"block"),children:e.text}),xRt=({diff:e,className:t})=>{const n=t4e(e);return f.jsxs("div",{className:T("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(wRt,{line:r},i)),n.hidden>0&&f.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:n4e(n.hidden)})]})},SRt=(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()},CK=e=>e.startsWith("file://")?e.slice(7):e,QRt={READ:{verb:"Read",runningVerb:"Reading",icon:Nce},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:A9},EDIT:{verb:"Edited",runningVerb:"Editing",icon:A6e},CODE:{verb:"Ran code",runningVerb:"Running code",icon:Gce},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:eCe},DONE:{verb:"Finished",runningVerb:"Finishing",icon:Q9},ASK:{verb:"Asked",runningVerb:"Asking",icon:Qp},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:o7e}},kRt={verb:"Worked on the request",runningVerb:"Working on the request",icon:Gce},_Rt=(e,t,n,r)=>{const i=e?QRt[e]:kRt;let a;if(t)a=CK(t);else if(n&&n.length>0){const s=n.filter(l=>!l.startsWith("data:"));s.length===1?a=CK(s[0]):s.length>1&&(a=`${s.length} files`)}const o=!a&&r?SRt(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:a,narration:o||void 0,icon:i.icon}},zK="min-h-5 py-0",PRt=({icon:e,verb:t,object:n,narration:r,running:i,failed:a,wrap:o})=>f.jsxs("span",{className:T("flex min-w-0 gap-2",o?"items-start":"items-center"),"aria-busy":i||void 0,children:[f.jsx(vRt,{className:T(a?"text-danger":"text-ink-dim",o&&XOe),children:e}),f.jsxs("span",{className:T(o?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[f.jsxs("span",{...G5,className:T("select-text font-mono text-mono-sm",a?"text-danger":"text-ink-muted"),children:[t,r?":":null]}),n?f.jsxs("span",{...G5,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?f.jsxs("span",{...G5,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),AK=({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=_Rt(e,t,n,r),g=c??(i?p.runningVerb:p.verb),y=a?uO:p.icon,v=a||!c||!O?f.jsx(y,{}):O,b=f.jsx(PRt,{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(qi,{summary:b,chevron:"leading",summaryAlign:x,defaultOpen:o,className:l,rowClassName:h?zK:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:s}):f.jsx(qi,{disabled:!0,summary:b,summaryAlign:x,className:l,rowClassName:h?zK:void 0})};function Xi(e){return e.normalize("NFKC").trim().replace(/\s+/g," ").toLocaleLowerCase()}function bW(e,t,n){const r=e.trim(),i=t.trim();return r===""||Xi(r)===Xi(i)?n.unnamed(i):n.named(r,i)}const $y="all";function Zdn(e){return e}function Idn(e){return e===$y?$y:e}function D6(e){return e.kind==="agent"?QW(e.display_label,null):L_(e.display_label)}function TRt(e,t){const n=e.name?.trim();if(n)return n;const r=e.members.filter(a=>a.state!=="removed"&&!(a.kind==="human"&&a.account_id===t));if(e.kind==="dm"){const a=r.find(o=>o.state==="active")??r[0];return a?D6(a):null}const i=r.filter(a=>a.state==="active").map(D6).filter(a=>a!==null);return i.length===0?null:i.length<=3?i.join(", "):`${i.slice(0,2).join(", ")} +${i.length-2}`}function Ddn(e){return e.discoverable===!0&&e.member===!1}function XRt(e){return e.notify??(e.muted?"mute":"all")}function RRt(e){return XRt(e)==="mute"}function Vdn(e){return RRt(e)?"quiet":"attention"}function Mdn(e){return e==="mute"?"all":"mute"}const Ldn=[{value:"all",labelKey:"ui.teamBridge.agentNotify.all"},{value:"mention",labelKey:"ui.teamBridge.agentNotify.mention"},{value:"mute",labelKey:"ui.teamBridge.agentNotify.mute"}];function ZSe(e,t){return t?e.members.find(n=>n.kind==="agent"&&n.account_id===t&&n.state==="active")??null:null}function wW(e){const t=e.notify;return t==="all"||t==="mention"||t==="mute"?t:null}function Fdn(e,t){const n=ZSe(e,t);return n?{notify:wW(n)}:void 0}function Bdn(e,t,n){const r=ZSe(t,n),i=r?wW(r):null;return i===null?e:ERt(e,{conversationId:t.id,tenantId:t.tenant_id},n,i)}function ERt(e,t,n,r){return{...e,conversations:e.conversations.map(i=>i.id===t.conversationId&&i.tenant_id===t.tenantId?{...i,members:i.members.map(a=>a.kind==="agent"&&a.account_id===n&&a.state==="active"?{...a,notify:r}:a)}:i)}}function Hdn(e,t,n,r,i){return{...e,conversations:e.conversations.map(a=>a.id===t.conversationId&&a.tenant_id===t.tenantId?{...a,members:a.members.map(o=>{if(o.kind!=="agent"||o.account_id!==n||o.state!=="active"||wW(o)!==r)return o;if(i!==null)return{...o,notify:i};const{notify:s,...l}=o;return l})}:a)}}const Kdn=[{value:"all",labelKey:"ui.teamBridge.notify.all"},{value:"mention",labelKey:"ui.teamBridge.notify.mention"},{value:"mute",labelKey:"ui.teamBridge.notify.mute"}];function Jdn(e){return e==="mention"||e==="mute"?e:"all"}function efn(e,t,n,r){return{...e,conversations:e.conversations.map(i=>i.id===t&&(!r||i.tenant_id===r)?{...i,notify:n,muted:n==="mute"}:i)}}function tfn(e){return e.kind==="channel"&&e.status==="open"&&!e.builtin&&e.can_administer===!0}function nfn(e){return e.kind==="channel"&&e.status==="archived"&&!e.builtin&&e.can_administer===!0}const ISe=(e,t,n)=>e.id===t&&(!n||e.tenant_id===n);function rfn(e,t,n){return{...e,conversations:e.conversations.filter(r=>!ISe(r,t,n))}}function ifn(e,t,n,r){return{...e,conversations:e.conversations.map(i=>ISe(i,t,r)?{...i,status:n}:i)}}function afn(e,t){const n=new Set(e.map(r=>r.id));return[...e,...t.filter(r=>!n.has(r.id))]}function ofn(e){return e.filter(t=>t.kind==="channel"&&t.status==="archived")}function sfn(e){return typeof e=="object"&&e!==null&&e.code==="not_a_member"}function lfn(e,t,n=[]){const r=ARt(e,n).channels,i=r.findIndex(l=>l.id===t),a=i>=0?r[i+1]??r[i-1]:UK(r,n),o=e.filter(l=>l.id!==t),s=a&&a.id!==t?a:UK(o,n);return s?{type:"conversation",id:s.id}:null}function cfn(e,t){const n=new Set(e.conversations.map(r=>r.id));return{...t,conversations:[...e.conversations,...t.conversations.filter(r=>!n.has(r.id))]}}function ufn(e,t){return e.isError&&e.variables?.conversationId===t}function Ofn(e){return e.members.length>0?e.members.filter(t=>t.state==="active").length:e.member_count??0}function dfn(e){let t=0,n=0;for(const r of e.members)r.state==="active"&&(t+=1),r.state==="invited"&&(n+=1);return{active:t,invited:n}}function qRt(e){return[...e].sort((t,n)=>t.seq-n.seq)}function ffn(e,t=[],n){const r=new Map(t.map(l=>[l.tenant_id,l.unread])),i=e.filter(l=>l.status==="active");if(!n)return i.map(l=>({tenantId:l.tenant_id,name:l.tenant_name,role:l.role,unread:r.get(l.tenant_id)??0}));const a=new Map(i.map(l=>[l.tenant_id,l])),o=new Set,s=[];for(const l of n){if(o.has(l.tenant_id))continue;o.add(l.tenant_id);const c=a.get(l.tenant_id);s.push({tenantId:l.tenant_id,name:l.tenant_name?.trim()||c?.tenant_name?.trim()||l.tenant_id,role:c?.role??"",unread:r.get(l.tenant_id)??0})}return s}function hfn(e,t,n,r){if(n)return t;if(e.length===1)return e[0].tenantId;if(e.length>1)return $y;const i=new Set((r??[]).map(a=>a.tenant_id));return t===$y&&i.size===1?[...i][0]:t}function pfn(e,t){return e.find(n=>n.tenantId===t)??null}function xW(e){const t=n=>{const r=Date.parse(n);return Number.isNaN(r)?Number.NEGATIVE_INFINITY:r};return[...e].sort((n,r)=>{const i=t(r.last_message_at)-t(n.last_message_at);return i!==0?i:n.id.localeCompare(r.id)})}function mfn(e){return e?.status?.tenants??null}function gfn(e,t){return e!==null?{pending:!1,failed:!1}:{pending:t.isLoading,failed:t.isError}}function jRt(e,t){return t.find(n=>n.tenantId===e.tenant_id)?.name??null}function $fn(e,t,n){return t!==$y?[...e]:xW(e).filter(r=>jRt(r,n)!==null)}function yfn(e){return e?e.state==="signed_out"?"signed_out":e.state==="update_required"||e.update_required?"update_required":e.state==="unavailable"?"unavailable":e.surface_state==="A"?"plan_required":e.state!=="ready"?null:e.surface_state==="E"?"off":(e.surface_state==="C"||e.surface_state==="D")&&e.local?.enabled===!1?"off_local":null:null}function dx(e){return e.display_label.trim()||e.account_id}function vfn(e){const t=e,n=typeof t?.status=="number"?t.status:null,r=typeof t?.code=="string"?t.code:null;return n===401?"sign_in":n===403&&r==="bridge_not_available"?"plan":n===403?"refused":n===422||r==="invalid_request"?"invalid":n===400||n===404||t?.name==="ZodError"?"outdated":n===null?"unreachable":"server"}function CRt(e,t){return t&&e.account_id===t?"self":e.bridge_enabled&&(e.bridge_state==="active"||e.bridge_state==="paused")?e.bridge_state==="paused"?"paused":"openable":"unavailable"}function V6(e,t,n){const r=e.filter(i=>i.kind!=="dm"||i.status==="archived"||!i.members.some(o=>o.kind==="human"&&o.account_id===t&&o.state!=="removed")?!1:n?i.members.some(o=>o.kind==="human"&&o.account_id===n&&o.state!=="removed"):!0);return r.length===0?null:xW(r)[0]??null}function bfn(e){return e.trim().charAt(0).toUpperCase()||"?"}function zRt(e,t){const n=[];for(const r of e){if(t&&r.account_id===t)continue;const i=r.agent;!i||i.state==="disabled"||n.push({person:r,endpointId:i.endpoint_id,agentName:i.name.trim(),paused:i.state==="paused"})}return n}function M6(e,t,n){const r=e.filter(i=>i.kind==="dm"&&i.status!=="archived"&&i.members.some(a=>a.kind==="agent"&&a.account_id===t&&a.state!=="removed")&&(!n||i.members.some(a=>a.kind==="human"&&a.account_id===n&&a.state!=="removed")));return r.length===0?null:xW(r)[0]??null}const L6=["general","humans","agents"];function DSe(e,t,n){const r=L6.indexOf(e.builtin)-L6.indexOf(t.builtin);if(r!==0)return r;const i=o=>{const s=n.indexOf(o);return s<0?Number.POSITIVE_INFINITY:s},a=i(e.tenant_id)-i(t.tenant_id);return a!==0&&!Number.isNaN(a)?a:e.tenant_id.localeCompare(t.tenant_id)}function UK(e,t=[]){const n=r=>e.filter(i=>i.builtin===r).sort((i,a)=>DSe(i,a,t))[0];return n("general")??n("humans")??e[0]}function wfn(e){switch(e){case"general":return"ui.teamBridge.builtin.general_topic";case"humans":return"ui.teamBridge.builtin.humans_topic";case"agents":return"ui.teamBridge.builtin.agents_topic";default:return null}}function ARt(e,t=[]){const n=[],r=[],i=[],a=[];for(const o of e)o.kind==="channel"?o.builtin&&L6.includes(o.builtin)?n.push(o):r.push(o):o.kind==="group"?i.push(o):a.push(o);return n.sort((o,s)=>DSe(o,s,t)),{channels:[...n,...r],groups:i,directs:a}}function xfn(e,t,n,r){const i=new Set;for(const a of t){if(r!==void 0&&a.account_id===r)continue;const o=V6(e,a.account_id,r);o&&i.add(o.id)}for(const a of n){const o=M6(e,a.person.account_id,r);o&&i.add(o.id)}return e.filter(a=>!i.has(a.id))}function Sfn(e){return`${e.kind}:${e.accountId}`}function Qfn(e,t,n){if(e===null)return null;switch(e.type){case"conversation":return t.find(r=>r.id===e.id)??null;case"person":return V6(t,e.accountId,n);case"chief":return M6(t,e.accountId,n);case"compose":{if(e.recipients.length!==1)return null;const[r]=e.recipients;return r.kind==="agent"?M6(t,r.accountId,n):V6(t,r.accountId,n)}}}function URt(e){return SW(e.trim())??e}function WRt(e){const t=e.ownerLabel?.trim();if(e.agentName!==void 0&&t){const n=e.agentName.trim();return n!==""&&Xi(n)!==Xi(t)?n:t}return URt(e.label)}function NRt(e){return e.kind==="agent"?{account_id:e.accountId,kind:"agent",endpoint_id:e.endpointId,display_label:WRt(e).slice(0,64)}:{account_id:e.accountId,kind:"human",display_label:e.label.slice(0,64)}}function kfn(e,t,n){const r=e.filter(a=>{const o=CRt(a,t);return o==="openable"||o==="paused"}).map(a=>({kind:"human",accountId:a.account_id,label:dx(a)})),i=zRt(e,t).map(a=>({kind:"agent",accountId:a.person.account_id,endpointId:a.endpointId,agentName:a.agentName,ownerLabel:dx(a.person),label:bW(a.agentName,dx(a.person),n)}));return[...r,...i]}function _fn(e){if(e.length===0)return null;const t=e.map(NRt);return{kind:e.length===1?"dm":"group",visibility:"private",agentCapable:e.some(n=>n.kind==="agent"),members:t}}const YRt="Member";function L_(e){const t=e.trim();return t===""||t===YRt?null:t}const KS={"(":")","(":")"},VSe=256;function GRt(e,t){if(e.length>VSe)return null;const n=Xi(t);if(n==="")return null;for(let r=0;r<e.length;r+=1){const i=KS[e[r]];if(i===void 0||!e.endsWith(i))continue;const a=e.slice(r+1,e.length-i.length),o=e.slice(0,r).trim();if(o!==""&&Xi(a)===n)return o}return null}function ZRt(e){const t=new Set(Object.values(KS)),n=[];for(const r of e){const i=KS[r];if(i!==void 0)n.push(i);else if(t.has(r)&&n.pop()!==r)return!1}return n.length===0}function SW(e){if(e.length>VSe)return null;for(let t=0;t<e.length;t+=1){const n=KS[e[t]];if(n===void 0||!e.endsWith(n))continue;const r=e.slice(t+1,e.length-n.length),i=e.slice(0,t).trim();if(i!==""&&ZRt(r)&&Xi(i)===Xi(r))return i}return null}const MSe=["'s chief of staff","’s chief of staff"],IRt=64;function DRt(e){const t=e.replace(/[\s\u0085]+/gu," ").trim(),n=new TextEncoder().encode(t);let r=IRt-MSe[0].length;if(n.length<=r)return t;for(;r>0&&(n[r]&192)===128;)r-=1;return new TextDecoder().decode(n.subarray(0,r)).trim()}function QW(e,t){const n=L_(e);if(n===null||t!==null&&Xi(n)===Xi(t)||t!==null&&[t,DRt(t)].some(r=>MSe.some(i=>Xi(n)===Xi(`${r}${i}`))))return null;if(t!==null){const r=GRt(n,t);if(r!==null)return Xi(r)===Xi(t)?null:r}return SW(n)!==null?null:n}function LSe(e,t){const n=D6(e);if(n!==null||e.kind!=="agent")return n;const r=L_(e.display_label),i=r===null?null:SW(r);return i===null?null:t.unnamed(i)}function Pfn(e,t){const n=e.ownerLabel.trim();return n===""?LSe({kind:"agent",display_label:e.label},t):bW(QW(e.label,n)??"",n,t)}function Tfn(e,t,n,r){const i=t.find(l=>l.account_id===e.account_id),a=i?dx(i):null;if(e.kind==="human"){const l=L_(e.display_label),c=r&&r.accountId===e.account_id&&r.name.trim()||null;return a??c??l}const o=i?.agent?.name.trim()??"",s=o!==""&&(a===null||Xi(o)!==Xi(a))?o:QW(e.display_label,a);return a?bW(s??"",a,n):s??LSe({kind:"agent",display_label:e.display_label},n)}const VRt=5*6e4;function zX(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function Xfn(e,t){const n=zX(t),r=zX(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1)),i=[];let a=null,o=null;for(const s of qRt(e)){const l=new Date(s.created_at),c=!Number.isNaN(l.getTime()),u=c?zX(l):null;u!==null&&u!==o&&i.push({type:"day",key:u,date:l,relative:u===n?"today":u===r?"yesterday":null});const O=a!==null&&c&&u===o&&a.sender.account_id===s.sender.account_id&&a.sender.kind===s.sender.kind&&l.getTime()-Date.parse(a.created_at)<VRt;i.push({type:"message",message:s,continuation:O}),a=s,u!==null&&(o=u)}return i}const WK="Team Bridge create answered for another tenant",AX=new WeakMap;async function Rfn(e){if(AX.get(e.remembered)?.has(e.draftKey))throw new Error(WK);let t=e.remembered.get(e.draftKey);if(t===void 0){const n=await e.create(e.input);if(!n.id)throw new Error("create returned no conversation id");if(e.tenantId!==void 0&&typeof n.tenant_id=="string"&&n.tenant_id!==e.tenantId){const r=AX.get(e.remembered)??new Set;throw r.add(e.draftKey),AX.set(e.remembered,r),new Error(WK)}t={id:n.id,tenantId:n.tenant_id??e.tenantId},e.remembered.set(e.draftKey,t)}return e.onCreated?.(t),await e.post(t.id,{clientRef:e.clientRef,body:e.body,tenantId:t.tenantId}),e.remembered.delete(e.draftKey),t}const MRt=["channel","here","everyone"];function Efn(e){const{body:t,candidates:n,self:r}=e;if(!t||!t.includes("@"))return null;const i=r?[...n,{kind:"human",accountId:r.accountId,label:r.label}]:n,a=c=>r!==null&&c===r.accountId;if(Array.isArray(e.mentions)){const c=[];for(const u of e.mentions){if(!u||typeof u!="object")continue;if(u.kind==="channel"){const d=MRt.find(h=>FSe(t,[{label:h,viewer:!1}],!0).some(p=>p.kind==="mention"));d&&c.push({label:d,viewer:!1});continue}const O=i.find(d=>d.kind===u.kind&&d.accountId===u.account_id);O&&O.label!==""&&c.push({label:O.label,viewer:a(u.account_id)})}return c.length>0?{source:"message",runs:c,caseSensitive:!0}:null}const o=c=>r!==null&&r.labelUnique===!0&&c.kind==="human"&&c.accountId===r.accountId&&!n.some(u=>u.accountId!==r.accountId&&Xi(u.label)===Xi(c.label)),s=new Map;for(const c of i)c.label===""||!t.includes(`@${c.label}`)||s.set(c.label,(s.get(c.label)??!1)||o(c));const l=[...s].map(([c,u])=>({label:c,viewer:u}));return l.length>0?{source:"fallback",runs:l,caseSensitive:!0}:null}const NK=/[\p{L}\p{N}_]/u;function FSe(e,t,n=!0){const r=(l,c)=>n?l===c:l.toLocaleLowerCase()===c.toLocaleLowerCase(),i=[...t].sort((l,c)=>c.label.length-l.label.length),a=[];let o="",s=0;for(;s<e.length;){const l=s===0?"":e.charAt(s-1),c=e.charAt(s)==="@"&&!NK.test(l)&&l!=="."?i.find(O=>{const d=s+1+O.label.length;return r(e.slice(s+1,d),O.label)&&!NK.test(e.charAt(d))}):void 0;if(!c){o+=e.charAt(s),s+=1;continue}o&&a.push({kind:"text",text:o}),o="";const u=s+1+c.label.length;a.push({kind:"mention",text:e.slice(s,u),viewer:c.viewer}),s=u}return o&&a.push({kind:"text",text:o}),a}const LRt="team-bridge-mention rounded-sm px-0.5 font-medium bg-accent-wash text-accent",FRt="team-bridge-mention rounded-sm px-0.5 font-medium bg-warning-wash text-warning";function BRt(e){return()=>t=>{Dk(t,"text",(n,r,i)=>{if(!i||r===void 0||!n.value.includes("@"))return;const a=FSe(n.value,e);if(a.some(o=>o.kind==="mention"))return i.children.splice(r,1,...a.map(o=>o.kind==="text"?{type:"text",value:o.text}:{type:"mention",data:{hName:"span",hProperties:{className:o.viewer?FRt:LRt,"data-mention":o.viewer?"viewer":"other"}},children:[{type:"text",value:o.text}]})),r+a.length})}}const HRt=/^(https?:|mailto:)/i,KRt={a:({href:e,children:t})=>typeof e=="string"&&HRt.test(e)?f.jsx("a",{href:e,target:"_blank",rel:"noreferrer",children:t}):f.jsx("span",{className:"font-mono text-mono-sm",children:t}),img:({alt:e,src:t})=>f.jsx("span",{className:"text-ink-muted",children:e||(typeof t=="string"?t:"")}),table:QSe},BSe=$.memo(({children:e,className:t,mentions:n,style:r})=>{const i=$.useMemo(()=>n?.length?[Gs,BRt(n)]:[Gs],[n]);return f.jsx("div",{className:T("lo-markdown",t),style:r,children:f.jsx(Fx,{remarkPlugins:i,components:KRt,children:e})})});BSe.displayName="TeamBridgeMarkdown";const HSe=8,JRt="… deeper values not shown",e4t="(empty)";function t4t(e){return`… ${e} more line${e===1?"":"s"}`}const YK=.5;function n4t(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 KSe(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function kW(e){return typeof e=="object"&&e!==null}function JSe(e,t,n,r){if(n>HSe){r.push({key:t,value:JRt,depth:n});return}if(kW(e)){for(const[a,o]of Object.entries(e))JSe(o,t?`${t}.${a}`:a,n+1,r);return}const i=KSe(e);i!==null&&r.push({key:t,value:i,depth:n})}function eQe(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))JSe(r,n,1,t);return t}const r4t=512;function i4t(e,t){if(t)return!0;if(!e)return!1;let n=r4t;const r=(i,a)=>{if(n--<=0||a>HSe)return!0;if(!kW(i))return KSe(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 a4t(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(!kW(n))return null;const r=eQe(n);return r.length>0?r:[{key:"",value:e4t,depth:1}]}const o4t=8,yy="max-h-[min(320px,40vh)]",tQe=yy,nQe=({line:e})=>f.jsxs("div",{className:T("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*o4t},children:[e.key?f.jsxs("span",{className:T("text-ink-muted"),children:[e.key,": "]}):null,f.jsx("span",{className:T("text-ink-dim"),children:e.value})]}),GK=({lines:e,section:t})=>f.jsx("div",{className:T("flex flex-col gap-1"),"data-detail-lines":t,children:e.map((n,r)=>f.jsx(nQe,{line:n},r))});function ZK(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+YK);const h=c.children.length>0?Array.from(c.children):[c];n(n4t(h.map(p=>{const g=p.getBoundingClientRect();return{top:g.top,height:g.height}}),u,O.bottom,YK))};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 IK=({lines:e,overflowing:t})=>t?f.jsx("span",{className:T("mt-1 block text-ink-dim"),children:e>0?t4t(e):" "}):null,s4t=({args:e,output:t,isError:n,interrupted:r=!1,note:i=null})=>{const a=eQe(e),o=a4t(t),s=$.useRef(null),l=$.useRef(null),c=ZK(s),u=ZK(l);return a.length===0&&!t&&!i?null:f.jsxs("div",{className:T("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:T(yy,"overflow-auto"),children:f.jsx(GK,{lines:a,section:"input"})}),f.jsx(IK,{lines:c.lines,overflowing:c.overflowing})]}),i&&f.jsx("div",{className:T("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:T(a.length>0&&"mt-3"),"data-detail-section":"output",children:[f.jsx("span",{className:T("mb-1 block text-meta",n&&!r?"text-danger":"text-ink-dim"),children:r?"Interrupted":n?"Error":"Output"}),f.jsx("div",{ref:l,className:T(yy,"overflow-auto"),children:o?f.jsx(GK,{lines:o,section:"result-json"}):f.jsx("pre",{className:T("whitespace-pre font-mono",n&&!r?"text-danger":"text-ink"),children:t})}),f.jsx(IK,{lines:u.lines,overflowing:u.overflowing})]})]})},rQe=({view:e,isError:t,note:n=null,children:r})=>{const i=n??e.outcome,a=e.internals.length>0||!!e.raw;return f.jsxs("div",{className:T("flex w-full flex-col gap-2 rounded-md bg-sunken p-3 font-sans text-body-sm"),"data-bridge-detail":"",children:[e.headline?f.jsx("div",{className:T("font-medium text-ink"),"data-detail-section":"bridge-target",children:e.headline}):null,e.body?f.jsx("div",{className:T(yy,"overflow-auto text-ink"),"data-detail-section":"bridge-body",children:f.jsx(BSe,{children:e.body})}):null,i?f.jsx("div",{className:T("whitespace-normal",t?"text-danger":"text-ink-muted"),"data-detail-section":"bridge-outcome",children:i}):null,r,a?f.jsx(qi,{chevron:"trailing",chevronClassName:"text-ink-dim",summary:f.jsx("span",{className:T("text-ink-dim text-meta"),children:m("ui.chat.canonical.tool_row.bridge.detail.details")}),triggerData:{"data-detail-section":"bridge-details"},children:f.jsxs("div",{className:T(yy,"overflow-auto pt-1 font-mono text-mono-sm"),children:[e.internals.map(o=>f.jsx(nQe,{line:{key:o.key,value:o.value,depth:1}},o.key)),e.raw?f.jsx("pre",{className:T("mt-2 whitespace-pre-wrap break-words font-mono text-ink-dim"),children:e.raw}):null]})}):null]})},l4t="mcp__",c4t={bash:oCe,read:X$,write:xG,edit:xG,glob:kp,grep:dv,todo:K7e,wake:uv,list_variables:PG,read_variable:PG,browser:SG,console:Bce,project:e7e,project_delete:uCe,web_search:SG,web_fetch:vk,task:N0,agent:N0,send:jx,peer:I7e,sessions:N6e,bridge:h6e};function u4t(e){const t=e.trim().toLowerCase(),n=c4t[t];return n||(t.startsWith(l4t)?Hce:SCe)}const O4t=j9,d4t=r6e,f4t=t6e,h4t=s6e,p4t=Vce,DK="min-h-5 py-0",VK={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent-alt",plain:"text-ink-muted"},m4t=(e,t)=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":e==="receipt"?VK.plain:VK[r4e(t)],g4t=e=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":"text-ink-muted",$4t=({added:e,removed:t})=>e<=0&&t<=0?null:f.jsxs("span",{className:T("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&f.jsxs("span",{className:T("text-success"),children:["+",e]}),t>0&&f.jsxs("span",{className:T("text-danger"),children:["-",t]})]}),y4t={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:""},UX=e=>{const t=y4t[e];return t===""?"":m(t)},v4t=1e3;function b4t(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,v4t);return()=>window.clearInterval(i)},[e]),t}const w4t=({toolName:e="",outcome:t,deliveryState:n=null,failureWord:r=null,durationS:i,startedAt:a})=>{const o=t==="running",s=b4t(o?a??null:null),l=t==="error"||t==="not-run",c=t==="partial",u=a4e(n,e),O=c?u:l?u??r??UX(t):null,d=c?"text-warning":"text-danger",h=c?o4e(n,e):null,p=T("font-medium text-meta",d,c&&(h?"hidden @[40rem]/toolrow:inline":"hidden @[19rem]/toolrow:inline")),g=T("font-medium text-meta",d,"hidden @[20rem]/toolrow:inline @[40rem]/toolrow:hidden"),y=c?s4e(n,e):null,v=c?l4e(n,e):void 0,b=c?n==="mailbox"?d4t:n==="unconfirmed"?f4t:n==="inbox_only"?h4t:n==="awaiting_acceptance"?p4t:null:t==="interrupted"?O4t:null,x=b&&c?"text-warning":"text-ink-dim",Q=o?a==null?"":lO(s??0):d9(i);return f.jsxs("span",{className:T("flex shrink-0 items-center gap-1.5"),children:[O?f.jsx("span",{className:p,title:v,"aria-hidden":y?!0:void 0,children:O}):null,O&&h?f.jsx("span",{className:g,title:v,"aria-hidden":y?!0:void 0,"data-status-word":"short",children:h}):null,f.jsxs("span",{className:T("flex shrink-0 [&_svg]:size-3.5",b&&"size-3.5",x),children:[b?f.jsx(b,{"aria-hidden":!0}):null,!l&&UX(t)?f.jsx("span",{className:T("sr-only"),children:UX(t)}):null,y?f.jsx("span",{className:T("sr-only"),children:y}):null]}),f.jsx("span",{className:T("hidden w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums @[19rem]/toolrow:inline"),children:Q})]})},Uc=({toolName:e,op:t="",verbless:n=!1,summary:r,summaryFallback:i=null,summaryHold:a=!1,summaryWrap:o=!1,outcome:s,deliveryState:l=null,settledVerb:c=null,failureWord:u=null,durationS:O,startedAt:d=null,added:h=0,removed:p=0,details:g,defaultOpen:y=!1,className:v,media:b})=>{we();const x=s==="running",Q=s==="error",w=u4t(e),S=Q$(e),{verb:k,object:P}=ece(e,r,i,x,t,c??i4e(l)),X=f.jsxs("span",{className:T("flex min-w-0 flex-1 items-center gap-2"),children:[f.jsx("span",{"aria-hidden":!0,className:T("flex size-3.5 shrink-0 [&_svg]:size-3.5",m4t(s,e)),children:f.jsx(w,{})}),n?null:f.jsx("span",{"data-trace-verb":"",className:T("shrink-0 whitespace-nowrap text-body-sm",g4t(s)),title:S,children:k}),f.jsx("span",{className:T(o?"min-w-0 flex-1 break-words whitespace-normal font-mono text-ink-muted text-mono-sm":"min-w-0 flex-1 truncate font-mono text-ink-muted text-mono-sm"),title:a?void 0:P,children:a?f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"text-ink-dim","data-label-hold":"true","aria-hidden":!0,children:"…"}),f.jsx("span",{className:T("sr-only"),children:m("ui.chat.canonical.tool_row.pending")})]}):f.jsx("bdi",{dir:"ltr",children:P})}),f.jsx($4t,{added:h,removed:p}),f.jsx(w4t,{toolName:e,outcome:s,deliveryState:l,failureWord:u,durationS:O,startedAt:d})]}),E=x?{"data-glass-state":"running"}:void 0,R=x?"bg-elevated":Q?"bg-danger-wash":"hover:bg-row-hover",q=g?f.jsx(qi,{summary:X,chevron:"leading",defaultOpen:y,className:T("@container/toolrow",v),triggerData:E,rowClassName:DK,triggerClassName:T("-mx-2 rounded-sm px-2",R),children:g}):f.jsx(qi,{disabled:!0,summary:X,triggerData:E,rowClassName:DK,className:T("@container/toolrow",(x||Q)&&T("-mx-2 rounded-sm px-2",R),v)});return b?f.jsxs("div",{className:T("flex flex-col"),children:[q,b]}):q},x4t=3,S4t=2;function Q4t(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=tce(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 iQe=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},aQe=e=>{const t=new Map;let n=0;for(const o of e){const s=iQe(o.name);s===null?n+=1:t.set(s,(t.get(s)??0)+1)}const r=_W(e);if(n>0||t.size>2){const o=oQe(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}},k4t=e=>aQe(e).units;function _4t(e){return k4t(e).join(" · ")}const WX={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"}},NX=5,oQe=e=>{if(e.length<=NX)return e.map(r=>r.label);const t=e.slice(0,NX),n=e.slice(NX).reduce((r,i)=>r+i.count,0);return[...t.map(r=>r.label),`and ${n} other action${n===1?"":"s"}`]},_W=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=iQe(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",WX.todo);else if(l==="jobs")(s.op??"").toLowerCase()==="cancel"?n("kind:jobs:cancel",{noun:"job cancellation",plural:"job cancellations"}):n("kind:jobs",WX.jobs);else if(l==="bridge")c4e.has((s.op??"").toLowerCase())?n("kind:bridge:post",{noun:m("ui.chat.canonical.fold.bridge_post.one"),plural:m("ui.chat.canonical.fold.bridge_post.other")}):n("kind:bridge",{noun:m("ui.chat.canonical.fold.bridge.one"),plural:m("ui.chat.canonical.fold.bridge.other")});else{const u=WX[l];if(u)n(`kind:${l}`,u);else{const O=Q$(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 P4t(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 T4t(e){let t=null,n=null,r=!1;for(const i of e){i.running===!0&&(r=!0);const a=P4t(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 X4t(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.executing===!0)return ece(n.name,n.summary??"",null,!0,n.op)}return null}function R4t(e,t){let n=0;for(let r=e.length-1;r>=0&&t(e[r]);r-=1)n+=1;return n}function E4t(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?R4t(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>=x4t||c>=S4t||u){const O=(()=>{if(o.length===0)return{units:[],prose:!1,countUnits:[]};const d=_W(o);return l.length>0?{units:oQe(d),prose:!1,countUnits:d}:aQe(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:T4t(o),live:X4t(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 q4t(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 MK=e=>{const t=[];for(const n of e)if(!(n.record.kind!=="tool"&&!(n.record.kind==="custom"&&tce(n.record)==="incoming")))for(const r of n.record.images??[])Sp(r)&&t.push(r);return t},fx=5,j4t=(e,{uncapped:t=!1}={})=>t?{shown:Math.max(e,0),more:0}:e<fx?{shown:Math.max(e,0),more:0}:{shown:fx-1,more:e-(fx-1)},C4t=e=>{const t=fx-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},JS=e=>e<=0?null:`${e} image${e===1?"":"s"}`;function eQ(e){return e.record.kind==="tool"?e.record.durationS:null}function sQe(e){let t=null;for(const n of e){const r=eQ(n);typeof r=="number"&&(t=(t??0)+r)}return t}function z4t(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 A4t="min-h-5 py-0",U4t=1e3;function W4t(e){const[t,n]=$.useState(()=>Date.now());return $.useEffect(()=>{if(!e)return;const r=()=>n(Date.now());r();const i=window.setInterval(r,U4t);return()=>window.clearInterval(i)},[e]),t}const N4t=({summary:e,span:t,live:n,open:r,onOpenChange:i,className:a,condensedMedia:o,mediaCount:s=0,recordIds:l,children:c})=>{const u=W4t(t?.running===!0),O=t===null?null:Math.max(0,((t.running?u:t.endedAtMs??u)-t.startedAtMs)/1e3),d=O===null?"":d9(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(qi,{animate:r||!o,open:r,onOpenChange:i,rowClassName:A4t,triggerClassName:T("-mx-2 rounded-sm px-2","hover:bg-row-hover"),summary:f.jsxs("span",{className:T("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:T("min-w-0 shrink-[100000] truncate"),title:`${n.verb} ${n.object}`,children:[f.jsx("span",{className:T("text-accent"),children:n.verb})," ",f.jsx("span",{className:T("font-mono text-mono-sm text-ink-muted"),children:n.object})]}),f.jsx("span",{"aria-hidden":!0,className:T("text-ink-dim text-meta"),children:"·"})]}),f.jsx("span",{className:T("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:T(e.prose?"whitespace-normal":"whitespace-nowrap"),children:g})]},g))}),JS(s)!==null&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":!0,className:T("text-ink-dim text-meta"),children:"·"}),f.jsx("span",{className:T("shrink-0 text-ink-muted text-meta"),children:JS(s)})]}),d!==""&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":!0,className:T("text-ink-dim text-meta"),children:"·"}),f.jsx("span",{"data-fold-span":"",className:T("shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:d})]})]}),children:f.jsx("div",{className:T("flex flex-col"),children:c})}),!r&&o&&o(p)]})},LK=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],Y4t=80,G4t=1e3,lQe=({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=hA("(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)),G4t):null;if(d)return o(0),()=>{b!==null&&window.clearInterval(b)};const x=window.setInterval(()=>o(Q=>(Q+1)%LK.length),Y4t);return()=>{window.clearInterval(x),b!==null&&window.clearInterval(b)}},[d,O]),f.jsxs("div",{className:T("flex items-center gap-2",i),"data-lo-working-line":!0,"aria-live":"polite",children:[f.jsx("span",{"aria-hidden":!0,className:T("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:LK[a]}),f.jsx("span",{className:T("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),f.jsx("span",{"aria-hidden":!0,className:T("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:O?lO(s):""})]})},Z4t="min-h-5 py-0",Ru=()=>f.jsx("span",{"aria-hidden":!0,className:T("text-ink-dim text-meta"),children:"·"}),I4t=({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})=>{we();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:T("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(qi,{open:O,onOpenChange:d,chevron:"trailing",rowClassName:Z4t,triggerClassName:T("-ms-2 -me-2 w-[calc(100%+1rem)] rounded-sm ps-2 pe-6","hover:bg-row-hover"),chevronClassName:T("-mr-6","text-ink-muted"),summary:f.jsxs("span",{className:T("flex min-w-0 flex-1 items-center gap-2"),title:s??void 0,children:[c!==null&&f.jsx("span",{className:T("shrink-0 text-body-sm text-ink-muted"),"data-segment-label":"",children:c}),u&&!v?.active&&f.jsx(f.Fragment,{children:f.jsx(Q9,{"aria-hidden":!0,className:T("size-3.5 shrink-0 text-success")})}),v?.active?f.jsxs(f.Fragment,{children:[c!==null&&f.jsx(Ru,{}),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(Ru,{}),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(Ru,{}),f.jsx(lQe,{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(Ru,{}),f.jsx("span",{className:T("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(Ru,{}),f.jsx("span",{className:T("shrink-0 text-body-sm text-ink-muted"),children:lO(y.spanS)})]})]}):f.jsxs(f.Fragment,{children:[c!==null&&(i!==null||a>0)&&f.jsx(Ru,{}),i!==null&&f.jsx("span",{className:T("shrink-0 text-body-sm text-ink-muted"),children:m("ui.chat.canonical.turn_summary.took",{duration:lO(i)})}),i!==null&&a>0&&f.jsx(Ru,{}),a>0&&f.jsx("span",{className:T("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})})]}),JS(g)!==null&&f.jsxs(f.Fragment,{children:[f.jsx(Ru,{}),f.jsx("span",{className:T("shrink-0 text-body-sm text-ink-muted"),children:JS(g)})]}),u&&!v?.active&&f.jsx("span",{className:T("sr-only"),children:m("ui.chat.canonical.turn_summary.completed")}),l!==null&&f.jsx("span",{className:T("ms-auto"),children:f.jsx(HS,{timestamp:l,scope:"answer"})})]}),children:f.jsx("div",{className:T("flex flex-col"),children:h})}),!O&&p&&f.jsx("div",{className:T("pb-2"),children:p(k)})]})},cQe="lo-missing-session-notice",Hc=({children:e,className:t,boundary:n="hairline",...r})=>f.jsx("div",{className:T("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}),D4t="could not be displayed. It may have been moved, renamed, or deleted.",PW="could not be displayed. Its stored copy is not available to this reader.",uQe="could not be played. Its stored copy is not available to this reader.",OQe=uQe,lf=({name:e,detail:t=D4t,className:n,compact:r=!1})=>r?f.jsx("div",{className:T("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(kG,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0})}):f.jsxs("div",{className:T("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(kG,{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}`]})]}),V4t="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",tQ=4,dQe=2,M4t=2,fQe=4,hQe=tQ+dQe,L4t=.8,F4t=24,FK=.3,BK=1;function B4t(e){return!Number.isFinite(e)||e<=0?1:Math.max(1,Math.floor((e+dQe)/hQe))}function H4t(e,t){const n=Math.min(e,t-e);return Number.isFinite(n)?Math.max(0,Math.min(1,n/F4t)):0}function K4t(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 pQe(e,t,n){const r=B4t(t),i=e===null?null:K4t(e,r),a=[],o=Math.max(1,r-1);for(let s=0;s<r;s+=1){const l=s*hQe,c=l+tQ/2,O=(i===null?0:i[s])*n*L4t,d=Math.max(fQe,Math.round(O)),h=FK+(BK-FK)*(s/o);a.push({x:l,width:tQ,height:d,alpha:Math.min(BK,h)*H4t(c,t)})}return a}function f$(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 J4t(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 eEt(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?0:Math.max(0,Math.min(1,e/t))}function HK(e,t){return`${f$(e)} of ${f$(t)}`}const tEt=4,KK=1,mQe=({ownerId:e,src:t,label:n,peaks:r,durationHint:i=null,hideUnknownTotal:a=!1,variant:o="full",className:s})=>{we();const l=Yi(F=>F.ownerId===e),c=Yi(F=>F.ownerId===e?F.status:"idle"),u=Yi(F=>F.ownerId===e?F.duration:0),[O,d]=$.useState(!1),[h,p]=$.useState(!1);$.useEffect(()=>{(c==="loading"||c==="playing")&&p(!1)},[c]);const g=u>0?u:i??0,y=l&&c==="playing",v=l&&c==="loading",b=h||l&&c==="error",x=$.useRef(null),Q=$.useRef(null),w=$.useRef(null),S=$.useRef(null),k=$.useRef(null),[P,X]=$.useState({width:0,height:0,dpr:1});$.useEffect(()=>{const F=x.current;if(!F)return;const H=()=>{const ee=F.getBoundingClientRect();X({width:ee.width,height:ee.height,dpr:window.devicePixelRatio||1})};H();const se=new ResizeObserver(H);return se.observe(F),()=>se.disconnect()},[]);const E=$.useCallback(F=>{if(!F||P.width<=0)return;const H=F.getContext("2d");if(!H)return;F.width=Math.max(1,Math.round(P.width*P.dpr)),F.height=Math.max(1,Math.round(P.height*P.dpr)),H.setTransform(P.dpr,0,0,P.dpr,0,0),H.clearRect(0,0,P.width,P.height);const se=getComputedStyle(F).color,ee=pQe(r,P.width,P.height);H.fillStyle=se;for(const L of ee)H.globalAlpha=L.alpha,H.beginPath(),H.roundRect(L.x,(P.height-L.height)/2,L.width,L.height,M4t),H.fill();H.globalAlpha=1},[P.width,P.height,P.dpr,r]);$.useEffect(()=>{E(Q.current),E(w.current)},[E]);const R=$.useRef(null),q=$.useCallback(F=>{const H=eEt(F,g),se=w.current;x.current?.style.setProperty("--sound-progress",`${H*100}%`),se&&(se.style.clipPath=`inset(0 ${(1-H)*100}% 0 0)`);const ee=f$(F);k.current&&k.current.textContent!==ee&&(k.current.textContent=ee);const L=S.current;L&&(L.setAttribute("aria-valuenow",String(Math.floor(F))),L.setAttribute("aria-valuetext",HK(F,g)))},[g]);$.useEffect(()=>{const F=y||O,H=()=>q(l?oT()?.currentTime??0:G.current);if(!F){H();return}let se=0;const ee=()=>{const L=R.current??oT()?.currentTime??0;q(L),se=requestAnimationFrame(ee)};return se=requestAnimationFrame(ee),()=>cancelAnimationFrame(se)},[y,O,l,q]);const C=$.useCallback(async()=>(p(!1),Yi.getState().play(e,t,{onError:()=>p(!0)})),[e,t]),z=$.useCallback(F=>{const H=Yi.getState();if(y){H.seek(e,F),q(F);return}C().then(se=>{se!==!1&&(Yi.getState().seek(e,F),q(F))})},[e,y,C,q]),W=$.useCallback(async()=>{if(y){Yi.getState().pause(e);return}p(!1),await Yi.getState().toggle(e,t,{onError:()=>p(!0)})},[e,t,y]),G=$.useRef(0),A=$.useRef(null),I=$.useCallback(F=>{const H=x.current;if(!H)return 0;const se=H.getBoundingClientRect();return J4t(F-se.left,se.width,g)},[g]),Z=F=>{if(v)return;F.currentTarget.setPointerCapture?.(F.pointerId),A.current={pointerId:F.pointerId,startX:F.clientX,moved:!1,pendingX:F.clientX,raf:0}},U=F=>{const H=A.current;!H||H.pointerId!==F.pointerId||(Math.abs(F.clientX-H.startX)>tEt&&(H.moved||d(!0),H.moved=!0),H.pendingX=F.clientX,H.moved&&H.raf===0&&(H.raf=requestAnimationFrame(()=>{const se=A.current;if(!se)return;se.raf=0;const ee=I(se.pendingX);R.current=ee,Yi.getState().scrub(e,ee),q(ee)})))},D=F=>{const H=A.current;if(!H||H.pointerId!==F.pointerId)return;H.raf!==0&&cancelAnimationFrame(H.raf),A.current=null,R.current=null,F.currentTarget.releasePointerCapture?.(F.pointerId);const se=I(F.clientX);if(H.moved){G.current=se,d(!1),Yi.getState().seek(e,se),q(se);return}z(se)},K=F=>{const H=oT(),se=l&&H?H.currentTime:0;if(F.key===" "||F.key==="Enter"){F.preventDefault(),W();return}let ee=null;if(F.key==="ArrowLeft"?ee=se-KK:F.key==="ArrowRight"?ee=se+KK:F.key==="Home"?ee=0:F.key==="End"&&(ee=g),ee===null)return;F.preventDefault();const L=Math.max(0,Math.min(g,ee));z(L)},Y=o==="compact",le=`${n} position`;return f.jsxs("div",{"data-sound-player":o,"data-sound-peaks":r?"stored":"flat","data-sound-status":b?"error":O?"scrubbing":l?c:"idle",className:T("flex w-full min-w-0 items-center gap-2",Y?"gap-1.5":"gap-2",s),children:[f.jsx("button",{type:"button",className:V4t,disabled:v,onClick:()=>void W(),"aria-label":y?m("ui.chat.audio.pause_label",{label:n}):m("ui.chat.audio.play_label",{label:n}),children:v?f.jsx(Sa,{size:"sm"}):y?f.jsx(Yce,{size:22,"aria-hidden":"true"}):f.jsx(L3e,{size:22,"aria-hidden":"true"})}),f.jsx("div",{ref:S,role:"slider",tabIndex:0,"aria-label":le,"aria-valuemin":0,"aria-valuemax":Math.max(0,Math.round(g)),"aria-valuenow":0,"aria-valuetext":HK(0,g),"data-sound-slider":"",className:T("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",b&&"cursor-default"),onPointerDown:Z,onPointerMove:U,onPointerUp:D,onPointerCancel:D,onKeyDown:K,children:f.jsxs("div",{ref:x,className:"absolute inset-0",children:[f.jsx("canvas",{ref:Q,className:"absolute inset-0 h-full w-full text-ink-dim"}),f.jsx("canvas",{ref:w,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:T("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",O&&"bg-accent"),style:{left:"var(--sound-progress, 0%)"}})]})}),f.jsx("span",{ref:k,"data-sound-time":"",className:T("min-w-10 shrink-0 text-center text-meta text-ink-muted tabular-nums"),children:f$(0)}),f.jsx("span",{"data-sound-total":"","aria-hidden":a&&g<=0?!0:void 0,className:T("min-w-10 shrink-0 text-center text-meta text-ink-dim tabular-nums",a&&g<=0&&"invisible"),children:f$(g)}),b?f.jsx("span",{"data-sound-error":"",className:T("shrink-0 text-meta text-ink-muted"),children:m("ui.chat.canonical.sound.player_failed")}):null]})};function JK(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 eJ=new Map;async function nEt(e,t){try{const n=await is({op:"sessions.attachment.waveform",sessionId:e.sessionId,digest:t},null);if(n.kind==="json")return JK(n.body);if(n.kind==="bytes"){const r=new TextDecoder().decode(n.data);try{return JK(JSON.parse(r))}catch{return null}}return null}catch{return null}}function gQe(e,t){const n=t?.sessionId??null,r=t?.childId??null,[i,a]=$.useState(()=>e?rEt(e):null);return $.useEffect(()=>{if(!e||!n){a(null);return}let o=!0;return iEt({sessionId:n,childId:r},e).then(s=>{o&&a(s)}),()=>{o=!1}},[e,n,r]),i}function rEt(e){return F6.get(e)??null}const F6=new Map;function iEt(e,t){const n=eJ.get(t);if(n)return n;const r=nEt(e,t).then(i=>(F6.set(t,i),i)).catch(()=>(F6.set(t,null),null));return eJ.set(t,r),r}function $Qe(e){return`sound:${e.attachment??e.id}`}const TW=({audio:e,scope:t,label:n,ownerId:r})=>{const i=Mv(e,t),a=gQe(e.attachment,t);return i.state==="missing"?f.jsx(lf,{name:n,detail:OQe}):i.state==="resolving"?f.jsx("div",{className:T("inline-block max-w-full self-start"),"aria-hidden":!0,children:f.jsx(Hc,{"data-attachment-reserved":""})}):f.jsx("div",{className:T("w-full max-w-[560px] self-start"),children:f.jsx(mQe,{ownerId:r??$Qe(e),src:i.url,label:n,peaks:a,durationHint:e.durationS??null})})},hd=1,yQe=4,tJ=(e,t)=>Math.min(yQe,Math.max(hd,e+t)),Bg=Object.freeze({x:0,y:0}),YX=(e,t)=>t<=0?0:Math.min(t-1,Math.max(0,Math.trunc(e))),GX=(e,t,n)=>t<=0?0:((e+n)%t+t)%t,aEt=(e,t)=>m("ui.common.viewer.position",{kind:"image",index:e+1,count:t}),nJ=(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))}},oEt="max-h-[min(90vh,calc(100vh-104px))] max-w-[min(90vw,calc(100vw-104px))]",sEt="max-h-[min(90vh,calc(100vh-208px))] max-w-[min(90vw,calc(100vw-104px))]",rJ=e=>T(e,"flex min-h-16 min-w-64 items-center justify-center p-6"),lEt="opacity-85",wh="bg-surface/85 disabled:bg-surface/85",XW=({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})=>{we();const d=c==="video",h=(ee,L)=>u==="asset"?m("ui.common.viewer.position",{kind:"asset",index:ee+1,count:L}):aEt(ee,L),[p,g]=$.useState(null),y=e!==void 0&&p===e,[v,b]=$.useState(hd),[x,Q]=$.useState(Bg),w=$.useRef(e);$.useLayoutEffect(()=>{w.current!==e&&(w.current=e,b(hd),Q(Bg))},[e]);const[S,k]=$.useState(!0),P=$.useRef(null);$.useEffect(()=>{if(!n)return;let ee;const L=()=>{clearTimeout(ee),ee=setTimeout(()=>{const Oe=P.current;if(Oe&&(Oe.matches(":hover")||Oe.contains(document.activeElement))){L();return}k(!1)},BOe)},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(ee),document.removeEventListener("pointermove",ne),document.removeEventListener("pointerdown",ne),document.removeEventListener("keydown",ne),document.removeEventListener("focusin",ne)}},[n]);const X=s?.onPrev,E=s?.onNext,R=s!==void 0&&s.count>1,q=R?sEt:oEt,C=$.useRef(null),z=l??C;$.useEffect(()=>{if(!n||!R)return;const ee=L=>{L.defaultPrevented||L.metaKey||L.ctrlKey||L.altKey||(L.key==="ArrowLeft"?(L.preventDefault(),X?.()):L.key==="ArrowRight"&&(L.preventDefault(),E?.()))};return document.addEventListener("keydown",ee),()=>document.removeEventListener("keydown",ee)},[n,R,X,E]),r9(n,"lightbox");const W=$.useRef(null),G=!d&&e!==void 0&&!y,A=v===hd&&x.x===Bg.x&&x.y===Bg.y,I=ee=>{if(!G)return;b(ee);const L=W.current;L&&Q(ne=>nJ(ne,{width:L.clientWidth,height:L.clientHeight},ee))},Z=()=>{G&&(b(hd),Q(Bg))},U=$.useRef(null),[D,K]=$.useState(!1),Y=G&&v>hd,le=ee=>{!Y||ee.button!==0||(ee.currentTarget.setPointerCapture(ee.pointerId),U.current={pointerId:ee.pointerId,startX:ee.clientX,startY:ee.clientY,pan:x},K(!0))},F=ee=>{const L=U.current,ne=W.current;!L||L.pointerId!==ee.pointerId||!ne||Q(nJ({x:L.pan.x+(ee.clientX-L.startX),y:L.pan.y+(ee.clientY-L.startY)},{width:ne.clientWidth,height:ne.clientHeight},v))},H=ee=>{U.current?.pointerId===ee.pointerId&&(U.current=null,K(!1))},se=e!==void 0&&!y?f.jsx("div",{ref:W,"data-image-viewport":"",tabIndex:-1,className:T(q,"relative h-fit w-fit overflow-hidden leading-none outline-none",Y&&(D?"cursor-grabbing":"cursor-grab"),Y&&"touch-none"),onPointerDown:le,onPointerMove:F,onPointerUp:H,onPointerCancel:H,children:d?f.jsx("video",{src:e,controls:!0,autoPlay:!0,className:T(q,"block object-contain"),"data-lightbox-video":"",onError:()=>g(e),children:t}):f.jsx("img",{src:e,alt:t,draggable:!1,className:T(q,"block select-none object-contain"),style:A?void 0:{transform:`translate(${x.x}px, ${x.y}px) scale(${v})`},onError:()=>g(e)})}):e===void 0&&o?f.jsx("div",{className:rJ(q),"aria-hidden":"true"}):f.jsx("div",{className:rJ(q),children:a});return f.jsx(y9,{open:n,onOpenChange:r,children:f.jsxs(v9,{ref:z,tabIndex:-1,onOpenAutoFocus:ee=>{ee.preventDefault(),(W.current??z.current)?.focus()},showClose:!1,"aria-describedby":void 0,onCloseAutoFocus:ee=>{const L=i?.current;L&&(ee.preventDefault(),L.focus())},className:T("inset-0 top-0 left-0 m-auto h-fit w-fit translate-none outline-none",q,"gap-0 rounded-none bg-transparent p-0 shadow-none"),...O,children:[f.jsx(b9,{className:"sr-only",children:t}),R&&s?f.jsx("div",{"aria-live":"polite",className:"sr-only",children:h(s.index,s.count)}):null,se,f.jsxs("div",{ref:P,"data-image-viewer-controls":"",className:T("pointer-events-none fixed inset-0 transition-opacity ease-out-quart",S?"opacity-100 duration-fast":`${lEt} duration-base`),children:[R&&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,R?f.jsxs(f.Fragment,{children:[f.jsx(Qe,{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:T("pointer-events-auto fixed top-0 bottom-0 left-4 my-auto",wh),"data-image-viewer-prev":"",children:f.jsx(j3e,{"aria-hidden":"true"})}),f.jsx(Qe,{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:T("pointer-events-auto fixed top-0 right-4 bottom-0 my-auto",wh),"data-image-viewer-next":"",children:f.jsx($ce,{"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(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.common.viewer.zoom_out"),title:m("ui.common.viewer.zoom_out"),disabled:!G||v===hd,onClick:()=>I(tJ(v,-1)),className:wh,children:f.jsx(nue,{"aria-hidden":"true"})}),f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.common.viewer.zoom_in"),title:m("ui.common.viewer.zoom_in"),disabled:!G||v===yQe,onClick:()=>I(tJ(v,1)),className:wh,children:f.jsx(tue,{"aria-hidden":"true"})}),f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.common.viewer.reset_view"),title:m("ui.common.viewer.reset_view"),disabled:!G||A,onClick:Z,className:wh,children:f.jsx(xk,{"aria-hidden":"true"})})]}),f.jsx(dqe,{asChild:!0,children:f.jsx(Qe,{variant:"ghost",size:"icon-sm",className:T("pointer-events-auto fixed top-4 right-4",wh),"aria-label":m("ui.common.viewer.close",{kind:u}),title:m("ui.common.viewer.close",{kind:u}),children:f.jsx(oi,{"aria-hidden":"true"})})})]})]})})};XW.displayName="ImageLightbox";const cEt={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(" ")},uEt=/[/\\]/,iJ=e=>{const t=e.split(uEt);return t[t.length-1]},vQe=$.memo(({file:e,src:t,conversationId:n,label:r,size:i="full",overlay:a,press:o,pathActions:s})=>{we();const[l,c]=$.useState(!1),[u,O]=$.useState(!1),[d,h]=$.useState(!1),p=$.useRef(null),g=Yt(E=>E.setCanvasOpen),{setViewMode:y}=xd(),v=$.useCallback(async()=>{const E=iJ(e),R=W=>{W&&console.error("Error processing file:",W);const G=e.startsWith("file://")?e.substring(7):e;window.api.openFile(G).catch(A=>{console.error("Error opening file:",A)})},{setFiles:q,setOpenTabs:C,setSelectedTab:z}=xd.getState();if(e.startsWith("data:"))if(q6(E)){const W=e,G={id:W,title:E,path:W,content:e,type:nS(e)},I=xd.getState().conversations?.[n],Z=I?.files??[],U=I?.openTabs??[],D=(()=>{const le=Z.findIndex(F=>F.id===W);return le!==-1?[...Z.slice(0,le),G,...Z.slice(le+1)]:[...Z,G]})();q(n,D);const Y=U.some(le=>le.id===W)?U:[...U,{id:W,title:E}];C(n,Y),z(n,W),g(!0),y(n,"documents")}else g(!0),y(n,"files");else{const W=e.startsWith("file://")?e.substring(7):e;try{const G=await window.api.readFile(W);if(G.success&&q6(E)){const A=W,I={id:A,title:E,path:W,content:G.data,type:nS(e)},U=xd.getState().conversations?.[n],D=U?.files??[],K=U?.openTabs??[],Y=(()=>{const H=D.findIndex(se=>se.id===A);return H!==-1?[...D.slice(0,H),I,...D.slice(H+1)]:[...D,I]})();q(n,Y);const F=K.some(H=>H.id===A)?K:[...K,{id:A,title:E}];C(n,F),z(n,A),g(!0),y(n,"documents");return}g(!0),y(n,"files")}catch(G){const A=G instanceof Error?G.message:String(G??"Unknown error reading file");return R(A)}}},[e,g,y,n]),b=()=>{c(!0)},x=dW(e),w=(x==="path"||x==="data")&&n!==""||!!s?.onShowInCanvas,S=vSe(x,{canShowInCanvas:w,source:t,artifactPathActions:!!s}),k=x==="path",P=r??iJ(e);if(l)return f.jsx(lf,{name:P,compact:i==="thumbnail"});const X=f.jsx(Hc,{boundary:i==="thumbnail"?"control":"hairline",children:f.jsx("img",{className:T(cEt[i],u?"opacity-100":"opacity-0"),src:t,alt:P,loading:"lazy",decoding:"async",onLoad:()=>O(!0),onError:b})});return f.jsxs("div",{className:"group relative inline-block",children:[f.jsx("button",{ref:p,type:"button",className:T("block max-w-full cursor-pointer",i==="thumbnail"&&"group/tile rounded-sm"),onClick:o?o.onPress:()=>h(!0),"aria-label":o?o.label:m("ui.chat.attachments.expand_aria",{name:P}),title:o?o.title:m("ui.chat.attachments.expand_title",{name:P}),"aria-current":o?.current?"true":void 0,children:X}),S&&f.jsx("div",{className:"file-actions-menu pointer-events-none absolute top-1 end-1 z-[2] opacity-0 transition-opacity duration-fast ease-out-quart group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100 has-[[aria-expanded=true]]:pointer-events-auto has-[[aria-expanded=true]]:opacity-100",onClick:E=>{E.stopPropagation()},onKeyDown:E=>E.stopPropagation(),children:f.jsx(xSe,{file:e,src:t,label:P,onShowInCanvas:s?.onShowInCanvas??(w?v:void 0),resolvePath:s?.resolvePath})}),o?null:a?a({open:d,onOpenChange:h,restoreFocusTo:p}):f.jsx(XW,{src:t,label:P,open:d,onOpenChange:h,restoreFocusTo:p,fallback:f.jsx(lf,{name:P,detail:k?void 0:PW})})]})});vQe.displayName="ImageAttachment";const OEt=(e,t,n)=>e.name??(n===1?"Image":`Image ${t+1}`),dEt={id:"image-group:empty",data:null,attachment:null,mimeType:"image/png"},fEt=({cold:e,children:t})=>e?f.jsx("div",{className:"flex h-[79px] w-[117px] items-start leading-none",children:t}):t,hEt=({images:e,index:t,scope:n,open:r,onOpenChange:i,restoreFocusTo:a,labelFor:o=OEt})=>{we();const s=e.length,[l,c]=$.useState(()=>YX(t,s)),[u,O]=$.useState(r);u!==r&&(O(r),r&&c(YX(t,s)));const d=YX(l,s),h=e[d]??dEt,p=o(h,d,s),g=pW(h,n),y=$.useRef(null),v=$.useRef(null),[b,x]=$.useState(!1),Q=$.useCallback(A=>{y.current=A,x(A!==null)},[]),w=A=>{const I=y.current?.querySelector(`button[aria-label="Show image ${A+1} of ${s}"]`);I?I.focus():v.current?.focus()},S=A=>{const I=GX(d,s,A),Z=y.current?.contains(document.activeElement)??!1;c(I),Z&&w(I)},k=()=>S(-1),P=()=>S(1),X=JSON.stringify([n?.sessionId,n?.childId,e.map(A=>[A.id,A.attachment,A.mimeType])]),[E,R]=$.useState(()=>({identity:X,open:r,indices:new Set}));(E.identity!==X||E.open!==r)&&R({identity:X,open:r,indices:new Set});const q=$.useCallback(A=>{R(I=>{if(!r||I.identity!==X||!I.open||A.every(U=>I.indices.has(U)))return I;const Z=new Set(I.indices);for(const U of A)Z.add(U);return{...I,indices:Z}})},[X,r]),C=GX(d,s,-1),z=GX(d,s,1);$.useEffect(()=>{r&&q([d,C,z])},[r,d,C,z,q]),$.useEffect(()=>{const A=y.current;if(!r||!b||!A||typeof IntersectionObserver>"u")return;let I=!0;const Z=new IntersectionObserver(U=>{I&&q(U.filter(D=>D.isIntersecting).map(D=>Number(D.target.dataset.imageSlot)-1))},{root:A});for(const U of A.querySelectorAll("[data-image-slot]"))Z.observe(U);return()=>{I=!1,Z.disconnect()}},[r,b,q]);const W=(A,I)=>!!A.data||!A.attachment||I===d||I===C||I===z||E.identity===X&&E.open&&E.indices.has(I);$.useEffect(()=>{(y.current?.querySelector(`[data-image-slot="${d+1}"]`)??y.current)?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[b,d]);const G=s>1?f.jsx("ul",{role:"list",ref:Q,"aria-label":m("ui.chat.canonical.lightbox.filmstrip_aria",{count:s,count_display:String(s)}),"data-image-filmstrip":"",className:"flex max-w-full items-center gap-2 overflow-x-auto px-2 py-1 leading-none",children:e.map((A,I)=>f.jsx("li",{"data-image-slot":I+1,className:T("flex shrink-0 scroll-mx-px rounded-sm leading-none",I===d&&"ring-1 ring-ink"),children:f.jsx(fEt,{cold:!!A.attachment&&!A.data,children:W(A,I)?f.jsx(zf,{image:A,scope:n,size:"thumbnail",label:o(A,I,s),press:{onPress:()=>c(I),label:`Show image ${I+1} of ${s}`,title:`Show image ${I+1} of ${s}`,current:I===d}}):f.jsx("button",{type:"button","aria-label":m("ui.chat.canonical.lightbox.show_image",{index:I+1,count:s}),title:m("ui.chat.canonical.lightbox.show_image",{index:I+1,count:s}),className:"group/tile inline-block max-w-full cursor-zoom-in rounded-sm leading-none",onClick:()=>{q([I]),c(I)},children:f.jsx(Hc,{boundary:"control",className:"h-[78px] w-[117px]","data-attachment-reserved":"","data-attachment-deferred":""})})})},A.id))}):void 0;return f.jsx(XW,{src:g.state==="ready"?g.url:void 0,pending:g.state==="resolving",label:p,open:r,onOpenChange:i,restoreFocusTo:a,fallback:f.jsx(lf,{name:p,detail:PW}),layerRef:v,group:{index:d,count:s,onPrev:k,onNext:P,filmstrip:G}})},zf=({image:e,scope:t,label:n,size:r,group:i,press:a,pathActions:o})=>{const s=pW(e,t);if(s.state==="resolving"){const c=f.jsx(Hc,{boundary:r==="thumbnail"?"control":"hairline",className:r==="thumbnail"?"h-[78px] w-[117px]":void 0,"data-attachment-reserved":""});return a?f.jsx("button",{type:"button","aria-label":a.label,title:a.title,"aria-current":a.current||void 0,className:"group/tile inline-block max-w-full cursor-zoom-in rounded-sm leading-none",onClick:a.onPress,children:c}):f.jsx("div",{className:T("inline-block max-w-full"),"aria-hidden":!0,children:c})}if(s.state==="missing")return f.jsx(lf,{name:n,compact:r==="thumbnail",detail:PW});const l=s.url;return f.jsx("div",{className:T("inline-block max-w-full"),children:f.jsx(vQe,{file:l,src:l,label:n,size:r,conversationId:t?.sessionId??"",press:a,pathActions:o,overlay:i?c=>f.jsx(hEt,{images:i.images,index:i.index,labelFor:i.labelFor,scope:t,open:c.open,onOpenChange:c.onOpenChange,restoreFocusTo:c.restoreFocusTo}):void 0})})};function pEt(){return m("ui.chat.checkpoint.generating_name")}const mEt={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 gEt(e){return e.id===e.activeId?"active":e.id===e.previewId?"preview":e.loaded===!1?"unloaded":"rest"}function bQe(e,t){return m("ui.chat.checkpoint.turn",{turn:e,total:t})}function $Et(e,t){const n=bQe(e.turn,t),r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`${n} · ${r}`:n}function yEt(e){return e.kind==="completion"&&e.naming?.state==="pending"}function vEt(e){const t=e.naming?.state==="ready"?e.naming.summary:null;return t?.trim()?t:null}function bEt(e){let t=0;for(const n of e)n.turn>t&&(t=n.turn);return t}const wEt={complete:"Complete",error:"Error",interrupted:"Interrupted",open:"Open"};function xEt(e){if(!Number.isFinite(e)||e<=0)return"";const t=new Date(e*1e3);return Number.isNaN(t.getTime())?"":yk(t,{hour:"numeric",minute:"2-digit"})}function SEt(e,t){if(e.kind==="user"){const r=xEt(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 QEt(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 ZX(e,t){const n=[];for(const r of t)QEt(e,r)==="pending"&&n.push(r);return n}const kEt=120,aJ=80,_c=10,nQ=24,_Et=2,B6=420,wQe=32;function F_(e,t){return(t?_Et:0)+nQ+e*_c}function oJ(e,t){return F_(e,t)+nQ}function PEt(e,t,n){if(t<=0)return{start:0,end:0};const r=wQe*_c,i=Math.floor(Math.max(0,e)/r),a=i*r-B6,o=(i+1)*r+2*B6,s=F_(0,n),l=Math.max(0,Math.floor((a-s)/_c)),c=Math.min(t,Math.ceil((o-s)/_c));return{start:Math.min(l,c),end:c}}function TEt(e,t,n,r,i=24){const a=F_(e,t),o=a+_c;return a<n+i?Math.max(0,a-i):o>n+r-i?o-r+i:null}const XEt="Turn checkpoints",REt={complete:sa,error:uO,interrupted:j9,open:I3e},EEt={complete:"text-success",error:"text-danger",interrupted:"text-warning",open:"text-ink-dim"},qEt=({checkpoint:e,turnCount:t})=>{const n=e.outcome,r=n?REt[n]:null,i=vEt(e),a=e.naming?.state==="ready"?e.naming.name?.trim():"";return f.jsxs(f.Fragment,{children:[f.jsxs("p",{className:T("text-body-sm font-medium text-ink"),children:[bQe(e.turn,t),a&&f.jsxs(f.Fragment,{children:[f.jsx("span",{"aria-hidden":"true",children:" · "}),f.jsx("span",{className:T("font-normal text-ink-muted"),children:a})]})]}),yEt(e)&&f.jsx("p",{className:T("text-ink-dim text-meta"),children:pEt()}),i&&f.jsx("p",{className:T("line-clamp-2 break-words text-body-sm text-ink-muted"),children:i}),n&&r&&f.jsx("div",{className:T("flex items-center gap-1.5 text-ink-dim text-meta"),children:f.jsxs("span",{className:T("flex items-center gap-1",EEt[n]),children:[f.jsx(r,{"aria-hidden":"true",className:T("size-3.5 shrink-0")}),wEt[n]]})})]})},jEt=$.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:T("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:T("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",mEt[n])})})}),CEt=({sessionId:e,checkpoints:t,onJump:n,onHover:r,building:i=!1,loadedIds:a,activeId:o=null})=>{we();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((ue,ge)=>[ue.id,ge])),[t]),b=$.useRef(v);b.current=v;const x=$.useRef(i);x.current=i;const[Q,w]=$.useState({sessionId:"",top:0}),S=wQe*_c,k=$.useCallback(ue=>{const ge=Math.floor(Math.max(0,ue)/S)*S;w(Ke=>Ke.sessionId===e&&Ke.top===ge?Ke:{sessionId:e,top:ge})},[S,e]),P=Q.sessionId===e?Q.top:Math.max(0,oJ(t.length,i)-B6),X=$.useRef(null),E=$.useRef(null),R=$.useCallback(()=>{X.current!==null&&(clearTimeout(X.current),X.current=null),E.current!==null&&(clearTimeout(E.current),E.current=null)},[]),q=$.useCallback((ue,ge)=>{R();const Ke=()=>{O(ue),h(p.current.find(dt=>dt.id===ue)??null)};if(ge<=0){Ke();return}X.current=setTimeout(()=>{X.current=null,Ke()},ge)},[R]),C=$.useCallback(ue=>{if(R(),ue<=0){O(null);return}E.current=setTimeout(()=>{E.current=null,O(null)},ue)},[R]),z=$.useRef(e);$.useEffect(()=>{z.current!==e&&(z.current=e,R(),L.current=null,c(null),O(null),h(null))},[e,R]);const W=$.useRef(null);$.useLayoutEffect(()=>{const ue=y.current;if(!(t.length===0||ue===null)){if(o!==null&&G.current===e){W.current=e,k(ue.scrollTop);return}W.current!==e&&(W.current=e,ue.scrollTop=oJ(t.length,i),k(ue.scrollTop))}},[o,i,t.length,e,k]);const G=$.useRef(null);$.useLayoutEffect(()=>{if(o===null)return;const ue=y.current,ge=b.current.get(o);if(ue===null||ge===void 0)return;G.current=e;const Ke=TEt(ge,x.current,ue.scrollTop,ue.clientHeight);Ke!==null&&(ue.scrollTop=Ke),k(ue.scrollTop)},[o,e,k]),$.useEffect(()=>()=>R(),[R]);const A=$.useRef(r);$.useEffect(()=>{A.current=r});const I=$.useMemo(()=>bEt(t),[t]),Z=u&&d?.id===u?d:null,U=u&&g.current.get(u)||null,D=$.useMemo(()=>({current:U}),[U]),K=Z!==null&&U!==null;$.useEffect(()=>{A.current(K&&u?u:null)},[K,u]);const Y=$.useCallback((ue,ge)=>{ge?g.current.set(ue,ge):g.current.delete(ue)},[]),[le,F]=$.useState(null),H=le&&v.has(le)?le:t[0]?.id??null,se=$.useRef(null),ee=$.useCallback(ue=>{const ge=Math.max(0,Math.min(t.length-1,ue)),Ke=t[ge];if(!Ke)return;F(Ke.id);const dt=g.current.get(Ke.id);if(dt){dt.focus();return}const Ee=y.current;Ee!==null&&(Ee.scrollTop=Math.max(0,F_(ge,i)+_c/2-Ee.clientHeight/2),k(Ee.scrollTop)),se.current=Ke.id},[i,t,k]);$.useLayoutEffect(()=>{const ue=se.current;if(ue===null)return;const ge=g.current.get(ue);ge&&(se.current=null,ge.focus())});const L=$.useRef(null),ne=$.useCallback(ue=>{L.current!==ue&&(L.current=ue,c(ue),q(ue,kEt))},[q]),Oe=$.useCallback(()=>{L.current=null,c(ue=>ue===null?ue:null),C(aJ)},[C]),he=$.useCallback(ue=>{L.current=ue,F(ue),c(ge=>ge===ue?ge:ue),q(ue,0)},[q]),_e=$.useCallback(()=>{L.current=null,c(ue=>ue===null?ue:null),C(aJ)},[C]),te=$.useCallback(ue=>{C(0),L.current=null,c(null),n(ue)},[C,n]),be=$.useCallback((ue,ge)=>{if(ue.key==="Escape"){C(0);return}const Ke=v.get(ge);if(Ke!==void 0){if(ue.key==="ArrowDown"){ue.preventDefault(),ue.stopPropagation(),ee(Ke+1);return}if(ue.key==="ArrowUp"){ue.preventDefault(),ue.stopPropagation(),ee(Ke-1);return}if(ue.key==="Home"){ue.preventDefault(),ue.stopPropagation(),ee(0);return}ue.key==="End"&&(ue.preventDefault(),ue.stopPropagation(),ee(t.length-1))}},[t.length,C,ee,v]),xe=PEt(P,t.length,i),Xe=[];for(let ue=xe.start;ue<xe.end;ue+=1)Xe.push(ue);for(const ue of[H,u,l]){const ge=ue===null?void 0:v.get(ue);ge!==void 0&&(ge<xe.start||ge>=xe.end)&&!Xe.includes(ge)&&Xe.push(ge)}return Xe.sort((ue,ge)=>ue-ge),t.length===0&&!i?null:f.jsxs("div",{"data-lo-checkpoint-rail":"",role:"toolbar","aria-orientation":"vertical","aria-label":XEt,className:T("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:ue=>k(ue.currentTarget.scrollTop),className:T("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:T("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*_c+2*nQ},children:Xe.map(ue=>{const ge=t[ue];return f.jsx(jEt,{checkpoint:ge,top:nQ+ue*_c,state:gEt({id:ge.id,previewId:l,activeId:o,loaded:a?a.has(ge.id):!0}),label:SEt(ge,I),roving:ge.id===H,registerTick:Y,onPreview:ne,onPreviewEnd:Oe,onFocusMark:he,onBlurMark:_e,onActivate:te,onKeyMark:be,describedBy:K&&u===ge.id?s:void 0},ge.id)})})]}),f.jsxs(fqe,{open:K,onOpenChange:ue=>{ue||C(0)},children:[f.jsx(hqe,{virtualRef:D}),Z&&f.jsx(pqe,{id:s,"data-checkpoint-card":"",side:"left",align:"center",sideOffset:10,collisionPadding:8,role:"tooltip","aria-label":Z.kind==="user"?m("ui.chat.transcript_copy.row.your_message"):$Et(Z,I),onOpenAutoFocus:ue=>ue.preventDefault(),onCloseAutoFocus:ue=>ue.preventDefault(),onFocusOutside:ue=>{const ge=ue.detail?.originalEvent?.target;ge instanceof Element&&ge.closest("[data-lo-checkpoint-rail]")&&ue.preventDefault()},className:T("pointer-events-none max-h-[176px] w-[300px] max-w-[300px] overflow-hidden","flex flex-col gap-2"),children:Z.kind==="user"?f.jsx("div",{"data-checkpoint-card-text":"",className:T("line-clamp-3 break-words whitespace-pre-wrap","text-body-sm text-ink"),children:Z.text}):f.jsx(qEt,{checkpoint:Z,turnCount:I})})]})]})},zEt=$.memo(CEt);function AEt(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 UEt=(e,t,n)=>(e.getAttribute(t)??"").split(" ").includes(n);function WEt(e,t){return e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`)!==null}function xQe(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):!UEt(a,i,t))continue;if(a.querySelector("button[aria-expanded]")?.getAttribute("aria-expanded")==="false")return a}return null}function NEt(e,t){return WEt(e,t)||xQe(e,t)!==null}const YEt=3;function GEt(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>=YEt){n.onMissing();return}const s=xQe(e,t)?.querySelector("button[aria-expanded]");if(!s){n.onMissing();return}s.click(),window.requestAnimationFrame(()=>{r(i+1)})};r(0)}const sJ=(e,t,n)=>n===1?"Image":`Image ${t+1}`,lJ=({images:e,scope:t,onRevealMore:n,uncapped:r=!1,indent:i="content"})=>{we();const{shown:a,more:o}=j4t(e.length,{uncapped:r}),s=C4t(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:T("flex leading-none",l&&c.has(d)&&"col-start-1"),children:f.jsx(zf,{image:O,scope:t,size:"thumbnail",label:sJ(O,d,e.length),group:{images:e,index:d,labelFor:sJ}})},O.id));return f.jsxs("ul",{role:"list","aria-label":m("ui.chat.canonical.fold.images_aria",{count_display:String(e.length),count:e.length}),"data-fold-media":"",className:T("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:T("flex h-[78px] items-center leading-none"),children:f.jsx(Qe,{variant:"outline",size:"sm",onClick:n,"aria-label":m("ui.chat.canonical.fold.more_images",{count_display:String(o),count:o}),title:m("ui.chat.canonical.fold.more_images",{count:o,count_display:String(o)}),children:`+${o}`})},"fold-media-more")]})};function cJ(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 ZEt(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 IEt=({video:e,scope:t,label:n})=>{const r=Mv(e,t),[i,a]=$.useState(!1);return r.state==="missing"||i?f.jsx(lf,{name:n,detail:uQe}):r.state==="resolving"?f.jsx("div",{className:T("inline-block max-w-full self-start"),"aria-hidden":!0,children:f.jsx(Hc,{"data-attachment-reserved":""})}):f.jsx("div",{className:T("inline-block max-w-full self-start"),children:f.jsx(Hc,{children:f.jsx("video",{controls:!0,preload:"metadata",src:r.url,"aria-label":n,className:T("max-h-[240px] max-w-full object-contain"),onError:()=>a(!0)})})})};function DEt({items:e,summary:t,scope:n}){return we(),f.jsxs("div",{"data-sound-batch":"",className:T("flex w-full min-w-0 max-w-[560px] flex-col gap-4"),children:[f.jsx("p",{className:T("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:T("min-w-0"),children:[f.jsxs("p",{className:T("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:T("text-body-sm text-ink break-words [overflow-wrap:anywhere]"),children:r.error}):r.audio?f.jsx(TW,{audio:r.audio,ownerId:`${$Qe(r.audio)}:batch:${r.audio.id}:${r.id}`,scope:n,label:r.label}):f.jsx("p",{className:T("text-meta text-ink-muted"),children:m("ui.chat.canonical.sound.batch_attachment_unavailable")}),f.jsx("p",{className:T("text-meta text-ink-dim"),children:r.costCaption??"Cost not yet known."})]},r.id))})]})}function qfn({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(SQe,{onKeepWaiting:c,onRequestStop:O}):null,[a,t,c,O]);return{paneRef:s,stop:u,confirmation:d}}function SQe({onKeepWaiting:e,onRequestStop:t}){we();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(Qe,{ref:n,"aria-describedby":r,variant:"ghost",size:"sm",onClick:e,children:m("ui.chat.canonical.sound.stop.keep_waiting")}),f.jsx(Qe,{variant:"secondary",size:"sm",onClick:t,children:m("ui.chat.canonical.sound.stop.request_stop")})]})]})}const VEt=1e3;function MEt(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,VEt);return()=>window.clearInterval(i)},[e]),t}function LEt(){return f.jsx("div",{"aria-hidden":!0,"data-imagegen-tile":"",className:T("relative aspect-[3/2] w-[240px] max-w-full overflow-hidden rounded-sm bg-sunken"),children:f.jsx("span",{className:T("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 uJ=44,FEt=240,IX=12,BEt=Array.from({length:240},(e,t)=>Math.min(1,.18+Math.abs(Math.sin(t/7)*Math.cos(t/17))*.72));function HEt({state:e}){const t=pQe(BEt,FEt-IX*2,uJ);return f.jsx("div",{"aria-hidden":!0,"data-sound-loading-tile":"","data-sound-loading":e,className:T("relative flex w-[240px] max-w-full items-center overflow-hidden rounded-sm bg-sunken"),style:{height:uJ},children:f.jsx("div",{className:T("flex w-full items-center"),style:{paddingLeft:IX,paddingRight:IX},children:t.map((n,r)=>f.jsx("span",{"data-sound-loading-bar":"",className:T("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:tQ,height:e==="failed"?fQe:n.height,marginRight:n===t.at(-1)?0:2,animationDelay:e==="running"?`${r%12*90}ms`:void 0}},n.x))})})}function KEt({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?k1(e.argumentBytes):null;break;case"running":n=e.batchProgress?`Generating ${e.batchProgress.total} ${Yh(e.material)}${e.batchProgress.total===1?"":"s"}…`:`Generating ${Yh(e.material)}…`,r=t===null?null:lO(t);break;case"cancelling":n=e.generating?Tj:OG;break;case"done":n=e.receipt==="already-finished"?"Already finished.":e.batch?`${DX(e.material)} batch`:`Generated ${Yh(e.material)}`,r=e.receipt==="already-finished"||e.durationS===null?null:d9(e.durationS);break;case"failed":n=e.batch?`${DX(e.material)} batch failed.`:e.message??`The ${Yh(e.material)} could not be generated.`,i=!0;break;case"cancelled":{const a=e.message??(e.generating?Tj:OG);n=e.batch?`${DX(e.material??"sound-effect")} batch stopped.`:e.settlementCaption||e.settled?Jqe(a):a;break}}return f.jsxs("p",{className:T("flex min-w-0 items-baseline gap-1.5 text-body-sm"),children:[f.jsx("span",{className:T("min-w-0",i?"text-ink":"text-ink-muted"),children:n}),r===null?null:f.jsxs("span",{className:T("shrink-0 text-meta text-ink-dim"),children:["· ",r]})]})}function JEt({line:e}){return f.jsx("p",{"data-imagegen-log":"",title:e,className:T("min-w-0 truncate font-mono text-mono-sm text-ink-dim"),children:e})}function DX(e){const t=Yh(e);return t.charAt(0).toUpperCase()+t.slice(1)}function xh({line:e,prominent:t=!1}){return f.jsx("p",{"data-imagegen-note":"",className:T("min-w-0 text-body-sm",t?"text-ink-muted":"text-ink-dim"),children:e})}function eqt(e,t){return e==="cancel"?m("ui.chat.canonical.image_gen.control.stop"):e==="restart"?t==="failed"?m("ui.common.actions.retry"):m("ui.chat.canonical.image_gen.control.restart"):m("ui.chat.canonical.image_gen.control.edit_and_restart")}const tqt=({view:e,scope:t,actions:n})=>{we();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=MEt(c),O=tje(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))?Tj: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:T("flex w-full flex-col gap-2"),children:[v?f.jsx(HEt,{state:v}):p?f.jsx(LEt,{}):null,e.state==="failed"&&(e.material==="voiceover"||e.material==="sound-effect")&&e.errorType?f.jsx("p",{className:T("text-meta text-ink-dim"),children:e.errorType}):null,f.jsx(KEt,{view:e,elapsed:u}),(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.costCaption?f.jsx(xh,{line:e.costCaption,prominent:!!e.batch}):null,(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.batchNote?f.jsx(xh,{line:e.batchNote,prominent:!0}):null,e.state==="running"&&e.batchProgress?.note?f.jsx(xh,{line:e.batchProgress.note}):null,e.state==="cancelled"&&e.settlementCaption?f.jsx(xh,{line:e.settlementCaption}):null,b?f.jsx(xh,{line:b}):null,l&&r?f.jsx(SQe,{onKeepWaiting:a,onRequestStop:()=>{i(!1),n?.onCancel?.()}}):null,e.state==="running"&&typeof e.note=="string"?f.jsx(xh,{line:e.note}):null,p&&e.progress.fraction!==null?f.jsx(mqe,{"aria-label":m("ui.chat.canonical.image_gen.progress"),className:T("max-w-[240px]"),value:Math.round(Math.min(1,Math.max(0,e.progress.fraction))*100)}):null,x===null?null:f.jsx(JEt,{line:x}),(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.batch?f.jsx(DEt,{items:e.batch,summary:e.batchSummary??m("ui.chat.canonical.image_gen.batch_summary",{count_display:String(e.batch.length),count:e.batch.length}),scope:t}):e.state==="done"&&e.images.length>0?f.jsx("div",{className:T("flex flex-col gap-2"),children:e.images.map((Q,w)=>{const S=`Generated ${Yh(Q.kind==="audio"?e.material:Q.kind??"image")}`,k=e.images.length===1?S:`${S} ${w+1}`;return Q.kind==="video"?f.jsx(IEt,{video:Q,scope:t,label:k},Q.id):Q.kind==="audio"?f.jsx(TW,{audio:Q,scope:t,label:k},Q.id):f.jsx(zf,{image:Q,scope:t,label:k},Q.id)})}):null,O.length>0&&!(l&&r)?f.jsx("div",{"data-imagegen-controls":"",className:T("flex items-center gap-2"),children:O.map(Q=>f.jsx(Qe,{variant:"secondary",size:"sm",disabled:Q.disabled,title:Q.kind==="cancel"?e.state==="queued"||e.state==="cancelling"&&!e.generating?m("ui.chat.canonical.image_gen.control.stop_hint_queued"):m("ui.chat.canonical.image_gen.control.stop_hint_running"):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:eqt(Q.kind,e.state)},Q.kind))}):null]})},Im="data-lo-quote-toolkit";function H6(e,t){return e.kind!=="user"&&e.kind!=="assistant"||t.trim().length===0?!1:e.kind!=="assistant"?!0:!e.streaming}const OJ=e=>(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(`[${Im}]`)??null,nqt=e=>e.nodeType===Node.ELEMENT_NODE,rqt=e=>{const t=Array.from(e.childNodes),n=t.findIndex(r=>nqt(r)&&r.hasAttribute(Im));return n===-1?t.length:n},iqt=(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,aqt=e=>{const t=Array.from(document.querySelectorAll(`[${Im}]`),n=>n.getBoundingClientRect());return Array.from(e.getClientRects()).filter(n=>!t.some(r=>iqt(r,n))).map(n=>({top:n.top,left:n.left,right:n.right,bottom:n.bottom}))};function hp(e){if(!e)return null;const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;const n=t.getRangeAt(0);if(OJ(n.startContainer)||OJ(n.endContainer)||!e.contains(n.startContainer))return null;const r=n.cloneRange();e.contains(n.endContainer)||r.setEnd(e,rqt(e));const i=r.toString().trim();return i.length===0?null:{text:i,lines:aqt(n)}}const dJ="[data-lo-canonical-transcript]",oqt="[data-lo-transcript-content]",fJ=e=>({top:e.top,left:e.left,right:e.right,bottom:e.bottom}),sqt=()=>({top:0,left:0,right:window.innerWidth,bottom:window.innerHeight});function QQe(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=IIe({lines:h,container:fJ((O.closest(dJ)??O).getBoundingClientRect()),viewport:sqt(),size:{width:d.offsetWidth,height:d.offsetHeight},row:fJ(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(dJ),p=h?.querySelector(oqt),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 kQe(e){const[t,n]=$.useState(null);$.useEffect(()=>{const i=()=>n(hp(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 Wh="data-lo-link-toolbar",lqt=120,cqt=2;function _Qe(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=d5t(u);if(O){n(h=>h===O?h:O),i(h=>h===!0?h:!0);return}if(i(h=>h===!1?h:!1),Wxe()){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()},lqt))},p=(k,P)=>{const X=o.current;if(!X||!u.contains(X))return!1;const E=u.querySelector(`[${Wh}]`),R=CA+cqt;for(const q of[X,E]){if(!q)continue;const C=q.getBoundingClientRect();if(!(C.width<=0||C.height<=0)&&k>=C.left-R&&k<=C.right+R&&P>=C.top-R&&P<=C.bottom+R)return!0}return!1},g=k=>{const P=k.target;if(P?.closest(`[${Im}]`))return;const X=P?.closest(Uh)??null;!X&&p(k.clientX,k.clientY)||h(X)},y=k=>{const P=k.relatedTarget;P&&u.contains(P)||p(k.clientX,k.clientY)||d(null)},v=k=>{const P=k.target?.closest(Uh);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(`[${Wh}] button:not([disabled])`)),Q=k=>{const P=k.target;if(!P)return!1;if(P.closest(`[${Wh}]`)){const q=x(),C=q.indexOf(P);if(C===-1)return!1;if(k.shiftKey&&C===0){const z=o.current;return z instanceof HTMLElement?(z.focus(),!0):!1}if(!k.shiftKey&&C===q.length-1){const z=Array.from(u.querySelectorAll(Uh)),W=o.current,G=W?z.indexOf(W)+1:-1,A=G>0?z[G]:void 0;return A?(A.focus(),!0):!1}return!1}if(k.shiftKey)return!1;const E=P.closest(Uh);if(!E||!u.contains(E))return!1;o.current!==E&&d(E);const[R]=x();return R?(R.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 X=k.target?.closest(Uh);!X||!u.contains(X)||(k.preventDefault(),d(X),requestAnimationFrame(()=>{u.querySelector(`[${Wh}] 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(`[${Wh}]`))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 PQe(e,t,n){const r=Mn(i=>i.addReply);return $.useCallback(()=>{const a=hp(t.current)?.text??(Wxe()?null:n?.()??null);a&&(r(e,{id:Za(),text:a}),window.getSelection()?.removeAllRanges(),aA())},[r,e,t,n])}const TQe=({conversationId:e,turnRef:t,subject:n,quoteAvailable:r,onDismiss:i})=>{we();const a=n.getAttribute(Axe)??"",o=n.getAttribute("data-lo-kind")??"file",s=Iv(),l=$.useCallback(()=>(n.textContent??"").trim()||null,[n]),c=PQe(e,t,l),{text:u}=kQe(t),{speak:O}=qm(),d=zk(e),h=u??l(),p=h===null?null:Cp(e,Ck(h).text);sfe(p);const g=Uk({key:p,getText:()=>hp(t.current)?.text??l(),play:({text:W})=>O(Cp(e,W),Ak(d,W))}),[y,v]=$.useState(!1),[b,x]=$.useState(()=>cx(a)??null),{controlRef:Q,placement:w}=QQe({turnRef:t,visible:!0,lines:()=>{const W=n.getClientRects();return Array.from(W,G=>({top:G.top,left:G.left,right:G.right,bottom:G.bottom}))},measureKey:n,belowWhenOffFirstLine:!0});$.useEffect(()=>{const W=cx(a);if(x(W??null),v(!1),W!==void 0)return;let G=!0;return o5t(a,window.api?.probeFiles).then(()=>{G&&x(cx(a)??null)}),()=>{G=!1}},[a]);const S=o==="file"&&oW(s,a),k=Gxe({target:a,isDirectory:b?.exists===!0&&!b.isFile,probe:b,canOpenInCanvas:S}),P=p5t({kind:o,target:a,probe:b,quotable:r,canOpenInCanvas:S});if(!P||!a)return null;const X=async()=>{await Dv(a)&&v(!0)},E=async()=>{if(o==="url"){await KH(o,a);return}s&&k&&await s.openInCanvas(a)||await KH(o,a)||x(null)},R=async()=>{await xO(a)||x(null)},q=async()=>{await sW(a)||x(null)},C={quote:f.jsx(Kce,{}),copy:y?f.jsx(sa,{}):f.jsx(vf,{}),open:k?f.jsx(R6e,{}):o==="url"?f.jsx(bk,{}):f.jsx(Ov,{}),"open-default":f.jsx(x3e,{}),"open-folder":f.jsx(kp,{})},z={quote:c,copy:()=>{X()},open:()=>{E()},"open-default":()=>{R()},"open-folder":()=>{q()}};return f.jsxs(zA,{[Im]:"",[Wh]:"",ref:Q,label:P.label,className:T("absolute z-20",!w&&"invisible"),style:w?{top:w.top,left:w.left}:void 0,onKeyDown:W=>{if(W.key!=="Escape")return;window.getSelection()?.removeAllRanges();const G=n;W.preventDefault(),i(),G.focus?.()},children:[P.actions.map(W=>f.jsxs($.Fragment,{children:[f.jsx(vt,{content:W.id==="copy"&&y?m("ui.common.actions.copied"):W.label,side:w?.placement==="below"?"bottom":"top",children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":W.id==="copy"&&y?m("ui.common.actions.copied"):W.label,className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:z[W.id],children:C[W.id]})}),W.id==="quote"&&f.jsx(Wk,{control:g,side:w?.placement==="below"?"bottom":"top"})]},W.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 uqt({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 K6(e){return e.kind!=="user"&&e.kind!=="assistant"||e.kind==="assistant"&&e.streaming?null:e.id||null}const hJ=96;function Oqt(e){const t=e.replace(/\s+/g," ").trim();return t.length<=hJ?t:`${t.slice(0,hJ-1).trimEnd()}…`}function dqt(){return m("ui.chat.response_actions.answer_label")}function fqt(){return m("ui.chat.response_actions.yours_label")}const hqt="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 pJ(e){return e?"opacity-100":hqt}const XQe=2e3,pqt=1e4;function jfn(e){const{request:t}=e;return t?e.now-t.requestedAt>pqt?"retire":e.presentable?e.claimed?"hold":"present":"yield":null}let mJ=0,Hw=0;const mqt=gi(e=>({request:null,requestPanel:(t,n,r,i)=>{mJ+=1,e({request:{destination:t,nonce:mJ,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:()=>{Hw+=1,e({presenterClaimed:!0});let t=!1;return()=>{t||(t=!0,Hw=Math.max(0,Hw-1),Hw===0&&e({presenterClaimed:!1}))}}})),gqt=(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)},$qt=9e4,gJ=new Set,yqt=2600,hx=$.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}=qm(),Q=zk(r??null),w=Uk({key:i?afe(i):null,getText:()=>t,play:({text:C})=>{i&&x(i,Q,C)}}),S=mqt(C=>C.requestPanel),k=!!(s&&l);we();const P=uqt({role:n,forkable:k}),X=O||w.active;$.useEffect(()=>()=>{g.current!==null&&clearTimeout(g.current)},[]),$.useEffect(()=>{if(!a||o===void 0||gJ.has(a)||(gJ.add(a),Date.now()-o>$qt))return;const C=y.current;if(C===null)return;const z=C.closest(".group")??C;if(gqt(C,z))return;p(!0);const W=()=>{p(!1),z.removeEventListener("pointerenter",W),z.removeEventListener("focusin",W)};return z.addEventListener("pointerenter",W),z.addEventListener("focusin",W),()=>{z.removeEventListener("pointerenter",W),z.removeEventListener("focusin",W)}},[a,o]),$.useEffect(()=>{if(h)return b.current=setTimeout(()=>{b.current=null,p(!1)},yqt),()=>{b.current!==null&&clearTimeout(b.current)}},[h]);const E=async()=>{await Dv(t)&&(d(!0),g.current!==null&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,d(!1)},XQe))},R=()=>{!s||!l||S("session.fork",v.current,s,{id:l,excerpt:Oqt(t)})},q={copy:f.jsx(vt,{content:O?m("ui.chat.response_actions.copied"):m("ui.chat.response_actions.copy"),side:"bottom",children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":O?m("ui.chat.response_actions.copied"):m("ui.chat.response_actions.copy"),className:T("text-ink-dim hover:bg-transparent hover:text-ink"),onClick:E,children:O?f.jsx(sa,{"aria-hidden":"true"}):f.jsx(vf,{"aria-hidden":"true"})})}),speak:f.jsx(Wk,{control:w,side:"bottom",className:T("text-ink-dim hover:bg-transparent hover:text-ink")}),fork:f.jsx(vt,{content:m("ui.chat.pickers.destination_pickers.fork_from_this_message"),side:"bottom",children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.pickers.destination_pickers.fork_from_this_message"),ref:v,className:T("text-ink-dim hover:bg-transparent hover:text-ink"),onClick:R,children:f.jsx(E7e,{"aria-hidden":"true"})})})};return f.jsx("div",{role:"toolbar","aria-label":n==="user"?fqt():n==="commentary"?m("ui.chat.commentary_actions.label"):n==="response"?m("ui.chat.response_actions.label"):dqt(),ref:y,onAnimationEnd:C=>{C.target===C.currentTarget&&p(!1)},...h?{"data-lo-arrive":""}:{},...n==="user"?{"data-lo-user-actions":""}:n==="commentary"?{"data-lo-gutter-actions":""}:n==="response"?{"data-lo-response-actions":""}:{"data-lo-answer-actions":""},className:T(c?T("absolute z-10 flex h-8 items-center gap-1","-top-2 end-0",pJ(X),u):T("flex h-8 shrink-0 items-center gap-1",pJ(X))),children:P.map(C=>f.jsx($.Fragment,{children:q[C]},C))})}),vqt="@container/olderhistory mb-4 flex h-7 min-w-0 items-center gap-2",Kw="@min-[260px]/olderhistory:hidden",Jw="@max-[260px]/olderhistory:hidden",RQe="lo-older-history-hint",bqt=({state:e,transportDown:t=!1,onLoadOlder:n,onRetryHydration:r})=>{we();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:vqt,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:Kw,children:m("ui.chat.canonical.older_history.transport.short")}),f.jsx("span",{className:Jw,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:Kw,children:m("ui.chat.canonical.older_history.failed.short")}),f.jsx("span",{className:Jw,children:m("ui.chat.canonical.older_history.failed.long")})]}),f.jsx(Qe,{variant:"ghost",size:"sm",className:"shrink-0",onClick:n,children:m("ui.chat.canonical.older_history.try_again")})]}):a?f.jsxs(Qe,{variant:"ghost",size:"sm","aria-disabled":!0,onClick:o=>{o.preventDefault()},className:"text-ink-muted",children:[f.jsx(Sa,{size:"sm"}),m("ui.chat.canonical.older_history.loading")]}):e==="idle"?f.jsx(Qe,{variant:"ghost",size:"sm",onClick:n,children:m("ui.chat.canonical.older_history.load")}):e==="windowed"?f.jsxs("span",{id:RQe,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:Kw,children:t?m("ui.chat.canonical.older_history.windowed.title"):m("ui.chat.canonical.older_history.windowed.short_gesture")}),f.jsx("span",{className:Jw,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:Kw,children:m("ui.chat.canonical.older_history.unproven.short")}),f.jsx("span",{className:Jw,children:m("ui.chat.canonical.older_history.unproven.long")})]}),!t&&r&&f.jsx(Qe,{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")})]})},wqt="/settings?section=providers",$J="/settings?section=providers&provider=radient",xqt="/settings?section=radient",yJ=/sign in to radient/i,Sqt=[/insufficient credits/i,/credit balance is too low/i],Qqt=[/rate limit or quota/i],kqt=[/insufficient credits/i,/\bHTTP 402\b/i];function EQe(e){return(e??"").split("/")[0]?.trim().toLowerCase()==="radient"}function RW(e){return EQe(e.provider)?e.category==="billing"?!0:(e.category==null||e.category==="unknown"||e.category==="rate-limit")&&kqt.some(n=>n.test(e.text)):!1}function _qt(e){if(!RW(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 Pqt(e){return e==="auth"?"sign-in":e==="billing"?"billing":e==="rate-limit"?"quota":null}function vJ(e){const t=EQe(e.provider)||yJ.test(e.text);let n=Pqt(e.category);return RW(e)&&(n="billing"),n===null&&(e.category==null||e.category==="unknown")&&(yJ.test(e.text)?n="sign-in":Sqt.some(r=>r.test(e.text))?n="billing":Qqt.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:$J}:n==="billing"&&t?{label:m("ui.chat.provider_error.action.open_radient_account"),to:xqt}:{label:m("ui.chat.provider_error.action.open_provider_settings"),to:t?$J:wqt}}const qQe=({conversationId:e,turnRef:t,allowQuote:n=!0})=>{we();const{text:r,clear:i}=kQe(t),a=r!==null,o=PQe(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=hp(t.current)?.text??r;v&&await Dv(v)&&(l(!0),c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,l(!1)},XQe))},[r,t]),{controlRef:O,placement:d}=QQe({turnRef:t,visible:a,lines:()=>hp(t.current)?.lines??null}),{speak:h}=qm(),p=zk(e),g=r===null?null:Cp(e,Ck(r).text);sfe(g);const y=Uk({key:g,getText:()=>hp(t.current)?.text??null,play:({text:v})=>h(Cp(e,v),Ak(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(zA,{[Im]:"",ref:O,label:m("ui.chat.transcript_copy.selection.toolbar"),className:T("absolute z-20",!d&&"invisible"),style:d?{top:d.top,left:d.left}:void 0,children:[n&&f.jsx(vt,{content:m("ui.chat.transcript_copy.selection.quote"),side:d?.placement==="below"?"bottom":"top",children:f.jsx(Qe,{variant:"ghost",size:"icon-sm","aria-label":m("ui.chat.transcript_copy.selection.quote"),className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:o,children:f.jsx(Kce,{})})}),f.jsx(vt,{content:s?m("ui.chat.transcript_copy.toast.copied_selection"):m("ui.chat.transcript_copy.selection.copy"),side:d?.placement==="below"?"bottom":"top",children:f.jsx(Qe,{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(sa,{}):f.jsx(vf,{})})}),f.jsx(Wk,{control:y,side:d?.placement==="below"?"bottom":"top"})]}):null},jQe={all:["radient-prices"],prices:()=>[...jQe.all,"prices"]},Tqt=()=>{const e=bt({queryKey:jQe.prices(),queryFn:()=>yA({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}},bJ="https://console.radienthq.com/dashboard/verification",wJ="https://console.radienthq.com/dashboard/billing",xJ=()=>m("ui.common.account.top_up");function Xqt(e){return!e.email_verified&&e.signup_grant!=="claimed"}const Cfn=e=>typeof e!="number"||!Number.isFinite(e)?m("ui.common.account.free_credits_unknown"):m("ui.common.account.free_credits",{amount:`$${e.toFixed(2)}`}),J6=e=>Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`,Rqt=e=>typeof e!="number"||!Number.isFinite(e)?m("ui.common.account.free_credits_unknown"):m("ui.common.account.free_credits",{amount:J6(e)});function SJ(e,t){if(!e)return t;try{const{protocol:n}=new URL(e);return n==="https:"||n==="http:"?e:t}catch{return t}}function Eqt(e){window.api?.openExternal?window.api.openExternal(e):window.open(e,"_blank")}const qqt=(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 jqt(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:bJ},{label:xJ(),url:wJ}]};if(Xqt(e)){const i=SJ(e.claim_url,bJ),{action:a}=qqt(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=Rqt(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:J6(n.bonus_amount),minimum:J6(n.minimum_purchase)})),{state:"verified",lines:r,links:[{label:xJ(),url:SJ(n?.topup_url,wJ)}]}}const Cqt=5*1e3,zqt=({action:e})=>{const{user:t,accountRead:n}=NOe({staleTime:Cqt,retryOnMount:!1}),r=hr(),{prices:i}=Tqt(),o=r.isPending||n==="checking"?null:jqt(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(cv,{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(Qe,{variant:"secondary",size:"sm",onClick:()=>Eqt(s.url),children:s.label},s.url)),f.jsx(Qe,{variant:"ghost",size:"sm",asChild:!0,children:f.jsx(Wce,{to:e.to,children:e.label})})]})]})},X0="data-jump-highlight",Aqt=1400,VX=new WeakMap;function eC(e){const t=VX.get(e);t!==void 0&&window.clearTimeout(t);const n=e.hasAttribute(X0);e.removeAttribute(X0),n&&e.offsetHeight,e.setAttribute(X0,""),VX.set(e,window.setTimeout(()=>{VX.delete(e),e.removeAttribute(X0)},Aqt))}const MX=(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)},px=24,CQe=6,tC=()=>new Promise(e=>{window.requestAnimationFrame(()=>{e()})}),QJ=async e=>{for(let t=0;t<CQe;t+=1){if(e())return;await tC()}},zQe=e=>{let t=null;return()=>(t!==null||(t=e().finally(()=>{t=null})),t)},Uqt=e=>{const t=zQe(e.loadOlder),n=()=>QJ(()=>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 QJ(()=>e.reachable()),e.reachable()?"landed":"exhausted"}if(o>=i.maxPages||(o+=1,!await t()))return"exhausted";await n()}}}},Wqt=12,Nqt=1200,Yqt=CQe,Gqt=Yqt+2,Zqt=2,Iqt=30,kJ=1,Hg=px;let Sh=0;async function Dqt(e){const{isReachable:t,rowDistance:n,mount:r,loadOlder:i}=e,a=e.hasHeadroom??(()=>!0);return await Uqt({reachable:t,rowDistance:n,mount:r,loadOlder:i,hasHeadroom:a}).loadThrough({maxPages:Wqt,maxRows:Nqt})==="landed"}async function Vqt(e,t,n){if(!n()||!t.isConnected)return;Sh+=1;const r=Sh;MX(e,t,"reversed",Hg);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<Gqt&&(await tC(),!(!n()||!t.isConnected||a||r!==Sh));u+=1){const O=t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-Hg;if(Math.abs(O)<=kJ){if(l+=1,l>=Zqt){c=!0;break}continue}l=0,MX(e,t,"reversed",Hg)}if(c&&!a&&r===Sh){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<Iqt;h+=1){if(await tC(),!n()||a||r!==Sh||!u.isConnected||!O.isConnected)return;const p=O.getBoundingClientRect().top-u.getBoundingClientRect().top-u.clientTop-Hg;if(Math.abs(p)<=kJ)continue;MX(u,O,"reversed",Hg);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===Sh){const l=e.ownerDocument?.defaultView;l!=null&&e.dispatchEvent(new l.Event("scroll"))}}function AQe(e,t,n,r=()=>!0){return r()?new Promise(i=>{GEt(e,n,{isCurrent:r,onRevealed:a=>{if(!r()){i("missing");return}eC(a),Vqt(t,a,r).then(()=>{r()&&a.isConnected&&!a.hasAttribute(X0)&&eC(a),i(r()?"landed":"missing")})},onMissing:()=>{i("missing")}})}):Promise.resolve("missing")}const Ju=120,e1=400,Mqt=.5,Lqt=320,Fqt=900,t1=64,B_=2,LX=24,FX=3,Bqt=4,vy=12,nC=vy,Hqt=120,Kqt=.35,_J=12,Jqt=8,ejt=vy,tjt=.5,PJ=()=>({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}),UQe=e=>Math.min(Fqt,Math.max(Lqt,Math.round(e*Mqt))),njt=(e,t)=>{if(t.direction==="down")return{...e,armed:!1,deliberate:!1,retained:!1,actFetchSpent:t.at-e.lastInputAt>=e1?!1:e.actFetchSpent,actAsks:t.at-e.lastInputAt>=e1?0:e.actAsks,revealsThisAct:t.at-e.lastInputAt>=e1?0:e.revealsThisAct,continuation:!1,clampLatched:!1,travelledSinceLatch:!1,actTravelled:e.actTravelled||t.travelledPx>=t1,pageWidenOwed:!1,turnedAround:e.busy,chainFetch:0,chainWiden:0,chainInvisible:0,lastInputAt:t.at};const n=t.at-e.lastInputAt>=e1,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>=t1:e.actTravelled||t.travelledPx>=t1,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>=t1&&!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}},Kg=(e,t,n)=>({action:t,state:{...e,armed:!1,deliberate:!1,busy:!0,continuation:!1,clampLatched:e.clampLatched||e.armed&&n.distanceFromTopPx<=B_,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}}),rjt=(e,t,n)=>e.busy||e.pageWidenOwed?!0:!e.armed||!WQe(t).inZone?!1:t.distanceFromTopPx<=B_?!e.pressDemand||!e.clampLatched||e.actTravelled||e.actAsks>=nC?!1:n-e.lastInputAt>=Ju:!0;function WQe(e,t=UQe(e.clientHeight)){return{inZone:e.distanceFromTopPx<=t}}const ijt=(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=UQe(t.clientHeight),{inZone:a}=WQe(t,i),o=n-e.lastInputAt>=Ju||t.distanceFromTopPx<=B_,s=e.revealsThisAct<ejt;if(e.pageWidenOwed&&r==="widen"&&e.chainWiden<_J&&s)return o?Kg({...e,pageWidenOwed:!1,continuation:!1,armed:!1,retained:!1,deliberate:!1},r,t):{action:"none",state:e};if(e.armed){if(e.deliberate)return Kg(e,r,t);if(r==="fetch"&&e.failures>=FX)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>=Ju;return l&&e.clampLatched&&!e.actTravelled&&e.pressDemand&&e.actAsks<nC?Kg(e,r,t):l?{action:"none",state:{...e,armed:!1}}:{action:"none",state:e}}return Kg(e,r,t)}if(e.continuation){const l=e.actAsks<nC,c=l&&e.chainInvisible>0&&e.chainInvisible<vy;return t.scrollable&&!(e.pageWidenOwed&&r==="widen")&&!c?{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}:s&&(r==="widen"?e.chainWiden<_J:(c||l&&e.chainFetch<Bqt)&&e.failures<FX)?Kg({...e,pageWidenOwed:!1,continuation:!1},r,t):{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}}return{action:"none",state:e}},TJ=(e,{network:t=!0,hiddenRowsAfter:n=0,paintedDelta:r=null,growthPx:i=null,clientHeight:a=0,newRecords:o=null}={})=>{const s=r!==null&&r<Jqt,l=r===null&&t&&i!==null&&i<Math.max(Hqt,Kqt*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,vy):0,continuation:t&&n>0||c&&e.chainInvisible+1<vy||!e.retained&&!e.turnedAround}},ajt=e=>({...e,busy:!1,pressDemand:!1,failures:e.failures+1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),ojt=e=>({...e,busy:!1,pressDemand:!1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),sjt=(e,t,n,r)=>n===r?NQe(e,t):null,NQe=(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)<tjt?0:n};function rQ({path:e}){switch(_A(e)){case"image":return f.jsx(Ice,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"spreadsheet":return f.jsx(Dce,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"markdown":case"text":case"document":return f.jsx(X$,{"aria-hidden":"true",className:"size-3.5 shrink-0"});default:return f.jsx(Ov,{"aria-hidden":"true",className:"size-3.5 shrink-0"})}}function ljt(e,t){try{return oW(e,t)}catch{return!1}}function Lv(e,t,n,r){const i=$.useCallback(async s=>{try{const l=r?await r():e,[c]=await window.api.probeFiles([l],t??void 0);if(!c?.resolved.startsWith("/"))throw new Error("File path has no session working directory");await s(c.resolved)}catch{Rr(m("ui.chat.highlights.file_resolution_failed"))}},[e,t,r]),a=ljt(n??null,e),o=$.useCallback(()=>{i(async s=>{a&&n&&await n.openInCanvas(s)||await xO(s)})},[i,a,n]);return{canOpenInCanvas:a,press:o,withTarget:i}}const H_=$.memo(function({actionPath:t,label:n,cwd:r,pane:i,overlay:a=!1,resolveActionPath:o,missing:s=!1}){we();const{canOpenInCanvas:l,withTarget:c}=Lv(t,r,i,o),[u,O]=$.useState(!1),d=`Actions for ${n||"this file"}`;return f.jsxs(w9,{children:[f.jsx(vt,{content:m("ui.common.actions.file_actions_menu.file_actions"),children:f.jsx(x9,{asChild:!0,children:a?f.jsx(Qe,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":d,children:f.jsx(jj,{"aria-hidden":"true"})}):f.jsx("button",{type:"button",className:"flex size-6 shrink-0 items-center justify-center text-ink-dim opacity-0 group-hover:opacity-100 focus-visible:opacity-100","aria-label":d,children:f.jsx(jj,{"aria-hidden":"true",className:"size-3.5"})})})}),f.jsxs(S9,{align:"end",className:"min-w-45",children:[l&&!s&&f.jsxs(gl,{onSelect:()=>{c(h=>i?.openInCanvas(h))},children:[f.jsx(Mce,{"aria-hidden":"true"}),f.jsx("span",{children:m("ui.chat.canonical.supplement.file_actions.open_in_canvas")})]}),!s&&f.jsxs(gl,{onSelect:()=>{c(xO)},children:[f.jsx(Ov,{"aria-hidden":"true"}),f.jsx("span",{children:m("ui.chat.canonical.supplement.file_actions.open_in_default_app")})]}),!s&&f.jsxs(gl,{onSelect:()=>{c(sW)},children:[f.jsx(kp,{"aria-hidden":"true"}),f.jsx("span",{children:m("ui.chat.canonical.supplement.file_actions.reveal_in_finder")})]}),f.jsxs(gl,{onSelect:()=>{(o&&!s?o():Promise.resolve(t)).then(h=>navigator.clipboard.writeText(h)).then(()=>O(!0)).catch(()=>Rr(m("ui.notices.files.copy_path_failed")))},children:[f.jsx(C9,{"aria-hidden":"true"}),f.jsx("span",{children:u?"Copied":"Copy file path"})]})]})]})});function cjt(e){return e.materialisable===!1&&!e.stored?"gone":e.exists===!0?"present":e.exists===!1?e.stored?"retained":"gone":e.stored?"present":"gone"}const EW=(e,t,n)=>`${e}:${t??`#${n}`}`;function ujt(e){if(!e||typeof e.message_id!="string"||!e.message_id||e.kind!=="document"&&e.kind!=="image")return null;const t=typeof e.attachment=="string"&&e.attachment?e.attachment:null;return{key:EW(e.message_id,t,e.index??0),messageId:e.message_id,ts:Math.round((typeof e.ts=="number"?e.ts:0)*1e3),kind:e.kind,digest:t,data:null,filename:e.filename??null,mimeType:e.mime_type??(e.kind==="image"?"image/png":"application/octet-stream"),bytes:typeof e.bytes=="number"?e.bytes:null,path:e.path??null,storedPath:e.stored_path??null,availability:cjt(e),index:typeof e.index=="number"?e.index:0,materialisable:typeof e.materialisable=="boolean"?e.materialisable:null,originExists:typeof e.exists=="boolean"?e.exists:null}}function Ojt(e,t,n){return{key:EW(e.id,t.attachment,n),messageId:e.id,ts:e.ts,kind:"document",digest:t.attachment,data:null,filename:t.filename,mimeType:t.mimeType,bytes:t.bytes>0?t.bytes:null,path:t.path,storedPath:t.storedPath,availability:"unknown",materialisable:null}}function djt(e,t,n){return{key:EW(e.id,t.attachment,n),messageId:e.id,ts:e.ts,kind:"image",digest:t.attachment,data:t.data,filename:t.name??null,mimeType:t.mimeType,bytes:t.sizeBytes??null,path:null,storedPath:null,availability:"unknown",materialisable:null}}function YQe(e){const t=[];for(const n of e??[])n.kind==="user"&&((n.documents??[]).forEach((r,i)=>{t.push(Ojt(n,r,i))}),n.images.forEach((r,i)=>{r.kind!==void 0&&r.kind!=="image"||t.push(djt(n,r,i))}));return t}function fjt(e,t,n=!1){const r=e?.state==="ready",i=r?(e?.items??[]).map(ujt).filter(p=>p!==null):[],a=!n||e?.state==="unsupported"?"none":r?i.length>0&&i.every(p=>p.materialisable===null)?"none":"ready":"pending",o=new Map(i.map(p=>[p.key,p])),s=new Map;for(const p of i){const g=`${p.messageId}:${p.kind}`;s.set(g,(s.get(g)??0)+1)}const l=YQe(t),c=new Map,u=pjt({items:i,verdicts:a}),O=new Map;for(const p of l){const g=`${p.messageId}:${p.kind}`;O.set(g,(O.get(g)??0)+1)}const d=new Map,h=[...i];for(const p of l){const g=`${p.messageId}:${p.kind}`,y=d.get(g)??0;if(d.set(g,y+1),o.has(p.key))continue;const v=rC(u,{messageId:p.messageId,kind:p.kind,position:y,count:O.get(g)??0,digest:p.digest,path:p.path}),b=v===null?p:{...p,materialisable:v};if(b.digest===null){const x=`${b.messageId}:${b.kind}`,Q=c.get(x)??0;if(c.set(x,Q+1),Q<(s.get(x)??0))continue}o.set(b.key,b),h.push(b)}return h.sort((p,g)=>g.ts-p.ts),{items:h,complete:r,truncated:!!e?.truncated,verdicts:a}}const Fv={digests:new Set,slots:new Map,paths:new Set,verdicts:"none",judged:new Map},hjt={...Fv,verdicts:"pending"};function pjt(e){const t=e.verdicts??"none";if(t==="pending")return hjt;const n=new Set,r=new Set,i=new Map,a=new Map;for(const s of e.items){if(typeof s.materialisable!="boolean"||s.index===void 0)continue;const l=`${s.messageId}:${s.kind}`;i.set(l,(i.get(l)??0)+1);const c=s.materialisable===!1;c&&s.digest&&n.add(s.digest),c&&s.path&&r.add(s.path);const u=a.get(l)??[];u.push({index:s.index,refused:c}),a.set(l,u)}const o=new Map;for(const[s,l]of a)l.some(c=>c.refused)&&(l.sort((c,u)=>c.index-u.index),o.set(s,l.map(c=>c.refused)));return!o.size&&t==="none"?Fv:{digests:n,slots:o,paths:r,verdicts:t,judged:i}}function rC(e,t){if(t.digest&&e.digests.has(t.digest)||t.path&&e.paths.has(t.path))return!1;if(e.verdicts==="pending")return"pending";const n=`${t.messageId}:${t.kind}`,r=e.slots.get(n);return r&&(r.length!==t.count||r[t.position])?!1:e.verdicts==="ready"&&(e.judged.get(n)??0)<t.count?"pending":null}function XJ(e,t){return e&&t!==!1&&t!=="pending"}function zfn(e){return new Set(e.items.map(t=>t.digest).filter(t=>t!==null))}function Afn(e,t,n=0,r=!0){const i=hr(),a=i.data!==void 0,o=Un(i.data,"session_attachments"),s=$.useMemo(()=>YQe(t),[t]),l=s.map(X=>`${X.key}:${X.digest??""}`).join("|"),[c,u]=$.useState({key:"",value:null,state:"loading"}),O=`${e??"draft"}:${o}`,[d,h]=$.useState(0),{echoIds:p,durableIds:g}=$.useMemo(()=>{const X=new Set(s.map(q=>q.messageId)),E=[],R=[];for(const q of t??[])q.kind!=="user"||!X.has(q.id)||(q.local||q.provisional?E:R).push(q.id);return{echoIds:E.join(`
916
916
  `),durableIds:R.join(`
@@ -1042,4 +1042,4 @@ ${g}`,K=C.current;C.current=D,!(K===null||K===D)&&(aan(K.split(`
1042
1042
 
1043
1043
  ${mr}`:ys,ie),Wi=Qr?void 0:async ys=>(Te=await pu(V,ys),Kr(Te.text)),d5=Kr(Le.text),yu=await e(d5,$e.map(ys=>ys.path),fe,V,Wi,Kf());return yu!==!1&&(Hf.current=!1,Ks.current=!1),yu!==!1&&Te&&(Te.stored.length>0&&OO(cK(Te.stored)),Te.refused.length>0&&jh(uK(Te.refused)),Te.unconfirmed.length>0&&jh(OK(Te.unconfirmed))),yu===!1?yu:xA(yu)?(GOe(yu,Bf),yu):(Bf(),yu)},[e,$e,ie,Bf,pu,Qr,og,L?.onOpenDraftPicker,Kf,Se,Be,sg,lg,q,Oe]),Jf=fr(V=>UYe(V.drafts,d)),{inputValue:Pe,setInputValue:Dn,handleKeyDown:ZO,handleSubmit:eh,textareaRef:Ht,sendInFlight:th,appendTranscriptText:ms}=hNe({conversationId:d,onSubmit:FP,scrollToBottom:x,draftHeld:Wa(wi),transcriptless:Y,draftUnredacted:Mf}),IO=th||Jf;$.useEffect(()=>{Pe===""&&!th&&!Jf&&(Hf.current=!1,Ks.current=!1)},[Pe,th,Jf]);const Ui=dK(cb,Pe),[pr,Qi]=$.useState(0),[DO,cg]=$.useState(!1),BP=hsn(d),Js=he??!1,ot=tln({inputValue:Pe,selectionStart:pr,sessionId:BP,paneHasSession:Js,activeProfile:{team:L?.frontend?.active_team,agent:L?.frontend?.active_agent},activeModel:iQ(L?.frontend?.effective_model??L?.frontend?.selected_model),activeSpec:L?.frontend?.effective_model??L?.frontend?.selected_model,cwd:q}),hb=fs&&!(ot.open&&ot.phase==="argument"),Hr=nsn({text:Pe,caret:pr,cwd:q,attached:Js,commandNames:ot.commandNames,argumentWords:ot.argumentWords,enabled:!Wa(wi)});$.useEffect(()=>{fb.current=Hr.vocabulary.map(V=>V.name)},[Hr.vocabulary]);const Xa=mon({text:Pe,caret:pr,cwd:q,enabled:se,unsupported:ee}),el=Oln({text:Pe,cwd:q,enabled:se}),Hl=$.useMemo(()=>[...el.resolved.values()].filter(V=>V.outside).length,[el.resolved]),kr=$.useRef(null),mu=$.useRef(null),Ra=$.useRef(null);$.useLayoutEffect(()=>{d!==void 0&&Ra.current!==d&&Pe&&(Ra.current=d,kr.current=Pe.length,Qi(Pe.length))},[Pe,d]);const ug=$.useRef(Pe);$.useLayoutEffect(()=>{ug.current=Pe;const V=Ht.current,fe=kr.current;!V||fe===null||(kr.current=null,V.setSelectionRange(fe,fe))},[Pe,Ht,Zr]);const nh=$.useCallback(()=>[...LP.current,...[...Si.current.values()].map(V=>V.key)],[]),gu=$.useCallback((V,fe)=>{d&&(Wa(V)||Mn.getState().setCurrentInput(d,fe,Mf(fe)))},[d,Mf]),Mi=$.useCallback(V=>{const fe=V.payload??null;fe&&(Si.current.set(fe.index,fe),hs.current=Math.max(hs.current,fe.index+1)),V.buffer!==ug.current&&(kr.current=V.caret,Qi(V.caret)),ps.current=V.buffer,hu.current!==null&&!V.buffer.includes(hu.current.trim())&&(hu.current=null),Ll.current!==null&&!V.buffer.includes(Ll.current.text.trim())&&(Ll.current=null),To(V.capture),Dn(V.buffer),gu(V.capture,V.buffer)},[gu,To,Dn]);$.useLayoutEffect(()=>{ps.current!==Pe&&(ps.current=Pe,kTt(xi.current)&&(To(Ga),Zr(null)))},[Pe,To,Zr]),$.useEffect(()=>{xi.current=Ga,To(Ga),Si.current.clear(),hs.current=1,Lf.current=!1,Ll.current=null,hu.current=null,Bl.current=null,Zr(null),YO(null),sb(null)},[d,To,Zr]);const Og=Mn(V=>d?V.getUnredactedChars(d):0),VO=Mn(V=>d?V.getCurrentInput(d):"");$.useEffect(()=>{Og<=0||!VO||Pe!==VO||Vf.current?.over!==VO&&Zr({chars:Og,over:VO})},[Og,VO,Pe,Zr]),$.useLayoutEffect(()=>{const V=Vf.current;V&&V.over!==Pe&&Zr(null)},[Pe,Zr]),$.useLayoutEffect(()=>{const V=ag.current;V&&V.over!==Pe&&fu(null)},[Pe,fu]),$.useEffect(()=>{Lf.current&&(lK(Pe,Si.current.values()).length>0||(Si.current.clear(),hs.current=1,Lf.current=!1))},[Pe,Ob]),$.useEffect(()=>{wi.arm===null||!Qr||Ff.current!==Qr&&(Ff.current=Qr,je({op:"sessions.credential",sessionId:Qr,action:"list"}).then(V=>{LP.current=uW(V)}).catch(()=>{}))},[wi.arm,Qr]);const dg=$.useCallback(()=>{const V=xi.current;if(!Wa(V))return!1;const fe=TTt({capture:V,buffer:Pe,caret:Ht.current?.selectionEnd??Pe.length,index:hs.current,taken:nh()});return fe.minted?(Mi(fe),Zr(null),!0):!1},[Mi,Pe,nh,Zr]),pb=$.useCallback(V=>{const fe=xi.current;if(!Wa(fe))return!1;const Te=V.currentTarget,Le={start:Te.selectionStart??Pe.length,end:Te.selectionEnd??Pe.length};if(V.key==="Enter"&&!V.shiftKey&&!V.nativeEvent.isComposing)return dg();if(V.key==="Escape"){if(XTt(fe)&&!GO(Pe,fe))return YO({buffer:Pe,value:fe.value}),!0;const _n=fe.value!=="",$n=RTt(fe,Pe);return $n.cancelled?(Ll.current=$n.token,Zr(null),_n&&sb($n.buffer),Mi($n),!0):!1}return V.key==="Enter"?(Mi(sK(fe,Pe,Le,`
1044
1044
  `)),!0):V.key==="Tab"?!0:Array.from(V.key).length===1&&!V.ctrlKey&&!V.metaKey&&!V.altKey&&!V.nativeEvent.isComposing?(Mi(sK(fe,Pe,Le,V.key)),!0):!1},[Pe,Mi,dg,Zr,GO]),ae=$.useCallback((V,fe,Te="typed")=>Fsn({gesture:Te,draft:V,caret:fe,commandNames:ot.commandNames,promptCommands:ot.promptCommands,armedOnlyCommands:ot.armedOnlyCommands,valueArgumentCommands:ot.valueArgumentCommands,argumentCommands:ot.argumentCommands,argumentShapes:ot.argumentShapes,prefixingCommands:ot.prefixingCommands,commandLockedWords:pln,unmaskedRunWord:nn(V)?Fl.current?.word:void 0,nameListCommands:ot.nameListCommands,enabled:ot.available&&!!ne}),[ot.commandNames,ot.promptCommands,ot.armedOnlyCommands,ot.valueArgumentCommands,ot.argumentCommands,ot.argumentShapes,ot.prefixingCommands,ot.nameListCommands,ot.available,ne]),ce=$.useCallback((V,fe,Te)=>{kr.current=fe,Dn(V),Qi(fe),Oe?.(Te)},[Oe,Dn]),tt=$.useCallback(V=>{const fe=Ll.current;if(fe!==null&&fe.text.trim().length>0&&V.includes(fe.text.trim()))return fe.text.trim();const Te=hu.current;return Te!==null&&Te.trim().length>0&&V.includes(Te.trim())?Te.trim():null},[]),et=$.useCallback(V=>ETt(V,Ll.current)?"send":tt(V)===null?"typed":"pick",[tt]),nn=$.useCallback(V=>{const fe=Fl.current;return fe!==null&&wTt(V,fe.run)},[]),Ze=$.useCallback((V,fe)=>{const Te=et(V);if(Te==="send")return{kind:"send"};const Le=Te==="pick"?ae(V,fe,"pick"):ae(V,fe);if(Te!=="pick"||Le.kind!=="send")return Le;const Kt=tt(V);if(Kt===null)return Le;const _n=V.indexOf(Kt);return _n<0?Le:ae(V,_n+Kt.length,"pick")},[et,ae,tt]),dn=$.useMemo(()=>{if(DO)return[];const V=bon({draft:Pe,commandNames:ot.commandNames,nameListCommands:ot.nameListCommands,nameChoices:ot.nameChoices,picking:ot.open&&ot.matches.length>0});if(V.length===0)return V;const fe=ae(Pe,pr,"typed");return won(V,Pe,{sendsAsWritten:fe.kind==="send"})},[Pe,pr,DO,ae,ot.commandNames,ot.nameListCommands,ot.nameChoices,ot.open,ot.matches.length]),fn=$.useMemo(()=>DO?[]:Non({draft:Pe,vocabulary:Hr.vocabulary,settled:Hr.settled,picking:Hr.open,expands:Ze(Pe,pr).kind==="send"}),[Pe,pr,DO,Hr.vocabulary,Hr.settled,Hr.open,Ze]),_r=$.useMemo(()=>[...dn,...fn],[dn,fn]),sn=G2e(_r),ir=$.useCallback(async(V,fe,Te)=>{const Le=ne;if(!Le)return;if(V.kind==="whole"||V.kind==="splice"){const _n=ot.commands.find(mr=>mr.name===V.command.name||mr.aliases.includes(V.command.name)),$n=Bn(V.command.args??"");if(_n?.destination==="session.model"&&$n){const mr=zke(ot.argumentList.rows,$n);if(mr){aO.getState().openConnect({providerId:mr});return}}if(_n?.destination==="session.tags"){if(!Bn(V.command.args??"")){const mr=V.kind==="splice"?V.start:0,Kr=V.kind==="splice"?V.end:fe.length,Wi=xc(fe,mr,Kr,`/${_n.name} `);kr.current=Wi.caret,Dn(Wi.text),Qi(Wi.caret)}ot.reopen();return}}if(V.kind==="list-open"){if(ot.open&&ot.matches.length>0)return;Oe?.(`Type a name after /${V.command.name}, or choose one from the list.`);return}if(V.kind==="unrecognised"){await Le(V.command),kr.current=Te,Dn(fe),Qi(Te);return}if(V.kind==="reassemble"){ce(V.text,V.caret,Tsn(V.text.trim(),Js));return}if(await Le(V.command)==="consumed"){const _n=V.kind==="whole"?"":V.text,$n=V.kind==="whole"?0:V.caret;if(kr.current=$n,Dn(_n),Qi($n),V.locked===!0){const mr=c2t(fe,xi.current),Wi=!(V.kind==="whole"?mr:mr.slice(V.start,V.end)).includes(rSe);Bl.current=Wi?{text:mr,caret:Te,plain:tm(V.command.args).length}:null,Oe?.(Xsn(V.command.name,{dialog:Js&&ot.commandNames.has(V.command.name),undo:Wi},bj))}return}kr.current=Te,Dn(fe),Qi(Te)},[ne,Oe,Dn,ot.commandNames,ot.open,ot.matches.length,ot.commands,ot.argumentList.rows,ot.reopen,ce,Js]),Li=!!(t&&p),gn=!!s,wt=H||Li||gn||!!o?.blocksInput,[Qt,Ea]=$.useState(null),[mb,$u]=$.useState(null),[Vn,hY]=$.useState(!1),pY=$.useRef(null),gb=$.useRef(null),mY=$.useRef(Pe);$.useEffect(()=>{mY.current=Pe},[Pe]),$.useEffect(()=>{Ea(null),$u(null)},[d]),$.useEffect(()=>{Qt!==null&&pY.current?.focus()},[Qt]),$.useEffect(()=>{if(!Vn)return;const V=document.activeElement;V!==null&&V!==document.body&&!gb.current?.contains(V)||gb.current?.focus()},[Vn]);const fg=$.useRef(!1);$.useEffect(()=>{if(Qt===null||l!==null&&l.key===Qt.key)return;if(Ea(null),$u(l===null?m("ui.chat.composer.secret_fill_gone"):m("ui.chat.composer.secret_fill_changed")),fg.current){fg.current=!1;return}const V=document.activeElement;V!==null&&V!==document.body&&V!==Ht.current&&!gb.current?.contains(V)||Ht.current?.focus()},[l,Qt,Ht]),$.useEffect(()=>{$u(null)},[Pe]),$.useEffect(()=>{Qt!==null&&Pe.trim()!==Qt.value&&Ea(null)},[Pe,Qt]);const $b=$.useCallback(V=>!l||!hK(V)?!1:(fg.current=!1,Ea({value:V.trim(),key:l.key}),!0),[l]),yb=$.useCallback(()=>{Ea(null),$u(null),Ht.current?.focus()},[Ht]),gY=$.useCallback(V=>{switch(V){case"locked":return m("ui.chat.composer.secret_fill_locked");case"stale":return m("ui.chat.composer.secret_fill_changed");case"multi":return m("ui.chat.composer.secret_fill_multi");case"refused":return m("ui.chat.composer.secret_fill_refused");case"unavailable":return m("ui.chat.composer.secret_fill_unavailable")}},[]),oXe=$.useCallback(async()=>{if(Qt===null||l===null||Vn)return;if(!l.fillable){Ea(null),$u(m("ui.chat.composer.secret_fill_multi")),l.onOpen(),fg.current=!0;return}hY(!0);let V;try{V=await l.onFill(Qt.value,Qt.key)}catch{V="unavailable"}finally{hY(!1)}if(Ea(null),V==="sent"){mY.current.trim()===Qt.value&&Dn(""),Ht.current?.focus();return}$u(gY(V));const fe=V==="unavailable"?!1:l.onOpen({focus:!1});fg.current=fe,fe||Ht.current?.focus()},[l,Qt,Vn,gY,Dn,Ht]),sXe=$.useCallback(()=>{Ea(null),eh(),Ht.current?.focus()},[eh,Ht]),hg=X||E,vb=$.useCallback(()=>{Br(!0)},[]),HP=$.useCallback(async V=>{const fe=iQ(V.model);if(!(wt||!l_e(V)||V.id!=="model-default"||!fe)){ot.close();try{await s_e(fe,(Te,Le)=>je({op:"settings.edit",key:Te,value:Le})),Dn(""),Oe?.(`Default for new sessions: ${fe.provider}/${fe.model_id}`)}catch(Te){Oe?.(`The default was not saved: ${Te instanceof Error?Te.message:"the backend refused it"}`)}}},[wt,ot.close,Dn,Oe]),KP=$.useCallback(async(V,fe)=>{if(V.kind==="action"){fe.run&&await HP(V.row);return}if(wt)return;if(V.kind==="argument"&&ot.inline?.source==="session-tags"&&fe.run){await ot.actOnTagRow(V.row);return}const Te=lln(Pe,pr,V,ot.commandNames,ot.argumentWords,ot.inline?.nameThenMessage??!1);if(!Te)return;if(ot.close(),fe.run&&V.kind==="argument"&&!Js&&ne){const $n=Hrn(ot.inline?.source);if($n){const mr=P$(Pe,pr,ot.commandNames),Kr=mr?Bn(xc(Pe,mr.start,mr.end,"").text):"";fr.getState().restageDraft({kind:$n,name:V.row.value},Kr);return}}Fh.lastIndex=0;const Le=Fh.exec(Te.text);if(hu.current=Le?Le[0].trim():null,V.kind==="command"&&fe.run&&t9(V,ot.armedOnlyCommands)){const $n=Bsn({draft:Te.text,caret:Te.caret,commandNames:ot.commandNames,armedOnlyCommands:ot.armedOnlyCommands});if($n.kind==="armed"){ce($n.text,$n.caret,Psn($n.text.trim(),V.command.destination,S2e(V.command.destination)?Js:!0));return}}if(Mi({capture:Bh(xi.current,Te.text,Te.caret,"completion"),buffer:Te.text,caret:Te.caret}),!(fe.run&&(V.kind==="command"?F2e(V.command.destination,ot.effectiveEntry(V.command.destination)):ot.inline?.runs??!1)&&!!ne))return;const _n=ae(Te.text,Te.caret,"pick");_n.kind!=="send"&&await ir(_n,Pe,pr)},[Pe,pr,ot,Mi,ne,ae,ir,ce,Js,wt,HP]),$Y=$.useCallback(V=>{const fe=psn(Pe,pr,V,ot.commandNames);fe&&(kr.current=fe.caret,Dn(fe.text),Qi(fe.caret))},[Pe,pr,ot.commandNames,Dn]),yY=$.useCallback(V=>{if(wt)return;const fe=W2e(Pe,pr);if(!fe)return;const Te=Lan(V),Le=Pe.slice(fe.end,fe.end+1),Kt=fe.start>0&&(Le===" "||Le===`
1045
- `)?1:0,_n=xc(Pe,fe.start,fe.end+Kt,Te),$n=Te.endsWith('"')?_n.caret-1:_n.caret;kr.current=$n,Dn(_n.text),Qi($n),Xa.remember(V.path),Xa.close()},[Pe,pr,Xa,Dn,wt]),JP=$.useCallback(V=>{if(wt||!Hr.token)return;const fe=Won(Pe,Hr.token,V.name);Hr.close(),kr.current=fe.caret,Dn(fe.text),Qi(fe.caret)},[Pe,Hr,Dn,wt]),lXe=$.useCallback(V=>{const fe=Bl.current;return fe===null||!(V.metaKey||V.ctrlKey)||V.altKey||V.shiftKey||V.key.toLowerCase()!=="z"?!1:(Bl.current=null,kr.current=fe.caret,fe.plain>0&&Zr({chars:fe.plain,over:fe.text}),Dn(fe.text),Qi(fe.caret),!0)},[Zr,Dn]),cXe=$.useCallback(V=>{if(wt)return;if(pb(V)){V.preventDefault();return}if(V.key==="Escape"&&Qt!==null){if(V.preventDefault(),Vn)return;yb();return}if(OXe(V)){V.preventDefault();return}if(lXe(V)){V.preventDefault();return}if(gon(V,Xa,yY)){V.preventDefault();return}if(sln(V,ot,KP,$Y)){V.preventDefault();return}if(asn(V,Hr,JP)){V.preventDefault();return}if(Ee!==null&&V.key==="Escape"){V.preventDefault(),h3(c??"");return}if(Ee!==null&&OYe(V)){const Le=Ee.turns.at(-1),Kt=Le?vr.getState().streams[Le.asideId]:void 0;if(!Le||Ee.queued!==void 0||!nde(Kt,u,O))return;V.preventDefault();const _n=c??"",$n=Date.now(),mr=fYe(Xt.current,Le.asideId,$n);if(mr==="arm"){Xt.current={turnId:Le.asideId,at:$n},vr.getState().setAsideNotice(_n,DZ(bj));return}if(mr==="ignore")return;Xt.current=null,ede(_n).catch(()=>{});return}if(V.key==="Backspace"||V.key==="Delete"){const Le=Uan(pr,V.key==="Backspace"?"back":"forward",el.spans,el.resolved);if(Le&&!V.nativeEvent.isComposing){const Kt=xc(Pe,Le.start,Le.end,"");kr.current=Kt.caret,Qi(Kt.caret),Dn(Kt.text),V.preventDefault();return}}const fe=Ht.current,Te=Sln();if(Te&&OUe(V,{value:Pe,selectionStart:fe?.selectionStart??null,selectionEnd:fe?.selectionEnd??null})){Te.focus(),V.preventDefault();return}if(hg&&V.key==="Enter"&&!V.shiftKey&&!V.nativeEvent.isComposing){V.preventDefault(),vb();return}if(V.key==="Enter"&&!V.shiftKey&&!V.nativeEvent.isComposing){const Le=Ze(Pe,pr);if(Le.kind!=="send"){V.preventDefault(),ir(Le,Pe,pr);return}if($b(Pe)){V.preventDefault();return}}ZO(V)},[ot,KP,$Y,Hr,JP,$b,ZO,pb,Qt,yb,Ze,ir,Pe,pr,wt,Ee,c,u,O]),vY=$.useRef(null),tl=$.useCallback(V=>{n9=!1,Ht.current?.focus({preventScroll:V?.preventScroll===!0})},[Ht]),uXe=$.useCallback(()=>{dA(Pe)!==null&&Dn("")},[Pe,Dn]);$.useImperativeHandle(ge,()=>({focusInput:tl,openWorkingDirectoryMenu:()=>{vY.current?.openMenu()},submitNow:()=>{$b(Pe)||eh()},consumeApprovalAnswerDraft:uXe}));const bY=$.useCallback(()=>Ht.current,[Ht]);$.useEffect(()=>a8e(tl,bY),[tl,bY]);const nl=$.useRef(null),wY=$.useRef(Pe);$.useLayoutEffect(()=>{wY.current=Pe},[Pe]);const xY=$.useCallback(V=>{nl.current===V&&(nl.current=null,Si.current.delete(V.index))},[]),bb=$.useCallback(V=>{if(nl.current!==V)return!1;const fe=BTt({buffer:wY.current,cleared:V.cleared});return fe?(Si.current.set(V.index,V.payload),nl.current===V&&(nl.current=null),V.toastId!==null&&W0(V.toastId),Mi({capture:Bh(xi.current,fe.buffer,fe.caret,"arrival"),buffer:fe.buffer,caret:fe.caret}),fu(null),!0):!1},[Mi,fu]);$.useLayoutEffect(()=>{const V=nl.current;V!==null&&V.cleared.buffer!==Pe&&(V.toastId!==null&&W0(V.toastId),xY(V))},[Pe,xY]);const OXe=$.useCallback(V=>{const fe=nl.current;return fe===null||!(V.metaKey||V.ctrlKey)||V.altKey||V.shiftKey||V.key.toLowerCase()!=="z"?!1:(bb(fe),!0)},[bb]),SY=$.useCallback(V=>{bb(V)&&tl()},[tl,bb]),dXe=$.useCallback(V=>{if(wt)return;const fe=Si.current.get(V);if(!fe)return;const Te=FTt({buffer:Pe,payload:fe});if(!Te.cleared)return;const Le=nl.current;Le&&(nl.current=null,Si.current.delete(Le.index),Le.toastId!==null&&W0(Le.toastId));const Kt={index:V,payload:fe,cleared:Te,toastId:null};nl.current=Kt,Mi({capture:Bh(xi.current,Te.buffer,Te.caret,"arrival"),buffer:Te.buffer,caret:Te.caret}),fu({key:fe.key,index:V,over:Te.buffer}),Kt.toastId=jh(MTt(V),{action:{label:VTt,onClick:()=>SY(Kt)}}),tl()},[Mi,tl,wt,Pe,fu,SY]),fXe=Se,hXe=wt||Se||Be||Pe.trim().length>0;$.useEffect(()=>{const V=Ht.current;V&&(V.style.height="auto",V.style.height=`${V.scrollHeight}px`)},[Pe,Ht,Se,Be,Je]);const e5=!!o?.blocksInput&&Pe==="",wb=$.useRef(null);$.useLayoutEffect(()=>{const V=Ht.current;if(!V||!e5){V&&wb.current!==null&&(V.style.overflowY=""),wb.current=null;return}wb.current!==V.placeholder&&(wb.current=V.placeholder,jle(V))}),$.useEffect(()=>{const V=Ht.current;if(!V||!e5||typeof ResizeObserver>"u")return;let fe=V.clientWidth;const Te=new ResizeObserver(()=>{V.clientWidth!==fe&&(fe=V.clientWidth,jle(V))});return Te.observe(V),()=>Te.disconnect()},[e5,Ht]);const QY=$.useRef(!1);$.useEffect(()=>{const V=Se||Be,fe=QY.current&&!V;if(QY.current=V,!F&&!fe||wt||V)return;const Te=document.activeElement;!(Te&&(Te.tagName==="INPUT"||Te.tagName==="TEXTAREA"||Te.getAttribute("role")==="tab"))&&!X&&Ht.current?.focus({preventScroll:!0})},[F,wt,Se,Be,Ht,X]),$.useEffect(()=>{window.electron.ipcRenderer.invoke("get-platform-info").then(V=>{Tt(V.platform)}).catch(V=>{console.error("Failed to get platform info:",V)})},[]);const gs=$.useRef(null),pXe=250,kY=$.useRef(xe);$.useEffect(()=>{kY.current=xe}),$.useEffect(()=>(Jse("message-input",Se||Je),()=>Jse("message-input",!1)),[Se,Je]),$.useEffect(()=>{kY.current?.(Se)},[Se]);const $s=$.useCallback(V=>{St(!1);const fe=Xn.current;if(!fe)return;const Te=gs.current?.startedAt??null,Le=Te===null?Number.POSITIVE_INFINITY:performance.now()-Te;if(gs.current=null,fe.state==="inactive"){Me(!1);return}(V==="abort"||Le<pXe)&&(fe.onstop=()=>{if(fe.stream)for(const Kt of fe.stream.getTracks())Kt.stop();Ne(null),Yr.current=[],Hn.current=null,Ut(Kt=>Eh(Kt,{type:"discarded"}))}),fe.stop(),Me(!1)},[]);$.useEffect(()=>()=>{const V=gs.current!==null;gs.current=null;const fe=Xn.current;if(fe&&fe.state!=="inactive"){$s("abort");return}V&&St(!1)},[$s]);const t5=$.useCallback((V="release")=>{const fe=gs.current;if(fe){if(fe.startedAt===null){gs.current=null,St(!1);return}$s(V)}},[$s]),_Y=$.useCallback(async()=>{if(!(wt||!zi)&&!gs.current)if(navigator?.mediaDevices?.getUserMedia){const V={startedAt:null};gs.current=V,St(!0);try{const fe=await navigator.mediaDevices.getUserMedia({audio:!0});if(gs.current!==V){for(const Te of fe.getTracks())Te.stop();return}Xn.current=new MediaRecorder(fe),Yr.current=[],Xn.current.ondataavailable=Te=>{Yr.current.push(Te.data)},Xn.current.onstop=()=>{const Te=new Blob(Yr.current,{type:"audio/webm"});rt(null),Ne(Te);for(const Le of fe.getTracks())Le.stop()},Xn.current.start(),V.startedAt=performance.now(),St(!1),Me(!0),Ne(null)}catch(fe){if(gs.current!==V)return;gs.current=null,St(!1),console.error("Error accessing microphone:",fe),Rr(m("ui.canvas.inline_edit.error_accessing_microphone_please_ensure_microphone_permissions_are_gran"))}}else console.error("This runtime exposes no MediaRecorder"),Rr(m("ui.canvas.inline_edit.dictation_is_not_available_on_this_device"))},[zi,wt]),n5=$.useCallback(()=>{Se&&$s("release")},[Se,$s]),r5=$.useCallback(()=>{Se&&$s("abort")},[Se,$s]),mXe=$.useCallback(()=>{if(!(!Se||_t!=="idle")&&!(wt||X||E||IO)){if(Xn.current?.state!=="recording"){$s("release");return}Hn.current={draftAtPress:Pe,transcript:null},Ut(V=>Eh(V,{type:"press"})),$s("release")}},[Se,_t,wt,X,E,IO,Pe,$s]);$.useEffect(()=>{if(!Se&&!Je)return;const V=fe=>{if(Se){if(fe.key==="Enter"){const Te=fe.target;if(Te instanceof Element&&Te.closest("[data-lo-composer-controls] button"))return;fe.preventDefault(),n5()}else fe.key==="Escape"&&(fe.preventDefault(),r5());return}fe.key==="Escape"&&(fe.preventDefault(),t5("abort"),St(!1))};return window.addEventListener("keydown",V),()=>{window.removeEventListener("keydown",V)}},[Se,Je,n5,r5,t5]);const xb=$.useCallback(()=>{Hn.current&&(Hn.current=null,Ut(V=>Eh(V,{type:"transcript",usable:!1})))},[]),PY=$.useCallback(async()=>{if(!Ae)return;Nt.current?.abort();const V=new AbortController;Nt.current=V;try{Bt(!0);const fe=await Z9.createTranscriptionWithRetry(bf.baseUrl,{file:new File([Ae],"recording.webm",{type:"audio/webm"})},{signal:V.signal,onRetry:({attempt:Te,total:Le,delayMs:Kt,error:_n})=>{console.warn(`Transcription attempt ${Te}/${Le} failed with a transient upstream fault; retrying in ${Kt} ms.`,_n)}});if(fe.result?.text){const Te=fe.result?.text||"";Ks.current=!0,ms(Te),Hn.current&&(Hn.current.transcript=Te,Ut(Le=>Eh(Le,{type:"transcript",usable:!0})))}else Jo(Eze()),xb();rt(null),Ne(null)}catch(fe){if(V.signal.aborted){xb();return}console.error("Error transcribing audio:",fe),xb();const Te=Sk(fe);rt(Te?Oze(fe):null),Te||Rr(lue(fe))}finally{Nt.current===V&&Bt(!1)}},[Ae,ms,xb]),gXe=$.useCallback(()=>{rt(null),pt(V=>V+1)},[]);$.useEffect(()=>{if(!Ae){On.current=null;return}On.current?.blob===Ae&&On.current.attempt===Pt||(On.current={blob:Ae,attempt:Pt},PY())},[Ae,Pt,PY]);const TY=$.useRef(!0);$.useEffect(()=>{if(typeof IntersectionObserver>"u")return;const V=Ht.current;if(V===null)return;const fe=new IntersectionObserver(Te=>{const Le=Te[Te.length-1];Le!==void 0&&(TY.current=Le.isIntersecting)});return fe.observe(V),()=>fe.disconnect()},[Ht]),cin(le,Q2e.MESSAGE_INPUT,{start:_Y,stop:t5},()=>!!(!wt&&!Se&&!Be&&zi&&TY.current));const i5=(V=!1)=>{if(wt||X)return!1;if(E)return vb(),!1;if(!Pe.trim()&&$e.length===0||V&&Wa(wi)||V&&r&&Xrn(Pe))return!1;if(dg())return!0;const fe=Ze(Pe,pr);if(fe.kind!=="send")return V?!1:(ir(fe,Pe,pr),!0);if(V){if(l&&hK(Pe))return!1}else if($b(Pe))return!0;return eh(),!0},$Xe=V=>{V.preventDefault(),i5()},XY=$.useRef(i5);XY.current=i5,$.useEffect(()=>{if(_t==="ready-to-submit"){if(Be)return;const V=Hn.current;if(!V||V.transcript===null){Ut("idle");return}const{intact:fe}=Trn({draftAtPress:V.draftAtPress,transcript:V.transcript,current:Pe,join:f3});Hn.current=null;const Te=fe?XY.current(!0):!1;Ut(Le=>Eh(Le,{type:"checked",draftIntact:fe&&Te}));return}_t==="submitting"&&!IO&&Ut(V=>Eh(V,{type:"settled",sendBusy:!1}))},[_t,Be,Pe,IO]);const a5=$.useCallback(V=>{wt&&V.preventDefault()},[wt]),RY=$.useCallback(V=>{!wt&&!hg||(V.preventDefault(),hg&&!wt&&vb())},[wt,hg,vb]),yXe=V=>{d&&pe(d,V)},vXe=async()=>{const V=await window.electron.ipcRenderer.invoke("show-open-dialog",{properties:["openFile","multiSelections"]});if(!V.canceled&&V.filePaths.length>0&&d)for(const fe of V.filePaths)tn(d,{id:Za(),path:tG(fe)})},bXe=V=>{if(wt)return;const fe=V.clipboardData?.getData("text/plain")??"";if(fe&&xi.current.arm!==null){const Le=V.currentTarget,Kt=jTt({capture:xi.current,buffer:Pe,caret:Le.selectionEnd??Pe.length,selection:{start:Le.selectionStart??Pe.length,end:Le.selectionEnd??Pe.length},pasted:fe,index:hs.current,taken:nh()});if(Kt){V.preventDefault(),Mi(Kt),Zr(null);return}}vin(V.clipboardData??null)?V.preventDefault():fe&&(Fl.current=xTt(fe));const Te=V.clipboardData?.items;if(Te){for(let Le=0;Le<Te.length;Le++)if(Te[Le].type.indexOf("image")!==-1||Te[Le].kind==="file"){const Kt=Te[Le].getAsFile();if(Kt){const _n=new FileReader;_n.onload=$n=>{$n.target?.result&&d&&tn(d,{id:Za(),path:$n.target.result})},_n.readAsDataURL(Kt)}}}},wXe=V=>{wt||V.dataTransfer?.types.includes("Files")&&(V.preventDefault(),V.stopPropagation(),V.dataTransfer.dropEffect="copy",o5(!0))},xXe=V=>{V.currentTarget.contains(V.relatedTarget)||o5(!1)},SXe=V=>{if(o5(!1),wt)return;const fe=V.dataTransfer?.files;!fe||fe.length===0||(V.preventDefault(),V.stopPropagation(),d&&QXe(d,Array.from(fe)))},QXe=async(V,fe)=>{for(const Te of fe){const Le=window.api?.getPathForFile?window.api.getPathForFile(Te):"";if(Le){tn(V,{id:Za(),path:tG(Le)});continue}const Kt=await xln(Te);Kt&&tn(V,{id:Za(),path:Kt})}},[EY,o5]=$.useState(!1),kXe=V=>{wt||(Pe||y?.(),kr.current=V.length,Dn(V),Qi(V.length),Ht.current?.focus())},s5=Wa(wi)?wi.value!==""?GO(Pe,wi)?a2t:r2t:Qr?i2t:s2t:ob!==null&&ob===Pe?o2t:LTt({unredacted:Ui!==null?l2t(Ui):null,armed:wi.arm!==null&&cSe(Pe,Pe.length)!==null,cleared:ig===null?null:{key:ig.key,index:ig.index},undoCap:J2e(da==="darwin")}),qY=nin(da==="darwin"?"mac":da==="win32"?"win":"linux",!Y),l5=$.useRef(null),_Xe=V=>{d&&(l5.current=ie.findIndex(fe=>fe.id===V),ht(d,V))};$.useEffect(()=>{const V=l5.current;if(V===null)return;l5.current=null;const fe=document.querySelectorAll(i8e),Te=fe[Math.min(V,fe.length-1)];Te?Te.focus():tl()},[ie,tl]);const Xo=$.useMemo(()=>{const fe=eG(Pe,ie)!==""||$e.length>0,Te=X||S?.message&&efe.test(S.message)?[{get label(){return m("ui.chat.composer.connect_provider")},onClick:()=>aO.getState().openConnect()}]:[];return{message:S?.message,muted:S?.muted===!0,polite:S?.polite===!0,actions:[...S?.actions??[],...Te],retry:S?.retry===!0,clear:S?.muted!==!0&&(S?.onClear!==void 0||fe)}},[S,Pe,ie,$e,X]),rh=Q6t(),jY=T("block text-body-sm",A?"px-2 pb-1":"px-4 pb-2",Ui!==null?"text-warning":"text-ink-muted"),c5=T("flex flex-wrap items-center gap-2 text-body-sm text-ink-muted",A?"px-2 pb-1":"px-4 pb-2"),CY=gn&&Pe.length>0,PXe=f.jsx("output",{className:T($r,"block pb-2",rh.issue.kind==="hidden"&&"hidden"),children:f.jsx(Uon,{issue:rh.issue,onSignIn:rh.start,onCancel:rh.cancel,onDismiss:rh.dismiss,isSmallView:A,onFocusComposer:()=>Ht.current?.focus()})}),pg=DEe(L),TXe=pg&&!VEe(pg,MEe(rh.issue))?f.jsx("output",{className:T($r,"block pb-2"),children:f.jsx(Jrn,{access:pg,isSmallView:A,onSwitchModel:L?.onCommand?()=>L.onCommand?.({name:"model",args:""}):void 0,onConnect:()=>aO.getState().openConnect({providerId:pg.provider})})}):null,zY=Je||!Se&&!Be&&!(t&&p),u5=Se?"recording":Be?"transcribing":Je?"preparing":"idle",XXe=Pe.trim()!==""||$e.length>0,ih=Qrn(u5,_t),O5=krn(u5),jr=Srn({dictation:u5,alive:!!Q?.active,stopping:Q?.stopping===!0,hasPayload:XXe,refused:wt||hg,sendBusy:IO,sendRecording:_t,reviewRequired:Wa(wi)}),RXe=jr.role==="stop-busy"?"stop":jr.role,{ignore:EXe,arming:qXe}=fj(O5??"none"),{ignore:jXe,arming:CXe}=fj(ih),{ignore:AY,arming:UY}=fj(RXe),Sb=$.useRef(!1),zXe=`${ih}|${jr.role}|${O5}`;$.useEffect(()=>{if(!Sb.current)return;const V=document.activeElement;V&&V!==document.body||(Sb.current=!1,Ht.current?.focus({preventScroll:!0}))},[zXe]);const AXe=f.jsxs("form",{onSubmit:$Xe,"data-chat-region":"composer","aria-label":due("composer"),tabIndex:-1,className:"w-full",children:[f.jsx(oG,{fallback:null,children:f.jsx(xrn,{frontend:L?.frontend,askFrontend:L?.asks,runDetails:_e,isSmallView:A,askExpanded:I,onAskToggle:Z,askOutcomes:U,onNote:Oe,onFocusComposer:()=>Ht.current?.focus()},d)}),!LEe(pg)&&PXe,TXe,a,o?.blocksInput&&o.placeholder&&!o.statedByNode&&Pe.trim().length>0?f.jsx("p",{id:Ple,className:"mb-2 text-meta text-ink-muted",children:o.placeholder}):null,o?.node,Xo.message!==void 0&&f.jsxs("div",{role:Xo.polite?"status":"alert","data-composer-notice":!0,"data-composer-queued":S?.message===HEe.queuedSend?!0:void 0,className:T($r,"flex flex-wrap items-center gap-x-3 gap-y-1 text-body-sm",A?"px-2 pb-1":"px-4 pb-2"),children:[f.jsxs("p",{className:T("flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",Xo.muted?"text-ink-muted":"text-danger"),children:[!Xo.muted&&f.jsx("span",{className:"flex shrink-0 items-center pt-0.5",children:f.jsx(uO,{size:14,"aria-hidden":"true"})}),f.jsx("span",{className:T("min-w-0 break-words",!Xo.muted&&"font-medium"),children:Xo.message})]}),(Xo.retry||Xo.clear||Xo.actions.length>0)&&f.jsxs(f.Fragment,{children:[Xo.actions.map(V=>f.jsx(Qe,{type:"button",variant:"link",size:"sm",className:T("min-h-6 cursor-pointer text-body-sm underline"),onClick:V.onClick,children:V.label},V.label)),Xo.retry&&S?.onRetry&&f.jsx(Qe,{type:"button",variant:"link",size:"sm",className:T("min-h-6 cursor-pointer font-semibold text-body-sm underline"),onClick:()=>S.onRetry?.(),children:FEe()}),Xo.clear&&S?.onClear&&f.jsx(Qe,{type:"button",variant:"link",size:"sm","aria-label":m("ui.chat.composer.clear_message"),className:T("min-h-6 cursor-pointer text-ink-dim text-body-sm underline"),onClick:()=>S.onClear?.(),children:BEe()})]})]}),w&&f.jsx("output",{className:T($r,"block text-body-sm text-ink-muted",A?"px-2 pb-1":"px-4 pb-2"),children:w}),c&&Ee!==null&&f.jsx(San,{sessionId:c,sessionStreaming:u,adoptQueueSupported:O,isSmallView:A,onReturnFocus:()=>Ht.current?.focus()}),k?f.jsx("div",{className:T($r,A?"px-2 pb-2":"px-4 pb-2"),children:k}):null,f.jsxs("div",{className:T($r,"relative w-full"),children:[f.jsx(rln,{state:ot,onPick:KP,onActionPick:HP}),f.jsx(yon,{state:Xa,onPick:yY}),f.jsx(isn,{state:Hr,onPick:JP}),!Y&&!ot.open&&!Xa.open&&!Hr.open&&f.jsx(rzt,{visible:v,onClick:x,hasNewActivity:b}),f.jsx("output",{id:xle,className:T($r,s5?jY:"hidden"),children:s5}),CY&&f.jsx("output",{id:Sle,className:T($r,jY),children:m("ui.chat.composer.secret_closure_notice")}),l&&Qt===null&&f.jsxs("output",{id:Qle,className:T(c5,$r),children:[f.jsx("span",{className:"min-w-0",children:m("ui.chat.composer.secret_ask_notice")}),f.jsx(Qe,{type:"button",size:"sm",variant:"secondary","data-lo-ask-item-toggle":"",onClick:()=>l.onOpen(),children:m("ui.chat.composer.secret_ask_open")})]}),mb!==null&&Qt===null&&f.jsx("output",{id:mln,className:T(c5,$r),children:f.jsx("span",{className:"min-w-0",children:mb})}),Qt!==null&&f.jsxs("fieldset",{ref:gb,tabIndex:-1,id:gln,"aria-labelledby":kle,"aria-busy":Vn,onKeyDown:V=>{V.key==="Escape"&&(V.preventDefault(),!Vn&&yb())},className:T("m-0 min-w-0 border-0 p-0",c5,$r),children:[f.jsxs("span",{id:kle,className:"min-w-0",children:[Vn?m("ui.chat.composer.secret_confirm_sending"):m("ui.chat.composer.secret_confirm_message"),f.jsx("span",{className:T("whitespace-nowrap",Vn&&"invisible"),"aria-hidden":Vn||void 0,children:` ${m("ui.chat.composer.secret_confirm_chars",{count:Qt.value.length})}`})]}),f.jsx(Qe,{ref:pY,type:"button",size:"sm",disabled:Vn,onClick:oXe,children:l?.fillable?m("ui.chat.composer.secret_confirm_put"):m("ui.chat.composer.secret_confirm_put_multi")}),f.jsx(Qe,{type:"button",size:"sm",variant:"secondary",disabled:Vn,onClick:sXe,children:m("ui.chat.composer.secret_confirm_send")}),f.jsx(Qe,{type:"button",size:"sm",variant:"ghost",disabled:Vn,onClick:yb,children:m("ui.chat.composer.secret_confirm_cancel")})]}),Hl>0&&f.jsx("span",{id:_le,className:"sr-only",children:Hl===1?"1 reference points outside this session's working directory; the agent will ask you to approve it before reading.":`${Hl} references point outside this session's working directory; the agent will ask you to approve them before reading.`}),i&&f.jsx("span",{id:Tle,className:"sr-only",children:m("ui.chat.composer.delivery_remedies_hint")}),f.jsxs("div",{"data-glass-region":"composer",className:T(kln,EY?void 0:_ln,A?"gap-2 rounded-md p-2":"gap-3 rounded-frame p-4",$r,EY&&"outline-dashed outline-2 outline-accent outline-offset-2"),"data-lo-composer-measure":"","data-tour-tag":"chat-input-textarea",children:[(ie.length>0||$e.length>0)&&f.jsxs("div",{className:"max-h-[240px] shrink-0 overflow-y-auto",children:[ie.length>0&&f.jsx(vW,{replies:ie,onRemoveReply:_Xe}),$e.length>0&&f.jsx(yGe,{attachments:$e,onRemoveAttachment:yXe,disabled:wt||Se||Be,byteSizes:ue})]}),f.jsxs("div",{className:"relative isolate w-full",children:[f.jsx(Ain,{text:Pe,payloads:Si.current,capture:wi,held:GO(Pe,wi),fieldRef:Ht,mirrorRef:mu,isSmallView:A}),f.jsx(ton,{text:Pe,spans:el.spans,resolved:el.resolved,fieldRef:Ht,isSmallView:A}),f.jsx(kon,{draft:Pe,runs:_r,textareaRef:Ht,fieldClassName:lk(A),refused:wt,children:f.jsx("textarea",{ref:Ht,"data-region-entry":!0,className:T(lk(A),"block",A?"max-h-24":"max-h-28","resize-none overflow-y-auto bg-transparent",sn?"text-transparent caret-ink":"text-ink","outline-none placeholder:text-ink-dim",o?.blocksInput?"read-only:text-ink-muted read-only:placeholder:text-ink-muted disabled:text-ink-disabled disabled:placeholder:text-ink-disabled":"read-only:text-ink-disabled read-only:placeholder:text-ink-disabled disabled:text-ink-disabled disabled:placeholder:text-ink-disabled"),placeholder:Se?m(Qs.recording):lNe({unavailable:H,secretAnswer:gn,inputDisabled:wt,awaitingAnswer:r,asideAttached:Ee!==null,sendingUnsettled:Jf||th,awaitingReply:n,stopping:Q?.stopping===!0,noProvider:X,idle:Xe,hostLine:o?.placeholder??null}),value:Pe,onCompositionStart:()=>cg(!0),onCompositionEnd:()=>cg(!1),onChange:V=>{Hf.current=!0;const fe=V.target.value,Te=V.target.selectionStart??fe.length;Bl.current=null;const Le=PTt(xi.current,Pe,fe,Te,"typing");Le.buffer!==fe?(kr.current=Le.caret,Qi(Le.caret)):Qi(Te),Le.capture!==xi.current&&To(Le.capture),!Pe&&Le.buffer&&y?.(),ps.current=Le.buffer,gu(Le.capture,Le.buffer),Dn(Le.buffer),Date.now()-Rn.current>=yln&&S?.onDismiss?.()},onSelect:V=>{const fe=V.target,Te=kr.current;if(Te!==null){fe.selectionStart===Te&&(kr.current=null);return}Qi(fe.selectionStart),To(Bh(xi.current,Pe,fe.selectionStart,"caret"))},onKeyDown:cXe,onPointerDown:()=>{n9=!0},onPaste:bXe,rows:1,readOnly:wt,"aria-disabled":wt||void 0,"aria-label":m("ui.chat.composer.message"),role:"combobox","aria-describedby":[o?o.id:null,o?.blocksInput&&o.placeholder&&!o.statedByNode&&Pe.trim().length>0?Ple:null,s5?xle:null,CY?Sle:null,l&&Qt===null?Qle:null,Hl>0?_le:null,H?cQe:null,i?Tle:null].filter(Boolean).join(" ")||void 0,"aria-expanded":ot.open||Xa.open,"aria-controls":ot.open?ot.listId:Xa.open?Xa.listId:void 0,"aria-activedescendant":(ot.open?ot.activeDescendantId:Xa.activeDescendantId)??void 0})}),f.jsx(jin,{small:A,text:Pe,payloads:Si.current,capture:wi,mirrorRef:mu,fieldRef:Ht,onClear:wt?null:dXe,onControlUnmounted:tl})]}),(Se||Je&&zY)&&f.jsx(zde,{isRecording:Se,preparingLabel:!Se&&Je?A?m("ui.chat.composer.starting"):m("ui.chat.composer.starting_recording"):null,sendsNow:jr.role==="send-recording"&&jr.enabled}),Be&&f.jsxs("div",{"data-transcribing-indicator":"",className:"mt-1 flex items-center gap-2 px-2 [min-height:1.5rem]",children:[f.jsx("span",{className:"font-medium text-body-sm text-ink-muted",children:m("ui.chat.composer.processing_audio")}),_t==="idle"&&f.jsx(nXe,{})]}),ze!==null&&!Be&&Ae!==null&&f.jsxs("div",{"data-dictation-retry":"",className:"mt-1 flex items-center gap-2 px-2 [min-height:1.5rem]",children:[f.jsx(uO,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"}),f.jsx("span",{className:"font-medium text-body-sm text-ink-muted",children:ze}),f.jsx(Qe,{type:"button",variant:"link",size:"sm",className:"h-7 shrink-0 px-2 underline",onClick:gXe,children:m("ui.common.actions.retry")})]}),f.jsxs("div",{className:"flex min-w-0 flex-nowrap items-center gap-x-2",children:[L&&f.jsx(oG,{fallback:null,children:f.jsx(fIe,{frontend:L.frontend,onCommand:L.onCommand,effortEntities:L.effortEntities,draft:L.draft,onOpenDraftPicker:L.onOpenDraftPicker,draftResolution:L.draftResolution,held:L.held,contextHeld:L.contextHeld,readingsDropped:L.readingsDropped,pendingModel:L.pendingModel,costChannels:L.costChannels,controlsThirdBox:fXe})}),f.jsxs("div",{className:"contents",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-1 shrink-0",children:[f.jsx(vt,{content:m("ui.chat.composer.attach_file"),children:f.jsx("span",{children:f.jsx(Qe,{variant:"ghost",size:A?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:a5,onClick:vXe,"aria-label":m("ui.chat.composer.attach_file"),"data-tour-tag":"chat-input-attach-file-button",disabled:wt||Se||Be,children:f.jsx(q6e,{"aria-hidden":"true"})})})}),dt!==void 0&&f.jsx(qon,{ref:vY,currentWorkingDirectory:dt,writePath:C,pending:W,pendingAccepted:G,readOnlyReason:C?void 0:z??w2e})]}),f.jsxs("div",{"data-lo-composer-controls":!0,onFocus:()=>{Sb.current=!0},onBlur:V=>{V.target.isConnected&&(Sb.current=!1)},className:"ms-auto flex order-3 shrink-0 items-center gap-1",children:[O5==="confirm"&&f.jsx(vt,{content:m("ui.chat.composer.insert_transcript_hint"),children:f.jsx("span",{children:f.jsx(Qe,{"data-composer-slot":"c",variant:"outline",size:A?"icon-sm":"icon",type:"button",className:T("border-success-border bg-success-wash text-success hover:bg-success-wash",CXe&&"opacity-72"),onClick:V=>{jXe(V.detail)||n5()},"aria-label":m("ui.chat.composer.insert_transcript"),children:f.jsx(sa,{"aria-hidden":"true"})})})},"confirm"),(ih==="mic"||ih==="mic-preparing")&&zY&&f.jsx(vt,{content:f.jsx(Oin,{text:Je?m("ui.chat.composer.starting_recording"):zi?qY===null?m("ui.chat.composer.start_recording"):m("ui.chat.composer.start_recording_hint",{shortcut:Uqe(qY),pushToTalk:Hz().label}):Po}),children:f.jsx("span",{children:f.jsx(Qe,{"data-composer-slot":"a",variant:"ghost",size:A?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:a5,onClick:_Y,"aria-label":m("ui.chat.composer.start_recording"),"aria-busy":Je||void 0,disabled:wt||!zi,children:Je?f.jsx(Sa,{size:"sm"}):f.jsx(m6e,{"aria-hidden":"true"})})})},"mic"),ih==="spinner"&&f.jsx(Qe,{"data-composer-slot":"a",variant:"ghost",size:A?"icon-sm":"icon",type:"button",className:"text-ink-dim","aria-busy":!0,"aria-disabled":!0,"aria-label":m("ui.chat.composer.processing_audio"),onClick:V=>V.preventDefault(),children:f.jsx(Sa,{size:"sm"})},"spinner"),ih==="cancel"&&f.jsx(vt,{content:m("ui.chat.composer.cancel_recording_hint"),children:f.jsx("span",{children:f.jsx(Qe,{"data-composer-slot":"a",variant:"outline",size:A?"icon-sm":"icon",type:"button",className:T("text-danger hover:bg-danger-wash hover:text-danger focus-visible:bg-danger-wash",qXe&&"opacity-72"),onClick:V=>{EXe(V.detail)||r5()},"aria-label":m("ui.chat.composer.cancel_recording"),children:f.jsx(oi,{"aria-hidden":"true"})})})},"cancel"),(jr.role==="send-recording"||jr.role==="send-recording-busy")&&f.jsx(vt,{content:m("ui.chat.composer.send_recording_hint"),children:f.jsx("span",{children:f.jsx(Qe,{"data-composer-slot":"b",variant:"primary",size:A?"icon-sm":"icon",type:"button",className:T("rounded-full disabled:bg-surface",(jr.role==="send-recording-busy"||UY)&&"opacity-72"),"aria-busy":jr.role==="send-recording-busy"||void 0,"aria-disabled":jr.role==="send-recording-busy"||void 0,onPointerDown:RY,onClick:V=>{jr.role!=="send-recording-busy"&&(AY(V.detail)||mXe())},disabled:!jr.enabled&&jr.role!=="send-recording-busy","aria-label":Ee!==null&&!r?m("ui.chat.composer.ask_aside"):m("ui.chat.composer.send_recording"),children:f.jsx(jx,{"aria-hidden":"true"})})})},"send-recording"),jr.role==="connecting"&&f.jsx(Qe,{"data-composer-slot":"b",variant:"secondary",size:A?"icon-sm":"icon",type:"button",className:"rounded-full","aria-busy":!0,"aria-disabled":!0,"aria-label":m("ui.chat.composer.placeholder.sending"),onClick:V=>V.preventDefault(),children:f.jsx(Sa,{size:"sm"})},"connecting"),(jr.role==="stop"||jr.role==="stop-busy")&&Q&&f.jsx(vt,{content:m("ui.chat.composer.stop_work_hint"),children:f.jsx("span",{children:f.jsx(Qe,{"data-composer-slot":"b",variant:"danger",size:A?"icon-sm":"icon",type:"button",onClick:V=>{jr.role!=="stop-busy"&&(AY(V.detail)||Q.onStop())},"aria-label":m("ui.chat.composer.stop"),"aria-keyshortcuts":"Escape","data-stopping":Q.stopping===!0?"true":void 0,"aria-busy":Q.stopping===!0?!0:void 0,className:T("data-[stopping]:border-danger data-[stopping]:text-ink data-[stopping]:bg-[color-mix(in_oklab,var(--color-danger-wash)_80%,var(--color-danger))]",UY&&"opacity-72"),children:f.jsx(Cj,{"aria-hidden":"true"})})})},"stop"),t&&p&&f.jsx(vt,{content:m("ui.chat.composer.stop_agent"),children:f.jsx("span",{children:f.jsx(Qe,{variant:"danger",size:A?"icon-sm":"icon",type:"button",onClick:()=>g?.(p),"aria-label":m("ui.chat.composer.stop_agent"),children:f.jsx(Cj,{"aria-hidden":"true"})})})}),(jr.role==="send"||jr.role==="steer")&&!(t&&p)&&f.jsx(vt,{content:Ee!==null&&!r?m("ui.chat.composer.ask_aside"):jr.role==="steer"?m("ui.chat.composer.steer_hint"):m("ui.chat.composer.send_message"),children:f.jsx("span",{children:f.jsx(Qe,{"data-composer-slot":"b",variant:"primary",size:A?"icon-sm":"icon",type:"submit",onPointerDown:RY,disabled:!jr.enabled,className:"rounded-full disabled:bg-surface","aria-label":Ee!==null&&!r?m("ui.chat.composer.ask_aside"):m("ui.chat.composer.send_message"),children:f.jsx(jx,{"aria-hidden":"true"})})})},jr.role)]})]})]})]})]}),X&&!fs?f.jsx("div",{className:T("mt-2",$r),children:f.jsx(fan,{})}):null,(X||E)&&kn?f.jsx("div",{className:T("mt-2",$r),children:f.jsx("output",{className:"block text-body-sm text-ink-muted",children:E?"Choose a model for this conversation before sending.":"Connect a provider to send."})}):null]});return f.jsxs("div",{className:T(Ode,"flex w-full flex-col items-center",Ai?"grow":"shrink-0",D?void 0:ZYe,A?"pb-1 pt-0.5":"pb-4 pt-2"),"data-lo-composer-band":!0,ref:rg,onDragOver:wXe,onDragLeave:xXe,onDrop:SXe,children:[f.jsx("div",{"data-lo-composer-splash":"",className:T("flex w-full flex-col items-center justify-center",Ai?"grow":null),children:f.jsx("div",{ref:If,className:T(hb?"flex w-full flex-col items-center gap-6 py-4":"hidden"),children:hb?f.jsxs(f.Fragment,{children:[f.jsx("span",{"data-lo-empty-mark":"",className:"contents",children:f.jsx(hln,{className:"size-8",tone:"ink-muted"})}),X?null:f.jsx("h2",{className:"text-center text-ink text-title",children:m("ui.chat.composer.welcome")}),X?f.jsx("div",{className:T("w-full",$r),children:f.jsx(dan,{})}):f.jsxs("div",{className:T("flex flex-col gap-3",$r),children:[f.jsx(Con,{band:Bs,splash:Hs,foot:Df,suggestions:ab,disabled:hXe,onRefusedPress:a5,onSelect:kXe,focusComposer:()=>Ht.current?.focus()}),f.jsx(Ein,{suspended:Pe.trim().length>0,mentionsEnabled:se})]})]}):null})}),fs?f.jsx("div",{className:T("mb-2 mt-2",$r),children:f.jsx(Oan,{selection:tg})}):null,f.jsx("div",{ref:Gr,"data-lo-composer-foot":"",className:"w-full",children:AXe})]})});function jle(e){e.style.height="auto",e.style.height=`${Math.ceil(e.scrollHeight)}px`,e.style.overflowY=e.scrollHeight<=e.clientHeight+1?"hidden":""}const Tln=$.memo(Pln);Tln.displayName="MessageInput";const fY=1024,Sx=1024*1024,VP=.85,Xln=new Set(["image/png","image/jpeg","image/webp"]),Rln=[{maxEdge:fY,quality:.8},{maxEdge:768,quality:.7},{maxEdge:512,quality:.6}];function Eln(e){const t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}function qln(e){const t=Uint8Array.fromBase64;if(typeof t=="function")return t.call(Uint8Array,e);const n=atob(e),r=new Uint8Array(n.length);for(let i=0;i<n.length;i+=1)r[i]=n.charCodeAt(i);return r}function Cle(e){const t=e.toBase64;if(typeof t=="function")return t.call(e);let n="";const r=32768;for(let i=0;i<e.length;i+=r)n+=String.fromCharCode(...e.subarray(i,i+r));return btoa(n)}async function jln(e,t,n,r,i,a=!1){const o=Math.max(e.width,e.height),s=o>r?r/o:1,l=Math.max(1,Math.round(e.width*s)),c=Math.max(1,Math.round(e.height*s)),u=new OffscreenCanvas(l,c),O=u.getContext("2d");if(!O)return null;O.drawImage(e,0,0,l,c);const d=[],h=await u.convertToBlob({type:"image/png"}),p=new Uint8Array(await h.arrayBuffer());if(p.byteLength<=Sx&&d.push({bytes:p,mime_type:"image/png"}),p.byteLength>Sx||i<VP){const v=new OffscreenCanvas(l,c),b=v.getContext("2d");if(!b)return null;b.fillStyle="#ffffff",b.fillRect(0,0,l,c),b.drawImage(e,0,0,l,c);const x=await v.convertToBlob({type:"image/jpeg",quality:i}),Q=new Uint8Array(await x.arrayBuffer());d.push({bytes:Q,mime_type:"image/jpeg"}),p.byteLength>Sx&&Q.byteLength>p.byteLength&&d.push({bytes:p,mime_type:"image/png"})}let g=null,y=Number.POSITIVE_INFINITY;for(const v of d)v.bytes.byteLength<y&&(g=v,y=v.bytes.byteLength);return g?a&&s<1?{data_b64:Cle(g.bytes),mime_type:g.mime_type}:y>=n?t:{data_b64:Cle(g.bytes),mime_type:g.mime_type,...t.origin_path?{origin_path:t.origin_path}:{}}:null}async function ypn(e,t=fY,n=VP,r={}){const i=await iXe(e);if(!i)return e;try{return await aXe(e,i,t,n,r.edgeIsHard??!1)}finally{i.close()}}async function iXe(e){if(!Xln.has(e.mime_type)||typeof createImageBitmap!="function"||typeof OffscreenCanvas!="function")return null;try{return await createImageBitmap(new Blob([qln(e.data_b64)],{type:e.mime_type}))}catch{return null}}async function aXe(e,t,n,r,i=!1){const a=Eln(e.data_b64);try{return Math.max(t.width,t.height)<=n&&a<=Sx&&r>=VP?e:await jln(t,e,a,n,r,i)??e}catch{return e}}async function Cln(e,t,n){if(!e.length)return e;const r=await Promise.all(e.map(i=>iXe(i)));try{return await zln(e,r,t,n)}finally{for(const i of r)i?.close()}}async function zln(e,t,n,r){const i=(c,u)=>Promise.all(e.map((O,d)=>{const h=t[d];return h?aXe(O,h,c,u):Promise.resolve(O)})),a=await i(fY,VP);if(r(a)<=n)return a;let o=e,s=r(e);const l=c=>{const u=r(c);return u<s&&(o=c,s=u),u};l(a);for(const c of Rln){const u=await i(c.maxEdge,c.quality);if(l(u)<=n)return u}return o}const zle=/^data:(image\/(png|jpeg|gif|webp));base64,(.+)$/,Aln=/^file:\/\//,Ale={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp"},wj=e=>e.replace(Aln,"");async function vpn(e,t,n){const r=[],i=[],a=[],o=e.filter(u=>{if(zle.test(u))return!1;const O=u.split(".").pop()?.toLowerCase()??"";return!Ale[O]}),s=Math.max(0,o.length-Qj),l=s===0;for(const u of e){const O=zle.exec(u);if(O){r.push({data_b64:O[3],mime_type:O[1]});continue}const d=u.split(".").pop()?.toLowerCase()??"",h=Ale[d];if(h){if(!window.api?.readFile){a.push({name:jd(u),kind:"read"});continue}const x=await window.api.readFile(wj(u),"base64");x.success?r.push({data_b64:x.data,mime_type:h,...u.startsWith("data:")?{}:{origin_path:wj(u)}}):a.push({name:jd(u),kind:"read"});continue}const p=jd(u);if(n?.remoteOwned){a.push({name:p,kind:"remote"});continue}if(!l)continue;const g=window.api?.uploadAttachment;if(!g){a.push({name:p,kind:"upload",detail:"this window cannot upload files"});continue}const y=u.startsWith("data:")?{kind:"dataUrl",dataUrl:u,name:p}:{kind:"path",path:wj(u),name:p},v=await g(y);if(!v.success){a.push({name:p,kind:"upload",detail:v.error});continue}const b=v.attachment;i.push({digest:b.digest,name:b.name??p,mime_type:b.mime_type,bytes:b.bytes,...b.path?{path:b.path}:{}})}const c=Math.max(0,r.length-kj);return{images:await Cln(r.slice(0,kj),hk,u=>a3(t,u)),files:i.slice(0,Qj),failures:a,overflow:c,fileOverflow:s}}const Uln=/\.+$/,Ule=e=>typeof e=="string"?jd(e):e.name,Wln=e=>e?.trim().replace(Uln,"")??"",Nln=e=>`${e} could not be read (it may have been moved or deleted)`,Yln=(e,t)=>{const n=Wln(t);return n?`${e} could not be attached (${n})`:`${e} could not be attached`},Gln=e=>`${e} cannot be attached because this conversation is owned by another device, and files are only attachable to conversations on this one`;function bpn(e){if(e.length===0)return null;const t=e.map(Ule),n=e.length>0&&e.every(o=>typeof o!="string"&&o.kind==="remote");if(e.every(o=>typeof o=="string"||o.kind==="read"))return t.length===1?`${t[0]} could not be read (it may have been moved or deleted), so this message was not sent. Attach it again, or remove it from the draft.`:`${t.join(", ")} could not be read (they may have been moved or deleted), so this message was not sent. Attach them again, or remove them from the draft.`;if(n)return`${t.length===1?`${t[0]} cannot be attached`:`${t.join(", ")} cannot be attached`} because this conversation is owned by another device, and files are only attachable to conversations on this one. Send the message without ${t.length===1?"it":"them"}, or start the conversation here.`;const i=e.map(o=>typeof o=="string"||o.kind==="read"?Nln(Ule(o)):o.kind==="remote"?Gln(o.name):Yln(o.name,o.detail)),a=t.length===1?"it":"them";return`${i.join("; ")}, so this message was not sent. Attach ${a} again, or remove ${a} from the draft.`}function wpn(e){if(e<=0)return null;const t=kj,n=t+e;return e===1?`This draft carries ${n} images and one message carries up to ${t}, so this message was not sent. Remove the extra image, or send it in a second message.`:`This draft carries ${n} images and one message carries up to ${t}, so this message was not sent. Remove ${e} of them, or send them in a second message.`}function xpn(e){if(e<=0)return null;const t=Qj,n=t+e;return e===1?`This draft carries ${n} files and one message carries up to ${t}, so this message was not sent. Remove the extra file, or send it in a second message.`:`This draft carries ${n} files and one message carries up to ${t}, so this message was not sent. Remove ${e} of them, or send them in a second message.`}function Spn(e){const t=e.trim();if(t.startsWith("="))return null;const n=t.toLowerCase();return n==="pause"||n==="resume"||n==="status"?n:null}function Qpn(e){const t=e.trim();return t.startsWith("=")?t.slice(1).trimStart():t}function kpn(e,t){return e==="pause"?{text:"Aida is paused. She will not check in until you resume her.",kind:"success"}:e==="resume"?{text:"Aida is resumed. She will check in on her usual schedule.",kind:"success"}:{kind:"info",text:t.paused?"Aida is paused.":"Aida is active."}}function Zln(e){return Ns(e,m("ui.notices.aida.unreachable"))}const _pn="The chief of staff is switched off on this install.",Iln="aida_no_provider",Dln="aida_disabled";function Ppn(e,t){const n=e instanceof Zn?e.code:void 0;return n===Dln?null:n===Iln?{kind:"info",text:`${t} will say hello once an AI account is connected. Connect one from the chat to start.`}:{kind:"error",text:`${t}'s conversation could not be opened, so you are in a new chat instead. ${Zln(e)}`}}function Tpn(e,t){if(e.held===!0)return`${t} is already open in another window, so she will say hello there.`;const n=e.greeting_state==="delivered"||e.greeting_state==="skipped"||e.greeting_state==null&&e.greeted===!0;return e.paused&&!n?`${t} is paused, so she will say hello when you resume her: type /aida resume.`:null}function Xpn(e){const t=e?.greeting_state;return t==null||t==="owed"}function Vln(e){return e.eventKey===e.storeKey&&!e.focused}let Wle=!1;function Rpn(){if(Wle)return;Wle=!0;const e=Mn.persist?.getOptions?.()?.name??"conversation-input-store",t=n=>{Vln({eventKey:n.key,storeKey:e,focused:document.hasFocus()})&&Mn.persist?.rehydrate?.()?.catch?.(()=>{})};window.addEventListener("storage",t)}export{Rue as $,Or as A,mn as B,_f as C,u_ as D,lt as E,Ev as F,Er as G,Sr as H,Nr as I,ts as J,L8 as K,Qn as L,Fx as M,ua as N,In as O,X8 as P,Jn as Q,us as R,xk as S,Ocn as T,tcn as U,dcn as V,Dd as W,z9 as X,uA as Y,L8e as Z,bOe as _,QSe as a,sr as a$,yk as a0,bk as a1,jj as a2,Ma as a3,WUe as a4,UUe as a5,Pk as a6,eWe as a7,XUe as a8,TUe as a9,OO as aA,Jo as aB,que as aC,U9e as aD,Rcn as aE,C9e as aF,Gcn as aG,Rr as aH,Ccn as aI,Ncn as aJ,W9e as aK,N9e as aL,Bcn as aM,Ij as aN,At as aO,Zj as aP,Run as aQ,Fcn as aR,zcn as aS,$y as aT,Zdn as aU,hfn as aV,R$ as aW,rN as aX,mN as aY,fhn as aZ,uc as a_,PUe as aa,Hj as ab,_Ue as ac,QOe as ad,hA as ae,ccn as af,Tcn as ag,Dcn as ah,Hcn as ai,K9 as aj,Lcn as ak,L9e as al,Vcn as am,I9e as an,jcn as ao,q9e as ap,Ecn as aq,qcn as ar,Xcn as as,Acn as at,Ucn as au,Wcn as av,iO as aw,Icn as ax,UG as ay,Zcn as az,Rc as b,tb as b$,pZe as b0,C$ as b1,hhn as b2,ZW as b3,yA as b4,c3 as b5,hv as b6,bf as b7,jWe as b8,_pn as b9,Gdn as bA,fl as bB,Gh as bC,WWe as bD,qi as bE,pA as bF,x6e as bG,Bce as bH,Va as bI,gYt as bJ,gN as bK,QPe as bL,Jv as bM,PPe as bN,Bhn as bO,mZt as bP,Tie as bQ,Pie as bR,VPe as bS,RN as bT,mP as bU,iGt as bV,rGt as bW,um as bX,nGt as bY,tGt as bZ,QQ as b_,vpn as ba,bpn as bb,wpn as bc,xpn as bd,Jun as be,tet as bf,xd as bg,sin as bh,Xm as bi,wd as bj,Tln as bk,uUe as bl,Qun as bm,_Xt as bn,icn as bo,ocn as bp,Rpn as bq,OOn as br,cOn as bs,PXt as bt,XXt as bu,acn as bv,LWe as bw,Rx as bx,uCe as by,vk as bz,Q_e as c,tue as c$,TN as c0,_N as c1,Td as c2,SQ as c3,j3e as c4,dv as c5,jh as c6,LCe as c7,$k as c8,G5 as c9,PG as cA,Gce as cB,hcn as cC,d6e as cD,I9 as cE,Kun as cF,Gze as cG,_cn as cH,Pce as cI,JK as cJ,h6e as cK,kp as cL,A9 as cM,C9 as cN,Ov as cO,X$ as cP,pCe as cQ,b6e as cR,G7e as cS,wk as cT,ZQe as cU,mQe as cV,$hn as cW,YX as cX,XW as cY,GX as cZ,nue as c_,yke as ca,SG as cb,YOe as cc,$r as cd,ZYe as ce,Ode as cf,Cj as cg,wOn as ch,Scn as ci,Qcn as cj,xcn as ck,k9e as cl,Pcn as cm,m9e as cn,DW as co,Qce as cp,E1 as cq,bOn as cr,SA as cs,WNe as ct,HOe as cu,yOn as cv,vOn as cw,N0 as cx,nCe as cy,ve as cz,or as d,Kdn as d$,Lce as d0,Mce as d1,hZ as d2,ncn as d3,S5 as d4,W0 as d5,Lze as d6,Zce as d7,KPt as d8,_A as d9,pJ as dA,Q3e as dB,vin as dC,ypn as dD,VP as dE,fY as dF,Z9 as dG,Eze as dH,Sk as dI,Oze as dJ,lue as dK,cin as dL,Q2e as dM,Jse as dN,hNe as dO,a8e as dP,zOe as dQ,nin as dR,Hz as dS,Uqe as dT,yGe as dU,m6e as dV,q6e as dW,XRt as dX,Ldn as dY,Jdn as dZ,Mdn as d_,Hc as da,rQ as db,Ede as dc,lf as dd,vQe as de,Xp as df,NNe as dg,z3e as dh,_3e as di,KKt as dj,oOn as dk,sOn as dl,Eqt as dm,dx as dn,CRt as dp,bW as dq,LSe as dr,NRt as ds,Xi as dt,uv as du,bfn as dv,l3 as dw,j$ as dx,Tfn as dy,Sfn as dz,Mhn as e,gfn as e$,Ddn as e0,UK as e1,y7t as e2,Zx as e3,kG as e4,nGe as e5,_O as e6,tGe as e7,PA as e8,K2t as e9,GWe as eA,_fn as eB,Rfn as eC,jd as eD,Wce as eE,Tke as eF,Vun as eG,$fn as eH,ARt as eI,afn as eJ,Qfn as eK,jRt as eL,kfn as eM,wfn as eN,dfn as eO,ofn as eP,tfn as eQ,V6 as eR,M6 as eS,Ofn as eT,nfn as eU,lfn as eV,vfn as eW,Fdn as eX,yfn as eY,mfn as eZ,ffn as e_,kk as ea,pv as eb,gue as ec,E$ as ed,_p as ee,Pp as ef,L9 as eg,Ffe as eh,Dk as ei,Nfe as ej,HRt as ek,Efn as el,Pfn as em,Xfn as en,qRt as eo,BSe as ep,zRt as eq,xfn as er,pfn as es,Idn as et,D6 as eu,L_ as ev,RRt as ew,Vdn as ex,TRt as ey,Kln as ez,Ls as f,Lfn as f$,Aqt as f0,ufn as f1,ZSe as f2,sfn as f3,MO as f4,Zun as f5,XWe as f6,Sc as f7,HKt as f8,qP as f9,lpn as fA,mc as fB,cpn as fC,lsn as fD,e_e as fE,Hce as fF,lW as fG,Vrn as fH,xO as fI,Kfn as fJ,L3e as fK,V4t as fL,rhn as fM,Mfn as fN,Ifn as fO,Yi as fP,Yfn as fQ,_ke as fR,Dfn as fS,D7t as fT,ihn as fU,Jfn as fV,ehn as fW,nhn as fX,thn as fY,Z7t as fZ,I7t as f_,jP as fa,vFt as fb,RP as fc,NOe as fd,rcn as fe,H7t as ff,K7t as fg,eC as fh,uWe as fi,sue as fj,KWe as fk,Pke as fl,Fke as fm,$Rt as fn,vf as fo,gW as fp,py as fq,g3t as fr,$3t as fs,eke as ft,mx as fu,o3e as fv,M_ as fw,szt as fx,$C as fy,osn as fz,Zhn as g,qce as g$,_ue as g0,V7t as g1,Bfn as g2,Zfn as g3,Gfn as g4,Vfn as g5,Ffn as g6,Hfn as g7,AOe as g8,lOn as g9,spn as gA,BWe as gB,tNe as gC,ghn as gD,Yd as gE,j_e as gF,lQ as gG,vQ as gH,Uie as gI,TYt as gJ,jy as gK,w8t as gL,x8t as gM,b8t as gN,v8t as gO,y8t as gP,$8t as gQ,g8t as gR,sP as gS,t8t as gT,e8t as gU,m8t as gV,p8t as gW,nze as gX,Wn as gY,Vz as gZ,jce as g_,Tqt as ga,qqt as gb,Cfn as gc,SJ as gd,bJ as ge,Oin as gf,MJt as gg,Ri as gh,rc as gi,iOn as gj,pCt as gk,pd as gl,p6t as gm,Udn as gn,kSe as go,_Se as gp,Wdn as gq,zdn as gr,kK as gs,Ndn as gt,PSe as gu,kXt as gv,Adn as gw,XSe as gx,kCe as gy,scn as gz,ene as h,MX as h$,eOn as h0,tOn as h1,HCe as h2,nOn as h3,rOn as h4,Yze as h5,FWe as h6,gWe as h7,uOn as h8,QKe as h9,LX as hA,sun as hB,gC as hC,ozt as hD,rzt as hE,lun as hF,Ux as hG,UAe as hH,uun as hI,Ozt as hJ,G3e as hK,Qp as hL,IW as hM,vee as hN,m0 as hO,eun as hP,Zue as hQ,L6e as hR,$un as hS,mun as hT,Vj as hU,gAe as hV,yAe as hW,b3e as hX,Jcn as hY,Gue as hZ,aun as h_,EKe as ha,GMe as hb,Y$ as hc,xKe as hd,wpe as he,ZUe as hf,IUe as hg,va as hh,o8e as hi,r3 as hj,gy as hk,aA as hl,wun as hm,vhn as hn,yhn as ho,VAe as hp,pun as hq,fun as hr,hun as hs,vun as ht,bun as hu,xAe as hv,iun as hw,nun as hx,oun as hy,Kcn as hz,Ihn as i,rS as i$,xun as i0,T6e as i1,H9e as i2,run as i3,gun as i4,Oun as i5,YAe as i6,yun as i7,QAe as i8,dun as i9,JGe as iA,Ade as iB,UOn as iC,j7e as iD,nZe as iE,qOn as iF,uZe as iG,WOn as iH,COn as iI,ZGe as iJ,zn as iK,zOn as iL,Ize as iM,_un as iN,Lj as iO,dzt as iP,e6t as iQ,Jk as iR,JOn as iS,LOn as iT,MJe as iU,Uet as iV,MOn as iW,x8 as iX,S8 as iY,w8 as iZ,zpe as i_,pzt as ia,Mj as ib,EAe as ic,l2e as id,Wfn as ie,bCt as ig,T3e as ih,iA as ii,s8e as ij,hln as ik,W7e as il,_ce as im,vCe as io,eue as ip,kce as iq,YGe as ir,IGe as is,VGe as it,XOn as iu,ROn as iv,EOn as iw,aZe as ix,AOn as iy,jOn as iz,Fhn as j,ldn as j$,b8 as j0,qpe as j1,KOn as j2,oA as j3,aOe as j4,y8e as j5,Epe as j6,LJe as j7,eet as j8,nS as j9,sM as jA,mo as jB,vc as jC,rme as jD,on as jE,jn as jF,Bd as jG,Fo as jH,idn as jI,ddn as jJ,su as jK,kdn as jL,ydn as jM,Pat as jN,hdn as jO,pdn as jP,sdn as jQ,vdn as jR,adn as jS,odn as jT,$dn as jU,wdn as jV,xdn as jW,Qdn as jX,_dn as jY,udn as jZ,Odn as j_,c_ as ja,xt as jb,bdn as jc,De as jd,Qge as je,eit as jf,$O as jg,Jrt as jh,Gn as ji,Ka as jj,ft as jk,kl as jl,Wt as jm,kf as jn,Di as jo,Wm as jp,br as jq,wn as jr,Pi as js,zc as jt,hw as ju,pS as jv,s_ as jw,RO as jx,fdn as jy,mi as jz,Dhn as k,xhn as k$,i_ as k0,cdn as k1,Rxe as k2,wSe as k3,hW as k4,Ydn as k5,jdn as k6,Mv as k7,gQe as k8,Exe as k9,GA as kA,k3 as kB,Mfe as kC,QDe as kD,lDe as kE,wDe as kF,YD as kG,WLe as kH,B7e as kI,Kce as kJ,fpn as kK,yj as kL,D2e as kM,hpn as kN,dpn as kO,csn as kP,upn as kQ,Opn as kR,SWe as kS,p$ as kT,mpn as kU,Jh as kV,Yhn as kW,mp as kX,Ghn as kY,fsn as kZ,N3e as k_,iW as ka,f3 as kb,zde as kc,nXe as kd,jx as ke,FIe as kf,sze as kg,lze as kh,xSe as ki,FOn as kj,Nk as kk,yfe as kl,vT as km,yFe as kn,$Fe as ko,$fe as kp,YOn as kq,Lfe as kr,Oa as ks,TO as kt,wv as ku,ZOn as kv,fDe as kw,qFe as kx,VKe as ky,Lx as kz,Lhn as l,oWe as l$,wcn as l0,Sue as l1,NZ as l2,mqt as l3,Nun as l4,wzt as l5,ycn as l6,ppn as l7,Fze as l8,gpn as l9,p_e as lA,P5 as lB,Rm as lC,gOn as lD,$On as lE,UNe as lF,eNe as lG,lhn as lH,chn as lI,uhn as lJ,K6e as lK,Vze as lL,_On as lM,p9e as lN,pjt as lO,Pun as lP,g8e as lQ,Tun as lR,G9e as lS,wOe as lT,i9e as lU,kun as lV,HGe as lW,opn as lX,TOn as lY,GYe as lZ,jOe as l_,bhn as la,i_e as lb,whn as lc,mcn as ld,E7e as le,$cn as lf,dsn as lg,gcn as lh,pcn as li,vcn as lj,r9e as lk,Qjt as ll,sW as lm,XJ as ln,kjt as lo,BOn as lp,nXt as lq,S7e as lr,zfn as ls,GQe as lt,gRt as lu,HOn as lv,X7e as lw,qon as lx,Afn as ly,E9t as lz,Vhn as m,aO as m$,Eun as m0,qun as m1,jun as m2,F8e as m3,Lun as m4,U3t as m5,rke as m6,Rrn as m7,w2e as m8,Hhn as m9,h9e as mA,tpn as mB,Xun as mC,Wun as mD,Uun as mE,Tk as mF,yOe as mG,I8e as mH,Aun as mI,dA as mJ,Cun as mK,zun as mL,apn as mM,jfn as mN,epn as mO,cfn as mP,c9e as mQ,efn as mR,Hdn as mS,Bdn as mT,wW as mU,ERt as mV,rfn as mW,ifn as mX,aOn as mY,yx as mZ,R6e as m_,Zf as ma,Spn as mb,kpn as mc,Zln as md,Qpn as me,Jhn as mf,S2e as mg,xOn as mh,kOn as mi,SOn as mj,QOn as mk,Hun as ml,O_e as mm,pqt as mn,Krn as mo,fUe as mp,WYe as mq,NYe as mr,POn as ms,tun as mt,cun as mu,mzt as mv,Khn as mw,$pn as mx,r8e as my,qfn as mz,xQ as n,ree as n$,Gun as n0,NUe as n1,Yun as n2,EWe as n3,Q6t as n4,Ake as n5,Ahn as n6,ahn as n7,shn as n8,Yke as n9,N9 as nA,P2e as nB,o_e as nC,o3 as nD,Xpn as nE,Tpn as nF,Ppn as nG,tin as nH,k2e as nI,Nfn as nJ,lY as nK,rpn as nL,Ohn as nM,V6t as nN,ipn as nO,uC as nP,Ske as nQ,Zke as nR,dhn as nS,npn as nT,vke as nU,bke as nV,Y7t as nW,dCt as nX,Mke as nY,Vke as nZ,Aqe as n_,Jc as na,ohn as nb,WOe as nc,Uke as nd,_hn as ne,Uhn as nf,Whn as ng,Phn as nh,Nhn as ni,S6t as nj,Uin as nk,qhn as nl,jhn as nm,E6t as nn,Qhn as no,Wzt as np,Shn as nq,khn as nr,zzt as ns,Xhn as nt,zhn as nu,Chn as nv,J_ as nw,Ehn as nx,Rhn as ny,Thn as nz,Ry as o,phn as o0,mhn as o1,$We as o2,yWe as o3,Iun as o4,bcn as o5,l9e as o6,Mcn as o7,Ycn as o8,Mun as o9,C7t as oa,ecn as ob,Fun as oc,U3e as od,Dun as oe,kcn as of,Sun as og,pNe as oh,Bun as oi,qm as oj,NOn as ok,o9e as ol,Ufn as om,eCt as on,hOn as oo,dOn as op,fOn as oq,xg as or,pOn as os,fcn as ot,RXt as ou,T1 as ov,mOn as ow,lcn as ox,VOn as oy,Cdn as oz,rm as p,X_e as q,Gs as r,sQ as s,oP as t,h8t as u,ml as v,nN as w,Tn as x,_ as y,Sn as z};
1045
+ `)?1:0,_n=xc(Pe,fe.start,fe.end+Kt,Te),$n=Te.endsWith('"')?_n.caret-1:_n.caret;kr.current=$n,Dn(_n.text),Qi($n),Xa.remember(V.path),Xa.close()},[Pe,pr,Xa,Dn,wt]),JP=$.useCallback(V=>{if(wt||!Hr.token)return;const fe=Won(Pe,Hr.token,V.name);Hr.close(),kr.current=fe.caret,Dn(fe.text),Qi(fe.caret)},[Pe,Hr,Dn,wt]),lXe=$.useCallback(V=>{const fe=Bl.current;return fe===null||!(V.metaKey||V.ctrlKey)||V.altKey||V.shiftKey||V.key.toLowerCase()!=="z"?!1:(Bl.current=null,kr.current=fe.caret,fe.plain>0&&Zr({chars:fe.plain,over:fe.text}),Dn(fe.text),Qi(fe.caret),!0)},[Zr,Dn]),cXe=$.useCallback(V=>{if(wt)return;if(pb(V)){V.preventDefault();return}if(V.key==="Escape"&&Qt!==null){if(V.preventDefault(),Vn)return;yb();return}if(OXe(V)){V.preventDefault();return}if(lXe(V)){V.preventDefault();return}if(gon(V,Xa,yY)){V.preventDefault();return}if(sln(V,ot,KP,$Y)){V.preventDefault();return}if(asn(V,Hr,JP)){V.preventDefault();return}if(Ee!==null&&V.key==="Escape"){V.preventDefault(),h3(c??"");return}if(Ee!==null&&OYe(V)){const Le=Ee.turns.at(-1),Kt=Le?vr.getState().streams[Le.asideId]:void 0;if(!Le||Ee.queued!==void 0||!nde(Kt,u,O))return;V.preventDefault();const _n=c??"",$n=Date.now(),mr=fYe(Xt.current,Le.asideId,$n);if(mr==="arm"){Xt.current={turnId:Le.asideId,at:$n},vr.getState().setAsideNotice(_n,DZ(bj));return}if(mr==="ignore")return;Xt.current=null,ede(_n).catch(()=>{});return}if(V.key==="Backspace"||V.key==="Delete"){const Le=Uan(pr,V.key==="Backspace"?"back":"forward",el.spans,el.resolved);if(Le&&!V.nativeEvent.isComposing){const Kt=xc(Pe,Le.start,Le.end,"");kr.current=Kt.caret,Qi(Kt.caret),Dn(Kt.text),V.preventDefault();return}}const fe=Ht.current,Te=Sln();if(Te&&OUe(V,{value:Pe,selectionStart:fe?.selectionStart??null,selectionEnd:fe?.selectionEnd??null})){Te.focus(),V.preventDefault();return}if(hg&&V.key==="Enter"&&!V.shiftKey&&!V.nativeEvent.isComposing){V.preventDefault(),vb();return}if(V.key==="Enter"&&!V.shiftKey&&!V.nativeEvent.isComposing){const Le=Ze(Pe,pr);if(Le.kind!=="send"){V.preventDefault(),ir(Le,Pe,pr);return}if($b(Pe)){V.preventDefault();return}}ZO(V)},[ot,KP,$Y,Hr,JP,$b,ZO,pb,Qt,yb,Ze,ir,Pe,pr,wt,Ee,c,u,O]),vY=$.useRef(null),tl=$.useCallback(V=>{n9=!1,Ht.current?.focus({preventScroll:V?.preventScroll===!0})},[Ht]),uXe=$.useCallback(()=>{dA(Pe)!==null&&Dn("")},[Pe,Dn]);$.useImperativeHandle(ge,()=>({focusInput:tl,openWorkingDirectoryMenu:()=>{vY.current?.openMenu()},submitNow:()=>{$b(Pe)||eh()},consumeApprovalAnswerDraft:uXe}));const bY=$.useCallback(()=>Ht.current,[Ht]);$.useEffect(()=>a8e(tl,bY),[tl,bY]);const nl=$.useRef(null),wY=$.useRef(Pe);$.useLayoutEffect(()=>{wY.current=Pe},[Pe]);const xY=$.useCallback(V=>{nl.current===V&&(nl.current=null,Si.current.delete(V.index))},[]),bb=$.useCallback(V=>{if(nl.current!==V)return!1;const fe=BTt({buffer:wY.current,cleared:V.cleared});return fe?(Si.current.set(V.index,V.payload),nl.current===V&&(nl.current=null),V.toastId!==null&&W0(V.toastId),Mi({capture:Bh(xi.current,fe.buffer,fe.caret,"arrival"),buffer:fe.buffer,caret:fe.caret}),fu(null),!0):!1},[Mi,fu]);$.useLayoutEffect(()=>{const V=nl.current;V!==null&&V.cleared.buffer!==Pe&&(V.toastId!==null&&W0(V.toastId),xY(V))},[Pe,xY]);const OXe=$.useCallback(V=>{const fe=nl.current;return fe===null||!(V.metaKey||V.ctrlKey)||V.altKey||V.shiftKey||V.key.toLowerCase()!=="z"?!1:(bb(fe),!0)},[bb]),SY=$.useCallback(V=>{bb(V)&&tl()},[tl,bb]),dXe=$.useCallback(V=>{if(wt)return;const fe=Si.current.get(V);if(!fe)return;const Te=FTt({buffer:Pe,payload:fe});if(!Te.cleared)return;const Le=nl.current;Le&&(nl.current=null,Si.current.delete(Le.index),Le.toastId!==null&&W0(Le.toastId));const Kt={index:V,payload:fe,cleared:Te,toastId:null};nl.current=Kt,Mi({capture:Bh(xi.current,Te.buffer,Te.caret,"arrival"),buffer:Te.buffer,caret:Te.caret}),fu({key:fe.key,index:V,over:Te.buffer}),Kt.toastId=jh(MTt(V),{action:{label:VTt,onClick:()=>SY(Kt)}}),tl()},[Mi,tl,wt,Pe,fu,SY]),fXe=Se,hXe=wt||Se||Be||Pe.trim().length>0;$.useEffect(()=>{const V=Ht.current;V&&(V.style.height="auto",V.style.height=`${V.scrollHeight}px`)},[Pe,Ht,Se,Be,Je]);const e5=!!o?.blocksInput&&Pe==="",wb=$.useRef(null);$.useLayoutEffect(()=>{const V=Ht.current;if(!V||!e5){V&&wb.current!==null&&(V.style.overflowY=""),wb.current=null;return}wb.current!==V.placeholder&&(wb.current=V.placeholder,jle(V))}),$.useEffect(()=>{const V=Ht.current;if(!V||!e5||typeof ResizeObserver>"u")return;let fe=V.clientWidth;const Te=new ResizeObserver(()=>{V.clientWidth!==fe&&(fe=V.clientWidth,jle(V))});return Te.observe(V),()=>Te.disconnect()},[e5,Ht]);const QY=$.useRef(!1);$.useEffect(()=>{const V=Se||Be,fe=QY.current&&!V;if(QY.current=V,!F&&!fe||wt||V)return;const Te=document.activeElement;!(Te&&(Te.tagName==="INPUT"||Te.tagName==="TEXTAREA"||Te.getAttribute("role")==="tab"))&&!X&&Ht.current?.focus({preventScroll:!0})},[F,wt,Se,Be,Ht,X]),$.useEffect(()=>{window.electron.ipcRenderer.invoke("get-platform-info").then(V=>{Tt(V.platform)}).catch(V=>{console.error("Failed to get platform info:",V)})},[]);const gs=$.useRef(null),pXe=250,kY=$.useRef(xe);$.useEffect(()=>{kY.current=xe}),$.useEffect(()=>(Jse("message-input",Se||Je),()=>Jse("message-input",!1)),[Se,Je]),$.useEffect(()=>{kY.current?.(Se)},[Se]);const $s=$.useCallback(V=>{St(!1);const fe=Xn.current;if(!fe)return;const Te=gs.current?.startedAt??null,Le=Te===null?Number.POSITIVE_INFINITY:performance.now()-Te;if(gs.current=null,fe.state==="inactive"){Me(!1);return}(V==="abort"||Le<pXe)&&(fe.onstop=()=>{if(fe.stream)for(const Kt of fe.stream.getTracks())Kt.stop();Ne(null),Yr.current=[],Hn.current=null,Ut(Kt=>Eh(Kt,{type:"discarded"}))}),fe.stop(),Me(!1)},[]);$.useEffect(()=>()=>{const V=gs.current!==null;gs.current=null;const fe=Xn.current;if(fe&&fe.state!=="inactive"){$s("abort");return}V&&St(!1)},[$s]);const t5=$.useCallback((V="release")=>{const fe=gs.current;if(fe){if(fe.startedAt===null){gs.current=null,St(!1);return}$s(V)}},[$s]),_Y=$.useCallback(async()=>{if(!(wt||!zi)&&!gs.current)if(navigator?.mediaDevices?.getUserMedia){const V={startedAt:null};gs.current=V,St(!0);try{const fe=await navigator.mediaDevices.getUserMedia({audio:!0});if(gs.current!==V){for(const Te of fe.getTracks())Te.stop();return}Xn.current=new MediaRecorder(fe),Yr.current=[],Xn.current.ondataavailable=Te=>{Yr.current.push(Te.data)},Xn.current.onstop=()=>{const Te=new Blob(Yr.current,{type:"audio/webm"});rt(null),Ne(Te);for(const Le of fe.getTracks())Le.stop()},Xn.current.start(),V.startedAt=performance.now(),St(!1),Me(!0),Ne(null)}catch(fe){if(gs.current!==V)return;gs.current=null,St(!1),console.error("Error accessing microphone:",fe),Rr(m("ui.canvas.inline_edit.error_accessing_microphone_please_ensure_microphone_permissions_are_gran"))}}else console.error("This runtime exposes no MediaRecorder"),Rr(m("ui.canvas.inline_edit.dictation_is_not_available_on_this_device"))},[zi,wt]),n5=$.useCallback(()=>{Se&&$s("release")},[Se,$s]),r5=$.useCallback(()=>{Se&&$s("abort")},[Se,$s]),mXe=$.useCallback(()=>{if(!(!Se||_t!=="idle")&&!(wt||X||E||IO)){if(Xn.current?.state!=="recording"){$s("release");return}Hn.current={draftAtPress:Pe,transcript:null},Ut(V=>Eh(V,{type:"press"})),$s("release")}},[Se,_t,wt,X,E,IO,Pe,$s]);$.useEffect(()=>{if(!Se&&!Je)return;const V=fe=>{if(Se){if(fe.key==="Enter"){const Te=fe.target;if(Te instanceof Element&&Te.closest("[data-lo-composer-controls] button"))return;fe.preventDefault(),n5()}else fe.key==="Escape"&&(fe.preventDefault(),r5());return}fe.key==="Escape"&&(fe.preventDefault(),t5("abort"),St(!1))};return window.addEventListener("keydown",V),()=>{window.removeEventListener("keydown",V)}},[Se,Je,n5,r5,t5]);const xb=$.useCallback(()=>{Hn.current&&(Hn.current=null,Ut(V=>Eh(V,{type:"transcript",usable:!1})))},[]),PY=$.useCallback(async()=>{if(!Ae)return;Nt.current?.abort();const V=new AbortController;Nt.current=V;try{Bt(!0);const fe=await Z9.createTranscriptionWithRetry(bf.baseUrl,{file:new File([Ae],"recording.webm",{type:"audio/webm"})},{signal:V.signal,onRetry:({attempt:Te,total:Le,delayMs:Kt,error:_n})=>{console.warn(`Transcription attempt ${Te}/${Le} failed with a transient upstream fault; retrying in ${Kt} ms.`,_n)}});if(fe.result?.text){const Te=fe.result?.text||"";Ks.current=!0,ms(Te),Hn.current&&(Hn.current.transcript=Te,Ut(Le=>Eh(Le,{type:"transcript",usable:!0})))}else Jo(Eze()),xb();rt(null),Ne(null)}catch(fe){if(V.signal.aborted){xb();return}console.error("Error transcribing audio:",fe),xb();const Te=Sk(fe);rt(Te?Oze(fe):null),Te||Rr(lue(fe))}finally{Nt.current===V&&Bt(!1)}},[Ae,ms,xb]),gXe=$.useCallback(()=>{rt(null),pt(V=>V+1)},[]);$.useEffect(()=>{if(!Ae){On.current=null;return}On.current?.blob===Ae&&On.current.attempt===Pt||(On.current={blob:Ae,attempt:Pt},PY())},[Ae,Pt,PY]);const TY=$.useRef(!0);$.useEffect(()=>{if(typeof IntersectionObserver>"u")return;const V=Ht.current;if(V===null)return;const fe=new IntersectionObserver(Te=>{const Le=Te[Te.length-1];Le!==void 0&&(TY.current=Le.isIntersecting)});return fe.observe(V),()=>fe.disconnect()},[Ht]),cin(le,Q2e.MESSAGE_INPUT,{start:_Y,stop:t5},()=>!!(!wt&&!Se&&!Be&&zi&&TY.current));const i5=(V=!1)=>{if(wt||X)return!1;if(E)return vb(),!1;if(!Pe.trim()&&$e.length===0||V&&Wa(wi)||V&&r&&Xrn(Pe))return!1;if(dg())return!0;const fe=Ze(Pe,pr);if(fe.kind!=="send")return V?!1:(ir(fe,Pe,pr),!0);if(V){if(l&&hK(Pe))return!1}else if($b(Pe))return!0;return eh(),!0},$Xe=V=>{V.preventDefault(),i5()},XY=$.useRef(i5);XY.current=i5,$.useEffect(()=>{if(_t==="ready-to-submit"){if(Be)return;const V=Hn.current;if(!V||V.transcript===null){Ut("idle");return}const{intact:fe}=Trn({draftAtPress:V.draftAtPress,transcript:V.transcript,current:Pe,join:f3});Hn.current=null;const Te=fe?XY.current(!0):!1;Ut(Le=>Eh(Le,{type:"checked",draftIntact:fe&&Te}));return}_t==="submitting"&&!IO&&Ut(V=>Eh(V,{type:"settled",sendBusy:!1}))},[_t,Be,Pe,IO]);const a5=$.useCallback(V=>{wt&&V.preventDefault()},[wt]),RY=$.useCallback(V=>{!wt&&!hg||(V.preventDefault(),hg&&!wt&&vb())},[wt,hg,vb]),yXe=V=>{d&&pe(d,V)},vXe=async()=>{const V=await window.electron.ipcRenderer.invoke("show-open-dialog",{properties:["openFile","multiSelections"]});if(!V.canceled&&V.filePaths.length>0&&d)for(const fe of V.filePaths)tn(d,{id:Za(),path:tG(fe)})},bXe=V=>{if(wt)return;const fe=V.clipboardData?.getData("text/plain")??"";if(fe&&xi.current.arm!==null){const Le=V.currentTarget,Kt=jTt({capture:xi.current,buffer:Pe,caret:Le.selectionEnd??Pe.length,selection:{start:Le.selectionStart??Pe.length,end:Le.selectionEnd??Pe.length},pasted:fe,index:hs.current,taken:nh()});if(Kt){V.preventDefault(),Mi(Kt),Zr(null);return}}vin(V.clipboardData??null)?V.preventDefault():fe&&(Fl.current=xTt(fe));const Te=V.clipboardData?.items;if(Te){for(let Le=0;Le<Te.length;Le++)if(Te[Le].type.indexOf("image")!==-1||Te[Le].kind==="file"){const Kt=Te[Le].getAsFile();if(Kt){const _n=new FileReader;_n.onload=$n=>{$n.target?.result&&d&&tn(d,{id:Za(),path:$n.target.result})},_n.readAsDataURL(Kt)}}}},wXe=V=>{wt||V.dataTransfer?.types.includes("Files")&&(V.preventDefault(),V.stopPropagation(),V.dataTransfer.dropEffect="copy",o5(!0))},xXe=V=>{V.currentTarget.contains(V.relatedTarget)||o5(!1)},SXe=V=>{if(o5(!1),wt)return;const fe=V.dataTransfer?.files;!fe||fe.length===0||(V.preventDefault(),V.stopPropagation(),d&&QXe(d,Array.from(fe)))},QXe=async(V,fe)=>{for(const Te of fe){const Le=window.api?.getPathForFile?window.api.getPathForFile(Te):"";if(Le){tn(V,{id:Za(),path:tG(Le)});continue}const Kt=await xln(Te);Kt&&tn(V,{id:Za(),path:Kt})}},[EY,o5]=$.useState(!1),kXe=V=>{wt||(Pe||y?.(),kr.current=V.length,Dn(V),Qi(V.length),Ht.current?.focus())},s5=Wa(wi)?wi.value!==""?GO(Pe,wi)?a2t:r2t:Qr?i2t:s2t:ob!==null&&ob===Pe?o2t:LTt({unredacted:Ui!==null?l2t(Ui):null,armed:wi.arm!==null&&cSe(Pe,Pe.length)!==null,cleared:ig===null?null:{key:ig.key,index:ig.index},undoCap:J2e(da==="darwin")}),qY=nin(da==="darwin"?"mac":da==="win32"?"win":"linux",!Y),l5=$.useRef(null),_Xe=V=>{d&&(l5.current=ie.findIndex(fe=>fe.id===V),ht(d,V))};$.useEffect(()=>{const V=l5.current;if(V===null)return;l5.current=null;const fe=document.querySelectorAll(i8e),Te=fe[Math.min(V,fe.length-1)];Te?Te.focus():tl()},[ie,tl]);const Xo=$.useMemo(()=>{const fe=eG(Pe,ie)!==""||$e.length>0,Te=X||S?.message&&efe.test(S.message)?[{get label(){return m("ui.chat.composer.connect_provider")},onClick:()=>aO.getState().openConnect()}]:[];return{message:S?.message,muted:S?.muted===!0,polite:S?.polite===!0,actions:[...S?.actions??[],...Te],retry:S?.retry===!0,clear:S?.muted!==!0&&(S?.onClear!==void 0||fe)}},[S,Pe,ie,$e,X]),rh=Q6t(),jY=T("block text-body-sm",A?"px-2 pb-1":"px-4 pb-2",Ui!==null?"text-warning":"text-ink-muted"),c5=T("flex flex-wrap items-center gap-2 text-body-sm text-ink-muted",A?"px-2 pb-1":"px-4 pb-2"),CY=gn&&Pe.length>0,PXe=f.jsx("output",{className:T($r,"block pb-2",rh.issue.kind==="hidden"&&"hidden"),children:f.jsx(Uon,{issue:rh.issue,onSignIn:rh.start,onCancel:rh.cancel,onDismiss:rh.dismiss,isSmallView:A,onFocusComposer:()=>Ht.current?.focus()})}),pg=DEe(L),TXe=pg&&!VEe(pg,MEe(rh.issue))?f.jsx("output",{className:T($r,"block pb-2"),children:f.jsx(Jrn,{access:pg,isSmallView:A,onSwitchModel:L?.onCommand?()=>L.onCommand?.({name:"model",args:""}):void 0,onConnect:()=>aO.getState().openConnect({providerId:pg.provider})})}):null,zY=Je||!Se&&!Be&&!(t&&p),u5=Se?"recording":Be?"transcribing":Je?"preparing":"idle",XXe=Pe.trim()!==""||$e.length>0,ih=Qrn(u5,_t),O5=krn(u5),jr=Srn({dictation:u5,alive:!!Q?.active,stopping:Q?.stopping===!0,hasPayload:XXe,refused:wt||hg,sendBusy:IO,sendRecording:_t,reviewRequired:Wa(wi)}),RXe=jr.role==="stop-busy"?"stop":jr.role,{ignore:EXe,arming:qXe}=fj(O5??"none"),{ignore:jXe,arming:CXe}=fj(ih),{ignore:AY,arming:UY}=fj(RXe),Sb=$.useRef(!1),zXe=`${ih}|${jr.role}|${O5}`;$.useEffect(()=>{if(!Sb.current)return;const V=document.activeElement;V&&V!==document.body||(Sb.current=!1,Ht.current?.focus({preventScroll:!0}))},[zXe]);const AXe=f.jsxs("form",{onSubmit:$Xe,"data-chat-region":"composer","aria-label":due("composer"),tabIndex:-1,className:"w-full",children:[f.jsx(oG,{fallback:null,children:f.jsx(xrn,{frontend:L?.frontend,askFrontend:L?.asks,runDetails:_e,isSmallView:A,askExpanded:I,onAskToggle:Z,askOutcomes:U,onNote:Oe,onFocusComposer:()=>Ht.current?.focus()},d)}),!LEe(pg)&&PXe,TXe,a,o?.blocksInput&&o.placeholder&&!o.statedByNode&&Pe.trim().length>0?f.jsx("p",{id:Ple,className:"mb-2 text-meta text-ink-muted",children:o.placeholder}):null,o?.node,Xo.message!==void 0&&f.jsxs("div",{role:Xo.polite?"status":"alert","data-composer-notice":!0,"data-composer-queued":S?.message===HEe.queuedSend?!0:void 0,className:T($r,"flex flex-wrap items-center gap-x-3 gap-y-1 text-body-sm",A?"px-2 pb-1":"px-4 pb-2"),children:[f.jsxs("p",{className:T("flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",Xo.muted?"text-ink-muted":"text-danger"),children:[!Xo.muted&&f.jsx("span",{className:"flex shrink-0 items-center pt-0.5",children:f.jsx(uO,{size:14,"aria-hidden":"true"})}),f.jsx("span",{className:T("min-w-0 break-words",!Xo.muted&&"font-medium"),children:Xo.message})]}),(Xo.retry||Xo.clear||Xo.actions.length>0)&&f.jsxs(f.Fragment,{children:[Xo.actions.map(V=>f.jsx(Qe,{type:"button",variant:"link",size:"sm",className:T("min-h-6 cursor-pointer text-body-sm underline"),onClick:V.onClick,children:V.label},V.label)),Xo.retry&&S?.onRetry&&f.jsx(Qe,{type:"button",variant:"link",size:"sm",className:T("min-h-6 cursor-pointer font-semibold text-body-sm underline"),onClick:()=>S.onRetry?.(),children:FEe()}),Xo.clear&&S?.onClear&&f.jsx(Qe,{type:"button",variant:"link",size:"sm","aria-label":m("ui.chat.composer.clear_message"),className:T("min-h-6 cursor-pointer text-ink-dim text-body-sm underline"),onClick:()=>S.onClear?.(),children:BEe()})]})]}),w&&f.jsx("output",{className:T($r,"block text-body-sm text-ink-muted",A?"px-2 pb-1":"px-4 pb-2"),children:w}),c&&Ee!==null&&f.jsx(San,{sessionId:c,sessionStreaming:u,adoptQueueSupported:O,isSmallView:A,onReturnFocus:()=>Ht.current?.focus()}),k?f.jsx("div",{className:T($r,A?"px-2 pb-2":"px-4 pb-2"),children:k}):null,f.jsxs("div",{className:T($r,"relative w-full"),children:[f.jsx(rln,{state:ot,onPick:KP,onActionPick:HP}),f.jsx(yon,{state:Xa,onPick:yY}),f.jsx(isn,{state:Hr,onPick:JP}),!Y&&!ot.open&&!Xa.open&&!Hr.open&&f.jsx(rzt,{visible:v,onClick:x,hasNewActivity:b}),f.jsx("output",{id:xle,className:T($r,s5?jY:"hidden"),children:s5}),CY&&f.jsx("output",{id:Sle,className:T($r,jY),children:m("ui.chat.composer.secret_closure_notice")}),l&&Qt===null&&f.jsxs("output",{id:Qle,className:T(c5,$r),children:[f.jsx("span",{className:"min-w-0",children:m("ui.chat.composer.secret_ask_notice")}),f.jsx(Qe,{type:"button",size:"sm",variant:"secondary","data-lo-ask-item-toggle":"",onClick:()=>l.onOpen(),children:m("ui.chat.composer.secret_ask_open")})]}),mb!==null&&Qt===null&&f.jsx("output",{id:mln,className:T(c5,$r),children:f.jsx("span",{className:"min-w-0",children:mb})}),Qt!==null&&f.jsxs("fieldset",{ref:gb,tabIndex:-1,id:gln,"aria-labelledby":kle,"aria-busy":Vn,onKeyDown:V=>{V.key==="Escape"&&(V.preventDefault(),!Vn&&yb())},className:T("m-0 min-w-0 border-0 p-0",c5,$r),children:[f.jsxs("span",{id:kle,className:"min-w-0",children:[Vn?m("ui.chat.composer.secret_confirm_sending"):m("ui.chat.composer.secret_confirm_message"),f.jsx("span",{className:T("whitespace-nowrap",Vn&&"invisible"),"aria-hidden":Vn||void 0,children:` ${m("ui.chat.composer.secret_confirm_chars",{count:Qt.value.length})}`})]}),f.jsx(Qe,{ref:pY,type:"button",size:"sm",disabled:Vn,onClick:oXe,children:l?.fillable?m("ui.chat.composer.secret_confirm_put"):m("ui.chat.composer.secret_confirm_put_multi")}),f.jsx(Qe,{type:"button",size:"sm",variant:"secondary",disabled:Vn,onClick:sXe,children:m("ui.chat.composer.secret_confirm_send")}),f.jsx(Qe,{type:"button",size:"sm",variant:"ghost",disabled:Vn,onClick:yb,children:m("ui.chat.composer.secret_confirm_cancel")})]}),Hl>0&&f.jsx("span",{id:_le,className:"sr-only",children:Hl===1?"1 reference points outside this session's working directory; the agent will ask you to approve it before reading.":`${Hl} references point outside this session's working directory; the agent will ask you to approve them before reading.`}),i&&f.jsx("span",{id:Tle,className:"sr-only",children:m("ui.chat.composer.delivery_remedies_hint")}),f.jsxs("div",{"data-glass-region":"composer",className:T(kln,EY?void 0:_ln,A?"gap-2 rounded-md p-2":"gap-3 rounded-frame p-4",$r,EY&&"outline-dashed outline-2 outline-accent outline-offset-2"),"data-lo-composer-measure":"","data-tour-tag":"chat-input-textarea",children:[(ie.length>0||$e.length>0)&&f.jsxs("div",{className:"max-h-[240px] shrink-0 overflow-y-auto",children:[ie.length>0&&f.jsx(vW,{replies:ie,onRemoveReply:_Xe}),$e.length>0&&f.jsx(yGe,{attachments:$e,onRemoveAttachment:yXe,disabled:wt||Se||Be,byteSizes:ue})]}),f.jsxs("div",{className:"relative isolate w-full",children:[f.jsx(Ain,{text:Pe,payloads:Si.current,capture:wi,held:GO(Pe,wi),fieldRef:Ht,mirrorRef:mu,isSmallView:A}),f.jsx(ton,{text:Pe,spans:el.spans,resolved:el.resolved,fieldRef:Ht,isSmallView:A}),f.jsx(kon,{draft:Pe,runs:_r,textareaRef:Ht,fieldClassName:lk(A),refused:wt,children:f.jsx("textarea",{ref:Ht,"data-region-entry":!0,className:T(lk(A),"block",A?"max-h-24":"max-h-28","resize-none overflow-y-auto bg-transparent",sn?"text-transparent caret-ink":"text-ink","outline-none placeholder:text-ink-dim",o?.blocksInput?"read-only:text-ink-muted read-only:placeholder:text-ink-muted disabled:text-ink-disabled disabled:placeholder:text-ink-disabled":"read-only:text-ink-disabled read-only:placeholder:text-ink-disabled disabled:text-ink-disabled disabled:placeholder:text-ink-disabled"),placeholder:Se?m(Qs.recording):lNe({unavailable:H,secretAnswer:gn,inputDisabled:wt,awaitingAnswer:r,asideAttached:Ee!==null,sendingUnsettled:Jf||th,awaitingReply:n,stopping:Q?.stopping===!0,noProvider:X,idle:Xe,hostLine:o?.placeholder??null}),value:Pe,onCompositionStart:()=>cg(!0),onCompositionEnd:()=>cg(!1),onChange:V=>{Hf.current=!0;const fe=V.target.value,Te=V.target.selectionStart??fe.length;Bl.current=null;const Le=PTt(xi.current,Pe,fe,Te,"typing");Le.buffer!==fe?(kr.current=Le.caret,Qi(Le.caret)):Qi(Te),Le.capture!==xi.current&&To(Le.capture),!Pe&&Le.buffer&&y?.(),ps.current=Le.buffer,gu(Le.capture,Le.buffer),Dn(Le.buffer),Date.now()-Rn.current>=yln&&S?.onDismiss?.()},onSelect:V=>{const fe=V.target,Te=kr.current;if(Te!==null){fe.selectionStart===Te&&(kr.current=null);return}Qi(fe.selectionStart),To(Bh(xi.current,Pe,fe.selectionStart,"caret"))},onKeyDown:cXe,onPointerDown:()=>{n9=!0},onPaste:bXe,rows:1,readOnly:wt,"aria-disabled":wt||void 0,"aria-label":m("ui.chat.composer.message"),role:"combobox","aria-describedby":[o?o.id:null,o?.blocksInput&&o.placeholder&&!o.statedByNode&&Pe.trim().length>0?Ple:null,s5?xle:null,CY?Sle:null,l&&Qt===null?Qle:null,Hl>0?_le:null,H?cQe:null,i?Tle:null].filter(Boolean).join(" ")||void 0,"aria-expanded":ot.open||Xa.open,"aria-controls":ot.open?ot.listId:Xa.open?Xa.listId:void 0,"aria-activedescendant":(ot.open?ot.activeDescendantId:Xa.activeDescendantId)??void 0})}),f.jsx(jin,{small:A,text:Pe,payloads:Si.current,capture:wi,mirrorRef:mu,fieldRef:Ht,onClear:wt?null:dXe,onControlUnmounted:tl})]}),(Se||Je&&zY)&&f.jsx(zde,{isRecording:Se,preparingLabel:!Se&&Je?A?m("ui.chat.composer.starting"):m("ui.chat.composer.starting_recording"):null,sendsNow:jr.role==="send-recording"&&jr.enabled}),Be&&f.jsxs("div",{"data-transcribing-indicator":"",className:"mt-1 flex items-center gap-2 px-2 [min-height:1.5rem]",children:[f.jsx("span",{className:"font-medium text-body-sm text-ink-muted",children:m("ui.chat.composer.processing_audio")}),_t==="idle"&&f.jsx(nXe,{})]}),ze!==null&&!Be&&Ae!==null&&f.jsxs("div",{"data-dictation-retry":"",className:"mt-1 flex items-center gap-2 px-2 [min-height:1.5rem]",children:[f.jsx(uO,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"}),f.jsx("span",{className:"font-medium text-body-sm text-ink-muted",children:ze}),f.jsx(Qe,{type:"button",variant:"link",size:"sm",className:"h-7 shrink-0 px-2 underline",onClick:gXe,children:m("ui.common.actions.retry")})]}),f.jsxs("div",{className:"flex min-w-0 flex-nowrap items-center gap-x-2",children:[L&&f.jsx(oG,{fallback:null,children:f.jsx(fIe,{frontend:L.frontend,onCommand:L.onCommand,effortEntities:L.effortEntities,draft:L.draft,onOpenDraftPicker:L.onOpenDraftPicker,draftResolution:L.draftResolution,held:L.held,contextHeld:L.contextHeld,readingsDropped:L.readingsDropped,pendingModel:L.pendingModel,costChannels:L.costChannels,controlsThirdBox:fXe})}),f.jsxs("div",{className:"contents",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-1 shrink-0",children:[f.jsx(vt,{content:m("ui.chat.composer.attach_file"),children:f.jsx("span",{children:f.jsx(Qe,{variant:"ghost",size:A?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:a5,onClick:vXe,"aria-label":m("ui.chat.composer.attach_file"),"data-tour-tag":"chat-input-attach-file-button",disabled:wt||Se||Be,children:f.jsx(q6e,{"aria-hidden":"true"})})})}),dt!==void 0&&f.jsx(qon,{ref:vY,currentWorkingDirectory:dt,writePath:C,pending:W,pendingAccepted:G,readOnlyReason:C?void 0:z??w2e})]}),f.jsxs("div",{"data-lo-composer-controls":!0,onFocus:()=>{Sb.current=!0},onBlur:V=>{V.target.isConnected&&(Sb.current=!1)},className:"ms-auto flex order-3 shrink-0 items-center gap-1",children:[O5==="confirm"&&f.jsx(vt,{content:m("ui.chat.composer.insert_transcript_hint"),children:f.jsx("span",{children:f.jsx(Qe,{"data-composer-slot":"c",variant:"outline",size:A?"icon-sm":"icon",type:"button",className:T("border-success-border bg-success-wash text-success hover:bg-success-wash",CXe&&"opacity-72"),onClick:V=>{jXe(V.detail)||n5()},"aria-label":m("ui.chat.composer.insert_transcript"),children:f.jsx(sa,{"aria-hidden":"true"})})})},"confirm"),(ih==="mic"||ih==="mic-preparing")&&zY&&f.jsx(vt,{content:f.jsx(Oin,{text:Je?m("ui.chat.composer.starting_recording"):zi?qY===null?m("ui.chat.composer.start_recording"):m("ui.chat.composer.start_recording_hint",{shortcut:Uqe(qY),pushToTalk:Hz().label}):Po}),children:f.jsx("span",{children:f.jsx(Qe,{"data-composer-slot":"a",variant:"ghost",size:A?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:a5,onClick:_Y,"aria-label":m("ui.chat.composer.start_recording"),"aria-busy":Je||void 0,disabled:wt||!zi,children:Je?f.jsx(Sa,{size:"sm"}):f.jsx(m6e,{"aria-hidden":"true"})})})},"mic"),ih==="spinner"&&f.jsx(Qe,{"data-composer-slot":"a",variant:"ghost",size:A?"icon-sm":"icon",type:"button",className:"text-ink-dim","aria-busy":!0,"aria-disabled":!0,"aria-label":m("ui.chat.composer.processing_audio"),onClick:V=>V.preventDefault(),children:f.jsx(Sa,{size:"sm"})},"spinner"),ih==="cancel"&&f.jsx(vt,{content:m("ui.chat.composer.cancel_recording_hint"),children:f.jsx("span",{children:f.jsx(Qe,{"data-composer-slot":"a",variant:"outline",size:A?"icon-sm":"icon",type:"button",className:T("text-danger hover:bg-danger-wash hover:text-danger focus-visible:bg-danger-wash",qXe&&"opacity-72"),onClick:V=>{EXe(V.detail)||r5()},"aria-label":m("ui.chat.composer.cancel_recording"),children:f.jsx(oi,{"aria-hidden":"true"})})})},"cancel"),(jr.role==="send-recording"||jr.role==="send-recording-busy")&&f.jsx(vt,{content:m("ui.chat.composer.send_recording_hint"),children:f.jsx("span",{children:f.jsx(Qe,{"data-composer-slot":"b",variant:"primary",size:A?"icon-sm":"icon",type:"button",className:T("rounded-full disabled:bg-surface",(jr.role==="send-recording-busy"||UY)&&"opacity-72"),"aria-busy":jr.role==="send-recording-busy"||void 0,"aria-disabled":jr.role==="send-recording-busy"||void 0,onPointerDown:RY,onClick:V=>{jr.role!=="send-recording-busy"&&(AY(V.detail)||mXe())},disabled:!jr.enabled&&jr.role!=="send-recording-busy","aria-label":Ee!==null&&!r?m("ui.chat.composer.ask_aside"):m("ui.chat.composer.send_recording"),children:f.jsx(jx,{"aria-hidden":"true"})})})},"send-recording"),jr.role==="connecting"&&f.jsx(Qe,{"data-composer-slot":"b",variant:"secondary",size:A?"icon-sm":"icon",type:"button",className:"rounded-full","aria-busy":!0,"aria-disabled":!0,"aria-label":m("ui.chat.composer.placeholder.sending"),onClick:V=>V.preventDefault(),children:f.jsx(Sa,{size:"sm"})},"connecting"),(jr.role==="stop"||jr.role==="stop-busy")&&Q&&f.jsx(vt,{content:m("ui.chat.composer.stop_work_hint"),children:f.jsx("span",{children:f.jsx(Qe,{"data-composer-slot":"b",variant:"danger",size:A?"icon-sm":"icon",type:"button",onClick:V=>{jr.role!=="stop-busy"&&(AY(V.detail)||Q.onStop())},"aria-label":m("ui.chat.composer.stop"),"aria-keyshortcuts":"Escape","data-stopping":Q.stopping===!0?"true":void 0,"aria-busy":Q.stopping===!0?!0:void 0,className:T("data-[stopping]:border-danger data-[stopping]:text-ink data-[stopping]:bg-[color-mix(in_oklab,var(--color-danger-wash)_80%,var(--color-danger))]",UY&&"opacity-72"),children:f.jsx(Cj,{"aria-hidden":"true"})})})},"stop"),t&&p&&f.jsx(vt,{content:m("ui.chat.composer.stop_agent"),children:f.jsx("span",{children:f.jsx(Qe,{variant:"danger",size:A?"icon-sm":"icon",type:"button",onClick:()=>g?.(p),"aria-label":m("ui.chat.composer.stop_agent"),children:f.jsx(Cj,{"aria-hidden":"true"})})})}),(jr.role==="send"||jr.role==="steer")&&!(t&&p)&&f.jsx(vt,{content:Ee!==null&&!r?m("ui.chat.composer.ask_aside"):jr.role==="steer"?m("ui.chat.composer.steer_hint"):m("ui.chat.composer.send_message"),children:f.jsx("span",{children:f.jsx(Qe,{"data-composer-slot":"b",variant:"primary",size:A?"icon-sm":"icon",type:"submit",onPointerDown:RY,disabled:!jr.enabled,className:"rounded-full disabled:bg-surface","aria-label":Ee!==null&&!r?m("ui.chat.composer.ask_aside"):m("ui.chat.composer.send_message"),children:f.jsx(jx,{"aria-hidden":"true"})})})},jr.role)]})]})]})]})]}),X&&!fs?f.jsx("div",{className:T("mt-2",$r),children:f.jsx(fan,{})}):null,(X||E)&&kn?f.jsx("div",{className:T("mt-2",$r),children:f.jsx("output",{className:"block text-body-sm text-ink-muted",children:E?"Choose a model for this conversation before sending.":"Connect a provider to send."})}):null]});return f.jsxs("div",{className:T(Ode,"flex w-full flex-col items-center",Ai?"grow":"shrink-0",D?void 0:ZYe,A?"pb-1 pt-0.5":"pb-4 pt-2"),"data-lo-composer-band":!0,ref:rg,onDragOver:wXe,onDragLeave:xXe,onDrop:SXe,children:[f.jsx("div",{"data-lo-composer-splash":"",className:T("flex w-full flex-col items-center justify-center",Ai?"grow":null),children:f.jsx("div",{ref:If,className:T(hb?"flex w-full flex-col items-center gap-6 py-4":"hidden"),children:hb?f.jsxs(f.Fragment,{children:[f.jsx("span",{"data-lo-empty-mark":"",className:"contents",children:f.jsx(hln,{className:"size-8",tone:"ink-muted"})}),X?null:f.jsx("h2",{className:"text-center text-ink text-title",children:m("ui.chat.composer.welcome")}),X?f.jsx("div",{className:T("w-full",$r),children:f.jsx(dan,{})}):f.jsxs("div",{className:T("flex flex-col gap-3",$r),children:[f.jsx(Con,{band:Bs,splash:Hs,foot:Df,suggestions:ab,disabled:hXe,onRefusedPress:a5,onSelect:kXe,focusComposer:()=>Ht.current?.focus()}),f.jsx(Ein,{suspended:Pe.trim().length>0,mentionsEnabled:se})]})]}):null})}),fs?f.jsx("div",{className:T("mb-2 mt-2",$r),children:f.jsx(Oan,{selection:tg})}):null,f.jsx("div",{ref:Gr,"data-lo-composer-foot":"",className:"w-full",children:AXe})]})});function jle(e){e.style.height="auto",e.style.height=`${Math.ceil(e.scrollHeight)}px`,e.style.overflowY=e.scrollHeight<=e.clientHeight+1?"hidden":""}const Tln=$.memo(Pln);Tln.displayName="MessageInput";const fY=1024,Sx=1024*1024,VP=.85,Xln=new Set(["image/png","image/jpeg","image/webp"]),Rln=[{maxEdge:fY,quality:.8},{maxEdge:768,quality:.7},{maxEdge:512,quality:.6}];function Eln(e){const t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}function qln(e){const t=Uint8Array.fromBase64;if(typeof t=="function")return t.call(Uint8Array,e);const n=atob(e),r=new Uint8Array(n.length);for(let i=0;i<n.length;i+=1)r[i]=n.charCodeAt(i);return r}function Cle(e){const t=e.toBase64;if(typeof t=="function")return t.call(e);let n="";const r=32768;for(let i=0;i<e.length;i+=r)n+=String.fromCharCode(...e.subarray(i,i+r));return btoa(n)}async function jln(e,t,n,r,i,a=!1){const o=Math.max(e.width,e.height),s=o>r?r/o:1,l=Math.max(1,Math.round(e.width*s)),c=Math.max(1,Math.round(e.height*s)),u=new OffscreenCanvas(l,c),O=u.getContext("2d");if(!O)return null;O.drawImage(e,0,0,l,c);const d=[],h=await u.convertToBlob({type:"image/png"}),p=new Uint8Array(await h.arrayBuffer());if(p.byteLength<=Sx&&d.push({bytes:p,mime_type:"image/png"}),p.byteLength>Sx||i<VP){const v=new OffscreenCanvas(l,c),b=v.getContext("2d");if(!b)return null;b.fillStyle="#ffffff",b.fillRect(0,0,l,c),b.drawImage(e,0,0,l,c);const x=await v.convertToBlob({type:"image/jpeg",quality:i}),Q=new Uint8Array(await x.arrayBuffer());d.push({bytes:Q,mime_type:"image/jpeg"}),p.byteLength>Sx&&Q.byteLength>p.byteLength&&d.push({bytes:p,mime_type:"image/png"})}let g=null,y=Number.POSITIVE_INFINITY;for(const v of d)v.bytes.byteLength<y&&(g=v,y=v.bytes.byteLength);return g?a&&s<1?{data_b64:Cle(g.bytes),mime_type:g.mime_type}:y>=n?t:{data_b64:Cle(g.bytes),mime_type:g.mime_type,...t.origin_path?{origin_path:t.origin_path}:{}}:null}async function ypn(e,t=fY,n=VP,r={}){const i=await iXe(e);if(!i)return e;try{return await aXe(e,i,t,n,r.edgeIsHard??!1)}finally{i.close()}}async function iXe(e){if(!Xln.has(e.mime_type)||typeof createImageBitmap!="function"||typeof OffscreenCanvas!="function")return null;try{return await createImageBitmap(new Blob([qln(e.data_b64)],{type:e.mime_type}))}catch{return null}}async function aXe(e,t,n,r,i=!1){const a=Eln(e.data_b64);try{return Math.max(t.width,t.height)<=n&&a<=Sx&&r>=VP?e:await jln(t,e,a,n,r,i)??e}catch{return e}}async function Cln(e,t,n){if(!e.length)return e;const r=await Promise.all(e.map(i=>iXe(i)));try{return await zln(e,r,t,n)}finally{for(const i of r)i?.close()}}async function zln(e,t,n,r){const i=(c,u)=>Promise.all(e.map((O,d)=>{const h=t[d];return h?aXe(O,h,c,u):Promise.resolve(O)})),a=await i(fY,VP);if(r(a)<=n)return a;let o=e,s=r(e);const l=c=>{const u=r(c);return u<s&&(o=c,s=u),u};l(a);for(const c of Rln){const u=await i(c.maxEdge,c.quality);if(l(u)<=n)return u}return o}const zle=/^data:(image\/(png|jpeg|gif|webp));base64,(.+)$/,Aln=/^file:\/\//,Ale={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp"},wj=e=>e.replace(Aln,"");async function vpn(e,t,n){const r=[],i=[],a=[],o=e.filter(u=>{if(zle.test(u))return!1;const O=u.split(".").pop()?.toLowerCase()??"";return!Ale[O]}),s=Math.max(0,o.length-Qj),l=s===0;for(const u of e){const O=zle.exec(u);if(O){r.push({data_b64:O[3],mime_type:O[1]});continue}const d=u.split(".").pop()?.toLowerCase()??"",h=Ale[d];if(h){if(!window.api?.readFile){a.push({name:jd(u),kind:"read"});continue}const x=await window.api.readFile(wj(u),"base64");x.success?r.push({data_b64:x.data,mime_type:h,...u.startsWith("data:")?{}:{origin_path:wj(u)}}):a.push({name:jd(u),kind:"read"});continue}const p=jd(u);if(n?.remoteOwned){a.push({name:p,kind:"remote"});continue}if(!l)continue;const g=window.api?.uploadAttachment;if(!g){a.push({name:p,kind:"upload",detail:"this window cannot upload files"});continue}const y=u.startsWith("data:")?{kind:"dataUrl",dataUrl:u,name:p}:{kind:"path",path:wj(u),name:p},v=await g(y);if(!v.success){a.push({name:p,kind:"upload",detail:v.error});continue}const b=v.attachment;i.push({digest:b.digest,name:b.name??p,mime_type:b.mime_type,bytes:b.bytes,...b.path?{path:b.path}:{}})}const c=Math.max(0,r.length-kj);return{images:await Cln(r.slice(0,kj),hk,u=>a3(t,u)),files:i.slice(0,Qj),failures:a,overflow:c,fileOverflow:s}}const Uln=/\.+$/,Ule=e=>typeof e=="string"?jd(e):e.name,Wln=e=>e?.trim().replace(Uln,"")??"",Nln=e=>`${e} could not be read (it may have been moved or deleted)`,Yln=(e,t)=>{const n=Wln(t);return n?`${e} could not be attached (${n})`:`${e} could not be attached`},Gln=e=>`${e} cannot be attached because this conversation is owned by another device, and files are only attachable to conversations on this one`;function bpn(e){if(e.length===0)return null;const t=e.map(Ule),n=e.length>0&&e.every(o=>typeof o!="string"&&o.kind==="remote");if(e.every(o=>typeof o=="string"||o.kind==="read"))return t.length===1?`${t[0]} could not be read (it may have been moved or deleted), so this message was not sent. Attach it again, or remove it from the draft.`:`${t.join(", ")} could not be read (they may have been moved or deleted), so this message was not sent. Attach them again, or remove them from the draft.`;if(n)return`${t.length===1?`${t[0]} cannot be attached`:`${t.join(", ")} cannot be attached`} because this conversation is owned by another device, and files are only attachable to conversations on this one. Send the message without ${t.length===1?"it":"them"}, or start the conversation here.`;const i=e.map(o=>typeof o=="string"||o.kind==="read"?Nln(Ule(o)):o.kind==="remote"?Gln(o.name):Yln(o.name,o.detail)),a=t.length===1?"it":"them";return`${i.join("; ")}, so this message was not sent. Attach ${a} again, or remove ${a} from the draft.`}function wpn(e){if(e<=0)return null;const t=kj,n=t+e;return e===1?`This draft carries ${n} images and one message carries up to ${t}, so this message was not sent. Remove the extra image, or send it in a second message.`:`This draft carries ${n} images and one message carries up to ${t}, so this message was not sent. Remove ${e} of them, or send them in a second message.`}function xpn(e){if(e<=0)return null;const t=Qj,n=t+e;return e===1?`This draft carries ${n} files and one message carries up to ${t}, so this message was not sent. Remove the extra file, or send it in a second message.`:`This draft carries ${n} files and one message carries up to ${t}, so this message was not sent. Remove ${e} of them, or send them in a second message.`}function Spn(e){const t=e.trim();if(t.startsWith("="))return null;const n=t.toLowerCase();return n==="pause"||n==="resume"||n==="status"?n:null}function Qpn(e){const t=e.trim();return t.startsWith("=")?t.slice(1).trimStart():t}function kpn(e,t){return e==="pause"?{text:"Aida is paused. She will not check in until you resume her.",kind:"success"}:e==="resume"?{text:"Aida is resumed. She will check in on her usual schedule.",kind:"success"}:{kind:"info",text:t.paused?"Aida is paused.":"Aida is active."}}function Zln(e){return Ns(e,m("ui.notices.aida.unreachable"))}const _pn="The chief of staff is switched off on this install.",Iln="aida_no_provider",Dln="aida_disabled";function Ppn(e,t){const n=e instanceof Zn?e.code:void 0;return n===Dln?null:n===Iln?{kind:"info",text:`${t} will say hello once an AI account is connected. Connect one from the chat to start.`}:{kind:"error",text:`${t}'s conversation could not be opened, so you are in a new chat instead. ${Zln(e)}`}}function Tpn(e,t){if(e.held===!0)return`${t} is already open in another window, so she will say hello there.`;const n=e.greeting_state==="delivered"||e.greeting_state==="skipped"||e.greeting_state==null&&e.greeted===!0;return e.paused&&!n?`${t} is paused, so she will say hello when you resume her: type /aida resume.`:null}function Xpn(e){const t=e?.greeting_state;return t==null||t==="owed"}function Vln(e){return e.eventKey===e.storeKey&&!e.focused}let Wle=!1;function Rpn(){if(Wle)return;Wle=!0;const e=Mn.persist?.getOptions?.()?.name??"conversation-input-store",t=n=>{Vln({eventKey:n.key,storeKey:e,focused:document.hasFocus()})&&Mn.persist?.rehydrate?.()?.catch?.(()=>{})};window.addEventListener("storage",t)}export{Rue as $,Or as A,mn as B,_f as C,u_ as D,lt as E,Ev as F,Er as G,Sr as H,Nr as I,ts as J,L8 as K,Qn as L,Fx as M,ua as N,In as O,X8 as P,Jn as Q,us as R,xk as S,Ocn as T,tcn as U,dcn as V,Dd as W,z9 as X,uA as Y,L8e as Z,bOe as _,QSe as a,sr as a$,yk as a0,bk as a1,jj as a2,Ma as a3,WUe as a4,UUe as a5,Pk as a6,eWe as a7,XUe as a8,TUe as a9,OO as aA,Jo as aB,que as aC,U9e as aD,Rcn as aE,C9e as aF,Gcn as aG,Rr as aH,Ccn as aI,Ncn as aJ,W9e as aK,N9e as aL,Bcn as aM,Ij as aN,At as aO,Zj as aP,Run as aQ,Fcn as aR,zcn as aS,$y as aT,Zdn as aU,hfn as aV,R$ as aW,rN as aX,mN as aY,fhn as aZ,uc as a_,PUe as aa,Hj as ab,_Ue as ac,QOe as ad,hA as ae,ccn as af,Tcn as ag,Dcn as ah,Hcn as ai,K9 as aj,Lcn as ak,L9e as al,Vcn as am,I9e as an,jcn as ao,q9e as ap,Ecn as aq,qcn as ar,Xcn as as,Acn as at,Ucn as au,Wcn as av,iO as aw,Icn as ax,UG as ay,Zcn as az,Rc as b,tb as b$,pZe as b0,C$ as b1,hhn as b2,ZW as b3,yA as b4,c3 as b5,hv as b6,bf as b7,jWe as b8,_pn as b9,Gdn as bA,fl as bB,Gh as bC,WWe as bD,qi as bE,pA as bF,x6e as bG,Bce as bH,Va as bI,gYt as bJ,gN as bK,QPe as bL,Jv as bM,PPe as bN,Bhn as bO,mZt as bP,Tie as bQ,Pie as bR,VPe as bS,RN as bT,mP as bU,iGt as bV,rGt as bW,um as bX,nGt as bY,tGt as bZ,QQ as b_,vpn as ba,bpn as bb,wpn as bc,xpn as bd,Jun as be,tet as bf,xd as bg,sin as bh,Xm as bi,wd as bj,Tln as bk,uUe as bl,Qun as bm,_Xt as bn,icn as bo,ocn as bp,Rpn as bq,OOn as br,cOn as bs,PXt as bt,XXt as bu,acn as bv,LWe as bw,Rx as bx,uCe as by,vk as bz,Q_e as c,tue as c$,TN as c0,_N as c1,Td as c2,SQ as c3,j3e as c4,dv as c5,jh as c6,LCe as c7,$k as c8,G5 as c9,PG as cA,Gce as cB,hcn as cC,d6e as cD,I9 as cE,Kun as cF,Gze as cG,_cn as cH,Pce as cI,JK as cJ,h6e as cK,kp as cL,A9 as cM,C9 as cN,Ov as cO,X$ as cP,pCe as cQ,b6e as cR,G7e as cS,wk as cT,ZQe as cU,mQe as cV,$hn as cW,YX as cX,XW as cY,GX as cZ,nue as c_,yke as ca,SG as cb,YOe as cc,$r as cd,ZYe as ce,Ode as cf,Cj as cg,wOn as ch,Scn as ci,Qcn as cj,xcn as ck,k9e as cl,Pcn as cm,m9e as cn,DW as co,Qce as cp,E1 as cq,bOn as cr,SA as cs,WNe as ct,HOe as cu,yOn as cv,vOn as cw,N0 as cx,nCe as cy,ve as cz,or as d,Kdn as d$,Lce as d0,Mce as d1,hZ as d2,ncn as d3,S5 as d4,W0 as d5,Lze as d6,Zce as d7,KPt as d8,_A as d9,pJ as dA,Q3e as dB,vin as dC,ypn as dD,VP as dE,fY as dF,Z9 as dG,Eze as dH,Sk as dI,Oze as dJ,lue as dK,cin as dL,Q2e as dM,Jse as dN,hNe as dO,a8e as dP,zOe as dQ,nin as dR,Hz as dS,Uqe as dT,yGe as dU,m6e as dV,q6e as dW,XRt as dX,Ldn as dY,Jdn as dZ,Mdn as d_,Hc as da,rQ as db,Ede as dc,lf as dd,vQe as de,Xp as df,NNe as dg,z3e as dh,_3e as di,KKt as dj,oOn as dk,sOn as dl,Eqt as dm,dx as dn,CRt as dp,bW as dq,LSe as dr,NRt as ds,Xi as dt,uv as du,bfn as dv,l3 as dw,j$ as dx,Tfn as dy,Sfn as dz,Mhn as e,gfn as e$,Ddn as e0,UK as e1,y7t as e2,Zx as e3,kG as e4,nGe as e5,_O as e6,tGe as e7,PA as e8,K2t as e9,GWe as eA,_fn as eB,Rfn as eC,jd as eD,Wce as eE,Tke as eF,Vun as eG,$fn as eH,ARt as eI,afn as eJ,Qfn as eK,jRt as eL,kfn as eM,wfn as eN,dfn as eO,ofn as eP,tfn as eQ,V6 as eR,M6 as eS,Ofn as eT,nfn as eU,lfn as eV,vfn as eW,Fdn as eX,yfn as eY,mfn as eZ,ffn as e_,kk as ea,pv as eb,gue as ec,E$ as ed,_p as ee,Pp as ef,L9 as eg,Ffe as eh,Dk as ei,Nfe as ej,HRt as ek,Efn as el,Pfn as em,Xfn as en,qRt as eo,BSe as ep,zRt as eq,xfn as er,pfn as es,Idn as et,D6 as eu,L_ as ev,RRt as ew,Vdn as ex,TRt as ey,Kln as ez,Ls as f,Lfn as f$,Aqt as f0,ufn as f1,ZSe as f2,sfn as f3,MO as f4,Zun as f5,XWe as f6,Sc as f7,HKt as f8,qP as f9,lpn as fA,mc as fB,cpn as fC,lsn as fD,e_e as fE,Hce as fF,lW as fG,Vrn as fH,xO as fI,Kfn as fJ,L3e as fK,V4t as fL,rhn as fM,Mfn as fN,Ifn as fO,Yi as fP,Yfn as fQ,_ke as fR,Dfn as fS,D7t as fT,ihn as fU,Jfn as fV,ehn as fW,nhn as fX,thn as fY,Z7t as fZ,I7t as f_,jP as fa,vFt as fb,RP as fc,NOe as fd,rcn as fe,H7t as ff,K7t as fg,eC as fh,uWe as fi,sue as fj,KWe as fk,Pke as fl,Fke as fm,$Rt as fn,vf as fo,gW as fp,py as fq,g3t as fr,$3t as fs,eke as ft,mx as fu,o3e as fv,M_ as fw,szt as fx,$C as fy,osn as fz,Zhn as g,qce as g$,_ue as g0,V7t as g1,Bfn as g2,Zfn as g3,Gfn as g4,Vfn as g5,Ffn as g6,Hfn as g7,AOe as g8,lOn as g9,spn as gA,BWe as gB,tNe as gC,ghn as gD,Yd as gE,j_e as gF,lQ as gG,vQ as gH,Uie as gI,TYt as gJ,jy as gK,w8t as gL,x8t as gM,b8t as gN,v8t as gO,y8t as gP,$8t as gQ,g8t as gR,sP as gS,t8t as gT,e8t as gU,m8t as gV,p8t as gW,nze as gX,Wn as gY,Vz as gZ,jce as g_,Tqt as ga,qqt as gb,Cfn as gc,SJ as gd,bJ as ge,Oin as gf,MJt as gg,Ri as gh,rc as gi,iOn as gj,pCt as gk,pd as gl,p6t as gm,Udn as gn,kSe as go,_Se as gp,Wdn as gq,zdn as gr,kK as gs,Ndn as gt,PSe as gu,kXt as gv,Adn as gw,XSe as gx,kCe as gy,scn as gz,ene as h,MX as h$,eOn as h0,tOn as h1,HCe as h2,nOn as h3,rOn as h4,Yze as h5,FWe as h6,gWe as h7,uOn as h8,QKe as h9,LX as hA,sun as hB,gC as hC,ozt as hD,rzt as hE,lun as hF,Ux as hG,UAe as hH,uun as hI,Ozt as hJ,G3e as hK,Qp as hL,IW as hM,vee as hN,m0 as hO,eun as hP,Zue as hQ,L6e as hR,$un as hS,mun as hT,Vj as hU,gAe as hV,yAe as hW,b3e as hX,Jcn as hY,Gue as hZ,aun as h_,EKe as ha,GMe as hb,Y$ as hc,xKe as hd,wpe as he,ZUe as hf,IUe as hg,va as hh,o8e as hi,r3 as hj,gy as hk,aA as hl,wun as hm,vhn as hn,yhn as ho,VAe as hp,pun as hq,fun as hr,hun as hs,vun as ht,bun as hu,xAe as hv,iun as hw,nun as hx,oun as hy,Kcn as hz,Ihn as i,rS as i$,xun as i0,T6e as i1,H9e as i2,run as i3,gun as i4,Oun as i5,YAe as i6,yun as i7,QAe as i8,dun as i9,JGe as iA,Ade as iB,UOn as iC,j7e as iD,nZe as iE,qOn as iF,uZe as iG,WOn as iH,COn as iI,ZGe as iJ,zn as iK,zOn as iL,Ize as iM,_un as iN,Lj as iO,dzt as iP,e6t as iQ,Jk as iR,JOn as iS,LOn as iT,MJe as iU,Uet as iV,MOn as iW,x8 as iX,S8 as iY,w8 as iZ,zpe as i_,pzt as ia,Mj as ib,EAe as ic,l2e as id,Wfn as ie,bCt as ig,T3e as ih,iA as ii,s8e as ij,hln as ik,W7e as il,_ce as im,vCe as io,eue as ip,kce as iq,YGe as ir,IGe as is,VGe as it,XOn as iu,ROn as iv,EOn as iw,aZe as ix,AOn as iy,jOn as iz,Fhn as j,ldn as j$,b8 as j0,qpe as j1,KOn as j2,oA as j3,aOe as j4,y8e as j5,Epe as j6,LJe as j7,eet as j8,nS as j9,sM as jA,mo as jB,vc as jC,rme as jD,on as jE,jn as jF,Bd as jG,Fo as jH,idn as jI,ddn as jJ,su as jK,kdn as jL,ydn as jM,Pat as jN,hdn as jO,pdn as jP,sdn as jQ,vdn as jR,adn as jS,odn as jT,$dn as jU,wdn as jV,xdn as jW,Qdn as jX,_dn as jY,udn as jZ,Odn as j_,c_ as ja,xt as jb,bdn as jc,De as jd,Qge as je,eit as jf,$O as jg,Jrt as jh,Gn as ji,Ka as jj,ft as jk,kl as jl,Wt as jm,kf as jn,Di as jo,Wm as jp,br as jq,wn as jr,Pi as js,zc as jt,hw as ju,pS as jv,s_ as jw,RO as jx,fdn as jy,mi as jz,Dhn as k,xhn as k$,i_ as k0,cdn as k1,Rxe as k2,wSe as k3,hW as k4,Ydn as k5,jdn as k6,Mv as k7,gQe as k8,Exe as k9,GA as kA,k3 as kB,Mfe as kC,QDe as kD,lDe as kE,wDe as kF,YD as kG,WLe as kH,B7e as kI,Kce as kJ,fpn as kK,yj as kL,D2e as kM,hpn as kN,dpn as kO,csn as kP,upn as kQ,Opn as kR,SWe as kS,p$ as kT,mpn as kU,Jh as kV,Yhn as kW,mp as kX,Ghn as kY,fsn as kZ,N3e as k_,iW as ka,f3 as kb,zde as kc,nXe as kd,jx as ke,FIe as kf,sze as kg,lze as kh,xSe as ki,FOn as kj,Nk as kk,yfe as kl,vT as km,yFe as kn,$Fe as ko,$fe as kp,YOn as kq,Lfe as kr,Oa as ks,TO as kt,wv as ku,ZOn as kv,fDe as kw,qFe as kx,VKe as ky,Lx as kz,Lhn as l,jOe as l$,wcn as l0,Sue as l1,NZ as l2,mqt as l3,Nun as l4,wzt as l5,ycn as l6,ppn as l7,Fze as l8,gpn as l9,E9t as lA,p_e as lB,P5 as lC,Rm as lD,gOn as lE,$On as lF,UNe as lG,eNe as lH,lhn as lI,chn as lJ,uhn as lK,K6e as lL,Vze as lM,_On as lN,p9e as lO,pjt as lP,Pun as lQ,g8e as lR,Tun as lS,G9e as lT,wOe as lU,i9e as lV,kun as lW,HGe as lX,opn as lY,TOn as lZ,GYe as l_,bhn as la,i_e as lb,whn as lc,mcn as ld,E7e as le,$cn as lf,dsn as lg,gcn as lh,pcn as li,vcn as lj,r9e as lk,Osn as ll,Qjt as lm,sW as ln,XJ as lo,kjt as lp,BOn as lq,nXt as lr,S7e as ls,zfn as lt,GQe as lu,gRt as lv,HOn as lw,X7e as lx,qon as ly,Afn as lz,Vhn as m,R6e as m$,oWe as m0,Eun as m1,qun as m2,jun as m3,F8e as m4,Lun as m5,U3t as m6,rke as m7,Rrn as m8,w2e as m9,qfn as mA,h9e as mB,tpn as mC,Xun as mD,Wun as mE,Uun as mF,Tk as mG,yOe as mH,I8e as mI,Aun as mJ,dA as mK,Cun as mL,zun as mM,apn as mN,jfn as mO,epn as mP,cfn as mQ,c9e as mR,efn as mS,Hdn as mT,Bdn as mU,wW as mV,ERt as mW,rfn as mX,ifn as mY,aOn as mZ,yx as m_,Hhn as ma,Zf as mb,Spn as mc,kpn as md,Zln as me,Qpn as mf,Jhn as mg,S2e as mh,xOn as mi,kOn as mj,SOn as mk,QOn as ml,Hun as mm,O_e as mn,pqt as mo,Krn as mp,fUe as mq,WYe as mr,NYe as ms,POn as mt,tun as mu,cun as mv,mzt as mw,Khn as mx,$pn as my,r8e as mz,xQ as n,Aqe as n$,aO as n0,Gun as n1,NUe as n2,Yun as n3,EWe as n4,Q6t as n5,Ake as n6,Ahn as n7,ahn as n8,shn as n9,Thn as nA,N9 as nB,P2e as nC,o_e as nD,o3 as nE,Xpn as nF,Tpn as nG,Ppn as nH,tin as nI,k2e as nJ,Nfn as nK,lY as nL,rpn as nM,Ohn as nN,V6t as nO,ipn as nP,uC as nQ,Ske as nR,Zke as nS,dhn as nT,npn as nU,vke as nV,bke as nW,Y7t as nX,dCt as nY,Mke as nZ,Vke as n_,Yke as na,Jc as nb,ohn as nc,WOe as nd,Uke as ne,_hn as nf,Uhn as ng,Whn as nh,Phn as ni,Nhn as nj,S6t as nk,Uin as nl,qhn as nm,jhn as nn,E6t as no,Qhn as np,Wzt as nq,Shn as nr,khn as ns,zzt as nt,Xhn as nu,zhn as nv,Chn as nw,J_ as nx,Ehn as ny,Rhn as nz,Ry as o,ree as o0,phn as o1,mhn as o2,$We as o3,yWe as o4,Iun as o5,bcn as o6,l9e as o7,Mcn as o8,Ycn as o9,Cdn as oA,Mun as oa,C7t as ob,ecn as oc,Fun as od,U3e as oe,Dun as of,kcn as og,Sun as oh,pNe as oi,Bun as oj,qm as ok,NOn as ol,o9e as om,Ufn as on,eCt as oo,hOn as op,dOn as oq,fOn as or,xg as os,pOn as ot,fcn as ou,RXt as ov,T1 as ow,mOn as ox,lcn as oy,VOn as oz,rm as p,X_e as q,Gs as r,sQ as s,oP as t,h8t as u,ml as v,nN as w,Tn as x,_ as y,Sn as z};