local-operator-ui 0.26.1 → 0.26.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/out/renderer/assets/{_basePickBy-Baq4DnUq.js → _basePickBy-Yh6ElFVE.js} +1 -1
  2. package/out/renderer/assets/{_baseUniq-CT5phjoq.js → _baseUniq-o6svF9UW.js} +1 -1
  3. package/out/renderer/assets/{agent-details-page-X_YX-39M.js → agent-details-page-BkC2lX7r.js} +1 -1
  4. package/out/renderer/assets/{agent-hub-page-CWks9bfB.js → agent-hub-page-DUxDs-Kn.js} +1 -1
  5. package/out/renderer/assets/{agents-page-Ciczw9Ds.js → agents-page-DAebxFRb.js} +2 -2
  6. package/out/renderer/assets/{arc-uy_mgfhj.js → arc-C3lR8mfR.js} +1 -1
  7. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-Bz3MQOa1.js → architectureDiagram-IEHRJDOE-C645_jS6.js} +1 -1
  8. package/out/renderer/assets/{blockDiagram-JOT3LUYC-CXr9Yrrr.js → blockDiagram-JOT3LUYC-Du9DQ6FQ.js} +1 -1
  9. package/out/renderer/assets/{browser-page-CSGhUQfP.js → browser-page-D_Iq6NfX.js} +1 -1
  10. package/out/renderer/assets/{c4Diagram-VJAJSXHY-nvGJUVZ_.js → c4Diagram-VJAJSXHY-DpM_PJYK.js} +1 -1
  11. package/out/renderer/assets/channel-BT1OyuPi.js +1 -0
  12. package/out/renderer/assets/{chunk-4BMEZGHF-DiE_Vfns.js → chunk-4BMEZGHF-CmWFwhfL.js} +1 -1
  13. package/out/renderer/assets/{chunk-A2AXSNBT-CjanOF0i.js → chunk-A2AXSNBT-CpUzW8wB.js} +1 -1
  14. package/out/renderer/assets/{chunk-AEK57VVT--NxY1ySr.js → chunk-AEK57VVT-CLlsGZV5.js} +1 -1
  15. package/out/renderer/assets/{chunk-D6G4REZN-DdQX80fV.js → chunk-D6G4REZN-CQJonAXh.js} +1 -1
  16. package/out/renderer/assets/{chunk-RZ5BOZE2-CuvYc0pK.js → chunk-RZ5BOZE2-CKVoS-gF.js} +1 -1
  17. package/out/renderer/assets/{chunk-XZIHB7SX-CqBeExN7.js → chunk-XZIHB7SX-B6793RIq.js} +1 -1
  18. package/out/renderer/assets/classDiagram-GIVACNV2-BxGKz_N_.js +1 -0
  19. package/out/renderer/assets/classDiagram-v2-COTLJTTW-BxGKz_N_.js +1 -0
  20. package/out/renderer/assets/clone-BjcUGFxf.js +1 -0
  21. package/out/renderer/assets/{compact-pagination-BVJZzl0-.js → compact-pagination-T1jmplV0.js} +1 -1
  22. package/out/renderer/assets/{dagre-OKDRZEBW-Bylo0nXt.js → dagre-OKDRZEBW-BCz3Jhej.js} +1 -1
  23. package/out/renderer/assets/{diagram-SSKATNLV-BAC_j1KH.js → diagram-SSKATNLV-DBvre51R.js} +1 -1
  24. package/out/renderer/assets/{diagram-VNBRO52H-CDCLIp1T.js → diagram-VNBRO52H-DR3_-QrB.js} +1 -1
  25. package/out/renderer/assets/{erDiagram-Q7BY3M3F-DWXnkyeh.js → erDiagram-Q7BY3M3F-C5WKRf1i.js} +1 -1
  26. package/out/renderer/assets/{flowDiagram-4HSFHLVR-CJ56lelm.js → flowDiagram-4HSFHLVR-BDr6xFe-.js} +1 -1
  27. package/out/renderer/assets/{ganttDiagram-APWFNJXF-aNXY31kw.js → ganttDiagram-APWFNJXF-2Q5OUp3Q.js} +1 -1
  28. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-BNCDhA6Y.js → gitGraphDiagram-7IBYFJ6S-CS96w_AJ.js} +1 -1
  29. package/out/renderer/assets/{graph-BuqZiexr.js → graph-CydyUtTs.js} +1 -1
  30. package/out/renderer/assets/{index-DKlDMMK2.js → index-3dOhEzqL.js} +5 -5
  31. package/out/renderer/assets/{index-CoGIjH_w.js → index-B67rWyNs.js} +1 -1
  32. package/out/renderer/assets/{index-BbmcajTx.js → index-CiNiUEhN.js} +1 -1
  33. package/out/renderer/assets/{infoDiagram-PH2N3AL5-lNr89M3a.js → infoDiagram-PH2N3AL5-BluJPlfV.js} +1 -1
  34. package/out/renderer/assets/{journeyDiagram-U35MCT3I-DQAam-IH.js → journeyDiagram-U35MCT3I-BXzCbMiD.js} +1 -1
  35. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-cfQGdZGS.js → kanban-definition-NDS4AKOZ-CWnEWdT3.js} +1 -1
  36. package/out/renderer/assets/{layout-YIfQDVRk.js → layout-BZxn8yaA.js} +1 -1
  37. package/out/renderer/assets/{legacy-agents-page-BJQ2e1UW.js → legacy-agents-page-CBN2d2Km.js} +1 -1
  38. package/out/renderer/assets/{mermaid.core--Jdw1dfM.js → mermaid.core-CkgQHyLv.js} +5 -5
  39. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-BMeLnkQX.js → mindmap-definition-ALO5MXBD-CMdsYtR2.js} +1 -1
  40. package/out/renderer/assets/{parseISO-Pm3ShzVp.js → parseISO-B4A0wn_M.js} +1 -1
  41. package/out/renderer/assets/{pieDiagram-IB7DONF6-BDW4nh3l.js → pieDiagram-IB7DONF6--Ch74RbA.js} +1 -1
  42. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-DZMhMF12.js → quadrantDiagram-7GDLP6J5-BhMZpv_m.js} +1 -1
  43. package/out/renderer/assets/{radar-MK3ICKWK-AbV3oSGi.js → radar-MK3ICKWK-CQVUegyJ.js} +1 -1
  44. package/out/renderer/assets/{radient-auth-buttons-CXvteKm4.js → radient-auth-buttons-kol7Tscy.js} +1 -1
  45. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-XaV98AiM.js → requirementDiagram-KVF5MWMF-C1VBqnM2.js} +1 -1
  46. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-2dy5he2r.js → sankeyDiagram-QLVOVGJD-7HYTv-zO.js} +1 -1
  47. package/out/renderer/assets/{schedules-page-BlsJzf_J.js → schedules-page-BHVkJmVD.js} +1 -1
  48. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-CkovrlKR.js → sequenceDiagram-X6HHIX6F-BD0nIQXN.js} +1 -1
  49. package/out/renderer/assets/{settings-page-DJSZic3M.js → settings-page-BujhgJa0.js} +1 -1
  50. package/out/renderer/assets/{stateDiagram-DGXRK772-6Bb556OO.js → stateDiagram-DGXRK772-BPHghgWL.js} +1 -1
  51. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-D6Z_BxtC.js +1 -0
  52. package/out/renderer/assets/{timeline-definition-BDJGKUSR-DdtsW7ix.js → timeline-definition-BDJGKUSR-qjwFHKyY.js} +1 -1
  53. package/out/renderer/assets/{use-agent-like-mutation-CHHf_jeR.js → use-agent-like-mutation-9tqsIjhh.js} +1 -1
  54. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-B-JOA5F7.js → xychartDiagram-VJFVF3MP-BaPrSrI7.js} +1 -1
  55. package/out/renderer/index.html +1 -1
  56. package/package.json +1 -1
  57. package/out/renderer/assets/channel-C8ahiNYh.js +0 -1
  58. package/out/renderer/assets/classDiagram-GIVACNV2-BllHFvXx.js +0 -1
  59. package/out/renderer/assets/classDiagram-v2-COTLJTTW-BllHFvXx.js +0 -1
  60. package/out/renderer/assets/clone-CveoUN3H.js +0 -1
  61. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CwhRiYcz.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./mermaid.core--Jdw1dfM.js","./icon-Bny6j4NZ.js","./icon-B8Li1YYS.css","./katex-BCx1q_2Y.css","./index-CoGIjH_w.js","./index-BbmcajTx.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./agent-details-page-X_YX-39M.js","./use-agent-like-mutation-CHHf_jeR.js","./agent-hub-page-CWks9bfB.js","./compact-pagination-BVJZzl0-.js","./page-header-un3csrkZ.js","./agents-page-Ciczw9Ds.js","./schedules-page-BlsJzf_J.js","./parseISO-Pm3ShzVp.js","./browser-page-CSGhUQfP.js","./settings-page-DJSZic3M.js","./radient-auth-buttons-CXvteKm4.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./mermaid.core-CkgQHyLv.js","./icon-Bny6j4NZ.js","./icon-B8Li1YYS.css","./katex-BCx1q_2Y.css","./index-B67rWyNs.js","./index-CiNiUEhN.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./agent-details-page-BkC2lX7r.js","./use-agent-like-mutation-9tqsIjhh.js","./agent-hub-page-DUxDs-Kn.js","./compact-pagination-T1jmplV0.js","./page-header-un3csrkZ.js","./agents-page-DAebxFRb.js","./schedules-page-BHVkJmVD.js","./parseISO-B4A0wn_M.js","./browser-page-D_Iq6NfX.js","./settings-page-BujhgJa0.js","./radient-auth-buttons-kol7Tscy.js"])))=>i.map(i=>d[i]);
2
2
  import{r as b,j as p,n as H,a2 as Uq,a as qe,a5 as f_e,B as we,c as A,ac as up,ad as jP,ae as LP,af as mZe,ag as I1,ah as vZe,ai as qR,aj as qP,h as sn,a4 as yZe,ak as bZe,a1 as wZe,D as xZe,A as Ml,X as Qi,F as rT,L as Us,I as Si,T as tm,S as pr,V as Ul,al as p_e,am as vre,g as rt,z as SZe,an as B2,a3 as Cr,f as oa,ao as $Ze,ap as kZe,aq as yre,ar as bre,as as TZe,at as wre,t as Au,au as XY,U as O_e,b as F1,v as Ec,C as Dp,Z as Wq,k as g_e,K as M1,M as j1,N as L1,O as q1,Q as z1,o as px,p as iv,q as Ox,s as $s,Y as m_e,av as _Ze,aw as PZe,ax as CZe,ay as EZe,az as xre,y as v_e,aA as IY,aB as sv,W as QZe,aC as RZe,u as tO,aD as y_e,a9 as b_e,P as w_e,w as x_e,x as S_e,aE as Yb,i as FY,H as zR,aF as HX,aG as AZe,d as $_e,e as k_e,aH as DZe,aI as NZe,aJ as XZe,aK as IZe,E as Gq,aL as T_e,aM as Sre,l as FZe,m as MZe,R as jZe}from"./icon-Bny6j4NZ.js";var gx=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},av=typeof window>"u"||"Deno"in globalThis;function au(){}function LZe(e,t){return typeof e=="function"?e(t):e}function Vq(e){return typeof e=="number"&&e>=0&&e!==1/0}function __e(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Zb(e,t){return typeof e=="function"?e(t):e}function hd(e,t){return typeof e=="function"?e(t):e}function $re(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:a,stale:o}=e;if(a){if(r){if(t.queryHash!==MY(a,t.options))return!1}else if(!iT(t.queryKey,a))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||i&&i!==t.state.fetchStatus||s&&!s(t))}function kre(e,t){const{exact:n,status:r,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(n){if(ov(t.options.mutationKey)!==ov(s))return!1}else if(!iT(t.options.mutationKey,s))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function MY(e,t){return(t?.queryKeyHashFn||ov)(e)}function ov(e){return JSON.stringify(e,(t,n)=>Bq(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function iT(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>iT(e[n],t[n])):!1}function P_e(e,t){if(e===t)return e;const n=Tre(e)&&Tre(t);if(n||Bq(e)&&Bq(t)){const r=n?e:Object.keys(e),i=r.length,s=n?t:Object.keys(t),a=s.length,o=n?[]:{};let l=0;for(let c=0;c<a;c++){const u=n?c:s[c];(!n&&r.includes(u)||n)&&e[u]===void 0&&t[u]===void 0?(o[u]=void 0,l++):(o[u]=P_e(e[u],t[u]),o[u]===e[u]&&e[u]!==void 0&&l++)}return i===a&&l===i?e:o}return t}function UR(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function Tre(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Bq(e){if(!_re(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!_re(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function _re(e){return Object.prototype.toString.call(e)==="[object Object]"}function qZe(e){return new Promise(t=>{setTimeout(t,e)})}function Yq(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?P_e(e,t):t}function zP(e){return e}function zZe(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function UZe(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var jY=Symbol();function C_e(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===jY?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}var WZe=class extends gx{#t;#e;#n;constructor(){super(),this.#n=e=>{if(!av&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#n=e,this.#e?.(),this.#e=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#t!==e&&(this.#t=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},LY=new WZe,GZe=class extends gx{#t=!0;#e;#n;constructor(){super(),this.#n=e=>{if(!av&&window.addEventListener){const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#e||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(e){this.#n=e,this.#e?.(),this.#e=e(this.setOnline.bind(this))}setOnline(e){this.#t!==e&&(this.#t=e,this.listeners.forEach(n=>{n(e)}))}isOnline(){return this.#t}},WR=new GZe;function Zq(){let e,t;const n=new Promise((i,s)=>{e=i,t=s});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),e(i)},n.reject=i=>{r({status:"rejected",reason:i}),t(i)},n}function VZe(e){return Math.min(1e3*2**e,3e4)}function E_e(e){return(e??"online")==="online"?WR.isOnline():!0}var Q_e=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function KX(e){return e instanceof Q_e}function R_e(e){let t=!1,n=0,r=!1,i;const s=Zq(),a=g=>{r||(h(new Q_e(g)),e.abort?.())},o=()=>{t=!0},l=()=>{t=!1},c=()=>LY.isFocused()&&(e.networkMode==="always"||WR.isOnline())&&e.canRun(),u=()=>E_e(e.networkMode)&&e.canRun(),d=g=>{r||(r=!0,e.onSuccess?.(g),i?.(),s.resolve(g))},h=g=>{r||(r=!0,e.onError?.(g),i?.(),s.reject(g))},f=()=>new Promise(g=>{i=m=>{(r||c())&&g(m)},e.onPause?.()}).then(()=>{i=void 0,r||e.onContinue?.()}),O=()=>{if(r)return;let g;const m=n===0?e.initialPromise:void 0;try{g=m??e.fn()}catch(v){g=Promise.reject(v)}Promise.resolve(g).then(d).catch(v=>{if(r)return;const y=e.retry??(av?0:3),w=e.retryDelay??VZe,k=typeof w=="function"?w(n,v):w,x=y===!0||typeof y=="number"&&n<y||typeof y=="function"&&y(n,v);if(t||!x){h(v);return}n++,e.onFail?.(n,v),qZe(k).then(()=>c()?void 0:f()).then(()=>{t?h(v):O()})})};return{promise:s,cancel:a,continue:()=>(i?.(),s),cancelRetry:o,continueRetry:l,canStart:u,start:()=>(u()?O():f().then(O),s)}}var BZe=e=>setTimeout(e,0);function YZe(){let e=[],t=0,n=o=>{o()},r=o=>{o()},i=BZe;const s=o=>{t?e.push(o):i(()=>{n(o)})},a=()=>{const o=e;e=[],o.length&&i(()=>{r(()=>{o.forEach(l=>{n(l)})})})};return{batch:o=>{let l;t++;try{l=o()}finally{t--,t||a()}return l},batchCalls:o=>(...l)=>{s(()=>{o(...l)})},schedule:s,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{i=o}}}var va=YZe(),A_e=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Vq(this.gcTime)&&(this.#t=setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(av?1/0:5*60*1e3))}clearGcTimeout(){this.#t&&(clearTimeout(this.#t),this.#t=void 0)}},ZZe=class extends A_e{#t;#e;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=HZe(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(e,t){const n=Yq(this.state.data,e,this.options);return this.#s({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#s({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(au).catch(au):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(e=>hd(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===jY||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!__e(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:"invalidate"})}fetch(e,t){if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){const o=this.observers.find(l=>l.options.queryFn);o&&this.setOptions(o.options)}const n=new AbortController,r=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{const o=C_e(this.options,t),l={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(l),this.#o=!1,this.options.persister?this.options.persister(o,l,this):o(l)},s={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};r(s),this.options.behavior?.onFetch(s,this),this.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&this.#s({type:"fetch",meta:s.fetchOptions?.meta});const a=o=>{KX(o)&&o.silent||this.#s({type:"error",error:o}),KX(o)||(this.#n.config.onError?.(o,this),this.#n.config.onSettled?.(this.state.data,o,this)),this.scheduleGc()};return this.#i=R_e({initialPromise:t?.initialPromise,fn:s.fetchFn,abort:n.abort.bind(n),onSuccess:o=>{if(o===void 0){a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(o)}catch(l){a(l);return}this.#n.config.onSuccess?.(o,this),this.#n.config.onSettled?.(o,this.state.error,this),this.scheduleGc()},onError:a,onFail:(o,l)=>{this.#s({type:"failed",failureCount:o,error:l})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>!0}),this.#i.start()}#s(e){const t=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...D_e(n.data,this.options),fetchMeta:e.meta??null};case"success":return{...n,data:e.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const r=e.error;return KX(r)&&r.revert&&this.#e?{...this.#e,fetchStatus:"idle"}:{...n,error:r,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=t(this.state),va.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:e})})}};function D_e(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:E_e(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function HZe(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var KZe=class extends gx{constructor(e={}){super(),this.config=e,this.#t=new Map}#t;build(e,t,n){const r=t.queryKey,i=t.queryHash??MY(r,t);let s=this.get(i);return s||(s=new ZZe({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(s)),s}add(e){this.#t.has(e.queryHash)||(this.#t.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#t.get(e.queryHash);t&&(e.destroy(),t===e&&this.#t.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){va.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#t.get(e)}getAll(){return[...this.#t.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(n=>$re(t,n))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(n=>$re(e,n)):t}notify(e){va.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){va.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){va.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},JZe=class extends A_e{#t;#e;#n;constructor(e){super(),this.mutationId=e.mutationId,this.#e=e.mutationCache,this.#t=[],this.state=e.state||N_e(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#e.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#e.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#e.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(e){this.#n=R_e({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(r,i)=>{this.#r({type:"failed",failureCount:r,error:i})},onPause:()=>{this.#r({type:"pause"})},onContinue:()=>{this.#r({type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#e.canRun(this)});const t=this.state.status==="pending",n=!this.#n.canStart();try{if(!t){this.#r({type:"pending",variables:e,isPaused:n}),await this.#e.config.onMutate?.(e,this);const i=await this.options.onMutate?.(e);i!==this.state.context&&this.#r({type:"pending",context:i,variables:e,isPaused:n})}const r=await this.#n.start();return await this.#e.config.onSuccess?.(r,e,this.state.context,this),await this.options.onSuccess?.(r,e,this.state.context),await this.#e.config.onSettled?.(r,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(r,null,e,this.state.context),this.#r({type:"success",data:r}),r}catch(r){try{throw await this.#e.config.onError?.(r,e,this.state.context,this),await this.options.onError?.(r,e,this.state.context),await this.#e.config.onSettled?.(void 0,r,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,r,e,this.state.context),r}finally{this.#r({type:"error",error:r})}}finally{this.#e.runNext(this)}}#r(e){const t=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),va.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#e.notify({mutation:this,type:"updated",action:e})})}};function N_e(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var eHe=class extends gx{constructor(e={}){super(),this.config=e,this.#t=new Set,this.#e=new Map,this.#n=0}#t;#e;#n;build(e,t,n){const r=new JZe({mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#t.add(e);const t=Y2(e);if(typeof t=="string"){const n=this.#e.get(t);n?n.push(e):this.#e.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#t.delete(e)){const t=Y2(e);if(typeof t=="string"){const n=this.#e.get(t);if(n)if(n.length>1){const r=n.indexOf(e);r!==-1&&n.splice(r,1)}else n[0]===e&&this.#e.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=Y2(e);if(typeof t=="string"){const r=this.#e.get(t)?.find(i=>i.state.status==="pending");return!r||r===e}else return!0}runNext(e){const t=Y2(e);return typeof t=="string"?this.#e.get(t)?.find(r=>r!==e&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){va.batch(()=>{this.#t.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(e){const t={exact:!0,...e};return this.getAll().find(n=>kre(t,n))}findAll(e={}){return this.getAll().filter(t=>kre(e,t))}notify(e){va.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return va.batch(()=>Promise.all(e.map(t=>t.continue().catch(au))))}};function Y2(e){return e.options.scope?.id}function Pre(e){return{onFetch:(t,n)=>{const r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,s=t.state.data?.pages||[],a=t.state.data?.pageParams||[];let o={pages:[],pageParams:[]},l=0;const c=async()=>{let u=!1;const d=O=>{Object.defineProperty(O,"signal",{enumerable:!0,get:()=>(t.signal.aborted?u=!0:t.signal.addEventListener("abort",()=>{u=!0}),t.signal)})},h=C_e(t.options,t.fetchOptions),f=async(O,g,m)=>{if(u)return Promise.reject();if(g==null&&O.pages.length)return Promise.resolve(O);const v={client:t.client,queryKey:t.queryKey,pageParam:g,direction:m?"backward":"forward",meta:t.options.meta};d(v);const y=await h(v),{maxPages:w}=t.options,k=m?UZe:zZe;return{pages:k(O.pages,y,w),pageParams:k(O.pageParams,g,w)}};if(i&&s.length){const O=i==="backward",g=O?tHe:Cre,m={pages:s,pageParams:a},v=g(r,m);o=await f(m,v,O)}else{const O=e??s.length;do{const g=l===0?a[0]??r.initialPageParam:Cre(r,o);if(l>0&&g==null)break;o=await f(o,g),l++}while(l<O)}return o};t.options.persister?t.fetchFn=()=>t.options.persister?.(c,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=c}}}function Cre(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function tHe(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var nHe=class{#t;#e;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#t=e.queryCache||new KZe,this.#e=e.mutationCache||new eHe,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=LY.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=WR.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#t.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#e.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#t.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Zb(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#t.findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=this.#t.get(r.queryHash)?.state.data,a=LZe(t,s);if(a!==void 0)return this.#t.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return va.batch(()=>this.#t.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#t.get(t.queryHash)?.state}removeQueries(e){const t=this.#t;va.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=this.#t;return va.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=va.batch(()=>this.#t.findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(au).catch(au)}invalidateQueries(e,t={}){return va.batch(()=>(this.#t.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=va.batch(()=>this.#t.findAll(e).filter(i=>!i.isDisabled()).map(i=>{let s=i.fetch(void 0,n);return n.throwOnError||(s=s.catch(au)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(au)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=this.#t.build(this,t);return n.isStaleByTime(Zb(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(au).catch(au)}fetchInfiniteQuery(e){return e.behavior=Pre(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(au).catch(au)}ensureInfiniteQueryData(e){return e.behavior=Pre(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return WR.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(ov(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#r.values()],n={};return t.forEach(r=>{iT(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(ov(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#i.values()],n={};return t.forEach(r=>{iT(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=MY(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===jY&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},rHe=class extends gx{constructor(e,t){super(),this.options=t,this.#t=e,this.#s=null,this.#o=Zq(),this.options.experimental_prefetchInRender||this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(t)}#t;#e=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#O;#h;#f;#c;#u;#l;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),Ere(this.#e,this.options)?this.#d():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Hq(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Hq(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#w(),this.#e.removeObserver(this)}setOptions(e){const t=this.options,n=this.#e;if(this.options=this.#t.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof hd(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#x(),this.#e.setOptions(this.options),t._defaulted&&!UR(this.options,t)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&Qre(this.#e,n,this.options,t)&&this.#d(),this.updateResult(),r&&(this.#e!==n||hd(this.options.enabled,this.#e)!==hd(t.enabled,this.#e)||Zb(this.options.staleTime,this.#e)!==Zb(t.staleTime,this.#e))&&this.#g();const i=this.#m();r&&(this.#e!==n||hd(this.options.enabled,this.#e)!==hd(t.enabled,this.#e)||i!==this.#l)&&this.#v(i)}getOptimisticResult(e){const t=this.#t.getQueryCache().build(this.#t,e),n=this.createResult(t,e);return sHe(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#e.state),n}getCurrentResult(){return this.#r}trackResult(e,t){const n={};return Object.keys(e).forEach(r=>{Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:()=>(this.trackProp(r),t?.(r),e[r])})}),n}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#t.defaultQueryOptions(e),n=this.#t.getQueryCache().build(this.#t,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#d({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#d(e){this.#x();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(au)),t}#g(){this.#b();const e=Zb(this.options.staleTime,this.#e);if(av||this.#r.isStale||!Vq(e))return;const n=__e(this.#r.dataUpdatedAt,e)+1;this.#c=setTimeout(()=>{this.#r.isStale||this.updateResult()},n)}#m(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#v(e){this.#w(),this.#l=e,!(av||hd(this.options.enabled,this.#e)===!1||!Vq(this.#l)||this.#l===0)&&(this.#u=setInterval(()=>{(this.options.refetchIntervalInBackground||LY.isFocused())&&this.#d()},this.#l))}#y(){this.#g(),this.#v(this.#m())}#b(){this.#c&&(clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(clearInterval(this.#u),this.#u=void 0)}createResult(e,t){const n=this.#e,r=this.options,i=this.#r,s=this.#i,a=this.#a,l=e!==n?e.state:this.#n,{state:c}=e;let u={...c},d=!1,h;if(t._optimisticResults){const _=this.hasListeners(),P=!_&&Ere(e,t),E=_&&Qre(e,n,t,r);(P||E)&&(u={...u,...D_e(c.data,e.options)}),t._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:f,errorUpdatedAt:O,status:g}=u;h=u.data;let m=!1;if(t.placeholderData!==void 0&&h===void 0&&g==="pending"){let _;i?.isPlaceholderData&&t.placeholderData===a?.placeholderData?(_=i.data,m=!0):_=typeof t.placeholderData=="function"?t.placeholderData(this.#f?.state.data,this.#f):t.placeholderData,_!==void 0&&(g="success",h=Yq(i?.data,_,t),d=!0)}if(t.select&&h!==void 0&&!m)if(i&&h===s?.data&&t.select===this.#O)h=this.#h;else try{this.#O=t.select,h=t.select(h),h=Yq(i?.data,h,t),this.#h=h,this.#s=null}catch(_){this.#s=_}this.#s&&(f=this.#s,h=this.#h,O=Date.now(),g="error");const v=u.fetchStatus==="fetching",y=g==="pending",w=g==="error",k=y&&v,x=h!==void 0,T={status:g,fetchStatus:u.fetchStatus,isPending:y,isSuccess:g==="success",isError:w,isInitialLoading:k,isLoading:k,data:h,dataUpdatedAt:u.dataUpdatedAt,error:f,errorUpdatedAt:O,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>l.dataUpdateCount||u.errorUpdateCount>l.errorUpdateCount,isFetching:v,isRefetching:v&&!y,isLoadingError:w&&!x,isPaused:u.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:w&&x,isStale:qY(e,t),refetch:this.refetch,promise:this.#o};if(this.options.experimental_prefetchInRender){const _=C=>{T.status==="error"?C.reject(T.error):T.data!==void 0&&C.resolve(T.data)},P=()=>{const C=this.#o=T.promise=Zq();_(C)},E=this.#o;switch(E.status){case"pending":e.queryHash===n.queryHash&&_(E);break;case"fulfilled":(T.status==="error"||T.data!==E.value)&&P();break;case"rejected":(T.status!=="error"||T.error!==E.reason)&&P();break}}return T}updateResult(){const e=this.#r,t=this.createResult(this.#e,this.options);if(this.#i=this.#e.state,this.#a=this.options,this.#i.data!==void 0&&(this.#f=this.#e),UR(t,e))return;this.#r=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#p.size)return!0;const s=new Set(i??this.#p);return this.options.throwOnError&&s.add("error"),Object.keys(this.#r).some(a=>{const o=a;return this.#r[o]!==e[o]&&s.has(o)})};this.#S({listeners:n()})}#x(){const e=this.#t.getQueryCache().build(this.#t,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#S(e){va.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#r)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function iHe(e,t){return hd(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Ere(e,t){return iHe(e,t)||e.state.data!==void 0&&Hq(e,t,t.refetchOnMount)}function Hq(e,t,n){if(hd(t.enabled,e)!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&qY(e,t)}return!1}function Qre(e,t,n,r){return(e!==t||hd(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&qY(e,n)}function qY(e,t){return hd(t.enabled,e)!==!1&&e.isStaleByTime(Zb(t.staleTime,e))}function sHe(e,t){return!UR(e.getCurrentResult(),t)}var aHe=class extends gx{#t;#e=void 0;#n;#r;constructor(t,n){super(),this.#t=t,this.setOptions(n),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const n=this.options;this.options=this.#t.defaultMutationOptions(t),UR(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&ov(n.mutationKey)!==ov(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(t){this.#i(),this.#a(t)}getCurrentResult(){return this.#e}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(t,n){return this.#r=n,this.#n?.removeObserver(this),this.#n=this.#t.getMutationCache().build(this.#t,this.options),this.#n.addObserver(this),this.#n.execute(t)}#i(){const t=this.#n?.state??N_e();this.#e={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#a(t){va.batch(()=>{if(this.#r&&this.hasListeners()){const n=this.#e.variables,r=this.#e.context;t?.type==="success"?(this.#r.onSuccess?.(t.data,n,r),this.#r.onSettled?.(t.data,null,n,r)):t?.type==="error"&&(this.#r.onError?.(t.error,n,r),this.#r.onSettled?.(void 0,t.error,n,r))}this.listeners.forEach(n=>{n(this.#e)})})}},X_e=b.createContext(void 0),Mi=e=>{const t=b.useContext(X_e);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},I_e=({client:e,children:t})=>(b.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),p.jsx(X_e.Provider,{value:e,children:t})),F_e=b.createContext(!1),oHe=()=>b.useContext(F_e);F_e.Provider;function lHe(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var cHe=b.createContext(lHe()),uHe=()=>b.useContext(cHe);function M_e(e,t){return typeof e=="function"?e(...t):!!e}function Kq(){}var dHe=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},hHe=e=>{b.useEffect(()=>{e.clearReset()},[e])},fHe=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||M_e(n,[e.error,r])),pHe=e=>{const t=e.staleTime;e.suspense&&(e.staleTime=typeof t=="function"?(...n)=>Math.max(t(...n),1e3):Math.max(t??1e3,1e3),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3)))},OHe=(e,t)=>e.isLoading&&e.isFetching&&!t,gHe=(e,t)=>e?.suspense&&t.isPending,Rre=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function mHe(e,t,n){const r=Mi(),i=oHe(),s=uHe(),a=r.defaultQueryOptions(e);r.getDefaultOptions().queries?._experimental_beforeQuery?.(a),a._optimisticResults=i?"isRestoring":"optimistic",pHe(a),dHe(a,s),hHe(s);const o=!r.getQueryCache().get(a.queryHash),[l]=b.useState(()=>new t(r,a)),c=l.getOptimisticResult(a),u=!i&&e.subscribed!==!1;if(b.useSyncExternalStore(b.useCallback(d=>{const h=u?l.subscribe(va.batchCalls(d)):Kq;return l.updateResult(),h},[l,u]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),b.useEffect(()=>{l.setOptions(a)},[a,l]),gHe(a,c))throw Rre(a,l,s);if(fHe({result:c,errorResetBoundary:s,throwOnError:a.throwOnError,query:r.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw c.error;return r.getDefaultOptions().queries?._experimental_afterQuery?.(a,c),a.experimental_prefetchInRender&&!av&&OHe(c,i)&&(o?Rre(a,l,s):r.getQueryCache().get(a.queryHash)?.promise)?.catch(Kq).finally(()=>{l.updateResult()}),a.notifyOnChangeProps?c:l.trackResult(c)}function ir(e,t){return mHe(e,rHe)}function Ol(e,t){const n=Mi(),[r]=b.useState(()=>new aHe(n,e));b.useEffect(()=>{r.setOptions(e)},[r,e]);const i=b.useSyncExternalStore(b.useCallback(a=>r.subscribe(va.batchCalls(a)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=b.useCallback((a,o)=>{r.mutate(a,o).catch(Kq)},[r]);if(i.error&&M_e(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}const vHe=function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"}(),yHe=function(e,t){return new URL(e,t).href},Are={},Le=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){const a=document.getElementsByTagName("link"),o=document.querySelector("meta[property=csp-nonce]"),l=o?.nonce||o?.getAttribute("nonce");i=Promise.allSettled(n.map(c=>{if(c=yHe(c,r),c in Are)return;Are[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(!!r)for(let O=a.length-1;O>=0;O--){const g=a[O];if(g.href===c&&(!u||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${c}"]${d}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":vHe,u||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((O,g)=>{f.addEventListener("load",O),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&s(o.reason);return t().catch(s)})};var pd,Ve=typeof window<"u"?window:void 0,Al=typeof globalThis<"u"?globalThis:Ve,j_e=Array.prototype,Dre=j_e.forEach,Nre=j_e.indexOf,kc=Al?.navigator,ln=Al?.document,Pl=Al?.location,Jq=Al?.fetch,ez=Al!=null&&Al.XMLHttpRequest&&"withCredentials"in new Al.XMLHttpRequest?Al.XMLHttpRequest:void 0,Xre=Al?.AbortController,ia=kc?.userAgent,er=Ve??{},Zf={DEBUG:!1,LIB_VERSION:"1.235.6"},JX="$copy_autocapture",bHe=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];(function(e){e.GZipJS="gzip-js",e.Base64="base64"})(pd||(pd={}));var wHe=["fatal","error","warning","log","info","debug"];function wr(e,t){return e.indexOf(t)!==-1}var j3=function(e){return e.trim()},zY=function(e){return e.replace(/^\$/,"")},xHe=Array.isArray,L_e=Object.prototype,q_e=L_e.hasOwnProperty,L3=L_e.toString,_s=xHe||function(e){return L3.call(e)==="[object Array]"},Sd=e=>typeof e=="function",Ps=e=>e===Object(e)&&!_s(e),Eb=e=>{if(Ps(e)){for(var t in e)if(q_e.call(e,t))return!1;return!0}return!1},Yt=e=>e===void 0,ca=e=>L3.call(e)=="[object String]",tz=e=>ca(e)&&e.trim().length===0,nm=e=>e===null,fi=e=>Yt(e)||nm(e),al=e=>L3.call(e)=="[object Number]",rp=e=>L3.call(e)==="[object Boolean]",SHe=e=>e instanceof FormData,$He=e=>wr(bHe,e),z_e=e=>{var t={_log:function(n){if(Ve&&(Zf.DEBUG||er.POSTHOG_DEBUG)&&!Yt(Ve.console)&&Ve.console){for(var r=("__rrweb_original__"in Ve.console[n])?Ve.console[n].__rrweb_original__:Ve.console[n],i=arguments.length,s=new Array(i>1?i-1:0),a=1;a<i;a++)s[a-1]=arguments[a];r(e,...s)}},info:function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];t._log("log",...r)},warn:function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];t._log("warn",...r)},error:function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];t._log("error",...r)},critical:function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];console.error(e,...r)},uninitializedWarning:n=>{t.error("You must initialize PostHog before calling ".concat(n))},createLogger:n=>z_e("".concat(e," ").concat(n))};return t},yn=z_e("[PostHog.js]"),Uo=yn.createLogger,kHe=Uo("[ExternalScriptsLoader]"),Ire=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return kHe.warn("".concat(t," was requested but loading of external scripts is disabled.")),n("Loading of external scripts is disabled");var r=ln?.querySelectorAll("script");if(r){for(var i=0;i<r.length;i++)if(r[i].src===t)return n()}var s=()=>{if(!ln)return n("document not found");var a=ln.createElement("script");if(a.type="text/javascript",a.crossOrigin="anonymous",a.src=t,a.onload=c=>n(void 0,c),a.onerror=c=>n(c),e.config.prepare_external_dependency_script&&(a=e.config.prepare_external_dependency_script(a)),!a)return n("prepare_external_dependency_script returned null");var o,l=ln.querySelectorAll("body > script");l.length>0?(o=l[0].parentNode)===null||o===void 0||o.insertBefore(a,l[0]):ln.body.appendChild(a)};ln!=null&&ln.body?s():ln?.addEventListener("DOMContentLoaded",s)};function Fre(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Je(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Fre(Object(n),!0).forEach(function(r){Xt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Fre(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Xt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function U_e(e,t){if(e==null)return{};var n,r,i=function(a,o){if(a==null)return{};var l,c,u={},d=Object.keys(a);for(c=0;c<d.length;c++)l=d[c],o.indexOf(l)>=0||(u[l]=a[l]);return u}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}er.__PosthogExtensions__=er.__PosthogExtensions__||{},er.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{var r="/static/".concat(t,".js")+"?v=".concat(e.version);if(t==="remote-config"&&(r="/array/".concat(e.config.token,"/config.js")),t==="toolbar"){var i=3e5,s=Math.floor(Date.now()/i)*i;r="".concat(r,"&t=").concat(s)}var a=e.requestRouter.endpointFor("assets",r);Ire(e,a,n)},er.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{var r=e.requestRouter.endpointFor("api",t);Ire(e,r,n)};var GR={};function yg(e,t,n){if(_s(e)){if(Dre&&e.forEach===Dre)e.forEach(t,n);else if("length"in e&&e.length===+e.length){for(var r=0,i=e.length;r<i;r++)if(r in e&&t.call(n,e[r],r)===GR)return}}}function _i(e,t,n){if(!fi(e)){if(_s(e))return yg(e,t,n);if(SHe(e)){for(var r of e.entries())if(t.call(n,r[1],r[0])===GR)return}else for(var i in e)if(q_e.call(e,i)&&t.call(n,e[i],i)===GR)return}}var Fs=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return yg(n,function(i){for(var s in i)i[s]!==void 0&&(e[s]=i[s])}),e},PQ=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return yg(n,function(i){yg(i,function(s){e.push(s)})}),e};function CQ(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r}var Mre=function(e){try{return e()}catch{return}},THe=function(e){return function(){try{for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return e.apply(this,n)}catch(i){yn.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),yn.critical(i)}}},sT=function(e){var t={};return _i(e,function(n,r){ca(n)&&n.length>0&&(t[r]=n)}),t};function _He(e,t){return n=e,r=s=>ca(s)&&!nm(t)?s.slice(0,t):s,i=new Set,function s(a,o){return a!==Object(a)?r?r(a,o):a:i.has(a)?void 0:(i.add(a),_s(a)?(l=[],yg(a,c=>{l.push(s(c))})):(l={},_i(a,(c,u)=>{i.has(c)||(l[u]=s(c,u))})),l);var l}(n);var n,r,i}var PHe=["herokuapp.com","vercel.app","netlify.app"];function CHe(e){var t=e?.hostname;if(!ca(t))return!1;var n=t.split(".").slice(-2).join(".");for(var r of PHe)if(n===r)return!1;return!0}function W_e(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return e[n]}function Ls(e,t,n,r){var{capture:i=!1,passive:s=!0}=r??{};e?.addEventListener(t,n,{capture:i,passive:s})}var G_e="$people_distinct_id",v$="__alias",y$="__timers",jre="$autocapture_disabled_server_side",nz="$heatmaps_enabled_server_side",Lre="$exception_capture_enabled_server_side",qre="$web_vitals_enabled_server_side",V_e="$dead_clicks_enabled_server_side",zre="$web_vitals_allowed_metrics",rz="$session_recording_enabled_server_side",Ure="$console_log_recording_enabled_server_side",Wre="$session_recording_network_payload_capture",Gre="$session_recording_masking",Vre="$session_recording_canvas_recording",Bre="$replay_sample_rate",Yre="$replay_minimum_duration",Zre="$replay_script_config",VR="$sesid",b$="$session_is_sampled",e6="$session_recording_url_trigger_activated_session",t6="$session_recording_event_trigger_activated_session",Qb="$enabled_feature_flags",EQ="$early_access_features",iz="$feature_flag_details",w$="$stored_person_properties",Jm="$stored_group_properties",sz="$surveys",Z2="$surveys_activated",BR="$flag_call_reported",qf="$user_state",az="$client_session_props",oz="$capture_rate_limit",lz="$initial_campaign_params",cz="$initial_referrer_info",uz="$initial_person_info",YR="$epp",B_e="__POSTHOG_TOOLBAR__",Hre="$posthog_cookieless",EHe=[G_e,v$,"__cmpns",y$,rz,nz,VR,Qb,qf,EQ,iz,Jm,w$,sz,BR,az,oz,lz,cz,YR];function Kre(e){var t;return e instanceof Element&&(e.id===B_e||!((t=e.closest)===null||t===void 0||!t.call(e,".toolbar-global-fade-container")))}function q3(e){return!!e&&e.nodeType===1}function bg(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Y_e(e){return!!e&&e.nodeType===3}function Z_e(e){return!!e&&e.nodeType===11}function UY(e){return e?j3(e).split(/\s+/):[]}function Jre(e){var t=Ve?.location.href;return!!(t&&e&&e.some(n=>t.match(n)))}function ZR(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return UY(t)}function H_e(e){return fi(e)?null:j3(e).split(/(\s+)/).filter(t=>U1(t)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function z3(e){var t="";return hz(e)&&!ePe(e)&&e.childNodes&&e.childNodes.length&&_i(e.childNodes,function(n){var r;Y_e(n)&&n.textContent&&(t+=(r=H_e(n.textContent))!==null&&r!==void 0?r:"")}),j3(t)}function K_e(e){return Yt(e.target)?e.srcElement||null:(t=e.target)!==null&&t!==void 0&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var dz=["a","button","form","input","select","textarea","label"];function J_e(e){var t=e.parentNode;return!(!t||!q3(t))&&t}function QHe(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0;if(!Ve||!e||bg(e,"html")||!q3(e)||n!=null&&n.url_allowlist&&!Jre(n.url_allowlist)||n!=null&&n.url_ignorelist&&Jre(n.url_ignorelist))return!1;if(n!=null&&n.dom_event_allowlist){var s=n.dom_event_allowlist;if(s&&!s.some(f=>t.type===f))return!1}for(var a=!1,o=[e],l=!0,c=e;c.parentNode&&!bg(c,"body");)if(Z_e(c.parentNode))o.push(c.parentNode.host),c=c.parentNode.host;else{if(!(l=J_e(c)))break;if(r||dz.indexOf(l.tagName.toLowerCase())>-1)a=!0;else{var u=Ve.getComputedStyle(l);u&&u.getPropertyValue("cursor")==="pointer"&&(a=!0)}o.push(l),c=l}if(!function(f,O){var g=O?.element_allowlist;if(Yt(g))return!0;var m=function(w){if(g.some(k=>w.tagName.toLowerCase()===k))return{v:!0}};for(var v of f){var y=m(v);if(typeof y=="object")return y.v}return!1}(o,n)||!function(f,O){var g=O?.css_selector_allowlist;if(Yt(g))return!0;var m=function(w){if(g.some(k=>w.matches(k)))return{v:!0}};for(var v of f){var y=m(v);if(typeof y=="object")return y.v}return!1}(o,n))return!1;var d=Ve.getComputedStyle(e);if(d&&d.getPropertyValue("cursor")==="pointer"&&t.type==="click")return!0;var h=e.tagName.toLowerCase();switch(h){case"html":return!1;case"form":return(i||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(i||["change","click"]).indexOf(t.type)>=0;default:return a?(i||["click"]).indexOf(t.type)>=0:(i||["click"]).indexOf(t.type)>=0&&(dz.indexOf(h)>-1||e.getAttribute("contenteditable")==="true")}}function hz(e){for(var t=e;t.parentNode&&!bg(t,"body");t=t.parentNode){var n=ZR(t);if(wr(n,"ph-sensitive")||wr(n,"ph-no-capture"))return!1}if(wr(ZR(e),"ph-include"))return!0;var r=e.type||"";if(ca(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var i=e.name||e.id||"";return!(ca(i)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,"")))}function ePe(e){return!!(bg(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||bg(e,"select")||bg(e,"textarea")||e.getAttribute("contenteditable")==="true")}var tPe="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",RHe=new RegExp("^(?:".concat(tPe,")$")),AHe=new RegExp(tPe),nPe="\\d{3}-?\\d{2}-?\\d{4}",DHe=new RegExp("^(".concat(nPe,")$")),NHe=new RegExp("(".concat(nPe,")"));function U1(e){var t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return!(fi(e)||ca(e)&&(e=j3(e),(t?RHe:AHe).test((e||"").replace(/[- ]/g,""))||(t?DHe:NHe).test(e)))}function rPe(e){var t=z3(e);return U1(t="".concat(t," ").concat(iPe(e)).trim())?t:""}function iPe(e){var t="";return e&&e.childNodes&&e.childNodes.length&&_i(e.childNodes,function(n){var r;if(n&&((r=n.tagName)===null||r===void 0?void 0:r.toLowerCase())==="span")try{var i=z3(n);t="".concat(t," ").concat(i).trim(),n.childNodes&&n.childNodes.length&&(t="".concat(t," ").concat(iPe(n)).trim())}catch(s){yn.error("[AutoCapture]",s)}}),t}function XHe(e){return function(t){var n=t.map(r=>{var i,s,a="";if(r.tag_name&&(a+=r.tag_name),r.attr_class)for(var o of(r.attr_class.sort(),r.attr_class))a+=".".concat(o.replace(/"/g,""));var l=Je(Je(Je(Je({},r.text?{text:r.text}:{}),{},{"nth-child":(i=r.nth_child)!==null&&i!==void 0?i:0,"nth-of-type":(s=r.nth_of_type)!==null&&s!==void 0?s:0},r.href?{href:r.href}:{}),r.attr_id?{attr_id:r.attr_id}:{}),r.attributes),c={};return CQ(l).sort((u,d)=>{var[h]=u,[f]=d;return h.localeCompare(f)}).forEach(u=>{var[d,h]=u;return c[eie(d.toString())]=eie(h.toString())}),a+=":",a+=CQ(l).map(u=>{var[d,h]=u;return"".concat(d,'="').concat(h,'"')}).join("")});return n.join(";")}(function(t){return t.map(n=>{var r,i,s={text:(r=n.$el_text)===null||r===void 0?void 0:r.slice(0,400),tag_name:n.tag_name,href:(i=n.attr__href)===null||i===void 0?void 0:i.slice(0,2048),attr_class:IHe(n),attr_id:n.attr__id,nth_child:n.nth_child,nth_of_type:n.nth_of_type,attributes:{}};return CQ(n).filter(a=>{var[o]=a;return o.indexOf("attr__")===0}).forEach(a=>{var[o,l]=a;return s.attributes[o]=l}),s})}(e))}function eie(e){return e.replace(/"|\\"/g,'\\"')}function IHe(e){var t=e.attr__class;return t?_s(t)?t:UY(t):void 0}class sPe{constructor(){this.clicks=[]}isRageClick(t,n,r){var i=this.clicks[this.clicks.length-1];if(i&&Math.abs(t-i.x)+Math.abs(n-i.y)<30&&r-i.timestamp<1e3){if(this.clicks.push({x:t,y:n,timestamp:r}),this.clicks.length===3)return!0}else this.clicks=[{x:t,y:n,timestamp:r}];return!1}}var FHe=["localhost","127.0.0.1"],Hb=e=>{var t=ln?.createElement("a");return Yt(t)?null:(t.href=e,t)},MHe=function(e){var t,n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"&",i=[];return _i(e,function(s,a){Yt(s)||Yt(a)||a==="undefined"||(t=encodeURIComponent((o=>o instanceof File)(s)?s.name:s.toString()),n=encodeURIComponent(a),i[i.length]=n+"="+t)}),i.join(r)},HR=function(e,t){for(var n,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i=0;i<r.length;i++){var s=r[i].split("=");if(s[0]===t){n=s;break}}if(!_s(n)||n.length<2)return"";var a=n[1];try{a=decodeURIComponent(a)}catch{yn.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},n6=function(e,t,n){if(!e||!t||!t.length)return e;for(var r=e.split("#"),i=r[0]||"",s=r[1],a=i.split("?"),o=a[1],l=a[0],c=(o||"").split("&"),u=[],d=0;d<c.length;d++){var h=c[d].split("=");_s(h)&&(t.includes(h[0])?u.push(h[0]+"="+n):u.push(c[d]))}var f=l;return o!=null&&(f+="?"+u.join("&")),s!=null&&(f+="#"+s),f},KR=function(e,t){var n=e.match(new RegExp(t+"=([^&]*)"));return n?n[1]:null},tie=Uo("[AutoCapture]");function r6(e,t){return t.length>e?t.slice(0,e)+"...":t}function jHe(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!q3(t));return t}function LHe(e,t,n,r){var i=e.tagName.toLowerCase(),s={tag_name:i};dz.indexOf(i)>-1&&!n&&(i.toLowerCase()==="a"||i.toLowerCase()==="button"?s.$el_text=r6(1024,rPe(e)):s.$el_text=r6(1024,z3(e)));var a=ZR(e);a.length>0&&(s.classes=a.filter(function(u){return u!==""})),_i(e.attributes,function(u){var d;if((!ePe(e)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(r==null||!r.includes(u.name))&&!t&&U1(u.value)&&(d=u.name,!ca(d)||d.substring(0,10)!=="_ngcontent"&&d.substring(0,7)!=="_nghost")){var h=u.value;u.name==="class"&&(h=UY(h).join(" ")),s["attr__"+u.name]=r6(1024,h)}});for(var o=1,l=1,c=e;c=jHe(c);)o++,c.tagName===e.tagName&&l++;return s.nth_child=o,s.nth_of_type=l,s}function qHe(e,t){for(var n,r,{e:i,maskAllElementAttributes:s,maskAllText:a,elementAttributeIgnoreList:o,elementsChainAsString:l}=t,c=[e],u=e;u.parentNode&&!bg(u,"body");)Z_e(u.parentNode)?(c.push(u.parentNode.host),u=u.parentNode.host):(c.push(u.parentNode),u=u.parentNode);var d,h=[],f={},O=!1,g=!1;if(_i(c,k=>{var x=hz(k);k.tagName.toLowerCase()==="a"&&(O=k.getAttribute("href"),O=x&&O&&U1(O)&&O),wr(ZR(k),"ph-no-capture")&&(g=!0),h.push(LHe(k,s,a,o));var S=function(T){if(!hz(T))return{};var _={};return _i(T.attributes,function(P){if(P.name&&P.name.indexOf("data-ph-capture-attribute")===0){var E=P.name.replace("data-ph-capture-attribute-",""),C=P.value;E&&C&&U1(C)&&(_[E]=C)}}),_}(k);Fs(f,S)}),g)return{props:{},explicitNoCapture:g};if(a||(e.tagName.toLowerCase()==="a"||e.tagName.toLowerCase()==="button"?h[0].$el_text=rPe(e):h[0].$el_text=z3(e)),O){var m,v;h[0].attr__href=O;var y=(m=Hb(O))===null||m===void 0?void 0:m.host,w=Ve==null||(v=Ve.location)===null||v===void 0?void 0:v.host;y&&w&&y!==w&&(d=O)}return{props:Fs({$event_type:i.type,$ce_version:1},l?{}:{$elements:h},{$elements_chain:XHe(h)},(n=h[0])!==null&&n!==void 0&&n.$el_text?{$el_text:(r=h[0])===null||r===void 0?void 0:r.$el_text}:{},d&&i.type==="click"?{$external_click_url:d}:{},f)}}let zHe=class{constructor(t){Xt(this,"_initialized",!1),Xt(this,"_isDisabledServerSide",null),Xt(this,"rageclicks",new sPe),Xt(this,"_elementsChainAsString",!1),this.instance=t,this._elementSelectors=null}get config(){var t,n,r=Ps(this.instance.config.autocapture)?this.instance.config.autocapture:{};return r.url_allowlist=(t=r.url_allowlist)===null||t===void 0?void 0:t.map(i=>new RegExp(i)),r.url_ignorelist=(n=r.url_ignorelist)===null||n===void 0?void 0:n.map(i=>new RegExp(i)),r}_addDomEventHandlers(){if(this.isBrowserSupported()){if(Ve&&ln){var t=r=>{r=r||Ve?.event;try{this._captureEvent(r)}catch(i){tie.error("Failed to capture event",i)}};if(Ls(ln,"submit",t,{capture:!0}),Ls(ln,"change",t,{capture:!0}),Ls(ln,"click",t,{capture:!0}),this.config.capture_copied_text){var n=r=>{r=r||Ve?.event,this._captureEvent(r,JX)};Ls(ln,"copy",n,{capture:!0}),Ls(ln,"cut",n,{capture:!0})}}}else tie.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this._elementsChainAsString=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[jre]:!!t.autocapture_opt_out}),this._isDisabledServerSide=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this._elementSelectors=t}getElementSelectors(t){var n,r=[];return(n=this._elementSelectors)===null||n===void 0||n.forEach(i=>{var s=ln?.querySelectorAll(i);s?.forEach(a=>{t===a&&r.push(i)})}),r}get isEnabled(){var t,n,r=(t=this.instance.persistence)===null||t===void 0?void 0:t.props[jre],i=this._isDisabledServerSide;if(nm(i)&&!rp(r)&&!this.instance.config.advanced_disable_decide)return!1;var s=(n=this._isDisabledServerSide)!==null&&n!==void 0?n:!!r;return!!this.instance.config.autocapture&&!s}_captureEvent(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"$autocapture";if(this.isEnabled){var r,i=K_e(t);Y_e(i)&&(i=i.parentNode||null),n==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&this.instance.config.rageclick&&(r=this.rageclicks)!==null&&r!==void 0&&r.isRageClick(t.clientX,t.clientY,new Date().getTime())&&this._captureEvent(t,"$rageclick");var s=n===JX;if(i&&QHe(i,t,this.config,s,s?["copy","cut"]:void 0)){var{props:a,explicitNoCapture:o}=qHe(i,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(o)return!1;var l=this.getElementSelectors(i);if(l&&l.length>0&&(a.$element_selectors=l),n===JX){var c,u=H_e(Ve==null||(c=Ve.getSelection())===null||c===void 0?void 0:c.toString()),d=t.type||"clipboard";if(!u)return!1;a.$selected_content=u,a.$copy_type=d}return this.instance.capture(n,a),!0}}}isBrowserSupported(){return Sd(ln?.querySelectorAll)}};Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return al(e)&&isFinite(e)&&Math.floor(e)===e});var nie="0123456789abcdef";let UHe=class fz{constructor(t){if(this.bytes=t,t.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||t<0||n<0||r<0||i<0||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=t/Math.pow(2,40),s[1]=t/Math.pow(2,32),s[2]=t/Math.pow(2,24),s[3]=t/Math.pow(2,16),s[4]=t/Math.pow(2,8),s[5]=t,s[6]=112|n>>>8,s[7]=n,s[8]=128|r>>>24,s[9]=r>>>16,s[10]=r>>>8,s[11]=r,s[12]=i>>>24,s[13]=i>>>16,s[14]=i>>>8,s[15]=i,new fz(s)}toString(){for(var t="",n=0;n<this.bytes.length;n++)t=t+nie.charAt(this.bytes[n]>>>4)+nie.charAt(15&this.bytes[n]),n!==3&&n!==5&&n!==7&&n!==9||(t+="-");if(t.length!==36)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new fz(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(var n=0;n<16;n++){var r=this.bytes[n]-t.bytes[n];if(r!==0)return Math.sign(r)}return 0}},WHe=class{constructor(){Xt(this,"timestamp",0),Xt(this,"counter",0),Xt(this,"random",new GHe)}generate(){var t=this.generateOrAbort();if(Yt(t)){this.timestamp=0;var n=this.generateOrAbort();if(Yt(n))throw new Error("Could not generate UUID after timestamp reset");return n}return t}generateOrAbort(){var t=Date.now();if(t>this.timestamp)this.timestamp=t,this.resetCounter();else{if(!(t+1e4>this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return UHe.fromFieldsV7(this.timestamp,Math.trunc(this.counter/Math.pow(2,30)),this.counter&Math.pow(2,30)-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}};var rie,aPe=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};Ve&&!Yt(Ve.crypto)&&crypto.getRandomValues&&(aPe=e=>crypto.getRandomValues(e));let GHe=class{constructor(){Xt(this,"buffer",new Uint32Array(8)),Xt(this,"cursor",1/0)}nextUint32(){return this.cursor>=this.buffer.length&&(aPe(this.buffer),this.cursor=0),this.buffer[this.cursor++]}};var eg=()=>VHe().toString(),VHe=()=>(rie||(rie=new WHe)).generate(),BHe="Thu, 01 Jan 1970 00:00:00 GMT",sS="",YHe=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function ZHe(e,t){if(t){var n=function(i){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ln;if(sS)return sS;if(!s||["localhost","127.0.0.1"].includes(i))return"";for(var a=i.split("."),o=Math.min(a.length,8),l="dmn_chk_"+eg(),c=new RegExp("(^|;)\\s*"+l+"=1");!sS&&o--;){var u=a.slice(o).join("."),d=l+"=1;domain=."+u;s.cookie=d,c.test(s.cookie)&&(s.cookie=d+";expires="+BHe,sS=u)}return sS}(e);if(!n){var r=(i=>{var s=i.match(YHe);return s?s[0]:""})(e);r!==n&&yn.info("Warning: cookie subdomain discovery mismatch",r,n),n=r}return n?"; domain=."+n:""}return""}var LO,mp={is_supported:()=>!!ln,error:function(e){yn.error("cookieStore error: "+e)},get:function(e){if(ln){try{for(var t=e+"=",n=ln.cookie.split(";").filter(s=>s.length),r=0;r<n.length;r++){for(var i=n[r];i.charAt(0)==" ";)i=i.substring(1,i.length);if(i.indexOf(t)===0)return decodeURIComponent(i.substring(t.length,i.length))}}catch{}return null}},parse:function(e){var t;try{t=JSON.parse(mp.get(e))||{}}catch{}return t},set:function(e,t,n,r,i){if(ln)try{var s="",a="",o=ZHe(ln.location.hostname,r);if(n){var l=new Date;l.setTime(l.getTime()+24*n*60*60*1e3),s="; expires="+l.toUTCString()}i&&(a="; secure");var c=e+"="+encodeURIComponent(JSON.stringify(t))+s+"; SameSite=Lax; path=/"+o+a;return c.length>3686.4&&yn.warn("cookieStore warning: large cookie, len="+c.length),ln.cookie=c,c}catch{return}},remove:function(e,t){try{mp.set(e,"",-1,t)}catch{return}}},i6=null,ga={is_supported:function(){if(!nm(i6))return i6;var e=!0;if(Yt(Ve))e=!1;else try{var t="__mplssupport__";ga.set(t,"xyz"),ga.get(t)!=='"xyz"'&&(e=!1),ga.remove(t)}catch{e=!1}return e||yn.error("localStorage unsupported; falling back to cookie store"),i6=e,e},error:function(e){yn.error("localStorage error: "+e)},get:function(e){try{return Ve?.localStorage.getItem(e)}catch(t){ga.error(t)}return null},parse:function(e){try{return JSON.parse(ga.get(e))||{}}catch{}return null},set:function(e,t){try{Ve?.localStorage.setItem(e,JSON.stringify(t))}catch(n){ga.error(n)}},remove:function(e){try{Ve?.localStorage.removeItem(e)}catch(t){ga.error(t)}}},HHe=["distinct_id",VR,b$,YR,uz],H2=Je(Je({},ga),{},{parse:function(e){try{var t={};try{t=mp.parse(e)||{}}catch{}var n=Fs(t,JSON.parse(ga.get(e)||"{}"));return ga.set(e,n),n}catch{}return null},set:function(e,t,n,r,i,s){try{ga.set(e,t,void 0,void 0,s);var a={};HHe.forEach(o=>{t[o]&&(a[o]=t[o])}),Object.keys(a).length&&mp.set(e,a,n,r,i,s)}catch(o){ga.error(o)}},remove:function(e,t){try{Ve?.localStorage.removeItem(e),mp.remove(e,t)}catch(n){ga.error(n)}}}),K2={},KHe={is_supported:function(){return!0},error:function(e){yn.error("memoryStorage error: "+e)},get:function(e){return K2[e]||null},parse:function(e){return K2[e]||null},set:function(e,t){K2[e]=t},remove:function(e){delete K2[e]}},Qm=null,no={is_supported:function(){if(!nm(Qm))return Qm;if(Qm=!0,Yt(Ve))Qm=!1;else try{var e="__support__";no.set(e,"xyz"),no.get(e)!=='"xyz"'&&(Qm=!1),no.remove(e)}catch{Qm=!1}return Qm},error:function(e){yn.error("sessionStorage error: ",e)},get:function(e){try{return Ve?.sessionStorage.getItem(e)}catch(t){no.error(t)}return null},parse:function(e){try{return JSON.parse(no.get(e))||null}catch{}return null},set:function(e,t){try{Ve?.sessionStorage.setItem(e,JSON.stringify(t))}catch(n){no.error(n)}},remove:function(e){try{Ve?.sessionStorage.removeItem(e)}catch(t){no.error(t)}}};(function(e){e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED"})(LO||(LO={}));let JHe=class{constructor(t){this.instance=t}get config(){return this.instance.config}get consent(){return this.getDnt()?LO.DENIED:this.storedConsent}isOptedOut(){return this.consent===LO.DENIED||this.consent===LO.PENDING&&this.config.opt_out_capturing_by_default}isOptedIn(){return!this.isOptedOut()}optInOut(t){this.storage.set(this.storageKey,t?1:0,this.config.cookie_expiration,this.config.cross_subdomain_cookie,this.config.secure_cookie)}reset(){this.storage.remove(this.storageKey,this.config.cross_subdomain_cookie)}get storageKey(){var{token:t,opt_out_capturing_cookie_prefix:n}=this.instance.config;return(n||"__ph_opt_in_out_")+t}get storedConsent(){var t=this.storage.get(this.storageKey);return t==="1"?LO.GRANTED:t==="0"?LO.DENIED:LO.PENDING}get storage(){if(!this._storage){var t=this.config.opt_out_capturing_persistence_type;this._storage=t==="localStorage"?ga:mp;var n=t==="localStorage"?mp:ga;n.get(this.storageKey)&&(this._storage.get(this.storageKey)||this.optInOut(n.get(this.storageKey)==="1"),n.remove(this.storageKey,this.config.cross_subdomain_cookie))}return this._storage}getDnt(){return!!this.config.respect_dnt&&!!W_e([kc?.doNotTrack,kc?.msDoNotTrack,er.doNotTrack],t=>wr([!0,1,"1","yes"],t))}};var J2=Uo("[Dead Clicks]"),eKe=()=>!0,tKe=e=>{var t,n=!((t=e.instance.persistence)===null||t===void 0||!t.get_property(V_e)),r=e.instance.config.capture_dead_clicks;return rp(r)?r:n};let oPe=class{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(t,n,r){this.instance=t,this.isEnabled=n,this.onCapture=r,this.startIfEnabled()}onRemoteConfig(t){this.instance.persistence&&this.instance.persistence.register({[V_e]:t?.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.loadScript(()=>{this.start()})}loadScript(t){var n,r,i;(n=er.__PosthogExtensions__)!==null&&n!==void 0&&n.initDeadClicksAutocapture&&t(),(r=er.__PosthogExtensions__)===null||r===void 0||(i=r.loadExternalDependency)===null||i===void 0||i.call(r,this.instance,"dead-clicks-autocapture",s=>{s?J2.error("failed to load script",s):t()})}start(){var t;if(ln){if(!this._lazyLoadedDeadClicksAutocapture&&(t=er.__PosthogExtensions__)!==null&&t!==void 0&&t.initDeadClicksAutocapture){var n=Ps(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};n.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=er.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this._lazyLoadedDeadClicksAutocapture.start(ln),J2.info("starting...")}}else J2.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,J2.info("stopping..."))}};var s6=Uo("[ExceptionAutocapture]");let nKe=class{constructor(t){var n;Xt(this,"startCapturing",()=>{var r;if(Ve&&this.isEnabled&&(r=er.__PosthogExtensions__)!==null&&r!==void 0&&r.errorWrappingFunctions){var i=er.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,s=er.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=er.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.unwrapOnError&&this.config.capture_unhandled_errors&&(this.unwrapOnError=i(this.captureException.bind(this))),!this.unwrapUnhandledRejection&&this.config.capture_unhandled_rejections&&(this.unwrapUnhandledRejection=s(this.captureException.bind(this))),!this.unwrapConsoleError&&this.config.capture_console_errors&&(this.unwrapConsoleError=a(this.captureException.bind(this)))}catch(o){s6.error("failed to start",o),this.stopCapturing()}}}),this.instance=t,this.remoteEnabled=!((n=this.instance.persistence)===null||n===void 0||!n.props[Lre]),this.config=this.requiredConfig(),this.startIfEnabled()}requiredConfig(){var t=this.instance.config.capture_exceptions,n={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Ps(t)?n=Je(Je({},n),t):(Yt(t)?this.remoteEnabled:t)&&(n=Je(Je({},n),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),n}get isEnabled(){return this.config.capture_console_errors||this.config.capture_unhandled_errors||this.config.capture_unhandled_rejections}startIfEnabled(){this.isEnabled&&(s6.info("enabled"),this.loadScript(this.startCapturing))}loadScript(t){var n,r,i;(n=er.__PosthogExtensions__)!==null&&n!==void 0&&n.errorWrappingFunctions&&t(),(r=er.__PosthogExtensions__)===null||r===void 0||(i=r.loadExternalDependency)===null||i===void 0||i.call(r,this.instance,"exception-autocapture",s=>{if(s)return s6.error("failed to load script",s);t()})}stopCapturing(){var t,n,r;(t=this.unwrapOnError)===null||t===void 0||t.call(this),this.unwrapOnError=void 0,(n=this.unwrapUnhandledRejection)===null||n===void 0||n.call(this),this.unwrapUnhandledRejection=void 0,(r=this.unwrapConsoleError)===null||r===void 0||r.call(this),this.unwrapConsoleError=void 0}onRemoteConfig(t){var n=t.autocaptureExceptions;this.remoteEnabled=!!n||!1,this.config=this.requiredConfig(),this.instance.persistence&&this.instance.persistence.register({[Lre]:this.remoteEnabled}),this.startIfEnabled()}captureException(t){var n=this.instance.requestRouter.endpointFor("ui");t.$exception_personURL="".concat(n,"/project/").concat(this.instance.config.token,"/person/").concat(this.instance.get_distinct_id()),this.instance.exceptions.sendExceptionEvent(t)}};function lPe(e){return!Yt(Event)&&cPe(e,Event)}function cPe(e,t){try{return e instanceof t}catch{return!1}}function QQ(e,t){return Object.prototype.toString.call(e)==="[object ".concat(t,"]")}function a6(e){return QQ(e,"DOMError")}var iie=/\(error: (.*)\)/,sie=50,Rb="?";function o6(e,t,n,r){var i={platform:"web:javascript",filename:e,function:t==="<anonymous>"?Rb:t,in_app:!0};return Yt(n)||(i.lineno=n),Yt(r)||(i.colno=r),i}var rKe=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,iKe=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,sKe=/\((\S*)(?::(\d+))(?::(\d+))\)/,aKe=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,oKe=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,lKe=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=t.sort((i,s)=>i[0]-s[0]).map(i=>i[1]);return function(i){for(var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=[],o=i.split(`
3
3
  `),l=s;l<o.length;l++){var c=o[l];if(!(c.length>1024)){var u=iie.test(c)?c.replace(iie,"$1"):c;if(!u.match(/\S*Error: /)){for(var d of r){var h=d(u);if(h){a.push(h);break}}if(a.length>=sie)break}}}return function(f){if(!f.length)return[];var O=Array.from(f);return O.reverse(),O.slice(0,sie).map(g=>Je(Je({},g),{},{filename:g.filename||cKe(O).filename,function:g.function||Rb}))}(a)}}([30,e=>{var t=rKe.exec(e);if(t){var[,n,r,i]=t;return o6(n,Rb,+r,+i)}var s=iKe.exec(e);if(s){if(s[2]&&s[2].indexOf("eval")===0){var a=sKe.exec(s[2]);a&&(s[2]=a[1],s[3]=a[2],s[4]=a[3])}var[o,l]=oie(s[1]||Rb,s[2]);return o6(l,o,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}}],[50,e=>{var t=aKe.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var n=oKe.exec(t[3]);n&&(t[1]=t[1]||"eval",t[3]=n[1],t[4]=n[2],t[5]="")}var r=t[3],i=t[1]||Rb;return[i,r]=oie(i,r),o6(r,i,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}}]);function cKe(e){return e[e.length-1]||{}}var eC,aie,l6,oie=(e,t)=>{var n=e.indexOf("safari-extension")!==-1,r=e.indexOf("safari-web-extension")!==-1;return n||r?[e.indexOf("@")!==-1?e.split("@")[0]:Rb,n?"safari-extension:".concat(t):"safari-web-extension:".concat(t)]:[e,t]},uKe=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;function WY(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=e.stacktrace||e.stack||"",r=function(a){return a&&dKe.test(a.message)?1:0}(e);try{var i=lKe,s=function(a,o){var l=function(c){var u=globalThis._posthogChunkIds;if(!u)return{};var d=Object.keys(u);return l6&&d.length===aie||(aie=d.length,l6=d.reduce((h,f)=>{eC||(eC={});var O=eC[f];if(O)h[O[0]]=O[1];else for(var g=c(f),m=g.length-1;m>=0;m--){var v=g[m],y=v?.filename,w=u[f];if(y&&w){h[y]=w,eC[f]=[y,w];break}}return h},{})),l6}(o);return a.forEach(c=>{c.filename&&(c.chunk_id=l[c.filename])}),a}(i(n,r),i);return s.slice(0,s.length-t)}catch{}return[]}var dKe=/Minified React error #\d+;/i;function c6(e,t){var n,r,i=WY(e),s=(n=t?.handled)===null||n===void 0||n,a=(r=t?.synthetic)!==null&&r!==void 0&&r;return{$exception_list:[{type:t!=null&&t.overrideExceptionType?t.overrideExceptionType:e.name,value:function(o){var l=o.message;return l.error&&typeof l.error.message=="string"?String(l.error.message):String(l)}(e),stacktrace:{frames:i,type:"raw"},mechanism:{handled:s,synthetic:a}}],$exception_level:"error"}}function u6(e,t){var n,r,i,s=(n=t?.handled)===null||n===void 0||n,a=(r=t?.synthetic)===null||r===void 0||r,o={type:t!=null&&t.overrideExceptionType?t.overrideExceptionType:(i=t?.defaultExceptionType)!==null&&i!==void 0?i:"Error",value:e||t?.defaultExceptionMessage,mechanism:{handled:s,synthetic:a}};if(t!=null&&t.syntheticException){var l=WY(t.syntheticException,1);l.length&&(o.stacktrace={frames:l,type:"raw"})}return{$exception_list:[o],$exception_level:"error"}}function hKe(e){return ca(e)&&!tz(e)&&wHe.indexOf(e)>=0}function fKe(e,t){var n,r,i=(n=t?.handled)===null||n===void 0||n,s=(r=t?.synthetic)===null||r===void 0||r,a=t!=null&&t.overrideExceptionType?t.overrideExceptionType:lPe(e)?e.constructor.name:"Error",o="Non-Error 'exception' captured with keys: ".concat(function(u){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:40,h=Object.keys(u);if(h.sort(),!h.length)return"[object has no keys]";for(var f=h.length;f>0;f--){var O=h.slice(0,f).join(", ");if(!(O.length>d))return f===h.length||O.length<=d?O:"".concat(O.slice(0,d),"...")}return""}(e)),l={type:a,value:o,mechanism:{handled:i,synthetic:s}};if(t!=null&&t.syntheticException){var c=WY(t?.syntheticException,1);c.length&&(l.stacktrace={frames:c,type:"raw"})}return{$exception_list:[l],$exception_level:hKe(e.level)?e.level:"error"}}function pKe(e,t){var{error:n,event:r}=e,i={$exception_list:[]},s=n||r;if(a6(s)||function(f){return QQ(f,"DOMException")}(s)){var a=s;if(function(f){return"stack"in f}(s))i=c6(s,t);else{var o=a.name||(a6(a)?"DOMError":"DOMException"),l=a.message?"".concat(o,": ").concat(a.message):o,c=a6(a)?"DOMError":"DOMException";i=u6(l,Je(Je({},t),{},{overrideExceptionType:c,defaultExceptionMessage:l}))}return"code"in a&&(i.$exception_DOMException_code="".concat(a.code)),i}if(function(f){return QQ(f,"ErrorEvent")}(s)&&s.error)return c6(s.error,t);if(function(f){switch(Object.prototype.toString.call(f)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":return!0;default:return cPe(f,Error)}}(s))return c6(s,t);if(function(f){return QQ(f,"Object")}(s)||lPe(s))return fKe(s,t);if(Yt(n)&&ca(r)){var u="Error",d=r,h=r.match(uKe);return h&&(u=h[1],d=h[2]),u6(d,Je(Je({},t),{},{overrideExceptionType:u,defaultExceptionMessage:d}))}return u6(s,t)}function JR(e){var t,n;return((t=JSON.stringify(e,(n=[],function(r,i){if(Ps(i)){for(;n.length>0&&n[n.length-1]!==this;)n.pop();return n.includes(i)?"[Circular]":(n.push(i),i)}return i})))===null||t===void 0?void 0:t.length)||0}function pz(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:66060288e-1;if(e.size>=t&&e.data.length>1){var n=Math.floor(e.data.length/2),r=e.data.slice(0,n),i=e.data.slice(n);return[pz({size:JR(r),data:r,sessionId:e.sessionId,windowId:e.windowId}),pz({size:JR(i),data:i,sessionId:e.sessionId,windowId:e.windowId})].flatMap(s=>s)}return[e]}var zf=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(zf||{}),sd=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(sd||{}),Oz="[SessionRecording]",gz="redacted",tC={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:e=>e,recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:1e6,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io",".clarity.ms","analytics.google.com"]},OKe=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],gKe=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],mKe=["/s/","/e/","/i/"];function lie(e,t,n,r){if(fi(e))return e;var i=t?.["content-length"]||function(s){return new Blob([s]).size}(e);return ca(i)&&(i=parseInt(i)),i>n?Oz+" ".concat(r," body too large to record (").concat(i," bytes)"):e}function cie(e,t){if(fi(e))return e;var n=e;return U1(n,!1)||(n=Oz+" "+t+" body "+gz),_i(gKe,r=>{var i,s;(i=n)!==null&&i!==void 0&&i.length&&((s=n)===null||s===void 0?void 0:s.indexOf(r))!==-1&&(n=Oz+" "+t+" body "+gz+" as might contain: "+r)}),n}var vKe=(e,t)=>{var n,r,i,s={payloadSizeLimitBytes:tC.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...tC.performanceEntryTypeToObserve],payloadHostDenyList:[...t.payloadHostDenyList||[],...tC.payloadHostDenyList]},a=e.session_recording.recordHeaders!==!1&&t.recordHeaders,o=e.session_recording.recordBody!==!1&&t.recordBody,l=e.capture_performance!==!1&&t.recordPerformance,c=(n=s,i=Math.min(1e6,(r=n.payloadSizeLimitBytes)!==null&&r!==void 0?r:1e6),h=>(h!=null&&h.requestBody&&(h.requestBody=lie(h.requestBody,h.requestHeaders,i,"Request")),h!=null&&h.responseBody&&(h.responseBody=lie(h.responseBody,h.responseHeaders,i,"Response")),h)),u=h=>{return c(((g,m)=>{var v,y=Hb(g.name),w=m.indexOf("http")===0?(v=Hb(m))===null||v===void 0?void 0:v.pathname:m;w==="/"&&(w="");var k=y?.pathname.replace(w||"","");if(!(y&&k&&mKe.some(x=>k.indexOf(x)===0)))return g})((O=(f=h).requestHeaders,fi(O)||_i(Object.keys(O??{}),g=>{OKe.includes(g.toLowerCase())&&(O[g]=gz)}),f),e.api_host));var f,O},d=Sd(e.session_recording.maskNetworkRequestFn);return d&&Sd(e.session_recording.maskCapturedNetworkRequestFn)&&yn.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),d&&(e.session_recording.maskCapturedNetworkRequestFn=h=>{var f=e.session_recording.maskNetworkRequestFn({url:h.name});return Je(Je({},h),{},{name:f?.url})}),s.maskRequestFn=Sd(e.session_recording.maskCapturedNetworkRequestFn)?h=>{var f,O,g,m=u(h);return m&&(f=(O=(g=e.session_recording).maskCapturedNetworkRequestFn)===null||O===void 0?void 0:O.call(g,m))!==null&&f!==void 0?f:void 0}:h=>function(f){if(!Yt(f))return f.requestBody=cie(f.requestBody,"Request"),f.responseBody=cie(f.responseBody,"Response"),f}(u(h)),Je(Je(Je({},tC),s),{},{recordHeaders:a,recordBody:o,recordPerformance:l,recordInitialRequests:l})};function gu(e,t,n,r,i){return t>n&&(yn.warn("min cannot be greater than max."),t=n),al(e)?e>n?(r&&yn.warn(r+" cannot be greater than max: "+n+". Using max value instead."),n):e<t?(r&&yn.warn(r+" cannot be less than min: "+t+". Using min value instead."),t):e:(r&&yn.warn(r+" must be a number. using max or fallback. max: "+n+", fallback: "+i),gu(i||n,t,n,r))}let yKe=class{constructor(t){var n,r,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Xt(this,"bucketSize",100),Xt(this,"refillRate",10),Xt(this,"mutationBuckets",{}),Xt(this,"loggedTracker",{}),Xt(this,"refillBuckets",()=>{Object.keys(this.mutationBuckets).forEach(s=>{this.mutationBuckets[s]=this.mutationBuckets[s]+this.refillRate,this.mutationBuckets[s]>=this.bucketSize&&delete this.mutationBuckets[s]})}),Xt(this,"getNodeOrRelevantParent",s=>{var a=this.rrweb.mirror.getNode(s);if(a?.nodeName!=="svg"&&a instanceof Element){var o=a.closest("svg");if(o)return[this.rrweb.mirror.getId(o),o]}return[s,a]}),Xt(this,"numberOfChanges",s=>{var a,o,l,c,u,d,h,f;return((a=(o=s.removes)===null||o===void 0?void 0:o.length)!==null&&a!==void 0?a:0)+((l=(c=s.attributes)===null||c===void 0?void 0:c.length)!==null&&l!==void 0?l:0)+((u=(d=s.texts)===null||d===void 0?void 0:d.length)!==null&&u!==void 0?u:0)+((h=(f=s.adds)===null||f===void 0?void 0:f.length)!==null&&h!==void 0?h:0)}),Xt(this,"throttleMutations",s=>{if(s.type!==3||s.data.source!==0)return s;var a=s.data,o=this.numberOfChanges(a);a.attributes&&(a.attributes=a.attributes.filter(c=>{var u,d,h,[f,O]=this.getNodeOrRelevantParent(c.id);return this.mutationBuckets[f]===0?!1:(this.mutationBuckets[f]=(u=this.mutationBuckets[f])!==null&&u!==void 0?u:this.bucketSize,this.mutationBuckets[f]=Math.max(this.mutationBuckets[f]-1,0),this.mutationBuckets[f]===0&&(this.loggedTracker[f]||(this.loggedTracker[f]=!0,(d=(h=this.options).onBlockedNode)===null||d===void 0||d.call(h,f,O))),c)}));var l=this.numberOfChanges(a);return l!==0||o===l?s:void 0}),this.rrweb=t,this.options=i,this.refillRate=gu((n=this.options.refillRate)!==null&&n!==void 0?n:this.refillRate,0,100,"mutation throttling refill rate"),this.bucketSize=gu((r=this.options.bucketSize)!==null&&r!==void 0?r:this.bucketSize,0,100,"mutation throttling bucket size"),setInterval(()=>{this.refillBuckets()},1e3)}};var ku=Uint8Array,Dl=Uint16Array,W1=Uint32Array,GY=new ku([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),VY=new ku([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),uie=new ku([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),uPe=function(e,t){for(var n=new Dl(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var i=new W1(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)i[s]=s-n[r]<<5|r;return[n,i]},dPe=uPe(GY,2),bKe=dPe[0],mz=dPe[1];bKe[28]=258,mz[258]=28;for(var die=uPe(VY,0)[1],hPe=new Dl(32768),Ui=0;Ui<32768;++Ui){var Rm=(43690&Ui)>>>1|(21845&Ui)<<1;Rm=(61680&(Rm=(52428&Rm)>>>2|(13107&Rm)<<2))>>>4|(3855&Rm)<<4,hPe[Ui]=((65280&Rm)>>>8|(255&Rm)<<8)>>>1}var Z$=function(e,t,n){for(var r=e.length,i=0,s=new Dl(t);i<r;++i)++s[e[i]-1];var a,o=new Dl(t);for(i=0;i<t;++i)o[i]=o[i-1]+s[i-1]<<1;for(a=new Dl(r),i=0;i<r;++i)a[i]=hPe[o[e[i]-1]++]>>>15-e[i];return a},lv=new ku(288);for(Ui=0;Ui<144;++Ui)lv[Ui]=8;for(Ui=144;Ui<256;++Ui)lv[Ui]=9;for(Ui=256;Ui<280;++Ui)lv[Ui]=7;for(Ui=280;Ui<288;++Ui)lv[Ui]=8;var e5=new ku(32);for(Ui=0;Ui<32;++Ui)e5[Ui]=5;var wKe=Z$(lv,9),xKe=Z$(e5,5),fPe=function(e){return(e/8>>0)+(7&e&&1)},pPe=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof Dl?Dl:e instanceof W1?W1:ku)(n-t);return r.set(e.subarray(t,n)),r},Tf=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8},aS=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},d6=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,s=n.slice();if(!i)return[new ku(0),0];if(i==1){var a=new ku(n[0].s+1);return a[n[0].s]=1,[a,1]}n.sort(function(x,S){return x.f-S.f}),n.push({s:-1,f:25001});var o=n[0],l=n[1],c=0,u=1,d=2;for(n[0]={s:-1,f:o.f+l.f,l:o,r:l};u!=i-1;)o=n[n[c].f<n[d].f?c++:d++],l=n[c!=u&&n[c].f<n[d].f?c++:d++],n[u++]={s:-1,f:o.f+l.f,l:o,r:l};var h=s[0].s;for(r=1;r<i;++r)s[r].s>h&&(h=s[r].s);var f=new Dl(h+1),O=vz(n[u-1],f,0);if(O>t){r=0;var g=0,m=O-t,v=1<<m;for(s.sort(function(x,S){return f[S.s]-f[x.s]||x.f-S.f});r<i;++r){var y=s[r].s;if(!(f[y]>t))break;g+=v-(1<<O-f[y]),f[y]=t}for(g>>>=m;g>0;){var w=s[r].s;f[w]<t?g-=1<<t-f[w]++-1:++r}for(;r>=0&&g;--r){var k=s[r].s;f[k]==t&&(--f[k],++g)}O=t}return[new ku(f),O]},vz=function(e,t,n){return e.s==-1?Math.max(vz(e.l,t,n+1),vz(e.r,t,n+1)):t[e.s]=n},hie=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Dl(++t),r=0,i=e[0],s=1,a=function(l){n[r++]=l},o=1;o<=t;++o)if(e[o]==i&&o!=t)++s;else{if(!i&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(i),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(i);s=1,i=e[o]}return[n.subarray(0,r),t]},oS=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},yz=function(e,t,n){var r=n.length,i=fPe(t+2);e[i]=255&r,e[i+1]=r>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var s=0;s<r;++s)e[i+s+4]=n[s];return 8*(i+4+r)},fie=function(e,t,n,r,i,s,a,o,l,c,u){Tf(t,u++,n),++i[256];for(var d=d6(i,15),h=d[0],f=d[1],O=d6(s,15),g=O[0],m=O[1],v=hie(h),y=v[0],w=v[1],k=hie(g),x=k[0],S=k[1],T=new Dl(19),_=0;_<y.length;++_)T[31&y[_]]++;for(_=0;_<x.length;++_)T[31&x[_]]++;for(var P=d6(T,7),E=P[0],C=P[1],Q=19;Q>4&&!E[uie[Q-1]];--Q);var D,F,I,U,q=c+5<<3,Z=oS(i,lv)+oS(s,e5)+a,W=oS(i,h)+oS(s,g)+a+14+3*Q+oS(T,E)+(2*T[16]+3*T[17]+7*T[18]);if(q<=Z&&q<=W)return yz(t,u,e.subarray(l,l+c));if(Tf(t,u,1+(W<Z)),u+=2,W<Z){D=Z$(h,f),F=h,I=Z$(g,m),U=g;var M=Z$(E,C);for(Tf(t,u,w-257),Tf(t,u+5,S-1),Tf(t,u+10,Q-4),u+=14,_=0;_<Q;++_)Tf(t,u+3*_,E[uie[_]]);u+=3*Q;for(var J=[y,x],L=0;L<2;++L){var N=J[L];for(_=0;_<N.length;++_){var z=31&N[_];Tf(t,u,M[z]),u+=E[z],z>15&&(Tf(t,u,N[_]>>>5&127),u+=N[_]>>>12)}}}else D=wKe,F=lv,I=xKe,U=e5;for(_=0;_<o;++_)if(r[_]>255){z=r[_]>>>18&31,aS(t,u,D[z+257]),u+=F[z+257],z>7&&(Tf(t,u,r[_]>>>23&31),u+=GY[z]);var V=31&r[_];aS(t,u,I[V]),u+=U[V],V>3&&(aS(t,u,r[_]>>>5&8191),u+=VY[V])}else aS(t,u,D[r[_]]),u+=F[r[_]];return aS(t,u,D[256]),u+F[256]},SKe=new W1([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),$Ke=function(){for(var e=new W1(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),kKe=function(){var e=4294967295;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=$Ke[255&n^t[r]]^n>>>8;e=n},d:function(){return 4294967295^e}}},TKe=function(e,t,n,r,i){return function(s,a,o,l,c,u){var d=s.length,h=new ku(l+d+5*(1+Math.floor(d/7e3))+c),f=h.subarray(l,h.length-c),O=0;if(!a||d<8)for(var g=0;g<=d;g+=65535){var m=g+65535;m<d?O=yz(f,O,s.subarray(g,m)):(f[g]=u,O=yz(f,O,s.subarray(g,d)))}else{for(var v=SKe[a-1],y=v>>>13,w=8191&v,k=(1<<o)-1,x=new Dl(32768),S=new Dl(k+1),T=Math.ceil(o/3),_=2*T,P=function(ye){return(s[ye]^s[ye+1]<<T^s[ye+2]<<_)&k},E=new W1(25e3),C=new Dl(288),Q=new Dl(32),D=0,F=0,I=(g=0,0),U=0,q=0;g<d;++g){var Z=P(g),W=32767&g,M=S[Z];if(x[W]=M,S[Z]=W,U<=g){var J=d-g;if((D>7e3||I>24576)&&J>423){O=fie(s,f,0,E,C,Q,F,I,q,g-q,O),I=D=F=0,q=g;for(var L=0;L<286;++L)C[L]=0;for(L=0;L<30;++L)Q[L]=0}var N=2,z=0,V=w,ee=W-M&32767;if(J>2&&Z==P(g-ee))for(var oe=Math.min(y,J)-1,ie=Math.min(32767,g),he=Math.min(258,J);ee<=ie&&--V&&W!=M;){if(s[g+N]==s[g+N-ee]){for(var te=0;te<he&&s[g+te]==s[g+te-ee];++te);if(te>N){if(N=te,z=ee,te>oe)break;var pe=Math.min(ee,te-2),B=0;for(L=0;L<pe;++L){var Ce=g-ee+L+32768&32767,Qe=Ce-x[Ce]+32768&32767;Qe>B&&(B=Qe,M=Ce)}}}ee+=(W=M)-(M=x[W])+32768&32767}if(z){E[I++]=268435456|mz[N]<<18|die[z];var Fe=31&mz[N],Oe=31&die[z];F+=GY[Fe]+VY[Oe],++C[257+Fe],++Q[Oe],U=g+N,++D}else E[I++]=s[g],++C[s[g]]}}O=fie(s,f,u,E,C,Q,F,I,q,g-q,O)}return pPe(h,0,l+fPe(O)+c)}(e,t.level==null?6:t.level,t.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!0)},bz=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},_Ke=function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&bz(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;r<=n.length;++r)e[r+10]=n.charCodeAt(r)}},PKe=function(e){return 10+(e.filename&&e.filename.length+1||0)};function OPe(e,t){t===void 0&&(t={});var n=kKe(),r=e.length;n.p(e);var i=TKe(e,t,PKe(t),8),s=i.length;return _Ke(i,t),bz(i,s-8,n.d()),bz(i,s-4,r),i}function gPe(e,t){var n=e.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(e);for(var r=new ku(e.length+(e.length>>>1)),i=0,s=function(c){r[i++]=c},a=0;a<n;++a){if(i+5>r.length){var o=new ku(i+8+(n-a<<1));o.set(r),r=o}var l=e.charCodeAt(a);l<128||t?s(l):l<2048?(s(192|l>>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++a))>>>18),s(128|l>>>12&63),s(128|l>>>6&63),s(128|63&l)):(s(224|l>>>12),s(128|l>>>6&63),s(128|63&l))}return pPe(r,0,i)}function CKe(e,t){return function(n){for(var r=0,i=0;i<n.length;i++)r=(r<<5)-r+n.charCodeAt(i),r|=0;return Math.abs(r)}(e)%100<gu(100*t,0,100)}var x$="[SessionRecording]",mo=Uo(x$);function nC(){var e,t;return er==null||(e=er.__PosthogExtensions__)===null||e===void 0||(t=e.rrweb)===null||t===void 0?void 0:t.record}var EKe=3e5,QKe=[sd.MouseMove,sd.MouseInteraction,sd.Scroll,sd.ViewportResize,sd.Input,sd.TouchMove,sd.MediaInteraction,sd.Drag],pie=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1});function Am(e){return function(t,n){for(var r="",i=0;i<t.length;){var s=t[i++];r+=String.fromCharCode(s)}return r}(OPe(gPe(JSON.stringify(e))))}function Oie(e){return e.type===zf.Custom&&e.data.tag==="sessionIdle"}function gie(e,t){return t.some(n=>n.matching==="regex"&&new RegExp(n.url).test(e))}let RKe=class{get sessionIdleThresholdMilliseconds(){return this.instance.config.session_recording.session_idle_threshold_ms||3e5}get started(){return this._captureStarted}get sessionManager(){if(!this.instance.sessionManager)throw new Error(x$+" must be started with a valid sessionManager.");return this.instance.sessionManager}get fullSnapshotIntervalMillis(){var t,n;return this.triggerStatus==="trigger_pending"?6e4:(t=(n=this.instance.config.session_recording)===null||n===void 0?void 0:n.full_snapshot_interval_millis)!==null&&t!==void 0?t:EKe}get isSampled(){var t=this.instance.get_property(b$);return rp(t)?t:null}get sessionDuration(){var t,n,r=(t=this.buffer)===null||t===void 0?void 0:t.data[((n=this.buffer)===null||n===void 0?void 0:n.data.length)-1],{sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0);return r?r.timestamp-i:null}get isRecordingEnabled(){var t=!!this.instance.get_property(rz),n=!this.instance.config.disable_session_recording;return Ve&&t&&n}get isConsoleLogCaptureEnabled(){var t=!!this.instance.get_property(Ure),n=this.instance.config.enable_recording_console_log;return n??t}get canvasRecording(){var t,n,r,i,s,a,o=this.instance.config.session_recording.captureCanvas,l=this.instance.get_property(Vre),c=(t=(n=o?.recordCanvas)!==null&&n!==void 0?n:l?.enabled)!==null&&t!==void 0&&t,u=(r=(i=o?.canvasFps)!==null&&i!==void 0?i:l?.fps)!==null&&r!==void 0?r:4,d=(s=(a=o?.canvasQuality)!==null&&a!==void 0?a:l?.quality)!==null&&s!==void 0?s:.4;if(typeof d=="string"){var h=parseFloat(d);d=isNaN(h)?.4:h}return{enabled:c,fps:gu(u,0,12,"canvas recording fps",4),quality:gu(d,0,1,"canvas recording quality",.4)}}get networkPayloadCapture(){var t,n,r=this.instance.get_property(Wre),i={recordHeaders:(t=this.instance.config.session_recording)===null||t===void 0?void 0:t.recordHeaders,recordBody:(n=this.instance.config.session_recording)===null||n===void 0?void 0:n.recordBody},s=i?.recordHeaders||r?.recordHeaders,a=i?.recordBody||r?.recordBody,o=Ps(this.instance.config.capture_performance)?this.instance.config.capture_performance.network_timing:this.instance.config.capture_performance,l=!!(rp(o)?o:r?.capturePerformance);return s||a||l?{recordHeaders:s,recordBody:a,recordPerformance:l}:void 0}get masking(){var t,n,r,i,s,a,o=this.instance.get_property(Gre),l={maskAllInputs:(t=this.instance.config.session_recording)===null||t===void 0?void 0:t.maskAllInputs,maskTextSelector:(n=this.instance.config.session_recording)===null||n===void 0?void 0:n.maskTextSelector,blockSelector:(r=this.instance.config.session_recording)===null||r===void 0?void 0:r.blockSelector},c=(i=l?.maskAllInputs)!==null&&i!==void 0?i:o?.maskAllInputs,u=(s=l?.maskTextSelector)!==null&&s!==void 0?s:o?.maskTextSelector,d=(a=l?.blockSelector)!==null&&a!==void 0?a:o?.blockSelector;return Yt(c)&&Yt(u)&&Yt(d)?void 0:{maskAllInputs:c==null||c,maskTextSelector:u,blockSelector:d}}get sampleRate(){var t=this.instance.get_property(Bre);return al(t)?t:null}get minimumDuration(){var t=this.instance.get_property(Yre);return al(t)?t:null}get status(){return this.receivedDecide?this.isRecordingEnabled?this.isSampled===!1?"disabled":this._urlBlocked?"paused":fi(this._linkedFlag)||this._linkedFlagSeen?this.triggerStatus==="trigger_pending"?"buffering":rp(this.isSampled)?this.isSampled?"sampled":"disabled":"active":"buffering":"disabled":"buffering"}get urlTriggerStatus(){var t;return this._urlTriggers.length===0?"trigger_disabled":((t=this.instance)===null||t===void 0?void 0:t.get_property(e6))===this.sessionId?"trigger_activated":"trigger_pending"}get eventTriggerStatus(){var t;return this._eventTriggers.length===0?"trigger_disabled":((t=this.instance)===null||t===void 0?void 0:t.get_property(t6))===this.sessionId?"trigger_activated":"trigger_pending"}get triggerStatus(){var t=this.eventTriggerStatus==="trigger_activated"||this.urlTriggerStatus==="trigger_activated",n=this.eventTriggerStatus==="trigger_pending"||this.urlTriggerStatus==="trigger_pending";return t?"trigger_activated":n?"trigger_pending":"trigger_disabled"}constructor(t){if(Xt(this,"queuedRRWebEvents",[]),Xt(this,"isIdle","unknown"),Xt(this,"_linkedFlagSeen",!1),Xt(this,"_lastActivityTimestamp",Date.now()),Xt(this,"_linkedFlag",null),Xt(this,"_removePageViewCaptureHook",void 0),Xt(this,"_onSessionIdListener",void 0),Xt(this,"_persistDecideOnSessionListener",void 0),Xt(this,"_samplingSessionListener",void 0),Xt(this,"_urlTriggers",[]),Xt(this,"_urlBlocklist",[]),Xt(this,"_urlBlocked",!1),Xt(this,"_eventTriggers",[]),Xt(this,"_removeEventTriggerCaptureHook",void 0),Xt(this,"_forceAllowLocalhostNetworkCapture",!1),Xt(this,"_onBeforeUnload",()=>{this._flushBuffer()}),Xt(this,"_onOffline",()=>{this._tryAddCustomEvent("browser offline",{})}),Xt(this,"_onOnline",()=>{this._tryAddCustomEvent("browser online",{})}),Xt(this,"_onVisibilityChange",()=>{if(ln!=null&&ln.visibilityState){var i="window "+ln.visibilityState;this._tryAddCustomEvent(i,{})}}),this.instance=t,this._captureStarted=!1,this._endpoint="/s/",this.stopRrweb=void 0,this.receivedDecide=!1,!this.instance.sessionManager)throw mo.error("started without valid sessionManager"),new Error(x$+" started without valid sessionManager. This is a bug.");if(this.instance.config.__preview_experimental_cookieless_mode)throw new Error(x$+" cannot be used with __preview_experimental_cookieless_mode.");var{sessionId:n,windowId:r}=this.sessionManager.checkAndGetSessionAndWindowId();this.sessionId=n,this.windowId=r,this.buffer=this.clearBuffer(),this.sessionIdleThresholdMilliseconds>=this.sessionManager.sessionTimeoutMs&&mo.warn("session_idle_threshold_ms (".concat(this.sessionIdleThresholdMilliseconds,") is greater than the session timeout (").concat(this.sessionManager.sessionTimeoutMs,"). Session will never be detected as idle"))}startIfEnabledOrStop(t){this.isRecordingEnabled?(this._startCapture(t),Ls(Ve,"beforeunload",this._onBeforeUnload),Ls(Ve,"offline",this._onOffline),Ls(Ve,"online",this._onOnline),Ls(Ve,"visibilitychange",this._onVisibilityChange),this._setupSampling(),this._addEventTriggerListener(),fi(this._removePageViewCaptureHook)&&(this._removePageViewCaptureHook=this.instance.on("eventCaptured",n=>{try{if(n.event==="$pageview"){var r=n!=null&&n.properties.$current_url?this._maskUrl(n?.properties.$current_url):"";if(!r)return;this._tryAddCustomEvent("$pageview",{href:r})}}catch(i){mo.error("Could not add $pageview to rrweb session",i)}})),this._onSessionIdListener||(this._onSessionIdListener=this.sessionManager.onSessionId((n,r,i)=>{var s,a,o,l;i&&(this._tryAddCustomEvent("$session_id_change",{sessionId:n,windowId:r,changeReason:i}),(s=this.instance)===null||s===void 0||(a=s.persistence)===null||a===void 0||a.unregister(t6),(o=this.instance)===null||o===void 0||(l=o.persistence)===null||l===void 0||l.unregister(e6))}))):this.stopRecording()}stopRecording(){var t,n,r,i;this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1,Ve?.removeEventListener("beforeunload",this._onBeforeUnload),Ve?.removeEventListener("offline",this._onOffline),Ve?.removeEventListener("online",this._onOnline),Ve?.removeEventListener("visibilitychange",this._onVisibilityChange),this.clearBuffer(),clearInterval(this._fullSnapshotTimer),(t=this._removePageViewCaptureHook)===null||t===void 0||t.call(this),this._removePageViewCaptureHook=void 0,(n=this._removeEventTriggerCaptureHook)===null||n===void 0||n.call(this),this._removeEventTriggerCaptureHook=void 0,(r=this._onSessionIdListener)===null||r===void 0||r.call(this),this._onSessionIdListener=void 0,(i=this._samplingSessionListener)===null||i===void 0||i.call(this),this._samplingSessionListener=void 0,mo.info("stopped"))}_resetSampling(){var t;(t=this.instance.persistence)===null||t===void 0||t.unregister(b$)}makeSamplingDecision(t){var n,r=this.sessionId!==t,i=this.sampleRate;if(al(i)){var s=this.isSampled,a=r||!rp(s),o=a?CKe(t,i):s;a&&(o?this._reportStarted("sampled"):mo.warn("Sample rate (".concat(i,") has determined that this sessionId (").concat(t,") will not be sent to the server.")),this._tryAddCustomEvent("samplingDecisionMade",{sampleRate:i,isSampled:o})),(n=this.instance.persistence)===null||n===void 0||n.register({[b$]:o})}else this._resetSampling()}onRemoteConfig(t){var n,r,i,s,a,o;if(this._tryAddCustomEvent("$remote_config_received",t),this._persistRemoteConfig(t),this._linkedFlag=((n=t.sessionRecording)===null||n===void 0?void 0:n.linkedFlag)||null,(r=t.sessionRecording)!==null&&r!==void 0&&r.endpoint&&(this._endpoint=(o=t.sessionRecording)===null||o===void 0?void 0:o.endpoint),this._setupSampling(),!fi(this._linkedFlag)&&!this._linkedFlagSeen){var l=ca(this._linkedFlag)?this._linkedFlag:this._linkedFlag.flag,c=ca(this._linkedFlag)?null:this._linkedFlag.variant;this.instance.onFeatureFlags((u,d)=>{var h=Ps(d)&&l in d,f=c?d[l]===c:h;f&&this._reportStarted("linked_flag_matched",{linkedFlag:l,linkedVariant:c}),this._linkedFlagSeen=f})}(i=t.sessionRecording)!==null&&i!==void 0&&i.urlTriggers&&(this._urlTriggers=t.sessionRecording.urlTriggers),(s=t.sessionRecording)!==null&&s!==void 0&&s.urlBlocklist&&(this._urlBlocklist=t.sessionRecording.urlBlocklist),(a=t.sessionRecording)!==null&&a!==void 0&&a.eventTriggers&&(this._eventTriggers=t.sessionRecording.eventTriggers),this.receivedDecide=!0,this.startIfEnabledOrStop()}_setupSampling(){al(this.sampleRate)&&fi(this._samplingSessionListener)&&(this._samplingSessionListener=this.sessionManager.onSessionId(t=>{this.makeSamplingDecision(t)}))}_persistRemoteConfig(t){if(this.instance.persistence){var n,r=this.instance.persistence,i=()=>{var s,a,o,l,c,u,d,h,f,O=(s=t.sessionRecording)===null||s===void 0?void 0:s.sampleRate,g=fi(O)?null:parseFloat(O);fi(g)&&this._resetSampling();var m=(a=t.sessionRecording)===null||a===void 0?void 0:a.minimumDurationMilliseconds;r.register({[rz]:!!t.sessionRecording,[Ure]:(o=t.sessionRecording)===null||o===void 0?void 0:o.consoleLogRecordingEnabled,[Wre]:Je({capturePerformance:t.capturePerformance},(l=t.sessionRecording)===null||l===void 0?void 0:l.networkPayloadCapture),[Gre]:(c=t.sessionRecording)===null||c===void 0?void 0:c.masking,[Vre]:{enabled:(u=t.sessionRecording)===null||u===void 0?void 0:u.recordCanvas,fps:(d=t.sessionRecording)===null||d===void 0?void 0:d.canvasFps,quality:(h=t.sessionRecording)===null||h===void 0?void 0:h.canvasQuality},[Bre]:g,[Yre]:Yt(m)?null:m,[Zre]:(f=t.sessionRecording)===null||f===void 0?void 0:f.scriptConfig})};i(),(n=this._persistDecideOnSessionListener)===null||n===void 0||n.call(this),this._persistDecideOnSessionListener=this.sessionManager.onSessionId(i)}}log(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"log";(n=this.instance.sessionRecording)===null||n===void 0||n.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:r,trace:[],payload:[JSON.stringify(t)]}},timestamp:Date.now()})}_startCapture(t){if(!Yt(Object.assign)&&!Yt(Array.from)&&!(this._captureStarted||this.instance.config.disable_session_recording||this.instance.consent.isOptedOut())){var n,r;this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId(),nC()?this._onScriptLoaded():(n=er.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this.instance,this.scriptName,i=>{if(i)return mo.error("could not load recorder",i);this._onScriptLoaded()}),mo.info("starting"),this.status==="active"&&this._reportStarted(t||"recording_initialized")}}get scriptName(){var t,n,r;return((t=this.instance)===null||t===void 0||(n=t.persistence)===null||n===void 0||(r=n.get_property(Zre))===null||r===void 0?void 0:r.script)||"recorder"}isInteractiveEvent(t){var n;return t.type===3&&QKe.indexOf((n=t.data)===null||n===void 0?void 0:n.source)!==-1}_updateWindowAndSessionIds(t){var n=this.isInteractiveEvent(t);n||this.isIdle||t.timestamp-this._lastActivityTimestamp>this.sessionIdleThresholdMilliseconds&&(this.isIdle=!0,clearInterval(this._fullSnapshotTimer),this._tryAddCustomEvent("sessionIdle",{eventTimestamp:t.timestamp,lastActivityTimestamp:this._lastActivityTimestamp,threshold:this.sessionIdleThresholdMilliseconds,bufferLength:this.buffer.data.length,bufferSize:this.buffer.size}),this._flushBuffer());var r=!1;if(n&&(this._lastActivityTimestamp=t.timestamp,this.isIdle)){var i=this.isIdle==="unknown";this.isIdle=!1,i||(this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:t.type}),r=!0)}if(!this.isIdle){var{windowId:s,sessionId:a}=this.sessionManager.checkAndGetSessionAndWindowId(!n,t.timestamp),o=this.sessionId!==a,l=this.windowId!==s;this.windowId=s,this.sessionId=a,o||l?(this.stopRecording(),this.startIfEnabledOrStop("session_id_changed")):r&&this._scheduleFullSnapshot()}}_tryRRWebMethod(t){try{return t.rrwebMethod(),!0}catch(n){return this.queuedRRWebEvents.length<10?this.queuedRRWebEvents.push({enqueuedAt:t.enqueuedAt||Date.now(),attempt:t.attempt++,rrwebMethod:t.rrwebMethod}):mo.warn("could not emit queued rrweb event.",n,t),!1}}_tryAddCustomEvent(t,n){return this._tryRRWebMethod(pie(()=>nC().addCustomEvent(t,n)))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(pie(()=>nC().takeFullSnapshot()))}_onScriptLoaded(){var t,n,r,i,s={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1},a=this.instance.config.session_recording;for(var[o,l]of Object.entries(a||{}))o in s&&(o==="maskInputOptions"?s.maskInputOptions=Je({password:!0},l):s[o]=l);this.canvasRecording&&this.canvasRecording.enabled&&(s.recordCanvas=!0,s.sampling={canvas:this.canvasRecording.fps},s.dataURLOptions={type:"image/webp",quality:this.canvasRecording.quality}),this.masking&&(s.maskAllInputs=(n=this.masking.maskAllInputs)===null||n===void 0||n,s.maskTextSelector=(r=this.masking.maskTextSelector)!==null&&r!==void 0?r:void 0,s.blockSelector=(i=this.masking.blockSelector)!==null&&i!==void 0?i:void 0);var c=nC();if(c){this.mutationRateLimiter=(t=this.mutationRateLimiter)!==null&&t!==void 0?t:new yKe(c,{refillRate:this.instance.config.session_recording.__mutationRateLimiterRefillRate,bucketSize:this.instance.config.session_recording.__mutationRateLimiterBucketSize,onBlockedNode:(d,h)=>{var f="Too many mutations on node '".concat(d,"'. Rate limiting. This could be due to SVG animations or something similar");mo.info(f,{node:h}),this.log(x$+" "+f,"warn")}});var u=this._gatherRRWebPlugins();this.stopRrweb=c(Je({emit:d=>{this.onRRwebEmit(d)},plugins:u},s)),this._lastActivityTimestamp=Date.now(),this.isIdle=rp(this.isIdle)?this.isIdle:"unknown",this._tryAddCustomEvent("$session_options",{sessionRecordingOptions:s,activePlugins:u.map(d=>d?.name)}),this._tryAddCustomEvent("$posthog_config",{config:this.instance.config})}else mo.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),this.isIdle!==!0){var t=this.fullSnapshotIntervalMillis;t&&(this._fullSnapshotTimer=setInterval(()=>{this._tryTakeFullSnapshot()},t))}}_gatherRRWebPlugins(){var t,n,r,i,s=[],a=(t=er.__PosthogExtensions__)===null||t===void 0||(n=t.rrwebPlugins)===null||n===void 0?void 0:n.getRecordConsolePlugin;a&&this.isConsoleLogCaptureEnabled&&s.push(a());var o=(r=er.__PosthogExtensions__)===null||r===void 0||(i=r.rrwebPlugins)===null||i===void 0?void 0:i.getRecordNetworkPlugin;return this.networkPayloadCapture&&Sd(o)&&(!FHe.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?s.push(o(vKe(this.instance.config,this.networkPayloadCapture))):mo.info("NetworkCapture not started because we are on localhost.")),s}onRRwebEmit(t){var n;if(this._processQueuedEvents(),t&&Ps(t)){if(t.type===zf.Meta){var r=this._maskUrl(t.data.href);if(this._lastHref=r,!r)return;t.data.href=r}else this._pageViewFallBack();if(this._checkUrlTriggerConditions(),!this._urlBlocked||function(d){return d.type===zf.Custom&&d.data.tag==="recording paused"}(t)){t.type===zf.FullSnapshot&&this._scheduleFullSnapshot(),t.type===zf.FullSnapshot&&this.triggerStatus==="trigger_pending"&&this.clearBuffer();var i=this.mutationRateLimiter?this.mutationRateLimiter.throttleMutations(t):t;if(i){var s=function(d){var h=d;if(h&&Ps(h)&&h.type===6&&Ps(h.data)&&h.data.plugin==="rrweb/console@1"){h.data.payload.payload.length>10&&(h.data.payload.payload=h.data.payload.payload.slice(0,10),h.data.payload.payload.push("...[truncated]"));for(var f=[],O=0;O<h.data.payload.payload.length;O++)h.data.payload.payload[O]&&h.data.payload.payload[O].length>2e3?f.push(h.data.payload.payload[O].slice(0,2e3)+"...[truncated]"):f.push(h.data.payload.payload[O]);return h.data.payload.payload=f,d}return d}(i);if(this._updateWindowAndSessionIds(s),this.isIdle!==!0||Oie(s)){if(Oie(s)){var a=s.data.payload;if(a){var o=a.lastActivityTimestamp,l=a.threshold;s.timestamp=o+l}}var c=(n=this.instance.config.session_recording.compress_events)===null||n===void 0||n?function(d){if(JR(d)<1024)return d;try{if(d.type===zf.FullSnapshot)return Je(Je({},d),{},{data:Am(d.data),cv:"2024-10"});if(d.type===zf.IncrementalSnapshot&&d.data.source===sd.Mutation)return Je(Je({},d),{},{cv:"2024-10",data:Je(Je({},d.data),{},{texts:Am(d.data.texts),attributes:Am(d.data.attributes),removes:Am(d.data.removes),adds:Am(d.data.adds)})});if(d.type===zf.IncrementalSnapshot&&d.data.source===sd.StyleSheetRule)return Je(Je({},d),{},{cv:"2024-10",data:Je(Je({},d.data),{},{adds:d.data.adds?Am(d.data.adds):void 0,removes:d.data.removes?Am(d.data.removes):void 0})})}catch(h){mo.error("could not compress event - will use uncompressed event",h)}return d}(s):s,u={$snapshot_bytes:JR(c),$snapshot_data:c,$session_id:this.sessionId,$window_id:this.windowId};this.status!=="disabled"?this._captureSnapshotBuffered(u):this.clearBuffer()}}}}}_pageViewFallBack(){if(!this.instance.config.capture_pageview&&Ve){var t=this._maskUrl(Ve.location.href);this._lastHref!==t&&(this._tryAddCustomEvent("$url_changed",{href:t}),this._lastHref=t)}}_processQueuedEvents(){if(this.queuedRRWebEvents.length){var t=[...this.queuedRRWebEvents];this.queuedRRWebEvents=[],t.forEach(n=>{Date.now()-n.enqueuedAt<=2e3&&this._tryRRWebMethod(n)})}}_maskUrl(t){var n=this.instance.config.session_recording;if(n.maskNetworkRequestFn){var r,i={url:t};return(r=i=n.maskNetworkRequestFn(i))===null||r===void 0?void 0:r.url}return t}clearBuffer(){return this.buffer={size:0,data:[],sessionId:this.sessionId,windowId:this.windowId},this.buffer}_flushBuffer(){this.flushBufferTimer&&(clearTimeout(this.flushBufferTimer),this.flushBufferTimer=void 0);var t=this.minimumDuration,n=this.sessionDuration,r=al(n)&&n>=0,i=al(t)&&r&&n<t;return this.status==="buffering"||this.status==="paused"||this.status==="disabled"||i?(this.flushBufferTimer=setTimeout(()=>{this._flushBuffer()},2e3),this.buffer):(this.buffer.data.length>0&&pz(this.buffer).forEach(s=>{this._captureSnapshot({$snapshot_bytes:s.size,$snapshot_data:s.data,$session_id:s.sessionId,$window_id:s.windowId,$lib:"web",$lib_version:Zf.LIB_VERSION})}),this.clearBuffer())}_captureSnapshotBuffered(t){var n,r=2+(((n=this.buffer)===null||n===void 0?void 0:n.data.length)||0);!this.isIdle&&(this.buffer.size+t.$snapshot_bytes+r>943718.4||this.buffer.sessionId!==this.sessionId)&&(this.buffer=this._flushBuffer()),this.buffer.size+=t.$snapshot_bytes,this.buffer.data.push(t.$snapshot_data),this.flushBufferTimer||this.isIdle||(this.flushBufferTimer=setTimeout(()=>{this._flushBuffer()},2e3))}_captureSnapshot(t){this.instance.capture("$snapshot",t,{_url:this.instance.requestRouter.endpointFor("api",this._endpoint),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}_checkUrlTriggerConditions(){if(Ve!==void 0&&Ve.location.href){var t=Ve.location.href,n=this._urlBlocked,r=gie(t,this._urlBlocklist);r&&!n?this._pauseRecording():!r&&n&&this._resumeRecording(),gie(t,this._urlTriggers)&&this._activateTrigger("url")}}_activateTrigger(t){var n,r;this.triggerStatus==="trigger_pending"&&((n=this.instance)===null||n===void 0||(r=n.persistence)===null||r===void 0||r.register({[t==="url"?e6:t6]:this.sessionId}),this._flushBuffer(),this._reportStarted(t+"_trigger_matched"))}_pauseRecording(){this._urlBlocked||(this._urlBlocked=!0,clearInterval(this._fullSnapshotTimer),mo.info("recording paused due to URL blocker"),this._tryAddCustomEvent("recording paused",{reason:"url blocker"}))}_resumeRecording(){this._urlBlocked&&(this._urlBlocked=!1,this._tryTakeFullSnapshot(),this._scheduleFullSnapshot(),this._tryAddCustomEvent("recording resumed",{reason:"left blocked url"}),mo.info("recording resumed"))}_addEventTriggerListener(){this._eventTriggers.length!==0&&fi(this._removeEventTriggerCaptureHook)&&(this._removeEventTriggerCaptureHook=this.instance.on("eventCaptured",t=>{try{this._eventTriggers.includes(t.event)&&this._activateTrigger("event")}catch(n){mo.error("Could not activate event trigger",n)}}))}overrideLinkedFlag(){this._linkedFlagSeen=!0,this._tryTakeFullSnapshot(),this._reportStarted("linked_flag_overridden")}overrideSampling(){var t;(t=this.instance.persistence)===null||t===void 0||t.register({[b$]:!0}),this._tryTakeFullSnapshot(),this._reportStarted("sampling_overridden")}overrideTrigger(t){this._activateTrigger(t)}_reportStarted(t,n){this.instance.register_for_session({$session_recording_start_reason:t}),mo.info(t.replace("_"," "),n),wr(["recording_initialized","session_id_changed"],t)||this._tryAddCustomEvent(t,n)}get sdkDebugProperties(){var{sessionStartTimestamp:t}=this.sessionManager.checkAndGetSessionAndWindowId(!0);return{$recording_status:this.status,$sdk_debug_replay_internal_buffer_length:this.buffer.data.length,$sdk_debug_replay_internal_buffer_size:this.buffer.size,$sdk_debug_current_session_duration:this.sessionDuration,$sdk_debug_session_start:t}}};var h6=Uo("[SegmentIntegration]");function AKe(e,t){var n=e.config.segment;if(!n)return t();(function(r,i){var s=r.config.segment;if(!s)return i();var a=l=>{var c=()=>l.anonymousId()||eg();r.config.get_device_id=c,l.id()&&(r.register({distinct_id:l.id(),$device_id:c()}),r.persistence.set_property(qf,"identified")),i()},o=s.user();"then"in o&&Sd(o.then)?o.then(l=>a(l)):a(o)})(e,()=>{n.register((r=>{Promise&&Promise.resolve||h6.warn("This browser does not have Promise support, and can not use the segment integration");var i=(s,a)=>{var o;if(!a)return s;s.event.userId||s.event.anonymousId===r.get_distinct_id()||(h6.info("No userId set, resetting PostHog"),r.reset()),s.event.userId&&s.event.userId!==r.get_distinct_id()&&(h6.info("UserId set, identifying with PostHog"),r.identify(s.event.userId));var l=r._calculate_event_properties(a,(o=s.event.properties)!==null&&o!==void 0?o:{},new Date);return s.event.properties=Object.assign({},l,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:s=>i(s,s.event.event),page:s=>i(s,"$pageview"),identify:s=>i(s,"$identify"),screen:s=>i(s,"$screen")}})(e)).then(()=>{t()})})}var mPe="posthog-js";function vPe(e){var{organization:t,projectId:n,prefix:r,severityAllowList:i=["error"]}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return s=>{var a,o,l,c,u;if(!(i==="*"||i.includes(s.level))||!e.__loaded)return s;s.tags||(s.tags={});var d=e.requestRouter.endpointFor("ui","/project/".concat(e.config.token,"/person/").concat(e.get_distinct_id()));s.tags["PostHog Person URL"]=d,e.sessionRecordingStarted()&&(s.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var h=((a=s.exception)===null||a===void 0?void 0:a.values)||[],f=h.map(g=>Je(Je({},g),{},{stacktrace:g.stacktrace?Je(Je({},g.stacktrace),{},{type:"raw",frames:(g.stacktrace.frames||[]).map(m=>Je(Je({},m),{},{platform:"web:javascript"}))}):void 0})),O={$exception_message:((o=h[0])===null||o===void 0?void 0:o.value)||s.message,$exception_type:(l=h[0])===null||l===void 0?void 0:l.type,$exception_personURL:d,$exception_level:s.level,$exception_list:f,$sentry_event_id:s.event_id,$sentry_exception:s.exception,$sentry_exception_message:((c=h[0])===null||c===void 0?void 0:c.value)||s.message,$sentry_exception_type:(u=h[0])===null||u===void 0?void 0:u.type,$sentry_tags:s.tags};return t&&n&&(O.$sentry_url=(r||"https://sentry.io/organizations/")+t+"/issues/?project="+n+"&query="+s.event_id),e.exceptions.sendExceptionEvent(O),s}}let DKe=class{constructor(t,n,r,i,s){this.name=mPe,this.setupOnce=function(a){a(vPe(t,{organization:n,projectId:r,prefix:i,severityAllowList:s}))}}};var Uf,NKe=Ve!=null&&Ve.location?KR(Ve.location.hash,"__posthog")||KR(location.hash,"state"):null,mie="_postHogToolbarParams",vie=Uo("[Toolbar]");(function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED"})(Uf||(Uf={}));class XKe{constructor(t){this.instance=t}setToolbarState(t){er.ph_toolbar_state=t}getToolbarState(){var t;return(t=er.ph_toolbar_state)!==null&&t!==void 0?t:Uf.UNINITIALIZED}maybeLoadToolbar(){var t,n,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;if(!Ve||!ln)return!1;r=(t=r)!==null&&t!==void 0?t:Ve.location,s=(n=s)!==null&&n!==void 0?n:Ve.history;try{if(!i){try{Ve.localStorage.setItem("test","test"),Ve.localStorage.removeItem("test")}catch{return!1}i=Ve?.localStorage}var a,o=NKe||KR(r.hash,"__posthog")||KR(r.hash,"state"),l=o?Mre(()=>JSON.parse(atob(decodeURIComponent(o))))||Mre(()=>JSON.parse(decodeURIComponent(o))):null;return l&&l.action==="ph_authorize"?((a=l).source="url",a&&Object.keys(a).length>0&&(l.desiredHash?r.hash=l.desiredHash:s?s.replaceState(s.state,"",r.pathname+r.search):r.hash="")):((a=JSON.parse(i.getItem(mie)||"{}")).source="localstorage",delete a.userIntent),!(!a.token||this.instance.config.token!==a.token)&&(this.loadToolbar(a),!0)}catch{return!1}}_callLoadToolbar(t){var n=er.ph_load_toolbar||er.ph_load_editor;!fi(n)&&Sd(n)?n(t,this.instance):vie.warn("No toolbar load function found")}loadToolbar(t){var n=!(ln==null||!ln.getElementById(B_e));if(!Ve||n)return!1;var r=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=Je(Je({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(Ve.localStorage.setItem(mie,JSON.stringify(Je(Je({},i),{},{source:void 0}))),this.getToolbarState()===Uf.LOADED)this._callLoadToolbar(i);else if(this.getToolbarState()===Uf.UNINITIALIZED){var s,a;this.setToolbarState(Uf.LOADING),(s=er.__PosthogExtensions__)===null||s===void 0||(a=s.loadExternalDependency)===null||a===void 0||a.call(s,this.instance,"toolbar",o=>{if(o)return vie.error("[Toolbar] Failed to load",o),void this.setToolbarState(Uf.UNINITIALIZED);this.setToolbarState(Uf.LOADED),this._callLoadToolbar(i)}),Ls(Ve,"turbolinks:load",()=>{this.setToolbarState(Uf.UNINITIALIZED),this.loadToolbar(i)})}return!0}_loadEditor(t){return this.loadToolbar(t)}maybeLoadEditor(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;return this.maybeLoadToolbar(t,n,r)}}var IKe=Uo("[TracingHeaders]");class FKe{constructor(t){Xt(this,"_restoreXHRPatch",void 0),Xt(this,"_restoreFetchPatch",void 0),Xt(this,"_startCapturing",()=>{var n,r,i,s;Yt(this._restoreXHRPatch)&&((n=er.__PosthogExtensions__)===null||n===void 0||(r=n.tracingHeadersPatchFns)===null||r===void 0||r._patchXHR(this.instance.sessionManager)),Yt(this._restoreFetchPatch)&&((i=er.__PosthogExtensions__)===null||i===void 0||(s=i.tracingHeadersPatchFns)===null||s===void 0||s._patchFetch(this.instance.sessionManager))}),this.instance=t}_loadScript(t){var n,r,i;(n=er.__PosthogExtensions__)!==null&&n!==void 0&&n.tracingHeadersPatchFns&&t(),(r=er.__PosthogExtensions__)===null||r===void 0||(i=r.loadExternalDependency)===null||i===void 0||i.call(r,this.instance,"tracing-headers",s=>{if(s)return IKe.error("failed to load script",s);t()})}startIfEnabledOrStop(){var t,n;this.instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):((t=this._restoreXHRPatch)===null||t===void 0||t.call(this),(n=this._restoreFetchPatch)===null||n===void 0||n.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}}var bO=Uo("[Web Vitals]"),yie=9e5;class MKe{constructor(t){var n;Xt(this,"_enabledServerSide",!1),Xt(this,"_initialized",!1),Xt(this,"buffer",{url:void 0,metrics:[],firstMetricTimestamp:void 0}),Xt(this,"_flushToCapture",()=>{clearTimeout(this._delayedFlushTimer),this.buffer.metrics.length!==0&&(this.instance.capture("$web_vitals",this.buffer.metrics.reduce((r,i)=>Je(Je({},r),{},{["$web_vitals_".concat(i.name,"_event")]:Je({},i),["$web_vitals_".concat(i.name,"_value")]:i.value}),{})),this.buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})}),Xt(this,"_addToBuffer",r=>{var i,s=(i=this.instance.sessionManager)===null||i===void 0?void 0:i.checkAndGetSessionAndWindowId(!0);if(Yt(s))bO.error("Could not read session ID. Dropping metrics!");else{this.buffer=this.buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var a=this._currentURL();Yt(a)||(fi(r?.name)||fi(r?.value)?bO.error("Invalid metric received",r):this._maxAllowedValue&&r.value>=this._maxAllowedValue?bO.error("Ignoring metric with value >= "+this._maxAllowedValue,r):(this.buffer.url!==a&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),Yt(this.buffer.url)&&(this.buffer.url=a),this.buffer.firstMetricTimestamp=Yt(this.buffer.firstMetricTimestamp)?Date.now():this.buffer.firstMetricTimestamp,r.attribution&&r.attribution.interactionTargetElement&&(r.attribution.interactionTargetElement=void 0),this.buffer.metrics.push(Je(Je({},r),{},{$current_url:a,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this.buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()))}}),Xt(this,"_startCapturing",()=>{var r,i,s,a,o=er.__PosthogExtensions__;Yt(o)||Yt(o.postHogWebVitalsCallbacks)||({onLCP:r,onCLS:i,onFCP:s,onINP:a}=o.postHogWebVitalsCallbacks),r&&i&&s&&a?(this.allowedMetrics.indexOf("LCP")>-1&&r(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&i(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&s(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&a(this._addToBuffer.bind(this)),this._initialized=!0):bO.error("web vitals callbacks not loaded - not starting")}),this.instance=t,this._enabledServerSide=!((n=this.instance.persistence)===null||n===void 0||!n.props[qre]),this.startIfEnabled()}get allowedMetrics(){var t,n,r=Ps(this.instance.config.capture_performance)?(t=this.instance.config.capture_performance)===null||t===void 0?void 0:t.web_vitals_allowed_metrics:void 0;return Yt(r)?((n=this.instance.persistence)===null||n===void 0?void 0:n.props[zre])||["CLS","FCP","INP","LCP"]:r}get flushToCaptureTimeoutMs(){return(Ps(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var t=Ps(this.instance.config.capture_performance)&&al(this.instance.config.capture_performance.__web_vitals_max_value)?this.instance.config.capture_performance.__web_vitals_max_value:yie;return 0<t&&t<=6e4?yie:t}get isEnabled(){var t=Pl?.protocol;if(t!=="http:"&&t!=="https:")return bO.info("Web Vitals are disabled on non-http/https protocols"),!1;var n=Ps(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals:rp(this.instance.config.capture_performance)?this.instance.config.capture_performance:void 0;return rp(n)?n:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(bO.info("enabled, starting..."),this.loadScript(this._startCapturing))}onRemoteConfig(t){var n=Ps(t.capturePerformance)&&!!t.capturePerformance.web_vitals,r=Ps(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this.instance.persistence&&(this.instance.persistence.register({[qre]:n}),this.instance.persistence.register({[zre]:r})),this._enabledServerSide=n,this.startIfEnabled()}loadScript(t){var n,r,i;(n=er.__PosthogExtensions__)!==null&&n!==void 0&&n.postHogWebVitalsCallbacks&&t(),(r=er.__PosthogExtensions__)===null||r===void 0||(i=r.loadExternalDependency)===null||i===void 0||i.call(r,this.instance,"web-vitals",s=>{s?bO.error("failed to load script",s):t()})}_currentURL(){var t=Ve?Ve.location.href:void 0;return t||bO.error("Could not determine current URL"),t}}var jKe=Uo("[Heatmaps]");function bie(e){return Ps(e)&&"clientX"in e&&"clientY"in e&&al(e.clientX)&&al(e.clientY)}class LKe{constructor(t){var n;Xt(this,"rageclicks",new sPe),Xt(this,"_enabledServerSide",!1),Xt(this,"_initialized",!1),Xt(this,"_flushInterval",null),this.instance=t,this._enabledServerSide=!((n=this.instance.persistence)===null||n===void 0||!n.props[nz])}get flushIntervalMilliseconds(){var t=5e3;return Ps(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(t=this.instance.config.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return Yt(this.instance.config.capture_heatmaps)?Yt(this.instance.config.enable_heatmaps)?this._enabledServerSide:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;jKe.info("starting..."),this._setupListeners(),this._flushInterval=setInterval(this.flush.bind(this),this.flushIntervalMilliseconds)}else{var t,n;clearInterval((t=this._flushInterval)!==null&&t!==void 0?t:void 0),(n=this.deadClicksCapture)===null||n===void 0||n.stop(),this.getAndClearBuffer()}}onRemoteConfig(t){var n=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[nz]:n}),this._enabledServerSide=n,this.startIfEnabled()}getAndClearBuffer(){var t=this.buffer;return this.buffer=void 0,t}_onDeadClick(t){this._onClick(t.originalEvent,"deadclick")}_setupListeners(){Ve&&ln&&(Ls(Ve,"beforeunload",this.flush.bind(this)),Ls(ln,"click",t=>this._onClick(t||Ve?.event),{capture:!0}),Ls(ln,"mousemove",t=>this._onMouseMove(t||Ve?.event),{capture:!0}),this.deadClicksCapture=new oPe(this.instance,eKe,this._onDeadClick.bind(this)),this.deadClicksCapture.startIfEnabled(),this._initialized=!0)}_getProperties(t,n){var r=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),a=function(o,l,c){for(var u=o;u&&q3(u)&&!bg(u,"body");){if(u===c)return!1;if(wr(l,Ve?.getComputedStyle(u).position))return!0;u=J_e(u)}return!1}(K_e(t),["fixed","sticky"],s);return{x:t.clientX+(a?0:i),y:t.clientY+(a?0:r),target_fixed:a,type:n}}_onClick(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"click";if(!Kre(t.target)&&bie(t)){var i=this._getProperties(t,r);(n=this.rageclicks)!==null&&n!==void 0&&n.isRageClick(t.clientX,t.clientY,new Date().getTime())&&this._capture(Je(Je({},i),{},{type:"rageclick"})),this._capture(i)}}_onMouseMove(t){!Kre(t.target)&&bie(t)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(()=>{this._capture(this._getProperties(t,"mousemove"))},500))}_capture(t){if(Ve){var n=Ve.location.href;this.buffer=this.buffer||{},this.buffer[n]||(this.buffer[n]=[]),this.buffer[n].push(t)}}flush(){this.buffer&&!Eb(this.buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}let qKe=class{constructor(t){this._instance=t}doPageView(t,n){var r,i=this._previousPageViewProperties(t,n);return this._currentPageview={pathname:(r=Ve?.location.pathname)!==null&&r!==void 0?r:"",pageViewId:n,timestamp:t},this._instance.scrollManager.resetContext(),i}doPageLeave(t){var n;return this._previousPageViewProperties(t,(n=this._currentPageview)===null||n===void 0?void 0:n.pageViewId)}doEvent(){var t;return{$pageview_id:(t=this._currentPageview)===null||t===void 0?void 0:t.pageViewId}}_previousPageViewProperties(t,n){var r=this._currentPageview;if(!r)return{$pageview_id:n};var i={$pageview_id:n,$prev_pageview_id:r.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:a,lastScrollY:o,maxScrollY:l,maxContentHeight:c,lastContentY:u,maxContentY:d}=s;if(!(Yt(a)||Yt(o)||Yt(l)||Yt(c)||Yt(u)||Yt(d))){a=Math.ceil(a),o=Math.ceil(o),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u),d=Math.ceil(d);var h=a<=1?1:gu(o/a,0,1),f=a<=1?1:gu(l/a,0,1),O=c<=1?1:gu(u/c,0,1),g=c<=1?1:gu(d/c,0,1);i=Fs(i,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:h,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:O,$prev_pageview_max_content:d,$prev_pageview_max_content_percentage:g})}}return r.pathname&&(i.$prev_pageview_pathname=r.pathname),r.timestamp&&(i.$prev_pageview_duration=(t.getTime()-r.timestamp.getTime())/1e3),i}},zKe=class{constructor(t){this.instance=t}sendExceptionEvent(t){this.instance.capture("$exception",t,{_noTruncate:!0,_batchKey:"exceptionEvent"})}};var Tu="Mobile",t5="iOS",Qh="Android",aT="Tablet",yPe=Qh+" "+aT,bPe="iPad",wPe="Apple",xPe=wPe+" Watch",oT="Safari",G1="BlackBerry",SPe="Samsung",$Pe=SPe+"Browser",kPe=SPe+" Internet",cv="Chrome",UKe=cv+" OS",TPe=cv+" "+t5,BY="Internet Explorer",_Pe=BY+" "+Tu,YY="Opera",WKe=YY+" Mini",ZY="Edge",PPe="Microsoft "+ZY,Kb="Firefox",CPe=Kb+" "+t5,lT="Nintendo",cT="PlayStation",Jb="Xbox",EPe=Qh+" "+Tu,QPe=Tu+" "+oT,S$="Windows",wz=S$+" Phone",wie="Nokia",xz="Ouya",RPe="Generic",GKe=RPe+" "+Tu.toLowerCase(),APe=RPe+" "+aT.toLowerCase(),Sz="Konqueror",Ko="(\\d+(\\.\\d+)?)",f6=new RegExp("Version/"+Ko),VKe=new RegExp(Jb,"i"),BKe=new RegExp(cT+" \\w+","i"),YKe=new RegExp(lT+" \\w+","i"),HY=new RegExp(G1+"|PlayBook|BB10","i"),ZKe={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},$z,HKe=(e,t)=>t&&wr(t,wPe)||function(n){return wr(n,oT)&&!wr(n,cv)&&!wr(n,Qh)}(e),xie=function(e,t){return t=t||"",wr(e," OPR/")&&wr(e,"Mini")?WKe:wr(e," OPR/")?YY:HY.test(e)?G1:wr(e,"IE"+Tu)||wr(e,"WPDesktop")?_Pe:wr(e,$Pe)?kPe:wr(e,ZY)||wr(e,"Edg/")?PPe:wr(e,"FBIOS")?"Facebook "+Tu:wr(e,"UCWEB")||wr(e,"UCBrowser")?"UC Browser":wr(e,"CriOS")?TPe:wr(e,"CrMo")||wr(e,cv)?cv:wr(e,Qh)&&wr(e,oT)?EPe:wr(e,"FxiOS")?CPe:wr(e.toLowerCase(),Sz.toLowerCase())?Sz:HKe(e,t)?wr(e,Tu)?QPe:oT:wr(e,Kb)?Kb:wr(e,"MSIE")||wr(e,"Trident/")?BY:wr(e,"Gecko")?Kb:""},KKe={[_Pe]:[new RegExp("rv:"+Ko)],[PPe]:[new RegExp(ZY+"?\\/"+Ko)],[cv]:[new RegExp("("+cv+"|CrMo)\\/"+Ko)],[TPe]:[new RegExp("CriOS\\/"+Ko)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ko)],[oT]:[f6],[QPe]:[f6],[YY]:[new RegExp("(Opera|OPR)\\/"+Ko)],[Kb]:[new RegExp(Kb+"\\/"+Ko)],[CPe]:[new RegExp("FxiOS\\/"+Ko)],[Sz]:[new RegExp("Konqueror[:/]?"+Ko,"i")],[G1]:[new RegExp(G1+" "+Ko),f6],[EPe]:[new RegExp("android\\s"+Ko,"i")],[kPe]:[new RegExp($Pe+"\\/"+Ko)],[BY]:[new RegExp("(rv:|MSIE )"+Ko)],Mozilla:[new RegExp("rv:"+Ko)]},Sie=[[new RegExp(Jb+"; "+Jb+" (.*?)[);]","i"),e=>[Jb,e&&e[1]||""]],[new RegExp(lT,"i"),[lT,""]],[new RegExp(cT,"i"),[cT,""]],[HY,[G1,""]],[new RegExp(S$,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[wz,""];if(new RegExp(Tu).test(t)&&!/IEMobile\b/.test(t))return[S$+" "+Tu,""];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var r=n[1],i=ZKe[r]||"";return/arm/i.test(t)&&(i="RT"),[S$,i]}return[S$,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[t5,t.join(".")]}return[t5,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=Yt(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+Qh+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Qh+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[Qh,t.join(".")]}return[Qh,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var n=[e[1],e[2],e[3]||"0"];t[1]=n.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[UKe,""]],[/Linux|debian/i,["Linux",""]]],$ie=function(e){return YKe.test(e)?lT:BKe.test(e)?cT:VKe.test(e)?Jb:new RegExp(xz,"i").test(e)?xz:new RegExp("("+wz+"|WPDesktop)","i").test(e)?wz:/iPad/.test(e)?bPe:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?xPe:HY.test(e)?G1:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(wie,"i").test(e)?wie:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(Tu).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?Qh:yPe:Qh:new RegExp("(pda|"+Tu+")","i").test(e)?GKe:new RegExp(aT,"i").test(e)&&!new RegExp(aT+" pc","i").test(e)?APe:""},rC="https?://(.*)",RQ=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","irclid","_kx"],JKe=PQ(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],RQ),p6="<masked>",ns={campaignParams:function(){var{customTrackedParams:e,maskPersonalDataProperties:t,customPersonalDataProperties:n}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!ln)return{};var r=t?PQ([],RQ,n||[]):[];return this._campaignParamsFromUrl(n6(ln.URL,r,p6),e)},_campaignParamsFromUrl:function(e,t){var n=JKe.concat(t||[]),r={};return _i(n,function(i){var s=HR(e,i);r[i]=s||null}),r},_searchEngine:function(e){return e?e.search(rC+"google.([^/?]*)")===0?"google":e.search(rC+"bing.com")===0?"bing":e.search(rC+"yahoo.com")===0?"yahoo":e.search(rC+"duckduckgo.com")===0?"duckduckgo":null:null},_searchInfoFromReferrer:function(e){var t=ns._searchEngine(e),n=t!="yahoo"?"q":"p",r={};if(!nm(t)){r.$search_engine=t;var i=ln?HR(ln.referrer,n):"";i.length&&(r.ph_keyword=i)}return r},searchInfo:function(){var e=ln?.referrer;return e?this._searchInfoFromReferrer(e):{}},browser:xie,browserVersion:function(e,t){var n=xie(e,t),r=KKe[n];if(Yt(r))return null;for(var i=0;i<r.length;i++){var s=r[i],a=e.match(s);if(a)return parseFloat(a[a.length-2])}return null},browserLanguage:function(){return navigator.language||navigator.userLanguage},browserLanguagePrefix:function(){var e=this.browserLanguage();return typeof e=="string"?e.split("-")[0]:void 0},os:function(e){for(var t=0;t<Sie.length;t++){var[n,r]=Sie[t],i=n.exec(e),s=i&&(Sd(r)?r(i,e):r);if(s)return s}return["",""]},device:$ie,deviceType:function(e){var t=$ie(e);return t===bPe||t===yPe||t==="Kobo"||t==="Kindle Fire"||t===APe?aT:t===lT||t===Jb||t===cT||t===xz?"Console":t===xPe?"Wearable":t?Tu:"Desktop"},referrer:function(){return ln?.referrer||"$direct"},referringDomain:function(){var e;return ln!=null&&ln.referrer&&((e=Hb(ln.referrer))===null||e===void 0?void 0:e.host)||"$direct"},referrerInfo:function(){return{$referrer:this.referrer(),$referring_domain:this.referringDomain()}},personInfo:function(){var{maskPersonalDataProperties:e,customPersonalDataProperties:t}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=e?PQ([],RQ,t||[]):[],r=Pl?.href.substring(0,1e3);return{r:this.referrer().substring(0,1e3),u:r?n6(r,n,p6):void 0}},personPropsFromInfo:function(e){var t,{r:n,u:r}=e,i={$referrer:n,$referring_domain:n==null?void 0:n=="$direct"?"$direct":(t=Hb(n))===null||t===void 0?void 0:t.host};if(r){i.$current_url=r;var s=Hb(r);i.$host=s?.host,i.$pathname=s?.pathname;var a=this._campaignParamsFromUrl(r);Fs(i,a)}if(n){var o=this._searchInfoFromReferrer(n);Fs(i,o)}return i},initialPersonPropsFromInfo:function(e){var t=this.personPropsFromInfo(e),n={};return _i(t,function(r,i){n["$initial_".concat(zY(i))]=r}),n},timezone:function(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}},timezoneOffset:function(){try{return new Date().getTimezoneOffset()}catch{return}},properties:function(){var{maskPersonalDataProperties:e,customPersonalDataProperties:t}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!ia)return{};var n=e?PQ([],RQ,t||[]):[],[r,i]=ns.os(ia);return Fs(sT({$os:r,$os_version:i,$browser:ns.browser(ia,navigator.vendor),$device:ns.device(ia),$device_type:ns.deviceType(ia),$timezone:ns.timezone(),$timezone_offset:ns.timezoneOffset()}),{$current_url:n6(Pl?.href,n,p6),$host:Pl?.host,$pathname:Pl?.pathname,$raw_user_agent:ia.length>1e3?ia.substring(0,997)+"...":ia,$browser_version:ns.browserVersion(ia,navigator.vendor),$browser_language:ns.browserLanguage(),$browser_language_prefix:ns.browserLanguagePrefix(),$screen_height:Ve?.screen.height,$screen_width:Ve?.screen.width,$viewport_height:Ve?.innerHeight,$viewport_width:Ve?.innerWidth,$lib:"web",$lib_version:Zf.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})},people_properties:function(){if(!ia)return{};var[e,t]=ns.os(ia);return Fs(sT({$os:e,$os_version:t,$browser:ns.browser(ia,navigator.vendor)}),{$browser_version:ns.browserVersion(ia,navigator.vendor)})}},hh=Uo("[FeatureFlags]"),O6="$active_feature_flags",Xy="$override_feature_flags",kie="$feature_flag_payloads",lS="$override_feature_flag_payloads",Tie="$feature_flag_request_id",_ie=e=>{var t={};for(var[n,r]of CQ(e||{}))r&&(t[n]=r);return t},eJe=e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map(n=>{var r;return[n,(r=t[n].variant)!==null&&r!==void 0?r:t[n].enabled]})),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter(n=>t[n].enabled).filter(n=>{var r;return(r=t[n].metadata)===null||r===void 0?void 0:r.payload}).map(n=>{var r;return[n,(r=t[n].metadata)===null||r===void 0?void 0:r.payload]}))):hh.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e};(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})($z||($z={}));class tJe{constructor(t){Xt(this,"_override_warning",!1),Xt(this,"_hasLoadedFlags",!1),Xt(this,"_requestInFlight",!1),Xt(this,"_reloadingDisabled",!1),Xt(this,"_additionalReloadRequested",!1),Xt(this,"_decideCalled",!1),Xt(this,"_flagsLoadedFromRemote",!1),this.instance=t,this.featureFlagEventHandlers=[]}decide(){if(this.instance.config.__preview_remote_config)this._decideCalled=!0;else{var t=!this._reloadDebouncer&&(this.instance.config.advanced_disable_feature_flags||this.instance.config.advanced_disable_feature_flags_on_first_load);this._callDecideEndpoint({disableFlags:t})}}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.instance.get_property(iz),n=this.instance.get_property(Xy),r=this.instance.get_property(lS);if(!r&&!n)return t||{};var i=Fs({},t||{}),s=[...new Set([...Object.keys(r||{}),...Object.keys(n||{})])];for(var a of s){var o,l,c=i[a],u=n?.[a],d=Yt(u)?(o=c?.enabled)!==null&&o!==void 0&&o:!!u,h=Yt(u)?c.variant:typeof u=="string"?u:void 0,f=r?.[a],O=Je(Je({},c),{},{enabled:d,variant:d?h??c?.variant:void 0});d!==c?.enabled&&(O.original_enabled=c?.enabled),h!==c?.variant&&(O.original_variant=c?.variant),f&&(O.metadata=Je(Je({},c?.metadata),{},{payload:f,original_payload:c==null||(l=c.metadata)===null||l===void 0?void 0:l.payload})),i[a]=O}return this._override_warning||(hh.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:i}),this._override_warning=!0),i}getFlagVariants(){var t=this.instance.get_property(Qb),n=this.instance.get_property(Xy);if(!n)return t||{};for(var r=Fs({},t),i=Object.keys(n),s=0;s<i.length;s++)r[i[s]]=n[i[s]];return this._override_warning||(hh.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:n,finalFlags:r}),this._override_warning=!0),r}getFlagPayloads(){var t=this.instance.get_property(kie),n=this.instance.get_property(lS);if(!n)return t||{};for(var r=Fs({},t||{}),i=Object.keys(n),s=0;s<i.length;s++)r[i[s]]=n[i[s]];return this._override_warning||(hh.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:n,finalPayloads:r}),this._override_warning=!0),r}reloadFeatureFlags(){this._reloadingDisabled||this.instance.config.advanced_disable_feature_flags||this._reloadDebouncer||(this._reloadDebouncer=setTimeout(()=>{this._callDecideEndpoint()},5))}clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this._reloadingDisabled=t}_callDecideEndpoint(t){var n;if(this.clearDebouncer(),!this.instance.config.advanced_disable_decide)if(this._requestInFlight)this._additionalReloadRequested=!0;else{var r={token:this.instance.config.token,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:Je(Je({},((n=this.instance.persistence)===null||n===void 0?void 0:n.get_initial_props())||{}),this.instance.get_property(w$)||{}),group_properties:this.instance.get_property(Jm)};(t!=null&&t.disableFlags||this.instance.config.advanced_disable_feature_flags)&&(r.disable_flags=!0);var i=this.instance.config.__preview_flags_v2&&this.instance.config.__preview_remote_config;i&&(r.timezone=ns.timezone()),this._requestInFlight=!0,this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api",i?"/flags/?v=2":"/decide/?v=4"),data:r,compression:this.instance.config.disable_compression?void 0:pd.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:s=>{var a,o,l,c=!0;s.statusCode===200&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),c=!1),this._requestInFlight=!1,this._decideCalled||(this._decideCalled=!0,this.instance._onRemoteConfig((l=s.json)!==null&&l!==void 0?l:{})),r.disable_flags&&!this._additionalReloadRequested||(this._flagsLoadedFromRemote=!c,s.json&&(a=s.json.quotaLimited)!==null&&a!==void 0&&a.includes($z.FeatureFlags)?hh.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):(this.receivedFeatureFlags((o=s.json)!==null&&o!==void 0?o:{},c),this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callDecideEndpoint())))}})}}getFeatureFlag(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var r=this.getFlagVariants()[t],i="".concat(r),s=this.instance.get_property(Tie)||void 0,a=this.instance.get_property(BR)||{};if((n.send_event||!("send_event"in n))&&(!(t in a)||!a[t].includes(i))){var o,l,c,u,d,h,f,O,g,m,v;_s(a[t])?a[t].push(i):a[t]=[i],(o=this.instance.persistence)===null||o===void 0||o.register({[BR]:a});var y=this.getFeatureFlagDetails(t),w={$feature_flag:t,$feature_flag_response:r,$feature_flag_payload:this.getFeatureFlagPayload(t)||null,$feature_flag_request_id:s,$feature_flag_bootstrapped_response:((l=this.instance.config.bootstrap)===null||l===void 0||(c=l.featureFlags)===null||c===void 0?void 0:c[t])||null,$feature_flag_bootstrapped_payload:((u=this.instance.config.bootstrap)===null||u===void 0||(d=u.featureFlagPayloads)===null||d===void 0?void 0:d[t])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};Yt(y==null||(h=y.metadata)===null||h===void 0?void 0:h.version)||(w.$feature_flag_version=y.metadata.version);var k,x=(f=y==null||(O=y.reason)===null||O===void 0?void 0:O.description)!==null&&f!==void 0?f:y==null||(g=y.reason)===null||g===void 0?void 0:g.code;x&&(w.$feature_flag_reason=x),y!=null&&(m=y.metadata)!==null&&m!==void 0&&m.id&&(w.$feature_flag_id=y.metadata.id),Yt(y?.original_variant)&&Yt(y?.original_enabled)||(w.$feature_flag_original_response=Yt(y.original_variant)?y.original_enabled:y.original_variant),y!=null&&(v=y.metadata)!==null&&v!==void 0&&v.original_payload&&(w.$feature_flag_original_payload=y==null||(k=y.metadata)===null||k===void 0?void 0:k.original_payload),this.instance.capture("$feature_flag_called",w)}return r}hh.warn('getFeatureFlag for key "'+t+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){return this.getFlagPayloads()[t]}getRemoteConfigPayload(t,n){var r=this.instance.config.token;this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=4"),data:{distinct_id:this.instance.get_distinct_id(),token:r},compression:this.instance.config.disable_compression?void 0:pd.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:i=>{var s,a=(s=i.json)===null||s===void 0?void 0:s.featureFlagPayloads;n(a?.[t]||void 0)}})}isFeatureEnabled(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(t,n);hh.warn('isFeatureEnabled for key "'+t+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(n=>n!==t)}receivedFeatureFlags(t,n){if(this.instance.persistence){this._hasLoadedFlags=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),s=this.getFlagsWithDetails();(function(a,o){var l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},c=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},u=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{},d=eJe(a),h=d.flags,f=d.featureFlags,O=d.featureFlagPayloads;if(f){var g=a.requestId;if(_s(f)){hh.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var m={};if(f)for(var v=0;v<f.length;v++)m[f[v]]=!0;o&&o.register({[O6]:f,[Qb]:m})}else{var y=f,w=O,k=h;a.errorsWhileComputingFlags&&(y=Je(Je({},l),y),w=Je(Je({},c),w),k=Je(Je({},u),k)),o&&o.register(Je({[O6]:Object.keys(_ie(y)),[Qb]:y||{},[kie]:w||{},[iz]:k||{}},g?{[Tie]:g}:{}))}}})(t,this.instance.persistence,r,i,s),this._fireFeatureFlagsCallbacks(n)}}override(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];hh.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:n})}overrideFeatureFlags(t){if(!this.instance.__loaded||!this.instance.persistence)return hh.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(t===!1)return this.instance.persistence.unregister(Xy),this.instance.persistence.unregister(lS),void this._fireFeatureFlagsCallbacks();if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var n,r=t;if(this._override_warning=!!((n=r.suppressWarning)!==null&&n!==void 0&&n),"flags"in r){if(r.flags===!1)this.instance.persistence.unregister(Xy);else if(r.flags)if(_s(r.flags)){for(var i={},s=0;s<r.flags.length;s++)i[r.flags[s]]=!0;this.instance.persistence.register({[Xy]:i})}else this.instance.persistence.register({[Xy]:r.flags})}return"payloads"in r&&(r.payloads===!1?this.instance.persistence.unregister(lS):r.payloads&&this.instance.persistence.register({[lS]:r.payloads})),void this._fireFeatureFlagsCallbacks()}this._fireFeatureFlagsCallbacks()}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this._hasLoadedFlags){var{flags:n,flagVariants:r}=this._prepareFeatureFlagsForCallbacks();t(n,r)}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,n){var r,i=(this.instance.get_property(EQ)||[]).find(l=>l.flagKey===t),s={["$feature_enrollment/".concat(t)]:n},a={$feature_flag:t,$feature_enrollment:n,$set:s};i&&(a.$early_access_feature_name=i.name),this.instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(s,!1);var o=Je(Je({},this.getFlagVariants()),{},{[t]:n});(r=this.instance.persistence)===null||r===void 0||r.register({[O6]:Object.keys(_ie(o)),[Qb]:o}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1],r=arguments.length>2?arguments[2]:void 0,i=this.instance.get_property(EQ),s=r?"&".concat(r.map(a=>"stage=".concat(a)).join("&")):"";if(i&&!n)return t(i);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/early_access_features/?token=".concat(this.instance.config.token).concat(s)),method:"GET",callback:a=>{var o;if(a.json){var l=a.json.earlyAccessFeatures;return(o=this.instance.persistence)===null||o===void 0||o.register({[EQ]:l}),t(l)}}})}_prepareFeatureFlagsForCallbacks(){var t=this.getFlags(),n=this.getFlagVariants();return{flags:t.filter(r=>n[r]),flagVariants:Object.keys(n).filter(r=>n[r]).reduce((r,i)=>(r[i]=n[i],r),{})}}_fireFeatureFlagsCallbacks(t){var{flags:n,flagVariants:r}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach(i=>i(n,r,{errorsLoading:t}))}setPersonPropertiesForFlags(t){var n=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],r=this.instance.get_property(w$)||{};this.instance.register({[w$]:Je(Je({},r),t)}),n&&this.instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this.instance.unregister(w$)}setGroupPropertiesForFlags(t){var n=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],r=this.instance.get_property(Jm)||{};Object.keys(r).length!==0&&Object.keys(r).forEach(i=>{r[i]=Je(Je({},r[i]),t[i]),delete t[i]}),this.instance.register({[Jm]:Je(Je({},r),t)}),n&&this.instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var n=this.instance.get_property(Jm)||{};this.instance.register({[Jm]:Je(Je({},n),{},{[t]:{}})})}else this.instance.unregister(Jm)}}var nJe=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class g6{constructor(t){this.config=t,this.props={},this.campaign_params_saved=!1,this.name=(n=>{var r="";return n.token&&(r=n.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),n.persistence_name?"ph_"+n.persistence_name:"ph_"+r+"_posthog"})(t),this.storage=this.buildStorage(t),this.load(),t.debug&&yn.info("Persistence loaded",t.persistence,Je({},this.props)),this.update_config(t,t),this.save()}buildStorage(t){nJe.indexOf(t.persistence.toLowerCase())===-1&&(yn.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");var n=t.persistence.toLowerCase();return n==="localstorage"&&ga.is_supported()?ga:n==="localstorage+cookie"&&H2.is_supported()?H2:n==="sessionstorage"&&no.is_supported()?no:n==="memory"?KHe:n==="cookie"?mp:H2.is_supported()?H2:mp}properties(){var t={};return _i(this.props,function(n,r){if(r===Qb&&Ps(n))for(var i=Object.keys(n),s=0;s<i.length;s++)t["$feature/".concat(i[s])]=n[i[s]];else o=r,l=!1,(nm(a=EHe)?l:Nre&&a.indexOf===Nre?a.indexOf(o)!=-1:(_i(a,function(c){if(l||(l=c===o))return GR}),l))||(t[r]=n);var a,o,l}),t}load(){if(!this.disabled){var t=this.storage.parse(this.name);t&&(this.props=Fs({},t))}}save(){this.disabled||this.storage.set(this.name,this.props,this.expire_days,this.cross_subdomain,this.secure,this.config.debug)}remove(){this.storage.remove(this.name,!1),this.storage.remove(this.name,!0)}clear(){this.remove(),this.props={}}register_once(t,n,r){if(Ps(t)){Yt(n)&&(n="None"),this.expire_days=Yt(r)?this.default_expiry:r;var i=!1;if(_i(t,(s,a)=>{this.props.hasOwnProperty(a)&&this.props[a]!==n||(this.props[a]=s,i=!0)}),i)return this.save(),!0}return!1}register(t,n){if(Ps(t)){this.expire_days=Yt(n)?this.default_expiry:n;var r=!1;if(_i(t,(i,s)=>{t.hasOwnProperty(s)&&this.props[s]!==i&&(this.props[s]=i,r=!0)}),r)return this.save(),!0}return!1}unregister(t){t in this.props&&(delete this.props[t],this.save())}update_campaign_params(){if(!this.campaign_params_saved){var t=ns.campaignParams({customTrackedParams:this.config.custom_campaign_params,maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties});Eb(sT(t))||this.register(t),this.campaign_params_saved=!0}}update_search_keyword(){this.register(ns.searchInfo())}update_referrer_info(){this.register_once(ns.referrerInfo(),void 0)}set_initial_person_info(){this.props[lz]||this.props[cz]||this.register_once({[uz]:ns.personInfo({maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties})},void 0)}get_referrer_info(){return sT({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}get_initial_props(){var t={};_i([cz,lz],i=>{var s=this.props[i];s&&_i(s,function(a,o){t["$initial_"+zY(o)]=a})});var n=this.props[uz];if(n){var r=ns.initialPersonPropsFromInfo(n);Fs(t,r)}return t}safe_merge(t){return _i(this.props,function(n,r){r in t||(t[r]=n)}),t}update_config(t,n){if(this.default_expiry=this.expire_days=t.cookie_expiration,this.set_disabled(t.disable_persistence),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),t.persistence!==n.persistence){var r=this.buildStorage(t),i=this.props;this.clear(),this.storage=r,this.props=i,this.save()}}set_disabled(t){this.disabled=t,this.disabled?this.remove():this.save()}set_cross_subdomain(t){t!==this.cross_subdomain&&(this.cross_subdomain=t,this.remove(),this.save())}get_cross_subdomain(){return!!this.cross_subdomain}set_secure(t){t!==this.secure&&(this.secure=t,this.remove(),this.save())}set_event_timer(t,n){var r=this.props[y$]||{};r[t]=n,this.props[y$]=r,this.save()}remove_event_timer(t){var n=(this.props[y$]||{})[t];return Yt(n)||(delete this.props[y$][t],this.save()),n}get_property(t){return this.props[t]}set_property(t,n){this.props[t]=n,this.save()}}var DPe,Cs,NPe,l0,Pie,XPe,kz,IPe,Cie,Tz,Eie,Qie,Rie,Aie,_z={},FPe=[],rJe=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,KY=Array.isArray;function tg(e,t){for(var n in t)e[n]=t[n];return e}function MPe(e){var t=e.parentNode;t&&t.removeChild(e)}function m6(e,t,n,r,i){var s={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:i??++NPe,__i:-1,__u:0};return i==null&&Cs.vnode!=null&&Cs.vnode(s),s}function JY(e){return e.children}function AQ(e,t){this.props=e,this.context=t}function V1(e,t){if(t==null)return e.__?V1(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?V1(e):null}function jPe(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=e.__c.base=n.__e;break}return jPe(e)}}function Pz(e){(!e.__d&&(e.__d=!0)&&l0.push(e)&&!n5.__r++||Pie!==Cs.debounceRendering)&&((Pie=Cs.debounceRendering)||XPe)(n5)}function n5(){var e,t,n,r,i,s,a,o,l;for(l0.sort(kz);e=l0.shift();)e.__d&&(t=l0.length,r=void 0,s=(i=(n=e).__v).__e,o=[],l=[],(a=n.__P)&&((r=tg({},i)).__v=i.__v+1,Cs.vnode&&Cs.vnode(r),zPe(a,r,i,n.__n,a.ownerSVGElement!==void 0,32&i.__u?[s]:null,o,s??V1(i),!!(32&i.__u),l),r.__.__k[r.__i]=r,aJe(o,r,l),r.__e!=s&&jPe(r)),l0.length>t&&l0.sort(kz));n5.__r=0}function LPe(e,t,n,r,i,s,a,o,l,c,u){var d,h,f,O,g,m=r&&r.__k||FPe,v=t.length;for(n.__d=l,iJe(n,t,m),l=n.__d,d=0;d<v;d++)(f=n.__k[d])!=null&&typeof f!="boolean"&&typeof f!="function"&&(h=f.__i===-1?_z:m[f.__i]||_z,f.__i=d,zPe(e,f,h,i,s,a,o,l,c,u),O=f.__e,f.ref&&h.ref!=f.ref&&(h.ref&&eZ(h.ref,null,f),u.push(f.ref,f.__c||O,f)),g==null&&O!=null&&(g=O),65536&f.__u||h.__k===f.__k?l=qPe(f,l,e):typeof f.type=="function"&&f.__d!==void 0?l=f.__d:O&&(l=O.nextSibling),f.__d=void 0,f.__u&=-196609);n.__d=l,n.__e=g}function iJe(e,t,n){var r,i,s,a,o,l=t.length,c=n.length,u=c,d=0;for(e.__k=[],r=0;r<l;r++)(i=e.__k[r]=(i=t[r])==null||typeof i=="boolean"||typeof i=="function"?null:typeof i=="string"||typeof i=="number"||typeof i=="bigint"||i.constructor==String?m6(null,i,null,null,i):KY(i)?m6(JY,{children:i},null,null,null):i.constructor===void 0&&i.__b>0?m6(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i)!=null?(i.__=e,i.__b=e.__b+1,o=sJe(i,n,a=r+d,u),i.__i=o,s=null,o!==-1&&(u--,(s=n[o])&&(s.__u|=131072)),s==null||s.__v===null?(o==-1&&d--,typeof i.type!="function"&&(i.__u|=65536)):o!==a&&(o===a+1?d++:o>a?u>l-a?d+=o-a:d--:d=o<a&&o==a-1?o-a:0,o!==r+d&&(i.__u|=65536))):(s=n[r])&&s.key==null&&s.__e&&(s.__e==e.__d&&(e.__d=V1(s)),Cz(s,s,!1),n[r]=null,u--);if(u)for(r=0;r<c;r++)(s=n[r])!=null&&(131072&s.__u)==0&&(s.__e==e.__d&&(e.__d=V1(s)),Cz(s,s))}function qPe(e,t,n){var r,i;if(typeof e.type=="function"){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=qPe(r[i],t,n));return t}return e.__e!=t&&(n.insertBefore(e.__e,t||null),t=e.__e),t&&t.nextSibling}function sJe(e,t,n,r){var i=e.key,s=e.type,a=n-1,o=n+1,l=t[n];if(l===null||l&&i==l.key&&s===l.type)return n;if(r>(l!=null&&(131072&l.__u)==0?1:0))for(;a>=0||o<t.length;){if(a>=0){if((l=t[a])&&(131072&l.__u)==0&&i==l.key&&s===l.type)return a;a--}if(o<t.length){if((l=t[o])&&(131072&l.__u)==0&&i==l.key&&s===l.type)return o;o++}}return-1}function Die(e,t,n){t[0]==="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||rJe.test(t)?n:n+"px"}function iC(e,t,n,r,i){var s;e:if(t==="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||Die(e.style,t,"");if(n)for(t in n)r&&n[t]===r[t]||Die(e.style,t,n[t])}else if(t[0]==="o"&&t[1]==="n")s=t!==(t=t.replace(/(PointerCapture)$|Capture$/,"$1")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=n,n?r?n.u=r.u:(n.u=Date.now(),e.addEventListener(t,s?Xie:Nie,s)):e.removeEventListener(t,s?Xie:Nie,s);else{if(i)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!=="width"&&t!=="height"&&t!=="href"&&t!=="list"&&t!=="form"&&t!=="tabIndex"&&t!=="download"&&t!=="rowSpan"&&t!=="colSpan"&&t!=="role"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!=="-"?e.removeAttribute(t):e.setAttribute(t,n))}}function Nie(e){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(Cs.event?Cs.event(e):e)}function Xie(e){return this.l[e.type+!0](Cs.event?Cs.event(e):e)}function zPe(e,t,n,r,i,s,a,o,l,c){var u,d,h,f,O,g,m,v,y,w,k,x,S,T,_,P=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),s=[o=t.__e=n.__e]),(u=Cs.__b)&&u(t);e:if(typeof P=="function")try{if(v=t.props,y=(u=P.contextType)&&r[u.__c],w=u?y?y.props.value:u.__:r,n.__c?m=(d=t.__c=n.__c).__=d.__E:("prototype"in P&&P.prototype.render?t.__c=d=new P(v,w):(t.__c=d=new AQ(v,w),d.constructor=P,d.render=lJe),y&&y.sub(d),d.props=v,d.state||(d.state={}),d.context=w,d.__n=r,h=d.__d=!0,d.__h=[],d._sb=[]),d.__s==null&&(d.__s=d.state),P.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=tg({},d.__s)),tg(d.__s,P.getDerivedStateFromProps(v,d.__s))),f=d.props,O=d.state,d.__v=t,h)P.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(P.getDerivedStateFromProps==null&&v!==f&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(v,w),!d.__e&&(d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(v,d.__s,w)===!1||t.__v===n.__v)){for(t.__v!==n.__v&&(d.props=v,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.forEach(function(E){E&&(E.__=t)}),k=0;k<d._sb.length;k++)d.__h.push(d._sb[k]);d._sb=[],d.__h.length&&a.push(d);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(v,d.__s,w),d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(f,O,g)})}if(d.context=w,d.props=v,d.__P=e,d.__e=!1,x=Cs.__r,S=0,"prototype"in P&&P.prototype.render){for(d.state=d.__s,d.__d=!1,x&&x(t),u=d.render(d.props,d.state,d.context),T=0;T<d._sb.length;T++)d.__h.push(d._sb[T]);d._sb=[]}else do d.__d=!1,x&&x(t),u=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++S<25);d.state=d.__s,d.getChildContext!=null&&(r=tg(tg({},r),d.getChildContext())),h||d.getSnapshotBeforeUpdate==null||(g=d.getSnapshotBeforeUpdate(f,O)),LPe(e,KY(_=u!=null&&u.type===JY&&u.key==null?u.props.children:u)?_:[_],t,n,r,i,s,a,o,l,c),d.base=t.__e,t.__u&=-161,d.__h.length&&a.push(d),m&&(d.__E=d.__=null)}catch(E){t.__v=null,l||s!=null?(t.__e=o,t.__u|=l?160:32,s[s.indexOf(o)]=null):(t.__e=n.__e,t.__k=n.__k),Cs.__e(E,t,n)}else s==null&&t.__v===n.__v?(t.__k=n.__k,t.__e=n.__e):t.__e=oJe(n.__e,t,n,r,i,s,a,l,c);(u=Cs.diffed)&&u(t)}function aJe(e,t,n){t.__d=void 0;for(var r=0;r<n.length;r++)eZ(n[r],n[++r],n[++r]);Cs.__c&&Cs.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(s){s.call(i)})}catch(s){Cs.__e(s,i.__v)}})}function oJe(e,t,n,r,i,s,a,o,l){var c,u,d,h,f,O,g,m=n.props,v=t.props,y=t.type;if(y==="svg"&&(i=!0),s!=null){for(c=0;c<s.length;c++)if((f=s[c])&&"setAttribute"in f==!!y&&(y?f.localName===y:f.nodeType===3)){e=f,s[c]=null;break}}if(e==null){if(y===null)return document.createTextNode(v);e=i?document.createElementNS("http://www.w3.org/2000/svg",y):document.createElement(y,v.is&&v),s=null,o=!1}if(y===null)m===v||o&&e.data===v||(e.data=v);else{if(s=s&&DPe.call(e.childNodes),m=n.props||_z,!o&&s!=null)for(m={},c=0;c<e.attributes.length;c++)m[(f=e.attributes[c]).name]=f.value;for(c in m)f=m[c],c=="children"||(c=="dangerouslySetInnerHTML"?d=f:c==="key"||c in v||iC(e,c,null,f,i));for(c in v)f=v[c],c=="children"?h=f:c=="dangerouslySetInnerHTML"?u=f:c=="value"?O=f:c=="checked"?g=f:c==="key"||o&&typeof f!="function"||m[c]===f||iC(e,c,f,m[c],i);if(u)o||d&&(u.__html===d.__html||u.__html===e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=""),LPe(e,KY(h)?h:[h],t,n,r,i&&y!=="foreignObject",s,a,s?s[0]:n.__k&&V1(n,0),o,l),s!=null)for(c=s.length;c--;)s[c]!=null&&MPe(s[c]);o||(c="value",O!==void 0&&(O!==e[c]||y==="progress"&&!O||y==="option"&&O!==m[c])&&iC(e,c,O,m[c],!1),c="checked",g!==void 0&&g!==e[c]&&iC(e,c,g,m[c],!1))}return e}function eZ(e,t,n){try{typeof e=="function"?e(t):e.current=t}catch(r){Cs.__e(r,n)}}function Cz(e,t,n){var r,i;if(Cs.unmount&&Cs.unmount(e),(r=e.ref)&&(r.current&&r.current!==e.__e||eZ(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(s){Cs.__e(s,t)}r.base=r.__P=null,e.__c=void 0}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Cz(r[i],t,n||typeof e.type!="function");n||e.__e==null||MPe(e.__e),e.__=e.__e=e.__d=void 0}function lJe(e,t,n){return this.constructor(e,n)}DPe=FPe.slice,Cs={__e:function(e,t,n,r){for(var i,s,a;t=t.__;)if((i=t.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(e)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),a=i.__d),a)return i.__E=i}catch(o){e=o}throw e}},NPe=0,AQ.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=tg({},this.state),typeof e=="function"&&(e=e(tg({},n),this.props)),e&&tg(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Pz(this))},AQ.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Pz(this))},AQ.prototype.render=JY,l0=[],XPe=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,kz=function(e,t){return e.__v.__b-t.__v.__b},n5.__r=0,IPe=0,function(e){e.Button="button",e.Tab="tab",e.Selector="selector"}(Cie||(Cie={})),function(e){e.Left="left",e.Center="center",e.Right="right",e.NextToTrigger="next_to_trigger"}(Tz||(Tz={})),function(e){e.Popover="popover",e.API="api",e.Widget="widget"}(Eie||(Eie={})),function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"}(Qie||(Qie={})),function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"}(Rie||(Rie={})),function(e){e.Once="once",e.Recurring="recurring",e.Always="always"}(Aie||(Aie={}));var B1=function(e,t){if(!function(n){try{new RegExp(n)}catch{return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}},Za=Uo("[Surveys]"),Iie={icontains:(e,t)=>e.some(n=>t.toLowerCase().includes(n.toLowerCase())),not_icontains:(e,t)=>e.every(n=>!t.toLowerCase().includes(n.toLowerCase())),regex:(e,t)=>e.some(n=>B1(t,n)),not_regex:(e,t)=>e.every(n=>!B1(t,n)),exact:(e,t)=>e.some(n=>t===n),is_not:(e,t)=>e.every(n=>t!==n)};function Fie(e){return e??"icontains"}Tz.Right;(function(e,t){var n={__c:t="__cC"+IPe++,__:e,Consumer:function(r,i){return r.children(i)},Provider:function(r){var i,s;return this.getChildContext||(i=[],(s={})[t]=this,this.getChildContext=function(){return s},this.shouldComponentUpdate=function(a){this.props.value!==a.value&&i.some(function(o){o.__e=!0,Pz(o)})},this.sub=function(a){i.push(a);var o=a.componentWillUnmount;a.componentWillUnmount=function(){i.splice(i.indexOf(a),1),o&&o.call(a)}}),r.children}};n.Provider.__=n.Consumer.contextType=n})({isPreviewMode:!1,previewPageIndex:0,onPopupSurveyDismissed:()=>{},isPopup:!0,onPreviewSubmit:()=>{}});let UPe=class{constructor(){Xt(this,"events",{}),this.events={}}on(t,n){return this.events[t]||(this.events[t]=[]),this.events[t].push(n),()=>{this.events[t]=this.events[t].filter(r=>r!==n)}}emit(t,n){for(var r of this.events[t]||[])r(n);for(var i of this.events["*"]||[])i(t,n)}},cJe=class vb{constructor(t){Xt(this,"_debugEventEmitter",new UPe),Xt(this,"checkStep",(n,r)=>this.checkStepEvent(n,r)&&this.checkStepUrl(n,r)&&this.checkStepElement(n,r)),Xt(this,"checkStepEvent",(n,r)=>r==null||!r.event||n?.event===r?.event),this.instance=t,this.actionEvents=new Set,this.actionRegistry=new Set}init(){var t;if(!Yt((t=this.instance)===null||t===void 0?void 0:t._addCaptureHook)){var n;(n=this.instance)===null||n===void 0||n._addCaptureHook((r,i)=>{this.on(r,i)})}}register(t){var n,r;if(!Yt((n=this.instance)===null||n===void 0?void 0:n._addCaptureHook)&&(t.forEach(a=>{var o,l;(o=this.actionRegistry)===null||o===void 0||o.add(a),(l=a.steps)===null||l===void 0||l.forEach(c=>{var u;(u=this.actionEvents)===null||u===void 0||u.add(c?.event||"")})}),(r=this.instance)!==null&&r!==void 0&&r.autocapture)){var i,s=new Set;t.forEach(a=>{var o;(o=a.steps)===null||o===void 0||o.forEach(l=>{l!=null&&l.selector&&s.add(l?.selector)})}),(i=this.instance)===null||i===void 0||i.autocapture.setElementSelectors(s)}}on(t,n){var r;n!=null&&t.length!=0&&(this.actionEvents.has(t)||this.actionEvents.has(n?.event))&&this.actionRegistry&&((r=this.actionRegistry)===null||r===void 0?void 0:r.size)>0&&this.actionRegistry.forEach(i=>{this.checkAction(n,i)&&this._debugEventEmitter.emit("actionCaptured",i.name)})}_addActionHook(t){this.onAction("actionCaptured",n=>t(n))}checkAction(t,n){if(n?.steps==null)return!1;for(var r of n.steps)if(this.checkStep(t,r))return!0;return!1}onAction(t,n){return this._debugEventEmitter.on(t,n)}checkStepUrl(t,n){if(n!=null&&n.url){var r,i=t==null||(r=t.properties)===null||r===void 0?void 0:r.$current_url;if(!i||typeof i!="string"||!vb.matchString(i,n?.url,n?.url_matching||"contains"))return!1}return!0}static matchString(t,n,r){switch(r){case"regex":return!!Ve&&B1(t,n);case"exact":return n===t;case"contains":var i=vb.escapeStringRegexp(n).replace(/_/g,".").replace(/%/g,".*");return B1(t,i);default:return!1}}static escapeStringRegexp(t){return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}checkStepElement(t,n){if((n!=null&&n.href||n!=null&&n.tag_name||n!=null&&n.text)&&!this.getElementsList(t).some(s=>!(n!=null&&n.href&&!vb.matchString(s.href||"",n?.href,n?.href_matching||"exact"))&&(n==null||!n.tag_name||s.tag_name===n?.tag_name)&&!(n!=null&&n.text&&!vb.matchString(s.text||"",n?.text,n?.text_matching||"exact")&&!vb.matchString(s.$el_text||"",n?.text,n?.text_matching||"exact"))))return!1;if(n!=null&&n.selector){var r,i=t==null||(r=t.properties)===null||r===void 0?void 0:r.$element_selectors;if(!i||!i.includes(n?.selector))return!1}return!0}getElementsList(t){return t?.properties.$elements==null?[]:t?.properties.$elements}},Ez=class WPe{constructor(t){this.instance=t,this.eventToSurveys=new Map,this.actionToSurveys=new Map}register(t){var n;Yt((n=this.instance)===null||n===void 0?void 0:n._addCaptureHook)||(this.setupEventBasedSurveys(t),this.setupActionBasedSurveys(t))}setupActionBasedSurveys(t){var n=t.filter(r=>{var i,s,a,o;return((i=r.conditions)===null||i===void 0?void 0:i.actions)&&((s=r.conditions)===null||s===void 0||(a=s.actions)===null||a===void 0||(o=a.values)===null||o===void 0?void 0:o.length)>0});n.length!==0&&(this.actionMatcher==null&&(this.actionMatcher=new cJe(this.instance),this.actionMatcher.init(),this.actionMatcher._addActionHook(r=>{this.onAction(r)})),n.forEach(r=>{var i,s,a,o,l,c,u,d,h,f;r.conditions&&(i=r.conditions)!==null&&i!==void 0&&i.actions&&(s=r.conditions)!==null&&s!==void 0&&(a=s.actions)!==null&&a!==void 0&&a.values&&((o=r.conditions)===null||o===void 0||(l=o.actions)===null||l===void 0||(c=l.values)===null||c===void 0?void 0:c.length)>0&&((u=this.actionMatcher)===null||u===void 0||u.register(r.conditions.actions.values),(d=r.conditions)===null||d===void 0||(h=d.actions)===null||h===void 0||(f=h.values)===null||f===void 0||f.forEach(O=>{if(O&&O.name){var g=this.actionToSurveys.get(O.name);g&&g.push(r.id),this.actionToSurveys.set(O.name,g||[r.id])}}))}))}setupEventBasedSurveys(t){var n;t.filter(r=>{var i,s,a,o;return((i=r.conditions)===null||i===void 0?void 0:i.events)&&((s=r.conditions)===null||s===void 0||(a=s.events)===null||a===void 0||(o=a.values)===null||o===void 0?void 0:o.length)>0}).length!==0&&((n=this.instance)===null||n===void 0||n._addCaptureHook((r,i)=>{this.onEvent(r,i)}),t.forEach(r=>{var i,s,a;(i=r.conditions)===null||i===void 0||(s=i.events)===null||s===void 0||(a=s.values)===null||a===void 0||a.forEach(o=>{if(o&&o.name){var l=this.eventToSurveys.get(o.name);l&&l.push(r.id),this.eventToSurveys.set(o.name,l||[r.id])}})}))}onEvent(t,n){var r,i,s=((r=this.instance)===null||r===void 0||(i=r.persistence)===null||i===void 0?void 0:i.props[Z2])||[];if(WPe.SURVEY_SHOWN_EVENT_NAME==t&&n&&s.length>0){var a,o=n==null||(a=n.properties)===null||a===void 0?void 0:a.$survey_id;if(o){var l=s.indexOf(o);l>=0&&(s.splice(l,1),this._updateActivatedSurveys(s))}}else this.eventToSurveys.has(t)&&this._updateActivatedSurveys(s.concat(this.eventToSurveys.get(t)||[]))}onAction(t){var n,r,i=((n=this.instance)===null||n===void 0||(r=n.persistence)===null||r===void 0?void 0:r.props[Z2])||[];this.actionToSurveys.has(t)&&this._updateActivatedSurveys(i.concat(this.actionToSurveys.get(t)||[]))}_updateActivatedSurveys(t){var n,r;(n=this.instance)===null||n===void 0||(r=n.persistence)===null||r===void 0||r.register({[Z2]:[...new Set(t)]})}getSurveys(){var t,n,r=(t=this.instance)===null||t===void 0||(n=t.persistence)===null||n===void 0?void 0:n.props[Z2];return r||[]}getEventToSurveys(){return this.eventToSurveys}_getActionMatcher(){return this.actionMatcher}};Xt(Ez,"SURVEY_SHOWN_EVENT_NAME","survey shown");let uJe=class{constructor(t){Xt(this,"_isFetchingSurveys",!1),Xt(this,"_isInitializingSurveys",!1),Xt(this,"_surveyCallbacks",[]),this.instance=t,this._surveyEventReceiver=null}onRemoteConfig(t){var n=t.surveys;if(fi(n))return Za.warn("Decide not loaded yet. Not loading surveys.");var r=_s(n);this._hasSurveys=r?n.length>0:n,Za.info("decide response received, hasSurveys: ".concat(this._hasSurveys)),this._hasSurveys&&this.loadIfEnabled()}reset(){localStorage.removeItem("lastSeenSurveyDate");var t=(()=>{for(var n=[],r=0;r<localStorage.length;r++){var i=localStorage.key(r);i!=null&&i.startsWith("seenSurvey_")&&n.push(i)}return n})();t.forEach(n=>localStorage.removeItem(n))}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)Za.info("Already initializing surveys, skipping...");else if(this.instance.config.disable_surveys)Za.info("Disabled. Not loading surveys.");else{var t=er?.__PosthogExtensions__;if(t)if(this._hasSurveys){this._isInitializingSurveys=!0;try{var n=t.generateSurveys;if(n)this._surveyManager=n(this.instance),this._isInitializingSurveys=!1,this._surveyEventReceiver=new Ez(this.instance),Za.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0});else{var r=t.loadExternalDependency;if(r)r(this.instance,"surveys",s=>{if(s||!t.generateSurveys)return Za.error("Could not load surveys script",s),void(this._isInitializingSurveys=!1);this._surveyManager=t.generateSurveys(this.instance),this._isInitializingSurveys=!1,this._surveyEventReceiver=new Ez(this.instance),Za.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})});else{var i="PostHog loadExternalDependency extension not found. Cannot load remote config.";Za.error(i),this._isInitializingSurveys=!1,this._notifySurveyCallbacks({isLoaded:!1,error:i})}}}catch(s){throw Za.error("Error initializing surveys",s),this._isInitializingSurveys=!1,this._notifySurveyCallbacks({isLoaded:!1,error:"Error initializing surveys"}),s}}else Za.info("No surveys to load.");else Za.error("PostHog Extensions not found.")}}onSurveysLoaded(t){return this._surveyCallbacks.push(t),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter(n=>n!==t)}}getSurveys(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(this.instance.config.disable_surveys)return Za.info("Disabled. Not loading surveys."),t([]);var r=this.instance.get_property(sz);if(r&&!n)return t(r,{isLoaded:!0});if(this._isFetchingSurveys)return t([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this._isFetchingSurveys=!0,this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/surveys/?token=".concat(this.instance.config.token)),method:"GET",timeout:this.instance.config.surveys_request_timeout_ms,callback:i=>{var s;this._isFetchingSurveys=!1;var a=i.statusCode;if(a!==200||!i.json){var o="Surveys API could not be loaded, status: ".concat(a);return Za.error(o),t([],{isLoaded:!1,error:o})}var l,c=i.json.surveys||[],u=c.filter(d=>{var h,f,O,g,m,v,y,w,k,x,S,T;return((h=d.conditions)===null||h===void 0?void 0:h.events)&&((f=d.conditions)===null||f===void 0||(O=f.events)===null||O===void 0?void 0:O.values)&&((g=d.conditions)===null||g===void 0||(m=g.events)===null||m===void 0||(v=m.values)===null||v===void 0?void 0:v.length)>0||((y=d.conditions)===null||y===void 0?void 0:y.actions)&&((w=d.conditions)===null||w===void 0||(k=w.actions)===null||k===void 0?void 0:k.values)&&((x=d.conditions)===null||x===void 0||(S=x.actions)===null||S===void 0||(T=S.values)===null||T===void 0?void 0:T.length)>0});return u.length>0&&((l=this._surveyEventReceiver)===null||l===void 0||l.register(u)),(s=this.instance.persistence)===null||s===void 0||s.register({[sz]:c}),t(c,{isLoaded:!0})}})}catch(i){throw this._isFetchingSurveys=!1,i}}_notifySurveyCallbacks(t){for(var n of this._surveyCallbacks)try{t.isLoaded?this.getSurveys(n):n([],t)}catch(r){Za.error("Error in survey callback",r)}}isSurveyFeatureFlagEnabled(t){return!t||this.instance.featureFlags.isFeatureEnabled(t)}getActiveMatchingSurveys(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.getSurveys(r=>{var i,s=r.filter(l=>!(!l.start_date||l.end_date)).filter(l=>{var c;if(!l.conditions)return!0;var u=function(f){var O,g,m;if((O=f.conditions)===null||O===void 0||!O.url)return!0;var v=Ve==null||(g=Ve.location)===null||g===void 0?void 0:g.href;if(!v)return!1;var y=[f.conditions.url];return Iie[Fie((m=f.conditions)===null||m===void 0?void 0:m.urlMatchType)](y,v)}(l),d=(c=l.conditions)===null||c===void 0||!c.selector||ln?.querySelector(l.conditions.selector),h=function(f){var O,g,m;if((O=f.conditions)===null||O===void 0||!O.deviceTypes||((g=f.conditions)===null||g===void 0?void 0:g.deviceTypes.length)===0)return!0;if(!ia)return!1;var v=ns.deviceType(ia);return Iie[Fie((m=f.conditions)===null||m===void 0?void 0:m.deviceTypesMatchType)](f.conditions.deviceTypes,v)}(l);return u&&d&&h}),a=(i=this._surveyEventReceiver)===null||i===void 0?void 0:i.getSurveys(),o=s.filter(l=>{var c,u,d,h,f,O,g,m,v;if(!(l.linked_flag_key||l.targeting_flag_key||l.internal_targeting_flag_key||(c=l.feature_flag_keys)!==null&&c!==void 0&&c.length))return!0;var y=this.isSurveyFeatureFlagEnabled(l.linked_flag_key),w=this.isSurveyFeatureFlagEnabled(l.targeting_flag_key),k=((u=(d=l.conditions)===null||d===void 0||(h=d.events)===null||h===void 0||(f=h.values)===null||f===void 0?void 0:f.length)!==null&&u!==void 0?u:0)>0,x=((O=(g=l.conditions)===null||g===void 0||(m=g.actions)===null||m===void 0||(v=m.values)===null||v===void 0?void 0:v.length)!==null&&O!==void 0?O:0)>0,S=!k&&!x||a?.includes(l.id),T=this._canActivateRepeatedly(l)||this.isSurveyFeatureFlagEnabled(l.internal_targeting_flag_key),_=this.checkFlags(l);return y&&w&&T&&S&&_});return t(o)},n)}checkFlags(t){var n;return(n=t.feature_flag_keys)===null||n===void 0||!n.length||t.feature_flag_keys.every(r=>{var{key:i,value:s}=r;return!i||!s||this.instance.featureFlags.isFeatureEnabled(s)})}_canActivateRepeatedly(t){var n;return fi((n=er.__PosthogExtensions__)===null||n===void 0?void 0:n.canActivateRepeatedly)?(Za.warn("init was not called"),!1):er.__PosthogExtensions__.canActivateRepeatedly(t)}canRenderSurvey(t){if(fi(this._surveyManager))return Za.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var n=null;return this.getSurveys(r=>{var i=r.filter(s=>s.id===t)[0];n=i?Je({},this._surveyManager.canRenderSurvey(i)):{visible:!1,disabledReason:"Survey not found"}}),n}renderSurvey(t,n){fi(this._surveyManager)?Za.warn("init was not called"):this.getSurveys(r=>{var i=r.filter(s=>s.id===t)[0];this._surveyManager.renderSurvey(i,ln?.querySelector(n))})}};var Mie=Uo("[RateLimiter]");let dJe=class{constructor(t){var n,r;Xt(this,"serverLimits",{}),Xt(this,"lastEventRateLimited",!1),Xt(this,"checkForLimiting",i=>{var s=i.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach(a=>{Mie.info("".concat(a||"events"," is quota limited.")),this.serverLimits[a]=new Date().getTime()+6e4})}catch(a){return void Mie.warn('could not rate limit - continuing. Error: "'.concat(a?.message,'"'),{text:s})}}),this.instance=t,this.captureEventsPerSecond=((n=t.config.rate_limiting)===null||n===void 0?void 0:n.events_per_second)||10,this.captureEventsBurstLimit=Math.max(((r=t.config.rate_limiting)===null||r===void 0?void 0:r.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(){var t,n,r,i=arguments.length>0&&arguments[0]!==void 0&&arguments[0],s=new Date().getTime(),a=(t=(n=this.instance.persistence)===null||n===void 0?void 0:n.get_property(oz))!==null&&t!==void 0?t:{tokens:this.captureEventsBurstLimit,last:s};a.tokens+=(s-a.last)/1e3*this.captureEventsPerSecond,a.last=s,a.tokens>this.captureEventsBurstLimit&&(a.tokens=this.captureEventsBurstLimit);var o=a.tokens<1;return o||i||(a.tokens=Math.max(0,a.tokens-1)),!o||this.lastEventRateLimited||i||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to ".concat(this.captureEventsPerSecond," events per second and ").concat(this.captureEventsBurstLimit," events burst limit.")},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=o,(r=this.instance.persistence)===null||r===void 0||r.set_property(oz,a),{isRateLimited:o,remainingTokens:a.tokens}}isServerRateLimited(t){var n=this.serverLimits[t||"events"]||!1;return n!==!1&&new Date().getTime()<n}};var Dm=Uo("[RemoteConfig]");let hJe=class{constructor(t){this.instance=t}get remoteConfig(){var t,n;return(t=er._POSTHOG_REMOTE_CONFIG)===null||t===void 0||(n=t[this.instance.config.token])===null||n===void 0?void 0:n.config}_loadRemoteConfigJs(t){var n,r,i;(n=er.__PosthogExtensions__)!==null&&n!==void 0&&n.loadExternalDependency?(r=er.__PosthogExtensions__)===null||r===void 0||(i=r.loadExternalDependency)===null||i===void 0||i.call(r,this.instance,"remote-config",()=>t(this.remoteConfig)):(Dm.error("PostHog Extensions not found. Cannot load remote config."),t())}_loadRemoteConfigJSON(t){this.instance._send_request({method:"GET",url:this.instance.requestRouter.endpointFor("assets","/array/".concat(this.instance.config.token,"/config")),callback:n=>{t(n.json)}})}load(){try{if(this.remoteConfig)return Dm.info("Using preloaded remote config",this.remoteConfig),void this.onRemoteConfig(this.remoteConfig);if(this.instance.config.advanced_disable_decide)return void Dm.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs(t=>{if(!t)return Dm.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON(n=>{this.onRemoteConfig(n)});this.onRemoteConfig(t)})}catch(t){Dm.error("Error loading remote config",t)}}onRemoteConfig(t){t?this.instance.config.__preview_remote_config?(this.instance._onRemoteConfig(t),t.hasFeatureFlags!==!1&&this.instance.featureFlags.ensureFlagsLoaded()):Dm.info("__preview_remote_config is disabled. Logging config instead",t):Dm.error("Failed to fetch remote config from PostHog.")}};var fJe=function(e){var t,n,r,i,s="";for(t=n=0,r=(e=(e+"").replace(/\r\n/g,`
4
4
  `).replace(/\r/g,`
@@ -776,7 +776,7 @@ try {
776
776
  ${c}
777
777
  }
778
778
  } catch(e){}})();`}},"mui-color-scheme-init")}function Elt(){}const Qlt=({key:e,storageWindow:t})=>(!t&&typeof window<"u"&&(t=window),{get(n){if(typeof window>"u")return;if(!t)return n;let r;try{r=t.localStorage.getItem(e)}catch{}return r||n},set:n=>{if(t)try{t.localStorage.setItem(e,n)}catch{}},subscribe:n=>{if(!t)return Elt;const r=i=>{const s=i.newValue;i.key===e&&n(s)};return t.addEventListener("storage",r),()=>{t.removeEventListener("storage",r)}}});function N6(){}function Lse(e){if(typeof window<"u"&&typeof window.matchMedia=="function"&&e==="system")return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function xCe(e,t){if(e.mode==="light"||e.mode==="system"&&e.systemMode==="light")return t("light");if(e.mode==="dark"||e.mode==="system"&&e.systemMode==="dark")return t("dark")}function Rlt(e){return xCe(e,t=>{if(t==="light")return e.lightColorScheme;if(t==="dark")return e.darkColorScheme})}function Alt(e){const{defaultMode:t="light",defaultLightColorScheme:n,defaultDarkColorScheme:r,supportedColorSchemes:i=[],modeStorageKey:s=EZ,colorSchemeStorageKey:a=QZ,storageWindow:o=typeof window>"u"?void 0:window,storageManager:l=Qlt,noSsr:c=!1}=e,u=i.join(","),d=i.length>1,h=b.useMemo(()=>l?.({key:s,storageWindow:o}),[l,s,o]),f=b.useMemo(()=>l?.({key:`${a}-light`,storageWindow:o}),[l,a,o]),O=b.useMemo(()=>l?.({key:`${a}-dark`,storageWindow:o}),[l,a,o]),[g,m]=b.useState(()=>{const _=h?.get(t)||t,P=f?.get(n)||n,E=O?.get(r)||r;return{mode:_,systemMode:Lse(_),lightColorScheme:P,darkColorScheme:E}}),[v,y]=b.useState(c||!d);b.useEffect(()=>{y(!0)},[]);const w=Rlt(g),k=b.useCallback(_=>{m(P=>{if(_===P.mode)return P;const E=_??t;return h?.set(E),{...P,mode:E,systemMode:Lse(E)}})},[h,t]),x=b.useCallback(_=>{_?typeof _=="string"?_&&!u.includes(_)?console.error(`\`${_}\` does not exist in \`theme.colorSchemes\`.`):m(P=>{const E={...P};return xCe(P,C=>{C==="light"&&(f?.set(_),E.lightColorScheme=_),C==="dark"&&(O?.set(_),E.darkColorScheme=_)}),E}):m(P=>{const E={...P},C=_.light===null?n:_.light,Q=_.dark===null?r:_.dark;return C&&(u.includes(C)?(E.lightColorScheme=C,f?.set(C)):console.error(`\`${C}\` does not exist in \`theme.colorSchemes\`.`)),Q&&(u.includes(Q)?(E.darkColorScheme=Q,O?.set(Q)):console.error(`\`${Q}\` does not exist in \`theme.colorSchemes\`.`)),E}):m(P=>(f?.set(n),O?.set(r),{...P,lightColorScheme:n,darkColorScheme:r}))},[u,f,O,n,r]),S=b.useCallback(_=>{g.mode==="system"&&m(P=>{const E=_?.matches?"dark":"light";return P.systemMode===E?P:{...P,systemMode:E}})},[g.mode]),T=b.useRef(S);return T.current=S,b.useEffect(()=>{if(typeof window.matchMedia!="function"||!d)return;const _=(...E)=>T.current(...E),P=window.matchMedia("(prefers-color-scheme: dark)");return P.addListener(_),_(P),()=>{P.removeListener(_)}},[d]),b.useEffect(()=>{if(d){const _=h?.subscribe(C=>{(!C||["light","dark","system"].includes(C))&&k(C||t)})||N6,P=f?.subscribe(C=>{(!C||u.match(C))&&x({light:C})})||N6,E=O?.subscribe(C=>{(!C||u.match(C))&&x({dark:C})})||N6;return()=>{_(),P(),E()}}},[x,k,u,t,o,d,h,f,O]),{...g,mode:v?g.mode:void 0,systemMode:v?g.systemMode:void 0,colorScheme:v?w:void 0,setMode:k,setColorScheme:x}}const Dlt="*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}";function Nlt(e){const{themeId:t,theme:n={},modeStorageKey:r=EZ,colorSchemeStorageKey:i=QZ,disableTransitionOnChange:s=!1,defaultColorScheme:a,resolveTheme:o}=e,l={allColorSchemes:[],colorScheme:void 0,darkColorScheme:void 0,lightColorScheme:void 0,mode:void 0,setColorScheme:()=>{},setMode:()=>{},systemMode:void 0},c=b.createContext(void 0),u=()=>b.useContext(c)||l,d={},h={};function f(v){const{children:y,theme:w,modeStorageKey:k=r,colorSchemeStorageKey:x=i,disableTransitionOnChange:S=s,storageManager:T,storageWindow:_=typeof window>"u"?void 0:window,documentNode:P=typeof document>"u"?void 0:document,colorSchemeNode:E=typeof document>"u"?void 0:document.documentElement,disableNestedContext:C=!1,disableStyleSheetGeneration:Q=!1,defaultMode:D="system",noSsr:F}=v,I=b.useRef(!1),U=CZ(),q=b.useContext(c),Z=!!q&&!C,W=b.useMemo(()=>w||(typeof n=="function"?n():n),[w]),M=W[t],J=M||W,{colorSchemes:L=d,components:N=h,cssVarPrefix:z}=J,V=Object.keys(L).filter(Re=>!!L[Re]).join(","),ee=b.useMemo(()=>V.split(","),[V]),oe=typeof a=="string"?a:a.light,ie=typeof a=="string"?a:a.dark,he=L[oe]&&L[ie]?D:L[J.defaultColorScheme]?.palette?.mode||J.palette?.mode,{mode:te,setMode:pe,systemMode:B,lightColorScheme:Ce,darkColorScheme:Qe,colorScheme:Fe,setColorScheme:Oe}=Alt({supportedColorSchemes:ee,defaultLightColorScheme:oe,defaultDarkColorScheme:ie,modeStorageKey:k,colorSchemeStorageKey:x,defaultMode:he,storageManager:T,storageWindow:_,noSsr:F});let ye=te,_e=Fe;Z&&(ye=q.mode,_e=q.colorScheme);const Ge=b.useMemo(()=>{const Re=_e||J.defaultColorScheme,Tt=J.generateThemeVars?.()||J.vars,Te={...J,components:N,colorSchemes:L,cssVarPrefix:z,vars:Tt};if(typeof Te.generateSpacing=="function"&&(Te.spacing=Te.generateSpacing()),Re){const ze=L[Re];ze&&typeof ze=="object"&&Object.keys(ze).forEach(et=>{ze[et]&&typeof ze[et]=="object"?Te[et]={...Te[et],...ze[et]}:Te[et]=ze[et]})}return o?o(Te):Te},[J,_e,N,L,z]),tt=J.colorSchemeSelector;blt(()=>{if(_e&&E&&tt&&tt!=="media"){const Re=tt;let Tt=tt;if(Re==="class"&&(Tt=".%s"),Re==="data"&&(Tt="[data-%s]"),Re?.startsWith("data-")&&!Re.includes("%s")&&(Tt=`[${Re}="%s"]`),Tt.startsWith("."))E.classList.remove(...ee.map(Te=>Tt.substring(1).replace("%s",Te))),E.classList.add(Tt.substring(1).replace("%s",_e));else{const Te=Tt.replace("%s",_e).match(/\[([^\]]+)\]/);if(Te){const[ze,et]=Te[1].split("=");et||ee.forEach(Dt=>{E.removeAttribute(ze.replace(_e,Dt))}),E.setAttribute(ze,et?et.replace(/"|'/g,""):"")}else E.setAttribute(Tt,_e)}}},[_e,tt,E,ee]),b.useEffect(()=>{let Re;if(S&&I.current&&P){const Tt=P.createElement("style");Tt.appendChild(P.createTextNode(Dlt)),P.head.appendChild(Tt),window.getComputedStyle(P.body),Re=setTimeout(()=>{P.head.removeChild(Tt)},1)}return()=>{clearTimeout(Re)}},[_e,S,P]),b.useEffect(()=>(I.current=!0,()=>{I.current=!1}),[]);const Lt=b.useMemo(()=>({allColorSchemes:ee,colorScheme:_e,darkColorScheme:Qe,lightColorScheme:Ce,mode:ye,setColorScheme:Oe,setMode:pe,systemMode:B}),[ee,_e,Qe,Ce,ye,Oe,pe,B,Ge.colorSchemeSelector]);let Qt=!0;(Q||J.cssVariables===!1||Z&&U?.cssVarPrefix===z)&&(Qt=!1);const an=p.jsxs(b.Fragment,{children:[p.jsx(wCe,{themeId:M?t:void 0,theme:Ge,children:y}),Qt&&p.jsx(mlt,{styles:Ge.generateStyleSheets?.()||[]})]});return Z?an:p.jsx(c.Provider,{value:Lt,children:an})}const O=typeof a=="string"?a:a.light,g=typeof a=="string"?a:a.dark;return{CssVarsProvider:f,useColorScheme:u,getInitColorSchemeScript:v=>Clt({colorSchemeStorageKey:i,defaultLightColorScheme:O,defaultDarkColorScheme:g,modeStorageKey:r,...v})}}function X6({theme:e,...t}){const n=n1 in e?e[n1]:void 0;return p.jsx(wCe,{...t,themeId:n?n1:void 0,theme:n||e})}const lC={colorSchemeStorageKey:"mui-color-scheme",defaultLightColorScheme:"light",defaultDarkColorScheme:"dark",modeStorageKey:"mui-mode"},{CssVarsProvider:Xlt}=Nlt({themeId:n1,theme:()=>yZe({cssVariables:!0}),colorSchemeStorageKey:lC.colorSchemeStorageKey,modeStorageKey:lC.modeStorageKey,defaultColorScheme:{light:lC.defaultLightColorScheme,dark:lC.defaultDarkColorScheme},resolveTheme:e=>{const t={...e,typography:bZe(e.palette,e.typography)};return t.unstable_sx=function(r){return wZe({sx:r,theme:this})},t}}),Ilt=Xlt;function Flt({theme:e,...t}){if(typeof e=="function")return p.jsx(X6,{theme:e,...t});const n=n1 in e?e[n1]:e;return"colorSchemes"in n?p.jsx(Ilt,{theme:e,...t}):"vars"in n?p.jsx(X6,{theme:e,...t}):p.jsx(X6,{theme:{...e,vars:null},...t})}const cC=e=>({isRunPanelOpen:e==="isRunPanelOpen",isCanvasOpen:e==="isCanvasOpen",isBrowserPaneOpen:e==="isBrowserPaneOpen"}),qse=800,zse=280,Hz=420,Use=640,bn=po()(jd(e=>({isCommandPaletteOpen:!1,commandPaletteQuery:"",isSidebarCollapsed:!1,showAgentReasoning:!1,themeName:xZe,canvasWidth:qse,chatSidebarWidth:zse,isCanvasOpen:!1,isRunPanelOpen:!1,isBrowserPaneOpen:!1,runPanelReveal:null,runPanelWidth:Hz,browserPanelWidth:Use,browserPaneScope:"conversation",isCreateAgentDialogOpen:!1,openCreateAgentDialog:()=>{e({isCreateAgentDialogOpen:!0})},closeCreateAgentDialog:()=>{e({isCreateAgentDialogOpen:!1})},openCommandPalette:()=>{e({isCommandPaletteOpen:!0})},closeCommandPalette:()=>{e({isCommandPaletteOpen:!1,commandPaletteQuery:""})},toggleCommandPalette:()=>{e(t=>({isCommandPaletteOpen:!t.isCommandPaletteOpen,commandPaletteQuery:t.isCommandPaletteOpen?t.commandPaletteQuery:""}))},setCommandPaletteQuery:t=>{e({commandPaletteQuery:t})},toggleSidebar:()=>{e(t=>({isSidebarCollapsed:!t.isSidebarCollapsed}))},setSidebarCollapsed:t=>{e({isSidebarCollapsed:t})},setShowAgentReasoning:t=>{e({showAgentReasoning:t})},setTheme:t=>{e({themeName:t})},setCanvasOpen:t=>{e(t?cC("isCanvasOpen"):{isCanvasOpen:!1})},setRunPanelOpen:t=>{e(t?cC("isRunPanelOpen"):{isRunPanelOpen:!1})},setBrowserPaneOpen:t=>{e(t?cC("isBrowserPaneOpen"):{isBrowserPaneOpen:!1})},setBrowserPanelWidth:t=>{e({browserPanelWidth:t})},restoreDefaultBrowserPanelWidth:()=>{e({browserPanelWidth:Use})},setBrowserPaneScope:t=>{e({browserPaneScope:t})},revealRunPanelSection:t=>{e(n=>({...cC("isRunPanelOpen"),runPanelReveal:{section:t,nonce:(n.runPanelReveal?.nonce??0)+1}}))},clearRunPanelReveal:t=>{e(n=>n.runPanelReveal?.nonce===t?{runPanelReveal:null}:{})},setRunPanelWidth:t=>{e({runPanelWidth:t})},restoreDefaultRunPanelWidth:()=>{e({runPanelWidth:Hz})},setCanvasWidth:t=>{e({canvasWidth:t})},setChatSidebarWidth:t=>{e({chatSidebarWidth:Math.min(360,Math.max(240,t))})},restoreDefaultCanvasWidth:()=>{e({canvasWidth:qse})},restoreDefaultChatSidebarWidth:()=>{e({chatSidebarWidth:zse})}}),{name:"ui-preferences-storage",partialize:e=>{const{runPanelReveal:t,...n}=e;return n}})),Mlt=16,jlt=64,Llt=200;let m0=null;const qlt=()=>{m0||(m0=document.createElement("div"),Object.assign(m0.style,{position:"fixed",top:"0",left:"0",width:"100vw",height:"100vh",cursor:"col-resize",zIndex:"9999"}),document.body.appendChild(m0))},zlt=()=>{m0&&(document.body.removeChild(m0),m0=null)},jQ=({sidebarWidth:e,onSidebarWidthChange:t,minWidth:n=180,maxWidth:r=600,side:i="right",onDoubleClick:s,label:a})=>{const[o,l]=b.useState(!1),[c,u]=b.useState(!1),d=b.useRef(!1),h=b.useRef(null);b.useEffect(()=>()=>{h.current&&clearTimeout(h.current)},[]);const f=y=>Math.max(n,Math.min(r,y)),O=y=>{t(f(e+(i==="right"?y:-y)))},g=y=>{const w=y.shiftKey?jlt:Mlt;switch(y.key){case"ArrowLeft":y.preventDefault(),O(-w);return;case"ArrowRight":y.preventDefault(),O(w);return;case"Home":y.preventDefault(),t(i==="right"?n:r);return;case"End":y.preventDefault(),t(i==="right"?r:n);return;case"Enter":s&&(y.preventDefault(),s());return}},m=y=>{y.preventDefault(),d.current=!0,u(!0);const w=y.clientX,k=e;document.body.style.userSelect="none",qlt();const x=T=>{if(!d.current)return;const _=T.clientX-w,P=i==="right"?k+_:k-_;t(f(P))},S=()=>{d.current&&(d.current=!1,u(!1),l(!1),document.body.style.userSelect="",zlt(),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",S),window.removeEventListener("blur",S),document.documentElement.removeEventListener("mouseleave",S))};window.addEventListener("mousemove",x),window.addEventListener("mouseup",S),window.addEventListener("blur",S),document.documentElement.addEventListener("mouseleave",S)},v=o||c;return p.jsxs("div",{className:"relative z-10 h-full w-0 shrink-0",children:[p.jsx("div",{"aria-hidden":"true",className:A("pointer-events-none absolute top-0 z-12 h-full w-0.5","transition-[opacity,background-color] duration-fast ease-out-quart",i==="left"?"left-0":"right-0",c?"bg-accent":"bg-control",v?"opacity-100":"opacity-0")}),p.jsx("div",{role:"separator","aria-label":a,"aria-orientation":"vertical","aria-valuenow":Math.round(e),"aria-valuemin":n,"aria-valuemax":r,tabIndex:0,className:A("absolute top-0 z-11 h-full w-3 cursor-col-resize touch-none",i==="left"?"-left-1.5":"-right-1.5"),onMouseEnter:()=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>l(!0),Llt)},onMouseLeave:()=>{h.current&&clearTimeout(h.current),d.current||l(!1)},onFocus:()=>l(!0),onBlur:()=>{d.current||l(!1)},onKeyDown:g,onMouseDown:m,onDoubleClick:s})]})},Ult=({sidebar:e,content:t})=>{const n=bn(a=>a.chatSidebarWidth),r=Number.isFinite(n)?Math.min(360,Math.max(240,n)):280,i=bn(a=>a.setChatSidebarWidth),s=bn(a=>a.restoreDefaultChatSidebarWidth);return p.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[p.jsx("div",{className:"h-full shrink-0",style:{width:r},children:e}),p.jsx(jQ,{sidebarWidth:r,onSidebarWidthChange:i,minWidth:240,maxWidth:360,onDoubleClick:s,label:"Resize chat sidebar"}),p.jsx("div",{className:"h-full grow overflow-hidden",children:t})]})},Db=({open:e,onClose:t,autoHideDuration:n,variant:r="info",role:i,action:s,children:a})=>{if(b.useEffect(()=>{if(!e||n===void 0)return;const l=window.setTimeout(t,n);return()=>window.clearTimeout(l)},[e,n,t]),!e)return null;const o=i??(r==="danger"||r==="warning"?"alert":"status");return p.jsxs("div",{className:"fixed right-4 bottom-4 z-50 w-100 max-w-[calc(100vw-2rem)]",children:[p.jsxs(Ml,{variant:r,role:o,className:"relative pr-10 shadow-overlay",children:[a,s?p.jsx("div",{className:"flex justify-end gap-2 pt-1",children:s}):null]}),p.jsx(we,{variant:"ghost",size:"icon-sm",onClick:t,"aria-label":"Dismiss",className:"absolute top-1.5 right-1.5",children:p.jsx(Qi,{})})]})};Db.displayName="FloatingAlert";const Wlt=48*60*60*1e3;var wb=(e=>(e.UI="ui",e.BACKEND="backend",e))(wb||{});const Glt=po()(jd((e,t)=>({uiDeferredVersion:null,uiDeferredAt:null,backendDeferredVersion:null,backendDeferredAt:null,hydrated:!1,deferUpdate:(n,r)=>{e(n==="ui"?{uiDeferredVersion:r,uiDeferredAt:Date.now()}:{backendDeferredVersion:r,backendDeferredAt:Date.now()})},shouldShowUpdate:(n,r)=>{const{uiDeferredVersion:i,uiDeferredAt:s,backendDeferredVersion:a,backendDeferredAt:o}=t();let l,c;return n==="ui"?(l=i,c=s):(l=a,c=o),!l||!c||l!==r?!0:Date.now()-c>Wlt},clearDeferredUpdate:n=>{if(n==="ui")e({uiDeferredVersion:null,uiDeferredAt:null});else if(n==="backend")e({backendDeferredVersion:null,backendDeferredAt:null});else throw new Error(`Invalid update type: ${n}`)}}),{name:"deferred-updates-storage",onRehydrateStorage:()=>e=>{e&&typeof e=="object"&&"setState"in e&&typeof e.setState=="function"&&e.setState({hydrated:!0})}})),Wse=/^Error invoking remote method '[^']+':\s*/;function RZ(e){let n=(e instanceof Error?e.message:String(e)).trim();for(;Wse.test(n);)n=n.replace(Wse,"").trim();return n}const I6="The app could not reach the update server. Check this machine's connection, then try again.",Gse={download:"The update could not be downloaded. Check this machine's connection, then start the download again.",install:"The update could not be installed. Check this machine's connection, then start it again from the update panel.",quit:"The app could not quit to finish the install. Quit the app yourself, then let the update finish."},Vlt="The update check could not finish. The app will try again at its next check.",Blt=72,Ylt=400,SCe=/https?:\/\/|\b(?:net::)?(?:ERR_[A-Z0-9_]+|[A-Z]{2,}_[A-Z_]+)\b|\bE[A-Z]{3,}\b|HttpError|(?:\b[45]\d\d\s+[A-Z][a-z]|:\s*[45]\d\d\b)/,Zlt=/^(Error downloading update|Error starting the update|Error quitting for the update)\b/i;function Hlt(e){switch(Zlt.exec(e)?.[1]?.toLowerCase()){case"error downloading update":return"download";case"error starting the update":return"install";case"error quitting for the update":return"quit";default:return null}}const Klt=[],Jlt=/[:\uff1a\u2014]+$/,ect=/\s+/;function $Ce(e){const t=eD(e).trim(),n=Hlt(t),r=Y2e(t);if(r===null)return nct(t)?{sentence:t,detail:null,action:null}:{sentence:n===null?Vlt:Gse[n],detail:t===""?null:t,action:null};const i=tct(r);if(n!==null)return{sentence:Gse[n],detail:i,action:null};const s="check";if(!r.clause)return{sentence:I6,detail:i,action:s};const a=t.slice(0,r.start),o=t.slice(r.end).trim();return!Vse(a)||o!==""&&!Vse(o)?{sentence:I6,detail:i,action:s}:{sentence:`${a}${I6}${t.slice(r.end)}`,detail:i,action:s}}function tct(e){if(e.code.startsWith("net::"))return e.code;const t=e.clauseText.trim();return t===""||t===e.code?null:t}function Vse(e){const t=e.trim().replace(Jlt,"").trim();return t===""?!0:t.includes(`
779
- `)||t.length>Blt||SCe.test(t)?!1:Klt.includes(t.toLowerCase())}function nct(e){const t=e.trim();return t===""||t.length>Ylt||SCe.test(t)?!1:t.split(ect).length>=4}function AZ(e){return $Ce(e).sentence}function If(e){return eD(RZ(e))}const rct=/cannot find .* in the latest release artifacts/i;function Bse(e){return rct.test(e)?"muted":"show"}const Kz=5e3,kCe=()=>({firstNegativeAt:null});function F6(e,t){return t.isOnline?{state:kCe(),report:!1}:e.firstNegativeAt===null?{state:{firstNegativeAt:t.at},report:!1}:{state:e,report:t.at-e.firstNegativeAt>=Kz}}function ict(e,t){return e.firstNegativeAt===null?Kz:Math.max(0,e.firstNegativeAt+Kz-t)}const sct=({autoCheck:e=!0})=>{const{hostingProvider:t,shouldCheckInternet:n,isOnline:r,hasConnectivityIssue:i,connectivityIssue:s,serverSnapshot:a,refetchServerStatus:o,refetchInternetStatus:l}=nCe(),[c,u]=b.useState(!1),d=b.useRef(kCe()),[h,f]=b.useState(!1);b.useEffect(()=>{(!i||s!=="internet_offline")&&u(!1)},[i,s]),b.useEffect(()=>{const x=()=>F6(d.current,{isOnline:navigator.onLine,at:Date.now()}),S=()=>{const T=x();d.current=T.state,f(T.report)};return window.addEventListener("offline",S),window.addEventListener("online",S),()=>{window.removeEventListener("offline",S),window.removeEventListener("online",S)}},[]),b.useEffect(()=>{const x=F6(d.current,{isOnline:r,at:Date.now()});if(d.current=x.state,f(x.report),r||x.report)return;const S=window.setTimeout(()=>{l().then(T=>{const _=F6(d.current,{isOnline:T.data!==!1,at:Date.now()});d.current=_.state,f(_.report)})},ict(d.current,Date.now()));return()=>window.clearTimeout(S)},[r,l]),b.useEffect(()=>{if(e){o();const x=setInterval(()=>{o()},3e3);return()=>clearInterval(x)}},[e,o]);const O=()=>{(async()=>{try{await window.api?.backend?.reconnect?.()}finally{o(),n&&l()}})()},g=()=>{u(!0)},m=s==="internet_offline";if(!(m?h&&!c:i))return null;const y=m?null:sot(a),w=a?.reconnecting===!0,k=m||w||a?.state==="wedged"?"warning":"danger";return p.jsx("div",{className:"fixed inset-x-0 top-0 z-2200 w-full",children:p.jsx(Ml,{variant:k,role:"alert",className:"items-center rounded-none border-x-0 border-t-0",children:p.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[p.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[p.jsx(rT,{children:m?`You are offline. ${t?`Your configured hosting provider (${t}) requires`:"This app's updates require"} an internet connection.`:y?.title??"A connectivity issue has been detected."}),!m&&y?.detail?p.jsx(rT,{children:y.detail}):null]}),p.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[p.jsx(we,{variant:"ghost",size:"sm",onClick:O,children:"Retry"}),m&&p.jsx(we,{variant:"ghost",size:"sm","aria-label":"dismiss",onClick:g,children:"Dismiss"})]})]})})})},Tr=re.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/),uC=re.string().min(1).max(256).regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/),dC=re.string().min(1).max(32768),Wr=re.string().regex(/^[a-f0-9]{12}$/),TCe=/^[a-f0-9]{32}$/,Zs=re.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/),Yse=re.object({data_b64:re.string().min(1).max(1e6),mime_type:re.enum(["image/png","image/jpeg","image/gif","image/webp"])}).strict(),Rg=2e5,VP=256,_Ce=100,Jz=1e6,Kf=re.string().min(1).max(128).refine(e=>e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\")&&[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127)),Zse=re.object({kind:re.enum(["agent","team"]),name:Kf}).strict(),Hse=re.object({provider:re.string().min(1).max(128),model_id:re.string().min(1).max(512),reasoning_effort:re.string().min(1).max(64).nullable()}).strict(),Kse=re.object({kind:re.enum(["role","specialist"]).optional(),description:re.string().max(8e3).optional(),instructions:re.string().max(8e3).optional(),tools:re.array(re.string().min(1).max(128)).max(256).optional(),effort:re.string().max(64).optional(),delegate:re.boolean().optional()}).strict(),Jse=re.object({name:re.string().min(1).max(64).optional(),description:re.string().max(8e3).optional(),manager:Kf.optional(),members:re.array(re.object({role:Kf,count:re.number().int().min(1).max(16),kind:re.enum(["agent","team"])}).strict()).max(128).optional(),instructions:re.string().max(8e3).optional(),project:re.string().max(8e3).optional()}).strict(),act=re.record(re.array(re.string().max(1024)).max(100)),eae=re.enum(["minutes","hours","days"]);function oct(e){return!/^\.+$/.test(e)}const PCe=e=>LQ.safeParse(e).success,LQ=re.string().min(1).max(128).refine(e=>[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127&&t!=="/"&&t!=="\\")).refine(oct),tae=re.enum(["str","int","float","bool","list","dict"]),nae=re.string().max(16384),rae=re.object({is_active:re.boolean().nullish(),one_time:re.boolean().nullish(),start_time_utc:re.string().max(64).nullish(),end_time_utc:re.string().max(64).nullish()}).strict(),lct=re.object({conversation_length:re.number().int().optional(),detail_length:re.number().int().optional(),max_learnings_history:re.number().int().optional(),hosting:re.string().max(256).optional(),model_name:re.string().max(1024).optional(),auto_save_conversation:re.boolean().optional()}).strict();re.discriminatedUnion("op",[re.object({op:re.literal("capabilities")}).strict(),re.object({op:re.literal("profiles.list")}).strict(),re.object({op:re.literal("profiles.get"),name:Kf}).strict(),re.object({op:re.literal("profiles.install"),name:Kf,requestId:Zs}).strict(),re.object({op:re.literal("profiles.create"),name:Kf,requestId:Zs,fields:Kse.extend({description:re.string().max(8e3),instructions:re.string().min(1).max(8e3)})}).strict(),re.object({op:re.literal("profiles.update"),name:Kf,requestId:Zs,fields:Kse}).strict(),re.object({op:re.literal("teams.list")}).strict(),re.object({op:re.literal("teams.get"),name:Kf}).strict(),re.object({op:re.literal("teams.create"),requestId:Zs,fields:Jse.extend({name:re.string().min(1).max(64)})}).strict(),re.object({op:re.literal("teams.update"),name:Kf,requestId:Zs,fields:Jse}).strict(),re.object({op:re.literal("sessions.list"),limit:re.number().int().min(1).max(500).optional()}).strict(),re.object({op:re.literal("sessions.search"),q:re.string().min(1).max(VP),limit:re.number().int().min(1).max(500).optional()}).strict(),re.object({op:re.literal("sessions.create"),requestId:Zs,cwd:re.string().min(1).max(4096),target:Zse.optional(),model:Hse.optional()}).strict(),re.object({op:re.literal("sessions.preview"),requestId:Zs,cwd:re.string().min(1).max(4096),target:Zse.optional(),model:Hse.optional()}).strict(),re.object({op:re.literal("sessions.get"),sessionId:Wr}).strict(),re.object({op:re.literal("sessions.history"),sessionId:Wr,beforeId:Tr.optional(),limit:re.number().int().min(1).max(500).optional()}).strict(),re.object({op:re.literal("subagents.transcript"),sessionId:Wr,childId:Wr,beforeId:Tr.optional(),limit:re.number().int().min(1).max(500).optional()}).strict(),re.object({op:re.literal("sessions.message"),sessionId:Wr,requestId:Zs,text:re.string().max(Rg),images:re.array(Yse).max(8).optional(),mode:re.enum(["prompt","steer"]).optional()}).strict(),re.object({op:re.literal("sessions.command"),sessionId:Wr,requestId:Zs,command:re.string().regex(/^\/?[A-Za-z]+$/).max(64),args:re.string().max(Rg).optional(),images:re.array(Yse).max(8).optional()}).strict(),re.object({op:re.literal("sessions.move"),sessionId:Wr,requestId:Zs,cwd:re.string().min(1).max(4096)}).strict(),re.object({op:re.literal("sessions.answer"),sessionId:Wr,epoch:Tr,requestId:Tr,value:re.string().max(32768).optional(),approved:re.boolean().optional(),questionIndex:re.number().int().min(0).optional()}).strict(),re.object({op:re.literal("sessions.seen"),sessionId:Wr,completionToken:re.string().uuid()}).strict(),re.object({op:re.literal("sessions.notified"),sessionId:Wr,completionToken:re.string().uuid()}).strict(),re.object({op:re.literal("sessions.watch"),sessionId:Wr,subscriptionId:re.string().regex(TCe),visible:re.boolean(),canNotify:re.boolean()}).strict(),re.object({op:re.literal("sessions.warm"),sessionId:Wr}).strict(),re.object({op:re.literal("sessions.interrupt"),sessionId:Wr,requestId:Zs}).strict(),re.object({op:re.literal("sessions.variables.list"),sessionId:Wr}).strict(),re.object({op:re.literal("sessions.variables.create"),sessionId:Wr,key:LQ,value:nae,type:tae}).strict(),re.object({op:re.literal("sessions.variables.update"),sessionId:Wr,key:LQ,value:nae,type:tae}).strict(),re.object({op:re.literal("sessions.variables.delete"),sessionId:Wr,key:LQ}).strict(),re.object({op:re.literal("sessions.presence"),subscriptionId:re.string().regex(/^[a-f0-9]{1,64}$/),canNotify:re.boolean(),canNotifyKinds:re.array(re.enum(["complete","error"])).max(4),sessionId:re.string().regex(/^([a-f0-9]{12})?$/),window:re.object({exists:re.boolean(),focused:re.boolean(),visible:re.boolean(),minimized:re.boolean()}).strict()}).strict(),re.object({op:re.literal("legacy.models"),provider:re.string().max(128).optional(),sort:re.enum(["id","name","provider","recommended"]).optional(),direction:re.enum(["ascending","descending"]).optional()}).strict(),re.object({op:re.literal("legacy.models.providers")}).strict(),re.object({op:re.literal("auth.probe"),provider:Tr}).strict(),re.object({op:re.literal("legacy.agent.upload"),agentId:Tr}).strict(),re.object({op:re.literal("legacy.agents.list"),page:re.number().int().min(1).optional(),perPage:re.number().int().min(1).max(500).optional(),name:re.string().max(256).optional(),sort:re.string().max(64).optional(),direction:re.enum(["asc","desc"]).optional()}).strict(),re.object({op:re.literal("legacy.agent.get"),agentId:Tr}).strict(),re.object({op:re.literal("legacy.agent.history"),agentId:Tr,page:re.number().int().min(1).optional(),perPage:re.number().int().min(1).max(500).optional()}).strict(),re.object({op:re.literal("legacy.jobs.list"),agentId:Tr.optional(),status:re.string().max(64).optional()}).strict(),re.object({op:re.literal("legacy.job.get"),jobId:Tr}).strict(),re.object({op:re.literal("legacy.schedules.list"),page:re.number().int().min(1).optional(),perPage:re.number().int().min(1).max(100).optional()}).strict(),re.object({op:re.literal("legacy.agent.schedules.list"),agentId:Tr,page:re.number().int().min(1).optional(),perPage:re.number().int().min(1).max(100).optional()}).strict(),re.object({op:re.literal("legacy.agent.schedule.create"),agentId:Tr,schedule:rae.extend({prompt:re.string().max(64e3),interval:re.number().int().min(1),unit:eae})}).strict(),re.object({op:re.literal("legacy.schedule.get"),scheduleId:Tr}).strict(),re.object({op:re.literal("legacy.schedule.edit"),scheduleId:Tr,schedule:rae.extend({prompt:re.string().max(64e3).nullish(),interval:re.number().int().min(1).nullish(),unit:eae.nullish()})}).strict(),re.object({op:re.literal("legacy.schedule.remove"),scheduleId:Tr}).strict(),re.object({op:re.literal("legacy.agent.create"),agent:re.record(re.unknown())}).strict(),re.object({op:re.literal("legacy.agent.update"),agentId:Tr,update:re.record(re.unknown())}).strict(),re.object({op:re.literal("legacy.agent.delete"),agentId:Tr}).strict(),re.object({op:re.literal("legacy.agent.conversation.clear"),agentId:Tr}).strict(),re.object({op:re.literal("legacy.agent.systemPrompt.get"),agentId:Tr}).strict(),re.object({op:re.literal("legacy.agent.systemPrompt.update"),agentId:Tr,systemPrompt:re.string().max(Jz)}).strict(),re.object({op:re.literal("legacy.agent.download"),agentId:Tr}).strict(),re.object({op:re.literal("legacy.job.cancel"),jobId:Tr}).strict(),re.object({op:re.literal("commands.list")}).strict(),re.object({op:re.literal("commands.entities"),sessionId:Wr,command:Tr,name:re.string().max(128).optional()}).strict(),re.object({op:re.literal("models.catalogue"),live:re.boolean().optional()}).strict(),re.object({op:re.literal("usage.get"),provider:Tr.optional(),live:re.boolean().optional(),refresh:re.boolean().optional()}).strict(),re.object({op:re.literal("analytics.get"),sessionId:Wr.optional(),sinceMs:re.number().int().nonnegative().optional(),untilMs:re.number().int().nonnegative().optional(),days:re.number().int().min(1).max(366).optional()}).strict(),re.object({op:re.literal("info.get")}).strict(),re.object({op:re.literal("sessions.report"),sessionId:Wr,recentLimit:re.number().int().min(0).max(50).optional()}).strict(),re.object({op:re.literal("skills.list"),sessionId:Wr,name:Tr.optional()}).strict(),re.object({op:re.literal("sessions.failovers"),sessionId:Wr}).strict(),re.object({op:re.literal("sessions.credential"),sessionId:Wr,action:re.enum(["list","store","forget"]),key:uC.optional(),value:dC.optional(),confirmed:re.boolean().optional()}).strict(),re.object({op:re.literal("sessions.fork"),sessionId:Wr,requestId:Zs,message:re.string().max(2e5).optional(),boundary:re.literal("next_safe").optional()}).strict(),re.object({op:re.literal("sessions.stop"),requestId:Zs,targets:re.array(Wr).min(1).max(100),confirmed:re.literal(!0)}).strict(),re.object({op:re.literal("sessions.aside"),sessionId:Wr,requestId:Zs,text:re.string().min(1).max(32768),asideId:Zs.optional()}).strict(),re.object({op:re.literal("sessions.adopt"),sessionId:Wr,requestId:Zs,asideId:Zs,confirmed:re.literal(!0)}).strict(),re.object({op:re.literal("sessions.aside.get"),sessionId:Wr,asideId:Zs}).strict(),re.object({op:re.literal("sessions.aside.close"),sessionId:Wr,asideId:Zs}).strict(),re.object({op:re.literal("mcp.list"),sessionId:Wr}).strict(),re.object({op:re.literal("mcp.credentials.store"),sessionId:Wr,name:re.string().min(1).max(256),values:re.record(re.string().min(1).max(128),re.string().min(1).max(32768)).refine(e=>Object.keys(e).length<=32&&Object.values(e).reduce((t,n)=>t+n.length,0)<=65536,{message:"Too many secret values, or too much secret text, for one MCP credential write."}),confirmedReplace:re.array(re.string().min(1).max(128)).max(32)}).strict(),re.object({op:re.literal("mcp.control"),sessionId:Wr,control:re.object({action:re.enum(["list","add","remove","reload","connect","probe","disconnect","login","logout","reauth","status","cancel"]),name:re.string().regex(/^[A-Za-z0-9_.:-]{1,100}$/).optional(),scope:re.enum(["global","project"]).optional(),command:re.string().min(1).max(4096).optional(),args:re.array(re.string().max(8192)).max(128).optional(),env:re.record(re.string().regex(/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/)).optional(),url:re.string().max(4096).optional(),headers:re.record(re.string().regex(/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/)).optional(),oauth:re.boolean().optional(),confirmed:re.boolean().optional(),operation_id:re.string().regex(/^[a-f0-9]{32}$/).optional()}).strict()}).strict(),re.object({op:re.literal("radient.request"),control:re.object({operation:re.enum(["account","prices","credits","usage","provision","application.create","agents.list","agents.get","agents.create","agents.update","agents.delete","agents.like","agents.unlike","agents.liked","agents.like_count","agents.favourite","agents.unfavourite","agents.favourited","agents.favourite_count","agents.download_count","comments.list","comments.create","comments.update","comments.delete","account.agents"]),request_id:Zs.optional(),tenant_id:Tr.optional(),account_id:Tr.optional(),agent_id:Tr.optional(),comment_id:Tr.optional(),query:re.record(re.union([re.string().max(1024),re.number().int()])).optional(),payload:re.record(re.unknown()).optional(),confirmed:re.boolean().optional()}).strict()}).strict(),re.object({op:re.literal("providers.list")}).strict(),re.object({op:re.literal("accounts.list")}).strict(),re.object({op:re.literal("accounts.remove"),accountId:re.number().int().positive(),confirmed:re.literal(!0)}).strict(),re.object({op:re.literal("auth.start"),provider:Tr}).strict(),re.object({op:re.literal("auth.status"),id:Tr}).strict(),re.object({op:re.literal("auth.input"),id:Tr,promptId:Tr,value:dC}).strict(),re.object({op:re.literal("auth.cancel"),id:Tr}).strict(),re.object({op:re.literal("auth.key"),provider:Tr,value:dC}).strict(),re.object({op:re.literal("auth.logout"),provider:Tr}).strict(),re.object({op:re.literal("settings.list")}).strict(),re.object({op:re.literal("settings.edit"),key:uC,value:re.unknown().refine(e=>e!==void 0,"A setting value is required."),base:act.optional()}).strict(),re.object({op:re.literal("settings.reset"),key:uC}).strict(),re.object({op:re.literal("config.get")}).strict(),re.object({op:re.literal("config.update"),value:lct}).strict(),re.object({op:re.literal("instructions.get")}).strict(),re.object({op:re.literal("instructions.update"),content:re.string().max(64e3)}).strict(),re.object({op:re.literal("credentials.list")}).strict(),re.object({op:re.literal("credentials.update"),key:uC,value:dC}).strict()]);const cct=88e4,uct=11e5,lD=cct,dct=uct;function DZ(e){switch(e.op){case"capabilities":return{path:"/v1/capabilities",method:"GET"};case"profiles.list":return{path:"/v1/desktop/profiles",method:"GET"};case"profiles.get":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"GET"};case"profiles.install":return{path:"/v1/desktop/profiles/install",method:"POST",body:{request_id:e.requestId,name:e.name}};case"profiles.create":return{path:"/v1/desktop/profiles",method:"POST",body:{request_id:e.requestId,name:e.name,...e.fields}};case"profiles.update":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields}};case"teams.list":return{path:"/v1/desktop/teams",method:"GET"};case"teams.get":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"GET"};case"teams.create":return{path:"/v1/desktop/teams",method:"POST",body:{request_id:e.requestId,...e.fields}};case"teams.update":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields}};case"sessions.list":return{path:`/v1/desktop/sessions?limit=${e.limit??100}`,method:"GET"};case"sessions.search":return{path:`/v1/desktop/sessions/search?${new URLSearchParams({q:e.q,limit:String(e.limit??_Ce)})}`,method:"GET"};case"sessions.create":return{path:"/v1/desktop/sessions",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.preview":return{path:"/v1/desktop/sessions/preview",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.get":return{path:`/v1/desktop/sessions/${e.sessionId}`,method:"GET"};case"sessions.history":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),{path:`/v1/desktop/sessions/${e.sessionId}/history?${t}`,method:"GET"}}case"subagents.transcript":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),{path:`/v1/desktop/sessions/${e.sessionId}/children/${e.childId}/transcript?${t}`,method:"GET"}}case"sessions.message":return{path:`/v1/desktop/sessions/${e.sessionId}/messages`,method:"POST",body:{request_id:e.requestId,text:e.text,images:e.images??[],mode:e.mode??"prompt"}};case"sessions.command":return{path:`/v1/desktop/sessions/${e.sessionId}/commands`,method:"POST",body:{request_id:e.requestId,command:e.command,args:e.args??"",images:e.images??[]}};case"sessions.answer":return{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{epoch:e.epoch,request_id:e.requestId,value:e.value,approved:e.approved,question_index:e.questionIndex}};case"sessions.seen":return{path:`/v1/desktop/sessions/${e.sessionId}/seen`,method:"POST",body:{completion_token:e.completionToken}};case"sessions.notified":return{path:`/v1/desktop/sessions/${e.sessionId}/notified`,method:"POST",body:{completion_token:e.completionToken}};case"sessions.watch":return{path:`/v1/desktop/sessions/${e.sessionId}/watch`,method:"POST",body:{subscription_id:e.subscriptionId,visible:e.visible,can_notify:e.canNotify}};case"sessions.presence":return{path:"/v1/desktop/presence",method:"POST",body:{subscription_id:e.subscriptionId,can_notify_kinds:e.canNotifyKinds,session_id:e.sessionId,window:e.window,can_notify:e.canNotify}};case"sessions.move":return{path:`/v1/desktop/sessions/${e.sessionId}/working-directory`,method:"POST",body:{request_id:e.requestId,cwd:e.cwd}};case"sessions.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/warm`,method:"POST",body:{}};case"sessions.interrupt":return{path:`/v1/desktop/sessions/${e.sessionId}/interrupt`,method:"POST",body:{request_id:e.requestId}};case"sessions.variables.list":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"GET"};case"sessions.variables.create":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"POST",body:{key:e.key,value:e.value,type:e.type}};case"sessions.variables.update":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"PATCH",body:{value:e.value,type:e.type}};case"sessions.variables.delete":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"DELETE"};case"legacy.models":{const t=new URLSearchParams;return e.provider&&t.set("provider",e.provider),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:t.size>0?`/v1/models?${t}`:"/v1/models",method:"GET"}}case"legacy.models.providers":return{path:"/v1/models/providers",method:"GET"};case"auth.probe":return{path:`/v1/auth/providers/${e.provider}/probe`,method:"POST"};case"legacy.agent.upload":return{path:`/v1/agents/${e.agentId}/upload`,method:"POST"};case"legacy.agents.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return e.name&&t.set("name",e.name),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:`/v1/agents?${t}`,method:"GET"}}case"legacy.agent.get":return{path:`/v1/agents/${e.agentId}`,method:"GET"};case"legacy.agent.history":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/history?${t}`,method:"GET"}}case"legacy.jobs.list":{const t=new URLSearchParams;return e.agentId&&t.set("agent_id",e.agentId),e.status&&t.set("status",e.status),{path:t.size>0?`/v1/jobs?${t}`:"/v1/jobs",method:"GET"}}case"legacy.job.get":return{path:`/v1/jobs/${e.jobId}`,method:"GET"};case"legacy.schedules.list":return{path:`/v1/schedules?${new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)})}`,method:"GET"};case"legacy.agent.schedules.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/schedules?${t}`,method:"GET"}}case"legacy.agent.schedule.create":return{path:`/v1/agents/${e.agentId}/schedules`,method:"POST",body:e.schedule};case"legacy.schedule.get":return{path:`/v1/schedules/${e.scheduleId}`,method:"GET"};case"legacy.schedule.edit":return{path:`/v1/schedules/${e.scheduleId}`,method:"PATCH",body:e.schedule};case"legacy.schedule.remove":return{path:`/v1/schedules/${e.scheduleId}`,method:"DELETE"};case"legacy.agent.create":return{path:"/v1/agents",method:"POST",body:e.agent};case"legacy.agent.update":return{path:`/v1/agents/${e.agentId}`,method:"PATCH",body:e.update};case"legacy.agent.delete":return{path:`/v1/agents/${e.agentId}`,method:"DELETE"};case"legacy.agent.conversation.clear":return{path:`/v1/agents/${e.agentId}/conversation`,method:"DELETE"};case"legacy.agent.systemPrompt.get":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"GET"};case"legacy.agent.systemPrompt.update":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"PUT",body:{system_prompt:e.systemPrompt}};case"legacy.agent.download":return{path:`/v1/agents/${e.agentId}/download`,method:"GET"};case"legacy.job.cancel":return{path:`/v1/jobs/${e.jobId}`,method:"DELETE"};case"commands.list":return{path:"/v1/desktop/commands",method:"GET"};case"commands.entities":return{path:`/v1/desktop/sessions/${e.sessionId}/command-entities?command=${encodeURIComponent(e.command)}${e.name?`&name=${encodeURIComponent(e.name)}`:""}`,method:"GET"};case"models.catalogue":return{path:`/v1/desktop/models?live=${e.live??!1}`,method:"GET"};case"usage.get":{const t=new URLSearchParams({live:String(e.live??!1),refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),{path:`/v1/desktop/usage?${t}`,method:"GET"}}case"analytics.get":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics?${t}`,method:"GET"}}case"info.get":return{path:"/v1/desktop/info",method:"GET"};case"sessions.report":{const t=new URLSearchParams({recent_limit:String(e.recentLimit??12)});return{path:`/v1/desktop/sessions/${e.sessionId}/report?${t}`,method:"GET"}}case"skills.list":return{path:`/v1/desktop/skills?session_id=${e.sessionId}${e.name?`&name=${encodeURIComponent(e.name)}`:""}`,method:"GET"};case"sessions.failovers":return{path:`/v1/desktop/sessions/${e.sessionId}/failovers`,method:"GET"};case"sessions.credential":return{path:`/v1/desktop/sessions/${e.sessionId}/credentials`,method:"POST",body:{action:e.action,key:e.key,value:e.value,confirmed:e.confirmed}};case"sessions.fork":return{path:`/v1/desktop/sessions/${e.sessionId}/fork`,method:"POST",body:{request_id:e.requestId,message:e.message,boundary:e.boundary}};case"sessions.stop":return{path:"/v1/desktop/stop",method:"POST",body:{request_id:e.requestId,targets:e.targets,confirmed:e.confirmed}};case"sessions.aside":return{path:`/v1/desktop/sessions/${e.sessionId}/asides`,method:"POST",body:{request_id:e.requestId,text:e.text,aside_id:e.asideId}};case"sessions.adopt":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}/adopt`,method:"POST",body:{request_id:e.requestId,confirmed:e.confirmed}};case"sessions.aside.get":case"sessions.aside.close":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}`,method:e.op==="sessions.aside.get"?"GET":"DELETE"};case"mcp.list":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"GET"};case"mcp.credentials.store":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp/credentials`,method:"POST",body:{name:e.name,values:e.values,confirmed_replace:e.confirmedReplace}};case"mcp.control":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"POST",body:e.control};case"radient.request":return{path:"/v1/desktop/radient",method:"POST",body:e.control};case"providers.list":return{path:"/v1/auth/providers",method:"GET"};case"accounts.list":return{path:"/v1/auth/status",method:"GET"};case"accounts.remove":return{path:`/v1/auth/accounts/${e.accountId}`,method:"DELETE"};case"auth.start":return{path:"/v1/auth/login",method:"POST",body:{provider:e.provider}};case"auth.status":return{path:`/v1/auth/operations/${e.id}`,method:"GET"};case"auth.input":return{path:`/v1/auth/operations/${e.id}/input`,method:"POST",body:{prompt_id:e.promptId,value:e.value}};case"auth.cancel":return{path:`/v1/auth/operations/${e.id}`,method:"DELETE"};case"auth.key":return{path:`/v1/auth/providers/${e.provider}/key`,method:"PUT",body:{value:e.value}};case"auth.logout":return{path:`/v1/auth/providers/${e.provider}/credentials`,method:"DELETE"};case"settings.list":return{path:"/v1/settings",method:"GET"};case"settings.edit":return{path:`/v1/settings/${e.key}`,method:"PATCH",body:{value:e.value,base:e.base}};case"settings.reset":return{path:`/v1/settings/${e.key}/reset`,method:"POST"};case"config.get":return{path:"/v1/config",method:"GET"};case"config.update":return{path:"/v1/config",method:"PATCH",body:e.value};case"instructions.get":return{path:"/v1/config/system-prompt",method:"GET"};case"instructions.update":return{path:"/v1/config/system-prompt",method:"PATCH",body:{content:e.content}};case"credentials.list":return{path:"/v1/credentials",method:"GET"};case"credentials.update":return{path:"/v1/credentials",method:"PATCH",body:{key:e.key,value:e.value}}}}const iae=64,sae=64*1024*1024,NZ="000000000000",XZ="00000000-0000-0000-0000-000000000000";function eU(e,t){const n=DZ({op:"sessions.message",sessionId:NZ,requestId:XZ,text:e,images:t,mode:"prompt"});return new TextEncoder().encode(JSON.stringify(n.body)).length}function M6(e){return e>=999500?`${(e/1e6).toFixed(1)} MB`:`${Math.round(e/1e3)} KB`}function ET(e,t){const n=M6(e);if(n!==M6(t))return[n,M6(t)];const r=n.endsWith("MB"),i=r?1e6:1e3,s=r?"MB":"KB";for(const a of[2,3]){const o=(e/i).toFixed(a),l=(t/i).toFixed(a);if(o!==l)return[`${o} ${s}`,`${l} ${s}`]}return[`${e.toLocaleString()} bytes`,`${t.toLocaleString()} bytes`]}function hct(e,t,n=lD){if(t.length>Rg)return`This command is ${t.length.toLocaleString()} characters, more than the ${Rg.toLocaleString()} one command can carry. Shorten it, or put the text in a message instead.`;const r=DZ({op:"sessions.command",sessionId:NZ,requestId:XZ,command:e,args:t}),i=new TextEncoder().encode(JSON.stringify(r.body)).length;if(i<=n)return null;const[s,a]=ET(i,n);return`This command is ${s}, more than the ${a} one command can carry. Shorten it, or put the text in a message instead.`}function Orr(e,t=dct){if(e.length>Jz)return`This system prompt is ${e.length.toLocaleString()} characters, more than the ${Jz.toLocaleString()} one agent can carry. Shorten it.`;const n=new TextEncoder().encode(JSON.stringify({system_prompt:e})).length;if(n<=t)return null;const[r,i]=ET(n,t);return`This system prompt is ${r}, more than the ${i} one agent can carry. Shorten it.`}function fct(e,t=lD){if(e.length>Rg)return`This first message is ${e.length.toLocaleString()} characters, more than the ${Rg.toLocaleString()} one message can carry. Shorten it, or send it in the new conversation instead.`;const n=DZ({op:"sessions.fork",sessionId:NZ,requestId:XZ,message:e,boundary:"next_safe"}),r=new TextEncoder().encode(JSON.stringify(n.body)).length;if(r<=t)return null;const[i,s]=ET(r,t);return`This first message is ${i}, more than the ${s} one message can carry. Shorten it, or send it in the new conversation instead.`}function pct(e,t,n=lD){if(e.length>Rg)return`This message is ${e.length.toLocaleString()} characters, more than the ${Rg.toLocaleString()} one message can carry. Split it across two messages.`;const r=eU(e,t);if(r<=n)return null;const i=eU(e,[]),s=r-i;if(t.length&&s>=i){const[l,c]=ET(s,n);return`These images total ${l}, more than the ${c} one message can carry. Remove an image, or send them in a second message.`}const[a,o]=ET(i,n);return`This message is ${a} of text, more than the ${o} one message can carry. Split it across two messages.`}const Td={capabilities:["desktop","capabilities"],providers:["desktop","auth","providers"],commands:["desktop","commands"],accounts:["desktop","auth","accounts"]},Oct=3e4,gct=15e3;function mct(e){return e?.desktop_available===!0}function Wa(){return ir({queryKey:Td.capabilities,queryFn:async()=>{try{return await qt({op:"capabilities"})}catch(e){throw e instanceof Error?e:new Error(String(e))}},staleTime:6e4,retry:!1,refetchInterval:e=>mct(e.state.data)?Oct:gct,refetchIntervalInBackground:!0})}function Oi(e,t,n=1){return!e||!e.desktop_available?!1:(e.features?.[t]??0)>=n}function BP(e){return ir({queryKey:Td.providers,queryFn:()=>qt({op:"providers.list"}).then(t=>t.providers),enabled:e,staleTime:3e4,retry:tD})}var $i=(e=>(e.CONNECT_PROVIDER="connect_provider",e.USER_PROFILE="user_profile",e.SEARCH_API="search_api",e.DEFAULT_MODEL="default_model",e.CREATE_AGENT="create_agent",e.CONGRATULATIONS="congratulations",e))($i||{});const QT=po()(jd((e,t)=>({isModalComplete:!1,isTourComplete:!1,currentStep:"connect_provider",isModalActive:!1,completeModalOnboarding:()=>{e({isModalComplete:!0,isModalActive:!1})},completeTourOnboarding:()=>{e({isTourComplete:!0})},setCurrentStep:n=>{e({currentStep:n})},activateModalOnboarding:()=>{e({isModalActive:!0})},deactivateModalOnboarding:()=>{e({isModalActive:!1})},resetOnboarding:()=>{e({isModalComplete:!1,isTourComplete:!1,currentStep:"connect_provider",isModalActive:!1})}}),{name:"onboarding-storage",partialize:e=>({isModalComplete:e.isModalComplete,isTourComplete:e.isTourComplete,currentStep:e.currentStep}),merge:(e,t)=>{const{isModalActive:n,...r}=e??{};return{...t,...r}},onRehydrateStorage:()=>(e,t)=>{t?console.error("Failed to rehydrate onboarding store:",t):e&&JSON.parse(localStorage.getItem("onboarding-storage")||"{}")?.state?.isComplete===!0&&!e.isModalComplete&&(console.log("Migrating old 'isComplete:true' state to 'isModalComplete:true'"),e.isModalComplete=!0)}}));function CCe(e){return e.some(t=>!t.local&&!t.credential_optional&&(t.configured||t.has_credential))}function vct(e){return e.onboardingComplete?"returning":e.census.status==="loading"||e.census.status==="failed"?"pending":e.census.status==="ready"?CCe(e.census.providers)?"returning":"first_time":e.legacy.status!=="ready"?"pending":e.legacy.keys.length===0?"first_time":"returning"}const yct=()=>{const e=Wa(),t=Oi(e.data,"auth"),n=BP(t),{shouldEnableQuery:r}=WP(),i=ir({queryKey:["open-credentials"],enabled:!t&&!e.isPending&&r({bypassInternetCheck:!0}),queryFn:()=>D2e.listOpenCredentials(oi.baseUrl),staleTime:5e3,retry:!1}),{isModalComplete:s,isModalActive:a,activateModalOnboarding:o,deactivateModalOnboarding:l,resetOnboarding:c}=QT();let u;e.isPending?u={status:"loading"}:t?n.isSuccess?u={status:"ready",providers:n.data}:n.isError?u={status:"failed"}:u={status:"loading"}:u={status:"unavailable"};let d;t||e.isPending?d={status:"loading"}:i.isSuccess&&i.data?d={status:"ready",keys:i.data.keys}:i.isError?d={status:"error"}:d={status:"loading"};const f=vct({onboardingComplete:s,census:u,legacy:d})==="first_time";return b.useEffect(()=>{f&&!a&&o()},[f,a,o]),{isFirstTimeUser:f,isOnboardingActive:a,activateOnboarding:o,deactivateOnboarding:l,resetOnboarding:c}},bct=(e,t)=>e===t?!0:!e||!t?!e&&!t:e.length!==t.length?!1:e.every((n,r)=>n===t[r]),aae=(e,t)=>{const n=e.timestamp instanceof Date?e.timestamp.getTime():new Date(e.timestamp).getTime(),r=t.timestamp instanceof Date?t.timestamp.getTime():new Date(t.timestamp).getTime();return e.id===t.id&&e.role===t.role&&n===r&&e.message===t.message&&e.code===t.code&&e.stdout===t.stdout&&e.stderr===t.stderr&&e.logging===t.logging&&e.formatted_print===t.formatted_print&&e.status===t.status&&e.task_classification===t.task_classification&&e.action===t.action&&e.execution_type===t.execution_type&&e.is_streamable===t.is_streamable&&e.is_complete===t.is_complete&&e.conversation_id===t.conversation_id&&e.content===t.content&&e.file_path===t.file_path&&e.replacements===t.replacements&&e.agent===t.agent&&e.learnings===t.learnings&&e.thinking===t.thinking&&bct(e.files,t.files)},Jc=e=>e.timestamp instanceof Date?e.timestamp.getTime():new Date(e.timestamp).getTime(),oae=e=>{for(let t=1;t<e.length;t+=1)if(Jc(e[t-1])>Jc(e[t]))return!1;return!0},tU=po((e,t)=>({messagesByConversation:{},paginationByConversation:{},lastUpdated:Date.now(),addMessages:(n,r,i=!1)=>{e(s=>{const a=s.messagesByConversation[n]||[],o=new Set(a.map(h=>h.id)),l=r.filter(h=>!o.has(h.id));if(l.length===0)return s;const c=oae(l)?l:[...l].sort((h,f)=>Jc(h)-Jc(f));let u=i?[...c,...a]:[...a,...c];return a.length===0||(i?Jc(c[c.length-1])<=Jc(a[0]):Jc(c[0])>=Jc(a[a.length-1]))||(u=[...u].sort((h,f)=>Jc(h)-Jc(f))),{messagesByConversation:{...s.messagesByConversation,[n]:u},lastUpdated:Date.now()}})},setMessages:(n,r)=>{e(i=>{const s=oae(r)?r:[...r].sort((o,l)=>Jc(o)-Jc(l)),a=i.messagesByConversation[n]||[];if(a.length===s.length){let o=!1;for(let l=0;l<a.length;l+=1)if(!aae(a[l],s[l])){o=!0;break}if(!o)return i}return{messagesByConversation:{...i.messagesByConversation,[n]:s},lastUpdated:Date.now()}})},addMessage:(n,r)=>{e(i=>{const s=i.messagesByConversation[n]||[];return s.some(a=>a.id===r.id)?i:{messagesByConversation:{...i.messagesByConversation,[n]:[...s,r]},lastUpdated:Date.now()}})},updateMessage:(n,r)=>{let i=!1;return e(s=>{const o=(s.messagesByConversation[n]||[]).map(l=>l.id===r.id?aae(l,r)?l:(i=!0,r):l);return i?{messagesByConversation:{...s.messagesByConversation,[n]:o},lastUpdated:Date.now()}:s}),i},clearConversation:n=>{e(r=>{const{[n]:i,...s}=r.messagesByConversation,{[n]:a,...o}=r.paginationByConversation;return{messagesByConversation:s,paginationByConversation:o,lastUpdated:Date.now()}})},getMessages:n=>t().messagesByConversation[n]||[],updatePagination:(n,r,i,s)=>{e(a=>{const o=a.paginationByConversation[n]||{currentPage:1,totalPages:1,hasMore:!1};return o.currentPage===r&&o.totalPages===i&&o.hasMore===s?a:{paginationByConversation:{...a.paginationByConversation,[n]:{...o,currentPage:r,totalPages:i,hasMore:s}},lastUpdated:Date.now()}})},getPagination:n=>t().paginationByConversation[n]||{currentPage:1,totalPages:1,hasMore:!1},updateScrollPosition:(n,r)=>{e(i=>{const s=i.paginationByConversation[n]||{currentPage:1,totalPages:1,hasMore:!1};return s.scrollPosition===r?i:{paginationByConversation:{...i.paginationByConversation,[n]:{...s,scrollPosition:r}}}})},getScrollPosition:n=>t().paginationByConversation[n]?.scrollPosition})),wct=po((e,t)=>({historyByConversation:{},setCurrentMessage:(n,r)=>{e(i=>{const s=i.historyByConversation[n]||{currentMessage:"",currentSequenceId:null};return{historyByConversation:{...i.historyByConversation,[n]:{...s,currentMessage:r}}}})},getCurrentMessage:n=>t().historyByConversation[n]?.currentMessage||"",setCurrentSequenceId:(n,r)=>{e(i=>{const s=i.historyByConversation[n]||{currentMessage:"",currentSequenceId:null};return{historyByConversation:{...i.historyByConversation,[n]:{...s,currentSequenceId:r}}}})},getCurrentSequenceId:n=>t().historyByConversation[n]?.currentSequenceId||null,resetHistory:n=>{e(r=>{const i=r.historyByConversation[n];return i?{historyByConversation:{...r.historyByConversation,[n]:{...i,currentSequenceId:null}}}:r})},clearConversationHistory:n=>{e(r=>{const{[n]:i,...s}=r.historyByConversation;return{historyByConversation:s}})}})),ECe=()=>{const e=Mi(),t=tU(r=>r.clearConversation),n=wct(r=>r.clearConversationHistory);return Ol({mutationFn:async({agentId:r})=>As(oi.baseUrl).agents.clearAgentConversation(r),onSuccess:(r,i)=>{e.invalidateQueries({queryKey:["agent",i.agentId,"conversation"]}),e.invalidateQueries({queryKey:["conversation-messages",i.agentId]}),t(i.agentId),n(i.agentId),ms("Conversation cleared")},onError:r=>{console.error("Error clearing agent conversation:",r),Rr(`Failed to clear conversation: ${r instanceof Error?r.message:"Unknown error"}`)}})},xct=(e,t)=>{const n=e.role==="user"||e.role==="human"?"user":"assistant";return{id:e.id,role:n,message:e.message,code:e.code,stdout:e.stdout,stderr:e.stderr,logging:e.logging,timestamp:e.timestamp?new Date(e.timestamp):new Date,files:e.files,action:e.action,execution_type:e.execution_type,task_classification:e.task_classification,is_complete:e.is_complete,is_streamable:e.is_streamable,conversation_id:t,content:e.content,file_path:e.file_path,replacements:e.replacements,agent:e.agent,learnings:e.learnings,thinking:e.thinking}},qQ=["credentials"],YP=()=>{const{shouldEnableQuery:e,getConnectivityError:t}=WP(),n=t();return b.useEffect(()=>{n&&console.error("Credentials connectivity error:",n.message)},[n]),ir({enabled:e({bypassInternetCheck:!0}),queryKey:qQ,queryFn:async()=>{const i=await As(oi.baseUrl).credentials.listCredentials();if(i.status>=400)throw new Error(i.message||"Failed to fetch credentials");return i.result},refetchOnWindowFocus:!1,staleTime:5e3})},IZ=()=>{const{data:e,isError:t,isPending:n,fetchStatus:r}=YP();return{hasRadientApiKey:!!e?.keys?.includes("RADIENT_API_KEY"),isUnavailable:t||n&&r==="idle"}},Sct=15*60*1e3,QCe=po()(jd((e,t)=>({providers:[],models:[],isLoading:!1,error:null,lastFetched:null,isInitialized:!1,fetchModels:async(n,r=!1)=>{const{lastFetched:i,isInitialized:s}=t(),a=Date.now();if(!(!r&&s&&i&&a-i<Sct)){e({isLoading:!0,error:null});try{const o=As(n),c=(await o.models.listProviders()).result?.providers||[],d=(await o.models.listModels("","recommended","descending")).result?.models||[];e({providers:c,models:d,isLoading:!1,lastFetched:a,isInitialized:!0})}catch(o){console.error("Failed to fetch models:",o),e({isLoading:!1,error:o instanceof Error?o.message:String(o)})}}},getModelsForProvider:n=>t().models.filter(r=>r.provider===n),reset:()=>{e({providers:[],models:[],isLoading:!1,error:null,lastFetched:null,isInitialized:!1})}}),{name:"local-operator-models",partialize:e=>({providers:e.providers,models:e.models,lastFetched:e.lastFetched,isInitialized:e.isInitialized})})),cD=({autoFetch:e=!0}={})=>{const t=oi.baseUrl,n=b.useRef(null),{shouldEnableQuery:r,getConnectivityError:i,hasConnectivityIssue:s}=WP(),{providers:a,models:o,isLoading:l,error:c,lastFetched:u,isInitialized:d,fetchModels:h,getModelsForProvider:f}=QCe(),O=b.useRef(!0),g=b.useRef(!1),m=b.useRef(null);b.useEffect(()=>(n.current&&(clearInterval(n.current),n.current=null),m.current&&(clearTimeout(m.current),m.current=null),e&&r({bypassInternetCheck:!0})?(O.current?(O.current=!1,m.current=window.setTimeout(()=>{!g.current&&r({bypassInternetCheck:!0})&&(h(t),g.current=!0),m.current=null},1e3)):g.current||(h(t),g.current=!0),n.current=window.setInterval(()=>{r({bypassInternetCheck:!0})&&h(t)},15*60*1e3),()=>{n.current&&(clearInterval(n.current),n.current=null),m.current&&(clearTimeout(m.current),m.current=null)}):()=>{m.current&&(clearTimeout(m.current),m.current=null)}),[e,t,h,r]),b.useEffect(()=>{!s&&e&&d&&h(t)},[s,e,d,t,h]);const v=b.useCallback(async()=>{if(r({bypassInternetCheck:!0}))await h(t,!0);else{const w=i();if(w)throw w}},[t,h,r,i]);return{providers:a,models:o,isLoading:l,error:c,lastFetched:u,isInitialized:d,getModelsForProvider:f,getModelById:w=>o.find(k=>k.id===w),refreshModels:v}},$ct=()=>{const{isLoading:e,error:t,refreshModels:n}=cD({autoFetch:!1}),r=b.useRef(!1);return b.useEffect(()=>{r.current||(r.current=!0)},[]),{isLoading:e,error:t,refreshModels:n}},lae=/name=([^;,]+)/,kct=/[/\\]/,Tct=/^data:([^;,]+)/,Ag=e=>{if(e.startsWith("data:image/")){const n=e.match(lae);if(n?.[1])try{return decodeURIComponent(n[1])}catch{return"Pasted image"}return"Pasted image"}if(e.startsWith("data:")){const n=e.match(lae);if(n?.[1])try{return decodeURIComponent(n[1])}catch{return"Pasted file"}const r=e.match(Tct);if(r?.[1]){const i=r[1].split("/")[0];if(i)return`Pasted ${i} file`}return"Pasted file"}const t=e.split(kct);return t[t.length-1]},Ss=po()(jd((e,t)=>({inputByConversation:{},addReply:(n,r)=>{const i=t().inputByConversation[n]||{currentInput:"",submittedMessages:[],currentHistoryIndex:null,replies:[],attachments:[]},s=Array.isArray(i.replies)?i.replies:[];e({inputByConversation:{...t().inputByConversation,[n]:{...i,replies:[...s,r]}}})},removeReply:(n,r)=>{const i=t().inputByConversation[n];i&&e({inputByConversation:{...t().inputByConversation,[n]:{...i,replies:i.replies.filter(s=>s.id!==r)}}})},clearReplies:n=>{const r=t().inputByConversation[n];r&&e({inputByConversation:{...t().inputByConversation,[n]:{...r,replies:[]}}})},addAttachment:(n,r)=>{const i=t().inputByConversation[n]||{currentInput:"",submittedMessages:[],currentHistoryIndex:null,replies:[],attachments:[]},s=Array.isArray(i.attachments)?i.attachments:[];e({inputByConversation:{...t().inputByConversation,[n]:{...i,attachments:[...s,r]}}})},removeAttachment:(n,r)=>{const i=t().inputByConversation[n];i&&e({inputByConversation:{...t().inputByConversation,[n]:{...i,attachments:i.attachments.filter(s=>s.id!==r)}}})},clearAttachments:n=>{const r=t().inputByConversation[n];r&&e({inputByConversation:{...t().inputByConversation,[n]:{...r,attachments:[]}}})},setCurrentInput:(n,r,i=0)=>{const s=t().inputByConversation[n]||{currentInput:"",submittedMessages:[],currentHistoryIndex:null,replies:[],attachments:[]};e({inputByConversation:{...t().inputByConversation,[n]:{...s,currentInput:r,unredactedChars:r?i:0}}})},getUnredactedChars:n=>t().inputByConversation[n]?.unredactedChars||0,getCurrentInput:n=>t().inputByConversation[n]?.currentInput||"",addSubmittedMessage:(n,r)=>{const i=t().inputByConversation[n]||{currentInput:"",submittedMessages:[],currentHistoryIndex:null,replies:[],attachments:[]},s=i.submittedMessages[i.submittedMessages.length-1],a=r&&r!==s?[...i.submittedMessages.slice(-19),r]:i.submittedMessages;e({inputByConversation:{...t().inputByConversation,[n]:{...i,submittedMessages:a}}})},getSubmittedMessages:n=>t().inputByConversation[n]?.submittedMessages||[],clearSubmittedMessages:n=>{const r=t().inputByConversation[n];r&&e({inputByConversation:{...t().inputByConversation,[n]:{...r,submittedMessages:[]}}})},getCurrentHistoryIndex:n=>t().inputByConversation[n]?.currentHistoryIndex??null,setCurrentHistoryIndex:(n,r)=>{const i=t().inputByConversation[n]||{currentInput:"",submittedMessages:[],currentHistoryIndex:null,replies:[],attachments:[]},s=i.submittedMessages;let a=null;typeof r=="number"&&s.length>0&&(a=Math.max(0,Math.min(r,s.length-1))),e({inputByConversation:{...t().inputByConversation,[n]:{...i,currentHistoryIndex:a}}})},resetCurrentHistoryIndex:n=>{const r=t().inputByConversation[n];r&&e({inputByConversation:{...t().inputByConversation,[n]:{...r,currentHistoryIndex:null}}})},clearAll:n=>{const{[n]:r,...i}=t().inputByConversation;e({inputByConversation:i})}}),{name:"conversation-input-store",partialize:e=>({inputByConversation:e.inputByConversation})})),v5="held",_ct=(e,t)=>e===t?"":e,RCe=(e,t)=>e===""?t:e,Pct=(e,t)=>e.length===0&&t?t:nU,nU=[],Cct=(e,t,n)=>{const r=n.text??"",i=RCe(e,r),s=t===null?nU:Pct(t,n.attachments),a=(n.attachments?.length??0)>0,o=r!=="",l=new Set([...(t??[]).map(f=>f.path),...s]),c=(n.attachments??nU).filter(f=>!l.has(f)),u=o&&i===e,d=a&&c.length>0;return{text:i,paths:s,missingFiles:c,withheld:o&&a&&u!==d?u?"text":"files":null}},Ect=(e,t,n)=>{if(e===null)return null;const i=((e==="text"?t:n??t)??[]).map(Ag),s=i.length===1,a=i.join(", ");return e==="text"?`The ${s?"file":"files"} ${a} from your refused message ${s?"is":"are"} attached again; its text was left out because the box already holds text you typed.`:`The text of your refused message was restored, but not its ${s?"file":"files"} ${a} — the composer already holds files you picked, so attach ${s?"it":"them"} again if you still need ${s?"it":"them"}.`},Qct=()=>0,Rct=({conversationId:e,onSubmit:t,scrollToBottom:n,draftHeld:r=!1,draftUnredacted:i=Qct})=>{const s=Ss(F=>F.getCurrentInput),a=Ss(F=>F.setCurrentInput),o=Ss(F=>F.addSubmittedMessage),l=Ss(F=>F.getSubmittedMessages),c=Ss(F=>F.getCurrentHistoryIndex),u=Ss(F=>F.setCurrentHistoryIndex),d=Ss(F=>F.resetCurrentHistoryIndex),[h,f]=b.useState(Ss.persist.hasHydrated?.()??!1),O=b.useRef(void 0),[g,m]=b.useState("");b.useEffect(()=>{const F=Ss.persist;let I,U;return F&&typeof F.onHydrate=="function"&&typeof F.onFinishHydration=="function"?(I=F.onHydrate(()=>f(!1)),U=F.onFinishHydration(()=>f(!0)),f(F.hasHydrated())):f(!0),()=>{I?.(),U?.()}},[]);const v=b.useRef(null),y=b.useRef(""),w=Ss(F=>e?F.inputByConversation[e]?.currentInput??"":""),k=b.useRef(""),x=e?l(e):[],S=e?c(e):null;b.useEffect(()=>{if(h)if(e){const F=s(e);S!==null&&x.length>0?m(x[S]||""):m(F),O.current=e,y.current=""}else m(""),O.current=void 0,y.current=""},[e,h,s,S,x]),b.useEffect(()=>{h&&e&&O.current!==e&&a(e,g)},[e,g,a,h]),b.useEffect(()=>{!h||!e||w!==k.current&&(k.current=w,w&&!g&&m(w))},[w,h,e,g]);const T=b.useCallback(F=>{if(m(F),e){if(r)return;k.current=F,a(e,F,i(F)),d(e)}},[e,a,d,r,i]),_=b.useRef(!1),P=b.useCallback(async()=>{if(!g.trim()||!e||_.current)return;_.current=!0;const F=g;let I=!1;const U=()=>{I||(I=!0,O.current===e&&m(Z=>_ct(Z,F)))},q=()=>{k.current="",a(e,""),d(e),y.current=""};try{const Z=await t?.(F,U);if(Z===!1){O.current===e&&m(W=>RCe(W,F));return}if(Z===v5){q();return}}finally{_.current=!1}U(),o(e,F),q(),n&&requestAnimationFrame(()=>{n()})},[g,e,t,o,a,d,n]),E=b.useCallback(()=>{const F=v.current;if(!F)return{line:0,totalLines:1};const I=F.value,U=F.selectionStart,Z=(I.substring(0,U).match(/\n/g)||[]).length+1,W=(I.match(/\n/g)||[]).length+1;return{line:Z,totalLines:W}},[]),C=b.useCallback(()=>E().line===1,[E]),Q=b.useCallback(()=>{const{line:F,totalLines:I}=E();return F===I},[E]),D=b.useCallback(F=>{if(e){if(F.key==="Enter"&&!F.shiftKey){F.preventDefault(),P();return}if(x.length){if(F.key==="ArrowUp"&&C()){if(F.preventDefault(),S===null)y.current=g,u(e,x.length-1),m(x[x.length-1]||"");else if(S>0){const I=S-1;u(e,I),m(x[I]||"")}setTimeout(()=>{if(v.current){const I=v.current.value.length;v.current.selectionStart=I,v.current.selectionEnd=I}},0)}if(F.key==="ArrowDown"&&Q()&&(F.preventDefault(),S!==null)){if(S<x.length-1){const I=S+1;u(e,I),m(x[I]||"")}else d(e),m(y.current),y.current="";setTimeout(()=>{if(v.current){const I=v.current.value.length;v.current.selectionStart=I,v.current.selectionEnd=I}},0)}}}},[P,C,Q,S,g,x,e,u,d]);return{inputValue:g,setInputValue:T,handleKeyDown:D,handleSubmit:P,textareaRef:v}},Act={name:"User",email:"user@example.com"},FZ=po()(jd(e=>({profile:Act,isSigningOut:!1,updateName:t=>{e(n=>({profile:{...n.profile,name:t}}))},updateEmail:t=>{e(n=>({profile:{...n.profile,email:t}}))},updateProfile:t=>{e(n=>({profile:{...n.profile,...t}}))},setIsSigningOut:t=>{e({isSigningOut:t})},clearProfile:()=>{e({profile:{name:"",email:""}})}}),{name:"user-profile-storage"}));function Dct(e){return{operation:e.operation,...e.tenantId?{tenant_id:e.tenantId}:{},...e.accountId?{account_id:e.accountId}:{},...e.agentId?{agent_id:e.agentId}:{},...e.commentId?{comment_id:e.commentId}:{},...e.query?{query:e.query}:{},...e.payload?{payload:e.payload}:{},...e.requestId?{request_id:e.requestId}:{},...e.confirmed?{confirmed:!0}:{}}}async function Oo(e){return(await qt({op:"radient.request",control:Dct(e)})).data}async function MZ(e){const t=await Oo(e);return t&&typeof t=="object"&&"result"in t?t.result:t}const zQ={all:["radient-user"],user:()=>[...zQ.all,"user"]};function cae(e){return e instanceof Error&&/sign in to radient/i.test(e.message)}const Nct=()=>{const e=Mi(),{setIsSigningOut:t}=FZ(),n=Wa(),r=Oi(n.data,"radient"),i=ir({queryKey:zQ.user(),queryFn:async()=>{try{return await MZ({operation:"account"})}catch(c){if(cae(c))return null;throw c}},enabled:r,staleTime:30*1e3,refetchOnWindowFocus:!0,retry:(c,u)=>!cae(u)&&c<2}),s=!!i.data&&!i.isLoading,a=s,o=Ol({onMutate:()=>{t(!0)},mutationFn:async()=>{const u=(await qt({op:"accounts.list"})).accounts.filter(d=>d.provider==="radient");for(const d of u)await qt({op:"accounts.remove",accountId:d.id,confirmed:!0});return!0},onSuccess:()=>{e.removeQueries({queryKey:zQ.all}),e.invalidateQueries({queryKey:Td.accounts}),ms("Successfully signed out"),t(!1)},onError:c=>{const u=c instanceof Error?c.message:String(c);Rr(`Failed to sign out: ${u}`),t(!1)}}),l=Ol({mutationFn:async()=>(e.invalidateQueries({queryKey:zQ.all}),!0)});return{user:i.data??void 0,isLoading:i.isLoading,isRefetching:i.isRefetching,error:i.error,hasLocalSession:a,isAuthenticated:s,unavailable:n.isSuccess&&!r,signOut:o.mutate,refreshUser:l.mutate,userQuery:i}},jZ=()=>{const e=FZ(),{user:t,isLoading:n,error:r,isAuthenticated:i,hasLocalSession:s,unavailable:a,signOut:o,refreshUser:l}=Nct();let c;return n?c=s?"restoring":"loading":i?c="authenticated":c="unauthenticated",b.useEffect(()=>{if(!i||!t?.account)return;const{account:u}=t;if(!u.name&&!u.email)return;const{name:d,email:h}=e.profile;(u.name&&u.name!==d||u.email&&u.email!==h)&&e.updateProfile({name:u.name||d,email:u.email||h})},[i,t,e]),{authStatus:c,isAuthenticated:i,hasLocalSession:s,isLoading:n,error:r,user:i&&t?.account?{name:t.account.name,email:t.account.email,radientUser:t}:null,unavailable:a,refreshUser:l,signOut:o,updateProfile:e.updateProfile,updateName:e.updateName,updateEmail:e.updateEmail}},RT=e=>e.replace(/\\/g,"/"),LZ=()=>window.location.hash?RT(window.location.hash.substring(1)):RT(window.location.pathname),e0=(e,t)=>RT(e).includes(t),Xct=()=>{const{agentId:e}=e2e(),t=ka(),n=()=>{const s=LZ();return e0(s,"/chat")?"chat":"agents"};return{agentId:e,navigateToAgent:(s,a)=>{if(!s)return;const o=a||n();t(`/${o}/${s}`)},clearAgentId:s=>{const a=s||n();t(`/${a}`)}}},Ict=()=>{const e=LZ();return e0(e,"/chat")?"chat":e0(e,"/agents")?"agents":e0(e,"/settings")?"settings":e0(e,"/agent-hub")?"agent-hub":e0(e,"/schedules")?"schedules":e0(e,"/browser")?"browser":"chat"},Fct=(e=50,t,n)=>{const r=b.useRef(null),i=t||r,[s,a]=b.useState(!1),o=b.useRef(!1),l=b.useRef(0),c=b.useRef(n),u=b.useCallback(()=>{const f=i.current;if(!f)return;const{scrollTop:O,scrollHeight:g,clientHeight:m}=f,v=Math.abs(O),w=g>m&&v>e;a(w)},[e,i]),d=b.useCallback(()=>{const f=i.current;f&&requestAnimationFrame(()=>{f.scrollTo({top:0,behavior:"smooth"}),requestAnimationFrame(u)})},[i,u]),h=b.useCallback(()=>{!i.current||o.current||(o.current=!0,requestAnimationFrame(()=>{u(),o.current=!1}))},[i,u]);return b.useEffect(()=>{const f=i.current;if(!f)return;c.current!==n&&(a(!1),l.current=0,c.current=n),f.addEventListener("scroll",h,{passive:!0});const O=requestAnimationFrame(u),g=window.setTimeout(u,100),m=window.setTimeout(u,500);return()=>{f.removeEventListener("scroll",h),cancelAnimationFrame(O),clearTimeout(g),clearTimeout(m)}},[i,n,h,u]),b.useEffect(()=>{const f=()=>{u()};return window.addEventListener("resize",f,{passive:!0}),()=>{window.removeEventListener("resize",f)}},[u]),b.useEffect(()=>{const f=i.current;if(!f)return;const O=new ResizeObserver(()=>{u()});return O.observe(f),()=>{O.disconnect()}},[i,u]),{containerRef:i,isFarFromBottom:s,scrollToBottom:d}},Mct=15*60*1e3,uae=250,dae=(e,t)=>e?e.is_complete!==t.is_complete||e.is_streamable!==t.is_streamable||e.message!==t.message||e.code!==t.code||e.stdout!==t.stdout||e.stderr!==t.stderr||e.logging!==t.logging||e.content!==t.content||e.replacements!==t.replacements||e.action!==t.action||e.execution_type!==t.execution_type:!0,j6=(e,t)=>{const r=Object.entries(e).filter(([s,a])=>!a.isComplete||t-a.lastUpdated<Mct);if(r.length<=uae)return Object.fromEntries(r);const i=[...r].sort((s,a)=>a[1].lastUpdated-s[1].lastUpdated);return Object.fromEntries(i.slice(0,uae))},ig=po(e=>({streamingMessages:{},updateStreamingMessage:(t,n)=>{e(r=>{const i=Date.now(),s=r.streamingMessages[t]||{content:null,isComplete:!1,lastUpdated:i};if(!s.isComplete&&!dae(s.content,n))return r;const a={...r.streamingMessages,[t]:{...s,content:n,lastUpdated:i}};return{streamingMessages:j6(a,i)}})},completeStreamingMessage:(t,n)=>{e(r=>{const i=Date.now(),s=r.streamingMessages[t];if(s?.isComplete&&!dae(s.content,n))return r;const a={...r.streamingMessages,[t]:{content:n,isComplete:!0,lastUpdated:i}};return{streamingMessages:j6(a,i)}})},pruneStreamingMessages:()=>{e(t=>{const n=Date.now(),r=j6(t.streamingMessages,n);return Object.keys(r).length===Object.keys(t.streamingMessages).length?t:{streamingMessages:r}})}})),jct=/\/+$/,Ha={Open:"stream.open",Gap:"stream.gap",Terminal:"stream.terminal",Error:"error",RecordUpdate:"record.update",RecordComplete:"record.complete",MessageDelta:"message.delta",ToolStart:"tool.start",ToolDelta:"tool.delta",ToolEnd:"tool.end",TurnStart:"turn.start",TurnEnd:"turn.end",AgentStart:"agent.start",AgentEnd:"agent.end",Notice:"notice",JobStatus:"job.status",Keepalive:"keepalive"},Lct={autoReconnect:!0,maxReconnectAttempts:5,stallTimeout:45e3,openTimeout:8e3};class qct extends bZ{source=null;baseUrl;channelId;channelKind;options;status="disconnected";failedOpens=0;lastSeq=null;stallTimerId=null;closedByServer=!1;opened=!1;openTimerId=null;constructor(t,n,r={},i="message"){super(),this.baseUrl=t.replace(jct,""),this.channelId=n,this.channelKind=i,this.options={...Lct,...r}}getStatus(){return this.status}getLastSequence(){return this.lastSeq}url(){const t=this.channelKind==="job"?`/v1/sse/jobs/${encodeURIComponent(this.channelId)}`:`/v1/sse/messages/${encodeURIComponent(this.channelId)}`,n=this.lastSeq!==null?`?after_seq=${this.lastSeq}`:"";return`${this.baseUrl}${t}${n}`}setStatus(t){this.status!==t&&(this.status=t,this.emit("status",t))}armStallTimer(){this.clearStallTimer(),this.stallTimerId=window.setTimeout(()=>{this.emit("error",new Error(`SSE stream stalled: no traffic for ${this.options.stallTimeout}ms`)),this.setStatus("error"),this.emit("stalled")},this.options.stallTimeout)}clearStallTimer(){this.stallTimerId!==null&&(window.clearTimeout(this.stallTimerId),this.stallTimerId=null)}clearOpenTimer(){this.openTimerId!==null&&(window.clearTimeout(this.openTimerId),this.openTimerId=null)}async connect(){if(!this.source)return this.closedByServer=!1,this.opened=!1,this.setStatus("connecting"),new Promise(t=>{let n=!1;const r=()=>{n||(n=!0,t())},i=new EventSource(this.url());this.source=i,this.openTimerId=window.setTimeout(()=>{this.opened||(this.teardown(),this.setStatus("error"),this.emit("error",new Error(`SSE open timed out after ${this.options.openTimeout}ms`)),r())},this.options.openTimeout),i.onopen=()=>{this.opened=!0,this.clearOpenTimer(),this.failedOpens=0,this.setStatus("connected"),this.armStallTimer(),r()},i.onerror=()=>{if(this.clearStallTimer(),this.closedByServer){this.teardown(),this.setStatus("disconnected"),r();return}if(i.readyState===EventSource.CONNECTING){if(this.failedOpens+=1,!this.options.autoReconnect||this.failedOpens>this.options.maxReconnectAttempts){this.teardown(),this.setStatus("failed"),this.emit("error",new Error(`SSE reconnect gave up after ${this.failedOpens} attempts`)),r();return}this.setStatus("reconnecting"),r();return}this.teardown(),this.setStatus("error"),this.emit("error",new Error("SSE connection closed unexpectedly")),r()},i.addEventListener(Ha.Open,a=>{this.armStallTimer();const o=this.parse(a);if(o){this.lastSeq=o.last_seq>0?o.last_seq:this.lastSeq,this.emit("open",o);for(const l of o.snapshot??[])this.emitRecord(l);r()}});const s=a=>{this.armStallTimer();const o=this.parse(a);o?.record&&(this.noteSeq(a),this.emitRecord(o.record))};i.addEventListener(Ha.RecordUpdate,s),i.addEventListener(Ha.RecordComplete,s),i.addEventListener(Ha.Terminal,a=>{this.noteSeq(a),this.closedByServer=!0,this.clearStallTimer(),this.emit("terminal",this.parse(a)),this.teardown(),this.setStatus("disconnected"),r()}),i.addEventListener(Ha.Gap,a=>{const o=this.parse(a);this.emit("gap",o)}),i.addEventListener(Ha.Error,a=>{const o=this.parse(a);this.emit("error",new Error(o?.error??"SSE stream reported an error"))});for(const a of[Ha.MessageDelta,Ha.ToolStart,Ha.ToolDelta,Ha.ToolEnd,Ha.TurnStart,Ha.TurnEnd,Ha.AgentStart,Ha.AgentEnd,Ha.Notice,Ha.JobStatus])i.addEventListener(a,o=>{this.armStallTimer(),this.noteSeq(o),this.emit(a,this.parse(o))});i.addEventListener(Ha.Keepalive,()=>{this.armStallTimer()})})}emitRecord(t){const n=t.message_id??t.id;this.emit(`update:${n}`,t),n!==this.channelId&&this.emit(`update:${this.channelId}`,t)}noteSeq(t){const n=t.lastEventId;if(!n)return;const r=Number.parseInt(n,10);Number.isFinite(r)&&(this.lastSeq=r)}parse(t){const n=t.data;if(typeof n!="string")return null;try{return JSON.parse(n)}catch{return console.error("[sse] frame was not valid JSON"),null}}teardown(){this.clearStallTimer(),this.clearOpenTimer(),this.source&&(this.source.close(),this.source=null)}disconnect(){this.teardown(),this.setStatus("disconnected")}}const ACe=/\/+$/,rU=new Map,iU=new Map,zct=2500,Uct=e=>{const t=e.replace(ACe,""),n=rU.get(t);if(n)return n;const r=(async()=>{const i=new AbortController,s=window.setTimeout(()=>i.abort(),zct);try{const a=await fetch(`${t}/v1/sse/capabilities`,{signal:i.signal});if(!a.ok)return{capabilities:null,sseProvenBroken:!1};const o=await a.json();return{capabilities:o?.transports?.includes("sse")??!1?o:null,sseProvenBroken:!1}}catch{return{capabilities:null,sseProvenBroken:!1}}finally{window.clearTimeout(s)}})();return rU.set(t,r),r.then(i=>iU.set(t,i)).catch(()=>{}),r};class Wct extends bZ{baseUrl;channelId;options;active=null;kind=null;disposed=!1;delivered=!1;connecting=!1;constructor(t,n,r={}){super(),this.baseUrl=t.replace(ACe,""),this.channelId=n,this.options=r}getTransport(){return this.kind}getStatus(){return this.active?.getStatus()??"disconnected"}async connect(){if(!(this.disposed||this.active||this.connecting)){this.connecting=!0;try{const t=this.options.force;let n=t==="sse";if(!t){const r=await Uct(this.baseUrl);if(this.disposed)return;n=r.capabilities!==null&&!r.sseProvenBroken}if(this.disposed)return;if(n){await this.startSse();return}await this.startWebSocket()}finally{this.connecting=!1}}}async startSse(){const t=new qct(this.baseUrl,this.channelId,this.options.sse,this.options.channelKind??"message");this.active=t,this.kind="sse",this.bind(t),t.on("stalled",()=>{this.delivered||this.fallback("stream stalled before any frame")}),t.on("status",n=>{(n==="failed"||n==="error")&&!this.delivered&&this.fallback(`sse status became ${String(n)}`)}),await t.connect()}async startWebSocket(){const t=new nst(this.baseUrl,this.channelId,this.options.websocket,I2e.MESSAGE);this.active=t,this.kind="websocket",this.bind(t),await t.connect()}bind(t){const n=["status","error",`update:${this.channelId}`,"open","terminal","gap","message.delta","tool.start","tool.delta","tool.end","turn.start","turn.end","agent.start","agent.end","notice","job.status"];for(const r of n)t.on(r,(...i)=>{r===`update:${this.channelId}`&&(this.delivered=!0),this.emit(r,...i)})}async fallback(t){if(this.disposed||this.kind!=="sse")return;const n=this.baseUrl,r=iU.get(n);r?r.sseProvenBroken=!0:(iU.set(n,{capabilities:null,sseProvenBroken:!0}),rU.set(n,Promise.resolve({capabilities:null,sseProvenBroken:!0}))),console.warn(`[streaming] falling back to websocket: ${t}`),this.active&&(this.active.removeAllListeners(),this.active.disconnect(),this.active=null),this.kind=null;try{await this.startWebSocket()}catch(i){console.error("[streaming] websocket fallback failed:",i)}}disconnect(){this.disposed=!0,this.active&&(this.active.removeAllListeners(),this.active.disconnect(),this.active=null)}}const Gct=["id","message","code","stdout","stderr","logging","content","replacements","thinking","learnings","formatted_print","file_path","agent","action","execution_type","task_classification","role","status","is_complete","is_streamable"],Vct=(e,t)=>{if(!e)return!0;for(const i of Gct)if(e[i]!==t[i])return!0;const n=e.files,r=t.files;return n===r?!1:!n||!r||n.length!==r.length?!0:n.some((i,s)=>i!==r[s])},Bct=e=>{const{baseUrl:t,messageId:n,autoReconnect:r=!0,reconnectInterval:i=2e3,maxReconnectAttempts:s=5,pingInterval:a=3e4,onUpdate:o,onStatusChange:l,onError:c}=e,[u,d]=b.useState(null),[h,f]=b.useState(!1),[O,g]=b.useState(!1),[m,v]=b.useState("disconnected"),[y,w]=b.useState(null),[k,x]=b.useState(!1),S=b.useRef(null),T=b.useRef(null),_=b.useRef(null),P=b.useRef(null),E=b.useRef({onUpdate:o,onStatusChange:l,onError:c});b.useEffect(()=>{E.current={onUpdate:o,onStatusChange:l,onError:c}},[o,l,c]);const C=b.useCallback(()=>{P.current=null;const U=T.current;U&&(T.current=null,!(!U.is_complete&&!Vct(_.current,U))&&(_.current=U,d(U),E.current.onUpdate?.(U)))},[]),Q=b.useCallback(()=>{P.current!==null&&(cancelAnimationFrame(P.current),P.current=null),T.current=null,S.current&&(S.current.removeAllListeners(),S.current.disconnect(),S.current=null)},[]),D=b.useCallback(()=>{if(S.current)return S.current;const U=new Wct(t,n,{websocket:{autoReconnect:r,reconnectInterval:i,maxReconnectAttempts:s,pingInterval:a,messageDelay:250},sse:{autoReconnect:r,maxReconnectAttempts:s}});return U.on("status",q=>{const Z=q;v(Z),Z==="connected"&&w(null),E.current.onStatusChange?.(Z)}),U.on(`update:${n}`,q=>{const Z=q;if(T.current={...T.current??_.current,...Z},typeof Z.is_complete=="boolean"&&f(Z.is_complete),typeof Z.is_streamable=="boolean"&&g(Z.is_streamable),Z.is_complete){P.current!==null&&cancelAnimationFrame(P.current),C();return}P.current===null&&(P.current=requestAnimationFrame(C))}),U.on("error",q=>{const Z=q instanceof Error?q:new Error(typeof q=="string"?q:`WebSocket error for ${n}`);w(Z),E.current.onError?.(Z)}),S.current=U,U},[t,n,r,i,s,a,C]),F=b.useCallback(async()=>{if(!n||!t)throw new Error("Missing messageId or baseUrl");w(null),x(!0);const U=D(),q=U.getStatus();if(q==="connected"||q==="connecting"||q==="reconnecting"){x(!1);return}try{await U.connect()}catch(Z){const W=Z instanceof Error?Z:new Error(String(Z));throw w(W),E.current.onError?.(W),W}finally{x(!1)}},[n,t,D]),I=b.useCallback(()=>{Q(),v("disconnected"),x(!1)},[Q]);return b.useEffect(()=>()=>{I()},[n,I]),b.useEffect(()=>{x(m==="connecting"||m==="reconnecting")},[m]),{message:u,isComplete:h,isStreamable:O,status:m,connect:F,disconnect:I,isLoading:k,error:y}},Yct=1500,Zct=80,Hct=180,nd=new Map,dS=(e,t)=>{const n=nd.get(e);if(n)return t&&(n.conversationId=t),n;const r={connected:!1,connecting:!1,connectionPromise:null,instanceCount:0,messageData:null,isComplete:!1,isStreamable:!1,conversationId:t,disconnect:null};return nd.set(e,r),r},Kct=({messageId:e,autoConnect:t=!0,onComplete:n,onUpdate:r,baseUrl:i=oi.baseUrl,conversationId:s,refetchOnComplete:a=!0})=>{const o=b.useRef(!1),l=b.useRef(!1),c=b.useRef(0),u=b.useRef(null),d=b.useRef(!1),h=b.useRef(null),f=b.useRef(null),O=b.useRef(null),[g,m]=b.useState(!1),v=ig(L=>L.updateStreamingMessage),y=ig(L=>L.completeStreamingMessage),w=ig(L=>L.pruneStreamingMessages),k=ig(L=>L.streamingMessages[e]?.isComplete??!1),x=tU(L=>L.addMessage),S=tU(L=>L.updateMessage),T=b.useCallback(L=>{if(!s||!L.id)return;const N=xct(L,s);S(s,N)||x(s,N)},[s,S,x]),_=b.useCallback(()=>{O.current&&(T(O.current),O.current=null)},[T]),P=b.useCallback(L=>{!n||!o.current||u.current!==e&&(u.current=e,n(L))},[n,e]),E=b.useCallback(async()=>{if(e)try{m(!0);const L=As(i),N=nd.get(e),z=N?.conversationId||s;if(!z)return;const V=await L.agents.getAgentExecutionHistory(z,1,30);if(V.status>=400||!V.result)throw new Error(V.message||"Failed to fetch message data");const ee=V.result.history.find(oe=>oe.id===e);if(ee){y(e,ee);const oe=dS(e,s);oe.messageData=ee,oe.isComplete=!0,oe.isStreamable=!!ee.is_streamable,T(ee),P(ee);return}N?.messageData&&N.isComplete&&(y(e,N.messageData),T(N.messageData),P(N.messageData))}catch(L){const N=L instanceof Error?L.message:String(L);console.error(`Error refetching message: ${N}`)}finally{m(!1)}},[e,i,s,y,T,P]),C=b.useCallback(()=>{!a||h.current||(h.current=setTimeout(()=>{h.current=null,o.current&&E()},Hct))},[a,E]),{message:Q,isComplete:D,isStreamable:F,status:I,isLoading:U,error:q,connect:Z,disconnect:W}=Bct({baseUrl:i,messageId:e,onUpdate:L=>{r&&o.current&&r(L);const N=dS(e,s),z={...N.messageData,...L};if(N.messageData=z,N.isStreamable=!!(L.is_streamable||N.isStreamable),L.is_complete){N.isComplete=!0,y(e,z),O.current=z,_(),P(z),C();return}v(e,z),s&&z.id&&(O.current=z,f.current||(f.current=setTimeout(()=>{f.current=null,_()},Zct)))}}),M=b.useCallback(async()=>{if(D||k)return;const L=Date.now();if(L-c.current<Yct)return;c.current=L;const N=dS(e,s);if(!N.connected){if(N.connectionPromise){try{await N.connectionPromise}catch{}return}N.connecting=!0,N.connectionPromise=Z().then(()=>{const z=nd.get(e);z&&(z.connected=!0,z.connecting=!1)}).catch(z=>{const V=nd.get(e);throw V&&(V.connected=!1,V.connecting=!1),z}).finally(()=>{const z=nd.get(e);z&&(z.connectionPromise=null)});try{await N.connectionPromise}catch(z){console.error("WebSocket connection failed:",z)}}},[D,k,e,s,Z]),J=b.useCallback(()=>{const L=nd.get(e);L&&(L.connected=!1,L.connecting=!1,L.connectionPromise=null,L.disconnect=null,L.instanceCount<=1&&nd.delete(e)),W()},[e,W]);return b.useEffect(()=>{if(o.current=!0,d.current=!1,u.current=null,!k){const N=dS(e,s);N.disconnect=W,l.current||(N.instanceCount+=1,l.current=!0)}let L=null;return t&&!D&&!k&&(L=setTimeout(()=>{o.current&&M()},120)),()=>{if(o.current=!1,L&&clearTimeout(L),h.current&&(clearTimeout(h.current),h.current=null),f.current&&(clearTimeout(f.current),f.current=null),_(),w(),l.current){const N=nd.get(e);N&&(N.instanceCount=Math.max(0,N.instanceCount-1),N.instanceCount===0&&(N.connected=!1,N.connecting=!1,N.connectionPromise=null,N.disconnect=null,nd.delete(e),W())),l.current=!1}}},[t,D,k,M,e,s,_,w,W]),b.useEffect(()=>{const L=nd.get(e);L&&(L.connected=I==="connected",L.connecting=I==="connecting"||I==="reconnecting",L.connecting||(L.connectionPromise=null))},[e,I]),b.useEffect(()=>{if(I!=="disconnected"||D||k||!o.current)return;const L=setTimeout(()=>{o.current&&M()},1600);return()=>clearTimeout(L)},[I,D,k,M]),b.useEffect(()=>{if(!D||!Q){d.current=!1;return}if(d.current)return;d.current=!0;const L=dS(e,s);L.isComplete=!0,L.messageData=Q,L.isStreamable=!!Q.is_streamable,y(e,Q),O.current=Q,_(),P(Q),C(),J()},[D,Q,e,s,y,_,P,C,J]),{message:Q,isComplete:D,isStreamable:F,status:I,isLoading:U,isRefetching:g,error:q,connect:M,disconnect:J,refetch:E}},Jct=()=>{const e=Mi(),t=As(oi.baseUrl);return Ol({mutationFn:async({agentId:n,update:r})=>{try{const i=await t.agents.updateAgent(n,r);if(i.status>=400)throw new Error(i.message||`Failed to update agent ${n}`);return i.result}catch(i){const s=i instanceof Error?i.message:`An unknown error occurred while updating agent ${n}`;throw Rr(s),i}},onSuccess:async(n,{agentId:r})=>{await e.invalidateQueries({queryKey:zh,refetchType:"none"}),e.setQueryData([...zh,r],i=>i&&{...i,...n}),await e.refetchQueries({queryKey:zh,type:"all"}),ms("Agent updated")},onError:n=>{console.error("Error updating agent:",n)}})},eut=()=>{const e=Mi(),t=As(oi.baseUrl);return Ol({mutationFn:async n=>{try{const r=await t.config.updateConfig(n);if(r.status>=400)throw new Error(r.message||"Failed to update configuration");return r.result}catch(r){const i=r instanceof Error?r.message:"An unknown error occurred while updating configuration";throw Rr(i),r}},onSuccess:async n=>{await e.invalidateQueries({queryKey:XQ,refetchType:"none"}),e.setQueryData(XQ,r=>r&&{...r,...n}),await e.refetchQueries({queryKey:XQ,type:"all"}),ms("Configuration updated")},onError:n=>{console.error("Error updating configuration:",n)}})},tut=()=>{const e=Mi(),t=As(oi.baseUrl);return Ol({mutationFn:async n=>{try{const r=await t.credentials.updateCredential(n);if(r.status>=400)throw new Error(r.message||"Failed to update credential");return r}catch(r){const i=r instanceof Error?r.message:"An unknown error occurred while updating credential";throw Rr(i),r}},onSuccess:async(n,r)=>{await e.invalidateQueries({queryKey:qQ,refetchType:"none"}),e.setQueryData(qQ,i=>i&&(i.keys.includes(r.key)?i:{...i,keys:[...i.keys,r.key]})),await e.refetchQueries({queryKey:qQ,type:"all"}),ms(`Credential "${r.key}" updated successfully`)},onError:n=>{console.error("Error updating credential:",n)}})},nut=({open:e,onClose:t,onAgentCreated:n})=>{const r=ka(),[i,s]=b.useState(""),[a,o]=b.useState(""),l=b.useRef(null),c=()=>{t(),setTimeout(()=>{r("/agent-hub")},200)},u=dot(),d=async m=>{if(m.preventDefault(),!i.trim())return;const v={name:i.trim(),description:a.trim()||void 0};try{const y=await u.mutateAsync(v);s(""),o(""),n&&y?.id&&n(y.id),t()}catch(y){console.error("Failed to create agent:",y)}},h=u.isPending,f=h||!i.trim(),O=p.jsxs(p.Fragment,{children:[p.jsx(Jv,{size:19,className:"text-accent","aria-hidden":"true"}),"Create new agent"]}),g=p.jsxs(p.Fragment,{children:[p.jsx(sl,{onClick:t,disabled:h,"data-tour-tag":"create-agent-dialog-cancel-button",children:"Cancel"}),p.jsx(vd,{type:"submit",form:"create-agent-form",disabled:f,startIcon:h?p.jsx(pr,{}):null,children:"Create agent"})]});return p.jsxs(Nc,{open:e,onClose:t,title:O,actions:g,maxWidth:"sm",dataTourTag:"create-agent-dialog",dialogProps:{onOpenAutoFocus:m=>{m.preventDefault(),l.current?.focus()}},children:[p.jsx("p",{className:"text-body-sm text-ink-muted",children:"Configure your new AI assistant with a name and optional description"}),p.jsxs(we,{variant:"link",onClick:c,className:"mt-1 mb-4 text-body-sm",children:["Browse Agent hub to fetch ready-made agents",p.jsx(Y3,{"aria-hidden":"true"})]}),p.jsx("form",{id:"create-agent-form",onSubmit:d,children:p.jsxs("div",{className:"flex flex-col gap-5",children:[p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx(Us,{htmlFor:"create-agent-name",children:"Agent name"}),p.jsx(Si,{ref:l,id:"create-agent-name",inputSize:"lg",value:i,onChange:m=>s(m.target.value),required:!0,disabled:h,placeholder:"Enter a name for your agent"})]}),p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx(Us,{htmlFor:"create-agent-description",children:"Description (optional)"}),p.jsx(tm,{id:"create-agent-description",rows:2,value:a,onChange:m=>o(m.target.value),disabled:h,placeholder:"Describe what this agent does"})]})]})})]})},hae=({value:e,label:t,onSave:n,multiline:r=!1,rows:i=4,placeholder:s="Enter value...",icon:a,isSaving:o=!1,readOnly:l=!1})=>{const[c,u]=b.useState(!1),[d,h]=b.useState(e),[f,O]=b.useState(e),[g,m]=b.useState(e),[v,y]=b.useState(!1),[w,k]=b.useState(!1),x=b.useRef(null),S=b.useRef(null),T=b.useId(),_=o||v;b.useEffect(()=>{c||(h(e),O(e)),m(e)},[e,c]),b.useEffect(()=>{if(c){const L=setTimeout(()=>{x.current&&(x.current.focus(),x.current.select())},0);return()=>clearTimeout(L)}},[c]);const P=()=>{l||u(!0)},E=L=>{h(L.target.value)},C=()=>{h(g),u(!1)},Q=async()=>{if(!(_||d===g)){y(!0);try{await n(d),m(d),O(d),u(!1)}catch(L){console.error("Failed to save editable field:",L)}finally{y(!1)}}},D=L=>{setTimeout(()=>{const N=L.relatedTarget;!(S.current?.contains(N)??!1)&&d===g&&u(!1)},0)},F=L=>{L.key==="Escape"?C():L.key==="Enter"&&(!r||r&&(L.ctrlKey||L.metaKey))&&(L.preventDefault(),d!==g?Q():u(!1))},I=L=>{L.preventDefault(),L.stopPropagation(),!(l||_||w)&&(k(!0),y(!0),h(""),O(""),n("").then(()=>{m(""),u(!1)}).catch(N=>{console.error("Failed to clear field:",N),h(g),O(g)}).finally(()=>{k(!1),y(!1)}))},U=L=>{l||(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),P())},q=d!==g,Z=!l&&!_&&g!=="",W=Z&&!q,M=_?"pr-20":W?"pr-28":q?"pr-18":"pr-10",J="opacity-0 transition-opacity duration-fast ease-out-quart group-hover:opacity-100 group-focus-within:opacity-100";return p.jsxs("div",{children:[(t||a)&&p.jsxs(Us,{htmlFor:T,className:"mb-1.5 flex items-center gap-2 text-ink-muted",children:[a,t]}),c?p.jsxs("div",{className:"relative",children:[r?p.jsx(tm,{id:T,ref:x,value:d,onChange:E,onBlur:D,onKeyDown:F,rows:i,placeholder:s,autoComplete:"off",className:A("min-h-9",M)}):p.jsx(Si,{id:T,ref:x,value:d,onChange:E,onBlur:D,onKeyDown:F,placeholder:s,autoComplete:"off",className:A("text-ellipsis",M)}),p.jsx("div",{ref:S,className:A("absolute right-1.5 z-10 flex items-center gap-1",r?"top-1.5":"top-1/2 -translate-y-1/2"),children:_?p.jsx("span",{className:"px-2 text-ink-dim text-meta",children:w?"Clearing...":"Saving..."}):p.jsxs(p.Fragment,{children:[q&&p.jsx(we,{variant:"ghost",size:"icon-sm",onClick:Q,title:"Save changes (Enter)","aria-label":`Save ${t}`,className:"text-success hover:bg-success-wash hover:text-success",children:p.jsx(Ul,{})}),p.jsx(we,{variant:"ghost",size:"icon-sm",onClick:C,title:"Cancel (Escape)","aria-label":`Cancel editing ${t}`,className:"text-danger hover:bg-danger-wash hover:text-danger",children:p.jsx(Qi,{})}),W&&p.jsxs(we,{variant:"danger",size:"sm",onClick:I,title:"Clear field","aria-label":`Clear ${t}`,children:[p.jsx(ise,{}),"Clear"]})]})})]}):p.jsxs("div",{className:"group relative w-full",children:[p.jsx("button",{type:"button",onClick:P,"aria-label":`Current value: ${f||s}.${l?"":" Click to edit."}`,onKeyDown:U,disabled:l,className:A("flex w-full rounded-sm border border-control bg-surface px-3 text-left text-body-sm text-ink","transition-colors duration-fast ease-out-quart","disabled:cursor-default disabled:border-hairline disabled:bg-sunken disabled:text-ink-disabled",r?"min-h-8 items-start py-2":"h-8 items-center",!l&&"cursor-pointer hover:bg-elevated"),children:f?p.jsx("span",{className:A("min-w-0 flex-1 pr-8",r?"whitespace-pre-wrap break-words":"truncate"),children:f}):p.jsx("span",{className:"min-w-0 flex-1 truncate pr-8 text-ink-dim",children:s})}),!l&&p.jsx(we,{variant:"ghost",size:"icon-sm",onClick:P,title:"Edit","aria-label":`Edit ${t}`,tabIndex:-1,className:A("absolute top-1/2 right-1.5 -translate-y-1/2",J),children:p.jsx(fZ,{})}),Z&&p.jsxs(we,{variant:"danger",size:"sm",onClick:I,title:"Clear field","aria-label":`Clear ${t}`,tabIndex:-1,className:A("absolute top-1/2 right-9 -translate-y-1/2",J),children:[p.jsx(ise,{}),"Clear"]})]})]})},DCe=b.memo(()=>($ct(),null));DCe.displayName="ModelsInitializer";const NCe=({size:e=24,className:t})=>p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:t,"aria-hidden":"true",children:[p.jsx("path",{d:"M12 2 20.7 7 20.7 17 12 22 3.3 17 3.3 7Z"}),p.jsx("path",{d:"M12 12V6.2"}),p.jsx("path",{d:"m12 12 5-2.9"}),p.jsx("path",{d:"m12 12 5 2.9"}),p.jsx("path",{d:"M12 12v5.8"}),p.jsx("path",{d:"m12 12-5 2.9"}),p.jsx("path",{d:"m12 12-5-2.9"})]}),Iy=({value:e,label:t,description:n,min:r,max:i,step:s=1,unit:a,onChange:o,icon:l,isSaving:c=!1})=>{const[u,d]=b.useState(e),[h,f]=b.useState(e.toString()),[O,g]=b.useState(!1),m=b.useId(),v=`${m}-label`,y=`${m}-description`,w=b.useRef(u);w.current=u,b.useEffect(()=>{O||(d(e),f(e.toString()))},[e,O]);const k=b.useCallback(async()=>{if(c)return;const D=Math.max(r,Math.min(i,w.current));if(d(D),f(D.toString()),D!==e)try{await o(D)}catch(F){console.error("Error updating setting via slider:",F),d(e),f(e.toString())}},[c,r,i,e,o]),x=D=>{const F=Number(D.target.value);d(F),f(F.toString())},S=()=>{const D=()=>{window.removeEventListener("pointerup",D),k()};window.addEventListener("pointerup",D)},T=D=>{(D.key.startsWith("Arrow")||D.key==="Home"||D.key==="End")&&k()},_=D=>{f(D.target.value)},P=async()=>{if(g(!1),c)return;let D=Number.parseFloat(h);if(Number.isNaN(D))D=e;else if(D=Math.max(r,Math.min(i,D)),s){D=Math.round(D/s)*s;const F=s.toString().split(".")[1]?.length||0;D=Number.parseFloat(D.toFixed(F))}if(D!==e){d(D),f(D.toString());try{await o(D)}catch(F){console.error("Error updating setting via input:",F),d(e),f(e.toString())}}else d(e),f(e.toString())},E=()=>{g(!0)},C=D=>{D.key==="Enter"&&D.target.blur()},Q=i>r?`${((u-r)/(i-r)*100).toFixed(2)}%`:"0%";return p.jsxs("div",{children:[p.jsxs("div",{className:"flex min-h-8 items-center justify-between gap-4",children:[p.jsxs("label",{id:v,htmlFor:`${m}-range`,className:"flex min-w-0 items-center gap-2 text-body text-ink",children:[l&&p.jsx(l,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim"}),p.jsx("span",{className:"truncate",children:t})]}),p.jsx("div",{className:"flex shrink-0 items-center gap-2",children:c?p.jsx(pr,{size:"md",label:`Saving ${t}`}):p.jsxs(p.Fragment,{children:[p.jsx(Si,{inputSize:"sm",type:"number",value:h,onChange:_,onBlur:P,onFocus:E,onKeyDown:C,min:r,max:i,step:s,disabled:c,"aria-labelledby":v,"aria-describedby":n?y:void 0,className:"w-18 text-right [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"}),a&&p.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:a})]})})]}),n&&p.jsx("p",{id:y,className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:n}),p.jsx("input",{id:`${m}-range`,type:"range",value:u,min:r,max:i,step:s,disabled:c,onChange:x,onPointerDown:S,onKeyUp:T,onBlur:()=>void k(),"aria-labelledby":v,"aria-describedby":n?y:void 0,style:{"--fill":Q},className:"mt-3 h-4 w-full cursor-pointer appearance-none bg-transparent bg-center bg-no-repeat bg-[length:100%_6px] bg-[linear-gradient(to_right,var(--color-accent)_0_var(--fill),var(--color-sunken)_var(--fill)_100%)] disabled:cursor-not-allowed disabled:bg-none disabled:bg-sunken [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-accent [&::-webkit-slider-thumb]:transition-colors [&::-webkit-slider-thumb]:duration-fast [&::-webkit-slider-thumb]:ease-out-quart [&::-webkit-slider-thumb]:hover:bg-accent-hover disabled:[&::-webkit-slider-thumb]:bg-ink-disabled"}),p.jsxs("div",{className:"flex justify-between font-mono text-mono-sm text-ink-dim",children:[p.jsx("span",{children:r}),p.jsx("span",{children:i})]})]})},rut={"--normal-bg":"var(--color-elevated)","--normal-text":"var(--color-ink)","--normal-border":"var(--color-control)","--border-radius":"var(--radius-md)","--gray12":"var(--color-ink)","--gray4":"var(--color-control)","--gray2":"var(--color-accent-wash)","--gray5":"var(--color-control)",background:"var(--color-elevated)",color:"var(--color-ink)",border:"1px solid var(--color-control)",boxShadow:"var(--shadow-overlay)",fontSize:"var(--text-meta)",padding:"12px 16px","--toast-close-button-start":"unset","--toast-close-button-end":"0px","--toast-close-button-transform":"translate(35%, -35%)"},iut=({duration:e})=>p.jsx(Lat,{duration:e,position:"bottom-right",toastOptions:{style:rut,closeButton:!0}});var hS={},Fy={},hC={},Nm={},Xm={},L6={},fae;function XCe(){return fae||(fae=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Doctype=e.CDATA=e.Tag=e.Style=e.Script=e.Comment=e.Directive=e.Text=e.Root=e.isTag=e.ElementType=void 0;var t;(function(r){r.Root="root",r.Text="text",r.Directive="directive",r.Comment="comment",r.Script="script",r.Style="style",r.Tag="tag",r.CDATA="cdata",r.Doctype="doctype"})(t=e.ElementType||(e.ElementType={}));function n(r){return r.type===t.Tag||r.type===t.Script||r.type===t.Style}e.isTag=n,e.Root=t.Root,e.Text=t.Text,e.Directive=t.Directive,e.Comment=t.Comment,e.Script=t.Script,e.Style=t.Style,e.Tag=t.Tag,e.CDATA=t.CDATA,e.Doctype=t.Doctype}(L6)),L6}var sr={},pae;function Oae(){if(pae)return sr;pae=1;var e=sr&&sr.__extends||function(){var x=function(S,T){return x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(_,P){_.__proto__=P}||function(_,P){for(var E in P)Object.prototype.hasOwnProperty.call(P,E)&&(_[E]=P[E])},x(S,T)};return function(S,T){if(typeof T!="function"&&T!==null)throw new TypeError("Class extends value "+String(T)+" is not a constructor or null");x(S,T);function _(){this.constructor=S}S.prototype=T===null?Object.create(T):(_.prototype=T.prototype,new _)}}(),t=sr&&sr.__assign||function(){return t=Object.assign||function(x){for(var S,T=1,_=arguments.length;T<_;T++){S=arguments[T];for(var P in S)Object.prototype.hasOwnProperty.call(S,P)&&(x[P]=S[P])}return x},t.apply(this,arguments)};Object.defineProperty(sr,"__esModule",{value:!0}),sr.cloneNode=sr.hasChildren=sr.isDocument=sr.isDirective=sr.isComment=sr.isText=sr.isCDATA=sr.isTag=sr.Element=sr.Document=sr.CDATA=sr.NodeWithChildren=sr.ProcessingInstruction=sr.Comment=sr.Text=sr.DataNode=sr.Node=void 0;var n=XCe(),r=function(){function x(){this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty(x.prototype,"parentNode",{get:function(){return this.parent},set:function(S){this.parent=S},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"previousSibling",{get:function(){return this.prev},set:function(S){this.prev=S},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"nextSibling",{get:function(){return this.next},set:function(S){this.next=S},enumerable:!1,configurable:!0}),x.prototype.cloneNode=function(S){return S===void 0&&(S=!1),w(this,S)},x}();sr.Node=r;var i=function(x){e(S,x);function S(T){var _=x.call(this)||this;return _.data=T,_}return Object.defineProperty(S.prototype,"nodeValue",{get:function(){return this.data},set:function(T){this.data=T},enumerable:!1,configurable:!0}),S}(r);sr.DataNode=i;var s=function(x){e(S,x);function S(){var T=x!==null&&x.apply(this,arguments)||this;return T.type=n.ElementType.Text,T}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 3},enumerable:!1,configurable:!0}),S}(i);sr.Text=s;var a=function(x){e(S,x);function S(){var T=x!==null&&x.apply(this,arguments)||this;return T.type=n.ElementType.Comment,T}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 8},enumerable:!1,configurable:!0}),S}(i);sr.Comment=a;var o=function(x){e(S,x);function S(T,_){var P=x.call(this,_)||this;return P.name=T,P.type=n.ElementType.Directive,P}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),S}(i);sr.ProcessingInstruction=o;var l=function(x){e(S,x);function S(T){var _=x.call(this)||this;return _.children=T,_}return Object.defineProperty(S.prototype,"firstChild",{get:function(){var T;return(T=this.children[0])!==null&&T!==void 0?T:null},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"lastChild",{get:function(){return this.children.length>0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"childNodes",{get:function(){return this.children},set:function(T){this.children=T},enumerable:!1,configurable:!0}),S}(r);sr.NodeWithChildren=l;var c=function(x){e(S,x);function S(){var T=x!==null&&x.apply(this,arguments)||this;return T.type=n.ElementType.CDATA,T}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 4},enumerable:!1,configurable:!0}),S}(l);sr.CDATA=c;var u=function(x){e(S,x);function S(){var T=x!==null&&x.apply(this,arguments)||this;return T.type=n.ElementType.Root,T}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 9},enumerable:!1,configurable:!0}),S}(l);sr.Document=u;var d=function(x){e(S,x);function S(T,_,P,E){P===void 0&&(P=[]),E===void 0&&(E=T==="script"?n.ElementType.Script:T==="style"?n.ElementType.Style:n.ElementType.Tag);var C=x.call(this,P)||this;return C.name=T,C.attribs=_,C.type=E,C}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"tagName",{get:function(){return this.name},set:function(T){this.name=T},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"attributes",{get:function(){var T=this;return Object.keys(this.attribs).map(function(_){var P,E;return{name:_,value:T.attribs[_],namespace:(P=T["x-attribsNamespace"])===null||P===void 0?void 0:P[_],prefix:(E=T["x-attribsPrefix"])===null||E===void 0?void 0:E[_]}})},enumerable:!1,configurable:!0}),S}(l);sr.Element=d;function h(x){return(0,n.isTag)(x)}sr.isTag=h;function f(x){return x.type===n.ElementType.CDATA}sr.isCDATA=f;function O(x){return x.type===n.ElementType.Text}sr.isText=O;function g(x){return x.type===n.ElementType.Comment}sr.isComment=g;function m(x){return x.type===n.ElementType.Directive}sr.isDirective=m;function v(x){return x.type===n.ElementType.Root}sr.isDocument=v;function y(x){return Object.prototype.hasOwnProperty.call(x,"children")}sr.hasChildren=y;function w(x,S){S===void 0&&(S=!1);var T;if(O(x))T=new s(x.data);else if(g(x))T=new a(x.data);else if(h(x)){var _=S?k(x.children):[],P=new d(x.name,t({},x.attribs),_);_.forEach(function(D){return D.parent=P}),x.namespace!=null&&(P.namespace=x.namespace),x["x-attribsNamespace"]&&(P["x-attribsNamespace"]=t({},x["x-attribsNamespace"])),x["x-attribsPrefix"]&&(P["x-attribsPrefix"]=t({},x["x-attribsPrefix"])),T=P}else if(f(x)){var _=S?k(x.children):[],E=new c(_);_.forEach(function(F){return F.parent=E}),T=E}else if(v(x)){var _=S?k(x.children):[],C=new u(_);_.forEach(function(F){return F.parent=C}),x["x-mode"]&&(C["x-mode"]=x["x-mode"]),T=C}else if(m(x)){var Q=new o(x.name,x.data);x["x-name"]!=null&&(Q["x-name"]=x["x-name"],Q["x-publicId"]=x["x-publicId"],Q["x-systemId"]=x["x-systemId"]),T=Q}else throw new Error("Not implemented yet: ".concat(x.type));return T.startIndex=x.startIndex,T.endIndex=x.endIndex,x.sourceCodeLocation!=null&&(T.sourceCodeLocation=x.sourceCodeLocation),T}sr.cloneNode=w;function k(x){for(var S=x.map(function(_){return w(_,!0)}),T=1;T<S.length;T++)S[T].prev=S[T-1],S[T-1].next=S[T];return S}return sr}var gae;function ICe(){return gae||(gae=1,function(e){var t=Xm&&Xm.__createBinding||(Object.create?function(o,l,c,u){u===void 0&&(u=c);var d=Object.getOwnPropertyDescriptor(l,c);(!d||("get"in d?!l.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return l[c]}}),Object.defineProperty(o,u,d)}:function(o,l,c,u){u===void 0&&(u=c),o[u]=l[c]}),n=Xm&&Xm.__exportStar||function(o,l){for(var c in o)c!=="default"&&!Object.prototype.hasOwnProperty.call(l,c)&&t(l,o,c)};Object.defineProperty(e,"__esModule",{value:!0}),e.DomHandler=void 0;var r=XCe(),i=Oae();n(Oae(),e);var s={withStartIndices:!1,withEndIndices:!1,xmlMode:!1},a=function(){function o(l,c,u){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof c=="function"&&(u=c,c=s),typeof l=="object"&&(c=l,l=void 0),this.callback=l??null,this.options=c??s,this.elementCB=u??null}return o.prototype.onparserinit=function(l){this.parser=l},o.prototype.onreset=function(){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null},o.prototype.onend=function(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))},o.prototype.onerror=function(l){this.handleCallback(l)},o.prototype.onclosetag=function(){this.lastNode=null;var l=this.tagStack.pop();this.options.withEndIndices&&(l.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(l)},o.prototype.onopentag=function(l,c){var u=this.options.xmlMode?r.ElementType.Tag:void 0,d=new i.Element(l,c,void 0,u);this.addNode(d),this.tagStack.push(d)},o.prototype.ontext=function(l){var c=this.lastNode;if(c&&c.type===r.ElementType.Text)c.data+=l,this.options.withEndIndices&&(c.endIndex=this.parser.endIndex);else{var u=new i.Text(l);this.addNode(u),this.lastNode=u}},o.prototype.oncomment=function(l){if(this.lastNode&&this.lastNode.type===r.ElementType.Comment){this.lastNode.data+=l;return}var c=new i.Comment(l);this.addNode(c),this.lastNode=c},o.prototype.oncommentend=function(){this.lastNode=null},o.prototype.oncdatastart=function(){var l=new i.Text(""),c=new i.CDATA([l]);this.addNode(c),l.parent=c,this.lastNode=l},o.prototype.oncdataend=function(){this.lastNode=null},o.prototype.onprocessinginstruction=function(l,c){var u=new i.ProcessingInstruction(l,c);this.addNode(u)},o.prototype.handleCallback=function(l){if(typeof this.callback=="function")this.callback(l,this.dom);else if(l)throw l},o.prototype.addNode=function(l){var c=this.tagStack[this.tagStack.length-1],u=c.children[c.children.length-1];this.options.withStartIndices&&(l.startIndex=this.parser.startIndex),this.options.withEndIndices&&(l.endIndex=this.parser.endIndex),c.children.push(l),u&&(l.prev=u,u.next=l),l.parent=c,this.lastNode=null},o}();e.DomHandler=a,e.default=a}(Xm)),Xm}var q6={},mae;function sut(){return mae||(mae=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CARRIAGE_RETURN_PLACEHOLDER_REGEX=e.CARRIAGE_RETURN_PLACEHOLDER=e.CARRIAGE_RETURN_REGEX=e.CARRIAGE_RETURN=e.CASE_SENSITIVE_TAG_NAMES_MAP=e.CASE_SENSITIVE_TAG_NAMES=void 0,e.CASE_SENSITIVE_TAG_NAMES=["animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"],e.CASE_SENSITIVE_TAG_NAMES_MAP=e.CASE_SENSITIVE_TAG_NAMES.reduce(function(t,n){return t[n.toLowerCase()]=n,t},{}),e.CARRIAGE_RETURN="\r",e.CARRIAGE_RETURN_REGEX=new RegExp(e.CARRIAGE_RETURN,"g"),e.CARRIAGE_RETURN_PLACEHOLDER="__HTML_DOM_PARSER_CARRIAGE_RETURN_PLACEHOLDER_".concat(Date.now(),"__"),e.CARRIAGE_RETURN_PLACEHOLDER_REGEX=new RegExp(e.CARRIAGE_RETURN_PLACEHOLDER,"g")}(q6)),q6}var vae;function FCe(){if(vae)return Nm;vae=1,Object.defineProperty(Nm,"__esModule",{value:!0}),Nm.formatAttributes=r,Nm.escapeSpecialCharacters=s,Nm.revertEscapedCharacters=a,Nm.formatDOM=o;var e=ICe(),t=sut();function n(l){return t.CASE_SENSITIVE_TAG_NAMES_MAP[l]}function r(l){for(var c={},u=0,d=l.length;u<d;u++){var h=l[u];c[h.name]=h.value}return c}function i(l){l=l.toLowerCase();var c=n(l);return c||l}function s(l){return l.replace(t.CARRIAGE_RETURN_REGEX,t.CARRIAGE_RETURN_PLACEHOLDER)}function a(l){return l.replace(t.CARRIAGE_RETURN_PLACEHOLDER_REGEX,t.CARRIAGE_RETURN)}function o(l,c,u){c===void 0&&(c=null);for(var d=[],h,f=0,O=l.length;f<O;f++){var g=l[f];switch(g.nodeType){case 1:{var m=i(g.nodeName);h=new e.Element(m,r(g.attributes)),h.children=o(m==="template"?g.content.childNodes:g.childNodes,h);break}case 3:h=new e.Text(a(g.nodeValue));break;case 8:h=new e.Comment(g.nodeValue);break;default:continue}var v=d[f-1]||null;v&&(v.next=h),h.parent=c,h.prev=v,h.next=null,d.push(h)}return u&&(h=new e.ProcessingInstruction(u.substring(0,u.indexOf(" ")).toLowerCase(),u),h.next=d[0]||null,h.parent=c,d.unshift(h),d[1]&&(d[1].prev=d[0])),d}return Nm}var yae;function aut(){if(yae)return hC;yae=1,Object.defineProperty(hC,"__esModule",{value:!0}),hC.default=g;var e=FCe(),t="html",n="head",r="body",i=/<([a-zA-Z]+[0-9]?)/,s=/<head[^]*>/i,a=/<body[^]*>/i,o=function(m,v){throw new Error("This browser does not support `document.implementation.createHTMLDocument`")},l=function(m,v){throw new Error("This browser does not support `DOMParser.prototype.parseFromString`")},c=typeof window=="object"&&window.DOMParser;if(typeof c=="function"){var u=new c,d="text/html";l=function(m,v){return v&&(m="<".concat(v,">").concat(m,"</").concat(v,">")),u.parseFromString(m,d)},o=l}if(typeof document=="object"&&document.implementation){var h=document.implementation.createHTMLDocument();o=function(m,v){if(v){var y=h.documentElement.querySelector(v);return y&&(y.innerHTML=m),h}return h.documentElement.innerHTML=m,h}}var f=typeof document=="object"&&document.createElement("template"),O;f&&f.content&&(O=function(m){return f.innerHTML=m,f.content.childNodes});function g(m){var v,y;m=(0,e.escapeSpecialCharacters)(m);var w=m.match(i),k=w&&w[1]?w[1].toLowerCase():"";switch(k){case t:{var x=l(m);if(!s.test(m)){var S=x.querySelector(n);(v=S?.parentNode)===null||v===void 0||v.removeChild(S)}if(!a.test(m)){var S=x.querySelector(r);(y=S?.parentNode)===null||y===void 0||y.removeChild(S)}return x.querySelectorAll(t)}case n:case r:{var T=o(m).querySelectorAll(k);return a.test(m)&&s.test(m)?T[0].parentNode.childNodes:T}default:{if(O)return O(m);var S=o(m,r).querySelector(r);return S.childNodes}}}return hC}var bae;function out(){if(bae)return Fy;bae=1;var e=Fy&&Fy.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Fy,"__esModule",{value:!0}),Fy.default=i;var t=e(aut()),n=FCe(),r=/<(![a-zA-Z\s]+)>/;function i(s){if(typeof s!="string")throw new TypeError("First argument must be a string");if(!s)return[];var a=s.match(r),o=a?a[1]:void 0;return(0,n.formatDOM)((0,t.default)(s),null,o)}return Fy}var fC={},zc={},fS={},wae;function lut(){if(wae)return fS;wae=1;var e=0;fS.SAME=e;var t=1;return fS.CAMELCASE=t,fS.possibleStandardNames={accept:0,acceptCharset:1,"accept-charset":"acceptCharset",accessKey:1,action:0,allowFullScreen:1,alt:0,as:0,async:0,autoCapitalize:1,autoComplete:1,autoCorrect:1,autoFocus:1,autoPlay:1,autoSave:1,capture:0,cellPadding:1,cellSpacing:1,challenge:0,charSet:1,checked:0,children:0,cite:0,class:"className",classID:1,className:1,cols:0,colSpan:1,content:0,contentEditable:1,contextMenu:1,controls:0,controlsList:1,coords:0,crossOrigin:1,dangerouslySetInnerHTML:1,data:0,dateTime:1,default:0,defaultChecked:1,defaultValue:1,defer:0,dir:0,disabled:0,disablePictureInPicture:1,disableRemotePlayback:1,download:0,draggable:0,encType:1,enterKeyHint:1,for:"htmlFor",form:0,formMethod:1,formAction:1,formEncType:1,formNoValidate:1,formTarget:1,frameBorder:1,headers:0,height:0,hidden:0,high:0,href:0,hrefLang:1,htmlFor:1,httpEquiv:1,"http-equiv":"httpEquiv",icon:0,id:0,innerHTML:1,inputMode:1,integrity:0,is:0,itemID:1,itemProp:1,itemRef:1,itemScope:1,itemType:1,keyParams:1,keyType:1,kind:0,label:0,lang:0,list:0,loop:0,low:0,manifest:0,marginWidth:1,marginHeight:1,max:0,maxLength:1,media:0,mediaGroup:1,method:0,min:0,minLength:1,multiple:0,muted:0,name:0,noModule:1,nonce:0,noValidate:1,open:0,optimum:0,pattern:0,placeholder:0,playsInline:1,poster:0,preload:0,profile:0,radioGroup:1,readOnly:1,referrerPolicy:1,rel:0,required:0,reversed:0,role:0,rows:0,rowSpan:1,sandbox:0,scope:0,scoped:0,scrolling:0,seamless:0,selected:0,shape:0,size:0,sizes:0,span:0,spellCheck:1,src:0,srcDoc:1,srcLang:1,srcSet:1,start:0,step:0,style:0,summary:0,tabIndex:1,target:0,title:0,type:0,useMap:1,value:0,width:0,wmode:0,wrap:0,about:0,accentHeight:1,"accent-height":"accentHeight",accumulate:0,additive:0,alignmentBaseline:1,"alignment-baseline":"alignmentBaseline",allowReorder:1,alphabetic:0,amplitude:0,arabicForm:1,"arabic-form":"arabicForm",ascent:0,attributeName:1,attributeType:1,autoReverse:1,azimuth:0,baseFrequency:1,baselineShift:1,"baseline-shift":"baselineShift",baseProfile:1,bbox:0,begin:0,bias:0,by:0,calcMode:1,capHeight:1,"cap-height":"capHeight",clip:0,clipPath:1,"clip-path":"clipPath",clipPathUnits:1,clipRule:1,"clip-rule":"clipRule",color:0,colorInterpolation:1,"color-interpolation":"colorInterpolation",colorInterpolationFilters:1,"color-interpolation-filters":"colorInterpolationFilters",colorProfile:1,"color-profile":"colorProfile",colorRendering:1,"color-rendering":"colorRendering",contentScriptType:1,contentStyleType:1,cursor:0,cx:0,cy:0,d:0,datatype:0,decelerate:0,descent:0,diffuseConstant:1,direction:0,display:0,divisor:0,dominantBaseline:1,"dominant-baseline":"dominantBaseline",dur:0,dx:0,dy:0,edgeMode:1,elevation:0,enableBackground:1,"enable-background":"enableBackground",end:0,exponent:0,externalResourcesRequired:1,fill:0,fillOpacity:1,"fill-opacity":"fillOpacity",fillRule:1,"fill-rule":"fillRule",filter:0,filterRes:1,filterUnits:1,floodOpacity:1,"flood-opacity":"floodOpacity",floodColor:1,"flood-color":"floodColor",focusable:0,fontFamily:1,"font-family":"fontFamily",fontSize:1,"font-size":"fontSize",fontSizeAdjust:1,"font-size-adjust":"fontSizeAdjust",fontStretch:1,"font-stretch":"fontStretch",fontStyle:1,"font-style":"fontStyle",fontVariant:1,"font-variant":"fontVariant",fontWeight:1,"font-weight":"fontWeight",format:0,from:0,fx:0,fy:0,g1:0,g2:0,glyphName:1,"glyph-name":"glyphName",glyphOrientationHorizontal:1,"glyph-orientation-horizontal":"glyphOrientationHorizontal",glyphOrientationVertical:1,"glyph-orientation-vertical":"glyphOrientationVertical",glyphRef:1,gradientTransform:1,gradientUnits:1,hanging:0,horizAdvX:1,"horiz-adv-x":"horizAdvX",horizOriginX:1,"horiz-origin-x":"horizOriginX",ideographic:0,imageRendering:1,"image-rendering":"imageRendering",in2:0,in:0,inlist:0,intercept:0,k1:0,k2:0,k3:0,k4:0,k:0,kernelMatrix:1,kernelUnitLength:1,kerning:0,keyPoints:1,keySplines:1,keyTimes:1,lengthAdjust:1,letterSpacing:1,"letter-spacing":"letterSpacing",lightingColor:1,"lighting-color":"lightingColor",limitingConeAngle:1,local:0,markerEnd:1,"marker-end":"markerEnd",markerHeight:1,markerMid:1,"marker-mid":"markerMid",markerStart:1,"marker-start":"markerStart",markerUnits:1,markerWidth:1,mask:0,maskContentUnits:1,maskUnits:1,mathematical:0,mode:0,numOctaves:1,offset:0,opacity:0,operator:0,order:0,orient:0,orientation:0,origin:0,overflow:0,overlinePosition:1,"overline-position":"overlinePosition",overlineThickness:1,"overline-thickness":"overlineThickness",paintOrder:1,"paint-order":"paintOrder",panose1:0,"panose-1":"panose1",pathLength:1,patternContentUnits:1,patternTransform:1,patternUnits:1,pointerEvents:1,"pointer-events":"pointerEvents",points:0,pointsAtX:1,pointsAtY:1,pointsAtZ:1,prefix:0,preserveAlpha:1,preserveAspectRatio:1,primitiveUnits:1,property:0,r:0,radius:0,refX:1,refY:1,renderingIntent:1,"rendering-intent":"renderingIntent",repeatCount:1,repeatDur:1,requiredExtensions:1,requiredFeatures:1,resource:0,restart:0,result:0,results:0,rotate:0,rx:0,ry:0,scale:0,security:0,seed:0,shapeRendering:1,"shape-rendering":"shapeRendering",slope:0,spacing:0,specularConstant:1,specularExponent:1,speed:0,spreadMethod:1,startOffset:1,stdDeviation:1,stemh:0,stemv:0,stitchTiles:1,stopColor:1,"stop-color":"stopColor",stopOpacity:1,"stop-opacity":"stopOpacity",strikethroughPosition:1,"strikethrough-position":"strikethroughPosition",strikethroughThickness:1,"strikethrough-thickness":"strikethroughThickness",string:0,stroke:0,strokeDasharray:1,"stroke-dasharray":"strokeDasharray",strokeDashoffset:1,"stroke-dashoffset":"strokeDashoffset",strokeLinecap:1,"stroke-linecap":"strokeLinecap",strokeLinejoin:1,"stroke-linejoin":"strokeLinejoin",strokeMiterlimit:1,"stroke-miterlimit":"strokeMiterlimit",strokeWidth:1,"stroke-width":"strokeWidth",strokeOpacity:1,"stroke-opacity":"strokeOpacity",suppressContentEditableWarning:1,suppressHydrationWarning:1,surfaceScale:1,systemLanguage:1,tableValues:1,targetX:1,targetY:1,textAnchor:1,"text-anchor":"textAnchor",textDecoration:1,"text-decoration":"textDecoration",textLength:1,textRendering:1,"text-rendering":"textRendering",to:0,transform:0,typeof:0,u1:0,u2:0,underlinePosition:1,"underline-position":"underlinePosition",underlineThickness:1,"underline-thickness":"underlineThickness",unicode:0,unicodeBidi:1,"unicode-bidi":"unicodeBidi",unicodeRange:1,"unicode-range":"unicodeRange",unitsPerEm:1,"units-per-em":"unitsPerEm",unselectable:0,vAlphabetic:1,"v-alphabetic":"vAlphabetic",values:0,vectorEffect:1,"vector-effect":"vectorEffect",version:0,vertAdvY:1,"vert-adv-y":"vertAdvY",vertOriginX:1,"vert-origin-x":"vertOriginX",vertOriginY:1,"vert-origin-y":"vertOriginY",vHanging:1,"v-hanging":"vHanging",vIdeographic:1,"v-ideographic":"vIdeographic",viewBox:1,viewTarget:1,visibility:0,vMathematical:1,"v-mathematical":"vMathematical",vocab:0,widths:0,wordSpacing:1,"word-spacing":"wordSpacing",writingMode:1,"writing-mode":"writingMode",x1:0,x2:0,x:0,xChannelSelector:1,xHeight:1,"x-height":"xHeight",xlinkActuate:1,"xlink:actuate":"xlinkActuate",xlinkArcrole:1,"xlink:arcrole":"xlinkArcrole",xlinkHref:1,"xlink:href":"xlinkHref",xlinkRole:1,"xlink:role":"xlinkRole",xlinkShow:1,"xlink:show":"xlinkShow",xlinkTitle:1,"xlink:title":"xlinkTitle",xlinkType:1,"xlink:type":"xlinkType",xmlBase:1,"xml:base":"xmlBase",xmlLang:1,"xml:lang":"xmlLang",xmlns:0,"xml:space":"xmlSpace",xmlnsXlink:1,"xmlns:xlink":"xmlnsXlink",xmlSpace:1,y1:0,y2:0,y:0,yChannelSelector:1,z:0,zoomAndPan:1},fS}var xae;function cut(){if(xae)return zc;xae=1;const e=0,t=1,n=2,r=3,i=4,s=5,a=6;function o(x){return c.hasOwnProperty(x)?c[x]:null}function l(x,S,T,_,P,E,C){this.acceptsBooleans=S===n||S===r||S===i,this.attributeName=_,this.attributeNamespace=P,this.mustUseProperty=T,this.propertyName=x,this.type=S,this.sanitizeURL=E,this.removeEmptyString=C}const c={};["children","dangerouslySetInnerHTML","defaultValue","defaultChecked","innerHTML","suppressContentEditableWarning","suppressHydrationWarning","style"].forEach(x=>{c[x]=new l(x,e,!1,x,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(([x,S])=>{c[x]=new l(x,t,!1,S,null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(x=>{c[x]=new l(x,n,!1,x.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(x=>{c[x]=new l(x,n,!1,x,null,!1,!1)}),["allowFullScreen","async","autoFocus","autoPlay","controls","default","defer","disabled","disablePictureInPicture","disableRemotePlayback","formNoValidate","hidden","loop","noModule","noValidate","open","playsInline","readOnly","required","reversed","scoped","seamless","itemScope"].forEach(x=>{c[x]=new l(x,r,!1,x.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(x=>{c[x]=new l(x,r,!0,x,null,!1,!1)}),["capture","download"].forEach(x=>{c[x]=new l(x,i,!1,x,null,!1,!1)}),["cols","rows","size","span"].forEach(x=>{c[x]=new l(x,a,!1,x,null,!1,!1)}),["rowSpan","start"].forEach(x=>{c[x]=new l(x,s,!1,x.toLowerCase(),null,!1,!1)});const d=/[\-\:]([a-z])/g,h=x=>x[1].toUpperCase();["accent-height","alignment-baseline","arabic-form","baseline-shift","cap-height","clip-path","clip-rule","color-interpolation","color-interpolation-filters","color-profile","color-rendering","dominant-baseline","enable-background","fill-opacity","fill-rule","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-name","glyph-orientation-horizontal","glyph-orientation-vertical","horiz-adv-x","horiz-origin-x","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","overline-position","overline-thickness","paint-order","panose-1","pointer-events","rendering-intent","shape-rendering","stop-color","stop-opacity","strikethrough-position","strikethrough-thickness","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-rendering","underline-position","underline-thickness","unicode-bidi","unicode-range","units-per-em","v-alphabetic","v-hanging","v-ideographic","v-mathematical","vector-effect","vert-adv-y","vert-origin-x","vert-origin-y","word-spacing","writing-mode","xmlns:xlink","x-height"].forEach(x=>{const S=x.replace(d,h);c[S]=new l(S,t,!1,x,null,!1,!1)}),["xlink:actuate","xlink:arcrole","xlink:role","xlink:show","xlink:title","xlink:type"].forEach(x=>{const S=x.replace(d,h);c[S]=new l(S,t,!1,x,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(x=>{const S=x.replace(d,h);c[S]=new l(S,t,!1,x,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(x=>{c[x]=new l(x,t,!1,x.toLowerCase(),null,!1,!1)});const f="xlinkHref";c[f]=new l("xlinkHref",t,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(x=>{c[x]=new l(x,t,!1,x.toLowerCase(),null,!0,!0)});const{CAMELCASE:O,SAME:g,possibleStandardNames:m}=lut(),y=":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD"+"\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",w=RegExp.prototype.test.bind(new RegExp("^(data|aria)-["+y+"]*$")),k=Object.keys(m).reduce((x,S)=>{const T=m[S];return T===g?x[S]=S:T===O?x[S.toLowerCase()]=S:x[S]=T,x},{});return zc.BOOLEAN=r,zc.BOOLEANISH_STRING=n,zc.NUMERIC=s,zc.OVERLOADED_BOOLEAN=i,zc.POSITIVE_NUMERIC=a,zc.RESERVED=e,zc.STRING=t,zc.getPropertyInfo=o,zc.isCustomAttribute=w,zc.possibleStandardNames=k,zc}var pS={},My={},z6,Sae;function uut(){if(Sae)return z6;Sae=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,o=/^\s+|\s+$/g,l=`
779
+ `)||t.length>Blt||SCe.test(t)?!1:Klt.includes(t.toLowerCase())}function nct(e){const t=e.trim();return t===""||t.length>Ylt||SCe.test(t)?!1:t.split(ect).length>=4}function AZ(e){return $Ce(e).sentence}function If(e){return eD(RZ(e))}const rct=/cannot find .* in the latest release artifacts/i;function Bse(e){return rct.test(e)?"muted":"show"}const Kz=5e3,kCe=()=>({firstNegativeAt:null});function F6(e,t){return t.isOnline?{state:kCe(),report:!1}:e.firstNegativeAt===null?{state:{firstNegativeAt:t.at},report:!1}:{state:e,report:t.at-e.firstNegativeAt>=Kz}}function ict(e,t){return e.firstNegativeAt===null?Kz:Math.max(0,e.firstNegativeAt+Kz-t)}const sct=({autoCheck:e=!0})=>{const{hostingProvider:t,shouldCheckInternet:n,isOnline:r,hasConnectivityIssue:i,connectivityIssue:s,serverSnapshot:a,refetchServerStatus:o,refetchInternetStatus:l}=nCe(),[c,u]=b.useState(!1),d=b.useRef(kCe()),[h,f]=b.useState(!1);b.useEffect(()=>{(!i||s!=="internet_offline")&&u(!1)},[i,s]),b.useEffect(()=>{const x=()=>F6(d.current,{isOnline:navigator.onLine,at:Date.now()}),S=()=>{const T=x();d.current=T.state,f(T.report)};return window.addEventListener("offline",S),window.addEventListener("online",S),()=>{window.removeEventListener("offline",S),window.removeEventListener("online",S)}},[]),b.useEffect(()=>{const x=F6(d.current,{isOnline:r,at:Date.now()});if(d.current=x.state,f(x.report),r||x.report)return;const S=window.setTimeout(()=>{l().then(T=>{const _=F6(d.current,{isOnline:T.data!==!1,at:Date.now()});d.current=_.state,f(_.report)})},ict(d.current,Date.now()));return()=>window.clearTimeout(S)},[r,l]),b.useEffect(()=>{if(e){o();const x=setInterval(()=>{o()},3e3);return()=>clearInterval(x)}},[e,o]);const O=()=>{(async()=>{try{await window.api?.backend?.reconnect?.()}finally{o(),n&&l()}})()},g=()=>{u(!0)},m=s==="internet_offline";if(!(m?h&&!c:i))return null;const y=m?null:sot(a),w=a?.reconnecting===!0,k=m||w||a?.state==="wedged"?"warning":"danger";return p.jsx("div",{className:"w-full",children:p.jsx(Ml,{variant:k,role:"alert",className:"items-center rounded-none border-x-0 border-t-0",children:p.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[p.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[p.jsx(rT,{children:m?`You are offline. ${t?`Your configured hosting provider (${t}) requires`:"This app's updates require"} an internet connection.`:y?.title??"A connectivity issue has been detected."}),!m&&y?.detail?p.jsx(rT,{children:y.detail}):null]}),p.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[p.jsx(we,{variant:"ghost",size:"sm",onClick:O,children:"Retry"}),m&&p.jsx(we,{variant:"ghost",size:"sm","aria-label":"dismiss",onClick:g,children:"Dismiss"})]})]})})})},Tr=re.string().min(1).max(128).regex(/^[a-zA-Z0-9_-]+$/),uC=re.string().min(1).max(256).regex(/^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/),dC=re.string().min(1).max(32768),Wr=re.string().regex(/^[a-f0-9]{12}$/),TCe=/^[a-f0-9]{32}$/,Zs=re.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/),Yse=re.object({data_b64:re.string().min(1).max(1e6),mime_type:re.enum(["image/png","image/jpeg","image/gif","image/webp"])}).strict(),Rg=2e5,VP=256,_Ce=100,Jz=1e6,Kf=re.string().min(1).max(128).refine(e=>e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\")&&[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127)),Zse=re.object({kind:re.enum(["agent","team"]),name:Kf}).strict(),Hse=re.object({provider:re.string().min(1).max(128),model_id:re.string().min(1).max(512),reasoning_effort:re.string().min(1).max(64).nullable()}).strict(),Kse=re.object({kind:re.enum(["role","specialist"]).optional(),description:re.string().max(8e3).optional(),instructions:re.string().max(8e3).optional(),tools:re.array(re.string().min(1).max(128)).max(256).optional(),effort:re.string().max(64).optional(),delegate:re.boolean().optional()}).strict(),Jse=re.object({name:re.string().min(1).max(64).optional(),description:re.string().max(8e3).optional(),manager:Kf.optional(),members:re.array(re.object({role:Kf,count:re.number().int().min(1).max(16),kind:re.enum(["agent","team"])}).strict()).max(128).optional(),instructions:re.string().max(8e3).optional(),project:re.string().max(8e3).optional()}).strict(),act=re.record(re.array(re.string().max(1024)).max(100)),eae=re.enum(["minutes","hours","days"]);function oct(e){return!/^\.+$/.test(e)}const PCe=e=>LQ.safeParse(e).success,LQ=re.string().min(1).max(128).refine(e=>[...e].every(t=>t.charCodeAt(0)>=32&&t.charCodeAt(0)!==127&&t!=="/"&&t!=="\\")).refine(oct),tae=re.enum(["str","int","float","bool","list","dict"]),nae=re.string().max(16384),rae=re.object({is_active:re.boolean().nullish(),one_time:re.boolean().nullish(),start_time_utc:re.string().max(64).nullish(),end_time_utc:re.string().max(64).nullish()}).strict(),lct=re.object({conversation_length:re.number().int().optional(),detail_length:re.number().int().optional(),max_learnings_history:re.number().int().optional(),hosting:re.string().max(256).optional(),model_name:re.string().max(1024).optional(),auto_save_conversation:re.boolean().optional()}).strict();re.discriminatedUnion("op",[re.object({op:re.literal("capabilities")}).strict(),re.object({op:re.literal("profiles.list")}).strict(),re.object({op:re.literal("profiles.get"),name:Kf}).strict(),re.object({op:re.literal("profiles.install"),name:Kf,requestId:Zs}).strict(),re.object({op:re.literal("profiles.create"),name:Kf,requestId:Zs,fields:Kse.extend({description:re.string().max(8e3),instructions:re.string().min(1).max(8e3)})}).strict(),re.object({op:re.literal("profiles.update"),name:Kf,requestId:Zs,fields:Kse}).strict(),re.object({op:re.literal("teams.list")}).strict(),re.object({op:re.literal("teams.get"),name:Kf}).strict(),re.object({op:re.literal("teams.create"),requestId:Zs,fields:Jse.extend({name:re.string().min(1).max(64)})}).strict(),re.object({op:re.literal("teams.update"),name:Kf,requestId:Zs,fields:Jse}).strict(),re.object({op:re.literal("sessions.list"),limit:re.number().int().min(1).max(500).optional()}).strict(),re.object({op:re.literal("sessions.search"),q:re.string().min(1).max(VP),limit:re.number().int().min(1).max(500).optional()}).strict(),re.object({op:re.literal("sessions.create"),requestId:Zs,cwd:re.string().min(1).max(4096),target:Zse.optional(),model:Hse.optional()}).strict(),re.object({op:re.literal("sessions.preview"),requestId:Zs,cwd:re.string().min(1).max(4096),target:Zse.optional(),model:Hse.optional()}).strict(),re.object({op:re.literal("sessions.get"),sessionId:Wr}).strict(),re.object({op:re.literal("sessions.history"),sessionId:Wr,beforeId:Tr.optional(),limit:re.number().int().min(1).max(500).optional()}).strict(),re.object({op:re.literal("subagents.transcript"),sessionId:Wr,childId:Wr,beforeId:Tr.optional(),limit:re.number().int().min(1).max(500).optional()}).strict(),re.object({op:re.literal("sessions.message"),sessionId:Wr,requestId:Zs,text:re.string().max(Rg),images:re.array(Yse).max(8).optional(),mode:re.enum(["prompt","steer"]).optional()}).strict(),re.object({op:re.literal("sessions.command"),sessionId:Wr,requestId:Zs,command:re.string().regex(/^\/?[A-Za-z]+$/).max(64),args:re.string().max(Rg).optional(),images:re.array(Yse).max(8).optional()}).strict(),re.object({op:re.literal("sessions.move"),sessionId:Wr,requestId:Zs,cwd:re.string().min(1).max(4096)}).strict(),re.object({op:re.literal("sessions.answer"),sessionId:Wr,epoch:Tr,requestId:Tr,value:re.string().max(32768).optional(),approved:re.boolean().optional(),questionIndex:re.number().int().min(0).optional()}).strict(),re.object({op:re.literal("sessions.seen"),sessionId:Wr,completionToken:re.string().uuid()}).strict(),re.object({op:re.literal("sessions.notified"),sessionId:Wr,completionToken:re.string().uuid()}).strict(),re.object({op:re.literal("sessions.watch"),sessionId:Wr,subscriptionId:re.string().regex(TCe),visible:re.boolean(),canNotify:re.boolean()}).strict(),re.object({op:re.literal("sessions.warm"),sessionId:Wr}).strict(),re.object({op:re.literal("sessions.interrupt"),sessionId:Wr,requestId:Zs}).strict(),re.object({op:re.literal("sessions.variables.list"),sessionId:Wr}).strict(),re.object({op:re.literal("sessions.variables.create"),sessionId:Wr,key:LQ,value:nae,type:tae}).strict(),re.object({op:re.literal("sessions.variables.update"),sessionId:Wr,key:LQ,value:nae,type:tae}).strict(),re.object({op:re.literal("sessions.variables.delete"),sessionId:Wr,key:LQ}).strict(),re.object({op:re.literal("sessions.presence"),subscriptionId:re.string().regex(/^[a-f0-9]{1,64}$/),canNotify:re.boolean(),canNotifyKinds:re.array(re.enum(["complete","error"])).max(4),sessionId:re.string().regex(/^([a-f0-9]{12})?$/),window:re.object({exists:re.boolean(),focused:re.boolean(),visible:re.boolean(),minimized:re.boolean()}).strict()}).strict(),re.object({op:re.literal("legacy.models"),provider:re.string().max(128).optional(),sort:re.enum(["id","name","provider","recommended"]).optional(),direction:re.enum(["ascending","descending"]).optional()}).strict(),re.object({op:re.literal("legacy.models.providers")}).strict(),re.object({op:re.literal("auth.probe"),provider:Tr}).strict(),re.object({op:re.literal("legacy.agent.upload"),agentId:Tr}).strict(),re.object({op:re.literal("legacy.agents.list"),page:re.number().int().min(1).optional(),perPage:re.number().int().min(1).max(500).optional(),name:re.string().max(256).optional(),sort:re.string().max(64).optional(),direction:re.enum(["asc","desc"]).optional()}).strict(),re.object({op:re.literal("legacy.agent.get"),agentId:Tr}).strict(),re.object({op:re.literal("legacy.agent.history"),agentId:Tr,page:re.number().int().min(1).optional(),perPage:re.number().int().min(1).max(500).optional()}).strict(),re.object({op:re.literal("legacy.jobs.list"),agentId:Tr.optional(),status:re.string().max(64).optional()}).strict(),re.object({op:re.literal("legacy.job.get"),jobId:Tr}).strict(),re.object({op:re.literal("legacy.schedules.list"),page:re.number().int().min(1).optional(),perPage:re.number().int().min(1).max(100).optional()}).strict(),re.object({op:re.literal("legacy.agent.schedules.list"),agentId:Tr,page:re.number().int().min(1).optional(),perPage:re.number().int().min(1).max(100).optional()}).strict(),re.object({op:re.literal("legacy.agent.schedule.create"),agentId:Tr,schedule:rae.extend({prompt:re.string().max(64e3),interval:re.number().int().min(1),unit:eae})}).strict(),re.object({op:re.literal("legacy.schedule.get"),scheduleId:Tr}).strict(),re.object({op:re.literal("legacy.schedule.edit"),scheduleId:Tr,schedule:rae.extend({prompt:re.string().max(64e3).nullish(),interval:re.number().int().min(1).nullish(),unit:eae.nullish()})}).strict(),re.object({op:re.literal("legacy.schedule.remove"),scheduleId:Tr}).strict(),re.object({op:re.literal("legacy.agent.create"),agent:re.record(re.unknown())}).strict(),re.object({op:re.literal("legacy.agent.update"),agentId:Tr,update:re.record(re.unknown())}).strict(),re.object({op:re.literal("legacy.agent.delete"),agentId:Tr}).strict(),re.object({op:re.literal("legacy.agent.conversation.clear"),agentId:Tr}).strict(),re.object({op:re.literal("legacy.agent.systemPrompt.get"),agentId:Tr}).strict(),re.object({op:re.literal("legacy.agent.systemPrompt.update"),agentId:Tr,systemPrompt:re.string().max(Jz)}).strict(),re.object({op:re.literal("legacy.agent.download"),agentId:Tr}).strict(),re.object({op:re.literal("legacy.job.cancel"),jobId:Tr}).strict(),re.object({op:re.literal("commands.list")}).strict(),re.object({op:re.literal("commands.entities"),sessionId:Wr,command:Tr,name:re.string().max(128).optional()}).strict(),re.object({op:re.literal("models.catalogue"),live:re.boolean().optional()}).strict(),re.object({op:re.literal("usage.get"),provider:Tr.optional(),live:re.boolean().optional(),refresh:re.boolean().optional()}).strict(),re.object({op:re.literal("analytics.get"),sessionId:Wr.optional(),sinceMs:re.number().int().nonnegative().optional(),untilMs:re.number().int().nonnegative().optional(),days:re.number().int().min(1).max(366).optional()}).strict(),re.object({op:re.literal("info.get")}).strict(),re.object({op:re.literal("sessions.report"),sessionId:Wr,recentLimit:re.number().int().min(0).max(50).optional()}).strict(),re.object({op:re.literal("skills.list"),sessionId:Wr,name:Tr.optional()}).strict(),re.object({op:re.literal("sessions.failovers"),sessionId:Wr}).strict(),re.object({op:re.literal("sessions.credential"),sessionId:Wr,action:re.enum(["list","store","forget"]),key:uC.optional(),value:dC.optional(),confirmed:re.boolean().optional()}).strict(),re.object({op:re.literal("sessions.fork"),sessionId:Wr,requestId:Zs,message:re.string().max(2e5).optional(),boundary:re.literal("next_safe").optional()}).strict(),re.object({op:re.literal("sessions.stop"),requestId:Zs,targets:re.array(Wr).min(1).max(100),confirmed:re.literal(!0)}).strict(),re.object({op:re.literal("sessions.aside"),sessionId:Wr,requestId:Zs,text:re.string().min(1).max(32768),asideId:Zs.optional()}).strict(),re.object({op:re.literal("sessions.adopt"),sessionId:Wr,requestId:Zs,asideId:Zs,confirmed:re.literal(!0)}).strict(),re.object({op:re.literal("sessions.aside.get"),sessionId:Wr,asideId:Zs}).strict(),re.object({op:re.literal("sessions.aside.close"),sessionId:Wr,asideId:Zs}).strict(),re.object({op:re.literal("mcp.list"),sessionId:Wr}).strict(),re.object({op:re.literal("mcp.credentials.store"),sessionId:Wr,name:re.string().min(1).max(256),values:re.record(re.string().min(1).max(128),re.string().min(1).max(32768)).refine(e=>Object.keys(e).length<=32&&Object.values(e).reduce((t,n)=>t+n.length,0)<=65536,{message:"Too many secret values, or too much secret text, for one MCP credential write."}),confirmedReplace:re.array(re.string().min(1).max(128)).max(32)}).strict(),re.object({op:re.literal("mcp.control"),sessionId:Wr,control:re.object({action:re.enum(["list","add","remove","reload","connect","probe","disconnect","login","logout","reauth","status","cancel"]),name:re.string().regex(/^[A-Za-z0-9_.:-]{1,100}$/).optional(),scope:re.enum(["global","project"]).optional(),command:re.string().min(1).max(4096).optional(),args:re.array(re.string().max(8192)).max(128).optional(),env:re.record(re.string().regex(/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/)).optional(),url:re.string().max(4096).optional(),headers:re.record(re.string().regex(/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/)).optional(),oauth:re.boolean().optional(),confirmed:re.boolean().optional(),operation_id:re.string().regex(/^[a-f0-9]{32}$/).optional()}).strict()}).strict(),re.object({op:re.literal("radient.request"),control:re.object({operation:re.enum(["account","prices","credits","usage","provision","application.create","agents.list","agents.get","agents.create","agents.update","agents.delete","agents.like","agents.unlike","agents.liked","agents.like_count","agents.favourite","agents.unfavourite","agents.favourited","agents.favourite_count","agents.download_count","comments.list","comments.create","comments.update","comments.delete","account.agents"]),request_id:Zs.optional(),tenant_id:Tr.optional(),account_id:Tr.optional(),agent_id:Tr.optional(),comment_id:Tr.optional(),query:re.record(re.union([re.string().max(1024),re.number().int()])).optional(),payload:re.record(re.unknown()).optional(),confirmed:re.boolean().optional()}).strict()}).strict(),re.object({op:re.literal("providers.list")}).strict(),re.object({op:re.literal("accounts.list")}).strict(),re.object({op:re.literal("accounts.remove"),accountId:re.number().int().positive(),confirmed:re.literal(!0)}).strict(),re.object({op:re.literal("auth.start"),provider:Tr}).strict(),re.object({op:re.literal("auth.status"),id:Tr}).strict(),re.object({op:re.literal("auth.input"),id:Tr,promptId:Tr,value:dC}).strict(),re.object({op:re.literal("auth.cancel"),id:Tr}).strict(),re.object({op:re.literal("auth.key"),provider:Tr,value:dC}).strict(),re.object({op:re.literal("auth.logout"),provider:Tr}).strict(),re.object({op:re.literal("settings.list")}).strict(),re.object({op:re.literal("settings.edit"),key:uC,value:re.unknown().refine(e=>e!==void 0,"A setting value is required."),base:act.optional()}).strict(),re.object({op:re.literal("settings.reset"),key:uC}).strict(),re.object({op:re.literal("config.get")}).strict(),re.object({op:re.literal("config.update"),value:lct}).strict(),re.object({op:re.literal("instructions.get")}).strict(),re.object({op:re.literal("instructions.update"),content:re.string().max(64e3)}).strict(),re.object({op:re.literal("credentials.list")}).strict(),re.object({op:re.literal("credentials.update"),key:uC,value:dC}).strict()]);const cct=88e4,uct=11e5,lD=cct,dct=uct;function DZ(e){switch(e.op){case"capabilities":return{path:"/v1/capabilities",method:"GET"};case"profiles.list":return{path:"/v1/desktop/profiles",method:"GET"};case"profiles.get":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"GET"};case"profiles.install":return{path:"/v1/desktop/profiles/install",method:"POST",body:{request_id:e.requestId,name:e.name}};case"profiles.create":return{path:"/v1/desktop/profiles",method:"POST",body:{request_id:e.requestId,name:e.name,...e.fields}};case"profiles.update":return{path:`/v1/desktop/profiles/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields}};case"teams.list":return{path:"/v1/desktop/teams",method:"GET"};case"teams.get":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"GET"};case"teams.create":return{path:"/v1/desktop/teams",method:"POST",body:{request_id:e.requestId,...e.fields}};case"teams.update":return{path:`/v1/desktop/teams/${encodeURIComponent(e.name)}`,method:"PATCH",body:{request_id:e.requestId,...e.fields}};case"sessions.list":return{path:`/v1/desktop/sessions?limit=${e.limit??100}`,method:"GET"};case"sessions.search":return{path:`/v1/desktop/sessions/search?${new URLSearchParams({q:e.q,limit:String(e.limit??_Ce)})}`,method:"GET"};case"sessions.create":return{path:"/v1/desktop/sessions",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.preview":return{path:"/v1/desktop/sessions/preview",method:"POST",body:{request_id:e.requestId,cwd:e.cwd,...e.target?{target:e.target}:{},...e.model?{model:e.model}:{}}};case"sessions.get":return{path:`/v1/desktop/sessions/${e.sessionId}`,method:"GET"};case"sessions.history":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),{path:`/v1/desktop/sessions/${e.sessionId}/history?${t}`,method:"GET"}}case"subagents.transcript":{const t=new URLSearchParams({limit:String(e.limit??100)});return e.beforeId&&t.set("before_id",e.beforeId),{path:`/v1/desktop/sessions/${e.sessionId}/children/${e.childId}/transcript?${t}`,method:"GET"}}case"sessions.message":return{path:`/v1/desktop/sessions/${e.sessionId}/messages`,method:"POST",body:{request_id:e.requestId,text:e.text,images:e.images??[],mode:e.mode??"prompt"}};case"sessions.command":return{path:`/v1/desktop/sessions/${e.sessionId}/commands`,method:"POST",body:{request_id:e.requestId,command:e.command,args:e.args??"",images:e.images??[]}};case"sessions.answer":return{path:`/v1/desktop/sessions/${e.sessionId}/answers`,method:"POST",body:{epoch:e.epoch,request_id:e.requestId,value:e.value,approved:e.approved,question_index:e.questionIndex}};case"sessions.seen":return{path:`/v1/desktop/sessions/${e.sessionId}/seen`,method:"POST",body:{completion_token:e.completionToken}};case"sessions.notified":return{path:`/v1/desktop/sessions/${e.sessionId}/notified`,method:"POST",body:{completion_token:e.completionToken}};case"sessions.watch":return{path:`/v1/desktop/sessions/${e.sessionId}/watch`,method:"POST",body:{subscription_id:e.subscriptionId,visible:e.visible,can_notify:e.canNotify}};case"sessions.presence":return{path:"/v1/desktop/presence",method:"POST",body:{subscription_id:e.subscriptionId,can_notify_kinds:e.canNotifyKinds,session_id:e.sessionId,window:e.window,can_notify:e.canNotify}};case"sessions.move":return{path:`/v1/desktop/sessions/${e.sessionId}/working-directory`,method:"POST",body:{request_id:e.requestId,cwd:e.cwd}};case"sessions.warm":return{path:`/v1/desktop/sessions/${e.sessionId}/warm`,method:"POST",body:{}};case"sessions.interrupt":return{path:`/v1/desktop/sessions/${e.sessionId}/interrupt`,method:"POST",body:{request_id:e.requestId}};case"sessions.variables.list":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"GET"};case"sessions.variables.create":return{path:`/v1/desktop/sessions/${e.sessionId}/variables`,method:"POST",body:{key:e.key,value:e.value,type:e.type}};case"sessions.variables.update":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"PATCH",body:{value:e.value,type:e.type}};case"sessions.variables.delete":return{path:`/v1/desktop/sessions/${e.sessionId}/variables/${encodeURIComponent(e.key)}`,method:"DELETE"};case"legacy.models":{const t=new URLSearchParams;return e.provider&&t.set("provider",e.provider),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:t.size>0?`/v1/models?${t}`:"/v1/models",method:"GET"}}case"legacy.models.providers":return{path:"/v1/models/providers",method:"GET"};case"auth.probe":return{path:`/v1/auth/providers/${e.provider}/probe`,method:"POST"};case"legacy.agent.upload":return{path:`/v1/agents/${e.agentId}/upload`,method:"POST"};case"legacy.agents.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return e.name&&t.set("name",e.name),e.sort&&t.set("sort",e.sort),e.direction&&t.set("direction",e.direction),{path:`/v1/agents?${t}`,method:"GET"}}case"legacy.agent.get":return{path:`/v1/agents/${e.agentId}`,method:"GET"};case"legacy.agent.history":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/history?${t}`,method:"GET"}}case"legacy.jobs.list":{const t=new URLSearchParams;return e.agentId&&t.set("agent_id",e.agentId),e.status&&t.set("status",e.status),{path:t.size>0?`/v1/jobs?${t}`:"/v1/jobs",method:"GET"}}case"legacy.job.get":return{path:`/v1/jobs/${e.jobId}`,method:"GET"};case"legacy.schedules.list":return{path:`/v1/schedules?${new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)})}`,method:"GET"};case"legacy.agent.schedules.list":{const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??10)});return{path:`/v1/agents/${e.agentId}/schedules?${t}`,method:"GET"}}case"legacy.agent.schedule.create":return{path:`/v1/agents/${e.agentId}/schedules`,method:"POST",body:e.schedule};case"legacy.schedule.get":return{path:`/v1/schedules/${e.scheduleId}`,method:"GET"};case"legacy.schedule.edit":return{path:`/v1/schedules/${e.scheduleId}`,method:"PATCH",body:e.schedule};case"legacy.schedule.remove":return{path:`/v1/schedules/${e.scheduleId}`,method:"DELETE"};case"legacy.agent.create":return{path:"/v1/agents",method:"POST",body:e.agent};case"legacy.agent.update":return{path:`/v1/agents/${e.agentId}`,method:"PATCH",body:e.update};case"legacy.agent.delete":return{path:`/v1/agents/${e.agentId}`,method:"DELETE"};case"legacy.agent.conversation.clear":return{path:`/v1/agents/${e.agentId}/conversation`,method:"DELETE"};case"legacy.agent.systemPrompt.get":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"GET"};case"legacy.agent.systemPrompt.update":return{path:`/v1/agents/${e.agentId}/system-prompt`,method:"PUT",body:{system_prompt:e.systemPrompt}};case"legacy.agent.download":return{path:`/v1/agents/${e.agentId}/download`,method:"GET"};case"legacy.job.cancel":return{path:`/v1/jobs/${e.jobId}`,method:"DELETE"};case"commands.list":return{path:"/v1/desktop/commands",method:"GET"};case"commands.entities":return{path:`/v1/desktop/sessions/${e.sessionId}/command-entities?command=${encodeURIComponent(e.command)}${e.name?`&name=${encodeURIComponent(e.name)}`:""}`,method:"GET"};case"models.catalogue":return{path:`/v1/desktop/models?live=${e.live??!1}`,method:"GET"};case"usage.get":{const t=new URLSearchParams({live:String(e.live??!1),refresh:String(e.refresh??!1)});return e.provider&&t.set("provider",e.provider),{path:`/v1/desktop/usage?${t}`,method:"GET"}}case"analytics.get":{const t=new URLSearchParams({days:String(e.days??30)});return e.sessionId&&t.set("session_id",e.sessionId),e.sinceMs!==void 0&&t.set("since_ms",String(e.sinceMs)),e.untilMs!==void 0&&t.set("until_ms",String(e.untilMs)),{path:`/v1/desktop/analytics?${t}`,method:"GET"}}case"info.get":return{path:"/v1/desktop/info",method:"GET"};case"sessions.report":{const t=new URLSearchParams({recent_limit:String(e.recentLimit??12)});return{path:`/v1/desktop/sessions/${e.sessionId}/report?${t}`,method:"GET"}}case"skills.list":return{path:`/v1/desktop/skills?session_id=${e.sessionId}${e.name?`&name=${encodeURIComponent(e.name)}`:""}`,method:"GET"};case"sessions.failovers":return{path:`/v1/desktop/sessions/${e.sessionId}/failovers`,method:"GET"};case"sessions.credential":return{path:`/v1/desktop/sessions/${e.sessionId}/credentials`,method:"POST",body:{action:e.action,key:e.key,value:e.value,confirmed:e.confirmed}};case"sessions.fork":return{path:`/v1/desktop/sessions/${e.sessionId}/fork`,method:"POST",body:{request_id:e.requestId,message:e.message,boundary:e.boundary}};case"sessions.stop":return{path:"/v1/desktop/stop",method:"POST",body:{request_id:e.requestId,targets:e.targets,confirmed:e.confirmed}};case"sessions.aside":return{path:`/v1/desktop/sessions/${e.sessionId}/asides`,method:"POST",body:{request_id:e.requestId,text:e.text,aside_id:e.asideId}};case"sessions.adopt":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}/adopt`,method:"POST",body:{request_id:e.requestId,confirmed:e.confirmed}};case"sessions.aside.get":case"sessions.aside.close":return{path:`/v1/desktop/sessions/${e.sessionId}/asides/${e.asideId}`,method:e.op==="sessions.aside.get"?"GET":"DELETE"};case"mcp.list":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"GET"};case"mcp.credentials.store":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp/credentials`,method:"POST",body:{name:e.name,values:e.values,confirmed_replace:e.confirmedReplace}};case"mcp.control":return{path:`/v1/desktop/sessions/${e.sessionId}/mcp`,method:"POST",body:e.control};case"radient.request":return{path:"/v1/desktop/radient",method:"POST",body:e.control};case"providers.list":return{path:"/v1/auth/providers",method:"GET"};case"accounts.list":return{path:"/v1/auth/status",method:"GET"};case"accounts.remove":return{path:`/v1/auth/accounts/${e.accountId}`,method:"DELETE"};case"auth.start":return{path:"/v1/auth/login",method:"POST",body:{provider:e.provider}};case"auth.status":return{path:`/v1/auth/operations/${e.id}`,method:"GET"};case"auth.input":return{path:`/v1/auth/operations/${e.id}/input`,method:"POST",body:{prompt_id:e.promptId,value:e.value}};case"auth.cancel":return{path:`/v1/auth/operations/${e.id}`,method:"DELETE"};case"auth.key":return{path:`/v1/auth/providers/${e.provider}/key`,method:"PUT",body:{value:e.value}};case"auth.logout":return{path:`/v1/auth/providers/${e.provider}/credentials`,method:"DELETE"};case"settings.list":return{path:"/v1/settings",method:"GET"};case"settings.edit":return{path:`/v1/settings/${e.key}`,method:"PATCH",body:{value:e.value,base:e.base}};case"settings.reset":return{path:`/v1/settings/${e.key}/reset`,method:"POST"};case"config.get":return{path:"/v1/config",method:"GET"};case"config.update":return{path:"/v1/config",method:"PATCH",body:e.value};case"instructions.get":return{path:"/v1/config/system-prompt",method:"GET"};case"instructions.update":return{path:"/v1/config/system-prompt",method:"PATCH",body:{content:e.content}};case"credentials.list":return{path:"/v1/credentials",method:"GET"};case"credentials.update":return{path:"/v1/credentials",method:"PATCH",body:{key:e.key,value:e.value}}}}const iae=64,sae=64*1024*1024,NZ="000000000000",XZ="00000000-0000-0000-0000-000000000000";function eU(e,t){const n=DZ({op:"sessions.message",sessionId:NZ,requestId:XZ,text:e,images:t,mode:"prompt"});return new TextEncoder().encode(JSON.stringify(n.body)).length}function M6(e){return e>=999500?`${(e/1e6).toFixed(1)} MB`:`${Math.round(e/1e3)} KB`}function ET(e,t){const n=M6(e);if(n!==M6(t))return[n,M6(t)];const r=n.endsWith("MB"),i=r?1e6:1e3,s=r?"MB":"KB";for(const a of[2,3]){const o=(e/i).toFixed(a),l=(t/i).toFixed(a);if(o!==l)return[`${o} ${s}`,`${l} ${s}`]}return[`${e.toLocaleString()} bytes`,`${t.toLocaleString()} bytes`]}function hct(e,t,n=lD){if(t.length>Rg)return`This command is ${t.length.toLocaleString()} characters, more than the ${Rg.toLocaleString()} one command can carry. Shorten it, or put the text in a message instead.`;const r=DZ({op:"sessions.command",sessionId:NZ,requestId:XZ,command:e,args:t}),i=new TextEncoder().encode(JSON.stringify(r.body)).length;if(i<=n)return null;const[s,a]=ET(i,n);return`This command is ${s}, more than the ${a} one command can carry. Shorten it, or put the text in a message instead.`}function Orr(e,t=dct){if(e.length>Jz)return`This system prompt is ${e.length.toLocaleString()} characters, more than the ${Jz.toLocaleString()} one agent can carry. Shorten it.`;const n=new TextEncoder().encode(JSON.stringify({system_prompt:e})).length;if(n<=t)return null;const[r,i]=ET(n,t);return`This system prompt is ${r}, more than the ${i} one agent can carry. Shorten it.`}function fct(e,t=lD){if(e.length>Rg)return`This first message is ${e.length.toLocaleString()} characters, more than the ${Rg.toLocaleString()} one message can carry. Shorten it, or send it in the new conversation instead.`;const n=DZ({op:"sessions.fork",sessionId:NZ,requestId:XZ,message:e,boundary:"next_safe"}),r=new TextEncoder().encode(JSON.stringify(n.body)).length;if(r<=t)return null;const[i,s]=ET(r,t);return`This first message is ${i}, more than the ${s} one message can carry. Shorten it, or send it in the new conversation instead.`}function pct(e,t,n=lD){if(e.length>Rg)return`This message is ${e.length.toLocaleString()} characters, more than the ${Rg.toLocaleString()} one message can carry. Split it across two messages.`;const r=eU(e,t);if(r<=n)return null;const i=eU(e,[]),s=r-i;if(t.length&&s>=i){const[l,c]=ET(s,n);return`These images total ${l}, more than the ${c} one message can carry. Remove an image, or send them in a second message.`}const[a,o]=ET(i,n);return`This message is ${a} of text, more than the ${o} one message can carry. Split it across two messages.`}const Td={capabilities:["desktop","capabilities"],providers:["desktop","auth","providers"],commands:["desktop","commands"],accounts:["desktop","auth","accounts"]},Oct=3e4,gct=15e3;function mct(e){return e?.desktop_available===!0}function Wa(){return ir({queryKey:Td.capabilities,queryFn:async()=>{try{return await qt({op:"capabilities"})}catch(e){throw e instanceof Error?e:new Error(String(e))}},staleTime:6e4,retry:!1,refetchInterval:e=>mct(e.state.data)?Oct:gct,refetchIntervalInBackground:!0})}function Oi(e,t,n=1){return!e||!e.desktop_available?!1:(e.features?.[t]??0)>=n}function BP(e){return ir({queryKey:Td.providers,queryFn:()=>qt({op:"providers.list"}).then(t=>t.providers),enabled:e,staleTime:3e4,retry:tD})}var $i=(e=>(e.CONNECT_PROVIDER="connect_provider",e.USER_PROFILE="user_profile",e.SEARCH_API="search_api",e.DEFAULT_MODEL="default_model",e.CREATE_AGENT="create_agent",e.CONGRATULATIONS="congratulations",e))($i||{});const QT=po()(jd((e,t)=>({isModalComplete:!1,isTourComplete:!1,currentStep:"connect_provider",isModalActive:!1,completeModalOnboarding:()=>{e({isModalComplete:!0,isModalActive:!1})},completeTourOnboarding:()=>{e({isTourComplete:!0})},setCurrentStep:n=>{e({currentStep:n})},activateModalOnboarding:()=>{e({isModalActive:!0})},deactivateModalOnboarding:()=>{e({isModalActive:!1})},resetOnboarding:()=>{e({isModalComplete:!1,isTourComplete:!1,currentStep:"connect_provider",isModalActive:!1})}}),{name:"onboarding-storage",partialize:e=>({isModalComplete:e.isModalComplete,isTourComplete:e.isTourComplete,currentStep:e.currentStep}),merge:(e,t)=>{const{isModalActive:n,...r}=e??{};return{...t,...r}},onRehydrateStorage:()=>(e,t)=>{t?console.error("Failed to rehydrate onboarding store:",t):e&&JSON.parse(localStorage.getItem("onboarding-storage")||"{}")?.state?.isComplete===!0&&!e.isModalComplete&&(console.log("Migrating old 'isComplete:true' state to 'isModalComplete:true'"),e.isModalComplete=!0)}}));function CCe(e){return e.some(t=>!t.local&&!t.credential_optional&&(t.configured||t.has_credential))}function vct(e){return e.onboardingComplete?"returning":e.census.status==="loading"||e.census.status==="failed"?"pending":e.census.status==="ready"?CCe(e.census.providers)?"returning":"first_time":e.legacy.status!=="ready"?"pending":e.legacy.keys.length===0?"first_time":"returning"}const yct=()=>{const e=Wa(),t=Oi(e.data,"auth"),n=BP(t),{shouldEnableQuery:r}=WP(),i=ir({queryKey:["open-credentials"],enabled:!t&&!e.isPending&&r({bypassInternetCheck:!0}),queryFn:()=>D2e.listOpenCredentials(oi.baseUrl),staleTime:5e3,retry:!1}),{isModalComplete:s,isModalActive:a,activateModalOnboarding:o,deactivateModalOnboarding:l,resetOnboarding:c}=QT();let u;e.isPending?u={status:"loading"}:t?n.isSuccess?u={status:"ready",providers:n.data}:n.isError?u={status:"failed"}:u={status:"loading"}:u={status:"unavailable"};let d;t||e.isPending?d={status:"loading"}:i.isSuccess&&i.data?d={status:"ready",keys:i.data.keys}:i.isError?d={status:"error"}:d={status:"loading"};const f=vct({onboardingComplete:s,census:u,legacy:d})==="first_time";return b.useEffect(()=>{f&&!a&&o()},[f,a,o]),{isFirstTimeUser:f,isOnboardingActive:a,activateOnboarding:o,deactivateOnboarding:l,resetOnboarding:c}},bct=(e,t)=>e===t?!0:!e||!t?!e&&!t:e.length!==t.length?!1:e.every((n,r)=>n===t[r]),aae=(e,t)=>{const n=e.timestamp instanceof Date?e.timestamp.getTime():new Date(e.timestamp).getTime(),r=t.timestamp instanceof Date?t.timestamp.getTime():new Date(t.timestamp).getTime();return e.id===t.id&&e.role===t.role&&n===r&&e.message===t.message&&e.code===t.code&&e.stdout===t.stdout&&e.stderr===t.stderr&&e.logging===t.logging&&e.formatted_print===t.formatted_print&&e.status===t.status&&e.task_classification===t.task_classification&&e.action===t.action&&e.execution_type===t.execution_type&&e.is_streamable===t.is_streamable&&e.is_complete===t.is_complete&&e.conversation_id===t.conversation_id&&e.content===t.content&&e.file_path===t.file_path&&e.replacements===t.replacements&&e.agent===t.agent&&e.learnings===t.learnings&&e.thinking===t.thinking&&bct(e.files,t.files)},Jc=e=>e.timestamp instanceof Date?e.timestamp.getTime():new Date(e.timestamp).getTime(),oae=e=>{for(let t=1;t<e.length;t+=1)if(Jc(e[t-1])>Jc(e[t]))return!1;return!0},tU=po((e,t)=>({messagesByConversation:{},paginationByConversation:{},lastUpdated:Date.now(),addMessages:(n,r,i=!1)=>{e(s=>{const a=s.messagesByConversation[n]||[],o=new Set(a.map(h=>h.id)),l=r.filter(h=>!o.has(h.id));if(l.length===0)return s;const c=oae(l)?l:[...l].sort((h,f)=>Jc(h)-Jc(f));let u=i?[...c,...a]:[...a,...c];return a.length===0||(i?Jc(c[c.length-1])<=Jc(a[0]):Jc(c[0])>=Jc(a[a.length-1]))||(u=[...u].sort((h,f)=>Jc(h)-Jc(f))),{messagesByConversation:{...s.messagesByConversation,[n]:u},lastUpdated:Date.now()}})},setMessages:(n,r)=>{e(i=>{const s=oae(r)?r:[...r].sort((o,l)=>Jc(o)-Jc(l)),a=i.messagesByConversation[n]||[];if(a.length===s.length){let o=!1;for(let l=0;l<a.length;l+=1)if(!aae(a[l],s[l])){o=!0;break}if(!o)return i}return{messagesByConversation:{...i.messagesByConversation,[n]:s},lastUpdated:Date.now()}})},addMessage:(n,r)=>{e(i=>{const s=i.messagesByConversation[n]||[];return s.some(a=>a.id===r.id)?i:{messagesByConversation:{...i.messagesByConversation,[n]:[...s,r]},lastUpdated:Date.now()}})},updateMessage:(n,r)=>{let i=!1;return e(s=>{const o=(s.messagesByConversation[n]||[]).map(l=>l.id===r.id?aae(l,r)?l:(i=!0,r):l);return i?{messagesByConversation:{...s.messagesByConversation,[n]:o},lastUpdated:Date.now()}:s}),i},clearConversation:n=>{e(r=>{const{[n]:i,...s}=r.messagesByConversation,{[n]:a,...o}=r.paginationByConversation;return{messagesByConversation:s,paginationByConversation:o,lastUpdated:Date.now()}})},getMessages:n=>t().messagesByConversation[n]||[],updatePagination:(n,r,i,s)=>{e(a=>{const o=a.paginationByConversation[n]||{currentPage:1,totalPages:1,hasMore:!1};return o.currentPage===r&&o.totalPages===i&&o.hasMore===s?a:{paginationByConversation:{...a.paginationByConversation,[n]:{...o,currentPage:r,totalPages:i,hasMore:s}},lastUpdated:Date.now()}})},getPagination:n=>t().paginationByConversation[n]||{currentPage:1,totalPages:1,hasMore:!1},updateScrollPosition:(n,r)=>{e(i=>{const s=i.paginationByConversation[n]||{currentPage:1,totalPages:1,hasMore:!1};return s.scrollPosition===r?i:{paginationByConversation:{...i.paginationByConversation,[n]:{...s,scrollPosition:r}}}})},getScrollPosition:n=>t().paginationByConversation[n]?.scrollPosition})),wct=po((e,t)=>({historyByConversation:{},setCurrentMessage:(n,r)=>{e(i=>{const s=i.historyByConversation[n]||{currentMessage:"",currentSequenceId:null};return{historyByConversation:{...i.historyByConversation,[n]:{...s,currentMessage:r}}}})},getCurrentMessage:n=>t().historyByConversation[n]?.currentMessage||"",setCurrentSequenceId:(n,r)=>{e(i=>{const s=i.historyByConversation[n]||{currentMessage:"",currentSequenceId:null};return{historyByConversation:{...i.historyByConversation,[n]:{...s,currentSequenceId:r}}}})},getCurrentSequenceId:n=>t().historyByConversation[n]?.currentSequenceId||null,resetHistory:n=>{e(r=>{const i=r.historyByConversation[n];return i?{historyByConversation:{...r.historyByConversation,[n]:{...i,currentSequenceId:null}}}:r})},clearConversationHistory:n=>{e(r=>{const{[n]:i,...s}=r.historyByConversation;return{historyByConversation:s}})}})),ECe=()=>{const e=Mi(),t=tU(r=>r.clearConversation),n=wct(r=>r.clearConversationHistory);return Ol({mutationFn:async({agentId:r})=>As(oi.baseUrl).agents.clearAgentConversation(r),onSuccess:(r,i)=>{e.invalidateQueries({queryKey:["agent",i.agentId,"conversation"]}),e.invalidateQueries({queryKey:["conversation-messages",i.agentId]}),t(i.agentId),n(i.agentId),ms("Conversation cleared")},onError:r=>{console.error("Error clearing agent conversation:",r),Rr(`Failed to clear conversation: ${r instanceof Error?r.message:"Unknown error"}`)}})},xct=(e,t)=>{const n=e.role==="user"||e.role==="human"?"user":"assistant";return{id:e.id,role:n,message:e.message,code:e.code,stdout:e.stdout,stderr:e.stderr,logging:e.logging,timestamp:e.timestamp?new Date(e.timestamp):new Date,files:e.files,action:e.action,execution_type:e.execution_type,task_classification:e.task_classification,is_complete:e.is_complete,is_streamable:e.is_streamable,conversation_id:t,content:e.content,file_path:e.file_path,replacements:e.replacements,agent:e.agent,learnings:e.learnings,thinking:e.thinking}},qQ=["credentials"],YP=()=>{const{shouldEnableQuery:e,getConnectivityError:t}=WP(),n=t();return b.useEffect(()=>{n&&console.error("Credentials connectivity error:",n.message)},[n]),ir({enabled:e({bypassInternetCheck:!0}),queryKey:qQ,queryFn:async()=>{const i=await As(oi.baseUrl).credentials.listCredentials();if(i.status>=400)throw new Error(i.message||"Failed to fetch credentials");return i.result},refetchOnWindowFocus:!1,staleTime:5e3})},IZ=()=>{const{data:e,isError:t,isPending:n,fetchStatus:r}=YP();return{hasRadientApiKey:!!e?.keys?.includes("RADIENT_API_KEY"),isUnavailable:t||n&&r==="idle"}},Sct=15*60*1e3,QCe=po()(jd((e,t)=>({providers:[],models:[],isLoading:!1,error:null,lastFetched:null,isInitialized:!1,fetchModels:async(n,r=!1)=>{const{lastFetched:i,isInitialized:s}=t(),a=Date.now();if(!(!r&&s&&i&&a-i<Sct)){e({isLoading:!0,error:null});try{const o=As(n),c=(await o.models.listProviders()).result?.providers||[],d=(await o.models.listModels("","recommended","descending")).result?.models||[];e({providers:c,models:d,isLoading:!1,lastFetched:a,isInitialized:!0})}catch(o){console.error("Failed to fetch models:",o),e({isLoading:!1,error:o instanceof Error?o.message:String(o)})}}},getModelsForProvider:n=>t().models.filter(r=>r.provider===n),reset:()=>{e({providers:[],models:[],isLoading:!1,error:null,lastFetched:null,isInitialized:!1})}}),{name:"local-operator-models",partialize:e=>({providers:e.providers,models:e.models,lastFetched:e.lastFetched,isInitialized:e.isInitialized})})),cD=({autoFetch:e=!0}={})=>{const t=oi.baseUrl,n=b.useRef(null),{shouldEnableQuery:r,getConnectivityError:i,hasConnectivityIssue:s}=WP(),{providers:a,models:o,isLoading:l,error:c,lastFetched:u,isInitialized:d,fetchModels:h,getModelsForProvider:f}=QCe(),O=b.useRef(!0),g=b.useRef(!1),m=b.useRef(null);b.useEffect(()=>(n.current&&(clearInterval(n.current),n.current=null),m.current&&(clearTimeout(m.current),m.current=null),e&&r({bypassInternetCheck:!0})?(O.current?(O.current=!1,m.current=window.setTimeout(()=>{!g.current&&r({bypassInternetCheck:!0})&&(h(t),g.current=!0),m.current=null},1e3)):g.current||(h(t),g.current=!0),n.current=window.setInterval(()=>{r({bypassInternetCheck:!0})&&h(t)},15*60*1e3),()=>{n.current&&(clearInterval(n.current),n.current=null),m.current&&(clearTimeout(m.current),m.current=null)}):()=>{m.current&&(clearTimeout(m.current),m.current=null)}),[e,t,h,r]),b.useEffect(()=>{!s&&e&&d&&h(t)},[s,e,d,t,h]);const v=b.useCallback(async()=>{if(r({bypassInternetCheck:!0}))await h(t,!0);else{const w=i();if(w)throw w}},[t,h,r,i]);return{providers:a,models:o,isLoading:l,error:c,lastFetched:u,isInitialized:d,getModelsForProvider:f,getModelById:w=>o.find(k=>k.id===w),refreshModels:v}},$ct=()=>{const{isLoading:e,error:t,refreshModels:n}=cD({autoFetch:!1}),r=b.useRef(!1);return b.useEffect(()=>{r.current||(r.current=!0)},[]),{isLoading:e,error:t,refreshModels:n}},lae=/name=([^;,]+)/,kct=/[/\\]/,Tct=/^data:([^;,]+)/,Ag=e=>{if(e.startsWith("data:image/")){const n=e.match(lae);if(n?.[1])try{return decodeURIComponent(n[1])}catch{return"Pasted image"}return"Pasted image"}if(e.startsWith("data:")){const n=e.match(lae);if(n?.[1])try{return decodeURIComponent(n[1])}catch{return"Pasted file"}const r=e.match(Tct);if(r?.[1]){const i=r[1].split("/")[0];if(i)return`Pasted ${i} file`}return"Pasted file"}const t=e.split(kct);return t[t.length-1]},Ss=po()(jd((e,t)=>({inputByConversation:{},addReply:(n,r)=>{const i=t().inputByConversation[n]||{currentInput:"",submittedMessages:[],currentHistoryIndex:null,replies:[],attachments:[]},s=Array.isArray(i.replies)?i.replies:[];e({inputByConversation:{...t().inputByConversation,[n]:{...i,replies:[...s,r]}}})},removeReply:(n,r)=>{const i=t().inputByConversation[n];i&&e({inputByConversation:{...t().inputByConversation,[n]:{...i,replies:i.replies.filter(s=>s.id!==r)}}})},clearReplies:n=>{const r=t().inputByConversation[n];r&&e({inputByConversation:{...t().inputByConversation,[n]:{...r,replies:[]}}})},addAttachment:(n,r)=>{const i=t().inputByConversation[n]||{currentInput:"",submittedMessages:[],currentHistoryIndex:null,replies:[],attachments:[]},s=Array.isArray(i.attachments)?i.attachments:[];e({inputByConversation:{...t().inputByConversation,[n]:{...i,attachments:[...s,r]}}})},removeAttachment:(n,r)=>{const i=t().inputByConversation[n];i&&e({inputByConversation:{...t().inputByConversation,[n]:{...i,attachments:i.attachments.filter(s=>s.id!==r)}}})},clearAttachments:n=>{const r=t().inputByConversation[n];r&&e({inputByConversation:{...t().inputByConversation,[n]:{...r,attachments:[]}}})},setCurrentInput:(n,r,i=0)=>{const s=t().inputByConversation[n]||{currentInput:"",submittedMessages:[],currentHistoryIndex:null,replies:[],attachments:[]};e({inputByConversation:{...t().inputByConversation,[n]:{...s,currentInput:r,unredactedChars:r?i:0}}})},getUnredactedChars:n=>t().inputByConversation[n]?.unredactedChars||0,getCurrentInput:n=>t().inputByConversation[n]?.currentInput||"",addSubmittedMessage:(n,r)=>{const i=t().inputByConversation[n]||{currentInput:"",submittedMessages:[],currentHistoryIndex:null,replies:[],attachments:[]},s=i.submittedMessages[i.submittedMessages.length-1],a=r&&r!==s?[...i.submittedMessages.slice(-19),r]:i.submittedMessages;e({inputByConversation:{...t().inputByConversation,[n]:{...i,submittedMessages:a}}})},getSubmittedMessages:n=>t().inputByConversation[n]?.submittedMessages||[],clearSubmittedMessages:n=>{const r=t().inputByConversation[n];r&&e({inputByConversation:{...t().inputByConversation,[n]:{...r,submittedMessages:[]}}})},getCurrentHistoryIndex:n=>t().inputByConversation[n]?.currentHistoryIndex??null,setCurrentHistoryIndex:(n,r)=>{const i=t().inputByConversation[n]||{currentInput:"",submittedMessages:[],currentHistoryIndex:null,replies:[],attachments:[]},s=i.submittedMessages;let a=null;typeof r=="number"&&s.length>0&&(a=Math.max(0,Math.min(r,s.length-1))),e({inputByConversation:{...t().inputByConversation,[n]:{...i,currentHistoryIndex:a}}})},resetCurrentHistoryIndex:n=>{const r=t().inputByConversation[n];r&&e({inputByConversation:{...t().inputByConversation,[n]:{...r,currentHistoryIndex:null}}})},clearAll:n=>{const{[n]:r,...i}=t().inputByConversation;e({inputByConversation:i})}}),{name:"conversation-input-store",partialize:e=>({inputByConversation:e.inputByConversation})})),v5="held",_ct=(e,t)=>e===t?"":e,RCe=(e,t)=>e===""?t:e,Pct=(e,t)=>e.length===0&&t?t:nU,nU=[],Cct=(e,t,n)=>{const r=n.text??"",i=RCe(e,r),s=t===null?nU:Pct(t,n.attachments),a=(n.attachments?.length??0)>0,o=r!=="",l=new Set([...(t??[]).map(f=>f.path),...s]),c=(n.attachments??nU).filter(f=>!l.has(f)),u=o&&i===e,d=a&&c.length>0;return{text:i,paths:s,missingFiles:c,withheld:o&&a&&u!==d?u?"text":"files":null}},Ect=(e,t,n)=>{if(e===null)return null;const i=((e==="text"?t:n??t)??[]).map(Ag),s=i.length===1,a=i.join(", ");return e==="text"?`The ${s?"file":"files"} ${a} from your refused message ${s?"is":"are"} attached again; its text was left out because the box already holds text you typed.`:`The text of your refused message was restored, but not its ${s?"file":"files"} ${a} — the composer already holds files you picked, so attach ${s?"it":"them"} again if you still need ${s?"it":"them"}.`},Qct=()=>0,Rct=({conversationId:e,onSubmit:t,scrollToBottom:n,draftHeld:r=!1,draftUnredacted:i=Qct})=>{const s=Ss(F=>F.getCurrentInput),a=Ss(F=>F.setCurrentInput),o=Ss(F=>F.addSubmittedMessage),l=Ss(F=>F.getSubmittedMessages),c=Ss(F=>F.getCurrentHistoryIndex),u=Ss(F=>F.setCurrentHistoryIndex),d=Ss(F=>F.resetCurrentHistoryIndex),[h,f]=b.useState(Ss.persist.hasHydrated?.()??!1),O=b.useRef(void 0),[g,m]=b.useState("");b.useEffect(()=>{const F=Ss.persist;let I,U;return F&&typeof F.onHydrate=="function"&&typeof F.onFinishHydration=="function"?(I=F.onHydrate(()=>f(!1)),U=F.onFinishHydration(()=>f(!0)),f(F.hasHydrated())):f(!0),()=>{I?.(),U?.()}},[]);const v=b.useRef(null),y=b.useRef(""),w=Ss(F=>e?F.inputByConversation[e]?.currentInput??"":""),k=b.useRef(""),x=e?l(e):[],S=e?c(e):null;b.useEffect(()=>{if(h)if(e){const F=s(e);S!==null&&x.length>0?m(x[S]||""):m(F),O.current=e,y.current=""}else m(""),O.current=void 0,y.current=""},[e,h,s,S,x]),b.useEffect(()=>{h&&e&&O.current!==e&&a(e,g)},[e,g,a,h]),b.useEffect(()=>{!h||!e||w!==k.current&&(k.current=w,w&&!g&&m(w))},[w,h,e,g]);const T=b.useCallback(F=>{if(m(F),e){if(r)return;k.current=F,a(e,F,i(F)),d(e)}},[e,a,d,r,i]),_=b.useRef(!1),P=b.useCallback(async()=>{if(!g.trim()||!e||_.current)return;_.current=!0;const F=g;let I=!1;const U=()=>{I||(I=!0,O.current===e&&m(Z=>_ct(Z,F)))},q=()=>{k.current="",a(e,""),d(e),y.current=""};try{const Z=await t?.(F,U);if(Z===!1){O.current===e&&m(W=>RCe(W,F));return}if(Z===v5){q();return}}finally{_.current=!1}U(),o(e,F),q(),n&&requestAnimationFrame(()=>{n()})},[g,e,t,o,a,d,n]),E=b.useCallback(()=>{const F=v.current;if(!F)return{line:0,totalLines:1};const I=F.value,U=F.selectionStart,Z=(I.substring(0,U).match(/\n/g)||[]).length+1,W=(I.match(/\n/g)||[]).length+1;return{line:Z,totalLines:W}},[]),C=b.useCallback(()=>E().line===1,[E]),Q=b.useCallback(()=>{const{line:F,totalLines:I}=E();return F===I},[E]),D=b.useCallback(F=>{if(e){if(F.key==="Enter"&&!F.shiftKey){F.preventDefault(),P();return}if(x.length){if(F.key==="ArrowUp"&&C()){if(F.preventDefault(),S===null)y.current=g,u(e,x.length-1),m(x[x.length-1]||"");else if(S>0){const I=S-1;u(e,I),m(x[I]||"")}setTimeout(()=>{if(v.current){const I=v.current.value.length;v.current.selectionStart=I,v.current.selectionEnd=I}},0)}if(F.key==="ArrowDown"&&Q()&&(F.preventDefault(),S!==null)){if(S<x.length-1){const I=S+1;u(e,I),m(x[I]||"")}else d(e),m(y.current),y.current="";setTimeout(()=>{if(v.current){const I=v.current.value.length;v.current.selectionStart=I,v.current.selectionEnd=I}},0)}}}},[P,C,Q,S,g,x,e,u,d]);return{inputValue:g,setInputValue:T,handleKeyDown:D,handleSubmit:P,textareaRef:v}},Act={name:"User",email:"user@example.com"},FZ=po()(jd(e=>({profile:Act,isSigningOut:!1,updateName:t=>{e(n=>({profile:{...n.profile,name:t}}))},updateEmail:t=>{e(n=>({profile:{...n.profile,email:t}}))},updateProfile:t=>{e(n=>({profile:{...n.profile,...t}}))},setIsSigningOut:t=>{e({isSigningOut:t})},clearProfile:()=>{e({profile:{name:"",email:""}})}}),{name:"user-profile-storage"}));function Dct(e){return{operation:e.operation,...e.tenantId?{tenant_id:e.tenantId}:{},...e.accountId?{account_id:e.accountId}:{},...e.agentId?{agent_id:e.agentId}:{},...e.commentId?{comment_id:e.commentId}:{},...e.query?{query:e.query}:{},...e.payload?{payload:e.payload}:{},...e.requestId?{request_id:e.requestId}:{},...e.confirmed?{confirmed:!0}:{}}}async function Oo(e){return(await qt({op:"radient.request",control:Dct(e)})).data}async function MZ(e){const t=await Oo(e);return t&&typeof t=="object"&&"result"in t?t.result:t}const zQ={all:["radient-user"],user:()=>[...zQ.all,"user"]};function cae(e){return e instanceof Error&&/sign in to radient/i.test(e.message)}const Nct=()=>{const e=Mi(),{setIsSigningOut:t}=FZ(),n=Wa(),r=Oi(n.data,"radient"),i=ir({queryKey:zQ.user(),queryFn:async()=>{try{return await MZ({operation:"account"})}catch(c){if(cae(c))return null;throw c}},enabled:r,staleTime:30*1e3,refetchOnWindowFocus:!0,retry:(c,u)=>!cae(u)&&c<2}),s=!!i.data&&!i.isLoading,a=s,o=Ol({onMutate:()=>{t(!0)},mutationFn:async()=>{const u=(await qt({op:"accounts.list"})).accounts.filter(d=>d.provider==="radient");for(const d of u)await qt({op:"accounts.remove",accountId:d.id,confirmed:!0});return!0},onSuccess:()=>{e.removeQueries({queryKey:zQ.all}),e.invalidateQueries({queryKey:Td.accounts}),ms("Successfully signed out"),t(!1)},onError:c=>{const u=c instanceof Error?c.message:String(c);Rr(`Failed to sign out: ${u}`),t(!1)}}),l=Ol({mutationFn:async()=>(e.invalidateQueries({queryKey:zQ.all}),!0)});return{user:i.data??void 0,isLoading:i.isLoading,isRefetching:i.isRefetching,error:i.error,hasLocalSession:a,isAuthenticated:s,unavailable:n.isSuccess&&!r,signOut:o.mutate,refreshUser:l.mutate,userQuery:i}},jZ=()=>{const e=FZ(),{user:t,isLoading:n,error:r,isAuthenticated:i,hasLocalSession:s,unavailable:a,signOut:o,refreshUser:l}=Nct();let c;return n?c=s?"restoring":"loading":i?c="authenticated":c="unauthenticated",b.useEffect(()=>{if(!i||!t?.account)return;const{account:u}=t;if(!u.name&&!u.email)return;const{name:d,email:h}=e.profile;(u.name&&u.name!==d||u.email&&u.email!==h)&&e.updateProfile({name:u.name||d,email:u.email||h})},[i,t,e]),{authStatus:c,isAuthenticated:i,hasLocalSession:s,isLoading:n,error:r,user:i&&t?.account?{name:t.account.name,email:t.account.email,radientUser:t}:null,unavailable:a,refreshUser:l,signOut:o,updateProfile:e.updateProfile,updateName:e.updateName,updateEmail:e.updateEmail}},RT=e=>e.replace(/\\/g,"/"),LZ=()=>window.location.hash?RT(window.location.hash.substring(1)):RT(window.location.pathname),e0=(e,t)=>RT(e).includes(t),Xct=()=>{const{agentId:e}=e2e(),t=ka(),n=()=>{const s=LZ();return e0(s,"/chat")?"chat":"agents"};return{agentId:e,navigateToAgent:(s,a)=>{if(!s)return;const o=a||n();t(`/${o}/${s}`)},clearAgentId:s=>{const a=s||n();t(`/${a}`)}}},Ict=()=>{const e=LZ();return e0(e,"/chat")?"chat":e0(e,"/agents")?"agents":e0(e,"/settings")?"settings":e0(e,"/agent-hub")?"agent-hub":e0(e,"/schedules")?"schedules":e0(e,"/browser")?"browser":"chat"},Fct=(e=50,t,n)=>{const r=b.useRef(null),i=t||r,[s,a]=b.useState(!1),o=b.useRef(!1),l=b.useRef(0),c=b.useRef(n),u=b.useCallback(()=>{const f=i.current;if(!f)return;const{scrollTop:O,scrollHeight:g,clientHeight:m}=f,v=Math.abs(O),w=g>m&&v>e;a(w)},[e,i]),d=b.useCallback(()=>{const f=i.current;f&&requestAnimationFrame(()=>{f.scrollTo({top:0,behavior:"smooth"}),requestAnimationFrame(u)})},[i,u]),h=b.useCallback(()=>{!i.current||o.current||(o.current=!0,requestAnimationFrame(()=>{u(),o.current=!1}))},[i,u]);return b.useEffect(()=>{const f=i.current;if(!f)return;c.current!==n&&(a(!1),l.current=0,c.current=n),f.addEventListener("scroll",h,{passive:!0});const O=requestAnimationFrame(u),g=window.setTimeout(u,100),m=window.setTimeout(u,500);return()=>{f.removeEventListener("scroll",h),cancelAnimationFrame(O),clearTimeout(g),clearTimeout(m)}},[i,n,h,u]),b.useEffect(()=>{const f=()=>{u()};return window.addEventListener("resize",f,{passive:!0}),()=>{window.removeEventListener("resize",f)}},[u]),b.useEffect(()=>{const f=i.current;if(!f)return;const O=new ResizeObserver(()=>{u()});return O.observe(f),()=>{O.disconnect()}},[i,u]),{containerRef:i,isFarFromBottom:s,scrollToBottom:d}},Mct=15*60*1e3,uae=250,dae=(e,t)=>e?e.is_complete!==t.is_complete||e.is_streamable!==t.is_streamable||e.message!==t.message||e.code!==t.code||e.stdout!==t.stdout||e.stderr!==t.stderr||e.logging!==t.logging||e.content!==t.content||e.replacements!==t.replacements||e.action!==t.action||e.execution_type!==t.execution_type:!0,j6=(e,t)=>{const r=Object.entries(e).filter(([s,a])=>!a.isComplete||t-a.lastUpdated<Mct);if(r.length<=uae)return Object.fromEntries(r);const i=[...r].sort((s,a)=>a[1].lastUpdated-s[1].lastUpdated);return Object.fromEntries(i.slice(0,uae))},ig=po(e=>({streamingMessages:{},updateStreamingMessage:(t,n)=>{e(r=>{const i=Date.now(),s=r.streamingMessages[t]||{content:null,isComplete:!1,lastUpdated:i};if(!s.isComplete&&!dae(s.content,n))return r;const a={...r.streamingMessages,[t]:{...s,content:n,lastUpdated:i}};return{streamingMessages:j6(a,i)}})},completeStreamingMessage:(t,n)=>{e(r=>{const i=Date.now(),s=r.streamingMessages[t];if(s?.isComplete&&!dae(s.content,n))return r;const a={...r.streamingMessages,[t]:{content:n,isComplete:!0,lastUpdated:i}};return{streamingMessages:j6(a,i)}})},pruneStreamingMessages:()=>{e(t=>{const n=Date.now(),r=j6(t.streamingMessages,n);return Object.keys(r).length===Object.keys(t.streamingMessages).length?t:{streamingMessages:r}})}})),jct=/\/+$/,Ha={Open:"stream.open",Gap:"stream.gap",Terminal:"stream.terminal",Error:"error",RecordUpdate:"record.update",RecordComplete:"record.complete",MessageDelta:"message.delta",ToolStart:"tool.start",ToolDelta:"tool.delta",ToolEnd:"tool.end",TurnStart:"turn.start",TurnEnd:"turn.end",AgentStart:"agent.start",AgentEnd:"agent.end",Notice:"notice",JobStatus:"job.status",Keepalive:"keepalive"},Lct={autoReconnect:!0,maxReconnectAttempts:5,stallTimeout:45e3,openTimeout:8e3};class qct extends bZ{source=null;baseUrl;channelId;channelKind;options;status="disconnected";failedOpens=0;lastSeq=null;stallTimerId=null;closedByServer=!1;opened=!1;openTimerId=null;constructor(t,n,r={},i="message"){super(),this.baseUrl=t.replace(jct,""),this.channelId=n,this.channelKind=i,this.options={...Lct,...r}}getStatus(){return this.status}getLastSequence(){return this.lastSeq}url(){const t=this.channelKind==="job"?`/v1/sse/jobs/${encodeURIComponent(this.channelId)}`:`/v1/sse/messages/${encodeURIComponent(this.channelId)}`,n=this.lastSeq!==null?`?after_seq=${this.lastSeq}`:"";return`${this.baseUrl}${t}${n}`}setStatus(t){this.status!==t&&(this.status=t,this.emit("status",t))}armStallTimer(){this.clearStallTimer(),this.stallTimerId=window.setTimeout(()=>{this.emit("error",new Error(`SSE stream stalled: no traffic for ${this.options.stallTimeout}ms`)),this.setStatus("error"),this.emit("stalled")},this.options.stallTimeout)}clearStallTimer(){this.stallTimerId!==null&&(window.clearTimeout(this.stallTimerId),this.stallTimerId=null)}clearOpenTimer(){this.openTimerId!==null&&(window.clearTimeout(this.openTimerId),this.openTimerId=null)}async connect(){if(!this.source)return this.closedByServer=!1,this.opened=!1,this.setStatus("connecting"),new Promise(t=>{let n=!1;const r=()=>{n||(n=!0,t())},i=new EventSource(this.url());this.source=i,this.openTimerId=window.setTimeout(()=>{this.opened||(this.teardown(),this.setStatus("error"),this.emit("error",new Error(`SSE open timed out after ${this.options.openTimeout}ms`)),r())},this.options.openTimeout),i.onopen=()=>{this.opened=!0,this.clearOpenTimer(),this.failedOpens=0,this.setStatus("connected"),this.armStallTimer(),r()},i.onerror=()=>{if(this.clearStallTimer(),this.closedByServer){this.teardown(),this.setStatus("disconnected"),r();return}if(i.readyState===EventSource.CONNECTING){if(this.failedOpens+=1,!this.options.autoReconnect||this.failedOpens>this.options.maxReconnectAttempts){this.teardown(),this.setStatus("failed"),this.emit("error",new Error(`SSE reconnect gave up after ${this.failedOpens} attempts`)),r();return}this.setStatus("reconnecting"),r();return}this.teardown(),this.setStatus("error"),this.emit("error",new Error("SSE connection closed unexpectedly")),r()},i.addEventListener(Ha.Open,a=>{this.armStallTimer();const o=this.parse(a);if(o){this.lastSeq=o.last_seq>0?o.last_seq:this.lastSeq,this.emit("open",o);for(const l of o.snapshot??[])this.emitRecord(l);r()}});const s=a=>{this.armStallTimer();const o=this.parse(a);o?.record&&(this.noteSeq(a),this.emitRecord(o.record))};i.addEventListener(Ha.RecordUpdate,s),i.addEventListener(Ha.RecordComplete,s),i.addEventListener(Ha.Terminal,a=>{this.noteSeq(a),this.closedByServer=!0,this.clearStallTimer(),this.emit("terminal",this.parse(a)),this.teardown(),this.setStatus("disconnected"),r()}),i.addEventListener(Ha.Gap,a=>{const o=this.parse(a);this.emit("gap",o)}),i.addEventListener(Ha.Error,a=>{const o=this.parse(a);this.emit("error",new Error(o?.error??"SSE stream reported an error"))});for(const a of[Ha.MessageDelta,Ha.ToolStart,Ha.ToolDelta,Ha.ToolEnd,Ha.TurnStart,Ha.TurnEnd,Ha.AgentStart,Ha.AgentEnd,Ha.Notice,Ha.JobStatus])i.addEventListener(a,o=>{this.armStallTimer(),this.noteSeq(o),this.emit(a,this.parse(o))});i.addEventListener(Ha.Keepalive,()=>{this.armStallTimer()})})}emitRecord(t){const n=t.message_id??t.id;this.emit(`update:${n}`,t),n!==this.channelId&&this.emit(`update:${this.channelId}`,t)}noteSeq(t){const n=t.lastEventId;if(!n)return;const r=Number.parseInt(n,10);Number.isFinite(r)&&(this.lastSeq=r)}parse(t){const n=t.data;if(typeof n!="string")return null;try{return JSON.parse(n)}catch{return console.error("[sse] frame was not valid JSON"),null}}teardown(){this.clearStallTimer(),this.clearOpenTimer(),this.source&&(this.source.close(),this.source=null)}disconnect(){this.teardown(),this.setStatus("disconnected")}}const ACe=/\/+$/,rU=new Map,iU=new Map,zct=2500,Uct=e=>{const t=e.replace(ACe,""),n=rU.get(t);if(n)return n;const r=(async()=>{const i=new AbortController,s=window.setTimeout(()=>i.abort(),zct);try{const a=await fetch(`${t}/v1/sse/capabilities`,{signal:i.signal});if(!a.ok)return{capabilities:null,sseProvenBroken:!1};const o=await a.json();return{capabilities:o?.transports?.includes("sse")??!1?o:null,sseProvenBroken:!1}}catch{return{capabilities:null,sseProvenBroken:!1}}finally{window.clearTimeout(s)}})();return rU.set(t,r),r.then(i=>iU.set(t,i)).catch(()=>{}),r};class Wct extends bZ{baseUrl;channelId;options;active=null;kind=null;disposed=!1;delivered=!1;connecting=!1;constructor(t,n,r={}){super(),this.baseUrl=t.replace(ACe,""),this.channelId=n,this.options=r}getTransport(){return this.kind}getStatus(){return this.active?.getStatus()??"disconnected"}async connect(){if(!(this.disposed||this.active||this.connecting)){this.connecting=!0;try{const t=this.options.force;let n=t==="sse";if(!t){const r=await Uct(this.baseUrl);if(this.disposed)return;n=r.capabilities!==null&&!r.sseProvenBroken}if(this.disposed)return;if(n){await this.startSse();return}await this.startWebSocket()}finally{this.connecting=!1}}}async startSse(){const t=new qct(this.baseUrl,this.channelId,this.options.sse,this.options.channelKind??"message");this.active=t,this.kind="sse",this.bind(t),t.on("stalled",()=>{this.delivered||this.fallback("stream stalled before any frame")}),t.on("status",n=>{(n==="failed"||n==="error")&&!this.delivered&&this.fallback(`sse status became ${String(n)}`)}),await t.connect()}async startWebSocket(){const t=new nst(this.baseUrl,this.channelId,this.options.websocket,I2e.MESSAGE);this.active=t,this.kind="websocket",this.bind(t),await t.connect()}bind(t){const n=["status","error",`update:${this.channelId}`,"open","terminal","gap","message.delta","tool.start","tool.delta","tool.end","turn.start","turn.end","agent.start","agent.end","notice","job.status"];for(const r of n)t.on(r,(...i)=>{r===`update:${this.channelId}`&&(this.delivered=!0),this.emit(r,...i)})}async fallback(t){if(this.disposed||this.kind!=="sse")return;const n=this.baseUrl,r=iU.get(n);r?r.sseProvenBroken=!0:(iU.set(n,{capabilities:null,sseProvenBroken:!0}),rU.set(n,Promise.resolve({capabilities:null,sseProvenBroken:!0}))),console.warn(`[streaming] falling back to websocket: ${t}`),this.active&&(this.active.removeAllListeners(),this.active.disconnect(),this.active=null),this.kind=null;try{await this.startWebSocket()}catch(i){console.error("[streaming] websocket fallback failed:",i)}}disconnect(){this.disposed=!0,this.active&&(this.active.removeAllListeners(),this.active.disconnect(),this.active=null)}}const Gct=["id","message","code","stdout","stderr","logging","content","replacements","thinking","learnings","formatted_print","file_path","agent","action","execution_type","task_classification","role","status","is_complete","is_streamable"],Vct=(e,t)=>{if(!e)return!0;for(const i of Gct)if(e[i]!==t[i])return!0;const n=e.files,r=t.files;return n===r?!1:!n||!r||n.length!==r.length?!0:n.some((i,s)=>i!==r[s])},Bct=e=>{const{baseUrl:t,messageId:n,autoReconnect:r=!0,reconnectInterval:i=2e3,maxReconnectAttempts:s=5,pingInterval:a=3e4,onUpdate:o,onStatusChange:l,onError:c}=e,[u,d]=b.useState(null),[h,f]=b.useState(!1),[O,g]=b.useState(!1),[m,v]=b.useState("disconnected"),[y,w]=b.useState(null),[k,x]=b.useState(!1),S=b.useRef(null),T=b.useRef(null),_=b.useRef(null),P=b.useRef(null),E=b.useRef({onUpdate:o,onStatusChange:l,onError:c});b.useEffect(()=>{E.current={onUpdate:o,onStatusChange:l,onError:c}},[o,l,c]);const C=b.useCallback(()=>{P.current=null;const U=T.current;U&&(T.current=null,!(!U.is_complete&&!Vct(_.current,U))&&(_.current=U,d(U),E.current.onUpdate?.(U)))},[]),Q=b.useCallback(()=>{P.current!==null&&(cancelAnimationFrame(P.current),P.current=null),T.current=null,S.current&&(S.current.removeAllListeners(),S.current.disconnect(),S.current=null)},[]),D=b.useCallback(()=>{if(S.current)return S.current;const U=new Wct(t,n,{websocket:{autoReconnect:r,reconnectInterval:i,maxReconnectAttempts:s,pingInterval:a,messageDelay:250},sse:{autoReconnect:r,maxReconnectAttempts:s}});return U.on("status",q=>{const Z=q;v(Z),Z==="connected"&&w(null),E.current.onStatusChange?.(Z)}),U.on(`update:${n}`,q=>{const Z=q;if(T.current={...T.current??_.current,...Z},typeof Z.is_complete=="boolean"&&f(Z.is_complete),typeof Z.is_streamable=="boolean"&&g(Z.is_streamable),Z.is_complete){P.current!==null&&cancelAnimationFrame(P.current),C();return}P.current===null&&(P.current=requestAnimationFrame(C))}),U.on("error",q=>{const Z=q instanceof Error?q:new Error(typeof q=="string"?q:`WebSocket error for ${n}`);w(Z),E.current.onError?.(Z)}),S.current=U,U},[t,n,r,i,s,a,C]),F=b.useCallback(async()=>{if(!n||!t)throw new Error("Missing messageId or baseUrl");w(null),x(!0);const U=D(),q=U.getStatus();if(q==="connected"||q==="connecting"||q==="reconnecting"){x(!1);return}try{await U.connect()}catch(Z){const W=Z instanceof Error?Z:new Error(String(Z));throw w(W),E.current.onError?.(W),W}finally{x(!1)}},[n,t,D]),I=b.useCallback(()=>{Q(),v("disconnected"),x(!1)},[Q]);return b.useEffect(()=>()=>{I()},[n,I]),b.useEffect(()=>{x(m==="connecting"||m==="reconnecting")},[m]),{message:u,isComplete:h,isStreamable:O,status:m,connect:F,disconnect:I,isLoading:k,error:y}},Yct=1500,Zct=80,Hct=180,nd=new Map,dS=(e,t)=>{const n=nd.get(e);if(n)return t&&(n.conversationId=t),n;const r={connected:!1,connecting:!1,connectionPromise:null,instanceCount:0,messageData:null,isComplete:!1,isStreamable:!1,conversationId:t,disconnect:null};return nd.set(e,r),r},Kct=({messageId:e,autoConnect:t=!0,onComplete:n,onUpdate:r,baseUrl:i=oi.baseUrl,conversationId:s,refetchOnComplete:a=!0})=>{const o=b.useRef(!1),l=b.useRef(!1),c=b.useRef(0),u=b.useRef(null),d=b.useRef(!1),h=b.useRef(null),f=b.useRef(null),O=b.useRef(null),[g,m]=b.useState(!1),v=ig(L=>L.updateStreamingMessage),y=ig(L=>L.completeStreamingMessage),w=ig(L=>L.pruneStreamingMessages),k=ig(L=>L.streamingMessages[e]?.isComplete??!1),x=tU(L=>L.addMessage),S=tU(L=>L.updateMessage),T=b.useCallback(L=>{if(!s||!L.id)return;const N=xct(L,s);S(s,N)||x(s,N)},[s,S,x]),_=b.useCallback(()=>{O.current&&(T(O.current),O.current=null)},[T]),P=b.useCallback(L=>{!n||!o.current||u.current!==e&&(u.current=e,n(L))},[n,e]),E=b.useCallback(async()=>{if(e)try{m(!0);const L=As(i),N=nd.get(e),z=N?.conversationId||s;if(!z)return;const V=await L.agents.getAgentExecutionHistory(z,1,30);if(V.status>=400||!V.result)throw new Error(V.message||"Failed to fetch message data");const ee=V.result.history.find(oe=>oe.id===e);if(ee){y(e,ee);const oe=dS(e,s);oe.messageData=ee,oe.isComplete=!0,oe.isStreamable=!!ee.is_streamable,T(ee),P(ee);return}N?.messageData&&N.isComplete&&(y(e,N.messageData),T(N.messageData),P(N.messageData))}catch(L){const N=L instanceof Error?L.message:String(L);console.error(`Error refetching message: ${N}`)}finally{m(!1)}},[e,i,s,y,T,P]),C=b.useCallback(()=>{!a||h.current||(h.current=setTimeout(()=>{h.current=null,o.current&&E()},Hct))},[a,E]),{message:Q,isComplete:D,isStreamable:F,status:I,isLoading:U,error:q,connect:Z,disconnect:W}=Bct({baseUrl:i,messageId:e,onUpdate:L=>{r&&o.current&&r(L);const N=dS(e,s),z={...N.messageData,...L};if(N.messageData=z,N.isStreamable=!!(L.is_streamable||N.isStreamable),L.is_complete){N.isComplete=!0,y(e,z),O.current=z,_(),P(z),C();return}v(e,z),s&&z.id&&(O.current=z,f.current||(f.current=setTimeout(()=>{f.current=null,_()},Zct)))}}),M=b.useCallback(async()=>{if(D||k)return;const L=Date.now();if(L-c.current<Yct)return;c.current=L;const N=dS(e,s);if(!N.connected){if(N.connectionPromise){try{await N.connectionPromise}catch{}return}N.connecting=!0,N.connectionPromise=Z().then(()=>{const z=nd.get(e);z&&(z.connected=!0,z.connecting=!1)}).catch(z=>{const V=nd.get(e);throw V&&(V.connected=!1,V.connecting=!1),z}).finally(()=>{const z=nd.get(e);z&&(z.connectionPromise=null)});try{await N.connectionPromise}catch(z){console.error("WebSocket connection failed:",z)}}},[D,k,e,s,Z]),J=b.useCallback(()=>{const L=nd.get(e);L&&(L.connected=!1,L.connecting=!1,L.connectionPromise=null,L.disconnect=null,L.instanceCount<=1&&nd.delete(e)),W()},[e,W]);return b.useEffect(()=>{if(o.current=!0,d.current=!1,u.current=null,!k){const N=dS(e,s);N.disconnect=W,l.current||(N.instanceCount+=1,l.current=!0)}let L=null;return t&&!D&&!k&&(L=setTimeout(()=>{o.current&&M()},120)),()=>{if(o.current=!1,L&&clearTimeout(L),h.current&&(clearTimeout(h.current),h.current=null),f.current&&(clearTimeout(f.current),f.current=null),_(),w(),l.current){const N=nd.get(e);N&&(N.instanceCount=Math.max(0,N.instanceCount-1),N.instanceCount===0&&(N.connected=!1,N.connecting=!1,N.connectionPromise=null,N.disconnect=null,nd.delete(e),W())),l.current=!1}}},[t,D,k,M,e,s,_,w,W]),b.useEffect(()=>{const L=nd.get(e);L&&(L.connected=I==="connected",L.connecting=I==="connecting"||I==="reconnecting",L.connecting||(L.connectionPromise=null))},[e,I]),b.useEffect(()=>{if(I!=="disconnected"||D||k||!o.current)return;const L=setTimeout(()=>{o.current&&M()},1600);return()=>clearTimeout(L)},[I,D,k,M]),b.useEffect(()=>{if(!D||!Q){d.current=!1;return}if(d.current)return;d.current=!0;const L=dS(e,s);L.isComplete=!0,L.messageData=Q,L.isStreamable=!!Q.is_streamable,y(e,Q),O.current=Q,_(),P(Q),C(),J()},[D,Q,e,s,y,_,P,C,J]),{message:Q,isComplete:D,isStreamable:F,status:I,isLoading:U,isRefetching:g,error:q,connect:M,disconnect:J,refetch:E}},Jct=()=>{const e=Mi(),t=As(oi.baseUrl);return Ol({mutationFn:async({agentId:n,update:r})=>{try{const i=await t.agents.updateAgent(n,r);if(i.status>=400)throw new Error(i.message||`Failed to update agent ${n}`);return i.result}catch(i){const s=i instanceof Error?i.message:`An unknown error occurred while updating agent ${n}`;throw Rr(s),i}},onSuccess:async(n,{agentId:r})=>{await e.invalidateQueries({queryKey:zh,refetchType:"none"}),e.setQueryData([...zh,r],i=>i&&{...i,...n}),await e.refetchQueries({queryKey:zh,type:"all"}),ms("Agent updated")},onError:n=>{console.error("Error updating agent:",n)}})},eut=()=>{const e=Mi(),t=As(oi.baseUrl);return Ol({mutationFn:async n=>{try{const r=await t.config.updateConfig(n);if(r.status>=400)throw new Error(r.message||"Failed to update configuration");return r.result}catch(r){const i=r instanceof Error?r.message:"An unknown error occurred while updating configuration";throw Rr(i),r}},onSuccess:async n=>{await e.invalidateQueries({queryKey:XQ,refetchType:"none"}),e.setQueryData(XQ,r=>r&&{...r,...n}),await e.refetchQueries({queryKey:XQ,type:"all"}),ms("Configuration updated")},onError:n=>{console.error("Error updating configuration:",n)}})},tut=()=>{const e=Mi(),t=As(oi.baseUrl);return Ol({mutationFn:async n=>{try{const r=await t.credentials.updateCredential(n);if(r.status>=400)throw new Error(r.message||"Failed to update credential");return r}catch(r){const i=r instanceof Error?r.message:"An unknown error occurred while updating credential";throw Rr(i),r}},onSuccess:async(n,r)=>{await e.invalidateQueries({queryKey:qQ,refetchType:"none"}),e.setQueryData(qQ,i=>i&&(i.keys.includes(r.key)?i:{...i,keys:[...i.keys,r.key]})),await e.refetchQueries({queryKey:qQ,type:"all"}),ms(`Credential "${r.key}" updated successfully`)},onError:n=>{console.error("Error updating credential:",n)}})},nut=({open:e,onClose:t,onAgentCreated:n})=>{const r=ka(),[i,s]=b.useState(""),[a,o]=b.useState(""),l=b.useRef(null),c=()=>{t(),setTimeout(()=>{r("/agent-hub")},200)},u=dot(),d=async m=>{if(m.preventDefault(),!i.trim())return;const v={name:i.trim(),description:a.trim()||void 0};try{const y=await u.mutateAsync(v);s(""),o(""),n&&y?.id&&n(y.id),t()}catch(y){console.error("Failed to create agent:",y)}},h=u.isPending,f=h||!i.trim(),O=p.jsxs(p.Fragment,{children:[p.jsx(Jv,{size:19,className:"text-accent","aria-hidden":"true"}),"Create new agent"]}),g=p.jsxs(p.Fragment,{children:[p.jsx(sl,{onClick:t,disabled:h,"data-tour-tag":"create-agent-dialog-cancel-button",children:"Cancel"}),p.jsx(vd,{type:"submit",form:"create-agent-form",disabled:f,startIcon:h?p.jsx(pr,{}):null,children:"Create agent"})]});return p.jsxs(Nc,{open:e,onClose:t,title:O,actions:g,maxWidth:"sm",dataTourTag:"create-agent-dialog",dialogProps:{onOpenAutoFocus:m=>{m.preventDefault(),l.current?.focus()}},children:[p.jsx("p",{className:"text-body-sm text-ink-muted",children:"Configure your new AI assistant with a name and optional description"}),p.jsxs(we,{variant:"link",onClick:c,className:"mt-1 mb-4 text-body-sm",children:["Browse Agent hub to fetch ready-made agents",p.jsx(Y3,{"aria-hidden":"true"})]}),p.jsx("form",{id:"create-agent-form",onSubmit:d,children:p.jsxs("div",{className:"flex flex-col gap-5",children:[p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx(Us,{htmlFor:"create-agent-name",children:"Agent name"}),p.jsx(Si,{ref:l,id:"create-agent-name",inputSize:"lg",value:i,onChange:m=>s(m.target.value),required:!0,disabled:h,placeholder:"Enter a name for your agent"})]}),p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx(Us,{htmlFor:"create-agent-description",children:"Description (optional)"}),p.jsx(tm,{id:"create-agent-description",rows:2,value:a,onChange:m=>o(m.target.value),disabled:h,placeholder:"Describe what this agent does"})]})]})})]})},hae=({value:e,label:t,onSave:n,multiline:r=!1,rows:i=4,placeholder:s="Enter value...",icon:a,isSaving:o=!1,readOnly:l=!1})=>{const[c,u]=b.useState(!1),[d,h]=b.useState(e),[f,O]=b.useState(e),[g,m]=b.useState(e),[v,y]=b.useState(!1),[w,k]=b.useState(!1),x=b.useRef(null),S=b.useRef(null),T=b.useId(),_=o||v;b.useEffect(()=>{c||(h(e),O(e)),m(e)},[e,c]),b.useEffect(()=>{if(c){const L=setTimeout(()=>{x.current&&(x.current.focus(),x.current.select())},0);return()=>clearTimeout(L)}},[c]);const P=()=>{l||u(!0)},E=L=>{h(L.target.value)},C=()=>{h(g),u(!1)},Q=async()=>{if(!(_||d===g)){y(!0);try{await n(d),m(d),O(d),u(!1)}catch(L){console.error("Failed to save editable field:",L)}finally{y(!1)}}},D=L=>{setTimeout(()=>{const N=L.relatedTarget;!(S.current?.contains(N)??!1)&&d===g&&u(!1)},0)},F=L=>{L.key==="Escape"?C():L.key==="Enter"&&(!r||r&&(L.ctrlKey||L.metaKey))&&(L.preventDefault(),d!==g?Q():u(!1))},I=L=>{L.preventDefault(),L.stopPropagation(),!(l||_||w)&&(k(!0),y(!0),h(""),O(""),n("").then(()=>{m(""),u(!1)}).catch(N=>{console.error("Failed to clear field:",N),h(g),O(g)}).finally(()=>{k(!1),y(!1)}))},U=L=>{l||(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),P())},q=d!==g,Z=!l&&!_&&g!=="",W=Z&&!q,M=_?"pr-20":W?"pr-28":q?"pr-18":"pr-10",J="opacity-0 transition-opacity duration-fast ease-out-quart group-hover:opacity-100 group-focus-within:opacity-100";return p.jsxs("div",{children:[(t||a)&&p.jsxs(Us,{htmlFor:T,className:"mb-1.5 flex items-center gap-2 text-ink-muted",children:[a,t]}),c?p.jsxs("div",{className:"relative",children:[r?p.jsx(tm,{id:T,ref:x,value:d,onChange:E,onBlur:D,onKeyDown:F,rows:i,placeholder:s,autoComplete:"off",className:A("min-h-9",M)}):p.jsx(Si,{id:T,ref:x,value:d,onChange:E,onBlur:D,onKeyDown:F,placeholder:s,autoComplete:"off",className:A("text-ellipsis",M)}),p.jsx("div",{ref:S,className:A("absolute right-1.5 z-10 flex items-center gap-1",r?"top-1.5":"top-1/2 -translate-y-1/2"),children:_?p.jsx("span",{className:"px-2 text-ink-dim text-meta",children:w?"Clearing...":"Saving..."}):p.jsxs(p.Fragment,{children:[q&&p.jsx(we,{variant:"ghost",size:"icon-sm",onClick:Q,title:"Save changes (Enter)","aria-label":`Save ${t}`,className:"text-success hover:bg-success-wash hover:text-success",children:p.jsx(Ul,{})}),p.jsx(we,{variant:"ghost",size:"icon-sm",onClick:C,title:"Cancel (Escape)","aria-label":`Cancel editing ${t}`,className:"text-danger hover:bg-danger-wash hover:text-danger",children:p.jsx(Qi,{})}),W&&p.jsxs(we,{variant:"danger",size:"sm",onClick:I,title:"Clear field","aria-label":`Clear ${t}`,children:[p.jsx(ise,{}),"Clear"]})]})})]}):p.jsxs("div",{className:"group relative w-full",children:[p.jsx("button",{type:"button",onClick:P,"aria-label":`Current value: ${f||s}.${l?"":" Click to edit."}`,onKeyDown:U,disabled:l,className:A("flex w-full rounded-sm border border-control bg-surface px-3 text-left text-body-sm text-ink","transition-colors duration-fast ease-out-quart","disabled:cursor-default disabled:border-hairline disabled:bg-sunken disabled:text-ink-disabled",r?"min-h-8 items-start py-2":"h-8 items-center",!l&&"cursor-pointer hover:bg-elevated"),children:f?p.jsx("span",{className:A("min-w-0 flex-1 pr-8",r?"whitespace-pre-wrap break-words":"truncate"),children:f}):p.jsx("span",{className:"min-w-0 flex-1 truncate pr-8 text-ink-dim",children:s})}),!l&&p.jsx(we,{variant:"ghost",size:"icon-sm",onClick:P,title:"Edit","aria-label":`Edit ${t}`,tabIndex:-1,className:A("absolute top-1/2 right-1.5 -translate-y-1/2",J),children:p.jsx(fZ,{})}),Z&&p.jsxs(we,{variant:"danger",size:"sm",onClick:I,title:"Clear field","aria-label":`Clear ${t}`,tabIndex:-1,className:A("absolute top-1/2 right-9 -translate-y-1/2",J),children:[p.jsx(ise,{}),"Clear"]})]})]})},DCe=b.memo(()=>($ct(),null));DCe.displayName="ModelsInitializer";const NCe=({size:e=24,className:t})=>p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:t,"aria-hidden":"true",children:[p.jsx("path",{d:"M12 2 20.7 7 20.7 17 12 22 3.3 17 3.3 7Z"}),p.jsx("path",{d:"M12 12V6.2"}),p.jsx("path",{d:"m12 12 5-2.9"}),p.jsx("path",{d:"m12 12 5 2.9"}),p.jsx("path",{d:"M12 12v5.8"}),p.jsx("path",{d:"m12 12-5 2.9"}),p.jsx("path",{d:"m12 12-5-2.9"})]}),Iy=({value:e,label:t,description:n,min:r,max:i,step:s=1,unit:a,onChange:o,icon:l,isSaving:c=!1})=>{const[u,d]=b.useState(e),[h,f]=b.useState(e.toString()),[O,g]=b.useState(!1),m=b.useId(),v=`${m}-label`,y=`${m}-description`,w=b.useRef(u);w.current=u,b.useEffect(()=>{O||(d(e),f(e.toString()))},[e,O]);const k=b.useCallback(async()=>{if(c)return;const D=Math.max(r,Math.min(i,w.current));if(d(D),f(D.toString()),D!==e)try{await o(D)}catch(F){console.error("Error updating setting via slider:",F),d(e),f(e.toString())}},[c,r,i,e,o]),x=D=>{const F=Number(D.target.value);d(F),f(F.toString())},S=()=>{const D=()=>{window.removeEventListener("pointerup",D),k()};window.addEventListener("pointerup",D)},T=D=>{(D.key.startsWith("Arrow")||D.key==="Home"||D.key==="End")&&k()},_=D=>{f(D.target.value)},P=async()=>{if(g(!1),c)return;let D=Number.parseFloat(h);if(Number.isNaN(D))D=e;else if(D=Math.max(r,Math.min(i,D)),s){D=Math.round(D/s)*s;const F=s.toString().split(".")[1]?.length||0;D=Number.parseFloat(D.toFixed(F))}if(D!==e){d(D),f(D.toString());try{await o(D)}catch(F){console.error("Error updating setting via input:",F),d(e),f(e.toString())}}else d(e),f(e.toString())},E=()=>{g(!0)},C=D=>{D.key==="Enter"&&D.target.blur()},Q=i>r?`${((u-r)/(i-r)*100).toFixed(2)}%`:"0%";return p.jsxs("div",{children:[p.jsxs("div",{className:"flex min-h-8 items-center justify-between gap-4",children:[p.jsxs("label",{id:v,htmlFor:`${m}-range`,className:"flex min-w-0 items-center gap-2 text-body text-ink",children:[l&&p.jsx(l,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim"}),p.jsx("span",{className:"truncate",children:t})]}),p.jsx("div",{className:"flex shrink-0 items-center gap-2",children:c?p.jsx(pr,{size:"md",label:`Saving ${t}`}):p.jsxs(p.Fragment,{children:[p.jsx(Si,{inputSize:"sm",type:"number",value:h,onChange:_,onBlur:P,onFocus:E,onKeyDown:C,min:r,max:i,step:s,disabled:c,"aria-labelledby":v,"aria-describedby":n?y:void 0,className:"w-18 text-right [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"}),a&&p.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:a})]})})]}),n&&p.jsx("p",{id:y,className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:n}),p.jsx("input",{id:`${m}-range`,type:"range",value:u,min:r,max:i,step:s,disabled:c,onChange:x,onPointerDown:S,onKeyUp:T,onBlur:()=>void k(),"aria-labelledby":v,"aria-describedby":n?y:void 0,style:{"--fill":Q},className:"mt-3 h-4 w-full cursor-pointer appearance-none bg-transparent bg-center bg-no-repeat bg-[length:100%_6px] bg-[linear-gradient(to_right,var(--color-accent)_0_var(--fill),var(--color-sunken)_var(--fill)_100%)] disabled:cursor-not-allowed disabled:bg-none disabled:bg-sunken [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-accent [&::-webkit-slider-thumb]:transition-colors [&::-webkit-slider-thumb]:duration-fast [&::-webkit-slider-thumb]:ease-out-quart [&::-webkit-slider-thumb]:hover:bg-accent-hover disabled:[&::-webkit-slider-thumb]:bg-ink-disabled"}),p.jsxs("div",{className:"flex justify-between font-mono text-mono-sm text-ink-dim",children:[p.jsx("span",{children:r}),p.jsx("span",{children:i})]})]})},rut={"--normal-bg":"var(--color-elevated)","--normal-text":"var(--color-ink)","--normal-border":"var(--color-control)","--border-radius":"var(--radius-md)","--gray12":"var(--color-ink)","--gray4":"var(--color-control)","--gray2":"var(--color-accent-wash)","--gray5":"var(--color-control)",background:"var(--color-elevated)",color:"var(--color-ink)",border:"1px solid var(--color-control)",boxShadow:"var(--shadow-overlay)",fontSize:"var(--text-meta)",padding:"12px 16px","--toast-close-button-start":"unset","--toast-close-button-end":"0px","--toast-close-button-transform":"translate(35%, -35%)"},iut=({duration:e})=>p.jsx(Lat,{duration:e,position:"bottom-right",toastOptions:{style:rut,closeButton:!0}});var hS={},Fy={},hC={},Nm={},Xm={},L6={},fae;function XCe(){return fae||(fae=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Doctype=e.CDATA=e.Tag=e.Style=e.Script=e.Comment=e.Directive=e.Text=e.Root=e.isTag=e.ElementType=void 0;var t;(function(r){r.Root="root",r.Text="text",r.Directive="directive",r.Comment="comment",r.Script="script",r.Style="style",r.Tag="tag",r.CDATA="cdata",r.Doctype="doctype"})(t=e.ElementType||(e.ElementType={}));function n(r){return r.type===t.Tag||r.type===t.Script||r.type===t.Style}e.isTag=n,e.Root=t.Root,e.Text=t.Text,e.Directive=t.Directive,e.Comment=t.Comment,e.Script=t.Script,e.Style=t.Style,e.Tag=t.Tag,e.CDATA=t.CDATA,e.Doctype=t.Doctype}(L6)),L6}var sr={},pae;function Oae(){if(pae)return sr;pae=1;var e=sr&&sr.__extends||function(){var x=function(S,T){return x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(_,P){_.__proto__=P}||function(_,P){for(var E in P)Object.prototype.hasOwnProperty.call(P,E)&&(_[E]=P[E])},x(S,T)};return function(S,T){if(typeof T!="function"&&T!==null)throw new TypeError("Class extends value "+String(T)+" is not a constructor or null");x(S,T);function _(){this.constructor=S}S.prototype=T===null?Object.create(T):(_.prototype=T.prototype,new _)}}(),t=sr&&sr.__assign||function(){return t=Object.assign||function(x){for(var S,T=1,_=arguments.length;T<_;T++){S=arguments[T];for(var P in S)Object.prototype.hasOwnProperty.call(S,P)&&(x[P]=S[P])}return x},t.apply(this,arguments)};Object.defineProperty(sr,"__esModule",{value:!0}),sr.cloneNode=sr.hasChildren=sr.isDocument=sr.isDirective=sr.isComment=sr.isText=sr.isCDATA=sr.isTag=sr.Element=sr.Document=sr.CDATA=sr.NodeWithChildren=sr.ProcessingInstruction=sr.Comment=sr.Text=sr.DataNode=sr.Node=void 0;var n=XCe(),r=function(){function x(){this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty(x.prototype,"parentNode",{get:function(){return this.parent},set:function(S){this.parent=S},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"previousSibling",{get:function(){return this.prev},set:function(S){this.prev=S},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"nextSibling",{get:function(){return this.next},set:function(S){this.next=S},enumerable:!1,configurable:!0}),x.prototype.cloneNode=function(S){return S===void 0&&(S=!1),w(this,S)},x}();sr.Node=r;var i=function(x){e(S,x);function S(T){var _=x.call(this)||this;return _.data=T,_}return Object.defineProperty(S.prototype,"nodeValue",{get:function(){return this.data},set:function(T){this.data=T},enumerable:!1,configurable:!0}),S}(r);sr.DataNode=i;var s=function(x){e(S,x);function S(){var T=x!==null&&x.apply(this,arguments)||this;return T.type=n.ElementType.Text,T}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 3},enumerable:!1,configurable:!0}),S}(i);sr.Text=s;var a=function(x){e(S,x);function S(){var T=x!==null&&x.apply(this,arguments)||this;return T.type=n.ElementType.Comment,T}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 8},enumerable:!1,configurable:!0}),S}(i);sr.Comment=a;var o=function(x){e(S,x);function S(T,_){var P=x.call(this,_)||this;return P.name=T,P.type=n.ElementType.Directive,P}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),S}(i);sr.ProcessingInstruction=o;var l=function(x){e(S,x);function S(T){var _=x.call(this)||this;return _.children=T,_}return Object.defineProperty(S.prototype,"firstChild",{get:function(){var T;return(T=this.children[0])!==null&&T!==void 0?T:null},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"lastChild",{get:function(){return this.children.length>0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"childNodes",{get:function(){return this.children},set:function(T){this.children=T},enumerable:!1,configurable:!0}),S}(r);sr.NodeWithChildren=l;var c=function(x){e(S,x);function S(){var T=x!==null&&x.apply(this,arguments)||this;return T.type=n.ElementType.CDATA,T}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 4},enumerable:!1,configurable:!0}),S}(l);sr.CDATA=c;var u=function(x){e(S,x);function S(){var T=x!==null&&x.apply(this,arguments)||this;return T.type=n.ElementType.Root,T}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 9},enumerable:!1,configurable:!0}),S}(l);sr.Document=u;var d=function(x){e(S,x);function S(T,_,P,E){P===void 0&&(P=[]),E===void 0&&(E=T==="script"?n.ElementType.Script:T==="style"?n.ElementType.Style:n.ElementType.Tag);var C=x.call(this,P)||this;return C.name=T,C.attribs=_,C.type=E,C}return Object.defineProperty(S.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"tagName",{get:function(){return this.name},set:function(T){this.name=T},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"attributes",{get:function(){var T=this;return Object.keys(this.attribs).map(function(_){var P,E;return{name:_,value:T.attribs[_],namespace:(P=T["x-attribsNamespace"])===null||P===void 0?void 0:P[_],prefix:(E=T["x-attribsPrefix"])===null||E===void 0?void 0:E[_]}})},enumerable:!1,configurable:!0}),S}(l);sr.Element=d;function h(x){return(0,n.isTag)(x)}sr.isTag=h;function f(x){return x.type===n.ElementType.CDATA}sr.isCDATA=f;function O(x){return x.type===n.ElementType.Text}sr.isText=O;function g(x){return x.type===n.ElementType.Comment}sr.isComment=g;function m(x){return x.type===n.ElementType.Directive}sr.isDirective=m;function v(x){return x.type===n.ElementType.Root}sr.isDocument=v;function y(x){return Object.prototype.hasOwnProperty.call(x,"children")}sr.hasChildren=y;function w(x,S){S===void 0&&(S=!1);var T;if(O(x))T=new s(x.data);else if(g(x))T=new a(x.data);else if(h(x)){var _=S?k(x.children):[],P=new d(x.name,t({},x.attribs),_);_.forEach(function(D){return D.parent=P}),x.namespace!=null&&(P.namespace=x.namespace),x["x-attribsNamespace"]&&(P["x-attribsNamespace"]=t({},x["x-attribsNamespace"])),x["x-attribsPrefix"]&&(P["x-attribsPrefix"]=t({},x["x-attribsPrefix"])),T=P}else if(f(x)){var _=S?k(x.children):[],E=new c(_);_.forEach(function(F){return F.parent=E}),T=E}else if(v(x)){var _=S?k(x.children):[],C=new u(_);_.forEach(function(F){return F.parent=C}),x["x-mode"]&&(C["x-mode"]=x["x-mode"]),T=C}else if(m(x)){var Q=new o(x.name,x.data);x["x-name"]!=null&&(Q["x-name"]=x["x-name"],Q["x-publicId"]=x["x-publicId"],Q["x-systemId"]=x["x-systemId"]),T=Q}else throw new Error("Not implemented yet: ".concat(x.type));return T.startIndex=x.startIndex,T.endIndex=x.endIndex,x.sourceCodeLocation!=null&&(T.sourceCodeLocation=x.sourceCodeLocation),T}sr.cloneNode=w;function k(x){for(var S=x.map(function(_){return w(_,!0)}),T=1;T<S.length;T++)S[T].prev=S[T-1],S[T-1].next=S[T];return S}return sr}var gae;function ICe(){return gae||(gae=1,function(e){var t=Xm&&Xm.__createBinding||(Object.create?function(o,l,c,u){u===void 0&&(u=c);var d=Object.getOwnPropertyDescriptor(l,c);(!d||("get"in d?!l.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return l[c]}}),Object.defineProperty(o,u,d)}:function(o,l,c,u){u===void 0&&(u=c),o[u]=l[c]}),n=Xm&&Xm.__exportStar||function(o,l){for(var c in o)c!=="default"&&!Object.prototype.hasOwnProperty.call(l,c)&&t(l,o,c)};Object.defineProperty(e,"__esModule",{value:!0}),e.DomHandler=void 0;var r=XCe(),i=Oae();n(Oae(),e);var s={withStartIndices:!1,withEndIndices:!1,xmlMode:!1},a=function(){function o(l,c,u){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof c=="function"&&(u=c,c=s),typeof l=="object"&&(c=l,l=void 0),this.callback=l??null,this.options=c??s,this.elementCB=u??null}return o.prototype.onparserinit=function(l){this.parser=l},o.prototype.onreset=function(){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null},o.prototype.onend=function(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))},o.prototype.onerror=function(l){this.handleCallback(l)},o.prototype.onclosetag=function(){this.lastNode=null;var l=this.tagStack.pop();this.options.withEndIndices&&(l.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(l)},o.prototype.onopentag=function(l,c){var u=this.options.xmlMode?r.ElementType.Tag:void 0,d=new i.Element(l,c,void 0,u);this.addNode(d),this.tagStack.push(d)},o.prototype.ontext=function(l){var c=this.lastNode;if(c&&c.type===r.ElementType.Text)c.data+=l,this.options.withEndIndices&&(c.endIndex=this.parser.endIndex);else{var u=new i.Text(l);this.addNode(u),this.lastNode=u}},o.prototype.oncomment=function(l){if(this.lastNode&&this.lastNode.type===r.ElementType.Comment){this.lastNode.data+=l;return}var c=new i.Comment(l);this.addNode(c),this.lastNode=c},o.prototype.oncommentend=function(){this.lastNode=null},o.prototype.oncdatastart=function(){var l=new i.Text(""),c=new i.CDATA([l]);this.addNode(c),l.parent=c,this.lastNode=l},o.prototype.oncdataend=function(){this.lastNode=null},o.prototype.onprocessinginstruction=function(l,c){var u=new i.ProcessingInstruction(l,c);this.addNode(u)},o.prototype.handleCallback=function(l){if(typeof this.callback=="function")this.callback(l,this.dom);else if(l)throw l},o.prototype.addNode=function(l){var c=this.tagStack[this.tagStack.length-1],u=c.children[c.children.length-1];this.options.withStartIndices&&(l.startIndex=this.parser.startIndex),this.options.withEndIndices&&(l.endIndex=this.parser.endIndex),c.children.push(l),u&&(l.prev=u,u.next=l),l.parent=c,this.lastNode=null},o}();e.DomHandler=a,e.default=a}(Xm)),Xm}var q6={},mae;function sut(){return mae||(mae=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CARRIAGE_RETURN_PLACEHOLDER_REGEX=e.CARRIAGE_RETURN_PLACEHOLDER=e.CARRIAGE_RETURN_REGEX=e.CARRIAGE_RETURN=e.CASE_SENSITIVE_TAG_NAMES_MAP=e.CASE_SENSITIVE_TAG_NAMES=void 0,e.CASE_SENSITIVE_TAG_NAMES=["animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"],e.CASE_SENSITIVE_TAG_NAMES_MAP=e.CASE_SENSITIVE_TAG_NAMES.reduce(function(t,n){return t[n.toLowerCase()]=n,t},{}),e.CARRIAGE_RETURN="\r",e.CARRIAGE_RETURN_REGEX=new RegExp(e.CARRIAGE_RETURN,"g"),e.CARRIAGE_RETURN_PLACEHOLDER="__HTML_DOM_PARSER_CARRIAGE_RETURN_PLACEHOLDER_".concat(Date.now(),"__"),e.CARRIAGE_RETURN_PLACEHOLDER_REGEX=new RegExp(e.CARRIAGE_RETURN_PLACEHOLDER,"g")}(q6)),q6}var vae;function FCe(){if(vae)return Nm;vae=1,Object.defineProperty(Nm,"__esModule",{value:!0}),Nm.formatAttributes=r,Nm.escapeSpecialCharacters=s,Nm.revertEscapedCharacters=a,Nm.formatDOM=o;var e=ICe(),t=sut();function n(l){return t.CASE_SENSITIVE_TAG_NAMES_MAP[l]}function r(l){for(var c={},u=0,d=l.length;u<d;u++){var h=l[u];c[h.name]=h.value}return c}function i(l){l=l.toLowerCase();var c=n(l);return c||l}function s(l){return l.replace(t.CARRIAGE_RETURN_REGEX,t.CARRIAGE_RETURN_PLACEHOLDER)}function a(l){return l.replace(t.CARRIAGE_RETURN_PLACEHOLDER_REGEX,t.CARRIAGE_RETURN)}function o(l,c,u){c===void 0&&(c=null);for(var d=[],h,f=0,O=l.length;f<O;f++){var g=l[f];switch(g.nodeType){case 1:{var m=i(g.nodeName);h=new e.Element(m,r(g.attributes)),h.children=o(m==="template"?g.content.childNodes:g.childNodes,h);break}case 3:h=new e.Text(a(g.nodeValue));break;case 8:h=new e.Comment(g.nodeValue);break;default:continue}var v=d[f-1]||null;v&&(v.next=h),h.parent=c,h.prev=v,h.next=null,d.push(h)}return u&&(h=new e.ProcessingInstruction(u.substring(0,u.indexOf(" ")).toLowerCase(),u),h.next=d[0]||null,h.parent=c,d.unshift(h),d[1]&&(d[1].prev=d[0])),d}return Nm}var yae;function aut(){if(yae)return hC;yae=1,Object.defineProperty(hC,"__esModule",{value:!0}),hC.default=g;var e=FCe(),t="html",n="head",r="body",i=/<([a-zA-Z]+[0-9]?)/,s=/<head[^]*>/i,a=/<body[^]*>/i,o=function(m,v){throw new Error("This browser does not support `document.implementation.createHTMLDocument`")},l=function(m,v){throw new Error("This browser does not support `DOMParser.prototype.parseFromString`")},c=typeof window=="object"&&window.DOMParser;if(typeof c=="function"){var u=new c,d="text/html";l=function(m,v){return v&&(m="<".concat(v,">").concat(m,"</").concat(v,">")),u.parseFromString(m,d)},o=l}if(typeof document=="object"&&document.implementation){var h=document.implementation.createHTMLDocument();o=function(m,v){if(v){var y=h.documentElement.querySelector(v);return y&&(y.innerHTML=m),h}return h.documentElement.innerHTML=m,h}}var f=typeof document=="object"&&document.createElement("template"),O;f&&f.content&&(O=function(m){return f.innerHTML=m,f.content.childNodes});function g(m){var v,y;m=(0,e.escapeSpecialCharacters)(m);var w=m.match(i),k=w&&w[1]?w[1].toLowerCase():"";switch(k){case t:{var x=l(m);if(!s.test(m)){var S=x.querySelector(n);(v=S?.parentNode)===null||v===void 0||v.removeChild(S)}if(!a.test(m)){var S=x.querySelector(r);(y=S?.parentNode)===null||y===void 0||y.removeChild(S)}return x.querySelectorAll(t)}case n:case r:{var T=o(m).querySelectorAll(k);return a.test(m)&&s.test(m)?T[0].parentNode.childNodes:T}default:{if(O)return O(m);var S=o(m,r).querySelector(r);return S.childNodes}}}return hC}var bae;function out(){if(bae)return Fy;bae=1;var e=Fy&&Fy.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Fy,"__esModule",{value:!0}),Fy.default=i;var t=e(aut()),n=FCe(),r=/<(![a-zA-Z\s]+)>/;function i(s){if(typeof s!="string")throw new TypeError("First argument must be a string");if(!s)return[];var a=s.match(r),o=a?a[1]:void 0;return(0,n.formatDOM)((0,t.default)(s),null,o)}return Fy}var fC={},zc={},fS={},wae;function lut(){if(wae)return fS;wae=1;var e=0;fS.SAME=e;var t=1;return fS.CAMELCASE=t,fS.possibleStandardNames={accept:0,acceptCharset:1,"accept-charset":"acceptCharset",accessKey:1,action:0,allowFullScreen:1,alt:0,as:0,async:0,autoCapitalize:1,autoComplete:1,autoCorrect:1,autoFocus:1,autoPlay:1,autoSave:1,capture:0,cellPadding:1,cellSpacing:1,challenge:0,charSet:1,checked:0,children:0,cite:0,class:"className",classID:1,className:1,cols:0,colSpan:1,content:0,contentEditable:1,contextMenu:1,controls:0,controlsList:1,coords:0,crossOrigin:1,dangerouslySetInnerHTML:1,data:0,dateTime:1,default:0,defaultChecked:1,defaultValue:1,defer:0,dir:0,disabled:0,disablePictureInPicture:1,disableRemotePlayback:1,download:0,draggable:0,encType:1,enterKeyHint:1,for:"htmlFor",form:0,formMethod:1,formAction:1,formEncType:1,formNoValidate:1,formTarget:1,frameBorder:1,headers:0,height:0,hidden:0,high:0,href:0,hrefLang:1,htmlFor:1,httpEquiv:1,"http-equiv":"httpEquiv",icon:0,id:0,innerHTML:1,inputMode:1,integrity:0,is:0,itemID:1,itemProp:1,itemRef:1,itemScope:1,itemType:1,keyParams:1,keyType:1,kind:0,label:0,lang:0,list:0,loop:0,low:0,manifest:0,marginWidth:1,marginHeight:1,max:0,maxLength:1,media:0,mediaGroup:1,method:0,min:0,minLength:1,multiple:0,muted:0,name:0,noModule:1,nonce:0,noValidate:1,open:0,optimum:0,pattern:0,placeholder:0,playsInline:1,poster:0,preload:0,profile:0,radioGroup:1,readOnly:1,referrerPolicy:1,rel:0,required:0,reversed:0,role:0,rows:0,rowSpan:1,sandbox:0,scope:0,scoped:0,scrolling:0,seamless:0,selected:0,shape:0,size:0,sizes:0,span:0,spellCheck:1,src:0,srcDoc:1,srcLang:1,srcSet:1,start:0,step:0,style:0,summary:0,tabIndex:1,target:0,title:0,type:0,useMap:1,value:0,width:0,wmode:0,wrap:0,about:0,accentHeight:1,"accent-height":"accentHeight",accumulate:0,additive:0,alignmentBaseline:1,"alignment-baseline":"alignmentBaseline",allowReorder:1,alphabetic:0,amplitude:0,arabicForm:1,"arabic-form":"arabicForm",ascent:0,attributeName:1,attributeType:1,autoReverse:1,azimuth:0,baseFrequency:1,baselineShift:1,"baseline-shift":"baselineShift",baseProfile:1,bbox:0,begin:0,bias:0,by:0,calcMode:1,capHeight:1,"cap-height":"capHeight",clip:0,clipPath:1,"clip-path":"clipPath",clipPathUnits:1,clipRule:1,"clip-rule":"clipRule",color:0,colorInterpolation:1,"color-interpolation":"colorInterpolation",colorInterpolationFilters:1,"color-interpolation-filters":"colorInterpolationFilters",colorProfile:1,"color-profile":"colorProfile",colorRendering:1,"color-rendering":"colorRendering",contentScriptType:1,contentStyleType:1,cursor:0,cx:0,cy:0,d:0,datatype:0,decelerate:0,descent:0,diffuseConstant:1,direction:0,display:0,divisor:0,dominantBaseline:1,"dominant-baseline":"dominantBaseline",dur:0,dx:0,dy:0,edgeMode:1,elevation:0,enableBackground:1,"enable-background":"enableBackground",end:0,exponent:0,externalResourcesRequired:1,fill:0,fillOpacity:1,"fill-opacity":"fillOpacity",fillRule:1,"fill-rule":"fillRule",filter:0,filterRes:1,filterUnits:1,floodOpacity:1,"flood-opacity":"floodOpacity",floodColor:1,"flood-color":"floodColor",focusable:0,fontFamily:1,"font-family":"fontFamily",fontSize:1,"font-size":"fontSize",fontSizeAdjust:1,"font-size-adjust":"fontSizeAdjust",fontStretch:1,"font-stretch":"fontStretch",fontStyle:1,"font-style":"fontStyle",fontVariant:1,"font-variant":"fontVariant",fontWeight:1,"font-weight":"fontWeight",format:0,from:0,fx:0,fy:0,g1:0,g2:0,glyphName:1,"glyph-name":"glyphName",glyphOrientationHorizontal:1,"glyph-orientation-horizontal":"glyphOrientationHorizontal",glyphOrientationVertical:1,"glyph-orientation-vertical":"glyphOrientationVertical",glyphRef:1,gradientTransform:1,gradientUnits:1,hanging:0,horizAdvX:1,"horiz-adv-x":"horizAdvX",horizOriginX:1,"horiz-origin-x":"horizOriginX",ideographic:0,imageRendering:1,"image-rendering":"imageRendering",in2:0,in:0,inlist:0,intercept:0,k1:0,k2:0,k3:0,k4:0,k:0,kernelMatrix:1,kernelUnitLength:1,kerning:0,keyPoints:1,keySplines:1,keyTimes:1,lengthAdjust:1,letterSpacing:1,"letter-spacing":"letterSpacing",lightingColor:1,"lighting-color":"lightingColor",limitingConeAngle:1,local:0,markerEnd:1,"marker-end":"markerEnd",markerHeight:1,markerMid:1,"marker-mid":"markerMid",markerStart:1,"marker-start":"markerStart",markerUnits:1,markerWidth:1,mask:0,maskContentUnits:1,maskUnits:1,mathematical:0,mode:0,numOctaves:1,offset:0,opacity:0,operator:0,order:0,orient:0,orientation:0,origin:0,overflow:0,overlinePosition:1,"overline-position":"overlinePosition",overlineThickness:1,"overline-thickness":"overlineThickness",paintOrder:1,"paint-order":"paintOrder",panose1:0,"panose-1":"panose1",pathLength:1,patternContentUnits:1,patternTransform:1,patternUnits:1,pointerEvents:1,"pointer-events":"pointerEvents",points:0,pointsAtX:1,pointsAtY:1,pointsAtZ:1,prefix:0,preserveAlpha:1,preserveAspectRatio:1,primitiveUnits:1,property:0,r:0,radius:0,refX:1,refY:1,renderingIntent:1,"rendering-intent":"renderingIntent",repeatCount:1,repeatDur:1,requiredExtensions:1,requiredFeatures:1,resource:0,restart:0,result:0,results:0,rotate:0,rx:0,ry:0,scale:0,security:0,seed:0,shapeRendering:1,"shape-rendering":"shapeRendering",slope:0,spacing:0,specularConstant:1,specularExponent:1,speed:0,spreadMethod:1,startOffset:1,stdDeviation:1,stemh:0,stemv:0,stitchTiles:1,stopColor:1,"stop-color":"stopColor",stopOpacity:1,"stop-opacity":"stopOpacity",strikethroughPosition:1,"strikethrough-position":"strikethroughPosition",strikethroughThickness:1,"strikethrough-thickness":"strikethroughThickness",string:0,stroke:0,strokeDasharray:1,"stroke-dasharray":"strokeDasharray",strokeDashoffset:1,"stroke-dashoffset":"strokeDashoffset",strokeLinecap:1,"stroke-linecap":"strokeLinecap",strokeLinejoin:1,"stroke-linejoin":"strokeLinejoin",strokeMiterlimit:1,"stroke-miterlimit":"strokeMiterlimit",strokeWidth:1,"stroke-width":"strokeWidth",strokeOpacity:1,"stroke-opacity":"strokeOpacity",suppressContentEditableWarning:1,suppressHydrationWarning:1,surfaceScale:1,systemLanguage:1,tableValues:1,targetX:1,targetY:1,textAnchor:1,"text-anchor":"textAnchor",textDecoration:1,"text-decoration":"textDecoration",textLength:1,textRendering:1,"text-rendering":"textRendering",to:0,transform:0,typeof:0,u1:0,u2:0,underlinePosition:1,"underline-position":"underlinePosition",underlineThickness:1,"underline-thickness":"underlineThickness",unicode:0,unicodeBidi:1,"unicode-bidi":"unicodeBidi",unicodeRange:1,"unicode-range":"unicodeRange",unitsPerEm:1,"units-per-em":"unitsPerEm",unselectable:0,vAlphabetic:1,"v-alphabetic":"vAlphabetic",values:0,vectorEffect:1,"vector-effect":"vectorEffect",version:0,vertAdvY:1,"vert-adv-y":"vertAdvY",vertOriginX:1,"vert-origin-x":"vertOriginX",vertOriginY:1,"vert-origin-y":"vertOriginY",vHanging:1,"v-hanging":"vHanging",vIdeographic:1,"v-ideographic":"vIdeographic",viewBox:1,viewTarget:1,visibility:0,vMathematical:1,"v-mathematical":"vMathematical",vocab:0,widths:0,wordSpacing:1,"word-spacing":"wordSpacing",writingMode:1,"writing-mode":"writingMode",x1:0,x2:0,x:0,xChannelSelector:1,xHeight:1,"x-height":"xHeight",xlinkActuate:1,"xlink:actuate":"xlinkActuate",xlinkArcrole:1,"xlink:arcrole":"xlinkArcrole",xlinkHref:1,"xlink:href":"xlinkHref",xlinkRole:1,"xlink:role":"xlinkRole",xlinkShow:1,"xlink:show":"xlinkShow",xlinkTitle:1,"xlink:title":"xlinkTitle",xlinkType:1,"xlink:type":"xlinkType",xmlBase:1,"xml:base":"xmlBase",xmlLang:1,"xml:lang":"xmlLang",xmlns:0,"xml:space":"xmlSpace",xmlnsXlink:1,"xmlns:xlink":"xmlnsXlink",xmlSpace:1,y1:0,y2:0,y:0,yChannelSelector:1,z:0,zoomAndPan:1},fS}var xae;function cut(){if(xae)return zc;xae=1;const e=0,t=1,n=2,r=3,i=4,s=5,a=6;function o(x){return c.hasOwnProperty(x)?c[x]:null}function l(x,S,T,_,P,E,C){this.acceptsBooleans=S===n||S===r||S===i,this.attributeName=_,this.attributeNamespace=P,this.mustUseProperty=T,this.propertyName=x,this.type=S,this.sanitizeURL=E,this.removeEmptyString=C}const c={};["children","dangerouslySetInnerHTML","defaultValue","defaultChecked","innerHTML","suppressContentEditableWarning","suppressHydrationWarning","style"].forEach(x=>{c[x]=new l(x,e,!1,x,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(([x,S])=>{c[x]=new l(x,t,!1,S,null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(x=>{c[x]=new l(x,n,!1,x.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(x=>{c[x]=new l(x,n,!1,x,null,!1,!1)}),["allowFullScreen","async","autoFocus","autoPlay","controls","default","defer","disabled","disablePictureInPicture","disableRemotePlayback","formNoValidate","hidden","loop","noModule","noValidate","open","playsInline","readOnly","required","reversed","scoped","seamless","itemScope"].forEach(x=>{c[x]=new l(x,r,!1,x.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(x=>{c[x]=new l(x,r,!0,x,null,!1,!1)}),["capture","download"].forEach(x=>{c[x]=new l(x,i,!1,x,null,!1,!1)}),["cols","rows","size","span"].forEach(x=>{c[x]=new l(x,a,!1,x,null,!1,!1)}),["rowSpan","start"].forEach(x=>{c[x]=new l(x,s,!1,x.toLowerCase(),null,!1,!1)});const d=/[\-\:]([a-z])/g,h=x=>x[1].toUpperCase();["accent-height","alignment-baseline","arabic-form","baseline-shift","cap-height","clip-path","clip-rule","color-interpolation","color-interpolation-filters","color-profile","color-rendering","dominant-baseline","enable-background","fill-opacity","fill-rule","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-name","glyph-orientation-horizontal","glyph-orientation-vertical","horiz-adv-x","horiz-origin-x","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","overline-position","overline-thickness","paint-order","panose-1","pointer-events","rendering-intent","shape-rendering","stop-color","stop-opacity","strikethrough-position","strikethrough-thickness","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-rendering","underline-position","underline-thickness","unicode-bidi","unicode-range","units-per-em","v-alphabetic","v-hanging","v-ideographic","v-mathematical","vector-effect","vert-adv-y","vert-origin-x","vert-origin-y","word-spacing","writing-mode","xmlns:xlink","x-height"].forEach(x=>{const S=x.replace(d,h);c[S]=new l(S,t,!1,x,null,!1,!1)}),["xlink:actuate","xlink:arcrole","xlink:role","xlink:show","xlink:title","xlink:type"].forEach(x=>{const S=x.replace(d,h);c[S]=new l(S,t,!1,x,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(x=>{const S=x.replace(d,h);c[S]=new l(S,t,!1,x,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(x=>{c[x]=new l(x,t,!1,x.toLowerCase(),null,!1,!1)});const f="xlinkHref";c[f]=new l("xlinkHref",t,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(x=>{c[x]=new l(x,t,!1,x.toLowerCase(),null,!0,!0)});const{CAMELCASE:O,SAME:g,possibleStandardNames:m}=lut(),y=":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD"+"\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",w=RegExp.prototype.test.bind(new RegExp("^(data|aria)-["+y+"]*$")),k=Object.keys(m).reduce((x,S)=>{const T=m[S];return T===g?x[S]=S:T===O?x[S.toLowerCase()]=S:x[S]=T,x},{});return zc.BOOLEAN=r,zc.BOOLEANISH_STRING=n,zc.NUMERIC=s,zc.OVERLOADED_BOOLEAN=i,zc.POSITIVE_NUMERIC=a,zc.RESERVED=e,zc.STRING=t,zc.getPropertyInfo=o,zc.isCustomAttribute=w,zc.possibleStandardNames=k,zc}var pS={},My={},z6,Sae;function uut(){if(Sae)return z6;Sae=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,o=/^\s+|\s+$/g,l=`
780
780
  `,c="/",u="*",d="",h="comment",f="declaration";z6=function(g,m){if(typeof g!="string")throw new TypeError("First argument must be a string");if(!g)return[];m=m||{};var v=1,y=1;function w(D){var F=D.match(t);F&&(v+=F.length);var I=D.lastIndexOf(l);y=~I?D.length-I:y+D.length}function k(){var D={line:v,column:y};return function(F){return F.position=new x(D),_(),F}}function x(D){this.start=D,this.end={line:v,column:y},this.source=m.source}x.prototype.content=g;function S(D){var F=new Error(m.source+":"+v+":"+y+": "+D);if(F.reason=D,F.filename=m.source,F.line=v,F.column=y,F.source=g,!m.silent)throw F}function T(D){var F=D.exec(g);if(F){var I=F[0];return w(I),g=g.slice(I.length),F}}function _(){T(n)}function P(D){var F;for(D=D||[];F=E();)F!==!1&&D.push(F);return D}function E(){var D=k();if(!(c!=g.charAt(0)||u!=g.charAt(1))){for(var F=2;d!=g.charAt(F)&&(u!=g.charAt(F)||c!=g.charAt(F+1));)++F;if(F+=2,d===g.charAt(F-1))return S("End of comment missing");var I=g.slice(2,F-2);return y+=2,w(I),g=g.slice(F),y+=2,D({type:h,comment:I})}}function C(){var D=k(),F=T(r);if(F){if(E(),!T(i))return S("property missing ':'");var I=T(s),U=D({type:f,property:O(F[0].replace(e,d)),value:I?O(I[0].replace(e,d)):d});return T(a),U}}function Q(){var D=[];P(D);for(var F;F=C();)F!==!1&&(D.push(F),P(D));return D}return _(),Q()};function O(g){return g?g.replace(o,d):d}return z6}var $ae;function dut(){if($ae)return My;$ae=1;var e=My&&My.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(My,"__esModule",{value:!0}),My.default=n;var t=e(uut());function n(r,i){var s=null;if(!r||typeof r!="string")return s;var a=(0,t.default)(r),o=typeof i=="function";return a.forEach(function(l){if(l.type==="declaration"){var c=l.property,u=l.value;o?i(c,u,l):u&&(s=s||{},s[c]=u)}}),s}return My}var OS={},kae;function hut(){if(kae)return OS;kae=1,Object.defineProperty(OS,"__esModule",{value:!0}),OS.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(c){return!c||n.test(c)||e.test(c)},a=function(c,u){return u.toUpperCase()},o=function(c,u){return"".concat(u,"-")},l=function(c,u){return u===void 0&&(u={}),s(c)?c:(c=c.toLowerCase(),u.reactCompat?c=c.replace(i,o):c=c.replace(r,o),c.replace(t,a))};return OS.camelCase=l,OS}var gS,Tae;function MCe(){if(Tae)return gS;Tae=1;var e=gS&&gS.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(dut()),n=hut();function r(i,s){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(o,l){o&&l&&(a[(0,n.camelCase)(o,s)]=l)}),a}return r.default=r,gS=r,gS}var _ae;function jCe(){return _ae||(_ae=1,function(e){var t=pS&&pS.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(e,"__esModule",{value:!0}),e.returnFirstArg=e.canTextBeChildOfNode=e.ELEMENTS_WITH_NO_TEXT_CHILDREN=e.PRESERVE_CUSTOM_ATTRIBUTES=void 0,e.isCustomComponent=s,e.setStyleProp=o;var n=p_e(),r=t(MCe()),i=new Set(["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"]);function s(u,d){return u.includes("-")?!i.has(u):!!(d&&typeof d.is=="string")}var a={reactCompat:!0};function o(u,d){if(typeof u=="string"){if(!u.trim()){d.style={};return}try{d.style=(0,r.default)(u,a)}catch{d.style={}}}}e.PRESERVE_CUSTOM_ATTRIBUTES=Number(n.version.split(".")[0])>=16,e.ELEMENTS_WITH_NO_TEXT_CHILDREN=new Set(["tr","tbody","thead","tfoot","colgroup","table","head","html","frameset"]);var l=function(u){return!e.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(u.name)};e.canTextBeChildOfNode=l;var c=function(u){return u};e.returnFirstArg=c}(pS)),pS}var Pae;function LCe(){if(Pae)return fC;Pae=1,Object.defineProperty(fC,"__esModule",{value:!0}),fC.default=s;var e=cut(),t=jCe(),n=["checked","value"],r=["input","select","textarea"],i={reset:!0,submit:!0};function s(o,l){o===void 0&&(o={});var c={},u=!!(o.type&&i[o.type]);for(var d in o){var h=o[d];if((0,e.isCustomAttribute)(d)){c[d]=h;continue}var f=d.toLowerCase(),O=a(f);if(O){var g=(0,e.getPropertyInfo)(O);switch(n.includes(O)&&r.includes(l)&&!u&&(O=a("default"+f)),c[O]=h,g&&g.type){case e.BOOLEAN:c[O]=!0;break;case e.OVERLOADED_BOOLEAN:h===""&&(c[O]=!0);break}continue}t.PRESERVE_CUSTOM_ATTRIBUTES&&(c[d]=h)}return(0,t.setStyleProp)(o.style,c),c}function a(o){return e.possibleStandardNames[o]}return fC}var jy={},Cae;function fut(){if(Cae)return jy;Cae=1;var e=jy&&jy.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(jy,"__esModule",{value:!0}),jy.default=s;var t=p_e(),n=e(LCe()),r=jCe(),i={cloneElement:t.cloneElement,createElement:t.createElement,isValidElement:t.isValidElement};function s(o,l){l===void 0&&(l={});for(var c=[],u=typeof l.replace=="function",d=l.transform||r.returnFirstArg,h=l.library||i,f=h.cloneElement,O=h.createElement,g=h.isValidElement,m=o.length,v=0;v<m;v++){var y=o[v];if(u){var w=l.replace(y,v);if(g(w)){m>1&&(w=f(w,{key:w.key||v})),c.push(d(w,y,v));continue}}if(y.type==="text"){var k=!y.data.trim().length;if(k&&y.parent&&!(0,r.canTextBeChildOfNode)(y.parent)||l.trim&&k)continue;c.push(d(y.data,y,v));continue}var x=y,S={};a(x)?((0,r.setStyleProp)(x.attribs.style,x.attribs),S=x.attribs):x.attribs&&(S=(0,n.default)(x.attribs,x.name));var T=void 0;switch(y.type){case"script":case"style":y.children[0]&&(S.dangerouslySetInnerHTML={__html:y.children[0].data});break;case"tag":y.name==="textarea"&&y.children[0]?S.defaultValue=y.children[0].data:y.children&&y.children.length&&(T=s(y.children,l));break;default:continue}m>1&&(S.key=v),c.push(d(O(y.name,S,T),y,v))}return c.length===1?c[0]:c}function a(o){return r.PRESERVE_CUSTOM_ATTRIBUTES&&o.type==="tag"&&(0,r.isCustomComponent)(o.name,o.attribs)}return jy}var Eae;function put(){return Eae||(Eae=1,function(e){var t=hS&&hS.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(e,"__esModule",{value:!0}),e.htmlToDOM=e.domToReact=e.attributesToProps=e.Text=e.ProcessingInstruction=e.Element=e.Comment=void 0,e.default=o;var n=t(out());e.htmlToDOM=n.default;var r=t(LCe());e.attributesToProps=r.default;var i=t(fut());e.domToReact=i.default;var s=ICe();Object.defineProperty(e,"Comment",{enumerable:!0,get:function(){return s.Comment}}),Object.defineProperty(e,"Element",{enumerable:!0,get:function(){return s.Element}}),Object.defineProperty(e,"ProcessingInstruction",{enumerable:!0,get:function(){return s.ProcessingInstruction}}),Object.defineProperty(e,"Text",{enumerable:!0,get:function(){return s.Text}});var a={lowerCaseAttributeNames:!1};function o(l,c){if(typeof l!="string")throw new TypeError("First argument must be a string");return l?(0,i.default)((0,n.default)(l,c?.htmlparser2||a),c):[]}}(hS)),hS}var Out=put();const Qae=sn(Out),gut=Qae.default||Qae,mut=/\/(?![\/\d])/g,Rae=e=>e.replace(mut,"/​"),xb=({detail:e,stacked:t=!1})=>{const[n,r]=b.useState(!1),i=p.jsxs(we,{variant:"ghost",size:"sm",className:t?"-ml-2":void 0,onClick:()=>{navigator.clipboard.writeText(e).then(()=>r(!0)).catch(()=>{})},children:[n?p.jsx(Ul,{}):p.jsx(ey,{}),n?"Copied":"Copy details"]});return p.jsx("div",{className:t?"mt-4 flex flex-col items-start gap-1":"mt-4 flex items-start gap-2",children:t?p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"text-meta text-ink-dim",children:"Details:"}),p.jsx("span",{className:"font-mono text-mono-sm break-all text-ink-dim",children:Rae(e)}),i]}):p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:"Details:"}),p.jsx("span",{className:"min-w-0 flex-1 break-words font-mono text-mono-sm text-ink-dim",children:Rae(e)}),i]})})},vut=({open:e,message:t,onClose:n,autoHideDuration:r,onRetry:i,retrying:s=!1})=>{const{sentence:a,detail:o,action:l}=$Ce(t);return p.jsxs(Db,{open:e,autoHideDuration:r,onClose:n,variant:"danger",action:l==="check"&&i?p.jsx(we,{variant:"primary",size:"sm",onClick:i,disabled:s,children:s?"Checking...":"Try again"}):null,children:[p.jsx("p",{children:a}),o!==null?p.jsx(xb,{detail:o,stacked:!0}):null]})},yut=/^v/i,qCe=(e,t)=>{const n=o=>o.trim().replace(yut,""),r=n(e),i=n(t);if(r===i)return!0;if(r.includes("-")||i.includes("-"))return!1;const s=r.split(".").map(Number),a=i.split(".").map(Number);for(let o=0;o<Math.max(s.length,a.length);o++){const l=s[o]??0,c=a[o]??0;if(!Number.isFinite(l)||!Number.isFinite(c))return!1;if(l>c)return!0;if(l<c)return!1}return!0},zCe=e=>{const{target:t,sourceBuild:n}=e.expectation;return n?!0:t==null?!1:e.reported!=null&&qCe(e.reported,t)},but=e=>e.manual===!0&&zCe({reported:e.currentVersion,expectation:e.expectation}),wut=e=>e?`The server update to ${e} did not complete.`:"The server update did not complete.",xut={"installed-bundle-not-sealed":"This app can't update itself","download-verification-failed":"The update couldn't be verified","artifact-metadata-missing":"The update couldn't be verified","insufficient-disk-space":"Not enough disk space to update"},_f=({className:e,tone:t="notice",role:n,...r})=>(up(!0,"update-notice"),p.jsx("div",{role:n??(t==="failed"?"alert":"status"),className:A("fixed top-4 right-4 z-50 w-100 max-w-[calc(100vw-2rem)]","rounded-lg bg-elevated p-4 shadow-overlay","[&_a]:text-accent [&_a]:underline-offset-4 [&_a]:hover:underline",e),...r})),mS=({children:e,tone:t="notice"})=>p.jsxs("h2",{className:A("mb-3 flex items-center gap-2 text-heading text-ink"),children:[t==="failed"&&p.jsx(qP,{className:"size-4 shrink-0 text-danger","aria-hidden":!0}),e]}),pC=({command:e})=>{const[t,n]=b.useState(!1);return p.jsxs("div",{className:"mt-2 flex items-start gap-2",children:[p.jsx("code",{className:"min-w-0 flex-1 rounded-sm bg-sunken p-2 text-mono-sm break-all text-ink",children:e}),p.jsxs(we,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(e).then(()=>n(!0)).catch(()=>{})},children:[t?p.jsx(Ul,{}):p.jsx(ey,{}),t?"Copied":"Copy command"]})]})},Sut=["[&_:is(h1,h2,h3,h4,h5,h6)]:mt-3 [&_:is(h1,h2,h3,h4,h5,h6)]:mb-1 [&_:is(h1,h2,h3,h4,h5,h6)]:font-semibold [&_:is(h1,h2,h3,h4,h5,h6)]:text-ink","[&_h1]:text-heading [&_h2]:text-heading [&_h3]:text-body [&_h4]:text-body [&_h5]:text-body-sm [&_h6]:text-body-sm","[&_p]:my-1.5 [&_p:first-child]:mt-0 [&_p:last-child]:mb-0","[&_:is(ul,ol)]:my-1.5 [&_:is(ul,ol)]:pl-5 [&_ul_li]:list-disc [&_ol_li]:list-decimal [&_li]:my-0.5","[&_code]:rounded-xs [&_code]:bg-sunken [&_code]:px-1 [&_code]:font-mono [&_code]:text-mono-sm"].join(" "),U6=({command:e,sourceBuild:t})=>t&&!e?p.jsx("p",{className:"mt-2 text-body text-ink",children:"This server follows this machine's checkout, so there is no command to run here."}):p.jsx("p",{className:"mt-2 text-body text-ink",children:t?"Run this in a terminal. It rebuilds the server from this machine's checkout, so the version it reports afterwards is your checkout's rather than the published release.":e?"Run this in a terminal, then check for updates again to pick up the new server version.":"Then check for updates again to pick up the new server version."}),Aae=({latestVersion:e,currentVersion:t,className:n})=>e?p.jsxs("p",{className:A("mb-2 text-body text-ink-muted",n),children:[`Server version ${e} is available.`,t?` You are currently using version ${t}.`:""]}):null,Pf=({className:e,...t})=>p.jsx("div",{className:A("mt-6 flex flex-wrap justify-end gap-3",e),...t}),Dae=({className:e,...t})=>p.jsx("div",{className:A("mt-4 mb-2",e),...t}),$ut=({autoCheck:e=!0})=>{const[t,n]=b.useState(!1),[r,i]=b.useState(!1),[s,a]=b.useState(!1),[o,l]=b.useState(null),[c,u]=b.useState(!1),[d,h]=b.useState(null),[f,O]=b.useState(!1),[g,m]=b.useState(null),[v,y]=b.useState(!1),[w,k]=b.useState("unknown"),[x,S]=b.useState(null),[T,_]=b.useState(!1),[P,E]=b.useState(null),[C,Q]=b.useState(!1),[D,F]=b.useState(!1),[I,U]=b.useState(null),q=b.useRef({target:null,sourceBuild:!1}),Z=b.useRef({terminal:!1,inFlight:!1}),[W,M]=b.useState(!1),[J,L]=b.useState(null),[N,z]=b.useState(null),[V,ee]=b.useState(null),{shouldShowUpdate:oe,deferUpdate:ie}=Glt(),he=b.useRef(null);b.useEffect(()=>{he.current=P},[P]),b.useEffect(()=>{window.api.systemInfo.getAppVersion().then(Re=>k(Re)).catch(()=>k("unknown"))},[]);const te=b.useCallback(Re=>{switch(Bse(Re)){case"muted":return console.warn(`Update check reported no artifact for this build: ${Re}`),!1;default:return m(Re),y(!0),!0}},[]),pe=b.useCallback(async Re=>{try{n(!0),Re?.keepFailure!==!0&&m(null),await window.api.updater.checkForUpdates(Re?.manual===void 0?void 0:{manual:Re.manual}),Re?.keepFailure===!0&&m(null)}catch(Tt){if(Re?.manual!==!0)return;const Te=If(Tt);Bse(Te)==="muted"&&(a(!1),l(null)),te(Te)}finally{n(!1)}},[te]),B=b.useCallback(async()=>{try{n(!0),m(null),await window.api.updater.checkForAllUpdates({manual:!0})}catch(Re){te(If(Re))}finally{n(!1)}},[te]),Ce=b.useCallback(async()=>{try{u(!0),m(null),await window.api.updater.downloadUpdate()}catch(Re){m(`Error downloading update: ${If(Re)}`),u(!1),y(!0)}},[]),Qe=b.useCallback(async()=>{M(!0),m(null);try{await window.api.updater.quitAndInstall()||M(!1)}catch(Re){M(!1),m(`Error starting the update: ${If(Re)}`),y(!0)}},[]),Fe=b.useCallback(async()=>{try{await window.api.updater.quitForUpdateInstall()}catch(Re){m(`Error quitting for the update: ${If(Re)}`),y(!0)}},[]),Oe=b.useCallback(Re=>{Re&&window.api.openExternal(Re)},[]),ye=b.useCallback(()=>{const Re=Z.current;return Re.inFlight?(Re.terminal=!0,Re.inFlight=!1,!0):!1},[]),_e=b.useCallback(async()=>{Z.current={terminal:!1,inFlight:!0};try{n(!0),i(!0),m(null),S(null);const Re=he.current?.latestVersion;await window.api.updater.updateBackend(Re)===!1&&!Z.current.terminal&&S(wut(Re))}catch(Re){Z.current.terminal||S(`The server update could not be started: ${If(Re)}`)}finally{Z.current.inFlight=!1,n(!1),i(!1)}},[]),Ge=b.useCallback(()=>{y(!1),m(null)},[]),tt=b.useCallback(()=>{P&&(ie(wb.BACKEND,P.latestVersion),_(!1),E(null)),Ge()},[Ge,ie,P]),Lt=b.useCallback(()=>{S(null),tt()},[tt]),Qt=b.useCallback(()=>{o&&(ie(wb.UI,o.version),a(!1),O(!1)),Ge()},[Ge,ie,o]);b.useEffect(()=>{const Re=window.api.updater.onUpdateAvailable(fn=>{oe(wb.UI,fn.version)&&(z(null),a(!0),l(fn),y(!0))}),Tt=window.api.updater.onUpdateNotAvailable(()=>{a(!1),l(null)}),Te=window.api.updater.onUpdateDownloaded(fn=>{u(!1),oe(wb.UI,fn.version)&&(z(null),O(!0),l(fn),y(!0))}),ze=window.api.updater.onUpdateError(fn=>{const Se=If(fn);te(Se)&&(n(!1),u(!1))}),et=window.api.updater.onBackendUpdateManualRequired(fn=>{ye(),q.current={target:fn.latestVersion??he.current?.latestVersion??null,sourceBuild:fn.sourceBuild===!0},F(!0),U(fn),n(!1),i(!1),_(!1),E(null)}),Dt=window.api.updater.onUpdateInstallBlocked(fn=>{L(fn),n(!1),i(!1),u(!1)}),St=window.api.updater.onUpdateInstallFailed(fn=>{z(fn),ee(null),n(!1)}),Tn=window.api.updater.onUpdateInstallInFlight(fn=>{ee(fn),z(null),n(!1)}),xn=window.api.updater.onUpdateProgress(fn=>{h(fn)}),Ct=window.api.updater.onBackendUpdateAvailable(fn=>{if(but({manual:fn.manual,currentVersion:fn.currentVersion,expectation:q.current})&&(F(!1),U(null),q.current={target:null,sourceBuild:!1}),oe(wb.BACKEND,fn.latestVersion)){const Se={...fn,canManageUpdate:fn.canManageUpdate??!fn.updateCommand.includes("manually")};_(!0),E(Se),S(null),y(!0)}}),Or=window.api.updater.onBackendUpdateNotAvailable(fn=>{const Se=he.current;_(xt=>Se&&qCe(fn.version,Se.latestVersion)?(E(null),!1):xt);const je=q.current;(je.target==null||zCe({reported:fn.version,expectation:je}))&&(F(!1),U(null),q.current={target:null,sourceBuild:!1})}),ni=window.api.updater.onBackendUpdateCompleted(()=>{ye(),_(!1),E(null),n(!1),i(!1),Q(!0),y(!0),setTimeout(()=>{Q(!1)},6e3)}),Gn=window.api.updater.onBackendUpdateError(fn=>{if(fn.phase==="update"&&ye()){S(AZ(fn.message)),n(!1),i(!1);return}m(If(fn.message)),y(!0)});return e&&pe(),()=>{Re(),Tt(),Te(),ze(),xn(),Ct(),Or(),ni(),Gn(),et(),Dt(),St(),Tn()}},[ye,e,pe,te,oe]);const an=(Re,Tt)=>p.jsxs(p.Fragment,{children:[Re,g!==null?p.jsx(vut,{open:v,message:g,onClose:Ge,onRetry:()=>void pe({manual:!0,keepFailure:!0}),retrying:t}):Tt]});return N?an(p.jsxs(_f,{tone:"failed",children:[p.jsx(mS,{tone:"failed",children:N.cancelledByRelaunch?"The update was cancelled":"The last update didn't finish"}),p.jsx("p",{className:"mb-2 text-body text-ink-muted",children:N.message}),p.jsx("p",{className:"mt-2 text-body text-ink",children:N.remedy.text}),(N.attempts??1)>1&&p.jsxs("p",{className:"mt-1 text-body-sm text-ink-muted",children:["Version ",N.targetVersion," has failed to install"," ",N.attempts," times on this machine."]}),p.jsx("p",{className:"mt-1 text-body-sm text-ink-muted",children:"This is also recorded in Settings, under Application updates."}),p.jsxs(Pf,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:()=>z(null),children:"Update later"}),p.jsx(we,{variant:"outline",size:"sm",onClick:()=>void pe({manual:!0}),disabled:t,children:t?"Checking...":"Check for updates"}),p.jsx(we,{variant:"primary",size:"sm",onClick:()=>Oe(N.remedy.url),children:"Open download page"})]}),N.detail&&p.jsx(xb,{detail:N.detail})]})):V?an(p.jsxs(_f,{role:"alert",children:[p.jsx(mS,{children:"The update is still installing"}),p.jsx("p",{className:"mb-2 text-body text-ink-muted",children:V.message}),p.jsxs(Pf,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:()=>ee(null),children:"Keep using Local Operator (cancels the install)"}),p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void Fe(),children:"Quit and let the update finish"})]}),V.detail&&p.jsx(xb,{detail:V.detail})]})):t?an(p.jsxs(_f,{children:[p.jsx("h2",{className:"mb-3 text-heading text-ink",children:r?"Updating server":"Checking for updates"}),p.jsx("p",{className:"mb-2 text-body text-ink-muted",children:r?"Please wait while the server is being updated. The server will temporarily go offline while it restarts to apply the update. The update can't be interrupted once it has started.":"Please wait while we check for available updates..."}),p.jsx(Dae,{children:p.jsx(vre,{})})]})):J?an(p.jsxs(_f,{tone:"failed",children:[p.jsx(mS,{tone:"failed",children:J.heading??xut[J.code]??"The update wasn't installed"}),p.jsx("p",{className:"mb-2 text-body text-ink-muted",children:J.message}),p.jsx("p",{className:"mt-2 text-body text-ink",children:J.remedy.text}),J.remedy.command&&p.jsx(pC,{command:J.remedy.command}),p.jsxs(Pf,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:()=>L(null),children:J.dismissLabel??"Update later"}),J.remedy.url?p.jsx(we,{variant:"primary",size:"sm",onClick:()=>Oe(J.remedy.url),children:"Open download page"}):p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void pe({manual:!0}),disabled:t,children:t?"Checking...":"Check for updates"})]}),J.detail&&p.jsx(xb,{detail:J.detail})]})):D&&I?an(p.jsxs(_f,{children:[p.jsx(mS,{children:"The server needs updating by hand"}),p.jsx("p",{className:"mb-2 text-body text-ink",children:I.message}),I.sourceBuild===!0?p.jsxs(p.Fragment,{children:[I.command?p.jsx(pC,{command:I.command}):null,p.jsx(U6,{command:!!I.command,sourceBuild:!0}),p.jsx(Aae,{className:"mt-2",latestVersion:I.latestVersion,currentVersion:I.currentVersion})]}):p.jsxs(p.Fragment,{children:[p.jsx(Aae,{latestVersion:I.latestVersion,currentVersion:I.currentVersion}),I.command?p.jsx(pC,{command:I.command}):null,p.jsx(U6,{command:!!I.command,sourceBuild:!1})]}),p.jsxs(Pf,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:()=>{F(!1),U(null)},children:"Update later"}),p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void B(),disabled:t,children:t?"Checking...":"Check for updates"})]}),I.detail&&p.jsx(xb,{detail:I.detail})]})):s&&!f&&o?an(p.jsxs(_f,{children:[p.jsx("h2",{className:"mb-3 text-heading text-ink",children:"Update available"}),p.jsxs("p",{className:"mb-2 text-body text-ink-muted",children:["Version ",o.version," is available. You are currently using version ",w,"."]}),o.releaseNotes&&p.jsxs("div",{className:A("mt-2 text-body text-ink-muted",Sut),children:["Release notes:"," ",typeof o.releaseNotes=="string"?p.jsxs(p.Fragment,{children:[gut(kut(o.releaseNotes,400)),o.releaseNotes.length>400&&p.jsx("a",{href:Nae(o),target:"_blank",rel:"noopener noreferrer",className:"ml-2",children:"View full release notes"})]}):p.jsx("a",{href:Nae(o),target:"_blank",rel:"noopener noreferrer",children:"See release notes on GitHub"})]}),c&&d&&p.jsxs(Dae,{children:[p.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Downloading: ",Math.round(d.percent),"%"]}),p.jsx(vre,{value:d.percent,className:"mt-2"}),p.jsxs("p",{className:"mt-1 text-mono-sm text-ink-dim",children:[Math.round(d.transferred/1024)," KB of"," ",Math.round(d.total/1024)," KB"]})]}),p.jsx(Pf,{children:!c&&p.jsxs(p.Fragment,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:Qt,disabled:c,children:"Update later"}),p.jsx(we,{variant:"primary",size:"sm",onClick:Ce,disabled:c,children:"Download update"})]})})]}),p.jsxs(Db,{open:v,autoHideDuration:6e3,onClose:Ge,variant:"info",children:["A new update is available: v",o.version]})):f&&o?an(p.jsxs(_f,{children:[p.jsx("h2",{className:"mb-3 text-heading text-ink",children:"Update ready to install"}),p.jsxs("p",{className:"mb-2 text-body text-ink-muted",children:["Version ",o.version," has been downloaded. You are currently using version ",w,"."]}),p.jsx("p",{className:"mt-2 text-body text-ink-muted",children:"Installing closes the app for a few minutes while the update is verified and put in place. Don't reopen it until it starts by itself. Opening it while the update is installing cancels the install."}),p.jsxs(Pf,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:Qt,disabled:W,children:"Update later"}),p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void Qe(),disabled:W,children:W?"Preparing to install...":"Install now"})]})]}),p.jsx(Db,{open:v,autoHideDuration:6e3,onClose:Ge,variant:"success",children:"Update downloaded and ready to install"})):x?an(p.jsxs(_f,{tone:"failed",children:[p.jsx(mS,{tone:"failed",children:"The server update didn't finish"}),p.jsx("p",{className:"mb-2 text-body text-ink-muted",children:x}),p.jsxs(Pf,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:Lt,children:"Update later"}),p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void _e(),children:"Try again"})]})]})):T&&P?an(p.jsxs(_f,{children:[p.jsx("h2",{className:"mb-3 text-heading text-ink",children:"Server update available"}),p.jsxs("p",{className:"mb-2 text-body text-ink-muted",children:["Server version ",P.latestVersion," is available. You are currently using version ",P.currentVersion,"."]}),p.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:"Updating the server will improve AI functionality, improve security, and fix bugs."}),P.canManageUpdate?p.jsxs(Pf,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:tt,disabled:t,children:"Update later"}),p.jsx(we,{variant:"primary",size:"sm",onClick:_e,disabled:t,children:t?"Updating...":"Update server"})]}):p.jsxs(p.Fragment,{children:[p.jsx("p",{className:"mt-4 text-body text-ink",children:P.remedy??"The server is installed outside the app, so use the tool you installed it with - uv, pipx or pip:"}),P.updateCommand&&p.jsx(pC,{command:P.updateCommand}),p.jsx(U6,{command:!!P.updateCommand,sourceBuild:P.sourceBuild===!0}),p.jsxs(Pf,{children:[p.jsx(we,{variant:"outline",size:"sm",onClick:tt,disabled:t,children:"Update later"}),p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void B(),disabled:t,children:t?"Checking...":"Check for updates"})]}),P.detail&&p.jsx(xb,{detail:P.detail})]})]}),P.canManageUpdate&&p.jsxs(Db,{open:v,autoHideDuration:6e3,onClose:Ge,variant:"info",children:["A new server update is available: v",P.latestVersion]})):C?an(null,p.jsx(Db,{open:!0,autoHideDuration:6e3,onClose:()=>Q(!1),variant:"success",children:"Server update completed successfully"})):an(null)},kut=(e,t)=>e.length<=t?e:`${e.substring(0,t)}...`,Nae=e=>{if(e.releaseNotes&&typeof e.releaseNotes!="string"){const t=e.releaseNotes,n=`https://github.com/damianvtran/local-operator-ui/releases/tag/v${e.version}`;return t.path||n}return`https://github.com/damianvtran/local-operator-ui/releases/tag/v${e.version}`},UCe=/\s+/,Tut=/[\\/]+$/,_ut=/[\\/]/,WCe=`
781
781
 
782
782
  `,Put=" — cancel with wake(",Cut=120,Eut=/(?:\u001b[\]PX^_]|[\u009d\u0090\u0098\u009e\u009f])(?:(?!\u0007|\u001b\\|\u009c)[\s\S])*(?:\u0007|\u001b\\|\u009c|$)|(?:\u001b\[|\u009b)[0-?]*[ -/]*[@-~]|(?:\u001b\[|\u009b)[0-?]*[ -/]*$|\u001b[ -/]+[0-~]|\u001b[@-Z\\-_]|\u001b$|[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g,Qut=new RegExp("\\p{Cf}","gu"),Rut=4096;function sU(e){return e==null?"":(typeof e=="string"?e:String(e)).replace(Eut,"").replace(Qut,"").split(UCe).filter(Boolean).join(" ").slice(0,Cut)}function GCe(e){if(e.conversationName)return{name:e.conversationName,quoted:!0};const t=e.cwd.replace(Tut,"");if(t){const n=t.split(_ut).pop()??"";if(n)return{name:`${n}/`,quoted:!1}}return e.sessionId?{name:e.sessionId.slice(0,8),quoted:!1}:{name:"",quoted:!1}}function VCe(e){const{name:t,quoted:n}=GCe(e);return t?n?`"${t}"`:t:e.pid?`pid ${e.pid}`:"another session"}function BCe(e){const{name:t,quoted:n}=GCe(e),r=[];return e.pid&&r.push(`pid ${e.pid}`),e.modelLabel&&r.push(e.modelLabel),t?[n?`"${t}"`:t,...r].join(" · "):r.length>0?r.join(" · "):"another session"}function Aut(e,t){return t.trim()?!0:BCe(e)!==VCe(e)}function Dut(e){for(const t of e.slice(0,Rut).split(`
@@ -1188,7 +1188,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
1188
1188
  `,before:f,encode:["$"],...u.current()})),O()}return f+=u.move(`
1189
1189
  `),c&&(f+=u.move(c+`
1190
1190
  `)),f+=u.move(d),h(),f}function r(s,a,o){let l=s.value||"",c=1;for(t||c++;new RegExp("(^|[^$])"+"\\$".repeat(c)+"([^$]|$)").test(l);)c++;const u="$".repeat(c);/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^\$|\$$/.test(l))&&(l=" "+l+" ");let d=-1;for(;++d<o.unsafe.length;){const h=o.unsafe[d];if(!h.atBreak)continue;const f=o.compilePattern(h);let O;for(;O=f.exec(l);){let g=O.index;l.codePointAt(g)===10&&l.codePointAt(g-1)===13&&g--,l=l.slice(0,g)+" "+l.slice(O.index+1)}}return u+l+u}function i(){return"$"}}const xMt={tokenize:SMt,concrete:!0,name:"mathFlow"},bge={tokenize:$Mt,partial:!0};function SMt(e,t,n){const r=this,i=r.events[r.events.length-1],s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0;let a=0;return o;function o(y){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),l(y)}function l(y){return y===36?(e.consume(y),a++,l):a<2?n(y):(e.exit("mathFlowFenceSequence"),yr(e,c,"whitespace")(y))}function c(y){return y===null||wn(y)?d(y):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(y))}function u(y){return y===null||wn(y)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),d(y)):y===36?n(y):(e.consume(y),u)}function d(y){return e.exit("mathFlowFence"),r.interrupt?t(y):e.attempt(bge,h,m)(y)}function h(y){return e.attempt({tokenize:v,partial:!0},m,f)(y)}function f(y){return(s?yr(e,O,"linePrefix",s+1):O)(y)}function O(y){return y===null?m(y):wn(y)?e.attempt(bge,h,m)(y):(e.enter("mathFlowValue"),g(y))}function g(y){return y===null||wn(y)?(e.exit("mathFlowValue"),O(y)):(e.consume(y),g)}function m(y){return e.exit("mathFlow"),t(y)}function v(y,w,k){let x=0;return yr(y,S,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function S(P){return y.enter("mathFlowFence"),y.enter("mathFlowFenceSequence"),T(P)}function T(P){return P===36?(x++,y.consume(P),T):x<a?k(P):(y.exit("mathFlowFenceSequence"),yr(y,_,"whitespace")(P))}function _(P){return P===null||wn(P)?(y.exit("mathFlowFence"),w(P)):k(P)}}}function $Mt(e,t,n){const r=this;return i;function i(a){return a===null?t(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s)}function s(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function kMt(e){let n=(e||{}).singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:TMt,previous:_Mt,name:"mathText"};function r(i,s,a){let o=0,l,c;return u;function u(g){return i.enter("mathText"),i.enter("mathTextSequence"),d(g)}function d(g){return g===36?(i.consume(g),o++,d):o<2&&!n?a(g):(i.exit("mathTextSequence"),h(g))}function h(g){return g===null?a(g):g===36?(c=i.enter("mathTextSequence"),l=0,O(g)):g===32?(i.enter("space"),i.consume(g),i.exit("space"),h):wn(g)?(i.enter("lineEnding"),i.consume(g),i.exit("lineEnding"),h):(i.enter("mathTextData"),f(g))}function f(g){return g===null||g===32||g===36||wn(g)?(i.exit("mathTextData"),h(g)):(i.consume(g),f)}function O(g){return g===36?(i.consume(g),l++,O):l===o?(i.exit("mathTextSequence"),i.exit("mathText"),s(g)):(c.type="mathTextData",f(g))}}}function TMt(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 _Mt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function PMt(e){return{flow:{36:xMt},text:{36:kMt(e)}}}const CMt={};function EMt(e){const t=this,n=e||CMt,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(PMt(n)),s.push(bMt()),a.push(wMt(n))}const QMt=e=>e.charCodeAt(e.length-1)===13?e.slice(0,-1):e,pNe=/^[ \t]*$/,RMt=/^ {0,3}(`{3,}|~{3,})/,ONe=/^ {0,3}(?:[-*+]|\d{1,9}[.)])(?:[ \t]|$)/,gNe=/^(?: {4}|\t)/,AMt=/^(?: {2,}|\t)/,DMt=()=>({source:"",cursor:0,blockStart:0,blankRunStart:-1,kind:"none",fence:null,blocks:[],revision:0}),NMt=e=>{e.source="",e.cursor=0,e.blockStart=0,e.blankRunStart=-1,e.kind="none",e.fence=null,e.blocks=[],e.revision+=1},wge=e=>gNe.test(e)?"indented-code":ONe.test(e)?"list":"other",XMt=(e,t)=>e==="list"?ONe.test(t)||AMt.test(t):e==="indented-code"?gNe.test(t):!1,IMt=(e,t)=>{let n=0;for(;n<3&&e.charCodeAt(n)===32;)n+=1;let r=0;for(;e[n+r]===t.char;)r+=1;return r<t.length?!1:pNe.test(e.slice(n+r))},FMt=(e,t)=>{(t.length<e.source.length||!t.startsWith(e.source))&&NMt(e),e.source=t;let n=e.cursor;for(;;){const r=t.indexOf(`
1191
- `,n);if(r===-1)break;const i=QMt(t.slice(n,r));if(e.fence){IMt(i,e.fence)&&(e.fence=null),n=r+1;continue}if(pNe.test(i)){e.blankRunStart<0&&(e.blankRunStart=n),n=r+1;continue}if(e.blankRunStart>=0){if(e.kind==="none"||!XMt(e.kind,i)){const s=t.slice(e.blockStart,e.blankRunStart);s.trim().length>0&&(e.blocks.push(s),e.revision+=1),e.blockStart=n,e.kind=wge(i)}e.blankRunStart=-1}else e.kind==="none"&&(e.kind=wge(i));if(e.kind!=="indented-code"){const s=RMt.exec(i);s&&(e.fence={char:s[1][0],length:s[1].length})}n=r+1}e.cursor=n},MMt=e=>{let t=e.length;for(;t>0;){const n=e.charCodeAt(t-1);if(n!==32&&n!==9&&n!==10&&n!==13)break;t-=1}return t},ar="var(--color-ink)",Qf="var(--color-ink-muted)",rh="var(--color-surface)",kO="var(--color-elevated)",Rf="var(--color-sunken)",vo="var(--color-hairline)",TO="var(--color-control)",Yy="var(--color-accent)",Q$="var(--color-accent-wash)",jMt="var(--color-on-accent)",LMt="var(--color-info)",mNe="var(--color-info-wash)",qMt="var(--color-success)",vNe="var(--color-success-wash)",zMt="var(--color-warning)",mG="var(--color-warning-wash)",UMt="var(--color-warning-border)",R7="var(--color-danger)",vG="var(--color-danger-wash)",xge=[Q$,mNe,vNe,mG,vG],_O=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),WMt=()=>{const e={primaryColor:_O("--color-accent"),secondaryColor:_O("--color-success"),tertiaryColor:_O("--color-info"),mainBkg:_O("--color-elevated"),clusterBkg:_O("--color-sunken"),clusterBorder:_O("--color-hairline"),edgeLabelBackground:_O("--color-surface"),quadrant1Fill:_O("--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:rh,primaryTextColor:ar,primaryBorderColor:TO,secondaryTextColor:ar,secondaryBorderColor:vo,tertiaryTextColor:ar,tertiaryBorderColor:vo,lineColor:Qf,arrowheadColor:Qf,textColor:ar,secondBkg:Rf,border1:TO,border2:vo,labelColor:ar,nodeBkg:kO,nodeBorder:TO,nodeTextColor:ar,defaultLinkColor:Qf,titleColor:ar,noteBkgColor:mG,noteBorderColor:UMt,noteTextColor:ar,actorBkg:kO,actorBorder:TO,actorTextColor:ar,actorLineColor:vo,signalColor:Qf,signalTextColor:ar,labelBoxBkgColor:kO,labelBoxBorderColor:vo,labelTextColor:ar,loopTextColor:ar,activationBkgColor:Q$,activationBorderColor:Yy,sequenceNumberColor:rh,sectionBkgColor:Rf,sectionBkgColor2:rh,altSectionBkgColor:Rf,excludeBkgColor:Rf,taskBkgColor:Q$,taskBorderColor:TO,taskTextColor:ar,taskTextLightColor:ar,taskTextDarkColor:ar,taskTextOutsideColor:ar,taskTextClickableColor:Yy,activeTaskBkgColor:Q$,activeTaskBorderColor:Yy,gridColor:vo,doneTaskBkgColor:Rf,doneTaskBorderColor:vo,critBkgColor:vG,critBorderColor:R7,todayLineColor:Yy,transitionColor:Qf,transitionLabelColor:ar,stateLabelColor:ar,stateBkg:kO,labelBackgroundColor:rh,compositeBackground:Rf,altBackground:Rf,compositeTitleBackground:kO,compositeBorder:vo,innerEndBackground:ar,specialStateColor:ar,classText:ar,attributeBackgroundColorOdd:rh,attributeBackgroundColorEven:Rf,rowOdd:rh,rowEven:Rf,errorBkgColor:vG,errorTextColor:R7,pieTitleTextColor:ar,pieSectionTextColor:ar,pieLegendTextColor:ar,pieStrokeColor:rh,pieOuterStrokeColor:vo,requirementBackground:kO,requirementBorderColor:TO,requirementTextColor:ar,relationColor:Qf,relationLabelBackground:rh,relationLabelColor:ar,branchLabelColor:jMt,commitLabelColor:ar,commitLabelBackground:rh,tagLabelColor:ar,tagLabelBackground:Q$,tagLabelBorder:TO,quadrant2Fill:mNe,quadrant3Fill:vNe,quadrant4Fill:mG,quadrant2TextFill:ar,quadrant3TextFill:ar,quadrant4TextFill:ar,quadrantPointFill:Yy,archEdgeColor:Qf,archEdgeArrowColor:Qf,archGroupBorderColor:vo,scaleLabelColor:ar,packet:{startByteColor:ar,endByteColor:ar,labelColor:ar,titleColor:ar,blockStrokeColor:TO,blockFillColor:kO},radar:{axisColor:Qf,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:vo,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:rh,titleColor:ar,xAxisTitleColor:ar,xAxisLabelColor:ar,xAxisTickColor:vo,xAxisLineColor:vo,yAxisTitleColor:ar,yAxisLabelColor:ar,yAxisTickColor:vo,yAxisLineColor:vo,plotColorPalette:[Yy,LMt,qMt,zMt,R7].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=kO,t[`surfacePeer${n}`]=vo;for(let n=0;n<8;n++)t[`fillType${n}`]=xge[n%xge.length];return{...t,...e}};let A7=null,Sge=null;const GMt=async e=>{A7||(A7=Le(async()=>{const{default:n}=await import("./mermaid.core--Jdw1dfM.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([0,1,2]),import.meta.url).then(({default:n})=>n));const t=await A7;return Sge!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:WMt()}),Sge=e),t},$ge=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:s,onCopy:a,children:o})=>p.jsxs("div",{className:A("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[p.jsx(rt,{content:"Zoom in",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:p.jsx(Eit,{})})}),p.jsx(rt,{content:"Zoom out",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:p.jsx(Rit,{})})}),p.jsx(rt,{content:"Drag the diagram to pan",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:p.jsx(trt,{})})}),p.jsx(rt,{content:"Reset view",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:p.jsx(OZ,{})})}),p.jsx(rt,{content:"Save as SVG",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:s,children:p.jsx(Np,{})})}),p.jsx(rt,{content:t?"Copied":"Copy mermaid text",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:a,children:p.jsx(ey,{className:A(t&&"text-success")})})}),o]}),yG=({title:e,children:t})=>p.jsxs(Ml,{variant:"danger",role:"alert",className:"my-4",children:[p.jsx(v_e,{children:e}),p.jsx(rT,{children:t})]});class VMt extends b.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||p.jsxs(yG,{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 BMt=b.memo(({chart:e,id:t})=>{const n=b.useRef(null),r=b.useRef(null),[i,s]=b.useState(null),[a,o]=b.useState(!0),[l,c]=b.useState(""),[u,d]=b.useState(!1),[h,f]=b.useState({scale:1,x:0,y:0}),[O,g]=b.useState({scale:1,x:0,y:0}),[m,v]=b.useState(!1),[y,w]=b.useState({x:0,y:0}),[k,x]=b.useState("idle"),[S,T]=b.useState("idle"),_=bn(N=>N.themeName),P=b.useCallback(async()=>{try{if(o(!0),s(null),c(""),!e||typeof e!="string"||e.trim().length===0)throw new Error("Invalid or empty chart content");const N=await GMt(_),z=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:V}=await N.render(z,e);if(!V||typeof V!="string"||V.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(V)}catch(N){console.error("Mermaid rendering error:",N);const z=N instanceof Error?N.message:"Failed to render mermaid diagram";s(z),c("")}finally{o(!1)}},[e,t,_]);b.useEffect(()=>{P().catch(N=>{console.error("Error in renderDiagram effect:",N),s("Failed to initialize diagram rendering"),o(!1)})},[P]);const E=b.useCallback(()=>{try{if(!l||!r.current)return 1;const z=r.current.getBoundingClientRect(),V=document.createElement("div");V.innerHTML=l;const ee=V.querySelector("svg");if(!ee)return 1;const oe=ee.getBoundingClientRect?.()?.width||Number.parseFloat(ee.getAttribute("width")||"0")||ee.viewBox?.baseVal?.width||800,ie=ee.getBoundingClientRect?.()?.height||Number.parseFloat(ee.getAttribute("height")||"0")||ee.viewBox?.baseVal?.height||600,he=z.width*.9/oe,te=z.height*.9/ie;return Math.min(he,te,1)}catch(N){return console.error("Error calculating fullscreen scale:",N),1}},[l]);b.useEffect(()=>{u&&l&&setTimeout(()=>{try{const N=E();g({scale:N,x:0,y:0})}catch(N){console.error("Error setting fullscreen transform:",N)}},100)},[u,l,E]);const C=b.useCallback((N=!1)=>{try{(N?g:f)(V=>({...V,scale:Math.min(V.scale*1.2,10)}))}catch(z){console.error("Error in zoom in:",z)}},[]),Q=b.useCallback((N=!1)=>{try{(N?g:f)(V=>({...V,scale:Math.max(V.scale/1.2,.1)}))}catch(z){console.error("Error in zoom out:",z)}},[]),D=b.useCallback((N=!1)=>{try{const z=N?g:f;if(N){const V=E();z({scale:V,x:0,y:0})}else z({scale:1,x:0,y:0})}catch(z){console.error("Error in reset:",z)}},[E]),F=b.useCallback(()=>{if(l)try{const N=new Blob([l],{type:"image/svg+xml"}),z=URL.createObjectURL(N),V=document.createElement("a");V.href=z,V.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(V),V.click(),document.body.removeChild(V),URL.revokeObjectURL(z)}catch(N){console.error("Failed to save SVG:",N)}},[l]),I=b.useCallback(async()=>{try{await navigator.clipboard.writeText(e),x("copied"),setTimeout(()=>x("idle"),1200)}catch(N){console.error("Failed to copy Mermaid chart text:",N)}},[e]),U=b.useCallback(async()=>{try{await navigator.clipboard.writeText(e),T("copied"),setTimeout(()=>T("idle"),1200)}catch(N){console.error("Failed to copy Mermaid chart text:",N)}},[e]),q=b.useCallback(N=>{try{v(!0),w({x:N.clientX,y:N.clientY}),N.preventDefault()}catch(z){console.error("Error in mouse down:",z)}},[]),Z=b.useCallback((N,z=!1)=>{try{if(!m)return;const V=N.clientX-y.x,ee=N.clientY-y.y;(z?g:f)(ie=>({...ie,x:ie.x+V,y:ie.y+ee})),w({x:N.clientX,y:N.clientY})}catch(V){console.error("Error in mouse move:",V)}},[m,y]),W=b.useCallback(()=>{try{v(!1)}catch(N){console.error("Error in mouse up:",N)}},[]),M=b.useCallback((N,z=!1)=>{try{N.preventDefault();const V=N.deltaY>0?.9:1.1;(z?g:f)(oe=>({...oe,scale:Math.min(Math.max(oe.scale*V,.1),5)}))}catch(V){console.error("Error in wheel:",V)}},[]),J=b.useCallback(N=>{try{d(N)}catch(z){console.error("Error toggling fullscreen:",z)}},[]);if(i)return p.jsxs(yG,{title:"Mermaid diagram error",children:[i,p.jsx("span",{className:A("mt-2 block text-ink-muted"),children:"Chart"}),p.jsx("span",{className:A("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const L=(N=!1)=>{try{const z=N?r:n,V=N?O:h;return p.jsx("div",{ref:z,className:A("mermaid flex w-full items-center justify-center",N?"h-full min-h-full":"h-auto min-h-50",m?"cursor-grabbing":"cursor-grab"),onMouseDown:q,onMouseMove:ee=>Z(ee,N),onMouseUp:W,onMouseLeave:W,onWheel:ee=>M(ee,N),children:a?p.jsx("div",{className:A("p-4 text-body-sm text-ink-muted"),children:"Loading diagram..."}):l?p.jsx("div",{className:A("flex h-full w-full items-center justify-center"),style:{transform:`translate(${V.x}px, ${V.y}px) scale(${V.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(z){return console.error("Error rendering diagram content:",z),p.jsx(yG,{title:"Rendering error",children:"Failed to render diagram content."})}};return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:A("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:[L(!1),p.jsx($ge,{className:"top-2 right-2",copied:k==="copied",onZoomIn:()=>C(!1),onZoomOut:()=>Q(!1),onReset:()=>D(!1),onSave:F,onCopy:I,children:p.jsx(rt,{content:"Fullscreen",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>J(!0),children:p.jsx(jnt,{})})})})]}),p.jsx(Nc,{open:u,onClose:()=>J(!1),title:"Mermaid diagram",maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:p.jsxs("div",{className:A("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:[L(!0),p.jsx($ge,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>C(!0),onZoomOut:()=>Q(!0),onReset:()=>D(!0),onSave:F,onCopy:U,children:p.jsx(rt,{content:"Close fullscreen",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>J(!1),children:p.jsx(Qi,{})})})})]})})]})}),YMt=b.memo(e=>p.jsx(VMt,{children:p.jsx(BMt,{...e})}));let yNe=!1,D7=null;const ZMt=()=>(D7||(D7=Le(()=>Promise.resolve({}),__vite__mapDeps([3]),import.meta.url).then(e=>(yNe=!0,e))),D7),HMt=/language-(\w+)/,KMt=/\n$/,JMt=/\$(?!\d)(.+?)\$/,e8t=/\$\$([\s\S]+?)\$\$/,t8t=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,n8t=/\\[a-zA-Z]+(\{[^}]*\})?/,bNe={a:({href:e,children:t})=>p.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}),code:({node:e,className:t,children:n,...r})=>HMt.exec(t??"")?.[1]==="mermaid"?p.jsx(YMt,{chart:String(n).replace(KMt,"")}):p.jsx("code",{className:t,...r,children:n})},r8t=[bN],i8t=[bN,EMt],s8t=[],a8t=[B6t],o8t=e=>JMt.test(e)||e8t.test(e)||t8t.test(e)?!0:n8t.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),wNe=e=>b.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),xNe=e=>{const t=b.useMemo(()=>o8t(e),[e]),[n,r]=b.useState(()=>t&&yNe);return b.useEffect(()=>{if(!t||n)return;let i=!1;return ZMt().then(()=>{i||r(!0)}),()=>{i=!0}},[t,n]),{remarkPlugins:n?i8t:r8t,rehypePlugins:n?a8t:s8t}},uy=b.memo(({content:e,styleProps:t,className:n})=>{const r=b.useMemo(()=>e.trim(),[e]),{remarkPlugins:i,rehypePlugins:s}=xNe(r),a=wNe(t);return p.jsx("div",{className:A("lo-markdown",n),style:a,children:p.jsx(AK,{remarkPlugins:i,rehypePlugins:s,components:bNe,children:r})})});uy.displayName="MarkdownRenderer";const SNe=b.memo(({source:e})=>{const{remarkPlugins:t,rehypePlugins:n}=xNe(e);return p.jsx(AK,{remarkPlugins:t,rehypePlugins:n,components:bNe,children:e})});SNe.displayName="StableBlock";const $Ne=b.memo(({text:e,animate:t})=>p.jsx("span",{className:t?"lo-stream-chunk":void 0,children:e}));$Ne.displayName="ArrivedText";const kNe=({content:e,styleProps:t,className:n})=>{const r=b.useRef(null);r.current===null&&(r.current=DMt());const i=r.current,s=b.useRef([]),a=b.useRef(0);FMt(i,e);const o=a.current;e.length>o?(o>0&&s.current.push({offset:o,animate:!0}),a.current=e.length):e.length<o&&(s.current=[],a.current=e.length);const{blockStart:l}=i,c=s.current;let u=0;for(;u<c.length&&c[u].offset<=l;)u+=1;u>0&&c.splice(0,u);const d=l+MMt(e.slice(l)),h=[{offset:l,animate:!1}];for(const O of c){if(O.offset>=d)break;h.push(O)}const f=wNe(t);return p.jsxs("div",{className:A("lo-markdown",n),style:f,children:[i.blocks.map((O,g)=>p.jsx(SNe,{source:O},g)),d>l&&p.jsx("p",{className:"lo-stream-tail",children:h.map((O,g)=>{const m=h[g+1]?.offset??d;return p.jsx($Ne,{text:e.slice(O.offset,m),animate:O.animate},O.offset)})})]})};kNe.displayName="StreamingMarkdown";const TNe=({className:e})=>p.jsx("div",{className:A("flex size-7 shrink-0 items-center justify-center rounded-full bg-sunken text-ink-muted",e),children:p.jsx(Jv,{size:16,"aria-label":"Assistant"})}),Ok="pl-10",yc=({isUser:e,children:t,isSmallView:n,showAvatar:r,className:i})=>e?p.jsx("div",{className:A("flex w-full justify-end",i),children:t}):p.jsxs("div",{className:A("relative w-full",!n&&Ok,i),children:[r&&!n&&p.jsx(TNe,{className:"absolute top-0 left-0"}),t]}),aJ=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},l8t=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 oJ=aJ(Date.now()),ZO=null;const KQ=new Set,_Ne=()=>{ZO!==null&&clearTimeout(ZO),ZO=setTimeout(()=>{ZO=null,oJ=aJ(Date.now());for(const e of KQ)e();_Ne()},l8t(Date.now())),ZO.unref?.()},c8t=e=>(KQ.add(e),oJ=aJ(Date.now()),_Ne(),()=>{KQ.delete(e),KQ.size===0&&ZO!==null&&(clearTimeout(ZO),ZO=null)}),kge=()=>oJ,u8t=()=>b.useSyncExternalStore(c8t,kge,kge),d8t=e=>new Date(e+1e3),h8t=()=>d8t(u8t()),PNe=6048e5,f8t=864e5,Tge=6e4,Crr=36e5,Err=1e3,_ge=525600,Pge=43200,Cge=1440,Ege=Symbol.for("constructDateFrom");function zp(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&Ege in e?e[Ege](t):e instanceof Date?new e.constructor(t):new Date(t)}function Xc(e,t){return zp(t||e,e)}let p8t={};function c2(){return p8t}function E_(e,t){const n=c2(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Xc(e,t?.in),s=i.getDay(),a=(s<r?7:0)+s-r;return i.setDate(i.getDate()-a),i.setHours(0,0,0,0),i}function F4(e,t){return E_(e,{...t,weekStartsOn:1})}function CNe(e,t){const n=Xc(e,t?.in),r=n.getFullYear(),i=zp(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);const s=F4(i),a=zp(n,0);a.setFullYear(r,0,4),a.setHours(0,0,0,0);const o=F4(a);return n.getTime()>=s.getTime()?r+1:n.getTime()>=o.getTime()?r:r-1}function M4(e){const t=Xc(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function ENe(e,...t){const n=zp.bind(null,t.find(r=>typeof r=="object"));return t.map(n)}function Qge(e,t){const n=Xc(e,t?.in);return n.setHours(0,0,0,0),n}function O8t(e,t,n){const[r,i]=ENe(n?.in,e,t),s=Qge(r),a=Qge(i),o=+s-M4(s),l=+a-M4(a);return Math.round((o-l)/f8t)}function g8t(e,t){const n=CNe(e,t),r=zp(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),F4(r)}function m8t(e,t){const n=+Xc(e)-+Xc(t);return n<0?-1:n>0?1:n}function v8t(e){return zp(e,Date.now())}function y8t(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function b8t(e){return!(!y8t(e)&&typeof e!="number"||isNaN(+Xc(e)))}function w8t(e){return t=>{const r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function x8t(e,t){const n=Xc(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const S8t={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},$8t=(e,t,n)=>{let r;const i=S8t[e];return typeof i=="string"?r=i:t===1?r=i.one:r=i.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function N7(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const k8t={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},T8t={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},_8t={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},P8t={date:N7({formats:k8t,defaultWidth:"full"}),time:N7({formats:T8t,defaultWidth:"full"}),dateTime:N7({formats:_8t,defaultWidth:"full"})},C8t={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},E8t=(e,t,n,r)=>C8t[e];function AS(e){return(t,n)=>{const r=n?.context?String(n.context):"standalone";let i;if(r==="formatting"&&e.formattingValues){const a=e.defaultFormattingWidth||e.defaultWidth,o=n?.width?String(n.width):a;i=e.formattingValues[o]||e.formattingValues[a]}else{const a=e.defaultWidth,o=n?.width?String(n.width):e.defaultWidth;i=e.values[o]||e.values[a]}const s=e.argumentCallback?e.argumentCallback(t):t;return i[s]}}const Q8t={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},R8t={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},A8t={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},D8t={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},N8t={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},X8t={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},I8t=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},F8t={ordinalNumber:I8t,era:AS({values:Q8t,defaultWidth:"wide"}),quarter:AS({values:R8t,defaultWidth:"wide",argumentCallback:e=>e-1}),month:AS({values:A8t,defaultWidth:"wide"}),day:AS({values:D8t,defaultWidth:"wide"}),dayPeriod:AS({values:N8t,defaultWidth:"wide",formattingValues:X8t,defaultFormattingWidth:"wide"})};function DS(e){return(t,n={})=>{const r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(i);if(!s)return null;const a=s[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?j8t(o,d=>d.test(a)):M8t(o,d=>d.test(a));let c;c=e.valueCallback?e.valueCallback(l):l,c=n.valueCallback?n.valueCallback(c):c;const u=t.slice(a.length);return{value:c,rest:u}}}function M8t(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function j8t(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function L8t(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const i=r[0],s=t.match(e.parsePattern);if(!s)return null;let a=e.valueCallback?e.valueCallback(s[0]):s[0];a=n.valueCallback?n.valueCallback(a):a;const o=t.slice(i.length);return{value:a,rest:o}}}const q8t=/^(\d+)(th|st|nd|rd)?/i,z8t=/\d+/i,U8t={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},W8t={any:[/^b/i,/^(a|c)/i]},G8t={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},V8t={any:[/1/i,/2/i,/3/i,/4/i]},B8t={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Y8t={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Z8t={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},H8t={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},K8t={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},J8t={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},e7t={ordinalNumber:L8t({matchPattern:q8t,parsePattern:z8t,valueCallback:e=>parseInt(e,10)}),era:DS({matchPatterns:U8t,defaultMatchWidth:"wide",parsePatterns:W8t,defaultParseWidth:"any"}),quarter:DS({matchPatterns:G8t,defaultMatchWidth:"wide",parsePatterns:V8t,defaultParseWidth:"any",valueCallback:e=>e+1}),month:DS({matchPatterns:B8t,defaultMatchWidth:"wide",parsePatterns:Y8t,defaultParseWidth:"any"}),day:DS({matchPatterns:Z8t,defaultMatchWidth:"wide",parsePatterns:H8t,defaultParseWidth:"any"}),dayPeriod:DS({matchPatterns:K8t,defaultMatchWidth:"any",parsePatterns:J8t,defaultParseWidth:"any"})},QNe={code:"en-US",formatDistance:$8t,formatLong:P8t,formatRelative:E8t,localize:F8t,match:e7t,options:{weekStartsOn:0,firstWeekContainsDate:1}};function t7t(e,t){const n=Xc(e,t?.in);return O8t(n,x8t(n))+1}function n7t(e,t){const n=Xc(e,t?.in),r=+F4(n)-+g8t(n);return Math.round(r/PNe)+1}function RNe(e,t){const n=Xc(e,t?.in),r=n.getFullYear(),i=c2(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,a=zp(t?.in||e,0);a.setFullYear(r+1,0,s),a.setHours(0,0,0,0);const o=E_(a,t),l=zp(t?.in||e,0);l.setFullYear(r,0,s),l.setHours(0,0,0,0);const c=E_(l,t);return+n>=+o?r+1:+n>=+c?r:r-1}function r7t(e,t){const n=c2(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=RNe(e,t),s=zp(t?.in||e,0);return s.setFullYear(i,0,r),s.setHours(0,0,0,0),E_(s,t)}function i7t(e,t){const n=Xc(e,t?.in),r=+E_(n,t)-+r7t(n,t);return Math.round(r/PNe)+1}function ci(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const PO={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return ci(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):ci(n+1,2)},d(e,t){return ci(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return ci(e.getHours()%12||12,t.length)},H(e,t){return ci(e.getHours(),t.length)},m(e,t){return ci(e.getMinutes(),t.length)},s(e,t){return ci(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return ci(i,t.length)}},Zy={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Rge={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),i=r>0?r:1-r;return n.ordinalNumber(i,{unit:"year"})}return PO.y(e,t)},Y:function(e,t,n,r){const i=RNe(e,r),s=i>0?i:1-i;if(t==="YY"){const a=s%100;return ci(a,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):ci(s,t.length)},R:function(e,t){const n=CNe(e);return ci(n,t.length)},u:function(e,t){const n=e.getFullYear();return ci(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return ci(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return ci(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return PO.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return ci(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const i=i7t(e,r);return t==="wo"?n.ordinalNumber(i,{unit:"week"}):ci(i,t.length)},I:function(e,t,n){const r=n7t(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):ci(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):PO.d(e,t)},D:function(e,t,n){const r=t7t(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):ci(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const i=e.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return ci(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});case"eeee":default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const i=e.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return ci(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});case"cccc":default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),i=r===0?7:r;switch(t){case"i":return String(i);case"ii":return ci(i,t.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const i=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let i;switch(r===12?i=Zy.noon:r===0?i=Zy.midnight:i=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let i;switch(r>=17?i=Zy.evening:r>=12?i=Zy.afternoon:r>=4?i=Zy.morning:i=Zy.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return PO.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):PO.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):ci(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):ci(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):PO.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):PO.s(e,t)},S:function(e,t){return PO.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return Dge(r);case"XXXX":case"XX":return r0(r);case"XXXXX":case"XXX":default:return r0(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return Dge(r);case"xxxx":case"xx":return r0(r);case"xxxxx":case"xxx":default:return r0(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+Age(r,":");case"OOOO":default:return"GMT"+r0(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+Age(r,":");case"zzzz":default:return"GMT"+r0(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return ci(r,t.length)},T:function(e,t,n){return ci(+e,t.length)}};function Age(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=Math.trunc(r/60),s=r%60;return s===0?n+String(i):n+String(i)+t+ci(s,2)}function Dge(e,t){return e%60===0?(e>0?"-":"+")+ci(Math.abs(e)/60,2):r0(e,t)}function r0(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=ci(Math.trunc(r/60),2),s=ci(r%60,2);return n+i+t+s}const Nge=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},ANe=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},s7t=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return Nge(e,t);let s;switch(r){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",Nge(r,t)).replace("{{time}}",ANe(i,t))},a7t={p:ANe,P:s7t},o7t=/^D+$/,l7t=/^Y+$/,c7t=["D","DD","YY","YYYY"];function u7t(e){return o7t.test(e)}function d7t(e){return l7t.test(e)}function h7t(e,t,n){const r=f7t(e,t,n);if(console.warn(r),c7t.includes(e))throw new RangeError(r)}function f7t(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const p7t=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,O7t=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,g7t=/^'([^]*?)'?$/,m7t=/''/g,v7t=/[a-zA-Z]/;function X7(e,t,n){const r=c2(),i=n?.locale??r.locale??QNe,s=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,o=Xc(e,n?.in);if(!b8t(o))throw new RangeError("Invalid time value");let l=t.match(O7t).map(u=>{const d=u[0];if(d==="p"||d==="P"){const h=a7t[d];return h(u,i.formatLong)}return u}).join("").match(p7t).map(u=>{if(u==="''")return{isToken:!1,value:"'"};const d=u[0];if(d==="'")return{isToken:!1,value:y7t(u)};if(Rge[d])return{isToken:!0,value:u};if(d.match(v7t))throw new RangeError("Format string contains an unescaped latin alphabet character `"+d+"`");return{isToken:!1,value:u}});i.localize.preprocessor&&(l=i.localize.preprocessor(o,l));const c={firstWeekContainsDate:s,weekStartsOn:a,locale:i};return l.map(u=>{if(!u.isToken)return u.value;const d=u.value;(!n?.useAdditionalWeekYearTokens&&d7t(d)||!n?.useAdditionalDayOfYearTokens&&u7t(d))&&h7t(d,t,String(e));const h=Rge[d[0]];return h(o,d,i.localize,c)}).join("")}function y7t(e){const t=e.match(g7t);return t?t[1].replace(m7t,"'"):e}function b7t(e,t,n){const r=c2(),i=n?.locale??r.locale??QNe,s=m8t(e,t);if(isNaN(s))throw new RangeError("Invalid time value");const a=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:s}),[o,l]=ENe(n?.in,...s>0?[t,e]:[e,t]),c=w8t("round"),u=l.getTime()-o.getTime(),d=u/Tge,h=M4(l)-M4(o),f=(u-h)/Tge,O=n?.unit;let g;if(d<1?g="second":d<60?g="minute":d<Cge?g="hour":f<Pge?g="day":f<_ge?g="month":g="year",g==="second"){const m=c(u/1e3);return i.formatDistance("xSeconds",m,a)}else if(g==="minute"){const m=c(d);return i.formatDistance("xMinutes",m,a)}else if(g==="hour"){const m=c(d/60);return i.formatDistance("xHours",m,a)}else if(g==="day"){const m=c(f/Cge);return i.formatDistance("xDays",m,a)}else if(g==="month"){const m=c(f/Pge);return m===12&&O!=="month"?i.formatDistance("xYears",1,a):i.formatDistance("xMonths",m,a)}else{const m=c(f/_ge);return i.formatDistance("xYears",m,a)}}function w7t(e,t){return b7t(e,v8t(e),t)}const x7t=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e),n=new Date,r=new Date(n);if(r.setDate(n.getDate()-1),t.toDateString()===n.toDateString())return X7(t,"h:mm a");if(t.toDateString()===r.toDateString())return"Yesterday";const i=new Date(n);return i.setDate(n.getDate()-7),t>i?X7(t,"EEEE"):X7(t,"yyyy-MM-dd")}catch(t){return console.error("Error formatting date:",t),""}},Qrr=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString(navigator.language,{year:"numeric",month:"long",day:"numeric"})}catch(t){return console.error("Error formatting calendar date:",t),""}},S7t=(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=n.toLocaleTimeString(navigator.language,{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 s=n.toLocaleDateString(navigator.language,{month:"short",day:"numeric"});return n.getFullYear()===t.getFullYear()?`${s}, ${r}`:`${s}, ${n.getFullYear()}, ${r}`}catch(n){return console.error("Error formatting turn timestamp:",n),""}},DNe=(e,t)=>{if(!e)return"";try{const n=e instanceof Date?e:new Date(e);return Number.isNaN(n.getTime())?"":n.toLocaleString(navigator.language,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit",...t})}catch(n){return console.error("Error formatting calendar date-time:",n),""}},lJ=({timestamp:e,scope:t,className:n})=>{const r=e instanceof Date?e:new Date(e),i=h8t();if(Number.isNaN(r.getTime()))return null;const s=DNe(r,{hour12:!0});return p.jsx(rt,{content:s,side:"bottom",delayDuration:1200,children:p.jsx("time",{dateTime:r.toISOString(),"data-stamp":t,"aria-label":`Sent ${s}`,className:A("shrink-0 cursor-help select-none whitespace-nowrap text-ink-dim text-meta",n),children:S7t(r,i)})})},Q_=({replies:e,onRemoveReply:t})=>p.jsxs("div",{className:"mb-2 flex flex-col gap-1.5 rounded-sm bg-sunken p-2",children:[p.jsxs("div",{className:"flex items-center gap-1.5 text-ink-dim",children:[p.jsx(O2e,{size:12,"aria-hidden":"true"}),p.jsx("span",{className:"text-meta",children:"Replying to"})]}),e.map(n=>p.jsxs("div",{className:"flex items-center gap-2 border-hairline border-l-2 py-0.5 pl-2",children:[p.jsx("span",{className:"flex-1 truncate text-body-sm text-ink-muted",title:n.text,children:n.text}),t&&p.jsx(we,{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:p.jsx(Qi,{"aria-hidden":"true"})})]},n.id))]}),NNe=({content:e,busy:t=!1,className:n})=>e?p.jsxs("section",{"aria-label":"Question from the agent",className:A("flex gap-3 rounded-md border border-accent bg-accent-wash px-4 py-3",n),children:[p.jsx(Unt,{className:"mt-0.5 size-4 shrink-0 text-accent","aria-hidden":!0}),p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[p.jsx("p",{className:"font-medium text-accent text-meta",children:t?"Sending your answer…":"Waiting for your answer"}),p.jsx("div",{className:"lo-on-wash text-ink",children:p.jsx(uy,{content:e})})]})]}):null,$7t=({options:e,recommended:t,busy:n=!1,onAnswer:r,requestId:i})=>{if(e.length===0)return null;const s=typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<e.length?t:null;return p.jsx("fieldset",{"aria-label":"Answer options",className:"mt-1 flex min-w-0 max-h-[380px] flex-col gap-2 overflow-y-auto border-0 px-0 py-1",children:e.map((a,o)=>p.jsxs("button",{type:"button",disabled:n,onClick:()=>r(a.label),className:A("flex w-full items-baseline gap-2 rounded-sm border px-3 py-2 text-left","transition-colors duration-fast ease-out-quart","border-control bg-surface hover:bg-elevated active:bg-sunken","disabled:border-hairline disabled:bg-sunken disabled:text-ink-disabled"),children:[o<9&&p.jsxs("span",{"aria-hidden":!0,className:A("shrink-0 font-mono text-mono-sm",n?"text-ink-disabled":"text-ink-dim"),children:[o+1,"."]}),p.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[p.jsxs("span",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[p.jsx("span",{className:A("min-w-0 text-body-sm",n?"text-ink-disabled":"text-ink"),children:a.label}),s===o&&p.jsx("span",{className:A("shrink-0 font-medium text-meta",n?"text-ink-disabled":"text-ink"),children:"Recommended"})]}),a.description&&p.jsx("span",{className:A("text-body-sm",n?"text-ink-disabled":"text-ink-muted"),children:a.description})]})]},`${i}-${String(o)}`))})},XNe=({children:e,className:t})=>p.jsx("span",{"aria-hidden":!0,className:A("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),cJ=({label:e="Reasoning",content:t})=>!bn(r=>r.showAgentReasoning)||!t?null:p.jsx(Nu,{summary:p.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[p.jsx(XNe,{}),p.jsx("span",{className:"truncate",children:p.jsx("span",{className:"text-ink-dim text-meta",children:e})})]}),children:p.jsx(uy,{content:t,className:"[--md-ink:var(--lo-ink-muted)]",styleProps:{fontSize:"var(--text-body-sm)",lineHeight:"var(--text-body-sm--line-height)"}})}),k7t={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},T7t=({line:e})=>p.jsx("span",{className:A(k7t[e.kind],"block"),children:e.text}),_7t=({diff:e,className:t})=>{const n=Odt(e);return p.jsxs("div",{className:A("max-h-[740px] overflow-y-auto overflow-x-hidden rounded-sm border border-hairline bg-sunken p-3 font-mono text-ink text-mono-sm whitespace-pre-wrap break-words",t),children:[n.lines.map((r,i)=>p.jsx(T7t,{line:r},i)),n.hidden>0&&p.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:gdt(n.hidden)})]})},P7t=({content:e,details:t,className:n})=>p.jsxs("section",{"aria-label":"Security notice",className:A("flex gap-3 border-warning border-l-2 py-0.5 pl-3",n),children:[p.jsx(T2e,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":!0}),p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[p.jsx("p",{className:"font-medium text-body-sm text-warning",children:"Blocked a risky action"}),e?p.jsx("p",{className:"text-body-sm text-ink-muted",children:e}):null,t?p.jsx(Nu,{summary:p.jsx("span",{className:"text-meta",children:"Show the reviewed code"}),children:t}):null]})]}),C7t=(e,t=72)=>{let i=e.replace(/```[\s\S]*?```/g," ").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/\s+/g," ").trim();if(i.length>t){const s=i.slice(0,t),a=s.lastIndexOf(" ");i=`${s.slice(0,a>32?a:t).trimEnd()}…`}return i.replace(/[.!?…]+$/g,"").trimEnd()},Xge=e=>e.startsWith("file://")?e.slice(7):e,E7t={READ:{verb:"Read",runningVerb:"Reading",icon:lZ},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:fZ},EDIT:{verb:"Edited",runningVerb:"Editing",icon:prt},CODE:{verb:"Ran code",runningVerb:"Running code",icon:cZ},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:zrt},DONE:{verb:"Finished",runningVerb:"Finishing",icon:IY},ASK:{verb:"Asked",runningVerb:"Asking",icon:G3},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:Qtt}},Q7t={verb:"Worked on the request",runningVerb:"Working on the request",icon:cZ},R7t=(e,t,n,r)=>{const i=e?E7t[e]:Q7t;let s;if(t)s=Xge(t);else if(n&&n.length>0){const o=n.filter(l=>!l.startsWith("data:"));o.length===1?s=Xge(o[0]):o.length>1&&(s=`${o.length} files`)}const a=!s&&r?C7t(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:s,narration:a||void 0,icon:i.icon}},Ige="min-h-5 py-0",A7t=({icon:e,verb:t,object:n,narration:r,running:i,failed:s,wrap:a})=>p.jsxs("span",{className:A("flex min-w-0 gap-2",a?"items-start":"items-center"),"aria-busy":i||void 0,children:[p.jsx(XNe,{className:A(s?"text-danger":"text-ink-dim",a&&v4e),children:e}),p.jsxs("span",{className:A(a?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[p.jsxs("span",{...U8,className:A("select-text font-mono text-mono-sm",i?"text-ink-muted":"text-ink-dim",s&&"text-danger"),children:[t,r?":":null]}),n?p.jsxs("span",{...U8,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?p.jsxs("span",{...U8,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),j4=({action:e,filePath:t,files:n,narration:r,running:i=!1,failed:s=!1,defaultOpen:a=!1,details:o,className:l,verbOverride:c,object:u,glyph:d,wrap:h,dense:f=!1})=>{const O=R7t(e,t,n,r),g=c??(i?O.runningVerb:O.verb),m=s?sv:O.icon,v=s||!c||!d?p.jsx(m,{}):d,y=p.jsx(A7t,{icon:v,verb:g,object:c?u:O.object,narration:c?r:O.narration,running:i,failed:s,wrap:h}),w=h?"firstLine":"center";return o?p.jsx(Nu,{summary:y,chevron:"leading",summaryAlign:w,defaultOpen:a,className:l,rowClassName:f?Ige:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:o}):p.jsx(Nu,{disabled:!0,summary:y,summaryAlign:w,className:l,rowClassName:f?Ige:void 0})},INe=8,D7t="… deeper values not shown",N7t="(empty)";function X7t(e){return`… ${e} more line${e===1?"":"s"}`}const Fge=.5;function I7t(e,t,n,r){if(!Number.isFinite(t)||t<=0)return 0;let i=0;for(const s of e){if(s.height<=0)continue;const a=Math.max(1,Math.round(s.height/t));for(let o=1;o<=a;o++)s.top+o*t>n+r&&i++}return i}function FNe(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function uJ(e){return typeof e=="object"&&e!==null}function MNe(e,t,n,r){if(n>INe){r.push({key:t,value:D7t,depth:n});return}if(uJ(e)){for(const[s,a]of Object.entries(e))MNe(a,t?`${t}.${s}`:s,n+1,r);return}const i=FNe(e);i!==null&&r.push({key:t,value:i,depth:n})}function jNe(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))MNe(r,n,1,t);return t}const F7t=512;function M7t(e,t){if(t)return!0;if(!e)return!1;let n=F7t;const r=(i,s)=>{if(n--<=0||s>INe)return!0;if(!uJ(i))return FNe(i)!==null;for(const a of Object.values(i))if(r(a,s+1))return!0;return!1};for(const i of Object.values(e))if(r(i,1))return!0;return!1}function j7t(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(!uJ(n))return null;const r=jNe(n);return r.length>0?r:[{key:"",value:N7t,depth:1}]}const L7t=8,Mge="max-h-[240px]",q7t=({line:e})=>p.jsxs("div",{className:A("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*L7t},children:[e.key?p.jsxs("span",{className:A("text-ink-dim"),children:[e.key,": "]}):null,p.jsx("span",{className:A("text-ink-muted"),children:e.value})]}),jge=({lines:e,label:t})=>p.jsx("div",{className:A("flex flex-col gap-1"),"data-detail-lines":t,children:e.map((n,r)=>p.jsx(q7t,{line:n},r))});function Lge(e){const[t,n]=b.useState(0),[r,i]=b.useState(!1);return b.useLayoutEffect(()=>{const s=e.current;if(!s)return;const a=s.firstElementChild,o=()=>{const c=a??s,u=Number.parseFloat(getComputedStyle(c).lineHeight);if(!Number.isFinite(u)||u<=0){n(0),i(!1);return}const d=s.getBoundingClientRect(),h=c.getBoundingClientRect();i(h.height>d.height+Fge);const f=c.children.length>0?Array.from(c.children):[c];n(I7t(f.map(O=>{const g=O.getBoundingClientRect();return{top:g.top,height:g.height}}),u,d.bottom,Fge))};o(),s.addEventListener("scroll",o,{passive:!0});const l=new ResizeObserver(o);return l.observe(a??s),()=>{s.removeEventListener("scroll",o),l.disconnect()}}),{lines:t,overflowing:r}}const qge=({lines:e,overflowing:t})=>t?p.jsx("span",{className:A("mt-1 block text-ink-dim"),children:e>0?X7t(e):" "}):null,z7t=({args:e,output:t,isError:n})=>{const r=jNe(e),i=j7t(t),s=b.useRef(null),a=b.useRef(null),o=Lge(s),l=Lge(a);return r.length===0&&!t?null:p.jsxs("div",{className:A("w-full rounded-sm border border-hairline bg-sunken p-3 font-mono text-mono-sm"),children:[r.length>0&&p.jsxs("div",{"data-detail-section":"input",children:[p.jsx("div",{ref:s,className:A(Mge,"overflow-auto"),children:p.jsx(jge,{lines:r,label:"input"})}),p.jsx(qge,{lines:o.lines,overflowing:o.overflowing})]}),t&&p.jsxs("div",{className:A(r.length>0&&"mt-3"),"data-detail-section":"output",children:[p.jsx("span",{className:A("mb-1 block text-meta",n?"text-danger":"text-ink-dim"),children:n?"Error":"Output"}),p.jsx("div",{ref:a,className:A(Mge,"overflow-auto"),children:i?p.jsx(jge,{lines:i,label:"result-json"}):p.jsx("pre",{className:A("whitespace-pre font-mono",n?"text-danger":"text-ink"),children:t})}),p.jsx(qge,{lines:l.lines,overflowing:l.overflowing})]})]})},U7t="mcp__",W7t={bash:mit,read:uv,write:sse,edit:sse,glob:hT,grep:dv,todo:Qnt,wake:V3,list_variables:o5,read_variable:o5,browser:_g,web_search:_g,web_fetch:Np,task:vp,agent:vp,send:gZ,peer:wnt};function G7t(e){const t=e.trim().toLowerCase(),n=W7t[t];return n||(t.startsWith(U7t)?pZ:QZe)}const V7t=Ul,B7t=Qi,Y7t=d2e,zge="min-h-5 py-0",Z7t={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent",plain:"text-ink-muted"},H7t=(e,t)=>e==="running"?"text-ink":e==="error"?"text-danger":e==="receipt"?"text-ink-muted":Z7t[idt(t)],K7t=({added:e,removed:t})=>e<=0&&t<=0?null:p.jsxs("span",{className:A("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&p.jsxs("span",{className:A("text-success"),children:["+",e]}),t>0&&p.jsxs("span",{className:A("text-danger"),children:["-",t]})]}),Uge={running:"",success:"succeeded",error:"failed",interrupted:"interrupted",receipt:""},J7t=1e3;function ejt(e){const[t,n]=b.useState(()=>e===null?null:Math.max(0,(Date.now()-e)/1e3));return b.useEffect(()=>{if(e===null){n(null);return}const r=()=>n(Math.max(0,(Date.now()-e)/1e3));r();const i=window.setInterval(r,J7t);return()=>window.clearInterval(i)},[e]),t}const tjt=({outcome:e,durationS:t,startedAt:n})=>{const r=e==="running",i=ejt(r?n??null:null),s=e==="success"?V7t:e==="error"?B7t:e==="interrupted"?Y7t:null,a=e==="success"?"text-success":e==="error"?"text-danger":"text-ink-dim",o=r?n==null?"":qZ(i??0):tdt(t);return p.jsxs("span",{className:A("flex shrink-0 items-center gap-1.5"),children:[p.jsxs("span",{className:A("flex size-3.5 shrink-0 [&_svg]:size-3.5",a),children:[s?p.jsx(s,{"aria-hidden":!0}):null,Uge[e]?p.jsx("span",{className:A("sr-only"),children:Uge[e]}):null]}),p.jsx("span",{className:A("w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums"),children:o})]})},L4=({toolName:e,summary:t,summaryFallback:n=null,outcome:r,durationS:i,startedAt:s=null,added:a=0,removed:o=0,nameColumn:l=ZCe,details:c,defaultOpen:u=!1,onOpenChange:d,className:h,media:f})=>{const O=b.useRef(u),g=b.useRef(d);b.useEffect(()=>{g.current=d,d?.(O.current)},[d]),b.useEffect(()=>()=>{O.current&&g.current?.(!1)},[]);const m=b.useCallback(P=>{O.current=P,g.current?.(P)},[]),v=r==="running",y=r==="error",w=G7t(e),k=AT(e),x=YCe(t,e)?n??"":t,S=p.jsxs("span",{className:A("flex min-w-0 flex-1 items-center gap-2"),children:[p.jsx("span",{"aria-hidden":!0,className:A("flex size-3.5 shrink-0 [&_svg]:size-3.5",v?"text-accent":y?"text-danger":"text-ink-dim"),children:p.jsx(w,{})}),p.jsx("span",{className:A("shrink-0 truncate font-mono text-mono-sm","pr-1",H7t(r,e)),style:{width:`calc(${l}ch + 0.25rem)`},title:k,children:k}),p.jsx("span",{className:A("min-w-0 flex-1 truncate font-mono text-mono-sm",v?"text-ink-muted":"text-ink-dim"),title:x,children:x}),p.jsx(K7t,{added:a,removed:o}),p.jsx(tjt,{outcome:r,durationS:i,startedAt:s})]}),T=v?"bg-elevated":y?"bg-danger-wash":"hover:bg-elevated",_=c?p.jsx(Nu,{summary:S,chevron:"leading",defaultOpen:u,onOpenChange:m,className:A("@container/toolrow",h),rowClassName:zge,triggerClassName:A("-mx-2 rounded-sm px-2",T),children:c}):p.jsx(Nu,{disabled:!0,summary:S,rowClassName:zge,className:A("@container/toolrow",(v||y)&&A("-mx-2 rounded-sm px-2",T),h)});return f?p.jsxs("div",{className:A("flex flex-col"),children:[_,f]}):_},dJ=e=>{const t=b.useCallback(r=>{const i=window.matchMedia(e);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[e]),n=b.useCallback(()=>window.matchMedia(e).matches,[e]);return b.useSyncExternalStore(t,n,()=>!1)},Wge=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],njt=80,rjt=1e3,ijt=({activity:e,phase:t,startedAt:n,className:r})=>{const[i,s]=b.useState(0),[a,o]=b.useState(()=>n===void 0?0:Math.floor((Date.now()-n)/1e3)),l=dJ("(prefers-reduced-motion: reduce)"),c=b.useRef(n??Date.now()),u=b.useRef(t);return u.current!==t&&(u.current=t,c.current=n??Date.now(),o(0)),b.useEffect(()=>{const d=window.setInterval(()=>o(Math.floor((Date.now()-c.current)/1e3)),rjt);if(l)return s(0),()=>window.clearInterval(d);const h=window.setInterval(()=>s(f=>(f+1)%Wge.length),njt);return()=>{window.clearInterval(h),window.clearInterval(d)}},[l]),p.jsxs("div",{className:A("flex items-center gap-2",r),"data-lo-working-line":!0,"aria-live":"polite",children:[p.jsx("span",{"aria-hidden":!0,className:A("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:Wge[i]}),p.jsx("span",{className:A("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),p.jsx("span",{"aria-hidden":!0,className:A("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:qZ(a)})]})},sjt=/^\s*<reply-to>([\s\S]*?)<\/reply-to>/,hJ=e=>{const t=[];let n=e;for(;;){const r=sjt.exec(n);if(r===null)break;t.push({id:za(),text:r[1]}),n=n.slice(r[0].length)}return{replies:t,remainingContent:n.trim()}},LNe=({children:e,className:t})=>p.jsx("div",{className:A("flex max-w-full items-center justify-center overflow-hidden","min-h-16 min-w-16 rounded-sm border border-hairline bg-sunken",t),children:e}),ajt="could not be displayed. It may have been moved, renamed, or deleted.",fJ="could not be displayed. Its stored copy is not available to this reader.",R_=({name:e,detail:t=ajt,className:n})=>p.jsxs("div",{className:A("flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2",n),children:[p.jsx(vnt,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),p.jsxs("span",{className:"min-w-0 text-body-sm text-ink-muted",children:[p.jsx("span",{className:"truncate font-mono text-ink text-mono-sm",children:e}),` ${t}`]})]}),wN=({filePath:e,tooltip:t="File actions",icon:n,"aria-label":r="File actions",onShowInCanvas:i})=>{const s=async()=>{if(e)try{await navigator.clipboard.writeText(e),ms("File path copied to clipboard")}catch(o){console.error("Failed to copy file path: ",o),Rr("Failed to copy file path")}},a=()=>{e&&window.api.openFile(e)};return p.jsxs(px,{children:[p.jsx(rt,{content:t,children:p.jsx(iv,{asChild:!0,children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":r,onClick:o=>o.stopPropagation(),children:n??p.jsx(B3,{"aria-hidden":"true"})})})}),p.jsxs(Ox,{align:"end",className:"min-w-45",onClick:o=>o.stopPropagation(),children:[i&&p.jsxs($s,{onSelect:i,children:[p.jsx(_nt,{"aria-hidden":"true"}),p.jsx("span",{children:"Show in canvas"})]}),p.jsxs($s,{onSelect:a,children:[p.jsx(vx,{"aria-hidden":"true"}),p.jsx("span",{children:"Open file"})]}),p.jsxs($s,{onSelect:()=>window.api.showItemInFolder(e),children:[p.jsx(hT,{"aria-hidden":"true"}),p.jsx("span",{children:"Open folder"})]}),p.jsxs($s,{onSelect:s,children:[p.jsx(h2e,{"aria-hidden":"true"}),p.jsx("span",{children:"Copy file path"})]})]})]})},I7="max-h-[min(90vh,calc(100vh-104px))] max-w-[min(90vw,calc(100vw-104px))]",pJ=({src:e,label:t,open:n,onOpenChange:r,restoreFocusTo:i,fallback:s})=>{const[a,o]=b.useState(!1);return up(n,"image-lightbox"),p.jsx(jP,{open:n,onOpenChange:r,children:p.jsxs(LP,{showClose:!1,"aria-describedby":void 0,onCloseAutoFocus:l=>{const c=i?.current;c&&(l.preventDefault(),c.focus())},className:A("inset-0 top-0 left-0 m-auto h-fit w-fit translate-none",I7,"gap-0 rounded-none border-0 border-transparent bg-transparent p-0 shadow-none"),children:[p.jsx(I1,{className:"sr-only",children:t}),a?p.jsx("div",{className:A(I7,"flex min-h-16 min-w-64 items-center justify-center p-6"),children:s}):p.jsx("img",{src:e,alt:t,className:A(I7,"object-contain"),onError:()=>o(!0)}),p.jsx(RZe,{asChild:!0,children:p.jsx(we,{variant:"ghost",size:"icon-sm",className:A("fixed top-4 right-4"),"aria-label":"Close image",children:p.jsx(Qi,{"aria-hidden":"true"})})})]})})};pJ.displayName="ImageLightbox";const qNe=1024;let ojt=0,yu=class{constructor(t,n){this.from=t,this.to=n}};class Wn{constructor(t={}){this.id=ojt++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=ha.match(t)),n=>{let r=t(n);return r===void 0?null:[this,r]}}}Wn.closedBy=new Wn({deserialize:e=>e.split(" ")});Wn.openedBy=new Wn({deserialize:e=>e.split(" ")});Wn.group=new Wn({deserialize:e=>e.split(" ")});Wn.isolate=new Wn({deserialize:e=>{if(e&&e!="rtl"&&e!="ltr"&&e!="auto")throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}});Wn.contextHash=new Wn({perNode:!0});Wn.lookAhead=new Wn({perNode:!0});Wn.mounted=new Wn({perNode:!0});class A_{constructor(t,n,r){this.tree=t,this.overlay=n,this.parser=r}static get(t){return t&&t.props&&t.props[Wn.mounted.id]}}const ljt=Object.create(null);class ha{constructor(t,n,r,i=0){this.name=t,this.props=n,this.id=r,this.flags=i}static define(t){let n=t.props&&t.props.length?Object.create(null):ljt,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new ha(t.name||"",n,t.id,r);if(t.props){for(let s of t.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return i}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let n=this.prop(Wn.group);return n?n.indexOf(t)>-1:!1}return this.id==t}static match(t){let n=Object.create(null);for(let r in t)for(let i of r.split(" "))n[i]=t[r];return r=>{for(let i=r.prop(Wn.group),s=-1;s<(i?i.length:0);s++){let a=n[s<0?r.name:i[s]];if(a)return a}}}}ha.none=new ha("",Object.create(null),0,8);class Fx{constructor(t){this.types=t;for(let n=0;n<t.length;n++)if(t[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let n=[];for(let r of this.types){let i=null;for(let s of t){let a=s(r);a&&(i||(i=Object.assign({},r.props)),i[a[0].id]=a[1])}n.push(i?new ha(r.name,i,r.id,r.flags):r)}return new Fx(n)}}const WC=new WeakMap,Gge=new WeakMap;var Pi;(function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"})(Pi||(Pi={}));class $r{constructor(t,n,r,i,s){if(this.type=t,this.children=n,this.positions=r,this.length=i,this.props=null,s&&s.length){this.props=Object.create(null);for(let[a,o]of s)this.props[typeof a=="number"?a:a.id]=o}}toString(){let t=A_.get(this);if(t&&!t.overlay)return t.tree.toString();let n="";for(let r of this.children){let i=r.toString();i&&(n&&(n+=","),n+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(t=0){return new q4(this.topNode,t)}cursorAt(t,n=0,r=0){let i=WC.get(this)||this.topNode,s=new q4(i);return s.moveTo(t,n),WC.set(this,s._tree),s}get topNode(){return new Fo(this,0,0,null)}resolve(t,n=0){let r=D_(WC.get(this)||this.topNode,t,n,!1);return WC.set(this,r),r}resolveInner(t,n=0){let r=D_(Gge.get(this)||this.topNode,t,n,!0);return Gge.set(this,r),r}resolveStack(t,n=0){return djt(this,t,n)}iterate(t){let{enter:n,leave:r,from:i=0,to:s=this.length}=t,a=t.mode||0,o=(a&Pi.IncludeAnonymous)>0;for(let l=this.cursor(a|Pi.IncludeAnonymous);;){let c=!1;if(l.from<=s&&l.to>=i&&(!o&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&r&&(o||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let n in this.props)t.push([+n,this.props[n]]);return t}balance(t={}){return this.children.length<=8?this:mJ(ha.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new $r(this.type,n,r,i,this.propValues),t.makeTree||((n,r,i)=>new $r(ha.none,n,r,i)))}static build(t){return hjt(t)}}$r.empty=new $r(ha.none,[],[],0);class OJ{constructor(t,n){this.buffer=t,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new OJ(this.buffer,this.index)}}class qg{constructor(t,n,r){this.buffer=t,this.length=n,this.set=r}get type(){return ha.none}toString(){let t=[];for(let n=0;n<this.buffer.length;)t.push(this.childString(n)),n=this.buffer[n+3];return t.join(",")}childString(t){let n=this.buffer[t],r=this.buffer[t+3],i=this.set.types[n],s=i.name;if(/\W/.test(s)&&!i.isError&&(s=JSON.stringify(s)),t+=4,r==t)return s;let a=[];for(;t<r;)a.push(this.childString(t)),t=this.buffer[t+3];return s+"("+a.join(",")+")"}findChild(t,n,r,i,s){let{buffer:a}=this,o=-1;for(let l=t;l!=n&&!(zNe(s,i,a[l+1],a[l+2])&&(o=l,r>0));l=a[l+3]);return o}slice(t,n,r){let i=this.buffer,s=new Uint16Array(n-t),a=0;for(let o=t,l=0;o<n;){s[l++]=i[o++],s[l++]=i[o++]-r;let c=s[l++]=i[o++]-r;s[l++]=i[o++]-t,a=Math.max(a,c)}return new qg(s,a,this.set)}}function zNe(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function D_(e,t,n,r){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let a=!r&&e instanceof Fo&&e.index<0?null:e.parent;if(!a)return e;e=a}let s=r?0:Pi.IgnoreOverlays;if(r)for(let a=e,o=a.parent;o;a=o,o=a.parent)a instanceof Fo&&a.index<0&&((i=o.enter(t,n,s))===null||i===void 0?void 0:i.from)!=a.from&&(e=o);for(;;){let a=e.enter(t,n,s);if(!a)return e;e=a}}class UNe{cursor(t=0){return new q4(this,t)}getChild(t,n=null,r=null){let i=Vge(this,t,n,r);return i.length?i[0]:null}getChildren(t,n=null,r=null){return Vge(this,t,n,r)}resolve(t,n=0){return D_(this,t,n,!1)}resolveInner(t,n=0){return D_(this,t,n,!0)}matchContext(t){return bG(this.parent,t)}enterUnfinishedNodesBefore(t){let n=this.childBefore(t),r=this;for(;n;){let i=n.lastChild;if(!i||i.to!=n.to)break;i.type.isError&&i.from==i.to?(r=n,n=i.prevSibling):n=i}return r}get node(){return this}get next(){return this.parent}}class Fo extends UNe{constructor(t,n,r,i){super(),this._tree=t,this.from=n,this.index=r,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,s=0){for(let a=this;;){for(let{children:o,positions:l}=a._tree,c=n>0?o.length:-1;t!=c;t+=n){let u=o[t],d=l[t]+a.from;if(zNe(i,r,d,d+u.length)){if(u instanceof qg){if(s&Pi.ExcludeBuffers)continue;let h=u.findChild(0,u.buffer.length,n,r-d,i);if(h>-1)return new Xh(new cjt(a,u,t,d),null,h)}else if(s&Pi.IncludeAnonymous||!u.type.isAnonymous||gJ(u)){let h;if(!(s&Pi.IgnoreMounts)&&(h=A_.get(u))&&!h.overlay)return new Fo(h.tree,d,t,a);let f=new Fo(u,d,t,a);return s&Pi.IncludeAnonymous||!f.type.isAnonymous?f:f.nextChild(n<0?u.children.length-1:0,n,r,i)}}}if(s&Pi.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?t=a.index+n:t=n<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,n,r=0){let i;if(!(r&Pi.IgnoreOverlays)&&(i=A_.get(this._tree))&&i.overlay){let s=t-this.from;for(let{from:a,to:o}of i.overlay)if((n>0?a<=s:a<s)&&(n<0?o>=s:o>s))return new Fo(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Vge(e,t,n,r){let i=e.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let a=!1;!a;)if(a=i.type.is(n),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(t)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function bG(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}class cjt{constructor(t,n,r,i){this.parent=t,this.buffer=n,this.index=r,this.start=i}}class Xh extends UNe{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,n,r){super(),this.context=t,this._parent=n,this.index=r,this.type=t.buffer.set.types[t.buffer.buffer[r]]}child(t,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return s<0?null:new Xh(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,n,r=0){if(r&Pi.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return s<0?null:new Xh(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new Xh(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Xh(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],n=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let a=r.buffer[this.index+1];t.push(r.slice(i,s,a)),n.push(0)}return new $r(this.type,t,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function WNe(e){if(!e.length)return null;let t=0,n=e[0];for(let s=1;s<e.length;s++){let a=e[s];(a.from>n.from||a.to<n.to)&&(n=a,t=s)}let r=n instanceof Fo&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new ujt(i,n)}class ujt{constructor(t,n){this.heads=t,this.node=n}get next(){return WNe(this.heads)}}function djt(e,t,n){let r=e.resolveInner(t,n),i=null;for(let s=r instanceof Fo?r:r.context.parent;s;s=s.parent)if(s.index<0){let a=s.parent;(i||(i=[r])).push(a.resolve(t,n)),s=a}else{let a=A_.get(s.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new Fo(a.tree,a.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(D_(o,t,n,!1))}}return i?WNe(i):r}class q4{get name(){return this.type.name}constructor(t,n=0){if(this.mode=n,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof Fo)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let r=t._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,n){this.index=t;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[t]],this.from=r+i.buffer[t+1],this.to=r+i.buffer[t+2],!0}yield(t){return t?t instanceof Fo?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.buffer.start,r);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,n,r=this.mode){return this.buffer?r&Pi.ExcludeBuffers?!1:this.enterChild(1,t,n):this.yield(this._tree.enter(t,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pi.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&Pi.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(t<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let n,r,{buffer:i}=this;if(i){if(t>0){if(this.index<i.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(i.buffer.buffer[s+3]<this.index)return!1;({index:n,parent:r}=i)}else({index:n,_parent:r}=this._tree);for(;r;{index:n,_parent:r}=r)if(n>-1)for(let s=n+t,a=t<0?-1:r._tree.children.length;s!=a;s+=t){let o=r._tree.children[s];if(this.mode&Pi.IncludeAnonymous||o instanceof qg||!o.type.isAnonymous||gJ(o))return!1}return!0}move(t,n){if(n&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,n=0){for(;(this.from==this.to||(n<1?this.from>=t:this.from>t)||(n>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,n););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,n=null,r=0;if(t&&t.context==this.buffer)e:for(let i=this.index,s=this.stack.length;s>=0;){for(let a=t;a;a=a._parent)if(a.index==i){if(i==this.index)return a;n=a,r=s+1;break e}i=this.stack[--s]}for(let i=r;i<this.stack.length;i++)n=new Xh(this.buffer,n,this.stack[i]);return this.bufferNode=new Xh(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,n){for(let r=0;;){let i=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&n&&n(this),i=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,i=!0}}}matchContext(t){if(!this.buffer)return bG(this.node.parent,t);let{buffer:n}=this.buffer,{types:r}=n.set;for(let i=t.length-1,s=this.stack.length-1;i>=0;s--){if(s<0)return bG(this._tree,t,i);let a=r[n.buffer[this.stack[s]]];if(!a.isAnonymous){if(t[i]&&t[i]!=a.name)return!1;i--}}return!0}}function gJ(e){return e.children.some(t=>t instanceof qg||!t.type.isAnonymous||gJ(t))}function hjt(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=qNe,reused:s=[],minRepeatType:a=r.types.length}=e,o=Array.isArray(n)?new OJ(n,n.length):n,l=r.types,c=0,u=0;function d(x,S,T,_,P,E){let{id:C,start:Q,end:D,size:F}=o,I=u,U=c;for(;F<0;)if(o.next(),F==-1){let J=s[C];T.push(J),_.push(Q-x);return}else if(F==-3){c=C;return}else if(F==-4){u=C;return}else throw new RangeError(`Unrecognized record size: ${F}`);let q=l[C],Z,W,M=Q-x;if(D-Q<=i&&(W=m(o.pos-S,P))){let J=new Uint16Array(W.size-W.skip),L=o.pos-W.size,N=J.length;for(;o.pos>L;)N=v(W.start,J,N);Z=new qg(J,D-W.start,r),M=W.start-x}else{let J=o.pos-F;o.next();let L=[],N=[],z=C>=a?C:-1,V=0,ee=D;for(;o.pos>J;)z>=0&&o.id==z&&o.size>=0?(o.end<=ee-i&&(O(L,N,Q,V,o.end,ee,z,I,U),V=L.length,ee=o.end),o.next()):E>2500?h(Q,J,L,N):d(Q,J,L,N,z,E+1);if(z>=0&&V>0&&V<L.length&&O(L,N,Q,V,Q,ee,z,I,U),L.reverse(),N.reverse(),z>-1&&V>0){let oe=f(q,U);Z=mJ(q,L,N,0,L.length,0,D-Q,oe,oe)}else Z=g(q,L,N,D-Q,I-D,U)}T.push(Z),_.push(M)}function h(x,S,T,_){let P=[],E=0,C=-1;for(;o.pos>S;){let{id:Q,start:D,end:F,size:I}=o;if(I>4)o.next();else{if(C>-1&&D<C)break;C<0&&(C=F-i),P.push(Q,D,F),E++,o.next()}}if(E){let Q=new Uint16Array(E*4),D=P[P.length-2];for(let F=P.length-3,I=0;F>=0;F-=3)Q[I++]=P[F],Q[I++]=P[F+1]-D,Q[I++]=P[F+2]-D,Q[I++]=I;T.push(new qg(Q,P[2]-D,r)),_.push(D-x)}}function f(x,S){return(T,_,P)=>{let E=0,C=T.length-1,Q,D;if(C>=0&&(Q=T[C])instanceof $r){if(!C&&Q.type==x&&Q.length==P)return Q;(D=Q.prop(Wn.lookAhead))&&(E=_[C]+Q.length+D)}return g(x,T,_,P,E,S)}}function O(x,S,T,_,P,E,C,Q,D){let F=[],I=[];for(;x.length>_;)F.push(x.pop()),I.push(S.pop()+T-P);x.push(g(r.types[C],F,I,E-P,Q-E,D)),S.push(P-T)}function g(x,S,T,_,P,E,C){if(E){let Q=[Wn.contextHash,E];C=C?[Q].concat(C):[Q]}if(P>25){let Q=[Wn.lookAhead,P];C=C?[Q].concat(C):[Q]}return new $r(x,S,T,_,C)}function m(x,S){let T=o.fork(),_=0,P=0,E=0,C=T.end-i,Q={size:0,start:0,skip:0};e:for(let D=T.pos-x;T.pos>D;){let F=T.size;if(T.id==S&&F>=0){Q.size=_,Q.start=P,Q.skip=E,E+=4,_+=4,T.next();continue}let I=T.pos-F;if(F<0||I<D||T.start<C)break;let U=T.id>=a?4:0,q=T.start;for(T.next();T.pos>I;){if(T.size<0)if(T.size==-3)U+=4;else break e;else T.id>=a&&(U+=4);T.next()}P=q,_+=F,E+=U}return(S<0||_==x)&&(Q.size=_,Q.start=P,Q.skip=E),Q.size>4?Q:void 0}function v(x,S,T){let{id:_,start:P,end:E,size:C}=o;if(o.next(),C>=0&&_<a){let Q=T;if(C>4){let D=o.pos-(C-4);for(;o.pos>D;)T=v(x,S,T)}S[--T]=Q,S[--T]=E-x,S[--T]=P-x,S[--T]=_}else C==-3?c=_:C==-4&&(u=_);return T}let y=[],w=[];for(;o.pos>0;)d(e.start||0,e.bufferStart||0,y,w,-1,0);let k=(t=e.length)!==null&&t!==void 0?t:y.length?w[0]+y[0].length:0;return new $r(l[e.topID],y.reverse(),w.reverse(),k)}const Bge=new WeakMap;function JQ(e,t){if(!e.isAnonymous||t instanceof qg||t.type!=e)return 1;let n=Bge.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof $r)){n=1;break}n+=JQ(e,r)}Bge.set(t,n)}return n}function mJ(e,t,n,r,i,s,a,o,l){let c=0;for(let O=r;O<i;O++)c+=JQ(e,t[O]);let u=Math.ceil(c*1.5/8),d=[],h=[];function f(O,g,m,v,y){for(let w=m;w<v;){let k=w,x=g[w],S=JQ(e,O[w]);for(w++;w<v;w++){let T=JQ(e,O[w]);if(S+T>=u)break;S+=T}if(w==k+1){if(S>u){let T=O[k];f(T.children,T.positions,0,T.children.length,g[k]+y);continue}d.push(O[k])}else{let T=g[w-1]+O[w-1].length-x;d.push(mJ(e,O,g,k,w,x,T,null,l))}h.push(x+y-s)}}return f(t,n,r,i,0),(o||l)(d,h,a)}class vJ{constructor(){this.map=new WeakMap}setBuffer(t,n,r){let i=this.map.get(t);i||this.map.set(t,i=new Map),i.set(n,r)}getBuffer(t,n){let r=this.map.get(t);return r&&r.get(n)}set(t,n){t instanceof Xh?this.setBuffer(t.context.buffer,t.index,n):t instanceof Fo&&this.map.set(t.tree,n)}get(t){return t instanceof Xh?this.getBuffer(t.context.buffer,t.index):t instanceof Fo?this.map.get(t.tree):void 0}cursorSet(t,n){t.buffer?this.setBuffer(t.buffer.buffer,t.index,n):this.map.set(t.tree,n)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class kp{constructor(t,n,r,i,s=!1,a=!1){this.from=t,this.to=n,this.tree=r,this.offset=i,this.open=(s?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new kp(0,t.length,t,0,!1,r)];for(let s of n)s.to>t.length&&i.push(s);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],s=1,a=t.length?t[0]:null;for(let o=0,l=0,c=0;;o++){let u=o<n.length?n[o]:null,d=u?u.fromA:1e9;if(d-l>=r)for(;a&&a.from<d;){let h=a;if(l>=h.from||d<=h.to||c){let f=Math.max(h.from,l)-c,O=Math.min(h.to,d)-c;h=f>=O?null:new kp(f,O,h.tree,h.offset+c,o>0,!!u)}if(h&&i.push(h),a.to>d)break;a=s<t.length?t[s++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return i}}let xN=class{startParse(t,n,r){return typeof t=="string"&&(t=new fjt(t)),r=r?r.length?r.map(i=>new yu(i.from,i.to)):[new yu(0,0)]:[new yu(0,t.length)],this.createParse(t,n||[],r)}parse(t,n,r){let i=this.startParse(t,n,r);for(;;){let s=i.advance();if(s)return s}}};class fjt{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,n){return this.string.slice(t,n)}}function zu(e){return(t,n,r,i)=>new Ojt(t,e,n,r,i)}class Yge{constructor(t,n,r,i,s){this.parser=t,this.parse=n,this.overlay=r,this.target=i,this.from=s}}function Zge(e){if(!e.length||e.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(e))}class pjt{constructor(t,n,r,i,s,a,o){this.parser=t,this.predicate=n,this.mounts=r,this.index=i,this.start=s,this.target=a,this.prev=o,this.depth=0,this.ranges=[]}}const wG=new Wn({perNode:!0});class Ojt{constructor(t,n,r,i,s){this.nest=n,this.input=r,this.fragments=i,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let r=this.baseParse.advance();if(!r)return null;if(this.baseParse=null,this.baseTree=r,this.startInner(),this.stoppedAt!=null)for(let i of this.inner)i.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let r=this.baseTree;return this.stoppedAt!=null&&(r=new $r(r.type,r.children,r.positions,r.length,r.propValues.concat([[wG,this.stoppedAt]]))),r}let t=this.inner[this.innerDone],n=t.parse.advance();if(n){this.innerDone++;let r=Object.assign(Object.create(null),t.target.props);r[Wn.mounted.id]=new A_(n,t.overlay,t.parser),t.target.props=r}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let n=this.innerDone;n<this.inner.length;n++)this.inner[n].from<t&&(t=Math.min(t,this.inner[n].parse.parsedPos));return t}stopAt(t){if(this.stoppedAt=t,this.baseParse)this.baseParse.stopAt(t);else for(let n=this.innerDone;n<this.inner.length;n++)this.inner[n].parse.stopAt(t)}startInner(){let t=new vjt(this.fragments),n=null,r=null,i=new q4(new Fo(this.baseTree,this.ranges[0].from,0,null),Pi.IncludeAnonymous|Pi.IgnoreMounts);e:for(let s,a;;){let o=!0,l;if(this.stoppedAt!=null&&i.from>=this.stoppedAt)o=!1;else if(t.hasNode(i)){if(n){let c=n.mounts.find(u=>u.frag.from<=i.from&&u.frag.to>=i.to&&u.mount.overlay);if(c)for(let u of c.mount.overlay){let d=u.from+c.pos,h=u.to+c.pos;d>=i.from&&h<=i.to&&!n.ranges.some(f=>f.from<h&&f.to>d)&&n.ranges.push({from:d,to:h})}}o=!1}else if(r&&(a=gjt(r.ranges,i.from,i.to)))o=a!=2;else if(!i.type.isAnonymous&&(s=this.nest(i,this.input))&&(i.from<i.to||!s.overlay)){i.tree||mjt(i);let c=t.findMounts(i.from,s.parser);if(typeof s.overlay=="function")n=new pjt(s.parser,s.overlay,c,this.inner.length,i.from,i.tree,n);else{let u=Jge(this.ranges,s.overlay||(i.from<i.to?[new yu(i.from,i.to)]:[]));u.length&&Zge(u),(u.length||!s.overlay)&&this.inner.push(new Yge(s.parser,u.length?s.parser.startParse(this.input,eme(c,u),u):s.parser.startParse(""),s.overlay?s.overlay.map(d=>new yu(d.from-i.from,d.to-i.from)):null,i.tree,u.length?u[0].from:i.from)),s.overlay?u.length&&(r={ranges:u,depth:0,prev:r}):o=!1}}else if(n&&(l=n.predicate(i))&&(l===!0&&(l=new yu(i.from,i.to)),l.from<l.to)){let c=n.ranges.length-1;c>=0&&n.ranges[c].to==l.from?n.ranges[c]={from:n.ranges[c].from,to:l.to}:n.ranges.push(l)}if(o&&i.firstChild())n&&n.depth++,r&&r.depth++;else for(;!i.nextSibling();){if(!i.parent())break e;if(n&&!--n.depth){let c=Jge(this.ranges,n.ranges);c.length&&(Zge(c),this.inner.splice(n.index,0,new Yge(n.parser,n.parser.startParse(this.input,eme(n.mounts,c),c),n.ranges.map(u=>new yu(u.from-n.start,u.to-n.start)),n.target,c[0].from))),n=n.prev}r&&!--r.depth&&(r=r.prev)}}}}function gjt(e,t,n){for(let r of e){if(r.from>=n)break;if(r.to>t)return r.from<=t&&r.to>=n?2:1}return 0}function Hge(e,t,n,r,i,s){if(t<n){let a=e.buffer[t+1];r.push(e.slice(t,n,a)),i.push(a-s)}}function mjt(e){let{node:t}=e,n=[],r=t.context.buffer;do n.push(e.index),e.parent();while(!e.tree);let i=e.tree,s=i.children.indexOf(r),a=i.children[s],o=a.buffer,l=[s];function c(u,d,h,f,O,g){let m=n[g],v=[],y=[];Hge(a,u,m,v,y,f);let w=o[m+1],k=o[m+2];l.push(v.length);let x=g?c(m+4,o[m+3],a.set.types[o[m]],w,k-w,g-1):t.toTree();return v.push(x),y.push(w-f),Hge(a,o[m+3],d,v,y,f),new $r(h,v,y,O)}i.children[s]=c(0,o.length,ha.none,0,a.length,n.length-1);for(let u of l){let d=e.tree.children[u],h=e.tree.positions[u];e.yield(new Fo(d,h+e.from,u,e._tree))}}class Kge{constructor(t,n){this.offset=n,this.done=!1,this.cursor=t.cursor(Pi.IncludeAnonymous|Pi.IgnoreMounts)}moveTo(t){let{cursor:n}=this,r=t-this.offset;for(;!this.done&&n.from<r;)n.to>=t&&n.enter(r,1,Pi.IgnoreOverlays|Pi.ExcludeBuffers)||n.next(!1)||(this.done=!0)}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let n=this.cursor.tree;;){if(n==t.tree)return!0;if(n.children.length&&n.positions[0]==0&&n.children[0]instanceof $r)n=n.children[0];else break}return!1}}let vjt=class{constructor(t){var n;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let r=this.curFrag=t[0];this.curTo=(n=r.tree.prop(wG))!==null&&n!==void 0?n:r.to,this.inner=new Kge(r.tree,-r.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let n=this.curFrag=this.fragments[this.fragI];this.curTo=(t=n.tree.prop(wG))!==null&&t!==void 0?t:n.to,this.inner=new Kge(n.tree,-n.offset)}}findMounts(t,n){var r;let i=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let s=this.inner.cursor.node;s;s=s.parent){let a=(r=s.tree)===null||r===void 0?void 0:r.prop(Wn.mounted);if(a&&a.parser==n)for(let o=this.fragI;o<this.fragments.length;o++){let l=this.fragments[o];if(l.from>=s.to)break;l.tree==this.curFrag.tree&&i.push({frag:l,pos:s.from-l.offset,mount:a})}}}return i}};function Jge(e,t){let n=null,r=t;for(let i=1,s=0;i<e.length;i++){let a=e[i-1].to,o=e[i].from;for(;s<r.length;s++){let l=r[s];if(l.from>=o)break;l.to<=a||(n||(r=n=t.slice()),l.from<a?(n[s]=new yu(l.from,a),l.to>o&&n.splice(s+1,0,new yu(o,l.to))):l.to>o?n[s--]=new yu(o,l.to):n.splice(s--,1))}}return r}function yjt(e,t,n,r){let i=0,s=0,a=!1,o=!1,l=-1e9,c=[];for(;;){let u=i==e.length?1e9:a?e[i].to:e[i].from,d=s==t.length?1e9:o?t[s].to:t[s].from;if(a!=o){let h=Math.max(l,n),f=Math.min(u,d,r);h<f&&c.push(new yu(h,f))}if(l=Math.min(u,d),l==1e9)break;u==l&&(a?(a=!1,i++):a=!0),d==l&&(o?(o=!1,s++):o=!0)}return c}function eme(e,t){let n=[];for(let{pos:r,mount:i,frag:s}of e){let a=r+(i.overlay?i.overlay[0].from:0),o=a+i.tree.length,l=Math.max(s.from,a),c=Math.min(s.to,o);if(i.overlay){let u=i.overlay.map(h=>new yu(h.from+r,h.to+r)),d=yjt(t,u,l,c);for(let h=0,f=l;;h++){let O=h==d.length,g=O?c:d[h].from;if(g>f&&n.push(new kp(f,g,i.tree,-a,s.from>=f||s.openStart,s.to<=g||s.openEnd)),O)break;f=d[h].to}}else n.push(new kp(l,c,i.tree,-a,s.from>=a||s.openStart,s.to<=o||s.openEnd))}return n}let xG=[],GNe=[];(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?GNe:xG).push(n=n+e[t])})();function bjt(e){if(e<768)return!1;for(let t=0,n=xG.length;;){let r=t+n>>1;if(e<xG[r])n=r;else if(e>=GNe[r])t=r+1;else return!0;if(t==n)return!1}}function tme(e){return e>=127462&&e<=127487}const nme=8205;function wjt(e,t,n=!0,r=!0){return(n?VNe:xjt)(e,t,r)}function VNe(e,t,n){if(t==e.length)return t;t&&BNe(e.charCodeAt(t))&&YNe(e.charCodeAt(t-1))&&t--;let r=F7(e,t);for(t+=rme(r);t<e.length;){let i=F7(e,t);if(r==nme||i==nme||n&&bjt(i))t+=rme(i),r=i;else if(tme(i)){let s=0,a=t-2;for(;a>=0&&tme(F7(e,a));)s++,a-=2;if(s%2==0)break;t+=2}else break}return t}function xjt(e,t,n){for(;t>0;){let r=VNe(e,t-2,n);if(r<t)return r;t--}return 0}function F7(e,t){let n=e.charCodeAt(t);if(!YNe(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return BNe(r)?(n-55296<<10)+(r-56320)+65536:n}function BNe(e){return e>=56320&&e<57344}function YNe(e){return e>=55296&&e<56320}function rme(e){return e<65536?1:2}let Vr=class ZNe{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,n,r){[t,n]=Nw(this,t,n);let i=[];return this.decompose(0,t,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),Th.from(i,this.length-(n-t)+r.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,n=this.length){[t,n]=Nw(this,t,n);let r=[];return this.decompose(t,n,r,0),Th.from(r,n-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let n=this.scanIdentical(t,1),r=this.length-this.scanIdentical(t,-1),i=new gk(this),s=new gk(t);for(let a=n,o=n;;){if(i.next(a),s.next(a),a=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(o+=i.value.length,i.done||o>=r)return!0}}iter(t=1){return new gk(this,t)}iterRange(t,n=this.length){return new HNe(this,t,n)}iterLines(t,n){let r;if(t==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(t).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new KNe(r)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?ZNe.empty:t.length<=32?new Xs(t):Th.from(Xs.split(t,[]))}};class Xs extends Vr{constructor(t,n=Sjt(t)){super(),this.text=t,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(t,n,r,i){for(let s=0;;s++){let a=this.text[s],o=i+a.length;if((n?r:o)>=t)return new $jt(i,o,r,a);i=o+1,r++}}decompose(t,n,r,i){let s=t<=0&&n>=this.length?this:new Xs(ime(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let a=r.pop(),o=eR(s.text,a.text.slice(),0,s.length);if(o.length<=32)r.push(new Xs(o,a.length+s.length));else{let l=o.length>>1;r.push(new Xs(o.slice(0,l)),new Xs(o.slice(l)))}}else r.push(s)}replace(t,n,r){if(!(r instanceof Xs))return super.replace(t,n,r);[t,n]=Nw(this,t,n);let i=eR(this.text,eR(r.text,ime(this.text,0,t)),n),s=this.length+r.length-(n-t);return i.length<=32?new Xs(i,s):Th.from(Xs.split(i,[]),s)}sliceString(t,n=this.length,r=`
1191
+ `,n);if(r===-1)break;const i=QMt(t.slice(n,r));if(e.fence){IMt(i,e.fence)&&(e.fence=null),n=r+1;continue}if(pNe.test(i)){e.blankRunStart<0&&(e.blankRunStart=n),n=r+1;continue}if(e.blankRunStart>=0){if(e.kind==="none"||!XMt(e.kind,i)){const s=t.slice(e.blockStart,e.blankRunStart);s.trim().length>0&&(e.blocks.push(s),e.revision+=1),e.blockStart=n,e.kind=wge(i)}e.blankRunStart=-1}else e.kind==="none"&&(e.kind=wge(i));if(e.kind!=="indented-code"){const s=RMt.exec(i);s&&(e.fence={char:s[1][0],length:s[1].length})}n=r+1}e.cursor=n},MMt=e=>{let t=e.length;for(;t>0;){const n=e.charCodeAt(t-1);if(n!==32&&n!==9&&n!==10&&n!==13)break;t-=1}return t},ar="var(--color-ink)",Qf="var(--color-ink-muted)",rh="var(--color-surface)",kO="var(--color-elevated)",Rf="var(--color-sunken)",vo="var(--color-hairline)",TO="var(--color-control)",Yy="var(--color-accent)",Q$="var(--color-accent-wash)",jMt="var(--color-on-accent)",LMt="var(--color-info)",mNe="var(--color-info-wash)",qMt="var(--color-success)",vNe="var(--color-success-wash)",zMt="var(--color-warning)",mG="var(--color-warning-wash)",UMt="var(--color-warning-border)",R7="var(--color-danger)",vG="var(--color-danger-wash)",xge=[Q$,mNe,vNe,mG,vG],_O=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),WMt=()=>{const e={primaryColor:_O("--color-accent"),secondaryColor:_O("--color-success"),tertiaryColor:_O("--color-info"),mainBkg:_O("--color-elevated"),clusterBkg:_O("--color-sunken"),clusterBorder:_O("--color-hairline"),edgeLabelBackground:_O("--color-surface"),quadrant1Fill:_O("--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:rh,primaryTextColor:ar,primaryBorderColor:TO,secondaryTextColor:ar,secondaryBorderColor:vo,tertiaryTextColor:ar,tertiaryBorderColor:vo,lineColor:Qf,arrowheadColor:Qf,textColor:ar,secondBkg:Rf,border1:TO,border2:vo,labelColor:ar,nodeBkg:kO,nodeBorder:TO,nodeTextColor:ar,defaultLinkColor:Qf,titleColor:ar,noteBkgColor:mG,noteBorderColor:UMt,noteTextColor:ar,actorBkg:kO,actorBorder:TO,actorTextColor:ar,actorLineColor:vo,signalColor:Qf,signalTextColor:ar,labelBoxBkgColor:kO,labelBoxBorderColor:vo,labelTextColor:ar,loopTextColor:ar,activationBkgColor:Q$,activationBorderColor:Yy,sequenceNumberColor:rh,sectionBkgColor:Rf,sectionBkgColor2:rh,altSectionBkgColor:Rf,excludeBkgColor:Rf,taskBkgColor:Q$,taskBorderColor:TO,taskTextColor:ar,taskTextLightColor:ar,taskTextDarkColor:ar,taskTextOutsideColor:ar,taskTextClickableColor:Yy,activeTaskBkgColor:Q$,activeTaskBorderColor:Yy,gridColor:vo,doneTaskBkgColor:Rf,doneTaskBorderColor:vo,critBkgColor:vG,critBorderColor:R7,todayLineColor:Yy,transitionColor:Qf,transitionLabelColor:ar,stateLabelColor:ar,stateBkg:kO,labelBackgroundColor:rh,compositeBackground:Rf,altBackground:Rf,compositeTitleBackground:kO,compositeBorder:vo,innerEndBackground:ar,specialStateColor:ar,classText:ar,attributeBackgroundColorOdd:rh,attributeBackgroundColorEven:Rf,rowOdd:rh,rowEven:Rf,errorBkgColor:vG,errorTextColor:R7,pieTitleTextColor:ar,pieSectionTextColor:ar,pieLegendTextColor:ar,pieStrokeColor:rh,pieOuterStrokeColor:vo,requirementBackground:kO,requirementBorderColor:TO,requirementTextColor:ar,relationColor:Qf,relationLabelBackground:rh,relationLabelColor:ar,branchLabelColor:jMt,commitLabelColor:ar,commitLabelBackground:rh,tagLabelColor:ar,tagLabelBackground:Q$,tagLabelBorder:TO,quadrant2Fill:mNe,quadrant3Fill:vNe,quadrant4Fill:mG,quadrant2TextFill:ar,quadrant3TextFill:ar,quadrant4TextFill:ar,quadrantPointFill:Yy,archEdgeColor:Qf,archEdgeArrowColor:Qf,archGroupBorderColor:vo,scaleLabelColor:ar,packet:{startByteColor:ar,endByteColor:ar,labelColor:ar,titleColor:ar,blockStrokeColor:TO,blockFillColor:kO},radar:{axisColor:Qf,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:vo,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:rh,titleColor:ar,xAxisTitleColor:ar,xAxisLabelColor:ar,xAxisTickColor:vo,xAxisLineColor:vo,yAxisTitleColor:ar,yAxisLabelColor:ar,yAxisTickColor:vo,yAxisLineColor:vo,plotColorPalette:[Yy,LMt,qMt,zMt,R7].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=kO,t[`surfacePeer${n}`]=vo;for(let n=0;n<8;n++)t[`fillType${n}`]=xge[n%xge.length];return{...t,...e}};let A7=null,Sge=null;const GMt=async e=>{A7||(A7=Le(async()=>{const{default:n}=await import("./mermaid.core-CkgQHyLv.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([0,1,2]),import.meta.url).then(({default:n})=>n));const t=await A7;return Sge!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:WMt()}),Sge=e),t},$ge=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:s,onCopy:a,children:o})=>p.jsxs("div",{className:A("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[p.jsx(rt,{content:"Zoom in",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Zoom in",onClick:n,children:p.jsx(Eit,{})})}),p.jsx(rt,{content:"Zoom out",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Zoom out",onClick:r,children:p.jsx(Rit,{})})}),p.jsx(rt,{content:"Drag the diagram to pan",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Drag to pan",children:p.jsx(trt,{})})}),p.jsx(rt,{content:"Reset view",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Reset view",onClick:i,children:p.jsx(OZ,{})})}),p.jsx(rt,{content:"Save as SVG",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Save as SVG",onClick:s,children:p.jsx(Np,{})})}),p.jsx(rt,{content:t?"Copied":"Copy mermaid text",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":t?"Copied":"Copy mermaid text",onClick:a,children:p.jsx(ey,{className:A(t&&"text-success")})})}),o]}),yG=({title:e,children:t})=>p.jsxs(Ml,{variant:"danger",role:"alert",className:"my-4",children:[p.jsx(v_e,{children:e}),p.jsx(rT,{children:t})]});class VMt extends b.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||p.jsxs(yG,{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 BMt=b.memo(({chart:e,id:t})=>{const n=b.useRef(null),r=b.useRef(null),[i,s]=b.useState(null),[a,o]=b.useState(!0),[l,c]=b.useState(""),[u,d]=b.useState(!1),[h,f]=b.useState({scale:1,x:0,y:0}),[O,g]=b.useState({scale:1,x:0,y:0}),[m,v]=b.useState(!1),[y,w]=b.useState({x:0,y:0}),[k,x]=b.useState("idle"),[S,T]=b.useState("idle"),_=bn(N=>N.themeName),P=b.useCallback(async()=>{try{if(o(!0),s(null),c(""),!e||typeof e!="string"||e.trim().length===0)throw new Error("Invalid or empty chart content");const N=await GMt(_),z=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:V}=await N.render(z,e);if(!V||typeof V!="string"||V.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(V)}catch(N){console.error("Mermaid rendering error:",N);const z=N instanceof Error?N.message:"Failed to render mermaid diagram";s(z),c("")}finally{o(!1)}},[e,t,_]);b.useEffect(()=>{P().catch(N=>{console.error("Error in renderDiagram effect:",N),s("Failed to initialize diagram rendering"),o(!1)})},[P]);const E=b.useCallback(()=>{try{if(!l||!r.current)return 1;const z=r.current.getBoundingClientRect(),V=document.createElement("div");V.innerHTML=l;const ee=V.querySelector("svg");if(!ee)return 1;const oe=ee.getBoundingClientRect?.()?.width||Number.parseFloat(ee.getAttribute("width")||"0")||ee.viewBox?.baseVal?.width||800,ie=ee.getBoundingClientRect?.()?.height||Number.parseFloat(ee.getAttribute("height")||"0")||ee.viewBox?.baseVal?.height||600,he=z.width*.9/oe,te=z.height*.9/ie;return Math.min(he,te,1)}catch(N){return console.error("Error calculating fullscreen scale:",N),1}},[l]);b.useEffect(()=>{u&&l&&setTimeout(()=>{try{const N=E();g({scale:N,x:0,y:0})}catch(N){console.error("Error setting fullscreen transform:",N)}},100)},[u,l,E]);const C=b.useCallback((N=!1)=>{try{(N?g:f)(V=>({...V,scale:Math.min(V.scale*1.2,10)}))}catch(z){console.error("Error in zoom in:",z)}},[]),Q=b.useCallback((N=!1)=>{try{(N?g:f)(V=>({...V,scale:Math.max(V.scale/1.2,.1)}))}catch(z){console.error("Error in zoom out:",z)}},[]),D=b.useCallback((N=!1)=>{try{const z=N?g:f;if(N){const V=E();z({scale:V,x:0,y:0})}else z({scale:1,x:0,y:0})}catch(z){console.error("Error in reset:",z)}},[E]),F=b.useCallback(()=>{if(l)try{const N=new Blob([l],{type:"image/svg+xml"}),z=URL.createObjectURL(N),V=document.createElement("a");V.href=z,V.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(V),V.click(),document.body.removeChild(V),URL.revokeObjectURL(z)}catch(N){console.error("Failed to save SVG:",N)}},[l]),I=b.useCallback(async()=>{try{await navigator.clipboard.writeText(e),x("copied"),setTimeout(()=>x("idle"),1200)}catch(N){console.error("Failed to copy Mermaid chart text:",N)}},[e]),U=b.useCallback(async()=>{try{await navigator.clipboard.writeText(e),T("copied"),setTimeout(()=>T("idle"),1200)}catch(N){console.error("Failed to copy Mermaid chart text:",N)}},[e]),q=b.useCallback(N=>{try{v(!0),w({x:N.clientX,y:N.clientY}),N.preventDefault()}catch(z){console.error("Error in mouse down:",z)}},[]),Z=b.useCallback((N,z=!1)=>{try{if(!m)return;const V=N.clientX-y.x,ee=N.clientY-y.y;(z?g:f)(ie=>({...ie,x:ie.x+V,y:ie.y+ee})),w({x:N.clientX,y:N.clientY})}catch(V){console.error("Error in mouse move:",V)}},[m,y]),W=b.useCallback(()=>{try{v(!1)}catch(N){console.error("Error in mouse up:",N)}},[]),M=b.useCallback((N,z=!1)=>{try{N.preventDefault();const V=N.deltaY>0?.9:1.1;(z?g:f)(oe=>({...oe,scale:Math.min(Math.max(oe.scale*V,.1),5)}))}catch(V){console.error("Error in wheel:",V)}},[]),J=b.useCallback(N=>{try{d(N)}catch(z){console.error("Error toggling fullscreen:",z)}},[]);if(i)return p.jsxs(yG,{title:"Mermaid diagram error",children:[i,p.jsx("span",{className:A("mt-2 block text-ink-muted"),children:"Chart"}),p.jsx("span",{className:A("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const L=(N=!1)=>{try{const z=N?r:n,V=N?O:h;return p.jsx("div",{ref:z,className:A("mermaid flex w-full items-center justify-center",N?"h-full min-h-full":"h-auto min-h-50",m?"cursor-grabbing":"cursor-grab"),onMouseDown:q,onMouseMove:ee=>Z(ee,N),onMouseUp:W,onMouseLeave:W,onWheel:ee=>M(ee,N),children:a?p.jsx("div",{className:A("p-4 text-body-sm text-ink-muted"),children:"Loading diagram..."}):l?p.jsx("div",{className:A("flex h-full w-full items-center justify-center"),style:{transform:`translate(${V.x}px, ${V.y}px) scale(${V.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(z){return console.error("Error rendering diagram content:",z),p.jsx(yG,{title:"Rendering error",children:"Failed to render diagram content."})}};return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:A("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:[L(!1),p.jsx($ge,{className:"top-2 right-2",copied:k==="copied",onZoomIn:()=>C(!1),onZoomOut:()=>Q(!1),onReset:()=>D(!1),onSave:F,onCopy:I,children:p.jsx(rt,{content:"Fullscreen",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Open diagram fullscreen",onClick:()=>J(!0),children:p.jsx(jnt,{})})})})]}),p.jsx(Nc,{open:u,onClose:()=>J(!1),title:"Mermaid diagram",maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:p.jsxs("div",{className:A("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:[L(!0),p.jsx($ge,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>C(!0),onZoomOut:()=>Q(!0),onReset:()=>D(!0),onSave:F,onCopy:U,children:p.jsx(rt,{content:"Close fullscreen",children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":"Close fullscreen",onClick:()=>J(!1),children:p.jsx(Qi,{})})})})]})})]})}),YMt=b.memo(e=>p.jsx(VMt,{children:p.jsx(BMt,{...e})}));let yNe=!1,D7=null;const ZMt=()=>(D7||(D7=Le(()=>Promise.resolve({}),__vite__mapDeps([3]),import.meta.url).then(e=>(yNe=!0,e))),D7),HMt=/language-(\w+)/,KMt=/\n$/,JMt=/\$(?!\d)(.+?)\$/,e8t=/\$\$([\s\S]+?)\$\$/,t8t=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,n8t=/\\[a-zA-Z]+(\{[^}]*\})?/,bNe={a:({href:e,children:t})=>p.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}),code:({node:e,className:t,children:n,...r})=>HMt.exec(t??"")?.[1]==="mermaid"?p.jsx(YMt,{chart:String(n).replace(KMt,"")}):p.jsx("code",{className:t,...r,children:n})},r8t=[bN],i8t=[bN,EMt],s8t=[],a8t=[B6t],o8t=e=>JMt.test(e)||e8t.test(e)||t8t.test(e)?!0:n8t.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),wNe=e=>b.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),xNe=e=>{const t=b.useMemo(()=>o8t(e),[e]),[n,r]=b.useState(()=>t&&yNe);return b.useEffect(()=>{if(!t||n)return;let i=!1;return ZMt().then(()=>{i||r(!0)}),()=>{i=!0}},[t,n]),{remarkPlugins:n?i8t:r8t,rehypePlugins:n?a8t:s8t}},uy=b.memo(({content:e,styleProps:t,className:n})=>{const r=b.useMemo(()=>e.trim(),[e]),{remarkPlugins:i,rehypePlugins:s}=xNe(r),a=wNe(t);return p.jsx("div",{className:A("lo-markdown",n),style:a,children:p.jsx(AK,{remarkPlugins:i,rehypePlugins:s,components:bNe,children:r})})});uy.displayName="MarkdownRenderer";const SNe=b.memo(({source:e})=>{const{remarkPlugins:t,rehypePlugins:n}=xNe(e);return p.jsx(AK,{remarkPlugins:t,rehypePlugins:n,components:bNe,children:e})});SNe.displayName="StableBlock";const $Ne=b.memo(({text:e,animate:t})=>p.jsx("span",{className:t?"lo-stream-chunk":void 0,children:e}));$Ne.displayName="ArrivedText";const kNe=({content:e,styleProps:t,className:n})=>{const r=b.useRef(null);r.current===null&&(r.current=DMt());const i=r.current,s=b.useRef([]),a=b.useRef(0);FMt(i,e);const o=a.current;e.length>o?(o>0&&s.current.push({offset:o,animate:!0}),a.current=e.length):e.length<o&&(s.current=[],a.current=e.length);const{blockStart:l}=i,c=s.current;let u=0;for(;u<c.length&&c[u].offset<=l;)u+=1;u>0&&c.splice(0,u);const d=l+MMt(e.slice(l)),h=[{offset:l,animate:!1}];for(const O of c){if(O.offset>=d)break;h.push(O)}const f=wNe(t);return p.jsxs("div",{className:A("lo-markdown",n),style:f,children:[i.blocks.map((O,g)=>p.jsx(SNe,{source:O},g)),d>l&&p.jsx("p",{className:"lo-stream-tail",children:h.map((O,g)=>{const m=h[g+1]?.offset??d;return p.jsx($Ne,{text:e.slice(O.offset,m),animate:O.animate},O.offset)})})]})};kNe.displayName="StreamingMarkdown";const TNe=({className:e})=>p.jsx("div",{className:A("flex size-7 shrink-0 items-center justify-center rounded-full bg-sunken text-ink-muted",e),children:p.jsx(Jv,{size:16,"aria-label":"Assistant"})}),Ok="pl-10",yc=({isUser:e,children:t,isSmallView:n,showAvatar:r,className:i})=>e?p.jsx("div",{className:A("flex w-full justify-end",i),children:t}):p.jsxs("div",{className:A("relative w-full",!n&&Ok,i),children:[r&&!n&&p.jsx(TNe,{className:"absolute top-0 left-0"}),t]}),aJ=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},l8t=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 oJ=aJ(Date.now()),ZO=null;const KQ=new Set,_Ne=()=>{ZO!==null&&clearTimeout(ZO),ZO=setTimeout(()=>{ZO=null,oJ=aJ(Date.now());for(const e of KQ)e();_Ne()},l8t(Date.now())),ZO.unref?.()},c8t=e=>(KQ.add(e),oJ=aJ(Date.now()),_Ne(),()=>{KQ.delete(e),KQ.size===0&&ZO!==null&&(clearTimeout(ZO),ZO=null)}),kge=()=>oJ,u8t=()=>b.useSyncExternalStore(c8t,kge,kge),d8t=e=>new Date(e+1e3),h8t=()=>d8t(u8t()),PNe=6048e5,f8t=864e5,Tge=6e4,Crr=36e5,Err=1e3,_ge=525600,Pge=43200,Cge=1440,Ege=Symbol.for("constructDateFrom");function zp(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&Ege in e?e[Ege](t):e instanceof Date?new e.constructor(t):new Date(t)}function Xc(e,t){return zp(t||e,e)}let p8t={};function c2(){return p8t}function E_(e,t){const n=c2(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Xc(e,t?.in),s=i.getDay(),a=(s<r?7:0)+s-r;return i.setDate(i.getDate()-a),i.setHours(0,0,0,0),i}function F4(e,t){return E_(e,{...t,weekStartsOn:1})}function CNe(e,t){const n=Xc(e,t?.in),r=n.getFullYear(),i=zp(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);const s=F4(i),a=zp(n,0);a.setFullYear(r,0,4),a.setHours(0,0,0,0);const o=F4(a);return n.getTime()>=s.getTime()?r+1:n.getTime()>=o.getTime()?r:r-1}function M4(e){const t=Xc(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function ENe(e,...t){const n=zp.bind(null,t.find(r=>typeof r=="object"));return t.map(n)}function Qge(e,t){const n=Xc(e,t?.in);return n.setHours(0,0,0,0),n}function O8t(e,t,n){const[r,i]=ENe(n?.in,e,t),s=Qge(r),a=Qge(i),o=+s-M4(s),l=+a-M4(a);return Math.round((o-l)/f8t)}function g8t(e,t){const n=CNe(e,t),r=zp(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),F4(r)}function m8t(e,t){const n=+Xc(e)-+Xc(t);return n<0?-1:n>0?1:n}function v8t(e){return zp(e,Date.now())}function y8t(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function b8t(e){return!(!y8t(e)&&typeof e!="number"||isNaN(+Xc(e)))}function w8t(e){return t=>{const r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function x8t(e,t){const n=Xc(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const S8t={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},$8t=(e,t,n)=>{let r;const i=S8t[e];return typeof i=="string"?r=i:t===1?r=i.one:r=i.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function N7(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const k8t={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},T8t={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},_8t={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},P8t={date:N7({formats:k8t,defaultWidth:"full"}),time:N7({formats:T8t,defaultWidth:"full"}),dateTime:N7({formats:_8t,defaultWidth:"full"})},C8t={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},E8t=(e,t,n,r)=>C8t[e];function AS(e){return(t,n)=>{const r=n?.context?String(n.context):"standalone";let i;if(r==="formatting"&&e.formattingValues){const a=e.defaultFormattingWidth||e.defaultWidth,o=n?.width?String(n.width):a;i=e.formattingValues[o]||e.formattingValues[a]}else{const a=e.defaultWidth,o=n?.width?String(n.width):e.defaultWidth;i=e.values[o]||e.values[a]}const s=e.argumentCallback?e.argumentCallback(t):t;return i[s]}}const Q8t={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},R8t={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},A8t={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},D8t={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},N8t={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},X8t={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},I8t=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},F8t={ordinalNumber:I8t,era:AS({values:Q8t,defaultWidth:"wide"}),quarter:AS({values:R8t,defaultWidth:"wide",argumentCallback:e=>e-1}),month:AS({values:A8t,defaultWidth:"wide"}),day:AS({values:D8t,defaultWidth:"wide"}),dayPeriod:AS({values:N8t,defaultWidth:"wide",formattingValues:X8t,defaultFormattingWidth:"wide"})};function DS(e){return(t,n={})=>{const r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(i);if(!s)return null;const a=s[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?j8t(o,d=>d.test(a)):M8t(o,d=>d.test(a));let c;c=e.valueCallback?e.valueCallback(l):l,c=n.valueCallback?n.valueCallback(c):c;const u=t.slice(a.length);return{value:c,rest:u}}}function M8t(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function j8t(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function L8t(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const i=r[0],s=t.match(e.parsePattern);if(!s)return null;let a=e.valueCallback?e.valueCallback(s[0]):s[0];a=n.valueCallback?n.valueCallback(a):a;const o=t.slice(i.length);return{value:a,rest:o}}}const q8t=/^(\d+)(th|st|nd|rd)?/i,z8t=/\d+/i,U8t={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},W8t={any:[/^b/i,/^(a|c)/i]},G8t={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},V8t={any:[/1/i,/2/i,/3/i,/4/i]},B8t={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Y8t={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Z8t={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},H8t={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},K8t={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},J8t={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},e7t={ordinalNumber:L8t({matchPattern:q8t,parsePattern:z8t,valueCallback:e=>parseInt(e,10)}),era:DS({matchPatterns:U8t,defaultMatchWidth:"wide",parsePatterns:W8t,defaultParseWidth:"any"}),quarter:DS({matchPatterns:G8t,defaultMatchWidth:"wide",parsePatterns:V8t,defaultParseWidth:"any",valueCallback:e=>e+1}),month:DS({matchPatterns:B8t,defaultMatchWidth:"wide",parsePatterns:Y8t,defaultParseWidth:"any"}),day:DS({matchPatterns:Z8t,defaultMatchWidth:"wide",parsePatterns:H8t,defaultParseWidth:"any"}),dayPeriod:DS({matchPatterns:K8t,defaultMatchWidth:"any",parsePatterns:J8t,defaultParseWidth:"any"})},QNe={code:"en-US",formatDistance:$8t,formatLong:P8t,formatRelative:E8t,localize:F8t,match:e7t,options:{weekStartsOn:0,firstWeekContainsDate:1}};function t7t(e,t){const n=Xc(e,t?.in);return O8t(n,x8t(n))+1}function n7t(e,t){const n=Xc(e,t?.in),r=+F4(n)-+g8t(n);return Math.round(r/PNe)+1}function RNe(e,t){const n=Xc(e,t?.in),r=n.getFullYear(),i=c2(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,a=zp(t?.in||e,0);a.setFullYear(r+1,0,s),a.setHours(0,0,0,0);const o=E_(a,t),l=zp(t?.in||e,0);l.setFullYear(r,0,s),l.setHours(0,0,0,0);const c=E_(l,t);return+n>=+o?r+1:+n>=+c?r:r-1}function r7t(e,t){const n=c2(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=RNe(e,t),s=zp(t?.in||e,0);return s.setFullYear(i,0,r),s.setHours(0,0,0,0),E_(s,t)}function i7t(e,t){const n=Xc(e,t?.in),r=+E_(n,t)-+r7t(n,t);return Math.round(r/PNe)+1}function ci(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const PO={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return ci(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):ci(n+1,2)},d(e,t){return ci(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return ci(e.getHours()%12||12,t.length)},H(e,t){return ci(e.getHours(),t.length)},m(e,t){return ci(e.getMinutes(),t.length)},s(e,t){return ci(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return ci(i,t.length)}},Zy={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Rge={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),i=r>0?r:1-r;return n.ordinalNumber(i,{unit:"year"})}return PO.y(e,t)},Y:function(e,t,n,r){const i=RNe(e,r),s=i>0?i:1-i;if(t==="YY"){const a=s%100;return ci(a,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):ci(s,t.length)},R:function(e,t){const n=CNe(e);return ci(n,t.length)},u:function(e,t){const n=e.getFullYear();return ci(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return ci(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return ci(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return PO.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return ci(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const i=i7t(e,r);return t==="wo"?n.ordinalNumber(i,{unit:"week"}):ci(i,t.length)},I:function(e,t,n){const r=n7t(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):ci(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):PO.d(e,t)},D:function(e,t,n){const r=t7t(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):ci(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const i=e.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return ci(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});case"eeee":default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const i=e.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return ci(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});case"cccc":default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),i=r===0?7:r;switch(t){case"i":return String(i);case"ii":return ci(i,t.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const i=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let i;switch(r===12?i=Zy.noon:r===0?i=Zy.midnight:i=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let i;switch(r>=17?i=Zy.evening:r>=12?i=Zy.afternoon:r>=4?i=Zy.morning:i=Zy.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return PO.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):PO.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):ci(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):ci(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):PO.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):PO.s(e,t)},S:function(e,t){return PO.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return Dge(r);case"XXXX":case"XX":return r0(r);case"XXXXX":case"XXX":default:return r0(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return Dge(r);case"xxxx":case"xx":return r0(r);case"xxxxx":case"xxx":default:return r0(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+Age(r,":");case"OOOO":default:return"GMT"+r0(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+Age(r,":");case"zzzz":default:return"GMT"+r0(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return ci(r,t.length)},T:function(e,t,n){return ci(+e,t.length)}};function Age(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=Math.trunc(r/60),s=r%60;return s===0?n+String(i):n+String(i)+t+ci(s,2)}function Dge(e,t){return e%60===0?(e>0?"-":"+")+ci(Math.abs(e)/60,2):r0(e,t)}function r0(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=ci(Math.trunc(r/60),2),s=ci(r%60,2);return n+i+t+s}const Nge=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},ANe=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},s7t=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return Nge(e,t);let s;switch(r){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",Nge(r,t)).replace("{{time}}",ANe(i,t))},a7t={p:ANe,P:s7t},o7t=/^D+$/,l7t=/^Y+$/,c7t=["D","DD","YY","YYYY"];function u7t(e){return o7t.test(e)}function d7t(e){return l7t.test(e)}function h7t(e,t,n){const r=f7t(e,t,n);if(console.warn(r),c7t.includes(e))throw new RangeError(r)}function f7t(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const p7t=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,O7t=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,g7t=/^'([^]*?)'?$/,m7t=/''/g,v7t=/[a-zA-Z]/;function X7(e,t,n){const r=c2(),i=n?.locale??r.locale??QNe,s=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,o=Xc(e,n?.in);if(!b8t(o))throw new RangeError("Invalid time value");let l=t.match(O7t).map(u=>{const d=u[0];if(d==="p"||d==="P"){const h=a7t[d];return h(u,i.formatLong)}return u}).join("").match(p7t).map(u=>{if(u==="''")return{isToken:!1,value:"'"};const d=u[0];if(d==="'")return{isToken:!1,value:y7t(u)};if(Rge[d])return{isToken:!0,value:u};if(d.match(v7t))throw new RangeError("Format string contains an unescaped latin alphabet character `"+d+"`");return{isToken:!1,value:u}});i.localize.preprocessor&&(l=i.localize.preprocessor(o,l));const c={firstWeekContainsDate:s,weekStartsOn:a,locale:i};return l.map(u=>{if(!u.isToken)return u.value;const d=u.value;(!n?.useAdditionalWeekYearTokens&&d7t(d)||!n?.useAdditionalDayOfYearTokens&&u7t(d))&&h7t(d,t,String(e));const h=Rge[d[0]];return h(o,d,i.localize,c)}).join("")}function y7t(e){const t=e.match(g7t);return t?t[1].replace(m7t,"'"):e}function b7t(e,t,n){const r=c2(),i=n?.locale??r.locale??QNe,s=m8t(e,t);if(isNaN(s))throw new RangeError("Invalid time value");const a=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:s}),[o,l]=ENe(n?.in,...s>0?[t,e]:[e,t]),c=w8t("round"),u=l.getTime()-o.getTime(),d=u/Tge,h=M4(l)-M4(o),f=(u-h)/Tge,O=n?.unit;let g;if(d<1?g="second":d<60?g="minute":d<Cge?g="hour":f<Pge?g="day":f<_ge?g="month":g="year",g==="second"){const m=c(u/1e3);return i.formatDistance("xSeconds",m,a)}else if(g==="minute"){const m=c(d);return i.formatDistance("xMinutes",m,a)}else if(g==="hour"){const m=c(d/60);return i.formatDistance("xHours",m,a)}else if(g==="day"){const m=c(f/Cge);return i.formatDistance("xDays",m,a)}else if(g==="month"){const m=c(f/Pge);return m===12&&O!=="month"?i.formatDistance("xYears",1,a):i.formatDistance("xMonths",m,a)}else{const m=c(f/_ge);return i.formatDistance("xYears",m,a)}}function w7t(e,t){return b7t(e,v8t(e),t)}const x7t=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e),n=new Date,r=new Date(n);if(r.setDate(n.getDate()-1),t.toDateString()===n.toDateString())return X7(t,"h:mm a");if(t.toDateString()===r.toDateString())return"Yesterday";const i=new Date(n);return i.setDate(n.getDate()-7),t>i?X7(t,"EEEE"):X7(t,"yyyy-MM-dd")}catch(t){return console.error("Error formatting date:",t),""}},Qrr=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString(navigator.language,{year:"numeric",month:"long",day:"numeric"})}catch(t){return console.error("Error formatting calendar date:",t),""}},S7t=(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=n.toLocaleTimeString(navigator.language,{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 s=n.toLocaleDateString(navigator.language,{month:"short",day:"numeric"});return n.getFullYear()===t.getFullYear()?`${s}, ${r}`:`${s}, ${n.getFullYear()}, ${r}`}catch(n){return console.error("Error formatting turn timestamp:",n),""}},DNe=(e,t)=>{if(!e)return"";try{const n=e instanceof Date?e:new Date(e);return Number.isNaN(n.getTime())?"":n.toLocaleString(navigator.language,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit",...t})}catch(n){return console.error("Error formatting calendar date-time:",n),""}},lJ=({timestamp:e,scope:t,className:n})=>{const r=e instanceof Date?e:new Date(e),i=h8t();if(Number.isNaN(r.getTime()))return null;const s=DNe(r,{hour12:!0});return p.jsx(rt,{content:s,side:"bottom",delayDuration:1200,children:p.jsx("time",{dateTime:r.toISOString(),"data-stamp":t,"aria-label":`Sent ${s}`,className:A("shrink-0 cursor-help select-none whitespace-nowrap text-ink-dim text-meta",n),children:S7t(r,i)})})},Q_=({replies:e,onRemoveReply:t})=>p.jsxs("div",{className:"mb-2 flex flex-col gap-1.5 rounded-sm bg-sunken p-2",children:[p.jsxs("div",{className:"flex items-center gap-1.5 text-ink-dim",children:[p.jsx(O2e,{size:12,"aria-hidden":"true"}),p.jsx("span",{className:"text-meta",children:"Replying to"})]}),e.map(n=>p.jsxs("div",{className:"flex items-center gap-2 border-hairline border-l-2 py-0.5 pl-2",children:[p.jsx("span",{className:"flex-1 truncate text-body-sm text-ink-muted",title:n.text,children:n.text}),t&&p.jsx(we,{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:p.jsx(Qi,{"aria-hidden":"true"})})]},n.id))]}),NNe=({content:e,busy:t=!1,className:n})=>e?p.jsxs("section",{"aria-label":"Question from the agent",className:A("flex gap-3 rounded-md border border-accent bg-accent-wash px-4 py-3",n),children:[p.jsx(Unt,{className:"mt-0.5 size-4 shrink-0 text-accent","aria-hidden":!0}),p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[p.jsx("p",{className:"font-medium text-accent text-meta",children:t?"Sending your answer…":"Waiting for your answer"}),p.jsx("div",{className:"lo-on-wash text-ink",children:p.jsx(uy,{content:e})})]})]}):null,$7t=({options:e,recommended:t,busy:n=!1,onAnswer:r,requestId:i})=>{if(e.length===0)return null;const s=typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<e.length?t:null;return p.jsx("fieldset",{"aria-label":"Answer options",className:"mt-1 flex min-w-0 max-h-[380px] flex-col gap-2 overflow-y-auto border-0 px-0 py-1",children:e.map((a,o)=>p.jsxs("button",{type:"button",disabled:n,onClick:()=>r(a.label),className:A("flex w-full items-baseline gap-2 rounded-sm border px-3 py-2 text-left","transition-colors duration-fast ease-out-quart","border-control bg-surface hover:bg-elevated active:bg-sunken","disabled:border-hairline disabled:bg-sunken disabled:text-ink-disabled"),children:[o<9&&p.jsxs("span",{"aria-hidden":!0,className:A("shrink-0 font-mono text-mono-sm",n?"text-ink-disabled":"text-ink-dim"),children:[o+1,"."]}),p.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[p.jsxs("span",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[p.jsx("span",{className:A("min-w-0 text-body-sm",n?"text-ink-disabled":"text-ink"),children:a.label}),s===o&&p.jsx("span",{className:A("shrink-0 font-medium text-meta",n?"text-ink-disabled":"text-ink"),children:"Recommended"})]}),a.description&&p.jsx("span",{className:A("text-body-sm",n?"text-ink-disabled":"text-ink-muted"),children:a.description})]})]},`${i}-${String(o)}`))})},XNe=({children:e,className:t})=>p.jsx("span",{"aria-hidden":!0,className:A("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),cJ=({label:e="Reasoning",content:t})=>!bn(r=>r.showAgentReasoning)||!t?null:p.jsx(Nu,{summary:p.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[p.jsx(XNe,{}),p.jsx("span",{className:"truncate",children:p.jsx("span",{className:"text-ink-dim text-meta",children:e})})]}),children:p.jsx(uy,{content:t,className:"[--md-ink:var(--lo-ink-muted)]",styleProps:{fontSize:"var(--text-body-sm)",lineHeight:"var(--text-body-sm--line-height)"}})}),k7t={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},T7t=({line:e})=>p.jsx("span",{className:A(k7t[e.kind],"block"),children:e.text}),_7t=({diff:e,className:t})=>{const n=Odt(e);return p.jsxs("div",{className:A("max-h-[740px] overflow-y-auto overflow-x-hidden rounded-sm border border-hairline bg-sunken p-3 font-mono text-ink text-mono-sm whitespace-pre-wrap break-words",t),children:[n.lines.map((r,i)=>p.jsx(T7t,{line:r},i)),n.hidden>0&&p.jsx("span",{className:"sticky -bottom-3 -mb-3 block bg-sunken pb-3 text-ink-dim",children:gdt(n.hidden)})]})},P7t=({content:e,details:t,className:n})=>p.jsxs("section",{"aria-label":"Security notice",className:A("flex gap-3 border-warning border-l-2 py-0.5 pl-3",n),children:[p.jsx(T2e,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":!0}),p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[p.jsx("p",{className:"font-medium text-body-sm text-warning",children:"Blocked a risky action"}),e?p.jsx("p",{className:"text-body-sm text-ink-muted",children:e}):null,t?p.jsx(Nu,{summary:p.jsx("span",{className:"text-meta",children:"Show the reviewed code"}),children:t}):null]})]}),C7t=(e,t=72)=>{let i=e.replace(/```[\s\S]*?```/g," ").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/\s+/g," ").trim();if(i.length>t){const s=i.slice(0,t),a=s.lastIndexOf(" ");i=`${s.slice(0,a>32?a:t).trimEnd()}…`}return i.replace(/[.!?…]+$/g,"").trimEnd()},Xge=e=>e.startsWith("file://")?e.slice(7):e,E7t={READ:{verb:"Read",runningVerb:"Reading",icon:lZ},WRITE:{verb:"Wrote",runningVerb:"Writing",icon:fZ},EDIT:{verb:"Edited",runningVerb:"Editing",icon:prt},CODE:{verb:"Ran code",runningVerb:"Running code",icon:cZ},DELEGATE:{verb:"Delegated work",runningVerb:"Delegating work",icon:zrt},DONE:{verb:"Finished",runningVerb:"Finishing",icon:IY},ASK:{verb:"Asked",runningVerb:"Asking",icon:G3},BYE:{verb:"Ended the conversation",runningVerb:"Ending",icon:Qtt}},Q7t={verb:"Worked on the request",runningVerb:"Working on the request",icon:cZ},R7t=(e,t,n,r)=>{const i=e?E7t[e]:Q7t;let s;if(t)s=Xge(t);else if(n&&n.length>0){const o=n.filter(l=>!l.startsWith("data:"));o.length===1?s=Xge(o[0]):o.length>1&&(s=`${o.length} files`)}const a=!s&&r?C7t(r):"";return{verb:i.verb,runningVerb:i.runningVerb,object:s,narration:a||void 0,icon:i.icon}},Ige="min-h-5 py-0",A7t=({icon:e,verb:t,object:n,narration:r,running:i,failed:s,wrap:a})=>p.jsxs("span",{className:A("flex min-w-0 gap-2",a?"items-start":"items-center"),"aria-busy":i||void 0,children:[p.jsx(XNe,{className:A(s?"text-danger":"text-ink-dim",a&&v4e),children:e}),p.jsxs("span",{className:A(a?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[p.jsxs("span",{...U8,className:A("select-text font-mono text-mono-sm",i?"text-ink-muted":"text-ink-dim",s&&"text-danger"),children:[t,r?":":null]}),n?p.jsxs("span",{...U8,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?p.jsxs("span",{...U8,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),j4=({action:e,filePath:t,files:n,narration:r,running:i=!1,failed:s=!1,defaultOpen:a=!1,details:o,className:l,verbOverride:c,object:u,glyph:d,wrap:h,dense:f=!1})=>{const O=R7t(e,t,n,r),g=c??(i?O.runningVerb:O.verb),m=s?sv:O.icon,v=s||!c||!d?p.jsx(m,{}):d,y=p.jsx(A7t,{icon:v,verb:g,object:c?u:O.object,narration:c?r:O.narration,running:i,failed:s,wrap:h}),w=h?"firstLine":"center";return o?p.jsx(Nu,{summary:y,chevron:"leading",summaryAlign:w,defaultOpen:a,className:l,rowClassName:f?Ige:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:o}):p.jsx(Nu,{disabled:!0,summary:y,summaryAlign:w,className:l,rowClassName:f?Ige:void 0})},INe=8,D7t="… deeper values not shown",N7t="(empty)";function X7t(e){return`… ${e} more line${e===1?"":"s"}`}const Fge=.5;function I7t(e,t,n,r){if(!Number.isFinite(t)||t<=0)return 0;let i=0;for(const s of e){if(s.height<=0)continue;const a=Math.max(1,Math.round(s.height/t));for(let o=1;o<=a;o++)s.top+o*t>n+r&&i++}return i}function FNe(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function uJ(e){return typeof e=="object"&&e!==null}function MNe(e,t,n,r){if(n>INe){r.push({key:t,value:D7t,depth:n});return}if(uJ(e)){for(const[s,a]of Object.entries(e))MNe(a,t?`${t}.${s}`:s,n+1,r);return}const i=FNe(e);i!==null&&r.push({key:t,value:i,depth:n})}function jNe(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))MNe(r,n,1,t);return t}const F7t=512;function M7t(e,t){if(t)return!0;if(!e)return!1;let n=F7t;const r=(i,s)=>{if(n--<=0||s>INe)return!0;if(!uJ(i))return FNe(i)!==null;for(const a of Object.values(i))if(r(a,s+1))return!0;return!1};for(const i of Object.values(e))if(r(i,1))return!0;return!1}function j7t(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(!uJ(n))return null;const r=jNe(n);return r.length>0?r:[{key:"",value:N7t,depth:1}]}const L7t=8,Mge="max-h-[240px]",q7t=({line:e})=>p.jsxs("div",{className:A("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*L7t},children:[e.key?p.jsxs("span",{className:A("text-ink-dim"),children:[e.key,": "]}):null,p.jsx("span",{className:A("text-ink-muted"),children:e.value})]}),jge=({lines:e,label:t})=>p.jsx("div",{className:A("flex flex-col gap-1"),"data-detail-lines":t,children:e.map((n,r)=>p.jsx(q7t,{line:n},r))});function Lge(e){const[t,n]=b.useState(0),[r,i]=b.useState(!1);return b.useLayoutEffect(()=>{const s=e.current;if(!s)return;const a=s.firstElementChild,o=()=>{const c=a??s,u=Number.parseFloat(getComputedStyle(c).lineHeight);if(!Number.isFinite(u)||u<=0){n(0),i(!1);return}const d=s.getBoundingClientRect(),h=c.getBoundingClientRect();i(h.height>d.height+Fge);const f=c.children.length>0?Array.from(c.children):[c];n(I7t(f.map(O=>{const g=O.getBoundingClientRect();return{top:g.top,height:g.height}}),u,d.bottom,Fge))};o(),s.addEventListener("scroll",o,{passive:!0});const l=new ResizeObserver(o);return l.observe(a??s),()=>{s.removeEventListener("scroll",o),l.disconnect()}}),{lines:t,overflowing:r}}const qge=({lines:e,overflowing:t})=>t?p.jsx("span",{className:A("mt-1 block text-ink-dim"),children:e>0?X7t(e):" "}):null,z7t=({args:e,output:t,isError:n})=>{const r=jNe(e),i=j7t(t),s=b.useRef(null),a=b.useRef(null),o=Lge(s),l=Lge(a);return r.length===0&&!t?null:p.jsxs("div",{className:A("w-full rounded-sm border border-hairline bg-sunken p-3 font-mono text-mono-sm"),children:[r.length>0&&p.jsxs("div",{"data-detail-section":"input",children:[p.jsx("div",{ref:s,className:A(Mge,"overflow-auto"),children:p.jsx(jge,{lines:r,label:"input"})}),p.jsx(qge,{lines:o.lines,overflowing:o.overflowing})]}),t&&p.jsxs("div",{className:A(r.length>0&&"mt-3"),"data-detail-section":"output",children:[p.jsx("span",{className:A("mb-1 block text-meta",n?"text-danger":"text-ink-dim"),children:n?"Error":"Output"}),p.jsx("div",{ref:a,className:A(Mge,"overflow-auto"),children:i?p.jsx(jge,{lines:i,label:"result-json"}):p.jsx("pre",{className:A("whitespace-pre font-mono",n?"text-danger":"text-ink"),children:t})}),p.jsx(qge,{lines:l.lines,overflowing:l.overflowing})]})]})},U7t="mcp__",W7t={bash:mit,read:uv,write:sse,edit:sse,glob:hT,grep:dv,todo:Qnt,wake:V3,list_variables:o5,read_variable:o5,browser:_g,web_search:_g,web_fetch:Np,task:vp,agent:vp,send:gZ,peer:wnt};function G7t(e){const t=e.trim().toLowerCase(),n=W7t[t];return n||(t.startsWith(U7t)?pZ:QZe)}const V7t=Ul,B7t=Qi,Y7t=d2e,zge="min-h-5 py-0",Z7t={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent",plain:"text-ink-muted"},H7t=(e,t)=>e==="running"?"text-ink":e==="error"?"text-danger":e==="receipt"?"text-ink-muted":Z7t[idt(t)],K7t=({added:e,removed:t})=>e<=0&&t<=0?null:p.jsxs("span",{className:A("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&p.jsxs("span",{className:A("text-success"),children:["+",e]}),t>0&&p.jsxs("span",{className:A("text-danger"),children:["-",t]})]}),Uge={running:"",success:"succeeded",error:"failed",interrupted:"interrupted",receipt:""},J7t=1e3;function ejt(e){const[t,n]=b.useState(()=>e===null?null:Math.max(0,(Date.now()-e)/1e3));return b.useEffect(()=>{if(e===null){n(null);return}const r=()=>n(Math.max(0,(Date.now()-e)/1e3));r();const i=window.setInterval(r,J7t);return()=>window.clearInterval(i)},[e]),t}const tjt=({outcome:e,durationS:t,startedAt:n})=>{const r=e==="running",i=ejt(r?n??null:null),s=e==="success"?V7t:e==="error"?B7t:e==="interrupted"?Y7t:null,a=e==="success"?"text-success":e==="error"?"text-danger":"text-ink-dim",o=r?n==null?"":qZ(i??0):tdt(t);return p.jsxs("span",{className:A("flex shrink-0 items-center gap-1.5"),children:[p.jsxs("span",{className:A("flex size-3.5 shrink-0 [&_svg]:size-3.5",a),children:[s?p.jsx(s,{"aria-hidden":!0}):null,Uge[e]?p.jsx("span",{className:A("sr-only"),children:Uge[e]}):null]}),p.jsx("span",{className:A("w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums"),children:o})]})},L4=({toolName:e,summary:t,summaryFallback:n=null,outcome:r,durationS:i,startedAt:s=null,added:a=0,removed:o=0,nameColumn:l=ZCe,details:c,defaultOpen:u=!1,onOpenChange:d,className:h,media:f})=>{const O=b.useRef(u),g=b.useRef(d);b.useEffect(()=>{g.current=d,d?.(O.current)},[d]),b.useEffect(()=>()=>{O.current&&g.current?.(!1)},[]);const m=b.useCallback(P=>{O.current=P,g.current?.(P)},[]),v=r==="running",y=r==="error",w=G7t(e),k=AT(e),x=YCe(t,e)?n??"":t,S=p.jsxs("span",{className:A("flex min-w-0 flex-1 items-center gap-2"),children:[p.jsx("span",{"aria-hidden":!0,className:A("flex size-3.5 shrink-0 [&_svg]:size-3.5",v?"text-accent":y?"text-danger":"text-ink-dim"),children:p.jsx(w,{})}),p.jsx("span",{className:A("shrink-0 truncate font-mono text-mono-sm","pr-1",H7t(r,e)),style:{width:`calc(${l}ch + 0.25rem)`},title:k,children:k}),p.jsx("span",{className:A("min-w-0 flex-1 truncate font-mono text-mono-sm",v?"text-ink-muted":"text-ink-dim"),title:x,children:x}),p.jsx(K7t,{added:a,removed:o}),p.jsx(tjt,{outcome:r,durationS:i,startedAt:s})]}),T=v?"bg-elevated":y?"bg-danger-wash":"hover:bg-elevated",_=c?p.jsx(Nu,{summary:S,chevron:"leading",defaultOpen:u,onOpenChange:m,className:A("@container/toolrow",h),rowClassName:zge,triggerClassName:A("-mx-2 rounded-sm px-2",T),children:c}):p.jsx(Nu,{disabled:!0,summary:S,rowClassName:zge,className:A("@container/toolrow",(v||y)&&A("-mx-2 rounded-sm px-2",T),h)});return f?p.jsxs("div",{className:A("flex flex-col"),children:[_,f]}):_},dJ=e=>{const t=b.useCallback(r=>{const i=window.matchMedia(e);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[e]),n=b.useCallback(()=>window.matchMedia(e).matches,[e]);return b.useSyncExternalStore(t,n,()=>!1)},Wge=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],njt=80,rjt=1e3,ijt=({activity:e,phase:t,startedAt:n,className:r})=>{const[i,s]=b.useState(0),[a,o]=b.useState(()=>n===void 0?0:Math.floor((Date.now()-n)/1e3)),l=dJ("(prefers-reduced-motion: reduce)"),c=b.useRef(n??Date.now()),u=b.useRef(t);return u.current!==t&&(u.current=t,c.current=n??Date.now(),o(0)),b.useEffect(()=>{const d=window.setInterval(()=>o(Math.floor((Date.now()-c.current)/1e3)),rjt);if(l)return s(0),()=>window.clearInterval(d);const h=window.setInterval(()=>s(f=>(f+1)%Wge.length),njt);return()=>{window.clearInterval(h),window.clearInterval(d)}},[l]),p.jsxs("div",{className:A("flex items-center gap-2",r),"data-lo-working-line":!0,"aria-live":"polite",children:[p.jsx("span",{"aria-hidden":!0,className:A("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:Wge[i]}),p.jsx("span",{className:A("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),p.jsx("span",{"aria-hidden":!0,className:A("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:qZ(a)})]})},sjt=/^\s*<reply-to>([\s\S]*?)<\/reply-to>/,hJ=e=>{const t=[];let n=e;for(;;){const r=sjt.exec(n);if(r===null)break;t.push({id:za(),text:r[1]}),n=n.slice(r[0].length)}return{replies:t,remainingContent:n.trim()}},LNe=({children:e,className:t})=>p.jsx("div",{className:A("flex max-w-full items-center justify-center overflow-hidden","min-h-16 min-w-16 rounded-sm border border-hairline bg-sunken",t),children:e}),ajt="could not be displayed. It may have been moved, renamed, or deleted.",fJ="could not be displayed. Its stored copy is not available to this reader.",R_=({name:e,detail:t=ajt,className:n})=>p.jsxs("div",{className:A("flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2",n),children:[p.jsx(vnt,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),p.jsxs("span",{className:"min-w-0 text-body-sm text-ink-muted",children:[p.jsx("span",{className:"truncate font-mono text-ink text-mono-sm",children:e}),` ${t}`]})]}),wN=({filePath:e,tooltip:t="File actions",icon:n,"aria-label":r="File actions",onShowInCanvas:i})=>{const s=async()=>{if(e)try{await navigator.clipboard.writeText(e),ms("File path copied to clipboard")}catch(o){console.error("Failed to copy file path: ",o),Rr("Failed to copy file path")}},a=()=>{e&&window.api.openFile(e)};return p.jsxs(px,{children:[p.jsx(rt,{content:t,children:p.jsx(iv,{asChild:!0,children:p.jsx(we,{variant:"ghost",size:"icon-sm","aria-label":r,onClick:o=>o.stopPropagation(),children:n??p.jsx(B3,{"aria-hidden":"true"})})})}),p.jsxs(Ox,{align:"end",className:"min-w-45",onClick:o=>o.stopPropagation(),children:[i&&p.jsxs($s,{onSelect:i,children:[p.jsx(_nt,{"aria-hidden":"true"}),p.jsx("span",{children:"Show in canvas"})]}),p.jsxs($s,{onSelect:a,children:[p.jsx(vx,{"aria-hidden":"true"}),p.jsx("span",{children:"Open file"})]}),p.jsxs($s,{onSelect:()=>window.api.showItemInFolder(e),children:[p.jsx(hT,{"aria-hidden":"true"}),p.jsx("span",{children:"Open folder"})]}),p.jsxs($s,{onSelect:s,children:[p.jsx(h2e,{"aria-hidden":"true"}),p.jsx("span",{children:"Copy file path"})]})]})]})},I7="max-h-[min(90vh,calc(100vh-104px))] max-w-[min(90vw,calc(100vw-104px))]",pJ=({src:e,label:t,open:n,onOpenChange:r,restoreFocusTo:i,fallback:s})=>{const[a,o]=b.useState(!1);return up(n,"image-lightbox"),p.jsx(jP,{open:n,onOpenChange:r,children:p.jsxs(LP,{showClose:!1,"aria-describedby":void 0,onCloseAutoFocus:l=>{const c=i?.current;c&&(l.preventDefault(),c.focus())},className:A("inset-0 top-0 left-0 m-auto h-fit w-fit translate-none",I7,"gap-0 rounded-none border-0 border-transparent bg-transparent p-0 shadow-none"),children:[p.jsx(I1,{className:"sr-only",children:t}),a?p.jsx("div",{className:A(I7,"flex min-h-16 min-w-64 items-center justify-center p-6"),children:s}):p.jsx("img",{src:e,alt:t,className:A(I7,"object-contain"),onError:()=>o(!0)}),p.jsx(RZe,{asChild:!0,children:p.jsx(we,{variant:"ghost",size:"icon-sm",className:A("fixed top-4 right-4"),"aria-label":"Close image",children:p.jsx(Qi,{"aria-hidden":"true"})})})]})})};pJ.displayName="ImageLightbox";const qNe=1024;let ojt=0,yu=class{constructor(t,n){this.from=t,this.to=n}};class Wn{constructor(t={}){this.id=ojt++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=ha.match(t)),n=>{let r=t(n);return r===void 0?null:[this,r]}}}Wn.closedBy=new Wn({deserialize:e=>e.split(" ")});Wn.openedBy=new Wn({deserialize:e=>e.split(" ")});Wn.group=new Wn({deserialize:e=>e.split(" ")});Wn.isolate=new Wn({deserialize:e=>{if(e&&e!="rtl"&&e!="ltr"&&e!="auto")throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}});Wn.contextHash=new Wn({perNode:!0});Wn.lookAhead=new Wn({perNode:!0});Wn.mounted=new Wn({perNode:!0});class A_{constructor(t,n,r){this.tree=t,this.overlay=n,this.parser=r}static get(t){return t&&t.props&&t.props[Wn.mounted.id]}}const ljt=Object.create(null);class ha{constructor(t,n,r,i=0){this.name=t,this.props=n,this.id=r,this.flags=i}static define(t){let n=t.props&&t.props.length?Object.create(null):ljt,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new ha(t.name||"",n,t.id,r);if(t.props){for(let s of t.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return i}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let n=this.prop(Wn.group);return n?n.indexOf(t)>-1:!1}return this.id==t}static match(t){let n=Object.create(null);for(let r in t)for(let i of r.split(" "))n[i]=t[r];return r=>{for(let i=r.prop(Wn.group),s=-1;s<(i?i.length:0);s++){let a=n[s<0?r.name:i[s]];if(a)return a}}}}ha.none=new ha("",Object.create(null),0,8);class Fx{constructor(t){this.types=t;for(let n=0;n<t.length;n++)if(t[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let n=[];for(let r of this.types){let i=null;for(let s of t){let a=s(r);a&&(i||(i=Object.assign({},r.props)),i[a[0].id]=a[1])}n.push(i?new ha(r.name,i,r.id,r.flags):r)}return new Fx(n)}}const WC=new WeakMap,Gge=new WeakMap;var Pi;(function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"})(Pi||(Pi={}));class $r{constructor(t,n,r,i,s){if(this.type=t,this.children=n,this.positions=r,this.length=i,this.props=null,s&&s.length){this.props=Object.create(null);for(let[a,o]of s)this.props[typeof a=="number"?a:a.id]=o}}toString(){let t=A_.get(this);if(t&&!t.overlay)return t.tree.toString();let n="";for(let r of this.children){let i=r.toString();i&&(n&&(n+=","),n+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(t=0){return new q4(this.topNode,t)}cursorAt(t,n=0,r=0){let i=WC.get(this)||this.topNode,s=new q4(i);return s.moveTo(t,n),WC.set(this,s._tree),s}get topNode(){return new Fo(this,0,0,null)}resolve(t,n=0){let r=D_(WC.get(this)||this.topNode,t,n,!1);return WC.set(this,r),r}resolveInner(t,n=0){let r=D_(Gge.get(this)||this.topNode,t,n,!0);return Gge.set(this,r),r}resolveStack(t,n=0){return djt(this,t,n)}iterate(t){let{enter:n,leave:r,from:i=0,to:s=this.length}=t,a=t.mode||0,o=(a&Pi.IncludeAnonymous)>0;for(let l=this.cursor(a|Pi.IncludeAnonymous);;){let c=!1;if(l.from<=s&&l.to>=i&&(!o&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&r&&(o||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let n in this.props)t.push([+n,this.props[n]]);return t}balance(t={}){return this.children.length<=8?this:mJ(ha.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new $r(this.type,n,r,i,this.propValues),t.makeTree||((n,r,i)=>new $r(ha.none,n,r,i)))}static build(t){return hjt(t)}}$r.empty=new $r(ha.none,[],[],0);class OJ{constructor(t,n){this.buffer=t,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new OJ(this.buffer,this.index)}}class qg{constructor(t,n,r){this.buffer=t,this.length=n,this.set=r}get type(){return ha.none}toString(){let t=[];for(let n=0;n<this.buffer.length;)t.push(this.childString(n)),n=this.buffer[n+3];return t.join(",")}childString(t){let n=this.buffer[t],r=this.buffer[t+3],i=this.set.types[n],s=i.name;if(/\W/.test(s)&&!i.isError&&(s=JSON.stringify(s)),t+=4,r==t)return s;let a=[];for(;t<r;)a.push(this.childString(t)),t=this.buffer[t+3];return s+"("+a.join(",")+")"}findChild(t,n,r,i,s){let{buffer:a}=this,o=-1;for(let l=t;l!=n&&!(zNe(s,i,a[l+1],a[l+2])&&(o=l,r>0));l=a[l+3]);return o}slice(t,n,r){let i=this.buffer,s=new Uint16Array(n-t),a=0;for(let o=t,l=0;o<n;){s[l++]=i[o++],s[l++]=i[o++]-r;let c=s[l++]=i[o++]-r;s[l++]=i[o++]-t,a=Math.max(a,c)}return new qg(s,a,this.set)}}function zNe(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function D_(e,t,n,r){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let a=!r&&e instanceof Fo&&e.index<0?null:e.parent;if(!a)return e;e=a}let s=r?0:Pi.IgnoreOverlays;if(r)for(let a=e,o=a.parent;o;a=o,o=a.parent)a instanceof Fo&&a.index<0&&((i=o.enter(t,n,s))===null||i===void 0?void 0:i.from)!=a.from&&(e=o);for(;;){let a=e.enter(t,n,s);if(!a)return e;e=a}}class UNe{cursor(t=0){return new q4(this,t)}getChild(t,n=null,r=null){let i=Vge(this,t,n,r);return i.length?i[0]:null}getChildren(t,n=null,r=null){return Vge(this,t,n,r)}resolve(t,n=0){return D_(this,t,n,!1)}resolveInner(t,n=0){return D_(this,t,n,!0)}matchContext(t){return bG(this.parent,t)}enterUnfinishedNodesBefore(t){let n=this.childBefore(t),r=this;for(;n;){let i=n.lastChild;if(!i||i.to!=n.to)break;i.type.isError&&i.from==i.to?(r=n,n=i.prevSibling):n=i}return r}get node(){return this}get next(){return this.parent}}class Fo extends UNe{constructor(t,n,r,i){super(),this._tree=t,this.from=n,this.index=r,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,s=0){for(let a=this;;){for(let{children:o,positions:l}=a._tree,c=n>0?o.length:-1;t!=c;t+=n){let u=o[t],d=l[t]+a.from;if(zNe(i,r,d,d+u.length)){if(u instanceof qg){if(s&Pi.ExcludeBuffers)continue;let h=u.findChild(0,u.buffer.length,n,r-d,i);if(h>-1)return new Xh(new cjt(a,u,t,d),null,h)}else if(s&Pi.IncludeAnonymous||!u.type.isAnonymous||gJ(u)){let h;if(!(s&Pi.IgnoreMounts)&&(h=A_.get(u))&&!h.overlay)return new Fo(h.tree,d,t,a);let f=new Fo(u,d,t,a);return s&Pi.IncludeAnonymous||!f.type.isAnonymous?f:f.nextChild(n<0?u.children.length-1:0,n,r,i)}}}if(s&Pi.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?t=a.index+n:t=n<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,n,r=0){let i;if(!(r&Pi.IgnoreOverlays)&&(i=A_.get(this._tree))&&i.overlay){let s=t-this.from;for(let{from:a,to:o}of i.overlay)if((n>0?a<=s:a<s)&&(n<0?o>=s:o>s))return new Fo(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Vge(e,t,n,r){let i=e.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let a=!1;!a;)if(a=i.type.is(n),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(t)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function bG(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}class cjt{constructor(t,n,r,i){this.parent=t,this.buffer=n,this.index=r,this.start=i}}class Xh extends UNe{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,n,r){super(),this.context=t,this._parent=n,this.index=r,this.type=t.buffer.set.types[t.buffer.buffer[r]]}child(t,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return s<0?null:new Xh(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,n,r=0){if(r&Pi.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return s<0?null:new Xh(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new Xh(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Xh(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],n=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let a=r.buffer[this.index+1];t.push(r.slice(i,s,a)),n.push(0)}return new $r(this.type,t,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function WNe(e){if(!e.length)return null;let t=0,n=e[0];for(let s=1;s<e.length;s++){let a=e[s];(a.from>n.from||a.to<n.to)&&(n=a,t=s)}let r=n instanceof Fo&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new ujt(i,n)}class ujt{constructor(t,n){this.heads=t,this.node=n}get next(){return WNe(this.heads)}}function djt(e,t,n){let r=e.resolveInner(t,n),i=null;for(let s=r instanceof Fo?r:r.context.parent;s;s=s.parent)if(s.index<0){let a=s.parent;(i||(i=[r])).push(a.resolve(t,n)),s=a}else{let a=A_.get(s.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new Fo(a.tree,a.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(D_(o,t,n,!1))}}return i?WNe(i):r}class q4{get name(){return this.type.name}constructor(t,n=0){if(this.mode=n,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof Fo)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let r=t._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,n){this.index=t;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[t]],this.from=r+i.buffer[t+1],this.to=r+i.buffer[t+2],!0}yield(t){return t?t instanceof Fo?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.buffer.start,r);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,n,r=this.mode){return this.buffer?r&Pi.ExcludeBuffers?!1:this.enterChild(1,t,n):this.yield(this._tree.enter(t,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pi.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&Pi.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(t<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let n,r,{buffer:i}=this;if(i){if(t>0){if(this.index<i.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(i.buffer.buffer[s+3]<this.index)return!1;({index:n,parent:r}=i)}else({index:n,_parent:r}=this._tree);for(;r;{index:n,_parent:r}=r)if(n>-1)for(let s=n+t,a=t<0?-1:r._tree.children.length;s!=a;s+=t){let o=r._tree.children[s];if(this.mode&Pi.IncludeAnonymous||o instanceof qg||!o.type.isAnonymous||gJ(o))return!1}return!0}move(t,n){if(n&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,n=0){for(;(this.from==this.to||(n<1?this.from>=t:this.from>t)||(n>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,n););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,n=null,r=0;if(t&&t.context==this.buffer)e:for(let i=this.index,s=this.stack.length;s>=0;){for(let a=t;a;a=a._parent)if(a.index==i){if(i==this.index)return a;n=a,r=s+1;break e}i=this.stack[--s]}for(let i=r;i<this.stack.length;i++)n=new Xh(this.buffer,n,this.stack[i]);return this.bufferNode=new Xh(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,n){for(let r=0;;){let i=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&n&&n(this),i=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,i=!0}}}matchContext(t){if(!this.buffer)return bG(this.node.parent,t);let{buffer:n}=this.buffer,{types:r}=n.set;for(let i=t.length-1,s=this.stack.length-1;i>=0;s--){if(s<0)return bG(this._tree,t,i);let a=r[n.buffer[this.stack[s]]];if(!a.isAnonymous){if(t[i]&&t[i]!=a.name)return!1;i--}}return!0}}function gJ(e){return e.children.some(t=>t instanceof qg||!t.type.isAnonymous||gJ(t))}function hjt(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=qNe,reused:s=[],minRepeatType:a=r.types.length}=e,o=Array.isArray(n)?new OJ(n,n.length):n,l=r.types,c=0,u=0;function d(x,S,T,_,P,E){let{id:C,start:Q,end:D,size:F}=o,I=u,U=c;for(;F<0;)if(o.next(),F==-1){let J=s[C];T.push(J),_.push(Q-x);return}else if(F==-3){c=C;return}else if(F==-4){u=C;return}else throw new RangeError(`Unrecognized record size: ${F}`);let q=l[C],Z,W,M=Q-x;if(D-Q<=i&&(W=m(o.pos-S,P))){let J=new Uint16Array(W.size-W.skip),L=o.pos-W.size,N=J.length;for(;o.pos>L;)N=v(W.start,J,N);Z=new qg(J,D-W.start,r),M=W.start-x}else{let J=o.pos-F;o.next();let L=[],N=[],z=C>=a?C:-1,V=0,ee=D;for(;o.pos>J;)z>=0&&o.id==z&&o.size>=0?(o.end<=ee-i&&(O(L,N,Q,V,o.end,ee,z,I,U),V=L.length,ee=o.end),o.next()):E>2500?h(Q,J,L,N):d(Q,J,L,N,z,E+1);if(z>=0&&V>0&&V<L.length&&O(L,N,Q,V,Q,ee,z,I,U),L.reverse(),N.reverse(),z>-1&&V>0){let oe=f(q,U);Z=mJ(q,L,N,0,L.length,0,D-Q,oe,oe)}else Z=g(q,L,N,D-Q,I-D,U)}T.push(Z),_.push(M)}function h(x,S,T,_){let P=[],E=0,C=-1;for(;o.pos>S;){let{id:Q,start:D,end:F,size:I}=o;if(I>4)o.next();else{if(C>-1&&D<C)break;C<0&&(C=F-i),P.push(Q,D,F),E++,o.next()}}if(E){let Q=new Uint16Array(E*4),D=P[P.length-2];for(let F=P.length-3,I=0;F>=0;F-=3)Q[I++]=P[F],Q[I++]=P[F+1]-D,Q[I++]=P[F+2]-D,Q[I++]=I;T.push(new qg(Q,P[2]-D,r)),_.push(D-x)}}function f(x,S){return(T,_,P)=>{let E=0,C=T.length-1,Q,D;if(C>=0&&(Q=T[C])instanceof $r){if(!C&&Q.type==x&&Q.length==P)return Q;(D=Q.prop(Wn.lookAhead))&&(E=_[C]+Q.length+D)}return g(x,T,_,P,E,S)}}function O(x,S,T,_,P,E,C,Q,D){let F=[],I=[];for(;x.length>_;)F.push(x.pop()),I.push(S.pop()+T-P);x.push(g(r.types[C],F,I,E-P,Q-E,D)),S.push(P-T)}function g(x,S,T,_,P,E,C){if(E){let Q=[Wn.contextHash,E];C=C?[Q].concat(C):[Q]}if(P>25){let Q=[Wn.lookAhead,P];C=C?[Q].concat(C):[Q]}return new $r(x,S,T,_,C)}function m(x,S){let T=o.fork(),_=0,P=0,E=0,C=T.end-i,Q={size:0,start:0,skip:0};e:for(let D=T.pos-x;T.pos>D;){let F=T.size;if(T.id==S&&F>=0){Q.size=_,Q.start=P,Q.skip=E,E+=4,_+=4,T.next();continue}let I=T.pos-F;if(F<0||I<D||T.start<C)break;let U=T.id>=a?4:0,q=T.start;for(T.next();T.pos>I;){if(T.size<0)if(T.size==-3)U+=4;else break e;else T.id>=a&&(U+=4);T.next()}P=q,_+=F,E+=U}return(S<0||_==x)&&(Q.size=_,Q.start=P,Q.skip=E),Q.size>4?Q:void 0}function v(x,S,T){let{id:_,start:P,end:E,size:C}=o;if(o.next(),C>=0&&_<a){let Q=T;if(C>4){let D=o.pos-(C-4);for(;o.pos>D;)T=v(x,S,T)}S[--T]=Q,S[--T]=E-x,S[--T]=P-x,S[--T]=_}else C==-3?c=_:C==-4&&(u=_);return T}let y=[],w=[];for(;o.pos>0;)d(e.start||0,e.bufferStart||0,y,w,-1,0);let k=(t=e.length)!==null&&t!==void 0?t:y.length?w[0]+y[0].length:0;return new $r(l[e.topID],y.reverse(),w.reverse(),k)}const Bge=new WeakMap;function JQ(e,t){if(!e.isAnonymous||t instanceof qg||t.type!=e)return 1;let n=Bge.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof $r)){n=1;break}n+=JQ(e,r)}Bge.set(t,n)}return n}function mJ(e,t,n,r,i,s,a,o,l){let c=0;for(let O=r;O<i;O++)c+=JQ(e,t[O]);let u=Math.ceil(c*1.5/8),d=[],h=[];function f(O,g,m,v,y){for(let w=m;w<v;){let k=w,x=g[w],S=JQ(e,O[w]);for(w++;w<v;w++){let T=JQ(e,O[w]);if(S+T>=u)break;S+=T}if(w==k+1){if(S>u){let T=O[k];f(T.children,T.positions,0,T.children.length,g[k]+y);continue}d.push(O[k])}else{let T=g[w-1]+O[w-1].length-x;d.push(mJ(e,O,g,k,w,x,T,null,l))}h.push(x+y-s)}}return f(t,n,r,i,0),(o||l)(d,h,a)}class vJ{constructor(){this.map=new WeakMap}setBuffer(t,n,r){let i=this.map.get(t);i||this.map.set(t,i=new Map),i.set(n,r)}getBuffer(t,n){let r=this.map.get(t);return r&&r.get(n)}set(t,n){t instanceof Xh?this.setBuffer(t.context.buffer,t.index,n):t instanceof Fo&&this.map.set(t.tree,n)}get(t){return t instanceof Xh?this.getBuffer(t.context.buffer,t.index):t instanceof Fo?this.map.get(t.tree):void 0}cursorSet(t,n){t.buffer?this.setBuffer(t.buffer.buffer,t.index,n):this.map.set(t.tree,n)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class kp{constructor(t,n,r,i,s=!1,a=!1){this.from=t,this.to=n,this.tree=r,this.offset=i,this.open=(s?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new kp(0,t.length,t,0,!1,r)];for(let s of n)s.to>t.length&&i.push(s);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],s=1,a=t.length?t[0]:null;for(let o=0,l=0,c=0;;o++){let u=o<n.length?n[o]:null,d=u?u.fromA:1e9;if(d-l>=r)for(;a&&a.from<d;){let h=a;if(l>=h.from||d<=h.to||c){let f=Math.max(h.from,l)-c,O=Math.min(h.to,d)-c;h=f>=O?null:new kp(f,O,h.tree,h.offset+c,o>0,!!u)}if(h&&i.push(h),a.to>d)break;a=s<t.length?t[s++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return i}}let xN=class{startParse(t,n,r){return typeof t=="string"&&(t=new fjt(t)),r=r?r.length?r.map(i=>new yu(i.from,i.to)):[new yu(0,0)]:[new yu(0,t.length)],this.createParse(t,n||[],r)}parse(t,n,r){let i=this.startParse(t,n,r);for(;;){let s=i.advance();if(s)return s}}};class fjt{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,n){return this.string.slice(t,n)}}function zu(e){return(t,n,r,i)=>new Ojt(t,e,n,r,i)}class Yge{constructor(t,n,r,i,s){this.parser=t,this.parse=n,this.overlay=r,this.target=i,this.from=s}}function Zge(e){if(!e.length||e.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(e))}class pjt{constructor(t,n,r,i,s,a,o){this.parser=t,this.predicate=n,this.mounts=r,this.index=i,this.start=s,this.target=a,this.prev=o,this.depth=0,this.ranges=[]}}const wG=new Wn({perNode:!0});class Ojt{constructor(t,n,r,i,s){this.nest=n,this.input=r,this.fragments=i,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let r=this.baseParse.advance();if(!r)return null;if(this.baseParse=null,this.baseTree=r,this.startInner(),this.stoppedAt!=null)for(let i of this.inner)i.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let r=this.baseTree;return this.stoppedAt!=null&&(r=new $r(r.type,r.children,r.positions,r.length,r.propValues.concat([[wG,this.stoppedAt]]))),r}let t=this.inner[this.innerDone],n=t.parse.advance();if(n){this.innerDone++;let r=Object.assign(Object.create(null),t.target.props);r[Wn.mounted.id]=new A_(n,t.overlay,t.parser),t.target.props=r}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let n=this.innerDone;n<this.inner.length;n++)this.inner[n].from<t&&(t=Math.min(t,this.inner[n].parse.parsedPos));return t}stopAt(t){if(this.stoppedAt=t,this.baseParse)this.baseParse.stopAt(t);else for(let n=this.innerDone;n<this.inner.length;n++)this.inner[n].parse.stopAt(t)}startInner(){let t=new vjt(this.fragments),n=null,r=null,i=new q4(new Fo(this.baseTree,this.ranges[0].from,0,null),Pi.IncludeAnonymous|Pi.IgnoreMounts);e:for(let s,a;;){let o=!0,l;if(this.stoppedAt!=null&&i.from>=this.stoppedAt)o=!1;else if(t.hasNode(i)){if(n){let c=n.mounts.find(u=>u.frag.from<=i.from&&u.frag.to>=i.to&&u.mount.overlay);if(c)for(let u of c.mount.overlay){let d=u.from+c.pos,h=u.to+c.pos;d>=i.from&&h<=i.to&&!n.ranges.some(f=>f.from<h&&f.to>d)&&n.ranges.push({from:d,to:h})}}o=!1}else if(r&&(a=gjt(r.ranges,i.from,i.to)))o=a!=2;else if(!i.type.isAnonymous&&(s=this.nest(i,this.input))&&(i.from<i.to||!s.overlay)){i.tree||mjt(i);let c=t.findMounts(i.from,s.parser);if(typeof s.overlay=="function")n=new pjt(s.parser,s.overlay,c,this.inner.length,i.from,i.tree,n);else{let u=Jge(this.ranges,s.overlay||(i.from<i.to?[new yu(i.from,i.to)]:[]));u.length&&Zge(u),(u.length||!s.overlay)&&this.inner.push(new Yge(s.parser,u.length?s.parser.startParse(this.input,eme(c,u),u):s.parser.startParse(""),s.overlay?s.overlay.map(d=>new yu(d.from-i.from,d.to-i.from)):null,i.tree,u.length?u[0].from:i.from)),s.overlay?u.length&&(r={ranges:u,depth:0,prev:r}):o=!1}}else if(n&&(l=n.predicate(i))&&(l===!0&&(l=new yu(i.from,i.to)),l.from<l.to)){let c=n.ranges.length-1;c>=0&&n.ranges[c].to==l.from?n.ranges[c]={from:n.ranges[c].from,to:l.to}:n.ranges.push(l)}if(o&&i.firstChild())n&&n.depth++,r&&r.depth++;else for(;!i.nextSibling();){if(!i.parent())break e;if(n&&!--n.depth){let c=Jge(this.ranges,n.ranges);c.length&&(Zge(c),this.inner.splice(n.index,0,new Yge(n.parser,n.parser.startParse(this.input,eme(n.mounts,c),c),n.ranges.map(u=>new yu(u.from-n.start,u.to-n.start)),n.target,c[0].from))),n=n.prev}r&&!--r.depth&&(r=r.prev)}}}}function gjt(e,t,n){for(let r of e){if(r.from>=n)break;if(r.to>t)return r.from<=t&&r.to>=n?2:1}return 0}function Hge(e,t,n,r,i,s){if(t<n){let a=e.buffer[t+1];r.push(e.slice(t,n,a)),i.push(a-s)}}function mjt(e){let{node:t}=e,n=[],r=t.context.buffer;do n.push(e.index),e.parent();while(!e.tree);let i=e.tree,s=i.children.indexOf(r),a=i.children[s],o=a.buffer,l=[s];function c(u,d,h,f,O,g){let m=n[g],v=[],y=[];Hge(a,u,m,v,y,f);let w=o[m+1],k=o[m+2];l.push(v.length);let x=g?c(m+4,o[m+3],a.set.types[o[m]],w,k-w,g-1):t.toTree();return v.push(x),y.push(w-f),Hge(a,o[m+3],d,v,y,f),new $r(h,v,y,O)}i.children[s]=c(0,o.length,ha.none,0,a.length,n.length-1);for(let u of l){let d=e.tree.children[u],h=e.tree.positions[u];e.yield(new Fo(d,h+e.from,u,e._tree))}}class Kge{constructor(t,n){this.offset=n,this.done=!1,this.cursor=t.cursor(Pi.IncludeAnonymous|Pi.IgnoreMounts)}moveTo(t){let{cursor:n}=this,r=t-this.offset;for(;!this.done&&n.from<r;)n.to>=t&&n.enter(r,1,Pi.IgnoreOverlays|Pi.ExcludeBuffers)||n.next(!1)||(this.done=!0)}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let n=this.cursor.tree;;){if(n==t.tree)return!0;if(n.children.length&&n.positions[0]==0&&n.children[0]instanceof $r)n=n.children[0];else break}return!1}}let vjt=class{constructor(t){var n;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let r=this.curFrag=t[0];this.curTo=(n=r.tree.prop(wG))!==null&&n!==void 0?n:r.to,this.inner=new Kge(r.tree,-r.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let n=this.curFrag=this.fragments[this.fragI];this.curTo=(t=n.tree.prop(wG))!==null&&t!==void 0?t:n.to,this.inner=new Kge(n.tree,-n.offset)}}findMounts(t,n){var r;let i=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let s=this.inner.cursor.node;s;s=s.parent){let a=(r=s.tree)===null||r===void 0?void 0:r.prop(Wn.mounted);if(a&&a.parser==n)for(let o=this.fragI;o<this.fragments.length;o++){let l=this.fragments[o];if(l.from>=s.to)break;l.tree==this.curFrag.tree&&i.push({frag:l,pos:s.from-l.offset,mount:a})}}}return i}};function Jge(e,t){let n=null,r=t;for(let i=1,s=0;i<e.length;i++){let a=e[i-1].to,o=e[i].from;for(;s<r.length;s++){let l=r[s];if(l.from>=o)break;l.to<=a||(n||(r=n=t.slice()),l.from<a?(n[s]=new yu(l.from,a),l.to>o&&n.splice(s+1,0,new yu(o,l.to))):l.to>o?n[s--]=new yu(o,l.to):n.splice(s--,1))}}return r}function yjt(e,t,n,r){let i=0,s=0,a=!1,o=!1,l=-1e9,c=[];for(;;){let u=i==e.length?1e9:a?e[i].to:e[i].from,d=s==t.length?1e9:o?t[s].to:t[s].from;if(a!=o){let h=Math.max(l,n),f=Math.min(u,d,r);h<f&&c.push(new yu(h,f))}if(l=Math.min(u,d),l==1e9)break;u==l&&(a?(a=!1,i++):a=!0),d==l&&(o?(o=!1,s++):o=!0)}return c}function eme(e,t){let n=[];for(let{pos:r,mount:i,frag:s}of e){let a=r+(i.overlay?i.overlay[0].from:0),o=a+i.tree.length,l=Math.max(s.from,a),c=Math.min(s.to,o);if(i.overlay){let u=i.overlay.map(h=>new yu(h.from+r,h.to+r)),d=yjt(t,u,l,c);for(let h=0,f=l;;h++){let O=h==d.length,g=O?c:d[h].from;if(g>f&&n.push(new kp(f,g,i.tree,-a,s.from>=f||s.openStart,s.to<=g||s.openEnd)),O)break;f=d[h].to}}else n.push(new kp(l,c,i.tree,-a,s.from>=a||s.openStart,s.to<=o||s.openEnd))}return n}let xG=[],GNe=[];(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?GNe:xG).push(n=n+e[t])})();function bjt(e){if(e<768)return!1;for(let t=0,n=xG.length;;){let r=t+n>>1;if(e<xG[r])n=r;else if(e>=GNe[r])t=r+1;else return!0;if(t==n)return!1}}function tme(e){return e>=127462&&e<=127487}const nme=8205;function wjt(e,t,n=!0,r=!0){return(n?VNe:xjt)(e,t,r)}function VNe(e,t,n){if(t==e.length)return t;t&&BNe(e.charCodeAt(t))&&YNe(e.charCodeAt(t-1))&&t--;let r=F7(e,t);for(t+=rme(r);t<e.length;){let i=F7(e,t);if(r==nme||i==nme||n&&bjt(i))t+=rme(i),r=i;else if(tme(i)){let s=0,a=t-2;for(;a>=0&&tme(F7(e,a));)s++,a-=2;if(s%2==0)break;t+=2}else break}return t}function xjt(e,t,n){for(;t>0;){let r=VNe(e,t-2,n);if(r<t)return r;t--}return 0}function F7(e,t){let n=e.charCodeAt(t);if(!YNe(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return BNe(r)?(n-55296<<10)+(r-56320)+65536:n}function BNe(e){return e>=56320&&e<57344}function YNe(e){return e>=55296&&e<56320}function rme(e){return e<65536?1:2}let Vr=class ZNe{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,n,r){[t,n]=Nw(this,t,n);let i=[];return this.decompose(0,t,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),Th.from(i,this.length-(n-t)+r.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,n=this.length){[t,n]=Nw(this,t,n);let r=[];return this.decompose(t,n,r,0),Th.from(r,n-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let n=this.scanIdentical(t,1),r=this.length-this.scanIdentical(t,-1),i=new gk(this),s=new gk(t);for(let a=n,o=n;;){if(i.next(a),s.next(a),a=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(o+=i.value.length,i.done||o>=r)return!0}}iter(t=1){return new gk(this,t)}iterRange(t,n=this.length){return new HNe(this,t,n)}iterLines(t,n){let r;if(t==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(t).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new KNe(r)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?ZNe.empty:t.length<=32?new Xs(t):Th.from(Xs.split(t,[]))}};class Xs extends Vr{constructor(t,n=Sjt(t)){super(),this.text=t,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(t,n,r,i){for(let s=0;;s++){let a=this.text[s],o=i+a.length;if((n?r:o)>=t)return new $jt(i,o,r,a);i=o+1,r++}}decompose(t,n,r,i){let s=t<=0&&n>=this.length?this:new Xs(ime(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let a=r.pop(),o=eR(s.text,a.text.slice(),0,s.length);if(o.length<=32)r.push(new Xs(o,a.length+s.length));else{let l=o.length>>1;r.push(new Xs(o.slice(0,l)),new Xs(o.slice(l)))}}else r.push(s)}replace(t,n,r){if(!(r instanceof Xs))return super.replace(t,n,r);[t,n]=Nw(this,t,n);let i=eR(this.text,eR(r.text,ime(this.text,0,t)),n),s=this.length+r.length-(n-t);return i.length<=32?new Xs(i,s):Th.from(Xs.split(i,[]),s)}sliceString(t,n=this.length,r=`
1192
1192
  `){[t,n]=Nw(this,t,n);let i="";for(let s=0,a=0;s<=n&&a<this.text.length;a++){let o=this.text[a],l=s+o.length;s>t&&a&&(i+=r),t<l&&n>s&&(i+=o.slice(Math.max(0,t-s),n-s)),s=l+1}return i}flatten(t){for(let n of this.text)t.push(n)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let s of t)r.push(s),i+=s.length+1,r.length==32&&(n.push(new Xs(r,i)),r=[],i=-1);return i>-1&&n.push(new Xs(r,i)),n}}class Th extends Vr{constructor(t,n){super(),this.children=t,this.length=n,this.lines=0;for(let r of t)this.lines+=r.lines}lineInner(t,n,r,i){for(let s=0;;s++){let a=this.children[s],o=i+a.length,l=r+a.lines-1;if((n?l:o)>=t)return a.lineInner(t,n,r,i);i=o+1,r=l+1}}decompose(t,n,r,i){for(let s=0,a=0;a<=n&&s<this.children.length;s++){let o=this.children[s],l=a+o.length;if(t<=l&&n>=a){let c=i&((a<=t?1:0)|(l>=n?2:0));a>=t&&l<=n&&!c?r.push(o):o.decompose(t-a,n-a,r,c)}a=l+1}}replace(t,n,r){if([t,n]=Nw(this,t,n),r.lines<this.lines)for(let i=0,s=0;i<this.children.length;i++){let a=this.children[i],o=s+a.length;if(t>=s&&n<=o){let l=a.replace(t-s,n-s,r),c=this.lines-a.lines+l.lines;if(l.lines<c>>4&&l.lines>c>>6){let u=this.children.slice();return u[i]=l,new Th(u,this.length-(n-t)+r.length)}return super.replace(s,o,l)}s=o+1}return super.replace(t,n,r)}sliceString(t,n=this.length,r=`
1193
1193
  `){[t,n]=Nw(this,t,n);let i="";for(let s=0,a=0;s<this.children.length&&a<=n;s++){let o=this.children[s],l=a+o.length;a>t&&s&&(i+=r),t<l&&n>a&&(i+=o.sliceString(t-a,n-a,r)),a=l+1}return i}flatten(t){for(let n of this.children)n.flatten(t)}scanIdentical(t,n){if(!(t instanceof Th))return 0;let r=0,[i,s,a,o]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,s+=n){if(i==a||s==o)return r;let l=this.children[i],c=t.children[s];if(l!=c)return r+l.scanIdentical(c,n);r+=l.length+1}}static from(t,n=t.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let f of t)r+=f.lines;if(r<32){let f=[];for(let O of t)O.flatten(f);return new Xs(f,n)}let i=Math.max(32,r>>5),s=i<<1,a=i>>1,o=[],l=0,c=-1,u=[];function d(f){let O;if(f.lines>s&&f instanceof Th)for(let g of f.children)d(g);else f.lines>a&&(l>a||!l)?(h(),o.push(f)):f instanceof Xs&&l&&(O=u[u.length-1])instanceof Xs&&f.lines+O.lines<=32?(l+=f.lines,c+=f.length+1,u[u.length-1]=new Xs(O.text.concat(f.text),O.length+1+f.length)):(l+f.lines>i&&h(),l+=f.lines,c+=f.length+1,u.push(f))}function h(){l!=0&&(o.push(u.length==1?u[0]:Th.from(u,c)),c=-1,l=u.length=0)}for(let f of t)d(f);return h(),o.length==1?o[0]:new Th(o,n)}}Vr.empty=new Xs([""],0);function Sjt(e){let t=-1;for(let n of e)t+=n.length+1;return t}function eR(e,t,n=0,r=1e9){for(let i=0,s=0,a=!0;s<e.length&&i<=r;s++){let o=e[s],l=i+o.length;l>=n&&(l>r&&(o=o.slice(0,r-i)),i<n&&(o=o.slice(n-i)),a?(t[t.length-1]+=o,a=!1):t.push(o)),i=l+1}return t}function ime(e,t,n){return eR(e,[""],t,n)}class gk{constructor(t,n=1){this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[n>0?1:(t instanceof Xs?t.text.length:t.children.length)<<1]}nextInner(t,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],s=this.offsets[r],a=s>>1,o=i instanceof Xs?i.text.length:i.children.length;if(a==(n>0?o:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[r]+=n,t==0)return this.lineBreak=!0,this.value=`
1194
1194
  `,this;t--}else if(i instanceof Xs){let l=i.text[a+(n<0?-1:0)];if(this.offsets[r]+=n,l.length>Math.max(0,t))return this.value=t==0?l:n>0?l.slice(t):l.slice(0,l.length-t),this;t-=l.length}else{let l=i.children[a+(n<0?-1:0)];t>l.length?(t-=l.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(l),this.offsets.push(n>0?1:(l instanceof Xs?l.text.length:l.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class HNe{constructor(t,n,r){this.value="",this.done=!1,this.cursor=new gk(t,n>r?-1:1),this.pos=n>r?t.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(t,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;t>r&&(t=r),r-=t;let{value:i}=this.cursor.next(t);return this.pos+=(i.length+t)*n,this.value=i.length<=r?i:n<0?i.slice(i.length-r):i.slice(0,r),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class KNe{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:n,lineBreak:r,value:i}=this.inner.next(t);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Vr.prototype[Symbol.iterator]=function(){return this.iter()},gk.prototype[Symbol.iterator]=HNe.prototype[Symbol.iterator]=KNe.prototype[Symbol.iterator]=function(){return this});let $jt=class{constructor(t,n,r,i){this.from=t,this.to=n,this.number=r,this.text=i}get length(){return this.to-this.from}};function Nw(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function uo(e,t,n=!0,r=!0){return wjt(e,t,n,r)}function kjt(e){return e>=56320&&e<57344}function Tjt(e){return e>=55296&&e<56320}function Cl(e,t){let n=e.charCodeAt(t);if(!Tjt(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return kjt(r)?(n-55296<<10)+(r-56320)+65536:n}function yJ(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function _h(e){return e<65536?1:2}const SG=/\r\n?|\n/;var oo=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(oo||(oo={}));class Yh{constructor(t){this.sections=t}get length(){let t=0;for(let n=0;n<this.sections.length;n+=2)t+=this.sections[n];return t}get newLength(){let t=0;for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n+1];t+=r<0?this.sections[n]:r}return t}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(t){for(let n=0,r=0,i=0;n<this.sections.length;){let s=this.sections[n++],a=this.sections[n++];a<0?(t(r,i,s),i+=s):i+=a,r+=s}}iterChangedRanges(t,n=!1){$G(this,t,n)}get invertedDesc(){let t=[];for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];i<0?t.push(r,i):t.push(i,r)}return new Yh(t)}composeDesc(t){return this.empty?t:t.empty?this:JNe(this,t)}mapDesc(t,n=!1){return t.empty?this:kG(this,t,n)}mapPos(t,n=-1,r=oo.Simple){let i=0,s=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],l=this.sections[a++],c=i+o;if(l<0){if(c>t)return s+(t-i);s+=o}else{if(r!=oo.Simple&&c>=t&&(r==oo.TrackDel&&i<t&&c>t||r==oo.TrackBefore&&i<t||r==oo.TrackAfter&&c>t))return null;if(c>t||c==t&&n<0&&!o)return t==i||n<0?s:s+l;s+=l}i=c}if(t>i)throw new RangeError(`Position ${t} is out of range for changeset of length ${i}`);return s}touchesRange(t,n=t){for(let r=0,i=0;r<this.sections.length&&i<=n;){let s=this.sections[r++],a=this.sections[r++],o=i+s;if(a>=0&&i<=n&&o>=t)return i<t&&o>n?"cover":!0;i=o}return!1}toString(){let t="";for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];t+=(t?" ":"")+r+(i>=0?":"+i:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Yh(t)}static create(t){return new Yh(t)}}class ma extends Yh{constructor(t,n){super(t),this.inserted=n}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return $G(this,(n,r,i,s,a)=>t=t.replace(i,i+(r-n),a),!1),t}mapDesc(t,n=!1){return kG(this,t,n,!0)}invert(t){let n=this.sections.slice(),r=[];for(let i=0,s=0;i<n.length;i+=2){let a=n[i],o=n[i+1];if(o>=0){n[i]=o,n[i+1]=a;let l=i>>1;for(;r.length<l;)r.push(Vr.empty);r.push(a?t.slice(s,s+a):Vr.empty)}s+=a}return new ma(n,r)}compose(t){return this.empty?t:t.empty?this:JNe(this,t,!0)}map(t,n=!1){return t.empty?this:kG(this,t,n,!0)}iterChanges(t,n=!1){$G(this,t,n)}get desc(){return Yh.create(this.sections)}filter(t){let n=[],r=[],i=[],s=new N_(this);e:for(let a=0,o=0;;){let l=a==t.length?1e9:t[a++];for(;o<l||o==l&&s.len==0;){if(s.done)break e;let u=Math.min(s.len,l-o);Po(i,u,-1);let d=s.ins==-1?-1:s.off==0?s.ins:0;Po(n,u,d),d>0&&cg(r,n,s.text),s.forward(u),o+=u}let c=t[a++];for(;o<c;){if(s.done)break e;let u=Math.min(s.len,c-o);Po(n,u,-1),Po(i,u,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(u),o+=u}}return{changes:new ma(n,r),filtered:Yh.create(i)}}toJSON(){let t=[];for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n],i=this.sections[n+1];i<0?t.push(r):i==0?t.push([r]):t.push([r].concat(this.inserted[n>>1].toJSON()))}return t}static of(t,n,r){let i=[],s=[],a=0,o=null;function l(u=!1){if(!u&&!i.length)return;a<n&&Po(i,n-a,-1);let d=new ma(i,s);o=o?o.compose(d.map(o)):d,i=[],s=[],a=0}function c(u){if(Array.isArray(u))for(let d of u)c(d);else if(u instanceof ma){if(u.length!=n)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${n})`);l(),o=o?o.compose(u.map(o)):u}else{let{from:d,to:h=d,insert:f}=u;if(d>h||d<0||h>n)throw new RangeError(`Invalid change range ${d} to ${h} (in doc of length ${n})`);let O=f?typeof f=="string"?Vr.of(f.split(r||SG)):f:Vr.empty,g=O.length;if(d==h&&g==0)return;d<a&&l(),d>a&&Po(i,d-a,-1),Po(i,h-d,g),cg(s,i,O),a=h}}return c(t),l(!o),o}static empty(t){return new ma(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;i<t.length;i++){let s=t[i];if(typeof s=="number")n.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((a,o)=>o&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;r.length<i;)r.push(Vr.empty);r[i]=Vr.of(s.slice(1)),n.push(s[0],r[i].length)}}}return new ma(n,r)}static createSet(t,n){return new ma(t,n)}}function Po(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function cg(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(Vr.empty);e.push(n)}}function $G(e,t,n){let r=e.inserted;for(let i=0,s=0,a=0;a<e.sections.length;){let o=e.sections[a++],l=e.sections[a++];if(l<0)i+=o,s+=o;else{let c=i,u=s,d=Vr.empty;for(;c+=o,u+=l,l&&r&&(d=d.append(r[a-2>>1])),!(n||a==e.sections.length||e.sections[a+1]<0);)o=e.sections[a++],l=e.sections[a++];t(i,c,s,u,d),i=c,s=u}}}function kG(e,t,n,r=!1){let i=[],s=r?[]:null,a=new N_(e),o=new N_(t);for(let l=-1;;){if(a.done&&o.len||o.done&&a.len)throw new Error("Mismatched change set lengths");if(a.ins==-1&&o.ins==-1){let c=Math.min(a.len,o.len);Po(i,c,-1),a.forward(c),o.forward(c)}else if(o.ins>=0&&(a.ins<0||l==a.i||a.off==0&&(o.len<a.len||o.len==a.len&&!n))){let c=o.len;for(Po(i,o.ins,-1);c;){let u=Math.min(a.len,c);a.ins>=0&&l<a.i&&a.len<=u&&(Po(i,0,a.ins),s&&cg(s,i,a.text),l=a.i),a.forward(u),c-=u}o.next()}else if(a.ins>=0){let c=0,u=a.len;for(;u;)if(o.ins==-1){let d=Math.min(u,o.len);c+=d,u-=d,o.forward(d)}else if(o.ins==0&&o.len<u)u-=o.len,o.next();else break;Po(i,c,l<a.i?a.ins:0),s&&l<a.i&&cg(s,i,a.text),l=a.i,a.forward(a.len-u)}else{if(a.done&&o.done)return s?ma.createSet(i,s):Yh.create(i);throw new Error("Mismatched change set lengths")}}}function JNe(e,t,n=!1){let r=[],i=n?[]:null,s=new N_(e),a=new N_(t);for(let o=!1;;){if(s.done&&a.done)return i?ma.createSet(r,i):Yh.create(r);if(s.ins==0)Po(r,s.len,0,o),s.next();else if(a.len==0&&!a.done)Po(r,0,a.ins,o),i&&cg(i,r,a.text),a.next();else{if(s.done||a.done)throw new Error("Mismatched change set lengths");{let l=Math.min(s.len2,a.len),c=r.length;if(s.ins==-1){let u=a.ins==-1?-1:a.off?0:a.ins;Po(r,l,u,o),i&&u&&cg(i,r,a.text)}else a.ins==-1?(Po(r,s.off?0:s.len,l,o),i&&cg(i,r,s.textBit(l))):(Po(r,s.off?0:s.len,a.off?0:a.ins,o),i&&!a.off&&cg(i,r,a.text));o=(s.ins>l||a.ins>=0&&a.len>l)&&(o||r.length>c),s.forward2(l),a.forward(l)}}}}class N_{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length?Vr.empty:t[n]}textBit(t){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!t?Vr.empty:n[r].slice(this.off,t==null?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){this.ins==-1?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class T0{constructor(t,n,r){this.from=t,this.to=n,this.flags=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let t=this.flags&7;return t==7?null:t}get goalColumn(){let t=this.flags>>6;return t==16777215?void 0:t}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new T0(r,i,this.flags)}extend(t,n=t){if(t<=this.anchor&&n>=this.anchor)return He.range(t,n);let r=Math.abs(t-this.anchor)>Math.abs(n-this.anchor)?t:n;return He.range(this.anchor,r)}eq(t,n=!1){return this.anchor==t.anchor&&this.head==t.head&&(!n||!this.empty||this.assoc==t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return He.range(t.anchor,t.head)}static create(t,n,r){return new T0(t,n,r)}}class He{constructor(t,n){this.ranges=t,this.mainIndex=n}map(t,n=-1){return t.empty?this:He.create(this.ranges.map(r=>r.map(t,n)),this.mainIndex)}eq(t,n=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let r=0;r<this.ranges.length;r++)if(!this.ranges[r].eq(t.ranges[r],n))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new He([this.main],0)}addRange(t,n=!0){return He.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,He.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!="number"||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new He(t.ranges.map(n=>T0.fromJSON(n)),t.main)}static single(t,n=t){return new He([He.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;i<t.length;i++){let s=t[i];if(s.empty?s.from<=r:s.from<r)return He.normalized(t.slice(),n);r=s.to}return new He(t,n)}static cursor(t,n=0,r,i){return T0.create(t,t,(n==0?0:n<0?8:16)|(r==null?7:Math.min(6,r))|(i??16777215)<<6)}static range(t,n,r,i){let s=(r??16777215)<<6|(i==null?7:Math.min(6,i));return n<t?T0.create(n,t,48|s):T0.create(t,n,(n>t?8:0)|s)}static normalized(t,n=0){let r=t[n];t.sort((i,s)=>i.from-s.from),n=t.indexOf(r);for(let i=1;i<t.length;i++){let s=t[i],a=t[i-1];if(s.empty?s.from<=a.to:s.from<a.to){let o=a.from,l=Math.max(s.to,a.to);i<=n&&n--,t.splice(--i,2,s.anchor>s.head?He.range(l,o):He.range(o,l))}}return new He(t,n)}}function eXe(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let bJ=0;class Jt{constructor(t,n,r,i,s){this.combine=t,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=bJ++,this.default=t([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(t={}){return new Jt(t.combine||(n=>n),t.compareInput||((n,r)=>n===r),t.compare||(t.combine?(n,r)=>n===r:wJ),!!t.static,t.enables)}of(t){return new tR([],this,0,t)}compute(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new tR(t,this,1,n)}computeN(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new tR(t,this,2,n)}from(t,n){return n||(n=r=>r),this.compute([t],r=>n(r.field(t)))}}function wJ(e,t){return e==t||e.length==t.length&&e.every((n,r)=>n===t[r])}class tR{constructor(t,n,r,i){this.dependencies=t,this.facet=n,this.type=r,this.value=i,this.id=bJ++}dynamicSlot(t){var n;let r=this.value,i=this.facet.compareInput,s=this.id,a=t[s]>>1,o=this.type==2,l=!1,c=!1,u=[];for(let d of this.dependencies)d=="doc"?l=!0:d=="selection"?c=!0:(((n=t[d.id])!==null&&n!==void 0?n:1)&1)==0&&u.push(t[d.id]);return{create(d){return d.values[a]=r(d),1},update(d,h){if(l&&h.docChanged||c&&(h.docChanged||h.selection)||TG(d,u)){let f=r(d);if(o?!sme(f,d.values[a],i):!i(f,d.values[a]))return d.values[a]=f,1}return 0},reconfigure:(d,h)=>{let f,O=h.config.address[s];if(O!=null){let g=U4(h,O);if(this.dependencies.every(m=>m instanceof Jt?h.facet(m)===d.facet(m):m instanceof Va?h.field(m,!1)==d.field(m,!1):!0)||(o?sme(f=r(d),g,i):i(f=r(d),g)))return d.values[a]=g,0}else f=r(d);return d.values[a]=f,1}}}}function sme(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function TG(e,t){let n=!1;for(let r of t)mk(e,r)&1&&(n=!0);return n}function _jt(e,t,n){let r=n.map(l=>e[l.id]),i=n.map(l=>l.type),s=r.filter(l=>!(l&1)),a=e[t.id]>>1;function o(l){let c=[];for(let u=0;u<r.length;u++){let d=U4(l,r[u]);if(i[u]==2)for(let h of d)c.push(h);else c.push(d)}return t.combine(c)}return{create(l){for(let c of r)mk(l,c);return l.values[a]=o(l),1},update(l,c){if(!TG(l,s))return 0;let u=o(l);return t.compare(u,l.values[a])?0:(l.values[a]=u,1)},reconfigure(l,c){let u=TG(l,r),d=c.config.facets[t.id],h=c.facet(t);if(d&&!u&&wJ(n,d))return l.values[a]=h,0;let f=o(l);return t.compare(f,h)?(l.values[a]=h,0):(l.values[a]=f,1)}}}const GC=Jt.define({static:!0});class Va{constructor(t,n,r,i,s){this.id=t,this.createF=n,this.updateF=r,this.compareF=i,this.spec=s,this.provides=void 0}static define(t){let n=new Va(bJ++,t.create,t.update,t.compare||((r,i)=>r===i),t);return t.provide&&(n.provides=t.provide(n)),n}create(t){let n=t.facet(GC).find(r=>r.field==this);return(n?.create||this.createF)(t)}slot(t){let n=t[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,i)=>{let s=r.values[n],a=this.updateF(s,i);return this.compareF(s,a)?0:(r.values[n]=a,1)},reconfigure:(r,i)=>{let s=r.facet(GC),a=i.facet(GC),o;return(o=s.find(l=>l.field==this))&&o!=a.find(l=>l.field==this)?(r.values[n]=o.create(r),1):i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}}init(t){return[this,GC.of({field:this,create:t})]}get extension(){return this}}const u0={lowest:4,low:3,default:2,high:1,highest:0};function NS(e){return t=>new tXe(t,e)}const cO={highest:NS(u0.highest),high:NS(u0.high),default:NS(u0.default),low:NS(u0.low),lowest:NS(u0.lowest)};class tXe{constructor(t,n){this.inner=t,this.prec=n}}class SN{of(t){return new _G(this,t)}reconfigure(t){return SN.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class _G{constructor(t,n){this.compartment=t,this.inner=n}}class z4{constructor(t,n,r,i,s,a){for(this.base=t,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=s,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<r.length;)this.statusTemplate.push(0)}staticFacet(t){let n=this.address[t.id];return n==null?t.default:this.staticValues[n>>1]}static resolve(t,n,r){let i=[],s=Object.create(null),a=new Map;for(let h of Pjt(t,n,a))h instanceof Va?i.push(h):(s[h.facet.id]||(s[h.facet.id]=[])).push(h);let o=Object.create(null),l=[],c=[];for(let h of i)o[h.id]=c.length<<1,c.push(f=>h.slot(f));let u=r?.config.facets;for(let h in s){let f=s[h],O=f[0].facet,g=u&&u[h]||[];if(f.every(m=>m.type==0))if(o[O.id]=l.length<<1|1,wJ(g,f))l.push(r.facet(O));else{let m=O.combine(f.map(v=>v.value));l.push(r&&O.compare(m,r.facet(O))?r.facet(O):m)}else{for(let m of f)m.type==0?(o[m.id]=l.length<<1|1,l.push(m.value)):(o[m.id]=c.length<<1,c.push(v=>m.dynamicSlot(v)));o[O.id]=c.length<<1,c.push(m=>_jt(m,O,f))}}let d=c.map(h=>h(o));return new z4(t,a,d,o,l,s)}}function Pjt(e,t,n){let r=[[],[],[],[],[]],i=new Map;function s(a,o){let l=i.get(a);if(l!=null){if(l<=o)return;let c=r[l].indexOf(a);c>-1&&r[l].splice(c,1),a instanceof _G&&n.delete(a.compartment)}if(i.set(a,o),Array.isArray(a))for(let c of a)s(c,o);else if(a instanceof _G){if(n.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=t.get(a.compartment)||a.inner;n.set(a.compartment,c),s(c,o)}else if(a instanceof tXe)s(a.inner,a.prec);else if(a instanceof Va)r[o].push(a),a.provides&&s(a.provides,o);else if(a instanceof tR)r[o].push(a),a.facet.extensions&&s(a.facet.extensions,u0.default);else{let c=a.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(c,o)}}return s(e,u0.default),r.reduce((a,o)=>a.concat(o))}function mk(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function U4(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}const nXe=Jt.define(),PG=Jt.define({combine:e=>e.some(t=>t),static:!0}),rXe=Jt.define({combine:e=>e.length?e[0]:void 0,static:!0}),iXe=Jt.define(),sXe=Jt.define(),aXe=Jt.define(),oXe=Jt.define({combine:e=>e.length?e[0]:!1});class yf{constructor(t,n){this.type=t,this.value=n}static define(){return new Cjt}}class Cjt{of(t){return new yf(this,t)}}class Ejt{constructor(t){this.map=t}of(t){return new Yn(this,t)}}class Yn{constructor(t,n){this.type=t,this.value=n}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new Yn(this.type,n)}is(t){return this.type==t}static define(t={}){return new Ejt(t.map||(n=>n))}static mapEffects(t,n){if(!t.length)return t;let r=[];for(let i of t){let s=i.map(n);s&&r.push(s)}return r}}Yn.reconfigure=Yn.define();Yn.appendConfig=Yn.define();class ua{constructor(t,n,r,i,s,a){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=s,this.scrollIntoView=a,this._doc=null,this._state=null,r&&eXe(r,n.newLength),s.some(o=>o.type==ua.time)||(this.annotations=s.concat(ua.time.of(Date.now())))}static create(t,n,r,i,s,a){return new ua(t,n,r,i,s,a)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let n of this.annotations)if(n.type==t)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(ua.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]=="."))}}ua.time=yf.define();ua.userEvent=yf.define();ua.addToHistory=yf.define();ua.remote=yf.define();function Qjt(e,t){let n=[];for(let r=0,i=0;;){let s,a;if(r<e.length&&(i==t.length||t[i]>=e[r]))s=e[r++],a=e[r++];else if(i<t.length)s=t[i++],a=t[i++];else return n;!n.length||n[n.length-1]<s?n.push(s,a):n[n.length-1]<a&&(n[n.length-1]=a)}}function lXe(e,t,n){var r;let i,s,a;return n?(i=t.changes,s=ma.empty(t.changes.length),a=e.changes.compose(t.changes)):(i=t.changes.map(e.changes),s=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(i)),{changes:a,selection:t.selection?t.selection.map(s):(r=e.selection)===null||r===void 0?void 0:r.map(i),effects:Yn.mapEffects(e.effects,i).concat(Yn.mapEffects(t.effects,s)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function CG(e,t,n){let r=t.selection,i=f1(t.annotations);return t.userEvent&&(i=i.concat(ua.userEvent.of(t.userEvent))),{changes:t.changes instanceof ma?t.changes:ma.of(t.changes||[],n,e.facet(rXe)),selection:r&&(r instanceof He?r:He.single(r.anchor,r.head)),effects:f1(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function cXe(e,t,n){let r=CG(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let s=1;s<t.length;s++){t[s].filter===!1&&(n=!1);let a=!!t[s].sequential;r=lXe(r,CG(e,t[s],a?r.changes.newLength:e.doc.length),a)}let i=ua.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return Ajt(n?Rjt(i):i)}function Rjt(e){let t=e.startState,n=!0;for(let i of t.facet(iXe)){let s=i(e);if(s===!1){n=!1;break}Array.isArray(s)&&(n=n===!0?s:Qjt(n,s))}if(n!==!0){let i,s;if(n===!1)s=e.changes.invertedDesc,i=ma.empty(t.doc.length);else{let a=e.changes.filter(n);i=a.changes,s=a.filtered.mapDesc(a.changes).invertedDesc}e=ua.create(t,i,e.selection&&e.selection.map(s),Yn.mapEffects(e.effects,s),e.annotations,e.scrollIntoView)}let r=t.facet(sXe);for(let i=r.length-1;i>=0;i--){let s=r[i](e);s instanceof ua?e=s:Array.isArray(s)&&s.length==1&&s[0]instanceof ua?e=s[0]:e=cXe(t,f1(s),!1)}return e}function Ajt(e){let t=e.startState,n=t.facet(aXe),r=e;for(let i=n.length-1;i>=0;i--){let s=n[i](e);s&&Object.keys(s).length&&(r=lXe(r,CG(t,s,e.changes.newLength),!0))}return r==e?e:ua.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}const Djt=[];function f1(e){return e==null?Djt:Array.isArray(e)?e:[e]}var ss=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(ss||(ss={}));const Njt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let EG;try{EG=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Xjt(e){if(EG)return EG.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||Njt.test(n)))return!0}return!1}function Ijt(e){return t=>{if(!/\S/.test(t))return ss.Space;if(Xjt(t))return ss.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return ss.Word;return ss.Other}}class _r{constructor(t,n,r,i,s,a){this.config=t,this.doc=n,this.selection=r,this.values=i,this.status=t.statusTemplate.slice(),this.computeSlot=s,a&&(a._state=this);for(let o=0;o<this.config.dynamicSlots.length;o++)mk(this,o<<1);this.computeSlot=null}field(t,n=!0){let r=this.config.address[t.id];if(r==null){if(n)throw new RangeError("Field is not present in this state");return}return mk(this,r),U4(this,r)}update(...t){return cXe(this,t,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let o of t.effects)o.is(SN.reconfigure)?(n&&(i=new Map,n.compartments.forEach((l,c)=>i.set(c,l)),n=null),i.set(o.value.compartment,o.value.extension)):o.is(Yn.reconfigure)?(n=null,r=o.value):o.is(Yn.appendConfig)&&(n=null,r=f1(r).concat(o.value));let s;n?s=t.startState.values.slice():(n=z4.resolve(r,i,this),s=new _r(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let a=t.startState.facet(PG)?t.newSelection:t.newSelection.asSingle();new _r(n,t.newDoc,a,s,(o,l)=>l.update(o,t),t)}replaceSelection(t){return typeof t=="string"&&(t=this.toText(t)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:t},range:He.cursor(n.from+t.length)}))}changeByRange(t){let n=this.selection,r=t(n.ranges[0]),i=this.changes(r.changes),s=[r.range],a=f1(r.effects);for(let o=1;o<n.ranges.length;o++){let l=t(n.ranges[o]),c=this.changes(l.changes),u=c.map(i);for(let h=0;h<o;h++)s[h]=s[h].map(u);let d=i.mapDesc(c,!0);s.push(l.range.map(d)),i=i.compose(u),a=Yn.mapEffects(a,u).concat(Yn.mapEffects(f1(l.effects),d))}return{changes:i,selection:He.create(s,n.mainIndex),effects:a}}changes(t=[]){return t instanceof ma?t:ma.of(t,this.doc.length,this.facet(_r.lineSeparator))}toText(t){return Vr.of(t.split(this.facet(_r.lineSeparator)||SG))}sliceDoc(t=0,n=this.doc.length){return this.doc.sliceString(t,n,this.lineBreak)}facet(t){let n=this.config.address[t.id];return n==null?t.default:(mk(this,n),U4(this,n))}toJSON(t){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let r in t){let i=t[r];i instanceof Va&&this.config.address[i.id]!=null&&(n[r]=i.spec.toJSON(this.field(t[r]),this))}return n}static fromJSON(t,n={},r){if(!t||typeof t.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(r){for(let s in r)if(Object.prototype.hasOwnProperty.call(t,s)){let a=r[s],o=t[s];i.push(a.init(l=>a.spec.fromJSON(o,l)))}}return _r.create({doc:t.doc,selection:He.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=z4.resolve(t.extensions||[],new Map),r=t.doc instanceof Vr?t.doc:Vr.of((t.doc||"").split(n.staticFacet(_r.lineSeparator)||SG)),i=t.selection?t.selection instanceof He?t.selection:He.single(t.selection.anchor,t.selection.head):He.single(0);return eXe(i,r.length),n.staticFacet(PG)||(i=i.asSingle()),new _r(n,r,i,n.dynamicSlots.map(()=>null),(s,a)=>a.create(s),null)}get tabSize(){return this.facet(_r.tabSize)}get lineBreak(){return this.facet(_r.lineSeparator)||`
@@ -1200,7 +1200,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
1200
1200
  `))};if(c.from==this.from&&s<this.from?c.from=s:c.to==this.to&&s>this.to&&(c.to=s),c.from==c.to&&!c.insert.length){let u=He.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));u.main.eq(i)||t.dispatch({selection:u,userEvent:"select"});return}if((rn.mac||rn.android)&&c.from==a-1&&/^\. ?$/.test(r.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:o,to:l,insert:Vr.of([r.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);EJ(t,c,He.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=[],s=null;for(let a=this.toEditorPos(r.rangeStart),o=this.toEditorPos(r.rangeEnd);a<o;a++){let l=t.coordsForChar(a);s=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||s||new DOMRect,i.push(s)}n.updateCharacterBounds(r.rangeStart,i)},this.handlers.textformatupdate=r=>{let i=[];for(let s of r.getTextFormats()){let a=s.underlineStyle,o=s.underlineThickness;if(a!="None"&&o!="None"){let l=this.toEditorPos(s.rangeStart),c=this.toEditorPos(s.rangeEnd);if(l<c){let u=`text-decoration: underline ${a=="Dashed"?"dashed ":a=="Squiggle"?"wavy ":""}${o=="Thin"?1:2}px`;i.push(Kt.mark({attributes:{style:u}}).range(l,c))}}}t.dispatch({effects:qXe.of(Kt.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=F_(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((s,a,o,l,c)=>{if(r)return;let u=c.length-(a-s);if(i&&a>=i.to)if(i.from==s&&i.to==a&&i.insert.eq(c)){i=this.pendingContextChange=null,n+=u,this.to+=u;return}else i=null,this.revertPending(t.state);if(s+=n,a+=n,a<=this.from)this.from+=u,this.to+=u;else if(s<this.to){if(s<this.from||a>this.to||this.to-this.from+c.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(a),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 At{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(s=>r(s,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=t.root||Vjt(t.parent)||document,this.viewState=new Fme(t.state||_r.create(t)),t.scrollTo&&t.scrollTo.is(ZC)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(jb).map(i=>new q7(i));for(let i of this.plugins)i.update(this);this.observer=new dLt(this),this.inputState=new D9t(this),this.inputState.ensureHandlers(this.plugins),this.docView=new yme(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 ua?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,s=this.state;for(let h of t){if(h.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=h.state}if(this.destroyed){this.viewState.state=s;return}let a=this.hasFocus,o=0,l=null;t.some(h=>h.annotation(t6e))?(this.inputState.notifiedFocused=a,o=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,l=n6e(s,a),l||(o=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(u=null)):this.observer.clear(),s.facet(_r.phrases)!=this.state.facet(_r.phrases))return this.setState(s);i=V4.create(this,s,t),i.flags|=o;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let h of t){if(d&&(d=d.map(h.changes)),h.scrollIntoView){let{main:f}=h.state.selection;d=new O1(f.empty?f:He.cursor(f.head,f.head>f.anchor?-1:1))}for(let f of h.effects)f.is(ZC)&&(d=f.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=Y4.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(R$)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(nE)!=i.state.facet(nE)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let h of this.state.facet(VG))try{h(i)}catch(f){Xl(this.state,f,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!YXe(this,u)&&c.force&&p1(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 Fme(t),this.plugins=t.facet(jb).map(r=>new q7(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new yme(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(jb),r=t.state.facet(jb);if(n!=r){let i=[];for(let s of r){let a=n.indexOf(s);if(a<0)i.push(new q7(s));else{let o=this.plugins[a];o.mustUpdate=t,i.push(o)}}for(let s of this.plugins)s.mustUpdate!=t&&s.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){Xl(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:s,scrollAnchorHeight:a}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let o=0;;o++){if(a<0)if(gXe(r))s=-1,a=this.viewState.heightMap.height;else{let f=this.viewState.scrollAnchorAt(i);s=f.from,a=f.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(o>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(O){return Xl(this.state,O),qme}}),d=V4.create(this,this.state,[]),h=!1;d.flags|=l,n?n.flags|=l:n=d,this.updateState=2,d.empty||(this.updatePlugins(d),this.inputState.update(d),this.updateAttrs(),h=this.docView.update(d),h&&this.docViewUpdate());for(let f=0;f<c.length;f++)if(u[f]!=qme)try{let O=c[f];O.write&&O.write(u[f],this)}catch(O){Xl(this.state,O)}if(h&&this.docView.updateSelection(!0),!d.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}else{let O=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-a;if(O>1||O<-1){i=i+O,r.scrollTop=i/this.scaleY,a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let o of this.state.facet(VG))o(n)}get themeClasses(){return KG+" "+(this.state.facet(HG)?a6e:s6e)+" "+this.state.facet(nE)}updateAttrs(){let t=zme(this,zXe,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(ap)?"true":"false",class:"cm-content",style:`${rn.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),zme(this,_J,n);let r=this.observer.ignore(()=>{let i=qG(this.contentDOM,this.contentAttrs,n),s=qG(this.dom,this.editorAttrs,t);return i||s});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(At.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(R$);let t=this.state.facet(At.cspNonce);zg.mount(this.root,this.styleModules.concat(cLt).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 U7(this,t,$me(this,t,n,r))}moveByGroup(t,n){return U7(this,t,$me(this,t,n,r=>k9t(this,t.head,r)))}visualLineSide(t,n){let r=this.bidiSpans(t),i=this.textDirectionAt(t.from),s=r[n?r.length-1:0];return He.cursor(s.side(n,i)+t.from,s.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return $9t(this,t,n,r)}moveVertically(t,n,r){return U7(this,t,T9t(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(),BXe(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),s=this.bidiSpans(i),a=s[dg.find(s,t-i.from,-1,n)];return u2(r,a.dir==Gi.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(MXe)||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>pLt)return QXe(t.length);let n=this.textDirectionAt(t.from),r;for(let s of this.bidiCache)if(s.from==t.from&&s.dir==n&&(s.fresh||EXe(s.isolates,r=vme(this,t))))return s.order;r||(r=vme(this,t));let i=l9t(t.text,n,r);return this.bidiCache.push(new Y4(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||rn.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{pXe(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 ZC.of(new O1(typeof t=="number"?He.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 ZC.of(new O1(He.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 vs.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return vs.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=zg.newName(),i=[nE.of(r),R$.of(JG(`.${r}`,t))];return n&&n.dark&&i.push(HG.of(!0)),i}static baseTheme(t){return cO.lowest(R$.of(JG("."+KG,t,o6e)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&Ei.get(r)||Ei.get(t);return((n=i?.rootView)===null||n===void 0?void 0:n.view)||null}}At.styleModule=R$;At.inputHandler=IXe;At.clipboardInputFilter=kJ;At.clipboardOutputFilter=TJ;At.scrollHandler=LXe;At.focusChangeEffect=FXe;At.perLineTextDirection=MXe;At.exceptionSink=XXe;At.updateListener=VG;At.editable=ap;At.mouseSelectionStyle=NXe;At.dragMovesSelection=DXe;At.clickAddsSelectionRange=AXe;At.decorations=M_;At.outerDecorations=UXe;At.atomicRanges=PJ;At.bidiIsolatedRanges=WXe;At.scrollMargins=GXe;At.darkTheme=HG;At.cspNonce=Jt.define({combine:e=>e.length?e[0]:""});At.contentAttributes=_J;At.editorAttributes=zXe;At.lineWrapping=At.contentAttributes.of({class:"cm-lineWrapping"});At.announce=Yn.define();const pLt=4096,qme={};class Y4{constructor(t,n,r,i,s,a){this.from=t,this.to=n,this.dir=r,this.isolates=i,this.fresh=s,this.order=a}static update(t,n){if(n.empty&&!t.some(s=>s.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:Gi.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let a=t[s];a.dir==i&&!n.touchesRange(a.from,a.to)&&r.push(new Y4(n.mapPos(a.from,1),n.mapPos(a.to,-1),a.dir,a.isolates,!1,a.order))}return r}}function zme(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let s=r[i],a=typeof s=="function"?s(e):s;a&&LG(a,n)}return n}const OLt=rn.mac?"mac":rn.windows?"win":rn.linux?"linux":"key";function gLt(e,t){const n=e.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,s,a,o;for(let l=0;l<n.length-1;++l){const c=n[l];if(/^(cmd|meta|m)$/i.test(c))o=!0;else if(/^a(lt)?$/i.test(c))i=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))a=!0;else if(/^mod$/i.test(c))t=="mac"?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return i&&(r="Alt-"+r),s&&(r="Ctrl-"+r),o&&(r="Meta-"+r),a&&(r="Shift-"+r),r}function rE(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 mLt=cO.default(At.domEventHandlers({keydown(e,t){return c6e(l6e(t.state),e,t,"editor")}})),dy=Jt.define({enables:mLt}),Ume=new WeakMap;function l6e(e){let t=e.facet(dy),n=Ume.get(t);return n||Ume.set(t,n=bLt(t.reduce((r,i)=>r.concat(i),[]))),n}function vLt(e,t,n){return c6e(l6e(e.state),t,e,n)}let HO=null;const yLt=4e3;function bLt(e,t=OLt){let n=Object.create(null),r=Object.create(null),i=(a,o)=>{let l=r[a];if(l==null)r[a]=o;else if(l!=o)throw new Error("Key binding "+a+" is used both as a regular binding and as a multi-stroke prefix")},s=(a,o,l,c,u)=>{var d,h;let f=n[a]||(n[a]=Object.create(null)),O=o.split(/ (?!$)/).map(v=>gLt(v,t));for(let v=1;v<O.length;v++){let y=O.slice(0,v).join(" ");i(y,!0),f[y]||(f[y]={preventDefault:!0,stopPropagation:!1,run:[w=>{let k=HO={view:w,prefix:y,scope:a};return setTimeout(()=>{HO==k&&(HO=null)},yLt),!0}]})}let g=O.join(" ");i(g,!1);let m=f[g]||(f[g]={preventDefault:!1,stopPropagation:!1,run:((h=(d=f._any)===null||d===void 0?void 0:d.run)===null||h===void 0?void 0:h.slice())||[]});l&&m.run.push(l),c&&(m.preventDefault=!0),u&&(m.stopPropagation=!0)};for(let a of e){let o=a.scope?a.scope.split(" "):["editor"];if(a.any)for(let c of o){let u=n[c]||(n[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:d}=a;for(let h in u)u[h].run.push(f=>d(f,eV))}let l=a[t]||a.key;if(l)for(let c of o)s(c,l,a.run,a.preventDefault,a.stopPropagation),a.shift&&s(c,"Shift-"+l,a.shift,a.preventDefault,a.stopPropagation)}return n}let eV=null;function c6e(e,t,n,r){eV=t;let i=qjt(t),s=Cl(i,0),a=_h(s)==i.length&&i!=" ",o="",l=!1,c=!1,u=!1;HO&&HO.view==n&&HO.scope==r&&(o=HO.prefix+" ",HXe.indexOf(t.keyCode)<0&&(c=!0,HO=null));let d=new Set,h=m=>{if(m){for(let v of m.run)if(!d.has(v)&&(d.add(v),v(n)))return m.stopPropagation&&(u=!0),!0;m.preventDefault&&(m.stopPropagation&&(u=!0),c=!0)}return!1},f=e[r],O,g;return f&&(h(f[o+rE(i,t,!a)])?l=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(rn.windows&&t.ctrlKey&&t.altKey)&&(O=Ug[t.keyCode])&&O!=i?(h(f[o+rE(O,t,!0)])||t.shiftKey&&(g=I_[t.keyCode])!=i&&g!=O&&h(f[o+rE(g,t,!1)]))&&(l=!0):a&&t.shiftKey&&h(f[o+rE(i,t,!0)])&&(l=!0),!l&&h(f._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),eV=null,l}class f2{constructor(t,n,r,i,s){this.className=t,this.left=n,this.top=r,this.width=i,this.height=s}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 s=u6e(t);return[new f2(n,i.left-s.left,i.top-s.top,null,i.bottom-i.top)]}else return wLt(t,n,r)}}function u6e(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Gi.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function Wme(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let s=e.dom.getBoundingClientRect(),a=(i.top+i.bottom)/2,o=e.posAtCoords({x:s.left+1,y:a}),l=e.posAtCoords({x:s.right-1,y:a});return o==null||l==null?r:{from:Math.max(r.from,Math.min(o,l)),to:Math.min(r.to,Math.max(o,l))}}function wLt(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),s=e.textDirection==Gi.LTR,a=e.contentDOM,o=a.getBoundingClientRect(),l=u6e(e),c=a.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),d=o.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),h=o.right-(u?parseInt(u.paddingRight):0),f=YG(e,r,1),O=YG(e,i,-1),g=f.type==dl.Text?f:null,m=O.type==dl.Text?O:null;if(g&&(e.lineWrapping||f.widgetLineBreaks)&&(g=Wme(e,r,1,g)),m&&(e.lineWrapping||O.widgetLineBreaks)&&(m=Wme(e,i,-1,m)),g&&m&&g.from==m.from&&g.to==m.to)return y(w(n.from,n.to,g));{let x=g?w(n.from,null,g):k(f,!1),S=m?w(null,n.to,m):k(O,!0),T=[];return(g||f).to<(m||O).from-(g&&m?1:0)||f.widgetLineBreaks>1&&x.bottom+e.defaultLineHeight/2<S.top?T.push(v(d,x.bottom,h,S.top)):x.bottom<S.top&&e.elementAtHeight((x.bottom+S.top)/2).type==dl.Text&&(x.bottom=S.top=(x.bottom+S.top)/2),y(x).concat(T).concat(y(S))}function v(x,S,T,_){return new f2(t,x-l.left,S-l.top,T-x,_-S)}function y({top:x,bottom:S,horizontal:T}){let _=[];for(let P=0;P<T.length;P+=2)_.push(v(T[P],x,T[P+1],S));return _}function w(x,S,T){let _=1e9,P=-1e9,E=[];function C(F,I,U,q,Z){let W=e.coordsAtPos(F,F==T.to?-2:2),M=e.coordsAtPos(U,U==T.from?2:-2);!W||!M||(_=Math.min(W.top,M.top,_),P=Math.max(W.bottom,M.bottom,P),Z==Gi.LTR?E.push(s&&I?d:W.left,s&&q?h:M.right):E.push(!s&&q?d:M.left,!s&&I?h:W.right))}let Q=x??T.from,D=S??T.to;for(let F of e.visibleRanges)if(F.to>Q&&F.from<D)for(let I=Math.max(F.from,Q),U=Math.min(F.to,D);;){let q=e.state.doc.lineAt(I);for(let Z of e.bidiSpans(q)){let W=Z.from+q.from,M=Z.to+q.from;if(W>=U)break;M>I&&C(Math.max(W,I),x==null&&W<=Q,Math.min(M,U),S==null&&M>=D,Z.dir)}if(I=q.to+1,I>=U)break}return E.length==0&&C(Q,x==null,D,S==null,e.textDirection),{top:_,bottom:P,horizontal:E}}function k(x,S){let T=o.top+(S?x.top:x.bottom);return{top:T,bottom:T,horizontal:[]}}}function xLt(e,t){return e.constructor==t.constructor&&e.eq(t)}class SLt{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(aR)!=t.state.facet(aR)&&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(aR);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)=>!xLt(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 aR=Jt.define();function d6e(e){return[vs.define(t=>new SLt(t,e)),aR.of(e)]}const j_=Jt.define({combine(e){return bf(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function $Lt(e={}){return[j_.of(e),kLt,TLt,_Lt,jXe.of(!0)]}function h6e(e){return e.startState.facet(j_)!=e.state.facet(j_)}const kLt=d6e({above:!0,markers(e){let{state:t}=e,n=t.facet(j_),r=[];for(let i of t.selection.ranges){let s=i==t.selection.main;if(i.empty||n.drawRangeCursor){let a=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",o=i.empty?i:He.cursor(i.head,i.head>i.anchor?-1:1);for(let l of f2.forRange(e,a,o))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=h6e(e);return n&&Gme(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){Gme(t.state,e)},class:"cm-cursorLayer"});function Gme(e,t){t.style.animationDuration=e.facet(j_).cursorBlinkRate+"ms"}const TLt=d6e({above:!1,markers(e){return e.state.selection.ranges.map(t=>t.empty?[]:f2.forRange(e,"cm-selectionBackground",t)).reduce((t,n)=>t.concat(n))},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||h6e(e)},class:"cm-selectionLayer"}),_Lt=cO.highest(At.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"}}}})),f6e=Yn.define({map(e,t){return e==null?null:t.mapPos(e)}}),N$=Va.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(f6e)?r.value:n,e)}}),PLt=vs.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(N$);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(N$)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(N$),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(N$)!=e&&this.view.dispatch({effects:f6e.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 CLt(){return[N$,PLt]}function Vme(e,t,n,r,i){t.lastIndex=0;for(let s=e.iterRange(n,r),a=n,o;!s.next().done;a+=s.value.length)if(!s.lineBreak)for(;o=t.exec(s.value);)i(a+o.index,o)}function ELt(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:s}of n)i=Math.max(e.state.doc.lineAt(i).from,i-t),s=Math.min(e.state.doc.lineAt(s).to,s+t),r.length&&r[r.length-1].to>=i?r[r.length-1].to=s:r.push({from:i,to:s});return r}class QLt{constructor(t){const{regexp:n,decoration:r,decorate:i,boundary:s,maxLength:a=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=(o,l,c,u)=>i(u,c,c+o[0].length,o,l);else if(typeof r=="function")this.addMatch=(o,l,c,u)=>{let d=r(o,l,c);d&&u(c,c+o[0].length,d)};else if(r)this.addMatch=(o,l,c,u)=>u(c,c+o[0].length,r);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=a}createDeco(t){let n=new Up,r=n.add.bind(n);for(let{from:i,to:s}of ELt(t,this.maxLength))Vme(t.state.doc,this.regexp,i,s,(a,o)=>this.addMatch(o,t,a,r));return n.finish()}updateDeco(t,n){let r=1e9,i=-1;return t.docChanged&&t.changes.iterChanges((s,a,o,l)=>{l>=t.view.viewport.from&&o<=t.view.viewport.to&&(r=Math.min(o,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 s of t.visibleRanges){let a=Math.max(s.from,r),o=Math.min(s.to,i);if(o>=a){let l=t.state.doc.lineAt(a),c=l.to<o?t.state.doc.lineAt(o):l,u=Math.max(s.from,l.from),d=Math.min(s.to,c.to);if(this.boundary){for(;a>l.from;a--)if(this.boundary.test(l.text[a-1-l.from])){u=a;break}for(;o<c.to;o++)if(this.boundary.test(c.text[o-c.from])){d=o;break}}let h=[],f,O=(g,m,v)=>h.push(v.range(g,m));if(l==c)for(this.regexp.lastIndex=u-l.from;(f=this.regexp.exec(l.text))&&f.index<d-l.from;)this.addMatch(f,t,f.index+l.from,O);else Vme(t.state.doc,this.regexp,u,d,(g,m)=>this.addMatch(m,t,g,O));n=n.update({filterFrom:u,filterTo:d,filter:(g,m)=>g<u||m>d,add:h})}}return n}}const tV=/x/.unicode!=null?"gu":"g",RLt=new RegExp(`[\0-\b
1201
1201
  --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,tV),ALt={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 V7=null;function DLt(){var e;if(V7==null&&typeof document<"u"&&document.body){let t=document.body.style;V7=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return V7||!1}const oR=Jt.define({combine(e){let t=bf(e,{render:null,specialChars:RLt,addSpecialChars:null});return(t.replaceTabs=!DLt())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,tV)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,tV)),t}});function NLt(e={}){return[oR.of(e),XLt()]}let Bme=null;function XLt(){return Bme||(Bme=vs.fromClass(class{constructor(e){this.view=e,this.decorations=Kt.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(oR)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new QLt({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,s=Cl(t[0],0);if(s==9){let a=i.lineAt(r),o=n.state.tabSize,l=Nd(a.text,o,r-a.from);return Kt.replace({widget:new jLt((o-l%o)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=Kt.replace({widget:new MLt(e,s)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(oR);e.startState.facet(oR)!=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 ILt="•";function FLt(e){return e>=32?ILt:e==10?"␤":String.fromCharCode(9216+e)}class MLt extends zd{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=FLt(this.code),r=t.state.phrase("Control character")+" "+(ALt[this.code]||"0x"+this.code.toString(16)),i=this.options.render&&this.options.render(this.code,r,n);if(i)return i;let s=document.createElement("span");return s.textContent=n,s.title=r,s.setAttribute("aria-label",r),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class jLt extends zd{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 LLt(){return zLt}const qLt=Kt.line({class:"cm-activeLine"}),zLt=vs.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(qLt.range(i.from)),t=i.from)}return Kt.set(n)}},{decorations:e=>e.decorations});class ULt extends zd{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?Xw(t.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(t.parentNode),i=u2(n[0],r.direction!="rtl"),s=parseInt(r.lineHeight);return i.bottom-i.top>s*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+s}:i}ignoreEvent(){return!1}}function WLt(e){let t=vs.fromClass(class{constructor(n){this.view=n,this.placeholder=e?Kt.set([Kt.widget({widget:new ULt(e),side:1}).range(0)]):Kt.none}get decorations(){return this.view.state.doc.length?Kt.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,At.contentAttributes.of({"aria-placeholder":e})]:t}const nV=2e3;function GLt(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),s=[];if(t.off>nV||n.off>nV||t.col<0||n.col<0){let a=Math.min(t.off,n.off),o=Math.max(t.off,n.off);for(let l=r;l<=i;l++){let c=e.doc.line(l);c.length<=o&&s.push(He.range(c.from+a,c.to+o))}}else{let a=Math.min(t.col,n.col),o=Math.max(t.col,n.col);for(let l=r;l<=i;l++){let c=e.doc.line(l),u=DG(c.text,a,e.tabSize,!0);if(u<0)s.push(He.cursor(c.to));else{let d=DG(c.text,o,e.tabSize);s.push(He.range(c.from+u,c.from+d))}}}return s}function VLt(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function Yme(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,s=i>nV?-1:i==r.length?VLt(e,t.clientX):Nd(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:s,off:i}}function BLt(e,t){let n=Yme(e,t),r=e.state.selection;return n?{update(i){if(i.docChanged){let s=i.changes.mapPos(i.startState.doc.line(n.line).from),a=i.state.doc.lineAt(s);n={line:a.number,col:n.col,off:Math.min(n.off,a.length)},r=r.map(i.changes)}},get(i,s,a){let o=Yme(e,i);if(!o)return r;let l=GLt(e.state,n,o);return l.length?a?He.create(l.concat(r.ranges)):He.create(l):r}}:null}function YLt(e){let t=n=>n.altKey&&n.button==0;return At.mouseSelectionStyle.of((n,r)=>t(r)?BLt(n,r):null)}const ZLt={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},HLt={style:"cursor: crosshair"};function KLt(e={}){let[t,n]=ZLt[e.key||"Alt"],r=vs.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,At.contentAttributes.of(i=>{var s;return!((s=i.plugin(r))===null||s===void 0)&&s.isDown?HLt:null})]}const IS="-10000px";class p6e{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(a=>a);let s=null;this.tooltipViews=this.tooltips.map(a=>s=r(a,s))}update(t,n){var r;let i=t.state.facet(this.facet),s=i.filter(l=>l);if(i===this.input){for(let l of this.tooltipViews)l.update&&l.update(t);return!1}let a=[],o=n?[]:null;for(let l=0;l<s.length;l++){let c=s[l],u=-1;if(c){for(let d=0;d<this.tooltips.length;d++){let h=this.tooltips[d];h&&h.create==c.create&&(u=d)}if(u<0)a[l]=this.createTooltipView(c,l?a[l-1]:null),o&&(o[l]=!!c.above);else{let d=a[l]=this.tooltipViews[u];o&&(o[l]=n[u]),d.update&&d.update(t)}}}for(let l of this.tooltipViews)a.indexOf(l)<0&&(this.removeTooltipView(l),(r=l.destroy)===null||r===void 0||r.call(l));return n&&(o.forEach((l,c)=>n[c]=l),n.length=o.length),this.input=i,this.tooltips=s,this.tooltipViews=a,!0}}function JLt(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const B7=Jt.define({combine:e=>{var t,n,r;return{position:rn.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)||JLt}}}),Zme=new WeakMap,AJ=vs.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(B7);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 p6e(e,DJ,(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(B7);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=IS,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:s}=this.manager.tooltipViews[0];if(rn.gecko)n=s.offsetParent!=this.container.ownerDocument.body;else if(s.style.top==IS&&s.style.left=="0px"){let a=s.getBoundingClientRect();n=Math.abs(a.top+1e4)>1||Math.abs(a.left)>1}}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(e=s.width/this.parent.offsetWidth,t=s.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=CJ(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((s,a)=>{let o=this.manager.tooltipViews[a];return o.getCoords?o.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(B7).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let o of this.manager.tooltipViews)o.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:s}=e,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let l=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:u}=c,d=e.pos[o],h=e.size[o];if(!d||l.clip!==!1&&(d.bottom<=Math.max(n.top,r.top)||d.top>=Math.min(n.bottom,r.bottom)||d.right<Math.max(n.left,r.left)-.1||d.left>Math.min(n.right,r.right)+.1)){u.style.top=IS;continue}let f=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,O=f?7:0,g=h.right-h.left,m=(t=Zme.get(c))!==null&&t!==void 0?t:h.bottom-h.top,v=c.offset||tqt,y=this.view.textDirection==Gi.LTR,w=h.width>r.right-r.left?y?r.left:r.right-h.width:y?Math.max(r.left,Math.min(d.left-(f?14:0)+v.x,r.right-g)):Math.min(Math.max(r.left,d.left-g+(f?14:0)-v.x),r.right-g),k=this.above[o];!l.strictSide&&(k?d.top-m-O-v.y<r.top:d.bottom+m+O+v.y>r.bottom)&&k==r.bottom-d.bottom>d.top-r.top&&(k=this.above[o]=!k);let x=(k?d.top-r.top:r.bottom-d.bottom)-O;if(x<m&&c.resize!==!1){if(x<this.view.defaultLineHeight){u.style.top=IS;continue}Zme.set(c,m),u.style.height=(m=x)/s+"px"}else u.style.height&&(u.style.height="");let S=k?d.top-m-O-v.y:d.bottom+O+v.y,T=w+g;if(c.overlap!==!0)for(let _ of a)_.left<T&&_.right>w&&_.top<S+m&&_.bottom>S&&(S=k?_.top-m-2-O:_.bottom+O+2);if(this.position=="absolute"?(u.style.top=(S-e.parent.top)/s+"px",Hme(u,(w-e.parent.left)/i)):(u.style.top=S/s+"px",Hme(u,w/i)),f){let _=d.left+(y?v.x:-v.x)-(w+14-7);f.style.left=_/i+"px"}c.overlap!==!0&&a.push({left:w,top:S,right:T,bottom:S+m}),u.classList.toggle("cm-tooltip-above",k),u.classList.toggle("cm-tooltip-below",!k),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=IS}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Hme(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const eqt=At.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"}}}),tqt={x:0,y:0},DJ=Jt.define({enables:[AJ,eqt]}),Z4=Jt.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class TN{static create(t){return new TN(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new p6e(t,Z4,(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 nqt=DJ.compute([Z4],e=>{let t=e.facet(Z4);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:TN.create,above:t[0].above,arrow:t.some(n=>n.arrow)}});class rqt{constructor(t,n,r,i,s){this.view=t,this.source=n,this.field=r,this.setHover=i,this.hoverTime=s,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,s=1;if(r instanceof ug)i=r.posAtStart;else{if(i=t.posAtCoords(n),i==null)return;let o=t.coordsAtPos(i);if(!o||n.y<o.top||n.y>o.bottom||n.x<o.left-t.defaultCharacterWidth||n.x>o.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==Gi.RTL?-1:1;s=n.x<o.left?-c:c}let a=this.source(t,i,s);if(a?.then){let o=this.pending={pos:i};a.then(l=>{this.pending==o&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>Xl(t.state,l,"hover tooltip"))}else a&&!(Array.isArray(a)&&!a.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])})}get tooltip(){let t=this.view.plugin(AJ),n=t?t.manager.tooltips.findIndex(r=>r.create==TN.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:s}=this;if(i.length&&s&&!iqt(s.dom,t)||this.pending){let{pos:a}=i[0]||this.pending,o=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:a;(a==o?this.view.posAtCoords(this.lastMove)!=a:!sqt(this.view,a,o,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 iE=4;function iqt(e,t){let{left:n,right:r,top:i,bottom:s}=e.getBoundingClientRect(),a;if(a=e.querySelector(".cm-tooltip-arrow")){let o=a.getBoundingClientRect();i=Math.min(o.top,i),s=Math.max(o.bottom,s)}return t.clientX>=n-iE&&t.clientX<=r+iE&&t.clientY>=i-iE&&t.clientY<=s+iE}function sqt(e,t,n,r,i,s){let a=e.scrollDOM.getBoundingClientRect(),o=e.documentTop+e.documentPadding.top+e.contentHeight;if(a.left>r||a.right<r||a.top>i||Math.min(a.bottom,o)<i)return!1;let l=e.posAtCoords({x:r,y:i},!1);return l>=t&&l<=n}function aqt(e,t={}){let n=Yn.define(),r=Va.define({create(){return[]},update(i,s){if(i.length&&(t.hideOnChange&&(s.docChanged||s.selection)?i=[]:t.hideOn&&(i=i.filter(a=>!t.hideOn(s,a))),s.docChanged)){let a=[];for(let o of i){let l=s.changes.mapPos(o.pos,-1,oo.TrackDel);if(l!=null){let c=Object.assign(Object.create(null),o);c.pos=l,c.end!=null&&(c.end=s.changes.mapPos(c.end)),a.push(c)}}i=a}for(let a of s.effects)a.is(n)&&(i=a.value),a.is(oqt)&&(i=[]);return i},provide:i=>Z4.from(i)});return{active:r,extension:[r,vs.define(i=>new rqt(i,e,r,n,t.hoverTime||300)),nqt]}}function O6e(e,t){let n=e.plugin(AJ);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const oqt=Yn.define(),Kme=Jt.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 L_(e,t){let n=e.plugin(g6e),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const g6e=vs.fromClass(class{constructor(e){this.input=e.state.facet(q_),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(Kme);this.top=new sE(e,!0,t.topContainer),this.bottom=new sE(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(Kme);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new sE(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new sE(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(q_);if(n!=this.input){let r=n.filter(l=>l),i=[],s=[],a=[],o=[];for(let l of r){let c=this.specs.indexOf(l),u;c<0?(u=l(e.view),o.push(u)):(u=this.panels[c],u.update&&u.update(e)),i.push(u),(u.top?s:a).push(u)}this.specs=r,this.panels=i,this.top.sync(s),this.bottom.sync(a);for(let l of o)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=>At.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class sE{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=Jme(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=Jme(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 Jme(e){let t=e.nextSibling;return e.remove(),t}const q_=Jt.define({enables:g6e});class Gp extends Sv{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Gp.prototype.elementClass="";Gp.prototype.toDOM=void 0;Gp.prototype.mapMode=oo.TrackBefore;Gp.prototype.startSide=Gp.prototype.endSide=-1;Gp.prototype.point=!0;const lR=Jt.define(),lqt=Jt.define(),cqt={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Ir.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},bk=Jt.define();function uqt(e){return[m6e(),bk.of({...cqt,...e})]}const e0e=Jt.define({combine:e=>e.some(t=>t)});function m6e(e){return[dqt]}const dqt=vs.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(bk).map(t=>new n0e(e,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!e.state.facet(e0e),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(e0e)!=!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=Ir.iter(this.view.state.facet(lR),this.view.viewport.from),r=[],i=this.gutters.map(s=>new hqt(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(s.type)){let a=!0;for(let o of s.type)if(o.type==dl.Text&&a){rV(n,r,o.from);for(let l of i)l.line(this.view,o,r);a=!1}else if(o.widget)for(let l of i)l.widget(this.view,o)}else if(s.type==dl.Text){rV(n,r,s.from);for(let a of i)a.line(this.view,s,r)}else if(s.widget)for(let a of i)a.widget(this.view,s);for(let s of i)s.finish();e&&this.view.scrollDOM.insertBefore(this.dom,t)}updateGutters(e){let t=e.startState.facet(bk),n=e.state.facet(bk),r=e.docChanged||e.heightChanged||e.viewportChanged||!Ir.eq(e.startState.facet(lR),e.state.facet(lR),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 s of n){let a=t.indexOf(s);a<0?i.push(new n0e(this.view,s)):(this.gutters[a].update(e),i.push(this.gutters[a]))}for(let s of this.gutters)s.dom.remove(),i.indexOf(s)<0&&s.destroy();for(let s of i)this.dom.appendChild(s.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove()}},{provide:e=>At.scrollMargins.of(t=>{let n=t.plugin(e);return!n||n.gutters.length==0||!n.fixed?null:t.textDirection==Gi.LTR?{left:n.dom.offsetWidth*t.scaleX}:{right:n.dom.offsetWidth*t.scaleX}})});function t0e(e){return Array.isArray(e)?e:[e]}function rV(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class hqt{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=Ir.iter(t.markers,n.from)}addElement(t,n,r){let{gutter:i}=this,s=(n.top-this.height)/t.scaleY,a=n.height/t.scaleY;if(this.i==i.elements.length){let o=new v6e(t,a,s,r);i.elements.push(o),i.dom.appendChild(o.dom)}else i.elements[this.i].update(t,a,s,r);this.height=n.bottom,this.i++}line(t,n,r){let i=[];rV(this.cursor,i,n.from),r.length&&(i=i.concat(r));let s=this.gutter.config.lineMarker(t,n,i);s&&i.unshift(s);let a=this.gutter;i.length==0&&!a.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 s of t.state.facet(lqt)){let a=s(t,n.widget,n);a&&(i||(i=[])).push(a)}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 n0e{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 s=i.target,a;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let l=s.getBoundingClientRect();a=(l.top+l.bottom)/2}else a=i.clientY;let o=t.lineBlockAtHeight(a-t.documentTop);n.domEventHandlers[r](t,o,i)&&i.preventDefault()});this.markers=t0e(n.markers(t)),n.initialSpacer&&(this.spacer=new v6e(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=t0e(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!Ir.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 v6e{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":""),fqt(this.markers,i)||this.setMarkers(t,i)}setMarkers(t,n){let r="cm-gutterElement",i=this.dom.firstChild;for(let s=0,a=0;;){let o=a,l=s<n.length?n[s++]:null,c=!1;if(l){let u=l.elementClass;u&&(r+=" "+u);for(let d=a;d<this.markers.length;d++)if(this.markers[d].compare(l)){o=d,c=!0;break}}else o=this.markers.length;for(;a<o;){let u=this.markers[a++];if(u.toDOM){u.destroy(i);let d=i.nextSibling;i.remove(),i=d}}if(!l)break;l.toDOM&&(c?i=i.nextSibling:this.dom.insertBefore(l.toDOM(t),i)),c&&a++}this.dom.className=r,this.markers=n}destroy(){this.setMarkers(null,[])}}function fqt(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 pqt=Jt.define(),Oqt=Jt.define(),Lb=Jt.define({combine(e){return bf(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,n){let r=Object.assign({},t);for(let i in n){let s=r[i],a=n[i];r[i]=s?(o,l,c)=>s(o,l,c)||a(o,l,c):a}return r}})}});class Y7 extends Gp{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function Z7(e,t){return e.state.facet(Lb).formatNumber(t,e.state)}const gqt=bk.compute([Lb],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(pqt)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new Y7(Z7(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(Oqt)){let s=i(t,n,r);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(Lb)!=t.state.facet(Lb),initialSpacer(t){return new Y7(Z7(t,r0e(t.state.doc.lines)))},updateSpacer(t,n){let r=Z7(n.view,r0e(n.view.state.doc.lines));return r==t.number?t:new Y7(r)},domEventHandlers:e.facet(Lb).domEventHandlers}));function mqt(e={}){return[Lb.of(e),m6e(),gqt]}function r0e(e){let t=9;for(;t<e;)t=t*10+9;return t}const vqt=new class extends Gp{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},yqt=lR.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(vqt.range(i)))}return Ir.of(t)});function bqt(){return yqt}let wqt=0;class Vt{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=wqt++}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 Vt&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new Vt(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(t){let n=new H4(t);return r=>r.modified.indexOf(n)>-1?r:H4.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let xqt=0;class H4{constructor(t){this.name=t,this.instances=[],this.id=xqt++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(o=>o.base==t&&Sqt(n,o.modified));if(r)return r;let i=[],s=new Vt(t.name,i,t,n);for(let o of n)o.instances.push(s);let a=$qt(n);for(let o of t.set)if(!o.modified.length)for(let l of a)i.push(H4.get(o,l));return s}}function Sqt(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function $qt(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 Yr(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 s=[],a=2,o=i;for(let d=0;;){if(o=="..."&&d>0&&d+3==i.length){a=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!h)throw new RangeError("Invalid path: "+i);if(s.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),d+=h[0].length,d==i.length)break;let f=i[d++];if(d==i.length&&f=="!"){a=0;break}if(f!="/")throw new RangeError("Invalid path: "+i);o=i.slice(d)}let l=s.length-1,c=s[l];if(!c)throw new RangeError("Invalid path: "+i);let u=new K4(r,a,l>0?s.slice(0,l):null);t[c]=u.sort(t[c])}}return y6e.add(t)}const y6e=new Wn;let K4=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}};K4.empty=new K4([],2,null);function b6e(e,t){let n=Object.create(null);for(let s of e)if(!Array.isArray(s.tag))n[s.tag.id]=s.class;else for(let a of s.tag)n[a.id]=s.class;let{scope:r,all:i=null}=t||{};return{style:s=>{let a=i;for(let o of s)for(let l of o.set){let c=n[l.id];if(c){a=a?a+" "+c:c;break}}return a},scope:r}}function kqt(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function Tqt(e,t,n,r=0,i=e.length){let s=new _qt(r,Array.isArray(t)?t:[t],n);s.highlightRange(e.cursor(),r,i,"",s.highlighters),s.flush(i)}class _qt{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,s){let{type:a,from:o,to:l}=t;if(o>=r||l<=n)return;a.isTop&&(s=this.highlighters.filter(f=>!f.scope||f.scope(a)));let c=i,u=Pqt(t)||K4.empty,d=kqt(s,u.tags);if(d&&(c&&(c+=" "),c+=d,u.mode==1&&(i+=(i?" ":"")+d)),this.startSpan(Math.max(n,o),c),u.opaque)return;let h=t.tree&&t.tree.prop(Wn.mounted);if(h&&h.overlay){let f=t.node.enter(h.overlay[0].from+o,1),O=this.highlighters.filter(m=>!m.scope||m.scope(h.tree.type)),g=t.firstChild();for(let m=0,v=o;;m++){let y=m<h.overlay.length?h.overlay[m]:null,w=y?y.from+o:l,k=Math.max(n,v),x=Math.min(r,w);if(k<x&&g)for(;t.from<x&&(this.highlightRange(t,k,x,i,s),this.startSpan(Math.min(x,t.to),c),!(t.to>=w||!t.nextSibling())););if(!y||w>r)break;v=y.to+o,v>n&&(this.highlightRange(f.cursor(),Math.max(n,y.from+o),Math.min(r,v),"",O),this.startSpan(Math.min(r,v),c))}g&&t.parent()}else if(t.firstChild()){h&&(i="");do if(!(t.to<=n)){if(t.from>=r)break;this.highlightRange(t,n,r,i,s),this.startSpan(Math.min(r,t.to),c)}while(t.nextSibling());t.parent()}}}function Pqt(e){let t=e.type.prop(y6e);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const zt=Vt.define,aE=zt(),zO=zt(),i0e=zt(zO),s0e=zt(zO),UO=zt(),oE=zt(UO),H7=zt(UO),fh=zt(),qm=zt(fh),sh=zt(),ah=zt(),iV=zt(),FS=zt(iV),lE=zt(),R={comment:aE,lineComment:zt(aE),blockComment:zt(aE),docComment:zt(aE),name:zO,variableName:zt(zO),typeName:i0e,tagName:zt(i0e),propertyName:s0e,attributeName:zt(s0e),className:zt(zO),labelName:zt(zO),namespace:zt(zO),macroName:zt(zO),literal:UO,string:oE,docString:zt(oE),character:zt(oE),attributeValue:zt(oE),number:H7,integer:zt(H7),float:zt(H7),bool:zt(UO),regexp:zt(UO),escape:zt(UO),color:zt(UO),url:zt(UO),keyword:sh,self:zt(sh),null:zt(sh),atom:zt(sh),unit:zt(sh),modifier:zt(sh),operatorKeyword:zt(sh),controlKeyword:zt(sh),definitionKeyword:zt(sh),moduleKeyword:zt(sh),operator:ah,derefOperator:zt(ah),arithmeticOperator:zt(ah),logicOperator:zt(ah),bitwiseOperator:zt(ah),compareOperator:zt(ah),updateOperator:zt(ah),definitionOperator:zt(ah),typeOperator:zt(ah),controlOperator:zt(ah),punctuation:iV,separator:zt(iV),bracket:FS,angleBracket:zt(FS),squareBracket:zt(FS),paren:zt(FS),brace:zt(FS),content:fh,heading:qm,heading1:zt(qm),heading2:zt(qm),heading3:zt(qm),heading4:zt(qm),heading5:zt(qm),heading6:zt(qm),contentSeparator:zt(fh),list:zt(fh),quote:zt(fh),emphasis:zt(fh),strong:zt(fh),link:zt(fh),monospace:zt(fh),strikethrough:zt(fh),inserted:zt(),deleted:zt(),changed:zt(),invalid:zt(),meta:lE,documentMeta:zt(lE),annotation:zt(lE),processingInstruction:zt(lE),definition:Vt.defineModifier("definition"),constant:Vt.defineModifier("constant"),function:Vt.defineModifier("function"),standard:Vt.defineModifier("standard"),local:Vt.defineModifier("local"),special:Vt.defineModifier("special")};for(let e in R){let t=R[e];t instanceof Vt&&(t.name=e)}b6e([{tag:R.link,class:"tok-link"},{tag:R.heading,class:"tok-heading"},{tag:R.emphasis,class:"tok-emphasis"},{tag:R.strong,class:"tok-strong"},{tag:R.keyword,class:"tok-keyword"},{tag:R.atom,class:"tok-atom"},{tag:R.bool,class:"tok-bool"},{tag:R.url,class:"tok-url"},{tag:R.labelName,class:"tok-labelName"},{tag:R.inserted,class:"tok-inserted"},{tag:R.deleted,class:"tok-deleted"},{tag:R.literal,class:"tok-literal"},{tag:R.string,class:"tok-string"},{tag:R.number,class:"tok-number"},{tag:[R.regexp,R.escape,R.special(R.string)],class:"tok-string2"},{tag:R.variableName,class:"tok-variableName"},{tag:R.local(R.variableName),class:"tok-variableName tok-local"},{tag:R.definition(R.variableName),class:"tok-variableName tok-definition"},{tag:R.special(R.variableName),class:"tok-variableName2"},{tag:R.definition(R.propertyName),class:"tok-propertyName tok-definition"},{tag:R.typeName,class:"tok-typeName"},{tag:R.namespace,class:"tok-namespace"},{tag:R.className,class:"tok-className"},{tag:R.macroName,class:"tok-macroName"},{tag:R.propertyName,class:"tok-propertyName"},{tag:R.operator,class:"tok-operator"},{tag:R.comment,class:"tok-comment"},{tag:R.meta,class:"tok-meta"},{tag:R.invalid,class:"tok-invalid"},{tag:R.punctuation,class:"tok-punctuation"}]);var K7;const hg=new Wn;function _N(e){return Jt.define({combine:e?t=>t.concat(e):void 0})}const NJ=new Wn;class _c{constructor(t,n,r=[],i=""){this.data=t,this.name=i,_r.prototype.hasOwnProperty("tree")||Object.defineProperty(_r.prototype,"tree",{get(){return Lr(this)}}),this.parser=n,this.extension=[Gg.of(this),_r.languageData.of((s,a,o)=>{let l=a0e(s,a,o),c=l.type.prop(hg);if(!c)return[];let u=s.facet(c),d=l.type.prop(NJ);if(d){let h=l.resolve(a-l.from,o);for(let f of d)if(f.test(h,s)){let O=s.facet(f.facet);return f.type=="replace"?O:O.concat(u)}}return u})].concat(r)}isActiveAt(t,n,r=-1){return a0e(t,n,r).type.prop(hg)==this.data}findRegions(t){let n=t.facet(Gg);if(n?.data==this.data)return[{from:0,to:t.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(s,a)=>{if(s.prop(hg)==this.data){r.push({from:a,to:a+s.length});return}let o=s.prop(Wn.mounted);if(o){if(o.tree.prop(hg)==this.data){if(o.overlay)for(let l of o.overlay)r.push({from:l.from+a,to:l.to+a});else r.push({from:a,to:a+s.length});return}else if(o.overlay){let l=r.length;if(i(o.tree,o.overlay[0].from+a),r.length>l)return}}for(let l=0;l<s.children.length;l++){let c=s.children[l];c instanceof $r&&i(c,s.positions[l]+a)}};return i(Lr(t),0),r}get allowsNesting(){return!0}}_c.setState=Yn.define();function a0e(e,t,n){let r=e.facet(Gg),i=Lr(e).topNode;if(!r||r.allowsNesting)for(let s=i;s;s=s.enter(t,n,Pi.ExcludeBuffers))s.type.isTop&&(i=s);return i}class jr extends _c{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=_N(t.languageData);return new jr(n,t.parser.configure({props:[hg.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new jr(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Lr(e){let t=e.field(_c.state,!1);return t?t.tree:$r.empty}class Cqt{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 MS=null;class _v{constructor(t,n,r=[],i,s,a,o,l){this.parser=t,this.state=n,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=a,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new _v(t,n,[],$r.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Cqt(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=$r.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(kp.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(kp.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=MS;MS=this;try{return t()}finally{MS=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=o0e(t,n.from,n.to);return t}changes(t,n){let{fragments:r,tree:i,treeLen:s,viewport:a,skipped:o}=this;if(this.takeTree(),!t.empty){let l=[];if(t.iterChangedRanges((c,u,d,h)=>l.push({fromA:c,toA:u,fromB:d,toB:h})),r=kp.applyChanges(r,l),i=$r.empty,s=0,a={from:t.mapPos(a.from,-1),to:t.mapPos(a.to,1)},this.skipped.length){o=[];for(let c of this.skipped){let u=t.mapPos(c.from,1),d=t.mapPos(c.to,-1);u<d&&o.push({from:u,to:d})}}}return new _v(this.parser,n,r,i,s,a,o,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:s}=this.skipped[r];i<t.to&&s>t.from&&(this.fragments=o0e(this.fragments,i,s),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 xN{createParse(n,r,i){let s=i[0].from,a=i[i.length-1].to;return{parsedPos:s,advance(){let l=MS;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=a,new $r(ha.none,[],[],a-s)},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 MS}}function o0e(e,t,n){return kp.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class jw{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 jw(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=_v.create(t.facet(Gg).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new jw(r)}}_c.state=Va.define({create:jw.init,update(e,t){for(let n of t.effects)if(n.is(_c.setState))return n.value;return t.startState.facet(Gg)!=t.state.facet(Gg)?jw.init(t.state):e.apply(t)}});let w6e=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(w6e=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const J7=typeof navigator<"u"&&(!((K7=navigator.scheduling)===null||K7===void 0)&&K7.isInputPending)?()=>navigator.scheduling.isInputPending():null,Eqt=vs.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(_c.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(_c.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=w6e(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,s=r.field(_c.state);if(s.tree==s.context.tree&&s.context.isDone(i+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,t&&!J7?Math.max(25,t.timeRemaining()-5):1e9),o=s.context.treeLen<i&&r.doc.length>i+1e3,l=s.context.work(()=>J7&&J7()||Date.now()>a,i+(o?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:_c.setState.of(new jw(s.context))})),this.chunkBudget>0&&!(l&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Xl(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()}}}),Gg=Jt.define({combine(e){return e.length?e[0]:null},enables:e=>[_c.state,Eqt,At.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class Ar{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}class Ie{constructor(t,n,r,i,s,a=void 0){this.name=t,this.alias=n,this.extensions=r,this.filename=i,this.loadFunc=s,this.support=a,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 Ie(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(s=>s==n))return i;if(r)for(let i of t)for(let s of i.alias){let a=n.indexOf(s);if(a>-1&&(s.length>2||!/\w/.test(n[a-1])&&!/\w/.test(n[a+s.length])))return i}return null}}const Qqt=Jt.define(),Mx=Jt.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 Pv(e){let t=e.facet(Mx);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function z_(e,t){let n="",r=e.tabSize,i=e.facet(Mx)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let s=0;s<t;s++)n+=i;return n}function XJ(e,t){e instanceof _r&&(e=new PN(e));for(let r of e.state.facet(Qqt)){let i=r(e,t);if(i!==void 0)return i}let n=Lr(e.state);return n.length>=t?Rqt(e,n,t):null}class PN{constructor(t,n={}){this.state=t,this.options=n,this.unit=Pv(t)}lineAt(t,n=1){let r=this.state.doc.lineAt(t),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return i!=null&&i>=r.from&&i<=r.to?s&&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),s=this.countColumn(r,t-i),a=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return a>-1&&(s+=a-this.countColumn(r,r.search(/\S|$/))),s}countColumn(t,n=t.length){return Nd(t,this.state.tabSize,n)}lineIndent(t,n=1){let{text:r,from:i}=this.lineAt(t,n),s=this.options.overrideIndentation;if(s){let a=s(i);if(a>-1)return a}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const ys=new Wn;function Rqt(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let s=[];for(let a=i;a&&!(a.from<r.node.from||a.to>r.node.to||a.from==r.node.from&&a.type==r.node.type);a=a.parent)s.push(a);for(let a=s.length-1;a>=0;a--)r={node:s[a],next:r}}return x6e(r,e,n)}function x6e(e,t,n){for(let r=e;r;r=r.next){let i=Dqt(r.node);if(i)return i(IJ.create(t,n,r))}return 0}function Aqt(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Dqt(e){let t=e.type.prop(ys);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Wn.closedBy))){let i=e.lastChild,s=i&&r.indexOf(i.name)>-1;return a=>S6e(a,!0,1,void 0,s&&!Aqt(a)?i.from:void 0)}return e.parent==null?Nqt:null}function Nqt(){return 0}class IJ extends PN{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 IJ(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(Xqt(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return x6e(this.context.next,this.base,this.pos)}}function Xqt(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Iqt(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,s=e.state.doc.lineAt(n.from),a=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let o=n.to;;){let l=t.childAfter(o);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=a)return null;let c=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+c}}o=l.to}}function Cu({closing:e,align:t=!0,units:n=1}){return r=>S6e(r,t,n,e)}function S6e(e,t,n,r,i){let s=e.textAfter,a=s.match(/^\s*/)[0].length,o=r&&s.slice(a,a+r.length)==r||i==e.pos+a,l=t?Iqt(e):null;return l?o?e.column(l.from):e.column(l.to):e.baseIndent+(o?0:e.unit*n)}const FJ=e=>e.baseIndent;function Es({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const Fqt=200;function Mqt(){return _r.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+Fqt)return e;let s=n.sliceString(i.from,r);if(!t.some(c=>c.test(s)))return e;let{state:a}=e,o=-1,l=[];for(let{head:c}of a.selection.ranges){let u=a.doc.lineAt(c);if(u.from==o)continue;o=u.from;let d=XJ(a,u.from);if(d==null)continue;let h=/^\s*/.exec(u.text)[0],f=z_(a,d);h!=f&&l.push({from:u.from,to:u.from+h.length,insert:f})}return l.length?[e,{changes:l,sequential:!0}]:e})}const $6e=Jt.define(),ls=new Wn;function qo(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 jqt(e,t,n){let r=Lr(e);if(r.length<n)return null;let i=r.resolveStack(n,1),s=null;for(let a=i;a;a=a.next){let o=a.node;if(o.to<=n||o.from>n)continue;if(s&&o.from<t)break;let l=o.type.prop(ls);if(l&&(o.to<r.length-50||r.length==e.doc.length||!Lqt(o))){let c=l(o,e);c&&c.from<=n&&c.from>=t&&c.to>n&&(s=c)}}return s}function Lqt(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function J4(e,t,n){for(let r of e.facet($6e)){let i=r(e,t,n);if(i)return i}return jqt(e,t,n)}function k6e(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 CN=Yn.define({map:k6e}),p2=Yn.define({map:k6e});function T6e(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 Cv=Va.define({create(){return Kt.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(CN)&&!qqt(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(C6e),i=r?Kt.replace({widget:new Yqt(r(t.state,n.value))}):l0e;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(p2)&&(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,s)=>{i<r&&s>r&&(n=!0)}),n&&(e=e.update({filterFrom:r,filterTo:r,filter:(i,s)=>s<=r||i>=r}))}return e},provide:e=>At.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(l0e.range(r,i))}return Kt.set(t,!0)}});function eA(e,t,n){var r;let i=null;return(r=e.field(Cv,!1))===null||r===void 0||r.between(t,n,(s,a)=>{(!i||i.from>s)&&(i={from:s,to:a})}),i}function qqt(e,t,n){let r=!1;return e.between(t,t,(i,s)=>{i==t&&s==n&&(r=!0)}),r}function _6e(e,t){return e.field(Cv,!1)?t:t.concat(Yn.appendConfig.of(E6e()))}const zqt=e=>{for(let t of T6e(e)){let n=J4(e.state,t.from,t.to);if(n)return e.dispatch({effects:_6e(e.state,[CN.of(n),P6e(e,n)])}),!0}return!1},Uqt=e=>{if(!e.state.field(Cv,!1))return!1;let t=[];for(let n of T6e(e)){let r=eA(e.state,n.from,n.to);r&&t.push(p2.of(r),P6e(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function P6e(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return At.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const Wqt=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),s=J4(t,i.from,i.to);s&&n.push(CN.of(s)),r=(s?e.lineBlockAt(s.to):i).to+1}return n.length&&e.dispatch({effects:_6e(e.state,n)}),!!n.length},Gqt=e=>{let t=e.state.field(Cv,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(p2.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},Vqt=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:zqt},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Uqt},{key:"Ctrl-Alt-[",run:Wqt},{key:"Ctrl-Alt-]",run:Gqt}],Bqt={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},C6e=Jt.define({combine(e){return bf(e,Bqt)}});function E6e(e){return[Cv,Kqt]}function Q6e(e,t){let{state:n}=e,r=n.facet(C6e),i=a=>{let o=e.lineBlockAt(e.posAtDOM(a.target)),l=eA(e.state,o.from,o.to);l&&e.dispatch({effects:p2.of(l)}),a.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let s=document.createElement("span");return s.textContent=r.placeholderText,s.setAttribute("aria-label",n.phrase("folded code")),s.title=n.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}const l0e=Kt.replace({widget:new class extends zd{toDOM(e){return Q6e(e,null)}}});class Yqt extends zd{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Q6e(t,this.value)}}const Zqt={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class ej extends Gp{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 Hqt(e={}){let t={...Zqt,...e},n=new ej(t,!0),r=new ej(t,!1),i=vs.fromClass(class{constructor(a){this.from=a.viewport.from,this.markers=this.buildMarkers(a)}update(a){(a.docChanged||a.viewportChanged||a.startState.facet(Gg)!=a.state.facet(Gg)||a.startState.field(Cv,!1)!=a.state.field(Cv,!1)||Lr(a.startState)!=Lr(a.state)||t.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let o=new Up;for(let l of a.viewportLineBlocks){let c=eA(a.state,l.from,l.to)?r:J4(a.state,l.from,l.to)?n:null;c&&o.add(l.from,l.from,c)}return o.finish()}}),{domEventHandlers:s}=t;return[i,uqt({class:"cm-foldGutter",markers(a){var o;return((o=a.plugin(i))===null||o===void 0?void 0:o.markers)||Ir.empty},initialSpacer(){return new ej(t,!1)},domEventHandlers:{...s,click:(a,o,l)=>{if(s.click&&s.click(a,o,l))return!0;let c=eA(a.state,o.from,o.to);if(c)return a.dispatch({effects:p2.of(c)}),!0;let u=J4(a.state,o.from,o.to);return u?(a.dispatch({effects:CN.of(u)}),!0):!1}}}),E6e()]}const Kqt=At.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 jx{constructor(t,n){this.specs=t;let r;function i(o){let l=zg.newName();return(r||(r=Object.create(null)))["."+l]=o,l}const s=typeof n.all=="string"?n.all:n.all?i(n.all):void 0,a=n.scope;this.scope=a instanceof _c?o=>o.prop(hg)==a.data:a?o=>o==a:void 0,this.style=b6e(t.map(o=>({tag:o.tag,class:o.class||i(Object.assign({},o,{tag:null}))})),{all:s}).style,this.module=r?new zg(r):null,this.themeType=n.themeType}static define(t,n){return new jx(t,n||{})}}const sV=Jt.define(),R6e=Jt.define({combine(e){return e.length?[e[0]]:null}});function tj(e){let t=e.facet(sV);return t.length?t:e.facet(R6e)}function tA(e,t){let n=[ezt],r;return e instanceof jx&&(e.module&&n.push(At.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(R6e.of(e)):r?n.push(sV.computeN([At.darkTheme],i=>i.facet(At.darkTheme)==(r=="dark")?[e]:[])):n.push(sV.of(e)),n}class Jqt{constructor(t){this.markCache=Object.create(null),this.tree=Lr(t.state),this.decorations=this.buildDeco(t,tj(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=Lr(t.state),r=tj(t.state),i=r!=tj(t.startState),{viewport:s}=t.view,a=t.changes.mapPos(this.decoratedTo,1);n.length<s.to&&!i&&n.type==this.tree.type&&a>=s.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=a):(n!=this.tree||t.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(t.view,r),this.decoratedTo=s.to)}buildDeco(t,n){if(!n||!this.tree.length)return Kt.none;let r=new Up;for(let{from:i,to:s}of t.visibleRanges)Tqt(this.tree,n,(a,o,l)=>{r.add(a,o,this.markCache[l]||(this.markCache[l]=Kt.mark({class:l})))},i,s);return r.finish()}}const ezt=cO.high(vs.fromClass(Jqt,{decorations:e=>e.decorations})),tzt=jx.define([{tag:R.meta,color:"#404740"},{tag:R.link,textDecoration:"underline"},{tag:R.heading,textDecoration:"underline",fontWeight:"bold"},{tag:R.emphasis,fontStyle:"italic"},{tag:R.strong,fontWeight:"bold"},{tag:R.strikethrough,textDecoration:"line-through"},{tag:R.keyword,color:"#708"},{tag:[R.atom,R.bool,R.url,R.contentSeparator,R.labelName],color:"#219"},{tag:[R.literal,R.inserted],color:"#164"},{tag:[R.string,R.deleted],color:"#a11"},{tag:[R.regexp,R.escape,R.special(R.string)],color:"#e40"},{tag:R.definition(R.variableName),color:"#00f"},{tag:R.local(R.variableName),color:"#30a"},{tag:[R.typeName,R.namespace],color:"#085"},{tag:R.className,color:"#167"},{tag:[R.special(R.variableName),R.macroName],color:"#256"},{tag:R.definition(R.propertyName),color:"#00c"},{tag:R.comment,color:"#940"},{tag:R.invalid,color:"#f00"}]),nzt=At.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),A6e=1e4,D6e="()[]{}",N6e=Jt.define({combine(e){return bf(e,{afterCursor:!0,brackets:D6e,maxScanDistance:A6e,renderMatch:szt})}}),rzt=Kt.mark({class:"cm-matchingBracket"}),izt=Kt.mark({class:"cm-nonmatchingBracket"});function szt(e){let t=[],n=e.matched?rzt:izt;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 azt=Va.define({create(){return Kt.none},update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(N6e);for(let i of t.state.selection.ranges){if(!i.empty)continue;let s=Ih(t.state,i.head,-1,r)||i.head>0&&Ih(t.state,i.head-1,1,r)||r.afterCursor&&(Ih(t.state,i.head,1,r)||i.head<t.state.doc.length&&Ih(t.state,i.head+1,-1,r));s&&(n=n.concat(r.renderMatch(s,t.state)))}return Kt.set(n,!0)},provide:e=>At.decorations.from(e)}),ozt=[azt,nzt];function lzt(e={}){return[N6e.of(e),ozt]}const MJ=new Wn;function aV(e,t,n){let r=e.prop(t<0?Wn.openedBy:Wn.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 oV(e){let t=e.type.prop(MJ);return t?t(e.node):e}function Ih(e,t,n,r={}){let i=r.maxScanDistance||A6e,s=r.brackets||D6e,a=Lr(e),o=a.resolveInner(t,n);for(let l=o;l;l=l.parent){let c=aV(l.type,n,s);if(c&&l.from<l.to){let u=oV(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return czt(e,t,n,l,u,c,s)}}return uzt(e,t,n,a,o.type,i,s)}function czt(e,t,n,r,i,s,a){let o=r.parent,l={from:i.from,to:i.to},c=0,u=o?.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&&s.indexOf(u.type.name)>-1&&u.from<u.to){let d=oV(u);return{start:l,end:d?{from:d.from,to:d.to}:void 0,matched:!0}}else if(aV(u.type,n,a))c++;else if(aV(u.type,-n,a)){if(c==0){let d=oV(u);return{start:l,end:d&&d.from<d.to?{from:d.from,to:d.to}:void 0,matched:!1}}c--}}while(n<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function uzt(e,t,n,r,i,s,a){let o=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=a.indexOf(o);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),d=0;for(let h=0;!u.next().done&&h<=s;){let f=u.value;n<0&&(h+=f.length);let O=t+h*n;for(let g=n>0?0:f.length-1,m=n>0?f.length:-1;g!=m;g+=n){let v=a.indexOf(f[g]);if(!(v<0||r.resolveInner(O+g,1).type!=i))if(v%2==0==n>0)d++;else{if(d==1)return{start:c,end:{from:O+g,to:O+g+1},matched:v>>1==l>>1};d--}}n>0&&(h+=f.length)}return u.done?{start:c,matched:!1}:null}function c0e(e,t,n,r=0,i=0){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let s=i;for(let a=r;a<t;a++)e.charCodeAt(a)==9?s+=n-s%n:s++;return s}class X6e{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=c0e(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:c0e(this.string,null,this.tabSize)}match(t,n,r){if(typeof t=="string"){let i=a=>r?a.toLowerCase():a,s=this.string.substr(this.pos,t.length);return i(s)==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 dzt(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||hzt,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||LJ,mergeTokens:e.mergeTokens!==!1}}function hzt(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 u0e=new WeakMap;class ft extends _c{constructor(t){let n=_N(t.languageData),r=dzt(t),i,s=new class extends xN{createParse(a,o,l){return new pzt(i,a,o,l)}};super(n,s,[],t.name),this.topNode=mzt(n,this),i=this,this.streamParser=r,this.stateAfter=new Wn({perNode:!0}),this.tokenTable=t.tokenTable?new j6e(r.tokenTable):gzt}static define(t){return new ft(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=u0e.get(t.state),n!=null&&n<t.pos-1e4&&(n=void 0));let i=jJ(this,t.node.tree,t.node.from,t.node.from,n??t.pos),s,a;if(i?(a=i.state,s=i.pos+1):(a=this.streamParser.startState(t.unit),s=t.node.from),t.pos-s>1e4)return null;for(;s<t.pos;){let l=t.state.doc.lineAt(s),c=Math.min(t.pos,l.to);if(l.length){let u=r?r(l.from):-1,d=new X6e(l.text,t.state.tabSize,t.unit,u<0?void 0:u);for(;d.pos<c-l.from;)F6e(this.streamParser.token,d,a)}else this.streamParser.blankLine(a,t.unit);if(c==t.pos)break;s=l.to+1}let o=t.lineAt(t.pos);return r&&n==null&&u0e.set(t.state,o.from),this.streamParser.indent(a,/^\s*(.*)/.exec(o.text)[1],t)}get allowsNesting(){return!1}}function jJ(e,t,n,r,i){let s=n>=r&&n+t.length<=i&&t.prop(e.stateAfter);if(s)return{state:e.streamParser.copyState(s),pos:n+t.length};for(let a=t.children.length-1;a>=0;a--){let o=t.children[a],l=n+t.positions[a],c=o instanceof $r&&l<i&&jJ(e,o,l,r,i);if(c)return c}return null}function I6e(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 s=t.children.length-1;s>=0;s--){let a=t.positions[s],o=t.children[s],l;if(a<r&&o instanceof $r){if(!(l=I6e(e,o,n-a,r-a,i)))break;return i?new $r(t.type,t.children.slice(0,s).concat(l),t.positions.slice(0,s+1),a+l.length):l}}return null}function fzt(e,t,n,r,i){for(let s of t){let a=s.from+(s.openStart?25:0),o=s.to-(s.openEnd?25:0),l=a<=n&&o>n&&jJ(e,s.tree,0-s.offset,n,o),c;if(l&&l.pos<=r&&(c=I6e(e,s.tree,n+s.offset,l.pos+s.offset,!1)))return{state:l.state,tree:c}}return{state:e.streamParser.startState(i?Pv(i):4),tree:$r.empty}}let pzt=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 s=_v.get(),a=i[0].from,{state:o,tree:l}=fzt(t,r,a,this.to,s?.state);this.state=o,this.parsedPos=this.chunkStart=a+l.length;for(let c=0;c<l.children.length;c++)this.chunks.push(l.children[c]),this.chunkPos.push(l.positions[c]);s&&this.parsedPos<s.viewport.from-1e5&&i.some(c=>c.from<=s.viewport.from&&c.to>=s.viewport.from)&&(this.state=this.lang.streamParser.startState(Pv(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let t=_v.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==`
1202
1202
  `&&(n="");else{let r=n.indexOf(`
1203
- `);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 s=this.ranges[i].to;if(s>=r||(n=n.slice(0,s-(r-n.length)),i++,i==this.ranges.length))break;let a=this.ranges[i].from,o=this.lineAfter(a);n+=o,r=a+o.length}return{line:n,end:r}}skipGapsTo(t,n,r){for(;;){let i=this.ranges[this.rangeIndex].to,s=t+n;if(r>0?i>s:i>=s)break;let a=this.ranges[++this.rangeIndex].from;n+=a-i}return n}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,n,r,i){let s=4;if(this.ranges.length>1){i=this.skipGapsTo(n,i,1),n+=i;let o=this.chunk.length;i=this.skipGapsTo(r,i,-1),r+=i,s+=this.chunk.length-o}let a=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&s==4&&a>=0&&this.chunk[a]==t&&this.chunk[a+2]==n?this.chunk[a+2]=r:this.chunk.push(t,n,r,s),i}parseLine(t){let{line:n,end:r}=this.nextLine(),i=0,{streamParser:s}=this.lang,a=new X6e(n,t?t.state.tabSize:4,t?Pv(t.state):2);if(a.eol())s.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let o=F6e(s.token,a,this.state);if(o&&(i=this.emitToken(this.lang.tokenTable.resolve(o),this.parsedPos+a.start,this.parsedPos+a.pos,i)),a.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=$r.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Ozt,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new $r(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 $r(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function F6e(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 LJ=Object.create(null),U_=[ha.none],Ozt=new Fx(U_),d0e=[],h0e=Object.create(null),M6e=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"]])M6e[e]=L6e(LJ,t);class j6e{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),M6e)}resolve(t){return t?this.table[t]||(this.table[t]=L6e(this.extra,t)):0}}const gzt=new j6e(LJ);function nj(e,t){d0e.indexOf(e)>-1||(d0e.push(e),console.warn(t))}function L6e(e,t){let n=[];for(let o of t.split(" ")){let l=[];for(let c of o.split(".")){let u=e[c]||R[c];u?typeof u=="function"?l.length?l=l.map(u):nj(c,`Modifier ${c} used at start of tag`):l.length?nj(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:nj(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(o=>o.id),s=h0e[i];if(s)return s.id;let a=h0e[i]=ha.define({id:U_.length,name:r,props:[Yr({[r]:n})]});return U_.push(a),a.id}function mzt(e,t){let n=ha.define({id:U_.length,name:"Document",props:[hg.add(()=>e),ys.add(()=>r=>t.getIndent(r))],top:!0});return U_.push(n),n}Gi.RTL,Gi.LTR;function it(e){return new Ar(ft.define(e))}function CO(e){return Le(()=>Promise.resolve().then(()=>zKt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const vzt=[Ie.of({name:"C",extensions:["c","h","ino"],load(){return Le(()=>Promise.resolve().then(()=>rye),void 0,import.meta.url).then(e=>e.cpp())}}),Ie.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return Le(()=>Promise.resolve().then(()=>rye),void 0,import.meta.url).then(e=>e.cpp())}}),Ie.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return CO("Cassandra")}}),Ie.of({name:"CSS",extensions:["css"],load(){return Le(()=>Promise.resolve().then(()=>iGt),void 0,import.meta.url).then(e=>e.css())}}),Ie.of({name:"Go",extensions:["go"],load(){return Le(()=>import("./index-CoGIjH_w.js"),__vite__mapDeps([4,1,2]),import.meta.url).then(e=>e.go())}}),Ie.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return Le(()=>Promise.resolve().then(()=>YGt),void 0,import.meta.url).then(e=>e.html())}}),Ie.of({name:"Java",extensions:["java"],load(){return Le(()=>Promise.resolve().then(()=>VKt),void 0,import.meta.url).then(e=>e.java())}}),Ie.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return Le(()=>Promise.resolve().then(()=>hE),void 0,import.meta.url).then(e=>e.javascript())}}),Ie.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return Le(()=>Promise.resolve().then(()=>eBt),void 0,import.meta.url).then(e=>e.json())}}),Ie.of({name:"JSX",extensions:["jsx"],load(){return Le(()=>Promise.resolve().then(()=>hE),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),Ie.of({name:"LESS",extensions:["less"],load(){return Le(()=>Promise.resolve().then(()=>gVt),void 0,import.meta.url).then(e=>e.less())}}),Ie.of({name:"Liquid",extensions:["liquid"],load(){return Le(()=>Promise.resolve().then(()=>Rtn),void 0,import.meta.url).then(e=>e.liquid())}}),Ie.of({name:"MariaDB SQL",load(){return CO("MariaSQL")}}),Ie.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return Le(()=>Promise.resolve().then(()=>sVt),void 0,import.meta.url).then(e=>e.markdown())}}),Ie.of({name:"MS SQL",load(){return CO("MSSQL")}}),Ie.of({name:"MySQL",load(){return CO("MySQL")}}),Ie.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return Le(()=>Promise.resolve().then(()=>ctn),void 0,import.meta.url).then(e=>e.php())}}),Ie.of({name:"PLSQL",extensions:["pls"],load(){return CO("PLSQL")}}),Ie.of({name:"PostgreSQL",load(){return CO("PostgreSQL")}}),Ie.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return Le(()=>Promise.resolve().then(()=>RHt),void 0,import.meta.url).then(e=>e.python())}}),Ie.of({name:"Rust",extensions:["rs"],load(){return Le(()=>Promise.resolve().then(()=>fJt),void 0,import.meta.url).then(e=>e.rust())}}),Ie.of({name:"Sass",extensions:["sass"],load(){return Le(()=>Promise.resolve().then(()=>vve),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),Ie.of({name:"SCSS",extensions:["scss"],load(){return Le(()=>Promise.resolve().then(()=>vve),void 0,import.meta.url).then(e=>e.sass())}}),Ie.of({name:"SQL",extensions:["sql"],load(){return CO("StandardSQL")}}),Ie.of({name:"SQLite",load(){return CO("SQLite")}}),Ie.of({name:"TSX",extensions:["tsx"],load(){return Le(()=>Promise.resolve().then(()=>hE),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Ie.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return Le(()=>Promise.resolve().then(()=>hE),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),Ie.of({name:"WebAssembly",extensions:["wat","wast"],load(){return Le(()=>Promise.resolve().then(()=>Ntn),void 0,import.meta.url).then(e=>e.wast())}}),Ie.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return Le(()=>Promise.resolve().then(()=>eKt),void 0,import.meta.url).then(e=>e.xml())}}),Ie.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return Le(()=>import("./index-BbmcajTx.js"),__vite__mapDeps([5,1,2]),import.meta.url).then(e=>e.yaml())}}),Ie.of({name:"APL",extensions:["dyalog","apl"],load(){return Le(()=>Promise.resolve().then(()=>uin),void 0,import.meta.url).then(e=>it(e.apl))}}),Ie.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return Le(()=>Promise.resolve().then(()=>din),void 0,import.meta.url).then(e=>it(e.asciiArmor))}}),Ie.of({name:"ASN.1",extensions:["asn","asn1"],load(){return Le(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>it(e.asn1({})))}}),Ie.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return Le(()=>Promise.resolve().then(()=>gin),void 0,import.meta.url).then(e=>it(e.asterisk))}}),Ie.of({name:"Brainfuck",extensions:["b","bf"],load(){return Le(()=>Promise.resolve().then(()=>vin),void 0,import.meta.url).then(e=>it(e.brainfuck))}}),Ie.of({name:"Cobol",extensions:["cob","cpy"],load(){return Le(()=>Promise.resolve().then(()=>Gin),void 0,import.meta.url).then(e=>it(e.cobol))}}),Ie.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return Le(()=>Promise.resolve().then(()=>Gm),void 0,import.meta.url).then(e=>it(e.csharp))}}),Ie.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return Le(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>it(e.clojure))}}),Ie.of({name:"ClojureScript",extensions:["cljs"],load(){return Le(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>it(e.clojure))}}),Ie.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return Le(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>it(e.gss))}}),Ie.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return Le(()=>Promise.resolve().then(()=>Iin),void 0,import.meta.url).then(e=>it(e.cmake))}}),Ie.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return Le(()=>Promise.resolve().then(()=>ssn),void 0,import.meta.url).then(e=>it(e.coffeeScript))}}),Ie.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return Le(()=>Promise.resolve().then(()=>dsn),void 0,import.meta.url).then(e=>it(e.commonLisp))}}),Ie.of({name:"Cypher",extensions:["cyp","cypher"],load(){return Le(()=>Promise.resolve().then(()=>Csn),void 0,import.meta.url).then(e=>it(e.cypher))}}),Ie.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return Le(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>it(e.cython))}}),Ie.of({name:"Crystal",extensions:["cr"],load(){return Le(()=>Promise.resolve().then(()=>Ssn),void 0,import.meta.url).then(e=>it(e.crystal))}}),Ie.of({name:"D",extensions:["d"],load(){return Le(()=>Promise.resolve().then(()=>Xsn),void 0,import.meta.url).then(e=>it(e.d))}}),Ie.of({name:"Dart",extensions:["dart"],load(){return Le(()=>Promise.resolve().then(()=>Gm),void 0,import.meta.url).then(e=>it(e.dart))}}),Ie.of({name:"diff",extensions:["diff","patch"],load(){return Le(()=>Promise.resolve().then(()=>Isn),void 0,import.meta.url).then(e=>it(e.diff))}}),Ie.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return Le(()=>Promise.resolve().then(()=>Zsn),void 0,import.meta.url).then(e=>it(e.dockerFile))}}),Ie.of({name:"DTD",extensions:["dtd"],load(){return Le(()=>Promise.resolve().then(()=>Jsn),void 0,import.meta.url).then(e=>it(e.dtd))}}),Ie.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return Le(()=>Promise.resolve().then(()=>ian),void 0,import.meta.url).then(e=>it(e.dylan))}}),Ie.of({name:"EBNF",load(){return Le(()=>Promise.resolve().then(()=>san),void 0,import.meta.url).then(e=>it(e.ebnf))}}),Ie.of({name:"ECL",extensions:["ecl"],load(){return Le(()=>Promise.resolve().then(()=>fan),void 0,import.meta.url).then(e=>it(e.ecl))}}),Ie.of({name:"edn",extensions:["edn"],load(){return Le(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>it(e.clojure))}}),Ie.of({name:"Eiffel",extensions:["e"],load(){return Le(()=>Promise.resolve().then(()=>yan),void 0,import.meta.url).then(e=>it(e.eiffel))}}),Ie.of({name:"Elm",extensions:["elm"],load(){return Le(()=>Promise.resolve().then(()=>Ean),void 0,import.meta.url).then(e=>it(e.elm))}}),Ie.of({name:"Erlang",extensions:["erl"],load(){return Le(()=>Promise.resolve().then(()=>eon),void 0,import.meta.url).then(e=>it(e.erlang))}}),Ie.of({name:"Esper",load(){return Le(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>it(e.esper))}}),Ie.of({name:"Factor",extensions:["factor"],load(){return Le(()=>Promise.resolve().then(()=>ton),void 0,import.meta.url).then(e=>it(e.factor))}}),Ie.of({name:"FCL",load(){return Le(()=>Promise.resolve().then(()=>aon),void 0,import.meta.url).then(e=>it(e.fcl))}}),Ie.of({name:"Forth",extensions:["forth","fth","4th"],load(){return Le(()=>Promise.resolve().then(()=>con),void 0,import.meta.url).then(e=>it(e.forth))}}),Ie.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return Le(()=>Promise.resolve().then(()=>gon),void 0,import.meta.url).then(e=>it(e.fortran))}}),Ie.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return Le(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>it(e.fSharp))}}),Ie.of({name:"Gas",extensions:["s"],load(){return Le(()=>Promise.resolve().then(()=>von),void 0,import.meta.url).then(e=>it(e.gas))}}),Ie.of({name:"Gherkin",extensions:["feature"],load(){return Le(()=>Promise.resolve().then(()=>yon),void 0,import.meta.url).then(e=>it(e.gherkin))}}),Ie.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return Le(()=>Promise.resolve().then(()=>Eon),void 0,import.meta.url).then(e=>it(e.groovy))}}),Ie.of({name:"Haskell",extensions:["hs"],load(){return Le(()=>Promise.resolve().then(()=>Ion),void 0,import.meta.url).then(e=>it(e.haskell))}}),Ie.of({name:"Haxe",extensions:["hx"],load(){return Le(()=>Promise.resolve().then(()=>Tbe),void 0,import.meta.url).then(e=>it(e.haxe))}}),Ie.of({name:"HXML",extensions:["hxml"],load(){return Le(()=>Promise.resolve().then(()=>Tbe),void 0,import.meta.url).then(e=>it(e.hxml))}}),Ie.of({name:"HTTP",load(){return Le(()=>Promise.resolve().then(()=>aln),void 0,import.meta.url).then(e=>it(e.http))}}),Ie.of({name:"IDL",extensions:["pro"],load(){return Le(()=>Promise.resolve().then(()=>fln),void 0,import.meta.url).then(e=>it(e.idl))}}),Ie.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return Le(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>it(e.jsonld))}}),Ie.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return Le(()=>Promise.resolve().then(()=>mln),void 0,import.meta.url).then(e=>it(e.jinja2))}}),Ie.of({name:"Julia",extensions:["jl"],load(){return Le(()=>Promise.resolve().then(()=>qln),void 0,import.meta.url).then(e=>it(e.julia))}}),Ie.of({name:"Kotlin",extensions:["kt","kts"],load(){return Le(()=>Promise.resolve().then(()=>Gm),void 0,import.meta.url).then(e=>it(e.kotlin))}}),Ie.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return Le(()=>Promise.resolve().then(()=>Gln),void 0,import.meta.url).then(e=>it(e.liveScript))}}),Ie.of({name:"Lua",extensions:["lua"],load(){return Le(()=>Promise.resolve().then(()=>ecn),void 0,import.meta.url).then(e=>it(e.lua))}}),Ie.of({name:"mIRC",extensions:["mrc"],load(){return Le(()=>Promise.resolve().then(()=>Scn),void 0,import.meta.url).then(e=>it(e.mirc))}}),Ie.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return Le(()=>Promise.resolve().then(()=>lcn),void 0,import.meta.url).then(e=>it(e.mathematica))}}),Ie.of({name:"Modelica",extensions:["mo"],load(){return Le(()=>Promise.resolve().then(()=>Acn),void 0,import.meta.url).then(e=>it(e.modelica))}}),Ie.of({name:"MUMPS",extensions:["mps"],load(){return Le(()=>Promise.resolve().then(()=>Ycn),void 0,import.meta.url).then(e=>it(e.mumps))}}),Ie.of({name:"Mbox",extensions:["mbox"],load(){return Le(()=>Promise.resolve().then(()=>bcn),void 0,import.meta.url).then(e=>it(e.mbox))}}),Ie.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return Le(()=>Promise.resolve().then(()=>eun),void 0,import.meta.url).then(e=>it(e.nginx))}}),Ie.of({name:"NSIS",extensions:["nsh","nsi"],load(){return Le(()=>Promise.resolve().then(()=>tun),void 0,import.meta.url).then(e=>it(e.nsis))}}),Ie.of({name:"NTriples",extensions:["nt","nq"],load(){return Le(()=>Promise.resolve().then(()=>nun),void 0,import.meta.url).then(e=>it(e.ntriples))}}),Ie.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return Le(()=>Promise.resolve().then(()=>Gm),void 0,import.meta.url).then(e=>it(e.objectiveC))}}),Ie.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return Le(()=>Promise.resolve().then(()=>Gm),void 0,import.meta.url).then(e=>it(e.objectiveCpp))}}),Ie.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return Le(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>it(e.oCaml))}}),Ie.of({name:"Octave",extensions:["m"],load(){return Le(()=>Promise.resolve().then(()=>fun),void 0,import.meta.url).then(e=>it(e.octave))}}),Ie.of({name:"Oz",extensions:["oz"],load(){return Le(()=>Promise.resolve().then(()=>kun),void 0,import.meta.url).then(e=>it(e.oz))}}),Ie.of({name:"Pascal",extensions:["p","pas"],load(){return Le(()=>Promise.resolve().then(()=>Qun),void 0,import.meta.url).then(e=>it(e.pascal))}}),Ie.of({name:"Perl",extensions:["pl","pm"],load(){return Le(()=>Promise.resolve().then(()=>Run),void 0,import.meta.url).then(e=>it(e.perl))}}),Ie.of({name:"Pig",extensions:["pig"],load(){return Le(()=>Promise.resolve().then(()=>Nun),void 0,import.meta.url).then(e=>it(e.pig))}}),Ie.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return Le(()=>Promise.resolve().then(()=>Hun),void 0,import.meta.url).then(e=>it(e.powerShell))}}),Ie.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return Le(()=>Promise.resolve().then(()=>Kun),void 0,import.meta.url).then(e=>it(e.properties))}}),Ie.of({name:"ProtoBuf",extensions:["proto"],load(){return Le(()=>Promise.resolve().then(()=>rdn),void 0,import.meta.url).then(e=>it(e.protobuf))}}),Ie.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return Le(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([6,7]),import.meta.url).then(e=>it(e.pug))}}),Ie.of({name:"Puppet",extensions:["pp"],load(){return Le(()=>Promise.resolve().then(()=>adn),void 0,import.meta.url).then(e=>it(e.puppet))}}),Ie.of({name:"Q",extensions:["q"],load(){return Le(()=>Promise.resolve().then(()=>pdn),void 0,import.meta.url).then(e=>it(e.q))}}),Ie.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return Le(()=>Promise.resolve().then(()=>wdn),void 0,import.meta.url).then(e=>it(e.r))}}),Ie.of({name:"RPM Changes",load(){return Le(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>it(e.rpmChanges))}}),Ie.of({name:"RPM Spec",extensions:["spec"],load(){return Le(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>it(e.rpmSpec))}}),Ie.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return Le(()=>Promise.resolve().then(()=>Edn),void 0,import.meta.url).then(e=>it(e.ruby))}}),Ie.of({name:"SAS",extensions:["sas"],load(){return Le(()=>Promise.resolve().then(()=>Ddn),void 0,import.meta.url).then(e=>it(e.sas))}}),Ie.of({name:"Scala",extensions:["scala"],load(){return Le(()=>Promise.resolve().then(()=>Gm),void 0,import.meta.url).then(e=>it(e.scala))}}),Ie.of({name:"Scheme",extensions:["scm","ss"],load(){return Le(()=>Promise.resolve().then(()=>Vdn),void 0,import.meta.url).then(e=>it(e.scheme))}}),Ie.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return Le(()=>Promise.resolve().then(()=>Hdn),void 0,import.meta.url).then(e=>it(e.shell))}}),Ie.of({name:"Sieve",extensions:["siv","sieve"],load(){return Le(()=>Promise.resolve().then(()=>nhn),void 0,import.meta.url).then(e=>it(e.sieve))}}),Ie.of({name:"Smalltalk",extensions:["st"],load(){return Le(()=>Promise.resolve().then(()=>shn),void 0,import.meta.url).then(e=>it(e.smalltalk))}}),Ie.of({name:"Solr",load(){return Le(()=>Promise.resolve().then(()=>hhn),void 0,import.meta.url).then(e=>it(e.solr))}}),Ie.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return Le(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>it(e.sml))}}),Ie.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return Le(()=>Promise.resolve().then(()=>yhn),void 0,import.meta.url).then(e=>it(e.sparql))}}),Ie.of({name:"Spreadsheet",alias:["excel","formula"],load(){return Le(()=>Promise.resolve().then(()=>bhn),void 0,import.meta.url).then(e=>it(e.spreadsheet))}}),Ie.of({name:"Squirrel",extensions:["nut"],load(){return Le(()=>Promise.resolve().then(()=>Gm),void 0,import.meta.url).then(e=>it(e.squirrel))}}),Ie.of({name:"Stylus",extensions:["styl"],load(){return Le(()=>Promise.resolve().then(()=>qhn),void 0,import.meta.url).then(e=>it(e.stylus))}}),Ie.of({name:"Swift",extensions:["swift"],load(){return Le(()=>Promise.resolve().then(()=>lfn),void 0,import.meta.url).then(e=>it(e.swift))}}),Ie.of({name:"sTeX",load(){return Le(()=>Promise.resolve().then(()=>m1e),void 0,import.meta.url).then(e=>it(e.stex))}}),Ie.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return Le(()=>Promise.resolve().then(()=>m1e),void 0,import.meta.url).then(e=>it(e.stex))}}),Ie.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return Le(()=>Promise.resolve().then(()=>I1e),void 0,import.meta.url).then(e=>it(e.verilog))}}),Ie.of({name:"Tcl",extensions:["tcl"],load(){return Le(()=>Promise.resolve().then(()=>hfn),void 0,import.meta.url).then(e=>it(e.tcl))}}),Ie.of({name:"Textile",extensions:["textile"],load(){return Le(()=>Promise.resolve().then(()=>gfn),void 0,import.meta.url).then(e=>it(e.textile))}}),Ie.of({name:"TiddlyWiki",load(){return Le(()=>Promise.resolve().then(()=>Ifn),void 0,import.meta.url).then(e=>it(e.tiddlyWiki))}}),Ie.of({name:"Tiki wiki",load(){return Le(()=>Promise.resolve().then(()=>Ufn),void 0,import.meta.url).then(e=>it(e.tiki))}}),Ie.of({name:"TOML",extensions:["toml"],load(){return Le(()=>Promise.resolve().then(()=>Wfn),void 0,import.meta.url).then(e=>it(e.toml))}}),Ie.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return Le(()=>Promise.resolve().then(()=>Bfn),void 0,import.meta.url).then(e=>it(e.troff))}}),Ie.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return Le(()=>Promise.resolve().then(()=>hpn),void 0,import.meta.url).then(e=>it(e.ttcn))}}),Ie.of({name:"TTCN_CFG",extensions:["cfg"],load(){return Le(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>it(e.ttcnCfg))}}),Ie.of({name:"Turtle",extensions:["ttl"],load(){return Le(()=>Promise.resolve().then(()=>Opn),void 0,import.meta.url).then(e=>it(e.turtle))}}),Ie.of({name:"Web IDL",extensions:["webidl"],load(){return Le(()=>Promise.resolve().then(()=>lOn),void 0,import.meta.url).then(e=>it(e.webIDL))}}),Ie.of({name:"VB.NET",extensions:["vb"],load(){return Le(()=>Promise.resolve().then(()=>Epn),void 0,import.meta.url).then(e=>it(e.vb))}}),Ie.of({name:"VBScript",extensions:["vbs"],load(){return Le(()=>Promise.resolve().then(()=>Rpn),void 0,import.meta.url).then(e=>it(e.vbScript))}}),Ie.of({name:"Velocity",extensions:["vtl"],load(){return Le(()=>Promise.resolve().then(()=>Npn),void 0,import.meta.url).then(e=>it(e.velocity))}}),Ie.of({name:"Verilog",extensions:["v"],load(){return Le(()=>Promise.resolve().then(()=>I1e),void 0,import.meta.url).then(e=>it(e.verilog))}}),Ie.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return Le(()=>Promise.resolve().then(()=>Upn),void 0,import.meta.url).then(e=>it(e.vhdl))}}),Ie.of({name:"XQuery",extensions:["xy","xquery"],load(){return Le(()=>Promise.resolve().then(()=>vOn),void 0,import.meta.url).then(e=>it(e.xQuery))}}),Ie.of({name:"Yacas",extensions:["ys"],load(){return Le(()=>Promise.resolve().then(()=>POn),void 0,import.meta.url).then(e=>it(e.yacas))}}),Ie.of({name:"Z80",extensions:["z80"],load(){return Le(()=>Promise.resolve().then(()=>AOn),void 0,import.meta.url).then(e=>it(e.z80))}}),Ie.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return Le(()=>Promise.resolve().then(()=>l9),void 0,import.meta.url).then(e=>it(e.mscgen))}}),Ie.of({name:"Xù",extensions:["xu"],load(){return Le(()=>Promise.resolve().then(()=>l9),void 0,import.meta.url).then(e=>it(e.xu))}}),Ie.of({name:"MsGenny",extensions:["msgenny"],load(){return Le(()=>Promise.resolve().then(()=>l9),void 0,import.meta.url).then(e=>it(e.msgenny))}}),Ie.of({name:"Vue",extensions:["vue"],load(){return Le(()=>Promise.resolve().then(()=>ztn),void 0,import.meta.url).then(e=>e.vue())}}),Ie.of({name:"Angular Template",load(){return Le(()=>Promise.resolve().then(()=>lnn),void 0,import.meta.url).then(e=>e.angular())}})];class qJ{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=Lr(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),s=i.search(q6e(t,!1));return s<0?null:{from:r+s,to:this.pos,text:i.slice(s)}}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 f0e(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 yzt(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let s=1;s<i.length;s++)n[i[s]]=!0}let r=f0e(t)+f0e(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function O2(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:yzt(t);return i=>{let s=i.matchBefore(r);return s||i.explicit?{from:s?s.from:i.pos,options:t,validFor:n}:null}}function EN(e,t){return n=>{for(let r=Lr(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 p0e{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function F0(e){return e.selection.main.from}function q6e(e,t){var n;let{source:r}=e,i=t&&r[0]!="^",s=r[r.length-1]!="$";return!i&&!s?e:new RegExp(`${i?"^":""}(?:${r})${s?"$":""}`,(n=e.flags)!==null&&n!==void 0?n:e.ignoreCase?"i":"")}const zJ=yf.define();function bzt(e,t,n,r){let{main:i}=e.selection,s=n-i.from,a=r-i.from;return Object.assign(Object.assign({},e.changeByRange(o=>{if(o!=i&&n!=r&&e.sliceDoc(o.from+s,o.from+a)!=e.sliceDoc(n,r))return{range:o};let l=e.toText(t);return{changes:{from:o.from+s,to:r==i.from?o.to:o.from+a,insert:l},range:He.cursor(o.from+s+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const O0e=new WeakMap;function wzt(e){if(!Array.isArray(e))return e;let t=O0e.get(e);return t||O0e.set(e,t=O2(e)),t}const nA=Yn.define(),W_=Yn.define();class xzt{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=Cl(t,n),i=_h(r);this.chars.push(r);let s=t.slice(n,n+i),a=s.toUpperCase();this.folded.push(Cl(a==s?s.toLowerCase():a,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:s,byWord:a}=this;if(n.length==1){let y=Cl(t,0),w=_h(y),k=w==t.length?0:-100;if(y!=n[0])if(y==r[0])k+=-200;else return null;return this.ret(k,[0,w])}let o=t.indexOf(this.pattern);if(o==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(o<0){for(let y=0,w=Math.min(t.length,200);y<w&&c<l;){let k=Cl(t,y);(k==n[c]||k==r[c])&&(i[c++]=y),y+=_h(k)}if(c<l)return null}let u=0,d=0,h=!1,f=0,O=-1,g=-1,m=/[a-z]/.test(t),v=!0;for(let y=0,w=Math.min(t.length,200),k=0;y<w&&d<l;){let x=Cl(t,y);o<0&&(u<l&&x==n[u]&&(s[u++]=y),f<l&&(x==n[f]||x==r[f]?(f==0&&(O=y),g=y+1,f++):f=0));let S,T=x<255?x>=48&&x<=57||x>=97&&x<=122?2:x>=65&&x<=90?1:0:(S=yJ(x))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!y||T==1&&m||k==0&&T!=0)&&(n[d]==x||r[d]==x&&(h=!0)?a[d++]=y:a.length&&(v=!1)),k=T,y+=_h(x)}return d==l&&a[0]==0&&v?this.result(-100+(h?-200:0),a,t):f==l&&O==0?this.ret(-200-t.length+(g==t.length?0:-100),[0,g]):o>-1?this.ret(-700-t.length,[o,o+this.pattern.length]):f==l?this.ret(-900-t.length,[O,g]):d==l?this.result(-100+(h?-200:0)+-700+(v?0:-1100),a,t):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,t)}result(t,n,r){let i=[],s=0;for(let a of n){let o=a+(this.astral?_h(Cl(r,a)):1);s&&i[s-1]==a?i[s-1]=o:(i[s++]=a,i[s++]=o)}return this.ret(t-r.length,i)}}class Szt{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 Ma=Jt.define({combine(e){return bf(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:$zt,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=>g0e(t(r),n(r)),optionClass:(t,n)=>r=>g0e(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function g0e(e,t){return e?t?e+" "+t:e:t}function $zt(e,t,n,r,i,s){let a=e.textDirection==Gi.RTL,o=a,l=!1,c="top",u,d,h=t.left-i.left,f=i.right-t.right,O=r.right-r.left,g=r.bottom-r.top;if(o&&h<Math.min(O,f)?o=!1:!o&&f<Math.min(O,h)&&(o=!0),O<=(o?h:f))u=Math.max(i.top,Math.min(n.top,i.bottom-g))-t.top,d=Math.min(400,o?h:f);else{l=!0,d=Math.min(400,(a?t.right:i.right-t.left)-30);let y=i.bottom-t.bottom;y>=g||y>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let m=(t.bottom-t.top)/s.offsetHeight,v=(t.right-t.left)/s.offsetWidth;return{style:`${c}: ${u/m}px; max-width: ${d/v}px`,class:"cm-completionInfo-"+(l?a?"left-narrow":"right-narrow":o?"left":"right")}}function kzt(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,s){let a=document.createElement("span");a.className="cm-completionLabel";let o=n.displayLabel||n.label,l=0;for(let c=0;c<s.length;){let u=s[c++],d=s[c++];u>l&&a.appendChild(document.createTextNode(o.slice(l,u)));let h=a.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(o.slice(u,d))),h.className="cm-completionMatchedText",l=d}return l<o.length&&a.appendChild(document.createTextNode(o.slice(l))),a},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 rj(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 Tzt{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:s,selected:a}=i.open,o=t.state.facet(Ma);this.optionContent=kzt(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=rj(s.length,a,o.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,d;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(d=/-(\d+)$/.exec(u.id))&&+d[1]<c.length){this.applyCompletion(t,c[+d[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=t.state.field(this.stateField,!1);c&&c.tooltip&&t.state.facet(Ma).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:W_.of(null)})}),this.showOptions(s,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:s,selected:a,disabled:o}=r.open;(!i.open||i.open.options!=s)&&(this.range=rj(s.length,a,t.state.facet(Ma).maxRenderedOptions),this.showOptions(s,r.id)),this.updateSel(),o!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}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=rj(n.options.length,n.selected,this.view.state.facet(Ma).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 s=typeof i=="string"?document.createTextNode(i):i(r);if(!s)return;"then"in s?s.then(a=>{a&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(a,r)}).catch(a=>Xl(this.view.state,a,"completion info")):this.addInfoPane(s,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:s}=t;r.appendChild(i),this.infoDestroy=s||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&&Pzt(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(),s=this.space;if(!s){let a=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:a.clientWidth,bottom:a.clientHeight}}return i.top>Math.min(s.bottom,n.bottom)-10||i.bottom<Math.max(s.top,n.top)+10?null:this.view.state.facet(Ma).positionInfo(this.view,n,i,r,s,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",a=>{a.target==i&&a.preventDefault()});let s=null;for(let a=r.from;a<r.to;a++){let{completion:o,match:l}=t[a],{section:c}=o;if(c){let h=typeof c=="string"?c:c.name;if(h!=s&&(a>r.from||r.from==0))if(s=h,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let f=i.appendChild(document.createElement("completion-section"));f.textContent=h}}const u=i.appendChild(document.createElement("li"));u.id=n+"-"+a,u.setAttribute("role","option");let d=this.optionClass(o);d&&(u.className=d);for(let h of this.optionContent){let f=h(o,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 _zt(e,t){return n=>new Tzt(n,e,t)}function Pzt(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 m0e(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Czt(e,t){let n=[],r=null,i=c=>{n.push(c);let{section:u}=c.completion;if(u){r||(r=[]);let d=typeof u=="string"?u:u.name;r.some(h=>h.name==d)||r.push(typeof u=="string"?{name:d}:u)}},s=t.facet(Ma);for(let c of e)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let d of c.result.options)i(new p0e(d,c.source,u?u(d):[],1e9-n.length));else{let d=t.sliceDoc(c.from,c.to),h,f=s.filterStrict?new Szt(d):new xzt(d);for(let O of c.result.options)if(h=f.match(O.label)){let g=O.displayLabel?u?u(O,h.matched):[]:h.matched;i(new p0e(O,c.source,g,h.score+(O.boost||0)))}}}if(r){let c=Object.create(null),u=0,d=(h,f)=>{var O,g;return((O=h.rank)!==null&&O!==void 0?O:1e9)-((g=f.rank)!==null&&g!==void 0?g:1e9)||(h.name<f.name?-1:1)};for(let h of r.sort(d))u-=1e5,c[h.name]=u;for(let h of n){let{section:f}=h.completion;f&&(h.score+=c[typeof f=="string"?f:f.name])}}let a=[],o=null,l=s.compareCompletions;for(let c of n.sort((u,d)=>d.score-u.score||l(u.completion,d.completion))){let u=c.completion;!o||o.label!=u.label||o.detail!=u.detail||o.type!=null&&u.type!=null&&o.type!=u.type||o.apply!=u.apply||o.boost!=u.boost?a.push(c):m0e(c.completion)>m0e(o)&&(a[a.length-1]=c),o=c.completion}return a}class qb{constructor(t,n,r,i,s,a){this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=s,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new qb(this.options,v0e(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,s,a){if(i&&!a&&t.some(c=>c.isPending))return i.setDisabled();let o=Czt(t,n);if(!o.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Ma).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let u=0;u<o.length;u++)if(o[u].completion==c){l=u;break}}return new qb(o,v0e(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:Nzt,above:s.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new qb(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 qb(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class rA{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new rA(Azt,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Ma),s=(r.override||n.languageDataAt("autocomplete",F0(n)).map(wzt)).map(l=>(this.active.find(u=>u.source==l)||new bu(l,this.active.some(u=>u.state!=0)?1:0)).update(t,r));s.length==this.active.length&&s.every((l,c)=>l==this.active[c])&&(s=this.active);let a=this.open,o=t.effects.some(l=>l.is(UJ));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||s.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Ezt(s,this.active)||o?a=qb.build(s,n,this.id,a,r,o):a&&a.disabled&&!s.some(l=>l.isPending)&&(a=null),!a&&s.every(l=>!l.isPending)&&s.some(l=>l.hasResult())&&(s=s.map(l=>l.hasResult()?new bu(l.source,0):l));for(let l of t.effects)l.is(U6e)&&(a=a&&a.setSelected(l.value,this.id));return s==this.active&&a==this.open?this:new rA(s,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Qzt:Rzt}}function Ezt(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,s=r==t.length;if(i||s)return i==s;if(e[n++].result!=t[r++].result)return!1}}const Qzt={"aria-autocomplete":"list"},Rzt={};function v0e(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Azt=[];function z6e(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(zJ);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 bu{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=z6e(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new bu(i.source,0)),r&4&&i.state==0&&(i=new bu(this.source,1)),i=i.updateFor(t,r);for(let s of t.effects)if(s.is(nA))i=new bu(i.source,1,s.value);else if(s.is(W_))i=new bu(i.source,0);else if(s.is(UJ))for(let a of s.value)a.source==i.source&&(i=a);return i}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(F0(t.state))}}class g1 extends bu{constructor(t,n,r,i,s,a){super(t,3,n),this.limit=r,this.result=i,this.from=s,this.to=a}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 s=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=F0(t.state);if(o>a||!i||n&2&&(F0(t.startState)==this.from||o<this.limit))return new bu(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return Dzt(i.validFor,t.state,s,a)?new g1(this.source,this.explicit,l,i,s,a):i.update&&(i=i.update(i,s,a,new qJ(t.state,o,!1)))?new g1(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:F0(t.state)):new bu(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new g1(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new bu(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Dzt(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):q6e(e,!0).test(i)}const UJ=Yn.define({map(e,t){return e.map(n=>n.map(t))}}),U6e=Yn.define(),Ql=Va.define({create(){return rA.start()},update(e,t){return e.update(t)},provide:e=>[DJ.from(e,t=>t.tooltip),At.contentAttributes.from(e,t=>t.attrs)]});function WJ(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ql).active.find(i=>i.source==t.source);return r instanceof g1?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},bzt(e.state,n,r.from,r.to)),{annotations:zJ.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const Nzt=_zt(Ql,WJ);function cE(e,t="option"){return n=>{let r=n.state.field(Ql,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ma).interactionDelay)return!1;let i=1,s;t=="page"&&(s=O6e(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:a}=r.open.options,o=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:a-1;return o<0?o=t=="page"?0:a-1:o>=a&&(o=t=="page"?a-1:0),n.dispatch({effects:U6e.of(o)}),!0}}const Xzt=e=>{let t=e.state.field(Ql,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ma).interactionDelay?!1:WJ(e,t.open.options[t.open.selected])},y0e=e=>e.state.field(Ql,!1)?(e.dispatch({effects:nA.of(!0)}),!0):!1,Izt=e=>{let t=e.state.field(Ql,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:W_.of(null)}),!0)};class Fzt{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const Mzt=50,jzt=1e3,Lzt=vs.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(Ql).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ql),n=e.state.facet(Ma);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ql)==t)return;let r=e.transactions.some(s=>{let a=z6e(s,n);return a&8||(s.selection||s.docChanged)&&!(a&3)});for(let s=0;s<this.running.length;s++){let a=this.running[s];if(r||a.context.abortOnDocChange&&e.docChanged||a.updates.length+e.transactions.length>Mzt&&Date.now()-a.time>jzt){for(let o of a.context.abortListeners)try{o()}catch(l){Xl(this.view.state,l)}a.context.abortListeners=null,this.running.splice(s--,1)}else a.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(s=>s.effects.some(a=>a.is(nA)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(s=>s.isPending&&!this.running.some(a=>a.active.source==s.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let s of e.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(Ql);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(Ma).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=F0(t),r=new qJ(t,n,e.explicit,this.view),i=new Fzt(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(s=>{i.context.aborted||(i.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:W_.of(null)}),Xl(this.view.state,s)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ma).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Ma),r=this.view.state.field(Ql);for(let i=0;i<this.running.length;i++){let s=this.running[i];if(s.done===void 0)continue;if(this.running.splice(i--,1),s.done){let o=F0(s.updates.length?s.updates[0].startState:this.view.state),l=Math.min(o,s.done.from+(s.active.explicit?0:1)),c=new g1(s.active.source,s.active.explicit,l,s.done,s.done.from,(e=s.done.to)!==null&&e!==void 0?e:o);for(let u of s.updates)c=c.update(u,n);if(c.hasResult()){t.push(c);continue}}let a=r.active.find(o=>o.source==s.active.source);if(a&&a.isPending)if(s.done==null){let o=new bu(s.active.source,0);for(let l of s.updates)o=o.update(l,n);o.isPending||t.push(o)}else this.startQuery(a)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:UJ.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ql,!1);if(t&&t.tooltip&&this.view.state.facet(Ma).closeOnBlur){let n=t.open&&O6e(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:W_.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:nA.of(!1)}),20),this.composing=0}}}),qzt=typeof navigator=="object"&&/Win/.test(navigator.platform),zzt=cO.highest(At.domEventHandlers({keydown(e,t){let n=t.state.field(Ql,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(qzt&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(a=>a.source==r.source),s=r.completion.commitCharacters||i.result.commitCharacters;return s&&s.indexOf(e.key)>-1&&WJ(t,r),!1}})),W6e=At.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 Uzt{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class GJ{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,oo.TrackDel),r=t.mapPos(this.to,1,oo.TrackDel);return n==null||r==null?null:new GJ(this.field,n,r)}}class VJ{constructor(t,n){this.lines=t,this.fieldPositions=n}instantiate(t,n){let r=[],i=[n],s=t.doc.lineAt(n),a=/^\s*/.exec(s.text)[0];for(let l of this.lines){if(r.length){let c=a,u=/^\t*/.exec(l)[0].length;for(let d=0;d<u;d++)c+=t.facet(Mx);i.push(n+c.length-u),l=c+l.slice(u)}r.push(l),n+=l.length+1}let o=this.fieldPositions.map(l=>new GJ(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:o}}static parse(t){let n=[],r=[],i=[],s;for(let a of t.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(a);){let o=s[1]?+s[1]:null,l=s[2]||s[3]||"",c=-1,u=l.replace(/\\[{}]/g,d=>d[1]);for(let d=0;d<n.length;d++)(o!=null?n[d].seq==o:u&&n[d].name==u)&&(c=d);if(c<0){let d=0;for(;d<n.length&&(o==null||n[d].seq!=null&&n[d].seq<o);)d++;n.splice(d,0,{seq:o,name:u}),c=d;for(let h of i)h.field>=c&&h.field++}i.push(new Uzt(c,r.length,s.index,s.index+u.length)),a=a.slice(0,s.index)+l+a.slice(s.index+s[0].length)}a=a.replace(/\\([{}])/g,(o,l,c)=>{for(let u of i)u.line==r.length&&u.from>c&&(u.from--,u.to--);return l}),r.push(a)}return new VJ(r,i)}}let Wzt=Kt.widget({widget:new class extends zd{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),Gzt=Kt.mark({class:"cm-snippetField"});class Lx{constructor(t,n){this.ranges=t,this.active=n,this.deco=Kt.set(t.map(r=>(r.from==r.to?Wzt:Gzt).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 Lx(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 g2=Yn.define({map(e,t){return e&&e.map(t)}}),Vzt=Yn.define(),G_=Va.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(g2))return n.value;if(n.is(Vzt)&&e)return new Lx(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=>At.decorations.from(e,t=>t?t.deco:Kt.none)});function BJ(e,t){return He.create(e.filter(n=>n.field==t).map(n=>He.range(n.from,n.to)))}function Bzt(e){let t=VJ.parse(e);return(n,r,i,s)=>{let{text:a,ranges:o}=t.instantiate(n.state,i),{main:l}=n.state.selection,c={changes:{from:i,to:s==l.from?l.to:s,insert:Vr.of(a)},scrollIntoView:!0,annotations:r?[zJ.of(r),ua.userEvent.of("input.complete")]:void 0};if(o.length&&(c.selection=BJ(o,0)),o.some(u=>u.field>0)){let u=new Lx(o,0),d=c.effects=[g2.of(u)];n.state.field(G_,!1)===void 0&&d.push(Yn.appendConfig.of([G_,Jzt,eUt,W6e]))}n.dispatch(n.state.update(c))}}function G6e(e){return({state:t,dispatch:n})=>{let r=t.field(G_,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,s=e>0&&!r.ranges.some(a=>a.field==i+e);return n(t.update({selection:BJ(r.ranges,i),effects:g2.of(s?null:new Lx(r.ranges,i)),scrollIntoView:!0})),!0}}const Yzt=({state:e,dispatch:t})=>e.field(G_,!1)?(t(e.update({effects:g2.of(null)})),!0):!1,Zzt=G6e(1),Hzt=G6e(-1),Kzt=[{key:"Tab",run:Zzt,shift:Hzt},{key:"Escape",run:Yzt}],b0e=Jt.define({combine(e){return e.length?e[0]:Kzt}}),Jzt=cO.highest(dy.compute([b0e],e=>e.facet(b0e)));function Li(e,t){return Object.assign(Object.assign({},t),{apply:Bzt(e)})}const eUt=At.domEventHandlers({mousedown(e,t){let n=t.state.field(G_,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(s=>s.from<=r&&s.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:BJ(n.ranges,i.field),effects:g2.of(n.ranges.some(s=>s.field>i.field)?new Lx(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),V_={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},_0=Yn.define({map(e,t){let n=t.mapPos(e,-1,oo.TrackAfter);return n??void 0}}),YJ=new class extends Sv{};YJ.startSide=1;YJ.endSide=-1;const V6e=Va.define({create(){return Ir.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(_0)&&(e=e.update({add:[YJ.range(n.value,n.value+1)]}));return e}});function tUt(){return[rUt,V6e]}const ij="()[]{}<>«»»«[]{}";function B6e(e){for(let t=0;t<ij.length;t+=2)if(ij.charCodeAt(t)==e)return ij.charAt(t+1);return yJ(e<128?e:e+1)}function Y6e(e,t){return e.languageDataAt("closeBrackets",t)[0]||V_}const nUt=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),rUt=At.inputHandler.of((e,t,n,r)=>{if((nUt?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&_h(Cl(r,0))==1||t!=i.from||n!=i.to)return!1;let s=aUt(e.state,r);return s?(e.dispatch(s),!0):!1}),iUt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Y6e(e,e.selection.main.head).brackets||V_.brackets,i=null,s=e.changeByRange(a=>{if(a.empty){let o=oUt(e.doc,a.head);for(let l of r)if(l==o&&QN(e.doc,a.head)==B6e(Cl(l,0)))return{changes:{from:a.head-l.length,to:a.head+l.length},range:He.cursor(a.head-l.length)}}return{range:i=a}});return i||t(e.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},sUt=[{key:"Backspace",run:iUt}];function aUt(e,t){let n=Y6e(e,e.selection.main.head),r=n.brackets||V_.brackets;for(let i of r){let s=B6e(Cl(i,0));if(t==i)return s==i?uUt(e,i,r.indexOf(i+i+i)>-1,n):lUt(e,i,s,n.before||V_.before);if(t==s&&Z6e(e,e.selection.main.from))return cUt(e,i,s)}return null}function Z6e(e,t){let n=!1;return e.field(V6e).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function QN(e,t){let n=e.sliceString(t,t+2);return n.slice(0,_h(Cl(n,0)))}function oUt(e,t){let n=e.sliceString(t-2,t);return _h(Cl(n,0))==n.length?n:n.slice(1)}function lUt(e,t,n,r){let i=null,s=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:_0.of(a.to+t.length),range:He.range(a.anchor+t.length,a.head+t.length)};let o=QN(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:_0.of(a.head+t.length),range:He.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function cUt(e,t,n){let r=null,i=e.changeByRange(s=>s.empty&&QN(e.doc,s.head)==n?{changes:{from:s.head,to:s.head+n.length,insert:n},range:He.cursor(s.head+n.length)}:r={range:s});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function uUt(e,t,n,r){let i=r.stringPrefixes||V_.stringPrefixes,s=null,a=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:t,from:o.to}],effects:_0.of(o.to+t.length),range:He.range(o.anchor+t.length,o.head+t.length)};let l=o.head,c=QN(e.doc,l),u;if(c==t){if(w0e(e,l))return{changes:{insert:t+t,from:l},effects:_0.of(l+t.length),range:He.cursor(l+t.length)};if(Z6e(e,l)){let h=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+h.length,insert:h},range:He.cursor(l+h.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=x0e(e,l-2*t.length,i))>-1&&w0e(e,u))return{changes:{insert:t+t+t+t,from:l},effects:_0.of(l+t.length),range:He.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=ss.Word&&x0e(e,l,i)>-1&&!dUt(e,l,t,i))return{changes:{insert:t+t,from:l},effects:_0.of(l+t.length),range:He.cursor(l+t.length)}}return{range:s=o}});return s?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function w0e(e,t){let n=Lr(e).resolveInner(t+1);return n.parent&&n.from==t}function dUt(e,t,n,r){let i=Lr(e).resolveInner(t,-1),s=r.reduce((a,o)=>Math.max(a,o.length),0);for(let a=0;a<5;a++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+s)),l=o.indexOf(n);if(!l||l>-1&&r.indexOf(o.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 x0e(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 s=t-i.length;if(e.sliceDoc(s,t)==i&&r(e.sliceDoc(s-1,s))!=ss.Word)return s}return-1}function hUt(e={}){return[zzt,Ql,Ma.of(e),Lzt,fUt,W6e]}const H6e=[{key:"Ctrl-Space",run:y0e},{mac:"Alt-`",run:y0e},{key:"Escape",run:Izt},{key:"ArrowDown",run:cE(!0)},{key:"ArrowUp",run:cE(!1)},{key:"PageDown",run:cE(!0,"page")},{key:"PageUp",run:cE(!1,"page")},{key:"Enter",run:Xzt}],fUt=cO.highest(dy.computeN([Ma],e=>e.facet(Ma).defaultKeymap?[H6e]:[]));class iA{static create(t,n,r,i,s){let a=i+(i<<8)+t+(n<<4)|0;return new iA(t,n,r,a,s,[],[])}constructor(t,n,r,i,s,a,o){this.type=t,this.value=n,this.from=r,this.hash=i,this.end=s,this.children=a,this.positions=o,this.hashProp=[[Wn.contextHash,i]]}addChild(t,n){t.prop(Wn.contextHash)!=this.hash&&(t=new $r(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 $r(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,s,a)=>new $r(ha.none,i,s,a,this.hashProp)})}}var Pt;(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"})(Pt||(Pt={}));class pUt{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}class OUt{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 wk(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 S0e(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==Pt.OrderedList?KJ:HJ)(n,t,!1);return r>0&&(e.type!=Pt.BulletList||ZJ(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const K6e={[Pt.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(Er(Pt.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(Uu(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[Pt.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Pt.OrderedList]:S0e,[Pt.BulletList]:S0e,[Pt.Document](){return!0}};function Uu(e){return e==32||e==9||e==10||e==13}function wk(e,t=0){for(;t<e.length&&Uu(e.charCodeAt(t));)t++;return t}function $0e(e,t,n){for(;t>n&&Uu(e.charCodeAt(t-1));)t--;return t}function J6e(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 eIe(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function ZJ(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 s=e.text.charCodeAt(i);if(s==e.next)r++;else if(!Uu(s))return-1}return n&&e.next==45&&rIe(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(oIe.SetextHeading)>-1||r<3?-1:1}function tIe(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function HJ(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||Uu(e.text.charCodeAt(e.pos+1)))&&(!n||tIe(t,Pt.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function KJ(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&&!Uu(e.text.charCodeAt(r+1))||n&&!tIe(t,Pt.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function nIe(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 rIe(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&&Uu(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const lV=/^[ \t]*$/,iIe=/-->/,sIe=/\?>/,cV=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,iIe],[/^\s*<\?/,sIe],[/^\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,lV],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,lV]];function aIe(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,s=cV.length-(n?1:0);i<s;i++)if(cV[i][0].test(r))return i;return-1}function k0e(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 zm(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Pt.CodeText?e[r].to=n:e.push(Er(Pt.CodeText,t,n))}const uE={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,s=e.lineStart+t.text.length,a=[],o=[];for(zm(a,i,s);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){zm(o,e.lineStart-1,e.lineStart);for(let l of t.markers)o.push(l)}else{if(t.indent<n)break;{if(o.length){for(let c of o)c.type==Pt.CodeText?zm(a,c.from,c.to):a.push(c);o=[]}zm(a,e.lineStart-1,e.lineStart);for(let c of t.markers)a.push(c);s=e.lineStart+t.text.length;let l=e.lineStart+t.findColumn(t.baseIndent+4);l<s&&zm(a,l,s)}}return o.length&&(o=o.filter(l=>l.type!=Pt.CodeText),o.length&&(t.markers=o.concat(t.markers))),e.addNode(e.buffer.writeElements(a,-i).finish(Pt.CodeBlock,s-i),i),!0},FencedCode(e,t){let n=J6e(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,s=n-t.pos,a=t.skipSpace(n),o=$0e(t.text,t.text.length,a),l=[Er(Pt.CodeMark,r,r+s)];a<o&&l.push(Er(Pt.CodeInfo,e.lineStart+a,e.lineStart+o));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>=s&&t.skipSpace(u)==t.text.length){for(let d of t.markers)l.push(d);l.push(Er(Pt.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||zm(l,e.lineStart-1,e.lineStart);for(let f of t.markers)l.push(f);let d=e.lineStart+t.basePos,h=e.lineStart+t.text.length;d<h&&zm(l,d,h)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Pt.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=eIe(t);return n<0?!1:(e.startContext(Pt.Blockquote,t.pos),e.addNode(Pt.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(ZJ(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Pt.HorizontalRule,n),!0},BulletList(e,t){let n=HJ(t,e,!1);if(n<0)return!1;e.block.type!=Pt.BulletList&&e.startContext(Pt.BulletList,t.basePos,t.next);let r=k0e(t,t.pos+1);return e.startContext(Pt.ListItem,t.basePos,r-t.baseIndent),e.addNode(Pt.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=KJ(t,e,!1);if(n<0)return!1;e.block.type!=Pt.OrderedList&&e.startContext(Pt.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=k0e(t,t.pos+n);return e.startContext(Pt.ListItem,t.basePos,r-t.baseIndent),e.addNode(Pt.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=nIe(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,s=$0e(t.text,t.text.length,r),a=s;for(;a>r&&t.text.charCodeAt(a-1)==t.next;)a--;(a==s||a==r||!Uu(t.text.charCodeAt(a-1)))&&(a=t.text.length);let o=e.buffer.write(Pt.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,a),i+n+1),-i);a<t.text.length&&o.write(Pt.HeaderMark,a-r,s-r);let l=o.finish(Pt.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=aIe(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=cV[n][1],s=[],a=i!=lV;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){a=!1;break}for(let c of t.markers)s.push(c)}a&&e.nextLine();let o=i==iIe?Pt.CommentBlock:i==sIe?Pt.ProcessingInstructionBlock:Pt.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(s,-r).finish(o,l-r),r),!0},SetextHeading:void 0};class gUt{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+`
1203
+ `);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 s=this.ranges[i].to;if(s>=r||(n=n.slice(0,s-(r-n.length)),i++,i==this.ranges.length))break;let a=this.ranges[i].from,o=this.lineAfter(a);n+=o,r=a+o.length}return{line:n,end:r}}skipGapsTo(t,n,r){for(;;){let i=this.ranges[this.rangeIndex].to,s=t+n;if(r>0?i>s:i>=s)break;let a=this.ranges[++this.rangeIndex].from;n+=a-i}return n}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,n,r,i){let s=4;if(this.ranges.length>1){i=this.skipGapsTo(n,i,1),n+=i;let o=this.chunk.length;i=this.skipGapsTo(r,i,-1),r+=i,s+=this.chunk.length-o}let a=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&s==4&&a>=0&&this.chunk[a]==t&&this.chunk[a+2]==n?this.chunk[a+2]=r:this.chunk.push(t,n,r,s),i}parseLine(t){let{line:n,end:r}=this.nextLine(),i=0,{streamParser:s}=this.lang,a=new X6e(n,t?t.state.tabSize:4,t?Pv(t.state):2);if(a.eol())s.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let o=F6e(s.token,a,this.state);if(o&&(i=this.emitToken(this.lang.tokenTable.resolve(o),this.parsedPos+a.start,this.parsedPos+a.pos,i)),a.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=$r.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Ozt,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new $r(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 $r(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function F6e(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 LJ=Object.create(null),U_=[ha.none],Ozt=new Fx(U_),d0e=[],h0e=Object.create(null),M6e=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"]])M6e[e]=L6e(LJ,t);class j6e{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),M6e)}resolve(t){return t?this.table[t]||(this.table[t]=L6e(this.extra,t)):0}}const gzt=new j6e(LJ);function nj(e,t){d0e.indexOf(e)>-1||(d0e.push(e),console.warn(t))}function L6e(e,t){let n=[];for(let o of t.split(" ")){let l=[];for(let c of o.split(".")){let u=e[c]||R[c];u?typeof u=="function"?l.length?l=l.map(u):nj(c,`Modifier ${c} used at start of tag`):l.length?nj(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:nj(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(o=>o.id),s=h0e[i];if(s)return s.id;let a=h0e[i]=ha.define({id:U_.length,name:r,props:[Yr({[r]:n})]});return U_.push(a),a.id}function mzt(e,t){let n=ha.define({id:U_.length,name:"Document",props:[hg.add(()=>e),ys.add(()=>r=>t.getIndent(r))],top:!0});return U_.push(n),n}Gi.RTL,Gi.LTR;function it(e){return new Ar(ft.define(e))}function CO(e){return Le(()=>Promise.resolve().then(()=>zKt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const vzt=[Ie.of({name:"C",extensions:["c","h","ino"],load(){return Le(()=>Promise.resolve().then(()=>rye),void 0,import.meta.url).then(e=>e.cpp())}}),Ie.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return Le(()=>Promise.resolve().then(()=>rye),void 0,import.meta.url).then(e=>e.cpp())}}),Ie.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return CO("Cassandra")}}),Ie.of({name:"CSS",extensions:["css"],load(){return Le(()=>Promise.resolve().then(()=>iGt),void 0,import.meta.url).then(e=>e.css())}}),Ie.of({name:"Go",extensions:["go"],load(){return Le(()=>import("./index-B67rWyNs.js"),__vite__mapDeps([4,1,2]),import.meta.url).then(e=>e.go())}}),Ie.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return Le(()=>Promise.resolve().then(()=>YGt),void 0,import.meta.url).then(e=>e.html())}}),Ie.of({name:"Java",extensions:["java"],load(){return Le(()=>Promise.resolve().then(()=>VKt),void 0,import.meta.url).then(e=>e.java())}}),Ie.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return Le(()=>Promise.resolve().then(()=>hE),void 0,import.meta.url).then(e=>e.javascript())}}),Ie.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return Le(()=>Promise.resolve().then(()=>eBt),void 0,import.meta.url).then(e=>e.json())}}),Ie.of({name:"JSX",extensions:["jsx"],load(){return Le(()=>Promise.resolve().then(()=>hE),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),Ie.of({name:"LESS",extensions:["less"],load(){return Le(()=>Promise.resolve().then(()=>gVt),void 0,import.meta.url).then(e=>e.less())}}),Ie.of({name:"Liquid",extensions:["liquid"],load(){return Le(()=>Promise.resolve().then(()=>Rtn),void 0,import.meta.url).then(e=>e.liquid())}}),Ie.of({name:"MariaDB SQL",load(){return CO("MariaSQL")}}),Ie.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return Le(()=>Promise.resolve().then(()=>sVt),void 0,import.meta.url).then(e=>e.markdown())}}),Ie.of({name:"MS SQL",load(){return CO("MSSQL")}}),Ie.of({name:"MySQL",load(){return CO("MySQL")}}),Ie.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return Le(()=>Promise.resolve().then(()=>ctn),void 0,import.meta.url).then(e=>e.php())}}),Ie.of({name:"PLSQL",extensions:["pls"],load(){return CO("PLSQL")}}),Ie.of({name:"PostgreSQL",load(){return CO("PostgreSQL")}}),Ie.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return Le(()=>Promise.resolve().then(()=>RHt),void 0,import.meta.url).then(e=>e.python())}}),Ie.of({name:"Rust",extensions:["rs"],load(){return Le(()=>Promise.resolve().then(()=>fJt),void 0,import.meta.url).then(e=>e.rust())}}),Ie.of({name:"Sass",extensions:["sass"],load(){return Le(()=>Promise.resolve().then(()=>vve),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),Ie.of({name:"SCSS",extensions:["scss"],load(){return Le(()=>Promise.resolve().then(()=>vve),void 0,import.meta.url).then(e=>e.sass())}}),Ie.of({name:"SQL",extensions:["sql"],load(){return CO("StandardSQL")}}),Ie.of({name:"SQLite",load(){return CO("SQLite")}}),Ie.of({name:"TSX",extensions:["tsx"],load(){return Le(()=>Promise.resolve().then(()=>hE),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Ie.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return Le(()=>Promise.resolve().then(()=>hE),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),Ie.of({name:"WebAssembly",extensions:["wat","wast"],load(){return Le(()=>Promise.resolve().then(()=>Ntn),void 0,import.meta.url).then(e=>e.wast())}}),Ie.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return Le(()=>Promise.resolve().then(()=>eKt),void 0,import.meta.url).then(e=>e.xml())}}),Ie.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return Le(()=>import("./index-CiNiUEhN.js"),__vite__mapDeps([5,1,2]),import.meta.url).then(e=>e.yaml())}}),Ie.of({name:"APL",extensions:["dyalog","apl"],load(){return Le(()=>Promise.resolve().then(()=>uin),void 0,import.meta.url).then(e=>it(e.apl))}}),Ie.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return Le(()=>Promise.resolve().then(()=>din),void 0,import.meta.url).then(e=>it(e.asciiArmor))}}),Ie.of({name:"ASN.1",extensions:["asn","asn1"],load(){return Le(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>it(e.asn1({})))}}),Ie.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return Le(()=>Promise.resolve().then(()=>gin),void 0,import.meta.url).then(e=>it(e.asterisk))}}),Ie.of({name:"Brainfuck",extensions:["b","bf"],load(){return Le(()=>Promise.resolve().then(()=>vin),void 0,import.meta.url).then(e=>it(e.brainfuck))}}),Ie.of({name:"Cobol",extensions:["cob","cpy"],load(){return Le(()=>Promise.resolve().then(()=>Gin),void 0,import.meta.url).then(e=>it(e.cobol))}}),Ie.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return Le(()=>Promise.resolve().then(()=>Gm),void 0,import.meta.url).then(e=>it(e.csharp))}}),Ie.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return Le(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>it(e.clojure))}}),Ie.of({name:"ClojureScript",extensions:["cljs"],load(){return Le(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>it(e.clojure))}}),Ie.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return Le(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>it(e.gss))}}),Ie.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return Le(()=>Promise.resolve().then(()=>Iin),void 0,import.meta.url).then(e=>it(e.cmake))}}),Ie.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return Le(()=>Promise.resolve().then(()=>ssn),void 0,import.meta.url).then(e=>it(e.coffeeScript))}}),Ie.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return Le(()=>Promise.resolve().then(()=>dsn),void 0,import.meta.url).then(e=>it(e.commonLisp))}}),Ie.of({name:"Cypher",extensions:["cyp","cypher"],load(){return Le(()=>Promise.resolve().then(()=>Csn),void 0,import.meta.url).then(e=>it(e.cypher))}}),Ie.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return Le(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>it(e.cython))}}),Ie.of({name:"Crystal",extensions:["cr"],load(){return Le(()=>Promise.resolve().then(()=>Ssn),void 0,import.meta.url).then(e=>it(e.crystal))}}),Ie.of({name:"D",extensions:["d"],load(){return Le(()=>Promise.resolve().then(()=>Xsn),void 0,import.meta.url).then(e=>it(e.d))}}),Ie.of({name:"Dart",extensions:["dart"],load(){return Le(()=>Promise.resolve().then(()=>Gm),void 0,import.meta.url).then(e=>it(e.dart))}}),Ie.of({name:"diff",extensions:["diff","patch"],load(){return Le(()=>Promise.resolve().then(()=>Isn),void 0,import.meta.url).then(e=>it(e.diff))}}),Ie.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return Le(()=>Promise.resolve().then(()=>Zsn),void 0,import.meta.url).then(e=>it(e.dockerFile))}}),Ie.of({name:"DTD",extensions:["dtd"],load(){return Le(()=>Promise.resolve().then(()=>Jsn),void 0,import.meta.url).then(e=>it(e.dtd))}}),Ie.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return Le(()=>Promise.resolve().then(()=>ian),void 0,import.meta.url).then(e=>it(e.dylan))}}),Ie.of({name:"EBNF",load(){return Le(()=>Promise.resolve().then(()=>san),void 0,import.meta.url).then(e=>it(e.ebnf))}}),Ie.of({name:"ECL",extensions:["ecl"],load(){return Le(()=>Promise.resolve().then(()=>fan),void 0,import.meta.url).then(e=>it(e.ecl))}}),Ie.of({name:"edn",extensions:["edn"],load(){return Le(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>it(e.clojure))}}),Ie.of({name:"Eiffel",extensions:["e"],load(){return Le(()=>Promise.resolve().then(()=>yan),void 0,import.meta.url).then(e=>it(e.eiffel))}}),Ie.of({name:"Elm",extensions:["elm"],load(){return Le(()=>Promise.resolve().then(()=>Ean),void 0,import.meta.url).then(e=>it(e.elm))}}),Ie.of({name:"Erlang",extensions:["erl"],load(){return Le(()=>Promise.resolve().then(()=>eon),void 0,import.meta.url).then(e=>it(e.erlang))}}),Ie.of({name:"Esper",load(){return Le(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>it(e.esper))}}),Ie.of({name:"Factor",extensions:["factor"],load(){return Le(()=>Promise.resolve().then(()=>ton),void 0,import.meta.url).then(e=>it(e.factor))}}),Ie.of({name:"FCL",load(){return Le(()=>Promise.resolve().then(()=>aon),void 0,import.meta.url).then(e=>it(e.fcl))}}),Ie.of({name:"Forth",extensions:["forth","fth","4th"],load(){return Le(()=>Promise.resolve().then(()=>con),void 0,import.meta.url).then(e=>it(e.forth))}}),Ie.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return Le(()=>Promise.resolve().then(()=>gon),void 0,import.meta.url).then(e=>it(e.fortran))}}),Ie.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return Le(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>it(e.fSharp))}}),Ie.of({name:"Gas",extensions:["s"],load(){return Le(()=>Promise.resolve().then(()=>von),void 0,import.meta.url).then(e=>it(e.gas))}}),Ie.of({name:"Gherkin",extensions:["feature"],load(){return Le(()=>Promise.resolve().then(()=>yon),void 0,import.meta.url).then(e=>it(e.gherkin))}}),Ie.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return Le(()=>Promise.resolve().then(()=>Eon),void 0,import.meta.url).then(e=>it(e.groovy))}}),Ie.of({name:"Haskell",extensions:["hs"],load(){return Le(()=>Promise.resolve().then(()=>Ion),void 0,import.meta.url).then(e=>it(e.haskell))}}),Ie.of({name:"Haxe",extensions:["hx"],load(){return Le(()=>Promise.resolve().then(()=>Tbe),void 0,import.meta.url).then(e=>it(e.haxe))}}),Ie.of({name:"HXML",extensions:["hxml"],load(){return Le(()=>Promise.resolve().then(()=>Tbe),void 0,import.meta.url).then(e=>it(e.hxml))}}),Ie.of({name:"HTTP",load(){return Le(()=>Promise.resolve().then(()=>aln),void 0,import.meta.url).then(e=>it(e.http))}}),Ie.of({name:"IDL",extensions:["pro"],load(){return Le(()=>Promise.resolve().then(()=>fln),void 0,import.meta.url).then(e=>it(e.idl))}}),Ie.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return Le(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>it(e.jsonld))}}),Ie.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return Le(()=>Promise.resolve().then(()=>mln),void 0,import.meta.url).then(e=>it(e.jinja2))}}),Ie.of({name:"Julia",extensions:["jl"],load(){return Le(()=>Promise.resolve().then(()=>qln),void 0,import.meta.url).then(e=>it(e.julia))}}),Ie.of({name:"Kotlin",extensions:["kt","kts"],load(){return Le(()=>Promise.resolve().then(()=>Gm),void 0,import.meta.url).then(e=>it(e.kotlin))}}),Ie.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return Le(()=>Promise.resolve().then(()=>Gln),void 0,import.meta.url).then(e=>it(e.liveScript))}}),Ie.of({name:"Lua",extensions:["lua"],load(){return Le(()=>Promise.resolve().then(()=>ecn),void 0,import.meta.url).then(e=>it(e.lua))}}),Ie.of({name:"mIRC",extensions:["mrc"],load(){return Le(()=>Promise.resolve().then(()=>Scn),void 0,import.meta.url).then(e=>it(e.mirc))}}),Ie.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return Le(()=>Promise.resolve().then(()=>lcn),void 0,import.meta.url).then(e=>it(e.mathematica))}}),Ie.of({name:"Modelica",extensions:["mo"],load(){return Le(()=>Promise.resolve().then(()=>Acn),void 0,import.meta.url).then(e=>it(e.modelica))}}),Ie.of({name:"MUMPS",extensions:["mps"],load(){return Le(()=>Promise.resolve().then(()=>Ycn),void 0,import.meta.url).then(e=>it(e.mumps))}}),Ie.of({name:"Mbox",extensions:["mbox"],load(){return Le(()=>Promise.resolve().then(()=>bcn),void 0,import.meta.url).then(e=>it(e.mbox))}}),Ie.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return Le(()=>Promise.resolve().then(()=>eun),void 0,import.meta.url).then(e=>it(e.nginx))}}),Ie.of({name:"NSIS",extensions:["nsh","nsi"],load(){return Le(()=>Promise.resolve().then(()=>tun),void 0,import.meta.url).then(e=>it(e.nsis))}}),Ie.of({name:"NTriples",extensions:["nt","nq"],load(){return Le(()=>Promise.resolve().then(()=>nun),void 0,import.meta.url).then(e=>it(e.ntriples))}}),Ie.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return Le(()=>Promise.resolve().then(()=>Gm),void 0,import.meta.url).then(e=>it(e.objectiveC))}}),Ie.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return Le(()=>Promise.resolve().then(()=>Gm),void 0,import.meta.url).then(e=>it(e.objectiveCpp))}}),Ie.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return Le(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>it(e.oCaml))}}),Ie.of({name:"Octave",extensions:["m"],load(){return Le(()=>Promise.resolve().then(()=>fun),void 0,import.meta.url).then(e=>it(e.octave))}}),Ie.of({name:"Oz",extensions:["oz"],load(){return Le(()=>Promise.resolve().then(()=>kun),void 0,import.meta.url).then(e=>it(e.oz))}}),Ie.of({name:"Pascal",extensions:["p","pas"],load(){return Le(()=>Promise.resolve().then(()=>Qun),void 0,import.meta.url).then(e=>it(e.pascal))}}),Ie.of({name:"Perl",extensions:["pl","pm"],load(){return Le(()=>Promise.resolve().then(()=>Run),void 0,import.meta.url).then(e=>it(e.perl))}}),Ie.of({name:"Pig",extensions:["pig"],load(){return Le(()=>Promise.resolve().then(()=>Nun),void 0,import.meta.url).then(e=>it(e.pig))}}),Ie.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return Le(()=>Promise.resolve().then(()=>Hun),void 0,import.meta.url).then(e=>it(e.powerShell))}}),Ie.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return Le(()=>Promise.resolve().then(()=>Kun),void 0,import.meta.url).then(e=>it(e.properties))}}),Ie.of({name:"ProtoBuf",extensions:["proto"],load(){return Le(()=>Promise.resolve().then(()=>rdn),void 0,import.meta.url).then(e=>it(e.protobuf))}}),Ie.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return Le(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([6,7]),import.meta.url).then(e=>it(e.pug))}}),Ie.of({name:"Puppet",extensions:["pp"],load(){return Le(()=>Promise.resolve().then(()=>adn),void 0,import.meta.url).then(e=>it(e.puppet))}}),Ie.of({name:"Q",extensions:["q"],load(){return Le(()=>Promise.resolve().then(()=>pdn),void 0,import.meta.url).then(e=>it(e.q))}}),Ie.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return Le(()=>Promise.resolve().then(()=>wdn),void 0,import.meta.url).then(e=>it(e.r))}}),Ie.of({name:"RPM Changes",load(){return Le(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>it(e.rpmChanges))}}),Ie.of({name:"RPM Spec",extensions:["spec"],load(){return Le(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>it(e.rpmSpec))}}),Ie.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return Le(()=>Promise.resolve().then(()=>Edn),void 0,import.meta.url).then(e=>it(e.ruby))}}),Ie.of({name:"SAS",extensions:["sas"],load(){return Le(()=>Promise.resolve().then(()=>Ddn),void 0,import.meta.url).then(e=>it(e.sas))}}),Ie.of({name:"Scala",extensions:["scala"],load(){return Le(()=>Promise.resolve().then(()=>Gm),void 0,import.meta.url).then(e=>it(e.scala))}}),Ie.of({name:"Scheme",extensions:["scm","ss"],load(){return Le(()=>Promise.resolve().then(()=>Vdn),void 0,import.meta.url).then(e=>it(e.scheme))}}),Ie.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return Le(()=>Promise.resolve().then(()=>Hdn),void 0,import.meta.url).then(e=>it(e.shell))}}),Ie.of({name:"Sieve",extensions:["siv","sieve"],load(){return Le(()=>Promise.resolve().then(()=>nhn),void 0,import.meta.url).then(e=>it(e.sieve))}}),Ie.of({name:"Smalltalk",extensions:["st"],load(){return Le(()=>Promise.resolve().then(()=>shn),void 0,import.meta.url).then(e=>it(e.smalltalk))}}),Ie.of({name:"Solr",load(){return Le(()=>Promise.resolve().then(()=>hhn),void 0,import.meta.url).then(e=>it(e.solr))}}),Ie.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return Le(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>it(e.sml))}}),Ie.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return Le(()=>Promise.resolve().then(()=>yhn),void 0,import.meta.url).then(e=>it(e.sparql))}}),Ie.of({name:"Spreadsheet",alias:["excel","formula"],load(){return Le(()=>Promise.resolve().then(()=>bhn),void 0,import.meta.url).then(e=>it(e.spreadsheet))}}),Ie.of({name:"Squirrel",extensions:["nut"],load(){return Le(()=>Promise.resolve().then(()=>Gm),void 0,import.meta.url).then(e=>it(e.squirrel))}}),Ie.of({name:"Stylus",extensions:["styl"],load(){return Le(()=>Promise.resolve().then(()=>qhn),void 0,import.meta.url).then(e=>it(e.stylus))}}),Ie.of({name:"Swift",extensions:["swift"],load(){return Le(()=>Promise.resolve().then(()=>lfn),void 0,import.meta.url).then(e=>it(e.swift))}}),Ie.of({name:"sTeX",load(){return Le(()=>Promise.resolve().then(()=>m1e),void 0,import.meta.url).then(e=>it(e.stex))}}),Ie.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return Le(()=>Promise.resolve().then(()=>m1e),void 0,import.meta.url).then(e=>it(e.stex))}}),Ie.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return Le(()=>Promise.resolve().then(()=>I1e),void 0,import.meta.url).then(e=>it(e.verilog))}}),Ie.of({name:"Tcl",extensions:["tcl"],load(){return Le(()=>Promise.resolve().then(()=>hfn),void 0,import.meta.url).then(e=>it(e.tcl))}}),Ie.of({name:"Textile",extensions:["textile"],load(){return Le(()=>Promise.resolve().then(()=>gfn),void 0,import.meta.url).then(e=>it(e.textile))}}),Ie.of({name:"TiddlyWiki",load(){return Le(()=>Promise.resolve().then(()=>Ifn),void 0,import.meta.url).then(e=>it(e.tiddlyWiki))}}),Ie.of({name:"Tiki wiki",load(){return Le(()=>Promise.resolve().then(()=>Ufn),void 0,import.meta.url).then(e=>it(e.tiki))}}),Ie.of({name:"TOML",extensions:["toml"],load(){return Le(()=>Promise.resolve().then(()=>Wfn),void 0,import.meta.url).then(e=>it(e.toml))}}),Ie.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return Le(()=>Promise.resolve().then(()=>Bfn),void 0,import.meta.url).then(e=>it(e.troff))}}),Ie.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return Le(()=>Promise.resolve().then(()=>hpn),void 0,import.meta.url).then(e=>it(e.ttcn))}}),Ie.of({name:"TTCN_CFG",extensions:["cfg"],load(){return Le(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>it(e.ttcnCfg))}}),Ie.of({name:"Turtle",extensions:["ttl"],load(){return Le(()=>Promise.resolve().then(()=>Opn),void 0,import.meta.url).then(e=>it(e.turtle))}}),Ie.of({name:"Web IDL",extensions:["webidl"],load(){return Le(()=>Promise.resolve().then(()=>lOn),void 0,import.meta.url).then(e=>it(e.webIDL))}}),Ie.of({name:"VB.NET",extensions:["vb"],load(){return Le(()=>Promise.resolve().then(()=>Epn),void 0,import.meta.url).then(e=>it(e.vb))}}),Ie.of({name:"VBScript",extensions:["vbs"],load(){return Le(()=>Promise.resolve().then(()=>Rpn),void 0,import.meta.url).then(e=>it(e.vbScript))}}),Ie.of({name:"Velocity",extensions:["vtl"],load(){return Le(()=>Promise.resolve().then(()=>Npn),void 0,import.meta.url).then(e=>it(e.velocity))}}),Ie.of({name:"Verilog",extensions:["v"],load(){return Le(()=>Promise.resolve().then(()=>I1e),void 0,import.meta.url).then(e=>it(e.verilog))}}),Ie.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return Le(()=>Promise.resolve().then(()=>Upn),void 0,import.meta.url).then(e=>it(e.vhdl))}}),Ie.of({name:"XQuery",extensions:["xy","xquery"],load(){return Le(()=>Promise.resolve().then(()=>vOn),void 0,import.meta.url).then(e=>it(e.xQuery))}}),Ie.of({name:"Yacas",extensions:["ys"],load(){return Le(()=>Promise.resolve().then(()=>POn),void 0,import.meta.url).then(e=>it(e.yacas))}}),Ie.of({name:"Z80",extensions:["z80"],load(){return Le(()=>Promise.resolve().then(()=>AOn),void 0,import.meta.url).then(e=>it(e.z80))}}),Ie.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return Le(()=>Promise.resolve().then(()=>l9),void 0,import.meta.url).then(e=>it(e.mscgen))}}),Ie.of({name:"Xù",extensions:["xu"],load(){return Le(()=>Promise.resolve().then(()=>l9),void 0,import.meta.url).then(e=>it(e.xu))}}),Ie.of({name:"MsGenny",extensions:["msgenny"],load(){return Le(()=>Promise.resolve().then(()=>l9),void 0,import.meta.url).then(e=>it(e.msgenny))}}),Ie.of({name:"Vue",extensions:["vue"],load(){return Le(()=>Promise.resolve().then(()=>ztn),void 0,import.meta.url).then(e=>e.vue())}}),Ie.of({name:"Angular Template",load(){return Le(()=>Promise.resolve().then(()=>lnn),void 0,import.meta.url).then(e=>e.angular())}})];class qJ{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=Lr(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),s=i.search(q6e(t,!1));return s<0?null:{from:r+s,to:this.pos,text:i.slice(s)}}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 f0e(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 yzt(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let s=1;s<i.length;s++)n[i[s]]=!0}let r=f0e(t)+f0e(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function O2(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:yzt(t);return i=>{let s=i.matchBefore(r);return s||i.explicit?{from:s?s.from:i.pos,options:t,validFor:n}:null}}function EN(e,t){return n=>{for(let r=Lr(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 p0e{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function F0(e){return e.selection.main.from}function q6e(e,t){var n;let{source:r}=e,i=t&&r[0]!="^",s=r[r.length-1]!="$";return!i&&!s?e:new RegExp(`${i?"^":""}(?:${r})${s?"$":""}`,(n=e.flags)!==null&&n!==void 0?n:e.ignoreCase?"i":"")}const zJ=yf.define();function bzt(e,t,n,r){let{main:i}=e.selection,s=n-i.from,a=r-i.from;return Object.assign(Object.assign({},e.changeByRange(o=>{if(o!=i&&n!=r&&e.sliceDoc(o.from+s,o.from+a)!=e.sliceDoc(n,r))return{range:o};let l=e.toText(t);return{changes:{from:o.from+s,to:r==i.from?o.to:o.from+a,insert:l},range:He.cursor(o.from+s+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const O0e=new WeakMap;function wzt(e){if(!Array.isArray(e))return e;let t=O0e.get(e);return t||O0e.set(e,t=O2(e)),t}const nA=Yn.define(),W_=Yn.define();class xzt{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=Cl(t,n),i=_h(r);this.chars.push(r);let s=t.slice(n,n+i),a=s.toUpperCase();this.folded.push(Cl(a==s?s.toLowerCase():a,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:s,byWord:a}=this;if(n.length==1){let y=Cl(t,0),w=_h(y),k=w==t.length?0:-100;if(y!=n[0])if(y==r[0])k+=-200;else return null;return this.ret(k,[0,w])}let o=t.indexOf(this.pattern);if(o==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(o<0){for(let y=0,w=Math.min(t.length,200);y<w&&c<l;){let k=Cl(t,y);(k==n[c]||k==r[c])&&(i[c++]=y),y+=_h(k)}if(c<l)return null}let u=0,d=0,h=!1,f=0,O=-1,g=-1,m=/[a-z]/.test(t),v=!0;for(let y=0,w=Math.min(t.length,200),k=0;y<w&&d<l;){let x=Cl(t,y);o<0&&(u<l&&x==n[u]&&(s[u++]=y),f<l&&(x==n[f]||x==r[f]?(f==0&&(O=y),g=y+1,f++):f=0));let S,T=x<255?x>=48&&x<=57||x>=97&&x<=122?2:x>=65&&x<=90?1:0:(S=yJ(x))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!y||T==1&&m||k==0&&T!=0)&&(n[d]==x||r[d]==x&&(h=!0)?a[d++]=y:a.length&&(v=!1)),k=T,y+=_h(x)}return d==l&&a[0]==0&&v?this.result(-100+(h?-200:0),a,t):f==l&&O==0?this.ret(-200-t.length+(g==t.length?0:-100),[0,g]):o>-1?this.ret(-700-t.length,[o,o+this.pattern.length]):f==l?this.ret(-900-t.length,[O,g]):d==l?this.result(-100+(h?-200:0)+-700+(v?0:-1100),a,t):n.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,t)}result(t,n,r){let i=[],s=0;for(let a of n){let o=a+(this.astral?_h(Cl(r,a)):1);s&&i[s-1]==a?i[s-1]=o:(i[s++]=a,i[s++]=o)}return this.ret(t-r.length,i)}}class Szt{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 Ma=Jt.define({combine(e){return bf(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:$zt,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=>g0e(t(r),n(r)),optionClass:(t,n)=>r=>g0e(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function g0e(e,t){return e?t?e+" "+t:e:t}function $zt(e,t,n,r,i,s){let a=e.textDirection==Gi.RTL,o=a,l=!1,c="top",u,d,h=t.left-i.left,f=i.right-t.right,O=r.right-r.left,g=r.bottom-r.top;if(o&&h<Math.min(O,f)?o=!1:!o&&f<Math.min(O,h)&&(o=!0),O<=(o?h:f))u=Math.max(i.top,Math.min(n.top,i.bottom-g))-t.top,d=Math.min(400,o?h:f);else{l=!0,d=Math.min(400,(a?t.right:i.right-t.left)-30);let y=i.bottom-t.bottom;y>=g||y>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let m=(t.bottom-t.top)/s.offsetHeight,v=(t.right-t.left)/s.offsetWidth;return{style:`${c}: ${u/m}px; max-width: ${d/v}px`,class:"cm-completionInfo-"+(l?a?"left-narrow":"right-narrow":o?"left":"right")}}function kzt(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,s){let a=document.createElement("span");a.className="cm-completionLabel";let o=n.displayLabel||n.label,l=0;for(let c=0;c<s.length;){let u=s[c++],d=s[c++];u>l&&a.appendChild(document.createTextNode(o.slice(l,u)));let h=a.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(o.slice(u,d))),h.className="cm-completionMatchedText",l=d}return l<o.length&&a.appendChild(document.createTextNode(o.slice(l))),a},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 rj(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 Tzt{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:s,selected:a}=i.open,o=t.state.facet(Ma);this.optionContent=kzt(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=rj(s.length,a,o.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,d;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(d=/-(\d+)$/.exec(u.id))&&+d[1]<c.length){this.applyCompletion(t,c[+d[1]]),l.preventDefault();return}}),this.dom.addEventListener("focusout",l=>{let c=t.state.field(this.stateField,!1);c&&c.tooltip&&t.state.facet(Ma).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:W_.of(null)})}),this.showOptions(s,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:s,selected:a,disabled:o}=r.open;(!i.open||i.open.options!=s)&&(this.range=rj(s.length,a,t.state.facet(Ma).maxRenderedOptions),this.showOptions(s,r.id)),this.updateSel(),o!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}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=rj(n.options.length,n.selected,this.view.state.facet(Ma).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 s=typeof i=="string"?document.createTextNode(i):i(r);if(!s)return;"then"in s?s.then(a=>{a&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(a,r)}).catch(a=>Xl(this.view.state,a,"completion info")):this.addInfoPane(s,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:s}=t;r.appendChild(i),this.infoDestroy=s||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&&Pzt(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(),s=this.space;if(!s){let a=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:a.clientWidth,bottom:a.clientHeight}}return i.top>Math.min(s.bottom,n.bottom)-10||i.bottom<Math.max(s.top,n.top)+10?null:this.view.state.facet(Ma).positionInfo(this.view,n,i,r,s,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",a=>{a.target==i&&a.preventDefault()});let s=null;for(let a=r.from;a<r.to;a++){let{completion:o,match:l}=t[a],{section:c}=o;if(c){let h=typeof c=="string"?c:c.name;if(h!=s&&(a>r.from||r.from==0))if(s=h,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let f=i.appendChild(document.createElement("completion-section"));f.textContent=h}}const u=i.appendChild(document.createElement("li"));u.id=n+"-"+a,u.setAttribute("role","option");let d=this.optionClass(o);d&&(u.className=d);for(let h of this.optionContent){let f=h(o,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 _zt(e,t){return n=>new Tzt(n,e,t)}function Pzt(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 m0e(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Czt(e,t){let n=[],r=null,i=c=>{n.push(c);let{section:u}=c.completion;if(u){r||(r=[]);let d=typeof u=="string"?u:u.name;r.some(h=>h.name==d)||r.push(typeof u=="string"?{name:d}:u)}},s=t.facet(Ma);for(let c of e)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let d of c.result.options)i(new p0e(d,c.source,u?u(d):[],1e9-n.length));else{let d=t.sliceDoc(c.from,c.to),h,f=s.filterStrict?new Szt(d):new xzt(d);for(let O of c.result.options)if(h=f.match(O.label)){let g=O.displayLabel?u?u(O,h.matched):[]:h.matched;i(new p0e(O,c.source,g,h.score+(O.boost||0)))}}}if(r){let c=Object.create(null),u=0,d=(h,f)=>{var O,g;return((O=h.rank)!==null&&O!==void 0?O:1e9)-((g=f.rank)!==null&&g!==void 0?g:1e9)||(h.name<f.name?-1:1)};for(let h of r.sort(d))u-=1e5,c[h.name]=u;for(let h of n){let{section:f}=h.completion;f&&(h.score+=c[typeof f=="string"?f:f.name])}}let a=[],o=null,l=s.compareCompletions;for(let c of n.sort((u,d)=>d.score-u.score||l(u.completion,d.completion))){let u=c.completion;!o||o.label!=u.label||o.detail!=u.detail||o.type!=null&&u.type!=null&&o.type!=u.type||o.apply!=u.apply||o.boost!=u.boost?a.push(c):m0e(c.completion)>m0e(o)&&(a[a.length-1]=c),o=c.completion}return a}class qb{constructor(t,n,r,i,s,a){this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=s,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new qb(this.options,v0e(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,s,a){if(i&&!a&&t.some(c=>c.isPending))return i.setDisabled();let o=Czt(t,n);if(!o.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Ma).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let u=0;u<o.length;u++)if(o[u].completion==c){l=u;break}}return new qb(o,v0e(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:Nzt,above:s.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new qb(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 qb(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class rA{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new rA(Azt,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Ma),s=(r.override||n.languageDataAt("autocomplete",F0(n)).map(wzt)).map(l=>(this.active.find(u=>u.source==l)||new bu(l,this.active.some(u=>u.state!=0)?1:0)).update(t,r));s.length==this.active.length&&s.every((l,c)=>l==this.active[c])&&(s=this.active);let a=this.open,o=t.effects.some(l=>l.is(UJ));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||s.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Ezt(s,this.active)||o?a=qb.build(s,n,this.id,a,r,o):a&&a.disabled&&!s.some(l=>l.isPending)&&(a=null),!a&&s.every(l=>!l.isPending)&&s.some(l=>l.hasResult())&&(s=s.map(l=>l.hasResult()?new bu(l.source,0):l));for(let l of t.effects)l.is(U6e)&&(a=a&&a.setSelected(l.value,this.id));return s==this.active&&a==this.open?this:new rA(s,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Qzt:Rzt}}function Ezt(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,s=r==t.length;if(i||s)return i==s;if(e[n++].result!=t[r++].result)return!1}}const Qzt={"aria-autocomplete":"list"},Rzt={};function v0e(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Azt=[];function z6e(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(zJ);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 bu{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=z6e(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new bu(i.source,0)),r&4&&i.state==0&&(i=new bu(this.source,1)),i=i.updateFor(t,r);for(let s of t.effects)if(s.is(nA))i=new bu(i.source,1,s.value);else if(s.is(W_))i=new bu(i.source,0);else if(s.is(UJ))for(let a of s.value)a.source==i.source&&(i=a);return i}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(F0(t.state))}}class g1 extends bu{constructor(t,n,r,i,s,a){super(t,3,n),this.limit=r,this.result=i,this.from=s,this.to=a}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 s=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=F0(t.state);if(o>a||!i||n&2&&(F0(t.startState)==this.from||o<this.limit))return new bu(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return Dzt(i.validFor,t.state,s,a)?new g1(this.source,this.explicit,l,i,s,a):i.update&&(i=i.update(i,s,a,new qJ(t.state,o,!1)))?new g1(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:F0(t.state)):new bu(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new g1(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new bu(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Dzt(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):q6e(e,!0).test(i)}const UJ=Yn.define({map(e,t){return e.map(n=>n.map(t))}}),U6e=Yn.define(),Ql=Va.define({create(){return rA.start()},update(e,t){return e.update(t)},provide:e=>[DJ.from(e,t=>t.tooltip),At.contentAttributes.from(e,t=>t.attrs)]});function WJ(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ql).active.find(i=>i.source==t.source);return r instanceof g1?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},bzt(e.state,n,r.from,r.to)),{annotations:zJ.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const Nzt=_zt(Ql,WJ);function cE(e,t="option"){return n=>{let r=n.state.field(Ql,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ma).interactionDelay)return!1;let i=1,s;t=="page"&&(s=O6e(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:a}=r.open.options,o=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:a-1;return o<0?o=t=="page"?0:a-1:o>=a&&(o=t=="page"?a-1:0),n.dispatch({effects:U6e.of(o)}),!0}}const Xzt=e=>{let t=e.state.field(Ql,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ma).interactionDelay?!1:WJ(e,t.open.options[t.open.selected])},y0e=e=>e.state.field(Ql,!1)?(e.dispatch({effects:nA.of(!0)}),!0):!1,Izt=e=>{let t=e.state.field(Ql,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:W_.of(null)}),!0)};class Fzt{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const Mzt=50,jzt=1e3,Lzt=vs.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(Ql).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ql),n=e.state.facet(Ma);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ql)==t)return;let r=e.transactions.some(s=>{let a=z6e(s,n);return a&8||(s.selection||s.docChanged)&&!(a&3)});for(let s=0;s<this.running.length;s++){let a=this.running[s];if(r||a.context.abortOnDocChange&&e.docChanged||a.updates.length+e.transactions.length>Mzt&&Date.now()-a.time>jzt){for(let o of a.context.abortListeners)try{o()}catch(l){Xl(this.view.state,l)}a.context.abortListeners=null,this.running.splice(s--,1)}else a.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(s=>s.effects.some(a=>a.is(nA)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(s=>s.isPending&&!this.running.some(a=>a.active.source==s.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let s of e.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(Ql);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(Ma).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=F0(t),r=new qJ(t,n,e.explicit,this.view),i=new Fzt(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(s=>{i.context.aborted||(i.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:W_.of(null)}),Xl(this.view.state,s)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ma).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Ma),r=this.view.state.field(Ql);for(let i=0;i<this.running.length;i++){let s=this.running[i];if(s.done===void 0)continue;if(this.running.splice(i--,1),s.done){let o=F0(s.updates.length?s.updates[0].startState:this.view.state),l=Math.min(o,s.done.from+(s.active.explicit?0:1)),c=new g1(s.active.source,s.active.explicit,l,s.done,s.done.from,(e=s.done.to)!==null&&e!==void 0?e:o);for(let u of s.updates)c=c.update(u,n);if(c.hasResult()){t.push(c);continue}}let a=r.active.find(o=>o.source==s.active.source);if(a&&a.isPending)if(s.done==null){let o=new bu(s.active.source,0);for(let l of s.updates)o=o.update(l,n);o.isPending||t.push(o)}else this.startQuery(a)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:UJ.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ql,!1);if(t&&t.tooltip&&this.view.state.facet(Ma).closeOnBlur){let n=t.open&&O6e(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:W_.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:nA.of(!1)}),20),this.composing=0}}}),qzt=typeof navigator=="object"&&/Win/.test(navigator.platform),zzt=cO.highest(At.domEventHandlers({keydown(e,t){let n=t.state.field(Ql,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(qzt&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(a=>a.source==r.source),s=r.completion.commitCharacters||i.result.commitCharacters;return s&&s.indexOf(e.key)>-1&&WJ(t,r),!1}})),W6e=At.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 Uzt{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class GJ{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,oo.TrackDel),r=t.mapPos(this.to,1,oo.TrackDel);return n==null||r==null?null:new GJ(this.field,n,r)}}class VJ{constructor(t,n){this.lines=t,this.fieldPositions=n}instantiate(t,n){let r=[],i=[n],s=t.doc.lineAt(n),a=/^\s*/.exec(s.text)[0];for(let l of this.lines){if(r.length){let c=a,u=/^\t*/.exec(l)[0].length;for(let d=0;d<u;d++)c+=t.facet(Mx);i.push(n+c.length-u),l=c+l.slice(u)}r.push(l),n+=l.length+1}let o=this.fieldPositions.map(l=>new GJ(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:o}}static parse(t){let n=[],r=[],i=[],s;for(let a of t.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(a);){let o=s[1]?+s[1]:null,l=s[2]||s[3]||"",c=-1,u=l.replace(/\\[{}]/g,d=>d[1]);for(let d=0;d<n.length;d++)(o!=null?n[d].seq==o:u&&n[d].name==u)&&(c=d);if(c<0){let d=0;for(;d<n.length&&(o==null||n[d].seq!=null&&n[d].seq<o);)d++;n.splice(d,0,{seq:o,name:u}),c=d;for(let h of i)h.field>=c&&h.field++}i.push(new Uzt(c,r.length,s.index,s.index+u.length)),a=a.slice(0,s.index)+l+a.slice(s.index+s[0].length)}a=a.replace(/\\([{}])/g,(o,l,c)=>{for(let u of i)u.line==r.length&&u.from>c&&(u.from--,u.to--);return l}),r.push(a)}return new VJ(r,i)}}let Wzt=Kt.widget({widget:new class extends zd{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),Gzt=Kt.mark({class:"cm-snippetField"});class Lx{constructor(t,n){this.ranges=t,this.active=n,this.deco=Kt.set(t.map(r=>(r.from==r.to?Wzt:Gzt).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 Lx(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 g2=Yn.define({map(e,t){return e&&e.map(t)}}),Vzt=Yn.define(),G_=Va.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(g2))return n.value;if(n.is(Vzt)&&e)return new Lx(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=>At.decorations.from(e,t=>t?t.deco:Kt.none)});function BJ(e,t){return He.create(e.filter(n=>n.field==t).map(n=>He.range(n.from,n.to)))}function Bzt(e){let t=VJ.parse(e);return(n,r,i,s)=>{let{text:a,ranges:o}=t.instantiate(n.state,i),{main:l}=n.state.selection,c={changes:{from:i,to:s==l.from?l.to:s,insert:Vr.of(a)},scrollIntoView:!0,annotations:r?[zJ.of(r),ua.userEvent.of("input.complete")]:void 0};if(o.length&&(c.selection=BJ(o,0)),o.some(u=>u.field>0)){let u=new Lx(o,0),d=c.effects=[g2.of(u)];n.state.field(G_,!1)===void 0&&d.push(Yn.appendConfig.of([G_,Jzt,eUt,W6e]))}n.dispatch(n.state.update(c))}}function G6e(e){return({state:t,dispatch:n})=>{let r=t.field(G_,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,s=e>0&&!r.ranges.some(a=>a.field==i+e);return n(t.update({selection:BJ(r.ranges,i),effects:g2.of(s?null:new Lx(r.ranges,i)),scrollIntoView:!0})),!0}}const Yzt=({state:e,dispatch:t})=>e.field(G_,!1)?(t(e.update({effects:g2.of(null)})),!0):!1,Zzt=G6e(1),Hzt=G6e(-1),Kzt=[{key:"Tab",run:Zzt,shift:Hzt},{key:"Escape",run:Yzt}],b0e=Jt.define({combine(e){return e.length?e[0]:Kzt}}),Jzt=cO.highest(dy.compute([b0e],e=>e.facet(b0e)));function Li(e,t){return Object.assign(Object.assign({},t),{apply:Bzt(e)})}const eUt=At.domEventHandlers({mousedown(e,t){let n=t.state.field(G_,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(s=>s.from<=r&&s.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:BJ(n.ranges,i.field),effects:g2.of(n.ranges.some(s=>s.field>i.field)?new Lx(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),V_={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},_0=Yn.define({map(e,t){let n=t.mapPos(e,-1,oo.TrackAfter);return n??void 0}}),YJ=new class extends Sv{};YJ.startSide=1;YJ.endSide=-1;const V6e=Va.define({create(){return Ir.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(_0)&&(e=e.update({add:[YJ.range(n.value,n.value+1)]}));return e}});function tUt(){return[rUt,V6e]}const ij="()[]{}<>«»»«[]{}";function B6e(e){for(let t=0;t<ij.length;t+=2)if(ij.charCodeAt(t)==e)return ij.charAt(t+1);return yJ(e<128?e:e+1)}function Y6e(e,t){return e.languageDataAt("closeBrackets",t)[0]||V_}const nUt=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),rUt=At.inputHandler.of((e,t,n,r)=>{if((nUt?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&_h(Cl(r,0))==1||t!=i.from||n!=i.to)return!1;let s=aUt(e.state,r);return s?(e.dispatch(s),!0):!1}),iUt=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=Y6e(e,e.selection.main.head).brackets||V_.brackets,i=null,s=e.changeByRange(a=>{if(a.empty){let o=oUt(e.doc,a.head);for(let l of r)if(l==o&&QN(e.doc,a.head)==B6e(Cl(l,0)))return{changes:{from:a.head-l.length,to:a.head+l.length},range:He.cursor(a.head-l.length)}}return{range:i=a}});return i||t(e.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},sUt=[{key:"Backspace",run:iUt}];function aUt(e,t){let n=Y6e(e,e.selection.main.head),r=n.brackets||V_.brackets;for(let i of r){let s=B6e(Cl(i,0));if(t==i)return s==i?uUt(e,i,r.indexOf(i+i+i)>-1,n):lUt(e,i,s,n.before||V_.before);if(t==s&&Z6e(e,e.selection.main.from))return cUt(e,i,s)}return null}function Z6e(e,t){let n=!1;return e.field(V6e).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function QN(e,t){let n=e.sliceString(t,t+2);return n.slice(0,_h(Cl(n,0)))}function oUt(e,t){let n=e.sliceString(t-2,t);return _h(Cl(n,0))==n.length?n:n.slice(1)}function lUt(e,t,n,r){let i=null,s=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:_0.of(a.to+t.length),range:He.range(a.anchor+t.length,a.head+t.length)};let o=QN(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:_0.of(a.head+t.length),range:He.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function cUt(e,t,n){let r=null,i=e.changeByRange(s=>s.empty&&QN(e.doc,s.head)==n?{changes:{from:s.head,to:s.head+n.length,insert:n},range:He.cursor(s.head+n.length)}:r={range:s});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function uUt(e,t,n,r){let i=r.stringPrefixes||V_.stringPrefixes,s=null,a=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:t,from:o.to}],effects:_0.of(o.to+t.length),range:He.range(o.anchor+t.length,o.head+t.length)};let l=o.head,c=QN(e.doc,l),u;if(c==t){if(w0e(e,l))return{changes:{insert:t+t,from:l},effects:_0.of(l+t.length),range:He.cursor(l+t.length)};if(Z6e(e,l)){let h=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+h.length,insert:h},range:He.cursor(l+h.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=x0e(e,l-2*t.length,i))>-1&&w0e(e,u))return{changes:{insert:t+t+t+t,from:l},effects:_0.of(l+t.length),range:He.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=ss.Word&&x0e(e,l,i)>-1&&!dUt(e,l,t,i))return{changes:{insert:t+t,from:l},effects:_0.of(l+t.length),range:He.cursor(l+t.length)}}return{range:s=o}});return s?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function w0e(e,t){let n=Lr(e).resolveInner(t+1);return n.parent&&n.from==t}function dUt(e,t,n,r){let i=Lr(e).resolveInner(t,-1),s=r.reduce((a,o)=>Math.max(a,o.length),0);for(let a=0;a<5;a++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+s)),l=o.indexOf(n);if(!l||l>-1&&r.indexOf(o.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 x0e(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 s=t-i.length;if(e.sliceDoc(s,t)==i&&r(e.sliceDoc(s-1,s))!=ss.Word)return s}return-1}function hUt(e={}){return[zzt,Ql,Ma.of(e),Lzt,fUt,W6e]}const H6e=[{key:"Ctrl-Space",run:y0e},{mac:"Alt-`",run:y0e},{key:"Escape",run:Izt},{key:"ArrowDown",run:cE(!0)},{key:"ArrowUp",run:cE(!1)},{key:"PageDown",run:cE(!0,"page")},{key:"PageUp",run:cE(!1,"page")},{key:"Enter",run:Xzt}],fUt=cO.highest(dy.computeN([Ma],e=>e.facet(Ma).defaultKeymap?[H6e]:[]));class iA{static create(t,n,r,i,s){let a=i+(i<<8)+t+(n<<4)|0;return new iA(t,n,r,a,s,[],[])}constructor(t,n,r,i,s,a,o){this.type=t,this.value=n,this.from=r,this.hash=i,this.end=s,this.children=a,this.positions=o,this.hashProp=[[Wn.contextHash,i]]}addChild(t,n){t.prop(Wn.contextHash)!=this.hash&&(t=new $r(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 $r(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,s,a)=>new $r(ha.none,i,s,a,this.hashProp)})}}var Pt;(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"})(Pt||(Pt={}));class pUt{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}class OUt{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 wk(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 S0e(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==Pt.OrderedList?KJ:HJ)(n,t,!1);return r>0&&(e.type!=Pt.BulletList||ZJ(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const K6e={[Pt.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(Er(Pt.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(Uu(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[Pt.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Pt.OrderedList]:S0e,[Pt.BulletList]:S0e,[Pt.Document](){return!0}};function Uu(e){return e==32||e==9||e==10||e==13}function wk(e,t=0){for(;t<e.length&&Uu(e.charCodeAt(t));)t++;return t}function $0e(e,t,n){for(;t>n&&Uu(e.charCodeAt(t-1));)t--;return t}function J6e(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 eIe(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function ZJ(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 s=e.text.charCodeAt(i);if(s==e.next)r++;else if(!Uu(s))return-1}return n&&e.next==45&&rIe(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(oIe.SetextHeading)>-1||r<3?-1:1}function tIe(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function HJ(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||Uu(e.text.charCodeAt(e.pos+1)))&&(!n||tIe(t,Pt.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function KJ(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&&!Uu(e.text.charCodeAt(r+1))||n&&!tIe(t,Pt.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function nIe(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 rIe(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&&Uu(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const lV=/^[ \t]*$/,iIe=/-->/,sIe=/\?>/,cV=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,iIe],[/^\s*<\?/,sIe],[/^\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,lV],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,lV]];function aIe(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,s=cV.length-(n?1:0);i<s;i++)if(cV[i][0].test(r))return i;return-1}function k0e(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 zm(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Pt.CodeText?e[r].to=n:e.push(Er(Pt.CodeText,t,n))}const uE={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,s=e.lineStart+t.text.length,a=[],o=[];for(zm(a,i,s);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){zm(o,e.lineStart-1,e.lineStart);for(let l of t.markers)o.push(l)}else{if(t.indent<n)break;{if(o.length){for(let c of o)c.type==Pt.CodeText?zm(a,c.from,c.to):a.push(c);o=[]}zm(a,e.lineStart-1,e.lineStart);for(let c of t.markers)a.push(c);s=e.lineStart+t.text.length;let l=e.lineStart+t.findColumn(t.baseIndent+4);l<s&&zm(a,l,s)}}return o.length&&(o=o.filter(l=>l.type!=Pt.CodeText),o.length&&(t.markers=o.concat(t.markers))),e.addNode(e.buffer.writeElements(a,-i).finish(Pt.CodeBlock,s-i),i),!0},FencedCode(e,t){let n=J6e(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,s=n-t.pos,a=t.skipSpace(n),o=$0e(t.text,t.text.length,a),l=[Er(Pt.CodeMark,r,r+s)];a<o&&l.push(Er(Pt.CodeInfo,e.lineStart+a,e.lineStart+o));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>=s&&t.skipSpace(u)==t.text.length){for(let d of t.markers)l.push(d);l.push(Er(Pt.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||zm(l,e.lineStart-1,e.lineStart);for(let f of t.markers)l.push(f);let d=e.lineStart+t.basePos,h=e.lineStart+t.text.length;d<h&&zm(l,d,h)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Pt.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=eIe(t);return n<0?!1:(e.startContext(Pt.Blockquote,t.pos),e.addNode(Pt.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(ZJ(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Pt.HorizontalRule,n),!0},BulletList(e,t){let n=HJ(t,e,!1);if(n<0)return!1;e.block.type!=Pt.BulletList&&e.startContext(Pt.BulletList,t.basePos,t.next);let r=k0e(t,t.pos+1);return e.startContext(Pt.ListItem,t.basePos,r-t.baseIndent),e.addNode(Pt.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=KJ(t,e,!1);if(n<0)return!1;e.block.type!=Pt.OrderedList&&e.startContext(Pt.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=k0e(t,t.pos+n);return e.startContext(Pt.ListItem,t.basePos,r-t.baseIndent),e.addNode(Pt.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=nIe(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,s=$0e(t.text,t.text.length,r),a=s;for(;a>r&&t.text.charCodeAt(a-1)==t.next;)a--;(a==s||a==r||!Uu(t.text.charCodeAt(a-1)))&&(a=t.text.length);let o=e.buffer.write(Pt.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,a),i+n+1),-i);a<t.text.length&&o.write(Pt.HeaderMark,a-r,s-r);let l=o.finish(Pt.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=aIe(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=cV[n][1],s=[],a=i!=lV;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){a=!1;break}for(let c of t.markers)s.push(c)}a&&e.nextLine();let o=i==iIe?Pt.CommentBlock:i==sIe?Pt.ProcessingInstructionBlock:Pt.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(s,-r).finish(o,l-r),r),!0},SetextHeading:void 0};class gUt{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+`
1204
1204
  `+n.scrub(),s=this.advance(i);return s>-1&&s<i.length?this.complete(t,r,s):!1}finish(t,n){return(this.stage==2||this.stage==3)&&wk(n.content,this.pos)==n.content.length?this.complete(t,n,n.content.length):!1}complete(t,n,r){return t.addLeafElement(n,Er(Pt.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(gIe(t,this.pos,this.start,!0)))return-1;if(t.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(Er(Pt.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(pIe(t,wk(t,this.pos),this.start)))return-1}else if(this.stage==2){let n=wk(t,this.pos),r=0;if(n>this.pos){let i=OIe(t,n,this.start);if(i){let s=sj(t,i.to-this.start);s>0&&(this.nextStage(i),r=s)}}return r||(r=sj(t,this.pos)),r>0&&r<t.length?r:-1}else return sj(t,this.pos)}}}function sj(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!Uu(n))return-1}return t}class mUt{nextLine(t,n,r){let i=n.depth<t.stack.length?-1:rIe(n),s=n.next;if(i<0)return!1;let a=Er(Pt.HeaderMark,t.lineStart+n.pos,t.lineStart+i);return t.nextLine(),t.addLeafElement(r,Er(s==61?Pt.SetextHeading1:Pt.SetextHeading2,r.start,t.prevLineEnd(),[...t.parser.parseInline(r.content,r.start),a])),!0}finish(){return!1}}const oIe={LinkReference(e,t){return t.content.charCodeAt(0)==91?new gUt(t):null},SetextHeading(){return new mUt}},vUt=[(e,t)=>nIe(t)>=0,(e,t)=>J6e(t)>=0,(e,t)=>eIe(t)>=0,(e,t)=>HJ(t,e,!0)>=0,(e,t)=>KJ(t,e,!0)>=0,(e,t)=>ZJ(t,e,!0)>=0,(e,t)=>aIe(t,e,!0)>=0],yUt={text:"",end:0};class bUt{constructor(t,n,r,i){this.parser=t,this.input=n,this.ranges=i,this.line=new OUt,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=iA.create(Pt.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new $Ut(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 s=t.markers[r++];this.addNode(s.type,s.from,s.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 pUt(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+=`
1205
1205
  `+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=mIe(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=yUt;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 s=this.ranges[i].from,a=this.lineChunkAt(s);n.end=s+a.length,n.text=n.text.slice(0,this.ranges[i-1].to-r)+a,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],s=this.parser.skipContextMarkup[i.type];if(!s)throw new Error("Unhandled block context "+Pt[i.type]);if(!s(i,this,t))break;t.forward()}}lineChunkAt(t){let n=this.input.chunk(t),r;if(this.input.lineChunks)r=n==`
1206
1206
  `?"":n;else{let i=n.indexOf(`
@@ -1453,7 +1453,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Hl=st,Ur=Ht);const vl=
1453
1453
  * LICENSE file in the root directory of this source tree.
1454
1454
  */var DTe;function PJn(){if(DTe)return m$;DTe=1;var e=H,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(o,l,c){var u,d={},h=null,f=null;c!==void 0&&(h=""+c),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(f=l.ref);for(u in l)r.call(l,u)&&!s.hasOwnProperty(u)&&(d[u]=l[u]);if(o&&o.defaultProps)for(u in l=o.defaultProps,l)d[u]===void 0&&(d[u]=l[u]);return{$$typeof:t,type:o,key:h,ref:f,props:d,_owner:i.current}}return m$.Fragment=n,m$.jsx=a,m$.jsxs=a,m$}var NTe;function CJn(){return NTe||(NTe=1,ATe.exports=PJn()),ATe.exports}var EJn=CJn();/*! shepherd.js 14.5.0 */function QJn(e){return e instanceof Element}function lx(e){return e instanceof HTMLElement}function Jg(e){return typeof e=="function"}function IP(e){return typeof e=="string"}function Do(e){return e===void 0}class nre{on(t,n,r,i=!1){var s;return Do(this.bindings)&&(this.bindings={}),Do(this.bindings[t])&&(this.bindings[t]=[]),(s=this.bindings[t])==null||s.push({handler:n,ctx:r,once:i}),this}once(t,n,r){return this.on(t,n,r,!0)}off(t,n){if(Do(this.bindings)||Do(this.bindings[t]))return this;if(Do(n))delete this.bindings[t];else{var r;(r=this.bindings[t])==null||r.forEach((i,s)=>{if(i.handler===n){var a;(a=this.bindings[t])==null||a.splice(s,1)}})}return this}trigger(t,...n){if(!Do(this.bindings)&&this.bindings[t]){var r;(r=this.bindings[t])==null||r.forEach((i,s)=>{const{ctx:a,handler:o,once:l}=i,c=a||this;if(o.apply(c,n),l){var u;(u=this.bindings[t])==null||u.splice(s,1)}})}return this}}function zl(){return zl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},zl.apply(null,arguments)}function rre(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}const Sm={defaultMerge:Symbol("deepmerge-ts: default merge"),skip:Symbol("deepmerge-ts: skip")};Sm.defaultMerge;function RJn(e,t){return t}function AJn(e,t){return e.filter(n=>n!==void 0)}var XTe;(function(e){e[e.NOT=0]="NOT",e[e.RECORD=1]="RECORD",e[e.ARRAY=2]="ARRAY",e[e.SET=3]="SET",e[e.MAP=4]="MAP",e[e.OTHER=5]="OTHER"})(XTe||(XTe={}));function ITe(e){return typeof e!="object"||e===null?0:Array.isArray(e)?2:XJn(e)?1:e instanceof Set?3:e instanceof Map?4:5}function DJn(e){const t=new Set;for(const n of e)for(const r of[...Object.keys(n),...Object.getOwnPropertySymbols(n)])t.add(r);return t}function NJn(e,t){return typeof e=="object"&&Object.prototype.propertyIsEnumerable.call(e,t)}function VYe(e){return{*[Symbol.iterator](){for(const t of e)for(const n of t)yield n}}}const FTe=new Set(["[object Object]","[object Module]"]);function XJn(e){if(!FTe.has(Object.prototype.toString.call(e)))return!1;const{constructor:t}=e;if(t===void 0)return!0;const n=t.prototype;return!(n===null||typeof n!="object"||!FTe.has(Object.prototype.toString.call(n))||!n.hasOwnProperty("isPrototypeOf"))}function IJn(e,t,n){const r={};for(const i of DJn(e)){const s=[];for(const l of e)NJn(l,i)&&s.push(l[i]);if(s.length===0)continue;const a=t.metaDataUpdater(n,{key:i,parents:e}),o=BYe(s,t,a);o!==Sm.skip&&(i==="__proto__"?Object.defineProperty(r,i,{value:o,configurable:!0,enumerable:!0,writable:!0}):r[i]=o)}return r}function FJn(e){return e.flat()}function MJn(e){return new Set(VYe(e))}function jJn(e){return new Map(VYe(e))}function LJn(e){return e.at(-1)}const TQ={mergeRecords:IJn,mergeArrays:FJn,mergeSets:MJn,mergeMaps:jJn,mergeOthers:LJn};function ire(...e){return qJn({})(...e)}function qJn(e,t){const n=zJn(e,r);function r(...i){return BYe(i,n,t)}return r}function zJn(e,t){var n,r,i;return{defaultMergeFunctions:TQ,mergeFunctions:zl({},TQ,Object.fromEntries(Object.entries(e).filter(([s,a])=>Object.hasOwn(TQ,s)).map(([s,a])=>a===!1?[s,TQ.mergeOthers]:[s,a]))),metaDataUpdater:(n=e.metaDataUpdater)!=null?n:RJn,deepmerge:t,useImplicitDefaultMerging:(r=e.enableImplicitDefaultMerging)!=null?r:!1,filterValues:e.filterValues===!1?void 0:(i=e.filterValues)!=null?i:AJn,actions:Sm}}function BYe(e,t,n){var r;const i=(r=t.filterValues==null?void 0:t.filterValues(e,n))!=null?r:e;if(i.length===0)return;if(i.length===1)return jq(i,t,n);const s=ITe(i[0]);if(s!==0&&s!==5){for(let a=1;a<i.length;a++)if(ITe(i[a])!==s)return jq(i,t,n)}switch(s){case 1:return UJn(i,t,n);case 2:return WJn(i,t,n);case 3:return GJn(i,t,n);case 4:return VJn(i,t,n);default:return jq(i,t,n)}}function UJn(e,t,n){const r=t.mergeFunctions.mergeRecords(e,t,n);return r===Sm.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeRecords!==t.defaultMergeFunctions.mergeRecords?t.defaultMergeFunctions.mergeRecords(e,t,n):r}function WJn(e,t,n){const r=t.mergeFunctions.mergeArrays(e,t,n);return r===Sm.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeArrays!==t.defaultMergeFunctions.mergeArrays?t.defaultMergeFunctions.mergeArrays(e):r}function GJn(e,t,n){const r=t.mergeFunctions.mergeSets(e,t,n);return r===Sm.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeSets!==t.defaultMergeFunctions.mergeSets?t.defaultMergeFunctions.mergeSets(e):r}function VJn(e,t,n){const r=t.mergeFunctions.mergeMaps(e,t,n);return r===Sm.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeMaps!==t.defaultMergeFunctions.mergeMaps?t.defaultMergeFunctions.mergeMaps(e):r}function jq(e,t,n){const r=t.mergeFunctions.mergeOthers(e,t,n);return r===Sm.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeOthers!==t.defaultMergeFunctions.mergeOthers?t.defaultMergeFunctions.mergeOthers(e):r}function sre(e){const t=Object.getOwnPropertyNames(e.constructor.prototype);for(let n=0;n<t.length;n++){const r=t[n],i=e[r];r!=="constructor"&&typeof i=="function"&&(e[r]=i.bind(e))}return e}function BJn(e,t){return n=>{if(e.isOpen()){const r=e.el&&n.currentTarget===e.el;(!Do(t)&&n.currentTarget.matches(t)||r)&&e.tour.next()}}}function YJn(e){const{event:t,selector:n}=e.options.advanceOn||{};if(t){const r=BJn(e,n);let i=null;if(!Do(n)&&(i=document.querySelector(n),!i))return console.error(`No element was found for the selector supplied to advanceOn: ${n}`);i?(i.addEventListener(t,r),e.on("destroy",()=>i.removeEventListener(t,r))):(document.body.addEventListener(t,r,!0),e.on("destroy",()=>document.body.removeEventListener(t,r,!0)))}else return console.error("advanceOn was defined, but no event name was passed.")}class ZJn{constructor(t){}}class HJn{constructor(t,n){}}function YYe(e){return!IP(e)||e===""?"":e.charAt(e.length-1)!=="-"?`${e}-`:e}function KJn(e){const t=e.options.attachTo||{},n=Object.assign({},t);if(Jg(n.element)&&(n.element=n.element.call(e)),IP(n.element)){try{n.element=document.querySelector(n.element)}catch{}n.element||console.error(`The element for this Shepherd step was not found ${t.element}`)}return n}function JJn(e){return e.options.extraHighlights?e.options.extraHighlights.flatMap(t=>Array.from(document.querySelectorAll(t))):[]}function ZYe(e){return e==null?!0:!e.element||!e.on}function HYe(){let e=Date.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=(e+Math.random()*16)%16|0;return e=Math.floor(e/16),(t=="x"?n:n&3|8).toString(16)})}const eer=["top","right","bottom","left"],MTe=["start","end"],jTe=eer.reduce((e,t)=>e.concat(t,t+"-"+MTe[0],t+"-"+MTe[1]),[]),cx=Math.min,tv=Math.max,D3=Math.round,_Q=Math.floor,Kh=e=>({x:e,y:e}),ter={left:"right",right:"left",bottom:"top",top:"bottom"},ner={start:"end",end:"start"};function QY(e,t,n){return tv(e,cx(t,n))}function Yv(e,t){return typeof e=="function"?e(t):e}function eO(e){return e.split("-")[0]}function Ap(e){return e.split("-")[1]}function are(e){return e==="x"?"y":"x"}function ore(e){return e==="y"?"height":"width"}function ux(e){return["top","bottom"].includes(eO(e))?"y":"x"}function lre(e){return are(ux(e))}function KYe(e,t,n){n===void 0&&(n=!1);const r=Ap(e),i=lre(e),s=ore(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=X3(a)),[a,X3(a)]}function rer(e){const t=X3(e);return[N3(e),t,N3(t)]}function N3(e){return e.replace(/start|end/g,t=>ner[t])}function ier(e,t,n){const r=["left","right"],i=["right","left"],s=["top","bottom"],a=["bottom","top"];switch(e){case"top":case"bottom":return n?t?i:r:t?r:i;case"left":case"right":return t?s:a;default:return[]}}function ser(e,t,n,r){const i=Ap(e);let s=ier(eO(e),n==="start",r);return i&&(s=s.map(a=>a+"-"+i),t&&(s=s.concat(s.map(N3)))),s}function X3(e){return e.replace(/left|right|bottom|top/g,t=>ter[t])}function aer(e){return zl({top:0,right:0,bottom:0,left:0},e)}function JYe(e){return typeof e!="number"?aer(e):{top:e,right:e,bottom:e,left:e}}function I3(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}const oer=["crossAxis","alignment","allowedPlacements","autoAlignment"],ler=["mainAxis","crossAxis","fallbackPlacements","fallbackStrategy","fallbackAxisSideDirection","flipAlignment"],cer=["mainAxis","crossAxis","limiter"];function LTe(e,t,n){let{reference:r,floating:i}=e;const s=ux(t),a=lre(t),o=ore(a),l=eO(t),c=s==="y",u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,h=r[o]/2-i[o]/2;let f;switch(l){case"top":f={x:u,y:r.y-i.height};break;case"bottom":f={x:u,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:d};break;case"left":f={x:r.x-i.width,y:d};break;default:f={x:r.x,y:r.y}}switch(Ap(t)){case"start":f[a]-=h*(n&&c?-1:1);break;case"end":f[a]+=h*(n&&c?-1:1);break}return f}const uer=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:a}=n,o=s.filter(Boolean),l=await(a.isRTL==null?void 0:a.isRTL(t));let c=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=LTe(c,r,l),h=r,f={},O=0;for(let g=0;g<o.length;g++){const{name:m,fn:v}=o[g],{x:y,y:w,data:k,reset:x}=await v({x:u,y:d,initialPlacement:r,placement:h,strategy:i,middlewareData:f,rects:c,platform:a,elements:{reference:e,floating:t}});u=y??u,d=w??d,f=zl({},f,{[m]:zl({},f[m],k)}),x&&O<=50&&(O++,typeof x=="object"&&(x.placement&&(h=x.placement),x.rects&&(c=x.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=LTe(c,h,l)),g=-1)}return{x:u,y:d,placement:h,strategy:i,middlewareData:f}};async function cre(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:a,elements:o,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:f=0}=Yv(t,e),O=JYe(f),g=o[h?d==="floating"?"reference":"floating":d],m=I3(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(o.floating)),boundary:c,rootBoundary:u,strategy:l})),v=d==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(o.floating)),w=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},k=I3(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:v,offsetParent:y,strategy:l}):v);return{top:(m.top-k.top+O.top)/w.y,bottom:(k.bottom-m.bottom+O.bottom)/w.y,left:(m.left-k.left+O.left)/w.x,right:(k.right-m.right+O.right)/w.x}}const der=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:a,elements:o,middlewareData:l}=t,{element:c,padding:u=0}=Yv(e,t)||{};if(c==null)return{};const d=JYe(u),h={x:n,y:r},f=lre(i),O=ore(f),g=await a.getDimensions(c),m=f==="y",v=m?"top":"left",y=m?"bottom":"right",w=m?"clientHeight":"clientWidth",k=s.reference[O]+s.reference[f]-h[f]-s.floating[O],x=h[f]-s.reference[f],S=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c));let T=S?S[w]:0;(!T||!await(a.isElement==null?void 0:a.isElement(S)))&&(T=o.floating[w]||s.floating[O]);const _=k/2-x/2,P=T/2-g[O]/2-1,E=cx(d[v],P),C=cx(d[y],P),Q=E,D=T-g[O]-C,F=T/2-g[O]/2+_,I=QY(Q,F,D),U=!l.arrow&&Ap(i)!=null&&F!==I&&s.reference[O]/2-(F<Q?E:C)-g[O]/2<0,q=U?F<Q?F-Q:F-D:0;return{[f]:h[f]+q,data:zl({[f]:I,centerOffset:F-I-q},U&&{alignmentOffset:q}),reset:U}}});function her(e,t,n){return(e?[...n.filter(r=>Ap(r)===e),...n.filter(r=>Ap(r)!==e)]:n.filter(r=>eO(r)===r)).filter(r=>e?Ap(r)===e||(t?N3(r)!==r:!1):!0)}const fer=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,r,i;const{rects:s,middlewareData:a,placement:o,platform:l,elements:c}=t,u=Yv(e,t),{crossAxis:d=!1,alignment:h,allowedPlacements:f=jTe,autoAlignment:O=!0}=u,g=rre(u,oer),m=h!==void 0||f===jTe?her(h||null,O,f):f,v=await cre(t,g),y=((n=a.autoPlacement)==null?void 0:n.index)||0,w=m[y];if(w==null)return{};const k=KYe(w,s,await(l.isRTL==null?void 0:l.isRTL(c.floating)));if(o!==w)return{reset:{placement:m[0]}};const x=[v[eO(w)],v[k[0]],v[k[1]]],S=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:w,overflows:x}],T=m[y+1];if(T)return{data:{index:y+1,overflows:S},reset:{placement:T}};const _=S.map(E=>{const C=Ap(E.placement);return[E.placement,C&&d?E.overflows.slice(0,2).reduce((Q,D)=>Q+D,0):E.overflows[0],E.overflows]}).sort((E,C)=>E[1]-C[1]),P=((i=_.filter(E=>E[2].slice(0,Ap(E[0])?2:3).every(C=>C<=0))[0])==null?void 0:i[0])||_[0][0];return P!==o?{data:{index:y+1,overflows:S},reset:{placement:P}}:{}}}},per=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:a,initialPlacement:o,platform:l,elements:c}=t,u=Yv(e,t),{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:f,fallbackStrategy:O="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:m=!0}=u,v=rre(u,ler);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=eO(i),w=ux(o),k=eO(o)===o,x=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=f||(k||!m?[X3(o)]:rer(o)),T=g!=="none";!f&&T&&S.push(...ser(o,m,g,x));const _=[o,...S],P=await cre(t,v),E=[];let C=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&E.push(P[y]),h){const I=KYe(i,a,x);E.push(P[I[0]],P[I[1]])}if(C=[...C,{placement:i,overflows:E}],!E.every(I=>I<=0)){var Q,D;const I=(((Q=s.flip)==null?void 0:Q.index)||0)+1,U=_[I];if(U)return{data:{index:I,overflows:C},reset:{placement:U}};let q=(D=C.filter(Z=>Z.overflows[0]<=0).sort((Z,W)=>Z.overflows[1]-W.overflows[1])[0])==null?void 0:D.placement;if(!q)switch(O){case"bestFit":{var F;const Z=(F=C.filter(W=>{if(T){const M=ux(W.placement);return M===w||M==="y"}return!0}).map(W=>[W.placement,W.overflows.filter(M=>M>0).reduce((M,J)=>M+J,0)]).sort((W,M)=>W[1]-M[1])[0])==null?void 0:F[0];Z&&(q=Z);break}case"initialPlacement":q=o;break}if(i!==q)return{reset:{placement:q}}}return{}}}},Oer=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i}=t,s=Yv(e,t),{mainAxis:a=!0,crossAxis:o=!1,limiter:l={fn:v=>{let{x:y,y:w}=v;return{x:y,y:w}}}}=s,c=rre(s,cer),u={x:n,y:r},d=await cre(t,c),h=ux(eO(i)),f=are(h);let O=u[f],g=u[h];if(a){const v=f==="y"?"top":"left",y=f==="y"?"bottom":"right",w=O+d[v],k=O-d[y];O=QY(w,O,k)}if(o){const v=h==="y"?"top":"left",y=h==="y"?"bottom":"right",w=g+d[v],k=g-d[y];g=QY(w,g,k)}const m=l.fn(zl({},t,{[f]:O,[h]:g}));return zl({},m,{data:{x:m.x-n,y:m.y-r}})}}},ger=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:a}=t,{offset:o=0,mainAxis:l=!0,crossAxis:c=!0}=Yv(e,t),u={x:n,y:r},d=ux(i),h=are(d);let f=u[h],O=u[d];const g=Yv(o,t),m=typeof g=="number"?{mainAxis:g,crossAxis:0}:zl({mainAxis:0,crossAxis:0},g);if(l){const w=h==="y"?"height":"width",k=s.reference[h]-s.floating[w]+m.mainAxis,x=s.reference[h]+s.reference[w]-m.mainAxis;f<k?f=k:f>x&&(f=x)}if(c){var v,y;const w=h==="y"?"width":"height",k=["top","left"].includes(eO(i)),x=s.reference[d]-s.floating[w]+(k&&((v=a.offset)==null?void 0:v[d])||0)+(k?0:m.crossAxis),S=s.reference[d]+s.reference[w]+(k?0:((y=a.offset)==null?void 0:y[d])||0)-(k?m.crossAxis:0);O<x?O=x:O>S&&(O=S)}return{[h]:f,[d]:O}}}};function UX(){return typeof window<"u"}function nS(e){return eZe(e)?(e.nodeName||"").toLowerCase():"#document"}function Dc(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function kf(e){var t;return(t=(eZe(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function eZe(e){return UX()?e instanceof Node||e instanceof Dc(e).Node:!1}function Fd(e){return UX()?e instanceof Element||e instanceof Dc(e).Element:!1}function hf(e){return UX()?e instanceof HTMLElement||e instanceof Dc(e).HTMLElement:!1}function qTe(e){return!UX()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Dc(e).ShadowRoot}function U2(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Md(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(i)}function mer(e){return["table","td","th"].includes(nS(e))}function WX(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function ure(e){const t=dre(),n=Fd(e)?Md(e):e;return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function ver(e){let t=em(e);for(;hf(t)&&!dx(t);){if(ure(t))return t;if(WX(t))return null;t=em(t)}return null}function dre(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function dx(e){return["html","body","#document"].includes(nS(e))}function Md(e){return Dc(e).getComputedStyle(e)}function GX(e){return Fd(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function em(e){if(nS(e)==="html")return e;const t=e.assignedSlot||e.parentNode||qTe(e)&&e.host||kf(e);return qTe(t)?t.host:t}function tZe(e){const t=em(e);return dx(t)?e.ownerDocument?e.ownerDocument.body:e.body:hf(t)&&U2(t)?t:tZe(t)}function FP(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=tZe(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),a=Dc(i);if(s){const o=RY(a);return t.concat(a,a.visualViewport||[],U2(i)?i:[],o&&n?FP(o):[])}return t.concat(i,FP(i,[],n))}function RY(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function nZe(e){const t=Md(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=hf(e),s=i?e.offsetWidth:n,a=i?e.offsetHeight:r,o=D3(n)!==s||D3(r)!==a;return o&&(n=s,r=a),{width:n,height:r,$:o}}function hre(e){return Fd(e)?e:e.contextElement}function N1(e){const t=hre(e);if(!hf(t))return Kh(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=nZe(t);let a=(s?D3(n.width):n.width)/r,o=(s?D3(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!o||!Number.isFinite(o))&&(o=1),{x:a,y:o}}const yer=Kh(0);function rZe(e){const t=Dc(e);return!dre()||!t.visualViewport?yer:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function ber(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Dc(e)?!1:t}function Zv(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=hre(e);let a=Kh(1);t&&(r?Fd(r)&&(a=N1(r)):a=N1(e));const o=ber(s,n,r)?rZe(s):Kh(0);let l=(i.left+o.x)/a.x,c=(i.top+o.y)/a.y,u=i.width/a.x,d=i.height/a.y;if(s){const h=Dc(s),f=r&&Fd(r)?Dc(r):r;let O=h,g=RY(O);for(;g&&r&&f!==O;){const m=N1(g),v=g.getBoundingClientRect(),y=Md(g),w=v.left+(g.clientLeft+parseFloat(y.paddingLeft))*m.x,k=v.top+(g.clientTop+parseFloat(y.paddingTop))*m.y;l*=m.x,c*=m.y,u*=m.x,d*=m.y,l+=w,c+=k,O=Dc(g),g=RY(O)}}return I3({width:u,height:d,x:l,y:c})}function fre(e,t){const n=GX(e).scrollLeft;return t?t.left+n:Zv(kf(e)).left+n}function iZe(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),i=r.left+t.scrollLeft-(n?0:fre(e,r)),s=r.top+t.scrollTop;return{x:i,y:s}}function wer(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",a=kf(r),o=t?WX(t.floating):!1;if(r===a||o&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Kh(1);const u=Kh(0),d=hf(r);if((d||!d&&!s)&&((nS(r)!=="body"||U2(a))&&(l=GX(r)),hf(r))){const f=Zv(r);c=N1(r),u.x=f.x+r.clientLeft,u.y=f.y+r.clientTop}const h=a&&!d&&!s?iZe(a,l,!0):Kh(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-l.scrollTop*c.y+u.y+h.y}}function xer(e){return Array.from(e.getClientRects())}function Ser(e){const t=kf(e),n=GX(e),r=e.ownerDocument.body,i=tv(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=tv(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+fre(e);const o=-n.scrollTop;return Md(r).direction==="rtl"&&(a+=tv(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:a,y:o}}function $er(e,t){const n=Dc(e),r=kf(e),i=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,o=0,l=0;if(i){s=i.width,a=i.height;const c=dre();(!c||c&&t==="fixed")&&(o=i.offsetLeft,l=i.offsetTop)}return{width:s,height:a,x:o,y:l}}function ker(e,t){const n=Zv(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=hf(e)?N1(e):Kh(1),a=e.clientWidth*s.x,o=e.clientHeight*s.y,l=i*s.x,c=r*s.y;return{width:a,height:o,x:l,y:c}}function zTe(e,t,n){let r;if(t==="viewport")r=$er(e,n);else if(t==="document")r=Ser(kf(e));else if(Fd(t))r=ker(t,n);else{const i=rZe(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return I3(r)}function sZe(e,t){const n=em(e);return n===t||!Fd(n)||dx(n)?!1:Md(n).position==="fixed"||sZe(n,t)}function Ter(e,t){const n=t.get(e);if(n)return n;let r=FP(e,[],!1).filter(o=>Fd(o)&&nS(o)!=="body"),i=null;const s=Md(e).position==="fixed";let a=s?em(e):e;for(;Fd(a)&&!dx(a);){const o=Md(a),l=ure(a);!l&&o.position==="fixed"&&(i=null),(s?!l&&!i:!l&&o.position==="static"&&i&&["absolute","fixed"].includes(i.position)||U2(a)&&!l&&sZe(e,a))?r=r.filter(c=>c!==a):i=o,a=em(a)}return t.set(e,r),r}function _er(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const s=[...n==="clippingAncestors"?WX(t)?[]:Ter(t,this._c):[].concat(n),r],a=s[0],o=s.reduce((l,c)=>{const u=zTe(t,c,i);return l.top=tv(u.top,l.top),l.right=cx(u.right,l.right),l.bottom=cx(u.bottom,l.bottom),l.left=tv(u.left,l.left),l},zTe(t,a,i));return{width:o.right-o.left,height:o.bottom-o.top,x:o.left,y:o.top}}function Per(e){const{width:t,height:n}=nZe(e);return{width:t,height:n}}function Cer(e,t,n){const r=hf(t),i=kf(t),s=n==="fixed",a=Zv(e,!0,s,t);let o={scrollLeft:0,scrollTop:0};const l=Kh(0);if(r||!r&&!s)if((nS(t)!=="body"||U2(i))&&(o=GX(t)),r){const h=Zv(t,!0,s,t);l.x=h.x+t.clientLeft,l.y=h.y+t.clientTop}else i&&(l.x=fre(i));const c=i&&!r&&!s?iZe(i,o):Kh(0),u=a.left+o.scrollLeft-l.x-c.x,d=a.top+o.scrollTop-l.y-c.y;return{x:u,y:d,width:a.width,height:a.height}}function Lq(e){return Md(e).position==="static"}function UTe(e,t){if(!hf(e)||Md(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return kf(e)===n&&(n=n.ownerDocument.body),n}function aZe(e,t){const n=Dc(e);if(WX(e))return n;if(!hf(e)){let i=em(e);for(;i&&!dx(i);){if(Fd(i)&&!Lq(i))return i;i=em(i)}return n}let r=UTe(e,t);for(;r&&mer(r)&&Lq(r);)r=UTe(r,t);return r&&dx(r)&&Lq(r)&&!ure(r)?n:r||ver(e)||n}const Eer=async function(e){const t=this.getOffsetParent||aZe,n=this.getDimensions,r=await n(e.floating);return{reference:Cer(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Qer(e){return Md(e).direction==="rtl"}const Rer={convertOffsetParentRelativeRectToViewportRelativeRect:wer,getDocumentElement:kf,getClippingRect:_er,getOffsetParent:aZe,getElementRects:Eer,getClientRects:xer,getDimensions:Per,getScale:N1,isElement:Fd,isRTL:Qer};function Aer(e,t){let n=null,r;const i=kf(e);function s(){var o;clearTimeout(r),(o=n)==null||o.disconnect(),n=null}function a(o,l){o===void 0&&(o=!1),l===void 0&&(l=1),s();const{left:c,top:u,width:d,height:h}=e.getBoundingClientRect();if(o||t(),!d||!h)return;const f=_Q(u),O=_Q(i.clientWidth-(c+d)),g=_Q(i.clientHeight-(u+h)),m=_Q(c),v={rootMargin:-f+"px "+-O+"px "+-g+"px "+-m+"px",threshold:tv(0,cx(1,l))||1};let y=!0;function w(k){const x=k[0].intersectionRatio;if(x!==l){if(!y)return a();x?a(!1,x):r=setTimeout(()=>{a(!1,1e-7)},1e3)}y=!1}try{n=new IntersectionObserver(w,zl({},v,{root:i.ownerDocument}))}catch{n=new IntersectionObserver(w,v)}n.observe(e)}return a(!0),s}function Der(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:o=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=hre(e),u=i||s?[...c?FP(c):[],...FP(t)]:[];u.forEach(v=>{i&&v.addEventListener("scroll",n,{passive:!0}),s&&v.addEventListener("resize",n)});const d=c&&o?Aer(c,n):null;let h=-1,f=null;a&&(f=new ResizeObserver(v=>{let[y]=v;y&&y.target===c&&f&&(f.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var w;(w=f)==null||w.observe(t)})),n()}),c&&!l&&f.observe(c),f.observe(t));let O,g=l?Zv(e):null;l&&m();function m(){const v=Zv(e);g&&(v.x!==g.x||v.y!==g.y||v.width!==g.width||v.height!==g.height)&&n(),g=v,O=requestAnimationFrame(m)}return n(),()=>{var v;u.forEach(y=>{i&&y.removeEventListener("scroll",n),s&&y.removeEventListener("resize",n)}),d?.(),(v=f)==null||v.disconnect(),f=null,l&&cancelAnimationFrame(O)}}const Ner=fer,Xer=Oer,Ier=per,Fer=der,Mer=ger,jer=(e,t,n)=>{const r=new Map,i=zl({platform:Rer},n),s=zl({},i.platform,{_c:r});return uer(e,t,zl({},i,{platform:s}))};function Ler(e){e.cleanup&&e.cleanup();const t=e._getResolvedAttachToOptions();let n=t.element;const r=Ver(t,e),i=ZYe(t);return i&&(n=document.body,e.shepherdElementComponent.getElement().classList.add("shepherd-centered")),e.cleanup=Der(n,e.el,()=>{if(!e.el){e.cleanup==null||e.cleanup();return}Uer(n,e,r,i)}),e.target=t.element,r}function qer(e,t){return{floatingUIOptions:ire(e.floatingUIOptions||{},t.floatingUIOptions||{})}}function zer(e){e.cleanup&&e.cleanup(),e.cleanup=null}function Uer(e,t,n,r){return jer(e,t.el,n).then(Wer(t,r)).then(i=>new Promise(s=>{setTimeout(()=>s(i),300)})).then(i=>{i!=null&&i.el&&i.el.focus({preventScroll:!0})})}function Wer(e,t){return({x:n,y:r,placement:i,middlewareData:s})=>(e.el&&(t?Object.assign(e.el.style,{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)"}):Object.assign(e.el.style,{position:"absolute",left:`${n}px`,top:`${r}px`}),e.el.dataset.popperPlacement=i,Ger(e.el,s)),e)}function Ger(e,t){const n=e.querySelector(".shepherd-arrow");if(lx(n)&&t.arrow){const{x:r,y:i}=t.arrow;Object.assign(n.style,{left:r!=null?`${r}px`:"",top:i!=null?`${i}px`:""})}}function Ver(e,t){var n,r,i;const s={strategy:"absolute"};s.middleware=[];const a=Ber(t),o=ZYe(e),l=(n=e.on)==null?void 0:n.includes("auto"),c=(e==null||(r=e.on)==null?void 0:r.includes("-start"))||(e==null||(i=e.on)==null?void 0:i.includes("-end"));if(!o){if(l){var u;s.middleware.push(Ner({crossAxis:!0,alignment:c?e==null||(u=e.on)==null?void 0:u.split("-").pop():null}))}else s.middleware.push(Ier());if(s.middleware.push(Xer({limiter:Mer(),crossAxis:!0})),a){const d=typeof t.options.arrow=="object"?t.options.arrow:{padding:4};s.middleware.push(Fer({element:a,padding:c?d.padding:0}))}l||(s.placement=e.on)}return ire(s,t.options.floatingUIOptions||{})}function Ber(e){return e.options.arrow&&e.el?e.el.querySelector(".shepherd-arrow"):!1}function jc(){}function Yer(e,t){for(const n in t)e[n]=t[n];return e}function oZe(e){return e()}function WTe(){return Object.create(null)}function W2(e){e.forEach(oZe)}function pre(e){return typeof e=="function"}function gO(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function Zer(e){return Object.keys(e).length===0}function hx(e,t){e.appendChild(t)}function Zd(e,t,n){e.insertBefore(t,n||null)}function Vu(e){e.parentNode&&e.parentNode.removeChild(e)}function Her(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function ff(e){return document.createElement(e)}function GTe(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function lZe(e){return document.createTextNode(e)}function F3(){return lZe(" ")}function Ker(){return lZe("")}function VX(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function Ci(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}const Jer=["width","height"];function VTe(e,t){const n=Object.getOwnPropertyDescriptors(e.__proto__);for(const r in t)t[r]==null?e.removeAttribute(r):r==="style"?e.style.cssText=t[r]:r==="__value"?e.value=e[r]=t[r]:n[r]&&n[r].set&&Jer.indexOf(r)===-1?e[r]=t[r]:Ci(e,r,t[r])}function etr(e){return Array.from(e.childNodes)}function gb(e,t,n){e.classList.toggle(t,!!n)}let MP;function tT(e){MP=e}function cZe(){if(!MP)throw new Error("Function called outside component initialization");return MP}function ttr(e){cZe().$$.on_mount.push(e)}function Ore(e){cZe().$$.after_update.push(e)}const Cb=[],fx=[];let X1=[];const BTe=[],ntr=Promise.resolve();let AY=!1;function rtr(){AY||(AY=!0,ntr.then(uZe))}function DY(e){X1.push(e)}const qq=new Set;let mb=0;function uZe(){if(mb!==0)return;const e=MP;do{try{for(;mb<Cb.length;){const t=Cb[mb];mb++,tT(t),itr(t.$$)}}catch(t){throw Cb.length=0,mb=0,t}for(tT(null),Cb.length=0,mb=0;fx.length;)fx.pop()();for(let t=0;t<X1.length;t+=1){const n=X1[t];qq.has(n)||(qq.add(n),n())}X1.length=0}while(Cb.length);for(;BTe.length;)BTe.pop()();AY=!1,qq.clear(),tT(e)}function itr(e){if(e.fragment!==null){e.update(),W2(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(DY)}}function str(e){const t=[],n=[];X1.forEach(r=>e.indexOf(r)===-1?t.push(r):n.push(r)),n.forEach(r=>r()),X1=t}const LR=new Set;let Q0;function nv(){Q0={r:0,c:[],p:Q0}}function rv(){Q0.r||W2(Q0.c),Q0=Q0.p}function hi(e,t){e&&e.i&&(LR.delete(e),e.i(t))}function js(e,t,n,r){if(e&&e.o){if(LR.has(e))return;LR.add(e),Q0.c.push(()=>{LR.delete(e),r&&(n&&e.d(1),r())}),e.o(t)}else r&&r()}function YTe(e){return e?.length!==void 0?e:Array.from(e)}function atr(e,t){const n={},r={},i={$$scope:1};let s=e.length;for(;s--;){const a=e[s],o=t[s];if(o){for(const l in a)l in o||(r[l]=1);for(const l in o)i[l]||(n[l]=o[l],i[l]=1);e[s]=o}else for(const l in a)i[l]=1}for(const a in r)a in n||(n[a]=void 0);return n}function Ny(e){e&&e.c()}function $m(e,t,n){const{fragment:r,after_update:i}=e.$$;r&&r.m(t,n),DY(()=>{const s=e.$$.on_mount.map(oZe).filter(pre);e.$$.on_destroy?e.$$.on_destroy.push(...s):W2(s),e.$$.on_mount=[]}),i.forEach(DY)}function km(e,t){const n=e.$$;n.fragment!==null&&(str(n.after_update),W2(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function otr(e,t){e.$$.dirty[0]===-1&&(Cb.push(e),rtr(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function mO(e,t,n,r,i,s,a=null,o=[-1]){const l=MP;tT(e);const c=e.$$={fragment:null,ctx:[],props:s,update:jc,not_equal:i,bound:WTe(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(l?l.$$.context:[])),callbacks:WTe(),dirty:o,skip_bound:!1,root:t.target||l.$$.root};a&&a(c.root);let u=!1;if(c.ctx=n?n(e,t.props||{},(d,h,...f)=>{const O=f.length?f[0]:h;return c.ctx&&i(c.ctx[d],c.ctx[d]=O)&&(!c.skip_bound&&c.bound[d]&&c.bound[d](O),u&&otr(e,d)),h}):[],c.update(),u=!0,W2(c.before_update),c.fragment=r?r(c.ctx):!1,t.target){if(t.hydrate){const d=etr(t.target);c.fragment&&c.fragment.l(d),d.forEach(Vu)}else c.fragment&&c.fragment.c();t.intro&&hi(e.$$.fragment),$m(e,t.target,t.anchor),uZe()}tT(l)}class vO{constructor(){this.$$=void 0,this.$$set=void 0}$destroy(){km(this,1),this.$destroy=jc}$on(t,n){if(!pre(n))return jc;const r=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return r.push(n),()=>{const i=r.indexOf(n);i!==-1&&r.splice(i,1)}}$set(t){this.$$set&&!Zer(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const ltr="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(ltr);function ctr(e){let t,n,r,i,s;return{c(){t=ff("button"),Ci(t,"aria-label",n=e[3]?e[3]:null),Ci(t,"class",r=`${e[1]||""} shepherd-button ${e[4]?"shepherd-button-secondary":""}`),t.disabled=e[2],Ci(t,"tabindex","0"),Ci(t,"type","button")},m(a,o){Zd(a,t,o),t.innerHTML=e[5],i||(s=VX(t,"click",function(){pre(e[0])&&e[0].apply(this,arguments)}),i=!0)},p(a,[o]){e=a,o&32&&(t.innerHTML=e[5]),o&8&&n!==(n=e[3]?e[3]:null)&&Ci(t,"aria-label",n),o&18&&r!==(r=`${e[1]||""} shepherd-button ${e[4]?"shepherd-button-secondary":""}`)&&Ci(t,"class",r),o&4&&(t.disabled=e[2])},i:jc,o:jc,d(a){a&&Vu(t),i=!1,s()}}}function utr(e,t,n){let{config:r,step:i}=t,s,a,o,l,c,u;function d(h){return Jg(h)?h=h.call(i):h}return e.$$set=h=>{"config"in h&&n(6,r=h.config),"step"in h&&n(7,i=h.step)},e.$$.update=()=>{e.$$.dirty&192&&(n(0,s=r.action?r.action.bind(i.tour):null),n(1,a=r.classes),n(2,o=r.disabled?d(r.disabled):!1),n(3,l=r.label?d(r.label):null),n(4,c=r.secondary),n(5,u=r.text?d(r.text):null))},[s,a,o,l,c,u,r,i]}class dtr extends vO{constructor(t){super(),mO(this,t,utr,ctr,gO,{config:6,step:7})}}function ZTe(e,t,n){const r=e.slice();return r[2]=t[n],r}function HTe(e){let t,n,r=YTe(e[1]),i=[];for(let a=0;a<r.length;a+=1)i[a]=KTe(ZTe(e,r,a));const s=a=>js(i[a],1,1,()=>{i[a]=null});return{c(){for(let a=0;a<i.length;a+=1)i[a].c();t=Ker()},m(a,o){for(let l=0;l<i.length;l+=1)i[l]&&i[l].m(a,o);Zd(a,t,o),n=!0},p(a,o){if(o&3){r=YTe(a[1]);let l;for(l=0;l<r.length;l+=1){const c=ZTe(a,r,l);i[l]?(i[l].p(c,o),hi(i[l],1)):(i[l]=KTe(c),i[l].c(),hi(i[l],1),i[l].m(t.parentNode,t))}for(nv(),l=r.length;l<i.length;l+=1)s(l);rv()}},i(a){if(!n){for(let o=0;o<r.length;o+=1)hi(i[o]);n=!0}},o(a){i=i.filter(Boolean);for(let o=0;o<i.length;o+=1)js(i[o]);n=!1},d(a){a&&Vu(t),Her(i,a)}}}function KTe(e){let t,n;return t=new dtr({props:{config:e[2],step:e[0]}}),{c(){Ny(t.$$.fragment)},m(r,i){$m(t,r,i),n=!0},p(r,i){const s={};i&2&&(s.config=r[2]),i&1&&(s.step=r[0]),t.$set(s)},i(r){n||(hi(t.$$.fragment,r),n=!0)},o(r){js(t.$$.fragment,r),n=!1},d(r){km(t,r)}}}function htr(e){let t,n,r=e[1]&&HTe(e);return{c(){t=ff("footer"),r&&r.c(),Ci(t,"class","shepherd-footer")},m(i,s){Zd(i,t,s),r&&r.m(t,null),n=!0},p(i,[s]){i[1]?r?(r.p(i,s),s&2&&hi(r,1)):(r=HTe(i),r.c(),hi(r,1),r.m(t,null)):r&&(nv(),js(r,1,1,()=>{r=null}),rv())},i(i){n||(hi(r),n=!0)},o(i){js(r),n=!1},d(i){i&&Vu(t),r&&r.d()}}}function ftr(e,t,n){let r,{step:i}=t;return e.$$set=s=>{"step"in s&&n(0,i=s.step)},e.$$.update=()=>{e.$$.dirty&1&&n(1,r=i.options.buttons)},[i,r]}class ptr extends vO{constructor(t){super(),mO(this,t,ftr,htr,gO,{step:0})}}function Otr(e){let t,n,r,i,s;return{c(){t=ff("button"),n=ff("span"),n.textContent="×",Ci(n,"aria-hidden","true"),Ci(t,"aria-label",r=e[0].label?e[0].label:"Close Tour"),Ci(t,"class","shepherd-cancel-icon"),Ci(t,"type","button")},m(a,o){Zd(a,t,o),hx(t,n),i||(s=VX(t,"click",e[1]),i=!0)},p(a,[o]){o&1&&r!==(r=a[0].label?a[0].label:"Close Tour")&&Ci(t,"aria-label",r)},i:jc,o:jc,d(a){a&&Vu(t),i=!1,s()}}}function gtr(e,t,n){let{cancelIcon:r,step:i}=t;const s=a=>{a.preventDefault(),i.cancel()};return e.$$set=a=>{"cancelIcon"in a&&n(0,r=a.cancelIcon),"step"in a&&n(2,i=a.step)},[r,s,i]}class mtr extends vO{constructor(t){super(),mO(this,t,gtr,Otr,gO,{cancelIcon:0,step:2})}}function vtr(e){let t;return{c(){t=ff("h3"),Ci(t,"id",e[1]),Ci(t,"class","shepherd-title")},m(n,r){Zd(n,t,r),e[3](t)},p(n,[r]){r&2&&Ci(t,"id",n[1])},i:jc,o:jc,d(n){n&&Vu(t),e[3](null)}}}function ytr(e,t,n){let{labelId:r,element:i,title:s}=t;Ore(()=>{Jg(s)&&n(2,s=s()),n(0,i.innerHTML=s,i)});function a(o){fx[o?"unshift":"push"](()=>{i=o,n(0,i)})}return e.$$set=o=>{"labelId"in o&&n(1,r=o.labelId),"element"in o&&n(0,i=o.element),"title"in o&&n(2,s=o.title)},[i,r,s,a]}class btr extends vO{constructor(t){super(),mO(this,t,ytr,vtr,gO,{labelId:1,element:0,title:2})}}function JTe(e){let t,n;return t=new btr({props:{labelId:e[0],title:e[2]}}),{c(){Ny(t.$$.fragment)},m(r,i){$m(t,r,i),n=!0},p(r,i){const s={};i&1&&(s.labelId=r[0]),i&4&&(s.title=r[2]),t.$set(s)},i(r){n||(hi(t.$$.fragment,r),n=!0)},o(r){js(t.$$.fragment,r),n=!1},d(r){km(t,r)}}}function e_e(e){let t,n;return t=new mtr({props:{cancelIcon:e[3],step:e[1]}}),{c(){Ny(t.$$.fragment)},m(r,i){$m(t,r,i),n=!0},p(r,i){const s={};i&8&&(s.cancelIcon=r[3]),i&2&&(s.step=r[1]),t.$set(s)},i(r){n||(hi(t.$$.fragment,r),n=!0)},o(r){js(t.$$.fragment,r),n=!1},d(r){km(t,r)}}}function wtr(e){let t,n,r,i=e[2]&&JTe(e),s=e[3]&&e[3].enabled&&e_e(e);return{c(){t=ff("header"),i&&i.c(),n=F3(),s&&s.c(),Ci(t,"class","shepherd-header")},m(a,o){Zd(a,t,o),i&&i.m(t,null),hx(t,n),s&&s.m(t,null),r=!0},p(a,[o]){a[2]?i?(i.p(a,o),o&4&&hi(i,1)):(i=JTe(a),i.c(),hi(i,1),i.m(t,n)):i&&(nv(),js(i,1,1,()=>{i=null}),rv()),a[3]&&a[3].enabled?s?(s.p(a,o),o&8&&hi(s,1)):(s=e_e(a),s.c(),hi(s,1),s.m(t,null)):s&&(nv(),js(s,1,1,()=>{s=null}),rv())},i(a){r||(hi(i),hi(s),r=!0)},o(a){js(i),js(s),r=!1},d(a){a&&Vu(t),i&&i.d(),s&&s.d()}}}function xtr(e,t,n){let{labelId:r,step:i}=t,s,a;return e.$$set=o=>{"labelId"in o&&n(0,r=o.labelId),"step"in o&&n(1,i=o.step)},e.$$.update=()=>{e.$$.dirty&2&&(n(2,s=i.options.title),n(3,a=i.options.cancelIcon))},[r,i,s,a]}class Str extends vO{constructor(t){super(),mO(this,t,xtr,wtr,gO,{labelId:0,step:1})}}function $tr(e){let t;return{c(){t=ff("div"),Ci(t,"class","shepherd-text"),Ci(t,"id",e[1])},m(n,r){Zd(n,t,r),e[3](t)},p(n,[r]){r&2&&Ci(t,"id",n[1])},i:jc,o:jc,d(n){n&&Vu(t),e[3](null)}}}function ktr(e,t,n){let{descriptionId:r,element:i,step:s}=t;Ore(()=>{let{text:o}=s.options;Jg(o)&&(o=o.call(s)),lx(o)?i.appendChild(o):n(0,i.innerHTML=o,i)});function a(o){fx[o?"unshift":"push"](()=>{i=o,n(0,i)})}return e.$$set=o=>{"descriptionId"in o&&n(1,r=o.descriptionId),"element"in o&&n(0,i=o.element),"step"in o&&n(2,s=o.step)},[i,r,s,a]}class Ttr extends vO{constructor(t){super(),mO(this,t,ktr,$tr,gO,{descriptionId:1,element:0,step:2})}}function t_e(e){let t,n;return t=new Str({props:{labelId:e[1],step:e[2]}}),{c(){Ny(t.$$.fragment)},m(r,i){$m(t,r,i),n=!0},p(r,i){const s={};i&2&&(s.labelId=r[1]),i&4&&(s.step=r[2]),t.$set(s)},i(r){n||(hi(t.$$.fragment,r),n=!0)},o(r){js(t.$$.fragment,r),n=!1},d(r){km(t,r)}}}function n_e(e){let t,n;return t=new Ttr({props:{descriptionId:e[0],step:e[2]}}),{c(){Ny(t.$$.fragment)},m(r,i){$m(t,r,i),n=!0},p(r,i){const s={};i&1&&(s.descriptionId=r[0]),i&4&&(s.step=r[2]),t.$set(s)},i(r){n||(hi(t.$$.fragment,r),n=!0)},o(r){js(t.$$.fragment,r),n=!1},d(r){km(t,r)}}}function r_e(e){let t,n;return t=new ptr({props:{step:e[2]}}),{c(){Ny(t.$$.fragment)},m(r,i){$m(t,r,i),n=!0},p(r,i){const s={};i&4&&(s.step=r[2]),t.$set(s)},i(r){n||(hi(t.$$.fragment,r),n=!0)},o(r){js(t.$$.fragment,r),n=!1},d(r){km(t,r)}}}function _tr(e){let t,n=!Do(e[2].options.title)||e[2].options.cancelIcon&&e[2].options.cancelIcon.enabled,r,i=!Do(e[2].options.text),s,a=Array.isArray(e[2].options.buttons)&&e[2].options.buttons.length,o,l=n&&t_e(e),c=i&&n_e(e),u=a&&r_e(e);return{c(){t=ff("div"),l&&l.c(),r=F3(),c&&c.c(),s=F3(),u&&u.c(),Ci(t,"class","shepherd-content")},m(d,h){Zd(d,t,h),l&&l.m(t,null),hx(t,r),c&&c.m(t,null),hx(t,s),u&&u.m(t,null),o=!0},p(d,[h]){h&4&&(n=!Do(d[2].options.title)||d[2].options.cancelIcon&&d[2].options.cancelIcon.enabled),n?l?(l.p(d,h),h&4&&hi(l,1)):(l=t_e(d),l.c(),hi(l,1),l.m(t,r)):l&&(nv(),js(l,1,1,()=>{l=null}),rv()),h&4&&(i=!Do(d[2].options.text)),i?c?(c.p(d,h),h&4&&hi(c,1)):(c=n_e(d),c.c(),hi(c,1),c.m(t,s)):c&&(nv(),js(c,1,1,()=>{c=null}),rv()),h&4&&(a=Array.isArray(d[2].options.buttons)&&d[2].options.buttons.length),a?u?(u.p(d,h),h&4&&hi(u,1)):(u=r_e(d),u.c(),hi(u,1),u.m(t,null)):u&&(nv(),js(u,1,1,()=>{u=null}),rv())},i(d){o||(hi(l),hi(c),hi(u),o=!0)},o(d){js(l),js(c),js(u),o=!1},d(d){d&&Vu(t),l&&l.d(),c&&c.d(),u&&u.d()}}}function Ptr(e,t,n){let{descriptionId:r,labelId:i,step:s}=t;return e.$$set=a=>{"descriptionId"in a&&n(0,r=a.descriptionId),"labelId"in a&&n(1,i=a.labelId),"step"in a&&n(2,s=a.step)},[r,i,s]}class Ctr extends vO{constructor(t){super(),mO(this,t,Ptr,_tr,gO,{descriptionId:0,labelId:1,step:2})}}function i_e(e){let t;return{c(){t=ff("div"),Ci(t,"class","shepherd-arrow"),Ci(t,"data-popper-arrow","")},m(n,r){Zd(n,t,r)},d(n){n&&Vu(t)}}}function Etr(e){let t,n,r,i,s,a,o,l,c=e[4].options.arrow&&e[4].options.attachTo&&e[4].options.attachTo.element&&e[4].options.attachTo.on&&i_e();r=new Ctr({props:{descriptionId:e[2],labelId:e[3],step:e[4]}});let u=[{"aria-describedby":i=Do(e[4].options.text)?null:e[2]},{"aria-labelledby":s=e[4].options.title?e[3]:null},e[1],{open:"true"}],d={};for(let h=0;h<u.length;h+=1)d=Yer(d,u[h]);return{c(){t=ff("dialog"),c&&c.c(),n=F3(),Ny(r.$$.fragment),VTe(t,d),gb(t,"shepherd-has-cancel-icon",e[5]),gb(t,"shepherd-has-title",e[6]),gb(t,"shepherd-element",!0)},m(h,f){Zd(h,t,f),c&&c.m(t,null),hx(t,n),$m(r,t,null),e[13](t),a=!0,o||(l=VX(t,"keydown",e[7]),o=!0)},p(h,[f]){h[4].options.arrow&&h[4].options.attachTo&&h[4].options.attachTo.element&&h[4].options.attachTo.on?c||(c=i_e(),c.c(),c.m(t,n)):c&&(c.d(1),c=null);const O={};f&4&&(O.descriptionId=h[2]),f&8&&(O.labelId=h[3]),f&16&&(O.step=h[4]),r.$set(O),VTe(t,d=atr(u,[(!a||f&20&&i!==(i=Do(h[4].options.text)?null:h[2]))&&{"aria-describedby":i},(!a||f&24&&s!==(s=h[4].options.title?h[3]:null))&&{"aria-labelledby":s},f&2&&h[1],{open:"true"}])),gb(t,"shepherd-has-cancel-icon",h[5]),gb(t,"shepherd-has-title",h[6]),gb(t,"shepherd-element",!0)},i(h){a||(hi(r.$$.fragment,h),a=!0)},o(h){js(r.$$.fragment,h),a=!1},d(h){h&&Vu(t),c&&c.d(),km(r),e[13](null),o=!1,l()}}}const Qtr=9,Rtr=27,Atr=37,Dtr=39;function s_e(e){return e.split(" ").filter(t=>!!t.length)}function Ntr(e,t,n){let{classPrefix:r,element:i,descriptionId:s,firstFocusableElement:a,focusableElements:o,labelId:l,lastFocusableElement:c,step:u,dataStepId:d}=t,h,f,O;const g=()=>i;ttr(()=>{n(1,d={[`data-${r}shepherd-step-id`]:u.id}),n(9,o=i.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]')),n(8,a=o[0]),n(10,c=o[o.length-1])}),Ore(()=>{O!==u.options.classes&&m()});function m(){v(O),O=u.options.classes,y(O)}function v(x){if(IP(x)){const S=s_e(x);S.length&&i.classList.remove(...S)}}function y(x){if(IP(x)){const S=s_e(x);S.length&&i.classList.add(...S)}}const w=x=>{const{tour:S}=u;switch(x.keyCode){case Qtr:if(o.length===0){x.preventDefault();break}x.shiftKey?(document.activeElement===a||document.activeElement.classList.contains("shepherd-element"))&&(x.preventDefault(),c.focus()):document.activeElement===c&&(x.preventDefault(),a.focus());break;case Rtr:S.options.exitOnEsc&&(x.preventDefault(),x.stopPropagation(),u.cancel());break;case Atr:S.options.keyboardNavigation&&(x.preventDefault(),x.stopPropagation(),S.back());break;case Dtr:S.options.keyboardNavigation&&(x.preventDefault(),x.stopPropagation(),S.next());break}};function k(x){fx[x?"unshift":"push"](()=>{i=x,n(0,i)})}return e.$$set=x=>{"classPrefix"in x&&n(11,r=x.classPrefix),"element"in x&&n(0,i=x.element),"descriptionId"in x&&n(2,s=x.descriptionId),"firstFocusableElement"in x&&n(8,a=x.firstFocusableElement),"focusableElements"in x&&n(9,o=x.focusableElements),"labelId"in x&&n(3,l=x.labelId),"lastFocusableElement"in x&&n(10,c=x.lastFocusableElement),"step"in x&&n(4,u=x.step),"dataStepId"in x&&n(1,d=x.dataStepId)},e.$$.update=()=>{e.$$.dirty&16&&(n(5,h=u.options&&u.options.cancelIcon&&u.options.cancelIcon.enabled),n(6,f=u.options&&u.options.title))},[i,d,s,l,u,h,f,w,a,o,c,r,g,k]}class Xtr extends vO{constructor(t){super(),mO(this,t,Ntr,Etr,gO,{classPrefix:11,element:0,descriptionId:2,firstFocusableElement:8,focusableElements:9,labelId:3,lastFocusableElement:10,step:4,dataStepId:1,getElement:12})}get getElement(){return this.$$.ctx[12]}}class NY extends nre{constructor(t,n={}){return super(),this._resolvedAttachTo=void 0,this._resolvedExtraHighlightElements=void 0,this.classPrefix=void 0,this.el=void 0,this.target=void 0,this.tour=void 0,this.tour=t,this.classPrefix=this.tour.options?YYe(this.tour.options.classPrefix):"",this.styles=t.styles,this._resolvedAttachTo=null,sre(this),this._setOptions(n),this}cancel(){this.tour.cancel(),this.trigger("cancel")}complete(){this.tour.complete(),this.trigger("complete")}destroy(){zer(this),lx(this.el)&&(this.el.remove(),this.el=null),this._updateStepTargetOnHide(),this.trigger("destroy")}getTour(){return this.tour}hide(){var t;(t=this.tour.modal)==null||t.hide(),this.trigger("before-hide"),this.el&&(this.el.hidden=!0),this._updateStepTargetOnHide(),this.trigger("hide")}_resolveExtraHiglightElements(){return this._resolvedExtraHighlightElements=JJn(this),this._resolvedExtraHighlightElements}_resolveAttachToOptions(){return this._resolvedAttachTo=KJn(this),this._resolvedAttachTo}_getResolvedAttachToOptions(){return this._resolvedAttachTo===null?this._resolveAttachToOptions():this._resolvedAttachTo}isOpen(){return!!(this.el&&!this.el.hidden)}show(){return Jg(this.options.beforeShowPromise)?Promise.resolve(this.options.beforeShowPromise()).then(()=>this._show()):Promise.resolve(this._show())}updateStepOptions(t){Object.assign(this.options,t),this.shepherdElementComponent&&this.shepherdElementComponent.$set({step:this})}getElement(){return this.el}getTarget(){return this.target}_createTooltipContent(){const t=`${this.id}-description`,n=`${this.id}-label`;return this.shepherdElementComponent=new Xtr({target:this.tour.options.stepsContainer||document.body,props:{classPrefix:this.classPrefix,descriptionId:t,labelId:n,step:this,styles:this.styles}}),this.shepherdElementComponent.getElement()}_scrollTo(t){const{element:n}=this._getResolvedAttachToOptions();Jg(this.options.scrollToHandler)?this.options.scrollToHandler(n):QJn(n)&&typeof n.scrollIntoView=="function"&&n.scrollIntoView(t)}_getClassOptions(t){const n=this.tour&&this.tour.options&&this.tour.options.defaultStepOptions,r=t.classes?t.classes:"",i=n&&n.classes?n.classes:"",s=[...r.split(" "),...i.split(" ")],a=new Set(s);return Array.from(a).join(" ").trim()}_setOptions(t={}){let n=this.tour&&this.tour.options&&this.tour.options.defaultStepOptions;n=ire({},n||{}),this.options=Object.assign({arrow:!0},n,t,qer(n,t));const{when:r}=this.options;this.options.classes=this._getClassOptions(t),this.destroy(),this.id=this.options.id||`step-${HYe()}`,r&&Object.keys(r).forEach(i=>{this.on(i,r[i],this)})}_setupElements(){Do(this.el)||this.destroy(),this.el=this._createTooltipContent(),this.options.advanceOn&&YJn(this),Ler(this)}_show(){var t;this.trigger("before-show"),this._resolveAttachToOptions(),this._resolveExtraHiglightElements(),this._setupElements(),this.tour.modal||this.tour.setupModal(),(t=this.tour.modal)==null||t.setupForStep(this),this._styleTargetElementForStep(this),this.el&&(this.el.hidden=!1),this.options.scrollTo&&setTimeout(()=>{this._scrollTo(this.options.scrollTo)}),this.el&&(this.el.hidden=!1);const n=this.shepherdElementComponent.getElement(),r=this.target||document.body,i=this._resolvedExtraHighlightElements;r.classList.add(`${this.classPrefix}shepherd-enabled`),r.classList.add(`${this.classPrefix}shepherd-target`),n.classList.add("shepherd-enabled"),i?.forEach(s=>{s.classList.add(`${this.classPrefix}shepherd-enabled`),s.classList.add(`${this.classPrefix}shepherd-target`)}),this.trigger("show")}_styleTargetElementForStep(t){const n=t.target,r=t._resolvedExtraHighlightElements;if(!n)return;const i=t.options.highlightClass;i&&(n.classList.add(i),r?.forEach(s=>s.classList.add(i))),n.classList.remove("shepherd-target-click-disabled"),r?.forEach(s=>s.classList.remove("shepherd-target-click-disabled")),t.options.canClickTarget===!1&&(n.classList.add("shepherd-target-click-disabled"),r?.forEach(s=>s.classList.add("shepherd-target-click-disabled")))}_updateStepTargetOnHide(){const t=this.target||document.body,n=this._resolvedExtraHighlightElements,r=this.options.highlightClass;r&&(t.classList.remove(r),n?.forEach(i=>i.classList.remove(r))),t.classList.remove("shepherd-target-click-disabled",`${this.classPrefix}shepherd-enabled`,`${this.classPrefix}shepherd-target`),n?.forEach(i=>{i.classList.remove("shepherd-target-click-disabled",`${this.classPrefix}shepherd-enabled`,`${this.classPrefix}shepherd-target`)})}}function Itr(e){if(e){const{steps:t}=e;t.forEach(n=>{n.options&&n.options.canClickTarget===!1&&n.options.attachTo&&(lx(n.target)&&n.target.classList.remove("shepherd-target-click-disabled"),n._resolvedExtraHighlightElements&&n._resolvedExtraHighlightElements.forEach(r=>{lx(r)&&r.classList.remove("shepherd-target-click-disabled")}))})}}function Ftr(e){let t="";const{innerWidth:n,innerHeight:r}=window;return e.forEach(i=>{const{width:s,height:a,x:o=0,y:l=0,r:c=0}=i,{topLeft:u=0,topRight:d=0,bottomRight:h=0,bottomLeft:f=0}=typeof c=="number"?{topLeft:c,topRight:c,bottomRight:c,bottomLeft:c}:c;t+=`M${o+u},${l} a${u},${u},0,0,0-${u},${u} V${a+l-f} a${f},${f},0,0,0,${f},${f} H${s+o-h} a${h},${h},0,0,0,${h}-${h} V${l+d} a${d},${d},0,0,0-${d}-${d} Z`}),`M${n},${r} H0 V0 H${n} V${r} Z ${t}`.replace(/\s/g,"")}function Mtr(e){let t,n,r,i,s;return{c(){t=GTe("svg"),n=GTe("path"),Ci(n,"d",e[2]),Ci(t,"class",r=`${e[1]?"shepherd-modal-is-visible":""} shepherd-modal-overlay-container`)},m(a,o){Zd(a,t,o),hx(t,n),e[11](t),i||(s=VX(t,"touchmove",e[3]),i=!0)},p(a,[o]){o&4&&Ci(n,"d",a[2]),o&2&&r!==(r=`${a[1]?"shepherd-modal-is-visible":""} shepherd-modal-overlay-container`)&&Ci(t,"class",r)},i:jc,o:jc,d(a){a&&Vu(t),e[11](null),i=!1,s()}}}function dZe(e){if(!e)return null;const t=e instanceof HTMLElement&&window.getComputedStyle(e).overflowY;return t!=="hidden"&&t!=="visible"&&e.scrollHeight>=e.clientHeight?e:dZe(e.parentElement)}function jtr(e){let t={top:0,left:0};if(!e)return t;let n=e.ownerDocument.defaultView;for(;n!==window.top;){var r;const a=(r=n)==null?void 0:r.frameElement;if(a){var i,s;const o=a.getBoundingClientRect();t.top+=o.top+((i=o.scrollTop)!=null?i:0),t.left+=o.left+((s=o.scrollLeft)!=null?s:0)}n=n.parent}return t}function Ltr(e,t){const n=e.getBoundingClientRect();let r=n.y||n.top,i=n.bottom||r+n.height;if(t){const a=t.getBoundingClientRect(),o=a.y||a.top,l=a.bottom||o+a.height;r=Math.max(r,o),i=Math.min(i,l)}const s=Math.max(i-r,0);return{y:r,height:s}}function qtr(e,t,n){let{element:r,openingProperties:i}=t,s=!1,a,o;c();const l=()=>r;function c(){n(4,i=[{width:0,height:0,x:0,y:0,r:0}])}function u(){n(1,s=!1),v()}function d(k=0,x=0,S=0,T=0,_,P,E){if(P){const C=[P,...E||[]];n(4,i=[]);for(const Q of C){if(!Q||C.indexOf(Q)!==C.lastIndexOf(Q))continue;const{y:D,height:F}=Ltr(Q,_),{x:I,width:U,left:q}=Q.getBoundingClientRect();C.some(Z=>{if(Z===Q)return!1;const W=Z.getBoundingClientRect();return I>=W.left&&I+U<=W.right&&D>=W.top&&D+F<=W.bottom})||i.push({width:U+k*2,height:F+k*2,x:(I||q)+S-k,y:D+T-k,r:x})}}else c()}function h(k){v(),k.tour.options.useModalOverlay?(y(k),f()):u()}function f(){n(1,s=!0)}const O=k=>{k.preventDefault()},g=k=>{k.stopPropagation()};function m(){window.addEventListener("touchmove",O,{passive:!1})}function v(){a&&(cancelAnimationFrame(a),a=void 0),window.removeEventListener("touchmove",O,{passive:!1})}function y(k){const{modalOverlayOpeningPadding:x,modalOverlayOpeningRadius:S,modalOverlayOpeningXOffset:T=0,modalOverlayOpeningYOffset:_=0}=k.options,P=jtr(k.target),E=dZe(k.target),C=()=>{a=void 0,d(x,S,T+P.left,_+P.top,E,k.target,k._resolvedExtraHighlightElements),a=requestAnimationFrame(C)};C(),m()}function w(k){fx[k?"unshift":"push"](()=>{r=k,n(0,r)})}return e.$$set=k=>{"element"in k&&n(0,r=k.element),"openingProperties"in k&&n(4,i=k.openingProperties)},e.$$.update=()=>{e.$$.dirty&16&&n(2,o=Ftr(i))},[r,s,o,g,i,l,c,u,d,h,f,w]}class ztr extends vO{constructor(t){super(),mO(this,t,qtr,Mtr,gO,{element:0,openingProperties:4,getElement:5,closeModalOpening:6,hide:7,positionModal:8,setupForStep:9,show:10})}get getElement(){return this.$$.ctx[5]}get closeModalOpening(){return this.$$.ctx[6]}get hide(){return this.$$.ctx[7]}get positionModal(){return this.$$.ctx[8]}get setupForStep(){return this.$$.ctx[9]}get show(){return this.$$.ctx[10]}}class Utr extends nre{constructor(){super(),this.activeTour=void 0,sre(this)}}class Wtr extends nre{constructor(t={}){super(),this.trackedEvents=["active","cancel","complete","show"],this.classPrefix=void 0,this.currentStep=void 0,this.focusedElBeforeOpen=void 0,this.id=void 0,this.modal=void 0,this.options=void 0,this.steps=void 0,sre(this);const n={exitOnEsc:!0,keyboardNavigation:!0};return this.options=Object.assign({},n,t),this.classPrefix=YYe(this.options.classPrefix),this.steps=[],this.addSteps(this.options.steps),["active","cancel","complete","inactive","show","start"].map(r=>{(i=>{this.on(i,s=>{s=s||{},s.tour=this,R0.trigger(i,s)})})(r)}),this._setTourID(t.id),this}addStep(t,n){let r=t;return r instanceof NY?r.tour=this:r=new NY(this,r),Do(n)?this.steps.push(r):this.steps.splice(n,0,r),r}addSteps(t){return Array.isArray(t)&&t.forEach(n=>{this.addStep(n)}),this}back(){const t=this.steps.indexOf(this.currentStep);this.show(t-1,!1)}async cancel(){if(this.options.confirmCancel){const t=this.options.confirmCancelMessage||"Are you sure you want to stop the tour?";let n;Jg(this.options.confirmCancel)?n=await this.options.confirmCancel():n=window.confirm(t),n&&this._done("cancel")}else this._done("cancel")}complete(){this._done("complete")}getById(t){return this.steps.find(n=>n.id===t)}getCurrentStep(){return this.currentStep}hide(){const t=this.getCurrentStep();if(t)return t.hide()}isActive(){return R0.activeTour===this}next(){const t=this.steps.indexOf(this.currentStep);t===this.steps.length-1?this.complete():this.show(t+1,!0)}removeStep(t){const n=this.getCurrentStep();this.steps.some((r,i)=>{if(r.id===t)return r.isOpen()&&r.hide(),r.destroy(),this.steps.splice(i,1),!0}),n&&n.id===t&&(this.currentStep=void 0,this.steps.length?this.show(0):this.cancel())}show(t=0,n=!0){const r=IP(t)?this.getById(t):this.steps[t];r&&(this._updateStateBeforeShow(),Jg(r.options.showOn)&&!r.options.showOn()?this._skipStep(r,n):(this.currentStep=r,this.trigger("show",{step:r,previous:this.currentStep}),r.show()))}async start(){this.trigger("start"),this.focusedElBeforeOpen=document.activeElement,this.currentStep=null,this.setupModal(),this._setupActiveTour(),this.next()}_done(t){const n=this.steps.indexOf(this.currentStep);if(Array.isArray(this.steps)&&this.steps.forEach(r=>r.destroy()),Itr(this),this.trigger(t,{index:n}),R0.activeTour=null,this.trigger("inactive",{tour:this}),this.modal&&this.modal.hide(),(t==="cancel"||t==="complete")&&this.modal){const r=document.querySelector(".shepherd-modal-overlay-container");r&&(r.remove(),this.modal=null)}lx(this.focusedElBeforeOpen)&&this.focusedElBeforeOpen.focus()}_setupActiveTour(){this.trigger("active",{tour:this}),R0.activeTour=this}setupModal(){this.modal=new ztr({target:this.options.modalContainer||document.body,props:{styles:this.styles}})}_skipStep(t,n){const r=this.steps.indexOf(t);if(r===this.steps.length-1)this.complete();else{const i=n?r+1:r-1;this.show(i,n)}}_updateStateBeforeShow(){this.currentStep&&this.currentStep.hide(),this.isActive()||this._setupActiveTour()}_setTourID(t){const n=this.options.tourName||"tour",r=t||HYe();this.id=`${n}--${r}`}}const R0=new Utr,hZe=typeof window>"u";R0.Step=hZe?ZJn:NY;R0.Tour=hZe?HJn:Wtr;const BX=b.createContext(void 0);BX.Consumer;const Gtr=({children:e})=>EJn.jsx(BX.Provider,{value:{Shepherd:R0},children:e}),Vtr=""+new URL("agentic-sequence-CExfswgi.png",import.meta.url).href,Btr=""+new URL("canvas-code-inline-edit-DLji9b0m.png",import.meta.url).href,Ytr=""+new URL("canvas-overview-CruGEIRC.png",import.meta.url).href,Ztr=""+new URL("canvas-variables-view-DrA20zqs.png",import.meta.url).href,Htr=""+new URL("chat-attachments-_3cRrONU.png",import.meta.url).href,Ktr=""+new URL("chat-full-view-e-eJPzrw.png",import.meta.url).href,Jtr=""+new URL("chat-input-CU-CA7Se.png",import.meta.url).href,enr=""+new URL("inline-edit-canvas-O9conTkE.png",import.meta.url).href,tnr=e=>{const t=Array.from(document.querySelectorAll(`[data-tour-tag="${e}"]`));return t.find(n=>n.offsetParent!==null)??t[0]??null},a_e=e=>{document.querySelector(`[data-tour-action="${e}"]`)?.click()},o_e=[{id:"welcome",title:"Welcome to Local Operator",text:`Local Operator is an AI agents platform that allows you to create a team of proactive AI agents that support you and help to reduce your daily workload.<br/><img src="${Ktr}" alt="Chat full view" style="width: 100%; height: 350px; object-fit: contain; border-radius: 8px;"/><br />These agents are different from simple chatbots because they can actually do things for you on your computer like create files, run code and analytics, edit images, videos, and PDFs, organize your system, and much more.<br/><br/>In this walkthrough we'll cover:<ul><li>Creating agents</li><li>Making agents do things</li><li>The canvas workspace</li><li>Customizing agents</li><li>Agent hub for sharing and collaborating</li><li>Schedules for proactive agents</li><li>Settings for customization</li></ul>Let's explore how it works.`,buttons:[{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"agent-list",attachTo:{element:'[data-tour-tag="agent-list-panel"]',on:"right"},title:"Your agents",text:"On the left, you'll see a list of your available AI agents. You can select an agent to start a conversation or manage its settings. Think of this as your messenger contacts list, but for AI agents. There are no limits to how many agents you can have, so create as many as you need to handle all your daily tasks.<br/><br/>Use the create agents button at the top of the toolbar to create a new agent at any time. You can also import agents from the Agent hub, which we will cover later in this tour.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"select-agent",attachTo:{element:'[data-tour-tag="agent-list-item-button-0"]',on:"right"},title:"Select an agent",text:"Click on an agent to open the chat window to pull up your conversation with it. This will show the messages that you have sent them and the responses and actions that they have taken.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="agent-list-item-button-0"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"chat-input",attachTo:{element:'[data-tour-tag="chat-input-textarea"]',on:"top"},title:"Ask your agent anything",text:`Type your request here. Agents can answer questions, perform tasks, search the web, and much more. When you create a new agent, you'll see suggested prompts for ideas.<br /><br />Some powerful requests that you can try:<br /><br /><ul><li>"Create a spreadsheet in my Documents folder with all the major cities in Canada."</li><li>"Search the web for the latest news on AI and make a thorough report."</li><li>Select an attachment and then "translate this document to French."</li></ul><br /><img src="${Jtr}" alt="Chat input" style="width: 100%; height: 200px; object-fit: contain; border-radius: 8px;"/><br />You can also attach files to your message by clicking the paperclip button, which we will cover in the next step.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"attachments",attachTo:{element:'button[data-tour-tag="chat-input-attach-file-button"]',on:"top"},title:"Attach files to your message",text:`You can attach any files, images, or documents to your message by clicking this paperclip button, there are no limitations on the file types. Your agent can process, analyze, or translate these attachments as part of your request.<br /><br />Try attaching a PDF, image, or text file and then ask your agent to summarize, translate, or extract information from it.<br /><img src="${Htr}" alt="Chat attachments" style="width: 100%; height: 200px; object-fit: contain; border-radius: 8px;"/><br />Images like PNGs, JPGs, and PDFs are natively streamed into the model context window, so they can understand them directly without needing to run any code. Other files like Excel, Word, and CSV files are included as file paths on your device to direct the model's attention to work with them using code. You can attach massive files like million line CSVs and have the agent work with them using code.<br /><br />You can also paste images into the chat input, and attach multiple files at once to achieve more complex tasks. Try taking a screenshot of a website and then asking your agent to try to code it.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"agent-capabilities",attachTo:{element:'[data-tour-tag="chat-header"]',on:"top"},title:"More than just chat",text:`Local Operator agents are different from simple chatbots. They can perform actions on your computer, like creating files, running code, or browsing the web, based on your instructions. You'll see them use "tools" like reading, writing, and executing code to get things done. Agents have memory of the conversation, previous steps, learnings, and even store the execution variables of previous steps in code to be able to use them later in the conversation.<br /><img src="${Vtr}" alt="Agentic sequence" style="width: 100%; height: 350px; object-fit: contain; border-radius: 8px;"/><br />Local Operator agents are extremely flexible, so they can bounce back and forth with you for simple chatting, and know when they need to embark on a work journey to get things done in multiple steps with tool use.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const{openCommandPalette:e}=bn.getState();e(),setTimeout(()=>{this.next()},500)}}]},{id:"pre-command-palette-open-canvas",title:"Command palette",attachTo:{element:'[data-tour-tag="command-palette-dialog"]',on:"right"},text:`Let's quickly look at another powerful feature: the Command Palette. You can open it anywhere in the app by pressing <code>${CY(!0)}</code> on Mac and <code>${CY(!1)}</code> on Windows or Linux. This is a helpful window that you can open from anywhere in the app to be able to access your chats, agents, settings, pages and actions, and much more, using your keyboard. It can often be faster to access sections in the app this way instead of clicking through menus. Type a word to search everything at once, or start with a prefix to narrow it: <code>#</code> for chats, <code>@</code> for agents, <code>,</code> for settings, and <code>&gt;</code> for commands and pages. You can also just click Search in the sidebar to open it.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const{closeCommandPalette:e}=bn.getState();e(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const{closeCommandPalette:e}=bn.getState();e(),setTimeout(()=>{this.next()},500)}}]},{id:"canvas-open-button",attachTo:{element:'button[data-tour-tag="open-canvas-button"]',on:"left"},title:"Open the canvas",text:"Click here to open the Canvas, a workspace for files and dynamic visualizations where you can organize, plan, and interact with your agents in a more flexible way.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const{openCommandPalette:e}=bn.getState();e(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="open-canvas-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"canvas-feature",attachTo:{element:'[data-tour-tag="canvas-container"]',on:"left"},title:"The canvas: your visual workspace",text:`This is the Canvas, your workspace for files and dynamic visualizations where you can organize, plan, and interact with your agents in a more flexible way. Any files that your agents create on your device can be opened here by clicking on the file icons that you see as they work.<br/><br/>Agents can make dynamic visualizations like games, charts, maps, and more in HTML files. Any HTML files you open will be rendered dynamically in an iframe. Any markdown files that you open will be rendered in full markdown viewer with support for code blocks, tables, mermaid diagrams, and more.<br/><img src="${Ytr}" alt="Canvas overview" style="width: 100%; height: 300px; object-fit: contain; border-radius: 8px;"/>`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="close-canvas-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="canvas-documents-view-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"canvas-documents-view",attachTo:{element:'button[data-tour-tag="canvas-documents-view-button"]',on:"top"},title:"Documents view",text:`The Documents view shows all your open notes, blog articles, code, and visualizations as tabs. You can switch between documents to edit them and see dynamic visualizations in HTML created by your agents. Use this view to work with your notes, reports, and agent-generated content.<br /><br />This is where you can get more precise around your agents' work.<br/><img src="${enr}" alt="Inline edit canvas" style="width: 100%; height: 200px; object-fit: contain; border-radius: 8px;"/><br />In your documents, highlight any text that you want your agent to improve and press Cmd/Ctrl+K to bring up the inline AI editor.
1455
1455
  <br /><img src="${Btr}" alt="Canvas code inline edit" style="width: 100%; height: 200px; object-fit: cover; object-position: top; border-radius: 8px;"/><br />You can be as precise as you want and the agent will edit the document for you in place, using its memories and context so you don't have to re-explain things.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="canvas-files-view-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"canvas-files-view",attachTo:{element:'button[data-tour-tag="canvas-files-view-button"]',on:"top"},title:"Files view",text:"The Files view lets you browse and open files that your agents have created or that are relevant to your current conversation. Use this to quickly access, preview, and open files in the Canvas workspace.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('button[data-tour-tag="canvas-documents-view-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="canvas-variables-view-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"canvas-variables-view",attachTo:{element:'button[data-tour-tag="canvas-variables-view-button"]',on:"top"},title:"Variables view",text:`The Variables view displays the "code memory" that agents have stored during their work. These are technical variables that include results, intermediate values, and other data that agents use to perform tasks. You can inspect and manage these variables here.<br /><br />This section will be most helpful for more technical users who want to understand how agents are working and what they are doing.<br/><img src="${Ztr}" alt="Canvas variables" style="width: 100%; height: 350px; object-fit: contain; border-radius: 8px;"/>`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('button[data-tour-tag="canvas-files-view-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="close-canvas-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"agent-options",attachTo:{element:'button[data-tour-tag="agent-options-button"]',on:"right"},title:"Agent options",text:"Click here to see options for the currently selected agent, like viewing its settings, exporting it, or deleting it.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('button[data-tour-tag="open-canvas-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="agent-options-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"click-view-settings-from-chat",attachTo:{element:'[role="menuitem"][data-tour-tag="view-agent-settings-menu-item"]',on:"right"},title:"View configuration",text:'Click "View agent settings" to see and change how this agent works and change things like its name, description, hosting provider, and AI model.',buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[role="menuitem"][data-tour-tag="view-agent-settings-menu-item"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"view-agent-settings",attachTo:{element:'div[data-tour-tag="agent-settings-details-paper"]',on:"left"},title:"Agent configuration",text:"This is where you can customize and configure your agent. You can change its name, description, the AI model it uses, its temperature for creativity, and other chat settings.<br /><br />The agents will already have default settings that work well for most use cases, but if you want to roll up your sleeves and customize, you can do so here.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-chat"]');e&&e.click(),setTimeout(()=>{const t=document.querySelector('button[data-tour-tag="agent-options-button"]');t&&t.click()},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"select-provider",attachTo:{element:'[data-tour-tag="agent-settings-hosting-select"]',on:"left"},title:"Select hosting provider",text:`Choose an AI provider for your agent. If you don't pick one here, then the default provider from the settings page will be used. Providers offer different AI models and pricing. Radient is recommended for Local Operator as its "Automatic" mode is optimized for the lowest cost and best performance.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"select-model",attachTo:{element:'[data-tour-tag="agent-settings-model-select"]',on:"left"},title:"Select AI model",text:"After selecting a provider, choose an AI model. Models marked as 'Recommended' are known to work well with Local Operator. Other models might have inconsistent performance. If a model you expect to be recommended isn't listed, please let us know if it works well for you in Local Operator via GitHub Issues or email.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"modify-security-prompt",attachTo:{element:'[data-tour-tag="agent-settings-security"]',on:"left"},title:"Customize security behaviors",text:"This prompt provides separate instructions to the security agent that reviews this agent's work. You can explicitly allow certain actions that would normally be blocked. If you encounter frequent security interventions, consider adding a note here for the security agent.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"modify-agent-prompt",attachTo:{element:'[data-tour-tag="agent-settings-system-prompt"]',on:"left"},title:"Customize the agent's behavior",text:"This prompt allows you to customize the baseline behavior of the agent. While most customization can happen by talking to the agent (it records learnings in its notebook), you can provide specific workflow instructions here that will be followed separately.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"create-new-agent",attachTo:{element:'button[data-tour-tag="create-new-agent-button"]',on:"bottom"},title:"Create a new agent",text:'Click the "+" button to create a brand new agent from scratch. You can then customize its behavior and capabilities.',buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="agent-list-item-button-0"]');e&&e.click(),setTimeout(()=>{const t=document.querySelector('button[data-tour-tag="agent-options-button"]');t&&t.click()},500),setTimeout(()=>{const t=document.querySelector('[role="menuitem"][data-tour-tag="view-agent-settings-menu-item"]');t&&t.click()},1e3),setTimeout(()=>{this.back()},1500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="create-new-agent-button"]');e&&e.click(),setTimeout(()=>{this.next()},1e3)}}]},{id:"agent-naming-guidelines",attachTo:{element:'[data-tour-tag="create-agent-dialog"]',on:"right"},title:"Naming and describing your agent",text:`Give your agent a clear, descriptive name that reflects its purpose (e.g., "File Organizer" or "Web Researcher").
1456
- A good description helps you and others understand what the agent does and any special instructions. The descriptions are also used by other agents to help them understand how to tag each other in for certain tasks.<br /><br />If you want this agent to be part of the agent-to-agent communication network, it will need to have a description that captures its purpose and capabilities. Be concise and specific.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="create-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="create-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"navigate-agent-hub",attachTo:{element:'[data-tour-tag="nav-item-agent-hub"]',on:"right"},title:"Discover more agents",text:`Let's visit the Agent hub to find community-created agents. Click on the "Agent hub" icon in the navigation bar.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agents"]');e&&e.click(),setTimeout(()=>{const t=document.querySelector('[data-tour-tag="create-new-agent-button"]');t&&t.click()},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agent-hub"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"agent-hub-view",attachTo:{element:'[data-tour-tag="agent-hub-sidebar-container"]',on:"right"},title:"The Agent hub",text:"Here you can browse agents by category or search for specific ones. These agents are shared by the community and can perform various specialized tasks.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"download-agent",attachTo:{element:'button[data-tour-tag="agent-hub-download-button"]',on:"bottom"},title:"Download an agent",text:'Find an agent that interests you and click the "Get" button to add it to your local agent list.',buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agents"]');e&&e.click(),setTimeout(()=>{this.next()},1e3)}}]},{id:"upload-agent-hub",attachTo:{element:()=>tnr("upload-to-hub-header-button"),on:"bottom"},title:"Share your agents",text:"If you create a useful agent, you can also share it with the community by uploading it to the Agent hub from the agent options menu.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agent-hub"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){a_e("open-upload-dialog"),setTimeout(()=>{this.next()},500)}}]},{id:"upload-agent-hub-dialog",attachTo:{element:'[data-tour-tag="upload-agent-dialog"]',on:"right"},title:"Upload agent to hub",text:"This dialog allows you to share your agent with the community. You need to have a Radient account to upload an agent, which is free to create and doesn't cost anything per upload. You can review the agent details and confirm the upload. Make sure your agent meets the required criteria before submitting. Also be aware that any conversation history and learnings for this agent will be part of its training and will be visible to the public. So don't share agents publicly that know sensitive information.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('button[data-tour-tag="upload-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="upload-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"navigate-schedules",attachTo:{element:'[data-tour-tag="nav-item-schedules"]',on:"right"},title:"Automate tasks with schedules",text:"Local Operator can run tasks for you on a regular basis. Let's check out the Schedules section.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agents"]');e&&e.click(),setTimeout(()=>{a_e("open-upload-dialog")},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-schedules"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"schedules-overview",title:"Proactive agents with schedules",text:"A powerful feature of Local Operator is the ability to ask agents to perform tasks on their own on a recurring basis. This turns them from reactive agent bots to proactive agents that work on their own in the background to support you without you needing to continually ask them to do things.<br /><br />You can simply ask any agent to do something at some point in the future, or to handle some daily task at a certain time, and it will create a prompt for itself that will be executed at the specified times.<br /><br />Here, you can view, create, and manage all your scheduled tasks in one place to streamline your workflow and ensure important actions happen automatically.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"create-schedule",attachTo:{element:'button[data-tour-tag="create-schedule-button"]',on:"bottom"},title:"Set up a recurring task",text:'Click "Create schedule" to ask an agent to perform a task for you regularly, like sending a daily report or checking for news updates.<br /><br />You can also create one-off tasks that only run once at some point in the future.',buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="create-schedule-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"create-schedule-dialog",attachTo:{element:'[data-tour-tag="create-schedule-dialog"]',on:"right"},title:"Configure your schedule",text:"While it is often much easier to simply ask the agent to do a task on a recurring basis for you, you can also manually set up a schedule for a task here or update existing tasks.<br /><br />The prompt is the message that will be sent to the agent at the predefined schedule. You can update the time of day in your local timezone, the frequency of the task, and even specify a specific date or time that the task should stop running at.<br /><br />You can also schedule one-off tasks that only run once at some point in the future.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="create-schedule-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="create-schedule-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"navigate-settings",attachTo:{element:'[data-tour-tag="nav-item-settings"]',on:"right"},title:"Personalize your experience",text:"Now, let's explore the Settings menu to customize Local Operator to your liking.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-schedules"]');e&&e.click(),setTimeout(()=>{const t=document.querySelector('button[data-tour-tag="create-schedule-button"]');t&&t.click()},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-settings"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"general-settings",attachTo:{element:'div[data-tour-tag="settings-general-section"]',on:"right"},title:"General settings",text:"Here you can update your user profile, configure model settings (like default hosting provider and model), and adjust history settings for conversations and learnings.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"appearance-settings",attachTo:{element:'[data-tour-tag="settings-appearance-section"]',on:"right"},title:"Customize appearance",text:"Choose from various themes to change the look and feel of Local Operator. Find one that suits your style.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"radient-account-settings",attachTo:{element:'[data-tour-tag="settings-radient-account-section"]',on:"right"},title:"Radient account",text:"Connect your Radient account to access your Radient Pass details, credits, and unlock unified access to models and tools. Radient is the best way to use Local Operator since it powers the AI models, web search, image generation, and much more with a single integration. You get free credits when you sign up to try it out and bonus credits when you top up.<br /><br />When you sign in for the first time, it will automatically create a Radient Pass for you and save it securely to your computer. This will power your Local Operator agents with Radient Automatic, which mixes and matches AI models to get you the best balance of speed, accuracy, and cost in every step of your agents' workflows.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"integrations-settings",attachTo:{element:'[data-tour-tag="settings-integrations-section"]',on:"right"},title:"Connect your services",text:"Enhance your agents' capabilities by connecting your Google services like Gmail, Calendar, and Drive. This allows agents to access and manage your information with your permission.<br /><br />You need to be logged in to a Radient account to use this feature, however it is free to use and doesn't cost any additional Radient credits per action.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"api-credentials-settings",attachTo:{element:'[data-tour-tag="settings-api-credentials-section"]',on:"right"},title:"Manage API keys",text:"Configure API keys for various services and AI models here. This allows your agents to access external tools and capabilities.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"application-updates-settings",attachTo:{element:'[data-tour-tag="settings-app-updates-section"]',on:"right"},title:"Stay up to date",text:"Check for updates to Local Operator here to ensure you have the latest features and improvements. You can see your current version information below.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"tour-complete",title:"Tour complete",text:"You've now seen the main features of Local Operator. Feel free to explore further and discover all the ways your AI agents can assist you. Happy automating.",buttons:[{text:"Finish",classes:"shepherd-button-primary",action:function(){this.complete()}}]}],nnr=()=>{const e=ka(),{completeTourOnboarding:t}=QT(),n=b.useContext(BX),r={cancelIcon:{enabled:!0},scrollTo:{behavior:"smooth",block:"center"}},i=!0;return{startTour:a=>{if(n?.tour?.isActive()&&!a?.forceModalCompleted){console.log("Onboarding tour is already active (from context.tour). Not starting another.");return}const o=QT.getState();if(!a?.forceModalCompleted&&!o.isModalComplete){console.log("Onboarding modal not completed (checked via store). Tour will not start.");return}if(o.isTourComplete&&!a?.forceModalCompleted){console.log("Onboarding tour already completed in store and not forced. Not starting again.");return}let l=n?.tour;const c=n?.Shepherd;if(!l&&c&&(l=c.activeTour,!l&&c.Tour&&(console.log("No active Shepherd tour found from context or global. Creating a new one."),l=new c.Tour({useModalOverlay:i,defaultStepOptions:r}))),!l){console.warn("Failed to get or create a Shepherd tour instance.",n);return}if(l.isActive()){console.log("Tour is already active. Not starting again.");return}if(l.options.defaultStepOptions={...l.options.defaultStepOptions||{},...r},l.options.useModalOverlay=i,a?.firstAgentId&&(l.options.firstAgentId=a.firstAgentId),l.off("complete",t),l.on("complete",t),l.off("cancel",t),l.on("cancel",t),a?.forceModalCompleted||!l.isActive()){const u=[...l.steps];for(const d of u)d.id&&l.removeStep(d.id);l.addSteps(o_e)}else l.steps.length===0&&l.addSteps(o_e);typeof l.start=="function"?(e("/"),l.start()):console.warn("Shepherd tour instance does not have a start method.",l)}}},rnr=()=>{const{isModalComplete:e,isTourComplete:t}=QT(),{startTour:n}=nnr(),r=H.useContext(BX),{data:i}=O5(1,1);return b.useEffect(()=>{if(e&&!t&&r){const s=setTimeout(()=>{const a=i?.agents?.[0]?.id;n({firstAgentId:a})},500);return()=>clearTimeout(s)}},[e,t,r,n,i]),null},inr=({children:e})=>p.jsxs(Gtr,{children:[e,p.jsx(rnr,{})]}),l_e=J2e,c_e="The backend update could not start. Retry, or update from Settings, under Application updates.",snr=()=>{const e=Wa(),t=Mi(),[n,r]=b.useState(!1),[i,s]=b.useState(null),a=b.useCallback(()=>{t.invalidateQueries({queryKey:Td.capabilities})},[t]),o=b.useCallback(async()=>{r(!0),s(null);let m=null;const v=window.api.updater.onBackendUpdateError(y=>{y.phase==="update"&&(m=AZ(y.message))});try{if(await window.api.updater.updateBackend()===!1){s(m??c_e);return}a()}catch(y){s(y instanceof Error?If(y):c_e)}finally{v(),r(!1)}},[a]);if(e.isLoading)return null;const l=e.data,c=l?l_e.filter(m=>(l.features?.[m]??0)<1):[...l_e],u=!!l&&!l?.desktop_available;if(!eCe(l))return null;const d=Z2e(e.error),h=!!l,f=!!window.api?.updater?.updateBackend,O=oot({kind:d,unpaired:u,missing:c,answered:h}),g=f&&aot({kind:d,unpaired:u,answered:h});return p.jsx("div",{className:"fixed inset-x-0 top-0 z-2100 w-full",children:p.jsx(Ml,{variant:"warning",className:"items-center rounded-none border-x-0 border-t-0",children:p.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[p.jsxs(rT,{children:[O,i?` ${i}`:null]}),p.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[g&&p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void o(),disabled:n,children:n?"Updating":"Update backend"}),p.jsx(we,{variant:"secondary",size:"sm",onClick:a,children:"Retry"})]})]})})})},anr=""+new URL("radient-icon-1024x1024-D_JJedvo.png",import.meta.url).href,fZe={all:["radient-prices"],prices:()=>[...fZe.all,"prices"]},onr=()=>{const e=ir({queryKey:fZe.prices(),queryFn:()=>MZ({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}},pZe=po()(jd(e=>({hasBeenNotified:!1,setHasBeenNotified:t=>{e({hasBeenNotified:t})}}),{name:"low-credits-storage"})),lnr=({open:e,onClose:t,onGoToConsole:n})=>{const{setHasBeenNotified:r}=pZe(),{prices:i,isLoading:s,error:a}=onr(),o=u=>typeof u!="number"?"$...":`$${u.toFixed(2)} USD`,l=()=>{r(!0),t()},c=()=>{r(!0),n()};return p.jsx(Nc,{open:e,onClose:l,title:p.jsxs(p.Fragment,{children:[p.jsx("img",{src:anr,alt:"Radient icon",className:"size-7"}),"Running low on Radient credits?"]}),maxWidth:"sm",fullWidth:!1,actions:p.jsxs(p.Fragment,{children:[p.jsx(sl,{onClick:l,children:"Maybe later"}),p.jsx(vd,{onClick:c,startIcon:p.jsx(Y3,{size:18}),className:"min-w-55",children:"Get more credits"})]}),children:p.jsxs("div",{className:"flex flex-col items-center gap-4 py-2 text-center",children:[p.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Unlock the full power of Local Operator with"," ",p.jsx("span",{className:"font-bold text-accent",children:"Radient Pass"}),"."]}),p.jsx("p",{className:"text-body-sm text-ink-muted",children:"Radient Automatic is often cheaper than bringing your own key: its smart model routing picks the most cost-effective model for each step of your agentic workflows."}),p.jsx("p",{className:"text-body-sm text-ink-muted",children:"It's pay-as-you-go with no commitments. Load up what you need, starting small for maximum flexibility."}),p.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Plus, get"," ",p.jsx("span",{className:"font-medium text-ink",children:s?p.jsx(pr,{size:"sm",className:"mr-0.5 align-middle"}):o(i?.default_registration_credits)})," ","in bonus credits with your first purchase.",a&&p.jsx("span",{className:"mt-1 block text-meta text-danger",children:"Could not load bonus credit information."})]}),p.jsx("p",{className:"text-meta text-ink-dim",children:"You can also reach the Radient Console from Settings at any time."})]})})},u_e=({expanded:e})=>p.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[p.jsx("img",{src:FZe,alt:e?"":"Local Operator",loading:"eager",className:"size-6 shrink-0"}),e&&p.jsx("span",{className:"truncate font-semibold text-body text-ink",children:"Local Operator"})]}),OZe=H.memo(({expanded:e,useAuth:t=!1})=>{const n=ka(),{user:r,isAuthenticated:i,signOut:s}=jZ(),a=r?.name??"User",o=r?.email??"",l=b.useCallback(async()=>{i&&(await s(),window.location.reload())},[i,s]),c=b.useMemo(()=>a?a.split(" ").map(h=>h.charAt(0)).join("").toUpperCase().substring(0,2):null,[a]),u=p.jsxs("button",{type:"button",onClick:t?void 0:()=>n("/settings"),"aria-label":e?void 0:"Account settings",className:A("flex w-full items-center gap-2 rounded-sm transition-colors duration-fast ease-out-quart hover:bg-elevated",e?"px-3 py-1.5":"justify-center py-1.5"),children:[p.jsx($_e,{className:"size-7 shrink-0",children:p.jsx(k_e,{className:"bg-elevated text-ink",children:c??p.jsx(E2e,{size:14,"aria-hidden":"true"})})}),e&&a&&p.jsxs("span",{className:"min-w-0 text-left",children:[p.jsx("span",{className:"block truncate text-body-sm text-ink",children:a}),o&&p.jsx("span",{className:"block truncate text-meta text-ink-dim",children:o})]})]}),d=e?u:p.jsx(rt,{content:"Account settings",side:"right",children:u});return t?p.jsxs(px,{children:[e?p.jsx(iv,{asChild:!0,children:u}):p.jsx(rt,{content:"Account settings",side:"right",children:p.jsx(iv,{asChild:!0,children:u})}),p.jsxs(Ox,{align:"end",side:"top",className:"min-w-50",children:[p.jsxs($s,{onSelect:()=>n("/settings"),children:[p.jsx(rg,{size:16,"aria-hidden":"true"}),"Settings"]}),p.jsxs($s,{children:[p.jsx(_2e,{size:16,"aria-hidden":"true"}),"Privacy and security"]}),p.jsx(Yb,{}),p.jsxs($s,{onSelect:l,className:"text-danger focus:bg-danger-wash focus:text-danger",children:[p.jsx(Fnt,{size:16,"aria-hidden":"true"}),"Sign out"]})]})]}):d});OZe.displayName="UserProfileSidebar";const d_e={expanded:"w-55",collapsed:"w-12"},cnr=()=>{const e=ka(),t=Ict(),{isSidebarCollapsed:n,toggleSidebar:r}=bn(),i=bn(f=>f.openCommandPalette),s=!n,a=[{icon:hZ,label:"Chat",path:"/chat",isActive:t==="chat",tourTag:"nav-item-chat"},{icon:Jv,label:"My agents",path:"/agents",isActive:t==="agents",tourTag:"nav-item-agents"},{icon:C2e,label:"Agent hub",path:"/agent-hub",isActive:t==="agent-hub",tourTag:"nav-item-agent-hub"},{icon:l2e,label:"Schedules",path:"/schedules",isActive:t==="schedules",tourTag:"nav-item-schedules"},{icon:_g,label:"Browser",path:"/browser",isActive:t==="browser",tourTag:"nav-item-browser"},{icon:rg,label:"Settings",path:"/settings",isActive:t==="settings",tourTag:"nav-item-settings"}],o=f=>{const O=p.jsxs("button",{type:"button",onClick:()=>e(f.path),"data-tour-tag":f.tourTag,"aria-current":f.isActive?"page":void 0,"aria-label":s?void 0:f.label,className:A("flex h-8 w-full items-center rounded-sm text-body-sm transition-colors duration-fast ease-out-quart",s?"justify-start gap-2 px-3":"justify-center",f.isActive?"bg-accent-wash font-medium text-ink":"text-ink-muted hover:bg-elevated hover:text-ink"),children:[p.jsx(f.icon,{size:16,"aria-hidden":"true",className:A("shrink-0",f.isActive&&"text-accent")}),s&&p.jsx("span",{className:"truncate",children:f.label})]});return s?p.jsx("li",{children:O},f.path):p.jsx("li",{children:p.jsx(rt,{content:f.label,side:"right",children:O})},f.path)},l=s?"Collapse sidebar":"Expand sidebar",c=navigator.platform.toUpperCase().indexOf("MAC")>=0,u=`Search (${CY(c)})`,d=s?p.jsxs("button",{type:"button","data-command-palette-trigger":"",onClick:i,className:A("flex h-8 w-full items-center gap-2 rounded-sm px-3 text-body-sm text-ink-muted","transition-colors duration-fast ease-out-quart","hover:bg-elevated hover:text-ink"),children:[p.jsx(dv,{size:16,"aria-hidden":"true",className:"shrink-0"}),p.jsx("span",{className:"truncate",children:"Search"}),p.jsx("span",{"aria-hidden":"true",className:"ml-auto",children:p.jsx(fd,{shortcut:eJn(c)})})]}):p.jsx(rt,{content:u,side:"right",children:p.jsx("button",{type:"button","data-command-palette-trigger":"",onClick:i,"aria-label":u,className:A("flex h-8 w-full items-center justify-center rounded-sm text-ink-muted","transition-colors duration-fast ease-out-quart","hover:bg-elevated hover:text-ink"),children:p.jsx(dv,{size:16,"aria-hidden":"true"})})}),h=p.jsx("div",{className:A("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"),children:p.jsx(rt,{content:l,side:"right",children:p.jsx(we,{variant:"ghost",size:"icon-sm",onClick:r,"aria-label":l,"aria-expanded":s,children:s?p.jsx(Y1,{"aria-hidden":"true"}):p.jsx(Dp,{"aria-hidden":"true"})})})});return p.jsxs("nav",{className:A("group flex shrink-0 flex-col overflow-x-hidden bg-sunken transition-[width] duration-base ease-out-quart",s?d_e.expanded:d_e.collapsed),children:[p.jsx("div",{className:A("flex h-12 shrink-0 items-center",s?"justify-between pr-2 pl-5":"justify-center"),children:s?p.jsxs(p.Fragment,{children:[p.jsx(u_e,{expanded:!0}),h]}):p.jsxs("div",{className:"relative flex size-8 items-center justify-center",children:[p.jsx("div",{className:"transition-opacity duration-fast ease-out-quart group-hover:opacity-0 group-focus-within:opacity-0",children:p.jsx(u_e,{expanded:!1})}),p.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:h})]})}),p.jsx("ul",{className:"flex flex-col gap-1 p-2",children:a.map(o)}),p.jsxs("div",{className:"mt-auto flex flex-col gap-1 p-2",children:[d,p.jsx(OZe,{expanded:s})]})]})},unr=1,dnr=()=>{const{isAuthenticated:e,user:t}=jZ(),{hasBeenNotified:n,setHasBeenNotified:r}=pZe(),[i,s]=b.useState(!1),[a,o]=b.useState(null),l=b.useCallback(async()=>{if(!(!e||!t?.radientUser?.account?.tenant_id))try{const h=await MZ({operation:"credits",tenantId:t.radientUser.account.tenant_id});if(!h||typeof h.balance!="number")throw new Error("Invalid credit balance response format");o(h.balance)}catch(h){console.error("Failed to fetch Radient credits:",h),o(null)}},[e,t?.radientUser?.account?.tenant_id]);return b.useEffect(()=>{e&&l()},[e,l]),b.useEffect(()=>{e&&a!==null?a<unr?n||s(!0):(s(!1),n&&r(!1)):s(!1)},[e,n,a,r]),{isLowCreditsDialogOpen:i,openRadientConsole:()=>{window.api?.openExternal?window.api.openExternal("https://console.radienthq.com"):window.open("https://console.radienthq.com","_blank"),r(!0),s(!1)},closeLowCreditsDialog:()=>{s(!1)},onLowCreditsDialogClose:()=>{r(!0),s(!1)},currentCredits:a}},hnr=b.lazy(()=>Le(()=>import("./agent-details-page-X_YX-39M.js"),__vite__mapDeps([8,1,2,9]),import.meta.url).then(e=>({default:e.AgentDetailsPage}))),fnr=b.lazy(()=>Le(()=>import("./agent-hub-page-CWks9bfB.js"),__vite__mapDeps([10,1,2,11,12,9]),import.meta.url).then(e=>({default:e.AgentHubPage}))),h_e=b.lazy(()=>Le(()=>import("./agents-page-Ciczw9Ds.js"),__vite__mapDeps([13,1,2]),import.meta.url).then(e=>({default:e.AgentsPage}))),pnr=b.lazy(()=>Le(()=>import("./schedules-page-BlsJzf_J.js"),__vite__mapDeps([14,1,2,12,15]),import.meta.url).then(e=>({default:e.SchedulesPage}))),Onr=b.lazy(()=>Le(()=>import("./browser-page-CSGhUQfP.js"),__vite__mapDeps([16,1,2]),import.meta.url).then(e=>({default:e.BrowserPage}))),gnr=b.lazy(()=>Le(()=>import("./settings-page-DJSZic3M.js"),__vite__mapDeps([17,1,2,12,18,15]),import.meta.url).then(e=>({default:e.SettingsPage}))),mnr=()=>{const{isOnboardingActive:e}=yct(),{isLowCreditsDialogOpen:t,openRadientConsole:n,onLowCreditsDialogClose:r}=dnr(),{isCommandPaletteOpen:i,isCreateAgentDialogOpen:s,closeCreateAgentDialog:a}=bn();up(i,"command-palette"),up(s,"create-agent-dialog"),up(e,"onboarding"),up(t,"low-credits");const o=ka(),l=Wa(),c=Oi(l.data,"session_catalogue",2),u=h=>{o(`/chat/${h}`),a()};tJn();const d=Sn(h=>h.setActiveSession);return b.useEffect(()=>{const h=window.api?.desktop?.onOpenConversation?.(f=>{f!==null&&performance.mark("lop:open:requested"),d(f),o("/chat")});return()=>h?.()},[o,d]),b.useEffect(()=>{const h=window.api?.browser?.onConsentAttention?.(f=>{G5t(f.entryId),o("/browser")});return()=>h?.()},[o]),b.useEffect(()=>{const h=f=>{e||c&&GHn(f)&&(f.preventDefault(),Sn.getState().stageDraft(void 0,!0),o("/chat"))};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[c,e,o]),p.jsx(inr,{children:p.jsxs("div",{className:"relative flex h-screen overflow-hidden",children:[i&&p.jsx(HKn,{}),p.jsx(hKn,{}),p.jsx(DCe,{}),p.jsx(_Jn,{open:e}),p.jsx(sct,{}),p.jsx(snr,{}),p.jsx($ut,{}),p.jsx(lnr,{open:t,onClose:r,onGoToConsole:n}),p.jsx(nut,{open:s,onClose:a,onAgentCreated:u}),p.jsx(cnr,{}),p.jsx("main",{className:"flex grow flex-col overflow-hidden",children:p.jsx(b.Suspense,{fallback:p.jsx("div",{className:"flex grow items-center justify-center",children:p.jsx(pr,{size:"lg",label:"Loading page"})}),children:p.jsxs(Tet,{children:[p.jsx(Bc,{path:"/",element:p.jsx(Jie,{to:"/chat",replace:!0})}),p.jsx(Bc,{path:"/chat",element:p.jsx(uTe,{})}),p.jsx(Bc,{path:"/chat/:agentId",element:p.jsx(uTe,{})}),p.jsx(Bc,{path:"/agents",element:p.jsx(h_e,{})}),p.jsx(Bc,{path:"/agents/:agentId",element:p.jsx(h_e,{})}),p.jsx(Bc,{path:"/settings",element:p.jsx(gnr,{})}),p.jsx(Bc,{path:"/agent-hub",element:p.jsx(fnr,{})}),p.jsx(Bc,{path:"/agent-hub/:agentId",element:p.jsx(hnr,{})}),p.jsx(Bc,{path:"/schedules",element:p.jsx(pnr,{})}),p.jsx(Bc,{path:"/browser",element:p.jsx(Onr,{})}),p.jsx(Bc,{path:"*",element:p.jsx(Jie,{to:"/chat",replace:!0})})]})})})]})})};function M3(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}const vnr=3,ynr=3e3;function bnr(e){return e instanceof CSSTransition&&e.playState==="running"}function wnr(e){const t=e.effect,n=t instanceof KeyframeEffect?t.target:null,r=e.transitionProperty,s=/^[a-z-]+$/.test(r)&&n instanceof Element?getComputedStyle(n).getPropertyValue(r).trim()||"(empty)":"(unreadable)";return`${r||"(unnamed property)"} on ${gre(n)??"an element no longer in the document"} = ${s}`}async function xnr(e=ynr){const t=performance.now();let n=0;for(;;){await M3();const r=Math.round(performance.now()-t),i=document.getAnimations().filter(bnr);if(n=i.length===0?n+1:0,n>=vnr)return{waitedMs:r,timedOut:!1,pending:[]};if(r>e)return{waitedMs:r,timedOut:!0,pending:i.map(wnr)}}}const Snr=/^#/;function nT(){const e=window.location.hash.replace(Snr,"");return e===""?"/":e}function gre(e){if(!e)return null;const t=e.getAttribute("aria-label")??e.textContent??"";return`${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""} "${t.trim().slice(0,60)}"`}function $nr(e){const t=e.getBoundingClientRect(),n=t.left+t.width/2,r=t.top+t.height/2,i=document.elementFromPoint(n,r),s=i!==null&&(i===e||e.contains(i)),a={bubbles:!0,cancelable:!0,composed:!0,button:0,buttons:1,clientX:n,clientY:r,view:window};return e.dispatchEvent(new PointerEvent("pointerdown",{...a,pointerId:1,isPrimary:!0})),e.dispatchEvent(new MouseEvent("mousedown",a)),e.dispatchEvent(new PointerEvent("pointerup",{...a,buttons:0,pointerId:1,isPrimary:!0})),e.dispatchEvent(new MouseEvent("mouseup",{...a,buttons:0})),e.dispatchEvent(new MouseEvent("click",{...a,buttons:0})),{hitTest:s,hit:gre(i),rect:{x:t.x,y:t.y,width:t.width,height:t.height}}}function zq(e,t){if(typeof e!="string"||e==="")throw new Error(`${t} must be a non-empty string`);return e}async function knr(e,t=1e4){const n=Date.now();for(;nT()!==e;){if(Date.now()-n>t)throw new Error(`route did not become ${e} (it is ${nT()})`);await new Promise(r=>setTimeout(r,50))}return await M3(),nT()}function Tnr(){const e=window.__loDevDriver;return e?.armed?e.install({hello:()=>({armed:!0,outDir:e.outDir,title:document.title,route:nT(),href:window.location.href,theme:bn.getState().themeName,viewport:{width:window.innerWidth,height:window.innerHeight,devicePixelRatio:window.devicePixelRatio},visibilityState:document.visibilityState,hasFocus:document.hasFocus(),apiBaseUrl:oi.baseUrl,userAgent:navigator.userAgent}),state:()=>{const t=bn.getState(),n=Sn.getState();return{route:nT(),theme:t.themeName,commandPaletteOpen:t.isCommandPaletteOpen,canvasOpen:t.isCanvasOpen,runPanelOpen:t.isRunPanelOpen,browserPaneOpen:t.isBrowserPaneOpen,browserPanelWidth:t.browserPanelWidth,activeSessionId:n.activeSessionId,sessionCount:n.sessions.length,onboardingVisible:!!document.querySelector("[data-onboarding-modal]")}},navigate:async t=>{const n=zq(t,"navigate path");if(!n.startsWith("/"))throw new Error(`navigate path must start with "/" (got "${n}")`);return window.location.hash=`#${n}`,{route:await knr(n)}},setTheme:async t=>{const n=zq(t,"theme name");bn.getState().setTheme(n),await M3();const r=document.documentElement.getAttribute("data-theme"),i=await xnr();return{theme:bn.getState().themeName,dataTheme:r,settledAfterMs:i.waitedMs,settleTimedOut:i.timedOut,settlePending:i.pending}},press:async t=>{const n=typeof t=="string"?{selector:t}:t,r=zq(n?.selector,"press selector"),i=typeof n?.timeoutMs=="number"?n.timeoutMs:1e4,s=Date.now();let a=null;for(;a===null&&(a=document.querySelector(r),a===null);){if(Date.now()-s>i)throw new Error(`nothing matches ${r} after ${i}ms of waiting`);await new Promise(l=>setTimeout(l,100))}const o=$nr(a);return await M3(),{selector:r,target:gre(a),...o}}}):[]}const _nr={queries:{staleTime:5*60*1e3,gcTime:10*60*1e3,retry:1,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!1,networkMode:"always"},mutations:{retry:1,networkMode:"always"}},gZe=new nHe({defaultOptions:_nr}),Pnr=`
1456
+ A good description helps you and others understand what the agent does and any special instructions. The descriptions are also used by other agents to help them understand how to tag each other in for certain tasks.<br /><br />If you want this agent to be part of the agent-to-agent communication network, it will need to have a description that captures its purpose and capabilities. Be concise and specific.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="create-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="create-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"navigate-agent-hub",attachTo:{element:'[data-tour-tag="nav-item-agent-hub"]',on:"right"},title:"Discover more agents",text:`Let's visit the Agent hub to find community-created agents. Click on the "Agent hub" icon in the navigation bar.`,buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agents"]');e&&e.click(),setTimeout(()=>{const t=document.querySelector('[data-tour-tag="create-new-agent-button"]');t&&t.click()},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agent-hub"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"agent-hub-view",attachTo:{element:'[data-tour-tag="agent-hub-sidebar-container"]',on:"right"},title:"The Agent hub",text:"Here you can browse agents by category or search for specific ones. These agents are shared by the community and can perform various specialized tasks.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"download-agent",attachTo:{element:'button[data-tour-tag="agent-hub-download-button"]',on:"bottom"},title:"Download an agent",text:'Find an agent that interests you and click the "Get" button to add it to your local agent list.',buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agents"]');e&&e.click(),setTimeout(()=>{this.next()},1e3)}}]},{id:"upload-agent-hub",attachTo:{element:()=>tnr("upload-to-hub-header-button"),on:"bottom"},title:"Share your agents",text:"If you create a useful agent, you can also share it with the community by uploading it to the Agent hub from the agent options menu.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agent-hub"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){a_e("open-upload-dialog"),setTimeout(()=>{this.next()},500)}}]},{id:"upload-agent-hub-dialog",attachTo:{element:'[data-tour-tag="upload-agent-dialog"]',on:"right"},title:"Upload agent to hub",text:"This dialog allows you to share your agent with the community. You need to have a Radient account to upload an agent, which is free to create and doesn't cost anything per upload. You can review the agent details and confirm the upload. Make sure your agent meets the required criteria before submitting. Also be aware that any conversation history and learnings for this agent will be part of its training and will be visible to the public. So don't share agents publicly that know sensitive information.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('button[data-tour-tag="upload-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="upload-agent-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"navigate-schedules",attachTo:{element:'[data-tour-tag="nav-item-schedules"]',on:"right"},title:"Automate tasks with schedules",text:"Local Operator can run tasks for you on a regular basis. Let's check out the Schedules section.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-agents"]');e&&e.click(),setTimeout(()=>{a_e("open-upload-dialog")},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-schedules"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"schedules-overview",title:"Proactive agents with schedules",text:"A powerful feature of Local Operator is the ability to ask agents to perform tasks on their own on a recurring basis. This turns them from reactive agent bots to proactive agents that work on their own in the background to support you without you needing to continually ask them to do things.<br /><br />You can simply ask any agent to do something at some point in the future, or to handle some daily task at a certain time, and it will create a prompt for itself that will be executed at the specified times.<br /><br />Here, you can view, create, and manage all your scheduled tasks in one place to streamline your workflow and ensure important actions happen automatically.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"create-schedule",attachTo:{element:'button[data-tour-tag="create-schedule-button"]',on:"bottom"},title:"Set up a recurring task",text:'Click "Create schedule" to ask an agent to perform a task for you regularly, like sending a daily report or checking for news updates.<br /><br />You can also create one-off tasks that only run once at some point in the future.',buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('button[data-tour-tag="create-schedule-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"create-schedule-dialog",attachTo:{element:'[data-tour-tag="create-schedule-dialog"]',on:"right"},title:"Configure your schedule",text:"While it is often much easier to simply ask the agent to do a task on a recurring basis for you, you can also manually set up a schedule for a task here or update existing tasks.<br /><br />The prompt is the message that will be sent to the agent at the predefined schedule. You can update the time of day in your local timezone, the frequency of the task, and even specify a specific date or time that the task should stop running at.<br /><br />You can also schedule one-off tasks that only run once at some point in the future.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="create-schedule-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.back()},500)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="create-schedule-dialog-cancel-button"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"navigate-settings",attachTo:{element:'[data-tour-tag="nav-item-settings"]',on:"right"},title:"Personalize your experience",text:"Now, let's explore the Settings menu to customize Local Operator to your liking.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-schedules"]');e&&e.click(),setTimeout(()=>{const t=document.querySelector('button[data-tour-tag="create-schedule-button"]');t&&t.click()},500),setTimeout(()=>{this.back()},1e3)}},{text:"Next",classes:"shepherd-button-primary",action:function(){const e=document.querySelector('[data-tour-tag="nav-item-settings"]');e&&e.click(),setTimeout(()=>{this.next()},500)}}]},{id:"general-settings",attachTo:{element:'div[data-tour-tag="settings-general-section"]',on:"right"},title:"General settings",text:"Here you can update your user profile, configure model settings (like default hosting provider and model), and adjust history settings for conversations and learnings.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"appearance-settings",attachTo:{element:'[data-tour-tag="settings-appearance-section"]',on:"right"},title:"Customize appearance",text:"Choose from various themes to change the look and feel of Local Operator. Find one that suits your style.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"radient-account-settings",attachTo:{element:'[data-tour-tag="settings-radient-account-section"]',on:"right"},title:"Radient account",text:"Connect your Radient account to access your Radient Pass details, credits, and unlock unified access to models and tools. Radient is the best way to use Local Operator since it powers the AI models, web search, image generation, and much more with a single integration. You get free credits when you sign up to try it out and bonus credits when you top up.<br /><br />When you sign in for the first time, it will automatically create a Radient Pass for you and save it securely to your computer. This will power your Local Operator agents with Radient Automatic, which mixes and matches AI models to get you the best balance of speed, accuracy, and cost in every step of your agents' workflows.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"integrations-settings",attachTo:{element:'[data-tour-tag="settings-integrations-section"]',on:"right"},title:"Connect your services",text:"Enhance your agents' capabilities by connecting your Google services like Gmail, Calendar, and Drive. This allows agents to access and manage your information with your permission.<br /><br />You need to be logged in to a Radient account to use this feature, however it is free to use and doesn't cost any additional Radient credits per action.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"api-credentials-settings",attachTo:{element:'[data-tour-tag="settings-api-credentials-section"]',on:"right"},title:"Manage API keys",text:"Configure API keys for various services and AI models here. This allows your agents to access external tools and capabilities.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"application-updates-settings",attachTo:{element:'[data-tour-tag="settings-app-updates-section"]',on:"right"},title:"Stay up to date",text:"Check for updates to Local Operator here to ensure you have the latest features and improvements. You can see your current version information below.",buttons:[{text:"Back",classes:"shepherd-button-secondary",action:function(){this.back()}},{text:"Next",classes:"shepherd-button-primary",action:function(){this.next()}}]},{id:"tour-complete",title:"Tour complete",text:"You've now seen the main features of Local Operator. Feel free to explore further and discover all the ways your AI agents can assist you. Happy automating.",buttons:[{text:"Finish",classes:"shepherd-button-primary",action:function(){this.complete()}}]}],nnr=()=>{const e=ka(),{completeTourOnboarding:t}=QT(),n=b.useContext(BX),r={cancelIcon:{enabled:!0},scrollTo:{behavior:"smooth",block:"center"}},i=!0;return{startTour:a=>{if(n?.tour?.isActive()&&!a?.forceModalCompleted){console.log("Onboarding tour is already active (from context.tour). Not starting another.");return}const o=QT.getState();if(!a?.forceModalCompleted&&!o.isModalComplete){console.log("Onboarding modal not completed (checked via store). Tour will not start.");return}if(o.isTourComplete&&!a?.forceModalCompleted){console.log("Onboarding tour already completed in store and not forced. Not starting again.");return}let l=n?.tour;const c=n?.Shepherd;if(!l&&c&&(l=c.activeTour,!l&&c.Tour&&(console.log("No active Shepherd tour found from context or global. Creating a new one."),l=new c.Tour({useModalOverlay:i,defaultStepOptions:r}))),!l){console.warn("Failed to get or create a Shepherd tour instance.",n);return}if(l.isActive()){console.log("Tour is already active. Not starting again.");return}if(l.options.defaultStepOptions={...l.options.defaultStepOptions||{},...r},l.options.useModalOverlay=i,a?.firstAgentId&&(l.options.firstAgentId=a.firstAgentId),l.off("complete",t),l.on("complete",t),l.off("cancel",t),l.on("cancel",t),a?.forceModalCompleted||!l.isActive()){const u=[...l.steps];for(const d of u)d.id&&l.removeStep(d.id);l.addSteps(o_e)}else l.steps.length===0&&l.addSteps(o_e);typeof l.start=="function"?(e("/"),l.start()):console.warn("Shepherd tour instance does not have a start method.",l)}}},rnr=()=>{const{isModalComplete:e,isTourComplete:t}=QT(),{startTour:n}=nnr(),r=H.useContext(BX),{data:i}=O5(1,1);return b.useEffect(()=>{if(e&&!t&&r){const s=setTimeout(()=>{const a=i?.agents?.[0]?.id;n({firstAgentId:a})},500);return()=>clearTimeout(s)}},[e,t,r,n,i]),null},inr=({children:e})=>p.jsxs(Gtr,{children:[e,p.jsx(rnr,{})]}),l_e=J2e,c_e="The backend update could not start. Retry, or update from Settings, under Application updates.",snr=()=>{const e=Wa(),t=Mi(),[n,r]=b.useState(!1),[i,s]=b.useState(null),a=b.useCallback(()=>{t.invalidateQueries({queryKey:Td.capabilities})},[t]),o=b.useCallback(async()=>{r(!0),s(null);let m=null;const v=window.api.updater.onBackendUpdateError(y=>{y.phase==="update"&&(m=AZ(y.message))});try{if(await window.api.updater.updateBackend()===!1){s(m??c_e);return}a()}catch(y){s(y instanceof Error?If(y):c_e)}finally{v(),r(!1)}},[a]);if(e.isLoading)return null;const l=e.data,c=l?l_e.filter(m=>(l.features?.[m]??0)<1):[...l_e],u=!!l&&!l?.desktop_available;if(!eCe(l))return null;const d=Z2e(e.error),h=!!l,f=!!window.api?.updater?.updateBackend,O=oot({kind:d,unpaired:u,missing:c,answered:h}),g=f&&aot({kind:d,unpaired:u,answered:h});return p.jsx("div",{className:"w-full",children:p.jsx(Ml,{variant:"warning",className:"items-center rounded-none border-x-0 border-t-0",children:p.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[p.jsxs(rT,{children:[O,i?` ${i}`:null]}),p.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[g&&p.jsx(we,{variant:"primary",size:"sm",onClick:()=>void o(),disabled:n,children:n?"Updating":"Update backend"}),p.jsx(we,{variant:"secondary",size:"sm",onClick:a,children:"Retry"})]})]})})})},anr=""+new URL("radient-icon-1024x1024-D_JJedvo.png",import.meta.url).href,fZe={all:["radient-prices"],prices:()=>[...fZe.all,"prices"]},onr=()=>{const e=ir({queryKey:fZe.prices(),queryFn:()=>MZ({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}},pZe=po()(jd(e=>({hasBeenNotified:!1,setHasBeenNotified:t=>{e({hasBeenNotified:t})}}),{name:"low-credits-storage"})),lnr=({open:e,onClose:t,onGoToConsole:n})=>{const{setHasBeenNotified:r}=pZe(),{prices:i,isLoading:s,error:a}=onr(),o=u=>typeof u!="number"?"$...":`$${u.toFixed(2)} USD`,l=()=>{r(!0),t()},c=()=>{r(!0),n()};return p.jsx(Nc,{open:e,onClose:l,title:p.jsxs(p.Fragment,{children:[p.jsx("img",{src:anr,alt:"Radient icon",className:"size-7"}),"Running low on Radient credits?"]}),maxWidth:"sm",fullWidth:!1,actions:p.jsxs(p.Fragment,{children:[p.jsx(sl,{onClick:l,children:"Maybe later"}),p.jsx(vd,{onClick:c,startIcon:p.jsx(Y3,{size:18}),className:"min-w-55",children:"Get more credits"})]}),children:p.jsxs("div",{className:"flex flex-col items-center gap-4 py-2 text-center",children:[p.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Unlock the full power of Local Operator with"," ",p.jsx("span",{className:"font-bold text-accent",children:"Radient Pass"}),"."]}),p.jsx("p",{className:"text-body-sm text-ink-muted",children:"Radient Automatic is often cheaper than bringing your own key: its smart model routing picks the most cost-effective model for each step of your agentic workflows."}),p.jsx("p",{className:"text-body-sm text-ink-muted",children:"It's pay-as-you-go with no commitments. Load up what you need, starting small for maximum flexibility."}),p.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Plus, get"," ",p.jsx("span",{className:"font-medium text-ink",children:s?p.jsx(pr,{size:"sm",className:"mr-0.5 align-middle"}):o(i?.default_registration_credits)})," ","in bonus credits with your first purchase.",a&&p.jsx("span",{className:"mt-1 block text-meta text-danger",children:"Could not load bonus credit information."})]}),p.jsx("p",{className:"text-meta text-ink-dim",children:"You can also reach the Radient Console from Settings at any time."})]})})},u_e=({expanded:e})=>p.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[p.jsx("img",{src:FZe,alt:e?"":"Local Operator",loading:"eager",className:"size-6 shrink-0"}),e&&p.jsx("span",{className:"truncate font-semibold text-body text-ink",children:"Local Operator"})]}),OZe=H.memo(({expanded:e,useAuth:t=!1})=>{const n=ka(),{user:r,isAuthenticated:i,signOut:s}=jZ(),a=r?.name??"User",o=r?.email??"",l=b.useCallback(async()=>{i&&(await s(),window.location.reload())},[i,s]),c=b.useMemo(()=>a?a.split(" ").map(h=>h.charAt(0)).join("").toUpperCase().substring(0,2):null,[a]),u=p.jsxs("button",{type:"button",onClick:t?void 0:()=>n("/settings"),"aria-label":e?void 0:"Account settings",className:A("flex w-full items-center gap-2 rounded-sm transition-colors duration-fast ease-out-quart hover:bg-elevated",e?"px-3 py-1.5":"justify-center py-1.5"),children:[p.jsx($_e,{className:"size-7 shrink-0",children:p.jsx(k_e,{className:"bg-elevated text-ink",children:c??p.jsx(E2e,{size:14,"aria-hidden":"true"})})}),e&&a&&p.jsxs("span",{className:"min-w-0 text-left",children:[p.jsx("span",{className:"block truncate text-body-sm text-ink",children:a}),o&&p.jsx("span",{className:"block truncate text-meta text-ink-dim",children:o})]})]}),d=e?u:p.jsx(rt,{content:"Account settings",side:"right",children:u});return t?p.jsxs(px,{children:[e?p.jsx(iv,{asChild:!0,children:u}):p.jsx(rt,{content:"Account settings",side:"right",children:p.jsx(iv,{asChild:!0,children:u})}),p.jsxs(Ox,{align:"end",side:"top",className:"min-w-50",children:[p.jsxs($s,{onSelect:()=>n("/settings"),children:[p.jsx(rg,{size:16,"aria-hidden":"true"}),"Settings"]}),p.jsxs($s,{children:[p.jsx(_2e,{size:16,"aria-hidden":"true"}),"Privacy and security"]}),p.jsx(Yb,{}),p.jsxs($s,{onSelect:l,className:"text-danger focus:bg-danger-wash focus:text-danger",children:[p.jsx(Fnt,{size:16,"aria-hidden":"true"}),"Sign out"]})]})]}):d});OZe.displayName="UserProfileSidebar";const d_e={expanded:"w-55",collapsed:"w-12"},cnr=()=>{const e=ka(),t=Ict(),{isSidebarCollapsed:n,toggleSidebar:r}=bn(),i=bn(f=>f.openCommandPalette),s=!n,a=[{icon:hZ,label:"Chat",path:"/chat",isActive:t==="chat",tourTag:"nav-item-chat"},{icon:Jv,label:"My agents",path:"/agents",isActive:t==="agents",tourTag:"nav-item-agents"},{icon:C2e,label:"Agent hub",path:"/agent-hub",isActive:t==="agent-hub",tourTag:"nav-item-agent-hub"},{icon:l2e,label:"Schedules",path:"/schedules",isActive:t==="schedules",tourTag:"nav-item-schedules"},{icon:_g,label:"Browser",path:"/browser",isActive:t==="browser",tourTag:"nav-item-browser"},{icon:rg,label:"Settings",path:"/settings",isActive:t==="settings",tourTag:"nav-item-settings"}],o=f=>{const O=p.jsxs("button",{type:"button",onClick:()=>e(f.path),"data-tour-tag":f.tourTag,"aria-current":f.isActive?"page":void 0,"aria-label":s?void 0:f.label,className:A("flex h-8 w-full items-center rounded-sm text-body-sm transition-colors duration-fast ease-out-quart",s?"justify-start gap-2 px-3":"justify-center",f.isActive?"bg-accent-wash font-medium text-ink":"text-ink-muted hover:bg-elevated hover:text-ink"),children:[p.jsx(f.icon,{size:16,"aria-hidden":"true",className:A("shrink-0",f.isActive&&"text-accent")}),s&&p.jsx("span",{className:"truncate",children:f.label})]});return s?p.jsx("li",{children:O},f.path):p.jsx("li",{children:p.jsx(rt,{content:f.label,side:"right",children:O})},f.path)},l=s?"Collapse sidebar":"Expand sidebar",c=navigator.platform.toUpperCase().indexOf("MAC")>=0,u=`Search (${CY(c)})`,d=s?p.jsxs("button",{type:"button","data-command-palette-trigger":"",onClick:i,className:A("flex h-8 w-full items-center gap-2 rounded-sm px-3 text-body-sm text-ink-muted","transition-colors duration-fast ease-out-quart","hover:bg-elevated hover:text-ink"),children:[p.jsx(dv,{size:16,"aria-hidden":"true",className:"shrink-0"}),p.jsx("span",{className:"truncate",children:"Search"}),p.jsx("span",{"aria-hidden":"true",className:"ml-auto",children:p.jsx(fd,{shortcut:eJn(c)})})]}):p.jsx(rt,{content:u,side:"right",children:p.jsx("button",{type:"button","data-command-palette-trigger":"",onClick:i,"aria-label":u,className:A("flex h-8 w-full items-center justify-center rounded-sm text-ink-muted","transition-colors duration-fast ease-out-quart","hover:bg-elevated hover:text-ink"),children:p.jsx(dv,{size:16,"aria-hidden":"true"})})}),h=p.jsx("div",{className:A("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"),children:p.jsx(rt,{content:l,side:"right",children:p.jsx(we,{variant:"ghost",size:"icon-sm",onClick:r,"aria-label":l,"aria-expanded":s,children:s?p.jsx(Y1,{"aria-hidden":"true"}):p.jsx(Dp,{"aria-hidden":"true"})})})});return p.jsxs("nav",{className:A("group flex shrink-0 flex-col overflow-x-hidden bg-sunken transition-[width] duration-base ease-out-quart",s?d_e.expanded:d_e.collapsed),children:[p.jsx("div",{className:A("flex h-12 shrink-0 items-center",s?"justify-between pr-2 pl-5":"justify-center"),children:s?p.jsxs(p.Fragment,{children:[p.jsx(u_e,{expanded:!0}),h]}):p.jsxs("div",{className:"relative flex size-8 items-center justify-center",children:[p.jsx("div",{className:"transition-opacity duration-fast ease-out-quart group-hover:opacity-0 group-focus-within:opacity-0",children:p.jsx(u_e,{expanded:!1})}),p.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:h})]})}),p.jsx("ul",{className:"flex flex-col gap-1 p-2",children:a.map(o)}),p.jsxs("div",{className:"mt-auto flex flex-col gap-1 p-2",children:[d,p.jsx(OZe,{expanded:s})]})]})},unr=1,dnr=()=>{const{isAuthenticated:e,user:t}=jZ(),{hasBeenNotified:n,setHasBeenNotified:r}=pZe(),[i,s]=b.useState(!1),[a,o]=b.useState(null),l=b.useCallback(async()=>{if(!(!e||!t?.radientUser?.account?.tenant_id))try{const h=await MZ({operation:"credits",tenantId:t.radientUser.account.tenant_id});if(!h||typeof h.balance!="number")throw new Error("Invalid credit balance response format");o(h.balance)}catch(h){console.error("Failed to fetch Radient credits:",h),o(null)}},[e,t?.radientUser?.account?.tenant_id]);return b.useEffect(()=>{e&&l()},[e,l]),b.useEffect(()=>{e&&a!==null?a<unr?n||s(!0):(s(!1),n&&r(!1)):s(!1)},[e,n,a,r]),{isLowCreditsDialogOpen:i,openRadientConsole:()=>{window.api?.openExternal?window.api.openExternal("https://console.radienthq.com"):window.open("https://console.radienthq.com","_blank"),r(!0),s(!1)},closeLowCreditsDialog:()=>{s(!1)},onLowCreditsDialogClose:()=>{r(!0),s(!1)},currentCredits:a}},hnr=b.lazy(()=>Le(()=>import("./agent-details-page-BkC2lX7r.js"),__vite__mapDeps([8,1,2,9]),import.meta.url).then(e=>({default:e.AgentDetailsPage}))),fnr=b.lazy(()=>Le(()=>import("./agent-hub-page-DUxDs-Kn.js"),__vite__mapDeps([10,1,2,11,12,9]),import.meta.url).then(e=>({default:e.AgentHubPage}))),h_e=b.lazy(()=>Le(()=>import("./agents-page-DAebxFRb.js"),__vite__mapDeps([13,1,2]),import.meta.url).then(e=>({default:e.AgentsPage}))),pnr=b.lazy(()=>Le(()=>import("./schedules-page-BHVkJmVD.js"),__vite__mapDeps([14,1,2,12,15]),import.meta.url).then(e=>({default:e.SchedulesPage}))),Onr=b.lazy(()=>Le(()=>import("./browser-page-D_Iq6NfX.js"),__vite__mapDeps([16,1,2]),import.meta.url).then(e=>({default:e.BrowserPage}))),gnr=b.lazy(()=>Le(()=>import("./settings-page-BujhgJa0.js"),__vite__mapDeps([17,1,2,12,18,15]),import.meta.url).then(e=>({default:e.SettingsPage}))),mnr=()=>{const{isOnboardingActive:e}=yct(),{isLowCreditsDialogOpen:t,openRadientConsole:n,onLowCreditsDialogClose:r}=dnr(),{isCommandPaletteOpen:i,isCreateAgentDialogOpen:s,closeCreateAgentDialog:a}=bn();up(i,"command-palette"),up(s,"create-agent-dialog"),up(e,"onboarding"),up(t,"low-credits");const o=ka(),l=Wa(),c=Oi(l.data,"session_catalogue",2),u=h=>{o(`/chat/${h}`),a()};tJn();const d=Sn(h=>h.setActiveSession);return b.useEffect(()=>{const h=window.api?.desktop?.onOpenConversation?.(f=>{f!==null&&performance.mark("lop:open:requested"),d(f),o("/chat")});return()=>h?.()},[o,d]),b.useEffect(()=>{const h=window.api?.browser?.onConsentAttention?.(f=>{G5t(f.entryId),o("/browser")});return()=>h?.()},[o]),b.useEffect(()=>{const h=f=>{e||c&&GHn(f)&&(f.preventDefault(),Sn.getState().stageDraft(void 0,!0),o("/chat"))};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[c,e,o]),p.jsx(inr,{children:p.jsxs("div",{className:"relative flex h-screen flex-col overflow-hidden",children:[p.jsx(sct,{}),p.jsx(snr,{}),p.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[i&&p.jsx(HKn,{}),p.jsx(hKn,{}),p.jsx(DCe,{}),p.jsx(_Jn,{open:e}),p.jsx($ut,{}),p.jsx(lnr,{open:t,onClose:r,onGoToConsole:n}),p.jsx(nut,{open:s,onClose:a,onAgentCreated:u}),p.jsx(cnr,{}),p.jsx("main",{className:"flex grow flex-col overflow-hidden",children:p.jsx(b.Suspense,{fallback:p.jsx("div",{className:"flex grow items-center justify-center",children:p.jsx(pr,{size:"lg",label:"Loading page"})}),children:p.jsxs(Tet,{children:[p.jsx(Bc,{path:"/",element:p.jsx(Jie,{to:"/chat",replace:!0})}),p.jsx(Bc,{path:"/chat",element:p.jsx(uTe,{})}),p.jsx(Bc,{path:"/chat/:agentId",element:p.jsx(uTe,{})}),p.jsx(Bc,{path:"/agents",element:p.jsx(h_e,{})}),p.jsx(Bc,{path:"/agents/:agentId",element:p.jsx(h_e,{})}),p.jsx(Bc,{path:"/settings",element:p.jsx(gnr,{})}),p.jsx(Bc,{path:"/agent-hub",element:p.jsx(fnr,{})}),p.jsx(Bc,{path:"/agent-hub/:agentId",element:p.jsx(hnr,{})}),p.jsx(Bc,{path:"/schedules",element:p.jsx(pnr,{})}),p.jsx(Bc,{path:"/browser",element:p.jsx(Onr,{})}),p.jsx(Bc,{path:"*",element:p.jsx(Jie,{to:"/chat",replace:!0})})]})})})]})]})})};function M3(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}const vnr=3,ynr=3e3;function bnr(e){return e instanceof CSSTransition&&e.playState==="running"}function wnr(e){const t=e.effect,n=t instanceof KeyframeEffect?t.target:null,r=e.transitionProperty,s=/^[a-z-]+$/.test(r)&&n instanceof Element?getComputedStyle(n).getPropertyValue(r).trim()||"(empty)":"(unreadable)";return`${r||"(unnamed property)"} on ${gre(n)??"an element no longer in the document"} = ${s}`}async function xnr(e=ynr){const t=performance.now();let n=0;for(;;){await M3();const r=Math.round(performance.now()-t),i=document.getAnimations().filter(bnr);if(n=i.length===0?n+1:0,n>=vnr)return{waitedMs:r,timedOut:!1,pending:[]};if(r>e)return{waitedMs:r,timedOut:!0,pending:i.map(wnr)}}}const Snr=/^#/;function nT(){const e=window.location.hash.replace(Snr,"");return e===""?"/":e}function gre(e){if(!e)return null;const t=e.getAttribute("aria-label")??e.textContent??"";return`${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""} "${t.trim().slice(0,60)}"`}function $nr(e){const t=e.getBoundingClientRect(),n=t.left+t.width/2,r=t.top+t.height/2,i=document.elementFromPoint(n,r),s=i!==null&&(i===e||e.contains(i)),a={bubbles:!0,cancelable:!0,composed:!0,button:0,buttons:1,clientX:n,clientY:r,view:window};return e.dispatchEvent(new PointerEvent("pointerdown",{...a,pointerId:1,isPrimary:!0})),e.dispatchEvent(new MouseEvent("mousedown",a)),e.dispatchEvent(new PointerEvent("pointerup",{...a,buttons:0,pointerId:1,isPrimary:!0})),e.dispatchEvent(new MouseEvent("mouseup",{...a,buttons:0})),e.dispatchEvent(new MouseEvent("click",{...a,buttons:0})),{hitTest:s,hit:gre(i),rect:{x:t.x,y:t.y,width:t.width,height:t.height}}}function zq(e,t){if(typeof e!="string"||e==="")throw new Error(`${t} must be a non-empty string`);return e}async function knr(e,t=1e4){const n=Date.now();for(;nT()!==e;){if(Date.now()-n>t)throw new Error(`route did not become ${e} (it is ${nT()})`);await new Promise(r=>setTimeout(r,50))}return await M3(),nT()}function Tnr(){const e=window.__loDevDriver;return e?.armed?e.install({hello:()=>({armed:!0,outDir:e.outDir,title:document.title,route:nT(),href:window.location.href,theme:bn.getState().themeName,viewport:{width:window.innerWidth,height:window.innerHeight,devicePixelRatio:window.devicePixelRatio},visibilityState:document.visibilityState,hasFocus:document.hasFocus(),apiBaseUrl:oi.baseUrl,userAgent:navigator.userAgent}),state:()=>{const t=bn.getState(),n=Sn.getState();return{route:nT(),theme:t.themeName,commandPaletteOpen:t.isCommandPaletteOpen,canvasOpen:t.isCanvasOpen,runPanelOpen:t.isRunPanelOpen,browserPaneOpen:t.isBrowserPaneOpen,browserPanelWidth:t.browserPanelWidth,activeSessionId:n.activeSessionId,sessionCount:n.sessions.length,onboardingVisible:!!document.querySelector("[data-onboarding-modal]")}},navigate:async t=>{const n=zq(t,"navigate path");if(!n.startsWith("/"))throw new Error(`navigate path must start with "/" (got "${n}")`);return window.location.hash=`#${n}`,{route:await knr(n)}},setTheme:async t=>{const n=zq(t,"theme name");bn.getState().setTheme(n),await M3();const r=document.documentElement.getAttribute("data-theme"),i=await xnr();return{theme:bn.getState().themeName,dataTheme:r,settledAfterMs:i.waitedMs,settleTimedOut:i.timedOut,settlePending:i.pending}},press:async t=>{const n=typeof t=="string"?{selector:t}:t,r=zq(n?.selector,"press selector"),i=typeof n?.timeoutMs=="number"?n.timeoutMs:1e4,s=Date.now();let a=null;for(;a===null&&(a=document.querySelector(r),a===null);){if(Date.now()-s>i)throw new Error(`nothing matches ${r} after ${i}ms of waiting`);await new Promise(l=>setTimeout(l,100))}const o=$nr(a);return await M3(),{selector:r,target:gre(a),...o}}}):[]}const _nr={queries:{staleTime:5*60*1e3,gcTime:10*60*1e3,retry:1,refetchOnWindowFocus:!0,refetchOnMount:!0,refetchOnReconnect:!1,networkMode:"always"},mutations:{retry:1,networkMode:"always"}},gZe=new nHe({defaultOptions:_nr}),Pnr=`
1457
1457
  *::-webkit-scrollbar {
1458
1458
  width: 8px;
1459
1459
  height: 8px;