local-operator-ui 0.34.45 → 0.34.46

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 (77) hide show
  1. package/out/main/index.js +103 -0
  2. package/out/preload/index.js +71 -0
  3. package/out/renderer/assets/{_basePickBy-AOIZJtmP.js → _basePickBy-hPi3fEQr.js} +1 -1
  4. package/out/renderer/assets/{_baseUniq-6rYoQPQm.js → _baseUniq-BH6SqqsG.js} +1 -1
  5. package/out/renderer/assets/{agent-details-page-B9MNIwUW.js → agent-details-page-D6Sf3QUC.js} +1 -1
  6. package/out/renderer/assets/{agent-hub-page-Bj3VsEfD.js → agent-hub-page-geh3R5Uy.js} +1 -1
  7. package/out/renderer/assets/{agents-page-y_fPy8cB.js → agents-page-CFjl9C1o.js} +3 -3
  8. package/out/renderer/assets/{arc-DEIVtaqP.js → arc-hK5DqZTp.js} +1 -1
  9. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-C6lgf3ft.js → architectureDiagram-IEHRJDOE-Od2Y7WJh.js} +1 -1
  10. package/out/renderer/assets/{blockDiagram-JOT3LUYC-rUXOYgBS.js → blockDiagram-JOT3LUYC-Ctc7-wAT.js} +1 -1
  11. package/out/renderer/assets/{browser-page-BENwHsVf.js → browser-page-KrEaCKVz.js} +1 -1
  12. package/out/renderer/assets/{browser-webauthn-prompt-BlawzvV4.js → browser-webauthn-prompt-CKqDqDU5.js} +1 -1
  13. package/out/renderer/assets/{c4Diagram-VJAJSXHY-B5DZCCX3.js → c4Diagram-VJAJSXHY-KjhfyGml.js} +1 -1
  14. package/out/renderer/assets/channel-Bs-Xt2ih.js +1 -0
  15. package/out/renderer/assets/{chunk-4BMEZGHF-LYO-H6gm.js → chunk-4BMEZGHF-DUs-A7ex.js} +1 -1
  16. package/out/renderer/assets/{chunk-A2AXSNBT-C-eXpCGB.js → chunk-A2AXSNBT-LbRRk1xd.js} +1 -1
  17. package/out/renderer/assets/{chunk-AEK57VVT-CkjgDW9B.js → chunk-AEK57VVT-Ddc0Dk4L.js} +1 -1
  18. package/out/renderer/assets/{chunk-D6G4REZN-hAERljt9.js → chunk-D6G4REZN-Cj8PtGTg.js} +1 -1
  19. package/out/renderer/assets/{chunk-RZ5BOZE2-D1aP9fPZ.js → chunk-RZ5BOZE2-KXGjmJKN.js} +1 -1
  20. package/out/renderer/assets/{chunk-XZIHB7SX-Chv37Bqx.js → chunk-XZIHB7SX-B8dmznR7.js} +1 -1
  21. package/out/renderer/assets/classDiagram-GIVACNV2-BrkzW__m.js +1 -0
  22. package/out/renderer/assets/classDiagram-v2-COTLJTTW-BrkzW__m.js +1 -0
  23. package/out/renderer/assets/clone-CnlBeott.js +1 -0
  24. package/out/renderer/assets/{console-mirror-DF_IQ1r-.js → console-mirror-cPzOwzR9.js} +1 -1
  25. package/out/renderer/assets/{consoleCapture-CAbvxCQS.js → consoleCapture-ComgYGzq.js} +1 -1
  26. package/out/renderer/assets/{conversation-input-sync-BdhFw-JY.js → conversation-input-sync-B5HfvhyR.js} +5 -5
  27. package/out/renderer/assets/{dagre-OKDRZEBW-ClDfyejg.js → dagre-OKDRZEBW-BaeP_npI.js} +1 -1
  28. package/out/renderer/assets/{diagram-SSKATNLV-BECmfn9C.js → diagram-SSKATNLV-BDwSJBgs.js} +1 -1
  29. package/out/renderer/assets/{diagram-VNBRO52H-82BMsx_Z.js → diagram-VNBRO52H-Ce2_qnEd.js} +1 -1
  30. package/out/renderer/assets/{erDiagram-Q7BY3M3F-BiCriqsZ.js → erDiagram-Q7BY3M3F-DUpyMDtK.js} +1 -1
  31. package/out/renderer/assets/{flowDiagram-4HSFHLVR-D4PQMO6X.js → flowDiagram-4HSFHLVR-Twa-e-xh.js} +1 -1
  32. package/out/renderer/assets/{ganttDiagram-APWFNJXF-Rts_QpVD.js → ganttDiagram-APWFNJXF-6IcdZzTN.js} +1 -1
  33. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-B1rxvfyh.js → gitGraphDiagram-7IBYFJ6S-BHwjqSB2.js} +1 -1
  34. package/out/renderer/assets/{graph-DxQCKx-L.js → graph-CjSBt2SL.js} +1 -1
  35. package/out/renderer/assets/{index-XFXAg7sM.js → index-BDqI882o.js} +1 -1
  36. package/out/renderer/assets/{index-BhsV-ipc.js → index-fKRRIb8a.js} +1 -1
  37. package/out/renderer/assets/{index-BJ-AJLyd.js → index-o-e57W52.js} +190 -190
  38. package/out/renderer/assets/{infoDiagram-PH2N3AL5-CDvWuX2O.js → infoDiagram-PH2N3AL5-DusuxGWy.js} +1 -1
  39. package/out/renderer/assets/{journeyDiagram-U35MCT3I-CnefKX-i.js → journeyDiagram-U35MCT3I-ouPHBWbW.js} +1 -1
  40. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-Kd7aNO4_.js → kanban-definition-NDS4AKOZ-BpfzQ_cF.js} +1 -1
  41. package/out/renderer/assets/{layout-CMQ0zdhs.js → layout-DWM2xDwq.js} +1 -1
  42. package/out/renderer/assets/{legacy-agents-page-PBvD5xd9.js → legacy-agents-page-DMWtT-nK.js} +1 -1
  43. package/out/renderer/assets/{mermaid.core-x5Fva3t5.js → mermaid.core-C2AhDEdD.js} +5 -5
  44. package/out/renderer/assets/{mesh-page-IOGN512j.js → mesh-page-DI_FXBTf.js} +1 -1
  45. package/out/renderer/assets/messages-Bf6oXWsi.js +3 -0
  46. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-DJwQ3wYh.js → mindmap-definition-ALO5MXBD-CWFoHd9r.js} +1 -1
  47. package/out/renderer/assets/{mini-DHQCkYmb.js → mini-BVxX6iDv.js} +1 -1
  48. package/out/renderer/assets/{org-access-_jPzS_wW.js → org-access-Cj7MYYx3.js} +1 -1
  49. package/out/renderer/assets/{org-surface-gate-D29XdDTt.js → org-surface-gate-B61_V5sH.js} +1 -1
  50. package/out/renderer/assets/{pieDiagram-IB7DONF6-CW-ezwOn.js → pieDiagram-IB7DONF6-C4p49jAq.js} +1 -1
  51. package/out/renderer/assets/{projects-page-DGLblpIY.js → projects-page-D0OgNUWf.js} +1 -1
  52. package/out/renderer/assets/{publication-validation-ZquLmMLD.js → publication-validation-DLHcjuJy.js} +1 -1
  53. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-cgwnEsXh.js → quadrantDiagram-7GDLP6J5-By3GJSI3.js} +1 -1
  54. package/out/renderer/assets/{radar-MK3ICKWK-DvOkOeQ6.js → radar-MK3ICKWK-n8dqb_zt.js} +1 -1
  55. package/out/renderer/assets/{radient-auth-buttons-y3JK-yD8.js → radient-auth-buttons-p_Axd8pX.js} +1 -1
  56. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-DOMWjtoO.js → requirementDiagram-KVF5MWMF-CQ7JllrS.js} +1 -1
  57. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-CE3E7VO5.js → sankeyDiagram-QLVOVGJD-DNyPn5zx.js} +1 -1
  58. package/out/renderer/assets/{schedules-page-ETT8R0wn.js → schedules-page-R7SXiFmi.js} +1 -1
  59. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-C4EGcl7U.js → sequenceDiagram-X6HHIX6F-CUHeYZkr.js} +1 -1
  60. package/out/renderer/assets/{settings-page-BZDF6UIV.js → settings-page-BZ_HPCkT.js} +60 -60
  61. package/out/renderer/assets/{stateDiagram-DGXRK772-wBbKaUQh.js → stateDiagram-DGXRK772-CL_twVvQ.js} +1 -1
  62. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-ruz5Lapk.js +1 -0
  63. package/out/renderer/assets/{timeline-definition-BDJGKUSR-CgTCOxCY.js → timeline-definition-BDJGKUSR-BCcBGH9R.js} +1 -1
  64. package/out/renderer/assets/{use-download-agent-mutation-DkI3E5yA.js → use-download-agent-mutation-B87MG4sW.js} +1 -1
  65. package/out/renderer/assets/{use-memberships-query-Hv-eprVl.js → use-memberships-query-DCEm9yOI.js} +1 -1
  66. package/out/renderer/assets/{use-session-snapshot-CfEF5TPK.js → use-session-snapshot-CChKOZqb.js} +1 -1
  67. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-G2SxM5sQ.js → xychartDiagram-VJFVF3MP-CvHda-UX.js} +1 -1
  68. package/out/renderer/console-capture.html +3 -3
  69. package/out/renderer/index.html +4 -4
  70. package/out/renderer/mini.html +4 -4
  71. package/package.json +2 -2
  72. package/out/renderer/assets/channel-vM9rusk9.js +0 -1
  73. package/out/renderer/assets/classDiagram-GIVACNV2-BCqIuRq4.js +0 -1
  74. package/out/renderer/assets/classDiagram-v2-COTLJTTW-BCqIuRq4.js +0 -1
  75. package/out/renderer/assets/clone-Bj8HwBLn.js +0 -1
  76. package/out/renderer/assets/messages-D3mGACg6.js +0 -3
  77. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-Bh0k2Dz3.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-XFXAg7sM.js","./messages-D3mGACg6.js","./index-B-uibf5k.js","./index-C7mMgpwT.css","./error-boundary-B4K6A3dS.js","./index-BhsV-ipc.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-x5Fva3t5.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
2
- import{aP as ep,aQ as iQ,aR as soe,aS as loe,aT as Z0,v as tp,aU as VTe,aV as aQ,aW as MTe,G as coe,aX as p6,aY as LTe,y as m6,aZ as FTe,a_ as BTe,e as ca,g as Bl,R as lm,A as uoe,z as g6,a$ as xu,b0 as HTe,u as Kn,b1 as KTe,b2 as JTe,b3 as e_e,b4 as t_e,b5 as xW,b6 as n_e,ax as r_e,aF as i_e,b7 as a_e,aK as o_e,b8 as s_e,b9 as l_e,az as QW,aA as c_e,ba as oQ,bb as np,bc as u_e,bd as kW,be as Ooe,bf as PW,bg as rp,t as va,M as doe,bh as foe,bi as O_e,bj as d_e,bk as f_e,L as Mu,s as h_e,bl as p_e,aM as $6,bm as m_e,D as g_e,r as TW,w as $_e,bn as y_e,bo as hoe,bp as ZE}from"./messages-D3mGACg6.js";import{r as $,b as F,j as h,f as v_e,c as j,g as Jn,w as poe,x as Pv,e as yn,t as DE}from"./index-B-uibf5k.js";import{ac as b_e,c as Me,B as je,ap as y6,D as v6,a as b6,b as w_e,d as w6,f as S_e,l as At,w as y1,x as moe,T as Dd,y as Xd,g as Ou,X as Zi,ad as VE,aC as x_e,aD as Q_e,aE as k_e,A as zl,S as hs,p as goe,q as S6,r as x6,s as Q6,v as Sl,m as a0,n as o0,aB as k6,o as ip,aH as P_e,a0 as T_e,a1 as __e,a2 as X_e,ao as R_e,$ as sQ,M as E_e,W as q_e,Y as j_e,Z as C_e,I as Va,z as $oe,F as yoe,G as voe,H as boe,J as ME,K as z_e,e as LE,L as woe,aI as A_e,C as U_e,k as vo,O as W_e,P as N_e,Q as _W,R as XW,U as Y_e,V as RW,aq as G_e,aJ as I_e,h as Z_e,t as FP,u as EW,E as qW}from"./error-boundary-B4K6A3dS.js";const D_e="superseded_completion_token",V_e="store_busy",M_e="session_is_remote",L_e="owner_build_behind";function F_e(e,t,n){if(!e||typeof e!="object")return!1;const r=e;return r.unseen===!1&&r.conversation_id===`session/${t}`&&r.completion_token===n}function $d(e,t,n){return!t||t.conversation_id!==`session/${n}`||!Array.isArray(t.revision)||t.revision.length!==2||!t.revision.every(r=>Number.isSafeInteger(r)&&r>=0)||e?.conversation_id===t.conversation_id&&(t.revision[0]<e.revision[0]||t.revision[1]<e.revision[1])?e:t.supported===void 0&&e?.supported!==void 0?{...t,supported:e.supported}:t}function Soe(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const xoe=e=>typeof e?.goal_status=="string",Qoe=e=>(e?.goal??"").trim().length>0;function B_e(e,t,n){return n.session_id!==t||n.payload.frontend.snapshot.session_id!==t||!e?!1:e.epoch===n.epoch&&n.seq>e.seq}const s0={notPaired:"This backend was not started with desktop controls.",serverDown:"The Local Operator server is not answering.",frameBudget:"The event stream exceeded its frame budget.",ended:"The event stream ended."},jW={statement:"Lost the connection to this conversation — reconnect to keep reading.",action:"reconnect"},H_e={statement:"The Local Operator server is not running — reconnect once it is back, or restart the app if it stays down.",action:"reconnect"},K_e={statement:"This app is not paired with the Local Operator server, so this conversation cannot be read yet.",action:null},J_e={statement:"Could not load this conversation's history — reconnect to try again.",action:"reconnect"},e2e={statement:"This conversation's updates were too large to display — reconnect to try again.",action:"reconnect"};function CW(e){return e?e===s0.notPaired?K_e:e===s0.serverDown?H_e:e===s0.frameBudget?e2e:jW:jW}async function P6(e){if(window.api?.desktop)try{return await t2e(window.api.desktop.request(e),e)}catch(n){throw n instanceof Ut?n:s2e(n)?new Fc(soe,loe):new Ut(null,"Desktop controls could not reach the backend process.",n)}let t;try{t=await fetch("/__desktop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(n){throw new Ut(null,"Desktop controls could not reach the backend process.",n)}if(!t.ok)throw new Ut(t.status,"Desktop controls need a compatible backend connection.");return t.json()}function t2e(e,t){const n=p6(t);let r;return Promise.race([e,new Promise((i,a)=>{r=setTimeout(()=>{const o=LTe(t.op,n);a(new Ut(null,o.message,void 0,o.code))},n)})]).finally(()=>clearTimeout(r))}const koe="This server did not answer the request for its desktop controls.";class Ut extends Error{status;cause;code;retryAfterMs;detail;constructor(t,n,r,i,a,o){super(n),this.name="DesktopControlError",this.status=t,this.cause=r,this.code=i,this.retryAfterMs=a,this.detail=o}}class Fc extends Error{code;constructor(t,n){super(t),this.name="UserFacingError",this.code=n}}function jo(e,t){return e instanceof Ut||e instanceof Fc?ep(e.code)?iQ[e.code]:e.message:t}function n2e(e,t,n,r){return typeof r=="string"?r:n===Z0.noCredential?tp.noCredential:n===Z0.transportFailed?tp.transportFailed:VTe(aQ(e).path,t)}async function ke(e){const t=await P6(e),n=t.body;if(t.status<200||t.status>=300){const r=typeof n?.detail=="string"?n.detail:typeof n?.detail?.text=="string"?n.detail.text:typeof n?.detail?.message=="string"?n.detail.message:null;throw new Ut(t.status,r??koe,void 0,n2e(e,t.status,r,typeof n?.detail=="object"?n.detail?.code:void 0),typeof n?.detail=="object"&&typeof n.detail?.retry_after_ms=="number"&&Number.isFinite(n.detail.retry_after_ms)?n.detail.retry_after_ms:void 0,typeof n?.detail=="object"?n.detail:void 0)}return e.op==="sessions.list"&&r2e(n?.result),n?.result}function r2e(e){if(typeof e!="object"||e===null)return;const t=MTe(e.delegated_cleanup_notice);t&&coe.getState().receive(t)}async function i2e(){try{await ke({op:"delegated_cleanup_notice.ack"})}catch{}}async function zrn(){coe.getState().dismiss(),await i2e()}function Poe(e){return e instanceof Ut&&e.code===m6}function a2e(e){if(!(e instanceof Ut))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===L_e:e.code===M_e}function o2e(e){return e instanceof Fc&&e.code===loe}function s2e(e){return e instanceof Error&&e.message.includes(soe)}async function jn(e){const t=await P6(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function l2e(e,t=!1){if(window.api?.desktop)return window.api.desktop.openAuthorization(e,t);const n=await ke({op:"auth.status",id:e});if(!n.auth_url)throw new Error("This sign-in is no longer waiting for a browser.");const r=new URL(n.auth_url);if(r.username||r.password||r.protocol!=="https:"&&!(r.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(r.hostname)))throw new Error("The provider returned an invalid sign-in address.");window.open(r.href,"_blank","noopener,noreferrer")}function c2e(e,t){const n=window.api?.desktop?.stream;if(n){const a=n.subscribe(e,t);return()=>a.dispose()}const r=new URLSearchParams({session:e.sessionId});e.epoch&&r.set("epoch",e.epoch),e.afterSeq!==void 0&&r.set("after_seq",String(e.afterSeq)),r.set("frontend_replace","1"),e.openFrame===!0&&r.set("open_frame","1"),e.journalOrder===!0&&(r.set("journal_order","1"),e.peerJournalSource===!0&&r.set("peer_journal_source","1"),FTe(r,"/__desktop/stream",e.orderIds??[]));const i=new EventSource(`/__desktop/stream?${r}`);return i.onmessage=a=>{t({kind:"data",data:a.data})},i.onerror=()=>{i.readyState===EventSource.CLOSED&&(t({kind:"error",detail:s0.ended}),i.close())},()=>{i.close(),t({kind:"end"})}}async function uO(e,t){const n=window.api?.desktop?.media;if(n)return n(e,t);const r=await fetch("/__desktop/media",{method:"POST",headers:{"x-desktop-media":JSON.stringify(e),"Content-Type":"application/octet-stream"},body:t?new Blob([t]):void 0}),i=r.headers.get("content-type")??"";if(!r.ok){let a="The media request failed.",o;if(i.includes("application/json"))try{const l=(await r.json())?.detail;if(typeof l=="string")a=l;else if(typeof l=="object"&&l!==null){const c=l;typeof c.text=="string"&&c.text.trim()?a=c.text:typeof c.message=="string"&&c.message.trim()&&(a=c.message),typeof c.code=="string"&&(o=c.code)}}catch{}return{status:r.status,kind:"error",detail:a,code:o!==void 0&&ep(o)?o:a===Z0.noCredential?tp.noCredential:void 0}}return i.includes("application/json")?{status:r.status,kind:"json",body:await r.json()}:{status:r.status,kind:"bytes",mimeType:i||"application/octet-stream",data:new Uint8Array(await r.arrayBuffer())}}function D0(e){return e.kind==="error"?ep(e.code)?new Fc(iQ[e.code],e.code):new Error(e.detail):new Error("The media request returned an unexpected response.")}const FE=e=>({revision:Do(e),demand:e.orderDemand}),Rd=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function ap(e,t,n,r,i,a={}){let o=e;const s=t.journal_generation;if(t.reconcile===!0){const d=typeof s=="string"&&s.length>0?s:void 0;return o.orderNeedsReconcile&&o.orderWantedGeneration===d?o.journalMode?o:{...o,journalMode:!0}:{...o,journalMode:!0,orderNeedsReconcile:!0,orderWantedGeneration:d,orderDemand:d!==void 0?{generation:d}:{}}}if(typeof s!="string"||s.length===0)return t.journal_order_state&&t.journal_order_state!=="unsupported"&&!o.journalMode?{...o,journalMode:!0}:o;if(r&&t.journal_order_state==="ready"&&i&&o.orderNeedsReconcile&&o.orderDemand===i.demand&&(o={...o,orderNeedsReconcile:!1,orderWantedGeneration:void 0,orderDemand:void 0}),s!==o.journalGeneration&&!r)return o.orderNeedsReconcile&&o.orderWantedGeneration===s?o:{...o,orderNeedsReconcile:!0,orderWantedGeneration:s,orderDemand:{generation:s}};let l=o.journalMode?o:{...o,journalMode:!0};if(s!==o.journalGeneration&&(l={...o,journalMode:!0,journalGeneration:s,orderRevision:(o.orderRevision??0)+1,journalPositions:new Map,orderNeedsReconcile:o.orderNeedsReconcile,orderWantedGeneration:o.orderWantedGeneration,orderDemand:o.orderDemand},a.peer===!0)){const d=(o.orderRevision??0)+1,f=new Map;for(const p of o.records){const m=p.sourceEntryId??(p.kind==="tool"||p.kind==="supplement"?null:p.id);typeof m=="string"&&m.length>0&&m.length<=128&&f.set(m,d)}l={...l,...f.size>0?{journalBodyOwed:f}:{},journalSourceVoid:void 0}}let c=l.journalPositions??new Map;const u=c,O=(d,f,p)=>{if(!Rd(p))return;const m=c.get(d);m&&m.seq>=p||(c===u&&(c=new Map(c)),c.set(d,{entryId:f,seq:p}))};for(const[d,f]of Object.entries(t.journal_ordinals??{}))O(d,d,f);for(const d of n)typeof d.id=="string"&&(O(d.id,d.id,d.journal_seq),d.role==="tool"&&typeof d.tool_call_id=="string"&&O(`tool:${d.tool_call_id}`,d.id,d.journal_seq),typeof d.anchor=="string"&&O(`supplement:${d.anchor}`,d.id,d.journal_seq));return c!==u&&(l={...l,journalPositions:c}),l}function T6(e,t){if(!e.journalMode||typeof t.id!="string"||!Array.isArray(t.tool_calls))return e;let n=e.journalCallOwners??new Map,r=e.journalCallSlots??new Map;const i=n,a=r;return t.tool_calls.forEach((o,s)=>{!o||typeof o.id!="string"||(n.get(o.id)!==t.id&&(n===i&&(n=new Map(n)),n.set(o.id,t.id)),r.get(o.id)!==s&&(r===a&&(r=new Map(r)),r.set(o.id,s)))}),n===i&&r===a?e:{...e,journalCallOwners:n,journalCallSlots:r}}function Toe(e,t){const n=new Set(e.map(a=>a.id));let r=!1,i;for(let a=0;a<e.length;a++){const o=e[a];if(o.kind==="user"&&o.provisional===!0){i=o;continue}!t(o)&&i&&(o.sourceAdmissionAnchor===void 0||!n.has(o.sourceAdmissionAnchor))&&(e[a]={...o,sourceAdmissionAnchor:i.id},r=!0),i=e[a]}return r}function _oe(e,t,n,r,i){const a=[],o=new Set;let s=e,l;for(;s!==void 0;){if(i.has(s.id)){l=i.get(s.id);break}if(n(s)){l=r(s);break}if(s.kind==="user"&&s.provisional===!0||o.has(s.id))break;o.add(s.id),a.push(s.id),s=s.sourceAdmissionAnchor?t.get(s.sourceAdmissionAnchor):void 0}for(const c of a)i.set(c,l);return l}function Xoe(e,t){const n=new Map;return r=>{if(!r)return;const i=t(r);if(i===void 0)return;const a=[],o=new Set;let s=r,l=!0;for(;s;){if(n.has(s.id)){l=n.get(s.id)===!0;break}if(o.has(s.id)||t(s)===void 0){l=!1;break}o.add(s.id),a.push(s.id),s=s.sourceAdmissionAnchor===void 0?void 0:e.get(s.sourceAdmissionAnchor)}for(const c of a)n.set(c,l);return l?i:void 0}}function v1(e,t){const n=e.journalCallOwners,r=e.journalCallSlots;if(!n||!r)return t;const i=new Map;t.forEach((o,s)=>{if(o.kind!=="tool")return;const l=n.get(o.toolCallId);if(l===void 0||!r.has(o.toolCallId))return;const c=i.get(l);c?c.push(s):i.set(l,[s])});let a=t;for(const o of i.values()){if(o.length<2)continue;const s=o.map(l=>t[l]).sort((l,c)=>(r.get(l.toolCallId)??0)-(r.get(c.toolCallId)??0));s.every((l,c)=>l===t[o[c]])||(a===t&&(a=t.slice()),o.forEach((l,c)=>{a[l]=s[c]}))}return a}function Roe(e,t){if(!e.journalMode)return t;if(e.journalPeerSource===!0)return u2e(e,t);const n=e.journalGeneration,r=e.journalPositions;let i=!1;const a=t.map(f=>{let m=[r?.get(f.sourceEntryId??f.id),r?.get(f.id)].filter(v=>v!==void 0).sort((v,S)=>S.seq-v.seq)[0];if(f.journalGeneration===n&&Rd(f.journalSeq)&&(!m||f.journalSeq>m.seq)&&(m={entryId:f.sourceEntryId??f.id,seq:f.journalSeq}),!m||!n||!(f.kind==="user"&&(f.provisional===!0||f.local===!0))&&f.sourceEntryId===m.entryId&&f.journalSeq===m.seq&&f.journalGeneration===n)return f;i=!0;let y={...f,sourceEntryId:m.entryId,journalSeq:m.seq,journalGeneration:n};if(y.kind==="user"){const{provisional:v,local:S,...x}=y;y=x}return y});Toe(a,f=>f.journalGeneration===n&&Rd(f.journalSeq))&&(i=!0);const s=new Map,l=new Map(a.map(f=>[f.id,f])),c=Xoe(l,f=>f!==void 0&&f.journalGeneration===n&&Rd(f.journalSeq)?f.journalSeq:void 0),u=f=>c(f)!==void 0,O=(f,p)=>{const m=c(f);if(f.kind==="user"&&f.provisional===!0&&m===void 0)return[1,0,0,0,p];const g=f.kind==="supplement"?f.anchor:f.kind==="tool"?e.journalCallOwners?.get(f.toolCallId)??e.argsByCall.get(f.toolCallId)?.anchorId:void 0,y=typeof g=="string"?c(l.get(g)):void 0,v=m===void 0?_oe(f,l,u,c,s):void 0,S=y??m??v;return S===void 0?[1,0,0,0,p]:[0,S,y!==void 0?1:m!==void 0?0:2,m??Number.MAX_SAFE_INTEGER,p]},d=a.map((f,p)=>({record:f,index:p,rank:O(f,p)}));return d.sort((f,p)=>{for(let m=0;m<f.rank.length;m++){const g=f.rank[m]-p.rank[m];if(g)return g}return 0}),!i&&d.every((f,p)=>f.index===p)?v1(e,t):v1(e,d.map(f=>f.record))}function u2e(e,t){const n=e.journalGeneration,r=e.journalPositions,i=new Map;for(const m of t){let y=[r?.get(m.sourceEntryId??m.id),r?.get(m.id)].filter(v=>v!==void 0).sort((v,S)=>S.seq-v.seq)[0];m.journalGeneration===n&&Rd(m.journalSeq)&&(!y||m.journalSeq>y.seq)&&(y={entryId:m.sourceEntryId??m.id,seq:m.journalSeq}),y&&i.set(m.id,y)}const a=m=>m===void 0?void 0:i.get(m.id)??r?.get(m.sourceEntryId??m.id)??r?.get(m.id);let o=!1;const s=t.slice();Toe(s,m=>m.journalGeneration===n&&Rd(m.journalSeq))&&(o=!0);const c=new Map,u=new Map(s.map(m=>[m.id,m])),O=Xoe(u,m=>a(m)?.seq),d=m=>O(m)!==void 0,f=(m,g)=>{const y=O(m);if(m.kind==="user"&&m.provisional===!0&&y===void 0)return[1,0,0,0,g];const v=m.kind==="supplement"?m.anchor:m.kind==="tool"?e.journalCallOwners?.get(m.toolCallId)??e.argsByCall.get(m.toolCallId)?.anchorId:void 0,S=typeof v=="string"?O(u.get(v)):void 0,x=y===void 0?_oe(m,u,d,O,c):void 0,b=S??y??x;return b===void 0?[1,0,0,0,g]:[0,b,S!==void 0?1:y!==void 0?0:2,y??Number.MAX_SAFE_INTEGER,g]},p=s.map((m,g)=>({record:m,index:g,rank:f(m,g)}));return p.sort((m,g)=>{for(let y=0;y<m.rank.length;y++){const v=m.rank[y]-g.rank[y];if(v)return v}return 0}),!o&&p.every((m,g)=>m.index===g)?v1(e,t):v1(e,p.map(m=>m.record))}function pl(e){const t=e.records.filter(i=>i.kind==="user"&&i.provisional===!0),n=e.records.filter(i=>i.journalGeneration!==e.journalGeneration||!Rd(i.journalSeq)),r=[...t,...n].map(i=>i.sourceEntryId??(i.kind==="tool"||i.kind==="supplement"?null:i.id));if(r.push(..._6(e)),e.journalPositions?.has(e.oldestId??"")||r.push(e.oldestId),e.journalSourceVoid?.size)for(let i=r.length-1;i>=0;i--){const a=r[i];typeof a=="string"&&e.journalSourceVoid.has(a)&&r.splice(i,1)}return[...new Set(r.filter(i=>typeof i=="string"&&i.length>0&&i.length<=128))]}function _6(e){if(e.journalPeerSource!==!0||!e.journalBodyOwed)return[];const t=new Set;for(const r of e.records){const i=r.sourceEntryId??(r.kind==="tool"||r.kind==="supplement"?null:r.id);typeof i=="string"&&i.length>0&&i.length<=128&&t.add(i)}const n=[];for(const r of e.journalBodyOwed.keys())r.length<1||r.length>128||t.has(r)&&(e.journalSourceVoid?.has(r)||n.push(r));return n}function Eoe(e,t){const n=e.journalPositions;return pl(e).filter(r=>!n?.has(r)&&!t?.has(r))}const Do=e=>e.orderRevision??0;async function O2e(e){const t=new Map,n=s=>{let l=t.get(s);return l||(l=new Set,t.set(s,l)),l},r=(s,l)=>l==="payload"?_6(s):l==="lookup"?Eoe(s):pl(s);let i=e.getTranscript().journalGeneration,a=0,o=0;for(;;){if(!e.isCurrent())return{kind:"stale"};const s=e.getTranscript(),l=FE(s),c=l.revision,u=e.sweep?.(s,n);if(u?.kind==="none")return{kind:"complete",transcript:s};const O=u?.kind??"authority",d=BTe(r(s,O).filter(g=>!n(O).has(g)),u?.path??e.lookupPath,u?.query??new URLSearchParams({journal_order:"1"})),f=await e.read(d,O);if(!e.isCurrent()||Do(e.getTranscript())!==c)return{kind:"stale"};if(e.commit(f,c,l),!e.isCurrent())return{kind:"stale"};const p=e.getTranscript(),m=e.page(f);if(m.journal_order_state==="ready"&&m.journal_generation===p.journalGeneration){m.journal_generation!==i&&(t.clear(),i=m.journal_generation);for(const v of d)n(O).add(v);if(p.orderNeedsReconcile){if(p.orderDemand===l.demand||a===1)return{kind:"waiting"};a++,t.clear();continue}if(O==="payload"){const v=(m.source_retry_ids??[]).filter(S=>typeof S=="string"&&S.length>0&&S.length<=128);if(v.length>0&&d.length>1&&o===0){o++;for(const S of v)n("payload").delete(S);continue}}const g=e.sweep?.(p,n);if(g?.kind==="none")return{kind:"complete",transcript:p};const y=g?.kind??"authority";if(r(p,y).some(v=>!n(y).has(v)))continue;return{kind:"complete",transcript:p}}if(!p.orderNeedsReconcile||p.orderDemand===l.demand||a===1)return{kind:"waiting"};a++,t.clear()}}function Us(e){const t=e.payload,n=t?.tool_call_id;if(t?.role==="tool"&&typeof n=="string"&&n)return`tool:${n}`;const i=(t?.details??{}).anchor;return t?.custom_type==="completion_attention"&&typeof i=="string"&&i?i:e.id}function BP(e){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.trunc(e))}function zW(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e}function Arn(e){if(!e||e.runs_state!=="ready")return null;const t=e.runs;if(!t||t.length===0)return null;const n=new Map;for(const a of t){if(!a.settled||typeof a.run_key!="string"||a.run_key.length===0)continue;const o=BP(a.action_count);if(o===null)continue;const s={actions:o,workedSeconds:zW(a.worked_seconds),failed:BP(a.failed_count)??0,complete:a.complete!==!1,openingUserId:typeof a.opening_user_id=="string"&&a.opening_user_id.length>0?a.opening_user_id:null,closingAnswerId:typeof a.closing_answer_id=="string"&&a.closing_answer_id.length>0?a.closing_answer_id:null,crossSessionActions:BP(a.cross_session_action_count),crossSessionWorkedSeconds:zW(a.cross_session_worked_seconds)};n.set(a.run_key,s),s.openingUserId!==null&&n.set(s.openingUserId,s),s.closingAnswerId!==null&&n.set(s.closingAnswerId,s)}if(n.size===0)return null;const r=new Set;for(const a of e.entries)r.add(Us(a));const i=e.entries[e.entries.length-1];return{runs:n,page:{ids:r,newestKey:i?Us(i):null}}}function d2e(e){if(!e||e.runs_state!=="ready"||e.head_cut===!0)return null;const t=e.runs,n=e.entries[0];if(!n||!t||t.length===0||!t.find(a=>a.opening_user_id===n.id))return null;const i=Math.round((n.ts??0)*1e3);return i>0?{id:n.id,tsMs:i}:null}function f2e(e,t,n){const r=d2e(e),i=e?.entries;if(r===null||!i||i.length===0)return!1;const a=Math.round((i[i.length-1].ts??0)*1e3);if(!(a>r.tsMs))return!1;for(const[o,s]of t)if(!n.has(o)&&(s===null||!(s>r.tsMs)||!(s<a)))return!1;return!0}const h2e=new Map([["This changes your instructions. Apply it from now on, and drop work it makes pointless.","steer"],["Answer it now with the `hub` tool — a short, direct reply — then carry on with what you were doing. Do not restructure your work around the question.","ask"],["This is a note, not a question. No reply is needed unless it changes what you should do.","note"]]),p2e=/\blabel=(['"])(.*?)\1/,m2e=/\bjob=(['"])(.*?)\1/,g2e=/^<(parent-message|subagent-message)\b[^>]*>\n([\s\S]*)\n<\/\1>$/;function BE(e){const t=typeof e.text=="string"?e.text:"",n=g2e.exec(t);let r=n?.[2];const i=r?.indexOf(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-BDqI882o.js","./messages-Bf6oXWsi.js","./index-B-uibf5k.js","./index-C7mMgpwT.css","./error-boundary-B4K6A3dS.js","./index-fKRRIb8a.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-C2AhDEdD.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
2
+ import{aR as ep,aS as iQ,aT as soe,aU as loe,aV as Z0,v as tp,aW as VTe,aX as aQ,aY as MTe,G as coe,aZ as p6,a_ as LTe,y as m6,a$ as FTe,b0 as BTe,e as ca,g as Bl,R as lm,A as uoe,z as g6,b1 as xu,b2 as HTe,u as Kn,b3 as KTe,b4 as JTe,b5 as e_e,b6 as t_e,b7 as xW,b8 as n_e,ax as r_e,aF as i_e,b9 as a_e,aM as o_e,ba as s_e,bb as l_e,az as QW,aA as c_e,bc as oQ,bd as np,be as u_e,bf as kW,bg as Ooe,bh as PW,bi as rp,t as va,M as doe,bj as foe,bk as O_e,bl as d_e,bm as f_e,L as Mu,s as h_e,bn as p_e,aO as $6,bo as m_e,D as g_e,r as TW,w as $_e,bp as y_e,bq as hoe,br as ZE}from"./messages-Bf6oXWsi.js";import{r as $,b as F,j as h,f as v_e,c as j,g as Jn,w as poe,x as Pv,e as yn,t as DE}from"./index-B-uibf5k.js";import{ac as b_e,c as Me,B as je,ap as y6,D as v6,a as b6,b as w_e,d as w6,f as S_e,l as At,w as y1,x as moe,T as Dd,y as Xd,g as Ou,X as Zi,ad as VE,aC as x_e,aD as Q_e,aE as k_e,A as zl,S as hs,p as goe,q as S6,r as x6,s as Q6,v as Sl,m as a0,n as o0,aB as k6,o as ip,aH as P_e,a0 as T_e,a1 as __e,a2 as X_e,ao as R_e,$ as sQ,M as E_e,W as q_e,Y as j_e,Z as C_e,I as Va,z as $oe,F as yoe,G as voe,H as boe,J as ME,K as z_e,e as LE,L as woe,aI as A_e,C as U_e,k as vo,O as W_e,P as N_e,Q as _W,R as XW,U as Y_e,V as RW,aq as G_e,aJ as I_e,h as Z_e,t as FP,u as EW,E as qW}from"./error-boundary-B4K6A3dS.js";const D_e="superseded_completion_token",V_e="store_busy",M_e="session_is_remote",L_e="owner_build_behind";function F_e(e,t,n){if(!e||typeof e!="object")return!1;const r=e;return r.unseen===!1&&r.conversation_id===`session/${t}`&&r.completion_token===n}function $d(e,t,n){return!t||t.conversation_id!==`session/${n}`||!Array.isArray(t.revision)||t.revision.length!==2||!t.revision.every(r=>Number.isSafeInteger(r)&&r>=0)||e?.conversation_id===t.conversation_id&&(t.revision[0]<e.revision[0]||t.revision[1]<e.revision[1])?e:t.supported===void 0&&e?.supported!==void 0?{...t,supported:e.supported}:t}function Soe(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.round(t*1e3):null}const xoe=e=>typeof e?.goal_status=="string",Qoe=e=>(e?.goal??"").trim().length>0;function B_e(e,t,n){return n.session_id!==t||n.payload.frontend.snapshot.session_id!==t||!e?!1:e.epoch===n.epoch&&n.seq>e.seq}const s0={notPaired:"This backend was not started with desktop controls.",serverDown:"The Local Operator server is not answering.",frameBudget:"The event stream exceeded its frame budget.",ended:"The event stream ended."},jW={statement:"Lost the connection to this conversation — reconnect to keep reading.",action:"reconnect"},H_e={statement:"The Local Operator server is not running — reconnect once it is back, or restart the app if it stays down.",action:"reconnect"},K_e={statement:"This app is not paired with the Local Operator server, so this conversation cannot be read yet.",action:null},J_e={statement:"Could not load this conversation's history — reconnect to try again.",action:"reconnect"},e2e={statement:"This conversation's updates were too large to display — reconnect to try again.",action:"reconnect"};function CW(e){return e?e===s0.notPaired?K_e:e===s0.serverDown?H_e:e===s0.frameBudget?e2e:jW:jW}async function P6(e){if(window.api?.desktop)try{return await t2e(window.api.desktop.request(e),e)}catch(n){throw n instanceof Ut?n:s2e(n)?new Fc(soe,loe):new Ut(null,"Desktop controls could not reach the backend process.",n)}let t;try{t=await fetch("/__desktop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(n){throw new Ut(null,"Desktop controls could not reach the backend process.",n)}if(!t.ok)throw new Ut(t.status,"Desktop controls need a compatible backend connection.");return t.json()}function t2e(e,t){const n=p6(t);let r;return Promise.race([e,new Promise((i,a)=>{r=setTimeout(()=>{const o=LTe(t.op,n);a(new Ut(null,o.message,void 0,o.code))},n)})]).finally(()=>clearTimeout(r))}const koe="This server did not answer the request for its desktop controls.";class Ut extends Error{status;cause;code;retryAfterMs;detail;constructor(t,n,r,i,a,o){super(n),this.name="DesktopControlError",this.status=t,this.cause=r,this.code=i,this.retryAfterMs=a,this.detail=o}}class Fc extends Error{code;constructor(t,n){super(t),this.name="UserFacingError",this.code=n}}function jo(e,t){return e instanceof Ut||e instanceof Fc?ep(e.code)?iQ[e.code]:e.message:t}function n2e(e,t,n,r){return typeof r=="string"?r:n===Z0.noCredential?tp.noCredential:n===Z0.transportFailed?tp.transportFailed:VTe(aQ(e).path,t)}async function ke(e){const t=await P6(e),n=t.body;if(t.status<200||t.status>=300){const r=typeof n?.detail=="string"?n.detail:typeof n?.detail?.text=="string"?n.detail.text:typeof n?.detail?.message=="string"?n.detail.message:null;throw new Ut(t.status,r??koe,void 0,n2e(e,t.status,r,typeof n?.detail=="object"?n.detail?.code:void 0),typeof n?.detail=="object"&&typeof n.detail?.retry_after_ms=="number"&&Number.isFinite(n.detail.retry_after_ms)?n.detail.retry_after_ms:void 0,typeof n?.detail=="object"?n.detail:void 0)}return e.op==="sessions.list"&&r2e(n?.result),n?.result}function r2e(e){if(typeof e!="object"||e===null)return;const t=MTe(e.delegated_cleanup_notice);t&&coe.getState().receive(t)}async function i2e(){try{await ke({op:"delegated_cleanup_notice.ack"})}catch{}}async function zrn(){coe.getState().dismiss(),await i2e()}function Poe(e){return e instanceof Ut&&e.code===m6}function a2e(e){if(!(e instanceof Ut))return!1;const t=e.detail?.cause;return typeof t=="string"&&t.length>0?t===L_e:e.code===M_e}function o2e(e){return e instanceof Fc&&e.code===loe}function s2e(e){return e instanceof Error&&e.message.includes(soe)}async function jn(e){const t=await P6(e);return new Response(t.status===204?null:JSON.stringify(t.body),{status:t.status,headers:{"Content-Type":"application/json"}})}async function l2e(e,t=!1){if(window.api?.desktop)return window.api.desktop.openAuthorization(e,t);const n=await ke({op:"auth.status",id:e});if(!n.auth_url)throw new Error("This sign-in is no longer waiting for a browser.");const r=new URL(n.auth_url);if(r.username||r.password||r.protocol!=="https:"&&!(r.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(r.hostname)))throw new Error("The provider returned an invalid sign-in address.");window.open(r.href,"_blank","noopener,noreferrer")}function c2e(e,t){const n=window.api?.desktop?.stream;if(n){const a=n.subscribe(e,t);return()=>a.dispose()}const r=new URLSearchParams({session:e.sessionId});e.epoch&&r.set("epoch",e.epoch),e.afterSeq!==void 0&&r.set("after_seq",String(e.afterSeq)),r.set("frontend_replace","1"),e.openFrame===!0&&r.set("open_frame","1"),e.journalOrder===!0&&(r.set("journal_order","1"),e.peerJournalSource===!0&&r.set("peer_journal_source","1"),FTe(r,"/__desktop/stream",e.orderIds??[]));const i=new EventSource(`/__desktop/stream?${r}`);return i.onmessage=a=>{t({kind:"data",data:a.data})},i.onerror=()=>{i.readyState===EventSource.CLOSED&&(t({kind:"error",detail:s0.ended}),i.close())},()=>{i.close(),t({kind:"end"})}}async function uO(e,t){const n=window.api?.desktop?.media;if(n)return n(e,t);const r=await fetch("/__desktop/media",{method:"POST",headers:{"x-desktop-media":JSON.stringify(e),"Content-Type":"application/octet-stream"},body:t?new Blob([t]):void 0}),i=r.headers.get("content-type")??"";if(!r.ok){let a="The media request failed.",o;if(i.includes("application/json"))try{const l=(await r.json())?.detail;if(typeof l=="string")a=l;else if(typeof l=="object"&&l!==null){const c=l;typeof c.text=="string"&&c.text.trim()?a=c.text:typeof c.message=="string"&&c.message.trim()&&(a=c.message),typeof c.code=="string"&&(o=c.code)}}catch{}return{status:r.status,kind:"error",detail:a,code:o!==void 0&&ep(o)?o:a===Z0.noCredential?tp.noCredential:void 0}}return i.includes("application/json")?{status:r.status,kind:"json",body:await r.json()}:{status:r.status,kind:"bytes",mimeType:i||"application/octet-stream",data:new Uint8Array(await r.arrayBuffer())}}function D0(e){return e.kind==="error"?ep(e.code)?new Fc(iQ[e.code],e.code):new Error(e.detail):new Error("The media request returned an unexpected response.")}const FE=e=>({revision:Do(e),demand:e.orderDemand}),Rd=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>=0;function ap(e,t,n,r,i,a={}){let o=e;const s=t.journal_generation;if(t.reconcile===!0){const d=typeof s=="string"&&s.length>0?s:void 0;return o.orderNeedsReconcile&&o.orderWantedGeneration===d?o.journalMode?o:{...o,journalMode:!0}:{...o,journalMode:!0,orderNeedsReconcile:!0,orderWantedGeneration:d,orderDemand:d!==void 0?{generation:d}:{}}}if(typeof s!="string"||s.length===0)return t.journal_order_state&&t.journal_order_state!=="unsupported"&&!o.journalMode?{...o,journalMode:!0}:o;if(r&&t.journal_order_state==="ready"&&i&&o.orderNeedsReconcile&&o.orderDemand===i.demand&&(o={...o,orderNeedsReconcile:!1,orderWantedGeneration:void 0,orderDemand:void 0}),s!==o.journalGeneration&&!r)return o.orderNeedsReconcile&&o.orderWantedGeneration===s?o:{...o,orderNeedsReconcile:!0,orderWantedGeneration:s,orderDemand:{generation:s}};let l=o.journalMode?o:{...o,journalMode:!0};if(s!==o.journalGeneration&&(l={...o,journalMode:!0,journalGeneration:s,orderRevision:(o.orderRevision??0)+1,journalPositions:new Map,orderNeedsReconcile:o.orderNeedsReconcile,orderWantedGeneration:o.orderWantedGeneration,orderDemand:o.orderDemand},a.peer===!0)){const d=(o.orderRevision??0)+1,f=new Map;for(const p of o.records){const m=p.sourceEntryId??(p.kind==="tool"||p.kind==="supplement"?null:p.id);typeof m=="string"&&m.length>0&&m.length<=128&&f.set(m,d)}l={...l,...f.size>0?{journalBodyOwed:f}:{},journalSourceVoid:void 0}}let c=l.journalPositions??new Map;const u=c,O=(d,f,p)=>{if(!Rd(p))return;const m=c.get(d);m&&m.seq>=p||(c===u&&(c=new Map(c)),c.set(d,{entryId:f,seq:p}))};for(const[d,f]of Object.entries(t.journal_ordinals??{}))O(d,d,f);for(const d of n)typeof d.id=="string"&&(O(d.id,d.id,d.journal_seq),d.role==="tool"&&typeof d.tool_call_id=="string"&&O(`tool:${d.tool_call_id}`,d.id,d.journal_seq),typeof d.anchor=="string"&&O(`supplement:${d.anchor}`,d.id,d.journal_seq));return c!==u&&(l={...l,journalPositions:c}),l}function T6(e,t){if(!e.journalMode||typeof t.id!="string"||!Array.isArray(t.tool_calls))return e;let n=e.journalCallOwners??new Map,r=e.journalCallSlots??new Map;const i=n,a=r;return t.tool_calls.forEach((o,s)=>{!o||typeof o.id!="string"||(n.get(o.id)!==t.id&&(n===i&&(n=new Map(n)),n.set(o.id,t.id)),r.get(o.id)!==s&&(r===a&&(r=new Map(r)),r.set(o.id,s)))}),n===i&&r===a?e:{...e,journalCallOwners:n,journalCallSlots:r}}function Toe(e,t){const n=new Set(e.map(a=>a.id));let r=!1,i;for(let a=0;a<e.length;a++){const o=e[a];if(o.kind==="user"&&o.provisional===!0){i=o;continue}!t(o)&&i&&(o.sourceAdmissionAnchor===void 0||!n.has(o.sourceAdmissionAnchor))&&(e[a]={...o,sourceAdmissionAnchor:i.id},r=!0),i=e[a]}return r}function _oe(e,t,n,r,i){const a=[],o=new Set;let s=e,l;for(;s!==void 0;){if(i.has(s.id)){l=i.get(s.id);break}if(n(s)){l=r(s);break}if(s.kind==="user"&&s.provisional===!0||o.has(s.id))break;o.add(s.id),a.push(s.id),s=s.sourceAdmissionAnchor?t.get(s.sourceAdmissionAnchor):void 0}for(const c of a)i.set(c,l);return l}function Xoe(e,t){const n=new Map;return r=>{if(!r)return;const i=t(r);if(i===void 0)return;const a=[],o=new Set;let s=r,l=!0;for(;s;){if(n.has(s.id)){l=n.get(s.id)===!0;break}if(o.has(s.id)||t(s)===void 0){l=!1;break}o.add(s.id),a.push(s.id),s=s.sourceAdmissionAnchor===void 0?void 0:e.get(s.sourceAdmissionAnchor)}for(const c of a)n.set(c,l);return l?i:void 0}}function v1(e,t){const n=e.journalCallOwners,r=e.journalCallSlots;if(!n||!r)return t;const i=new Map;t.forEach((o,s)=>{if(o.kind!=="tool")return;const l=n.get(o.toolCallId);if(l===void 0||!r.has(o.toolCallId))return;const c=i.get(l);c?c.push(s):i.set(l,[s])});let a=t;for(const o of i.values()){if(o.length<2)continue;const s=o.map(l=>t[l]).sort((l,c)=>(r.get(l.toolCallId)??0)-(r.get(c.toolCallId)??0));s.every((l,c)=>l===t[o[c]])||(a===t&&(a=t.slice()),o.forEach((l,c)=>{a[l]=s[c]}))}return a}function Roe(e,t){if(!e.journalMode)return t;if(e.journalPeerSource===!0)return u2e(e,t);const n=e.journalGeneration,r=e.journalPositions;let i=!1;const a=t.map(f=>{let m=[r?.get(f.sourceEntryId??f.id),r?.get(f.id)].filter(v=>v!==void 0).sort((v,S)=>S.seq-v.seq)[0];if(f.journalGeneration===n&&Rd(f.journalSeq)&&(!m||f.journalSeq>m.seq)&&(m={entryId:f.sourceEntryId??f.id,seq:f.journalSeq}),!m||!n||!(f.kind==="user"&&(f.provisional===!0||f.local===!0))&&f.sourceEntryId===m.entryId&&f.journalSeq===m.seq&&f.journalGeneration===n)return f;i=!0;let y={...f,sourceEntryId:m.entryId,journalSeq:m.seq,journalGeneration:n};if(y.kind==="user"){const{provisional:v,local:S,...x}=y;y=x}return y});Toe(a,f=>f.journalGeneration===n&&Rd(f.journalSeq))&&(i=!0);const s=new Map,l=new Map(a.map(f=>[f.id,f])),c=Xoe(l,f=>f!==void 0&&f.journalGeneration===n&&Rd(f.journalSeq)?f.journalSeq:void 0),u=f=>c(f)!==void 0,O=(f,p)=>{const m=c(f);if(f.kind==="user"&&f.provisional===!0&&m===void 0)return[1,0,0,0,p];const g=f.kind==="supplement"?f.anchor:f.kind==="tool"?e.journalCallOwners?.get(f.toolCallId)??e.argsByCall.get(f.toolCallId)?.anchorId:void 0,y=typeof g=="string"?c(l.get(g)):void 0,v=m===void 0?_oe(f,l,u,c,s):void 0,S=y??m??v;return S===void 0?[1,0,0,0,p]:[0,S,y!==void 0?1:m!==void 0?0:2,m??Number.MAX_SAFE_INTEGER,p]},d=a.map((f,p)=>({record:f,index:p,rank:O(f,p)}));return d.sort((f,p)=>{for(let m=0;m<f.rank.length;m++){const g=f.rank[m]-p.rank[m];if(g)return g}return 0}),!i&&d.every((f,p)=>f.index===p)?v1(e,t):v1(e,d.map(f=>f.record))}function u2e(e,t){const n=e.journalGeneration,r=e.journalPositions,i=new Map;for(const m of t){let y=[r?.get(m.sourceEntryId??m.id),r?.get(m.id)].filter(v=>v!==void 0).sort((v,S)=>S.seq-v.seq)[0];m.journalGeneration===n&&Rd(m.journalSeq)&&(!y||m.journalSeq>y.seq)&&(y={entryId:m.sourceEntryId??m.id,seq:m.journalSeq}),y&&i.set(m.id,y)}const a=m=>m===void 0?void 0:i.get(m.id)??r?.get(m.sourceEntryId??m.id)??r?.get(m.id);let o=!1;const s=t.slice();Toe(s,m=>m.journalGeneration===n&&Rd(m.journalSeq))&&(o=!0);const c=new Map,u=new Map(s.map(m=>[m.id,m])),O=Xoe(u,m=>a(m)?.seq),d=m=>O(m)!==void 0,f=(m,g)=>{const y=O(m);if(m.kind==="user"&&m.provisional===!0&&y===void 0)return[1,0,0,0,g];const v=m.kind==="supplement"?m.anchor:m.kind==="tool"?e.journalCallOwners?.get(m.toolCallId)??e.argsByCall.get(m.toolCallId)?.anchorId:void 0,S=typeof v=="string"?O(u.get(v)):void 0,x=y===void 0?_oe(m,u,d,O,c):void 0,b=S??y??x;return b===void 0?[1,0,0,0,g]:[0,b,S!==void 0?1:y!==void 0?0:2,y??Number.MAX_SAFE_INTEGER,g]},p=s.map((m,g)=>({record:m,index:g,rank:f(m,g)}));return p.sort((m,g)=>{for(let y=0;y<m.rank.length;y++){const v=m.rank[y]-g.rank[y];if(v)return v}return 0}),!o&&p.every((m,g)=>m.index===g)?v1(e,t):v1(e,p.map(m=>m.record))}function pl(e){const t=e.records.filter(i=>i.kind==="user"&&i.provisional===!0),n=e.records.filter(i=>i.journalGeneration!==e.journalGeneration||!Rd(i.journalSeq)),r=[...t,...n].map(i=>i.sourceEntryId??(i.kind==="tool"||i.kind==="supplement"?null:i.id));if(r.push(..._6(e)),e.journalPositions?.has(e.oldestId??"")||r.push(e.oldestId),e.journalSourceVoid?.size)for(let i=r.length-1;i>=0;i--){const a=r[i];typeof a=="string"&&e.journalSourceVoid.has(a)&&r.splice(i,1)}return[...new Set(r.filter(i=>typeof i=="string"&&i.length>0&&i.length<=128))]}function _6(e){if(e.journalPeerSource!==!0||!e.journalBodyOwed)return[];const t=new Set;for(const r of e.records){const i=r.sourceEntryId??(r.kind==="tool"||r.kind==="supplement"?null:r.id);typeof i=="string"&&i.length>0&&i.length<=128&&t.add(i)}const n=[];for(const r of e.journalBodyOwed.keys())r.length<1||r.length>128||t.has(r)&&(e.journalSourceVoid?.has(r)||n.push(r));return n}function Eoe(e,t){const n=e.journalPositions;return pl(e).filter(r=>!n?.has(r)&&!t?.has(r))}const Do=e=>e.orderRevision??0;async function O2e(e){const t=new Map,n=s=>{let l=t.get(s);return l||(l=new Set,t.set(s,l)),l},r=(s,l)=>l==="payload"?_6(s):l==="lookup"?Eoe(s):pl(s);let i=e.getTranscript().journalGeneration,a=0,o=0;for(;;){if(!e.isCurrent())return{kind:"stale"};const s=e.getTranscript(),l=FE(s),c=l.revision,u=e.sweep?.(s,n);if(u?.kind==="none")return{kind:"complete",transcript:s};const O=u?.kind??"authority",d=BTe(r(s,O).filter(g=>!n(O).has(g)),u?.path??e.lookupPath,u?.query??new URLSearchParams({journal_order:"1"})),f=await e.read(d,O);if(!e.isCurrent()||Do(e.getTranscript())!==c)return{kind:"stale"};if(e.commit(f,c,l),!e.isCurrent())return{kind:"stale"};const p=e.getTranscript(),m=e.page(f);if(m.journal_order_state==="ready"&&m.journal_generation===p.journalGeneration){m.journal_generation!==i&&(t.clear(),i=m.journal_generation);for(const v of d)n(O).add(v);if(p.orderNeedsReconcile){if(p.orderDemand===l.demand||a===1)return{kind:"waiting"};a++,t.clear();continue}if(O==="payload"){const v=(m.source_retry_ids??[]).filter(S=>typeof S=="string"&&S.length>0&&S.length<=128);if(v.length>0&&d.length>1&&o===0){o++;for(const S of v)n("payload").delete(S);continue}}const g=e.sweep?.(p,n);if(g?.kind==="none")return{kind:"complete",transcript:p};const y=g?.kind??"authority";if(r(p,y).some(v=>!n(y).has(v)))continue;return{kind:"complete",transcript:p}}if(!p.orderNeedsReconcile||p.orderDemand===l.demand||a===1)return{kind:"waiting"};a++,t.clear()}}function Us(e){const t=e.payload,n=t?.tool_call_id;if(t?.role==="tool"&&typeof n=="string"&&n)return`tool:${n}`;const i=(t?.details??{}).anchor;return t?.custom_type==="completion_attention"&&typeof i=="string"&&i?i:e.id}function BP(e){return typeof e!="number"||!Number.isFinite(e)?null:Math.max(0,Math.trunc(e))}function zW(e){return typeof e!="number"||!Number.isFinite(e)||e<0?null:e}function Arn(e){if(!e||e.runs_state!=="ready")return null;const t=e.runs;if(!t||t.length===0)return null;const n=new Map;for(const a of t){if(!a.settled||typeof a.run_key!="string"||a.run_key.length===0)continue;const o=BP(a.action_count);if(o===null)continue;const s={actions:o,workedSeconds:zW(a.worked_seconds),failed:BP(a.failed_count)??0,complete:a.complete!==!1,openingUserId:typeof a.opening_user_id=="string"&&a.opening_user_id.length>0?a.opening_user_id:null,closingAnswerId:typeof a.closing_answer_id=="string"&&a.closing_answer_id.length>0?a.closing_answer_id:null,crossSessionActions:BP(a.cross_session_action_count),crossSessionWorkedSeconds:zW(a.cross_session_worked_seconds)};n.set(a.run_key,s),s.openingUserId!==null&&n.set(s.openingUserId,s),s.closingAnswerId!==null&&n.set(s.closingAnswerId,s)}if(n.size===0)return null;const r=new Set;for(const a of e.entries)r.add(Us(a));const i=e.entries[e.entries.length-1];return{runs:n,page:{ids:r,newestKey:i?Us(i):null}}}function d2e(e){if(!e||e.runs_state!=="ready"||e.head_cut===!0)return null;const t=e.runs,n=e.entries[0];if(!n||!t||t.length===0||!t.find(a=>a.opening_user_id===n.id))return null;const i=Math.round((n.ts??0)*1e3);return i>0?{id:n.id,tsMs:i}:null}function f2e(e,t,n){const r=d2e(e),i=e?.entries;if(r===null||!i||i.length===0)return!1;const a=Math.round((i[i.length-1].ts??0)*1e3);if(!(a>r.tsMs))return!1;for(const[o,s]of t)if(!n.has(o)&&(s===null||!(s>r.tsMs)||!(s<a)))return!1;return!0}const h2e=new Map([["This changes your instructions. Apply it from now on, and drop work it makes pointless.","steer"],["Answer it now with the `hub` tool — a short, direct reply — then carry on with what you were doing. Do not restructure your work around the question.","ask"],["This is a note, not a question. No reply is needed unless it changes what you should do.","note"]]),p2e=/\blabel=(['"])(.*?)\1/,m2e=/\bjob=(['"])(.*?)\1/,g2e=/^<(parent-message|subagent-message)\b[^>]*>\n([\s\S]*)\n<\/\1>$/;function BE(e){const t=typeof e.text=="string"?e.text:"",n=g2e.exec(t);let r=n?.[2];const i=r?.indexOf(`
3
3
 
4
4
  `)??-1,o=n?.[1]==="parent-message"&&(e.direction===void 0||e.direction===""||e.direction==="to_child")&&i>=0?h2e.get((r??"").slice(0,i)):void 0;n?.[1]==="parent-message"&&o&&(r=(r??"").slice(i+2));const s=typeof e.direction=="string"?e.direction:n?.[1]==="subagent-message"?"to_parent":o?"to_child":"";return{body:typeof e.body=="string"?e.body:r?.trim()?r:t,envelope:t,direction:s,label:V0(e.label??(n&&p2e.exec(n[0].split(`
5
5
  `,1)[0])?.[2])),jobId:V0(e.job_id??(n&&m2e.exec(n[0].split(`
@@ -815,7 +815,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
815
815
  `))};if(c.from==this.from&&a<this.from?c.from=a:c.to==this.to&&a>this.to&&(c.to=a),c.from==c.to&&!c.insert.length){let u=Ze.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));u.main.eq(i)||t.dispatch({selection:u,userEvent:"select"});return}if((ot.mac||ot.android)&&c.from==o-1&&/^\. ?$/.test(r.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:s,to:l,insert:Ln.of([r.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);LA(t,c,Ze.single(this.toEditorPos(r.selectionStart,u),this.toEditorPos(r.selectionEnd,u)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state))},this.handlers.characterboundsupdate=r=>{let i=[],a=null;for(let o=this.toEditorPos(r.rangeStart),s=this.toEditorPos(r.rangeEnd);o<s;o++){let l=t.coordsForChar(o);a=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||a||new DOMRect,i.push(a)}n.updateCharacterBounds(r.rangeStart,i)},this.handlers.textformatupdate=r=>{let i=[];for(let a of r.getTextFormats()){let o=a.underlineStyle,s=a.underlineThickness;if(o!="None"&&s!="None"){let l=this.toEditorPos(a.rangeStart),c=this.toEditorPos(a.rangeEnd);if(l<c){let u=`text-decoration: underline ${o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${s=="Thin"?1:2}px`;i.push(sn.mark({attributes:{style:u}}).range(l,c))}}}t.dispatch({effects:Vhe.of(sn.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=g$(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 wt{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||_Ke(t.parent)||document,this.viewState=new ZZ(t.state||Wn.create(t)),t.scrollTo&&t.scrollTo.is(ab)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Sh).map(i=>new TT(i));for(let i of this.plugins)i.update(this);this.observer=new MJe(this),this.inputState=new mJe(this),this.inputState.ensureHandlers(this.plugins),this.docView=new QZ(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...t){let n=t.length==1&&t[0]instanceof Gi?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(n,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,i,a=this.state;for(let d of t){if(d.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=d.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,l=null;t.some(d=>d.annotation(ape))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=ope(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(Wn.phrases)!=this.state.facet(Wn.phrases))return this.setState(a);i=tS.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:f}=d.state.selection;O=new Zh(f.empty?f:Ze.cursor(f.head,f.head>f.anchor?-1:1))}for(let f of d.effects)f.is(ab)&&(O=f.value.clip(this.state))}this.viewState.update(i,O),this.bidiCache=rS.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Zg)!=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(Ob)!=i.state.facet(Ob)&&(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(V3))try{d(i)}catch(f){Ia(this.state,f,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!Jhe(this,u)&&c.force&&Ih(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 ZZ(t),this.plugins=t.facet(Sh).map(r=>new TT(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new QZ(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(Sh),r=t.state.facet(Sh);if(n!=r){let i=[];for(let a of r){let o=n.indexOf(a);if(o<0)i.push(new TT(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){Ia(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(vhe(r))a=-1,o=this.viewState.heightMap.height;else{let f=this.viewState.scrollAnchorAt(i);a=f.from,o=f.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(f=>{try{return f.read(this)}catch(p){return Ia(this.state,p),LZ}}),O=tS.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 f=0;f<c.length;f++)if(u[f]!=LZ)try{let p=c[f];p.write&&p.write(u[f],this)}catch(p){Ia(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(V3))s(n)}get themeClasses(){return H3+" "+(this.state.facet(B3)?upe:cpe)+" "+this.state.facet(Ob)}updateAttrs(){let t=FZ(this,Mhe,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Xc)?"true":"false",class:"cm-content",style:`${ot.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),FZ(this,DA,n);let r=this.observer.ignore(()=>{let i=Y3(this.contentDOM,this.contentAttrs,n),a=Y3(this.dom,this.editorAttrs,t);return i||a});return this.editorAttrs=t,this.contentAttrs=n,r}showAnnouncements(t){let n=!0;for(let r of t)for(let i of r.effects)if(i.is(wt.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(Zg);let t=this.state.facet(wt.cspNonce);mO.mount(this.root,this.styleModules.concat(DJe).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 XT(this,t,XZ(this,t,n,r))}moveByGroup(t,n){return XT(this,t,XZ(this,t,n,r=>sJe(this,t.head,r)))}visualLineSide(t,n){let r=this.bidiSpans(t),i=this.textDirectionAt(t.from),a=r[n?r.length-1:0];return Ze.cursor(a.side(n,i)+t.from,a.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return oJe(this,t,n,r)}moveVertically(t,n,r){return XT(this,t,lJe(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(),Khe(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[Ku.find(a,t-i.from,-1,n)];return Vy(r,o.dir==wr.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(Ihe)||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>BJe)return Che(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||jhe(a.isolates,r=xZ(this,t))))return a.order;r||(r=xZ(this,t));let i=ZKe(t.text,n,r);return this.bidiCache.push(new rS(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||ot.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{$he(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 ab.of(new Zh(typeof t=="number"?Ze.cursor(t):t,n.y,n.x,n.yMargin,n.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(t);return ab.of(new Zh(Ze.cursor(r.from),"start","start",r.top-t,n,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return bi.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return bi.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=mO.newName(),i=[Ob.of(r),Zg.of(K3(`.${r}`,t))];return n&&n.dark&&i.push(B3.of(!0)),i}static baseTheme(t){return PO.lowest(Zg.of(K3("."+H3,t,Ope)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&ar.get(r)||ar.get(t);return((n=i?.rootView)===null||n===void 0?void 0:n.view)||null}}wt.styleModule=Zg;wt.inputHandler=Yhe;wt.clipboardInputFilter=IA;wt.clipboardOutputFilter=ZA;wt.scrollHandler=Dhe;wt.focusChangeEffect=Ghe;wt.perLineTextDirection=Ihe;wt.exceptionSink=Nhe;wt.updateListener=V3;wt.editable=Xc;wt.mouseSelectionStyle=Whe;wt.dragMovesSelection=Uhe;wt.clickAddsSelectionRange=Ahe;wt.decorations=$$;wt.outerDecorations=Lhe;wt.atomicRanges=VA;wt.bidiIsolatedRanges=Fhe;wt.scrollMargins=Bhe;wt.darkTheme=B3;wt.cspNonce=Ot.define({combine:e=>e.length?e[0]:""});wt.contentAttributes=DA;wt.editorAttributes=Mhe;wt.lineWrapping=wt.contentAttributes.of({class:"cm-lineWrapping"});wt.announce=Tn.define();const BJe=4096,LZ={};class rS{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:wr.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 rS(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}}function FZ(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&&N3(o,n)}return n}const HJe=ot.mac?"mac":ot.windows?"win":ot.linux?"linux":"key";function KJe(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 db(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 JJe=PO.default(wt.domEventHandlers({keydown(e,t){return fpe(dpe(t.state),e,t,"editor")}})),VQ=Ot.define({enables:JJe}),BZ=new WeakMap;function dpe(e){let t=e.facet(VQ),n=BZ.get(t);return n||BZ.set(t,n=tet(t.reduce((r,i)=>r.concat(i),[]))),n}function kon(e,t,n){return fpe(dpe(e.state),t,e,n)}let Zu=null;const eet=4e3;function tet(e,t=HJe){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 f=n[o]||(n[o]=Object.create(null)),p=s.split(/ (?!$)/).map(y=>KJe(y,t));for(let y=1;y<p.length;y++){let v=p.slice(0,y).join(" ");i(v,!0),f[v]||(f[v]={preventDefault:!0,stopPropagation:!1,run:[S=>{let x=Zu={view:S,prefix:v,scope:o};return setTimeout(()=>{Zu==x&&(Zu=null)},eet),!0}]})}let m=p.join(" ");i(m,!1);let g=f[m]||(f[m]={preventDefault:!1,stopPropagation:!1,run:((d=(O=f._any)===null||O===void 0?void 0:O.run)===null||d===void 0?void 0:d.slice())||[]});l&&g.run.push(l),c&&(g.preventDefault=!0),u&&(g.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(f=>O(f,J3))}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 J3=null;function fpe(e,t,n,r){J3=t;let i=xKe(t),a=wo(i,0),o=_c(a)==i.length&&i!=" ",s="",l=!1,c=!1,u=!1;Zu&&Zu.view==n&&Zu.scope==r&&(s=Zu.prefix+" ",tpe.indexOf(t.keyCode)<0&&(c=!0,Zu=null));let O=new Set,d=g=>{if(g){for(let y of g.run)if(!O.has(y)&&(O.add(y),y(n)))return g.stopPropagation&&(u=!0),!0;g.preventDefault&&(g.stopPropagation&&(u=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[s+db(i,t,!o)])?l=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(ot.windows&&t.ctrlKey&&t.altKey)&&(p=gO[t.keyCode])&&p!=i?(d(f[s+db(p,t,!0)])||t.shiftKey&&(m=m$[t.keyCode])!=i&&m!=p&&d(f[s+db(m,t,!1)]))&&(l=!0):o&&t.shiftKey&&d(f[s+db(i,t,!0)])&&(l=!0),!l&&d(f._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),J3=null,l}class Fy{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=hpe(t);return[new Fy(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return net(t,n,r)}}function hpe(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==wr.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function HZ(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 net(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==wr.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),l=hpe(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),f=L3(e,r,1),p=L3(e,i,-1),m=f.type==Ta.Text?f:null,g=p.type==Ta.Text?p:null;if(m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=HZ(e,r,1,m)),g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=HZ(e,i,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return v(S(n.from,n.to,m));{let b=m?S(n.from,null,m):x(f,!1),w=g?S(null,n.to,g):x(p,!0),Q=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&b.bottom+e.defaultLineHeight/2<w.top?Q.push(y(O,b.bottom,d,w.top)):b.bottom<w.top&&e.elementAtHeight((b.bottom+w.top)/2).type==Ta.Text&&(b.bottom=w.top=(b.bottom+w.top)/2),v(b).concat(Q).concat(v(w))}function y(b,w,Q,k){return new Fy(t,b-l.left,w-l.top,Q-b,k-w)}function v({top:b,bottom:w,horizontal:Q}){let k=[];for(let _=0;_<Q.length;_+=2)k.push(y(Q[_],b,Q[_+1],w));return k}function S(b,w,Q){let k=1e9,_=-1e9,T=[];function E(z,W,I,N,Z){let G=e.coordsAtPos(z,z==Q.to?-2:2),U=e.coordsAtPos(I,I==Q.from?2:-2);!G||!U||(k=Math.min(G.top,U.top,k),_=Math.max(G.bottom,U.bottom,_),Z==wr.LTR?T.push(a&&W?O:G.left,a&&N?d:U.right):T.push(!a&&N?O:U.left,!a&&W?d:G.right))}let R=b??Q.from,q=w??Q.to;for(let z of e.visibleRanges)if(z.to>R&&z.from<q)for(let W=Math.max(z.from,R),I=Math.min(z.to,q);;){let N=e.state.doc.lineAt(W);for(let Z of e.bidiSpans(N)){let G=Z.from+N.from,U=Z.to+N.from;if(G>=I)break;U>W&&E(Math.max(G,W),b==null&&G<=R,Math.min(U,I),w==null&&U>=q,Z.dir)}if(W=N.to+1,W>=I)break}return T.length==0&&E(R,b==null,q,w==null,e.textDirection),{top:k,bottom:_,horizontal:T}}function x(b,w){let Q=s.top+(w?b.top:b.bottom);return{top:Q,bottom:Q,horizontal:[]}}}function ret(e,t){return e.constructor==t.constructor&&e.eq(t)}class iet{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(Iw)!=t.state.facet(Iw)&&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(Iw);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)=>!ret(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 Iw=Ot.define();function ppe(e){return[bi.define(t=>new iet(t,e)),Iw.of(e)]}const y$=Ot.define({combine(e){return $m(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function Pon(e={}){return[y$.of(e),aet,oet,set,Zhe.of(!0)]}function mpe(e){return e.startState.facet(y$)!=e.state.facet(y$)}const aet=ppe({above:!0,markers(e){let{state:t}=e,n=t.facet(y$),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor){let o=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",s=i.empty?i:Ze.cursor(i.head,i.head>i.anchor?-1:1);for(let l of Fy.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=mpe(e);return n&&KZ(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){KZ(t.state,e)},class:"cm-cursorLayer"});function KZ(e,t){t.style.animationDuration=e.facet(y$).cursorBlinkRate+"ms"}const oet=ppe({above:!1,markers(e){return e.state.selection.ranges.map(t=>t.empty?[]:Fy.forRange(e,"cm-selectionBackground",t)).reduce((t,n)=>t.concat(n))},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||mpe(e)},class:"cm-selectionLayer"}),set=PO.highest(wt.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"}}}})),gpe=Tn.define({map(e,t){return e==null?null:t.mapPos(e)}}),Mg=Ha.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(gpe)?r.value:n,e)}}),cet=bi.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(Mg);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(Mg)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(Mg),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(Mg)!=e&&this.view.dispatch({effects:gpe.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 Ton(){return[Mg,cet]}function JZ(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 uet(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 Oet{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 Jd,r=n.add.bind(n);for(let{from:i,to:a}of uet(t,this.maxLength))JZ(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=[],f,p=(m,g,y)=>d.push(y.range(m,g));if(l==c)for(this.regexp.lastIndex=u-l.from;(f=this.regexp.exec(l.text))&&f.index<O-l.from;)this.addMatch(f,t,f.index+l.from,p);else JZ(t.state.doc,this.regexp,u,O,(m,g)=>this.addMatch(g,t,m,p));n=n.update({filterFrom:u,filterTo:O,filter:(m,g)=>m<u||g>O,add:d})}}return n}}const ej=/x/.unicode!=null?"gu":"g",det=new RegExp(`[\0-\b
816
816
  --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,ej),fet={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 qT=null;function het(){var e;if(qT==null&&typeof document<"u"&&document.body){let t=document.body.style;qT=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return qT||!1}const Zw=Ot.define({combine(e){let t=$m(e,{render:null,specialChars:det,addSpecialChars:null});return(t.replaceTabs=!het())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,ej)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,ej)),t}});function _on(e={}){return[Zw.of(e),pet()]}let eD=null;function pet(){return eD||(eD=bi.fromClass(class{constructor(e){this.view=e,this.decorations=sn.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(Zw)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new Oet({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,a=wo(t[0],0);if(a==9){let o=i.lineAt(r),s=n.state.tabSize,l=pO(o.text,s,r-o.from);return sn.replace({widget:new yet((s-l%s)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=sn.replace({widget:new $et(e,a)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(Zw);e.startState.facet(Zw)!=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 met="•";function get(e){return e>=32?met:e==10?"␤":String.fromCharCode(9216+e)}class $et extends mu{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=get(this.code),r=t.state.phrase("Control character")+" "+(fet[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 yet extends mu{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 Xon(){return bet}const vet=sn.line({class:"cm-activeLine"}),bet=bi.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(vet.range(i.from)),t=i.from)}return sn.set(n)}},{decorations:e=>e.decorations});class wet extends mu{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?pp(t.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(t.parentNode),i=Vy(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 Ron(e){let t=bi.fromClass(class{constructor(n){this.view=n,this.placeholder=e?sn.set([sn.widget({widget:new wet(e),side:1}).range(0)]):sn.none}get decorations(){return this.view.state.doc.length?sn.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,wt.contentAttributes.of({"aria-placeholder":e})]:t}const tj=2e3;function xet(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>tj||n.off>tj||t.col<0||n.col<0){let o=Math.min(t.off,n.off),s=Math.max(t.off,n.off);for(let l=r;l<=i;l++){let c=e.doc.line(l);c.length<=s&&a.push(Ze.range(c.from+o,c.to+s))}}else{let o=Math.min(t.col,n.col),s=Math.max(t.col,n.col);for(let l=r;l<=i;l++){let c=e.doc.line(l),u=q3(c.text,o,e.tabSize,!0);if(u<0)a.push(Ze.cursor(c.to));else{let O=q3(c.text,s,e.tabSize);a.push(Ze.range(c.from+u,c.from+O))}}}return a}function Qet(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function tD(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>tj?-1:i==r.length?Qet(e,t.clientX):pO(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function ket(e,t){let n=tD(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=tD(e,i);if(!s)return r;let l=xet(e.state,n,s);return l.length?o?Ze.create(l.concat(r.ranges)):Ze.create(l):r}}:null}function Eon(e){let t=n=>n.altKey&&n.button==0;return wt.mouseSelectionStyle.of((n,r)=>t(r)?ket(n,r):null)}const Pet={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},Tet={style:"cursor: crosshair"};function qon(e={}){let[t,n]=Pet[e.key||"Alt"],r=bi.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,wt.contentAttributes.of(i=>{var a;return!((a=i.plugin(r))===null||a===void 0)&&a.isDown?Tet:null})]}const tg="-10000px";class $pe{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 _et(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const jT=Ot.define({combine:e=>{var t,n,r;return{position:ot.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)||_et}}}),nD=new WeakMap,HA=bi.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(jT);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 $pe(e,KA,(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(jT);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=tg,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(ot.gecko)n=a.offsetParent!=this.container.ownerDocument.body;else if(a.style.top==tg&&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=MA(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(jT).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=tg;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=d.right-d.left,g=(t=nD.get(c))!==null&&t!==void 0?t:d.bottom-d.top,y=c.offset||Ret,v=this.view.textDirection==wr.LTR,S=d.width>r.right-r.left?v?r.left:r.right-d.width:v?Math.max(r.left,Math.min(O.left-(f?14:0)+y.x,r.right-m)):Math.min(Math.max(r.left,O.left-m+(f?14:0)-y.x),r.right-m),x=this.above[s];!l.strictSide&&(x?O.top-g-p-y.y<r.top:O.bottom+g+p+y.y>r.bottom)&&x==r.bottom-O.bottom>O.top-r.top&&(x=this.above[s]=!x);let b=(x?O.top-r.top:r.bottom-O.bottom)-p;if(b<g&&c.resize!==!1){if(b<this.view.defaultLineHeight){u.style.top=tg;continue}nD.set(c,g),u.style.height=(g=b)/a+"px"}else u.style.height&&(u.style.height="");let w=x?O.top-g-p-y.y:O.bottom+p+y.y,Q=S+m;if(c.overlap!==!0)for(let k of o)k.left<Q&&k.right>S&&k.top<w+g&&k.bottom>w&&(w=x?k.top-g-2-p:k.bottom+p+2);if(this.position=="absolute"?(u.style.top=(w-e.parent.top)/a+"px",rD(u,(S-e.parent.left)/i)):(u.style.top=w/a+"px",rD(u,S/i)),f){let k=O.left+(v?y.x:-y.x)-(S+14-7);f.style.left=k/i+"px"}c.overlap!==!0&&o.push({left:S,top:w,right:Q,bottom:w+g}),u.classList.toggle("cm-tooltip-above",x),u.classList.toggle("cm-tooltip-below",!x),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=tg}},{eventObservers:{scroll(){this.maybeMeasure()}}});function rD(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const Xet=wt.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"}}}),Ret={x:0,y:0},KA=Ot.define({enables:[HA,Xet]}),iS=Ot.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class MQ{static create(t){return new MQ(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new $pe(t,iS,(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 Eet=KA.compute([iS],e=>{let t=e.facet(iS);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:MQ.create,above:t[0].above,arrow:t.some(n=>n.arrow)}});class qet{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 Hu)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==wr.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=>Ia(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(HA),n=t?t.manager.tooltips.findIndex(r=>r.create==MQ.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&&!jet(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:!Cet(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 fb=4;function jet(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-fb&&t.clientX<=r+fb&&t.clientY>=i-fb&&t.clientY<=a+fb}function Cet(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 jon(e,t={}){let n=Tn.define(),r=Ha.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,Ni.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(zet)&&(i=[]);return i},provide:i=>iS.from(i)});return{active:r,extension:[r,bi.define(i=>new qet(i,e,r,n,t.hoverTime||300)),Eet]}}function ype(e,t){let n=e.plugin(HA);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const zet=Tn.define(),iD=Ot.define({combine(e){let t,n;for(let r of e)t=t||r.topContainer,n=n||r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function Con(e,t){let n=e.plugin(vpe),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const vpe=bi.fromClass(class{constructor(e){this.input=e.state.facet(oD),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(iD);this.top=new hb(e,!0,t.topContainer),this.bottom=new hb(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(iD);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new hb(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new hb(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(oD);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=>wt.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class hb{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=aD(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=aD(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 aD(e){let t=e.nextSibling;return e.remove(),t}const oD=Ot.define({enables:vpe});class tu extends Kd{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}tu.prototype.elementClass="";tu.prototype.toDOM=void 0;tu.prototype.mapMode=Ni.TrackBefore;tu.prototype.startSide=tu.prototype.endSide=-1;tu.prototype.point=!0;const Dw=Ot.define(),Aet=Ot.define(),Uet={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Pn.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},w0=Ot.define();function Wet(e){return[bpe(),w0.of({...Uet,...e})]}const sD=Ot.define({combine:e=>e.some(t=>t)});function bpe(e){return[Net]}const Net=bi.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(w0).map(t=>new cD(e,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!e.state.facet(sD),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(sD)!=!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=Pn.iter(this.view.state.facet(Dw),this.view.viewport.from),r=[],i=this.gutters.map(a=>new Yet(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==Ta.Text&&o){nj(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==Ta.Text){nj(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(w0),n=e.state.facet(w0),r=e.docChanged||e.heightChanged||e.viewportChanged||!Pn.eq(e.startState.facet(Dw),e.state.facet(Dw),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 cD(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=>wt.scrollMargins.of(t=>{let n=t.plugin(e);return!n||n.gutters.length==0||!n.fixed?null:t.textDirection==wr.LTR?{left:n.dom.offsetWidth*t.scaleX}:{right:n.dom.offsetWidth*t.scaleX}})});function lD(e){return Array.isArray(e)?e:[e]}function nj(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class Yet{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=Pn.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 wpe(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=[];nj(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(Aet)){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 cD{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=lD(n.markers(t)),n.initialSpacer&&(this.spacer=new wpe(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=lD(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!Pn.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 wpe{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":""),Get(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 Get(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 Iet=Ot.define(),Zet=Ot.define(),xh=Ot.define({combine(e){return $m(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 CT extends tu{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function zT(e,t){return e.state.facet(xh).formatNumber(t,e.state)}const Det=w0.compute([xh],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(Iet)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new CT(zT(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(Zet)){let a=i(t,n,r);if(a)return a}return null},lineMarkerChange:t=>t.startState.facet(xh)!=t.state.facet(xh),initialSpacer(t){return new CT(zT(t,uD(t.state.doc.lines)))},updateSpacer(t,n){let r=zT(n.view,uD(n.view.state.doc.lines));return r==t.number?t:new CT(r)},domEventHandlers:e.facet(xh).domEventHandlers}));function zon(e={}){return[xh.of(e),bpe(),Det]}function uD(e){let t=9;for(;t<e;)t=t*10+9;return t}const Vet=new class extends tu{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Met=Dw.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(Vet.range(i)))}return Pn.of(t)});function Aon(){return Met}let Let=0;class et{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=Let++}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 et&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new et(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 aS(t);return r=>r.modified.indexOf(n)>-1?r:aS.get(r.base||r,r.modified.concat(n).sort((i,a)=>i.id-a.id))}}let Fet=0;class aS{constructor(t){this.name=t,this.instances=[],this.id=Fet++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(s=>s.base==t&&Bet(n,s.modified));if(r)return r;let i=[],a=new et(t.name,i,t,n);for(let s of n)s.instances.push(a);let o=Het(n);for(let s of t.set)if(!s.modified.length)for(let l of o)i.push(aS.get(s,l));return a}}function Bet(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function Het(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 zn(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 f=i[O++];if(O==i.length&&f=="!"){o=0;break}if(f!="/")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 oS(r,o,l>0?a.slice(0,l):null);t[c]=u.sort(t[c])}}return Spe.add(t)}const Spe=new Wt;let oS=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}};oS.empty=new oS([],2,null);function xpe(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 Ket(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function Jet(e,t,n,r=0,i=e.length){let a=new ett(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,"",a.highlighters),a.flush(i)}class ett{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(f=>!f.scope||f.scope(o)));let c=i,u=ttt(t)||oS.empty,O=Ket(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 f=t.node.enter(d.overlay[0].from+s,1),p=this.highlighters.filter(g=>!g.scope||g.scope(d.tree.type)),m=t.firstChild();for(let g=0,y=s;;g++){let v=g<d.overlay.length?d.overlay[g]:null,S=v?v.from+s:l,x=Math.max(n,y),b=Math.min(r,S);if(x<b&&m)for(;t.from<b&&(this.highlightRange(t,x,b,i,a),this.startSpan(Math.min(b,t.to),c),!(t.to>=S||!t.nextSibling())););if(!v||S>r)break;y=v.to+s,y>n&&(this.highlightRange(f.cursor(),Math.max(n,v.from+s),Math.min(r,y),"",p),this.startSpan(Math.min(r,y),c))}m&&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 ttt(e){let t=e.type.prop(Spe);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const Ke=et.define,pb=Ke(),Au=Ke(),OD=Ke(Au),dD=Ke(Au),Uu=Ke(),mb=Ke(Uu),AT=Ke(Uu),hl=Ke(),KO=Ke(hl),ll=Ke(),cl=Ke(),rj=Ke(),ng=Ke(rj),gb=Ke(),P={comment:pb,lineComment:Ke(pb),blockComment:Ke(pb),docComment:Ke(pb),name:Au,variableName:Ke(Au),typeName:OD,tagName:Ke(OD),propertyName:dD,attributeName:Ke(dD),className:Ke(Au),labelName:Ke(Au),namespace:Ke(Au),macroName:Ke(Au),literal:Uu,string:mb,docString:Ke(mb),character:Ke(mb),attributeValue:Ke(mb),number:AT,integer:Ke(AT),float:Ke(AT),bool:Ke(Uu),regexp:Ke(Uu),escape:Ke(Uu),color:Ke(Uu),url:Ke(Uu),keyword:ll,self:Ke(ll),null:Ke(ll),atom:Ke(ll),unit:Ke(ll),modifier:Ke(ll),operatorKeyword:Ke(ll),controlKeyword:Ke(ll),definitionKeyword:Ke(ll),moduleKeyword:Ke(ll),operator:cl,derefOperator:Ke(cl),arithmeticOperator:Ke(cl),logicOperator:Ke(cl),bitwiseOperator:Ke(cl),compareOperator:Ke(cl),updateOperator:Ke(cl),definitionOperator:Ke(cl),typeOperator:Ke(cl),controlOperator:Ke(cl),punctuation:rj,separator:Ke(rj),bracket:ng,angleBracket:Ke(ng),squareBracket:Ke(ng),paren:Ke(ng),brace:Ke(ng),content:hl,heading:KO,heading1:Ke(KO),heading2:Ke(KO),heading3:Ke(KO),heading4:Ke(KO),heading5:Ke(KO),heading6:Ke(KO),contentSeparator:Ke(hl),list:Ke(hl),quote:Ke(hl),emphasis:Ke(hl),strong:Ke(hl),link:Ke(hl),monospace:Ke(hl),strikethrough:Ke(hl),inserted:Ke(),deleted:Ke(),changed:Ke(),invalid:Ke(),meta:gb,documentMeta:Ke(gb),annotation:Ke(gb),processingInstruction:Ke(gb),definition:et.defineModifier("definition"),constant:et.defineModifier("constant"),function:et.defineModifier("function"),standard:et.defineModifier("standard"),local:et.defineModifier("local"),special:et.defineModifier("special")};for(let e in P){let t=P[e];t instanceof et&&(t.name=e)}xpe([{tag:P.link,class:"tok-link"},{tag:P.heading,class:"tok-heading"},{tag:P.emphasis,class:"tok-emphasis"},{tag:P.strong,class:"tok-strong"},{tag:P.keyword,class:"tok-keyword"},{tag:P.atom,class:"tok-atom"},{tag:P.bool,class:"tok-bool"},{tag:P.url,class:"tok-url"},{tag:P.labelName,class:"tok-labelName"},{tag:P.inserted,class:"tok-inserted"},{tag:P.deleted,class:"tok-deleted"},{tag:P.literal,class:"tok-literal"},{tag:P.string,class:"tok-string"},{tag:P.number,class:"tok-number"},{tag:[P.regexp,P.escape,P.special(P.string)],class:"tok-string2"},{tag:P.variableName,class:"tok-variableName"},{tag:P.local(P.variableName),class:"tok-variableName tok-local"},{tag:P.definition(P.variableName),class:"tok-variableName tok-definition"},{tag:P.special(P.variableName),class:"tok-variableName2"},{tag:P.definition(P.propertyName),class:"tok-propertyName tok-definition"},{tag:P.typeName,class:"tok-typeName"},{tag:P.namespace,class:"tok-namespace"},{tag:P.className,class:"tok-className"},{tag:P.macroName,class:"tok-macroName"},{tag:P.propertyName,class:"tok-propertyName"},{tag:P.operator,class:"tok-operator"},{tag:P.comment,class:"tok-comment"},{tag:P.meta,class:"tok-meta"},{tag:P.invalid,class:"tok-invalid"},{tag:P.punctuation,class:"tok-punctuation"}]);var UT;const Ju=new Wt;function LQ(e){return Ot.define({combine:e?t=>t.concat(e):void 0})}const JA=new Wt;class To{constructor(t,n,r=[],i=""){this.data=t,this.name=i,Wn.prototype.hasOwnProperty("tree")||Object.defineProperty(Wn.prototype,"tree",{get(){return Fn(this)}}),this.parser=n,this.extension=[yO.of(this),Wn.languageData.of((a,o,s)=>{let l=fD(a,o,s),c=l.type.prop(Ju);if(!c)return[];let u=a.facet(c),O=l.type.prop(JA);if(O){let d=l.resolve(o-l.from,s);for(let f of O)if(f.test(d,a)){let p=a.facet(f.facet);return f.type=="replace"?p:p.concat(u)}}return u})].concat(r)}isActiveAt(t,n,r=-1){return fD(t,n,r).type.prop(Ju)==this.data}findRegions(t){let n=t.facet(yO);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(Ju)==this.data){r.push({from:o,to:o+a.length});return}let s=a.prop(Wt.mounted);if(s){if(s.tree.prop(Ju)==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 dn&&i(c,a.positions[l]+o)}};return i(Fn(t),0),r}get allowsNesting(){return!0}}To.setState=Tn.define();function fD(e,t,n){let r=e.facet(yO),i=Fn(e).topNode;if(!r||r.allowsNesting)for(let a=i;a;a=a.enter(t,n,ir.ExcludeBuffers))a.type.isTop&&(i=a);return i}class Xn extends To{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=LQ(t.languageData);return new Xn(n,t.parser.configure({props:[Ju.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new Xn(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Fn(e){let t=e.field(To.state,!1);return t?t.tree:dn.empty}class ntt{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 rg=null;class rf{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 rf(t,n,[],dn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new ntt(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=dn.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(Ic.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(Ic.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=rg;rg=this;try{return t()}finally{rg=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=hD(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=Ic.applyChanges(r,l),i=dn.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 rf(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=hD(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 GQ{createParse(n,r,i){let a=i[0].from,o=i[i.length-1].to;return{parsedPos:a,advance(){let l=rg;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 dn(ci.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 rg}}function hD(e,t,n){return Ic.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class yp{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 yp(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=rf.create(t.facet(yO).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new yp(r)}}To.state=Ha.define({create:yp.init,update(e,t){for(let n of t.effects)if(n.is(To.setState))return n.value;return t.startState.facet(yO)!=t.state.facet(yO)?yp.init(t.state):e.apply(t)}});let Qpe=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Qpe=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const WT=typeof navigator<"u"&&(!((UT=navigator.scheduling)===null||UT===void 0)&&UT.isInputPending)?()=>navigator.scheduling.isInputPending():null,rtt=bi.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(To.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(To.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=Qpe(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(To.state);if(a.tree==a.context.tree&&a.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!WT?Math.max(25,t.timeRemaining()-5):1e9),s=a.context.treeLen<i&&r.doc.length>i+1e3,l=a.context.work(()=>WT&&WT()||Date.now()>o,i+(s?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:To.setState.of(new yp(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=>Ia(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()}}}),yO=Ot.define({combine(e){return e.length?e[0]:null},enables:e=>[To.state,rtt,wt.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class Sn{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}class me{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 me(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 itt=Ot.define(),FQ=Ot.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(n=>n!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function sS(e){let t=e.facet(FQ);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function att(e,t){let n="",r=e.tabSize,i=e.facet(FQ)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let a=0;a<t;a++)n+=i;return n}function ott(e,t){e instanceof Wn&&(e=new kpe(e));for(let r of e.state.facet(itt)){let i=r(e,t);if(i!==void 0)return i}let n=Fn(e.state);return n.length>=t?stt(e,n,t):null}class kpe{constructor(t,n={}){this.state=t,this.options=n,this.unit=sS(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 pO(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 stt(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 Ppe(r,e,n)}function Ppe(e,t,n){for(let r=e;r;r=r.next){let i=ctt(r.node);if(i)return i(e9.create(t,n,r))}return 0}function ltt(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function ctt(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=>Tpe(o,!0,1,void 0,a&&!ltt(o)?i.from:void 0)}return e.parent==null?utt:null}function utt(){return 0}class e9 extends kpe{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 e9(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(Ott(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Ppe(this.context.next,this.base,this.pos)}}function Ott(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function dtt(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 ds({closing:e,align:t=!0,units:n=1}){return r=>Tpe(r,t,n,e)}function Tpe(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?dtt(e):null;return l?s?e.column(l.from):e.column(l.to):e.baseIndent+(s?0:e.unit*n)}const t9=e=>e.baseIndent;function Ur({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const ftt=200;function Non(){return Wn.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+ftt)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=ott(o,u.from);if(O==null)continue;let d=/^\s*/.exec(u.text)[0],f=att(o,O);d!=f&&l.push({from:u.from,to:u.from+d.length,insert:f})}return l.length?[e,{changes:l,sequential:!0}]:e})}const _pe=Ot.define(),Qr=new Wt;function la(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 htt(e,t,n){let r=Fn(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(Qr);if(l&&(s.to<r.length-50||r.length==e.doc.length||!ptt(s))){let c=l(s,e);c&&c.from<=n&&c.from>=t&&c.to>n&&(a=c)}}return a}function ptt(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function lS(e,t,n){for(let r of e.facet(_pe)){let i=r(e,t,n);if(i)return i}return htt(e,t,n)}function Xpe(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 BQ=Tn.define({map:Xpe}),By=Tn.define({map:Xpe});function Rpe(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 af=Ha.define({create(){return sn.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(BQ)&&!mtt(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(jpe),i=r?sn.replace({widget:new wtt(r(t.state,n.value))}):pD;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(By)&&(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=>wt.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(pD.range(r,i))}return sn.set(t,!0)}});function cS(e,t,n){var r;let i=null;return(r=e.field(af,!1))===null||r===void 0||r.between(t,n,(a,o)=>{(!i||i.from>a)&&(i={from:a,to:o})}),i}function mtt(e,t,n){let r=!1;return e.between(t,t,(i,a)=>{i==t&&a==n&&(r=!0)}),r}function Epe(e,t){return e.field(af,!1)?t:t.concat(Tn.appendConfig.of(Cpe()))}const gtt=e=>{for(let t of Rpe(e)){let n=lS(e.state,t.from,t.to);if(n)return e.dispatch({effects:Epe(e.state,[BQ.of(n),qpe(e,n)])}),!0}return!1},$tt=e=>{if(!e.state.field(af,!1))return!1;let t=[];for(let n of Rpe(e)){let r=cS(e.state,n.from,n.to);r&&t.push(By.of(r),qpe(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function qpe(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return wt.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const ytt=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=lS(t,i.from,i.to);a&&n.push(BQ.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:Epe(e.state,n)}),!!n.length},vtt=e=>{let t=e.state.field(af,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(By.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},Yon=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:gtt},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:$tt},{key:"Ctrl-Alt-[",run:ytt},{key:"Ctrl-Alt-]",run:vtt}],btt={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},jpe=Ot.define({combine(e){return $m(e,btt)}});function Cpe(e){return[af,xtt]}function zpe(e,t){let{state:n}=e,r=n.facet(jpe),i=o=>{let s=e.lineBlockAt(e.posAtDOM(o.target)),l=cS(e.state,s.from,s.to);l&&e.dispatch({effects:By.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 pD=sn.replace({widget:new class extends mu{toDOM(e){return zpe(e,null)}}});class wtt extends mu{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return zpe(t,this.value)}}const Stt={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class NT extends tu{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 Gon(e={}){let t={...Stt,...e},n=new NT(t,!0),r=new NT(t,!1),i=bi.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(yO)!=o.state.facet(yO)||o.startState.field(af,!1)!=o.state.field(af,!1)||Fn(o.startState)!=Fn(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let s=new Jd;for(let l of o.viewportLineBlocks){let c=cS(o.state,l.from,l.to)?r:lS(o.state,l.from,l.to)?n:null;c&&s.add(l.from,l.from,c)}return s.finish()}}),{domEventHandlers:a}=t;return[i,Wet({class:"cm-foldGutter",markers(o){var s;return((s=o.plugin(i))===null||s===void 0?void 0:s.markers)||Pn.empty},initialSpacer(){return new NT(t,!1)},domEventHandlers:{...a,click:(o,s,l)=>{if(a.click&&a.click(o,s,l))return!0;let c=cS(o.state,s.from,s.to);if(c)return o.dispatch({effects:By.of(c)}),!0;let u=lS(o.state,s.from,s.to);return u?(o.dispatch({effects:BQ.of(u)}),!0):!1}}}),Cpe()]}const xtt=wt.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 HQ{constructor(t,n){this.specs=t;let r;function i(s){let l=mO.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 To?s=>s.prop(Ju)==o.data:o?s=>s==o:void 0,this.style=xpe(t.map(s=>({tag:s.tag,class:s.class||i(Object.assign({},s,{tag:null}))})),{all:a}).style,this.module=r?new mO(r):null,this.themeType=n.themeType}static define(t,n){return new HQ(t,n||{})}}const ij=Ot.define(),Ape=Ot.define({combine(e){return e.length?[e[0]]:null}});function YT(e){let t=e.facet(ij);return t.length?t:e.facet(Ape)}function Ion(e,t){let n=[ktt],r;return e instanceof HQ&&(e.module&&n.push(wt.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(Ape.of(e)):r?n.push(ij.computeN([wt.darkTheme],i=>i.facet(wt.darkTheme)==(r=="dark")?[e]:[])):n.push(ij.of(e)),n}class Qtt{constructor(t){this.markCache=Object.create(null),this.tree=Fn(t.state),this.decorations=this.buildDeco(t,YT(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=Fn(t.state),r=YT(t.state),i=r!=YT(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 sn.none;let r=new Jd;for(let{from:i,to:a}of t.visibleRanges)Jet(this.tree,n,(o,s,l)=>{r.add(o,s,this.markCache[l]||(this.markCache[l]=sn.mark({class:l})))},i,a);return r.finish()}}const ktt=PO.high(bi.fromClass(Qtt,{decorations:e=>e.decorations})),Zon=HQ.define([{tag:P.meta,color:"#404740"},{tag:P.link,textDecoration:"underline"},{tag:P.heading,textDecoration:"underline",fontWeight:"bold"},{tag:P.emphasis,fontStyle:"italic"},{tag:P.strong,fontWeight:"bold"},{tag:P.strikethrough,textDecoration:"line-through"},{tag:P.keyword,color:"#708"},{tag:[P.atom,P.bool,P.url,P.contentSeparator,P.labelName],color:"#219"},{tag:[P.literal,P.inserted],color:"#164"},{tag:[P.string,P.deleted],color:"#a11"},{tag:[P.regexp,P.escape,P.special(P.string)],color:"#e40"},{tag:P.definition(P.variableName),color:"#00f"},{tag:P.local(P.variableName),color:"#30a"},{tag:[P.typeName,P.namespace],color:"#085"},{tag:P.className,color:"#167"},{tag:[P.special(P.variableName),P.macroName],color:"#256"},{tag:P.definition(P.propertyName),color:"#00c"},{tag:P.comment,color:"#940"},{tag:P.invalid,color:"#f00"}]),Ptt=wt.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Upe=1e4,Wpe="()[]{}",Npe=Ot.define({combine(e){return $m(e,{afterCursor:!0,brackets:Wpe,maxScanDistance:Upe,renderMatch:Xtt})}}),Ttt=sn.mark({class:"cm-matchingBracket"}),_tt=sn.mark({class:"cm-nonmatchingBracket"});function Xtt(e){let t=[],n=e.matched?Ttt:_tt;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 Rtt=Ha.define({create(){return sn.none},update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(Npe);for(let i of t.state.selection.ranges){if(!i.empty)continue;let a=$b(t.state,i.head,-1,r)||i.head>0&&$b(t.state,i.head-1,1,r)||r.afterCursor&&($b(t.state,i.head,1,r)||i.head<t.state.doc.length&&$b(t.state,i.head+1,-1,r));a&&(n=n.concat(r.renderMatch(a,t.state)))}return sn.set(n,!0)},provide:e=>wt.decorations.from(e)}),Ett=[Rtt,Ptt];function Don(e={}){return[Npe.of(e),Ett]}const n9=new Wt;function aj(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 oj(e){let t=e.type.prop(n9);return t?t(e.node):e}function $b(e,t,n,r={}){let i=r.maxScanDistance||Upe,a=r.brackets||Wpe,o=Fn(e),s=o.resolveInner(t,n);for(let l=s;l;l=l.parent){let c=aj(l.type,n,a);if(c&&l.from<l.to){let u=oj(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return qtt(e,t,n,l,u,c,a)}}return jtt(e,t,n,o,s.type,i,a)}function qtt(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=oj(u);return{start:l,end:O?{from:O.from,to:O.to}:void 0,matched:!0}}else if(aj(u.type,n,o))c++;else if(aj(u.type,-n,o)){if(c==0){let O=oj(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 jtt(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 f=u.value;n<0&&(d+=f.length);let p=t+d*n;for(let m=n>0?0:f.length-1,g=n>0?f.length:-1;m!=g;m+=n){let y=o.indexOf(f[m]);if(!(y<0||r.resolveInner(p+m,1).type!=i))if(y%2==0==n>0)O++;else{if(O==1)return{start:c,end:{from:p+m,to:p+m+1},matched:y>>1==l>>1};O--}}n>0&&(d+=f.length)}return u.done?{start:c,matched:!1}:null}function mD(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 Ype{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=mD(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:mD(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 Ctt(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||ztt,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||i9,mergeTokens:e.mergeTokens!==!1}}function ztt(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 gD=new WeakMap;class Ee extends To{constructor(t){let n=LQ(t.languageData),r=Ctt(t),i,a=new class extends GQ{createParse(o,s,l){return new Utt(i,o,s,l)}};super(n,a,[],t.name),this.topNode=Ytt(n,this),i=this,this.streamParser=r,this.stateAfter=new Wt({perNode:!0}),this.tokenTable=t.tokenTable?new Dpe(r.tokenTable):Ntt}static define(t){return new Ee(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=gD.get(t.state),n!=null&&n<t.pos-1e4&&(n=void 0));let i=r9(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 Ype(l.text,t.state.tabSize,t.unit,u<0?void 0:u);for(;O.pos<c-l.from;)Ipe(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&&gD.set(t.state,s.from),this.streamParser.indent(o,/^\s*(.*)/.exec(s.text)[1],t)}get allowsNesting(){return!1}}function r9(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 dn&&l<i&&r9(e,s,l,r,i);if(c)return c}return null}function Gpe(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 dn){if(!(l=Gpe(e,s,n-o,r-o,i)))break;return i?new dn(t.type,t.children.slice(0,a).concat(l),t.positions.slice(0,a+1),o+l.length):l}}return null}function Att(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&&r9(e,a.tree,0-a.offset,n,s),c;if(l&&l.pos<=r&&(c=Gpe(e,a.tree,n+a.offset,l.pos+a.offset,!1)))return{state:l.state,tree:c}}return{state:e.streamParser.startState(i?sS(i):4),tree:dn.empty}}let Utt=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=rf.get(),o=i[0].from,{state:s,tree:l}=Att(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(sS(a.state)),a.skipUntilInView(this.parsedPos,a.viewport.from),this.parsedPos=a.viewport.from),this.moveRangeIndex()}advance(){let t=rf.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==`
817
817
  `&&(n="");else{let r=n.indexOf(`
818
- `);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 Ype(n,t?t.state.tabSize:4,t?sS(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=Ipe(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=dn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Wtt,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new dn(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 dn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Ipe(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 i9=Object.create(null),v$=[ci.none],Wtt=new gm(v$),$D=[],yD=Object.create(null),Zpe=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"]])Zpe[e]=Vpe(i9,t);class Dpe{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Zpe)}resolve(t){return t?this.table[t]||(this.table[t]=Vpe(this.extra,t)):0}}const Ntt=new Dpe(i9);function GT(e,t){$D.indexOf(e)>-1||($D.push(e),console.warn(t))}function Vpe(e,t){let n=[];for(let s of t.split(" ")){let l=[];for(let c of s.split(".")){let u=e[c]||P[c];u?typeof u=="function"?l.length?l=l.map(u):GT(c,`Modifier ${c} used at start of tag`):l.length?GT(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:GT(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(s=>s.id),a=yD[i];if(a)return a.id;let o=yD[i]=ci.define({id:v$.length,name:r,props:[zn({[r]:n})]});return v$.push(o),o.id}function Ytt(e,t){let n=ci.define({id:v$.length,name:"Document",props:[Ju.add(()=>e),Er.add(()=>r=>t.getIndent(r))],top:!0});return v$.push(n),n}wr.RTL,wr.LTR;function Qe(e){return new Sn(Ee.define(e))}function Tu(e){return ve(()=>Promise.resolve().then(()=>OOt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const Gtt=[me.of({name:"C",extensions:["c","h","ino"],load(){return ve(()=>Promise.resolve().then(()=>uM),void 0,import.meta.url).then(e=>e.cpp())}}),me.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return ve(()=>Promise.resolve().then(()=>uM),void 0,import.meta.url).then(e=>e.cpp())}}),me.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Tu("Cassandra")}}),me.of({name:"CSS",extensions:["css"],load(){return ve(()=>Promise.resolve().then(()=>kit),void 0,import.meta.url).then(e=>e.css())}}),me.of({name:"Go",extensions:["go"],load(){return ve(()=>import("./index-XFXAg7sM.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(e=>e.go())}}),me.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return ve(()=>Promise.resolve().then(()=>gat),void 0,import.meta.url).then(e=>e.html())}}),me.of({name:"Java",extensions:["java"],load(){return ve(()=>Promise.resolve().then(()=>pOt),void 0,import.meta.url).then(e=>e.java())}}),me.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return ve(()=>Promise.resolve().then(()=>wb),void 0,import.meta.url).then(e=>e.javascript())}}),me.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return ve(()=>Promise.resolve().then(()=>wot),void 0,import.meta.url).then(e=>e.json())}}),me.of({name:"JSX",extensions:["jsx"],load(){return ve(()=>Promise.resolve().then(()=>wb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),me.of({name:"LESS",extensions:["less"],load(){return ve(()=>Promise.resolve().then(()=>Uat),void 0,import.meta.url).then(e=>e.less())}}),me.of({name:"Liquid",extensions:["liquid"],load(){return ve(()=>Promise.resolve().then(()=>eht),void 0,import.meta.url).then(e=>e.liquid())}}),me.of({name:"MariaDB SQL",load(){return Tu("MariaSQL")}}),me.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return ve(()=>Promise.resolve().then(()=>Pat),void 0,import.meta.url).then(e=>e.markdown())}}),me.of({name:"MS SQL",load(){return Tu("MSSQL")}}),me.of({name:"MySQL",load(){return Tu("MySQL")}}),me.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return ve(()=>Promise.resolve().then(()=>Rft),void 0,import.meta.url).then(e=>e.php())}}),me.of({name:"PLSQL",extensions:["pls"],load(){return Tu("PLSQL")}}),me.of({name:"PostgreSQL",load(){return Tu("PostgreSQL")}}),me.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return ve(()=>Promise.resolve().then(()=>eut),void 0,import.meta.url).then(e=>e.python())}}),me.of({name:"Rust",extensions:["rs"],load(){return ve(()=>Promise.resolve().then(()=>COt),void 0,import.meta.url).then(e=>e.rust())}}),me.of({name:"Sass",extensions:["sass"],load(){return ve(()=>Promise.resolve().then(()=>QV),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),me.of({name:"SCSS",extensions:["scss"],load(){return ve(()=>Promise.resolve().then(()=>QV),void 0,import.meta.url).then(e=>e.sass())}}),me.of({name:"SQL",extensions:["sql"],load(){return Tu("StandardSQL")}}),me.of({name:"SQLite",load(){return Tu("SQLite")}}),me.of({name:"TSX",extensions:["tsx"],load(){return ve(()=>Promise.resolve().then(()=>wb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),me.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return ve(()=>Promise.resolve().then(()=>wb),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),me.of({name:"WebAssembly",extensions:["wat","wast"],load(){return ve(()=>Promise.resolve().then(()=>rht),void 0,import.meta.url).then(e=>e.wast())}}),me.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return ve(()=>Promise.resolve().then(()=>wut),void 0,import.meta.url).then(e=>e.xml())}}),me.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return ve(()=>import("./index-BhsV-ipc.js"),__vite__mapDeps([5,1,2,3,4]),import.meta.url).then(e=>e.yaml())}}),me.of({name:"APL",extensions:["dyalog","apl"],load(){return ve(()=>Promise.resolve().then(()=>Emt),void 0,import.meta.url).then(e=>Qe(e.apl))}}),me.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return ve(()=>Promise.resolve().then(()=>qmt),void 0,import.meta.url).then(e=>Qe(e.asciiArmor))}}),me.of({name:"ASN.1",extensions:["asn","asn1"],load(){return ve(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>Qe(e.asn1({})))}}),me.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return ve(()=>Promise.resolve().then(()=>Umt),void 0,import.meta.url).then(e=>Qe(e.asterisk))}}),me.of({name:"Brainfuck",extensions:["b","bf"],load(){return ve(()=>Promise.resolve().then(()=>Nmt),void 0,import.meta.url).then(e=>Qe(e.brainfuck))}}),me.of({name:"Cobol",extensions:["cob","cpy"],load(){return ve(()=>Promise.resolve().then(()=>hgt),void 0,import.meta.url).then(e=>Qe(e.cobol))}}),me.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return ve(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Qe(e.csharp))}}),me.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Qe(e.clojure))}}),me.of({name:"ClojureScript",extensions:["cljs"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Qe(e.clojure))}}),me.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return ve(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>Qe(e.gss))}}),me.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return ve(()=>Promise.resolve().then(()=>agt),void 0,import.meta.url).then(e=>Qe(e.cmake))}}),me.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return ve(()=>Promise.resolve().then(()=>Pgt),void 0,import.meta.url).then(e=>Qe(e.coffeeScript))}}),me.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return ve(()=>Promise.resolve().then(()=>qgt),void 0,import.meta.url).then(e=>Qe(e.commonLisp))}}),me.of({name:"Cypher",extensions:["cyp","cypher"],load(){return ve(()=>Promise.resolve().then(()=>Hgt),void 0,import.meta.url).then(e=>Qe(e.cypher))}}),me.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return ve(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>Qe(e.cython))}}),me.of({name:"Crystal",extensions:["cr"],load(){return ve(()=>Promise.resolve().then(()=>Dgt),void 0,import.meta.url).then(e=>Qe(e.crystal))}}),me.of({name:"D",extensions:["d"],load(){return ve(()=>Promise.resolve().then(()=>i0t),void 0,import.meta.url).then(e=>Qe(e.d))}}),me.of({name:"Dart",extensions:["dart"],load(){return ve(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Qe(e.dart))}}),me.of({name:"diff",extensions:["diff","patch"],load(){return ve(()=>Promise.resolve().then(()=>a0t),void 0,import.meta.url).then(e=>Qe(e.diff))}}),me.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return ve(()=>Promise.resolve().then(()=>$0t),void 0,import.meta.url).then(e=>Qe(e.dockerFile))}}),me.of({name:"DTD",extensions:["dtd"],load(){return ve(()=>Promise.resolve().then(()=>b0t),void 0,import.meta.url).then(e=>Qe(e.dtd))}}),me.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return ve(()=>Promise.resolve().then(()=>k0t),void 0,import.meta.url).then(e=>Qe(e.dylan))}}),me.of({name:"EBNF",load(){return ve(()=>Promise.resolve().then(()=>P0t),void 0,import.meta.url).then(e=>Qe(e.ebnf))}}),me.of({name:"ECL",extensions:["ecl"],load(){return ve(()=>Promise.resolve().then(()=>C0t),void 0,import.meta.url).then(e=>Qe(e.ecl))}}),me.of({name:"edn",extensions:["edn"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Qe(e.clojure))}}),me.of({name:"Eiffel",extensions:["e"],load(){return ve(()=>Promise.resolve().then(()=>Y0t),void 0,import.meta.url).then(e=>Qe(e.eiffel))}}),me.of({name:"Elm",extensions:["elm"],load(){return ve(()=>Promise.resolve().then(()=>K0t),void 0,import.meta.url).then(e=>Qe(e.elm))}}),me.of({name:"Erlang",extensions:["erl"],load(){return ve(()=>Promise.resolve().then(()=>w$t),void 0,import.meta.url).then(e=>Qe(e.erlang))}}),me.of({name:"Esper",load(){return ve(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>Qe(e.esper))}}),me.of({name:"Factor",extensions:["factor"],load(){return ve(()=>Promise.resolve().then(()=>S$t),void 0,import.meta.url).then(e=>Qe(e.factor))}}),me.of({name:"FCL",load(){return ve(()=>Promise.resolve().then(()=>T$t),void 0,import.meta.url).then(e=>Qe(e.fcl))}}),me.of({name:"Forth",extensions:["forth","fth","4th"],load(){return ve(()=>Promise.resolve().then(()=>R$t),void 0,import.meta.url).then(e=>Qe(e.forth))}}),me.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return ve(()=>Promise.resolve().then(()=>U$t),void 0,import.meta.url).then(e=>Qe(e.fortran))}}),me.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Qe(e.fSharp))}}),me.of({name:"Gas",extensions:["s"],load(){return ve(()=>Promise.resolve().then(()=>N$t),void 0,import.meta.url).then(e=>Qe(e.gas))}}),me.of({name:"Gherkin",extensions:["feature"],load(){return ve(()=>Promise.resolve().then(()=>Y$t),void 0,import.meta.url).then(e=>Qe(e.gherkin))}}),me.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return ve(()=>Promise.resolve().then(()=>K$t),void 0,import.meta.url).then(e=>Qe(e.groovy))}}),me.of({name:"Haskell",extensions:["hs"],load(){return ve(()=>Promise.resolve().then(()=>ayt),void 0,import.meta.url).then(e=>Qe(e.haskell))}}),me.of({name:"Haxe",extensions:["hx"],load(){return ve(()=>Promise.resolve().then(()=>qL),void 0,import.meta.url).then(e=>Qe(e.haxe))}}),me.of({name:"HXML",extensions:["hxml"],load(){return ve(()=>Promise.resolve().then(()=>qL),void 0,import.meta.url).then(e=>Qe(e.hxml))}}),me.of({name:"HTTP",load(){return ve(()=>Promise.resolve().then(()=>Tyt),void 0,import.meta.url).then(e=>Qe(e.http))}}),me.of({name:"IDL",extensions:["pro"],load(){return ve(()=>Promise.resolve().then(()=>Cyt),void 0,import.meta.url).then(e=>Qe(e.idl))}}),me.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return ve(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>Qe(e.jsonld))}}),me.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return ve(()=>Promise.resolve().then(()=>Wyt),void 0,import.meta.url).then(e=>Qe(e.jinja2))}}),me.of({name:"Julia",extensions:["jl"],load(){return ve(()=>Promise.resolve().then(()=>uvt),void 0,import.meta.url).then(e=>Qe(e.julia))}}),me.of({name:"Kotlin",extensions:["kt","kts"],load(){return ve(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Qe(e.kotlin))}}),me.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return ve(()=>Promise.resolve().then(()=>hvt),void 0,import.meta.url).then(e=>Qe(e.liveScript))}}),me.of({name:"Lua",extensions:["lua"],load(){return ve(()=>Promise.resolve().then(()=>wvt),void 0,import.meta.url).then(e=>Qe(e.lua))}}),me.of({name:"mIRC",extensions:["mrc"],load(){return ve(()=>Promise.resolve().then(()=>Dvt),void 0,import.meta.url).then(e=>Qe(e.mirc))}}),me.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return ve(()=>Promise.resolve().then(()=>Xvt),void 0,import.meta.url).then(e=>Qe(e.mathematica))}}),me.of({name:"Modelica",extensions:["mo"],load(){return ve(()=>Promise.resolve().then(()=>tbt),void 0,import.meta.url).then(e=>Qe(e.modelica))}}),me.of({name:"MUMPS",extensions:["mps"],load(){return ve(()=>Promise.resolve().then(()=>gbt),void 0,import.meta.url).then(e=>Qe(e.mumps))}}),me.of({name:"Mbox",extensions:["mbox"],load(){return ve(()=>Promise.resolve().then(()=>Gvt),void 0,import.meta.url).then(e=>Qe(e.mbox))}}),me.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return ve(()=>Promise.resolve().then(()=>wbt),void 0,import.meta.url).then(e=>Qe(e.nginx))}}),me.of({name:"NSIS",extensions:["nsh","nsi"],load(){return ve(()=>Promise.resolve().then(()=>Sbt),void 0,import.meta.url).then(e=>Qe(e.nsis))}}),me.of({name:"NTriples",extensions:["nt","nq"],load(){return ve(()=>Promise.resolve().then(()=>xbt),void 0,import.meta.url).then(e=>Qe(e.ntriples))}}),me.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return ve(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Qe(e.objectiveC))}}),me.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return ve(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Qe(e.objectiveCpp))}}),me.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Qe(e.oCaml))}}),me.of({name:"Octave",extensions:["m"],load(){return ve(()=>Promise.resolve().then(()=>Cbt),void 0,import.meta.url).then(e=>Qe(e.octave))}}),me.of({name:"Oz",extensions:["oz"],load(){return ve(()=>Promise.resolve().then(()=>Mbt),void 0,import.meta.url).then(e=>Qe(e.oz))}}),me.of({name:"Pascal",extensions:["p","pas"],load(){return ve(()=>Promise.resolve().then(()=>Jbt),void 0,import.meta.url).then(e=>Qe(e.pascal))}}),me.of({name:"Perl",extensions:["pl","pm"],load(){return ve(()=>Promise.resolve().then(()=>ewt),void 0,import.meta.url).then(e=>Qe(e.perl))}}),me.of({name:"Pig",extensions:["pig"],load(){return ve(()=>Promise.resolve().then(()=>rwt),void 0,import.meta.url).then(e=>Qe(e.pig))}}),me.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return ve(()=>Promise.resolve().then(()=>ywt),void 0,import.meta.url).then(e=>Qe(e.powerShell))}}),me.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return ve(()=>Promise.resolve().then(()=>vwt),void 0,import.meta.url).then(e=>Qe(e.properties))}}),me.of({name:"ProtoBuf",extensions:["proto"],load(){return ve(()=>Promise.resolve().then(()=>Qwt),void 0,import.meta.url).then(e=>Qe(e.protobuf))}}),me.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return ve(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([6,7]),import.meta.url).then(e=>Qe(e.pug))}}),me.of({name:"Puppet",extensions:["pp"],load(){return ve(()=>Promise.resolve().then(()=>Twt),void 0,import.meta.url).then(e=>Qe(e.puppet))}}),me.of({name:"Q",extensions:["q"],load(){return ve(()=>Promise.resolve().then(()=>zwt),void 0,import.meta.url).then(e=>Qe(e.q))}}),me.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return ve(()=>Promise.resolve().then(()=>Iwt),void 0,import.meta.url).then(e=>Qe(e.r))}}),me.of({name:"RPM Changes",load(){return ve(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Qe(e.rpmChanges))}}),me.of({name:"RPM Spec",extensions:["spec"],load(){return ve(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Qe(e.rpmSpec))}}),me.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return ve(()=>Promise.resolve().then(()=>Kwt),void 0,import.meta.url).then(e=>Qe(e.ruby))}}),me.of({name:"SAS",extensions:["sas"],load(){return ve(()=>Promise.resolve().then(()=>n1t),void 0,import.meta.url).then(e=>Qe(e.sas))}}),me.of({name:"Scala",extensions:["scala"],load(){return ve(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Qe(e.scala))}}),me.of({name:"Scheme",extensions:["scm","ss"],load(){return ve(()=>Promise.resolve().then(()=>p1t),void 0,import.meta.url).then(e=>Qe(e.scheme))}}),me.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return ve(()=>Promise.resolve().then(()=>y1t),void 0,import.meta.url).then(e=>Qe(e.shell))}}),me.of({name:"Sieve",extensions:["siv","sieve"],load(){return ve(()=>Promise.resolve().then(()=>x1t),void 0,import.meta.url).then(e=>Qe(e.sieve))}}),me.of({name:"Smalltalk",extensions:["st"],load(){return ve(()=>Promise.resolve().then(()=>P1t),void 0,import.meta.url).then(e=>Qe(e.smalltalk))}}),me.of({name:"Solr",load(){return ve(()=>Promise.resolve().then(()=>j1t),void 0,import.meta.url).then(e=>Qe(e.solr))}}),me.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Qe(e.sml))}}),me.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return ve(()=>Promise.resolve().then(()=>Y1t),void 0,import.meta.url).then(e=>Qe(e.sparql))}}),me.of({name:"Spreadsheet",alias:["excel","formula"],load(){return ve(()=>Promise.resolve().then(()=>G1t),void 0,import.meta.url).then(e=>Qe(e.spreadsheet))}}),me.of({name:"Squirrel",extensions:["nut"],load(){return ve(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Qe(e.squirrel))}}),me.of({name:"Stylus",extensions:["styl"],load(){return ve(()=>Promise.resolve().then(()=>uSt),void 0,import.meta.url).then(e=>Qe(e.stylus))}}),me.of({name:"Swift",extensions:["swift"],load(){return ve(()=>Promise.resolve().then(()=>XSt),void 0,import.meta.url).then(e=>Qe(e.swift))}}),me.of({name:"sTeX",load(){return ve(()=>Promise.resolve().then(()=>xF),void 0,import.meta.url).then(e=>Qe(e.stex))}}),me.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return ve(()=>Promise.resolve().then(()=>xF),void 0,import.meta.url).then(e=>Qe(e.stex))}}),me.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return ve(()=>Promise.resolve().then(()=>ZF),void 0,import.meta.url).then(e=>Qe(e.verilog))}}),me.of({name:"Tcl",extensions:["tcl"],load(){return ve(()=>Promise.resolve().then(()=>jSt),void 0,import.meta.url).then(e=>Qe(e.tcl))}}),me.of({name:"Textile",extensions:["textile"],load(){return ve(()=>Promise.resolve().then(()=>USt),void 0,import.meta.url).then(e=>Qe(e.textile))}}),me.of({name:"TiddlyWiki",load(){return ve(()=>Promise.resolve().then(()=>axt),void 0,import.meta.url).then(e=>Qe(e.tiddlyWiki))}}),me.of({name:"Tiki wiki",load(){return ve(()=>Promise.resolve().then(()=>dxt),void 0,import.meta.url).then(e=>Qe(e.tiki))}}),me.of({name:"TOML",extensions:["toml"],load(){return ve(()=>Promise.resolve().then(()=>fxt),void 0,import.meta.url).then(e=>Qe(e.toml))}}),me.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return ve(()=>Promise.resolve().then(()=>mxt),void 0,import.meta.url).then(e=>Qe(e.troff))}}),me.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return ve(()=>Promise.resolve().then(()=>jxt),void 0,import.meta.url).then(e=>Qe(e.ttcn))}}),me.of({name:"TTCN_CFG",extensions:["cfg"],load(){return ve(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>Qe(e.ttcnCfg))}}),me.of({name:"Turtle",extensions:["ttl"],load(){return ve(()=>Promise.resolve().then(()=>Axt),void 0,import.meta.url).then(e=>Qe(e.turtle))}}),me.of({name:"Web IDL",extensions:["webidl"],load(){return ve(()=>Promise.resolve().then(()=>XQt),void 0,import.meta.url).then(e=>Qe(e.webIDL))}}),me.of({name:"VB.NET",extensions:["vb"],load(){return ve(()=>Promise.resolve().then(()=>Kxt),void 0,import.meta.url).then(e=>Qe(e.vb))}}),me.of({name:"VBScript",extensions:["vbs"],load(){return ve(()=>Promise.resolve().then(()=>eQt),void 0,import.meta.url).then(e=>Qe(e.vbScript))}}),me.of({name:"Velocity",extensions:["vtl"],load(){return ve(()=>Promise.resolve().then(()=>rQt),void 0,import.meta.url).then(e=>Qe(e.velocity))}}),me.of({name:"Verilog",extensions:["v"],load(){return ve(()=>Promise.resolve().then(()=>ZF),void 0,import.meta.url).then(e=>Qe(e.verilog))}}),me.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return ve(()=>Promise.resolve().then(()=>dQt),void 0,import.meta.url).then(e=>Qe(e.vhdl))}}),me.of({name:"XQuery",extensions:["xy","xquery"],load(){return ve(()=>Promise.resolve().then(()=>NQt),void 0,import.meta.url).then(e=>Qe(e.xQuery))}}),me.of({name:"Yacas",extensions:["ys"],load(){return ve(()=>Promise.resolve().then(()=>BQt),void 0,import.meta.url).then(e=>Qe(e.yacas))}}),me.of({name:"Z80",extensions:["z80"],load(){return ve(()=>Promise.resolve().then(()=>tkt),void 0,import.meta.url).then(e=>Qe(e.z80))}}),me.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return ve(()=>Promise.resolve().then(()=>L_),void 0,import.meta.url).then(e=>Qe(e.mscgen))}}),me.of({name:"Xù",extensions:["xu"],load(){return ve(()=>Promise.resolve().then(()=>L_),void 0,import.meta.url).then(e=>Qe(e.xu))}}),me.of({name:"MsGenny",extensions:["msgenny"],load(){return ve(()=>Promise.resolve().then(()=>L_),void 0,import.meta.url).then(e=>Qe(e.msgenny))}}),me.of({name:"Vue",extensions:["vue"],load(){return ve(()=>Promise.resolve().then(()=>Oht),void 0,import.meta.url).then(e=>e.vue())}}),me.of({name:"Angular Template",load(){return ve(()=>Promise.resolve().then(()=>Xht),void 0,import.meta.url).then(e=>e.angular())}})];class a9{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=Fn(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(Mpe(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 vD(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 Itt(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=vD(t)+vD(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Hy(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:Itt(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function KQ(e,t){return n=>{for(let r=Fn(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 bD{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function Ud(e){return e.selection.main.from}function Mpe(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 o9=kf.define();function Ztt(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return Object.assign(Object.assign({},e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let l=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:l},range:Ze.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const wD=new WeakMap;function Dtt(e){if(!Array.isArray(e))return e;let t=wD.get(e);return t||wD.set(e,t=Hy(e)),t}const uS=Tn.define(),b$=Tn.define();class Vtt{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=wo(t,n),i=_c(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(wo(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 v=wo(t,0),S=_c(v),x=S==t.length?0:-100;if(v!=n[0])if(v==r[0])x+=-200;else return null;return this.ret(x,[0,S])}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 v=0,S=Math.min(t.length,200);v<S&&c<l;){let x=wo(t,v);(x==n[c]||x==r[c])&&(i[c++]=v),v+=_c(x)}if(c<l)return null}let u=0,O=0,d=!1,f=0,p=-1,m=-1,g=/[a-z]/.test(t),y=!0;for(let v=0,S=Math.min(t.length,200),x=0;v<S&&O<l;){let b=wo(t,v);s<0&&(u<l&&b==n[u]&&(a[u++]=v),f<l&&(b==n[f]||b==r[f]?(f==0&&(p=v),m=v+1,f++):f=0));let w,Q=b<255?b>=48&&b<=57||b>=97&&b<=122?2:b>=65&&b<=90?1:0:(w=ihe(b))!=w.toLowerCase()?1:w!=w.toUpperCase()?2:0;(!v||Q==1&&g||x==0&&Q!=0)&&(n[O]==b||r[O]==b&&(d=!0)?o[O++]=v:o.length&&(y=!1)),x=Q,v+=_c(b)}return O==l&&o[0]==0&&y?this.result(-100+(d?-200:0),o,t):f==l&&p==0?this.ret(-200-t.length+(m==t.length?0:-100),[0,m]):s>-1?this.ret(-700-t.length,[s,s+this.pattern.length]):f==l?this.ret(-900-t.length,[p,m]):O==l?this.result(-100+(d?-200:0)+-700+(y?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?_c(wo(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 Mtt{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 Ri=Ot.define({combine(e){return $m(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:Ltt,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=>SD(t(r),n(r)),optionClass:(t,n)=>r=>SD(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function SD(e,t){return e?t?e+" "+t:e:t}function Ltt(e,t,n,r,i,a){let o=e.textDirection==wr.RTL,s=o,l=!1,c="top",u,O,d=t.left-i.left,f=i.right-t.right,p=r.right-r.left,m=r.bottom-r.top;if(s&&d<Math.min(p,f)?s=!1:!s&&f<Math.min(p,d)&&(s=!0),p<=(s?d:f))u=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,O=Math.min(400,s?d:f);else{l=!0,O=Math.min(400,(o?t.right:i.right-t.left)-30);let v=i.bottom-t.bottom;v>=m||v>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,y=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${O/y}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function Ftt(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 IT(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 Btt{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(Ri);this.optionContent=Ftt(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=IT(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(Ri).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:b$.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=IT(a.length,o,t.state.facet(Ri).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=IT(n.options.length,n.selected,this.view.state.facet(Ri).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=>Ia(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&&Ktt(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(Ri).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 f=i.appendChild(document.createElement("completion-section"));f.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 f=d(s,this.view.state,this.view,l);f&&u.appendChild(f)}}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 Htt(e,t){return n=>new Btt(n,e,t)}function Ktt(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 xD(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Jtt(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(Ri);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 bD(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,f=a.filterStrict?new Mtt(O):new Vtt(O);for(let p of c.result.options)if(d=f.match(p.label)){let m=p.displayLabel?u?u(p,d.matched):[]:d.matched;i(new bD(p,c.source,m,d.score+(p.boost||0)))}}}if(r){let c=Object.create(null),u=0,O=(d,f)=>{var p,m;return((p=d.rank)!==null&&p!==void 0?p:1e9)-((m=f.rank)!==null&&m!==void 0?m:1e9)||(d.name<f.name?-1:1)};for(let d of r.sort(O))u-=1e5,c[d.name]=u;for(let d of n){let{section:f}=d.completion;f&&(d.score+=c[typeof f=="string"?f:f.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):xD(c.completion)>xD(s)&&(o[o.length-1]=c),s=c.completion}return o}class Qh{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 Qh(this.options,QD(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=Jtt(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Ri).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 Qh(s,QD(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:ant,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new Qh(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 Qh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class OS{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new OS(rnt,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Ri),a=(r.override||n.languageDataAt("autocomplete",Ud(n)).map(Dtt)).map(l=>(this.active.find(u=>u.source==l)||new ls(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(s9));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!ent(a,this.active)||s?o=Qh.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 ls(l.source,0):l));for(let l of t.effects)l.is(Fpe)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new OS(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?tnt:nnt}}function ent(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 tnt={"aria-autocomplete":"list"},nnt={};function QD(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const rnt=[];function Lpe(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(o9);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 ls{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=Lpe(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new ls(i.source,0)),r&4&&i.state==0&&(i=new ls(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(uS))i=new ls(i.source,1,a.value);else if(a.is(b$))i=new ls(i.source,0);else if(a.is(s9))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(Ud(t.state))}}class Dh extends ls{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=Ud(t.state);if(s>o||!i||n&2&&(Ud(t.startState)==this.from||s<this.limit))return new ls(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return int(i.validFor,t.state,a,o)?new Dh(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new a9(t.state,s,!1)))?new Dh(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:Ud(t.state)):new ls(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new Dh(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new ls(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function int(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Mpe(e,!0).test(i)}const s9=Tn.define({map(e,t){return e.map(n=>n.map(t))}}),Fpe=Tn.define(),Na=Ha.define({create(){return OS.start()},update(e,t){return e.update(t)},provide:e=>[KA.from(e,t=>t.tooltip),wt.contentAttributes.from(e,t=>t.attrs)]});function l9(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Na).active.find(i=>i.source==t.source);return r instanceof Dh?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},Ztt(e.state,n,r.from,r.to)),{annotations:o9.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const ant=Htt(Na,l9);function yb(e,t="option"){return n=>{let r=n.state.field(Na,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ri).interactionDelay)return!1;let i=1,a;t=="page"&&(a=ype(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:Fpe.of(s)}),!0}}const ont=e=>{let t=e.state.field(Na,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ri).interactionDelay?!1:l9(e,t.open.options[t.open.selected])},kD=e=>e.state.field(Na,!1)?(e.dispatch({effects:uS.of(!0)}),!0):!1,snt=e=>{let t=e.state.field(Na,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:b$.of(null)}),!0)};class lnt{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const cnt=50,unt=1e3,Ont=bi.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(Na).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Na),n=e.state.facet(Ri);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Na)==t)return;let r=e.transactions.some(a=>{let o=Lpe(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>cnt&&Date.now()-o.time>unt){for(let s of o.context.abortListeners)try{s()}catch(l){Ia(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(uS)))&&(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(Na);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(Ri).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=Ud(t),r=new a9(t,n,e.explicit,this.view),i=new lnt(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:b$.of(null)}),Ia(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(Ri).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Ri),r=this.view.state.field(Na);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=Ud(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new Dh(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 ls(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:s9.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Na,!1);if(t&&t.tooltip&&this.view.state.facet(Ri).closeOnBlur){let n=t.open&&ype(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:b$.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:uS.of(!1)}),20),this.composing=0}}}),dnt=typeof navigator=="object"&&/Win/.test(navigator.platform),fnt=PO.highest(wt.domEventHandlers({keydown(e,t){let n=t.state.field(Na,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(dnt&&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&&l9(t,r),!1}})),Bpe=wt.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 hnt{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class c9{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Ni.TrackDel),r=t.mapPos(this.to,1,Ni.TrackDel);return n==null||r==null?null:new c9(this.field,n,r)}}class u9{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(FQ);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 c9(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 hnt(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 u9(r,i)}}let pnt=sn.widget({widget:new class extends mu{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),mnt=sn.mark({class:"cm-snippetField"});class ym{constructor(t,n){this.ranges=t,this.active=n,this.deco=sn.set(t.map(r=>(r.from==r.to?pnt:mnt).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 ym(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 Ky=Tn.define({map(e,t){return e&&e.map(t)}}),gnt=Tn.define(),w$=Ha.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(Ky))return n.value;if(n.is(gnt)&&e)return new ym(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=>wt.decorations.from(e,t=>t?t.deco:sn.none)});function O9(e,t){return Ze.create(e.filter(n=>n.field==t).map(n=>Ze.range(n.from,n.to)))}function $nt(e){let t=u9.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:Ln.of(o)},scrollIntoView:!0,annotations:r?[o9.of(r),Gi.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=O9(s,0)),s.some(u=>u.field>0)){let u=new ym(s,0),O=c.effects=[Ky.of(u)];n.state.field(w$,!1)===void 0&&O.push(Tn.appendConfig.of([w$,Snt,xnt,Bpe]))}n.dispatch(n.state.update(c))}}function Hpe(e){return({state:t,dispatch:n})=>{let r=t.field(w$,!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:O9(r.ranges,i),effects:Ky.of(a?null:new ym(r.ranges,i)),scrollIntoView:!0})),!0}}const ynt=({state:e,dispatch:t})=>e.field(w$,!1)?(t(e.update({effects:Ky.of(null)})),!0):!1,vnt=Hpe(1),bnt=Hpe(-1),wnt=[{key:"Tab",run:vnt,shift:bnt},{key:"Escape",run:ynt}],PD=Ot.define({combine(e){return e.length?e[0]:wnt}}),Snt=PO.highest(VQ.compute([PD],e=>e.facet(PD)));function gr(e,t){return Object.assign(Object.assign({},t),{apply:$nt(e)})}const xnt=wt.domEventHandlers({mousedown(e,t){let n=t.state.field(w$,!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:O9(n.ranges,i.field),effects:Ky.of(n.ranges.some(a=>a.field>i.field)?new ym(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),S$={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Sd=Tn.define({map(e,t){let n=t.mapPos(e,-1,Ni.TrackAfter);return n??void 0}}),d9=new class extends Kd{};d9.startSide=1;d9.endSide=-1;const Kpe=Ha.define({create(){return Pn.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(Sd)&&(e=e.update({add:[d9.range(n.value,n.value+1)]}));return e}});function Mon(){return[knt,Kpe]}const ZT="()[]{}<>«»»«[]{}";function Jpe(e){for(let t=0;t<ZT.length;t+=2)if(ZT.charCodeAt(t)==e)return ZT.charAt(t+1);return ihe(e<128?e:e+1)}function eme(e,t){return e.languageDataAt("closeBrackets",t)[0]||S$}const Qnt=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),knt=wt.inputHandler.of((e,t,n,r)=>{if((Qnt?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&_c(wo(r,0))==1||t!=i.from||n!=i.to)return!1;let a=Tnt(e.state,r);return a?(e.dispatch(a),!0):!1}),Pnt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=eme(e,e.selection.main.head).brackets||S$.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=_nt(e.doc,o.head);for(let l of r)if(l==s&&JQ(e.doc,o.head)==Jpe(wo(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Ze.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},Lon=[{key:"Backspace",run:Pnt}];function Tnt(e,t){let n=eme(e,e.selection.main.head),r=n.brackets||S$.brackets;for(let i of r){let a=Jpe(wo(i,0));if(t==i)return a==i?Ent(e,i,r.indexOf(i+i+i)>-1,n):Xnt(e,i,a,n.before||S$.before);if(t==a&&tme(e,e.selection.main.from))return Rnt(e,i,a)}return null}function tme(e,t){let n=!1;return e.field(Kpe).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function JQ(e,t){let n=e.sliceString(t,t+2);return n.slice(0,_c(wo(n,0)))}function _nt(e,t){let n=e.sliceString(t-2,t);return _c(wo(n,0))==n.length?n:n.slice(1)}function Xnt(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:Sd.of(o.to+t.length),range:Ze.range(o.anchor+t.length,o.head+t.length)};let s=JQ(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:Sd.of(o.head+t.length),range:Ze.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function Rnt(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&JQ(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Ze.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function Ent(e,t,n,r){let i=r.stringPrefixes||S$.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:Sd.of(s.to+t.length),range:Ze.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=JQ(e.doc,l),u;if(c==t){if(TD(e,l))return{changes:{insert:t+t,from:l},effects:Sd.of(l+t.length),range:Ze.cursor(l+t.length)};if(tme(e,l)){let d=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+d.length,insert:d},range:Ze.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=_D(e,l-2*t.length,i))>-1&&TD(e,u))return{changes:{insert:t+t+t+t,from:l},effects:Sd.of(l+t.length),range:Ze.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=ss.Word&&_D(e,l,i)>-1&&!qnt(e,l,t,i))return{changes:{insert:t+t,from:l},effects:Sd.of(l+t.length),range:Ze.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function TD(e,t){let n=Fn(e).resolveInner(t+1);return n.parent&&n.from==t}function qnt(e,t,n,r){let i=Fn(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 _D(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=ss.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))!=ss.Word)return a}return-1}function Fon(e={}){return[fnt,Na,Ri.of(e),Ont,Cnt,Bpe]}const jnt=[{key:"Ctrl-Space",run:kD},{mac:"Alt-`",run:kD},{key:"Escape",run:snt},{key:"ArrowDown",run:yb(!0)},{key:"ArrowUp",run:yb(!1)},{key:"PageDown",run:yb(!0,"page")},{key:"PageUp",run:yb(!1,"page")},{key:"Enter",run:ont}],Cnt=PO.highest(VQ.computeN([Ri],e=>e.facet(Ri).defaultKeymap?[jnt]:[]));class dS{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new dS(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 dn(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 dn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new dn(ci.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 znt{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let Ant=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 S0(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 XD(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?p9:h9)(n,t,!1);return r>0&&(e.type!=Ve.BulletList||f9(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const nme={[Ve.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(wn(Ve.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(ws(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]:XD,[Ve.BulletList]:XD,[Ve.Document](){return!0}};function ws(e){return e==32||e==9||e==10||e==13}function S0(e,t=0){for(;t<e.length&&ws(e.charCodeAt(t));)t++;return t}function RD(e,t,n){for(;t>n&&ws(e.charCodeAt(t-1));)t--;return t}function rme(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 ime(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function f9(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(!ws(a))return-1}return n&&e.next==45&&sme(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(Ome.SetextHeading)>-1||r<3?-1:1}function ame(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function h9(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||ws(e.text.charCodeAt(e.pos+1)))&&(!n||ame(t,Ve.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function p9(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&&!ws(e.text.charCodeAt(r+1))||n&&!ame(t,Ve.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function ome(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 sme(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&&ws(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const sj=/^[ \t]*$/,lme=/-->/,cme=/\?>/,lj=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,lme],[/^\s*<\?/,cme],[/^\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,sj],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,sj]];function ume(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=lj.length-(n?1:0);i<a;i++)if(lj[i][0].test(r))return i;return-1}function ED(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function JO(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Ve.CodeText?e[r].to=n:e.push(wn(Ve.CodeText,t,n))}const vb={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(JO(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){JO(s,e.lineStart-1,e.lineStart);for(let l of t.markers)s.push(l)}else{if(t.indent<n)break;{if(s.length){for(let c of s)c.type==Ve.CodeText?JO(o,c.from,c.to):o.push(c);s=[]}JO(o,e.lineStart-1,e.lineStart);for(let c of t.markers)o.push(c);a=e.lineStart+t.text.length;let l=e.lineStart+t.findColumn(t.baseIndent+4);l<a&&JO(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=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=rme(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=RD(t.text,t.text.length,o),l=[wn(Ve.CodeMark,r,r+a)];o<s&&l.push(wn(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(wn(Ve.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||JO(l,e.lineStart-1,e.lineStart);for(let f of t.markers)l.push(f);let O=e.lineStart+t.basePos,d=e.lineStart+t.text.length;O<d&&JO(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Ve.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=ime(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(f9(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=h9(t,e,!1);if(n<0)return!1;e.block.type!=Ve.BulletList&&e.startContext(Ve.BulletList,t.basePos,t.next);let r=ED(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=p9(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=ED(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=ome(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=RD(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!ws(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=ume(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=lj[n][1],a=[],o=i!=sj;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==lme?Ve.CommentBlock:i==cme?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 Unt{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+`
818
+ `);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 Ype(n,t?t.state.tabSize:4,t?sS(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=Ipe(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=dn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Wtt,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new dn(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 dn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Ipe(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 i9=Object.create(null),v$=[ci.none],Wtt=new gm(v$),$D=[],yD=Object.create(null),Zpe=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"]])Zpe[e]=Vpe(i9,t);class Dpe{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Zpe)}resolve(t){return t?this.table[t]||(this.table[t]=Vpe(this.extra,t)):0}}const Ntt=new Dpe(i9);function GT(e,t){$D.indexOf(e)>-1||($D.push(e),console.warn(t))}function Vpe(e,t){let n=[];for(let s of t.split(" ")){let l=[];for(let c of s.split(".")){let u=e[c]||P[c];u?typeof u=="function"?l.length?l=l.map(u):GT(c,`Modifier ${c} used at start of tag`):l.length?GT(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:GT(c,`Unknown highlighting tag ${c}`)}for(let c of l)n.push(c)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(s=>s.id),a=yD[i];if(a)return a.id;let o=yD[i]=ci.define({id:v$.length,name:r,props:[zn({[r]:n})]});return v$.push(o),o.id}function Ytt(e,t){let n=ci.define({id:v$.length,name:"Document",props:[Ju.add(()=>e),Er.add(()=>r=>t.getIndent(r))],top:!0});return v$.push(n),n}wr.RTL,wr.LTR;function Qe(e){return new Sn(Ee.define(e))}function Tu(e){return ve(()=>Promise.resolve().then(()=>OOt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const Gtt=[me.of({name:"C",extensions:["c","h","ino"],load(){return ve(()=>Promise.resolve().then(()=>uM),void 0,import.meta.url).then(e=>e.cpp())}}),me.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return ve(()=>Promise.resolve().then(()=>uM),void 0,import.meta.url).then(e=>e.cpp())}}),me.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Tu("Cassandra")}}),me.of({name:"CSS",extensions:["css"],load(){return ve(()=>Promise.resolve().then(()=>kit),void 0,import.meta.url).then(e=>e.css())}}),me.of({name:"Go",extensions:["go"],load(){return ve(()=>import("./index-BDqI882o.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(e=>e.go())}}),me.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return ve(()=>Promise.resolve().then(()=>gat),void 0,import.meta.url).then(e=>e.html())}}),me.of({name:"Java",extensions:["java"],load(){return ve(()=>Promise.resolve().then(()=>pOt),void 0,import.meta.url).then(e=>e.java())}}),me.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return ve(()=>Promise.resolve().then(()=>wb),void 0,import.meta.url).then(e=>e.javascript())}}),me.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return ve(()=>Promise.resolve().then(()=>wot),void 0,import.meta.url).then(e=>e.json())}}),me.of({name:"JSX",extensions:["jsx"],load(){return ve(()=>Promise.resolve().then(()=>wb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),me.of({name:"LESS",extensions:["less"],load(){return ve(()=>Promise.resolve().then(()=>Uat),void 0,import.meta.url).then(e=>e.less())}}),me.of({name:"Liquid",extensions:["liquid"],load(){return ve(()=>Promise.resolve().then(()=>eht),void 0,import.meta.url).then(e=>e.liquid())}}),me.of({name:"MariaDB SQL",load(){return Tu("MariaSQL")}}),me.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return ve(()=>Promise.resolve().then(()=>Pat),void 0,import.meta.url).then(e=>e.markdown())}}),me.of({name:"MS SQL",load(){return Tu("MSSQL")}}),me.of({name:"MySQL",load(){return Tu("MySQL")}}),me.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return ve(()=>Promise.resolve().then(()=>Rft),void 0,import.meta.url).then(e=>e.php())}}),me.of({name:"PLSQL",extensions:["pls"],load(){return Tu("PLSQL")}}),me.of({name:"PostgreSQL",load(){return Tu("PostgreSQL")}}),me.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return ve(()=>Promise.resolve().then(()=>eut),void 0,import.meta.url).then(e=>e.python())}}),me.of({name:"Rust",extensions:["rs"],load(){return ve(()=>Promise.resolve().then(()=>COt),void 0,import.meta.url).then(e=>e.rust())}}),me.of({name:"Sass",extensions:["sass"],load(){return ve(()=>Promise.resolve().then(()=>QV),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),me.of({name:"SCSS",extensions:["scss"],load(){return ve(()=>Promise.resolve().then(()=>QV),void 0,import.meta.url).then(e=>e.sass())}}),me.of({name:"SQL",extensions:["sql"],load(){return Tu("StandardSQL")}}),me.of({name:"SQLite",load(){return Tu("SQLite")}}),me.of({name:"TSX",extensions:["tsx"],load(){return ve(()=>Promise.resolve().then(()=>wb),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),me.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return ve(()=>Promise.resolve().then(()=>wb),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),me.of({name:"WebAssembly",extensions:["wat","wast"],load(){return ve(()=>Promise.resolve().then(()=>rht),void 0,import.meta.url).then(e=>e.wast())}}),me.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return ve(()=>Promise.resolve().then(()=>wut),void 0,import.meta.url).then(e=>e.xml())}}),me.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return ve(()=>import("./index-fKRRIb8a.js"),__vite__mapDeps([5,1,2,3,4]),import.meta.url).then(e=>e.yaml())}}),me.of({name:"APL",extensions:["dyalog","apl"],load(){return ve(()=>Promise.resolve().then(()=>Emt),void 0,import.meta.url).then(e=>Qe(e.apl))}}),me.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return ve(()=>Promise.resolve().then(()=>qmt),void 0,import.meta.url).then(e=>Qe(e.asciiArmor))}}),me.of({name:"ASN.1",extensions:["asn","asn1"],load(){return ve(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>Qe(e.asn1({})))}}),me.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return ve(()=>Promise.resolve().then(()=>Umt),void 0,import.meta.url).then(e=>Qe(e.asterisk))}}),me.of({name:"Brainfuck",extensions:["b","bf"],load(){return ve(()=>Promise.resolve().then(()=>Nmt),void 0,import.meta.url).then(e=>Qe(e.brainfuck))}}),me.of({name:"Cobol",extensions:["cob","cpy"],load(){return ve(()=>Promise.resolve().then(()=>hgt),void 0,import.meta.url).then(e=>Qe(e.cobol))}}),me.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return ve(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Qe(e.csharp))}}),me.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Qe(e.clojure))}}),me.of({name:"ClojureScript",extensions:["cljs"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Qe(e.clojure))}}),me.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return ve(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>Qe(e.gss))}}),me.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return ve(()=>Promise.resolve().then(()=>agt),void 0,import.meta.url).then(e=>Qe(e.cmake))}}),me.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return ve(()=>Promise.resolve().then(()=>Pgt),void 0,import.meta.url).then(e=>Qe(e.coffeeScript))}}),me.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return ve(()=>Promise.resolve().then(()=>qgt),void 0,import.meta.url).then(e=>Qe(e.commonLisp))}}),me.of({name:"Cypher",extensions:["cyp","cypher"],load(){return ve(()=>Promise.resolve().then(()=>Hgt),void 0,import.meta.url).then(e=>Qe(e.cypher))}}),me.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return ve(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>Qe(e.cython))}}),me.of({name:"Crystal",extensions:["cr"],load(){return ve(()=>Promise.resolve().then(()=>Dgt),void 0,import.meta.url).then(e=>Qe(e.crystal))}}),me.of({name:"D",extensions:["d"],load(){return ve(()=>Promise.resolve().then(()=>i0t),void 0,import.meta.url).then(e=>Qe(e.d))}}),me.of({name:"Dart",extensions:["dart"],load(){return ve(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Qe(e.dart))}}),me.of({name:"diff",extensions:["diff","patch"],load(){return ve(()=>Promise.resolve().then(()=>a0t),void 0,import.meta.url).then(e=>Qe(e.diff))}}),me.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return ve(()=>Promise.resolve().then(()=>$0t),void 0,import.meta.url).then(e=>Qe(e.dockerFile))}}),me.of({name:"DTD",extensions:["dtd"],load(){return ve(()=>Promise.resolve().then(()=>b0t),void 0,import.meta.url).then(e=>Qe(e.dtd))}}),me.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return ve(()=>Promise.resolve().then(()=>k0t),void 0,import.meta.url).then(e=>Qe(e.dylan))}}),me.of({name:"EBNF",load(){return ve(()=>Promise.resolve().then(()=>P0t),void 0,import.meta.url).then(e=>Qe(e.ebnf))}}),me.of({name:"ECL",extensions:["ecl"],load(){return ve(()=>Promise.resolve().then(()=>C0t),void 0,import.meta.url).then(e=>Qe(e.ecl))}}),me.of({name:"edn",extensions:["edn"],load(){return ve(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>Qe(e.clojure))}}),me.of({name:"Eiffel",extensions:["e"],load(){return ve(()=>Promise.resolve().then(()=>Y0t),void 0,import.meta.url).then(e=>Qe(e.eiffel))}}),me.of({name:"Elm",extensions:["elm"],load(){return ve(()=>Promise.resolve().then(()=>K0t),void 0,import.meta.url).then(e=>Qe(e.elm))}}),me.of({name:"Erlang",extensions:["erl"],load(){return ve(()=>Promise.resolve().then(()=>w$t),void 0,import.meta.url).then(e=>Qe(e.erlang))}}),me.of({name:"Esper",load(){return ve(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>Qe(e.esper))}}),me.of({name:"Factor",extensions:["factor"],load(){return ve(()=>Promise.resolve().then(()=>S$t),void 0,import.meta.url).then(e=>Qe(e.factor))}}),me.of({name:"FCL",load(){return ve(()=>Promise.resolve().then(()=>T$t),void 0,import.meta.url).then(e=>Qe(e.fcl))}}),me.of({name:"Forth",extensions:["forth","fth","4th"],load(){return ve(()=>Promise.resolve().then(()=>R$t),void 0,import.meta.url).then(e=>Qe(e.forth))}}),me.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return ve(()=>Promise.resolve().then(()=>U$t),void 0,import.meta.url).then(e=>Qe(e.fortran))}}),me.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Qe(e.fSharp))}}),me.of({name:"Gas",extensions:["s"],load(){return ve(()=>Promise.resolve().then(()=>N$t),void 0,import.meta.url).then(e=>Qe(e.gas))}}),me.of({name:"Gherkin",extensions:["feature"],load(){return ve(()=>Promise.resolve().then(()=>Y$t),void 0,import.meta.url).then(e=>Qe(e.gherkin))}}),me.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return ve(()=>Promise.resolve().then(()=>K$t),void 0,import.meta.url).then(e=>Qe(e.groovy))}}),me.of({name:"Haskell",extensions:["hs"],load(){return ve(()=>Promise.resolve().then(()=>ayt),void 0,import.meta.url).then(e=>Qe(e.haskell))}}),me.of({name:"Haxe",extensions:["hx"],load(){return ve(()=>Promise.resolve().then(()=>qL),void 0,import.meta.url).then(e=>Qe(e.haxe))}}),me.of({name:"HXML",extensions:["hxml"],load(){return ve(()=>Promise.resolve().then(()=>qL),void 0,import.meta.url).then(e=>Qe(e.hxml))}}),me.of({name:"HTTP",load(){return ve(()=>Promise.resolve().then(()=>Tyt),void 0,import.meta.url).then(e=>Qe(e.http))}}),me.of({name:"IDL",extensions:["pro"],load(){return ve(()=>Promise.resolve().then(()=>Cyt),void 0,import.meta.url).then(e=>Qe(e.idl))}}),me.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return ve(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>Qe(e.jsonld))}}),me.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return ve(()=>Promise.resolve().then(()=>Wyt),void 0,import.meta.url).then(e=>Qe(e.jinja2))}}),me.of({name:"Julia",extensions:["jl"],load(){return ve(()=>Promise.resolve().then(()=>uvt),void 0,import.meta.url).then(e=>Qe(e.julia))}}),me.of({name:"Kotlin",extensions:["kt","kts"],load(){return ve(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Qe(e.kotlin))}}),me.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return ve(()=>Promise.resolve().then(()=>hvt),void 0,import.meta.url).then(e=>Qe(e.liveScript))}}),me.of({name:"Lua",extensions:["lua"],load(){return ve(()=>Promise.resolve().then(()=>wvt),void 0,import.meta.url).then(e=>Qe(e.lua))}}),me.of({name:"mIRC",extensions:["mrc"],load(){return ve(()=>Promise.resolve().then(()=>Dvt),void 0,import.meta.url).then(e=>Qe(e.mirc))}}),me.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return ve(()=>Promise.resolve().then(()=>Xvt),void 0,import.meta.url).then(e=>Qe(e.mathematica))}}),me.of({name:"Modelica",extensions:["mo"],load(){return ve(()=>Promise.resolve().then(()=>tbt),void 0,import.meta.url).then(e=>Qe(e.modelica))}}),me.of({name:"MUMPS",extensions:["mps"],load(){return ve(()=>Promise.resolve().then(()=>gbt),void 0,import.meta.url).then(e=>Qe(e.mumps))}}),me.of({name:"Mbox",extensions:["mbox"],load(){return ve(()=>Promise.resolve().then(()=>Gvt),void 0,import.meta.url).then(e=>Qe(e.mbox))}}),me.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return ve(()=>Promise.resolve().then(()=>wbt),void 0,import.meta.url).then(e=>Qe(e.nginx))}}),me.of({name:"NSIS",extensions:["nsh","nsi"],load(){return ve(()=>Promise.resolve().then(()=>Sbt),void 0,import.meta.url).then(e=>Qe(e.nsis))}}),me.of({name:"NTriples",extensions:["nt","nq"],load(){return ve(()=>Promise.resolve().then(()=>xbt),void 0,import.meta.url).then(e=>Qe(e.ntriples))}}),me.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return ve(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Qe(e.objectiveC))}}),me.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return ve(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Qe(e.objectiveCpp))}}),me.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Qe(e.oCaml))}}),me.of({name:"Octave",extensions:["m"],load(){return ve(()=>Promise.resolve().then(()=>Cbt),void 0,import.meta.url).then(e=>Qe(e.octave))}}),me.of({name:"Oz",extensions:["oz"],load(){return ve(()=>Promise.resolve().then(()=>Mbt),void 0,import.meta.url).then(e=>Qe(e.oz))}}),me.of({name:"Pascal",extensions:["p","pas"],load(){return ve(()=>Promise.resolve().then(()=>Jbt),void 0,import.meta.url).then(e=>Qe(e.pascal))}}),me.of({name:"Perl",extensions:["pl","pm"],load(){return ve(()=>Promise.resolve().then(()=>ewt),void 0,import.meta.url).then(e=>Qe(e.perl))}}),me.of({name:"Pig",extensions:["pig"],load(){return ve(()=>Promise.resolve().then(()=>rwt),void 0,import.meta.url).then(e=>Qe(e.pig))}}),me.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return ve(()=>Promise.resolve().then(()=>ywt),void 0,import.meta.url).then(e=>Qe(e.powerShell))}}),me.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return ve(()=>Promise.resolve().then(()=>vwt),void 0,import.meta.url).then(e=>Qe(e.properties))}}),me.of({name:"ProtoBuf",extensions:["proto"],load(){return ve(()=>Promise.resolve().then(()=>Qwt),void 0,import.meta.url).then(e=>Qe(e.protobuf))}}),me.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return ve(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([6,7]),import.meta.url).then(e=>Qe(e.pug))}}),me.of({name:"Puppet",extensions:["pp"],load(){return ve(()=>Promise.resolve().then(()=>Twt),void 0,import.meta.url).then(e=>Qe(e.puppet))}}),me.of({name:"Q",extensions:["q"],load(){return ve(()=>Promise.resolve().then(()=>zwt),void 0,import.meta.url).then(e=>Qe(e.q))}}),me.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return ve(()=>Promise.resolve().then(()=>Iwt),void 0,import.meta.url).then(e=>Qe(e.r))}}),me.of({name:"RPM Changes",load(){return ve(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Qe(e.rpmChanges))}}),me.of({name:"RPM Spec",extensions:["spec"],load(){return ve(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>Qe(e.rpmSpec))}}),me.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return ve(()=>Promise.resolve().then(()=>Kwt),void 0,import.meta.url).then(e=>Qe(e.ruby))}}),me.of({name:"SAS",extensions:["sas"],load(){return ve(()=>Promise.resolve().then(()=>n1t),void 0,import.meta.url).then(e=>Qe(e.sas))}}),me.of({name:"Scala",extensions:["scala"],load(){return ve(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Qe(e.scala))}}),me.of({name:"Scheme",extensions:["scm","ss"],load(){return ve(()=>Promise.resolve().then(()=>p1t),void 0,import.meta.url).then(e=>Qe(e.scheme))}}),me.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return ve(()=>Promise.resolve().then(()=>y1t),void 0,import.meta.url).then(e=>Qe(e.shell))}}),me.of({name:"Sieve",extensions:["siv","sieve"],load(){return ve(()=>Promise.resolve().then(()=>x1t),void 0,import.meta.url).then(e=>Qe(e.sieve))}}),me.of({name:"Smalltalk",extensions:["st"],load(){return ve(()=>Promise.resolve().then(()=>P1t),void 0,import.meta.url).then(e=>Qe(e.smalltalk))}}),me.of({name:"Solr",load(){return ve(()=>Promise.resolve().then(()=>j1t),void 0,import.meta.url).then(e=>Qe(e.solr))}}),me.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return ve(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>Qe(e.sml))}}),me.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return ve(()=>Promise.resolve().then(()=>Y1t),void 0,import.meta.url).then(e=>Qe(e.sparql))}}),me.of({name:"Spreadsheet",alias:["excel","formula"],load(){return ve(()=>Promise.resolve().then(()=>G1t),void 0,import.meta.url).then(e=>Qe(e.spreadsheet))}}),me.of({name:"Squirrel",extensions:["nut"],load(){return ve(()=>Promise.resolve().then(()=>nd),void 0,import.meta.url).then(e=>Qe(e.squirrel))}}),me.of({name:"Stylus",extensions:["styl"],load(){return ve(()=>Promise.resolve().then(()=>uSt),void 0,import.meta.url).then(e=>Qe(e.stylus))}}),me.of({name:"Swift",extensions:["swift"],load(){return ve(()=>Promise.resolve().then(()=>XSt),void 0,import.meta.url).then(e=>Qe(e.swift))}}),me.of({name:"sTeX",load(){return ve(()=>Promise.resolve().then(()=>xF),void 0,import.meta.url).then(e=>Qe(e.stex))}}),me.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return ve(()=>Promise.resolve().then(()=>xF),void 0,import.meta.url).then(e=>Qe(e.stex))}}),me.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return ve(()=>Promise.resolve().then(()=>ZF),void 0,import.meta.url).then(e=>Qe(e.verilog))}}),me.of({name:"Tcl",extensions:["tcl"],load(){return ve(()=>Promise.resolve().then(()=>jSt),void 0,import.meta.url).then(e=>Qe(e.tcl))}}),me.of({name:"Textile",extensions:["textile"],load(){return ve(()=>Promise.resolve().then(()=>USt),void 0,import.meta.url).then(e=>Qe(e.textile))}}),me.of({name:"TiddlyWiki",load(){return ve(()=>Promise.resolve().then(()=>axt),void 0,import.meta.url).then(e=>Qe(e.tiddlyWiki))}}),me.of({name:"Tiki wiki",load(){return ve(()=>Promise.resolve().then(()=>dxt),void 0,import.meta.url).then(e=>Qe(e.tiki))}}),me.of({name:"TOML",extensions:["toml"],load(){return ve(()=>Promise.resolve().then(()=>fxt),void 0,import.meta.url).then(e=>Qe(e.toml))}}),me.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return ve(()=>Promise.resolve().then(()=>mxt),void 0,import.meta.url).then(e=>Qe(e.troff))}}),me.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return ve(()=>Promise.resolve().then(()=>jxt),void 0,import.meta.url).then(e=>Qe(e.ttcn))}}),me.of({name:"TTCN_CFG",extensions:["cfg"],load(){return ve(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>Qe(e.ttcnCfg))}}),me.of({name:"Turtle",extensions:["ttl"],load(){return ve(()=>Promise.resolve().then(()=>Axt),void 0,import.meta.url).then(e=>Qe(e.turtle))}}),me.of({name:"Web IDL",extensions:["webidl"],load(){return ve(()=>Promise.resolve().then(()=>XQt),void 0,import.meta.url).then(e=>Qe(e.webIDL))}}),me.of({name:"VB.NET",extensions:["vb"],load(){return ve(()=>Promise.resolve().then(()=>Kxt),void 0,import.meta.url).then(e=>Qe(e.vb))}}),me.of({name:"VBScript",extensions:["vbs"],load(){return ve(()=>Promise.resolve().then(()=>eQt),void 0,import.meta.url).then(e=>Qe(e.vbScript))}}),me.of({name:"Velocity",extensions:["vtl"],load(){return ve(()=>Promise.resolve().then(()=>rQt),void 0,import.meta.url).then(e=>Qe(e.velocity))}}),me.of({name:"Verilog",extensions:["v"],load(){return ve(()=>Promise.resolve().then(()=>ZF),void 0,import.meta.url).then(e=>Qe(e.verilog))}}),me.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return ve(()=>Promise.resolve().then(()=>dQt),void 0,import.meta.url).then(e=>Qe(e.vhdl))}}),me.of({name:"XQuery",extensions:["xy","xquery"],load(){return ve(()=>Promise.resolve().then(()=>NQt),void 0,import.meta.url).then(e=>Qe(e.xQuery))}}),me.of({name:"Yacas",extensions:["ys"],load(){return ve(()=>Promise.resolve().then(()=>BQt),void 0,import.meta.url).then(e=>Qe(e.yacas))}}),me.of({name:"Z80",extensions:["z80"],load(){return ve(()=>Promise.resolve().then(()=>tkt),void 0,import.meta.url).then(e=>Qe(e.z80))}}),me.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return ve(()=>Promise.resolve().then(()=>L_),void 0,import.meta.url).then(e=>Qe(e.mscgen))}}),me.of({name:"Xù",extensions:["xu"],load(){return ve(()=>Promise.resolve().then(()=>L_),void 0,import.meta.url).then(e=>Qe(e.xu))}}),me.of({name:"MsGenny",extensions:["msgenny"],load(){return ve(()=>Promise.resolve().then(()=>L_),void 0,import.meta.url).then(e=>Qe(e.msgenny))}}),me.of({name:"Vue",extensions:["vue"],load(){return ve(()=>Promise.resolve().then(()=>Oht),void 0,import.meta.url).then(e=>e.vue())}}),me.of({name:"Angular Template",load(){return ve(()=>Promise.resolve().then(()=>Xht),void 0,import.meta.url).then(e=>e.angular())}})];class a9{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=Fn(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(Mpe(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 vD(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 Itt(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=vD(t)+vD(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Hy(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:Itt(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function KQ(e,t){return n=>{for(let r=Fn(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 bD{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function Ud(e){return e.selection.main.from}function Mpe(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 o9=kf.define();function Ztt(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return Object.assign(Object.assign({},e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let l=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:l},range:Ze.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const wD=new WeakMap;function Dtt(e){if(!Array.isArray(e))return e;let t=wD.get(e);return t||wD.set(e,t=Hy(e)),t}const uS=Tn.define(),b$=Tn.define();class Vtt{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=wo(t,n),i=_c(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(wo(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 v=wo(t,0),S=_c(v),x=S==t.length?0:-100;if(v!=n[0])if(v==r[0])x+=-200;else return null;return this.ret(x,[0,S])}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 v=0,S=Math.min(t.length,200);v<S&&c<l;){let x=wo(t,v);(x==n[c]||x==r[c])&&(i[c++]=v),v+=_c(x)}if(c<l)return null}let u=0,O=0,d=!1,f=0,p=-1,m=-1,g=/[a-z]/.test(t),y=!0;for(let v=0,S=Math.min(t.length,200),x=0;v<S&&O<l;){let b=wo(t,v);s<0&&(u<l&&b==n[u]&&(a[u++]=v),f<l&&(b==n[f]||b==r[f]?(f==0&&(p=v),m=v+1,f++):f=0));let w,Q=b<255?b>=48&&b<=57||b>=97&&b<=122?2:b>=65&&b<=90?1:0:(w=ihe(b))!=w.toLowerCase()?1:w!=w.toUpperCase()?2:0;(!v||Q==1&&g||x==0&&Q!=0)&&(n[O]==b||r[O]==b&&(d=!0)?o[O++]=v:o.length&&(y=!1)),x=Q,v+=_c(b)}return O==l&&o[0]==0&&y?this.result(-100+(d?-200:0),o,t):f==l&&p==0?this.ret(-200-t.length+(m==t.length?0:-100),[0,m]):s>-1?this.ret(-700-t.length,[s,s+this.pattern.length]):f==l?this.ret(-900-t.length,[p,m]):O==l?this.result(-100+(d?-200:0)+-700+(y?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?_c(wo(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 Mtt{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 Ri=Ot.define({combine(e){return $m(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:Ltt,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=>SD(t(r),n(r)),optionClass:(t,n)=>r=>SD(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function SD(e,t){return e?t?e+" "+t:e:t}function Ltt(e,t,n,r,i,a){let o=e.textDirection==wr.RTL,s=o,l=!1,c="top",u,O,d=t.left-i.left,f=i.right-t.right,p=r.right-r.left,m=r.bottom-r.top;if(s&&d<Math.min(p,f)?s=!1:!s&&f<Math.min(p,d)&&(s=!0),p<=(s?d:f))u=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,O=Math.min(400,s?d:f);else{l=!0,O=Math.min(400,(o?t.right:i.right-t.left)-30);let v=i.bottom-t.bottom;v>=m||v>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,y=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${O/y}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function Ftt(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 IT(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 Btt{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(Ri);this.optionContent=Ftt(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=IT(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(Ri).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:b$.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=IT(a.length,o,t.state.facet(Ri).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=IT(n.options.length,n.selected,this.view.state.facet(Ri).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=>Ia(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&&Ktt(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(Ri).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 f=i.appendChild(document.createElement("completion-section"));f.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 f=d(s,this.view.state,this.view,l);f&&u.appendChild(f)}}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 Htt(e,t){return n=>new Btt(n,e,t)}function Ktt(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 xD(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Jtt(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(Ri);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 bD(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),d,f=a.filterStrict?new Mtt(O):new Vtt(O);for(let p of c.result.options)if(d=f.match(p.label)){let m=p.displayLabel?u?u(p,d.matched):[]:d.matched;i(new bD(p,c.source,m,d.score+(p.boost||0)))}}}if(r){let c=Object.create(null),u=0,O=(d,f)=>{var p,m;return((p=d.rank)!==null&&p!==void 0?p:1e9)-((m=f.rank)!==null&&m!==void 0?m:1e9)||(d.name<f.name?-1:1)};for(let d of r.sort(O))u-=1e5,c[d.name]=u;for(let d of n){let{section:f}=d.completion;f&&(d.score+=c[typeof f=="string"?f:f.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):xD(c.completion)>xD(s)&&(o[o.length-1]=c),s=c.completion}return o}class Qh{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 Qh(this.options,QD(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=Jtt(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Ri).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 Qh(s,QD(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:ant,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new Qh(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 Qh(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class OS{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new OS(rnt,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Ri),a=(r.override||n.languageDataAt("autocomplete",Ud(n)).map(Dtt)).map(l=>(this.active.find(u=>u.source==l)||new ls(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(s9));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!ent(a,this.active)||s?o=Qh.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 ls(l.source,0):l));for(let l of t.effects)l.is(Fpe)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new OS(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?tnt:nnt}}function ent(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 tnt={"aria-autocomplete":"list"},nnt={};function QD(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const rnt=[];function Lpe(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(o9);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 ls{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=Lpe(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new ls(i.source,0)),r&4&&i.state==0&&(i=new ls(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(uS))i=new ls(i.source,1,a.value);else if(a.is(b$))i=new ls(i.source,0);else if(a.is(s9))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(Ud(t.state))}}class Dh extends ls{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=Ud(t.state);if(s>o||!i||n&2&&(Ud(t.startState)==this.from||s<this.limit))return new ls(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return int(i.validFor,t.state,a,o)?new Dh(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new a9(t.state,s,!1)))?new Dh(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:Ud(t.state)):new ls(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new Dh(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new ls(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function int(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Mpe(e,!0).test(i)}const s9=Tn.define({map(e,t){return e.map(n=>n.map(t))}}),Fpe=Tn.define(),Na=Ha.define({create(){return OS.start()},update(e,t){return e.update(t)},provide:e=>[KA.from(e,t=>t.tooltip),wt.contentAttributes.from(e,t=>t.attrs)]});function l9(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Na).active.find(i=>i.source==t.source);return r instanceof Dh?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},Ztt(e.state,n,r.from,r.to)),{annotations:o9.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const ant=Htt(Na,l9);function yb(e,t="option"){return n=>{let r=n.state.field(Na,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ri).interactionDelay)return!1;let i=1,a;t=="page"&&(a=ype(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:Fpe.of(s)}),!0}}const ont=e=>{let t=e.state.field(Na,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ri).interactionDelay?!1:l9(e,t.open.options[t.open.selected])},kD=e=>e.state.field(Na,!1)?(e.dispatch({effects:uS.of(!0)}),!0):!1,snt=e=>{let t=e.state.field(Na,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:b$.of(null)}),!0)};class lnt{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const cnt=50,unt=1e3,Ont=bi.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(Na).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Na),n=e.state.facet(Ri);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Na)==t)return;let r=e.transactions.some(a=>{let o=Lpe(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>cnt&&Date.now()-o.time>unt){for(let s of o.context.abortListeners)try{s()}catch(l){Ia(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(uS)))&&(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(Na);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(Ri).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=Ud(t),r=new a9(t,n,e.explicit,this.view),i=new lnt(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:b$.of(null)}),Ia(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(Ri).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Ri),r=this.view.state.field(Na);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=Ud(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new Dh(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 ls(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:s9.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Na,!1);if(t&&t.tooltip&&this.view.state.facet(Ri).closeOnBlur){let n=t.open&&ype(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:b$.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:uS.of(!1)}),20),this.composing=0}}}),dnt=typeof navigator=="object"&&/Win/.test(navigator.platform),fnt=PO.highest(wt.domEventHandlers({keydown(e,t){let n=t.state.field(Na,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(dnt&&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&&l9(t,r),!1}})),Bpe=wt.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 hnt{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class c9{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Ni.TrackDel),r=t.mapPos(this.to,1,Ni.TrackDel);return n==null||r==null?null:new c9(this.field,n,r)}}class u9{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(FQ);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 c9(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 hnt(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 u9(r,i)}}let pnt=sn.widget({widget:new class extends mu{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),mnt=sn.mark({class:"cm-snippetField"});class ym{constructor(t,n){this.ranges=t,this.active=n,this.deco=sn.set(t.map(r=>(r.from==r.to?pnt:mnt).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 ym(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 Ky=Tn.define({map(e,t){return e&&e.map(t)}}),gnt=Tn.define(),w$=Ha.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(Ky))return n.value;if(n.is(gnt)&&e)return new ym(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=>wt.decorations.from(e,t=>t?t.deco:sn.none)});function O9(e,t){return Ze.create(e.filter(n=>n.field==t).map(n=>Ze.range(n.from,n.to)))}function $nt(e){let t=u9.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:Ln.of(o)},scrollIntoView:!0,annotations:r?[o9.of(r),Gi.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=O9(s,0)),s.some(u=>u.field>0)){let u=new ym(s,0),O=c.effects=[Ky.of(u)];n.state.field(w$,!1)===void 0&&O.push(Tn.appendConfig.of([w$,Snt,xnt,Bpe]))}n.dispatch(n.state.update(c))}}function Hpe(e){return({state:t,dispatch:n})=>{let r=t.field(w$,!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:O9(r.ranges,i),effects:Ky.of(a?null:new ym(r.ranges,i)),scrollIntoView:!0})),!0}}const ynt=({state:e,dispatch:t})=>e.field(w$,!1)?(t(e.update({effects:Ky.of(null)})),!0):!1,vnt=Hpe(1),bnt=Hpe(-1),wnt=[{key:"Tab",run:vnt,shift:bnt},{key:"Escape",run:ynt}],PD=Ot.define({combine(e){return e.length?e[0]:wnt}}),Snt=PO.highest(VQ.compute([PD],e=>e.facet(PD)));function gr(e,t){return Object.assign(Object.assign({},t),{apply:$nt(e)})}const xnt=wt.domEventHandlers({mousedown(e,t){let n=t.state.field(w$,!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:O9(n.ranges,i.field),effects:Ky.of(n.ranges.some(a=>a.field>i.field)?new ym(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),S$={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Sd=Tn.define({map(e,t){let n=t.mapPos(e,-1,Ni.TrackAfter);return n??void 0}}),d9=new class extends Kd{};d9.startSide=1;d9.endSide=-1;const Kpe=Ha.define({create(){return Pn.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(Sd)&&(e=e.update({add:[d9.range(n.value,n.value+1)]}));return e}});function Mon(){return[knt,Kpe]}const ZT="()[]{}<>«»»«[]{}";function Jpe(e){for(let t=0;t<ZT.length;t+=2)if(ZT.charCodeAt(t)==e)return ZT.charAt(t+1);return ihe(e<128?e:e+1)}function eme(e,t){return e.languageDataAt("closeBrackets",t)[0]||S$}const Qnt=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),knt=wt.inputHandler.of((e,t,n,r)=>{if((Qnt?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&_c(wo(r,0))==1||t!=i.from||n!=i.to)return!1;let a=Tnt(e.state,r);return a?(e.dispatch(a),!0):!1}),Pnt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=eme(e,e.selection.main.head).brackets||S$.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=_nt(e.doc,o.head);for(let l of r)if(l==s&&JQ(e.doc,o.head)==Jpe(wo(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Ze.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},Lon=[{key:"Backspace",run:Pnt}];function Tnt(e,t){let n=eme(e,e.selection.main.head),r=n.brackets||S$.brackets;for(let i of r){let a=Jpe(wo(i,0));if(t==i)return a==i?Ent(e,i,r.indexOf(i+i+i)>-1,n):Xnt(e,i,a,n.before||S$.before);if(t==a&&tme(e,e.selection.main.from))return Rnt(e,i,a)}return null}function tme(e,t){let n=!1;return e.field(Kpe).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function JQ(e,t){let n=e.sliceString(t,t+2);return n.slice(0,_c(wo(n,0)))}function _nt(e,t){let n=e.sliceString(t-2,t);return _c(wo(n,0))==n.length?n:n.slice(1)}function Xnt(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:Sd.of(o.to+t.length),range:Ze.range(o.anchor+t.length,o.head+t.length)};let s=JQ(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:Sd.of(o.head+t.length),range:Ze.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function Rnt(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&JQ(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Ze.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function Ent(e,t,n,r){let i=r.stringPrefixes||S$.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:Sd.of(s.to+t.length),range:Ze.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=JQ(e.doc,l),u;if(c==t){if(TD(e,l))return{changes:{insert:t+t,from:l},effects:Sd.of(l+t.length),range:Ze.cursor(l+t.length)};if(tme(e,l)){let d=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+d.length,insert:d},range:Ze.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=_D(e,l-2*t.length,i))>-1&&TD(e,u))return{changes:{insert:t+t+t+t,from:l},effects:Sd.of(l+t.length),range:Ze.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=ss.Word&&_D(e,l,i)>-1&&!qnt(e,l,t,i))return{changes:{insert:t+t,from:l},effects:Sd.of(l+t.length),range:Ze.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function TD(e,t){let n=Fn(e).resolveInner(t+1);return n.parent&&n.from==t}function qnt(e,t,n,r){let i=Fn(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 _D(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=ss.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))!=ss.Word)return a}return-1}function Fon(e={}){return[fnt,Na,Ri.of(e),Ont,Cnt,Bpe]}const jnt=[{key:"Ctrl-Space",run:kD},{mac:"Alt-`",run:kD},{key:"Escape",run:snt},{key:"ArrowDown",run:yb(!0)},{key:"ArrowUp",run:yb(!1)},{key:"PageDown",run:yb(!0,"page")},{key:"PageUp",run:yb(!1,"page")},{key:"Enter",run:ont}],Cnt=PO.highest(VQ.computeN([Ri],e=>e.facet(Ri).defaultKeymap?[jnt]:[]));class dS{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new dS(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 dn(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 dn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new dn(ci.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 znt{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let Ant=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 S0(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 XD(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?p9:h9)(n,t,!1);return r>0&&(e.type!=Ve.BulletList||f9(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const nme={[Ve.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(wn(Ve.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(ws(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]:XD,[Ve.BulletList]:XD,[Ve.Document](){return!0}};function ws(e){return e==32||e==9||e==10||e==13}function S0(e,t=0){for(;t<e.length&&ws(e.charCodeAt(t));)t++;return t}function RD(e,t,n){for(;t>n&&ws(e.charCodeAt(t-1));)t--;return t}function rme(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 ime(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function f9(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(!ws(a))return-1}return n&&e.next==45&&sme(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(Ome.SetextHeading)>-1||r<3?-1:1}function ame(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function h9(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||ws(e.text.charCodeAt(e.pos+1)))&&(!n||ame(t,Ve.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function p9(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&&!ws(e.text.charCodeAt(r+1))||n&&!ame(t,Ve.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function ome(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 sme(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&&ws(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const sj=/^[ \t]*$/,lme=/-->/,cme=/\?>/,lj=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,lme],[/^\s*<\?/,cme],[/^\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,sj],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,sj]];function ume(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=lj.length-(n?1:0);i<a;i++)if(lj[i][0].test(r))return i;return-1}function ED(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.countIndent(e.skipSpace(t),t,n);return r>=n+5?n+1:r}function JO(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Ve.CodeText?e[r].to=n:e.push(wn(Ve.CodeText,t,n))}const vb={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(JO(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){JO(s,e.lineStart-1,e.lineStart);for(let l of t.markers)s.push(l)}else{if(t.indent<n)break;{if(s.length){for(let c of s)c.type==Ve.CodeText?JO(o,c.from,c.to):o.push(c);s=[]}JO(o,e.lineStart-1,e.lineStart);for(let c of t.markers)o.push(c);a=e.lineStart+t.text.length;let l=e.lineStart+t.findColumn(t.baseIndent+4);l<a&&JO(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=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=rme(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=RD(t.text,t.text.length,o),l=[wn(Ve.CodeMark,r,r+a)];o<s&&l.push(wn(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(wn(Ve.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||JO(l,e.lineStart-1,e.lineStart);for(let f of t.markers)l.push(f);let O=e.lineStart+t.basePos,d=e.lineStart+t.text.length;O<d&&JO(l,O,d)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Ve.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=ime(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(f9(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=h9(t,e,!1);if(n<0)return!1;e.block.type!=Ve.BulletList&&e.startContext(Ve.BulletList,t.basePos,t.next);let r=ED(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=p9(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=ED(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=ome(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=RD(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!ws(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=ume(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=lj[n][1],a=[],o=i!=sj;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==lme?Ve.CommentBlock:i==cme?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 Unt{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+`
819
819
  `+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)&&S0(n.content,this.pos)==n.content.length?this.complete(t,n,n.content.length):!1}complete(t,n,r){return t.addLeafElement(n,wn(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(vme(t,this.pos,this.start,!0)))return-1;if(t.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(wn(Ve.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage($me(t,S0(t,this.pos),this.start)))return-1}else if(this.stage==2){let n=S0(t,this.pos),r=0;if(n>this.pos){let i=yme(t,n,this.start);if(i){let a=DT(t,i.to-this.start);a>0&&(this.nextStage(i),r=a)}}return r||(r=DT(t,this.pos)),r>0&&r<t.length?r:-1}else return DT(t,this.pos)}}}function DT(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!ws(n))return-1}return t}class Wnt{nextLine(t,n,r){let i=n.depth<t.stack.length?-1:sme(n),a=n.next;if(i<0)return!1;let o=wn(Ve.HeaderMark,t.lineStart+n.pos,t.lineStart+i);return t.nextLine(),t.addLeafElement(r,wn(a==61?Ve.SetextHeading1:Ve.SetextHeading2,r.start,t.prevLineEnd(),[...t.parser.parseInline(r.content,r.start),o])),!0}finish(){return!1}}const Ome={LinkReference(e,t){return t.content.charCodeAt(0)==91?new Unt(t):null},SetextHeading(){return new Wnt}},Nnt=[(e,t)=>ome(t)>=0,(e,t)=>rme(t)>=0,(e,t)=>ime(t)>=0,(e,t)=>h9(t,e,!0)>=0,(e,t)=>p9(t,e,!0)>=0,(e,t)=>f9(t,e,!0)>=0,(e,t)=>ume(t,e,!0)>=0],Ynt={text:"",end:0};class Gnt{constructor(t,n,r,i){this.parser=t,this.input=n,this.ranges=i,this.line=new Ant,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=dS.create(Ve.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new Vnt(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 znt(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+=`
820
820
  `+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=bme(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=Ynt;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==`
821
821
  `?"":n;else{let i=n.indexOf(`
@@ -852,7 +852,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
852
852
  `,o.end),l=t.slice(o.end,s===-1?t.length:s);if($Pt.test(l))return Ya;const c=l.length-l.replace(yPt,"").length,u={start:o.start,end:o.end+c},O=e.typingAt;if(O!==null){const d=O+Xp(e.value).length;return n<O||n>d?{arm:u,typingAt:null,value:""}:{arm:u,typingAt:O,value:e.value}}return a&&n===u.end&&t[n-1]===Ck?{arm:u,typingAt:n,value:""}:{arm:u,typingAt:null,value:""}}const wl=e=>e.typingAt!==null,xPt=e=>e.arm!==null;function Cf(e){return e.typingAt===null?null:{start:e.typingAt,end:e.typingAt+Xp(e.value).length}}function $8(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=Xp(e.value),c=dC(a-i.start,0,l.length),u=dC(o-i.start,0,l.length),O=Xp(s),d=[...l.slice(0,c),...O,...l.slice(u)].join(""),f=a+O.length,p=t.slice(0,a)+r1e.repeat(O.length)+t.slice(f),m=O.length-s.length,g=n>=f?n+m:n;return{buffer:p,caret:g,capture:{...e,value:d}}}function oB(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=wl(e)&&e.value===""&&r.startsWith("-");if(wl(e)&&(a||r.includes(`
853
853
  `))){const o=YS(e);return r.includes(`
854
854
  `)?{...i,capture:o}:{...i,capture:Th(o,i.buffer,i.caret,"typing")}}return $8(e,i.buffer,i.caret,{top:n.start,bottom:n.end,inserted:r})??i}function YS(e){return wl(e)?{arm:e.arm,typingAt:null,value:""}:e}function QPt(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 kPt(e,t,n,r,i){const a=QPt(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:YS(e),buffer:n,caret:r};else{const l=$8(e,n,r,a);l?s=l:wl(e)&&a.inserted.includes(`
855
- `)&&(s={capture:YS(e),buffer:n,caret:r})}return{...s,capture:Th(s.capture,s.buffer,s.caret,i)}}function PPt(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=d1e(i,t.value),c=l+Ck,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:Ya,buffer:u,caret:s+c.length,payload:{index:i,key:m1e(a,e.draw),value:t.value,marker:l}}}function TPt(e,t){const n=Cf(e);if(n===null)return{cancelled:!1,capture:e,buffer:t,caret:0,restored:0,token:null};const r=e.value,i=p1e(t,e),a=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:Ya,buffer:i,caret:n.start+r.length,restored:OC(r),token:{span:{start:a,end:n.start},text:t.slice(a,n.start),restored:OC(r),restoredText:r}}}function sB(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function _Pt(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:YS(e),buffer:i,caret:a,payload:null}}function XPt(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=$8(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=pn(i);if(!a)return i===""?null:_Pt(t,n,e.selection,i);const o=t.arm,s=d1e(e.index,a),l=s+Ck,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:Ya,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:m1e(e.taken,e.draw),value:a,marker:s}}}const O1e=e=>`${OC(e)} chars`,d1e=(e,t)=>`[Credential #${e}, ${O1e(t)}]`;function RPt(e){ql.lastIndex=0;const t=ql.exec(e);return ql.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function EPt(e){ql.lastIndex=0;const t=ql.exec(e);if(ql.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 uv(e,t){if(RPt(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const O2=/\[credential ([A-Za-z_][A-Za-z0-9_]*) \((\d+) chars\) \u2014 available to bash and eval as \$([A-Za-z_][A-Za-z0-9_]*); its value cannot be read\]/y,d2=/\[credential NOT stored \u2014 [^\]\n]*\]/y,f2=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,qPt=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&uC.test(t[1])?t[1]:""};function jPt(e,t){if(e.charCodeAt(t)!==91)return null;O2.lastIndex=t;const n=O2.exec(e);if(O2.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};d2.lastIndex=t;const r=d2.exec(e);if(d2.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};f2.lastIndex=t;const i=f2.exec(e);return f2.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:qPt(i[0])}:null}function zk(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=jPt(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 lB(e,t){const n=[];for(const r of t){const i=uv(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 CPt(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 zPt=e=>`[credential ${e.key} (${O1e(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function APt(e,t,n=new Map){const r=[...t],i=[];for(const o of r){const s=uv(e,o);s!==null&&i.push({span:s,payload:o})}for(const o of s1e(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?CPt(l??"lost",s?.key):zPt(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const UPt=(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.`,WPt=e=>`Remove credential #${e}`,NPt=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,YPt=(e,t,n)=>UPt(e,t,n),GPt="Undo",IPt=e=>`Credential #${e} removed`,ZPt=e=>e.unredacted!==null?e.unredacted:e.armed?HPt:e.cleared!==null?YPt(e.cleared.key,e.cleared.index,e.undoCap):null;function DPt(e){const{buffer:t,payload:n}=e,r=uv(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===Ck?r.end+1:r.end;return{cleared:!0,buffer:t.slice(0,r.start)+t.slice(i),caret:r.start,removed:t.slice(r.start,i)}}function VPt(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 cB=e=>`Stored ${e.join(", ")}. Injected into every bash command as an environment variable; the agent cannot read the value.`;function uB(e){const t=e.length===1?"credential":"credentials";return`${e.length} ${t} could not be stored (${[...e].sort().join(", ")}); the agent has been told so. Paste the value again after /credential to retry.`}const MPt="store unconfirmed",LPt="Credential store unconfirmed",FPt=e=>e===""?LPt:`${e} · ${MPt}`,f1e="Paste the value again after /credential to store it again.",BPt=e=>`${e} ${f1e}`;function OB(e){const t=e.length===1?"credential":"credentials";return`${e.length} ${t} could not be confirmed as stored (${[...e].sort().join(", ")}); the agent has been told to check before using it. ${f1e}`}const HPt="armed — add a space, then type or paste the secret",KPt="masked as you type — Enter turns it into a pill, Esc cancels",JPt="masked — Enter opens the credential picker; type or paste the secret into this span",e5t="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",h1e="\0held",t5t=(e,t)=>t===void 0?`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`:t===h1e?`${e} characters are now PLAIN TEXT in the composer — Enter is held: clear the box to release your words`:`${e} characters are now PLAIN TEXT in the composer — Enter will take them as /${t}'s argument, not send them`;function p1e(e,t){const n=Cf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const dB=(e,t)=>e&&e.over===t?e.chars:null,n5t=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},r5t=16,i5t=16;function m1e(e=[],t=n5t){const n=new Set(e);for(let r=0;r<r5t;r++){const i=iB+fB(8,t);if(!n.has(i))return i}return iB+fB(i5t,t)}const fB=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=rB[t(rB.length)];return n},g1e=j("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),$1e=j("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),y1e=({label:e,chars:t=null,tone:n="live",title:r,onClear:i,clearLabel:a,className:o,style:s,small:l=!1})=>h.jsxs("span",{className:j("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?$1e:g1e,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?h.jsx(goe,{"aria-hidden":"true",className:"size-3 shrink-0"}):h.jsx(s7e,{"aria-hidden":"true",className:"size-3 shrink-0"}),h.jsx("span",{className:"min-w-0 truncate",children:e}),t!==null&&h.jsx("span",{className:"shrink-0",children:`· ${t} chars`}),i&&h.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:h.jsx(Zi,{"aria-hidden":"true",className:"size-3"})}),r&&h.jsx("span",{className:"sr-only",children:r})]}),W$="#lo-credential/",a5t=`${W$}unstored`,hB=`${W$}unconfirmed`,o5t=/^\d+$/,v1e=e=>e.kind==="stored"?`${W$}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${hB}/${e.key}`:hB:a5t;function s5t(e){if(!e||!e.startsWith(W$))return null;const t=e.slice(W$.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return uC.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!uC.test(r)||!o5t.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function pB(e,t){const n=s5t(e);if(n===null)return null;const r=zk(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return v1e(i)!==e?null:n}const Ak=()=>e=>{const t=n=>{if(!n.children)return;const r=[];let i=!1;for(const a of n.children){if(a.type!=="text"||typeof a.value!="string"){t(a),r.push(a);continue}const o=zk(a.value);if(o.length===1&&o[0].kind==="text"){r.push(a);continue}i=!0;for(const s of o){if(s.kind==="text"){r.push({type:"text",value:s.text});continue}r.push({type:"link",url:v1e(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},l5t=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?FPt(e.key):"Credential not stored",c5t=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?BPt(t):t,u5t=({citation:e,title:t})=>h.jsx(y1e,{tone:e.kind==="stored"?"live":"warning",label:l5t(e),chars:e.kind==="stored"?e.chars:null,title:c5t(e,t),className:"align-middle"}),O5t=(e,t)=>typeof t=="string"?pB(e,t):t==null?pB(e,""):null,d5t=e=>({href:t,title:n,children:r})=>{const i=O5t(t,r);if(i===null){const a=e;return h.jsx(a,{href:t,title:n,children:r})}return h.jsx(u5t,{citation:i,title:n})},b1e=e=>yHe(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",w1e=e=>{const t=b1e(e);return t==="other"?"path":t},mB={id:"open-file",label:"Open file"},f5t={id:"show-in-canvas",label:"Show in canvas"},h5t={id:"save-as",label:"Save as…"},gB={id:"open-folder",label:"Open folder"},$B={id:"copy-file-path",label:"Copy file path"},bg={id:"copy-image",label:"Copy image"},p5t={id:"copy-image-url",label:"Copy image URL"},m5t={id:"open-in-browser",label:"Open in browser"};function S1e(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const o=[...t?[f5t]:[],...a?[{id:"expand-image",label:"Expand image"}]:[]];switch(e){case"artifact":return[...o,...i?[mB,gB,$B]:[],h5t,...r==="video"?[]:[bg]];case"path":return[...o,mB,gB,$B,...r==="video"?[]:[bg]];case"data":return[...o,bg];case"blob":return[bg];case"http":return[...g5t(n)?[bg]:[],p5t,m5t];case"other":return[]}}const x1e=(e,t)=>S1e(e,t).length>0;function g5t(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 y8=e=>e.startsWith("file://")?e.slice(7):e;function $5t(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 yB(e,t,n){if(e==="data")return $5t(t);if(e==="blob"){const o=Fue(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=y8(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:Mue(i)})}const y5t=e=>e.trim().toLowerCase()!=="image/png";async function v5t(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!y5t(e.type))return e;const t=URL.createObjectURL(e);try{const n=await b5t(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 b5t(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 w5t=6e4;function S5t(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),w5t)}const vB=new Map,bB=new Map;function Q1e(e){return e===void 0?"":JSON.stringify(e)}function v8(e,t){const n=`${e}\0${Q1e(t)}`;let r=vB.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),vB.set(n,r)),r}function x5t(e,t){const n=`${e}\0${Q1e(t)}`;let r=bB.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),bB.set(n,r)),r}function k1e(e,t,n){return v8(n??rp(),t).format(e)}function Q5t(e,t,n){return v8(n??rp(),t).format(e)}function k5t(e,t,n){return v8(rp(),t).format(e)}function P1e(e,t,n){return x5t(n??rp(),t).format(e)}const l1=new Map;function P5t(e,t){const n=l1.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await uO(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=Lue(i.data,i.mimeType);return r.holders<=0?(TQ(a),null):(Bue(t,a),a)}catch{return null}finally{l1.delete(t)}})(),l1.set(t,r),r.promise}class T1e extends Error{constructor(){super("This item is no longer in the session"),this.name="AttachmentGoneError"}}async function rsn(e,t){const n=Uz(t),r=n?Fue(n):null;if(r)return r;const i=await uO(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 T1e:new Error("These bytes are not available right now");return new Blob([i.data],{type:i.mimeType})}function T5t(e){const t=l1.get(e);t&&(t.holders-=1)}function _1e(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=$.useState(()=>e.attachment?Uz(e.attachment):null),[a,o]=$.useState(!1),s=t?.sessionId??null,l=t?.childId??null;$.useEffect(()=>{const u=e.attachment;if(n||!u||!s)return;let O=!0;const d=A1(u);if(d)return i(d),o(!1),()=>{O=!1,U1(u)};i(null),o(!1);let f=!0;return P5t({sessionId:s,childId:l},u).then(p=>{if(f=!1,!!O){if(!p){o(!0);return}i(A1(u))}}),()=>{O=!1,f&&T5t(u),U1(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 X1e(e,t){return _1e(e,t)}const _5t={"expand-image":h.jsx(Tle,{"aria-hidden":"true"}),"open-file":h.jsx(jy,{"aria-hidden":"true"}),"show-in-canvas":h.jsx(Ple,{"aria-hidden":"true"}),"save-as":h.jsx(qy,{"aria-hidden":"true"}),"open-folder":h.jsx(lp,{"aria-hidden":"true"}),"copy-file-path":h.jsx(vle,{"aria-hidden":"true"}),"copy-image":h.jsx($Q,{"aria-hidden":"true"}),"copy-image-url":h.jsx(O7e,{"aria-hidden":"true"}),"open-in-browser":h.jsx(Sle,{"aria-hidden":"true"})},wB=(e,t)=>t instanceof T1e?`${e}: it is no longer in the session`:e,R1e=({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:f,tooltip:p="Image actions","aria-label":m})=>{const g=w1e(e),y=S1e(g,{canShowInCanvas:!!c,source:t??e,mediaKind:u,artifactPathActions:!!s,canExpand:!!O}).filter(Q=>(Q.id!=="save-as"||!!d)&&(!l||Q.id==="copy-file-path"));if(y.length===0)return null;const v=async(Q,k,_)=>{try{await navigator.clipboard.writeText(Q),Md(k)}catch(T){console.error(`${_}: `,T),oi(_)}},S=async()=>{try{if(typeof ClipboardItem>"u")throw new Error("this window cannot write an image to the clipboard");const Q=f?await f():await yB(g,e,t),k=await v5t(Q);await navigator.clipboard.write([new ClipboardItem({[k.type]:k})]),Md("Image copied to clipboard")}catch(Q){console.error("Failed to copy image: ",Q),oi(wB("Failed to copy image",Q))}},x=async()=>{try{const Q=f?await f():await yB(g,e,t);S5t(Q,d??"download")}catch(Q){console.error("Failed to save file: ",Q),oi(wB("Failed to save file",Q))}},b=async Q=>{let k=y8(e);if(s&&["open-file","open-folder","copy-file-path"].includes(Q.id))try{k=await s()}catch{oi(va("ui.canvas.files.prepareError"));return}switch(Q.id){case"expand-image":O?.();return;case"open-file":vO(k);return;case"open-folder":f8(k);return;case"show-in-canvas":c?.();return;case"copy-file-path":v(k,"File path copied to clipboard","Failed to copy file path");return;case"copy-image":S();return;case"save-as":x();return;case"copy-image-url":v(t??e,"Image URL copied to clipboard","Failed to copy image URL");return;case"open-in-browser":h8(t??e);return}},w=m??`Actions for ${n??"this image"}`;return h.jsxs(S6,{open:r,onOpenChange:i,children:[h.jsx(At,{content:p,children:h.jsx(x6,{asChild:!0,children:h.jsx(je,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":w,tabIndex:o,onClick:Q=>Q.stopPropagation(),children:h.jsx(wle,{"aria-hidden":"true"})})})}),h.jsxs(Q6,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:Q=>Q.stopPropagation(),children:[s&&h.jsx("div",{role:"note",className:j("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:va("ui.canvas.files.pathCopyNote")}),y.map(Q=>h.jsxs(Sl,{onSelect:()=>b(Q),children:[_5t[Q.id],h.jsx("span",{children:Q.label})]},Q.id))]})]})},X5t=({src:e,alt:t,title:n,className:r})=>{const i=_k(),a=e??"",o=b1e(a);if(o==="other")return h.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=x1e(o,{canShowInCanvas:s,source:a});return h.jsxs("span",{className:j("group/mdimg relative inline-block max-w-full"),children:[h.jsx("img",{src:e,alt:t,title:n,className:r}),l&&h.jsx("span",{"data-markdown-image":"",className:j("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:h.jsx(R1e,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||vO(y8(a))})}:void 0})})]})};function R5t(){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 E5t={tokenize:q5t,concrete:!0,name:"mathFlow"},SB={tokenize:j5t,partial:!0};function q5t(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(v){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),l(v)}function l(v){return v===36?(e.consume(v),o++,l):o<2?n(v):(e.exit("mathFlowFenceSequence"),on(e,c,"whitespace")(v))}function c(v){return v===null||gt(v)?O(v):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(v))}function u(v){return v===null||gt(v)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),O(v)):v===36?n(v):(e.consume(v),u)}function O(v){return e.exit("mathFlowFence"),r.interrupt?t(v):e.attempt(SB,d,g)(v)}function d(v){return e.attempt({tokenize:y,partial:!0},g,f)(v)}function f(v){return(a?on(e,p,"linePrefix",a+1):p)(v)}function p(v){return v===null?g(v):gt(v)?e.attempt(SB,d,g)(v):(e.enter("mathFlowValue"),m(v))}function m(v){return v===null||gt(v)?(e.exit("mathFlowValue"),p(v)):(e.consume(v),m)}function g(v){return e.exit("mathFlow"),t(v)}function y(v,S,x){let b=0;return on(v,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function w(_){return v.enter("mathFlowFence"),v.enter("mathFlowFenceSequence"),Q(_)}function Q(_){return _===36?(b++,v.consume(_),Q):b<o?x(_):(v.exit("mathFlowFenceSequence"),on(v,k,"whitespace")(_))}function k(_){return _===null||gt(_)?(v.exit("mathFlowFence"),S(_)):x(_)}}}function j5t(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 C5t(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:z5t,previous:A5t,name:"mathText"};function r(i,a,o){let s=0,l,c;return u;function u(m){return i.enter("mathText"),i.enter("mathTextSequence"),O(m)}function O(m){return m===36?(i.consume(m),s++,O):s<2&&!n?o(m):(i.exit("mathTextSequence"),d(m))}function d(m){return m===null?o(m):m===36?(c=i.enter("mathTextSequence"),l=0,p(m)):m===32?(i.enter("space"),i.consume(m),i.exit("space"),d):gt(m)?(i.enter("lineEnding"),i.consume(m),i.exit("lineEnding"),d):(i.enter("mathTextData"),f(m))}function f(m){return m===null||m===32||m===36||gt(m)?(i.exit("mathTextData"),d(m)):(i.consume(m),f)}function p(m){return m===36?(i.consume(m),l++,p):l===s?(i.exit("mathTextSequence"),i.exit("mathText"),a(m)):(c.type="mathTextData",f(m))}}}function z5t(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 A5t(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function U5t(e){return{flow:{36:E5t},text:{36:C5t()}}}const _h=36,xB=e=>e!==null&&e<-2,QB=e=>e===null||e===32||e<0,kB=e=>e!==null&&e>=48&&e<=57,E1e=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:W5t,previous:N5t,name:"mathText"};function n(r,i,a){const o=this;let s=0,l=null,c,u;return O;function O(g){return r.enter("mathText"),r.enter("mathTextSequence"),d(g)}function d(g){return g===_h?(r.consume(g),s++,d):s<2&&!t||s===1&&(QB(g)||kB(g))?a(g):(r.exit("mathTextSequence"),f(g))}function f(g){return g===null?a(g):g===_h?(u=r.enter("mathTextSequence"),c=0,l=o.previous,m(g)):g===32?(r.enter("space"),r.consume(g),r.exit("space"),f):xB(g)?(r.enter("lineEnding"),r.consume(g),r.exit("lineEnding"),f):(r.enter("mathTextData"),p(g))}function p(g){return g===null||g===32||g===_h||xB(g)?(r.exit("mathTextData"),f(g)):(r.consume(g),p)}function m(g){return g===_h?(r.consume(g),c++,m):c===s?s===1&&(QB(l)||kB(g))?a(g):(r.exit("mathTextSequence"),r.exit("mathText"),i(g)):(u.type="mathTextData",p(g))}}};function W5t(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 N5t(e){return e!==_h||this.events[this.events.length-1][1].type==="characterEscape"}const Y5t=U5t().flow,G5t=E1e();function Uk(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?G5t:E1e(e);n.push({flow:Y5t,text:{[_h]:i}}),r.push(R5t())}const I5t=({node:e,...t})=>h.jsx("div",{className:"lo-md-table-scroll",children:h.jsx("table",{...t})}),Z5t=/\$(?!\d)(.+?)\$/,D5t=/\$\$([\s\S]+?)\$\$/,V5t=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,M5t=/\\[a-zA-Z]+(\{[^}]*\})?/,PB=e=>Z5t.test(e)||D5t.test(e)||V5t.test(e)?!0:M5t.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),L5t=e=>{const t=zk(e);if(t.length===1&&t[0].kind==="text")return null;let n="",r=!1;for(const i of t){if(i.kind==="text"){n+=i.text;continue}r=!0,n+="x".repeat(i.text.length)}return r?n:null},F5t=e=>zk(e).filter(t=>t.kind!=="text").length,B5t=e=>{if(!PB(e))return!1;const t=L5t(e);return t===null?!0:PB(t)||t.includes("$")?!1:F5t(e)<2},Ht="var(--color-ink)",uc="var(--color-ink-muted)",dl="var(--color-surface)",Eu="var(--color-elevated)",Oc="var(--color-sunken)",Li="var(--color-hairline)",qu="var(--color-control)",oh="var(--color-accent)",Jg="var(--color-accent-wash)",H5t="var(--color-accent-alt-wash)",K5t="var(--color-on-accent)",J5t="var(--color-info)",q1e="var(--color-info-wash)",eTt="var(--color-success)",j1e="var(--color-success-wash)",tTt="var(--color-warning)",fC="var(--color-warning-wash)",nTt="var(--color-warning-border)",h2="var(--color-danger)",hC="var(--color-danger-wash)",TB=[Jg,H5t,q1e,j1e,fC,hC],ju=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),rTt=()=>{const e={primaryColor:ju("--color-accent"),secondaryColor:ju("--color-success"),tertiaryColor:ju("--color-info"),mainBkg:ju("--color-elevated"),clusterBkg:ju("--color-sunken"),clusterBorder:ju("--color-hairline"),edgeLabelBackground:ju("--color-surface"),quadrant1Fill:ju("--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:dl,primaryTextColor:Ht,primaryBorderColor:qu,secondaryTextColor:Ht,secondaryBorderColor:Li,tertiaryTextColor:Ht,tertiaryBorderColor:Li,lineColor:uc,arrowheadColor:uc,textColor:Ht,secondBkg:Oc,border1:qu,border2:Li,labelColor:Ht,nodeBkg:Eu,nodeBorder:qu,nodeTextColor:Ht,defaultLinkColor:uc,titleColor:Ht,noteBkgColor:fC,noteBorderColor:nTt,noteTextColor:Ht,actorBkg:Eu,actorBorder:qu,actorTextColor:Ht,actorLineColor:Li,signalColor:uc,signalTextColor:Ht,labelBoxBkgColor:Eu,labelBoxBorderColor:Li,labelTextColor:Ht,loopTextColor:Ht,activationBkgColor:Jg,activationBorderColor:oh,sequenceNumberColor:dl,sectionBkgColor:Oc,sectionBkgColor2:dl,altSectionBkgColor:Oc,excludeBkgColor:Oc,taskBkgColor:Jg,taskBorderColor:qu,taskTextColor:Ht,taskTextLightColor:Ht,taskTextDarkColor:Ht,taskTextOutsideColor:Ht,taskTextClickableColor:oh,activeTaskBkgColor:Jg,activeTaskBorderColor:oh,gridColor:Li,doneTaskBkgColor:Oc,doneTaskBorderColor:Li,critBkgColor:hC,critBorderColor:h2,todayLineColor:oh,transitionColor:uc,transitionLabelColor:Ht,stateLabelColor:Ht,stateBkg:Eu,labelBackgroundColor:dl,compositeBackground:Oc,altBackground:Oc,compositeTitleBackground:Eu,compositeBorder:Li,innerEndBackground:Ht,specialStateColor:Ht,classText:Ht,attributeBackgroundColorOdd:dl,attributeBackgroundColorEven:Oc,rowOdd:dl,rowEven:Oc,errorBkgColor:hC,errorTextColor:h2,pieTitleTextColor:Ht,pieSectionTextColor:Ht,pieLegendTextColor:Ht,pieStrokeColor:dl,pieOuterStrokeColor:Li,requirementBackground:Eu,requirementBorderColor:qu,requirementTextColor:Ht,relationColor:uc,relationLabelBackground:dl,relationLabelColor:Ht,branchLabelColor:K5t,commitLabelColor:Ht,commitLabelBackground:dl,tagLabelColor:Ht,tagLabelBackground:Jg,tagLabelBorder:qu,quadrant2Fill:q1e,quadrant3Fill:j1e,quadrant4Fill:fC,quadrant2TextFill:Ht,quadrant3TextFill:Ht,quadrant4TextFill:Ht,quadrantPointFill:oh,archEdgeColor:uc,archEdgeArrowColor:uc,archGroupBorderColor:Li,scaleLabelColor:Ht,packet:{startByteColor:Ht,endByteColor:Ht,labelColor:Ht,titleColor:Ht,blockStrokeColor:qu,blockFillColor:Eu},radar:{axisColor:uc,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:Li,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:dl,titleColor:Ht,xAxisTitleColor:Ht,xAxisLabelColor:Ht,xAxisTickColor:Li,xAxisLineColor:Li,yAxisTitleColor:Ht,yAxisLabelColor:Ht,yAxisTickColor:Li,yAxisLineColor:Li,plotColorPalette:[oh,J5t,eTt,tTt,h2].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Eu,t[`surfacePeer${n}`]=Li;for(let n=0;n<8;n++)t[`fillType${n}`]=TB[n%TB.length];return{...t,...e}};let p2=null,_B=null;const iTt=async e=>{p2||(p2=ve(async()=>{const{default:n}=await import("./mermaid.core-x5Fva3t5.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([8,2,3]),import.meta.url).then(({default:n})=>n));const t=await p2;return _B!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:rTt()}),_B=e),t},XB=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>h.jsxs("div",{className:j("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[h.jsx(At,{content:"Zoom in",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:h.jsx(Wle,{})})}),h.jsx(At,{content:"Zoom out",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:h.jsx(Nle,{})})}),h.jsx(At,{content:"Drag the diagram to pan",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:h.jsx(_7e,{})})}),h.jsx(At,{content:"Reset view",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:h.jsx(vQ,{})})}),h.jsx(At,{content:"Save as SVG",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:a,children:h.jsx(qy,{})})}),h.jsx(At,{content:t?"Copied":"Copy mermaid text",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:o,children:h.jsx($Q,{className:j(t&&"text-success")})})}),s]}),pC=({title:e,children:t})=>h.jsxs(zl,{variant:"danger",role:"alert",className:"my-4",children:[h.jsx(a0,{children:e}),h.jsx(o0,{children:t})]});class aTt 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||h.jsxs(pC,{title:"Mermaid diagram error",children:[this.state.error?.message||"An unexpected error occurred while rendering the diagram"," ","The error was contained within the diagram component."]}):this.props.children}}const oTt=$.memo(({chart:e,id:t})=>{const n=$.useRef(null),r=$.useRef(null),[i,a]=$.useState(null),[o,s]=$.useState(!0),[l,c]=$.useState(""),[u,O]=$.useState(!1),[d,f]=$.useState({scale:1,x:0,y:0}),[p,m]=$.useState({scale:1,x:0,y:0}),[g,y]=$.useState(!1),[v,S]=$.useState({x:0,y:0}),[x,b]=$.useState("idle"),[w,Q]=$.useState("idle"),k=Kn(A=>A.themeName),_=$.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 A=await iTt(k),ee=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:L}=await A.render(ee,e);if(!L||typeof L!="string"||L.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(L)}catch(A){console.error("Mermaid rendering error:",A);const ee=A instanceof Error?A.message:"Failed to render mermaid diagram";a(ee),c("")}finally{s(!1)}},[e,t,k]);$.useEffect(()=>{_().catch(A=>{console.error("Error in renderDiagram effect:",A),a("Failed to initialize diagram rendering"),s(!1)})},[_]);const T=$.useCallback(()=>{try{if(!l||!r.current)return 1;const ee=r.current.getBoundingClientRect(),L=document.createElement("div");L.innerHTML=l;const B=L.querySelector("svg");if(!B)return 1;const ce=B.getBoundingClientRect?.()?.width||Number.parseFloat(B.getAttribute("width")||"0")||B.viewBox?.baseVal?.width||800,M=B.getBoundingClientRect?.()?.height||Number.parseFloat(B.getAttribute("height")||"0")||B.viewBox?.baseVal?.height||600,H=ee.width*.9/ce,ne=ee.height*.9/M;return Math.min(H,ne,1)}catch(A){return console.error("Error calculating fullscreen scale:",A),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const A=T();m({scale:A,x:0,y:0})}catch(A){console.error("Error setting fullscreen transform:",A)}},100)},[u,l,T]);const E=$.useCallback((A=!1)=>{try{(A?m:f)(L=>({...L,scale:Math.min(L.scale*1.2,10)}))}catch(ee){console.error("Error in zoom in:",ee)}},[]),R=$.useCallback((A=!1)=>{try{(A?m:f)(L=>({...L,scale:Math.max(L.scale/1.2,.1)}))}catch(ee){console.error("Error in zoom out:",ee)}},[]),q=$.useCallback((A=!1)=>{try{const ee=A?m:f;if(A){const L=T();ee({scale:L,x:0,y:0})}else ee({scale:1,x:0,y:0})}catch(ee){console.error("Error in reset:",ee)}},[T]),z=$.useCallback(()=>{if(l)try{const A=new Blob([l],{type:"image/svg+xml"}),ee=URL.createObjectURL(A),L=document.createElement("a");L.href=ee,L.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(L),L.click(),document.body.removeChild(L),URL.revokeObjectURL(ee)}catch(A){console.error("Failed to save SVG:",A)}},[l]),W=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),b("copied"),setTimeout(()=>b("idle"),1200)}catch(A){console.error("Failed to copy Mermaid chart text:",A)}},[e]),I=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),Q("copied"),setTimeout(()=>Q("idle"),1200)}catch(A){console.error("Failed to copy Mermaid chart text:",A)}},[e]),N=$.useCallback(A=>{try{y(!0),S({x:A.clientX,y:A.clientY}),A.preventDefault()}catch(ee){console.error("Error in mouse down:",ee)}},[]),Z=$.useCallback((A,ee=!1)=>{try{if(!g)return;const L=A.clientX-v.x,B=A.clientY-v.y;(ee?m:f)(M=>({...M,x:M.x+L,y:M.y+B})),S({x:A.clientX,y:A.clientY})}catch(L){console.error("Error in mouse move:",L)}},[g,v]),G=$.useCallback(()=>{try{y(!1)}catch(A){console.error("Error in mouse up:",A)}},[]),U=$.useCallback((A,ee=!1)=>{try{A.preventDefault();const L=A.deltaY>0?.9:1.1;(ee?m:f)(ce=>({...ce,scale:Math.min(Math.max(ce.scale*L,.1),5)}))}catch(L){console.error("Error in wheel:",L)}},[]),K=$.useCallback(A=>{try{O(A)}catch(ee){console.error("Error toggling fullscreen:",ee)}},[]);if(i)return h.jsxs(pC,{title:"Mermaid diagram error",children:[i,h.jsx("span",{className:j("mt-2 block text-ink-muted"),children:"Chart"}),h.jsx("span",{className:j("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const J=(A=!1)=>{try{const ee=A?r:n,L=A?p:d;return h.jsx("div",{ref:ee,className:j("mermaid flex w-full items-center justify-center",A?"h-full min-h-full":"h-auto min-h-50",g?"cursor-grabbing":"cursor-grab"),onMouseDown:N,onMouseMove:B=>Z(B,A),onMouseUp:G,onMouseLeave:G,onWheel:B=>U(B,A),children:o?h.jsx("div",{className:j("p-4 text-body-sm text-ink-muted"),children:"Loading diagram..."}):l?h.jsx("div",{className:j("flex h-full w-full items-center justify-center"),style:{transform:`translate(${L.x}px, ${L.y}px) scale(${L.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(ee){return console.error("Error rendering diagram content:",ee),h.jsx(pC,{title:"Rendering error",children:"Failed to render diagram content."})}};return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:j("relative flex items-center justify-center overflow-hidden rounded-md bg-surface","[&_svg]:h-auto [&_svg]:min-h-100 [&_svg]:max-w-none [&_svg]:bg-transparent"),children:[J(!1),h.jsx(XB,{className:"top-2 right-2",copied:x==="copied",onZoomIn:()=>E(!1),onZoomOut:()=>R(!1),onReset:()=>q(!1),onSave:z,onCopy:W,children:h.jsx(At,{content:"Fullscreen",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>K(!0),children:h.jsx(Tle,{})})})})]}),h.jsx(K0,{open:u,onClose:()=>K(!1),title:"Mermaid diagram",maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:h.jsxs("div",{className:j("relative flex h-[80vh] w-full items-center justify-center overflow-hidden","[&_svg]:h-auto [&_svg]:max-h-full [&_svg]:w-auto [&_svg]:max-w-full [&_svg]:bg-transparent"),children:[J(!0),h.jsx(XB,{className:"top-4 right-4",copied:w==="copied",onZoomIn:()=>E(!0),onZoomOut:()=>R(!0),onReset:()=>q(!0),onSave:z,onCopy:I,children:h.jsx(At,{content:"Close fullscreen",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>K(!1),children:h.jsx(Zi,{})})})})]})})]})}),sTt=$.memo(e=>h.jsx(aTt,{children:h.jsx(oTt,{...e})}));let C1e=!1,m2=null;const lTt=()=>(m2||(m2=ve(()=>Promise.resolve({}),__vite__mapDeps([9]),import.meta.url).then(e=>(C1e=!0,e))),m2),cTt=/language-(\w+)/,uTt=Ek,OTt=new RegExp(`^[^${Ma}\\d*+-]`),dTt=/\n$/,z1e=({href:e,children:t})=>{const n=jwe(e),r=_k();return!n||n.kind==="other"?h.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}):h.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=>pTt(i,r):void 0,children:t})},fTt=e=>jwe(e)?.kind==="file",hTt=Wwe,pTt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(Uwe)??"file",i=n.getAttribute(hTt),a=ckt({kind:r,hasHighlight:xkt(n),canOpenInCanvas:d8(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||vO(i)});return}vO(i)}},mC=(e,t)=>t==="href"&&fTt(e)?e:nde(e),N$={a:z1e,table:I5t,img:X5t,code:({node:e,className:t,children:n,...r})=>cTt.exec(t??"")?.[1]==="mermaid"?h.jsx(sTt,{chart:String(n).replace(dTt,"")}):h.jsx("code",{className:t,...r,children:n})},mTt={...N$,a:d5t(z1e)},gTt=[kO],$Tt=[kO,Uk],yTt=[kO,Xk],vTt=[kO,Uk,Xk],bTt=[kO,Ak,Rk],wTt=[kO,Uk,Ak,Rk],STt=[kO,Xk,Ak,Rk],xTt=[kO,Uk,Xk,Ak,Rk],QTt={"000":gTt,"001":bTt,"010":yTt,"011":STt,100:$Tt,101:wTt,110:vTt,111:xTt},kTt=[],PTt=[sFe],A1e=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),U1e=(e,t,n)=>{const r=$.useMemo(()=>B5t(e),[e]),[i,a]=$.useState(C1e),o=r&&i;return $.useEffect(()=>{if(!r||i)return;let s=!1;return lTt().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:QTt[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?PTt:kTt}},W1e=(e,t)=>{const[,n]=$.useState(0);$.useEffect(()=>{if(!t)return;const r=GHe(e);if(r.length===0)return;let i=!0;const a=new Set(r),o=Okt(s=>{i&&s.some(l=>a.has(l))&&n(l=>l+1)});return Awe(r,window.api?.probeFiles,doe).then(()=>{i&&r.some(s=>zwe(s)!=="unknown")&&n(s=>s+1)}),()=>{i=!1,o()}},[e,t])},Wk=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1})=>{const a=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:o,rehypePlugins:s}=U1e(a,r,i),l=A1e(t);return W1e(a,r),h.jsx("div",{className:j("lo-markdown",n),style:l,children:h.jsx(r3,{remarkPlugins:o,rehypePlugins:s,urlTransform:mC,components:i?mTt:N$,children:a})})});Wk.displayName="MarkdownRenderer";const RB={...N$,a:({children:e})=>h.jsx(h.Fragment,{children:e})},N1e=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:eB(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=Kwe(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=U1e(n,t,!1);if(W1e(e,t),r!==null){const o=eB(r.before);return h.jsxs(h.Fragment,{children:[o.trim()!==""&&h.jsx(r3,{remarkPlugins:i,rehypePlugins:a,urlTransform:mC,components:t?N$:RB,children:o}),h.jsx(TTt,{info:r.info,body:r.body})]})}return h.jsx(r3,{remarkPlugins:i,rehypePlugins:a,urlTransform:mC,components:t?N$:RB,children:n})});N1e.displayName="ParsedBlock";const TTt=({info:e,body:t})=>{const n=e.split(uTt)[0];return h.jsx("pre",{children:h.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
855
+ `)&&(s={capture:YS(e),buffer:n,caret:r})}return{...s,capture:Th(s.capture,s.buffer,s.caret,i)}}function PPt(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=d1e(i,t.value),c=l+Ck,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:Ya,buffer:u,caret:s+c.length,payload:{index:i,key:m1e(a,e.draw),value:t.value,marker:l}}}function TPt(e,t){const n=Cf(e);if(n===null)return{cancelled:!1,capture:e,buffer:t,caret:0,restored:0,token:null};const r=e.value,i=p1e(t,e),a=e.arm===null?n.start:e.arm.start;return{cancelled:!0,capture:Ya,buffer:i,caret:n.start+r.length,restored:OC(r),token:{span:{start:a,end:n.start},text:t.slice(a,n.start),restored:OC(r),restoredText:r}}}function sB(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function _Pt(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:YS(e),buffer:i,caret:a,payload:null}}function XPt(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=$8(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=pn(i);if(!a)return i===""?null:_Pt(t,n,e.selection,i);const o=t.arm,s=d1e(e.index,a),l=s+Ck,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:Ya,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:m1e(e.taken,e.draw),value:a,marker:s}}}const O1e=e=>`${OC(e)} chars`,d1e=(e,t)=>`[Credential #${e}, ${O1e(t)}]`;function RPt(e){ql.lastIndex=0;const t=ql.exec(e);return ql.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function EPt(e){ql.lastIndex=0;const t=ql.exec(e);if(ql.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 uv(e,t){if(RPt(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const O2=/\[credential ([A-Za-z_][A-Za-z0-9_]*) \((\d+) chars\) \u2014 available to bash and eval as \$([A-Za-z_][A-Za-z0-9_]*); its value cannot be read\]/y,d2=/\[credential NOT stored \u2014 [^\]\n]*\]/y,f2=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,qPt=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&uC.test(t[1])?t[1]:""};function jPt(e,t){if(e.charCodeAt(t)!==91)return null;O2.lastIndex=t;const n=O2.exec(e);if(O2.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};d2.lastIndex=t;const r=d2.exec(e);if(d2.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};f2.lastIndex=t;const i=f2.exec(e);return f2.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:qPt(i[0])}:null}function zk(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=jPt(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 lB(e,t){const n=[];for(const r of t){const i=uv(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 CPt(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 zPt=e=>`[credential ${e.key} (${O1e(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function APt(e,t,n=new Map){const r=[...t],i=[];for(const o of r){const s=uv(e,o);s!==null&&i.push({span:s,payload:o})}for(const o of s1e(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?CPt(l??"lost",s?.key):zPt(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const UPt=(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.`,WPt=e=>`Remove credential #${e}`,NPt=(e,t)=>`Credential #${e}, ${t} chars — held in this message; its value cannot be read`,YPt=(e,t,n)=>UPt(e,t,n),GPt="Undo",IPt=e=>`Credential #${e} removed`,ZPt=e=>e.unredacted!==null?e.unredacted:e.armed?HPt:e.cleared!==null?YPt(e.cleared.key,e.cleared.index,e.undoCap):null;function DPt(e){const{buffer:t,payload:n}=e,r=uv(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===Ck?r.end+1:r.end;return{cleared:!0,buffer:t.slice(0,r.start)+t.slice(i),caret:r.start,removed:t.slice(r.start,i)}}function VPt(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 cB=e=>`Stored ${e.join(", ")}. Injected into every bash command as an environment variable; the agent cannot read the value.`;function uB(e){const t=e.length===1?"credential":"credentials";return`${e.length} ${t} could not be stored (${[...e].sort().join(", ")}); the agent has been told so. Paste the value again after /credential to retry.`}const MPt="store unconfirmed",LPt="Credential store unconfirmed",FPt=e=>e===""?LPt:`${e} · ${MPt}`,f1e="Paste the value again after /credential to store it again.",BPt=e=>`${e} ${f1e}`;function OB(e){const t=e.length===1?"credential":"credentials";return`${e.length} ${t} could not be confirmed as stored (${[...e].sort().join(", ")}); the agent has been told to check before using it. ${f1e}`}const HPt="armed — add a space, then type or paste the secret",KPt="masked as you type — Enter turns it into a pill, Esc cancels",JPt="masked — Enter opens the credential picker; type or paste the secret into this span",e5t="masked — Enter runs /credential, which needs an open conversation; type or paste the secret into this span",h1e="\0held",t5t=(e,t)=>t===void 0?`${e} characters are now PLAIN TEXT in the composer — Enter will expose them`:t===h1e?`${e} characters are now PLAIN TEXT in the composer — Enter is held: clear the box to release your words`:`${e} characters are now PLAIN TEXT in the composer — Enter will take them as /${t}'s argument, not send them`;function p1e(e,t){const n=Cf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const dB=(e,t)=>e&&e.over===t?e.chars:null,n5t=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},r5t=16,i5t=16;function m1e(e=[],t=n5t){const n=new Set(e);for(let r=0;r<r5t;r++){const i=iB+fB(8,t);if(!n.has(i))return i}return iB+fB(i5t,t)}const fB=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=rB[t(rB.length)];return n},g1e=j("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),$1e=j("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),y1e=({label:e,chars:t=null,tone:n="live",title:r,onClear:i,clearLabel:a,className:o,style:s,small:l=!1})=>h.jsxs("span",{className:j("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?$1e:g1e,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?h.jsx(goe,{"aria-hidden":"true",className:"size-3 shrink-0"}):h.jsx(s7e,{"aria-hidden":"true",className:"size-3 shrink-0"}),h.jsx("span",{className:"min-w-0 truncate",children:e}),t!==null&&h.jsx("span",{className:"shrink-0",children:`· ${t} chars`}),i&&h.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:h.jsx(Zi,{"aria-hidden":"true",className:"size-3"})}),r&&h.jsx("span",{className:"sr-only",children:r})]}),W$="#lo-credential/",a5t=`${W$}unstored`,hB=`${W$}unconfirmed`,o5t=/^\d+$/,v1e=e=>e.kind==="stored"?`${W$}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${hB}/${e.key}`:hB:a5t;function s5t(e){if(!e||!e.startsWith(W$))return null;const t=e.slice(W$.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return uC.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!uC.test(r)||!o5t.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function pB(e,t){const n=s5t(e);if(n===null)return null;const r=zk(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return v1e(i)!==e?null:n}const Ak=()=>e=>{const t=n=>{if(!n.children)return;const r=[];let i=!1;for(const a of n.children){if(a.type!=="text"||typeof a.value!="string"){t(a),r.push(a);continue}const o=zk(a.value);if(o.length===1&&o[0].kind==="text"){r.push(a);continue}i=!0;for(const s of o){if(s.kind==="text"){r.push({type:"text",value:s.text});continue}r.push({type:"link",url:v1e(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},l5t=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?FPt(e.key):"Credential not stored",c5t=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?BPt(t):t,u5t=({citation:e,title:t})=>h.jsx(y1e,{tone:e.kind==="stored"?"live":"warning",label:l5t(e),chars:e.kind==="stored"?e.chars:null,title:c5t(e,t),className:"align-middle"}),O5t=(e,t)=>typeof t=="string"?pB(e,t):t==null?pB(e,""):null,d5t=e=>({href:t,title:n,children:r})=>{const i=O5t(t,r);if(i===null){const a=e;return h.jsx(a,{href:t,title:n,children:r})}return h.jsx(u5t,{citation:i,title:n})},b1e=e=>yHe(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",w1e=e=>{const t=b1e(e);return t==="other"?"path":t},mB={id:"open-file",label:"Open file"},f5t={id:"show-in-canvas",label:"Show in canvas"},h5t={id:"save-as",label:"Save as…"},gB={id:"open-folder",label:"Open folder"},$B={id:"copy-file-path",label:"Copy file path"},bg={id:"copy-image",label:"Copy image"},p5t={id:"copy-image-url",label:"Copy image URL"},m5t={id:"open-in-browser",label:"Open in browser"};function S1e(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const o=[...t?[f5t]:[],...a?[{id:"expand-image",label:"Expand image"}]:[]];switch(e){case"artifact":return[...o,...i?[mB,gB,$B]:[],h5t,...r==="video"?[]:[bg]];case"path":return[...o,mB,gB,$B,...r==="video"?[]:[bg]];case"data":return[...o,bg];case"blob":return[bg];case"http":return[...g5t(n)?[bg]:[],p5t,m5t];case"other":return[]}}const x1e=(e,t)=>S1e(e,t).length>0;function g5t(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 y8=e=>e.startsWith("file://")?e.slice(7):e;function $5t(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 yB(e,t,n){if(e==="data")return $5t(t);if(e==="blob"){const o=Fue(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=y8(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:Mue(i)})}const y5t=e=>e.trim().toLowerCase()!=="image/png";async function v5t(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!y5t(e.type))return e;const t=URL.createObjectURL(e);try{const n=await b5t(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 b5t(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 w5t=6e4;function S5t(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),w5t)}const vB=new Map,bB=new Map;function Q1e(e){return e===void 0?"":JSON.stringify(e)}function v8(e,t){const n=`${e}\0${Q1e(t)}`;let r=vB.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),vB.set(n,r)),r}function x5t(e,t){const n=`${e}\0${Q1e(t)}`;let r=bB.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),bB.set(n,r)),r}function k1e(e,t,n){return v8(n??rp(),t).format(e)}function Q5t(e,t,n){return v8(n??rp(),t).format(e)}function k5t(e,t,n){return v8(rp(),t).format(e)}function P1e(e,t,n){return x5t(n??rp(),t).format(e)}const l1=new Map;function P5t(e,t){const n=l1.get(t);if(n)return n.holders+=1,n.promise;const r={holders:1,promise:null};return r.promise=(async()=>{try{const i=await uO(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=Lue(i.data,i.mimeType);return r.holders<=0?(TQ(a),null):(Bue(t,a),a)}catch{return null}finally{l1.delete(t)}})(),l1.set(t,r),r.promise}class T1e extends Error{constructor(){super("This item is no longer in the session"),this.name="AttachmentGoneError"}}async function rsn(e,t){const n=Uz(t),r=n?Fue(n):null;if(r)return r;const i=await uO(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 T1e:new Error("These bytes are not available right now");return new Blob([i.data],{type:i.mimeType})}function T5t(e){const t=l1.get(e);t&&(t.holders-=1)}function _1e(e,t){const n=e.data?`data:${e.mimeType};base64,${e.data}`:null,[r,i]=$.useState(()=>e.attachment?Uz(e.attachment):null),[a,o]=$.useState(!1),s=t?.sessionId??null,l=t?.childId??null;$.useEffect(()=>{const u=e.attachment;if(n||!u||!s)return;let O=!0;const d=A1(u);if(d)return i(d),o(!1),()=>{O=!1,U1(u)};i(null),o(!1);let f=!0;return P5t({sessionId:s,childId:l},u).then(p=>{if(f=!1,!!O){if(!p){o(!0);return}i(A1(u))}}),()=>{O=!1,f&&T5t(u),U1(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 X1e(e,t){return _1e(e,t)}const _5t={"expand-image":h.jsx(Tle,{"aria-hidden":"true"}),"open-file":h.jsx(jy,{"aria-hidden":"true"}),"show-in-canvas":h.jsx(Ple,{"aria-hidden":"true"}),"save-as":h.jsx(qy,{"aria-hidden":"true"}),"open-folder":h.jsx(lp,{"aria-hidden":"true"}),"copy-file-path":h.jsx(vle,{"aria-hidden":"true"}),"copy-image":h.jsx($Q,{"aria-hidden":"true"}),"copy-image-url":h.jsx(O7e,{"aria-hidden":"true"}),"open-in-browser":h.jsx(Sle,{"aria-hidden":"true"})},wB=(e,t)=>t instanceof T1e?`${e}: it is no longer in the session`:e,R1e=({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:f,tooltip:p="Image actions","aria-label":m})=>{const g=w1e(e),y=S1e(g,{canShowInCanvas:!!c,source:t??e,mediaKind:u,artifactPathActions:!!s,canExpand:!!O}).filter(Q=>(Q.id!=="save-as"||!!d)&&(!l||Q.id==="copy-file-path"));if(y.length===0)return null;const v=async(Q,k,_)=>{try{await navigator.clipboard.writeText(Q),Md(k)}catch(T){console.error(`${_}: `,T),oi(_)}},S=async()=>{try{if(typeof ClipboardItem>"u")throw new Error("this window cannot write an image to the clipboard");const Q=f?await f():await yB(g,e,t),k=await v5t(Q);await navigator.clipboard.write([new ClipboardItem({[k.type]:k})]),Md("Image copied to clipboard")}catch(Q){console.error("Failed to copy image: ",Q),oi(wB("Failed to copy image",Q))}},x=async()=>{try{const Q=f?await f():await yB(g,e,t);S5t(Q,d??"download")}catch(Q){console.error("Failed to save file: ",Q),oi(wB("Failed to save file",Q))}},b=async Q=>{let k=y8(e);if(s&&["open-file","open-folder","copy-file-path"].includes(Q.id))try{k=await s()}catch{oi(va("ui.canvas.files.prepareError"));return}switch(Q.id){case"expand-image":O?.();return;case"open-file":vO(k);return;case"open-folder":f8(k);return;case"show-in-canvas":c?.();return;case"copy-file-path":v(k,"File path copied to clipboard","Failed to copy file path");return;case"copy-image":S();return;case"save-as":x();return;case"copy-image-url":v(t??e,"Image URL copied to clipboard","Failed to copy image URL");return;case"open-in-browser":h8(t??e);return}},w=m??`Actions for ${n??"this image"}`;return h.jsxs(S6,{open:r,onOpenChange:i,children:[h.jsx(At,{content:p,children:h.jsx(x6,{asChild:!0,children:h.jsx(je,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":w,tabIndex:o,onClick:Q=>Q.stopPropagation(),children:h.jsx(wle,{"aria-hidden":"true"})})})}),h.jsxs(Q6,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:Q=>Q.stopPropagation(),children:[s&&h.jsx("div",{role:"note",className:j("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:va("ui.canvas.files.pathCopyNote")}),y.map(Q=>h.jsxs(Sl,{onSelect:()=>b(Q),children:[_5t[Q.id],h.jsx("span",{children:Q.label})]},Q.id))]})]})},X5t=({src:e,alt:t,title:n,className:r})=>{const i=_k(),a=e??"",o=b1e(a);if(o==="other")return h.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=x1e(o,{canShowInCanvas:s,source:a});return h.jsxs("span",{className:j("group/mdimg relative inline-block max-w-full"),children:[h.jsx("img",{src:e,alt:t,title:n,className:r}),l&&h.jsx("span",{"data-markdown-image":"",className:j("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:h.jsx(R1e,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||vO(y8(a))})}:void 0})})]})};function R5t(){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 E5t={tokenize:q5t,concrete:!0,name:"mathFlow"},SB={tokenize:j5t,partial:!0};function q5t(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(v){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),l(v)}function l(v){return v===36?(e.consume(v),o++,l):o<2?n(v):(e.exit("mathFlowFenceSequence"),on(e,c,"whitespace")(v))}function c(v){return v===null||gt(v)?O(v):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(v))}function u(v){return v===null||gt(v)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),O(v)):v===36?n(v):(e.consume(v),u)}function O(v){return e.exit("mathFlowFence"),r.interrupt?t(v):e.attempt(SB,d,g)(v)}function d(v){return e.attempt({tokenize:y,partial:!0},g,f)(v)}function f(v){return(a?on(e,p,"linePrefix",a+1):p)(v)}function p(v){return v===null?g(v):gt(v)?e.attempt(SB,d,g)(v):(e.enter("mathFlowValue"),m(v))}function m(v){return v===null||gt(v)?(e.exit("mathFlowValue"),p(v)):(e.consume(v),m)}function g(v){return e.exit("mathFlow"),t(v)}function y(v,S,x){let b=0;return on(v,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function w(_){return v.enter("mathFlowFence"),v.enter("mathFlowFenceSequence"),Q(_)}function Q(_){return _===36?(b++,v.consume(_),Q):b<o?x(_):(v.exit("mathFlowFenceSequence"),on(v,k,"whitespace")(_))}function k(_){return _===null||gt(_)?(v.exit("mathFlowFence"),S(_)):x(_)}}}function j5t(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 C5t(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:z5t,previous:A5t,name:"mathText"};function r(i,a,o){let s=0,l,c;return u;function u(m){return i.enter("mathText"),i.enter("mathTextSequence"),O(m)}function O(m){return m===36?(i.consume(m),s++,O):s<2&&!n?o(m):(i.exit("mathTextSequence"),d(m))}function d(m){return m===null?o(m):m===36?(c=i.enter("mathTextSequence"),l=0,p(m)):m===32?(i.enter("space"),i.consume(m),i.exit("space"),d):gt(m)?(i.enter("lineEnding"),i.consume(m),i.exit("lineEnding"),d):(i.enter("mathTextData"),f(m))}function f(m){return m===null||m===32||m===36||gt(m)?(i.exit("mathTextData"),d(m)):(i.consume(m),f)}function p(m){return m===36?(i.consume(m),l++,p):l===s?(i.exit("mathTextSequence"),i.exit("mathText"),a(m)):(c.type="mathTextData",f(m))}}}function z5t(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 A5t(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function U5t(e){return{flow:{36:E5t},text:{36:C5t()}}}const _h=36,xB=e=>e!==null&&e<-2,QB=e=>e===null||e===32||e<0,kB=e=>e!==null&&e>=48&&e<=57,E1e=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:W5t,previous:N5t,name:"mathText"};function n(r,i,a){const o=this;let s=0,l=null,c,u;return O;function O(g){return r.enter("mathText"),r.enter("mathTextSequence"),d(g)}function d(g){return g===_h?(r.consume(g),s++,d):s<2&&!t||s===1&&(QB(g)||kB(g))?a(g):(r.exit("mathTextSequence"),f(g))}function f(g){return g===null?a(g):g===_h?(u=r.enter("mathTextSequence"),c=0,l=o.previous,m(g)):g===32?(r.enter("space"),r.consume(g),r.exit("space"),f):xB(g)?(r.enter("lineEnding"),r.consume(g),r.exit("lineEnding"),f):(r.enter("mathTextData"),p(g))}function p(g){return g===null||g===32||g===_h||xB(g)?(r.exit("mathTextData"),f(g)):(r.consume(g),p)}function m(g){return g===_h?(r.consume(g),c++,m):c===s?s===1&&(QB(l)||kB(g))?a(g):(r.exit("mathTextSequence"),r.exit("mathText"),i(g)):(u.type="mathTextData",p(g))}}};function W5t(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 N5t(e){return e!==_h||this.events[this.events.length-1][1].type==="characterEscape"}const Y5t=U5t().flow,G5t=E1e();function Uk(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?G5t:E1e(e);n.push({flow:Y5t,text:{[_h]:i}}),r.push(R5t())}const I5t=({node:e,...t})=>h.jsx("div",{className:"lo-md-table-scroll",children:h.jsx("table",{...t})}),Z5t=/\$(?!\d)(.+?)\$/,D5t=/\$\$([\s\S]+?)\$\$/,V5t=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,M5t=/\\[a-zA-Z]+(\{[^}]*\})?/,PB=e=>Z5t.test(e)||D5t.test(e)||V5t.test(e)?!0:M5t.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),L5t=e=>{const t=zk(e);if(t.length===1&&t[0].kind==="text")return null;let n="",r=!1;for(const i of t){if(i.kind==="text"){n+=i.text;continue}r=!0,n+="x".repeat(i.text.length)}return r?n:null},F5t=e=>zk(e).filter(t=>t.kind!=="text").length,B5t=e=>{if(!PB(e))return!1;const t=L5t(e);return t===null?!0:PB(t)||t.includes("$")?!1:F5t(e)<2},Ht="var(--color-ink)",uc="var(--color-ink-muted)",dl="var(--color-surface)",Eu="var(--color-elevated)",Oc="var(--color-sunken)",Li="var(--color-hairline)",qu="var(--color-control)",oh="var(--color-accent)",Jg="var(--color-accent-wash)",H5t="var(--color-accent-alt-wash)",K5t="var(--color-on-accent)",J5t="var(--color-info)",q1e="var(--color-info-wash)",eTt="var(--color-success)",j1e="var(--color-success-wash)",tTt="var(--color-warning)",fC="var(--color-warning-wash)",nTt="var(--color-warning-border)",h2="var(--color-danger)",hC="var(--color-danger-wash)",TB=[Jg,H5t,q1e,j1e,fC,hC],ju=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),rTt=()=>{const e={primaryColor:ju("--color-accent"),secondaryColor:ju("--color-success"),tertiaryColor:ju("--color-info"),mainBkg:ju("--color-elevated"),clusterBkg:ju("--color-sunken"),clusterBorder:ju("--color-hairline"),edgeLabelBackground:ju("--color-surface"),quadrant1Fill:ju("--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:dl,primaryTextColor:Ht,primaryBorderColor:qu,secondaryTextColor:Ht,secondaryBorderColor:Li,tertiaryTextColor:Ht,tertiaryBorderColor:Li,lineColor:uc,arrowheadColor:uc,textColor:Ht,secondBkg:Oc,border1:qu,border2:Li,labelColor:Ht,nodeBkg:Eu,nodeBorder:qu,nodeTextColor:Ht,defaultLinkColor:uc,titleColor:Ht,noteBkgColor:fC,noteBorderColor:nTt,noteTextColor:Ht,actorBkg:Eu,actorBorder:qu,actorTextColor:Ht,actorLineColor:Li,signalColor:uc,signalTextColor:Ht,labelBoxBkgColor:Eu,labelBoxBorderColor:Li,labelTextColor:Ht,loopTextColor:Ht,activationBkgColor:Jg,activationBorderColor:oh,sequenceNumberColor:dl,sectionBkgColor:Oc,sectionBkgColor2:dl,altSectionBkgColor:Oc,excludeBkgColor:Oc,taskBkgColor:Jg,taskBorderColor:qu,taskTextColor:Ht,taskTextLightColor:Ht,taskTextDarkColor:Ht,taskTextOutsideColor:Ht,taskTextClickableColor:oh,activeTaskBkgColor:Jg,activeTaskBorderColor:oh,gridColor:Li,doneTaskBkgColor:Oc,doneTaskBorderColor:Li,critBkgColor:hC,critBorderColor:h2,todayLineColor:oh,transitionColor:uc,transitionLabelColor:Ht,stateLabelColor:Ht,stateBkg:Eu,labelBackgroundColor:dl,compositeBackground:Oc,altBackground:Oc,compositeTitleBackground:Eu,compositeBorder:Li,innerEndBackground:Ht,specialStateColor:Ht,classText:Ht,attributeBackgroundColorOdd:dl,attributeBackgroundColorEven:Oc,rowOdd:dl,rowEven:Oc,errorBkgColor:hC,errorTextColor:h2,pieTitleTextColor:Ht,pieSectionTextColor:Ht,pieLegendTextColor:Ht,pieStrokeColor:dl,pieOuterStrokeColor:Li,requirementBackground:Eu,requirementBorderColor:qu,requirementTextColor:Ht,relationColor:uc,relationLabelBackground:dl,relationLabelColor:Ht,branchLabelColor:K5t,commitLabelColor:Ht,commitLabelBackground:dl,tagLabelColor:Ht,tagLabelBackground:Jg,tagLabelBorder:qu,quadrant2Fill:q1e,quadrant3Fill:j1e,quadrant4Fill:fC,quadrant2TextFill:Ht,quadrant3TextFill:Ht,quadrant4TextFill:Ht,quadrantPointFill:oh,archEdgeColor:uc,archEdgeArrowColor:uc,archGroupBorderColor:Li,scaleLabelColor:Ht,packet:{startByteColor:Ht,endByteColor:Ht,labelColor:Ht,titleColor:Ht,blockStrokeColor:qu,blockFillColor:Eu},radar:{axisColor:uc,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:Li,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:dl,titleColor:Ht,xAxisTitleColor:Ht,xAxisLabelColor:Ht,xAxisTickColor:Li,xAxisLineColor:Li,yAxisTitleColor:Ht,yAxisLabelColor:Ht,yAxisTickColor:Li,yAxisLineColor:Li,plotColorPalette:[oh,J5t,eTt,tTt,h2].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Eu,t[`surfacePeer${n}`]=Li;for(let n=0;n<8;n++)t[`fillType${n}`]=TB[n%TB.length];return{...t,...e}};let p2=null,_B=null;const iTt=async e=>{p2||(p2=ve(async()=>{const{default:n}=await import("./mermaid.core-C2AhDEdD.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([8,2,3]),import.meta.url).then(({default:n})=>n));const t=await p2;return _B!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:rTt()}),_B=e),t},XB=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>h.jsxs("div",{className:j("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[h.jsx(At,{content:"Zoom in",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:h.jsx(Wle,{})})}),h.jsx(At,{content:"Zoom out",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:h.jsx(Nle,{})})}),h.jsx(At,{content:"Drag the diagram to pan",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:h.jsx(_7e,{})})}),h.jsx(At,{content:"Reset view",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:h.jsx(vQ,{})})}),h.jsx(At,{content:"Save as SVG",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:a,children:h.jsx(qy,{})})}),h.jsx(At,{content:t?"Copied":"Copy mermaid text",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:o,children:h.jsx($Q,{className:j(t&&"text-success")})})}),s]}),pC=({title:e,children:t})=>h.jsxs(zl,{variant:"danger",role:"alert",className:"my-4",children:[h.jsx(a0,{children:e}),h.jsx(o0,{children:t})]});class aTt 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||h.jsxs(pC,{title:"Mermaid diagram error",children:[this.state.error?.message||"An unexpected error occurred while rendering the diagram"," ","The error was contained within the diagram component."]}):this.props.children}}const oTt=$.memo(({chart:e,id:t})=>{const n=$.useRef(null),r=$.useRef(null),[i,a]=$.useState(null),[o,s]=$.useState(!0),[l,c]=$.useState(""),[u,O]=$.useState(!1),[d,f]=$.useState({scale:1,x:0,y:0}),[p,m]=$.useState({scale:1,x:0,y:0}),[g,y]=$.useState(!1),[v,S]=$.useState({x:0,y:0}),[x,b]=$.useState("idle"),[w,Q]=$.useState("idle"),k=Kn(A=>A.themeName),_=$.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 A=await iTt(k),ee=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:L}=await A.render(ee,e);if(!L||typeof L!="string"||L.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(L)}catch(A){console.error("Mermaid rendering error:",A);const ee=A instanceof Error?A.message:"Failed to render mermaid diagram";a(ee),c("")}finally{s(!1)}},[e,t,k]);$.useEffect(()=>{_().catch(A=>{console.error("Error in renderDiagram effect:",A),a("Failed to initialize diagram rendering"),s(!1)})},[_]);const T=$.useCallback(()=>{try{if(!l||!r.current)return 1;const ee=r.current.getBoundingClientRect(),L=document.createElement("div");L.innerHTML=l;const B=L.querySelector("svg");if(!B)return 1;const ce=B.getBoundingClientRect?.()?.width||Number.parseFloat(B.getAttribute("width")||"0")||B.viewBox?.baseVal?.width||800,M=B.getBoundingClientRect?.()?.height||Number.parseFloat(B.getAttribute("height")||"0")||B.viewBox?.baseVal?.height||600,H=ee.width*.9/ce,ne=ee.height*.9/M;return Math.min(H,ne,1)}catch(A){return console.error("Error calculating fullscreen scale:",A),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const A=T();m({scale:A,x:0,y:0})}catch(A){console.error("Error setting fullscreen transform:",A)}},100)},[u,l,T]);const E=$.useCallback((A=!1)=>{try{(A?m:f)(L=>({...L,scale:Math.min(L.scale*1.2,10)}))}catch(ee){console.error("Error in zoom in:",ee)}},[]),R=$.useCallback((A=!1)=>{try{(A?m:f)(L=>({...L,scale:Math.max(L.scale/1.2,.1)}))}catch(ee){console.error("Error in zoom out:",ee)}},[]),q=$.useCallback((A=!1)=>{try{const ee=A?m:f;if(A){const L=T();ee({scale:L,x:0,y:0})}else ee({scale:1,x:0,y:0})}catch(ee){console.error("Error in reset:",ee)}},[T]),z=$.useCallback(()=>{if(l)try{const A=new Blob([l],{type:"image/svg+xml"}),ee=URL.createObjectURL(A),L=document.createElement("a");L.href=ee,L.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(L),L.click(),document.body.removeChild(L),URL.revokeObjectURL(ee)}catch(A){console.error("Failed to save SVG:",A)}},[l]),W=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),b("copied"),setTimeout(()=>b("idle"),1200)}catch(A){console.error("Failed to copy Mermaid chart text:",A)}},[e]),I=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),Q("copied"),setTimeout(()=>Q("idle"),1200)}catch(A){console.error("Failed to copy Mermaid chart text:",A)}},[e]),N=$.useCallback(A=>{try{y(!0),S({x:A.clientX,y:A.clientY}),A.preventDefault()}catch(ee){console.error("Error in mouse down:",ee)}},[]),Z=$.useCallback((A,ee=!1)=>{try{if(!g)return;const L=A.clientX-v.x,B=A.clientY-v.y;(ee?m:f)(M=>({...M,x:M.x+L,y:M.y+B})),S({x:A.clientX,y:A.clientY})}catch(L){console.error("Error in mouse move:",L)}},[g,v]),G=$.useCallback(()=>{try{y(!1)}catch(A){console.error("Error in mouse up:",A)}},[]),U=$.useCallback((A,ee=!1)=>{try{A.preventDefault();const L=A.deltaY>0?.9:1.1;(ee?m:f)(ce=>({...ce,scale:Math.min(Math.max(ce.scale*L,.1),5)}))}catch(L){console.error("Error in wheel:",L)}},[]),K=$.useCallback(A=>{try{O(A)}catch(ee){console.error("Error toggling fullscreen:",ee)}},[]);if(i)return h.jsxs(pC,{title:"Mermaid diagram error",children:[i,h.jsx("span",{className:j("mt-2 block text-ink-muted"),children:"Chart"}),h.jsx("span",{className:j("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const J=(A=!1)=>{try{const ee=A?r:n,L=A?p:d;return h.jsx("div",{ref:ee,className:j("mermaid flex w-full items-center justify-center",A?"h-full min-h-full":"h-auto min-h-50",g?"cursor-grabbing":"cursor-grab"),onMouseDown:N,onMouseMove:B=>Z(B,A),onMouseUp:G,onMouseLeave:G,onWheel:B=>U(B,A),children:o?h.jsx("div",{className:j("p-4 text-body-sm text-ink-muted"),children:"Loading diagram..."}):l?h.jsx("div",{className:j("flex h-full w-full items-center justify-center"),style:{transform:`translate(${L.x}px, ${L.y}px) scale(${L.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(ee){return console.error("Error rendering diagram content:",ee),h.jsx(pC,{title:"Rendering error",children:"Failed to render diagram content."})}};return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:j("relative flex items-center justify-center overflow-hidden rounded-md bg-surface","[&_svg]:h-auto [&_svg]:min-h-100 [&_svg]:max-w-none [&_svg]:bg-transparent"),children:[J(!1),h.jsx(XB,{className:"top-2 right-2",copied:x==="copied",onZoomIn:()=>E(!1),onZoomOut:()=>R(!1),onReset:()=>q(!1),onSave:z,onCopy:W,children:h.jsx(At,{content:"Fullscreen",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>K(!0),children:h.jsx(Tle,{})})})})]}),h.jsx(K0,{open:u,onClose:()=>K(!1),title:"Mermaid diagram",maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:h.jsxs("div",{className:j("relative flex h-[80vh] w-full items-center justify-center overflow-hidden","[&_svg]:h-auto [&_svg]:max-h-full [&_svg]:w-auto [&_svg]:max-w-full [&_svg]:bg-transparent"),children:[J(!0),h.jsx(XB,{className:"top-4 right-4",copied:w==="copied",onZoomIn:()=>E(!0),onZoomOut:()=>R(!0),onReset:()=>q(!0),onSave:z,onCopy:I,children:h.jsx(At,{content:"Close fullscreen",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>K(!1),children:h.jsx(Zi,{})})})})]})})]})}),sTt=$.memo(e=>h.jsx(aTt,{children:h.jsx(oTt,{...e})}));let C1e=!1,m2=null;const lTt=()=>(m2||(m2=ve(()=>Promise.resolve({}),__vite__mapDeps([9]),import.meta.url).then(e=>(C1e=!0,e))),m2),cTt=/language-(\w+)/,uTt=Ek,OTt=new RegExp(`^[^${Ma}\\d*+-]`),dTt=/\n$/,z1e=({href:e,children:t})=>{const n=jwe(e),r=_k();return!n||n.kind==="other"?h.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}):h.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=>pTt(i,r):void 0,children:t})},fTt=e=>jwe(e)?.kind==="file",hTt=Wwe,pTt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(Uwe)??"file",i=n.getAttribute(hTt),a=ckt({kind:r,hasHighlight:xkt(n),canOpenInCanvas:d8(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||vO(i)});return}vO(i)}},mC=(e,t)=>t==="href"&&fTt(e)?e:nde(e),N$={a:z1e,table:I5t,img:X5t,code:({node:e,className:t,children:n,...r})=>cTt.exec(t??"")?.[1]==="mermaid"?h.jsx(sTt,{chart:String(n).replace(dTt,"")}):h.jsx("code",{className:t,...r,children:n})},mTt={...N$,a:d5t(z1e)},gTt=[kO],$Tt=[kO,Uk],yTt=[kO,Xk],vTt=[kO,Uk,Xk],bTt=[kO,Ak,Rk],wTt=[kO,Uk,Ak,Rk],STt=[kO,Xk,Ak,Rk],xTt=[kO,Uk,Xk,Ak,Rk],QTt={"000":gTt,"001":bTt,"010":yTt,"011":STt,100:$Tt,101:wTt,110:vTt,111:xTt},kTt=[],PTt=[sFe],A1e=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),U1e=(e,t,n)=>{const r=$.useMemo(()=>B5t(e),[e]),[i,a]=$.useState(C1e),o=r&&i;return $.useEffect(()=>{if(!r||i)return;let s=!1;return lTt().then(()=>{s||a(!0)}),()=>{s=!0}},[r,i]),{remarkPlugins:QTt[`${o?1:0}${t?1:0}${n?1:0}`],rehypePlugins:o?PTt:kTt}},W1e=(e,t)=>{const[,n]=$.useState(0);$.useEffect(()=>{if(!t)return;const r=GHe(e);if(r.length===0)return;let i=!0;const a=new Set(r),o=Okt(s=>{i&&s.some(l=>a.has(l))&&n(l=>l+1)});return Awe(r,window.api?.probeFiles,doe).then(()=>{i&&r.some(s=>zwe(s)!=="unknown")&&n(s=>s+1)}),()=>{i=!1,o()}},[e,t])},Wk=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1})=>{const a=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:o,rehypePlugins:s}=U1e(a,r,i),l=A1e(t);return W1e(a,r),h.jsx("div",{className:j("lo-markdown",n),style:l,children:h.jsx(r3,{remarkPlugins:o,rehypePlugins:s,urlTransform:mC,components:i?mTt:N$,children:a})})});Wk.displayName="MarkdownRenderer";const RB={...N$,a:({children:e})=>h.jsx(h.Fragment,{children:e})},N1e=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:eB(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=Kwe(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=U1e(n,t,!1);if(W1e(e,t),r!==null){const o=eB(r.before);return h.jsxs(h.Fragment,{children:[o.trim()!==""&&h.jsx(r3,{remarkPlugins:i,rehypePlugins:a,urlTransform:mC,components:t?N$:RB,children:o}),h.jsx(TTt,{info:r.info,body:r.body})]})}return h.jsx(r3,{remarkPlugins:i,rehypePlugins:a,urlTransform:mC,components:t?N$:RB,children:n})});N1e.displayName="ParsedBlock";const TTt=({info:e,body:t})=>{const n=e.split(uTt)[0];return h.jsx("pre",{children:h.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
856
856
  `)?"":`
857
857
  `}`})})},Y1e=({content:e,styleProps:t,className:n})=>{const r=$.useRef(null);r.current===null&&(r.current=Tkt());const i=r.current;Ekt(i,e);const{blockStart:a}=i,o=a+qkt(e.slice(a));let s=null,l=a;(i.kind==="other"||(i.kind==="list"||i.kind==="indented-code")&&OTt.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,f)=>({key:f,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=A1e(t);return h.jsx("div",{className:j("lo-markdown",n),style:O,children:u.map(d=>h.jsx(N1e,{source:d.source,closed:d.closed},d.key))})};Y1e.displayName="StreamingMarkdown";const Eo=({isUser:e,children:t,className:n})=>e?h.jsx("div",{className:j("flex w-full justify-end",n),children:t}):h.jsx("div",{className:j("group relative w-full",n),children:t}),b8=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},_Tt=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 w8=b8(Date.now()),Du=null;const c1=new Set,G1e=()=>{Du!==null&&clearTimeout(Du),Du=setTimeout(()=>{Du=null,w8=b8(Date.now());for(const e of c1)e();G1e()},_Tt(Date.now())),Du.unref?.()},XTt=e=>(c1.add(e),w8=b8(Date.now()),G1e(),()=>{c1.delete(e),c1.size===0&&Du!==null&&(clearTimeout(Du),Du=null)}),EB=()=>w8,RTt=()=>$.useSyncExternalStore(XTt,EB,EB),ETt=e=>new Date(e+1e3),qTt=()=>ETt(RTt()),jTt=5e3;let I1e=0;function CTt(e=jTt){I1e=Date.now()+e}function isn(e=Date.now()){return e<=I1e}function zTt(e){CTt(),e.invalidateQueries({queryKey:Vr.capabilities})}const asn=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":k1e(t,{year:"numeric",month:"long",day:"numeric"})}catch(t){return console.error("Error formatting calendar date:",t),""}},ATt=(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=Q5t(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`Yesterday ${r}`;const a=k1e(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),""}},UTt=(e,t)=>{if(!e)return"";try{const n=e instanceof Date?e:new Date(e);return Number.isNaN(n.getTime())?"":k5t(n,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit",...t})}catch(n){return console.error("Error formatting calendar date-time:",n),""}},WTt={turn:"Sent",answer:"Answered",tool:"Ran"},Z1e=({timestamp:e,scope:t,className:n})=>{const r=e instanceof Date?e:new Date(e),i=qTt();if(Number.isNaN(r.getTime()))return null;const a=UTt(r,{hour12:!0});return h.jsx(At,{content:a,side:"bottom",delayDuration:1200,children:h.jsx("time",{dateTime:r.toISOString(),"data-stamp":t,"aria-label":`${WTt[t]} ${a}`,className:j("shrink-0 select-none whitespace-nowrap text-ink-dim text-meta",n),children:ATt(r,i)})})},S8=({replies:e,onRemoveReply:t})=>h.jsxs("div",{className:"mb-2 flex flex-col gap-1.5 rounded-sm bg-sunken p-2",children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-ink-dim",children:[h.jsx(w7e,{size:12,"aria-hidden":"true"}),h.jsx("span",{className:"text-meta",children:"Replying to"})]}),e.map(n=>h.jsxs("div",{className:"flex items-center gap-2 border-hairline border-l-2 py-0.5 pl-2",children:[h.jsx("span",{className:"flex-1 truncate text-body-sm text-ink-muted",title:n.text,children:n.text}),t&&h.jsx(je,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-ink-dim hover:bg-elevated hover:text-ink",onClick:()=>t(n.id),"aria-label":"Remove reply",children:h.jsx(Zi,{"aria-hidden":"true"})})]},n.id))]}),NTt=({children:e,className:t})=>h.jsx("span",{"aria-hidden":!0,className:j("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),YTt={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},GTt=({line:e})=>h.jsx("span",{className:j(YTt[e.kind],"block"),children:e.text}),ITt=({diff:e,className:t})=>{const n=yXe(e);return h.jsxs("div",{className:j("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)=>h.jsx(GTt,{line:r},i)),n.hidden>0&&h.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:vXe(n.hidden)})]})},ZTt=(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()},qB=e=>e.startsWith("file://")?e.slice(7):e,DTt={READ:{verb:"Read",runningVerb:"Reading",icon:cz},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:qle},EDIT:{verb:"Edited",runningVerb:"Editing",icon:Y7e},CODE:{verb:"Ran code",runningVerb:"Running code",icon:ble},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:n6e},DONE:{verb:"Finished",runningVerb:"Finishing",icon:k6},ASK:{verb:"Asked",runningVerb:"Asking",icon:mQ},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:jCe}},VTt={verb:"Worked on the request",runningVerb:"Working on the request",icon:ble},MTt=(e,t,n,r)=>{const i=e?DTt[e]:VTt;let a;if(t)a=qB(t);else if(n&&n.length>0){const s=n.filter(l=>!l.startsWith("data:"));s.length===1?a=qB(s[0]):s.length>1&&(a=`${s.length} files`)}const o=!a&&r?ZTt(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:a,narration:o||void 0,icon:i.icon}},jB="min-h-5 py-0",LTt=({icon:e,verb:t,object:n,narration:r,running:i,failed:a,wrap:o})=>h.jsxs("span",{className:j("flex min-w-0 gap-2",o?"items-start":"items-center"),"aria-busy":i||void 0,children:[h.jsx(NTt,{className:j(a?"text-danger":"text-ink-dim",o&&Ice),children:e}),h.jsxs("span",{className:j(o?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[h.jsxs("span",{..._5,className:j("select-text font-mono text-mono-sm",a?"text-danger":"text-ink-muted"),children:[t,r?":":null]}),n?h.jsxs("span",{..._5,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?h.jsxs("span",{..._5,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),CB=({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:f=!1})=>{const p=MTt(e,t,n,r),m=c??(i?p.runningVerb:p.verb),g=a?ip:p.icon,y=a||!c||!O?h.jsx(g,{}):O,v=h.jsx(LTt,{icon:y,verb:m,object:c?u:p.object,narration:c?r:p.narration,running:i,failed:a,wrap:d}),S=d?"firstLine":"center";return s?h.jsx(Pa,{summary:v,chevron:"leading",summaryAlign:S,defaultOpen:o,className:l,rowClassName:f?jB:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:s}):h.jsx(Pa,{disabled:!0,summary:v,summaryAlign:S,className:l,rowClassName:f?jB:void 0})},D1e=8,FTt="… deeper values not shown",BTt="(empty)";function HTt(e){return`… ${e} more line${e===1?"":"s"}`}const zB=.5;function KTt(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 V1e(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function x8(e){return typeof e=="object"&&e!==null}function M1e(e,t,n,r){if(n>D1e){r.push({key:t,value:FTt,depth:n});return}if(x8(e)){for(const[a,o]of Object.entries(e))M1e(o,t?`${t}.${a}`:a,n+1,r);return}const i=V1e(e);i!==null&&r.push({key:t,value:i,depth:n})}function L1e(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))M1e(r,n,1,t);return t}const JTt=512;function e_t(e,t){if(t)return!0;if(!e)return!1;let n=JTt;const r=(i,a)=>{if(n--<=0||a>D1e)return!0;if(!x8(i))return V1e(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 t_t(e){if(!e)return null;const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return null;let n;try{n=JSON.parse(t)}catch{return null}if(!x8(n))return null;const r=L1e(n);return r.length>0?r:[{key:"",value:BTt,depth:1}]}const n_t=8,gC="max-h-[min(320px,40vh)]",r_t=gC,i_t=({line:e})=>h.jsxs("div",{className:j("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*n_t},children:[e.key?h.jsxs("span",{className:j("text-ink-muted"),children:[e.key,": "]}):null,h.jsx("span",{className:j("text-ink-dim"),children:e.value})]}),AB=({lines:e,label:t})=>h.jsx("div",{className:j("flex flex-col gap-1"),"data-detail-lines":t,children:e.map((n,r)=>h.jsx(i_t,{line:n},r))});function UB(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+zB);const f=c.children.length>0?Array.from(c.children):[c];n(KTt(f.map(p=>{const m=p.getBoundingClientRect();return{top:m.top,height:m.height}}),u,O.bottom,zB))};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 WB=({lines:e,overflowing:t})=>t?h.jsx("span",{className:j("mt-1 block text-ink-dim"),children:e>0?HTt(e):" "}):null,a_t=({args:e,output:t,isError:n,interrupted:r=!1,note:i=null})=>{const a=L1e(e),o=t_t(t),s=$.useRef(null),l=$.useRef(null),c=UB(s),u=UB(l);return a.length===0&&!t&&!i?null:h.jsxs("div",{className:j("w-full rounded-md bg-sunken p-3 font-mono text-mono-sm"),children:[a.length>0&&h.jsxs("div",{"data-detail-section":"input",children:[h.jsx("div",{ref:s,className:j(gC,"overflow-auto"),children:h.jsx(AB,{lines:a,label:"input"})}),h.jsx(WB,{lines:c.lines,overflowing:c.overflowing})]}),i&&h.jsx("div",{className:j("whitespace-normal font-sans text-body-sm text-ink-muted",a.length>0&&"mt-3"),"data-detail-section":"note",children:i}),t&&h.jsxs("div",{className:j(a.length>0&&"mt-3"),"data-detail-section":"output",children:[h.jsx("span",{className:j("mb-1 block text-meta",n&&!r?"text-danger":"text-ink-dim"),children:r?"Interrupted":n?"Error":"Output"}),h.jsx("div",{ref:l,className:j(gC,"overflow-auto"),children:o?h.jsx(AB,{lines:o,label:"result-json"}):h.jsx("pre",{className:j("whitespace-pre font-mono",n&&!r?"text-danger":"text-ink"),children:t})}),h.jsx(WB,{lines:u.lines,overflowing:u.overflowing})]})]})},o_t="mcp__",s_t={bash:o6e,read:yQ,write:HN,edit:HN,glob:lp,grep:Cy,todo:f7e,wake:gQ,list_variables:eY,read_variable:eY,browser:KN,console:Oz,project:TCe,project_delete:l6e,web_search:KN,web_fetch:qy,task:jd,agent:jd,send:zle,peer:a7e,sessions:Z7e};function l_t(e){const t=e.trim().toLowerCase(),n=s_t[t];return n||(t.startsWith(o_t)?jle:m6e)}const c_t=uz,u_t=y7e,O_t=g7e,NB="min-h-5 py-0",YB={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent-alt",plain:"text-ink-muted"},d_t=(e,t)=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":e==="receipt"?YB.plain:YB[sXe(t)],f_t=e=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":"text-ink-muted",h_t=({added:e,removed:t})=>e<=0&&t<=0?null:h.jsxs("span",{className:j("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&h.jsxs("span",{className:j("text-success"),children:["+",e]}),t>0&&h.jsxs("span",{className:j("text-danger"),children:["-",t]})]}),g2={running:"",success:"succeeded",error:"failed",interrupted:"interrupted","not-run":"never ran",partial:"",receipt:""},p_t=1e3;function m_t(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,p_t);return()=>window.clearInterval(i)},[e]),t}const g_t=({outcome:e,deliveryState:t=null,durationS:n,startedAt:r})=>{const i=e==="running",a=m_t(i?r??null:null),o=e==="error"||e==="not-run",s=e==="partial",l=t?F2e[t]:void 0,c=s?l??null:o?l??g2[e]:null,O=j("font-medium text-meta",s?"text-warning":"text-danger",s&&"hidden @[19rem]/toolrow:inline"),d=s&&t?K2e[t]??null:null,f=s&&t?B2e[t]:void 0,p=s?t==="mailbox"?u_t:t==="unconfirmed"?O_t:null:e==="interrupted"?c_t:null,m=p&&s?"text-warning":"text-ink-dim",g=i?r==null?"":Gl(a??0):q6(n);return h.jsxs("span",{className:j("flex shrink-0 items-center gap-1.5"),children:[c?h.jsx("span",{className:O,title:f,"aria-hidden":d?!0:void 0,children:c}):null,h.jsxs("span",{className:j("flex shrink-0 [&_svg]:size-3.5",p&&"size-3.5",m),children:[p?h.jsx(p,{"aria-hidden":!0}):null,!o&&g2[e]?h.jsx("span",{className:j("sr-only"),children:g2[e]}):null,d?h.jsx("span",{className:j("sr-only"),children:d}):null]}),h.jsx("span",{className:j("hidden w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums @[19rem]/toolrow:inline"),children:g})]})},lO=({toolName:e,op:t="",verbless:n=!1,summary:r,summaryFallback:i=null,summaryHold:a=!1,outcome:o,deliveryState:s=null,durationS:l,startedAt:c=null,added:u=0,removed:O=0,details:d,defaultOpen:f=!1,className:p,media:m})=>{const g=o==="running",y=o==="error",v=l_t(e),S=Vd(e),{verb:x,object:b}=Ioe(e,r,i,g,t,eXe(s)),w=h.jsxs("span",{className:j("flex min-w-0 flex-1 items-center gap-2"),children:[h.jsx("span",{"aria-hidden":!0,className:j("flex size-3.5 shrink-0 [&_svg]:size-3.5",d_t(o,e)),children:h.jsx(v,{})}),n?null:h.jsx("span",{"data-trace-verb":"",className:j("shrink-0 whitespace-nowrap text-body-sm",f_t(o)),title:S,children:x}),h.jsx("span",{className:j("min-w-0 flex-1 truncate font-mono text-ink-muted text-mono-sm"),title:a?void 0:b,children:a?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-ink-dim","data-label-hold":"true","aria-hidden":!0,children:"…"}),h.jsx("span",{className:j("sr-only"),children:"pending"})]}):b}),h.jsx(h_t,{added:u,removed:O}),h.jsx(g_t,{outcome:o,deliveryState:s,durationS:l,startedAt:c})]}),Q=g?"bg-elevated":y?"bg-danger-wash":"hover:bg-row-hover",k=d?h.jsx(Pa,{summary:w,chevron:"leading",defaultOpen:f,className:j("@container/toolrow",p),rowClassName:NB,triggerClassName:j("-mx-2 rounded-sm px-2",Q),children:d}):h.jsx(Pa,{disabled:!0,summary:w,rowClassName:NB,className:j("@container/toolrow",(g||y)&&j("-mx-2 rounded-sm px-2",Q),p)});return m?h.jsxs("div",{className:j("flex flex-col"),children:[k,m]}):k},$_t=3,F1e=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},$C=e=>{const t=new Map;let n=0;for(const a of e){const o=F1e(a.name);o===null?n+=1:t.set(o,(t.get(o)??0)+1)}if(n>0||t.size>2){const a=b_t(w_t(e));return{units:a.length===0?[`${e.length} actions`]:a,prose:!1}}const r=["files","searches","web","commands","edits","delegated"],i=[];for(const a of r){const o=t.get(a)??0;o!==0&&(a==="files"&&i.push(`Explored ${o} file${o===1?"":"s"}`),a==="searches"&&i.push(`${o} search${o===1?"":"es"}`),a==="web"&&i.push(`Searched the web ${o} time${o===1?"":"s"}`),a==="commands"&&i.push(`Ran ${o} command${o===1?"":"s"}`),a==="edits"&&i.push(`Edited ${o} file${o===1?"":"s"}`),a==="delegated"&&i.push(`Delegated ${o} task${o===1?"":"s"}`))}return i.length===0?{units:[`${e.length} actions`],prose:!0}:{units:[i.length===1?i[0]:`${i[0]}, ${i[1].charAt(0).toLowerCase()}${i[1].slice(1)}`],prose:!0}},y_t=e=>$C(e).units;function v_t(e){return y_t(e).join(" · ")}const GB={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",plural:"jobs"},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"}},$2=5,b_t=e=>{if(e.length<=$2)return e.map(r=>r.label);const t=e.slice(0,$2),n=e.slice($2).reduce((r,i)=>r+i.count,0);return[...t.map(r=>r.label),`and ${n} other action${n===1?"":"s"}`]},w_t=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=F1e(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",GB.todo);else{const u=GB[l];if(u)n(`kind:${l}`,u);else{const O=Vd(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({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]of o)i.push({label:a(s.count,s.kind),count:s.count});return i};function S_t(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 x_t(e){let t=null,n=null,r=!1;for(const i of e){i.running===!0&&(r=!0);const a=S_t(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 Q_t(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.executing===!0)return Ioe(n.name,n.summary??"",null,!0,n.op)}return null}function k_t(e,t){const n=[];let r=[];const i=()=>{if(r.length===0)return;const a=r.filter(s=>t.isReceipt?.(s)),o=r.filter(s=>t.isFoldable(s)).map(s=>{const l={name:t.nameOf(s),failed:t.failedOf(s),durationS:t.durationOf?t.durationOf(s):null,startedAtMs:t.startedAtOf?t.startedAtOf(s):null,endedAtMs:t.endedAtOf?t.endedAtOf(s):null};return t.summaryOf&&(l.summary=t.summaryOf(s)),t.opOf&&(l.op=t.opOf(s)),t.runningOf&&(l.running=t.runningOf(s)),t.executingOf&&(l.executing=t.executingOf(s)),l});if(o.length>=$_t)n.push({kind:"run",id:r[0].record.id,gap:r[0].gap,rows:r,actions:o,summary:{...$C(o),units:[...$C(o).units,...t.receiptSummaryOf?.(a)??[]]},failedCount:o.filter(s=>s.failed).length,span:x_t(o),live:Q_t(o)});else for(const s of r)n.push({kind:"row",row:s});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}const IB=e=>{const t=[];for(const n of e)if(!(n.record.kind!=="tool"&&!(n.record.kind==="custom"&&n.record.customType==="hub_message")))for(const r of n.record.images??[])lQ(r)&&t.push(r);return t},u1=5,P_t=(e,{uncapped:t=!1}={})=>t?{shown:Math.max(e,0),more:0}:e<u1?{shown:Math.max(e,0),more:0}:{shown:u1-1,more:e-(u1-1)},T_t=e=>{const t=u1-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},GS=e=>e<=0?null:`${e} image${e===1?"":"s"}`;function IS(e){return e.record.kind==="tool"?e.record.durationS:null}function yC(e){let t=null;for(const n of e){const r=IS(n);typeof r=="number"&&(t=(t??0)+r)}return t}function __t(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 X_t="min-h-5 py-0",R_t=1e3;function E_t(e){const[t,n]=$.useState(()=>Date.now());return $.useEffect(()=>{if(!e)return;const r=()=>n(Date.now());r();const i=window.setInterval(r,R_t);return()=>window.clearInterval(i)},[e]),t}const q_t=({summary:e,actionCount:t,span:n,live:r,open:i,onOpenChange:a,className:o,condensedMedia:s,mediaCount:l=0,recordIds:c,children:u})=>{const O=E_t(n?.running===!0),d=n===null?null:Math.max(0,((n.running?O:n.endedAtMs??O)-n.startedAtMs)/1e3),f=d===null?"":q6(d),p=$.useRef(null),m=()=>{p.current?.querySelector("button[aria-expanded]")?.focus(),a(!0)};return h.jsxs("div",{ref:p,className:o,"data-fold-ids":c.join(" "),children:[h.jsx(Pa,{animate:i||!s,open:i,onOpenChange:a,rowClassName:X_t,triggerClassName:j("-mx-2 rounded-sm px-2","hover:bg-row-hover"),summary:h.jsxs("span",{className:j("flex min-w-0 flex-1 items-center gap-2"),children:[r!==null&&!i&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{"data-fold-live":"",className:j("min-w-0 shrink-[100000] truncate"),title:`${r.verb} ${r.object}`,children:[h.jsx("span",{className:j("text-accent"),children:r.verb})," ",h.jsx("span",{className:j("font-mono text-mono-sm text-ink-muted"),children:r.object})]}),h.jsx("span",{"aria-hidden":!0,className:j("text-ink-dim text-meta"),children:"·"})]}),h.jsx("span",{className:j("min-w-0 break-words text-body-sm text-ink-muted"),title:`${t} actions`,"data-fold-summary":"",children:e.units.map((g,y)=>h.jsxs($.Fragment,{children:[y>0&&h.jsx("span",{"aria-hidden":"true",children:" · "}),h.jsx("span",{className:j(e.prose?"whitespace-normal":"whitespace-nowrap"),children:g})]},g))}),GS(l)!==null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":!0,className:j("text-ink-dim text-meta"),children:"·"}),h.jsx("span",{className:j("shrink-0 text-ink-muted text-meta"),children:GS(l)})]}),f!==""&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":!0,className:j("text-ink-dim text-meta"),children:"·"}),h.jsx("span",{"data-fold-span":"",className:j("shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:f})]})]}),children:h.jsx("div",{className:j("flex flex-col"),children:u})}),!i&&s&&s(m)]})},j_t="min-h-5 py-0",wg=()=>h.jsx("span",{"aria-hidden":!0,className:j("text-ink-dim text-meta"),children:"·"}),C_t=({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:f,condensedMedia:p,mediaCount:m=0,group:g=null})=>{const y=o?`${a}+ actions`:a===1?"1 action":`${a} actions`,v=`At least ${a===1?"1 action":`${a} actions`} — earlier rows of this turn are not loaded`,S=g===null?null:`At least ${g.count} messages — earlier rows are not loaded`,x=$.useRef(null),b=()=>{x.current?.querySelector("button[aria-expanded]")?.focus(),d(!0)};return h.jsxs("div",{ref:x,className:j("border-b border-hairline pb-3",r),"data-turn-summary":"","data-run-ids":e.join(" "),"data-segment-ids":t?.join(" "),"data-segment-complete":u?"true":void 0,"data-record-id":n,children:[h.jsx(Pa,{open:O,onOpenChange:d,chevron:"trailing",rowClassName:j_t,triggerClassName:j("-ml-2 -mr-2 w-[calc(100%+1rem)] rounded-sm pl-2 pr-6","hover:bg-row-hover"),chevronClassName:j("-mr-6","text-ink-muted"),summary:h.jsxs("span",{className:j("flex min-w-0 flex-1 items-center gap-2"),title:s??void 0,children:[c!==null&&h.jsx("span",{className:j("shrink-0 text-body-sm text-ink-muted"),"data-segment-label":"",children:c}),u&&h.jsx(h.Fragment,{children:h.jsx(k6,{"aria-hidden":!0,className:j("size-3.5 shrink-0 text-success")})}),g!==null?h.jsxs(h.Fragment,{children:[c!==null&&h.jsx(wg,{}),h.jsx("span",{className:j("shrink-0 text-body-sm text-ink-muted"),title:o?S??void 0:void 0,"aria-label":o?S??void 0:void 0,children:o?`${g.count}+`:`${g.count}`}),g.spanS!==null&&h.jsxs(h.Fragment,{children:[h.jsx(wg,{}),h.jsx("span",{className:j("shrink-0 text-body-sm text-ink-muted"),children:Gl(g.spanS)})]})]}):h.jsxs(h.Fragment,{children:[c!==null&&(i!==null||a>0)&&h.jsx(wg,{}),i!==null&&h.jsxs("span",{className:j("shrink-0 text-body-sm text-ink-muted"),children:["Took ",Gl(i)]}),i!==null&&a>0&&h.jsx(wg,{}),a>0&&h.jsx("span",{className:j("shrink-0 text-body-sm text-ink-muted"),title:o?v:void 0,"aria-label":o?v:void 0,children:y})]}),GS(m)!==null&&h.jsxs(h.Fragment,{children:[h.jsx(wg,{}),h.jsx("span",{className:j("shrink-0 text-body-sm text-ink-muted"),children:GS(m)})]}),u&&h.jsx("span",{className:j("sr-only"),children:"completed"}),l!==null&&h.jsx("span",{className:j("ml-auto"),children:h.jsx(Z1e,{timestamp:l,scope:"answer"})})]}),children:h.jsx("div",{className:j("flex flex-col"),children:f})}),!O&&p&&h.jsx("div",{className:j("pb-2"),children:p(b)})]})},ZB=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],z_t=80,A_t=1e3,U_t=({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=kz("(prefers-reduced-motion: reduce)"),f=$.useRef(n??Date.now()),p=$.useRef(t),m=$.useRef(n);if(p.current!==t)p.current=t,m.current=n,f.current=n??Date.now(),c&&u(!1),l(0);else if(m.current!==n){const v=m.current!==void 0&&n===void 0;m.current=n,u(v),v||(f.current=n,l(Math.floor((Date.now()-n)/1e3)))}const g=$.useRef(r!==!1),y=$.useRef(t);return $.useEffect(()=>{const v=r!==!1,S=g.current,x=y.current===t;g.current=v,y.current=t,!S&&v&&x&&l(Math.floor((Date.now()-f.current)/1e3))},[r,t]),$.useEffect(()=>{const v=O?window.setInterval(()=>l(Math.floor((Date.now()-f.current)/1e3)),A_t):null;if(d)return o(0),()=>{v!==null&&window.clearInterval(v)};const S=window.setInterval(()=>o(x=>(x+1)%ZB.length),z_t);return()=>{window.clearInterval(S),v!==null&&window.clearInterval(v)}},[d,O]),h.jsxs("div",{className:j("flex items-center gap-2",i),"data-lo-working-line":!0,"aria-live":"polite",children:[h.jsx("span",{"aria-hidden":!0,className:j("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:ZB[a]}),h.jsx("span",{className:j("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),h.jsx("span",{"aria-hidden":!0,className:j("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:O?Gl(s):""})]})},B1e="lo-missing-session-notice",W_t=/^\s*<reply-to>([\s\S]*?)<\/reply-to>/,Q8=e=>{const t=[];let n=e;for(;;){const r=W_t.exec(n);if(r===null)break;t.push({id:is(),text:r[1]}),n=n.slice(r[0].length)}return{replies:t,remainingContent:n.trim()}},Y$=({children:e,className:t,boundary:n="hairline",...r})=>h.jsx("div",{className:j("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}),N_t="could not be displayed. It may have been moved, renamed, or deleted.",k8="could not be displayed. Its stored copy is not available to this reader.",Y_t="could not be played. Its stored copy is not available to this reader.",G$=({name:e,detail:t=N_t,className:n,compact:r=!1})=>r?h.jsx("div",{className:j("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:h.jsx(JN,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0})}):h.jsxs("div",{className:j("flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2",n),children:[h.jsx(JN,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),h.jsxs("span",{className:"min-w-0 text-body-sm text-ink-muted",children:[h.jsx("span",{className:"truncate font-mono text-ink text-mono-sm",children:e}),` ${t}`]})]}),dd=1,H1e=4,DB=(e,t)=>Math.min(H1e,Math.max(dd,e+t)),Sg=Object.freeze({x:0,y:0}),y2=(e,t)=>t<=0?0:Math.min(t-1,Math.max(0,Math.trunc(e))),v2=(e,t,n)=>t<=0?0:((e+n)%t+t)%t,G_t=(e,t)=>`Image ${e+1} of ${t}`,VB=(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))}},I_t="max-h-[min(90vh,calc(100vh-104px))] max-w-[min(90vw,calc(100vw-104px))]",Z_t="max-h-[min(90vh,calc(100vh-208px))] max-w-[min(90vw,calc(100vw-104px))]",MB=e=>j(e,"flex min-h-16 min-w-64 items-center justify-center p-6"),D_t="opacity-45",P8=({src:e,label:t,open:n,onOpenChange:r,restoreFocusTo:i,fallback:a,pending:o=!1,group:s,layerRef:l})=>{const[c,u]=$.useState(null),O=e!==void 0&&c===e,[d,f]=$.useState(dd),[p,m]=$.useState(Sg),g=$.useRef(e);$.useLayoutEffect(()=>{g.current!==e&&(g.current=e,f(dd),m(Sg))},[e]);const[y,v]=$.useState(!0),S=$.useRef(null);$.useEffect(()=>{if(!n)return;let A;const ee=()=>{clearTimeout(A),A=setTimeout(()=>{const B=S.current;if(B&&(B.matches(":hover")||B.contains(document.activeElement))){ee();return}v(!1)},lue)},L=()=>{v(!0),ee()};return v(!0),ee(),document.addEventListener("pointermove",L,{passive:!0}),document.addEventListener("pointerdown",L,{passive:!0}),document.addEventListener("keydown",L),document.addEventListener("focusin",L),()=>{clearTimeout(A),document.removeEventListener("pointermove",L),document.removeEventListener("pointerdown",L),document.removeEventListener("keydown",L),document.removeEventListener("focusin",L)}},[n]);const x=s?.onPrev,b=s?.onNext,w=s!==void 0&&s.count>1,Q=w?Z_t:I_t,k=$.useRef(null),_=l??k;$.useEffect(()=>{if(!n||!w)return;const A=ee=>{ee.defaultPrevented||ee.metaKey||ee.ctrlKey||ee.altKey||(ee.key==="ArrowLeft"?(ee.preventDefault(),x?.()):ee.key==="ArrowRight"&&(ee.preventDefault(),b?.()))};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[n,w,x,b]),y6(n,"image-lightbox");const T=$.useRef(null),E=e!==void 0&&!O,R=d===dd&&p.x===Sg.x&&p.y===Sg.y,q=A=>{if(!E)return;f(A);const ee=T.current;ee&&m(L=>VB(L,{width:ee.clientWidth,height:ee.clientHeight},A))},z=()=>{E&&(f(dd),m(Sg))},W=$.useRef(null),[I,N]=$.useState(!1),Z=E&&d>dd,G=A=>{!Z||A.button!==0||(A.currentTarget.setPointerCapture(A.pointerId),W.current={pointerId:A.pointerId,startX:A.clientX,startY:A.clientY,pan:p},N(!0))},U=A=>{const ee=W.current,L=T.current;!ee||ee.pointerId!==A.pointerId||!L||m(VB({x:ee.pan.x+(A.clientX-ee.startX),y:ee.pan.y+(A.clientY-ee.startY)},{width:L.clientWidth,height:L.clientHeight},d))},K=A=>{W.current?.pointerId===A.pointerId&&(W.current=null,N(!1))},J=e!==void 0&&!O?h.jsx("div",{ref:T,"data-image-viewport":"",tabIndex:-1,className:j(Q,"relative h-fit w-fit overflow-hidden leading-none outline-none",Z&&(I?"cursor-grabbing":"cursor-grab"),Z&&"touch-none"),onPointerDown:G,onPointerMove:U,onPointerUp:K,onPointerCancel:K,children:h.jsx("img",{src:e,alt:t,draggable:!1,className:j(Q,"block select-none object-contain"),style:R?void 0:{transform:`translate(${p.x}px, ${p.y}px) scale(${d})`},onError:()=>u(e)})}):e===void 0&&o?h.jsx("div",{className:MB(Q),"aria-hidden":"true"}):h.jsx("div",{className:MB(Q),children:a});return h.jsx(v6,{open:n,onOpenChange:r,children:h.jsxs(b6,{ref:_,tabIndex:-1,onOpenAutoFocus:A=>{A.preventDefault(),(T.current??_.current)?.focus()},showClose:!1,"aria-describedby":void 0,onCloseAutoFocus:A=>{const ee=i?.current;ee&&(A.preventDefault(),ee.focus())},className:j("inset-0 top-0 left-0 m-auto h-fit w-fit translate-none outline-none",Q,"gap-0 rounded-none border-0 border-transparent bg-transparent p-0 shadow-none"),children:[h.jsx(w6,{className:"sr-only",children:t}),w&&s?h.jsx("div",{"aria-live":"polite",className:"sr-only",children:G_t(s.index,s.count)}):null,J,h.jsxs("div",{ref:S,"data-image-viewer-controls":"",className:j("pointer-events-none fixed inset-0 transition-opacity ease-out-quart",y?"opacity-100 duration-fast":`${D_t} duration-base`),children:[w&&s?.filmstrip?h.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,w?h.jsxs(h.Fragment,{children:[h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Previous image",title:"Previous image",onClick:s?.onPrev,className:"pointer-events-auto fixed top-0 bottom-0 left-4 my-auto","data-image-viewer-prev":"",children:h.jsx(OCe,{"aria-hidden":"true"})}),h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Next image",title:"Next image",onClick:s?.onNext,className:"pointer-events-auto fixed top-0 right-4 bottom-0 my-auto","data-image-viewer-next":"",children:h.jsx(moe,{"aria-hidden":"true"})})]}):null,h.jsxs("div",{className:"pointer-events-auto fixed right-4 bottom-4 flex items-center gap-1",children:[h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",title:"Zoom out",disabled:!E||d===dd,onClick:()=>q(DB(d,-1)),children:h.jsx(Nle,{"aria-hidden":"true"})}),h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",title:"Zoom in",disabled:!E||d===H1e,onClick:()=>q(DB(d,1)),children:h.jsx(Wle,{"aria-hidden":"true"})}),h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",title:"Reset view",disabled:!E||R,onClick:z,children:h.jsx(vQ,{"aria-hidden":"true"})})]}),h.jsx(P_e,{asChild:!0,children:h.jsx(je,{variant:"ghost",size:"icon-sm",className:j("pointer-events-auto fixed top-4 right-4"),"aria-label":"Close image",title:"Close image",children:h.jsx(Zi,{"aria-hidden":"true"})})})]})]})})};P8.displayName="ImageLightbox";const V_t={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(" ")},M_t=/[/\\]/,LB=e=>{const t=e.split(M_t);return t[t.length-1]},K1e=$.memo(({file:e,src:t,conversationId:n,label:r,size:i="full",overlay:a,press:o})=>{const[s,l]=$.useState(!1),[c,u]=$.useState(!1),[O,d]=$.useState(!1),f=$.useRef(null),p=Kn(_=>_.setCanvasOpen),{setViewMode:m}=bd(),g=$.useCallback(async()=>{const _=LB(e),T=z=>{z&&console.error("Error processing file:",z);const W=e.startsWith("file://")?e.substring(7):e;window.api.openFile(W).catch(I=>{console.error("Error opening file:",I)})},{setFiles:E,setOpenTabs:R,setSelectedTab:q}=bd.getState();if(e.startsWith("data:"))if(oC(_)){const z=e,W={id:z,title:_,path:z,content:e,type:F1(e)},N=bd.getState().conversations?.[n],Z=N?.files??[],G=N?.openTabs??[],U=(()=>{const A=Z.findIndex(ee=>ee.id===z);return A!==-1?[...Z.slice(0,A),W,...Z.slice(A+1)]:[...Z,W]})();E(n,U);const J=G.some(A=>A.id===z)?G:[...G,{id:z,title:_}];R(n,J),q(n,z),p(!0),m(n,"documents")}else p(!0),m(n,"files");else{const z=e.startsWith("file://")?e.substring(7):e;try{const W=await window.api.readFile(z);if(W.success&&oC(_)){const I=z,N={id:I,title:_,path:z,content:W.data,type:F1(e)},G=bd.getState().conversations?.[n],U=G?.files??[],K=G?.openTabs??[],J=(()=>{const L=U.findIndex(B=>B.id===I);return L!==-1?[...U.slice(0,L),N,...U.slice(L+1)]:[...U,N]})();E(n,J);const ee=K.some(L=>L.id===I)?K:[...K,{id:I,title:_}];R(n,ee),q(n,I),p(!0),m(n,"documents");return}p(!0),m(n,"files")}catch(W){const I=W instanceof Error?W.message:String(W??"Unknown error reading file");return T(I)}}},[e,p,m,n]),y=()=>{l(!0)},v=w1e(e),x=(v==="path"||v==="data")&&n!=="",b=x1e(v,{canShowInCanvas:x,source:t}),w=v==="path",Q=r??LB(e);if(s)return h.jsx(G$,{name:Q,compact:i==="thumbnail"});const k=h.jsx(Y$,{boundary:i==="thumbnail"?"control":"hairline",children:h.jsx("img",{className:j(V_t[i],c?"opacity-100":"opacity-0"),src:t,alt:Q,onLoad:()=>u(!0),onError:y})});return h.jsxs("div",{className:"group relative inline-block",children:[h.jsx("button",{ref:f,type:"button",className:j("block max-w-full cursor-pointer",i==="thumbnail"&&"group/tile rounded-sm"),onClick:o?o.onPress:()=>d(!0),"aria-label":o?o.label:`Expand ${Q}`,title:o?o.title:`Click to expand ${Q}`,"aria-current":o?.current?"true":void 0,children:k}),b&&h.jsx("div",{className:"file-actions-menu pointer-events-none absolute top-1 right-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:_=>{_.stopPropagation()},onKeyDown:_=>_.stopPropagation(),children:h.jsx(R1e,{file:e,src:t,label:Q,onShowInCanvas:x?g:void 0})}),o?null:a?a({open:O,onOpenChange:d,restoreFocusTo:f}):h.jsx(P8,{src:t,label:Q,open:O,onOpenChange:d,restoreFocusTo:f,fallback:h.jsx(G$,{name:Q,detail:w?void 0:k8})})]})});K1e.displayName="ImageAttachment";const L_t=(e,t,n)=>e.name??(n===1?"Image":`Image ${t+1}`),F_t={id:"image-group:empty",data:null,attachment:null,mimeType:"image/png"},B_t=({cold:e,children:t})=>e?h.jsx("div",{className:"flex h-[79px] w-[117px] items-start leading-none",children:t}):t,H_t=({images:e,index:t,scope:n,open:r,onOpenChange:i,restoreFocusTo:a,labelFor:o=L_t})=>{const s=e.length,[l,c]=$.useState(()=>y2(t,s)),[u,O]=$.useState(r);u!==r&&(O(r),r&&c(y2(t,s)));const d=y2(l,s),f=e[d]??F_t,p=o(f,d,s),m=X1e(f,n),g=$.useRef(null),y=$.useRef(null),[v,S]=$.useState(!1),x=$.useCallback(N=>{g.current=N,S(N!==null)},[]),b=N=>{const Z=g.current?.querySelector(`button[aria-label="Show image ${N+1} of ${s}"]`);Z?Z.focus():y.current?.focus()},w=N=>{const Z=v2(d,s,N),G=g.current?.contains(document.activeElement)??!1;c(Z),G&&b(Z)},Q=()=>w(-1),k=()=>w(1),_=JSON.stringify([n?.sessionId,n?.childId,e.map(N=>[N.id,N.attachment,N.mimeType])]),[T,E]=$.useState(()=>({identity:_,open:r,indices:new Set}));(T.identity!==_||T.open!==r)&&E({identity:_,open:r,indices:new Set});const R=$.useCallback(N=>{E(Z=>{if(!r||Z.identity!==_||!Z.open||N.every(U=>Z.indices.has(U)))return Z;const G=new Set(Z.indices);for(const U of N)G.add(U);return{...Z,indices:G}})},[_,r]),q=v2(d,s,-1),z=v2(d,s,1);$.useEffect(()=>{r&&R([d,q,z])},[r,d,q,z,R]),$.useEffect(()=>{const N=g.current;if(!r||!v||!N||typeof IntersectionObserver>"u")return;let Z=!0;const G=new IntersectionObserver(U=>{Z&&R(U.filter(K=>K.isIntersecting).map(K=>Number(K.target.dataset.imageSlot)-1))},{root:N});for(const U of N.querySelectorAll("[data-image-slot]"))G.observe(U);return()=>{Z=!1,G.disconnect()}},[r,v,R]);const W=(N,Z)=>!!N.data||!N.attachment||Z===d||Z===q||Z===z||T.identity===_&&T.open&&T.indices.has(Z);$.useEffect(()=>{(g.current?.querySelector(`[data-image-slot="${d+1}"]`)??g.current)?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[v,d]);const I=s>1?h.jsx("ul",{role:"list",ref:x,"aria-label":`${s} images`,"data-image-filmstrip":"",className:"flex max-w-full items-center gap-2 overflow-x-auto px-2 py-1 leading-none",children:e.map((N,Z)=>h.jsx("li",{"data-image-slot":Z+1,className:j("flex shrink-0 scroll-mx-px rounded-sm leading-none",Z===d&&"ring-1 ring-ink"),children:h.jsx(B_t,{cold:!!N.attachment&&!N.data,children:W(N,Z)?h.jsx(xm,{image:N,scope:n,size:"thumbnail",label:o(N,Z,s),press:{onPress:()=>c(Z),label:`Show image ${Z+1} of ${s}`,title:`Show image ${Z+1} of ${s}`,current:Z===d}}):h.jsx("button",{type:"button","aria-label":`Show image ${Z+1} of ${s}`,title:`Show image ${Z+1} of ${s}`,className:"group/tile inline-block max-w-full cursor-zoom-in rounded-sm leading-none",onClick:()=>{R([Z]),c(Z)},children:h.jsx(Y$,{boundary:"control",className:"h-[78px] w-[117px]","data-attachment-reserved":"","data-attachment-deferred":""})})})},N.id))}):void 0;return h.jsx(P8,{src:m.state==="ready"?m.url:void 0,pending:m.state==="resolving",label:p,open:r,onOpenChange:i,restoreFocusTo:a,fallback:h.jsx(G$,{name:p,detail:k8}),layerRef:y,group:{index:d,count:s,onPrev:Q,onNext:k,filmstrip:I}})},xm=({image:e,scope:t,label:n,size:r,group:i,press:a})=>{const o=X1e(e,t);if(o.state==="resolving"){const l=h.jsx(Y$,{boundary:r==="thumbnail"?"control":"hairline",className:r==="thumbnail"?"h-[78px] w-[117px]":void 0,"data-attachment-reserved":""});return a?h.jsx("button",{type:"button","aria-label":a.label,title:a.title,"aria-current":a.current||void 0,className:"group/tile inline-block max-w-full cursor-zoom-in rounded-sm leading-none",onClick:a.onPress,children:l}):h.jsx("div",{className:j("inline-block max-w-full"),"aria-hidden":!0,children:l})}if(o.state==="missing")return h.jsx(G$,{name:n,compact:r==="thumbnail",detail:k8});const s=o.url;return h.jsx("div",{className:j("inline-block max-w-full"),children:h.jsx(K1e,{file:s,src:s,label:n,size:r,conversationId:t?.sessionId??"",press:a,overlay:i?l=>h.jsx(H_t,{images:i.images,index:i.index,labelFor:i.labelFor,scope:t,open:l.open,onOpenChange:l.onOpenChange,restoreFocusTo:l.restoreFocusTo}):void 0})})},K_t="Generating name…",J_t={rest:"scale-x-60 bg-ink-dim",preview:"scale-x-90 bg-ink-muted",active:"scale-x-100 bg-ink",unloaded:"scale-x-40 bg-ink-dim opacity-75"};function e2t(e){return e.id===e.activeId?"active":e.id===e.previewId?"preview":e.loaded===!1?"unloaded":"rest"}function T8(e,t){return`Turn ${e} of ${t}`}const t2t=e=>e.charAt(0).toLowerCase()+e.slice(1);function n2t(e,t){const n=T8(e.turn,t),r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`${n} · ${r}`:n}function r2t(e){return e.kind==="completion"&&e.naming?.state==="pending"}function i2t(e){const t=e.naming?.state==="ready"?e.naming.summary:null;return t?.trim()?t:null}function a2t(e){let t=0;for(const n of e)n.turn>t&&(t=n.turn);return t}const o2t={complete:"Complete",error:"Error",interrupted:"Interrupted",open:"Open"};function s2t(e){if(!Number.isFinite(e)||e<=0)return"";const t=new Date(e*1e3);if(Number.isNaN(t.getTime()))return"";const n=t.getHours(),r=t.getMinutes().toString().padStart(2,"0"),i=n%12===0?12:n%12,a=n<12?"AM":"PM";return`${i}:${r} ${a}`}function l2t(e,t){const n=t2t(T8(e.turn,t));if(e.kind==="user"){const i=s2t(e.ts);return i?`Jump to your message in ${n}, ${i}`:`Jump to your message in ${n}`}const r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`Jump to ${n}, ${r}`:`Jump to ${n}`}function c2t(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 b2(e,t){const n=[];for(const r of t)c2t(e,r)==="pending"&&n.push(r);return n}const u2t=120,FB=80,O2t="Turn checkpoints",d2t={complete:Ou,error:ip,interrupted:uz,open:yCe},f2t={complete:"text-success",error:"text-danger",interrupted:"text-warning",open:"text-ink-dim"},h2t=({checkpoint:e,turnCount:t})=>{const n=e.outcome,r=n?d2t[n]:null,i=i2t(e),a=e.naming?.state==="ready"?e.naming.name?.trim():"";return h.jsxs(h.Fragment,{children:[h.jsxs("p",{className:j("text-body-sm font-medium text-ink"),children:[T8(e.turn,t),a&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",children:" · "}),h.jsx("span",{className:j("font-normal text-ink-muted"),children:a})]})]}),r2t(e)&&h.jsx("p",{className:j("text-ink-dim text-meta"),children:K_t}),i&&h.jsx("p",{className:j("line-clamp-2 break-words text-body-sm text-ink-muted"),children:i}),n&&r&&h.jsx("div",{className:j("flex items-center gap-1.5 text-ink-dim text-meta"),children:h.jsxs("span",{className:j("flex items-center gap-1",f2t[n]),children:[h.jsx(r,{"aria-hidden":"true",className:j("size-3.5 shrink-0")}),o2t[n]]})})]})},p2t=$.memo(function({checkpoint:t,state:n,label:r,roving:i,registerTick:a,onPreview:o,onPreviewEnd:s,onFocusMark:l,onBlurMark:c,onActivate:u,onKeyMark:O,describedBy:d}){const f=p=>{p.pointerType!=="touch"&&o(t.id)};return h.jsx("button",{ref:p=>a(t.id,p),type:"button","data-checkpoint-id":t.id,"data-mark-state":n,"aria-label":r,"aria-describedby":d,tabIndex:i?0:-1,className:j("group pointer-events-auto block h-2.5 w-7"),onPointerMove:f,onPointerLeave:s,onFocus:()=>l(t.id),onBlur:c,onClick:()=>u(t.id),onKeyDown:p=>O(p,t.id),children:h.jsx("span",{"aria-hidden":"true",className:j("ml-auto mr-1.5 block h-0.5 w-5 origin-right rounded-full","transition-[transform,background-color] duration-fast ease-out-quart","motion-reduce:transition-none",J_t[n])})})}),m2t=({sessionId:e,checkpoints:t,onJump:n,onHover:r,building:i=!1,loadedIds:a,activeId:o=null})=>{const s=$.useId(),[l,c]=$.useState(null),[u,O]=$.useState(null),[d,f]=$.useState(null),p=$.useRef(t);p.current=t;const m=$.useRef(new Map),g=$.useRef(null),y=$.useRef(null),v=$.useRef(null),S=$.useCallback(()=>{y.current!==null&&(clearTimeout(y.current),y.current=null),v.current!==null&&(clearTimeout(v.current),v.current=null)},[]),x=$.useCallback((M,H)=>{S();const ne=()=>{O(M),f(p.current.find(ue=>ue.id===M)??null)};if(H<=0){ne();return}y.current=setTimeout(()=>{y.current=null,ne()},H)},[S]),b=$.useCallback(M=>{if(S(),M<=0){O(null);return}v.current=setTimeout(()=>{v.current=null,O(null)},M)},[S]),w=$.useRef(e);$.useEffect(()=>{w.current!==e&&(w.current=e,S(),K.current=null,c(null),O(null),f(null))},[e,S]);const Q=$.useRef(null);$.useLayoutEffect(()=>{const M=g.current;if(!(t.length===0||M===null)){if(o!==null&&k.current===e){Q.current=e;return}Q.current!==e&&(Q.current=e,M.scrollTop=M.scrollHeight)}},[o,t.length,e]);const k=$.useRef(null);$.useLayoutEffect(()=>{if(o===null)return;const M=g.current,H=m.current.get(o);if(M===null||H===void 0)return;k.current=e;const ne=M.getBoundingClientRect(),ue=H.getBoundingClientRect(),Oe=ue.top-ne.top+M.scrollTop,Te=Oe+ue.height,xe=24;Oe<M.scrollTop+xe?M.scrollTop=Math.max(0,Oe-xe):Te>M.scrollTop+M.clientHeight-xe&&(M.scrollTop=Te-M.clientHeight+xe)},[o,e]),$.useEffect(()=>()=>S(),[S]);const _=$.useRef(r);$.useEffect(()=>{_.current=r});const T=$.useMemo(()=>a2t(t),[t]),E=$.useMemo(()=>new Map(t.map(M=>[M.id,l2t(M,T)])),[t,T]),R=u&&d?.id===u?d:null,q=u&&m.current.get(u)||null,z=$.useMemo(()=>({current:q}),[q]),W=R!==null&&q!==null;$.useEffect(()=>{_.current(W&&u?u:null)},[W,u]);const I=$.useCallback((M,H)=>{H?m.current.set(M,H):m.current.delete(M)},[]),[N,Z]=$.useState(null),G=N&&t.some(M=>M.id===N)?N:t[0]?.id??null,U=$.useCallback(M=>{const H=Math.max(0,Math.min(t.length-1,M)),ne=t[H];ne&&(Z(ne.id),m.current.get(ne.id)?.focus())},[t]),K=$.useRef(null),J=$.useCallback(M=>{K.current!==M&&(K.current=M,c(M),x(M,u2t))},[x]),A=$.useCallback(()=>{K.current=null,c(M=>M===null?M:null),b(FB)},[b]),ee=$.useCallback(M=>{K.current=M,Z(M),c(H=>H===M?H:M),x(M,0)},[x]),L=$.useCallback(()=>{K.current=null,c(M=>M===null?M:null),b(FB)},[b]),B=$.useCallback(M=>{b(0),K.current=null,c(null),n(M)},[b,n]),ce=$.useCallback((M,H)=>{if(M.key==="Escape"){b(0);return}const ne=t.findIndex(ue=>ue.id===H);if(!(ne<0)){if(M.key==="ArrowDown"){M.preventDefault(),M.stopPropagation(),U(ne+1);return}if(M.key==="ArrowUp"){M.preventDefault(),M.stopPropagation(),U(ne-1);return}if(M.key==="Home"){M.preventDefault(),M.stopPropagation(),U(0);return}M.key==="End"&&(M.preventDefault(),M.stopPropagation(),U(t.length-1))}},[t,b,U]);return t.length===0&&!i?null:h.jsxs("div",{"data-lo-checkpoint-rail":"",role:"toolbar","aria-orientation":"vertical","aria-label":O2t,className:j("pointer-events-none absolute inset-y-0 right-3 z-10 hidden w-7 select-none","flex-col justify-center","@[900px]/chatcol:flex"),children:[h.jsxs("div",{"data-rail-frame":"",ref:g,className:j("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&&h.jsx("span",{"aria-hidden":"true","data-rail-building":"",className:j("ml-auto mr-1.5 block h-0.5 w-5 animate-pulse-visible rounded-full bg-ink-dim")}),h.jsx("div",{"data-rail-track":"",className:"py-6",children:t.map(M=>h.jsx(p2t,{checkpoint:M,state:e2t({id:M.id,previewId:l,activeId:o,loaded:a?a.has(M.id):!0}),label:E.get(M.id)??"",roving:M.id===G,registerTick:I,onPreview:J,onPreviewEnd:A,onFocusMark:ee,onBlurMark:L,onActivate:B,onKeyMark:ce,describedBy:W&&u===M.id?s:void 0},M.id))})]}),h.jsxs(T_e,{open:W,onOpenChange:M=>{M||b(0)},children:[h.jsx(__e,{virtualRef:z}),R&&h.jsx(X_e,{id:s,"data-checkpoint-card":"",side:"left",align:"center",sideOffset:10,collisionPadding:8,role:"tooltip","aria-label":R.kind==="user"?"Your message":n2t(R,T),onOpenAutoFocus:M=>M.preventDefault(),onCloseAutoFocus:M=>M.preventDefault(),onFocusOutside:M=>{const H=M.detail?.originalEvent?.target;H instanceof Element&&H.closest("[data-lo-checkpoint-rail]")&&M.preventDefault()},className:j("pointer-events-none max-h-[176px] w-[300px] max-w-[300px] overflow-hidden","flex flex-col gap-2"),children:R.kind==="user"?h.jsx("div",{"data-checkpoint-card-text":"",className:j("line-clamp-3 break-words whitespace-pre-wrap","text-body-sm text-ink"),children:R.text}):h.jsx(h2t,{checkpoint:R,turnCount:T})})]})]})},g2t=$.memo(m2t);function $2t(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 y2t=(e,t,n)=>(e.getAttribute(t)??"").split(" ").includes(n);function v2t(e,t){return e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`)!==null}function J1e(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):!y2t(a,i,t))continue;if(a.querySelector("button[aria-expanded]")?.getAttribute("aria-expanded")==="false")return a}return null}function b2t(e,t){return v2t(e,t)||J1e(e,t)!==null}const w2t=3;function S2t(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>=w2t){n.onMissing();return}const s=J1e(e,t)?.querySelector("button[aria-expanded]");if(!s){n.onMissing();return}s.click(),window.requestAnimationFrame(()=>{r(i+1)})};r(0)}const BB=(e,t,n)=>n===1?"Image":`Image ${t+1}`,HB=({images:e,scope:t,onRevealMore:n,uncapped:r=!1,indent:i="content"})=>{const{shown:a,more:o}=P_t(e.length,{uncapped:r}),s=T_t(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)=>h.jsx("li",{className:j("flex leading-none",l&&c.has(d)&&"col-start-1"),children:h.jsx(xm,{image:O,scope:t,size:"thumbnail",label:BB(O,d,e.length),group:{images:e,index:d,labelFor:BB}})},O.id));return h.jsxs("ul",{role:"list","aria-label":e.length===1?"1 image from this run":`${e.length} images from this run`,"data-fold-media":"",className:j("mt-2 gap-2",l?"grid grid-cols-[repeat(4,max-content)] items-start":"flex flex-wrap items-center",i==="content"?"ml-5":"ml-0"),children:[u,o>0&&h.jsx("li",{className:j("flex h-[78px] items-center leading-none"),children:h.jsx(je,{variant:"outline",size:"sm",onClick:n,"aria-label":`+${o} more image${o===1?"":"s"}`,title:`+${o} more image${o===1?"":"s"}`,children:`+${o}`})},"fold-media-more")]})};function KB(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 x2t(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 Q2t=({video:e,scope:t,label:n})=>{const r=_1e(e,t),[i,a]=$.useState(!1);return r.state==="missing"||i?h.jsx(G$,{name:n,detail:Y_t}):r.state==="resolving"?h.jsx("div",{className:j("inline-block max-w-full self-start"),"aria-hidden":!0,children:h.jsx(Y$,{"data-attachment-reserved":""})}):h.jsx("div",{className:j("inline-block max-w-full self-start"),children:h.jsx(Y$,{children:h.jsx("video",{controls:!0,preload:"metadata",src:r.url,"aria-label":n,className:j("max-h-[240px] max-w-full object-contain"),onError:()=>a(!0)})})})},eSe="generate_video",k2t=new Set(["generate_image",eSe]);function P2t(e){return k2t.has(e)}function tSe(e){return e===eSe}function T2t(e){return tSe(e)?"video":"image"}function _2t(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 X2t(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:_2t(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 JB(e){return e.fraction===null&&e.logs.length===0&&e.queuePosition===null?nSe:{fraction:e.fraction,logs:e.logs,queuePosition:e.queuePosition}}const nSe=Object.freeze({fraction:null,logs:[],queuePosition:null});function R2t(e,{stopping:t=!1}={}){const n=X2t(e.details),r=T2t(e.toolName);if(e.stopped===!0)return{state:"cancelled"};if(e.notRunKind==="skipped"||e.notRunKind==="aborted")return{state:"cancelled"};if(e.notRunReason)return{state:"failed",material:r,message:e.notRunReason,errorType:null};if(e.neverSent===!0)return{state:"cancelled"};if(e.isError===!0)return n.errorType==="media_already_completed"?{state:"done",images:e.images??[],material:r,durationS:e.durationS??null,receipt:"already-finished"}:n.stage==="cancelled"&&n.errorType===null?{state:"cancelled"}:{state:"failed",material:r,message:n.error??e.output,errorType:n.errorType};switch(e.phase){case"composing":case"queued":return t?{state:"cancelling",generating:!1,startedAtMs:null,progress:nSe}:{state:"queued",composing:e.phase==="composing",argumentBytes:e.argumentBytes??0,queuePosition:n.queuePosition};case"running":{const i=e.startedAt??null;return t?{state:"cancelling",generating:!0,startedAtMs:i,progress:JB(n)}:{state:"running",material:r,startedAtMs:i,progress:JB(n),note:n.error}}case"done":return{state:"done",images:e.images??[],material:r,durationS:e.durationS??null,receipt:"generated"}}}function E2t(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 q2t(e,t){if(!tSe(e))return t?{onCancel:t}:void 0}const j2t=1e3;function C2t(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,j2t);return()=>window.clearInterval(i)},[e]),t}function z2t(){return h.jsx("div",{"aria-hidden":!0,"data-imagegen-tile":"",className:j("relative aspect-[3/2] w-[240px] max-w-full overflow-hidden rounded-sm bg-sunken"),children:h.jsx("span",{className:j("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")})})}function A2t({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?Qw(e.argumentBytes):null;break;case"running":n=e.material==="video"?"Generating video…":"Generating image…",r=t===null?null:Gl(t);break;case"cancelling":n="Cancelling…";break;case"done":n=e.receipt==="already-finished"?"Already finished.":e.material==="video"?"Generated video":"Generated image",r=e.receipt==="already-finished"||e.durationS===null?null:q6(e.durationS);break;case"failed":n=e.message??(e.material==="video"?"The video could not be generated.":"The image could not be generated."),i=!0;break;case"cancelled":n="Cancelled";break}return h.jsxs("p",{className:j("flex min-w-0 items-baseline gap-1.5 text-body-sm"),children:[h.jsx("span",{className:j("min-w-0",i?"text-ink":"text-ink-muted"),children:n}),r===null?null:h.jsxs("span",{className:j("shrink-0 text-meta text-ink-dim"),children:["· ",r]})]})}function U2t({line:e}){return h.jsx("p",{"data-imagegen-log":"",title:e,className:j("min-w-0 truncate font-mono text-mono-sm text-ink-dim"),children:e})}function W2t({line:e}){return h.jsx("p",{"data-imagegen-note":"",className:j("min-w-0 text-body-sm text-ink-dim"),children:e})}function N2t(e,t){return e==="cancel"?"Cancel":e==="restart"?t==="failed"?"Retry":"Restart":"Edit and restart"}const Y2t=({view:e,scope:t,actions:n})=>{const r=e.state==="running"||e.state==="cancelling"?e.startedAtMs:null,i=C2t(r),a=E2t(e,n),o={cancel:n?.onCancel,restart:n?.onRestart,editRestart:n?.onEditRestart},s=e.state==="running"||e.state==="cancelling",l=s&&(e.state==="running"||e.generating),c=s&&e.progress.logs.length>0?e.progress.logs[e.progress.logs.length-1]:null;return h.jsxs("div",{"data-imagegen-card":e.state,className:j("flex w-full flex-col gap-2"),children:[l?h.jsx(z2t,{}):null,h.jsx(A2t,{view:e,elapsed:i}),e.state==="running"&&typeof e.note=="string"?h.jsx(W2t,{line:e.note}):null,l&&e.progress.fraction!==null?h.jsx(R_e,{"aria-label":"Image generation progress",className:j("max-w-[240px]"),value:Math.round(Math.min(1,Math.max(0,e.progress.fraction))*100)}):null,c===null?null:h.jsx(U2t,{line:c}),e.state==="done"&&e.images.length>0?h.jsx("div",{className:j("flex flex-col gap-2"),children:e.images.map((u,O)=>{const d=u.kind==="video"?"Generated video":"Generated image",f=e.images.length===1?d:`${d} ${O+1}`;return u.kind==="video"?h.jsx(Q2t,{video:u,scope:t,label:f},u.id):h.jsx(xm,{image:u,scope:t,label:f},u.id)})}):null,a.length>0?h.jsx("div",{"data-imagegen-controls":"",className:j("flex items-center gap-2"),children:a.map(u=>h.jsx(je,{variant:"secondary",size:"sm",disabled:u.disabled,onClick:o[u.kind],children:N2t(u.kind,e.state)},u.kind))}):null]})},j0=1e4,rSe=/\s/,G2t=e=>{for(let t=e.length;t>0;t-=1){const n=e[t-1];if(n===`
858
858
  `)return t;if(n==="."||n==="!"||n==="?"){const r=e[t];if(r===void 0||rSe.test(r))return t}}return-1},I2t=e=>{for(let t=e.length;t>0;t-=1)if(rSe.test(e[t-1]))return t;return-1},Z2t=/[\uD800-\uDBFF]/,D2t=e=>Z2t.test(e[j0-1])?j0-1:j0;function _8(e){if(e.length<=j0)return{text:e,clipped:!1};const t=e.slice(0,j0),n=G2t(t),r=I2t(t),i=n>0?n:r>0?r:D2t(t),a=e.slice(0,i).trimEnd();return{text:a.length>0?a:t,clipped:!0}}const iSe="[speech]",V2t="Couldn't speak this aloud. Try again.",M2t="Couldn't speak this aloud. Try again.",aSe="This conversation's agent is no longer available.",L2t=new Set(["Your Radient sign-in has stopped working. Sign in again in Settings.","Your Radient credit balance is too low for speech. Add credits in the Radient Console to continue.","Speech is unavailable right now. Try again in a moment.","Speech is temporarily unavailable. Try again in a moment.","Speech is temporarily unavailable.","Sign in to Radient in Settings to enable speaking aloud.",aSe,"ElevenLabs refused your API key. Replace it.","Your ElevenLabs credit balance is too low for speech. Add credits with ElevenLabs to continue.","OpenAI refused your API key. Replace it.","Your OpenAI credit balance is too low for speech. Add credits with OpenAI to continue.","Your Radient sign-in has stopped working. Sign in again in the settings page.","Sign in to Radient in the settings page to enable text to speech."]);function F2t(e){const t=e instanceof Error?e.message:String(e);return L2t.has(t)?t:(console.error(`${iSe} ${t}`),V2t)}function B2t(e){return(e instanceof Error?e.message:String(e))===aSe}function H2t(e){const t=e?.binding?.agent;return typeof t=="string"&&t.length>0?t:null}function K2t(e,t){if(!e)return{state:"unknown"};const n=(t??[]).find(r=>r.name===e);return n?n.agent_id?{state:"agent",agentId:n.agent_id}:{state:"role-without-agent"}:{state:"unknown"}}const J2t=100;function eXt(e,t){if(!e)return null;const n=t?.agents??[],r=t?.total;if(typeof r=="number"&&r>n.length)return n.find(s=>s.name===e||s.id===e)?.id??null;const i=n.find(o=>o.name===e);if(i)return i.id;const a=n.find(o=>o.id===e);return a?a.id:null}async function w2(e){try{return await e()}catch{return null}}async function tXt(e){if(!e)return null;const t=zy(wf.baseUrl),n=await w2(async()=>{const{profiles:a}=await ke({op:"profiles.list"});return K2t(e,a)});if(n?.state==="agent")return n.agentId;if(n?.state==="role-without-agent")return null;const r=await w2(async()=>{const a=await t.agents.listAgents(1,J2t,e);return a.status<400?eXt(e,a.result??null):null});return r||await w2(async()=>{const a=await t.agents.getAgent(e);return a.status<400?a.result?.id??null:null})}function X8(e){return nr(t=>e?H2t(t.sessions.find(n=>n.session_id===e)):null)}const nXt=20,oSe=e=>`msg:${e}`,rXt=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")},ZS=(e,t)=>`sel:${e}:${rXt(t)}`,R8=(e,t)=>async()=>{const n=()=>eH.speech.create({input:t}),r=await tXt(e);return r===null?n():eH.speech.createForAgent(r,{input_text:t}).catch(i=>{if(!B2t(i))throw i;return n()})},eH=zy(wf.baseUrl),iXt=e=>{for(;e.size>nXt;){const t=e.keys().next().value;if(t===void 0)return;e.delete(t)}},S2=new Map,aXt=(e,t)=>{let n=S2.get(e);return n===void 0&&(n=t().finally(()=>{S2.delete(e)}),S2.set(e,n)),n},Ov=ca((e,t)=>({audioCache:new Map,heardKeys:new Set,loadingKey:null,playingKey:null,error:null,audioElement:null,currentUrl:null,generation:0,speak:async(n,r)=>{const i=t().generation+1;t().stopSpeech(),e({loadingKey:n,error:null,generation:i});try{let a=t().audioCache.get(n);if(a){const c=new Map(t().audioCache);c.delete(n),c.set(n,a),e({audioCache:c})}else{const c=await aXt(n,r);if(!c)throw new Error("Speech generation failed, no audio data received.");a=c;const u=new Map(t().audioCache);if(u.set(n,c),iXt(u),e({audioCache:u}),t().generation!==i)return}if(t().generation!==i)return;const o=URL.createObjectURL(a),s=new Audio(o);if(s.onended=()=>{URL.revokeObjectURL(o),e(c=>c.audioElement===s?{playingKey:null,audioElement:null,currentUrl:null}:{})},s.onerror=()=>{URL.revokeObjectURL(o);const c=t().audioElement===s;e(u=>u.audioElement===s?{error:"Error playing audio.",playingKey:null,audioElement:null,currentUrl:null}:{}),c&&(console.error(`${iSe} playback failed for ${n}`),oi(M2t))},await s.play(),t().generation!==i){s.pause(),s.onended=null,s.onerror=null,URL.revokeObjectURL(o);return}const l=new Set(t().heardKeys);l.add(n),e({playingKey:n,loadingKey:null,audioElement:s,currentUrl:o,heardKeys:l})}catch(a){if(t().generation!==i)return;const o=a instanceof Error?a.message:"Failed to generate speech";e({error:o,loadingKey:null}),oi(F2t(a))}},stopSpeech:()=>{const{audioElement:n,currentUrl:r}=t();n&&(n.pause(),n.onended=null,n.onerror=null,r&&URL.revokeObjectURL(r)),e({playingKey:null,audioElement:null,currentUrl:null})},dismiss:n=>{const{loadingKey:r,playingKey:i,generation:a}=t();r===n&&e({generation:a+1,loadingKey:null}),i===n&&t().stopSpeech()},playSpeech:async(n,r,i)=>{await t().speak(oSe(n),R8(r,i))}}));function E8({key:e,getText:t,play:n,available:r=!0}){const{dismiss:i,stopSpeech:a,loadingKey:o,playingKey:s,audioCache:l,heardKeys:c}=Ov(),{canUseRadientSpeech:u,speechBlock:O}=PUe(),d=e!==null&&s===e,f=e!==null&&o===e,p=e!==null&&l.has(e),m=p&&e!==null&&c.has(e),g=u?null:Bce("speaking-aloud",O),y=!d&&!f&&(!u||!r);return{label:d?"Stop":f?"Loading speech. Press again to cancel.":m?"Replay speech":"Speak aloud",tooltip:d?"Stop":f?"Loading speech. Press again to cancel.":g??(m?"Replay speech":"Speak aloud"),isPlaying:d,isLoading:f,disabled:y,reason:g,active:d||f,press:()=>{if(d){a();return}if(f){e!==null&&i(e);return}if(y)return;const b=t();if(b===null||b.trim().length===0)return;const{text:w,clipped:Q}=_8(b);Q&&!p&&sp(`Reading the first ${w.length.toLocaleString("en-US")} characters. The rest is not read aloud.`),n({text:w})}}}function sSe(e){$.useEffect(()=>{if(e!==null)return()=>{Ov.getState().dismiss(e)}},[e])}const q8=({control:e,side:t="top"})=>{const n=$.useId(),r=e.disabled&&e.reason!==null;return h.jsx(At,{content:e.tooltip,side:t,children:h.jsxs("span",{className:j("flex"),tabIndex:r?0:void 0,"aria-describedby":r?n:void 0,children:[h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":e.label,className:j("text-ink-dim hover:bg-accent-wash hover:text-accent"),onClick:e.press,disabled:e.disabled,children:e.isPlaying?h.jsx(_w,{"aria-hidden":"true"}):e.isLoading?h.jsx(hs,{size:"xs"}):h.jsx(h6e,{"aria-hidden":"true"})}),r&&h.jsx("span",{id:n,className:"sr-only",children:e.reason})]})})},Qm="data-lo-quote-toolkit";function vC(e,t){return e.kind!=="user"&&e.kind!=="assistant"||t.trim().length===0?!1:e.kind!=="assistant"?!0:!e.streaming}const tH=e=>(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(`[${Qm}]`)??null,oXt=e=>e.nodeType===Node.ELEMENT_NODE,sXt=e=>{const t=Array.from(e.childNodes),n=t.findIndex(r=>oXt(r)&&r.hasAttribute(Qm));return n===-1?t.length:n},lXt=(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,cXt=e=>{const t=Array.from(document.querySelectorAll(`[${Qm}]`),n=>n.getBoundingClientRect());return Array.from(e.getClientRects()).filter(n=>!t.some(r=>lXt(r,n))).map(n=>({top:n.top,left:n.left,right:n.right,bottom:n.bottom}))};function I$(e){if(!e)return null;const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;const n=t.getRangeAt(0);if(tH(n.startContainer)||tH(n.endContainer)||!e.contains(n.startContainer))return null;const r=n.cloneRange();e.contains(n.endContainer)||r.setEnd(e,sXt(e));const i=r.toString().trim();return i.length===0?null:{text:i,lines:cXt(n)}}const lSe=8,uXt=.5;function OXt(e,t){const n={top:Math.max(e.top,t.top),left:Math.max(e.left,t.left),right:Math.min(e.right,t.right),bottom:Math.min(e.bottom,t.bottom)};return n.right>n.left&&n.bottom>n.top?n:null}const nH=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));function dXt({lines:e,container:t,viewport:n,size:r,gap:i=lSe,row:a,belowWhenOffFirstLine:o=!1}){if(e.length===0)return null;const s=OXt(t,n);if(!s)return null;const l=e[0],c=e[e.length-1];if(l.bottom<=s.top||l.top>=s.bottom)return null;const u=Math.max(l.bottom-l.top,1),O=a!==void 0&&l.top-a.top>u*uXt,d=l.top-i-r.height>=s.top,f=c.bottom+i+r.height<=s.bottom,m=d&&!(o&&O&&f);return{top:nH(m?l.top-i-r.height:c.bottom+i,s.top,s.bottom-r.height),left:nH(l.left,s.left,s.right-r.width),placement:m?"above":"below"}}const rH="[data-lo-canonical-transcript]",fXt="[data-lo-transcript-content]",iH=e=>({top:e.top,left:e.left,right:e.right,bottom:e.bottom}),hXt=()=>({top:0,left:0,right:window.innerWidth,bottom:window.innerHeight});function cSe(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 f=c.current();if(!f||f.length===0){l(null);return}const p=dXt({lines:f,container:iH((O.closest(rH)??O).getBoundingClientRect()),viewport:hXt(),size:{width:d.offsetWidth,height:d.offsetHeight},row:iH(O.getBoundingClientRect()),belowWhenOffFirstLine:a}),m=O.getBoundingClientRect(),g=p?{top:p.top-m.top,left:p.left-m.left,placement:p.placement}:null;l(y=>y===g||y&&g&&y.top===g.top&&y.left===g.left&&y.placement===g.placement?y:g)},[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 f=t.current?.closest(rH),p=f?.querySelector(fXt),m=new ResizeObserver(d);return f&&m.observe(f),p&&m.observe(p),()=>{O&&cancelAnimationFrame(O),document.removeEventListener("scroll",d,!0),document.removeEventListener("selectionchange",d),window.removeEventListener("resize",d),m.disconnect()}},[n,u,t,i]),{controlRef:o,placement:s}}function uSe(e){const[t,n]=$.useState(null);$.useEffect(()=>{const i=()=>n(I$(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 yh="data-lo-link-toolbar",pXt=120,mXt=2;function OSe(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(f=>f===null?f:null),i(f=>f===!1?f:!1);return}const O=hkt(u);if(O){n(f=>f===O?f:O),i(f=>f===!0?f:!0);return}if(i(f=>f===!1?f:!1),Ywe()){n(f=>f===null?f:null);return}const d=o.current&&u.contains(o.current)?o.current:null;n(f=>f===d?f:d)},[e]);$.useEffect(()=>{const u=e.current;if(!u)return;let O=0;const d=Q=>{O&&(clearTimeout(O),O=0),o.current=Q,l()},f=Q=>{if(O&&clearTimeout(O),!Q){O=0,o.current=null,l();return}o.current!==Q&&(s.current=null,O=setTimeout(()=>{O=0,o.current=Q,l()},pXt))},p=(Q,k)=>{const _=o.current;if(!_||!u.contains(_))return!1;const T=u.querySelector(`[${yh}]`),E=lSe+mXt;for(const R of[_,T]){if(!R)continue;const q=R.getBoundingClientRect();if(!(q.width<=0||q.height<=0)&&Q>=q.left-E&&Q<=q.right+E&&k>=q.top-E&&k<=q.bottom+E)return!0}return!1},m=Q=>{const k=Q.target;if(k?.closest(`[${Qm}]`))return;const _=k?.closest($h)??null;!_&&p(Q.clientX,Q.clientY)||f(_)},g=Q=>{const k=Q.relatedTarget;k&&u.contains(k)||p(Q.clientX,Q.clientY)||d(null)},y=Q=>{const k=Q.target?.closest($h);if(k){if(k===s.current){s.current=null;return}d(k)}},v=Q=>{const k=Q.relatedTarget;k&&u.contains(k)||d(null)},S=()=>Array.from(u.querySelectorAll(`[${yh}] button:not([disabled])`)),x=Q=>{const k=Q.target;if(!k)return!1;if(k.closest(`[${yh}]`)){const R=S(),q=R.indexOf(k);if(q===-1)return!1;if(Q.shiftKey&&q===0){const z=o.current;return z instanceof HTMLElement?(z.focus(),!0):!1}if(!Q.shiftKey&&q===R.length-1){const z=Array.from(u.querySelectorAll($h)),W=o.current,I=W?z.indexOf(W)+1:-1,N=I>0?z[I]:void 0;return N?(N.focus(),!0):!1}return!1}if(Q.shiftKey)return!1;const T=k.closest($h);if(!T||!u.contains(T))return!1;o.current!==T&&d(T);const[E]=S();return E?(E.focus(),!0):!1},b=Q=>{if(Q.key==="Tab"&&x(Q)){Q.preventDefault();return}if(!(Q.key==="ContextMenu"||Q.shiftKey&&Q.key==="F10"))return;const _=Q.target?.closest($h);!_||!u.contains(_)||(Q.preventDefault(),d(_),requestAnimationFrame(()=>{u.querySelector(`[${yh}] button`)?.focus()}))},w=Q=>{const k=Q.target;k&&u.contains(k)||d(null)};return u.addEventListener("pointerover",m),u.addEventListener("pointerout",g),u.addEventListener("focusin",y),u.addEventListener("focusout",v),u.addEventListener("keydown",b),document.addEventListener("pointerdown",w,!0),document.addEventListener("selectionchange",l),l(),()=>{O&&clearTimeout(O),u.removeEventListener("pointerover",m),u.removeEventListener("pointerout",g),u.removeEventListener("focusin",y),u.removeEventListener("focusout",v),u.removeEventListener("keydown",b),document.removeEventListener("pointerdown",w,!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(`[${yh}]`))return;const f=window.getSelection();f&&!f.isCollapsed&&f.removeAllRanges(),c()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[t,c]),{subject:t,quoteAvailable:r,dismiss:c}}function dSe(e,t,n){const r=an(i=>i.addReply);return $.useCallback(()=>{const a=I$(t.current)?.text??(Ywe()?null:n?.()??null);a&&(r(e,{id:is(),text:a}),window.getSelection()?.removeAllRanges(),wz())},[r,e,t,n])}const fSe=({conversationId:e,turnRef:t,subject:n,quoteAvailable:r,onDismiss:i})=>{const a=n.getAttribute(Wwe)??"",o=n.getAttribute("data-lo-kind")??"file",s=_k(),l=$.useCallback(()=>(n.textContent??"").trim()||null,[n]),c=dSe(e,t,l),{text:u}=uSe(t),{speak:O}=Ov(),d=X8(e),f=u??l(),p=f===null?null:ZS(e,_8(f).text);sSe(p);const m=E8({key:p,getText:()=>I$(t.current)?.text??l(),play:({text:W})=>O(ZS(e,W),R8(d,W))}),[g,y]=$.useState(!1),[v,S]=$.useState(()=>s1(a)??null),{controlRef:x,placement:b}=cSe({turnRef:t,visible:!0,lines:()=>{const W=n.getClientRects();return Array.from(W,I=>({top:I.top,left:I.left,right:I.right,bottom:I.bottom}))},measureKey:n,belowWhenOffFirstLine:!0});$.useEffect(()=>{const W=s1(a);if(S(W??null),y(!1),W!==void 0)return;let I=!0;return ukt(a,window.api?.probeFiles).then(()=>{I&&S(s1(a)??null)}),()=>{I=!1}},[a]);const w=o==="file"&&d8(s,a),Q=Zwe({target:a,isDirectory:v?.exists===!0&&!v.isFile,probe:v,canOpenInCanvas:w}),k=gkt({kind:o,target:a,probe:v,quotable:r,canOpenInCanvas:w});if(!k||!a)return null;const _=async()=>{await Mwe(a)&&y(!0)},T=async()=>{if(o==="url"){await HF(o,a);return}s&&Q&&await s.openInCanvas(a)||await HF(o,a)||S(null)},E=async()=>{await vO(a)||S(null)},R=async()=>{await f8(a)||S(null)},q={quote:h.jsx(Cle,{}),copy:g?h.jsx(Ou,{}):h.jsx($Q,{}),open:Q?h.jsx(A7e,{}):o==="url"?h.jsx(Sle,{}):h.jsx(jy,{}),"open-default":h.jsx(rCe,{}),"open-folder":h.jsx(lp,{})},z={quote:c,copy:()=>{_()},open:()=>{T()},"open-default":()=>{E()},"open-folder":()=>{R()}};return h.jsxs("div",{[Qm]:"",[yh]:"",ref:x,role:"toolbar","aria-label":k.label,className:j("absolute z-10 flex h-8 items-center gap-0.5 rounded-md border border-hairline bg-elevated px-1",!b&&"invisible"),style:b?{top:b.top,left:b.left}:void 0,onMouseDown:W=>W.preventDefault(),onKeyDown:W=>{if(W.key!=="Escape")return;window.getSelection()?.removeAllRanges();const I=n;W.preventDefault(),i(),I.focus?.()},children:[k.actions.map(W=>h.jsxs($.Fragment,{children:[h.jsx(At,{content:W.id==="copy"&&g?"Copied":W.label,side:b?.placement==="below"?"bottom":"top",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":W.id==="copy"&&g?"Copied":W.label,className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:z[W.id],children:q[W.id]})}),W.id==="quote"&&h.jsx(q8,{control:m,side:b?.placement==="below"?"bottom":"top"})]},W.id)),k.note&&h.jsx("span",{className:"max-w-56 truncate pl-1 text-ink-dim text-meta",title:k.noteTitle??k.note,children:k.note})]})};function gXt({role:e="answer",forkable:t=!1}={}){const n=t?["fork"]:[];return e==="user"?["copy",...n]:["copy","speak",...n]}function hSe(e){return e.kind!=="user"&&e.kind!=="assistant"||e.kind==="assistant"&&e.streaming?null:e.id||null}const aH=96;function $Xt(e){const t=e.replace(/\s+/g," ").trim();return t.length<=aH?t:`${t.slice(0,aH-1).trimEnd()}…`}const yXt="Answer actions",vXt="Your message actions",bXt="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 wXt(e){return e?"opacity-100":bXt}const SXt=2e3,xXt=1e4;function osn(e){const{request:t}=e;return t?e.now-t.requestedAt>xXt?"retire":e.presentable?e.claimed?"hold":"present":"yield":null}let oH=0,Jb=0;const QXt=ca(e=>({request:null,requestPanel:(t,n,r,i)=>{oH+=1,e({request:{destination:t,nonce:oH,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:()=>{Jb+=1,e({presenterClaimed:!0});let t=!1;return()=>{t||(t=!0,Jb=Math.max(0,Jb-1),Jb===0&&e({presenterClaimed:!1}))}}})),kXt=(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)},PXt=9e4,sH=new Set,TXt=2600,pSe=$.memo(function({bodyText:t,kind:n="answer",agentId:r,speechId:i,revealId:a,revealAt:o,conversationId:s,entryId:l}){const[c,u]=$.useState(!1),[O,d]=$.useState(!1),f=$.useRef(null),p=$.useRef(null),m=$.useRef(null),g=$.useRef(null),{playSpeech:y}=Ov(),v=X8(r??null),S=E8({key:i?oSe(i):null,getText:()=>t,play:({text:E})=>{i&&y(i,v,E)}}),x=QXt(E=>E.requestPanel),w=gXt({role:n,forkable:!!(s&&l)}),Q=c||S.active;$.useEffect(()=>()=>{f.current!==null&&clearTimeout(f.current)},[]),$.useEffect(()=>{if(!a||o===void 0||sH.has(a)||(sH.add(a),Date.now()-o>PXt))return;const E=p.current;if(E===null)return;const R=E.closest(".group")??E;if(kXt(E,R))return;d(!0);const q=()=>{d(!1),R.removeEventListener("pointerenter",q),R.removeEventListener("focusin",q)};return R.addEventListener("pointerenter",q),R.addEventListener("focusin",q),()=>{R.removeEventListener("pointerenter",q),R.removeEventListener("focusin",q)}},[a,o]),$.useEffect(()=>{if(O)return g.current=setTimeout(()=>{g.current=null,d(!1)},TXt),()=>{g.current!==null&&clearTimeout(g.current)}},[O]);const k=async()=>{await Mwe(t)&&(u(!0),f.current!==null&&clearTimeout(f.current),f.current=setTimeout(()=>{f.current=null,u(!1)},SXt))},_=()=>{!s||!l||x("session.fork",m.current,s,{id:l,excerpt:$Xt(t)})},T={copy:h.jsx(At,{content:c?"Copied":"Copy",side:"bottom",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":c?"Copied":"Copy",className:j("text-ink-dim hover:bg-accent-wash hover:text-accent"),onClick:k,children:c?h.jsx(Ou,{"aria-hidden":"true"}):h.jsx($Q,{"aria-hidden":"true"})})}),speak:h.jsx(q8,{control:S,side:"bottom"}),fork:h.jsx(At,{content:"Fork from this message",side:"bottom",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Fork from this message",ref:m,className:j("text-ink-dim hover:bg-accent-wash hover:text-accent"),onClick:_,children:h.jsx(BCe,{"aria-hidden":"true"})})})};return h.jsx("div",{role:"toolbar","aria-label":n==="user"?vXt:yXt,ref:p,onAnimationEnd:E=>{E.target===E.currentTarget&&d(!1)},...O?{"data-lo-arrive":""}:{},...n==="user"?{"data-lo-user-actions":""}:{"data-lo-answer-actions":""},className:j("flex shrink-0 items-center gap-1",wXt(Q)),children:w.map(E=>h.jsx($.Fragment,{children:T[E]},E))})}),_Xt="@container/olderhistory mb-4 flex h-7 min-w-0 items-center gap-2",ew="@min-[260px]/olderhistory:hidden",tw="@max-[260px]/olderhistory:hidden",mSe="lo-older-history-hint",XXt=({state:e,transportDown:t=!1,onLoadOlder:n,onRetryHydration:r})=>{const i=e==="loading"?"Loading earlier messages":e==="failed"?t?"Earlier messages did not load":"Could not load earlier messages":e==="unproven"?"Earlier history not loaded":null,a=e==="loading";return h.jsxs("div",{className:_Xt,children:[h.jsx("output",{className:"sr-only","aria-live":"polite",children:i}),e==="failed"&&t?h.jsxs("span",{className:"min-w-0 truncate text-ink-dim text-meta",children:[h.jsx("span",{className:ew,children:"Not loaded"}),h.jsx("span",{className:tw,children:"Earlier messages did not load"})]}):e==="failed"?h.jsxs(h.Fragment,{children:[h.jsxs("span",{className:"min-w-0 truncate text-danger text-meta",title:"Could not load earlier messages",children:[h.jsx("span",{className:ew,children:"Did not load"}),h.jsx("span",{className:tw,children:"Could not load earlier messages"})]}),h.jsx(je,{variant:"ghost",size:"sm",className:"shrink-0",onClick:n,children:"Try again"})]}):a?h.jsxs(je,{variant:"ghost",size:"sm","aria-disabled":!0,onClick:o=>{o.preventDefault()},className:"text-ink-muted",children:[h.jsx(hs,{size:"sm"}),"Loading earlier messages"]}):e==="idle"?h.jsx(je,{variant:"ghost",size:"sm",onClick:n,children:"Load earlier messages"}):e==="windowed"?h.jsxs("span",{id:mSe,className:"min-w-0 truncate text-ink-dim text-meta",title:t?"Earlier history above":"Earlier history above — scroll up to load",children:[h.jsx("span",{className:ew,children:t?"Earlier history above":"Scroll up for earlier"}),h.jsxs("span",{className:tw,children:["Earlier history above",t?"":" — scroll up to load"]})]}):e==="unproven"?h.jsxs(h.Fragment,{children:[h.jsxs("span",{className:"min-w-0 truncate text-ink-dim text-meta",title:"Earlier history not loaded",children:[h.jsx("span",{className:ew,children:"Earlier not loaded"}),h.jsx("span",{className:tw,children:"Earlier history not loaded"})]}),!t&&r&&h.jsx(je,{variant:"ghost",size:"sm",className:"shrink-0",onClick:r,children:"Try again"})]}):h.jsx("span",{className:"min-w-0 truncate text-ink-dim text-meta",children:"Start of conversation"})]})},RXt="/settings?section=providers",lH="/settings?section=providers&provider=radient",EXt="/settings?section=radient",cH=/sign in to radient/i,qXt=[/insufficient credits/i,/credit balance is too low/i],jXt=[/rate limit or quota/i],CXt=[/insufficient credits/i,/\bHTTP 402\b/i];function gSe(e){return(e??"").split("/")[0]?.trim().toLowerCase()==="radient"}function j8(e){return gSe(e.provider)?e.category==="billing"?!0:(e.category==null||e.category==="unknown"||e.category==="rate-limit")&&CXt.some(n=>n.test(e.text)):!1}function zXt(e){if(!j8(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?`Out of credits${a}: ${i}`:`Out of credits${a}: Radient refused the request`}}function AXt(e){return e==="auth"?"sign-in":e==="billing"?"billing":e==="rate-limit"?"quota":null}function uH(e){const t=gSe(e.provider)||cH.test(e.text);let n=AXt(e.category);return j8(e)&&(n="billing"),n===null&&(e.category==null||e.category==="unknown")&&(cH.test(e.text)?n="sign-in":qXt.some(r=>r.test(e.text))?n="billing":jXt.some(r=>r.test(e.text))&&(n="quota")),n===null?null:n==="sign-in"&&t?{label:"Sign in to Radient",to:lH}:n==="billing"&&t?{label:"Open Radient account",to:EXt}:{label:"Open provider settings",to:t?lH:RXt}}const $Se=({conversationId:e,turnRef:t})=>{const{text:n,clear:r}=uSe(t),i=n!==null,a=dSe(e,t),{controlRef:o,placement:s}=cSe({turnRef:t,visible:i,lines:()=>I$(t.current)?.lines??null}),{speak:l}=Ov(),c=X8(e),u=n===null?null:ZS(e,_8(n).text);sSe(u);const O=E8({key:u,getText:()=>I$(t.current)?.text??null,play:({text:d})=>l(ZS(e,d),R8(c,d))});return $.useEffect(()=>{if(!i)return;const d=f=>{f.key!=="Escape"||f.defaultPrevented||(window.getSelection()?.removeAllRanges(),r())};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[i,r]),i?h.jsxs("div",{[Qm]:"",ref:o,className:j("absolute z-10 flex h-8 items-center gap-0.5 rounded-md border border-hairline bg-elevated px-1",!s&&"invisible"),style:s?{top:s.top,left:s.left}:void 0,onMouseDown:d=>d.preventDefault(),children:[h.jsx(At,{content:"Quote",side:s?.placement==="below"?"bottom":"top",children:h.jsx(je,{variant:"ghost",size:"icon-sm","aria-label":"Quote",className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:a,children:h.jsx(Cle,{})})}),h.jsx(q8,{control:O,side:s?.placement==="below"?"bottom":"top"})]}):null},ySe={all:["radient-prices"],prices:()=>[...ySe.all,"prices"]},UXt=()=>{const e=Rt({queryKey:ySe.prices(),queryFn:()=>Xz({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}},OH="https://console.radienthq.com/dashboard/verification",dH="https://console.radienthq.com/dashboard/billing",fH="Top up in Radient console";function WXt(e){return!e.email_verified&&e.signup_grant!=="claimed"}const ssn=e=>typeof e!="number"||!Number.isFinite(e)?"your free credits":`$${e.toFixed(2)} in free credits`,bC=e=>Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`,NXt=e=>typeof e!="number"||!Number.isFinite(e)?"your free credits":`${bC(e)} in free credits`;function hH(e,t){if(!e)return t;try{const{protocol:n}=new URL(e);return n==="https:"||n==="http:"?e:t}catch{return t}}function YXt(e){window.api?.openExternal?window.api.openExternal(e):window.open(e,"_blank")}const GXt=(e,t)=>e==="pending"?{sentence:`Verify your email to claim ${t}. Check your inbox for the link Radient sent.`,action:"Open verification page"}:e==="expired"?{sentence:`The link to claim ${t} has expired. Request a new one from the verification page.`,action:"Request a new link"}:{sentence:"No signup grant is attached to this account. Open the verification page to check the account.",action:"Open verification page"};function IXt(e,t){if(e===void 0)return{state:"unknown",lines:["You're out of credits. If you haven't verified your email yet, verify it to claim free credits and start using Local Operator for free.","Otherwise, top up in the Radient console."],links:[{label:"Open verification page",url:OH},{label:fH,url:dH}]};if(WXt(e)){const i=hH(e.claim_url,OH),{action:a}=GXt(e.signup_grant,"");return e.signup_grant==="none"?{state:"unverified",lines:["You haven't verified your email yet. Open the verification page to check whether free credits are waiting on your account."],links:[{label:a,url:i}]}:{state:"unverified",lines:[`You haven't verified your email yet. Verify to claim ${NXt(e.grant_amount??t)} and start using Local Operator for free.`,e.signup_grant==="expired"?"The link you were sent has expired. Request a new one on the verification page.":"Check your inbox for the link Radient sent."],links:[{label:a,url:i}]}}const n=e.first_topup,r=["You're out of credits. Top up in the Radient console."];return n!==void 0&&n.bonus_received===!1&&Number.isFinite(n.bonus_amount)&&Number.isFinite(n.minimum_purchase)&&r.push(`Get an extra ${bC(n.bonus_amount)} free on your first top-up of ${bC(n.minimum_purchase)} or more.`),{state:"verified",lines:r,links:[{label:fH,url:hH(n?.topup_url,dH)}]}}const ZXt=5*1e3,DXt=({action:e})=>{const{user:t,accountRead:n}=Jce({staleTime:ZXt,retryOnMount:!1}),r=wi(),{prices:i}=UXt(),o=r.isPending||n==="checking"?null:IXt(n==="ready"?t?.verification:void 0,i?.default_new_credits);return h.jsxs("div",{className:"mt-1 flex flex-col items-start gap-2 pl-6",children:[o?h.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:[h.jsx(sQ,{className:"mt-0.5 size-4 shrink-0 text-ink-muted","aria-hidden":"true"}),h.jsx("div",{className:"min-w-0 text-body-sm text-ink",children:o.lines.map(s=>h.jsx("p",{className:"[&:not(:first-child)]:mt-1",children:s},s))})]}):null,h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o?.links.map(s=>h.jsx(je,{variant:"secondary",size:"sm",onClick:()=>YXt(s.url),children:s.label},s.url)),h.jsx(je,{variant:"ghost",size:"sm",asChild:!0,children:h.jsx($le,{to:e.to,children:e.label})})]})]})},x2=(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)},O1=24,vSe=6,wC=()=>new Promise(e=>{window.requestAnimationFrame(()=>{e()})}),pH=async e=>{for(let t=0;t<vSe;t+=1){if(e())return;await wC()}},bSe=e=>{let t=null;return()=>(t!==null||(t=e().finally(()=>{t=null})),t)},VXt=e=>{const t=bSe(e.loadOlder),n=()=>pH(()=>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 pH(()=>e.reachable()),e.reachable()?"landed":"exhausted"}if(o>=i.maxPages||(o+=1,!await t()))return"exhausted";await n()}}}},e0="data-jump-highlight",MXt=1400,LXt=12,FXt=1200,BXt=vSe,HXt=BXt+2,KXt=2,JXt=30,mH=1,xg=O1;let sh=0;async function eRt(e){const{isReachable:t,rowDistance:n,mount:r,loadOlder:i}=e,a=e.hasHeadroom??(()=>!0);return await VXt({reachable:t,rowDistance:n,mount:r,loadOlder:i,hasHeadroom:a}).loadThrough({maxPages:LXt,maxRows:FXt})==="landed"}async function tRt(e,t,n){if(!n()||!t.isConnected)return;sh+=1;const r=sh;x2(e,t,"reversed",xg);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<HXt&&(await wC(),!(!n()||!t.isConnected||a||r!==sh));u+=1){const O=t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-xg;if(Math.abs(O)<=mH){if(l+=1,l>=KXt){c=!0;break}continue}l=0,x2(e,t,"reversed",xg)}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 f=0;f<JXt;f+=1){if(await wC(),!n()||a||r!==sh||!u.isConnected||!O.isConnected)return;const p=O.getBoundingClientRect().top-u.getBoundingClientRect().top-u.clientTop-xg;if(Math.abs(p)<=mH)continue;x2(u,O,"reversed",xg);const m=u.ownerDocument?.defaultView;m!=null&&u.dispatchEvent(new m.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 wSe(e,t,n,r=()=>!0){return r()?new Promise(i=>{S2t(e,n,{isCurrent:r,onRevealed:a=>{if(!r()){i("missing");return}gH(a),tRt(t,a,r).then(()=>{r()&&a.isConnected&&!a.hasAttribute(e0)&&gH(a),i(r()?"landed":"missing")})},onMissing:()=>{i("missing")}})}):Promise.resolve("missing")}const Q2=new WeakMap;function gH(e){const t=Q2.get(e);t!==void 0&&window.clearTimeout(t);const n=e.hasAttribute(e0);e.removeAttribute(e0),n&&e.offsetHeight,e.setAttribute(e0,""),Q2.set(e,window.setTimeout(()=>{Q2.delete(e),e.removeAttribute(e0)},MXt))}const Xh=120,nw=400,nRt=.5,rRt=320,iRt=900,aRt=64,C8=2,k2=24,P2=3,oRt=4,Z$=12,sRt=Z$,lRt=120,cRt=.35,$H=12,uRt=8,ORt=Z$,dRt=.5,yH=()=>({armed:!1,deliberate:!1,retained:!1,busy:!1,continuation:!1,clampLatched:!1,actFetchSpent:!1,travelledSinceLatch:!1,pageWidenOwed:!1,turnedAround:!1,lastInputAt:Number.NEGATIVE_INFINITY,failures:0,chainFetch:0,chainWiden:0,chainInvisible:0,actAsks:0,revealsThisAct:0}),SSe=e=>Math.min(iRt,Math.max(rRt,Math.round(e*nRt))),fRt=(e,t)=>{if(t.direction==="down")return{...e,armed:!1,deliberate:!1,retained:!1,actFetchSpent:t.at-e.lastInputAt>=nw?!1:e.actFetchSpent,actAsks:t.at-e.lastInputAt>=nw?0:e.actAsks,revealsThisAct:t.at-e.lastInputAt>=nw?0:e.revealsThisAct,continuation:!1,clampLatched:!1,travelledSinceLatch:!1,pageWidenOwed:!1,turnedAround:e.busy,chainFetch:0,chainWiden:0,chainInvisible:0,lastInputAt:t.at};const n=t.at-e.lastInputAt>=nw,r={...e,actFetchSpent:n?!1:e.actFetchSpent,actAsks:n?0:e.actAsks,revealsThisAct:n?0:e.revealsThisAct,travelledSinceLatch:n?!1:e.travelledSinceLatch,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,...e.busy?{retained:!0}:{armed:!0}}:t.atHardTop&&t.continuous&&e.clampLatched&&!n?t.travelledPx>=aRt&&!e.travelledSinceLatch?{...r,armed:!0,clampLatched:!1,travelledSinceLatch:!0}:{...e,lastInputAt:t.at}:e.busy?{...r,retained:!0}:{...r,armed:!0}},rw=(e,t,n)=>({action:t,state:{...e,armed:!1,deliberate:!1,busy:!0,continuation:!1,clampLatched:e.clampLatched||e.armed&&n.distanceFromTopPx<=C8,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}});function xSe(e,t=SSe(e.clientHeight)){return{inZone:e.distanceFromTopPx<=t}}const hRt=(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=SSe(t.clientHeight),{inZone:a}=xSe(t,i),o=n-e.lastInputAt>=Xh||t.distanceFromTopPx<=C8,s=e.revealsThisAct<ORt;if(e.pageWidenOwed&&r==="widen"&&e.chainWiden<$H&&s)return o?rw({...e,pageWidenOwed:!1,continuation:!1,armed:!1,retained:!1,deliberate:!1},r,t):{action:"none",state:e};if(e.armed)return e.deliberate?rw(e,r,t):r==="fetch"&&e.failures>=P2?{action:"none",state:{...e,armed:!1}}:o?a?r==="fetch"&&e.actFetchSpent?{action:"none",state:{...e,armed:!1}}:rw(e,r,t):{action:"none",state:{...e,armed:!1}}:{action:"none",state:e};if(e.continuation){const l=e.actAsks<sRt,c=l&&e.chainInvisible>0&&e.chainInvisible<Z$;return t.scrollable&&!(e.pageWidenOwed&&r==="widen")&&!c?{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}:s&&(r==="widen"?e.chainWiden<$H:(c||l&&e.chainFetch<oRt)&&e.failures<P2)?rw({...e,pageWidenOwed:!1,continuation:!1},r,t):{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}}return{action:"none",state:e}},vH=(e,{network:t=!0,hiddenRowsAfter:n=0,paintedDelta:r=null,growthPx:i=null,clientHeight:a=0,newRecords:o=null}={})=>{const s=r!==null&&r<uRt,l=r===null&&t&&i!==null&&i<Math.max(lRt,cRt*a),c=s||t&&o===0||l;return{...e,busy:!1,failures:t?0:e.failures,armed:e.retained,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,Z$):0,continuation:t&&n>0||c&&e.chainInvisible+1<Z$||!e.retained&&!e.turnedAround}},pRt=e=>({...e,busy:!1,failures:e.failures+1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),mRt=e=>({...e,busy:!1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),gRt=(e,t,n,r)=>n===r?QSe(e,t):null,QSe=(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)<dRt?0:n},$Rt="lo-supplement",yRt="s";function vRt(e,t){return`${$Rt}://${yRt}/${e}/${t}`}const bRt="[supplement] frame torn down after a second load (hostile navigation or a blocked attempt)";function wRt(e){let t=e.parentElement;for(;t;){const n=window.getComputedStyle(t);if((n.overflowY==="auto"||n.overflowY==="scroll")&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function SRt({component:e,sessionId:t,documentHtml:n,documentFailed:r=!1,onRetry:i,onHeightChange:a,className:o}){const s=Koe(e),[l,c]=$.useState(s),[u,O]=$.useState(!1),[d,f]=$.useState(!0),p=$.useRef(null),m=$.useRef(null),g=$.useRef(""),y=$.useRef(!1),v=$.useRef(""),S=$.useRef(()=>{}),x=$.useRef(0),b=$.useRef(s),w=$.useRef(null),Q=$.useRef(()=>{}),k=$.useRef(a),_=$.useRef(()=>{}),T=$.useCallback(E=>{y.current||(y.current=!0,v.current=E,O(!0))},[]);return $.useEffect(()=>{if(n===null)return;const E=m.current;if(!E)return;g.current=iRe();const R=window.api?.desktop?.armSupplementFrame,q=t!==null&&w1(e.attachment);let z;if(R===void 0)z=lRe(n);else if(q)z=vRt(t,e.attachment);else{T("no-address");return}let W=!1,I=!1,N=null,Z=null,G=null;const U={resize:null,error:!1},K=window.setTimeout(()=>{W||T("no-ready")},VW),J=ne=>{E.contentWindow?.postMessage(ne,"*")},A=()=>{y.current||Z===null&&(J({lo:"supplement-host",t:"ping"}),Z=window.setTimeout(()=>{Z=null,T("no-pong")},VW))};S.current=()=>{I||y.current||(I=!0,A(),N=window.setInterval(A,nRe))};const ee=ne=>{const ue=p.current;if(ue){const Oe=wRt(ue);if(Oe&&ue.getBoundingClientRect().top<Oe.getBoundingClientRect().top){w.current=ne,k.current?.(ne);return}}w.current=null,k.current?.(ne),ne!==b.current&&(b.current=ne,c(ne))},L=()=>{G===null&&(G=window.requestAnimationFrame(()=>{G=null;const{resize:ne,error:ue}=U;if(U.resize=null,U.error=!1,ue){T("frame-error");return}ne!==null&&ee(ne)}))},B=ne=>{if(y.current||ne.source!==E.contentWindow||ne.origin!=="null")return;const ue=rRe(ne.data,g.current);if(ue){if(ue.t==="ready"){W||(W=!0,window.clearTimeout(K));return}if(ue.t==="pong"){Z!==null&&(window.clearTimeout(Z),Z=null);return}if(ue.t==="resize"){U.resize=Joe(ue.h),f(!1),L();return}U.error=!0,L()}},ce=()=>{const ne=w.current;ne!==null&&ee(ne)};window.addEventListener("message",B),window.addEventListener("scroll",ce,!0);let M=!1;return(async()=>{if(R)try{await R(z)}catch{}M||(E.src=z)})(),()=>{M=!0,window.clearTimeout(K),N!==null&&window.clearInterval(N),Z!==null&&window.clearTimeout(Z),G!==null&&window.cancelAnimationFrame(G),window.removeEventListener("message",B),window.removeEventListener("scroll",ce,!0),S.current=()=>{}}},[n,T,t,e.attachment]),k.current=a,_.current=E=>{y.current||x.current!==1||m.current?.contentWindow?.postMessage({lo:"supplement-host",t:"theme",mode:E.mode,vars:E.vars,nonce:g.current},"*")},$.useEffect(()=>sRe(E=>_.current(E)),[]),Q.current=()=>{const E=x.current+1;if(x.current=E,E>1){console.debug(bRt),T("second-load");return}_.current(Hoe()),S.current()},u||r?h.jsxs("div",{className:"text-ink-dim text-meta","data-supplement-frame-fallback":r?"document":v.current,children:["Couldn't render this graphic",i&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",className:"px-1 text-ink-dim",children:"·"}),h.jsx("button",{type:"button",className:"text-ink-dim","data-supplement-frame-retry":"",onClick:()=>i(),children:"Retry"})]})]}):h.jsxs("div",{className:o,"data-supplement-frame-box":"",children:[h.jsxs("div",{ref:p,"data-supplement-frame":"",className:"relative overflow-hidden",style:{height:l,width:"100%"},children:[n!==null&&h.jsx("iframe",{ref:m,title:e.title,sandbox:"allow-scripts",onLoad:()=>Q.current(),className:"block h-full w-full border-0"}),d&&h.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 animate-shimmer bg-elevated/40 bg-gradient-to-r from-transparent via-elevated/60 to-transparent bg-[length:200%_100%] bg-[position:-200%_50%] bg-no-repeat"})]}),h.jsxs("span",{className:"block truncate text-ink-muted text-meta",title:`Source: ${e.source}`,"data-supplement-source":"",children:["Source: ",Ed(e.source)]})]})}const xRt=2*1024*1024,Rh=new Map,T2=new Map,QRt=64,bH={html:null,failed:!1};async function kRt(e,t){const n=`${e}:${t}`,r=T2.get(n);if(r)return r;const i=(async()=>{try{const a=await uO({op:"sessions.supplementDocument",sessionId:e,digest:t},null);if(a.kind!=="json")return null;const o=a.body,s=o&&typeof o.html=="string"?o.html:null;if(s===null||s.length>xRt)return null;for(Rh.set(n,s);Rh.size>QRt;){const l=Rh.keys().next().value;if(l===void 0)break;Rh.delete(l)}return s}catch{return null}finally{T2.delete(n)}})();return T2.set(n,i),i}function PRt(e,t,n){const[r,i]=$.useState(()=>{if(!e||!w1(t))return bH;const a=Rh.get(`${e}:${t}`);return a!==void 0?{html:a,failed:!1}:bH});return $.useEffect(()=>{if(!n||!e||!w1(t))return;const a=Rh.get(`${e}:${t}`);if(a!==void 0){i({html:a,failed:!1});return}let o=!1;return kRt(e,t).then(s=>{o||i(s!==null?{html:s,failed:!1}:{html:null,failed:!0})}),()=>{o=!0}},[n,e,t]),r}function TRt({path:e}){switch(Vue(e)){case"image":return h.jsx(WCe,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"spreadsheet":return h.jsx(GCe,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"markdown":case"text":case"document":return h.jsx(yQ,{"aria-hidden":"true",className:"size-3.5 shrink-0"});default:return h.jsx(jy,{"aria-hidden":"true",className:"size-3.5 shrink-0"})}}const _2=$.memo(function({actionPath:t,cwd:n,label:r,suffix:i,size:a,pane:o}){const s=_Rt(o,t),[l,c]=$.useState(!1),u=async d=>{try{const[f]=await window.api.probeFiles([t],n??void 0);if(!f?.resolved.startsWith("/"))throw new Error("File path has no session working directory");await d(f.resolved)}catch{oi(va("ui.chat.highlights.file_resolution_failed"))}},O=()=>u(async d=>{s&&o&&await o.openInCanvas(d)||await vO(d)});return h.jsxs("div",{className:"group flex w-full items-center gap-2 text-meta",children:[h.jsx(TRt,{path:t}),h.jsxs("button",{type:"button",className:"min-w-0 flex-1 truncate text-left text-ink hover:text-ink-dim","data-supplement-file":"",title:t,onClick:()=>{O()},children:[Ed(r),i&&i!==r&&h.jsx("span",{className:"ml-2 text-ink-muted",children:Ed(i)})]}),a&&h.jsx("span",{className:"shrink-0 text-ink-dim",children:a}),h.jsxs(S6,{children:[h.jsx(At,{content:"File actions",children:h.jsx(x6,{asChild:!0,children:h.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":`Actions for ${r||"this file"}`,children:h.jsx(wle,{"aria-hidden":"true",className:"size-3.5"})})})}),h.jsxs(Q6,{align:"end",className:"min-w-45",children:[s&&h.jsxs(Sl,{onSelect:()=>{u(d=>o?.openInCanvas(d))},children:[h.jsx(Ple,{"aria-hidden":"true"}),h.jsx("span",{children:"Open in canvas"})]}),h.jsxs(Sl,{onSelect:()=>{u(vO)},children:[h.jsx(jy,{"aria-hidden":"true"}),h.jsx("span",{children:"Open in default app"})]}),h.jsxs(Sl,{onSelect:()=>{u(f8)},children:[h.jsx(lp,{"aria-hidden":"true"}),h.jsx("span",{children:"Reveal in Finder"})]}),h.jsxs(Sl,{onSelect:()=>{navigator.clipboard.writeText(t).then(()=>c(!0)).catch(()=>oi("Failed to copy file path"))},children:[h.jsx(vle,{"aria-hidden":"true"}),h.jsx("span",{children:l?"Copied":"Copy file path"})]})]})]})]})});function _Rt(e,t){try{return d8(e,t)}catch{return!1}}const wH=$.memo(function({component:t,sessionId:n,onRetry:r,onHeight:i}){const a=$.useRef(null),[o,s]=$.useState(!1);$.useEffect(()=>{const u=a.current;if(u===null)return;if(typeof IntersectionObserver>"u"){s(!0);return}const O=new IntersectionObserver(d=>{for(const f of d)f.isIntersecting&&s(!0)},{rootMargin:"200px 0px"});return O.observe(u),()=>O.disconnect()},[]);const l=PRt(n,t.attachment,o),c=$.useCallback(u=>{i?.(t.attachment,u)},[i,t.attachment]);return h.jsx("div",{ref:a,"data-supplement-slot":"",children:h.jsx(SRt,{component:t,sessionId:n,documentHtml:l.html,documentFailed:l.failed,onRetry:r,onHeightChange:i?c:void 0})})}),XRt=$.memo(function({record:t,sessionId:n,cwd:r,condensed:i=!1}){const a=_k(),[o,s]=$.useState(!1),[l,c]=$.useState(!1),[u,O]=$.useState(!1),[d,f]=$.useState(!1),[p,m]=$.useState(""),[g,y]=$.useState(!1),[v,S]=$.useState(()=>new Map),[x,b]=$.useState(0),w=AXe(t,t.live),Q=t.files,k=t.filesMore,_=t.components,T=Q.length+k,E=async ee=>{if(n){y(!0);try{await ke({...ee,sessionId:n,job:t.job,anchor:t.anchor})}catch(L){oi(Ay("Highlights could not be updated.",L))}finally{y(!1)}}},R=()=>{E({op:"supplements.cancel"})},q=()=>{E({op:"supplements.restart"})},z=()=>{const ee=p.trim();ee&&(f(!1),m(""),E({op:"supplements.steer",text:ee}))},W=$.useCallback((ee,L)=>{S(B=>{if(B.get(ee)===L)return B;const ce=new Map(B);return ce.set(ee,L),ce})},[]),I=ORe(typeof window>"u"?900:window.innerHeight),{visible:N}=dRe(_,I,v);$.useEffect(()=>{b(ee=>Math.max(ee,N.length))},[N.length]);const Z=Math.min(_.length,Math.max(x,N.length)),G=_.slice(0,Z),U=_.slice(Z),K=ee=>w==="preparing"||w==="files_preparing"||w==="cancelled_retry"||w==="files_cancelled_retry"||w==="failed_retry"||w==="files_failed_retry"?h.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-meta","data-supplement-line":"",children:[ee!==null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-ink-muted",children:ee}),h.jsx("span",{"aria-hidden":"true",className:"text-ink-dim",children:"·"})]}),(w==="preparing"||w==="files_preparing")&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",className:"relative inline-block size-3 overflow-hidden rounded-full bg-sunken",children:h.jsx("span",{className:"absolute inset-0 animate-shimmer bg-gradient-to-r from-transparent via-elevated to-transparent bg-[length:200%_100%] bg-[position:-200%_50%] bg-no-repeat"})}),h.jsx("span",{className:"text-ink-muted",children:UXe})]}),(w==="cancelled_retry"||w==="files_cancelled_retry")&&h.jsx("span",{className:"text-ink-muted",children:WXe}),(w==="failed_retry"||w==="files_failed_retry")&&h.jsx("span",{className:"text-ink-muted",children:NXe}),(w==="preparing"||w==="files_preparing")&&n&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",className:"text-ink-dim",children:"·"}),!d&&h.jsx("button",{type:"button",className:"text-ink-dim","data-supplement-adjust":"",onClick:()=>f(!0),children:YXe}),h.jsx("button",{type:"button",className:"text-ink-dim disabled:text-ink-dim/60","data-supplement-cancel":"",disabled:g||t.state==="cancelling",onClick:R,children:GXe})]}),(w==="cancelled_retry"||w==="files_cancelled_retry"||w==="failed_retry"||w==="files_failed_retry")&&n&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",className:"text-ink-dim",children:"·"}),h.jsx("button",{type:"button",className:"text-ink-dim","data-supplement-retry":"",onClick:q,children:IXe})]})]}):null,J=d?h.jsxs("div",{className:"flex items-center gap-2 text-meta","data-supplement-adjust-form":"",children:[h.jsx("input",{autoFocus:!0,className:"min-w-0 flex-1 rounded-sm border border-control bg-canvas px-1.5 py-0.5 text-ink text-meta",maxLength:_Xe,placeholder:"Adjust the graphic…",value:p,onChange:ee=>m(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&z(),ee.key==="Escape"&&(f(!1),m(""))}}),h.jsx("button",{type:"button",className:"text-ink-dim disabled:text-ink-dim/60",disabled:g||!p.trim(),onClick:z,children:"Send"})]}):null;if(w==="nothing")return null;if(i){if(w==="block"){const ee=FXe(t);return ee===null?null:h.jsx("div",{className:"flex flex-col gap-2","data-supplement-record":t.anchor,children:h.jsx("div",{className:"text-ink-muted text-meta","data-supplement-condensed":"",children:ee})})}return h.jsxs("div",{className:"flex flex-col gap-2","data-supplement-record":t.anchor,children:[K(BXe(t)),J]})}let A=null;return(Q.length>0||k>0)&&(T<=2&&_.length===0&&k===0?A=h.jsx("div",{className:"flex flex-col gap-1","data-supplement-files-summary":"",children:Q.map(ee=>{const{name:L,path:B,size:ce}=nq(ee);return h.jsx(_2,{actionPath:ee.path,cwd:r,label:L||B,suffix:B,size:ce,pane:a},ee.path)})}):A=h.jsxs("div",{className:"flex flex-col gap-1","data-supplement-files":"",children:[Q.map(ee=>{const{name:L,path:B,size:ce}=nq(ee);return h.jsx(_2,{actionPath:ee.path,cwd:r,label:L||B,suffix:B,size:ce,pane:a},`${ee.path}:${ee.name}`)}),k>0&&h.jsx(Pa,{chevronClassName:"text-ink-dim",open:o,onOpenChange:s,rowClassName:"min-h-0 py-0",summary:h.jsx("span",{"data-supplement-more":"",children:o?"Show fewer":DXe(k)}),children:t.more.slice(0,20).map(ee=>h.jsx(_2,{actionPath:ee,cwd:r,label:ee,suffix:"",size:"",pane:a},ee))})]})),h.jsxs("div",{className:"flex flex-col gap-2","data-supplement-record":t.anchor,children:[A,K(null),t.detail?.includes("prepared:unsupported")&&h.jsx("p",{className:"text-meta text-ink-muted","data-supplement-refusal":"",children:"Inline preview unavailable. This HTML needs unsupported resources or document content. Open the file to view it."}),(w==="failed_retry"||w==="files_failed_retry")&&h.jsxs("div",{className:"flex flex-col gap-1 text-meta text-ink-muted","data-supplement-diagnostic":"",children:[h.jsx("p",{children:gRe(t)}),((t.attempts?.length??0)>0||(t.detail?.length??0)>0)&&h.jsx(Pa,{open:l,onOpenChange:c,rowClassName:"min-h-6 py-0",chevronClassName:"text-ink-dim",summary:"Details",children:h.jsxs("div",{className:"max-h-[min(320px,40vh)] overflow-auto break-words font-mono text-ink-dim",children:[t.model&&h.jsxs("p",{children:["Model: ",t.model]}),h.jsxs("p",{children:["Attempts: ",t.attempts?.length??0]}),t.detail?.map(ee=>h.jsx("p",{children:mRe(ee)},ee))]})})]}),J,w==="block"&&_.length>0&&h.jsxs("div",{className:"flex flex-col gap-2","data-supplement-components":"",children:[G.map(ee=>h.jsx(wH,{component:ee,sessionId:n,onRetry:n?q:void 0,onHeight:W},ee.attachment)),U.length>0&&h.jsx(Pa,{chevronClassName:"text-ink-dim",open:u,onOpenChange:O,rowClassName:"min-h-0 py-0",summary:h.jsx("span",{"data-supplement-show-all":"",children:u?"Show fewer":MXe(U.length)}),children:U.map(ee=>h.jsx(wH,{component:ee,sessionId:n,onRetry:n?q:void 0,onHeight:W},ee.attachment))})]})]})});function RRt(e){return e.shiftKey||e.altKey||!(e.metaKey||e.ctrlKey)?!1:e.key.toLowerCase()==="f"}const ERt=e=>e?"⌘F":"Ctrl+F";function qRt(e){switch(e){case"ready":case"building":case"unsupported":case"error":return e;default:return"error"}}function jRt(e,t,n){return n<=0?-1:(((e<0||e>=n?t>0?-1:0:e)+t)%n+n)%n}function CRt(e,t){return t>=0&&t<e.length?e[t]:null}function zRt(e,t){const n=[];let r=0;for(const[i,a]of t){const o=Math.max(r,Math.min(e.length,i)),s=Math.max(o,Math.min(e.length,a));s<=o||(o>r&&n.push({text:e.slice(r,o),matched:!1}),n.push({text:e.slice(o,s),matched:!0}),r=s)}return r<e.length&&n.push({text:e.slice(r),matched:!1}),n}const ARt={user:"You",agent:"Agent"},URt="related match",SH="Search this conversation",WRt="Search results",NRt="Close search";function YRt(e){const t=e.filter(r=>r.tier==="exact").length,n=e.length-t;return n===0?e.length===1?"1 match":`${e.length} matches`:t===0?n===1?"1 related match":`${n} related matches`:`${t} exact · ${n} related`}const GRt="No messages match this search.",IRt="Still indexing this conversation.",ZRt="Results appear as the index catches up.",DRt="Newer messages may be missing while the index catches up.",VRt="This conversation lives on another device, so it cannot be searched here.",MRt="This conversation could not be searched.",LRt="Try again",FRt="Check again",BRt="Could not reach that message. It is further back than the loaded history — scroll up in the transcript to load more.",HRt="Updating — the list below is the previous search's.",KRt="Going to that message…";function JRt(e){return e===1?"(the first match shown)":`(first ${e} shown)`}function e4t(e){return e.state==="building"}async function t4t(e,t){if(e===null)return"not-mounted";const n=e.querySelector("[data-lo-transcript-content]")??e;return await wSe(n,e,t)==="landed"?"revealed":"not-mounted"}async function n4t(e){const t=e.query.trim().slice(0,foe);if(t.length===0)return{query:"",state:"ready",partial:!1,hits:[],truncated:!1};const n=Math.min(Math.max(e.limit??O_e,1),d_e);return ke({op:"sessions.find",sessionId:e.sessionId,q:t,limit:n})}const r4t=200,i4t=1500;function a4t({sessionId:e,enabled:t}){const[n,r]=$.useState(""),[i,a]=$.useState("idle"),[o,s]=$.useState([]),[l,c]=$.useState(!1),[u,O]=$.useState(!1),[d,f]=$.useState(-1),p=$.useRef(0),m=$.useRef(0),g=$.useRef(0),y=$.useRef(""),v=$.useRef(null),S=$.useRef(null),x=$.useRef(new Set),b=$.useRef(e);b.current=e;const w=$.useCallback(()=>{S.current!==null&&(clearTimeout(S.current),S.current=null)},[]),Q=$.useCallback((z,W)=>{x.current.has(z)||(x.current.add(z),console.warn(z,W))},[]),k=$.useCallback(()=>{p.current+=1,w(),v.current=null,g.current=0,a("idle"),s(z=>z.length===0?z:[]),c(!1),O(!1),f(-1)},[w]),_=$.useRef(()=>{}),T=$.useCallback((z,W)=>{const I=qRt(W.state);a(I);const N=I==="ready"||I==="building",Z=N?W.hits:[];if(g.current=Z.length,s(Z),c(N&&W.truncated),O(I==="building"&&W.partial),f(Z.length>0?0:-1),I==="building"&&e4t(W)){if(v.current!==z){v.current=z;const G=p.current;S.current=setTimeout(()=>{S.current=null,p.current===G&&_.current(z,"follow-up")},i4t)}}else w()},[w]),E=$.useCallback((z,W)=>{const I=b.current;if(!I)return;const N=p.current,Z=++m.current;W==="fresh"&&(w(),v.current=null,a("loading")),n4t({sessionId:I,query:z}).then(G=>{Z!==m.current||p.current!==N||T(z,G)}).catch(G=>{Z!==m.current||p.current!==N||(Q("thread search could not be answered:",G),w(),v.current=null,g.current=0,s([]),c(!1),O(!1),f(-1),a("error"))})},[T,w,Q]);_.current=E,$.useEffect(()=>{const z=`${t?"1":"0"}:${e??""}`;if(y.current!==z&&(y.current=z,x.current=new Set,k(),r(Z=>Z===""?Z:""),!t||!e))return;if(!t||!e){k();return}const W=n.trim();if(W.length===0){k();return}const I=p.current,N=setTimeout(()=>{p.current===I&&_.current(W,"fresh")},r4t);return()=>clearTimeout(N)},[n,t,e,k]),$.useEffect(()=>()=>w(),[w]);const R=$.useCallback(z=>{f(W=>jRt(W,z,g.current))},[]),q=$.useCallback(()=>{const z=n.trim();!t||!e||z.length===0||_.current(z,"fresh")},[t,e,n]);return{query:n,setQuery:r,state:i,hits:o,truncated:l,partial:u,cursor:d,moveCursor:R,activeHit:CRt(o,d),refresh:q}}const o4t=j("bg-accent-wash","before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-accent"),s4t="bg-accent-wash font-medium text-ink underline decoration-accent decoration-2 underline-offset-2",l4t=()=>navigator.platform.toUpperCase().indexOf("MAC")>=0,c4t=({hit:e,active:t,optionId:n,onNavigate:r})=>{const i=zRt(e.snippet,e.ranges);return h.jsxs("li",{id:n,role:"option","aria-selected":t,onMouseDown:a=>a.preventDefault(),onClick:()=>r(e),className:j("relative flex cursor-pointer flex-col gap-0.5 px-3 py-2",t?o4t:"hover:bg-accent-wash"),children:[h.jsxs("span",{className:"flex items-center gap-1.5 text-ink-muted text-meta",children:[h.jsx("span",{children:ARt[e.role]}),e.tier==="soft"&&h.jsxs(h.Fragment,{children:[h.jsx("span",{"aria-hidden":"true",children:"·"}),h.jsx("span",{className:"text-ink-dim",children:URt})]})]}),h.jsx("span",{className:"line-clamp-2 text-body-sm text-ink",children:i.map((a,o)=>a.matched?h.jsx("mark",{className:s4t,children:a.text},o):h.jsx("span",{children:a.text},o))})]})},u4t=({query:e,onQueryChange:t,state:n,hits:r,cursor:i,truncated:a,partial:o,onMoveCursor:s,onNavigate:l,onRetry:c,onClose:u,isMac:O,jumping:d=!1})=>{const f=$.useId(),p=`${f}-list`,m=$.useCallback(b=>`${f}-opt-${b}`,[f]),g=$.useRef(null),y=i>=0&&i<r.length?r[i]:null,v=r.length>0,S=n==="error"||n==="building";$.useEffect(()=>{g.current?.focus(),g.current?.select()},[]),$.useEffect(()=>{i<0||document.getElementById(m(i))?.scrollIntoView({block:"nearest"})},[i,m]);const x=b=>{if(b.key==="ArrowDown"){b.preventDefault(),s(1);return}if(b.key==="ArrowUp"){b.preventDefault(),s(-1);return}if(b.key==="Enter"){b.preventDefault(),y!==null?l(y):S&&c();return}};return h.jsxs("div",{"data-lo-thread-search":"",role:"presentation",onKeyDown:b=>{b.defaultPrevented||b.key==="Escape"&&(b.preventDefault(),u())},className:"pointer-events-auto w-[26rem] max-w-full rounded-md border border-hairline bg-elevated text-body-sm text-ink shadow-overlay",children:[h.jsx("div",{className:"p-2",children:h.jsxs("div",{className:j("flex items-center gap-2 rounded-sm border border-control bg-surface px-2","transition-colors duration-fast ease-out-quart","has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-accent has-[:focus-visible]:outline-offset-2"),children:[h.jsx(Cy,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-ink-dim"}),h.jsx("input",{ref:g,type:"text",value:e,onChange:b=>t(b.target.value),onKeyDown:x,maxLength:foe,placeholder:SH,"aria-label":SH,role:"combobox","aria-expanded":v,"aria-controls":v?p:void 0,"aria-activedescendant":y!==null?m(i):void 0,"aria-autocomplete":"list",autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 border-0 bg-transparent text-body-sm text-ink outline-none placeholder:text-ink-dim"}),h.jsx(je,{type:"button",variant:"ghost",size:"icon-sm","aria-label":NRt,onClick:u,children:h.jsx(Zi,{"aria-hidden":"true"})})]})}),h.jsxs("div",{className:"flex items-start gap-2 px-3 pb-2",children:[h.jsxs("p",{className:"min-w-0 flex-1 text-ink-muted text-meta",children:[n==="loading"&&(v?HRt:"Searching…"),n==="ready"&&(r.length>0?YRt(r):GRt),n==="building"&&(o?DRt:IRt),n==="unsupported"&&VRt,n==="error"&&MRt,n==="ready"&&a&&v&&h.jsxs("span",{className:"text-ink-dim",children:[" ",JRt(r.length)]}),n==="building"&&!o&&h.jsxs("span",{className:"text-ink-dim",children:[" ",ZRt]})]}),S&&h.jsx(je,{type:"button",variant:"ghost",size:"sm",onClick:c,className:"shrink-0",children:n==="building"?FRt:LRt})]}),v&&h.jsx("ul",{id:p,role:"listbox","aria-label":WRt,"aria-busy":n==="loading",className:j("max-h-80 overflow-y-auto border-t border-hairline py-1",n==="loading"&&"opacity-60"),children:r.map((b,w)=>h.jsx(c4t,{hit:b,active:w===i,optionId:m(w),onNavigate:l},b.id))}),d&&h.jsx("output",{className:"block border-t border-hairline px-3 py-1.5 text-ink-muted text-meta",children:KRt}),h.jsxs("div",{className:"flex items-center gap-3 border-t border-hairline px-3 py-1.5",children:[h.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[h.jsx(vd,{shortcut:"↑"}),h.jsx(vd,{shortcut:"↓"}),h.jsx("span",{children:"browse"})]}),h.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[h.jsx(vd,{shortcut:"↵"}),h.jsx("span",{children:"jump"})]}),h.jsxs("span",{className:"flex items-center gap-1 text-ink-dim text-meta",children:[h.jsx(vd,{shortcut:"esc"}),h.jsx("span",{children:"close"})]}),h.jsx("span",{className:"ml-auto text-ink-dim text-meta",children:ERt(O)})]})]})},O4t=({sessionId:e,containerRef:t,onReveal:n})=>{const[r,i]=$.useState(!1),[a,o]=$.useState(!1),s=$.useRef(null),l=$.useRef(null),c=a4t({sessionId:e,enabled:r}),u=$.useCallback(()=>{const f=document.activeElement;l.current=f instanceof HTMLElement?f:null,i(!0)},[]),O=$.useCallback(()=>{i(!1);const f=l.current;l.current=null,f?.isConnected&&f.focus()},[]);$.useEffect(()=>{const f=p=>{if(p.defaultPrevented||!RRt(p))return;const m=p.target;if(!(!(s.current!==null&&m!==null&&s.current.contains(m))&&(J0(p.target)||Kle(p.target)===null))){if(p.preventDefault(),r){const y=s.current?.querySelector("input");y?.focus(),y?.select();return}u()}};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[r,u]);const d=$.useCallback(async f=>{o(!0);try{if(n){await n(f.id);return}await t4t(t.current,f.id)}finally{o(!1)}},[t,n]);return r?h.jsx("div",{ref:s,className:"pointer-events-none absolute top-3 right-6 z-20 max-w-[calc(100%-1.5rem)]",children:h.jsx(u4t,{query:c.query,onQueryChange:c.setQuery,state:c.state,hits:c.hits,cursor:c.cursor,truncated:c.truncated,partial:c.partial,onMoveCursor:c.moveCursor,onNavigate:d,onRetry:c.refresh,onClose:O,isMac:l4t(),jumping:a})}):null};function d4t(e,t,n){const r=new Set,i=[0];for(const a of e){if(r.has(a.key))throw new Error(`Duplicate transcript entry: ${a.key}`);r.add(a.key);const o=t.get(a.key),s=o?.signature===a.signature&&o.width===n?o.height:a.estimate;if(!Number.isFinite(s)||s<0)throw new Error(`Invalid transcript extent: ${a.key}`);i.push(i[i.length-1]+s)}return i}function f4t(e,t){for(const[n,r]of e)t.set(n,{...r});e.clear()}function xH(e,t){let n=0,r=e.length;for(;n<r;){const i=n+r>>>1;e[i]<t?n=i+1:r=i}return n}function h4t(e,t,n,r,i){const a=e.length-1,o=new Set(i.filter(O=>O>=0&&O<a)),s=Math.max(0,xH(e,t-r)-1),l=Math.min(a,xH(e,n+r));for(let O=s;O<l;O++)e[O+1]>t-r&&e[O]<n+r&&o.add(O);const c=[];let u=0;for(const O of[...o].sort((d,f)=>d-f))u<O&&c.push({kind:"spacer",start:u,end:O,height:e[O]-e[u]}),c.push({kind:"entry",index:O}),u=O+1;return u<a&&c.push({kind:"spacer",start:u,end:a,height:e[a]-e[u]}),c}function p4t(e,t,n,r){return!e||!t||e.id!==t.id||n!==r?null:t.viewportOffset-e.viewportOffset}function m4t(e){const t=[];let n=null;return e.forEach((r,i)=>{if((!r.candidate||r.boundary)&&(n=null),r.candidate&&n)n.indices.push(i);else{const a={key:r.firstId,indices:[i],representation:r.representation};t.push(a),n=r.candidate?a:null}}),t}function g4t(e,t){return e==="inline"&&t}function kSe(e,t,n,r){const i=Math.max(24,Math.floor((r||810)/7.2)),a=t.split(`
@@ -964,4 +964,4 @@ ${m}`,J=q.current;q.current=K,!(J===null||J===K)&&(AJt(J.split(`
964
964
  }`,pTe=()=>h.jsxs("div",{className:"flex h-6 items-center gap-0.5 [&>span]:animate-[waveform-bar_1.2s_infinite_ease-in-out]","aria-hidden":"true",children:[h.jsx("style",{children:Fnn}),h.jsx("span",{className:"size-[3px] rounded-[1px] bg-accent"}),h.jsx("span",{className:"h-2 size-[3px] rounded-[1px] bg-accent",style:{animationDelay:"0.2s"}}),h.jsx("span",{className:"size-[3px] rounded-[1px] bg-accent",style:{animationDelay:"0.4s"}}),h.jsx("span",{className:"h-3 size-[3px] rounded-[1px] bg-accent",style:{animationDelay:"0.6s"}}),h.jsx("span",{className:"size-[3px] rounded-[1px] bg-accent",style:{animationDelay:"0.8s"}})]});pTe.displayName="WaveformAnimation";const Bnn=120;function Hnn({text:e,cwd:t,enabled:n=!1}){const r=$.useMemo(()=>n?xen(e):[],[e,n]),i=$.useRef(new Map),a=$.useRef(t),[o,s]=$.useState(new Map),l=wi(),c=Fr(l.data,"projects",1),u=$.useRef(new Set),O=$.useMemo(()=>{const g=new Set;for(const y of r)if(y.path&&g.add(y.path),g.size>=doe)break;return[...g]},[r]),d=O.join(`
965
965
  `),f=$.useMemo(()=>{const g=new Set;for(const y of O){const v=jae(y);v&&g.add(v.toLowerCase())}return[...g]},[O]),p=()=>{const g=new Map(i.current);if(u.current.size===0)return g;for(const y of O){const v=jae(y);v&&u.current.has(v.toLowerCase())&&g.set(y,{exists:!0,outside:!1})}return g};$.useEffect(()=>{const g=window.api;if(a.current!==t&&(a.current=t,i.current.clear(),s(p())),!n||O.length===0){s(b=>b.size>0?new Map:b);return}if(typeof g?.probeFiles!="function"&&f.length===0){s(b=>b.size>0?p():b);return}const y=O.filter(b=>!i.current.has(b)),v=c?f.filter(b=>!u.current.has(b)):[];if(y.length===0&&v.length===0){s(p());return}let S=!1;const x=setTimeout(()=>{const b=y.length>0&&typeof g?.probeFiles=="function"?g.probeFiles(y,t).then(Q=>{if(!S)for(const k of Q)k.exists&&i.current.set(k.input,{exists:!0,outside:k.outsideWorkspace===!0})}).catch(()=>{}):Promise.resolve(),w=v.length>0?ke({op:"projects.list"}).then(Q=>{if(!S)for(const k of Q.projects){const _=k.name.toLowerCase();v.includes(_)&&u.current.add(_)}}).catch(()=>{}):Promise.resolve();Promise.allSettled([b,w]).then(()=>{S||s(p())})},Bnn);return()=>{S=!0,clearTimeout(x)}},[d,t,c]);const m=$.useMemo(()=>gen(r,o),[r,o]);return{spans:r,resolved:m}}const Bae=""+new URL("brand-mark-Bv0Hu-Cz.png",import.meta.url).href,Knn={ink:"bg-ink","ink-muted":"bg-ink-muted"},Jnn={maskImage:`linear-gradient(#000, #000), url(${Bae})`,WebkitMaskImage:`linear-gradient(#000, #000), url(${Bae})`,maskSize:"100% 100%, auto 50%",WebkitMaskSize:"100% 100%, auto 50%",maskRepeat:"no-repeat",WebkitMaskRepeat:"no-repeat",maskPosition:"center",WebkitMaskPosition:"center",maskComposite:"exclude",WebkitMaskComposite:"xor"},ern=({className:e,tone:t="ink",label:n})=>h.jsx("span",{role:n?"img":void 0,"aria-label":n,"aria-hidden":n?void 0:!0,"data-brand-mark":"",className:j("inline-block shrink-0 rounded-full",Knn[t],e),style:Jnn}),trn=new Set(i1e),IE=navigator.platform.toUpperCase().indexOf("MAC")>=0,Hae="composer-credential-notice",Kae="composer-secret-closure-notice",nrn="Answer the secret request in the asks panel — this box is paused until it is answered, and your draft is kept.",Jae="composer-mention-outside-notice",eoe="composer-host-blocked-reason",toe="composer-delivery-remedies-hint",rrn={canUseRadientSpeech:!1,speechBlock:"could-not-check"},irn=1500;function mTe(e,t){return new Promise((n,r)=>{const i=setTimeout(()=>r(new Error("credential store timed out")),t);e.then(a=>{clearTimeout(i),n(a)},a=>{clearTimeout(i),r(a)})})}const arn=p6("sessions.credential"),noe=5e3;async function roe(e,t,n){try{const r=await mTe(ke({op:"sessions.credential",sessionId:e,action:"store",key:t.key,value:t.value}),n);return r?.data?.ok===!1?{kind:"fate",fate:r.data.reason==="empty-key"?"rejected-key":"lost"}:{kind:"stored"}}catch(r){const i=r instanceof Ut?r.status:null;return i!==null&&i>=400&&i<500?{kind:"fate",fate:"lost"}:null}}async function orn(e,t,n){try{const r=await mTe(ke({op:"sessions.credential",sessionId:e,action:"list"}),n),i=r?.data;return i?.ok===!1||!Array.isArray(i?.credentials)?null:g8(r).includes(t)}catch{return null}}async function srn(e,t){const n=await roe(e,t,arn);if(n?.kind==="stored")return n;const r=n===null;let i=n;if(i===null&&(i=await roe(e,t,noe)),i?.kind==="stored")return i;const a=await orn(e,t.key,noe);return a===!0?{kind:"stored"}:a===!1&&i!==null&&!r?i:null}const ioe=[],aoe=[],lrn=e=>new Promise(t=>{const n=new FileReader;n.onload=r=>t(typeof r.target?.result=="string"?r.target.result:null),n.onerror=()=>t(null),n.readAsDataURL(e)}),crn=()=>document.querySelector('[aria-label="Answer options"] button:not([disabled])'),urn=()=>document.querySelector(xce),Orn='[aria-label="Remove reply"]';let h6=!1;const oln=()=>Ize(urn(),document.activeElement,h6),drn=j("mx-auto flex w-full flex-col bg-elevated","box-border transition-colors duration-fast ease-out-quart"),frn=j("has-[textarea:focus-visible]:outline-solid has-[textarea:focus-visible]:outline-2","has-[textarea:focus-visible]:outline-accent has-[textarea:focus-visible]:outline-offset-2"),hrn=$.forwardRef(({onSendMessage:e,isLoading:t,awaitingReply:n=!1,awaitingAnswer:r=!1,deliveryRemediesReachable:i=!1,deviceHold:a,hostNotice:o,secretAnswer:s=!1,asideSessionId:l,asideStreaming:c=!1,conversationId:u,messages:O,currentJobId:d,onCancelJob:f,onComposerInput:p,isFarFromBottom:m=!1,hasNewActivity:g=!1,scrollToBottom:y=()=>{},canonicalStop:v,canonicalStopAvailable:S=!1,interruptNotice:x,sendError:b,initialSuggestions:w,noProvider:Q=!1,noModel:k=!1,agentData:_,cwd:T,cwdWritePath:E,cwdReadOnlyReason:R,cwdPending:q,cwdPendingAccepted:z,isSmallView:W=!1,askExpanded:I,onAskToggle:N,askOutcomes:Z,ownGutter:G=!1,isHydrating:U=!1,transcriptless:K=!1,autoFocus:J=!0,unavailable:A=!1,mentionsEnabled:ee=!1,mentionsUnsupported:L=!1,sessionStatus:B,onSlashCommand:ce,onSlashNote:M,paneHasSession:H,runDetails:ne,recordingProbe:ue=rrn,onCredentialsStored:Oe,onDictationStateChange:Te,placeholderOverride:xe},nt)=>{const Ne=T??(E?.kind==="move"?void 0:_?.current_working_directory),Ie=Yi(D=>l?D.attached[l]??null:null),We=$.useRef(null);$.useEffect(()=>{if(!c||We.current===null)return;We.current=null;const D=Yi.getState(),de=l??"";D.attached[de]?.notice===rG(IE)&&D.setAsideNotice(de,null)},[c,l]);const ie=an(D=>D.removeReply),oe=an(D=>D.addAttachment),$e=an(D=>D.removeAttachment),be=an($.useCallback(D=>u?D.inputByConversation[u]?.replies??ioe:ioe,[u])),ye=an($.useCallback(D=>u?D.inputByConversation[u]?.attachments??aoe:aoe,[u])),he=$.useRef(Oe);$.useEffect(()=>{he.current=Oe});const[Re,fe]=$.useState(!1),[ge,De]=$.useState(!1),[Se,Je]=$.useState(null),[yt,vt]=$.useState(!1),[qt,Ye]=$.useState(!1);$.useEffect(()=>{if(!qt)return;const D=window.setTimeout(()=>Ye(!1),5e3);return()=>window.clearTimeout(D)},[qt]);const jt=$.useRef(null),Mt=$.useRef([]),[En,hr]=$.useState(""),Wr=$.useRef(0);$.useEffect(()=>{const D=b?.message;Wr.current=D?Date.now():0},[b?.message]);const{canUseRadientSpeech:eo,speechBlock:Br}=ue,Di=eo,Vi=Bce("recording",Br),St=!K&&O.length===0&&!U,mn=St,Jt=$.useMemo(()=>{const D=B?.frontend?.effective_model??B?.frontend?.selected_model??null;return D?{provider:D.provider,model_id:D.model_id}:null},[B]),ft=$.useRef(null),bt=$.useRef(null),ht=$.useMemo(()=>!w||w.length===0?[]:mn?(ft.current===null&&(ft.current=nJt(w)),ft.current):[],[w,mn]),[Qt,He]=$.useState(null),[ct,en]=$.useState(null),[gn,Ct]=$.useState(null),[Nt,pr]=$.useState(Ya),In=$.useRef(Ya),Nr=$.useCallback(D=>{In.current=D,pr(D)},[]),Bn=$.useRef(new Map),Hr=$.useRef(1),[to,tl]=$.useState(null),no=$.useRef(null),vn=$.useCallback(D=>{no.current=D,tl(D)},[]),[Oa,ze]=$.useState(null),Pe=$.useRef(null),tn=$.useCallback(D=>{Pe.current=D,ze(D)},[]),xn=$.useCallback(D=>dB(no.current,D)??0,[]),Qi=$.useRef(null),kt=$.useRef(null),Oi=$.useRef(null),Ft=$.useRef(null),bn=$.useRef(null),Yt=$.useRef(!1),[nl,rc]=$.useState(0),ro=$.useRef([]),bu=$.useRef(void 0),ji=B&&!B.draft?u:void 0,ic=$.useCallback(async(D,de=ji)=>{const _e=[...Bn.current.values()],Be=lB(D,_e);if(Be.length===0&&s1e(D,_e).length===0)return{text:D,stored:[],refused:[],unconfirmed:[]};const cn=new Map,Zt=[],er=await Promise.all(Be.map(async Ci=>({payload:Ci,attempt:de?await srn(de,Ci):{kind:"fate",fate:"unreachable"}})));for(const{payload:Ci,attempt:so}of er){if(so===null){cn.set(Ci.index,"unconfirmed");continue}if(so.kind==="stored"){Zt.push(Ci.key);continue}cn.set(Ci.index,so.fate)}Zt.length>0&&de&&await he.current?.(de);const jr=Ci=>[...cn.entries()].filter(([,so])=>Ci(so)).map(([so])=>_e.find(al=>al.index===so)?.key??`#${so}`);return{text:APt(D,_e,cn),stored:Zt,refused:jr(Ci=>Ci!=="unconfirmed"),unconfirmed:jr(Ci=>Ci==="unconfirmed")}},[ji]),Qn=B?.draft===!0&&B?.draftResolved===!1,Mi=$.useCallback(()=>{Yt.current=!0,rc(D=>D+1),vn(null),bn.current=null},[vn]),io=$.useRef(!1),ao=$.useRef(!1),AO=$.useCallback(()=>ao.current?io.current?"mixed":"dictated":"typed",[]),UO=$.useRef([]),{client:vv,provided:bv}=La(),jP=$.useMemo(()=>async(D,de)=>{if(Qn)return B?.onOpenDraftPicker?.("session.model"),!1;if(Re||yt)return!1;let _e;const Be=ji?await ic(D):{text:D,stored:[],refused:[],unconfirmed:[]};Be.stored.length>0&&Md(cB(Be.stored)),Be.refused.length>0&&Zm(uB(Be.refused)),Be.unconfirmed.length>0&&Zm(OB(Be.unconfirmed));const cn=UO.current,Zt=Dae(D,cn);let er=null;if(Zt&&bv){const ks=await Btn(vv,T??"",Zt.name);ks!==null&&Ctn(ks)?er=ks:M?.(ks!==null?`skill \`${Zt.name}\` has an empty body — sending your message as written`:`could not load skill \`${Zt.name}\` — sending your message as written`)}const jr=ks=>{if(Zt!==null&&er!==null){const LP=Dae(ks,cn),DTe=LP&&LP.name===Zt.name?LP.request:Zt.request;return l5(ztn({...Zt,request:DTe},er),be)}return l5(ks,be)},Ci=ji?void 0:async ks=>(_e=await ic(D,ks),jr(_e.text)),so=jr(Be.text),al=await e(so,ye.map(ks=>ks.path),de,D,Ci,AO());return al!==!1&&(io.current=!1,ao.current=!1),al!==!1&&_e&&(_e.stored.length>0&&Md(cB(_e.stored)),_e.refused.length>0&&Zm(uB(_e.refused)),_e.unconfirmed.length>0&&Zm(OB(_e.unconfirmed))),al===!1?al:qz(al)?(eue(al,Mi),al):(Mi(),al)},[e,ye,be,Mi,ic,ji,Qn,B?.onOpenDraftPicker,AO,Re,yt,vv,bv,T,M]),WO=nr(D=>oNe(D.drafts,u)),{inputValue:Ce,setInputValue:qn,handleKeyDown:Am,handleSubmit:wv,textareaRef:cr,sendInFlight:Um,appendTranscriptText:Sv}=DUe({conversationId:u,onSubmit:jP,scrollToBottom:y,draftHeld:wl(Nt),transcriptless:K,draftUnredacted:xn});$.useEffect(()=>{Ce===""&&!Um&&!WO&&(io.current=!1,ao.current=!1)},[Ce,Um,WO]);const NO=dB(to,Ce),[kr,Kr]=$.useState(0),[ac,wu]=$.useState(!1),oo=nnn(u),xs=H??!1,rt=Ynn({inputValue:Ce,selectionStart:kr,sessionId:oo,paneHasSession:xs,activeProfile:{team:B?.frontend?.active_team,agent:B?.frontend?.active_agent},activeModel:EC(B?.frontend?.effective_model??B?.frontend?.selected_model),activeSpec:B?.frontend?.effective_model??B?.frontend?.selected_model,cwd:T}),YO=mn&&!(rt.open&&rt.phase==="argument"),di=Ftn({text:Ce,caret:kr,cwd:T,attached:xs,commandNames:rt.commandNames,argumentWords:rt.argumentWords,enabled:!wl(Nt)});$.useEffect(()=>{UO.current=di.vocabulary.map(D=>D.name)},[di.vocabulary]);const Ao=ttn({text:Ce,caret:kr,cwd:T,enabled:ee,unsupported:L}),le=Hnn({text:Ce,cwd:T,enabled:ee}),se=$.useMemo(()=>[...le.resolved.values()].filter(D=>D.outside).length,[le.resolved]),qe=$.useRef(null),dt=$.useRef(null),ut=$.useRef(null);$.useLayoutEffect(()=>{u!==void 0&&ut.current!==u&&Ce&&(ut.current=u,qe.current=Ce.length,Kr(Ce.length))},[Ce,u]);const $n=$.useRef(Ce);$.useLayoutEffect(()=>{$n.current=Ce;const D=cr.current,de=qe.current;!D||de===null||(qe.current=null,D.setSelectionRange(de,de))},[Ce,cr,vn]);const Ra=$.useCallback(()=>[...ro.current,...[...Bn.current.values()].map(D=>D.key)],[]),Ea=$.useCallback((D,de)=>{u&&(wl(D)||an.getState().setCurrentInput(u,de,xn(de)))},[u,xn]),Zn=$.useCallback(D=>{const de=D.payload??null;de&&(Bn.current.set(de.index,de),Hr.current=Math.max(Hr.current,de.index+1)),D.buffer!==$n.current&&(qe.current=D.caret,Kr(D.caret)),Qi.current=D.buffer,Oi.current!==null&&!D.buffer.includes(Oi.current.trim())&&(Oi.current=null),kt.current!==null&&!D.buffer.includes(kt.current.text.trim())&&(kt.current=null),Nr(D.capture),qn(D.buffer),Ea(D.capture,D.buffer)},[Ea,Nr,qn]);$.useLayoutEffect(()=>{Qi.current!==Ce&&(Qi.current=Ce,xPt(In.current)&&(Nr(Ya),vn(null)))},[Ce,Nr,vn]),$.useEffect(()=>{In.current=Ya,Nr(Ya),Bn.current.clear(),Hr.current=1,Yt.current=!1,kt.current=null,Oi.current=null,bn.current=null,vn(null)},[u,Nr,vn]);const fn=an(D=>u?D.getUnredactedChars(u):0),Pr=an(D=>u?D.getCurrentInput(u):"");$.useEffect(()=>{fn<=0||!Pr||Ce!==Pr||no.current?.over!==Pr&&vn({chars:fn,over:Pr})},[fn,Pr,Ce,vn]),$.useLayoutEffect(()=>{const D=no.current;D&&D.over!==Ce&&vn(null)},[Ce,vn]),$.useLayoutEffect(()=>{const D=Pe.current;D&&D.over!==Ce&&tn(null)},[Ce,tn]),$.useEffect(()=>{Yt.current&&(lB(Ce,Bn.current.values()).length>0||(Bn.current.clear(),Hr.current=1,Yt.current=!1))},[Ce,nl]),$.useEffect(()=>{Nt.arm===null||!ji||bu.current!==ji&&(bu.current=ji,ke({op:"sessions.credential",sessionId:ji,action:"list"}).then(D=>{ro.current=g8(D)}).catch(()=>{}))},[Nt.arm,ji]);const Uo=$.useCallback(()=>{const D=In.current;if(!wl(D))return!1;const de=PPt({capture:D,buffer:Ce,caret:cr.current?.selectionEnd??Ce.length,index:Hr.current,taken:Ra()});return de.minted?(Zn(de),vn(null),!0):!1},[Zn,Ce,Ra,vn]),Hn=$.useCallback(D=>{const de=In.current;if(!wl(de))return!1;const _e=D.currentTarget,Be={start:_e.selectionStart??Ce.length,end:_e.selectionEnd??Ce.length};if(D.key==="Enter"&&!D.shiftKey&&!D.nativeEvent.isComposing)return Uo();if(D.key==="Escape"){const Zt=TPt(de,Ce);return Zt.cancelled?(kt.current=Zt.token,vn(Zt.restored>0?{chars:Zt.restored,over:Zt.buffer}:null),Zn(Zt),!0):!1}return D.key==="Enter"?(Zn(oB(de,Ce,Be,`
966
966
  `)),!0):D.key==="Tab"?!0:Array.from(D.key).length===1&&!D.ctrlKey&&!D.metaKey&&!D.altKey&&!D.nativeEvent.isComposing?(Zn(oB(de,Ce,Be,D.key)),!0):!1},[Ce,Zn,Uo,vn]),qr=$.useCallback((D,de,_e="typed")=>Cnn({gesture:_e,draft:D,caret:de,commandNames:rt.commandNames,promptCommands:rt.promptCommands,armedOnlyCommands:rt.armedOnlyCommands,valueArgumentCommands:rt.valueArgumentCommands,argumentCommands:rt.argumentCommands,argumentShapes:rt.argumentShapes,prefixingCommands:rt.prefixingCommands,commandLockedWords:trn,unmaskedRunWord:Yr(D)?kt.current?.text.trim().replace(/^\//,""):$Te(D)?Ft.current?.word:void 0,nameListCommands:rt.nameListCommands,enabled:rt.available&&!!ce}),[rt.commandNames,rt.promptCommands,rt.armedOnlyCommands,rt.valueArgumentCommands,rt.argumentCommands,rt.argumentShapes,rt.prefixingCommands,rt.nameListCommands,rt.available,ce]),da=$.useCallback((D,de,_e)=>{qe.current=de,qn(D),Kr(de),M?.(_e)},[M,qn]),Gf=$.useCallback(D=>{const de=kt.current;if(de!==null&&de.text.trim().length>0&&D.includes(de.text.trim()))return de.text.trim();const _e=Oi.current;return _e!==null&&_e.trim().length>0&&D.includes(_e.trim())?_e.trim():null},[]),xv=$.useCallback(D=>sB(D,kt.current)?"send":Gf(D)===null?"typed":"pick",[Gf]),Yr=$.useCallback(D=>{const de=kt.current;return de===null||de.restored===0?!1:aB(D,de.restoredText)},[]),$Te=$.useCallback(D=>{const de=Ft.current;return de!==null&&aB(D,de.run)},[]),CP=$.useCallback(D=>{const de=kt.current;return de!==null&&de.restored>0&&sB(D,de)},[]),zP=$.useCallback((D,de)=>{const _e=xv(D);if(_e==="send"&&CP(D))return{kind:"held",notice:"These characters are still the credentials you cancelled — clear the box to release your words and send your sentence."};if(_e==="send")return{kind:"send"};const Be=_e==="pick"?qr(D,de,"pick"):qr(D,de);if(_e!=="pick"||Be.kind!=="send")return Be;const cn=Gf(D);if(cn===null)return Be;const Zt=D.indexOf(cn);return Zt<0?Be:qr(D,Zt+cn.length,"pick")},[xv,CP,qr,Gf]),iW=$.useMemo(()=>{if(ac)return[];const D=otn({draft:Ce,commandNames:rt.commandNames,nameListCommands:rt.nameListCommands,nameChoices:rt.nameChoices,picking:rt.open&&rt.matches.length>0});if(D.length===0)return D;const de=qr(Ce,kr,"typed");return stn(D,Ce,{sendsAsWritten:de.kind==="send"})},[Ce,kr,ac,qr,rt.commandNames,rt.nameListCommands,rt.nameChoices,rt.open,rt.matches.length]),aW=$.useMemo(()=>ac?[]:Etn({draft:Ce,vocabulary:di.vocabulary,settled:di.settled,picking:di.open}),[Ce,ac,di.vocabulary,di.settled,di.open]),oW=$.useMemo(()=>[...iW,...aW],[iW,aW]),yTe=eTe(oW),Wm=$.useCallback(async(D,de,_e)=>{const Be=ce;if(D.kind==="held"){const Zt=kt.current;Zt!==null&&(bt.current?.token!==Zt||bt.current?.notice!==D.notice)&&(bt.current={token:Zt,notice:D.notice},M?.(D.notice));return}if(!Be)return;if(D.kind==="whole"||D.kind==="splice"){const Zt=rt.commands.find(jr=>jr.name===D.command.name||jr.aliases.includes(D.command.name)),er=pn(D.command.args??"");if(Zt?.destination==="session.model"&&er){const jr=FSe(rt.argumentList.rows,er);if(jr){oO.getState().openConnect({providerId:jr});return}}}if(D.kind==="list-open"){if(rt.open&&rt.matches.length>0)return;M?.(`Type a name after /${D.command.name}, or choose one from the list.`);return}if(D.kind==="unrecognised"){await Be(D.command),qe.current=_e,qn(de),Kr(_e);return}if(D.kind==="reassemble"){da(D.text,D.caret,gnn(D.text.trim(),xs));return}if(await Be(D.command)==="consumed"){const Zt=D.kind==="whole"?"":D.text,er=D.kind==="whole"?0:D.caret;if(qe.current=er,qn(Zt),Kr(er),D.locked===!0){const jr=p1e(de,In.current),so=!(D.kind==="whole"?jr:jr.slice(D.start,D.end)).includes(r1e);bn.current=so?{text:jr,caret:_e,plain:Xp(D.command.args).length}:null,M?.($nn(D.command.name,{dialog:xs&&rt.commandNames.has(D.command.name),undo:so},IE))}return}qe.current=_e,qn(de),Kr(_e)},[ce,M,qn,rt.commandNames,rt.open,rt.matches.length,rt.commands,rt.argumentList.rows,da,xs]),vTe=!!(t&&d),AP=!!s,ln=A||vTe||AP||!!o?.blocksInput,Nm=Q||k,Qv=$.useCallback(()=>{Ye(!0)},[]),UP=$.useCallback(async D=>{const de=EC(D.model);if(!(ln||!mxe(D)||D.id!=="model-default"||!de)){rt.close();try{await RC(de,(_e,Be)=>ke({op:"settings.edit",key:_e,value:Be})),qn(""),M?.(`Default for new sessions: ${de.provider}/${de.model_id}`)}catch(_e){M?.(`The default was not saved: ${_e instanceof Error?_e.message:"the backend refused it"}`)}}},[ln,rt.close,qn,M]),WP=$.useCallback(async(D,de)=>{if(D.kind==="action"){de.run&&await UP(D.row);return}if(ln)return;const _e=Lnn(Ce,kr,D,rt.commandNames,rt.argumentWords,rt.inline?.nameThenMessage??!1);if(!_e)return;if(rt.close(),de.run&&D.kind==="argument"&&!xs&&ce){const er=IKt(rt.inline?.source);if(er){const jr=U$(Ce,kr,rt.commandNames),Ci=jr?pn(sO(Ce,jr.start,jr.end,"").text):"";nr.getState().restageDraft({kind:er,name:D.row.value},Ci);return}}Ph.lastIndex=0;const Be=Ph.exec(_e.text);if(Oi.current=Be?Be[0].trim():null,D.kind==="command"&&de.run&&f6(D,rt.armedOnlyCommands)){const er=znn({draft:_e.text,caret:_e.caret,commandNames:rt.commandNames,armedOnlyCommands:rt.armedOnlyCommands});if(er.kind==="armed"){da(er.text,er.caret,mnn(er.text.trim(),D.command.destination,q5e(D.command.destination)?xs:!0));return}}if(Zn({capture:Th(In.current,_e.text,_e.caret,"completion"),buffer:_e.text,caret:_e.caret}),!(de.run&&(D.kind==="command"?lTe(D.command.destination,rt.effectiveEntry(D.command.destination)):rt.inline?.runs??!1)&&!!ce))return;const Zt=qr(_e.text,_e.caret,"pick");Zt.kind!=="send"&&await Wm(Zt,Ce,kr)},[Ce,kr,rt,Zn,ce,qr,Wm,da,xs,ln,UP]),sW=$.useCallback(D=>{const de=rnn(Ce,kr,D,rt.commandNames);de&&(qe.current=de.caret,qn(de.text),Kr(de.caret))},[Ce,kr,rt.commandNames,qn]),lW=$.useCallback(D=>{if(ln)return;const de=F5e(Ce,kr);if(!de)return;const _e=ken(D),Be=Ce.slice(de.end,de.end+1),cn=de.start>0&&(Be===" "||Be===`
967
- `)?1:0,Zt=sO(Ce,de.start,de.end+cn,_e),er=_e.endsWith('"')?Zt.caret-1:Zt.caret;qe.current=er,qn(Zt.text),Kr(er),Ao.remember(D.path),Ao.close()},[Ce,kr,Ao,qn,ln]),NP=$.useCallback(D=>{if(ln||!di.token)return;const de=ktn(Ce,di.token,D.name);di.close(),qe.current=de.caret,qn(de.text),Kr(de.caret)},[Ce,di,qn,ln]),bTe=$.useCallback(D=>{const de=bn.current;return de===null||!(D.metaKey||D.ctrlKey)||D.altKey||D.shiftKey||D.key.toLowerCase()!=="z"?!1:(bn.current=null,qe.current=de.caret,de.plain>0&&vn({chars:de.plain,over:de.text}),qn(de.text),Kr(de.caret),!0)},[vn,qn]),wTe=$.useCallback(D=>{if(ln)return;if(Hn(D)){D.preventDefault();return}if(xTe(D)){D.preventDefault();return}if(bTe(D)){D.preventDefault();return}if(ntn(D,Ao,lW)){D.preventDefault();return}if(Mnn(D,rt,WP,sW)){D.preventDefault();return}if(Ktn(D,di,NP)){D.preventDefault();return}if(Ie!==null&&D.key==="Escape"){D.preventDefault(),Gq(l??"");return}if(Ie!==null&&CWe(D)){const Be=Ie.turns.at(-1),cn=Be?Yi.getState().streams[Be.asideId]:void 0;if(!Be||!pue(cn,c))return;D.preventDefault();const Zt=l??"",er=Date.now(),jr=AWe(We.current,Be.asideId,er);if(jr==="arm"){We.current={turnId:Be.asideId,at:er},Yi.getState().setAsideNotice(Zt,rG(IE));return}if(jr==="ignore")return;We.current=null,fue(Zt).catch(()=>{});return}if(D.key==="Backspace"||D.key==="Delete"){const Be=men(kr,D.key==="Backspace"?"back":"forward",le.spans,le.resolved);if(Be&&!D.nativeEvent.isComposing){const cn=sO(Ce,Be.start,Be.end,"");qe.current=cn.caret,Kr(cn.caret),qn(cn.text),D.preventDefault();return}}const de=cr.current,_e=crn();if(_e&&Gze(D,{value:Ce,selectionStart:de?.selectionStart??null,selectionEnd:de?.selectionEnd??null})){_e.focus(),D.preventDefault();return}if(Nm&&D.key==="Enter"&&!D.shiftKey&&!D.nativeEvent.isComposing){D.preventDefault(),Qv();return}if(D.key==="Enter"&&!D.shiftKey&&!D.nativeEvent.isComposing){const Be=zP(Ce,kr);if(Be.kind!=="send"){D.preventDefault(),Wm(Be,Ce,kr);return}}Am(D)},[rt,WP,sW,di,NP,Am,Hn,zP,Wm,Ce,kr,ln,Ie,l,c]),cW=$.useRef(null),rl=$.useCallback(D=>{h6=!1,cr.current?.focus({preventScroll:D?.preventScroll===!0})},[cr]),STe=$.useCallback(()=>{Yze(Ce)!==null&&qn("")},[Ce,qn]);$.useImperativeHandle(nt,()=>({focusInput:rl,openWorkingDirectoryMenu:()=>{cW.current?.openMenu()},submitNow:()=>wv(),consumeApprovalAnswerDraft:STe}));const uW=$.useCallback(()=>cr.current,[cr]);$.useEffect(()=>f9e(rl,uW),[rl,uW]);const il=$.useRef(null),OW=$.useRef(Ce);$.useLayoutEffect(()=>{OW.current=Ce},[Ce]);const dW=$.useCallback(D=>{il.current===D&&(il.current=null,Bn.current.delete(D.index))},[]),kv=$.useCallback(D=>{if(il.current!==D)return!1;const de=VPt({buffer:OW.current,cleared:D.cleared});return de?(Bn.current.set(D.index,D.payload),il.current===D&&(il.current=null),D.toastId!==null&&O0(D.toastId),Zn({capture:Th(In.current,de.buffer,de.caret,"arrival"),buffer:de.buffer,caret:de.caret}),tn(null),!0):!1},[Zn,tn]);$.useLayoutEffect(()=>{const D=il.current;D!==null&&D.cleared.buffer!==Ce&&(D.toastId!==null&&O0(D.toastId),dW(D))},[Ce,dW]);const xTe=$.useCallback(D=>{const de=il.current;return de===null||!(D.metaKey||D.ctrlKey)||D.altKey||D.shiftKey||D.key.toLowerCase()!=="z"?!1:(kv(de),!0)},[kv]),fW=$.useCallback(D=>{kv(D)&&rl()},[rl,kv]),QTe=$.useCallback(D=>{if(ln)return;const de=Bn.current.get(D);if(!de)return;const _e=DPt({buffer:Ce,payload:de});if(!_e.cleared)return;const Be=il.current;Be&&(il.current=null,Bn.current.delete(Be.index),Be.toastId!==null&&O0(Be.toastId));const cn={index:D,payload:de,cleared:_e,toastId:null};il.current=cn,Zn({capture:Th(In.current,_e.buffer,_e.caret,"arrival"),buffer:_e.buffer,caret:_e.caret}),tn({key:de.key,index:D,over:_e.buffer}),cn.toastId=Zm(IPt(D),{action:{label:GPt,onClick:()=>fW(cn)}}),rl()},[Zn,rl,ln,Ce,tn,fW]),kTe=SKt(!!v?.active),hW=S&&!v?.active&&(kTe.held||Re)&&!(t&&d),PTe=!!v?.active||hW,TTe=ln||Re||yt||Ce.trim().length>0;$.useEffect(()=>{const D=cr.current;D&&(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)},[Ce,cr,Re,yt]);const pW=$.useRef(!1);$.useEffect(()=>{const D=Re||yt,de=pW.current&&!D;if(pW.current=D,!J&&!de||ln||D)return;const _e=document.activeElement;!(_e&&(_e.tagName==="INPUT"||_e.tagName==="TEXTAREA"))&&!Q&&cr.current?.focus({preventScroll:!0})},[J,ln,Re,yt,cr,Q]),$.useEffect(()=>{window.electron.ipcRenderer.invoke("get-platform-info").then(D=>{hr(D.platform)}).catch(D=>{console.error("Failed to get platform info:",D)})},[]);const Qs=$.useRef(null),_Te=250,mW=$.useRef(Te);$.useEffect(()=>{mW.current=Te}),$.useEffect(()=>(Qae("message-input",Re||ge),()=>Qae("message-input",!1)),[Re,ge]),$.useEffect(()=>{mW.current?.(Re)},[Re]);const Su=$.useCallback(D=>{De(!1);const de=jt.current;if(!de)return;const _e=Qs.current?.startedAt??null,Be=_e===null?Number.POSITIVE_INFINITY:performance.now()-_e;if(Qs.current=null,de.state==="inactive"){fe(!1);return}(D==="abort"||Be<_Te)&&(de.onstop=()=>{if(de.stream)for(const cn of de.stream.getTracks())cn.stop();Je(null),Mt.current=[]}),de.stop(),fe(!1)},[]);$.useEffect(()=>()=>{const D=Qs.current!==null;Qs.current=null;const de=jt.current;if(de&&de.state!=="inactive"){Su("abort");return}D&&De(!1)},[Su]);const YP=$.useCallback((D="release")=>{const de=Qs.current;if(de){if(de.startedAt===null){Qs.current=null,De(!1);return}Su(D)}},[Su]),gW=$.useCallback(async()=>{if(!(ln||!Di)&&!Qs.current)if(navigator?.mediaDevices?.getUserMedia){const D={startedAt:null};Qs.current=D,De(!0);try{const de=await navigator.mediaDevices.getUserMedia({audio:!0});if(Qs.current!==D){for(const _e of de.getTracks())_e.stop();return}jt.current=new MediaRecorder(de),Mt.current=[],jt.current.ondataavailable=_e=>{Mt.current.push(_e.data)},jt.current.onstop=()=>{const _e=new Blob(Mt.current,{type:"audio/webm"});Je(_e);for(const Be of de.getTracks())Be.stop()},jt.current.start(),D.startedAt=performance.now(),De(!1),fe(!0),Je(null)}catch(de){if(Qs.current!==D)return;Qs.current=null,De(!1),console.error("Error accessing microphone:",de),oi("Error accessing microphone. Please ensure microphone permissions are granted.")}}else console.error("This runtime exposes no MediaRecorder"),oi("Dictation is not available on this device.")},[Di,ln]),GP=$.useCallback(()=>{Re&&Su("release")},[Re,Su]),IP=$.useCallback(()=>{Re&&Su("abort")},[Re,Su]);$.useEffect(()=>{if(!Re&&!ge)return;const D=de=>{if(Re){de.key==="Enter"?(de.preventDefault(),GP()):de.key==="Escape"&&(de.preventDefault(),IP());return}de.key==="Escape"&&(de.preventDefault(),YP("abort"),De(!1))};return window.addEventListener("keydown",D),()=>{window.removeEventListener("keydown",D)}},[Re,ge,GP,IP,YP]);const $W=$.useCallback(async()=>{if(Se)try{vt(!0);const D=await Mle.createTranscription(wf.baseUrl,{file:new File([Se],"recording.webm",{type:"audio/webm"})});if(D.result?.text){const de=D.result?.text||"";ao.current=!0,Sv(de)}else sp(uze);Je(null)}catch(D){console.error("Error transcribing audio:",D),oi(Y6e(D))}finally{vt(!1)}},[Se,Sv]);$.useEffect(()=>{Se&&$W()},[Se,$W]);const yW=$.useRef(!0);$.useEffect(()=>{if(typeof IntersectionObserver>"u")return;const D=cr.current;if(D===null)return;const de=new IntersectionObserver(_e=>{const Be=_e[_e.length-1];Be!==void 0&&(yW.current=Be.isIntersecting)});return de.observe(D),()=>de.disconnect()},[cr]),KKt("message-input",j5e.MESSAGE_INPUT,{start:gW,stop:YP},()=>!!(!ln&&!Re&&!yt&&Di&&yW.current));const XTe=D=>{if(D.preventDefault(),ln||Q)return;if(k){Qv();return}if(!Ce.trim()&&ye.length===0||Uo())return;const de=zP(Ce,kr);if(de.kind!=="send"){Wm(de,Ce,kr);return}wv()},ZP=$.useCallback(D=>{ln&&D.preventDefault()},[ln]),RTe=$.useCallback(D=>{!ln&&!Nm||(D.preventDefault(),Nm&&!ln&&Qv())},[ln,Nm,Qv]),ETe=D=>{u&&$e(u,D)},qTe=async()=>{const D=await window.electron.ipcRenderer.invoke("show-open-dialog",{properties:["openFile","multiSelections"]});if(!D.canceled&&D.filePaths.length>0&&u)for(const de of D.filePaths)oe(u,{id:is(),path:t$(de)})},jTe=D=>{if(ln)return;const de=D.clipboardData?.getData("text/plain")??"";if(de&&In.current.arm!==null){const Be=D.currentTarget,cn=XPt({capture:In.current,buffer:Ce,caret:Be.selectionEnd??Ce.length,selection:{start:Be.selectionStart??Ce.length,end:Be.selectionEnd??Ce.length},pasted:de,index:Hr.current,taken:Ra()});if(cn){D.preventDefault(),Zn(cn),vn(null);return}}de&&(Ft.current=bPt(de));const _e=D.clipboardData?.items;if(_e){for(let Be=0;Be<_e.length;Be++)if(_e[Be].type.indexOf("image")!==-1||_e[Be].kind==="file"){const cn=_e[Be].getAsFile();if(cn){const Zt=new FileReader;Zt.onload=er=>{er.target?.result&&u&&oe(u,{id:is(),path:er.target.result})},Zt.readAsDataURL(cn)}}}},CTe=D=>{ln||D.dataTransfer?.types.includes("Files")&&(D.preventDefault(),D.stopPropagation(),D.dataTransfer.dropEffect="copy",DP(!0))},zTe=D=>{D.currentTarget.contains(D.relatedTarget)||DP(!1)},ATe=D=>{if(DP(!1),ln)return;const de=D.dataTransfer?.files;!de||de.length===0||(D.preventDefault(),D.stopPropagation(),u&&UTe(u,Array.from(de)))},UTe=async(D,de)=>{for(const _e of de){const Be=window.api?.getPathForFile?window.api.getPathForFile(_e):"";if(Be){oe(D,{id:is(),path:t$(Be)});continue}const cn=await lrn(_e);cn&&oe(D,{id:is(),path:cn})}},[vW,DP]=$.useState(!1),WTe=D=>{ln||(Ce||p?.(),qe.current=D.length,qn(D),Kr(D.length),cr.current?.focus())},VP=wl(Nt)?Nt.value!==""?KPt:ji?JPt:e5t:ZPt({unredacted:NO!==null?t5t(NO,CP(Ce)?h1e:void 0):null,armed:Nt.arm!==null&&c1e(Ce,Ce.length)!==null,cleared:Oa===null?null:{key:Oa.key,index:Oa.index},undoCap:dTe(En==="darwin")}),NTe=$.useMemo(()=>En==="darwin"?"Cmd+Shift+S":"Ctrl+Shift+S",[En]),MP=$.useRef(null),YTe=D=>{u&&(MP.current=be.findIndex(de=>de.id===D),ie(u,D))};$.useEffect(()=>{const D=MP.current;if(D===null)return;MP.current=null;const de=document.querySelectorAll(Orn),_e=de[Math.min(D,de.length-1)];_e?_e.focus():rl()},[be,rl]);const Wo=$.useMemo(()=>{const de=l5(Ce,be)!==""||ye.length>0,_e=Q||b?.message&&pOe.test(b.message)?[{label:"Connect a provider",onClick:()=>oO.getState().openConnect()}]:[];return{message:b?.message,muted:b?.muted===!0,polite:b?.polite===!0,actions:[...b?.actions??[],..._e],retry:b?.retry===!0,clear:b?.muted!==!0&&(b?.onClear!==void 0||de)}},[b,Ce,be,ye,Q]),If=LEt(),bW=j("block text-body-sm",W?"px-2 pb-1":"px-4 pb-2",NO!==null?"text-warning":"text-ink-muted"),wW=AP&&Ce.length>0,GTe=h.jsx("output",{className:j(ni,"block pb-2",If.issue.kind==="hidden"&&"hidden"),children:h.jsx(Stn,{issue:If.issue,onSignIn:If.start,onCancel:If.cancel,onDismiss:If.dismiss,isSmallView:W,onFocusComposer:()=>cr.current?.focus()})}),Ym=W4e(B),ITe=Ym&&!I4e(Ym,Y4e(If.issue))?h.jsx("output",{className:j(ni,"block pb-2"),children:h.jsx(ZKt,{access:Ym,isSmallView:W,onSwitchModel:B?.onCommand?()=>B.onCommand?.({name:"model",args:""}):void 0,onConnect:()=>oO.getState().openConnect({providerId:Ym.provider})})}):null,SW=ge||!Re&&!yt&&!(t&&d),ZTe=h.jsxs("form",{onSubmit:XTe,"data-chat-region":"composer","aria-label":Hle.composer,tabIndex:-1,className:"w-full",children:[h.jsx(qW,{fallback:null,children:h.jsx(vKt,{frontend:B?.frontend,runDetails:ne,isSmallView:W,askExpanded:I,onAskToggle:N,askOutcomes:Z,onNote:M,onFocusComposer:()=>cr.current?.focus()},u)}),!G4e(Ym)&&GTe,ITe,a,o?.blocksInput&&o.placeholder&&!o.statedByNode&&Ce.trim().length>0?h.jsx("p",{id:eoe,className:"mb-2 text-meta text-ink-muted",children:o.placeholder}):null,o?.node,Wo.message!==void 0&&h.jsxs("div",{role:Wo.polite?"status":"alert","data-composer-notice":!0,"data-composer-queued":b?.message===pa.queuedSend?!0:void 0,className:j(ni,"flex flex-wrap items-center gap-x-3 gap-y-1 text-body-sm",W?"px-2 pb-1":"px-4 pb-2"),children:[h.jsxs("p",{className:j("flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",Wo.muted?"text-ink-muted":"text-danger"),children:[!Wo.muted&&h.jsx("span",{className:"flex shrink-0 items-center pt-0.5",children:h.jsx(ip,{size:14,"aria-hidden":"true"})}),h.jsx("span",{className:j("min-w-0 break-words",!Wo.muted&&"font-medium"),children:Wo.message})]}),(Wo.retry||Wo.clear||Wo.actions.length>0)&&h.jsxs(h.Fragment,{children:[Wo.actions.map(D=>h.jsx(je,{type:"button",variant:"link",size:"sm",className:j("min-h-6 cursor-pointer text-body-sm underline"),onClick:D.onClick,children:D.label},D.label)),Wo.retry&&b?.onRetry&&h.jsx(je,{type:"button",variant:"link",size:"sm",className:j("min-h-6 cursor-pointer font-semibold text-body-sm underline"),onClick:()=>b.onRetry?.(),children:HEe}),Wo.clear&&b?.onClear&&h.jsx(je,{type:"button",variant:"link",size:"sm","aria-label":"Clear message",className:j("min-h-6 cursor-pointer text-ink-dim text-body-sm underline"),onClick:()=>b.onClear?.(),children:KEe})]})]}),x&&h.jsx("output",{className:j(ni,"block text-body-sm text-ink-muted",W?"px-2 pb-1":"px-4 pb-2"),children:x}),l&&Ie!==null&&h.jsx(nen,{sessionId:l,sessionStreaming:c,isSmallView:W,onReturnFocus:()=>cr.current?.focus()}),h.jsxs("div",{className:j(ni,"relative w-full"),children:[h.jsx(Inn,{state:rt,onPick:WP,onActionPick:UP}),h.jsx(itn,{state:Ao,onPick:lW}),h.jsx(Htn,{state:di,onPick:NP}),!K&&!rt.open&&!Ao.open&&!di.open&&h.jsx(g3t,{visible:m,onClick:y,hasNewActivity:g}),h.jsx("output",{id:Hae,className:j(ni,VP?bW:"hidden"),children:VP}),wW&&h.jsx("output",{id:Kae,className:j(ni,bW),children:nrn}),se>0&&h.jsx("span",{id:Jae,className:"sr-only",children:se===1?"1 reference points outside this session's working directory; the agent will ask you to approve it before reading.":`${se} references point outside this session's working directory; the agent will ask you to approve them before reading.`}),i&&h.jsx("span",{id:toe,className:"sr-only",children:"The message that could not be delivered has Send again and Edit controls in the conversation above this box: press Shift+Tab to reach them."}),h.jsxs("div",{className:j(drn,vW?void 0:frn,W?"gap-2 rounded-md p-2":"gap-3 rounded-frame p-4",ni,vW&&"outline-dashed outline-2 outline-accent outline-offset-2"),"data-lo-composer-measure":"","data-tour-tag":"chat-input-textarea",children:[(be.length>0||ye.length>0)&&h.jsxs("div",{className:"max-h-[240px] shrink-0 overflow-y-auto",children:[be.length>0&&h.jsx(S8,{replies:be,onRemoveReply:YTe}),ye.length>0&&h.jsx(qNe,{attachments:ye.map(D=>D.path),onRemoveAttachment:D=>ETe(ye[D].id),disabled:ln||Re||yt})]}),h.jsxs("div",{className:"relative isolate w-full",children:[h.jsx(pJt,{text:Ce,payloads:Bn.current,capture:Nt,fieldRef:cr,mirrorRef:dt,isSmallView:W}),h.jsx(qen,{text:Ce,spans:le.spans,resolved:le.resolved,fieldRef:cr,isSmallView:W}),h.jsx(Otn,{draft:Ce,runs:oW,textareaRef:cr,fieldClassName:Hx(W),refused:ln,children:h.jsx("textarea",{ref:cr,"data-region-entry":!0,className:j(Hx(W),"block",W?"max-h-24":"max-h-28","resize-none overflow-y-auto bg-transparent",yTe?"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:Re?Es.recording:WUe({unavailable:A,secretAnswer:AP,inputDisabled:ln,awaitingAnswer:r,asideAttached:Ie!==null,sendingUnsettled:WO||Um,awaitingReply:n,stopping:v?.stopping===!0,noProvider:Q,idle:xe,hostLine:o?.placeholder??null}),value:Ce,onCompositionStart:()=>wu(!0),onCompositionEnd:()=>wu(!1),onChange:D=>{io.current=!0;const de=D.target.value,_e=D.target.selectionStart??de.length;bn.current=null;const Be=kPt(In.current,Ce,de,_e,"typing");Be.buffer!==de?(qe.current=Be.caret,Kr(Be.caret)):Kr(_e),Be.capture!==In.current&&Nr(Be.capture),!Ce&&Be.buffer&&p?.(),Qi.current=Be.buffer,Ea(Be.capture,Be.buffer),qn(Be.buffer),Date.now()-Wr.current>=irn&&b?.onDismiss?.()},onSelect:D=>{const de=D.target,_e=qe.current;if(_e!==null){de.selectionStart===_e&&(qe.current=null);return}Kr(de.selectionStart),Nr(Th(In.current,Ce,de.selectionStart,"caret"))},onKeyDown:wTe,onPointerDown:()=>{h6=!0},onPaste:jTe,rows:1,readOnly:ln,"aria-disabled":ln||void 0,"aria-label":"Message",role:"combobox","aria-describedby":[o?o.id:null,o?.blocksInput&&o.placeholder&&!o.statedByNode&&Ce.trim().length>0?eoe:null,VP?Hae:null,wW?Kae:null,se>0?Jae:null,A?B1e:null,i?toe:null].filter(Boolean).join(" ")||void 0,"aria-expanded":rt.open||Ao.open,"aria-controls":rt.open?rt.listId:Ao.open?Ao.listId:void 0,"aria-activedescendant":(rt.open?rt.activeDescendantId:Ao.activeDescendantId)??void 0})}),h.jsx(dJt,{small:W,text:Ce,payloads:Bn.current,capture:Nt,mirrorRef:dt,fieldRef:cr,onClear:ln?null:QTe,onControlUnmounted:rl})]}),Re&&h.jsx(Kue,{isRecording:Re}),yt&&h.jsxs("div",{"data-transcribing-indicator":"",className:"mt-1 flex items-center gap-2 px-2 [min-height:1.5rem]",children:[h.jsx("span",{className:"font-medium text-body-sm text-ink-muted",children:"Processing audio"}),h.jsx(pTe,{})]}),h.jsxs("div",{className:"flex min-w-0 flex-nowrap items-center gap-x-2",children:[B&&h.jsx(qW,{fallback:null,children:h.jsx($Ge,{frontend:B.frontend,onCommand:B.onCommand,effortEntities:B.effortEntities,draft:B.draft,onOpenDraftPicker:B.onOpenDraftPicker,draftResolution:B.draftResolution,held:B.held,readingsDropped:B.readingsDropped,pendingModel:B.pendingModel,costChannels:B.costChannels,controlsThirdBox:PTe})}),h.jsxs("div",{className:"contents",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-1 shrink-0",children:[h.jsx(At,{content:"Attach file",children:h.jsx("span",{children:h.jsx(je,{variant:"ghost",size:W?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:ZP,onClick:qTe,"aria-label":"Attach file","data-tour-tag":"chat-input-attach-file-button",disabled:ln||Re||yt,children:h.jsx(W7e,{"aria-hidden":"true"})})})}),Ne!==void 0&&h.jsx($tn,{ref:cW,currentWorkingDirectory:Ne,writePath:E,pending:q,pendingAccepted:z,readOnlyReason:E?void 0:R??R5e})]}),h.jsxs("div",{className:"ml-auto flex order-3 items-center gap-1",children:[ge&&SW&&h.jsx("output",{"data-preparing-indicator":"",className:"shrink-0 font-medium text-body-sm text-ink-muted",children:W?"Starting":"Starting recording"}),SW&&h.jsx(At,{content:ge?"Starting recording":Di?`Start recording (${NTe} or hold ${c6().label})`:Vi,children:h.jsx("span",{children:h.jsx(je,{variant:"ghost",size:W?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:ZP,onClick:gW,"aria-label":"Start recording","aria-busy":ge||void 0,disabled:ln||!Di,children:ge?h.jsx(hs,{size:"sm"}):h.jsx(k7e,{"aria-hidden":"true"})})})}),Re&&h.jsxs(h.Fragment,{children:[h.jsx(At,{content:"Confirm recording (Enter)",children:h.jsx("span",{children:h.jsx(je,{variant:"ghost",size:W?"icon-sm":"icon",className:"text-success hover:bg-success-wash hover:text-success",onClick:GP,"aria-label":"Confirm recording",children:h.jsx(Ou,{"aria-hidden":"true"})})})}),h.jsx(At,{content:"Cancel recording (Esc)",children:h.jsx("span",{children:h.jsx(je,{variant:"ghost",size:W?"icon-sm":"icon",className:"text-danger hover:bg-danger-wash hover:text-danger",onClick:IP,"aria-label":"Cancel recording",children:h.jsx(Zi,{"aria-hidden":"true"})})})})]}),hW&&h.jsx("span",{"aria-hidden":"true","data-interrupt-slot":"",className:j("pointer-events-none invisible flex items-center"),children:h.jsx(je,{variant:"danger",size:W?"icon-sm":"icon",type:"button",tabIndex:-1,children:h.jsx(_w,{"aria-hidden":"true"})})}),v?.active&&h.jsx(At,{content:"Stop this session's current work (Esc)",children:h.jsx("span",{children:h.jsx(je,{variant:"danger",size:W?"icon-sm":"icon",type:"button",onClick:v.onStop,"aria-label":"Stop","aria-keyshortcuts":"Escape","data-stopping":v.stopping===!0?"true":void 0,"aria-busy":v.stopping===!0?!0:void 0,className:j("data-[stopping]:border-danger data-[stopping]:text-ink data-[stopping]:bg-[color-mix(in_oklab,var(--color-danger-wash)_80%,var(--color-danger))]"),children:h.jsx(_w,{"aria-hidden":"true"})})})}),t&&d?h.jsx(At,{content:"Stop agent",children:h.jsx("span",{children:h.jsx(je,{variant:"danger",size:W?"icon-sm":"icon",type:"button",onClick:()=>f?.(d),"aria-label":"Stop agent",children:h.jsx(_w,{"aria-hidden":"true"})})})}):!Re&&!yt&&h.jsx(At,{content:Ie!==null&&!r?"Ask the aside":"Send message",children:h.jsx("span",{children:h.jsx(je,{variant:"primary",size:W?"icon-sm":"icon",type:"submit",onPointerDown:RTe,disabled:ln||Nm||!Ce.trim()&&ye.length===0,className:"rounded-full disabled:bg-surface","aria-label":Ie!==null&&!r?"Ask the aside":"Send message",children:h.jsx(zle,{"aria-hidden":"true"})})})})]})]})]})]})]}),Q&&!mn?h.jsx("div",{className:j("mt-2",ni),children:h.jsx(DJt,{})}):null,(Q||k)&&qt?h.jsx("div",{className:j("mt-2",ni),children:h.jsx("output",{className:"block text-body-sm text-ink-muted",children:k?"Choose a model for this conversation before sending.":"Connect a provider to send."})}):null]});return h.jsxs("div",{className:j(Que,"flex w-full flex-col items-center",St?"grow":"shrink-0",G?void 0:ONe,W?"pb-1 pt-0.5":"pb-4 pt-2"),"data-lo-composer-band":!0,ref:He,onDragOver:CTe,onDragLeave:zTe,onDrop:ATe,children:[h.jsx("div",{"data-lo-composer-splash":"",className:j("flex w-full flex-col items-center justify-center",St?"grow":null),children:h.jsx("div",{ref:en,className:j(YO?"flex w-full flex-col items-center gap-6 py-4":"hidden"),children:YO?h.jsxs(h.Fragment,{children:[h.jsx("span",{"data-lo-empty-mark":"",className:"contents",children:h.jsx(ern,{className:"size-8",tone:"ink-muted"})}),Q?null:h.jsx("h2",{className:"text-center text-ink text-title",children:"What can I help you with today?"}),Q?h.jsx("div",{className:j("w-full",ni),children:h.jsx(ZJt,{})}):h.jsxs("div",{className:j("flex flex-col gap-3",ni),children:[h.jsx(vtn,{band:Qt,splash:ct,foot:gn,suggestions:ht,disabled:TTe,onRefusedPress:ZP,onSelect:WTe,focusComposer:()=>cr.current?.focus()}),h.jsx(uJt,{suspended:Ce.trim().length>0,mentionsEnabled:ee})]})]}):null})}),mn?h.jsx("div",{className:j("mb-2 mt-2",ni),children:h.jsx(IJt,{selection:Jt})}):null,h.jsx("div",{ref:Ct,"data-lo-composer-foot":"",className:"w-full",children:ZTe})]})}),prn=$.memo(hrn);prn.displayName="MessageInput";const gTe=1024,$1=1024*1024,rW=.85,mrn=new Set(["image/png","image/jpeg","image/webp"]),grn=[{maxEdge:gTe,quality:.8},{maxEdge:768,quality:.7},{maxEdge:512,quality:.6}];function $rn(e){const t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}function yrn(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 vrn(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 brn(e,t,n,r,i){const a=Math.max(e.width,e.height),o=a>r?r/a:1,s=Math.max(1,Math.round(e.width*o)),l=Math.max(1,Math.round(e.height*o)),c=new OffscreenCanvas(s,l),u=c.getContext("2d");if(!u)return null;u.drawImage(e,0,0,s,l);const O=[],d=await c.convertToBlob({type:"image/png"}),f=new Uint8Array(await d.arrayBuffer());if(f.byteLength<=$1&&O.push({bytes:f,mime_type:"image/png"}),f.byteLength>$1||i<rW){const g=new OffscreenCanvas(s,l),y=g.getContext("2d");if(!y)return null;y.fillStyle="#ffffff",y.fillRect(0,0,s,l),y.drawImage(e,0,0,s,l);const v=await g.convertToBlob({type:"image/jpeg",quality:i}),S=new Uint8Array(await v.arrayBuffer());O.push({bytes:S,mime_type:"image/jpeg"}),f.byteLength>$1&&S.byteLength>f.byteLength&&O.push({bytes:f,mime_type:"image/png"})}let p=null,m=Number.POSITIVE_INFINITY;for(const g of O)g.bytes.byteLength<m&&(p=g,m=g.bytes.byteLength);return p?m>=n?t:{data_b64:vrn(p.bytes),mime_type:p.mime_type}:null}async function wrn(e){if(!mrn.has(e.mime_type)||typeof createImageBitmap!="function"||typeof OffscreenCanvas!="function")return null;try{return await createImageBitmap(new Blob([yrn(e.data_b64)],{type:e.mime_type}))}catch{return null}}async function Srn(e,t,n,r){const i=$rn(e.data_b64);try{return Math.max(t.width,t.height)<=n&&i<=$1&&r>=rW?e:await brn(t,e,i,n,r)??e}catch{return e}}async function xrn(e,t,n){if(!e.length)return e;const r=await Promise.all(e.map(i=>wrn(i)));try{return await Qrn(e,r,t,n)}finally{for(const i of r)i?.close()}}async function Qrn(e,t,n,r){const i=(c,u)=>Promise.all(e.map((O,d)=>{const f=t[d];return f?Srn(O,f,c,u):Promise.resolve(O)})),a=await i(gTe,rW);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 grn){const u=await i(c.maxEdge,c.quality);if(l(u)<=n)return u}return o}const krn=/^data:(image\/(png|jpeg|gif|webp));base64,(.+)$/,Prn=/^file:\/\//,Trn={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp"};async function sln(e,t){const n=[],r=[];for(const a of e){const o=krn.exec(a);if(o){n.push({data_b64:o[3],mime_type:o[1]});continue}const s=a.split(".").pop()?.toLowerCase()??"",l=Trn[s];if(!l||!window.api?.readFile)continue;const c=await window.api.readFile(a.replace(Prn,""),"base64");c.success?n.push({data_b64:c.data,mime_type:l}):r.push(a)}const i=Math.max(0,n.length-ZE);return{images:await xrn(n.slice(0,ZE),oQ,a=>zq(t,a)),unreadable:r,overflow:i}}function lln(e){if(e.length===0)return null;const t=e.map(YQ);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.`}function cln(e){if(e<=0)return null;const t=ZE,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 uln(e){const t=e.trim();if(t.startsWith("="))return null;const n=t.toLowerCase();return n==="pause"||n==="resume"||n==="status"?n:null}function Oln(e){const t=e.trim();return t.startsWith("=")?t.slice(1).trimStart():t}function dln(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 _rn(e){return jo(e,"Aida's controls could not reach the backend.")}const fln="The chief of staff is switched off on this install.",Xrn="aida_no_provider",Rrn="aida_disabled";function hln(e,t){const n=e instanceof Ut?e.code:void 0;return n===Rrn?null:n===Xrn?{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. ${_rn(e)}`}}function pln(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 mln(e){const t=e?.greeting_state;return t==null||t==="owed"}function Ern(e){return e.eventKey===e.storeKey&&!e.focused}let ooe=!1;function gln(){if(ooe)return;ooe=!0;const e=an.persist?.getOptions?.()?.name??"conversation-input-store",t=n=>{Ern({eventKey:n.key,storeKey:e,focused:document.hasFocus()})&&an.persist?.rehydrate?.()?.catch?.(()=>{})};window.addEventListener("storage",t)}export{Ay as $,gUe as A,xUe as B,Rt as C,Qa as D,at as E,bl as F,zn as G,Pf as H,P as I,Xn as J,gr as K,Rn as L,Sn as M,KQ as N,Hy as O,Er as P,Qr as Q,Ur as R,ds as S,t9 as T,la as U,Fn as V,AA as W,ir as X,bs as Y,txe as Z,Ut as _,wi as a,UQe as a$,min as a0,jo as a1,Hrn as a2,gin as a3,eU as a4,fU as a5,yc as a6,Rr as a7,aOe as a8,r$ as a9,prn as aA,Nze as aB,gln as aC,Aan as aD,Can as aE,K0 as aF,oi as aG,yq as aH,Md as aI,l6e as aJ,Ey as aK,Oin as aL,qy as aM,asn as aN,$l as aO,bh as aP,Pa as aQ,Xle as aR,Oz as aS,wle as aT,Fce as aU,din as aV,Za as aW,m9t as aX,hU as aY,CQe as aZ,pv as a_,gsn as aa,$sn as ab,axe as ac,mze as ad,Xz as ae,Uq as af,zy as ag,wf as ah,dUe as ai,fln as aj,sln as ak,lln as al,Use as am,cln as an,Qan as ao,Vrn as ap,nr as aq,Brn as ar,pa as as,kHe as at,bd as au,nqe as av,JEe as aw,an as ax,am as ay,vd as az,bin as b,NN as b$,Bsn as b0,pUt as b1,ane as b2,ine as b3,nke as b4,TU as b5,iP as b6,r8t as b7,n8t as b8,Wp as b9,ve as bA,OCe as bB,Vr as bC,Zm as bD,Q6e as bE,_5 as bF,gze as bG,ISe as bH,KN as bI,eY as bJ,ble as bK,kin as bL,hz as bM,xan as bN,Om as bO,Sze as bP,cm as bQ,pi as bR,Kse as bS,z3e as bT,N3e as bU,I3e as bV,M3e as bW,Z3e as bX,D3e as bY,$q as bZ,F3e as b_,t8t as ba,e8t as bb,fx as bc,gv as bd,kU as be,xU as bf,Pd as bg,dx as bh,PUe as bi,VS as bj,ni as bk,ONe as bl,Que as bm,_w as bn,Zrn as bo,Dan as bp,pin as bq,k5t as br,jz as bs,van as bt,fWe as bu,uue as bv,Ian as bw,Zan as bx,jd as by,Cy as bz,Fr as c,ssn as c$,L3e as c0,V3e as c1,Qin as c2,k1e as c3,Q5t as c4,Krn as c5,sp as c6,Jrn as c7,O0 as c8,_ze as c9,Jce as cA,gan as cB,A8e as cC,Zle as cD,psn as cE,hqt as cF,nxe as cG,msn as cH,b3t as cI,XC as cJ,Uoe as cK,$Q as cL,Oqe as cM,Jtn as cN,iln as cO,kc as cP,aln as cQ,tnn as cR,fxe as cS,jle as cT,h8 as cU,WKt as cV,vO as cW,Hce as cX,Ran as cY,UXt as cZ,GXt as c_,qle as ca,r3 as cb,I5t as cc,kO as cd,Ple as ce,jy as cf,lp as cg,vle as ch,SNe as ci,Mue as cj,K1e as ck,Y$ as cl,G$ as cm,hWe as cn,fCe as co,oCe as cp,HMt as cq,IO as cr,man as cs,aUe as ct,qc as cu,BMt as cv,bP as cw,wP as cx,yZt as cy,yP as cz,ke as d,u$ as d$,hH as d0,OH as d1,YXt as d2,MLt as d3,Xi as d4,dc as d5,bze as d6,Xan as d7,Aqt as d8,fd as d9,JCt as dA,p7t as dB,h7t as dC,q6e as dD,Dn as dE,gQ as dF,o6 as dG,lin as dH,vqe as dI,yqe as dJ,Fse as dK,Lse as dL,kan as dM,Pan as dN,T6e as dO,Tan as dP,_an as dQ,Ean as dR,jan as dS,wze as dT,QUe as dU,Z8e as dV,zan as dW,R5 as dX,BFe as dY,rBe as dZ,ODe as d_,UEt as da,cxe as db,UTt as dc,$6e as dd,kUe as de,EUe as df,yEt as dg,bsn as dh,Zd as di,Sle as dj,Zxe as dk,BS as dl,lx as dm,hne as dn,T9t as dp,ry as dq,b7t as dr,w7t as ds,v7t as dt,y7t as du,$7t as dv,g7t as dw,m7t as dx,Fk as dy,e7t as dz,_z as e,nan as e$,LFe as e0,Tfe as e1,b8e as e2,w8e as e3,h9e as e4,Pq as e5,Wk as e6,wz as e7,aan as e8,xsn as e9,gCe as eA,p7e as eB,mQ as eC,$le as eD,Y8 as eE,KH as eF,Ng as eG,Ain as eH,fce as eI,H7e as eJ,tan as eK,Jin as eL,PAe as eM,Tq as eN,_Ae as eO,tCe as eP,zin as eQ,dce as eR,Gin as eS,x2 as eT,oan as eU,C7e as eV,lAe as eW,Nin as eX,ean as eY,Lin as eZ,HAe as e_,Ssn as ea,n9e as eb,Kin as ec,Bin as ed,Hin as ee,ran as ef,ian as eg,qAe as eh,Yin as ei,Win as ej,Ws as ek,u0 as el,Iin as em,Cin as en,k2 as eo,Zin as ep,_C as eq,v3t as er,g3t as es,wsn as et,Din as eu,koe as ev,q1 as ew,LAe as ex,Min as ey,Q3t as ez,Cxe as f,Tn as f$,CAe as f0,Fin as f1,_3t as f2,_q as f3,GAe as f4,XEe as f5,Fc as f6,g5e as f7,lsn as f8,Iqt as f9,Sin as fA,win as fB,Xq as fC,can as fD,k3t as fE,yQ as fF,zrn as fG,bEt as fH,qA as fI,bon as fJ,mon as fK,$He as fL,pon as fM,RA as fN,Ife as fO,XA as fP,Zfe as fQ,Yfe as fR,Wfe as fS,Nfe as fT,von as fU,mqe as fV,P6 as fW,Sz as fX,Xce as fY,R9e as fZ,Ha as f_,lCe as fa,xce as fb,JNe as fc,nYe as fd,ton as fe,non as ff,Kan as fg,Jan as fh,eon as fi,ion as fj,lYe as fk,Jue as fl,son as fm,KCe as fn,OYe as fo,ron as fp,gYe as fq,lon as fr,aon as fs,tYe as ft,Yn as fu,oon as fv,yle as fw,Qze as fx,yze as fy,xin as fz,Or as g,qwe as g$,PO as g0,wt as g1,Ze as g2,Ot as g3,Con as g4,bi as g5,oD as g6,$m as g7,wo as g8,_c as g9,Zc as gA,$b as gB,sS as gC,FQ as gD,jon as gE,mu as gF,Lon as gG,Yon as gH,jnt as gI,zon as gJ,Aon as gK,_on as gL,Gon as gM,Pon as gN,Ton as gO,Non as gP,Ion as gQ,Don as gR,Mon as gS,Fon as gT,Eon as gU,qon as gV,Xon as gW,VQ as gX,Zon as gY,HQ as gZ,Ron as g_,ihe as ga,sn as gb,Wn as gc,Jd as gd,ss as ge,El as gf,kon as gg,Ov as gh,X8 as gi,E8 as gj,ZS as gk,_8 as gl,R8 as gm,q8 as gn,w7e as go,is as gp,kpe as gq,ott as gr,pO as gs,att as gt,Ln as gu,Wt as gv,kf as gw,Gi as gx,wr as gy,Ti as gz,XJ as h,a2e as h$,O8 as h0,Qae as h1,Mle as h2,qY as h3,uze as h4,Y6e as h5,KKt as h6,j5e as h7,qNe as h8,Kue as h9,Oon as hA,zGe as hB,iMe as hC,gBe as hD,G1 as hE,iA as hF,Bz as hG,Jq as hH,ede as hI,LGe as hJ,RGe as hK,DGe as hL,II as hM,PVe as hN,mDe as hO,cVe as hP,O7e as hQ,Cle as hR,kle as hS,YQ as hT,Ufe as hU,yHe as hV,QHe as hW,Poe as hX,hQ as hY,V_e as hZ,SN as h_,pTe as ha,W7e as hb,Bce as hc,c6 as hd,k7e as he,zle as hf,t$ as hg,nsn as hh,U6e as hi,W6e as hj,_1e as hk,R1e as hl,rsn as hm,gon as hn,F1 as ho,_Q as hp,POe as hq,iT as hr,ZVe as hs,IVe as ht,kOe as hu,con as hv,tde as hw,ua as hx,xO as hy,Yy as hz,Msn as i,xoe as i$,uqe as i0,B8e as i1,kz as i2,pCe as i3,dan as i4,QXt as i5,cue as i6,l8e as i7,fan as i8,Dse as i9,Rjt as iA,Qxe as iB,W5 as iC,om as iD,ba as iE,_Ue as iF,VUe as iG,qan as iH,RUe as iI,dsn as iJ,fsn as iK,hsn as iL,Ale as iM,yin as iN,Pze as iO,lan as iP,rln as iQ,Arn as iR,xQ as iS,oYe as iT,uan as iU,nln as iV,Han as iW,uNe as iX,_Y as iY,Vce as iZ,Qoe as i_,sin as ia,tin as ib,ein as ic,QN as id,Xze as ie,nin as ig,Tin as ih,BCe as ii,Pin as ij,_in as ik,Uze as il,Lue as im,TQ as io,P1e as ip,f8 as iq,P8 as ir,$on as is,Tle as it,ATt as iu,yon as iv,xle as iw,$tn as ix,san as iy,J0 as iz,el as j,Xin as j$,q8e as j0,yan as j1,P4t as j2,TSe as j3,xKt as j4,R5e as j5,Hsn as j6,zm as j7,uln as j8,dln as j9,sNe as jA,lNe as jB,Ban as jC,Uin as jD,Vin as jE,X3t as jF,Ksn as jG,Nrn as jH,Ise as jI,oln as jJ,aqe as jK,fQ as jL,Lrn as jM,Frn as jN,Irn as jO,Yrn as jP,eln as jQ,Oan as jR,NEe as jS,oAe as jT,sAe as jU,aAe as jV,jin as jW,qin as jX,Ein as jY,Yse as jZ,Yze as j_,_rn as ja,Oln as jb,Urn as jc,Wrn as jd,rin as je,v3e as jf,iin as jg,oin as jh,ain as ji,q5e as jj,Ek as jk,Van as jl,Yi as jm,Fan as jn,Man as jo,Lan as jp,San as jq,yxe as jr,xXt as js,Ry as jt,tqe as ju,Fle as jv,vin as jw,H6 as jx,Zze as jy,Grn as jz,Isn as k,zH as k$,Gse as k0,LEe as k1,wN as k2,n8e as k3,t8e as k4,Rin as k5,Drn as k6,tln as k7,g9e as k8,osn as k9,mJt as kA,Csn as kB,zsn as kC,tqt as kD,Psn as kE,Y3t as kF,ksn as kG,Tsn as kH,U3t as kI,Esn as kJ,Usn as kK,Asn as kL,Yk as kM,jsn as kN,qsn as kO,Rsn as kP,fz as kQ,U5e as kR,pxe as kS,Aq as kT,mln as kU,pln as kV,hln as kW,jqt as kX,sxe as kY,oxe as kZ,zTt as k_,Jsn as ka,h1 as kb,A7e as kc,oO as kd,pan as ke,$8e as kf,Mrn as kg,han as kh,uUe as ki,BSe as kj,Wsn as kk,csn as kl,Osn as km,exe as kn,ou as ko,usn as kp,SUe as kq,HSe as kr,_sn as ks,Nsn as kt,Ysn as ku,Xsn as kv,Gsn as kw,vQ as kx,MEt as ky,l2e as kz,Zsn as l,ysn as l0,vsn as l1,isn as l2,D8e as l3,V8e as l4,$an as l5,ern as l6,ban as l7,MUe as l8,wan as l9,fin as la,Gje as lb,Qsn as lc,X3e as ld,wqt as le,Nan as lf,Uan as lg,Wan as lh,Bm as li,Yan as lj,uin as lk,$in as ll,Xw as lm,Gan as ln,hin as lo,hon as lp,Vsn as m,Fsn as n,Dsn as o,Ep as p,Lsn as q,zd as r,FS as s,Lk as t,Hl as u,Ox as v,J8 as w,ey as x,Nxe as y,f7t as z};
967
+ `)?1:0,Zt=sO(Ce,de.start,de.end+cn,_e),er=_e.endsWith('"')?Zt.caret-1:Zt.caret;qe.current=er,qn(Zt.text),Kr(er),Ao.remember(D.path),Ao.close()},[Ce,kr,Ao,qn,ln]),NP=$.useCallback(D=>{if(ln||!di.token)return;const de=ktn(Ce,di.token,D.name);di.close(),qe.current=de.caret,qn(de.text),Kr(de.caret)},[Ce,di,qn,ln]),bTe=$.useCallback(D=>{const de=bn.current;return de===null||!(D.metaKey||D.ctrlKey)||D.altKey||D.shiftKey||D.key.toLowerCase()!=="z"?!1:(bn.current=null,qe.current=de.caret,de.plain>0&&vn({chars:de.plain,over:de.text}),qn(de.text),Kr(de.caret),!0)},[vn,qn]),wTe=$.useCallback(D=>{if(ln)return;if(Hn(D)){D.preventDefault();return}if(xTe(D)){D.preventDefault();return}if(bTe(D)){D.preventDefault();return}if(ntn(D,Ao,lW)){D.preventDefault();return}if(Mnn(D,rt,WP,sW)){D.preventDefault();return}if(Ktn(D,di,NP)){D.preventDefault();return}if(Ie!==null&&D.key==="Escape"){D.preventDefault(),Gq(l??"");return}if(Ie!==null&&CWe(D)){const Be=Ie.turns.at(-1),cn=Be?Yi.getState().streams[Be.asideId]:void 0;if(!Be||!pue(cn,c))return;D.preventDefault();const Zt=l??"",er=Date.now(),jr=AWe(We.current,Be.asideId,er);if(jr==="arm"){We.current={turnId:Be.asideId,at:er},Yi.getState().setAsideNotice(Zt,rG(IE));return}if(jr==="ignore")return;We.current=null,fue(Zt).catch(()=>{});return}if(D.key==="Backspace"||D.key==="Delete"){const Be=men(kr,D.key==="Backspace"?"back":"forward",le.spans,le.resolved);if(Be&&!D.nativeEvent.isComposing){const cn=sO(Ce,Be.start,Be.end,"");qe.current=cn.caret,Kr(cn.caret),qn(cn.text),D.preventDefault();return}}const de=cr.current,_e=crn();if(_e&&Gze(D,{value:Ce,selectionStart:de?.selectionStart??null,selectionEnd:de?.selectionEnd??null})){_e.focus(),D.preventDefault();return}if(Nm&&D.key==="Enter"&&!D.shiftKey&&!D.nativeEvent.isComposing){D.preventDefault(),Qv();return}if(D.key==="Enter"&&!D.shiftKey&&!D.nativeEvent.isComposing){const Be=zP(Ce,kr);if(Be.kind!=="send"){D.preventDefault(),Wm(Be,Ce,kr);return}}Am(D)},[rt,WP,sW,di,NP,Am,Hn,zP,Wm,Ce,kr,ln,Ie,l,c]),cW=$.useRef(null),rl=$.useCallback(D=>{h6=!1,cr.current?.focus({preventScroll:D?.preventScroll===!0})},[cr]),STe=$.useCallback(()=>{Yze(Ce)!==null&&qn("")},[Ce,qn]);$.useImperativeHandle(nt,()=>({focusInput:rl,openWorkingDirectoryMenu:()=>{cW.current?.openMenu()},submitNow:()=>wv(),consumeApprovalAnswerDraft:STe}));const uW=$.useCallback(()=>cr.current,[cr]);$.useEffect(()=>f9e(rl,uW),[rl,uW]);const il=$.useRef(null),OW=$.useRef(Ce);$.useLayoutEffect(()=>{OW.current=Ce},[Ce]);const dW=$.useCallback(D=>{il.current===D&&(il.current=null,Bn.current.delete(D.index))},[]),kv=$.useCallback(D=>{if(il.current!==D)return!1;const de=VPt({buffer:OW.current,cleared:D.cleared});return de?(Bn.current.set(D.index,D.payload),il.current===D&&(il.current=null),D.toastId!==null&&O0(D.toastId),Zn({capture:Th(In.current,de.buffer,de.caret,"arrival"),buffer:de.buffer,caret:de.caret}),tn(null),!0):!1},[Zn,tn]);$.useLayoutEffect(()=>{const D=il.current;D!==null&&D.cleared.buffer!==Ce&&(D.toastId!==null&&O0(D.toastId),dW(D))},[Ce,dW]);const xTe=$.useCallback(D=>{const de=il.current;return de===null||!(D.metaKey||D.ctrlKey)||D.altKey||D.shiftKey||D.key.toLowerCase()!=="z"?!1:(kv(de),!0)},[kv]),fW=$.useCallback(D=>{kv(D)&&rl()},[rl,kv]),QTe=$.useCallback(D=>{if(ln)return;const de=Bn.current.get(D);if(!de)return;const _e=DPt({buffer:Ce,payload:de});if(!_e.cleared)return;const Be=il.current;Be&&(il.current=null,Bn.current.delete(Be.index),Be.toastId!==null&&O0(Be.toastId));const cn={index:D,payload:de,cleared:_e,toastId:null};il.current=cn,Zn({capture:Th(In.current,_e.buffer,_e.caret,"arrival"),buffer:_e.buffer,caret:_e.caret}),tn({key:de.key,index:D,over:_e.buffer}),cn.toastId=Zm(IPt(D),{action:{label:GPt,onClick:()=>fW(cn)}}),rl()},[Zn,rl,ln,Ce,tn,fW]),kTe=SKt(!!v?.active),hW=S&&!v?.active&&(kTe.held||Re)&&!(t&&d),PTe=!!v?.active||hW,TTe=ln||Re||yt||Ce.trim().length>0;$.useEffect(()=>{const D=cr.current;D&&(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)},[Ce,cr,Re,yt]);const pW=$.useRef(!1);$.useEffect(()=>{const D=Re||yt,de=pW.current&&!D;if(pW.current=D,!J&&!de||ln||D)return;const _e=document.activeElement;!(_e&&(_e.tagName==="INPUT"||_e.tagName==="TEXTAREA"))&&!Q&&cr.current?.focus({preventScroll:!0})},[J,ln,Re,yt,cr,Q]),$.useEffect(()=>{window.electron.ipcRenderer.invoke("get-platform-info").then(D=>{hr(D.platform)}).catch(D=>{console.error("Failed to get platform info:",D)})},[]);const Qs=$.useRef(null),_Te=250,mW=$.useRef(Te);$.useEffect(()=>{mW.current=Te}),$.useEffect(()=>(Qae("message-input",Re||ge),()=>Qae("message-input",!1)),[Re,ge]),$.useEffect(()=>{mW.current?.(Re)},[Re]);const Su=$.useCallback(D=>{De(!1);const de=jt.current;if(!de)return;const _e=Qs.current?.startedAt??null,Be=_e===null?Number.POSITIVE_INFINITY:performance.now()-_e;if(Qs.current=null,de.state==="inactive"){fe(!1);return}(D==="abort"||Be<_Te)&&(de.onstop=()=>{if(de.stream)for(const cn of de.stream.getTracks())cn.stop();Je(null),Mt.current=[]}),de.stop(),fe(!1)},[]);$.useEffect(()=>()=>{const D=Qs.current!==null;Qs.current=null;const de=jt.current;if(de&&de.state!=="inactive"){Su("abort");return}D&&De(!1)},[Su]);const YP=$.useCallback((D="release")=>{const de=Qs.current;if(de){if(de.startedAt===null){Qs.current=null,De(!1);return}Su(D)}},[Su]),gW=$.useCallback(async()=>{if(!(ln||!Di)&&!Qs.current)if(navigator?.mediaDevices?.getUserMedia){const D={startedAt:null};Qs.current=D,De(!0);try{const de=await navigator.mediaDevices.getUserMedia({audio:!0});if(Qs.current!==D){for(const _e of de.getTracks())_e.stop();return}jt.current=new MediaRecorder(de),Mt.current=[],jt.current.ondataavailable=_e=>{Mt.current.push(_e.data)},jt.current.onstop=()=>{const _e=new Blob(Mt.current,{type:"audio/webm"});Je(_e);for(const Be of de.getTracks())Be.stop()},jt.current.start(),D.startedAt=performance.now(),De(!1),fe(!0),Je(null)}catch(de){if(Qs.current!==D)return;Qs.current=null,De(!1),console.error("Error accessing microphone:",de),oi("Error accessing microphone. Please ensure microphone permissions are granted.")}}else console.error("This runtime exposes no MediaRecorder"),oi("Dictation is not available on this device.")},[Di,ln]),GP=$.useCallback(()=>{Re&&Su("release")},[Re,Su]),IP=$.useCallback(()=>{Re&&Su("abort")},[Re,Su]);$.useEffect(()=>{if(!Re&&!ge)return;const D=de=>{if(Re){de.key==="Enter"?(de.preventDefault(),GP()):de.key==="Escape"&&(de.preventDefault(),IP());return}de.key==="Escape"&&(de.preventDefault(),YP("abort"),De(!1))};return window.addEventListener("keydown",D),()=>{window.removeEventListener("keydown",D)}},[Re,ge,GP,IP,YP]);const $W=$.useCallback(async()=>{if(Se)try{vt(!0);const D=await Mle.createTranscription(wf.baseUrl,{file:new File([Se],"recording.webm",{type:"audio/webm"})});if(D.result?.text){const de=D.result?.text||"";ao.current=!0,Sv(de)}else sp(uze);Je(null)}catch(D){console.error("Error transcribing audio:",D),oi(Y6e(D))}finally{vt(!1)}},[Se,Sv]);$.useEffect(()=>{Se&&$W()},[Se,$W]);const yW=$.useRef(!0);$.useEffect(()=>{if(typeof IntersectionObserver>"u")return;const D=cr.current;if(D===null)return;const de=new IntersectionObserver(_e=>{const Be=_e[_e.length-1];Be!==void 0&&(yW.current=Be.isIntersecting)});return de.observe(D),()=>de.disconnect()},[cr]),KKt("message-input",j5e.MESSAGE_INPUT,{start:gW,stop:YP},()=>!!(!ln&&!Re&&!yt&&Di&&yW.current));const XTe=D=>{if(D.preventDefault(),ln||Q)return;if(k){Qv();return}if(!Ce.trim()&&ye.length===0||Uo())return;const de=zP(Ce,kr);if(de.kind!=="send"){Wm(de,Ce,kr);return}wv()},ZP=$.useCallback(D=>{ln&&D.preventDefault()},[ln]),RTe=$.useCallback(D=>{!ln&&!Nm||(D.preventDefault(),Nm&&!ln&&Qv())},[ln,Nm,Qv]),ETe=D=>{u&&$e(u,D)},qTe=async()=>{const D=await window.electron.ipcRenderer.invoke("show-open-dialog",{properties:["openFile","multiSelections"]});if(!D.canceled&&D.filePaths.length>0&&u)for(const de of D.filePaths)oe(u,{id:is(),path:t$(de)})},jTe=D=>{if(ln)return;const de=D.clipboardData?.getData("text/plain")??"";if(de&&In.current.arm!==null){const Be=D.currentTarget,cn=XPt({capture:In.current,buffer:Ce,caret:Be.selectionEnd??Ce.length,selection:{start:Be.selectionStart??Ce.length,end:Be.selectionEnd??Ce.length},pasted:de,index:Hr.current,taken:Ra()});if(cn){D.preventDefault(),Zn(cn),vn(null);return}}de&&(Ft.current=bPt(de));const _e=D.clipboardData?.items;if(_e){for(let Be=0;Be<_e.length;Be++)if(_e[Be].type.indexOf("image")!==-1||_e[Be].kind==="file"){const cn=_e[Be].getAsFile();if(cn){const Zt=new FileReader;Zt.onload=er=>{er.target?.result&&u&&oe(u,{id:is(),path:er.target.result})},Zt.readAsDataURL(cn)}}}},CTe=D=>{ln||D.dataTransfer?.types.includes("Files")&&(D.preventDefault(),D.stopPropagation(),D.dataTransfer.dropEffect="copy",DP(!0))},zTe=D=>{D.currentTarget.contains(D.relatedTarget)||DP(!1)},ATe=D=>{if(DP(!1),ln)return;const de=D.dataTransfer?.files;!de||de.length===0||(D.preventDefault(),D.stopPropagation(),u&&UTe(u,Array.from(de)))},UTe=async(D,de)=>{for(const _e of de){const Be=window.api?.getPathForFile?window.api.getPathForFile(_e):"";if(Be){oe(D,{id:is(),path:t$(Be)});continue}const cn=await lrn(_e);cn&&oe(D,{id:is(),path:cn})}},[vW,DP]=$.useState(!1),WTe=D=>{ln||(Ce||p?.(),qe.current=D.length,qn(D),Kr(D.length),cr.current?.focus())},VP=wl(Nt)?Nt.value!==""?KPt:ji?JPt:e5t:ZPt({unredacted:NO!==null?t5t(NO,CP(Ce)?h1e:void 0):null,armed:Nt.arm!==null&&c1e(Ce,Ce.length)!==null,cleared:Oa===null?null:{key:Oa.key,index:Oa.index},undoCap:dTe(En==="darwin")}),NTe=$.useMemo(()=>En==="darwin"?"Cmd+Shift+S":"Ctrl+Shift+S",[En]),MP=$.useRef(null),YTe=D=>{u&&(MP.current=be.findIndex(de=>de.id===D),ie(u,D))};$.useEffect(()=>{const D=MP.current;if(D===null)return;MP.current=null;const de=document.querySelectorAll(Orn),_e=de[Math.min(D,de.length-1)];_e?_e.focus():rl()},[be,rl]);const Wo=$.useMemo(()=>{const de=l5(Ce,be)!==""||ye.length>0,_e=Q||b?.message&&pOe.test(b.message)?[{label:"Connect a provider",onClick:()=>oO.getState().openConnect()}]:[];return{message:b?.message,muted:b?.muted===!0,polite:b?.polite===!0,actions:[...b?.actions??[],..._e],retry:b?.retry===!0,clear:b?.muted!==!0&&(b?.onClear!==void 0||de)}},[b,Ce,be,ye,Q]),If=LEt(),bW=j("block text-body-sm",W?"px-2 pb-1":"px-4 pb-2",NO!==null?"text-warning":"text-ink-muted"),wW=AP&&Ce.length>0,GTe=h.jsx("output",{className:j(ni,"block pb-2",If.issue.kind==="hidden"&&"hidden"),children:h.jsx(Stn,{issue:If.issue,onSignIn:If.start,onCancel:If.cancel,onDismiss:If.dismiss,isSmallView:W,onFocusComposer:()=>cr.current?.focus()})}),Ym=W4e(B),ITe=Ym&&!I4e(Ym,Y4e(If.issue))?h.jsx("output",{className:j(ni,"block pb-2"),children:h.jsx(ZKt,{access:Ym,isSmallView:W,onSwitchModel:B?.onCommand?()=>B.onCommand?.({name:"model",args:""}):void 0,onConnect:()=>oO.getState().openConnect({providerId:Ym.provider})})}):null,SW=ge||!Re&&!yt&&!(t&&d),ZTe=h.jsxs("form",{onSubmit:XTe,"data-chat-region":"composer","aria-label":Hle.composer,tabIndex:-1,className:"w-full",children:[h.jsx(qW,{fallback:null,children:h.jsx(vKt,{frontend:B?.frontend,runDetails:ne,isSmallView:W,askExpanded:I,onAskToggle:N,askOutcomes:Z,onNote:M,onFocusComposer:()=>cr.current?.focus()},u)}),!G4e(Ym)&&GTe,ITe,a,o?.blocksInput&&o.placeholder&&!o.statedByNode&&Ce.trim().length>0?h.jsx("p",{id:eoe,className:"mb-2 text-meta text-ink-muted",children:o.placeholder}):null,o?.node,Wo.message!==void 0&&h.jsxs("div",{role:Wo.polite?"status":"alert","data-composer-notice":!0,"data-composer-queued":b?.message===pa.queuedSend?!0:void 0,className:j(ni,"flex flex-wrap items-center gap-x-3 gap-y-1 text-body-sm",W?"px-2 pb-1":"px-4 pb-2"),children:[h.jsxs("p",{className:j("flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1",Wo.muted?"text-ink-muted":"text-danger"),children:[!Wo.muted&&h.jsx("span",{className:"flex shrink-0 items-center pt-0.5",children:h.jsx(ip,{size:14,"aria-hidden":"true"})}),h.jsx("span",{className:j("min-w-0 break-words",!Wo.muted&&"font-medium"),children:Wo.message})]}),(Wo.retry||Wo.clear||Wo.actions.length>0)&&h.jsxs(h.Fragment,{children:[Wo.actions.map(D=>h.jsx(je,{type:"button",variant:"link",size:"sm",className:j("min-h-6 cursor-pointer text-body-sm underline"),onClick:D.onClick,children:D.label},D.label)),Wo.retry&&b?.onRetry&&h.jsx(je,{type:"button",variant:"link",size:"sm",className:j("min-h-6 cursor-pointer font-semibold text-body-sm underline"),onClick:()=>b.onRetry?.(),children:HEe}),Wo.clear&&b?.onClear&&h.jsx(je,{type:"button",variant:"link",size:"sm","aria-label":"Clear message",className:j("min-h-6 cursor-pointer text-ink-dim text-body-sm underline"),onClick:()=>b.onClear?.(),children:KEe})]})]}),x&&h.jsx("output",{className:j(ni,"block text-body-sm text-ink-muted",W?"px-2 pb-1":"px-4 pb-2"),children:x}),l&&Ie!==null&&h.jsx(nen,{sessionId:l,sessionStreaming:c,isSmallView:W,onReturnFocus:()=>cr.current?.focus()}),h.jsxs("div",{className:j(ni,"relative w-full"),children:[h.jsx(Inn,{state:rt,onPick:WP,onActionPick:UP}),h.jsx(itn,{state:Ao,onPick:lW}),h.jsx(Htn,{state:di,onPick:NP}),!K&&!rt.open&&!Ao.open&&!di.open&&h.jsx(g3t,{visible:m,onClick:y,hasNewActivity:g}),h.jsx("output",{id:Hae,className:j(ni,VP?bW:"hidden"),children:VP}),wW&&h.jsx("output",{id:Kae,className:j(ni,bW),children:nrn}),se>0&&h.jsx("span",{id:Jae,className:"sr-only",children:se===1?"1 reference points outside this session's working directory; the agent will ask you to approve it before reading.":`${se} references point outside this session's working directory; the agent will ask you to approve them before reading.`}),i&&h.jsx("span",{id:toe,className:"sr-only",children:"The message that could not be delivered has Send again and Edit controls in the conversation above this box: press Shift+Tab to reach them."}),h.jsxs("div",{className:j(drn,vW?void 0:frn,W?"gap-2 rounded-md p-2":"gap-3 rounded-frame p-4",ni,vW&&"outline-dashed outline-2 outline-accent outline-offset-2"),"data-lo-composer-measure":"","data-tour-tag":"chat-input-textarea",children:[(be.length>0||ye.length>0)&&h.jsxs("div",{className:"max-h-[240px] shrink-0 overflow-y-auto",children:[be.length>0&&h.jsx(S8,{replies:be,onRemoveReply:YTe}),ye.length>0&&h.jsx(qNe,{attachments:ye.map(D=>D.path),onRemoveAttachment:D=>ETe(ye[D].id),disabled:ln||Re||yt})]}),h.jsxs("div",{className:"relative isolate w-full",children:[h.jsx(pJt,{text:Ce,payloads:Bn.current,capture:Nt,fieldRef:cr,mirrorRef:dt,isSmallView:W}),h.jsx(qen,{text:Ce,spans:le.spans,resolved:le.resolved,fieldRef:cr,isSmallView:W}),h.jsx(Otn,{draft:Ce,runs:oW,textareaRef:cr,fieldClassName:Hx(W),refused:ln,children:h.jsx("textarea",{ref:cr,"data-region-entry":!0,className:j(Hx(W),"block",W?"max-h-24":"max-h-28","resize-none overflow-y-auto bg-transparent",yTe?"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:Re?Es.recording:WUe({unavailable:A,secretAnswer:AP,inputDisabled:ln,awaitingAnswer:r,asideAttached:Ie!==null,sendingUnsettled:WO||Um,awaitingReply:n,stopping:v?.stopping===!0,noProvider:Q,idle:xe,hostLine:o?.placeholder??null}),value:Ce,onCompositionStart:()=>wu(!0),onCompositionEnd:()=>wu(!1),onChange:D=>{io.current=!0;const de=D.target.value,_e=D.target.selectionStart??de.length;bn.current=null;const Be=kPt(In.current,Ce,de,_e,"typing");Be.buffer!==de?(qe.current=Be.caret,Kr(Be.caret)):Kr(_e),Be.capture!==In.current&&Nr(Be.capture),!Ce&&Be.buffer&&p?.(),Qi.current=Be.buffer,Ea(Be.capture,Be.buffer),qn(Be.buffer),Date.now()-Wr.current>=irn&&b?.onDismiss?.()},onSelect:D=>{const de=D.target,_e=qe.current;if(_e!==null){de.selectionStart===_e&&(qe.current=null);return}Kr(de.selectionStart),Nr(Th(In.current,Ce,de.selectionStart,"caret"))},onKeyDown:wTe,onPointerDown:()=>{h6=!0},onPaste:jTe,rows:1,readOnly:ln,"aria-disabled":ln||void 0,"aria-label":"Message",role:"combobox","aria-describedby":[o?o.id:null,o?.blocksInput&&o.placeholder&&!o.statedByNode&&Ce.trim().length>0?eoe:null,VP?Hae:null,wW?Kae:null,se>0?Jae:null,A?B1e:null,i?toe:null].filter(Boolean).join(" ")||void 0,"aria-expanded":rt.open||Ao.open,"aria-controls":rt.open?rt.listId:Ao.open?Ao.listId:void 0,"aria-activedescendant":(rt.open?rt.activeDescendantId:Ao.activeDescendantId)??void 0})}),h.jsx(dJt,{small:W,text:Ce,payloads:Bn.current,capture:Nt,mirrorRef:dt,fieldRef:cr,onClear:ln?null:QTe,onControlUnmounted:rl})]}),Re&&h.jsx(Kue,{isRecording:Re}),yt&&h.jsxs("div",{"data-transcribing-indicator":"",className:"mt-1 flex items-center gap-2 px-2 [min-height:1.5rem]",children:[h.jsx("span",{className:"font-medium text-body-sm text-ink-muted",children:"Processing audio"}),h.jsx(pTe,{})]}),h.jsxs("div",{className:"flex min-w-0 flex-nowrap items-center gap-x-2",children:[B&&h.jsx(qW,{fallback:null,children:h.jsx($Ge,{frontend:B.frontend,onCommand:B.onCommand,effortEntities:B.effortEntities,draft:B.draft,onOpenDraftPicker:B.onOpenDraftPicker,draftResolution:B.draftResolution,held:B.held,readingsDropped:B.readingsDropped,pendingModel:B.pendingModel,costChannels:B.costChannels,controlsThirdBox:PTe})}),h.jsxs("div",{className:"contents",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-1 shrink-0",children:[h.jsx(At,{content:"Attach file",children:h.jsx("span",{children:h.jsx(je,{variant:"ghost",size:W?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:ZP,onClick:qTe,"aria-label":"Attach file","data-tour-tag":"chat-input-attach-file-button",disabled:ln||Re||yt,children:h.jsx(W7e,{"aria-hidden":"true"})})})}),Ne!==void 0&&h.jsx($tn,{ref:cW,currentWorkingDirectory:Ne,writePath:E,pending:q,pendingAccepted:z,readOnlyReason:E?void 0:R??R5e})]}),h.jsxs("div",{className:"ml-auto flex order-3 items-center gap-1",children:[ge&&SW&&h.jsx("output",{"data-preparing-indicator":"",className:"shrink-0 font-medium text-body-sm text-ink-muted",children:W?"Starting":"Starting recording"}),SW&&h.jsx(At,{content:ge?"Starting recording":Di?`Start recording (${NTe} or hold ${c6().label})`:Vi,children:h.jsx("span",{children:h.jsx(je,{variant:"ghost",size:W?"icon-sm":"icon",className:"text-ink-dim hover:bg-elevated hover:text-ink",onPointerDown:ZP,onClick:gW,"aria-label":"Start recording","aria-busy":ge||void 0,disabled:ln||!Di,children:ge?h.jsx(hs,{size:"sm"}):h.jsx(k7e,{"aria-hidden":"true"})})})}),Re&&h.jsxs(h.Fragment,{children:[h.jsx(At,{content:"Confirm recording (Enter)",children:h.jsx("span",{children:h.jsx(je,{variant:"ghost",size:W?"icon-sm":"icon",className:"text-success hover:bg-success-wash hover:text-success",onClick:GP,"aria-label":"Confirm recording",children:h.jsx(Ou,{"aria-hidden":"true"})})})}),h.jsx(At,{content:"Cancel recording (Esc)",children:h.jsx("span",{children:h.jsx(je,{variant:"ghost",size:W?"icon-sm":"icon",className:"text-danger hover:bg-danger-wash hover:text-danger",onClick:IP,"aria-label":"Cancel recording",children:h.jsx(Zi,{"aria-hidden":"true"})})})})]}),hW&&h.jsx("span",{"aria-hidden":"true","data-interrupt-slot":"",className:j("pointer-events-none invisible flex items-center"),children:h.jsx(je,{variant:"danger",size:W?"icon-sm":"icon",type:"button",tabIndex:-1,children:h.jsx(_w,{"aria-hidden":"true"})})}),v?.active&&h.jsx(At,{content:"Stop this session's current work (Esc)",children:h.jsx("span",{children:h.jsx(je,{variant:"danger",size:W?"icon-sm":"icon",type:"button",onClick:v.onStop,"aria-label":"Stop","aria-keyshortcuts":"Escape","data-stopping":v.stopping===!0?"true":void 0,"aria-busy":v.stopping===!0?!0:void 0,className:j("data-[stopping]:border-danger data-[stopping]:text-ink data-[stopping]:bg-[color-mix(in_oklab,var(--color-danger-wash)_80%,var(--color-danger))]"),children:h.jsx(_w,{"aria-hidden":"true"})})})}),t&&d?h.jsx(At,{content:"Stop agent",children:h.jsx("span",{children:h.jsx(je,{variant:"danger",size:W?"icon-sm":"icon",type:"button",onClick:()=>f?.(d),"aria-label":"Stop agent",children:h.jsx(_w,{"aria-hidden":"true"})})})}):!Re&&!yt&&h.jsx(At,{content:Ie!==null&&!r?"Ask the aside":"Send message",children:h.jsx("span",{children:h.jsx(je,{variant:"primary",size:W?"icon-sm":"icon",type:"submit",onPointerDown:RTe,disabled:ln||Nm||!Ce.trim()&&ye.length===0,className:"rounded-full disabled:bg-surface","aria-label":Ie!==null&&!r?"Ask the aside":"Send message",children:h.jsx(zle,{"aria-hidden":"true"})})})})]})]})]})]})]}),Q&&!mn?h.jsx("div",{className:j("mt-2",ni),children:h.jsx(DJt,{})}):null,(Q||k)&&qt?h.jsx("div",{className:j("mt-2",ni),children:h.jsx("output",{className:"block text-body-sm text-ink-muted",children:k?"Choose a model for this conversation before sending.":"Connect a provider to send."})}):null]});return h.jsxs("div",{className:j(Que,"flex w-full flex-col items-center",St?"grow":"shrink-0",G?void 0:ONe,W?"pb-1 pt-0.5":"pb-4 pt-2"),"data-lo-composer-band":!0,ref:He,onDragOver:CTe,onDragLeave:zTe,onDrop:ATe,children:[h.jsx("div",{"data-lo-composer-splash":"",className:j("flex w-full flex-col items-center justify-center",St?"grow":null),children:h.jsx("div",{ref:en,className:j(YO?"flex w-full flex-col items-center gap-6 py-4":"hidden"),children:YO?h.jsxs(h.Fragment,{children:[h.jsx("span",{"data-lo-empty-mark":"",className:"contents",children:h.jsx(ern,{className:"size-8",tone:"ink-muted"})}),Q?null:h.jsx("h2",{className:"text-center text-ink text-title",children:"What can I help you with today?"}),Q?h.jsx("div",{className:j("w-full",ni),children:h.jsx(ZJt,{})}):h.jsxs("div",{className:j("flex flex-col gap-3",ni),children:[h.jsx(vtn,{band:Qt,splash:ct,foot:gn,suggestions:ht,disabled:TTe,onRefusedPress:ZP,onSelect:WTe,focusComposer:()=>cr.current?.focus()}),h.jsx(uJt,{suspended:Ce.trim().length>0,mentionsEnabled:ee})]})]}):null})}),mn?h.jsx("div",{className:j("mb-2 mt-2",ni),children:h.jsx(IJt,{selection:Jt})}):null,h.jsx("div",{ref:Ct,"data-lo-composer-foot":"",className:"w-full",children:ZTe})]})}),prn=$.memo(hrn);prn.displayName="MessageInput";const gTe=1024,$1=1024*1024,rW=.85,mrn=new Set(["image/png","image/jpeg","image/webp"]),grn=[{maxEdge:gTe,quality:.8},{maxEdge:768,quality:.7},{maxEdge:512,quality:.6}];function $rn(e){const t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}function yrn(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 vrn(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 brn(e,t,n,r,i){const a=Math.max(e.width,e.height),o=a>r?r/a:1,s=Math.max(1,Math.round(e.width*o)),l=Math.max(1,Math.round(e.height*o)),c=new OffscreenCanvas(s,l),u=c.getContext("2d");if(!u)return null;u.drawImage(e,0,0,s,l);const O=[],d=await c.convertToBlob({type:"image/png"}),f=new Uint8Array(await d.arrayBuffer());if(f.byteLength<=$1&&O.push({bytes:f,mime_type:"image/png"}),f.byteLength>$1||i<rW){const g=new OffscreenCanvas(s,l),y=g.getContext("2d");if(!y)return null;y.fillStyle="#ffffff",y.fillRect(0,0,s,l),y.drawImage(e,0,0,s,l);const v=await g.convertToBlob({type:"image/jpeg",quality:i}),S=new Uint8Array(await v.arrayBuffer());O.push({bytes:S,mime_type:"image/jpeg"}),f.byteLength>$1&&S.byteLength>f.byteLength&&O.push({bytes:f,mime_type:"image/png"})}let p=null,m=Number.POSITIVE_INFINITY;for(const g of O)g.bytes.byteLength<m&&(p=g,m=g.bytes.byteLength);return p?m>=n?t:{data_b64:vrn(p.bytes),mime_type:p.mime_type}:null}async function wrn(e){if(!mrn.has(e.mime_type)||typeof createImageBitmap!="function"||typeof OffscreenCanvas!="function")return null;try{return await createImageBitmap(new Blob([yrn(e.data_b64)],{type:e.mime_type}))}catch{return null}}async function Srn(e,t,n,r){const i=$rn(e.data_b64);try{return Math.max(t.width,t.height)<=n&&i<=$1&&r>=rW?e:await brn(t,e,i,n,r)??e}catch{return e}}async function xrn(e,t,n){if(!e.length)return e;const r=await Promise.all(e.map(i=>wrn(i)));try{return await Qrn(e,r,t,n)}finally{for(const i of r)i?.close()}}async function Qrn(e,t,n,r){const i=(c,u)=>Promise.all(e.map((O,d)=>{const f=t[d];return f?Srn(O,f,c,u):Promise.resolve(O)})),a=await i(gTe,rW);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 grn){const u=await i(c.maxEdge,c.quality);if(l(u)<=n)return u}return o}const krn=/^data:(image\/(png|jpeg|gif|webp));base64,(.+)$/,Prn=/^file:\/\//,Trn={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp"};async function sln(e,t){const n=[],r=[];for(const a of e){const o=krn.exec(a);if(o){n.push({data_b64:o[3],mime_type:o[1]});continue}const s=a.split(".").pop()?.toLowerCase()??"",l=Trn[s];if(!l||!window.api?.readFile)continue;const c=await window.api.readFile(a.replace(Prn,""),"base64");c.success?n.push({data_b64:c.data,mime_type:l}):r.push(a)}const i=Math.max(0,n.length-ZE);return{images:await xrn(n.slice(0,ZE),oQ,a=>zq(t,a)),unreadable:r,overflow:i}}function lln(e){if(e.length===0)return null;const t=e.map(YQ);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.`}function cln(e){if(e<=0)return null;const t=ZE,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 uln(e){const t=e.trim();if(t.startsWith("="))return null;const n=t.toLowerCase();return n==="pause"||n==="resume"||n==="status"?n:null}function Oln(e){const t=e.trim();return t.startsWith("=")?t.slice(1).trimStart():t}function dln(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 _rn(e){return jo(e,"Aida's controls could not reach the backend.")}const fln="The chief of staff is switched off on this install.",Xrn="aida_no_provider",Rrn="aida_disabled";function hln(e,t){const n=e instanceof Ut?e.code:void 0;return n===Rrn?null:n===Xrn?{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. ${_rn(e)}`}}function pln(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 mln(e){const t=e?.greeting_state;return t==null||t==="owed"}function Ern(e){return e.eventKey===e.storeKey&&!e.focused}let ooe=!1;function gln(){if(ooe)return;ooe=!0;const e=an.persist?.getOptions?.()?.name??"conversation-input-store",t=n=>{Ern({eventKey:n.key,storeKey:e,focused:document.hasFocus()})&&an.persist?.rehydrate?.()?.catch?.(()=>{})};window.addEventListener("storage",t)}export{Ay as $,gUe as A,xUe as B,Rt as C,Qa as D,at as E,bl as F,zn as G,Pf as H,P as I,Xn as J,gr as K,Rn as L,Sn as M,KQ as N,Hy as O,Er as P,Qr as Q,Ur as R,ds as S,t9 as T,la as U,Fn as V,AA as W,ir as X,bs as Y,txe as Z,Ut as _,wi as a,UQe as a$,min as a0,jo as a1,Hrn as a2,gin as a3,eU as a4,fU as a5,yc as a6,Rr as a7,aOe as a8,r$ as a9,prn as aA,Nze as aB,gln as aC,Aan as aD,Can as aE,K0 as aF,oi as aG,yq as aH,Md as aI,l6e as aJ,Ey as aK,Oin as aL,qy as aM,asn as aN,$l as aO,bh as aP,Pa as aQ,Xle as aR,Oz as aS,wle as aT,Fce as aU,din as aV,Za as aW,m9t as aX,hU as aY,CQe as aZ,pv as a_,gsn as aa,$sn as ab,axe as ac,mze as ad,Xz as ae,Uq as af,zy as ag,wf as ah,dUe as ai,fln as aj,sln as ak,lln as al,Use as am,cln as an,Qan as ao,Vrn as ap,nr as aq,Brn as ar,pa as as,kHe as at,bd as au,nqe as av,JEe as aw,an as ax,am as ay,vd as az,bin as b,NN as b$,Bsn as b0,pUt as b1,ane as b2,ine as b3,nke as b4,TU as b5,iP as b6,r8t as b7,n8t as b8,Wp as b9,ve as bA,OCe as bB,Vr as bC,Zm as bD,Q6e as bE,_5 as bF,gze as bG,ISe as bH,KN as bI,eY as bJ,ble as bK,kin as bL,hz as bM,xan as bN,Om as bO,Sze as bP,cm as bQ,pi as bR,Kse as bS,z3e as bT,N3e as bU,I3e as bV,M3e as bW,Z3e as bX,D3e as bY,$q as bZ,F3e as b_,t8t as ba,e8t as bb,fx as bc,gv as bd,kU as be,xU as bf,Pd as bg,dx as bh,PUe as bi,VS as bj,ni as bk,ONe as bl,Que as bm,_w as bn,Zrn as bo,Dan as bp,pin as bq,k5t as br,jz as bs,van as bt,fWe as bu,uue as bv,Ian as bw,Zan as bx,jd as by,Cy as bz,Fr as c,ssn as c$,L3e as c0,V3e as c1,Qin as c2,k1e as c3,Q5t as c4,Krn as c5,sp as c6,Jrn as c7,O0 as c8,_ze as c9,Jce as cA,gan as cB,A8e as cC,Zle as cD,psn as cE,hqt as cF,nxe as cG,msn as cH,b3t as cI,XC as cJ,Uoe as cK,$Q as cL,Oqe as cM,Jtn as cN,iln as cO,kc as cP,aln as cQ,tnn as cR,fxe as cS,jle as cT,h8 as cU,WKt as cV,vO as cW,Hce as cX,Ran as cY,UXt as cZ,GXt as c_,qle as ca,r3 as cb,I5t as cc,kO as cd,Ple as ce,jy as cf,lp as cg,vle as ch,SNe as ci,Mue as cj,K1e as ck,Y$ as cl,G$ as cm,hWe as cn,fCe as co,oCe as cp,HMt as cq,IO as cr,man as cs,aUe as ct,qc as cu,BMt as cv,bP as cw,wP as cx,yZt as cy,yP as cz,ke as d,u$ as d$,hH as d0,OH as d1,YXt as d2,MLt as d3,Xi as d4,dc as d5,bze as d6,Xan as d7,Aqt as d8,fd as d9,JCt as dA,p7t as dB,h7t as dC,q6e as dD,Dn as dE,gQ as dF,o6 as dG,lin as dH,vqe as dI,yqe as dJ,Fse as dK,Lse as dL,kan as dM,Pan as dN,T6e as dO,Tan as dP,_an as dQ,Ean as dR,jan as dS,wze as dT,QUe as dU,Z8e as dV,zan as dW,R5 as dX,BFe as dY,rBe as dZ,ODe as d_,UEt as da,cxe as db,UTt as dc,$6e as dd,kUe as de,EUe as df,yEt as dg,bsn as dh,Zd as di,Sle as dj,Zxe as dk,BS as dl,lx as dm,hne as dn,T9t as dp,ry as dq,b7t as dr,w7t as ds,v7t as dt,y7t as du,$7t as dv,g7t as dw,m7t as dx,Fk as dy,e7t as dz,_z as e,nan as e$,LFe as e0,Tfe as e1,b8e as e2,w8e as e3,h9e as e4,Pq as e5,Wk as e6,wz as e7,aan as e8,xsn as e9,gCe as eA,p7e as eB,mQ as eC,$le as eD,Y8 as eE,KH as eF,Ng as eG,Ain as eH,fce as eI,H7e as eJ,tan as eK,Jin as eL,PAe as eM,Tq as eN,_Ae as eO,tCe as eP,zin as eQ,dce as eR,Gin as eS,x2 as eT,oan as eU,C7e as eV,lAe as eW,Nin as eX,ean as eY,Lin as eZ,HAe as e_,Ssn as ea,n9e as eb,Kin as ec,Bin as ed,Hin as ee,ran as ef,ian as eg,qAe as eh,Yin as ei,Win as ej,Ws as ek,u0 as el,Iin as em,Cin as en,k2 as eo,Zin as ep,_C as eq,v3t as er,g3t as es,wsn as et,Din as eu,koe as ev,q1 as ew,LAe as ex,Min as ey,Q3t as ez,Cxe as f,Tn as f$,CAe as f0,Fin as f1,_3t as f2,_q as f3,GAe as f4,XEe as f5,Fc as f6,g5e as f7,lsn as f8,Iqt as f9,Sin as fA,win as fB,Xq as fC,can as fD,k3t as fE,yQ as fF,zrn as fG,bEt as fH,qA as fI,bon as fJ,mon as fK,$He as fL,pon as fM,RA as fN,Ife as fO,XA as fP,Zfe as fQ,Yfe as fR,Wfe as fS,Nfe as fT,von as fU,mqe as fV,P6 as fW,Sz as fX,Xce as fY,R9e as fZ,Ha as f_,lCe as fa,xce as fb,JNe as fc,nYe as fd,ton as fe,non as ff,Kan as fg,Jan as fh,eon as fi,ion as fj,lYe as fk,Jue as fl,son as fm,KCe as fn,OYe as fo,ron as fp,gYe as fq,lon as fr,aon as fs,tYe as ft,Yn as fu,oon as fv,yle as fw,Qze as fx,yze as fy,xin as fz,Or as g,qwe as g$,PO as g0,wt as g1,Ze as g2,Ot as g3,Con as g4,bi as g5,oD as g6,$m as g7,wo as g8,_c as g9,Zc as gA,$b as gB,sS as gC,FQ as gD,jon as gE,mu as gF,Lon as gG,Yon as gH,jnt as gI,zon as gJ,Aon as gK,_on as gL,Gon as gM,Pon as gN,Ton as gO,Non as gP,Ion as gQ,Don as gR,Mon as gS,Fon as gT,Eon as gU,qon as gV,Xon as gW,VQ as gX,Zon as gY,HQ as gZ,Ron as g_,ihe as ga,sn as gb,Wn as gc,Jd as gd,ss as ge,El as gf,kon as gg,Ov as gh,X8 as gi,E8 as gj,ZS as gk,_8 as gl,R8 as gm,q8 as gn,w7e as go,is as gp,kpe as gq,ott as gr,pO as gs,att as gt,Ln as gu,Wt as gv,kf as gw,Gi as gx,wr as gy,Ti as gz,XJ as h,a2e as h$,O8 as h0,Qae as h1,Mle as h2,qY as h3,uze as h4,Y6e as h5,KKt as h6,j5e as h7,qNe as h8,Kue as h9,Oon as hA,zGe as hB,iMe as hC,gBe as hD,G1 as hE,iA as hF,Bz as hG,Jq as hH,ede as hI,LGe as hJ,RGe as hK,DGe as hL,II as hM,PVe as hN,mDe as hO,cVe as hP,O7e as hQ,Cle as hR,kle as hS,YQ as hT,Ufe as hU,yHe as hV,QHe as hW,Poe as hX,hQ as hY,V_e as hZ,SN as h_,pTe as ha,W7e as hb,Bce as hc,c6 as hd,k7e as he,zle as hf,t$ as hg,nsn as hh,U6e as hi,W6e as hj,_1e as hk,R1e as hl,rsn as hm,gon as hn,F1 as ho,_Q as hp,POe as hq,iT as hr,ZVe as hs,IVe as ht,kOe as hu,con as hv,tde as hw,ua as hx,xO as hy,Yy as hz,Msn as i,xoe as i$,uqe as i0,B8e as i1,kz as i2,pCe as i3,dan as i4,QXt as i5,cue as i6,l8e as i7,fan as i8,Dse as i9,Rjt as iA,Qxe as iB,W5 as iC,om as iD,ba as iE,_Ue as iF,VUe as iG,qan as iH,RUe as iI,dsn as iJ,fsn as iK,hsn as iL,Ale as iM,yin as iN,Pze as iO,lan as iP,rln as iQ,Arn as iR,xQ as iS,oYe as iT,uan as iU,nln as iV,Han as iW,uNe as iX,_Y as iY,Vce as iZ,Qoe as i_,sin as ia,tin as ib,ein as ic,QN as id,Xze as ie,nin as ig,Tin as ih,BCe as ii,Pin as ij,_in as ik,Uze as il,Lue as im,TQ as io,P1e as ip,f8 as iq,P8 as ir,$on as is,Tle as it,ATt as iu,yon as iv,xle as iw,$tn as ix,san as iy,J0 as iz,el as j,Xin as j$,q8e as j0,yan as j1,P4t as j2,TSe as j3,xKt as j4,R5e as j5,Hsn as j6,zm as j7,uln as j8,dln as j9,sNe as jA,lNe as jB,Ban as jC,Uin as jD,Vin as jE,X3t as jF,Ksn as jG,Nrn as jH,Ise as jI,oln as jJ,aqe as jK,fQ as jL,Lrn as jM,Frn as jN,Irn as jO,Yrn as jP,eln as jQ,Oan as jR,NEe as jS,oAe as jT,sAe as jU,aAe as jV,jin as jW,qin as jX,Ein as jY,Yse as jZ,Yze as j_,_rn as ja,Oln as jb,Urn as jc,Wrn as jd,rin as je,v3e as jf,iin as jg,oin as jh,ain as ji,q5e as jj,Ek as jk,Van as jl,Yi as jm,Fan as jn,Man as jo,Lan as jp,San as jq,yxe as jr,xXt as js,Ry as jt,tqe as ju,Fle as jv,vin as jw,H6 as jx,Zze as jy,Grn as jz,Isn as k,zTt as k$,Gse as k0,LEe as k1,wN as k2,n8e as k3,t8e as k4,Rin as k5,Drn as k6,tln as k7,g9e as k8,osn as k9,l2e as kA,mJt as kB,Csn as kC,zsn as kD,tqt as kE,Psn as kF,Y3t as kG,ksn as kH,Tsn as kI,U3t as kJ,Esn as kK,Usn as kL,Asn as kM,Yk as kN,jsn as kO,qsn as kP,Rsn as kQ,fz as kR,U5e as kS,pxe as kT,Aq as kU,mln as kV,pln as kW,hln as kX,jqt as kY,sxe as kZ,oxe as k_,Jsn as ka,h1 as kb,A7e as kc,oO as kd,pan as ke,$8e as kf,Mrn as kg,han as kh,uUe as ki,LEt as kj,BSe as kk,Wsn as kl,csn as km,Osn as kn,exe as ko,ou as kp,usn as kq,SUe as kr,HSe as ks,_sn as kt,Nsn as ku,Ysn as kv,Xsn as kw,Gsn as kx,vQ as ky,MEt as kz,Zsn as l,zH as l0,ysn as l1,vsn as l2,isn as l3,D8e as l4,V8e as l5,$an as l6,ern as l7,ban as l8,MUe as l9,wan as la,fin as lb,Gje as lc,Qsn as ld,X3e as le,wqt as lf,Nan as lg,Uan as lh,Wan as li,Bm as lj,Yan as lk,uin as ll,$in as lm,Xw as ln,Gan as lo,hin as lp,hon as lq,Vsn as m,Fsn as n,Dsn as o,Ep as p,Lsn as q,zd as r,FS as s,Lk as t,Hl as u,Ox as v,J8 as w,ey as x,Nxe as y,f7t as z};