@cmmd-center/forge 0.9.15 → 0.9.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.cjs +311 -53
- package/dist/bin.mjs +335 -76
- package/dist/client/assets/{CanvasPanel-Dc8j2ouo.js → CanvasPanel-D9sKevpO.js} +2 -2
- package/dist/client/assets/{CompositeItem-Cn5DdObI.js → CompositeItem-Bsi2e5qV.js} +2 -2
- package/dist/client/assets/{DiffPanel-CRdkVPEz.js → DiffPanel-ClMWe6-c.js} +2 -2
- package/dist/client/assets/{DiffPanel.logic-BIPcNz_o.js → DiffPanel.logic-o7tDdTzf.js} +2 -2
- package/dist/client/assets/{DiffPanelShell-tIdXu7mn.js → DiffPanelShell-R1Q66jTc.js} +2 -2
- package/dist/client/assets/{DiffWorkerPoolProvider-tFSGuVfC.js → DiffWorkerPoolProvider-lEFZi8QR.js} +2 -2
- package/dist/client/assets/{PullRequestCodePanel-inwJYfZC.js → PullRequestCodePanel-BpbniIb5.js} +2 -2
- package/dist/client/assets/{Virtualizer-DeKxnAeU.js → Virtualizer-B5NXbN5f.js} +2 -2
- package/dist/client/assets/{canvasStateStore-Dlm4tanv.js → canvasStateStore-qioLqOoT.js} +2 -2
- package/dist/client/assets/{cmmdAuthRedirect-C1FjO86g.js → cmmdAuthRedirect-lmPzseq5.js} +2 -2
- package/dist/client/assets/{index-Bublmabf.js → index-D0769c3n.js} +57 -57
- package/dist/client/assets/{src-DljvAdHI.js → src-BL6J64vk.js} +3 -3
- package/dist/client/assets/{toggle-It2CvaLA.js → toggle-CW3yNjj1.js} +2 -2
- package/dist/client/assets/{useTriggerFocusGuards-DfUh9uvu.js → useTriggerFocusGuards-mvO6ygs-.js} +2 -2
- package/dist/client/index.html +10 -10
- package/dist/{open-D8mGyWmt.mjs → open-FIgTDosf.mjs} +3 -3
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-y4e5bF-h.js","assets/rolldown-runtime-BaTzPAyU.js","assets/workspaceReadinessAtom-DsJoTBtH.js","assets/atomRegistry-Bz2MHqst.js","assets/Stream-D8tJNlvy.js","assets/angular-html-CNXPMsN2.js","assets/html-B9culvuL.js","assets/javascript-B0UuInDI.js","assets/css-5Tn8jvjX.js","assets/angular-ts-8naLoWoA.js","assets/scss-4x_6pmF2.js","assets/apl-9RqlfC4L.js","assets/xml-CW-6mCqa.js","assets/java-DD8v6SCw.js","assets/json-Bub81p9x.js","assets/astro-DEOUVaUL.js","assets/typescript-BjG390PS.js","assets/postcss-DmNgU5nO.js","assets/tsx-Dfm676IJ.js","assets/blade-qhaBLKQC.js","assets/html-derivative-PDPS4pLY.js","assets/sql-D4jklS0K.js","assets/bsl-COh4injU.js","assets/sdbl-DSLJ-P-D.js","assets/c-Dy_bYPSr.js","assets/cairo-D9XerGFI.js","assets/python-Cb0jrteY.js","assets/cobol-P2hn7TXm.js","assets/coffee-TsaJbZkc.js","assets/cpp-lB26TbTP.js","assets/regexp-BieKZPiU.js","assets/glsl-XlVJTcyG.js","assets/crystal-BMAMEN5_.js","assets/shellscript-BCP1gymp.js","assets/edge-BsY6Dvy0.js","assets/elixir-BZz-hqbR.js","assets/elm-BRjWHXlm.js","assets/erb-DyHbZJUF.js","assets/ruby-CSzE8NZD.js","assets/haml-B-iWdzkM.js","assets/graphql-B7KqOeHs.js","assets/jsx-CVsoW34k.js","assets/lua-BAG7dOge.js","assets/yaml-_V1dSWlR.js","assets/erlang-BAaIl4Bp.js","assets/markdown-DG21OhJI.js","assets/fortran-fixed-form-DWZWCeWi.js","assets/fortran-free-form-DJxAWUrC.js","assets/fsharp-wFdh0YAg.js","assets/gdresource-C5OXSCS9.js","assets/gdshader-CaVCQW9t.js","assets/gdscript-Cu0HLvj-.js","assets/git-commit-BJn43XzB.js","assets/diff-sVB8Iqu1.js","assets/git-rebase-D753LgR4.js","assets/glimmer-js-CWIQt_ca.js","assets/glimmer-ts-Ntr1SeR3.js","assets/hack-CTggiz-m.js","assets/handlebars-D1AkJdZI.js","assets/http-DiXWLGkE.js","assets/hurl-BZDc3Jtw.js","assets/csv-Bf0U-6f3.js","assets/hxml-DWvzLpTo.js","assets/haxe-DaP2bSo8.js","assets/jinja-C3Dq7ihL.js","assets/jison-DSf4rHmh.js","assets/julia-CZXumuBX.js","assets/r-BY2iEdK7.js","assets/just-D0yza6K2.js","assets/perl-CI7jecTq.js","assets/latex-B_y1lnEN.js","assets/tex-atcWI7rk.js","assets/liquid-DP7VlZYW.js","assets/marko-Cp7qGCQm.js","assets/less-CSmnzIFU.js","assets/mdc-B8NVymwE.js","assets/nextflow-DcTewtep.js","assets/nextflow-groovy-_1_mDVJM.js","assets/nginx-DJl5z2aR.js","assets/nim-Dg-nY8m2.js","assets/php-ChFP9CBe.js","assets/pug-B0fl0unF.js","assets/qml-7gZ29K0p.js","assets/razor-CZy2ujiF.js","assets/csharp-fzmjUXps.js","assets/rst-CfjqtaYt.js","assets/cmake-zaNLyYCh.js","assets/sas-BRUw9CAa.js","assets/shaderlab-BbCj-Nnu.js","assets/hlsl-DWiTaAA1.js","assets/shellsession-D5Ijwb2H.js","assets/soy-DQ7pPiO3.js","assets/sparql-FctWdqhV.js","assets/turtle-Cy-vlDVE.js","assets/stata-WbvGE-VS.js","assets/surrealql-D-lvEuCC.js","assets/svelte-bkJnqoJz.js","assets/templ-BrwbaRfa.js","assets/go-wxR-9SwJ.js","assets/ts-tags-CbY-UhSH.js","assets/twig-83VHDTty.js","assets/vue-DQ8jEd0y.js","assets/vue-html-aJaNf4Hi.js","assets/vue-vine-DtwgVsbD.js","assets/stylus-BJGv9v6m.js","assets/xsl-D3pa6zbH.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`forge-web@0.9.10`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`d798db5f-add5-4d07-a7bc-3016e5adaf01`,e._sentryDebugIdIdentifier=`sentry-dbid-d798db5f-add5-4d07-a7bc-3016e5adaf01`)}catch{}})();import{n as e,r as t,t as n}from"./rolldown-runtime-BaTzPAyU.js";import{$ as r,$i as i,$t as a,Ai as o,An as s,Ar as c,At as l,B as u,Ba as d,Bn as f,Br as p,Bt as m,C as h,Ci as g,Cn as _,Da as v,Dn as y,Dt as b,Ei as x,En as S,Er as C,Et as w,F as T,Fn as E,Fr as D,Ft as O,Gn as ee,Gt as te,Hn as k,Hr as A,Ht as ne,Ir as j,It as re,J as ie,Ji as ae,Jn as oe,Jt as se,K as ce,Ki as le,Kn as ue,Kt as de,L as fe,Ln as pe,Lr as me,Lt as he,M as ge,Ma as _e,Mi as ve,Mr as ye,Mt as be,N as xe,Na as Se,Nn as eee,Nt as Ce,O as we,Oa as tee,On as nee,Ot as ree,P as iee,Pa as Te,Pn as Ee,Pt as De,Qn as Oe,Qt as aee,R as ke,Ra as Ae,Rn as je,Rr as Me,Rt as oee,Sa as Ne,Sn as see,T as Pe,Ta as cee,Tn as lee,Tr as Fe,Tt as Ie,U as Le,Un as Re,Ur as ze,Ut as uee,V as dee,Va as fee,Vn as Be,Vr as Ve,Vt as He,W as Ue,Wn as pee,Wr as mee,Wt as hee,X as gee,Xn as _ee,Y as vee,Yi as We,Yn as Ge,Yt as yee,Z as Ke,Zi as qe,Zn as Je,Zt as bee,_ as xee,_i as See,_n as Cee,_r as wee,_t as Tee,aa as Ye,ai as Eee,an as Dee,at as Xe,bi as Oee,bn as kee,br as Aee,bt as Ze,ci as jee,cn as Mee,ct as Qe,di as Nee,dn as Pee,dr as Fee,dt as $e,ei as Iee,en as et,er as Lee,et as tt,fr as Ree,ft as nt,gn as rt,gt as it,hn as at,hr as ot,ht as st,in as ct,it as zee,j as lt,ja as Bee,ji as ut,jn as dt,jr as Vee,jt as ft,ka as Hee,ki as Uee,kr as Wee,kt as pt,li as Gee,ln as Kee,m as qee,ma as mt,mi as ht,mn as gt,mr as _t,mt as vt,ni as Jee,nr as yt,nt as bt,oi as xt,on as Yee,or as St,pn as Ct,pt as wt,q as Tt,qn as Et,qt as Xee,r as Zee,ra as Qee,rn as Dt,rr as $ee,rt as ete,s as tte,si as Ot,sn as nte,st as kt,ti as rte,ui as At,un as jt,ut as Mt,vn as Nt,vr as ite,vt as ate,w as Pt,wi as ote,wn as ste,wr as cte,wt as Ft,x as lte,xi as ute,xn as It,y as dte,yi as fte,yn as Lt,yt as pte,z as Rt,za as mte,zn as zt,zt as Bt}from"./Stream-D8tJNlvy.js";import{i as hte,l as Vt,n as Ht,o as Ut,s as Wt}from"./atomRegistry-Bz2MHqst.js";import{An as Gt,Fn as gte,Mn as Kt,Nn as _te,Pn as vte,Sn as yte,Z as bte,_ as xte,_n as qt,b as Jt,g as Yt,gn as Xt,i as Ste,pn as Zt,v as Cte,xn as Qt,y as wte}from"./CompositeItem-Cn5DdObI.js";import{$t as Tte,An as $t,At as Ete,B as Dte,Bn as Ote,Bt as en,Cn as tn,Ct as nn,D as kte,Dn as rn,Dt as an,E as on,En as Ate,Et as sn,F as jte,Ft as cn,Gt as Mte,H as ln,Ht as un,In as Nte,It as Pte,J as dn,Jt as Fte,Kt as fn,L as Ite,Ln as Lte,Lt as pn,Mn as mn,Mt as hn,Nn as gn,Nt as Rte,O as zte,On as Bte,Ot as _n,Pn as Vte,Pt as Hte,Q as Ute,Qt as Wte,Rn as Gte,Rt as vn,S as Kte,Sn as yn,T as bn,Tn as qte,Ut as xn,V as Sn,Vn as Jte,Vt as Cn,Wn as Yte,Wt as Xte,X as wn,Xt as Zte,Y as Tn,Yt as Qte,Zt as En,_n as Dn,a as M,an as On,bn as kn,bt as $te,c as An,cn as jn,ct as ene,d as tne,dn as Mn,en as nne,et as Nn,f as rne,fn as Pn,ft as Fn,g as In,gn as Ln,hn as ine,ht as ane,i as one,in as Rn,it as sne,jn as zn,jt as cne,k as Bn,kt as lne,l as une,ln as dne,m as fne,mn as Vn,mt as pne,n as mne,nn as Hn,nt as Un,o as Wn,pn as Gn,pt as Kn,qn,qt as hne,rn as Jn,s as Yn,st as Xn,t as Zn,tn as Qn,tt as $n,u as er,un as tr,ut as nr,v as rr,vt as gne,wn as ir,x as _ne,xn as ar,xt as or,y as vne,zn as yne,zt as sr}from"./src-DljvAdHI.js";import{A as cr,D as lr,E as ur,F as bne,I as dr,M as xne,O as fr,P as Sne,S as Cne,_ as wne,a as pr,b as Tne,c as Ene,j as mr,k as hr,l as Dne,n as gr,s as One,u as kne,v as Ane,w as _r,x as jne,y as Mne}from"./cmmdAuthRedirect-C1FjO86g.js";import{t as N}from"./preload-helper-DDBXDd-E.js";import{n as P,t as vr}from"./transport-1MbRJyXh.js";import{n as Nne,t as Pne}from"./workspaceReadinessAtom-DsJoTBtH.js";function Fne(e){return e[e.length-1]}function Ine(e,t){return typeof e==`function`?e(t):e}var yr=Object.prototype.hasOwnProperty,Lne=Object.prototype.propertyIsEnumerable;function Rne(e){for(let t in e)if(yr.call(e,t))return!0;return!1}var zne=()=>Object.create(null),Bne=(e,t)=>br(e,t,zne);function br(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=wr(e)&&wr(i);if(!a&&!(Sr(e)&&Sr(i)))return i;let o=a?e:xr(e);if(!o)return i;let s=a?i:xr(i);if(!s)return i;let c=o.length,l=s.length,u=a?Array(l):n(),d=0;for(let t=0;t<l;t++){let o=a?t:s[t],l=e[o],f=i[o];if(l===f){u[o]=l,(a?t<c:yr.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=br(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function xr(e){let t=Object.keys(e);if(t.length!==Object.getOwnPropertyNames(e).length)return!1;let n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;for(let r of n){if(!Lne.call(e,r))return!1;t.push(r)}return t}function Sr(e){if(!Cr(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Cr(n)||!n.hasOwnProperty(`isPrototypeOf`))}function Cr(e){return Object.prototype.toString.call(e)===`[object Object]`}function wr(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Tr(e,t,n){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!Tr(e[r],t[r],n))return!1;return!0}if(Sr(e)&&Sr(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!Tr(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!Tr(e[o],t[o],n)))return!1;return i===a}return!1}var Vne=/[\x00-\x1f\x7f"<>`{}]/g;function Hne(e){return e.replace(Vne,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function Er(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return Hne(t)}var Une=[`http:`,`https:`,`mailto:`,`tel:`];function Wne(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}function Gne(e){if(!e||!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith(`//`))return{path:e,handledProtocolRelativeURL:!1};let t=/%25|%5C/gi,n=0,r=``,i;for(;(i=t.exec(e))!==null;)r+=Er(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=Er(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function Kne(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function qne(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Dr(){throw Error(`Invariant failed`)}var F=t(fee(),1),Or=F.createContext(null);function kr(e){return F.useContext(Or)}var Ar=F.createContext(void 0),Jne=F.createContext(void 0),Yne=gte();function Xne(e,t){return e===t}function jr(e,t,n=Xne){let r=(0,F.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,F.useCallback)(()=>e?.get(),[e]);return(0,Yne.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var Mr={};function Nr(e,t){let n=F.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=br(n.current,i):i}}function Pr(e){let t=kr(),n=F.useContext(e.from?Jne:Ar),r=e.from??n,i=t.stores.getMatchStore(r),a=Nr(e,t),o=jr(i,e=>e?a(e):Mr);if(o!==Mr)return o;(e.shouldThrow??!0)&&Dr()}function Zne(e){return Pr({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}var Fr=d(),Ir=typeof window<`u`&&(window.desktopBridge!==void 0||window.nativeApi!==void 0),Lr=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(){}},Rr=new class extends Lr{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},Qne={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},zr=new class{#e=Qne;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function $ne(e){setTimeout(e,0)}var ere=typeof window>`u`||`Deno`in globalThis;function Br(){}function tre(e,t){return typeof e==`function`?e(t):e}function Vr(e){return typeof e==`number`&&e>=0&&e!==1/0}function Hr(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Ur(e,t){return typeof e==`function`?e(t):e}function Wr(e,t){return typeof e==`function`?e(t):e}function nre(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Gr(o,t.options))return!1}else if(!qr(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function rre(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Kr(t.options.mutationKey)!==Kr(a))return!1}else if(!qr(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Gr(e,t){return(t?.queryKeyHashFn||Kr)(e)}function Kr(e){return JSON.stringify(e,(e,t)=>Zr(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function qr(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!qr(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!qr(e[r],t[r]))return!1;return!0}return!1}var ire=Object.prototype.hasOwnProperty;function Jr(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Xr(e)&&Xr(t);if(!r&&!(Zr(e)&&Zr(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:ire.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Jr(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Yr(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Xr(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Zr(e){if(!Qr(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Qr(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Qr(e){return Object.prototype.toString.call(e)===`[object Object]`}function are(e){return new Promise(t=>{zr.setTimeout(t,e)})}function $r(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Jr(e,t)}function ore(e){return e}function sre(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function cre(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var ei=Symbol();function ti(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ei?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ni(e,t){return typeof e==`function`?e(...t):!!e}function lre(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var ri=(()=>{let e=()=>ere;return{isServer(){return e()},setIsServer(t){e=t}}})();function ii(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var ure=$ne;function dre(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=ure,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var ai=dre(),oi=new class extends Lr{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let 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.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function fre(e){return Math.min(1e3*2**e,3e4)}function si(e){return(e??`online`)!==`online`||oi.isOnline()}var ci=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function li(e){let t=!1,n=0,r,i=ii(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new ci(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>Rr.isFocused()&&(e.networkMode===`always`||oi.isOnline())&&e.canRun(),u=()=>si(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(ri.isServer()?0:3),o=e.retryDelay??fre,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),are(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var ui=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Vr(this.gcTime)&&(this.#e=zr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ri.isServer()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(zr.clearTimeout(this.#e),this.#e=void 0)}};function pre(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{lre(e,()=>t.signal,()=>n=!0)},u=ti(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?cre:sre;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?fi:di,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:di(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function di(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function fi(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function mre(e,t){return t?di(e,t)!=null:!1}function hre(e,t){return!t||!e.getPreviousPageParam?!1:fi(e,t)!=null}var gre=class extends ui{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=hi(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=hi(this.options);e.data!==void 0&&(this.setState(mi(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=$r(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(Br).catch(Br):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Wr(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ei||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Ur(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Hr(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.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.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=ti(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?pre(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=li({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof ci&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof ci){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...pi(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...mi(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),ai.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function pi(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:si(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function mi(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function hi(e){let 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 gi=class extends Lr{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=ii(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),_i(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return vi(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return vi(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof Wr(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Yr(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&yi(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||Wr(this.options.enabled,this.#t)!==Wr(t.enabled,this.#t)||Ur(this.options.staleTime,this.#t)!==Ur(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Wr(this.options.enabled,this.#t)!==Wr(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return vre(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Br)),t}#g(){this.#b();let e=Ur(this.options.staleTime,this.#t);if(ri.isServer()||this.#r.isStale||!Vr(e))return;let t=Hr(this.#r.dataUpdatedAt,e)+1;this.#d=zr.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(ri.isServer()||Wr(this.options.enabled,this.#t)===!1||!Vr(this.#p)||this.#p===0)&&(this.#f=zr.setInterval(()=>{(this.options.refetchIntervalInBackground||Rr.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(zr.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(zr.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&_i(e,t),o=i&&yi(e,n,t,r);(a||o)&&(l={...l,...pi(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=$r(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=$r(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:bi(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Wr(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{let e=this.#o=x.promise=ii();i(e)},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a()}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!Yr(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){ai.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function _re(e,t){return Wr(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||Wr(t.retryOnMount,e)!==!1)}function _i(e,t){return _re(e,t)||e.state.data!==void 0&&vi(e,t,t.refetchOnMount)}function vi(e,t,n){if(Wr(t.enabled,e)!==!1&&Ur(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&bi(e,t)}return!1}function yi(e,t,n,r){return(e!==t||Wr(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&bi(e,n)}function bi(e,t){return Wr(t.enabled,e)!==!1&&e.isStaleByTime(Ur(t.staleTime,e))}function vre(e,t){return!Yr(e.getCurrentResult(),t)}var xi=F.createContext(void 0),Si=e=>{let t=F.useContext(xi);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},yre=({client:e,children:t})=>(F.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,Fr.jsx)(xi.Provider,{value:e,children:t})),Ci=F.createContext(!1),wi=()=>F.useContext(Ci);Ci.Provider;function bre(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var xre=F.createContext(bre()),Ti=()=>F.useContext(xre),Ei=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?ni(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Di=e=>{F.useEffect(()=>{e.clearReset()},[e])},Oi=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||ni(n,[e.error,r])),ki=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Sre=(e,t)=>e.isLoading&&e.isFetching&&!t,Ai=(e,t)=>e?.suspense&&t.isPending,ji=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Mi(e,t,n){let r=wi(),i=Ti(),a=Si(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,ki(o),Ei(o,i,s),Di(i);let l=!a.getQueryCache().get(o.queryHash),[u]=F.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(F.useSyncExternalStore(F.useCallback(e=>{let t=f?u.subscribe(ai.batchCalls(e)):Br;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),F.useEffect(()=>{u.setOptions(o)},[o,u]),Ai(o,d))throw ji(o,u,i);if(Oi({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!ri.isServer()&&Sre(d,r)&&(l?ji(o,u,i):s?.promise)?.catch(Br).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function Ni(e,t){return Mi(e,gi,t)}function Cre(e){return e}var wre={[Symbol.iterator](){return Tre}},Tre={next(){return{done:!0,value:void 0}}},Ere=()=>wre,Dre=C,Pi=globalThis.Number,Ore=e=>{if(e===`NaN`)return ve(NaN);if(e===`Infinity`)return ve(1/0);if(e===`-Infinity`)return ve(-1/0);if(e.trim()===``)return ut();let t=Pi(e);return Pi.isNaN(t)?ut():ve(t)},kre=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`]],Fi=`~effect/http/HttpClientRequest`,Are={[Fi]:Fi,...We,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Qee(this.headers),body:this.body.toJSON()}},pipe(){return Ae(this,arguments)}};function Ii(e,t,n,r,i,a){let o=Object.create(Are);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var jre=Ii(`GET`,``,hne,ut(),pn,Mte),Li=e=>(t,n)=>Nre(jre,{method:e,url:t,...n??void 0}),Mre=Li(`POST`),Nre=_e(2,(e,t)=>{let n=e;return t.method&&(n=Pre(n,t.method)),t.url&&(n=Lre(n,t.url)),t.headers&&(n=Ri(n,t.headers)),t.urlParams&&(n=Rre(n,t.urlParams)),t.hash&&(n=zre(n,t.hash)),t.body&&(n=Bi(n,t.body)),t.accept&&(n=zi(n,t.accept)),t.acceptJson&&(n=Ire(n)),n}),Pre=_e(2,(e,t)=>Ii(t,e.url,e.urlParams,e.hash,e.headers,e.body)),Fre=_e(3,(e,t,n)=>Ii(e.method,e.url,e.urlParams,e.hash,xn(e.headers,t,n),e.body)),Ri=_e(2,(e,t)=>Ii(e.method,e.url,e.urlParams,e.hash,Xte(e.headers,t),e.body)),zi=_e(2,(e,t)=>Fre(e,`Accept`,t)),Ire=zi(`application/json`),Lre=_e(2,(e,t)=>{if(typeof t==`string`)return Ii(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=Fte(n.searchParams),i=fte(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,Ii(e.method,n.toString(),r,i,e.headers,e.body)}),Rre=_e(2,(e,t)=>Ii(e.method,e.url,Zte(e.urlParams,t),e.hash,e.headers,e.body)),zre=_e(2,(e,t)=>Ii(e.method,e.url,e.urlParams,ve(t),e.headers,e.body)),Bi=_e(2,(e,t)=>{let n=e.headers;return t._tag===`Empty`||t._tag===`FormData`?n=un(un(n,`Content-Type`),`Content-length`):(t.contentType&&(n=xn(n,`content-type`,t.contentType)),t.contentLength!==void 0&&(n=xn(n,`content-length`,t.contentLength.toString()))),Ii(e.method,e.url,e.urlParams,e.hash,n,t)}),Bre=e=>sr({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${o(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),Vi=`~effect/http/HttpClient`,Hi=Ot(`effect/HttpClient`),Ui=_e(2,(e,t)=>Wi(n=>t(e.postprocess(n)),e.preprocess)),Vre=Ui(bt(Rte)),Wi=(e,t)=>{let n=Object.create(Hre);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},Hre={[Vi]:Vi,pipe(){return Ae(this,arguments)},...We,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(kre.map(([e,t])=>[t,function(t,n){return this.execute(Li(e)(t,n))}]))},Ure=e=>Wi(t=>bt(t,t=>Nt(n=>{let i=qre.get(t),a=i??new AbortController,o=Qte(t.url,t.urlParams,g(t.hash));if(rte(o))return r(new En({reason:new Tte({request:t,cause:o.failure})}));let s=o.success;if(n.getRef(Wee)||n.getRef(Gi)(t)){let r=e(t,s,a.signal,n);return i?r:Ct(e=>Ie(e(r),{onSuccess(e){return qi.register(e,a),et(new Ji(e,a))},onFailure(e){return _t(e)&&a.abort(),tt(e)}}))}return at(n.getRef(Gre)(t),{kind:`client`},r=>{r.attribute(`http.request.method`,t.method),r.attribute(`server.address`,s.origin),s.port!==``&&r.attribute(`server.port`,+s.port),r.attribute(`url.full`,s.toString()),r.attribute(`url.path`,s.pathname),r.attribute(`url.scheme`,s.protocol.slice(0,-1));let o=s.search.slice(1);o!==``&&r.attribute(`url.query`,o);let c=n.getRef(Pte),l=Cn(t.headers,c);for(let e in l)r.attribute(`http.request.header.${e}`,String(l[e]));return t=n.getRef(Ki)?Ri(t,Bre(r)):t,Ct(o=>o(e(t,s,a.signal,n)).pipe(Lt(r,{captureStackTrace:!1}),Ie({onSuccess:e=>{r.attribute(`http.response.status_code`,e.status);let t=Cn(e.headers,c);for(let e in t)r.attribute(`http.response.header.${e}`,String(t[e]));return i?et(e):(qi.register(e,a),et(new Ji(e,a)))},onFailure(e){return!i&&_t(e)&&a.abort(),tt(e)}})))})})),et),Wre=_e(2,(e,t)=>{let n=lee(t),r=n?`errors-and-responses`:t.retryOn??`errors-and-responses`,i=n?t:t.schedule,a=i&&S(i),o=n?void 0:t.times;return Ui(e,Se(r===`errors-only`?Te:re({schedule:a,times:o,while:Xi}),r===`response-only`?Te:he({while:n||t.while===void 0?Yi:v(Yi,t.while),schedule:i,times:o})))}),Gi=xt(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>tee}),Ki=xt(`effect/HttpClient/TracerPropagationEnabled`,{defaultValue:Hee}),Gre=xt(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),Kre=e=>dt(Hi)(ie(t=>Ze(e,e=>Ui(e,gt(e=>ht(t,e)))))),qi=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{e.abort()});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),qre=new WeakMap,Ji=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[hn]=hn;[cn]=cn;applyInterrupt(e){return Dt(()=>(qi.unregister(this.original),pt(e,()=>ct(()=>{this.controller.abort()}))))}get request(){return this.original.request}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return xee(()=>(qi.unregister(this.original),Zee(this.original.stream,ct(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[qe](){return this.original[qe]()}pipe(){return Ae(this,arguments)}},Yi=e=>Aee(e)||Jre(e),Jre=e=>Qn(e)&&(e.reason._tag===`TransportError`||e.reason._tag===`StatusCodeError`&&Xi(e.reason.response)),Xi=e=>e.status===408||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504,Zi=`~effect/FiberSet`,Yre=e=>mt(e,Zi),Xre={[Zi]:Zi,[Symbol.iterator](){return this.state._tag===`Closed`?Ere():this.state.backing[Symbol.iterator]()},...le,toJSON(){return{_id:`FiberMap`,state:this.state}}},Zre=(e,t)=>{let n=Object.create(Xre);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},Qre=()=>ke(ct(()=>Zre(new Set,Ge())),e=>Dt(()=>{let t=e.state;if(t._tag===`Closed`)return rt;e.state={_tag:`Closed`};let n=t.backing;return T(n).pipe(oe(e.deferred))})),Qi=-1,$re=me(D(Fee,j(Qi))),eie=_e(e=>Yre(e[0]),(e,t,n)=>{if(e.state._tag===`Closed`){t.interruptUnsafe(Qi);return}e.state.backing.has(t)||(e.state.backing.add(t),t.addObserver(r=>{e.state._tag!==`Closed`&&(e.state.backing.delete(t),yt(r)&&(n?.propagateInterruption===!0?!$re(r.cause):!ot(r.cause))&&Et(e.deferred,r))}))}),tie=function(){let e;return()=>(e===void 0&&(e=m(vt)),e)}(),nie=e=>()=>Ze(Tt(),t=>{let n=He(t);return(t,r)=>{if(e.state._tag===`Closed`)return tie();let i=n(t,r);return eie(e,i),i}}),$i=e=>ue(e.deferred),ea=`~effect/socket/Socket`,ta=Ot(`effect/socket/Socket`),rie=`~effect/socket/Socket/CloseEvent`,iie=e=>mt(e,rie),na=`~effect/socket/Socket/SocketError`,aie=e=>mt(e,na),ra=class extends On(`effect/socket/Socket/SocketReadError`)({_tag:mn(`SocketReadError`),cause:Rn}){message=`An error occurred during Read`},oie=class extends On(`effect/socket/Socket/SocketWriteError`)({_tag:mn(`SocketWriteError`),cause:Rn}){message=`An error occurred during Write`},ia=class extends On(`effect/socket/Socket/SocketOpenError`)({_tag:mn(`SocketOpenError`),kind:jn([`Unknown`,`Timeout`]),cause:Rn}){get message(){return this.kind===`Timeout`?`timeout waiting for "open"`:`An error occurred during Open`}},aa=class extends On(`effect/socket/Socket/SocketCloseError`)({_tag:mn(`SocketCloseError`),code:Mn,closeReason:$t(Gn)}){static filterClean(e){return function(t){return sa.is(t)&&t.reason._tag===`SocketCloseError`&&e(t.reason.code)?Eee(t.reason):Iee(t)}}get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},oa=Dn([ra,oie,ia,aa]),sa=class extends ine(na)(`SocketError`,{_tag:mn(`SocketError`),reason:oa}){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[na]=na;static is(e){return aie(e)}message=this.reason.message},sie=e=>!0,cie=class extends Ot()(`~effect/socket/Socket/WebSocket`){},ca=class extends Ot()(`@effect/platform/Socket/WebSocketConstructor`){},lie=(e,t)=>ca.use(n=>uie(ke((typeof e==`string`?et(e):e).pipe(Ze(e=>n(e,t?.protocols))),e=>ct(()=>e.close(1e3))),t)),uie=(e,t)=>Nt(n=>{let i,a=lt(!1),o=n.context,s=t?.closeCodeIsError??sie,c=(n,c)=>bee(Xe(function*(o){let l=yield*Qre().pipe(ee(o)),u=yield*ee(e,o),d=yield*De(nie(l)(),cie,u),f=!1;function p(e){if(e.data instanceof Blob){let t=bt(ft(()=>e.data.arrayBuffer()),e=>{let t=n(new Uint8Array(e));return it(t)?t:rt});return d(t)}let t=n(e.data);it(t)&&d(t)}function m(e){u.removeEventListener(`message`,p),u.removeEventListener(`close`,h),Et(l.deferred,r(new sa({reason:f?new ra({cause:e}):new ia({kind:`Unknown`,cause:e})})))}function h(e){let t=typeof e.code==`number`?e.code:1001;u.removeEventListener(`message`,p),u.removeEventListener(`error`,m),Et(l.deferred,r(new sa({reason:new aa({code:t,closeReason:e.reason})})))}if(u.addEventListener(`close`,h,{once:!0}),u.addEventListener(`error`,m,{once:!0}),u.addEventListener(`message`,p),u.readyState!==1){let e=Ge();u.addEventListener(`open`,()=>{f=!0,Et(e,rt)},{once:!0}),yield*ue(e).pipe(jt({duration:t?.openTimeout??1e4,orElse:()=>r(new sa({reason:new ia({kind:`Timeout`,cause:Error(`timeout waiting for "open"`)})}))}),O($i(l)))}return f=!0,i=u,a.openUnsafe(),c?.onOpen&&(yield*c.onOpen),yield*ce($i(l),aa.filterClean(e=>!s(e)),()=>rt)})).pipe(gt(e=>ht(o,e)),Ke(ct(()=>{a.closeUnsafe(),i=void 0}))),l=new TextEncoder,u=(e,t)=>c(t=>typeof t==`string`?e(l.encode(t)):t instanceof Uint8Array?e(t):e(new Uint8Array(t)),t),d=et(e=>a.whenOpen(ct(()=>{let t=i;iie(e)?t.close(e.code,e.reason):t.send(e)})));return et(ta.of({[ea]:ea,run:u,runRaw:c,writer:d}))}),la=Se(lie,dt(ta)),ua=class extends Ot()(`effect/workers/Transferable/Collector`){},die=()=>{let e=[],t=t=>{e.push(...t)},n=()=>e,r=()=>{let t=e;return e=[],t};return ua.of({addAllUnsafe:t,addAll:e=>ct(()=>t(e)),readUnsafe:n,read:ct(n),clearUnsafe:r,clear:ct(r)})},fie=`~effect/workers/WorkerError`,pie=class extends On(`effect/workers/WorkerError/WorkerSpawnError`)({_tag:mn(`WorkerSpawnError`),message:Gn,cause:$t(Rn)}){},mie=class extends On(`effect/workers/WorkerError/WorkerSendError`)({_tag:mn(`WorkerSendError`),message:Gn,cause:$t(Rn)}){},hie=class extends On(`effect/workers/WorkerError/WorkerReceiveError`)({_tag:mn(`WorkerReceiveError`),message:Gn,cause:$t(Rn)}){},gie=class extends On(`effect/workers/WorkerError/WorkerUnknownError`)({_tag:mn(`WorkerUnknownError`),message:Gn,cause:$t(Rn)}){},da=Dn([pie,mie,hie,gie]);On(fie)({_tag:mn(`WorkerError`),reason:da});var fa=`~effect/rpc/RpcClientError`,pa=class extends On(`effect/rpc/RpcClientError/RpcClientDefect`)({_tag:mn(`RpcClientDefect`),message:Gn,cause:Rn}){},ma=class extends On(fa)({_tag:mn(`RpcClientError`),reason:Dn([da,oa,Wte,pa])}){[fa]=fa;get message(){return`${this.reason._tag}: ${this.reason.message}`}},ha=e=>typeof e==`bigint`?e:BigInt(e),_ie={_tag:`Ping`},ga;try{ga=new TextDecoder}catch{}var I,_a,L=0,va=[],ya=va,ba=0,xa={},Sa,Ca,wa=0,Ta=0,Ea,Da,Oa=[],ka,Aa={useRecords:!1,mapsAsObjects:!0},ja=class{},Ma=new ja;Ma.name=`MessagePack 0xC1`;var Na=!1,Pa=2,Fa,Ia,La;try{Function(``)}catch{Pa=1/0}var Ra=class e{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=0&&(e.structures=[],e.maxSharedStructures||=0)),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType=`number`)),Object.assign(this,e)}unpack(t,n){if(I)return so(()=>(co(),this?this.unpack(t,n):e.prototype.unpack.call(Aa,t,n)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<`u`?Buffer.from(t):new Uint8Array(t)),typeof n==`object`?(_a=n.end||t.length,L=n.start||0):(L=0,_a=n>-1?n:t.length),ba=0,Ta=0,Ca=null,ya=va,Ea=null,I=t;try{ka=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(e){throw I=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(xa=this,this.structures)return Sa=this.structures,za(n);(!Sa||Sa.length>0)&&(Sa=[])}else xa=Aa,(!Sa||Sa.length>0)&&(Sa=[]);return za(n)}unpackMultiple(e,t){let n,r=0;try{Na=!0;let i=e.length,a=this?this.unpack(e,i):uo.unpack(e,i);if(t){if(t(a,r,L)===!1)return;for(;L<i;)if(r=L,t(za(),r,L)===!1)return}else{for(n=[a];L<i;)r=L,n.push(za());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{Na=!1,co()}}_mergeStructures(e,t){Ia&&(e=Ia.call(this,e)),e||=[],Object.isFrozen(e)&&(e=e.map(e=>e.slice(0)));for(let t=0,n=e.length;t<n;t++){let n=e[t];n&&(n.isShared=!0,t>=32&&(n.highByte=t-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let r=e[n],i=t[n];i&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[n]=r),e[n]=i)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function za(e){try{if(!xa.trusted&&!Na){let e=Sa.sharedLength||0;e<Sa.length&&(Sa.length=e)}let t;if(xa.randomAccessStructure&&I[L]<64&&I[L]>=32&&Fa?(t=Fa(I,L,_a,xa),I=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),L=_a):t=Va(),Ea&&=(L=Ea.postBundlePosition,null),Na&&(Sa.restoreStructures=null),L==_a)Sa&&Sa.restoreStructures&&Ba(),Sa=null,I=null,Da&&=null;else if(L>_a)throw Error(`Unexpected end of MessagePack data`);else if(!Na){let e;try{e=JSON.stringify(t,(e,t)=>typeof t==`bigint`?`${t}n`:t).slice(0,100)}catch(t){e=`(JSON view not available `+t+`)`}throw Error(`Data read, but end of buffer not reached `+e)}return t}catch(e){throw Sa&&Sa.restoreStructures&&Ba(),co(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`)||L>_a)&&(e.incomplete=!0),e}}function Ba(){for(let e in Sa.restoreStructures)Sa[e]=Sa.restoreStructures[e];Sa.restoreStructures=null}function Va(){let e=I[L++];if(e<160)if(e<128){if(e<64)return e;{let t=Sa[e&63]||xa.getStructures&&Wa()[e&63];return t?(t.read||=Ha(t,e&63),t.read()):e}}else if(e<144){if(e-=128,xa.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=no();e===`__proto__`&&(e=`__proto_`),t[e]=Va()}return t}{let t=new Map;for(let n=0;n<e;n++)t.set(Va(),Va());return t}}else{e-=144;let t=Array(e);for(let n=0;n<e;n++)t[n]=Va();return xa.freezeData?Object.freeze(t):t}if(e<192){let t=e-160;if(Ta>=L)return Ca.slice(L-wa,(L+=t)-wa);if(Ta==0&&_a<140){let e=t<16?Za(t):Xa(t);if(e!=null)return e}return Ga(t)}{let t;switch(e){case 192:return null;case 193:return Ea?(t=Va(),t>0?Ea[1].slice(Ea.position1,Ea.position1+=t):Ea[0].slice(Ea.position0,Ea.position0-=t)):Ma;case 194:return!1;case 195:return!0;case 196:if(t=I[L++],t===void 0)throw Error(`Unexpected end of buffer`);return $a(t);case 197:return t=ka.getUint16(L),L+=2,$a(t);case 198:return t=ka.getUint32(L),L+=4,$a(t);case 199:return eo(I[L++]);case 200:return t=ka.getUint16(L),L+=2,eo(t);case 201:return t=ka.getUint32(L),L+=4,eo(t);case 202:if(t=ka.getFloat32(L),xa.useFloat32>2){let e=lo[(I[L]&127)<<1|I[L+1]>>7];return L+=4,(e*t+(t>0?.5:-.5)>>0)/e}return L+=4,t;case 203:return t=ka.getFloat64(L),L+=8,t;case 204:return I[L++];case 205:return t=ka.getUint16(L),L+=2,t;case 206:return t=ka.getUint32(L),L+=4,t;case 207:return xa.int64AsType===`number`?(t=ka.getUint32(L)*4294967296,t+=ka.getUint32(L+4)):xa.int64AsType===`string`?t=ka.getBigUint64(L).toString():xa.int64AsType===`auto`?(t=ka.getBigUint64(L),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=ka.getBigUint64(L),L+=8,t;case 208:return ka.getInt8(L++);case 209:return t=ka.getInt16(L),L+=2,t;case 210:return t=ka.getInt32(L),L+=4,t;case 211:return xa.int64AsType===`number`?(t=ka.getInt32(L)*4294967296,t+=ka.getUint32(L+4)):xa.int64AsType===`string`?t=ka.getBigInt64(L).toString():xa.int64AsType===`auto`?(t=ka.getBigInt64(L),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=ka.getBigInt64(L),L+=8,t;case 212:if(t=I[L++],t==114)return io(I[L++]&63);{let e=Oa[t];if(e)return e.read?(L++,e.read(Va())):e.noBuffer?(L++,e()):e(I.subarray(L,++L));throw Error(`Unknown extension `+t)}case 213:return t=I[L],t==114?(L++,io(I[L++]&63,I[L++])):eo(2);case 214:return eo(4);case 215:return eo(8);case 216:return eo(16);case 217:return t=I[L++],Ta>=L?Ca.slice(L-wa,(L+=t)-wa):yie(t);case 218:return t=ka.getUint16(L),L+=2,Ta>=L?Ca.slice(L-wa,(L+=t)-wa):bie(t);case 219:return t=ka.getUint32(L),L+=4,Ta>=L?Ca.slice(L-wa,(L+=t)-wa):xie(t);case 220:return t=ka.getUint16(L),L+=2,qa(t);case 221:return t=ka.getUint32(L),L+=4,qa(t);case 222:return t=ka.getUint16(L),L+=2,Ja(t);case 223:return t=ka.getUint32(L),L+=4,Ja(t);default:if(e>=224)return e-256;if(e===void 0){let e=Error(`Unexpected end of MessagePack data`);throw e.incomplete=!0,e}throw Error(`Unknown MessagePack token `+e)}}}var vie=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Ha(e,t){function n(){if(n.count++>Pa){let n=e.read=Function(`r`,`return function(){return `+(xa.freezeData?`Object.freeze`:``)+`({`+e.map(e=>e===`__proto__`?`__proto_:r()`:vie.test(e)?e+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`})}`)(Va);return e.highByte===0&&(e.read=Ua(t,e.read)),n()}let r={};for(let t=0,n=e.length;t<n;t++){let n=e[t];n===`__proto__`&&(n=`__proto_`),r[n]=Va()}return xa.freezeData?Object.freeze(r):r}return n.count=0,e.highByte===0?Ua(t,n):n}var Ua=(e,t)=>function(){let n=I[L++];if(n===0)return t();let r=e<32?-(e+(n<<5)):e+(n<<5),i=Sa[r]||Wa()[r];if(!i)throw Error(`Record id is not defined for `+r);return i.read||=Ha(i,e),i.read()};function Wa(){let e=so(()=>(I=null,xa.getStructures()));return Sa=xa._mergeStructures(e,Sa)}var Ga=Ka,yie=Ka,bie=Ka,xie=Ka;function Ka(e){let t;if(e<16&&(t=Za(e)))return t;if(e>64&&ga)return ga.decode(I.subarray(L,L+=e));let n=L+e,r=[];for(t=``;L<n;){let e=I[L++];if(!(e&128))r.push(e);else if((e&224)==192){let t=I[L++]&63,n=(e&31)<<6|t;n<128?r.push(65533):r.push(n)}else if((e&240)==224){let t=I[L++]&63,n=I[L++]&63,i=(e&31)<<12|t<<6|n;i<2048||i>=55296&&i<=57343?r.push(65533):r.push(i)}else if((e&248)==240){let t=I[L++]&63,n=I[L++]&63,i=I[L++]&63,a=(e&7)<<18|t<<12|n<<6|i;a<65536||a>1114111?r.push(65533):a>65535?(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023,r.push(a)):r.push(a)}else r.push(65533);r.length>=4096&&(t+=Ya.apply(String,r),r.length=0)}return r.length>0&&(t+=Ya.apply(String,r)),t}function qa(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=Va();return xa.freezeData?Object.freeze(t):t}function Ja(e){if(xa.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=no();e===`__proto__`&&(e=`__proto_`),t[e]=Va()}return t}{let t=new Map;for(let n=0;n<e;n++)t.set(Va(),Va());return t}}var Ya=String.fromCharCode;function Xa(e){let t=L,n=Array(e);for(let r=0;r<e;r++){let e=I[L++];if((e&128)>0){L=t;return}n[r]=e}return Ya.apply(String,n)}function Za(e){if(e<4)if(e<2){if(e===0)return``;{let e=I[L++];if((e&128)>1){--L;return}return Ya(e)}}else{let t=I[L++],n=I[L++];if((t&128)>0||(n&128)>0){L-=2;return}if(e<3)return Ya(t,n);let r=I[L++];if((r&128)>0){L-=3;return}return Ya(t,n,r)}{let t=I[L++],n=I[L++],r=I[L++],i=I[L++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){L-=4;return}if(e<6){if(e===4)return Ya(t,n,r,i);{let e=I[L++];if((e&128)>0){L-=5;return}return Ya(t,n,r,i,e)}}if(e<8){let a=I[L++],o=I[L++];if((a&128)>0||(o&128)>0){L-=6;return}if(e<7)return Ya(t,n,r,i,a,o);let s=I[L++];if((s&128)>0){L-=7;return}return Ya(t,n,r,i,a,o,s)}{let a=I[L++],o=I[L++],s=I[L++],c=I[L++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){L-=8;return}if(e<10){if(e===8)return Ya(t,n,r,i,a,o,s,c);{let e=I[L++];if((e&128)>0){L-=9;return}return Ya(t,n,r,i,a,o,s,c,e)}}if(e<12){let l=I[L++],u=I[L++];if((l&128)>0||(u&128)>0){L-=10;return}if(e<11)return Ya(t,n,r,i,a,o,s,c,l,u);let d=I[L++];if((d&128)>0){L-=11;return}return Ya(t,n,r,i,a,o,s,c,l,u,d)}{let l=I[L++],u=I[L++],d=I[L++],f=I[L++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){L-=12;return}if(e<14){if(e===12)return Ya(t,n,r,i,a,o,s,c,l,u,d,f);{let e=I[L++];if((e&128)>0){L-=13;return}return Ya(t,n,r,i,a,o,s,c,l,u,d,f,e)}}{let p=I[L++],m=I[L++];if((p&128)>0||(m&128)>0){L-=14;return}if(e<15)return Ya(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let h=I[L++];if((h&128)>0){L-=15;return}return Ya(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}}}}}function Qa(){let e=I[L++],t;if(e<192)t=e-160;else switch(e){case 217:t=I[L++];break;case 218:t=ka.getUint16(L),L+=2;break;case 219:t=ka.getUint32(L),L+=4;break;default:throw Error(`Expected string`)}return Ka(t)}function $a(e){return xa.copyBuffers?Uint8Array.prototype.slice.call(I,L,L+=e):I.subarray(L,L+=e)}function eo(e){let t=I[L++];if(Oa[t]){let n;return Oa[t](I.subarray(L,n=L+=e),e=>{L=e;try{return Va()}finally{L=n}})}throw Error(`Unknown extension type `+t)}var to=Array(4096);function no(){let e=I[L++];if(e>=160&&e<192){if(e-=160,Ta>=L)return Ca.slice(L-wa,(L+=e)-wa);if(!(Ta==0&&_a<180))return Ga(e)}else return L--,ro(Va());let t=(e<<5^(e>1?ka.getUint16(L):e>0?I[L]:0))&4095,n=to[t],r=L,i=L+e-3,a,o=0;if(n&&n.bytes==e){for(;r<i;){if(a=ka.getUint32(r),a!=n[o++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(a=I[r++],a!=n[o++]){r=1879048192;break}if(r===i)return L=r,n.string;i-=3,r=L}for(n=[],to[t]=n,n.bytes=e;r<i;)a=ka.getUint32(r),n.push(a),r+=4;for(i+=3;r<i;)a=I[r++],n.push(a);let s=e<16?Za(e):Xa(e);return s==null?n.string=Ga(e):n.string=s}function ro(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;if(xa.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(e=>[`string`,`number`,`boolean`,`bigint`].includes(typeof e)))return e.flat().toString();throw Error(`Invalid property type for record: ${typeof e}`)}var io=(e,t)=>{let n=Va().map(ro),r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,n.highByte=t);let i=Sa[e];return i&&(i.isShared||Na)&&((Sa.restoreStructures||(Sa.restoreStructures=[]))[e]=i),Sa[e]=n,n.read=Ha(n,r),n.read()};Oa[0]=()=>{},Oa[0].noBuffer=!0,Oa[66]=e=>{let t=e.byteLength%8||8,n=BigInt(e[0]&128?e[0]-256:e[0]);for(let r=1;r<t;r++)n<<=BigInt(8),n+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=(e,t)=>{let n=t-e;if(n<=40){let n=r.getBigUint64(e);for(let i=e+8;i<t;i+=8)n<<=64n,n|=r.getBigUint64(i);return n}let a=e+(n>>4<<3),o=i(e,a),s=i(a,t);return o<<BigInt((t-a)*8)|s};n=n<<BigInt((r.byteLength-t)*8)|i(t,r.byteLength)}return n};var ao={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError==`function`?AggregateError:null};Oa[101]=()=>{let e=Va();if(!ao[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return ao[e[0]](e[1],{cause:e[2]})},Oa[105]=e=>{if(xa.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=ka.getUint32(L-4);Da||=new Map;let n=I[L],r;r=n>=144&&n<160||n==220||n==221?[]:n>=128&&n<144||n==222||n==223?new Map:(n>=199&&n<=201||n>=212&&n<=216)&&I[L+1]===115?new Set:{};let i={target:r};Da.set(t,i);let a=Va();if(i.used)Object.assign(r,a);else return i.target=a;if(r instanceof Map)for(let[e,t]of a.entries())r.set(e,t);if(r instanceof Set)for(let e of Array.from(a))r.add(e);return r},Oa[112]=e=>{if(xa.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=ka.getUint32(L-4),n=Da.get(t);return n.used=!0,n.target},Oa[115]=()=>new Set(Va());var oo=[`Int8`,`Uint8`,`Uint8Clamped`,`Int16`,`Uint16`,`Int32`,`Uint32`,`Float32`,`Float64`,`BigInt64`,`BigUint64`].map(e=>e+`Array`),Sie=typeof globalThis==`object`?globalThis:window;Oa[116]=e=>{let t=e[0],n=Uint8Array.prototype.slice.call(e,1).buffer,r=oo[t];if(!r){if(t===16)return n;if(t===17)return new DataView(n);throw Error(`Could not find typed array for code `+t)}return new Sie[r](n)},Oa[120]=()=>{let e=Va();return new RegExp(e[0],e[1])};var Cie=[];Oa[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],n=L;return L+=t-e.length,Ea=Cie,Ea=[Qa(),Qa()],Ea.position0=0,Ea.position1=0,Ea.postBundlePosition=L,L=n,Va()},Oa[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date(`invalid`);function so(e){La&&La();let t=_a,n=L,r=ba,i=wa,a=Ta,o=Ca,s=ya,c=Da,l=Ea,u=new Uint8Array(I.slice(0,_a)),d=Sa,f=Sa.slice(0,Sa.length),p=xa,m=Na,h=e();return _a=t,L=n,ba=r,wa=i,Ta=a,Ca=o,ya=s,Da=c,Ea=l,I=u,Na=m,Sa=d,Sa.splice(0,Sa.length,...f),xa=p,ka=new DataView(I.buffer,I.byteOffset,I.byteLength),h}function co(){I=null,Da=null,Sa=null}var lo=Array(147);for(let e=0;e<256;e++)lo[e]=+(`1e`+Math.floor(45.15-e*.30103));var uo=new Ra({useRecords:!1});uo.unpack,uo.unpackMultiple,uo.unpack;var wie={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};new Uint8Array(new Float32Array(1).buffer,0,4);var fo;try{fo=new TextEncoder}catch{}var po,mo,ho=typeof Buffer<`u`,go=ho?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array,_o=ho?Buffer:Uint8Array,vo=ho?4294967296:2144337920,R,yo,bo,z=0,xo,So=null,Tie,Eie=21760,Die=/[\u0080-\uFFFF]/,Co=Symbol(`record-id`),Oie=class extends Ra{constructor(e){super(e),this.offset=0;let t,n,r,i,a=_o.prototype.utf8Write?function(e,t){return R.utf8Write(e,t,R.byteLength-t)}:fo&&fo.encodeInto?function(e,t){return fo.encodeInto(e,R.subarray(t)).written}:!1,o=this;e||={};let s=e&&e.sequential,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?32:0,l>8160)throw Error(`Maximum maxSharedStructure is 8160`);e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let u=e.maxOwnStructures;u??=c?32:64,!this.structures&&e.useRecords!=0&&(this.structures=[]);let d=l>32||u+l>64,f=l+64,p=l+u+64;if(p>8256)throw Error(`Maximum maxSharedStructure + maxOwnStructure is 8192`);let m=[],h=0,g=0;this.pack=this.encode=function(e,a){if(R||(R=new go(8192),bo=R.dataView||(R.dataView=new DataView(R.buffer,0,8192)),z=0),xo=R.length-10,xo-z<2048?(R=new go(R.length),bo=R.dataView||(R.dataView=new DataView(R.buffer,0,R.length)),xo=R.length-10,z=0):z=z+7&2147483640,t=z,a&2048&&(z+=a&255),i=o.structuredClone?new Map:null,o.bundleStrings&&typeof e!=`string`?(So=[],So.size=1/0):So=null,r=o.structures,r){r.uninitialized&&(r=o._mergeStructures(o.getStructures()));let e=r.sharedLength||0;if(e>l)throw Error(`Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to `+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let t=0;t<e;t++){let e=r[t];if(!e)continue;let n,i=r.transitions;for(let t=0,r=e.length;t<r;t++){let r=e[t];n=i[r],n||=i[r]=Object.create(null),i=n}i[Co]=t+64}this.lastNamedStructuresLength=e}s||(r.nextId=e+64)}n&&=!1;let c;try{o.randomAccessStructure&&e&&typeof e==`object`?e.constructor===Object?D(e):e.constructor!==Map&&!Array.isArray(e)&&!mo.some(t=>e instanceof t)?D(e.toJSON?e.toJSON():e):y(e):y(e);let n=So;if(So&&Do(t,y,0),i&&i.idsToInsert){let e=i.idsToInsert.sort((e,t)=>e.offset>t.offset?1:-1),r=e.length,a=-1;for(;n&&r>0;){let i=e[--r].offset+t;i<n.stringsPosition+t&&a===-1&&(a=0),i>n.position+t?a>=0&&(a+=6):(a>=0&&(bo.setUint32(n.position+t,bo.getUint32(n.position+t)+a),a=-1),n=n.previous,r++)}a>=0&&n&&bo.setUint32(n.position+t,bo.getUint32(n.position+t)+a),z+=e.length*6,z>xo&&w(z),o.offset=z;let s=kie(R.subarray(t,z),e);return i=null,s}return o.offset=z,a&512?(R.start=t,R.end=z,R):R.subarray(t,z)}catch(e){throw c=e,e}finally{if(r&&(_(),n&&o.saveStructures)){let n=r.sharedLength||0,i=R.subarray(t,z),s=Aie(r,o);if(!c)return o.saveStructures(s,s.isCompatible)===!1?o.pack(e,a):(o.lastNamedStructuresLength=n,R.length>1073741824&&(R=null),i)}R.length>1073741824&&(R=null),a&1024&&(z=t)}};let _=()=>{g<10&&g++;let e=r.sharedLength||0;if(r.length>e&&!s&&(r.length=e),h>1e4)r.transitions=null,g=0,h=0,m.length>0&&(m=[]);else if(m.length>0&&!s){for(let e=0,t=m.length;e<t;e++)m[e][Co]=0;m=[]}},v=e=>{var t=e.length;t<16?R[z++]=144|t:t<65536?(R[z++]=220,R[z++]=t>>8,R[z++]=t&255):(R[z++]=221,bo.setUint32(z,t),z+=4);for(let n=0;n<t;n++)y(e[n])},y=e=>{z>xo&&(R=w(z));var n=typeof e,r;if(n===`string`){let n=e.length;if(So&&n>=4&&n<4096){if((So.size+=n)>Eie){let e,n=(So[0]?So[0].length*3+So[1].length:0)+10;z+n>xo&&(R=w(z+n));let r;So.position?(r=So,R[z]=200,z+=3,R[z++]=98,e=z-t,z+=4,Do(t,y,0),bo.setUint16(e+t-3,z-t-e)):(R[z++]=214,R[z++]=98,e=z-t,z+=4),So=[``,``],So.previous=r,So.size=0,So.position=e}let r=Die.test(e);So[+!r]+=e,R[z++]=193,y(r?-n:n);return}let i;i=n<32?1:n<256?2:n<65536?3:5;let o=n*3;if(z+o>xo&&(R=w(z+o)),n<64||!a){let t,a,o,s=z+i;for(t=0;t<n;t++)a=e.charCodeAt(t),a<128?R[s++]=a:a<2048?(R[s++]=a>>6|192,R[s++]=a&63|128):(a&64512)==55296&&((o=e.charCodeAt(t+1))&64512)==56320?(a=65536+((a&1023)<<10)+(o&1023),t++,R[s++]=a>>18|240,R[s++]=a>>12&63|128,R[s++]=a>>6&63|128,R[s++]=a&63|128):(R[s++]=a>>12|224,R[s++]=a>>6&63|128,R[s++]=a&63|128);r=s-z-i}else r=a(e,z+i);r<32?R[z++]=160|r:r<256?(i<2&&R.copyWithin(z+2,z+1,z+1+r),R[z++]=217,R[z++]=r):r<65536?(i<3&&R.copyWithin(z+3,z+2,z+2+r),R[z++]=218,R[z++]=r>>8,R[z++]=r&255):(i<5&&R.copyWithin(z+5,z+3,z+3+r),R[z++]=219,bo.setUint32(z,r),z+=4),z+=r}else if(n===`number`)if(e>>>0===e)e<32||e<128&&this.useRecords===!1||e<64&&!this.randomAccessStructure?R[z++]=e:e<256?(R[z++]=204,R[z++]=e):e<65536?(R[z++]=205,R[z++]=e>>8,R[z++]=e&255):(R[z++]=206,bo.setUint32(z,e),z+=4);else if(e>>0===e)e>=-32?R[z++]=256+e:e>=-128?(R[z++]=208,R[z++]=e+256):e>=-32768?(R[z++]=209,bo.setInt16(z,e),z+=2):(R[z++]=210,bo.setInt32(z,e),z+=4);else{let t;if((t=this.useFloat32)>0&&e<4294967296&&e>=-2147483648){R[z++]=202,bo.setFloat32(z,e);let n;if(t<4||(n=e*lo[(R[z]&127)<<1|R[z+1]>>7])>>0===n){z+=4;return}z--}R[z++]=203,bo.setFloat64(z,e),z+=8}else if(n===`object`||n===`function`)if(!e)R[z++]=192;else{if(i){let n=i.get(e);if(n){n.id||=(i.idsToInsert||(i.idsToInsert=[])).push(n),R[z++]=214,R[z++]=112,bo.setUint32(z,n.id),z+=4;return}i.set(e,{offset:z-t})}let a=e.constructor;if(a===Object)C(e);else if(a===Array)v(e);else if(a===Map)if(this.mapAsEmptyObject)R[z++]=128;else{r=e.size,r<16?R[z++]=128|r:r<65536?(R[z++]=222,R[z++]=r>>8,R[z++]=r&255):(R[z++]=223,bo.setUint32(z,r),z+=4);for(let[t,n]of e)y(t),y(n)}else{for(let t=0,n=po.length;t<n;t++){let n=mo[t];if(e instanceof n){let n=po[t];if(n.write){n.type&&(R[z++]=212,R[z++]=n.type,R[z++]=0);let t=n.write.call(this,e);t===e?Array.isArray(e)?v(e):C(e):y(t);return}let r=R,i=bo,a=z;R=null;let o;try{o=n.pack.call(this,e,e=>(R=r,r=null,z+=e,z>xo&&w(z),{target:R,targetView:bo,position:z-e}),y)}finally{r&&(R=r,bo=i,z=a,xo=R.length-10)}o&&(o.length+z>xo&&w(o.length+z),z=Eo(o,R,z,n.type));return}}if(Array.isArray(e))v(e);else{if(e.toJSON){let t=e.toJSON();if(t!==e)return y(t)}if(n===`function`)return y(this.writeFunction&&this.writeFunction(e));C(e)}}}else if(n===`boolean`)R[z++]=e?195:194;else if(n===`bigint`){if(e<0x8000000000000000&&e>=-0x8000000000000000)R[z++]=211,bo.setBigInt64(z,e);else if(e<0x10000000000000000&&e>0)R[z++]=207,bo.setBigUint64(z,e);else if(this.largeBigIntToFloat)R[z++]=203,bo.setFloat64(z,Number(e));else if(this.largeBigIntToString)return y(e.toString());else if(this.useBigIntExtension||this.moreTypes){let t=BigInt(e<0?-1:0),n;if(e>>BigInt(65536)===t){let r=BigInt(0x10000000000000000)-BigInt(1),i=[];for(;i.push(e&r),e>>BigInt(63)!==t;)e>>=BigInt(64);n=new Uint8Array(new BigUint64Array(i).buffer),n.reverse()}else{let t=e<0,r=(t?~e:e).toString(16);if(r.length%2?r=`0`+r:parseInt(r.charAt(0),16)>=8&&(r=`00`+r),ho)n=Buffer.from(r,`hex`);else{n=new Uint8Array(r.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(r.slice(e*2,e*2+2),16)}if(t)for(let e=0;e<n.length;e++)n[e]=~n[e]}n.length+z>xo&&w(n.length+z),z=Eo(n,R,z,66);return}else throw RangeError(e+` was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string`);z+=8}else if(n===`undefined`)this.encodeUndefinedAsNil?R[z++]=192:(R[z++]=212,R[z++]=0,R[z++]=0);else throw Error(`Unknown type: `+n)},b=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?e=>{let t;if(this.skipValues){t=[];for(let n in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(n))&&!this.skipValues.includes(e[n])&&t.push(n)}else t=Object.keys(e);let n=t.length;n<16?R[z++]=128|n:n<65536?(R[z++]=222,R[z++]=n>>8,R[z++]=n&255):(R[z++]=223,bo.setUint32(z,n),z+=4);let r;if(this.coercibleKeyAsNumber)for(let i=0;i<n;i++){r=t[i];let n=Number(r);y(isNaN(n)?r:n),y(e[r])}else for(let i=0;i<n;i++)y(r=t[i]),y(e[r])}:e=>{R[z++]=222;let n=z-t;z+=2;let r=0;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(y(t),y(e[t]),r++);if(r>65535)throw Error(`Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object`);R[n+++t]=r>>8,R[n+t]=r&255},x=this.useRecords===!1?b:e.progressiveRecords&&!d?e=>{let n,i=r.transitions||(r.transitions=Object.create(null)),a=z++-t,o;for(let s in e)if(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(s)){if(n=i[s],n)i=n;else{let c=Object.keys(e),l=i;i=r.transitions;let u=0;for(let e=0,t=c.length;e<t;e++){let t=c[e];n=i[t],n||(n=i[t]=Object.create(null),u++),i=n}a+t+1==z?(z--,T(i,c,u)):E(i,c,a,u),o=!0,i=l[s]}y(e[s])}if(!o){let n=i[Co];n?R[a+t]=n:E(i,Object.keys(e),a,0)}}:e=>{let t,n=r.transitions||(r.transitions=Object.create(null)),i=0;for(let r in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(r))&&(t=n[r],t||(t=n[r]=Object.create(null),i++),n=t);let a=n[Co];a?a>=96&&d?(R[z++]=((a-=96)&31)+96,R[z++]=a>>5):R[z++]=a:T(n,n.__keys__||Object.keys(e),i);for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&y(e[t])},S=typeof this.useRecords==`function`&&this.useRecords,C=S?e=>{S(e)?x(e):b(e)}:x,w=e=>{let n;if(e>16777216){if(e-t>vo)throw Error(`Packed buffer would be larger than maximum buffer size`);n=Math.min(vo,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,R.length-1)>>12)+1<<12;let r=new go(n);return bo=r.dataView||=new DataView(r.buffer,0,n),e=Math.min(e,R.length),R.copy?R.copy(r,0,t,e):r.set(R.slice(t,e)),z-=t,t=0,xo=r.length-10,R=r},T=(e,t,i)=>{let a=r.nextId;a||=64,a<f&&this.shouldShareStructure&&!this.shouldShareStructure(t)?(a=r.nextOwnId,a<p||(a=f),r.nextOwnId=a+1):(a>=p&&(a=f),r.nextId=a+1);let o=t.highByte=a>=96&&d?a-96>>5:-1;e[Co]=a,e.__keys__=t,r[a-64]=t,a<f?(t.isShared=!0,r.sharedLength=a-63,n=!0,o>=0?(R[z++]=(a&31)+96,R[z++]=o):R[z++]=a):(o>=0?(R[z++]=213,R[z++]=114,R[z++]=(a&31)+96,R[z++]=o):(R[z++]=212,R[z++]=114,R[z++]=a),i&&(h+=g*i),m.length>=u&&(m.shift()[Co]=0),m.push(e),y(t))},E=(e,n,r,i)=>{let a=R,o=z,s=xo,c=t;R=yo,z=0,t=0,R||(yo=R=new go(8192)),xo=R.length-10,T(e,n,i),yo=R;let l=z;if(R=a,z=o,xo=s,t=c,l>1){let e=z+l-1;e>xo&&w(e);let n=r+t;R.copyWithin(n+l,n+1,z),R.set(yo.slice(0,l),n),z=e}else R[r+t]=yo[0]},D=e=>{let i=Tie(e,R,t,z,r,w,(e,t,r)=>{if(r)return n=!0;z=t;let i=R;return y(e),_(),i===R?z:{position:z,targetView:bo,target:R}},this);if(i===0)return C(e);z=i}}useBuffer(e){R=e,R.dataView||(R.dataView=new DataView(R.buffer,R.byteOffset,R.byteLength)),bo=R.dataView,z=0}set position(e){z=e}get position(){return z}clearSharedData(){this.structures&&=[],this.typedStructs&&=[]}};mo=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,ja],po=[{pack(e,t,n){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:e,targetView:n,position:i}=t(6);e[i++]=214,e[i++]=255,n.setUint32(i,r)}else if(r>0&&r<4294967296){let{target:n,targetView:i,position:a}=t(10);n[a++]=215,n[a++]=255,i.setUint32(a,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),i.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),n(this.onInvalidDate());let{target:e,targetView:r,position:i}=t(3);e[i++]=212,e[i++]=255,e[i++]=255}else{let{target:n,targetView:i,position:a}=t(15);n[a++]=199,n[a++]=12,n[a++]=255,i.setUint32(a,e.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(e,t,n){if(this.setAsEmptyObject)return t(0),n({});let r=Array.from(e),{target:i,position:a}=t(this.moreTypes?3:0);this.moreTypes&&(i[a++]=212,i[a++]=115,i[a++]=0),n(r)}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=101,r[i++]=0),n([e.name,e.message,e.cause])}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=120,r[i++]=0),n([e.source,e.flags])}},{pack(e,t){this.moreTypes?wo(e,16,t):To(ho?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let n=e.constructor;n!==_o&&this.moreTypes?wo(e,oo.indexOf(n.name),t):To(e,t)}},{pack(e,t){this.moreTypes?wo(e,17,t):To(ho?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let{target:n,position:r}=t(1);n[r]=193}}];function wo(e,t,n,r){let i=e.byteLength;if(i+1<256){var{target:a,position:o}=n(4+i);a[o++]=199,a[o++]=i+1}else if(i+1<65536){var{target:a,position:o}=n(5+i);a[o++]=200,a[o++]=i+1>>8,a[o++]=i+1&255}else{var{target:a,position:o,targetView:s}=n(7+i);a[o++]=201,s.setUint32(o,i+1),o+=4}a[o++]=116,a[o++]=t,e.buffer||(e=new Uint8Array(e)),a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),o)}function To(e,t){let n=e.byteLength;var r,i;if(n<256){var{target:r,position:i}=t(n+2);r[i++]=196,r[i++]=n}else if(n<65536){var{target:r,position:i}=t(n+3);r[i++]=197,r[i++]=n>>8,r[i++]=n&255}else{var{target:r,position:i,targetView:a}=t(n+5);r[i++]=198,a.setUint32(i,n),i+=4}r.set(e,i)}function Eo(e,t,n,r){let i=e.length;switch(i){case 1:t[n++]=212;break;case 2:t[n++]=213;break;case 4:t[n++]=214;break;case 8:t[n++]=215;break;case 16:t[n++]=216;break;default:i<256?(t[n++]=199,t[n++]=i):i<65536?(t[n++]=200,t[n++]=i>>8,t[n++]=i&255):(t[n++]=201,t[n++]=i>>24,t[n++]=i>>16&255,t[n++]=i>>8&255,t[n++]=i&255)}return t[n++]=r,t.set(e,n),n+=i,n}function kie(e,t){let n,r=t.length*6,i=e.length-r;for(;n=t.pop();){let t=n.offset,a=n.id;e.copyWithin(t+r,t,i),r-=6;let o=t+r;e[o++]=214,e[o++]=105,e[o++]=a>>24,e[o++]=a>>16&255,e[o++]=a>>8&255,e[o++]=a&255,i=t}return e}function Do(e,t,n){if(So.length>0){bo.setUint32(So.position+e,z+n-So.position-e),So.stringsPosition=z-e;let r=So;So=null,t(r[0]),t(r[1])}}function Aie(e,t){return e.isCompatible=e=>{let n=!e||(t.lastNamedStructuresLength||0)===e.length;return n||t._mergeStructures(e),n},e}var Oo=new Oie({useRecords:!1});Oo.pack,Oo.pack;var{NEVER:jie,ALWAYS:Mie,DECIMAL_ROUND:Nie,DECIMAL_FIT:Pie}=wie,ko=class extends Ot()(`effect/rpc/RpcSerialization`){},Fie=ko.of({contentType:`application/json`,includesFraming:!1,makeUnsafe:()=>{let e=new TextDecoder;return{decode:t=>{let n=JSON.parse(typeof t==`string`?t:e.decode(t));return Array.isArray(n)?n:[n]},encode:e=>JSON.stringify(e)}}}),Ao=pe(ko)(Fie),Iie=e=>Dt(()=>{let t=new Set,n=new Map,r=new Map,i=(e,t)=>ie(r=>{let i=n.get(e);return i||(i=[],n.set(e,i)),i.push([t,r]),rt});return Ze(e((e,t)=>{let n=r.get(e);return n?n(t):i(e,t)},t),e=>({...e,run(e,i){return nt(function*(){t.add(e),r.set(e,i);let a=n.get(e);if(a){n.delete(e);for(let[e,t]of a)yield*Ce(Dt(()=>i(e)),t)}return yield*ree(w,()=>(t.delete(e),r.delete(e),rt))})}}))}),Lie=BigInt(0),Rie=Xe(function*(e,t){let n=t?.spanPrefix??`RpcClient`,r=t?.supportsAck??!0,i=t?.disableTracing??!1,a=t?.generateRequestId??(()=>Lie++),o=yield*Tt(),s=At(o,je),c=new Map,l=!1;yield*zt(s,Nt(e=>(l=!0,u(Lee(e.id)))));let u=Xe(function*(e){for(let[t,n]of c)c.delete(t),n._tag===`Queue`?yield*e._tag===`Success`?Pt(n.queue):Pe(n.queue,e.cause):n.resume(e)}),d=e=>{let r=cne(e.successSchema),a=g(e);return(o,s)=>{let c=s?.headers?vn(s.headers):pn,l=s?.context??Gee();if(!r){let r=t=>p(e,a,t,e.payloadSchema.make(o),c,l,s?.discard??!1);return i?r(void 0):at(`${n}.${e._tag}`,{attributes:t.spanAttributes},r)}let u=m(e,a,e.payloadSchema.make(o),c,s?.streamBufferSize??16,l);return s?.asQueue?u:lte(Ze(u,tte))}},p=(e,n,r,i,o,s,u)=>Nt(d=>{if(l)return vt;let f=a(),p=n(e=>t.onFromClient({message:e,context:s,discard:u}),{_tag:`Request`,id:f,tag:e._tag,payload:i,...r?{traceId:r.traceId,spanId:r.spanId,sampled:r.sampled}:{},headers:en(d.getRef(No),o)});if(u)return p;let m;return pt(Le(t=>{let n={_tag:`Effect`,rpc:e,context:s,resume(e){t(e),m&&!m.pollUnsafe()&&d.currentDispatcher.scheduleTask(()=>{m.interruptUnsafe(d.id)},0)}};c.set(f,n),m=p.pipe(r?Lt(r,{captureStackTrace:!1}):Te,He(d.context)),m.addObserver(e=>{if(e._tag===`Failure`)return t(e)})}),e=>(c.delete(f),Rt(iee(m),_(f,Array.from(e),s))))}),m=Xe(function*(e,r,o,s,u,d){if(l)return yield*vt;let p=i?void 0:yield*pte(`${n}.${e._tag}`,{attributes:t.spanAttributes}),m=xe(),g=a(),v=Nee(m.context,je);yield*f(v,e=>c.has(g)?(c.delete(g),_(g,yt(e)?Array.from(wee(e.cause)):[],d)):rt);let y=yield*h(u);return c.set(g,{_tag:`Queue`,rpc:e,queue:y,scope:v,context:d}),yield*r(e=>t.onFromClient({message:e,context:d,discard:!1}),{_tag:`Request`,id:g,tag:e._tag,payload:o,...p?{traceId:p.traceId,spanId:p.spanId,sampled:p.sampled}:{},headers:en(m.getRef(No),s)}).pipe(p?Lt(p,{captureStackTrace:!1}):Te,Ue(e=>Pe(y,e)),st,Mt(v,{startImmediately:!0})),y}),g=e=>{let t=[];for(let n of e.middlewares.values()){let e=o.mapUnsafe.get(`${n.key}/Client`);e&&t.push(e)}return t.length===0?(e,t)=>e(t):function n(r,i,a=t.length-1){return a===-1?r(i):t[a]({rpc:e,request:i,next(e){return n(r,e,a-1)}})}},_=(e,n,r)=>Le(i=>{let a=xe();t.onFromClient({message:{_tag:`Interrupt`,requestId:e,interruptors:n},context:r,discard:!1}).pipe(Mee(1e3),He(a.context)).addObserver(()=>{i(rt)})}),v=e=>{switch(e._tag){case`Chunk`:{let n=e.requestId,i=c.get(n);return!i||i._tag!==`Queue`?rt:we(i.queue,e.values).pipe(r?bt(()=>t.onFromClient({message:{_tag:`Ack`,requestId:e.requestId},context:i.context,discard:!1})):Te,Ue(e=>Pe(i.queue,e)))}case`Exit`:{let t=e.requestId,n=c.get(t);return n?(c.delete(t),n._tag===`Effect`?(n.resume(e.exit),rt):e.exit._tag===`Success`?Pt(n.queue):Pe(n.queue,e.exit.cause)):rt}case`Defect`:return u(_ee(e.defect));case`ClientEnd`:return rt}},y;if(t.flatten){let t=new Map;y=function(n,r,i){let a=t.get(n);return a||(a=d(e.requests.get(n)),t.set(n,a)),a(r,i)}}else y={},e.requests.forEach(e=>{y[e._tag]=d(e)});return{client:y,write:v}}),zie=0,jo=Xe(function*(e,t){let n=zie++,{run:r,send:i,supportsAck:a,supportsTransferables:o}=yield*Po,s=new Map,{client:c,write:u}=yield*Rie(e,{...t,supportsAck:a,onFromClient({message:t}){switch(t._tag){case`Request`:{let r=e.requests.get(t.tag),a=o?die():void 0,c=xe(),u={rpc:r,context:a?jee(c.context,ua,a):c.context,schemas:Bie(r)};return s.set(t.id,u),u.schemas.encodePayload(t.payload).pipe(Ce(u.context),l,bt(e=>i(n,{...t,id:String(t.id),payload:e,headers:Object.entries(t.headers)},a&&a.readUnsafe())))}case`Ack`:return s.get(t.requestId)?i(n,{_tag:`Ack`,requestId:String(t.requestId)}):rt;case`Interrupt`:return s.get(t.requestId)?(s.delete(t.requestId),i(n,{_tag:`Interrupt`,requestId:String(t.requestId)})):rt;case`Eof`:return rt}}});return yield*r(n,e=>{switch(e._tag){case`Chunk`:{let t=ha(e.requestId),n=s.get(t);return!n||ote(n.schemas.decodeChunk)?rt:n.schemas.decodeChunk.value(e.values).pipe(Ce(n.context),l,bt(t=>u({_tag:`Chunk`,clientId:0,requestId:ha(e.requestId),values:t})),b(t=>u({_tag:`Exit`,clientId:0,requestId:ha(e.requestId),exit:Oe(t)})))}case`Exit`:{let t=ha(e.requestId),n=s.get(t);return n?(s.delete(t),n.schemas.decodeExit(e.exit).pipe(Ce(n.context),l,Ie({onSuccess:e=>u({_tag:`Exit`,clientId:0,requestId:t,exit:e}),onFailure:e=>u({_tag:`Exit`,clientId:0,requestId:t,exit:Oe(e)})}))):rt}case`Defect`:return u({_tag:`Defect`,clientId:0,defect:Wie(e.defect)});case`ClientProtocolError`:{let t=Je(e.error);return kt(s.keys(),e=>u({_tag:`Exit`,clientId:0,requestId:e,exit:t}))}default:return rt}}).pipe(Ue(ate),st,$e),c}),Mo=new WeakMap,Bie=e=>{let t=Mo.get(e);if(t!==void 0)return t;let n=Ete(e.successSchema);return t={decodeChunk:Uee(n,e=>yn(gn(dne(e.success)))),encodePayload:qte(gn(e.payloadSchema)),decodeExit:yn(gn(lne(e)))},Mo.set(e,t),t},No=xt(`effect/rpc/RpcClient/CurrentHeaders`,{defaultValue:()=>pn}),Po=class extends Ot()(`effect/rpc/RpcClient/Protocol`){static make=Iie},Fo=e=>Po.make(Xe(function*(t,n){let i=yield*ta,a=yield*ko,o=yield*aee(Uie),s=new Map,c=yield*i.writer,d=a.makeUnsafe(),f=yield*Hie(c(d.encode(_ie))),p,m=Dt(()=>(p=void 0,x(o)?o.value.onConnect:rt)),h=e=>kt(n,n=>t(n,e));return yield*Dt(()=>(d=a.makeUnsafe(),f.reset(),i.runRaw(e=>{try{let n=d.decode(e);if(n.length===0)return;let r=0;return Cee({while:()=>r<n.length,body:()=>{let e=n[r++];if(e._tag===`Pong`)return f.onPong(),rt;if(`requestId`in e){let n=s.get(e.requestId);if(n!==void 0)return e._tag===`Exit`&&s.delete(e.requestId),t(n,e)}return h(e)},step:Bee})}catch(e){return h({_tag:`ClientProtocolError`,error:new ma({reason:new pa({message:`Error decoding message`,cause:e})})})}},{onOpen:m}).pipe(O(bt(f.timeout,()=>r(new sa({reason:new ia({kind:`Timeout`,cause:Error(`ping timeout`)})}))))))).pipe(bt(()=>r(new sa({reason:new aa({code:1e3})}))),x(o)?Ke(o.value.onDisconnect):Te,Yee(t=>{let n=Ree(t),r=Jee(n);return e?.retryTransientErrors&&r&&n.success.reason._tag===`SocketOpenError`?rt:(p=new ma({reason:r?n.success.reason:new pa({message:`Unknown socket error`,cause:Fe(t)})}),h({_tag:`ClientProtocolError`,error:p}))}),he(e?.retryPolicy??Vie),u({module:`RpcClient`,method:`makeProtocolSocket`}),$e),{send(e,t){if(p)return r(p);t._tag===`Request`&&s.set(t.id,e);let n=d.encode(t);return n===void 0?rt:l(c(n))},supportsAck:!0,supportsTransferables:!1}})),Vie=_(500,1.5).pipe(see(nee(5e3))),Hie=Xe(function*(e){let t=!0,n=0,r=lt();return yield*Dt(()=>t?(t=!1,n=0,e):(n+=1,n>=3?r.open:e)).pipe(vee(`5 seconds`),wt,Qe,st,$e),{timeout:r.await,reset:()=>{t=!0,n=0,r.closeUnsafe()},onPong:()=>{t=!0,n=0}}}),Uie=class extends Ot()(`effect/rpc/RpcClient/ConnectionHooks`){},Wie=kn(Rn);function Io(e){return{id:e.id??`ws:${e.label}`,label:e.label,source:e.source??`manual`,target:e.target}}function Gie(e){return e?.target.wsBaseUrl??null}function Kie(e){return e?.target.httpBaseUrl??null}function qie(e,t){return{...e,environmentId:t.environmentId,label:t.label}}function Jie(e){return e.cloudMode?`cmmd-cloud-runtime`:`local-web`}function Yie(e){let t=Jie(e);return{topology:t,controlPlane:t!==`cmmd-cloud-runtime`,executionPlane:!0,workspaceProxy:!1}}function Xie(e){let t=e.topology===`cmmd-cloud-runtime`;return{cmmd:!0,ownerBootstrapPromotion:e.topology!==`cloud-shell`&&!t,bearerBootstrap:!0,desktopBootstrap:e.topology===`desktop-local`,providerCredentialBroker:e.topology===`cmmd-control-plane`}}function Zie(e){let t=e.executionPlane;return{agents:t,browser:t,github:t,terminal:t,providerEgress:e.topology===`cmmd-control-plane`}}function Qie(e,t){return{localProjects:t.executionPlane,cloudProjects:e.cloudMode}}function Lo(e){let t=e.capabilities,n=t.runtime??Yie(t);return{repositoryIdentity:t.repositoryIdentity,pullRequests:t.pullRequests??!1,cloudMode:t.cloudMode,posthogPublicKey:t.posthogPublicKey,posthogHost:t.posthogHost,runtime:n,auth:t.auth??Xie(n),tools:t.tools??Zie(n),projects:t.projects??Qie(t,n)}}function $ie(e){return e?Lo(e).projects.cloudProjects:!1}function eae(e){return e?Lo(e).runtime.workspaceProxy??!1:!1}function Ro(e,t){return{environmentId:e,projectId:t}}function zo(e,t){return{environmentId:e,threadId:t}}var Bo=`scoped:v1:`;function Vo(e){let t=`projectId`in e?e.projectId:e.threadId;return t.includes(`:`)||e.environmentId.startsWith(Bo)?`${Bo}${encodeURIComponent(e.environmentId)}:${encodeURIComponent(t)}`:`${e.environmentId}:${t}`}function Ho(e){return Vo(e)}function Uo(e){return Vo(e)}function tae(e){let t=e.slice(10),n=t.indexOf(`:`);if(n<=0||n>=t.length-1||t.indexOf(`:`,n+1)!==-1)return null;try{let e=decodeURIComponent(t.slice(0,n)),r=decodeURIComponent(t.slice(n+1));return e.length>0&&r.length>0?{environmentId:e,localId:r}:null}catch{return null}}function Wo(e){if(e.startsWith(Bo))return tae(e);let t=e.lastIndexOf(`:`);return t<=0||t>=e.length-1?null:{environmentId:e.slice(0,t),localId:e.slice(t+1)}}function Go(e){let t=Wo(e);return t?{environmentId:t.environmentId,projectId:t.localId}:null}function Ko(e){let t=Wo(e);return t?{environmentId:t.environmentId,threadId:t.localId}:null}var nae=1e3,rae=64e3;jo(Wn);function iae(e){return!Number.isInteger(e)||e<0||e>=10?null:Math.min(Math.round(nae*2**e),rae)}var qo=class extends Error{code;retryable;name=`RelayProtocolFailure`;constructor(e,t,n){super(t),this.code=e,this.retryable=n}};function Jo(e){return Array.isArray(e)?e.map(Jo):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,Jo(t)])):e}function aae(e){let t=JSON.stringify(Jo(e));if(t===void 0)throw Error(`Relay payload is not JSON serializable.`);return t}var oae={requestId:`@effect/rpc/Ping`,correlationId:`@effect/rpc/Ping`,method:`@effect/rpc/Ping`,requiredScope:null,deliveryClass:`read`,journalPersistence:`none`};function sae(e){return e._tag===`Ping`?oae:null}function cae(e){if(e.policy===null||e.policy.method!==e.method)throw new qo(`method_not_remotable`,`Relay method has no exact dispatch policy: ${e.method}`,!1);if(e.policy.requiredScope!==null&&!e.grantedScopes.includes(e.policy.requiredScope))throw new qo(`scope_denied`,`Relay method ${e.method} requires scope ${e.policy.requiredScope}`,!1);return{requiredScope:e.policy.requiredScope,deliveryClass:e.policy.deliveryClass,journalPersistence:e.policy.journalPersistence}}function lae(e){let t=new Set(e.registeredMethods),n=new Map;for(let r of e.policies){if(n.has(r.method))throw new qo(`method_not_remotable`,`Relay method has duplicate dispatch policies: ${r.method}`,!1);if(!t.has(r.method))throw new qo(`method_not_remotable`,`Relay dispatch policy targets an unregistered method: ${r.method}`,!1);if((r.deliveryClass===`idempotent-command`||r.deliveryClass===`create-command`)==(r.journalPersistence===`none`))throw new qo(`method_not_remotable`,`Relay dispatch policy has incompatible journal persistence: ${r.method}`,!1);n.set(r.method,r)}for(let t of e.registeredMethods)if(!n.has(t))throw new qo(`method_not_remotable`,`Remotely registered method has no dispatch policy: ${t}`,!1);return n}var uae=[{method:M.projectsSearchEntries,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.projectsListEntries,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.serverDiscoverSourceControl,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.serverReportClientActivity,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.codeGraphSummary,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.codeGraphNeighborhood,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.codeGraphSearch,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.projectsWriteFile,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.projectCheckoutDeletionPreview,requiredScope:`workspace.write`,deliveryClass:`read`},{method:M.projectCheckoutDeletionExecute,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.workspaceReadFile,requiredScope:`workspace.read`,deliveryClass:`bulk-transfer`},{method:M.workspaceBeginWriteFile,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.workspaceWriteFileChunk,requiredScope:`workspace.write`,deliveryClass:`bulk-transfer`},{method:M.workspaceCommitWriteFile,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.workspaceCancelWriteFile,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.shellOpenInEditor,requiredScope:`shell.open`,deliveryClass:`idempotent-command`},{method:M.gitPull,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitRefreshStatus,requiredScope:`git.read`,deliveryClass:`read`},{method:M.gitRunStackedAction,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitListBranches,requiredScope:`git.read`,deliveryClass:`read`},{method:M.vcsListRefs,requiredScope:`git.read`,deliveryClass:`read`},{method:M.vcsRefreshStatus,requiredScope:`git.read`,deliveryClass:`read`},{method:M.vcsPull,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.vcsCreateWorktree,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.vcsRemoveWorktree,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.vcsCreateRef,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.vcsSwitchRef,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.vcsInit,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitCreateWorktree,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.gitRemoveWorktree,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitCreateBranch,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.gitCheckout,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitInit,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitResolvePullRequest,requiredScope:`git.read`,deliveryClass:`read`},{method:M.gitPreparePullRequestThread,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.terminalOpen,requiredScope:`terminal.write`,deliveryClass:`create-command`},{method:M.terminalAttach,requiredScope:`terminal.write`,deliveryClass:`terminal-output`},{method:M.terminalWrite,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalResize,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalSignal,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalClear,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalRestart,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalClose,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.browserOpenSession,requiredScope:`browser.control`,deliveryClass:`create-command`},{method:M.browserListSessions,requiredScope:`browser.read`,deliveryClass:`read`},{method:M.browserCloseSession,requiredScope:`browser.control`,deliveryClass:`browser-control`},{method:M.browserGetSession,requiredScope:`browser.read`,deliveryClass:`read`},{method:M.browserCommand,requiredScope:`browser.control`,deliveryClass:`browser-control`},{method:M.browserClearBrowsingData,requiredScope:`browser.control`,deliveryClass:`browser-control`},{method:M.browserAttachDisplay,requiredScope:`browser.read`,deliveryClass:`subscription`},{method:M.computerInput,requiredScope:`browser.control`,deliveryClass:`browser-control`},{method:M.browserAddDisplayIceCandidate,requiredScope:`browser.read`,deliveryClass:`browser-control`},{method:M.devTunnelRegister,requiredScope:`browser.control`,deliveryClass:`idempotent-command`},{method:M.devTunnelUnregister,requiredScope:`browser.control`,deliveryClass:`idempotent-command`},{method:M.devTunnelList,requiredScope:`browser.read`,deliveryClass:`read`},{method:M.threadDevRuntimeGet,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.threadDevRuntimeAllocatePort,requiredScope:`runtime.manage`,deliveryClass:`idempotent-command`},{method:M.threadDevRuntimeRelease,requiredScope:`runtime.manage`,deliveryClass:`idempotent-command`},{method:M.workspaceEnvironmentPreflight,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.workspaceEnsureScratch,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.serverGetConfig,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.serverRefreshProviders,requiredScope:`provider.read`,deliveryClass:`read`},{method:M.serverStartProviderAuth,requiredScope:`provider.manage`,deliveryClass:`create-command`},{method:M.serverRepairProviderAuthRuntime,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverDisconnectProviderAuth,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverGetProviderAuthSession,requiredScope:`provider.read`,deliveryClass:`read`},{method:M.serverCancelProviderAuth,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverSubmitProviderAuthCode,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverSyncPersonalCodexToCloud,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverSyncPersonalClaudeToCloud,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverUpsertKeybinding,requiredScope:`settings.write`,deliveryClass:`idempotent-command`},{method:M.serverRemoveKeybinding,requiredScope:`settings.write`,deliveryClass:`idempotent-command`},{method:M.serverGetSettings,requiredScope:`settings.read`,deliveryClass:`read`},{method:M.serverUpdateSettings,requiredScope:`settings.write`,deliveryClass:`idempotent-command`},{method:M.serverUpdateEnvironmentDisplayName,requiredScope:`settings.write`,deliveryClass:`idempotent-command`},{method:M.serverGetTraceDiagnostics,requiredScope:`settings.read`,deliveryClass:`read`},{method:M.serverHeartbeat,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.usageGetSummary,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.pullRequestsList,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsListStats,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsDetail,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsActivity,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsThreadComments,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsDiffFileContents,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsRunAction,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsUpdate,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsComment,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.pullRequestsUpdateComment,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsSubmitReview,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.pullRequestsReplyToThread,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.pullRequestsSetThreadResolution,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsSetReaction,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsInvalidate,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsReviewerCandidates,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsRequestReviewers,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.subscribeGitStatus,requiredScope:`git.read`,deliveryClass:`subscription`},{method:M.subscribeVcsStatus,requiredScope:`git.read`,deliveryClass:`subscription`},{method:M.subscribeTerminalEvents,requiredScope:`terminal.read`,deliveryClass:`terminal-output`},{method:M.subscribeTerminalMetadata,requiredScope:`terminal.read`,deliveryClass:`read`},{method:M.subscribeBrowserEvents,requiredScope:`browser.read`,deliveryClass:`browser-frame`},{method:M.subscribeServerConfig,requiredScope:`runtime.read`,deliveryClass:`subscription`},{method:M.subscribeServerLifecycle,requiredScope:`runtime.read`,deliveryClass:`subscription`},{method:M.subscribeAuthAccess,requiredScope:`provider.read`,deliveryClass:`subscription`},{method:M.subscribeWorkspaceReadiness,requiredScope:`runtime.read`,deliveryClass:`subscription`},{method:ln.dispatchCommand,requiredScope:null,deliveryClass:`idempotent-command`},{method:ln.getTurnDiff,requiredScope:`diff.read`,deliveryClass:`read`},{method:ln.getFullThreadDiff,requiredScope:`diff.read`,deliveryClass:`read`},{method:ln.streamTurnDiff,requiredScope:`diff.read`,deliveryClass:`bulk-transfer`},{method:ln.streamFullThreadDiff,requiredScope:`diff.read`,deliveryClass:`bulk-transfer`},{method:ln.replayEvents,requiredScope:`thread.read`,deliveryClass:`subscription`},{method:ln.subscribeShell,requiredScope:`thread.read`,deliveryClass:`subscription`},{method:ln.subscribeThread,requiredScope:`thread.read`,deliveryClass:`subscription`}],dae=new Set([M.gitPull,M.gitRunStackedAction,M.gitCreateWorktree,M.gitRemoveWorktree,M.gitCreateBranch,M.gitCheckout,M.gitInit,M.gitPreparePullRequestThread,M.threadDevRuntimeAllocatePort,M.threadDevRuntimeRelease,M.serverUpsertKeybinding,M.serverRemoveKeybinding,M.serverUpdateEnvironmentDisplayName,ln.dispatchCommand]),fae=uae.map(e=>{let t=e.deliveryClass===`idempotent-command`||e.deliveryClass===`create-command`;return{method:e.method,requiredScope:e.requiredScope,deliveryClass:e.deliveryClass,journalPersistence:t?dae.has(e.method)?`frame`:`metadata-only`:`none`}}),pae=lae({registeredMethods:[...Wn.requests.keys()],policies:fae}),Yo={"project.create":{requiredScope:`project.write`,deliveryClass:`create-command`},"project.meta.update":{requiredScope:`project.write`,deliveryClass:`idempotent-command`},"project.delete":{requiredScope:`project.write`,deliveryClass:`idempotent-command`},"thread.create":{requiredScope:`thread.create`,deliveryClass:`create-command`},"thread.delete":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.archive":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.settle":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.unsettle":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.unarchive":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.meta.update":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.runtime-mode.set":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.interaction-mode.set":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.turn.start":{requiredScope:`turn.dispatch`,deliveryClass:`create-command`},"thread.turn.interrupt":{requiredScope:`turn.stop`,deliveryClass:`idempotent-command`},"thread.approval.respond":{requiredScope:`approval.respond`,deliveryClass:`idempotent-command`},"thread.user-input.respond":{requiredScope:`approval.respond`,deliveryClass:`idempotent-command`},"thread.checkpoint.revert":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.session.stop":{requiredScope:`turn.stop`,deliveryClass:`idempotent-command`},"thread.plan-approval.respond":{requiredScope:`approval.respond`,deliveryClass:`idempotent-command`}},mae=new Set([`thread.approval.respond`,`thread.user-input.respond`,`thread.plan-approval.respond`]);function hae(e){if(e.method!==ln.dispatchCommand||!e.payload||typeof e.payload!=`object`||Array.isArray(e.payload))return null;let t=e.payload;if(typeof t.type!=`string`||!mae.has(t.type))return null;let n=t.type===`thread.plan-approval.respond`?t.promptId:t.requestId;if(typeof t.commandId!=`string`||t.commandId.length===0||typeof n!=`string`||n.length===0)throw new qo(`action_grant_invalid`,`Relay sensitive action metadata is incomplete`,!1);return{commandType:t.type,commandId:t.commandId,targetId:n}}function Xo(e){let t=pae.get(e.method)??null,n=cae({method:e.method,grantedScopes:e.grantedScopes,policy:t});if(e.method!==ln.dispatchCommand)return n;if(!e.payload||typeof e.payload!=`object`||!(`type`in e.payload))throw new qo(`method_not_remotable`,`Relay orchestration dispatch payload has no command policy`,!1);let r=e.payload.type;if(typeof r!=`string`||!(r in Yo))throw new qo(`method_not_remotable`,`Relay orchestration command has no dispatch policy: ${String(r)}`,!1);let i=Yo[r];if(!e.grantedScopes.includes(i.requiredScope))throw new qo(`scope_denied`,`Relay orchestration command ${r} requires scope ${i.requiredScope}`,!1);return{requiredScope:i.requiredScope,deliveryClass:i.deliveryClass,journalPersistence:n.journalPersistence}}var Zo=class extends Error{constructor(e){let t;t=e instanceof Error?e.message:typeof e==`string`?e:``,super(t),this.name=this.constructor.name}},Qo=class extends Zo{},$o=class extends Zo{},es=class extends Zo{},gae=class extends Zo{},_ae=class extends Zo{},vae=class extends Zo{},yae=class extends Zo{},bae=class extends Zo{},xae=class extends Zo{},Sae=class extends Zo{},ts=class extends Zo{},ns=Cae(globalThis,{});function Cae(e,t){return new Proxy(e,{get(n,r,i){return r in t?t[r]:e[r]},set(n,r,i){return r in t&&delete t[r],e[r]=i,!0},deleteProperty(n,r){let i=!1;return r in t&&(delete t[r],i=!0),r in e&&(delete e[r],i=!0),i},ownKeys(n){let r=Reflect.ownKeys(e),i=Reflect.ownKeys(t),a=new Set(i);return[...r.filter(e=>!a.has(e)),...i]},defineProperty(n,r,i){return r in t&&delete t[r],Reflect.defineProperty(e,r,i),!0},getOwnPropertyDescriptor(n,r){return r in t?Reflect.getOwnPropertyDescriptor(t,r):Reflect.getOwnPropertyDescriptor(e,r)},has(n,r){return r in t||r in e}})}async function wae(){if(ns!==void 0&&globalThis.crypto!==void 0)return globalThis.crypto.subtle;try{let{webcrypto:e}=await N(async()=>{let{webcrypto:e}=await import(`./__vite-browser-external-y4e5bF-h.js`).then(e=>t(e.default));return{webcrypto:e}},__vite__mapDeps([0,1]));return e.subtle}catch(e){throw new ts(e)}}var rs=class{constructor(){Object.defineProperty(this,"_api",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}async _setup(){this._api===void 0&&(this._api=await wae())}},is={Base:0,Psk:1,Auth:2,AuthPsk:3},Tae={NotAssigned:0,DhkemP256HkdfSha256:16,DhkemP384HkdfSha384:17,DhkemP521HkdfSha512:18,DhkemSecp256k1HkdfSha256:19,DhkemX25519HkdfSha256:32,DhkemX448HkdfSha512:33,HybridkemX25519Kyber768:48,MlKem512:64,MlKem768:65,MlKem1024:66,XWing:25722},as={HkdfSha256:1,HkdfSha384:2,HkdfSha512:3,Sha3256:4,Sha3384:5,Sha3512:6,Shake128:16,Shake256:17,TurboShake128:18,TurboShake256:19},os={Aes128Gcm:1,Aes256Gcm:2,Chacha20Poly1305:3,ExportOnly:65535},ss=new Uint8Array,cs=0n,ls=1n,us=2n,Eae=new Uint8Array([75,69,77,0,0]),ds=new Uint8Array([72,80,75,69,45,118,49]);function fs(e){return new Uint8Array(ps(e))}function ps(e){return e instanceof ArrayBuffer?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength).slice().buffer:new Uint8Array(e).slice().buffer}var Dae=class extends rs{constructor(){super(),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:as.HkdfSha256}),Object.defineProperty(this,"hashSize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_suiteId",{enumerable:!0,configurable:!0,writable:!0,value:ss}),Object.defineProperty(this,"algHash",{enumerable:!0,configurable:!0,writable:!0,value:{name:`HMAC`,hash:`SHA-256`,length:256}})}init(e){this._suiteId=e}buildLabeledIkm(e,t){this._checkInit();let n=new Uint8Array(7+this._suiteId.byteLength+e.byteLength+t.byteLength);return n.set(ds,0),n.set(this._suiteId,7),n.set(e,7+this._suiteId.byteLength),n.set(t,7+this._suiteId.byteLength+e.byteLength),n}buildLabeledInfo(e,t,n){this._checkInit();let r=new Uint8Array(9+this._suiteId.byteLength+e.byteLength+t.byteLength);return r.set(new Uint8Array([0,n]),0),r.set(ds,2),r.set(this._suiteId,9),r.set(e,9+this._suiteId.byteLength),r.set(t,9+this._suiteId.byteLength+e.byteLength),r}async extract(e,t){await this._setup();let n=e.byteLength===0?new ArrayBuffer(this.hashSize):ps(e);if(n.byteLength!==this.hashSize)throw new Qo(`The salt length must be the same as the hashSize`);let r=ps(t),i=await this._api.importKey(`raw`,n,this.algHash,!1,[`sign`]);return await this._api.sign(`HMAC`,i,r)}async expand(e,t,n){await this._setup();let r=ps(e),i=await this._api.importKey(`raw`,r,this.algHash,!1,[`sign`]),a=new ArrayBuffer(n),o=new Uint8Array(a),s=ss,c=fs(t),l=new Uint8Array(1);if(n>255*this.hashSize)throw Error(`Entropy limit reached`);let u=new Uint8Array(this.hashSize+c.length+1);for(let e=1,t=0;t<o.length;e++)l[0]=e,u.set(s,0),u.set(c,s.length),u.set(l,s.length+c.length),s=new Uint8Array(await this._api.sign(`HMAC`,i,u.slice(0,s.length+c.length+1))),o.length-t>=s.length?(o.set(s,t),t+=s.length):(o.set(s.slice(0,o.length-t),t),t+=o.length-t);return a}async extractAndExpand(e,t,n,r){await this._setup();let i=ps(t),a=await this._api.importKey(`raw`,i,`HKDF`,!1,[`deriveBits`]);return await this._api.deriveBits({name:`HKDF`,hash:this.algHash.hash,salt:ps(e),info:ps(n)},a,r*8)}async labeledExtract(e,t,n){return await this.extract(e,this.buildLabeledIkm(t,n))}async labeledExpand(e,t,n,r){return await this.expand(e,this.buildLabeledInfo(t,n,r),r)}_checkInit(){if(this._suiteId===ss)throw Error(`Not initialized. Call init()`)}},Oae=class extends Dae{constructor(){super(...arguments),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:as.HkdfSha256}),Object.defineProperty(this,"hashSize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"algHash",{enumerable:!0,configurable:!0,writable:!0,value:{name:`HMAC`,hash:`SHA-256`,length:256}})}},ms=e=>typeof e==`object`&&!!e&&typeof e.privateKey==`object`&&typeof e.publicKey==`object`;function hs(e,t){if(t<=0)throw Error(`i2Osp: too small size`);if(e>=256**t)throw Error(`i2Osp: too large integer`);let n=new Uint8Array(t);for(let r=0;r<t&&e;r++)n[t-(r+1)]=e%256,e=Math.floor(e/256);return n}function gs(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}function _s(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}async function kae(){if(ns!==void 0&&globalThis.crypto!==void 0)return globalThis.crypto;try{let{webcrypto:e}=await N(async()=>{let{webcrypto:e}=await import(`./__vite-browser-external-y4e5bF-h.js`).then(e=>t(e.default));return{webcrypto:e}},__vite__mapDeps([0,1]));return e}catch{throw Error(`failed to load Crypto`)}}function Aae(e,t){if(e.byteLength!==t.byteLength)throw Error(`xor: different length inputs`);let n=new Uint8Array(e.byteLength);for(let r=0;r<e.byteLength;r++)n[r]=e[r]^t[r];return n}var jae=new Uint8Array([101,97,101,95,112,114,107]),Mae=new Uint8Array([115,104,97,114,101,100,95,115,101,99,114,101,116]);function Nae(e,t,n){let r=new Uint8Array(e.length+t.length+n.length);return r.set(e,0),r.set(t,e.length),r.set(n,e.length+t.length),r}var Pae=class{constructor(e,t,n){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"secretSize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"encSize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"publicKeySize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"privateKeySize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_prim",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_kdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.id=e,this._prim=t,this._kdf=n;let r=new Uint8Array(Eae);r.set(hs(this.id,2),3),this._kdf.init(r)}async serializePublicKey(e){return await this._prim.serializePublicKey(e)}async deserializePublicKey(e){return await this._prim.deserializePublicKey(ps(e))}async serializePrivateKey(e){return await this._prim.serializePrivateKey(e)}async deserializePrivateKey(e){return await this._prim.deserializePrivateKey(ps(e))}async importKey(e,t,n=!0){return await this._prim.importKey(e,t,n)}async generateKeyPair(){return await this._prim.generateKeyPair()}async deriveKeyPair(e){let t=ps(e);if(t.byteLength>8192)throw new Qo(`Too long ikm`);return await this._prim.deriveKeyPair(t)}async encap(e){let t;t=e.ekm===void 0?await this.generateKeyPair():ms(e.ekm)?e.ekm:await this.deriveKeyPair(e.ekm);let n=await this._prim.serializePublicKey(t.publicKey),r=await this._prim.serializePublicKey(e.recipientPublicKey);try{let i;if(e.senderKey===void 0)i=new Uint8Array(await this._prim.dh(t.privateKey,e.recipientPublicKey));else{let n=ms(e.senderKey)?e.senderKey.privateKey:e.senderKey;i=gs(new Uint8Array(await this._prim.dh(t.privateKey,e.recipientPublicKey)),new Uint8Array(await this._prim.dh(n,e.recipientPublicKey)))}let a;if(e.senderKey===void 0)a=gs(new Uint8Array(n),new Uint8Array(r));else{let t=ms(e.senderKey)?e.senderKey.publicKey:await this._prim.derivePublicKey(e.senderKey),i=await this._prim.serializePublicKey(t);a=Nae(new Uint8Array(n),new Uint8Array(r),new Uint8Array(i))}return{enc:n,sharedSecret:await this._generateSharedSecret(i,a)}}catch(e){throw new gae(e)}}async decap(e){let t=ps(e.enc),n=await this._prim.deserializePublicKey(t),r=ms(e.recipientKey)?e.recipientKey.privateKey:e.recipientKey,i=ms(e.recipientKey)?e.recipientKey.publicKey:await this._prim.derivePublicKey(e.recipientKey),a=await this._prim.serializePublicKey(i);try{let i;i=e.senderPublicKey===void 0?new Uint8Array(await this._prim.dh(r,n)):gs(new Uint8Array(await this._prim.dh(r,n)),new Uint8Array(await this._prim.dh(r,e.senderPublicKey)));let o;if(e.senderPublicKey===void 0)o=gs(new Uint8Array(t),new Uint8Array(a));else{let n=await this._prim.serializePublicKey(e.senderPublicKey);o=new Uint8Array(t.byteLength+a.byteLength+n.byteLength),o.set(new Uint8Array(t),0),o.set(new Uint8Array(a),t.byteLength),o.set(new Uint8Array(n),t.byteLength+a.byteLength)}return await this._generateSharedSecret(i,o)}catch(e){throw new _ae(e)}}async _generateSharedSecret(e,t){let n=this._kdf.buildLabeledIkm(jae,e),r=this._kdf.buildLabeledInfo(Mae,t,this.secretSize);return await this._kdf.extractAndExpand(ss,n,r,this.secretSize)}},vs=[`deriveBits`],Fae=new Uint8Array([100,107,112,95,112,114,107]),Iae=new Uint8Array([115,107]),ys=class{constructor(e,t,n,r=[]){Object.defineProperty(this,"key",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extractable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"algorithm",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"usages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.key=t,this.type=n,this.algorithm={name:e},this.usages=r,n===`public`&&(this.usages=[])}},Lae=class{constructor(e,t,n,r){Object.defineProperty(this,"_algName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_curve",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_hkdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nPk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nSk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._algName=e,this._nPk=t,this._nSk=t,this._curve=n,this._hkdf=r}serializePublicKey(e){try{return Promise.resolve(e.key.buffer)}catch(e){return Promise.reject(new $o(e))}}async deserializePublicKey(e){try{return await this._importRawKey(ps(e),!0)}catch(e){throw new es(e)}}serializePrivateKey(e){try{return Promise.resolve(e.key.buffer)}catch(e){return Promise.reject(new $o(e))}}async deserializePrivateKey(e){try{return await this._importRawKey(ps(e),!1)}catch(e){throw new es(e)}}async importKey(e,t,n){try{if(e===`raw`)return await this._importRawKey(t,n);if(t instanceof ArrayBuffer)throw Error(`Invalid jwk key format`);return await this._importJWK(t,n)}catch(e){throw new es(e)}}async generateKeyPair(){try{let e=await this._curve.utils.randomSecretKey(),t=new ys(this._algName,e,`private`,vs);return{publicKey:await this.derivePublicKey(t),privateKey:t}}catch(e){throw new ts(e)}}async deriveKeyPair(e){try{let t=ps(e),n=await this._hkdf.labeledExtract(ss.buffer,Fae,new Uint8Array(t)),r=await this._hkdf.labeledExpand(n,Iae,ss,this._nSk),i=new ys(this._algName,new Uint8Array(r),`private`,vs);return{privateKey:i,publicKey:await this.derivePublicKey(i)}}catch(e){throw new Sae(e)}}derivePublicKey(e){try{let t=this._curve.getPublicKey(e.key);return Promise.resolve(new ys(this._algName,t,`public`))}catch(e){return Promise.reject(new es(e))}}dh(e,t){try{return Promise.resolve(this._curve.getSharedSecret(e.key,t.key).buffer)}catch(e){return Promise.reject(new $o(e))}}_importRawKey(e,t){return new Promise((n,r)=>{t&&e.byteLength!==this._nPk&&r(Error(`Invalid length of the key`)),!t&&e.byteLength!==this._nSk&&r(Error(`Invalid length of the key`)),n(new ys(this._algName,new Uint8Array(e),t?`public`:`private`,t?[]:vs))})}_importJWK(e,t){return new Promise((n,r)=>{e.kty!==`OKP`&&r(Error(`Invalid kty: ${e.kty}`)),e.crv!==this._algName&&r(Error(`Invalid crv: ${e.crv}`)),t?(e.d!==void 0&&r(Error("Invalid key: `d` should not be set")),typeof e.x!=`string`&&r(Error("Invalid key: `x` not found")),n(new ys(this._algName,_s(e.x),`public`))):(typeof e.d!=`string`&&r(Error("Invalid key: `d` not found")),n(new ys(this._algName,_s(e.d),`private`,vs)))})}};function Rae(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function bs(e,t=``){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw Error(`${n}expected integer >0, got ${e}`)}}function xs(e,t,n=``){let r=Rae(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`;throw Error(o+`expected Uint8Array`+s+`, got `+c)}return e}function Ss(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function Cs(e,t){xs(e,void 0,`digestInto() output`);let n=t.outputLen;if(e.length<n)throw Error(`"digestInto() output" expected to be of length >=`+n)}function zae(e){if(typeof e==`bigint`){if(!Ps(e))throw Error(`positive bigint expected, got `+e)}else bs(e);return e}function ws(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ts(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var Bae=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Es(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ds(e,t){return e<<32-t|e>>>t}var Os=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,Vae=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`)),Hae=[0n,1n,2n,3n,4n,5n,6n,7n,8n,9n,10n,11n,12n,13n,14n,15n];function Uae(e){if(xs(e),Os)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=Vae[e[n]];return t}var ks={_0:48,_9:57,A:65,F:70,a:97,f:102};function As(e){if(e>=ks._0&&e<=ks._9)return e-ks._0;if(e>=ks.A&&e<=ks.F)return e-(ks.A-10);if(e>=ks.a&&e<=ks.f)return e-(ks.a-10)}function Wae(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(Os)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=As(e.charCodeAt(i)),a=As(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function Gae(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);let t=cs;for(let n=0;n<e.length;n++){let r=As(e.charCodeAt(n));if(r===void 0)throw Error(`hex string expected, got non-hex character "`+e[n]+`" at index `+n);t=t<<4n|Hae[r]}return t}function js(e){bs(e,`numberToBigint`);let t=e,n=cs,r=1n;for(;t>0;)t%2==1&&(n+=r),t=Math.floor(t/2),r<<=1n;return n}function Ms(e){return Gae(Uae(Ns(xs(e)).reverse()))}function Kae(e,t){bs(t),e=zae(e);let n=Wae(e.toString(16).padStart(t*2,`0`));if(n.length!==t)throw Error(`number too large`);return n}function qae(e,t){return Kae(e,t).reverse()}function Ns(e){return Uint8Array.from(e)}function Ps(e){return typeof e==`bigint`&&0n<=e}function Jae(e,t,n){return Ps(e)&&Ps(t)&&Ps(n)&&t<=e&&e<n}function Fs(e,t,n,r){if(!Jae(t,n,r))throw Error(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function Yae(e,t={},n={}){if(!e||typeof e!=`object`)throw Error(`expected valid options object`);function r(t,n,r){let i=e[t];if(r&&i===void 0)return;let a=typeof i;if(a!==n||i===null)throw Error(`param "${t}" is invalid: expected ${n}, got ${a}`)}let i=(e,t)=>Object.entries(e).forEach(([e,n])=>r(e,n,t));i(t,!1),i(n,!0)}async function Xae(e=32){let t=await kae(),n=new Uint8Array(e);return t.getRandomValues(n),n}function Zae(e){return{oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])}}function Qae(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash must wrapped by utils.createHasher`);bs(e.outputLen),bs(e.blockLen)}function $ae(e,t={}){let n=(t,n)=>e(n).update(t).digest(),r=e(void 0),i=Object.assign(n,{outputLen:r.outputLen,blockLen:r.blockLen,create:t=>e(t),...t});return Object.freeze(i)}var Is=class{constructor(e,t){if(Object.defineProperty(this,"oHash",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"iHash",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"blockLen",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputLen",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"finished",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Qae(e),xs(t,void 0,`key`),this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,r=new Uint8Array(n);r.set(t.length>n?e.create().update(t).digest():t);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),Ts(r)}update(e){return Ss(this),this.iHash.update(e),this}digestInto(e){Ss(this),xs(e,this.outputLen,`output`),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ls=(e,t,n)=>new Is(e,t).update(n).digest();Ls.create=(e,t)=>new Is(e,t);function eoe(e,t,n){return e&t^~e&n}function toe(e,t,n){return e&t^e&n^t&n}var noe=class{constructor(e,t,n,r){Object.defineProperty(this,"blockLen",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputLen",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"padOffset",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLE",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"buffer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"view",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"finished",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"length",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"pos",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Es(this.buffer)}update(e){Ss(this),xs(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=Es(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ss(this),Cs(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,Ts(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;n.setBigUint64(r-8,js(this.length*8),i),this.process(n,0);let o=Es(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen must be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},Rs=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),roe=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),zs=new Uint32Array(64),ioe=class extends noe{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)zs[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=zs[e-15],n=zs[e-2],r=Ds(t,7)^Ds(t,18)^t>>>3,i=Ds(n,17)^Ds(n,19)^n>>>10;zs[e]=i+zs[e-7]+r+zs[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=Ds(o,6)^Ds(o,11)^Ds(o,25),u=l+t+eoe(o,s,c)+roe[e]+zs[e]|0,d=(Ds(n,2)^Ds(n,13)^Ds(n,22))+toe(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){Ts(zs)}destroy(){this.set(0,0,0,0,0,0,0,0),Ts(this.buffer)}},aoe=class extends ioe{constructor(){super(32),Object.defineProperty(this,"A",{enumerable:!0,configurable:!0,writable:!0,value:Rs[0]|0}),Object.defineProperty(this,"B",{enumerable:!0,configurable:!0,writable:!0,value:Rs[1]|0}),Object.defineProperty(this,"C",{enumerable:!0,configurable:!0,writable:!0,value:Rs[2]|0}),Object.defineProperty(this,"D",{enumerable:!0,configurable:!0,writable:!0,value:Rs[3]|0}),Object.defineProperty(this,"E",{enumerable:!0,configurable:!0,writable:!0,value:Rs[4]|0}),Object.defineProperty(this,"F",{enumerable:!0,configurable:!0,writable:!0,value:Rs[5]|0}),Object.defineProperty(this,"G",{enumerable:!0,configurable:!0,writable:!0,value:Rs[6]|0}),Object.defineProperty(this,"H",{enumerable:!0,configurable:!0,writable:!0,value:Rs[7]|0})}},Bs=$ae(()=>new aoe,Zae(1));function Vs(e,t){let n=e%t;return n>=0n?n:t+n}function Hs(e,t,n){let r=e;for(;t-->cs;)r*=r,r%=n;return r}function ooe(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}function soe(e){return Yae(e,{adjustScalarBytes:`function`,powPminus2:`function`}),Object.freeze({...e})}function coe(e){let{P:t,type:n,adjustScalarBytes:r,powPminus2:i,randomBytes:a}=soe(e),o=n===`x25519`;if(!o&&n!==`x448`)throw Error(`invalid type`);let s=a||Xae,c=o?255n:448n,l=o?32:56,u=o?9n:5n,d=o?121665n:39081n,f=o?us**254n:us**447n,p=f+(o?8n*us**251n-ls:4n*us**445n-ls)+ls,m=e=>Vs(e,t),h=g(u);function g(e){return qae(m(e),l)}function _(e){let t=Ns(xs(e,l,`uCoordinate`));return o&&(t[31]&=127),m(Ms(t))}function v(e){return Ms(r(Ns(xs(e,l,`scalar`))))}function y(e,t){let n=w(_(t),v(e));if(n===0n)throw Error(`invalid private or public key received`);return g(n)}function b(e){return y(e,h)}let x=b,S=y;function C(e,t,n){let r=m(e*(t-n));return t=m(t-r),n=m(n+r),{x_2:t,x_3:n}}function w(e,n){Fs(`u`,e,cs,t),Fs(`scalar`,n,f,p);let r=n,a=e,o=ls,s=cs,l=e,u=ls,h=cs;for(let e=c-1n;e>=cs;e--){let t=r>>e&ls;h^=t,{x_2:o,x_3:l}=C(h,o,l),{x_2:s,x_3:u}=C(h,s,u),h=t;let n=o+s,i=m(n*n),c=o-s,f=m(c*c),p=i-f,g=l+u,_=l-u,v=m(_*n),y=m(g*c),b=v+y,x=v-y;l=m(b*b),u=m(a*m(x*x)),o=m(i*f),s=m(p*(i+m(d*p)))}({x_2:o,x_3:l}=C(h,o,l)),{x_2:s,x_3:u}=C(h,s,u);let g=i(s);return m(o*g)}let T={secretKey:l,publicKey:l,seed:l},E=async e=>(e===void 0&&(e=await s(l)),xs(e,T.seed,`seed`),e),D={randomSecretKey:E};return Object.freeze({keygen:ooe(E,x),getSharedSecret:S,getPublicKey:x,scalarMult:y,scalarMultBase:b,utils:D,GuBytes:h.slice(),lengths:T})}function Us(e){if(typeof e!=`boolean`)throw Error(`boolean expected, not ${e}`)}var loe=(e,t)=>{function n(n,...r){if(xs(n,void 0,`key`),!Bae)throw Error(`Non little-endian hardware is not yet supported`);if(e.nonceLength!==void 0){let t=r[0];xs(t,e.varSizeNonce?void 0:e.nonceLength,`nonce`)}let i=e.tagLength;i&&r[1]!==void 0&&xs(r[1],void 0,`AAD`);let a=t(n,...r),o=(e,t)=>{if(t!==void 0){if(e!==2)throw Error(`cipher output not supported`);xs(t,void 0,`output`)}},s=!1;return{encrypt(e,t){if(s)throw Error(`cannot encrypt() twice with same key + nonce`);return s=!0,xs(e),o(a.encrypt.length,t),a.encrypt(e,t)},decrypt(e,t){if(xs(e),i&&e.length<i)throw Error(`"ciphertext" expected length bigger than tagLength=`+i);return o(a.decrypt.length,t),a.decrypt(e,t)}}}return Object.assign(n,e),n};function uoe(e,t){if(typeof t!=`object`||!t)throw Error(`options must be defined`);return Object.assign(e,t)}function doe(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function Ws(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(t.length!==e)throw Error(`"output" expected Uint8Array of length `+e+`, got: `+t.length);if(n&&!poe(t))throw Error(`invalid output, must be aligned`);return t}function foe(e,t,n){Us(n);let r=new Uint8Array(16),i=Es(r);return i.setBigUint64(0,js(t),n),i.setBigUint64(8,js(e),n),r}function poe(e){return e.byteOffset%4==0}var Gs=e=>Uint8Array.from(e.split(``).map(e=>e.charCodeAt(0))),moe=Gs(`expand 16-byte k`),hoe=Gs(`expand 32-byte k`),goe=ws(moe),_oe=ws(hoe);function Ks(e,t){return e<<t|e>>>32-t}function qs(e){return e.byteOffset%4==0}var Js=64,voe=16,Ys=2**32-1,Xs=Uint32Array.of();function yoe(e,t,n,r,i,a,o,s){let c=i.length,l=new Uint8Array(Js),u=ws(l),d=qs(i)&&qs(a),f=d?ws(i):Xs,p=d?ws(a):Xs;for(let m=0;m<c;o++){if(e(t,n,r,u,o,s),o>=Ys)throw Error(`arx: counter overflow`);let h=Math.min(Js,c-m);if(d&&h===Js){let e=m/4;if(m%4!=0)throw Error(`arx: invalid block position`);for(let t=0,n;t<voe;t++)n=e+t,p[n]=f[n]^u[t];m+=Js;continue}for(let e=0,t;e<h;e++)t=m+e,a[t]=i[t]^l[e];m+=h}}function boe(e,t){let{allowShortKeys:n,extendNonceFn:r,counterLength:i,counterRight:a,rounds:o}=uoe({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=`function`)throw Error(`core must be a function`);return bs(i),bs(o),Us(a),Us(n),(t,s,c,l,u=0)=>{xs(t,void 0,`key`),xs(s,void 0,`nonce`),xs(c,void 0,`data`);let d=c.length;if(l===void 0&&(l=new Uint8Array(d)),xs(l,void 0,`output`),bs(u),u<0||u>=Ys)throw Error(`arx: counter overflow`);if(l.length<d)throw Error(`arx: output (${l.length}) is shorter than data (${d})`);let f=[],p=t.length,m,h;if(p===32)f.push(m=Ns(t)),h=_oe;else if(p===16&&n)m=new Uint8Array(32),m.set(t),m.set(t,16),h=goe,f.push(m);else throw xs(t,32,`arx key`),Error(`invalid key size`);qs(s)||f.push(s=Ns(s));let g=ws(m);if(r){if(s.length!==24)throw Error(`arx: extended nonce must be 24 bytes`);r(h,g,ws(s.subarray(0,16)),g),s=s.subarray(16)}let _=16-i;if(_!==s.length)throw Error(`arx: nonce must be ${_} or 16 bytes`);if(_!==12){let e=new Uint8Array(12);e.set(s,a?0:12-s.length),s=e,f.push(s)}let v=ws(s);return yoe(e,h,g,v,c,l,u,o),Ts(...f),l}}function Zs(e,t){return e[t++]&255|(e[t++]&255)<<8}var xoe=class{constructor(e){Object.defineProperty(this,"blockLen",{enumerable:!0,configurable:!0,writable:!0,value:16}),Object.defineProperty(this,"outputLen",{enumerable:!0,configurable:!0,writable:!0,value:16}),Object.defineProperty(this,"buffer",{enumerable:!0,configurable:!0,writable:!0,value:new Uint8Array(16)}),Object.defineProperty(this,"r",{enumerable:!0,configurable:!0,writable:!0,value:new Uint16Array(10)}),Object.defineProperty(this,"h",{enumerable:!0,configurable:!0,writable:!0,value:new Uint16Array(10)}),Object.defineProperty(this,"pad",{enumerable:!0,configurable:!0,writable:!0,value:new Uint16Array(8)}),Object.defineProperty(this,"pos",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"finished",{enumerable:!0,configurable:!0,writable:!0,value:!1}),e=Ns(xs(e,32,`key`));let t=Zs(e,0),n=Zs(e,2),r=Zs(e,4),i=Zs(e,6),a=Zs(e,8),o=Zs(e,10),s=Zs(e,12),c=Zs(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|n<<3)&8191,this.r[2]=(n>>>10|r<<6)&7939,this.r[3]=(r>>>7|i<<9)&8191,this.r[4]=(i>>>4|a<<12)&255,this.r[5]=a>>>1&8190,this.r[6]=(a>>>14|o<<2)&8191,this.r[7]=(o>>>11|s<<5)&8065,this.r[8]=(s>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=Zs(e,16+2*t)}process(e,t,n=!1){let r=n?0:2048,{h:i,r:a}=this,o=a[0],s=a[1],c=a[2],l=a[3],u=a[4],d=a[5],f=a[6],p=a[7],m=a[8],h=a[9],g=Zs(e,t+0),_=Zs(e,t+2),v=Zs(e,t+4),y=Zs(e,t+6),b=Zs(e,t+8),x=Zs(e,t+10),S=Zs(e,t+12),C=Zs(e,t+14),w=i[0]+(g&8191),T=i[1]+((g>>>13|_<<3)&8191),E=i[2]+((_>>>10|v<<6)&8191),D=i[3]+((v>>>7|y<<9)&8191),O=i[4]+((y>>>4|b<<12)&8191),ee=i[5]+(b>>>1&8191),te=i[6]+((b>>>14|x<<2)&8191),k=i[7]+((x>>>11|S<<5)&8191),A=i[8]+((S>>>8|C<<8)&8191),ne=i[9]+(C>>>5|r),j=0,re=j+w*o+5*h*T+5*m*E+5*p*D+5*f*O;j=re>>>13,re&=8191,re+=5*d*ee+5*u*te+5*l*k+5*c*A+5*s*ne,j+=re>>>13,re&=8191;let ie=j+w*s+T*o+5*h*E+5*m*D+5*p*O;j=ie>>>13,ie&=8191,ie+=5*f*ee+5*d*te+5*u*k+5*l*A+5*c*ne,j+=ie>>>13,ie&=8191;let ae=j+w*c+T*s+E*o+5*h*D+5*m*O;j=ae>>>13,ae&=8191,ae+=5*p*ee+5*f*te+5*d*k+5*u*A+5*l*ne,j+=ae>>>13,ae&=8191;let oe=j+w*l+T*c+E*s+D*o+5*h*O;j=oe>>>13,oe&=8191,oe+=5*m*ee+5*p*te+5*f*k+5*d*A+5*u*ne,j+=oe>>>13,oe&=8191;let se=j+w*u+T*l+E*c+D*s+O*o;j=se>>>13,se&=8191,se+=5*h*ee+5*m*te+5*p*k+5*f*A+5*d*ne,j+=se>>>13,se&=8191;let ce=j+w*d+T*u+E*l+D*c+O*s;j=ce>>>13,ce&=8191,ce+=ee*o+5*h*te+5*m*k+5*p*A+5*f*ne,j+=ce>>>13,ce&=8191;let le=j+w*f+T*d+E*u+D*l+O*c;j=le>>>13,le&=8191,le+=ee*s+te*o+5*h*k+5*m*A+5*p*ne,j+=le>>>13,le&=8191;let ue=j+w*p+T*f+E*d+D*u+O*l;j=ue>>>13,ue&=8191,ue+=ee*c+te*s+k*o+5*h*A+5*m*ne,j+=ue>>>13,ue&=8191;let de=j+w*m+T*p+E*f+D*d+O*u;j=de>>>13,de&=8191,de+=ee*l+te*c+k*s+A*o+5*h*ne,j+=de>>>13,de&=8191;let fe=j+w*h+T*m+E*p+D*f+O*d;j=fe>>>13,fe&=8191,fe+=ee*u+te*l+k*c+A*s+ne*o,j+=fe>>>13,fe&=8191,j=(j<<2)+j|0,j=j+re|0,re=j&8191,j>>>=13,ie+=j,i[0]=re,i[1]=ie,i[2]=ae,i[3]=oe,i[4]=se,i[5]=ce,i[6]=le,i[7]=ue,i[8]=de,i[9]=fe}finalize(){let{h:e,pad:t}=this,n=new Uint16Array(10),r=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=r,r=e[t]>>>13,e[t]&=8191;e[0]+=r*5,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,n[0]=e[0]+5,r=n[0]>>>13,n[0]&=8191;for(let t=1;t<10;t++)n[t]=e[t]+r,r=n[t]>>>13,n[t]&=8191;n[9]-=8192;let i=(r^1)-1;for(let e=0;e<10;e++)n[e]&=i;i=~i;for(let t=0;t<10;t++)e[t]=e[t]&i|n[t];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let a=e[0]+t[0];e[0]=a&65535;for(let n=1;n<8;n++)a=(e[n]+t[n]|0)+(a>>>16)|0,e[n]=a&65535;Ts(n)}update(e){Ss(this),xs(e),e=Ns(e);let{buffer:t,blockLen:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(n-this.pos,r-i);if(a===n){for(;n<=r-i;i+=n)this.process(e,i);continue}t.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===n&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){Ts(this.h,this.r,this.buffer,this.pad)}digestInto(e){Ss(this),Cs(e,this),this.finished=!0;let{buffer:t,h:n}=this,{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let i=0;for(let t=0;t<8;t++)e[i++]=n[t]>>>0,e[i++]=n[t]>>>8;return e}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}};function Soe(e){let t=(t,n)=>e(n).update(t).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}var Coe=Soe(e=>new xoe(e));function woe(e,t,n,r,i,a=20){let o=e[0],s=e[1],c=e[2],l=e[3],u=t[0],d=t[1],f=t[2],p=t[3],m=t[4],h=t[5],g=t[6],_=t[7],v=i,y=n[0],b=n[1],x=n[2],S=o,C=s,w=c,T=l,E=u,D=d,O=f,ee=p,te=m,k=h,A=g,ne=_,j=v,re=y,ie=b,ae=x;for(let e=0;e<a;e+=2)S=S+E|0,j=Ks(j^S,16),te=te+j|0,E=Ks(E^te,12),S=S+E|0,j=Ks(j^S,8),te=te+j|0,E=Ks(E^te,7),C=C+D|0,re=Ks(re^C,16),k=k+re|0,D=Ks(D^k,12),C=C+D|0,re=Ks(re^C,8),k=k+re|0,D=Ks(D^k,7),w=w+O|0,ie=Ks(ie^w,16),A=A+ie|0,O=Ks(O^A,12),w=w+O|0,ie=Ks(ie^w,8),A=A+ie|0,O=Ks(O^A,7),T=T+ee|0,ae=Ks(ae^T,16),ne=ne+ae|0,ee=Ks(ee^ne,12),T=T+ee|0,ae=Ks(ae^T,8),ne=ne+ae|0,ee=Ks(ee^ne,7),S=S+D|0,ae=Ks(ae^S,16),A=A+ae|0,D=Ks(D^A,12),S=S+D|0,ae=Ks(ae^S,8),A=A+ae|0,D=Ks(D^A,7),C=C+O|0,j=Ks(j^C,16),ne=ne+j|0,O=Ks(O^ne,12),C=C+O|0,j=Ks(j^C,8),ne=ne+j|0,O=Ks(O^ne,7),w=w+ee|0,re=Ks(re^w,16),te=te+re|0,ee=Ks(ee^te,12),w=w+ee|0,re=Ks(re^w,8),te=te+re|0,ee=Ks(ee^te,7),T=T+E|0,ie=Ks(ie^T,16),k=k+ie|0,E=Ks(E^k,12),T=T+E|0,ie=Ks(ie^T,8),k=k+ie|0,E=Ks(E^k,7);let oe=0;r[oe++]=o+S|0,r[oe++]=s+C|0,r[oe++]=c+w|0,r[oe++]=l+T|0,r[oe++]=u+E|0,r[oe++]=d+D|0,r[oe++]=f+O|0,r[oe++]=p+ee|0,r[oe++]=m+te|0,r[oe++]=h+k|0,r[oe++]=g+A|0,r[oe++]=_+ne|0,r[oe++]=v+j|0,r[oe++]=y+re|0,r[oe++]=b+ie|0,r[oe++]=x+ae|0}var Toe=boe(woe,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Eoe=new Uint8Array(16),Qs=(e,t)=>{e.update(t);let n=t.length%16;n&&e.update(Eoe.subarray(n))},Doe=new Uint8Array(32);function $s(e,t,n,r,i){i!==void 0&&xs(i,void 0,`AAD`);let a=e(t,n,Doe),o=foe(r.length,i?i.length:0,!0),s=Coe.create(a);i&&Qs(s,i),Qs(s,r),s.update(o);let c=s.digest();return Ts(a,o),c}var ec=loe({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,n,r)=>({encrypt(i,a){let o=i.length;a=Ws(o+16,a,!1),a.set(i);let s=a.subarray(0,-16);e(t,n,s,s,1);let c=$s(e,t,n,s,r);return a.set(c,o),Ts(c),a},decrypt(i,a){a=Ws(i.length-16,a,!1);let o=i.subarray(0,-16),s=i.subarray(-16),c=$s(e,t,n,o,r);if(!doe(s,c))throw Error(`invalid tag`);return a.set(i.subarray(0,-16)),e(t,n,a,a,1),Ts(c),a}}))(Toe)),Ooe=class{constructor(e){Object.defineProperty(this,"_key",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._key=new Uint8Array(ps(e))}async seal(e,t,n){return await this._seal(ps(e),ps(t),ps(n))}async open(e,t,n){return await this._open(ps(e),ps(t),ps(n))}_seal(e,t,n){return new Promise(r=>{r(ec(this._key,new Uint8Array(e),new Uint8Array(n)).encrypt(new Uint8Array(t)).buffer)})}_open(e,t,n){return new Promise(r=>{r(ec(this._key,new Uint8Array(e),new Uint8Array(n)).decrypt(new Uint8Array(t)).buffer)})}},koe=class{constructor(){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:os.Chacha20Poly1305}),Object.defineProperty(this,"keySize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"nonceSize",{enumerable:!0,configurable:!0,writable:!0,value:12}),Object.defineProperty(this,"tagSize",{enumerable:!0,configurable:!0,writable:!0,value:16})}createEncryptionContext(e){return new Ooe(e)}};function tc(){return new Promise((e,t)=>{t(new ts(`Not supported`))})}var Aoe=new Uint8Array([115,101,99]),nc=class{constructor(e,t,n){Object.defineProperty(this,"_api",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"exporterSecret",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_kdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._api=e,this._kdf=t,this.exporterSecret=n}async seal(e,t){return await tc()}async open(e,t){return await tc()}async export(e,t){let n=ps(e);if(n.byteLength>8192)throw new Qo(`Too long exporter context`);try{return await this._kdf.labeledExpand(this.exporterSecret,Aoe,new Uint8Array(n),t)}catch(e){throw new vae(e)}}},joe=class extends nc{},Moe=class extends nc{constructor(e,t,n,r){super(e,t,n),Object.defineProperty(this,"enc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.enc=r}},rc=class extends nc{constructor(e,t,n){if(super(e,t,n.exporterSecret),Object.defineProperty(this,"_aead",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nK",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nN",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nT",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_ctx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n.key===void 0||n.baseNonce===void 0||n.seq===void 0)throw Error(`Required parameters are missing`);this._aead=n.aead,this._nK=this._aead.keySize,this._nN=this._aead.nonceSize,this._nT=this._aead.tagSize;let r=this._aead.createEncryptionContext(n.key);this._ctx={key:r,baseNonce:n.baseNonce,seq:n.seq}}computeNonce(e){let t=hs(e.seq,e.baseNonce.byteLength);return Aae(e.baseNonce,t).buffer}incrementSeq(e){if(e.seq>2**53-1)throw new xae(`Message limit reached`);e.seq+=1}},Noe=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Poe=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},ic,ac=class{constructor(){ic.set(this,Promise.resolve())}async lock(){let e,t=new Promise(t=>{e=t}),n=Noe(this,ic,`f`);return Poe(this,ic,t,`f`),await n,e}};ic=new WeakMap;var oc=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Foe=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},sc,Ioe=class extends rc{constructor(){super(...arguments),sc.set(this,void 0)}async open(e,t=ss.buffer){Foe(this,sc,oc(this,sc,`f`)??new ac,`f`);let n=await oc(this,sc,`f`).lock(),r;try{r=await this._ctx.key.open(this.computeNonce(this._ctx),ps(e),ps(t))}catch(e){throw new bae(e)}finally{n()}return this.incrementSeq(this._ctx),r}};sc=new WeakMap;var cc=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Loe=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},lc,Roe=class extends rc{constructor(e,t,n,r){super(e,t,n),Object.defineProperty(this,"enc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),lc.set(this,void 0),this.enc=r}async seal(e,t=ss.buffer){Loe(this,lc,cc(this,lc,`f`)??new ac,`f`);let n=await cc(this,lc,`f`).lock(),r;try{r=await this._ctx.key.seal(this.computeNonce(this._ctx),ps(e),ps(t))}catch(e){throw new yae(e)}finally{n()}return this.incrementSeq(this._ctx),r}};lc=new WeakMap;var zoe=new Uint8Array([98,97,115,101,95,110,111,110,99,101]),Boe=new Uint8Array([101,120,112]),Voe=new Uint8Array([105,110,102,111,95,104,97,115,104]),Hoe=new Uint8Array([107,101,121]),Uoe=new Uint8Array([112,115,107,95,105,100,95,104,97,115,104]),Woe=new Uint8Array([115,101,99,114,101,116]),Goe=new Uint8Array([72,80,75,69,0,0,0,0,0,0]),Koe=class extends rs{constructor(e){if(super(),Object.defineProperty(this,"_kem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_kdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_aead",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_suiteId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),typeof e.kem==`number`)throw new Qo(`KemId cannot be used`);if(this._kem=e.kem,typeof e.kdf==`number`)throw new Qo(`KdfId cannot be used`);if(this._kdf=e.kdf,typeof e.aead==`number`)throw new Qo(`AeadId cannot be used`);this._aead=e.aead,this._suiteId=new Uint8Array(Goe),this._suiteId.set(hs(this._kem.id,2),4),this._suiteId.set(hs(this._kdf.id,2),6),this._suiteId.set(hs(this._aead.id,2),8),this._kdf.init(this._suiteId)}get kem(){return this._kem}get kdf(){return this._kdf}get aead(){return this._aead}async createSenderContext(e){this._validateInputLength(e),await this._setup();let t=await this._kem.encap(e),n;return n=e.psk===void 0?e.senderKey===void 0?is.Base:is.Auth:e.senderKey===void 0?is.Psk:is.AuthPsk,await this._keyScheduleS(n,t.sharedSecret,t.enc,e)}async createRecipientContext(e){this._validateInputLength(e),await this._setup();let t=await this._kem.decap(e),n;return n=e.psk===void 0?e.senderPublicKey===void 0?is.Base:is.Auth:e.senderPublicKey===void 0?is.Psk:is.AuthPsk,await this._keyScheduleR(n,t,e)}async seal(e,t,n=ss.buffer){let r=await this.createSenderContext(e);return{ct:await r.seal(t,n),enc:r.enc}}async open(e,t,n=ss.buffer){return await(await this.createRecipientContext(e)).open(t,n)}async _keySchedule(e,t,n){let r=n.psk===void 0?ss:fs(n.psk.id),i=await this._kdf.labeledExtract(ss,Uoe,r),a=n.info===void 0?ss:fs(n.info),o=await this._kdf.labeledExtract(ss,Voe,a),s=new Uint8Array(1+i.byteLength+o.byteLength);s.set(new Uint8Array([e]),0),s.set(new Uint8Array(i),1),s.set(new Uint8Array(o),1+i.byteLength);let c=n.psk===void 0?ss:fs(n.psk.key),l=this._kdf.buildLabeledIkm(Woe,c),u=this._kdf.buildLabeledInfo(Boe,s,this._kdf.hashSize),d=await this._kdf.extractAndExpand(t,l,u,this._kdf.hashSize);if(this._aead.id===os.ExportOnly)return{aead:this._aead,exporterSecret:d};let f=this._kdf.buildLabeledInfo(Hoe,s,this._aead.keySize),p=await this._kdf.extractAndExpand(t,l,f,this._aead.keySize),m=this._kdf.buildLabeledInfo(zoe,s,this._aead.nonceSize),h=await this._kdf.extractAndExpand(t,l,m,this._aead.nonceSize);return{aead:this._aead,exporterSecret:d,key:p,baseNonce:new Uint8Array(h),seq:0}}async _keyScheduleS(e,t,n,r){let i=await this._keySchedule(e,t,r);return i.key===void 0?new Moe(this._api,this._kdf,i.exporterSecret,n):new Roe(this._api,this._kdf,i,n)}async _keyScheduleR(e,t,n){let r=await this._keySchedule(e,t,n);return r.key===void 0?new joe(this._api,this._kdf,r.exporterSecret):new Ioe(this._api,this._kdf,r)}_validateInputLength(e){if(e.info!==void 0&&e.info.byteLength>268435456)throw new Qo(`Too long info`);if(e.psk!==void 0){if(e.psk.key.byteLength<32)throw new Qo(`PSK must have at least 32 bytes`);if(e.psk.key.byteLength>8192)throw new Qo(`Too long psk.key`);if(e.psk.id.byteLength>8192)throw new Qo(`Too long psk.id`)}}},qoe=class extends Koe{},Joe=1n,uc=2n,Yoe=3n,Xoe=5n,dc=57896044618658097711785492504343953926634992332820282019728792003956564819949n;function Zoe(e){let t=10n,n=80n,r=dc,i=e*e%r*e%r,a=Hs(Hs(i,uc,r)*i%r,Joe,r)*e%r,o=Hs(a,Xoe,r)*a%r,s=Hs(o,t,r)*o%r,c=Hs(s,20n,r)*s%r,l=Hs(c,40n,r)*c%r;return{pow_p_5_8:Hs(Hs(Hs(Hs(l,n,r)*l%r,n,r)*l%r,t,r)*o%r,uc,r)*e%r,b2:i}}function Qoe(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var $oe=(()=>{let e=dc;return coe({P:e,type:`x25519`,powPminus2:t=>{let{pow_p_5_8:n,b2:r}=Zoe(t);return Vs(Hs(n,Yoe,e)*r,e)},adjustScalarBytes:Qoe})})(),ese=class extends Lae{constructor(e){super(`X25519`,32,$oe,e)}derive(e,t){try{return Promise.resolve(this._curve.getSharedSecret(e,t))}catch(e){return Promise.reject(new $o(e))}}},fc=`DHKEM_X25519_HKDF_SHA256/HKDF_SHA256/CHACHA20_POLY1305/AUTH`,tse=2**31,nse=65536,rse=16,pc=32,mc=(1n<<255n)-19n,hc=new TextEncoder,gc=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`;function _c(e){let t=0n;for(let n=0;n<e.length;n+=2)t|=BigInt(Number.parseInt(e.slice(n,n+2),16))<<BigInt(n/2*8);return t}var ise=new Set([0n,1n,_c(`e0eb7a7c3b41b8ae1656e3faf19fc46ada098deb9c32b1fd866205165f49b800`),_c(`5f9c95bca3508c24b1d0b1559c83ef5b04445cc4581c8e86d8224eddd09f1157`),mc-1n]),ase=new Uint8Array,vc=class extends Oae{async extract(e,t){return ps(Ls(Bs,e.byteLength===0?new Uint8Array(this.hashSize):fs(e),fs(t)))}async expand(e,t,n){if(!Number.isSafeInteger(n)||n<0||n>255*this.hashSize)throw Error(`HKDF output length exceeds the RFC 5869 limit.`);let r=fs(e),i=fs(t),a=new Uint8Array(n),o=ase;for(let e=1,t=0;t<a.byteLength;e+=1){let n=Sc([o,i,Uint8Array.of(e)]);o=new Uint8Array(Ls(Bs,r,n));let s=a.byteLength-t;a.set(o.subarray(0,Math.min(o.byteLength,s)),t),t+=Math.min(o.byteLength,s)}return ps(a)}async extractAndExpand(e,t,n,r){return this.expand(await this.extract(e,t),n,r)}},yc=new qoe({kem:new class extends Pae{secretSize=32;encSize=32;publicKeySize=32;privateKeySize=32;constructor(e){super(Tae.DhkemX25519HkdfSha256,new ese(e),e)}}(new vc),kdf:new vc,aead:new koe}),bc=class extends Error{code;name=`RelayPayloadChannelFailure`;constructor(e,t){super(t),this.code=e}};function xc(e){return new Uint8Array(e.slice(0))}function ose(e){let t=new Uint8Array(e.byteLength);return t.set(e),t.buffer}function Sc(e){let t=e.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}function Cc(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new bc(`channel_ticket_binding_invalid`,`Invalid uint32 value.`);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!1),t}function wc(e){if(!Number.isSafeInteger(e)||e<0)throw new bc(`channel_ticket_binding_invalid`,`Invalid uint64 value.`);let t=new Uint8Array(8);return new DataView(t.buffer).setBigUint64(0,BigInt(e),!1),t}function sse(e){return Sc([Cc(e.byteLength),e])}function Tc(e){return Uint8Array.of(e===`control-to-runtime`?0:1)}function cse(e){return e===`handshake`?Uint8Array.of(0):e===`application`?Uint8Array.of(1):Uint8Array.of(2)}function Ec(e){let t=``;for(let n=0;n<e.byteLength;n+=3){let r=e[n]??0,i=e[n+1]??0,a=e[n+2]??0,o=r<<16|i<<8|a;t+=gc[o>>>18&63],t+=gc[o>>>12&63],n+1<e.byteLength&&(t+=gc[o>>>6&63]),n+2<e.byteLength&&(t+=gc[o&63])}return t}function Dc(e){if(!/^[A-Za-z0-9_-]*$/.test(e)||e.length%4==1)throw new bc(`channel_authentication_failed`,`Encrypted relay frame is not canonical base64url.`);let t=new Uint8Array(Math.floor(e.length*6/8)),n=0,r=0,i=0;for(let a of e){let e=gc.indexOf(a);n=n<<6|e,r+=6,r>=8&&(r-=8,t[i]=n>>>r&255,i+=1)}if(Ec(t)!==e)throw new bc(`channel_authentication_failed`,`Encrypted relay frame has a non-canonical base64url encoding.`);return t}function lse(e){let t=new Uint8Array(e);t[31]=(t[31]??0)&127;let n=0n;for(let e=0;e<t.byteLength;e+=1)n|=BigInt(t[e]??0)<<BigInt(e*8);return ise.has(n%mc)}var use={async sha256(e){if(globalThis.crypto?.subtle===void 0)throw new bc(`channel_authentication_failed`,`SHA-256 is unavailable in this runtime.`);return xc(await globalThis.crypto.subtle.digest(`SHA-256`,ose(e)))}},Oc={randomBytes(e){if(globalThis.crypto?.getRandomValues===void 0)throw new bc(`endpoint_key_invalid`,`A cryptographically secure random source is unavailable.`);return globalThis.crypto.getRandomValues(new Uint8Array(e))}};function kc(e,t){let n=hc.encode(e).byteLength;if(n===0||n>256)throw new bc(`channel_ticket_binding_invalid`,`${t} must contain between 1 and 256 UTF-8 bytes.`)}function dse(e){let t=hc.encode(e).byteLength;if(t===0||t>65536)throw new bc(`channel_ticket_binding_invalid`,`Control ticket must contain between 1 and ${nse} UTF-8 bytes.`)}async function Ac(e,t=use){dse(e.exactCompactTicket),kc(e.channelId,`Channel ID`),kc(e.runtimeId,`Runtime ID`),wc(e.connectionEpoch);let n=await t.sha256(hc.encode(e.exactCompactTicket));if(n.byteLength!==32)throw new bc(`channel_ticket_binding_invalid`,`The control ticket digest must be 32 bytes.`);return{...e,ticketDigest:new Uint8Array(n)}}function fse(e){return Ec(e.ticketDigest)}async function pse(e=Oc){let t=new Uint8Array(await e.randomBytes(pc));if(t.byteLength!==pc)throw new bc(`endpoint_key_invalid`,`The endpoint random source must return ${pc} bytes.`);try{return Ec(t)}finally{t.fill(0)}}function jc(e){return Sc([hc.encode(`forge-relay-v4`),Uint8Array.of(0),e.ticketDigest,Tc(e.direction)])}function Mc(e){return Sc([hc.encode(`forge-relay`),Cc(4),e.binding.ticketDigest,hc.encode(e.binding.channelId),Tc(e.binding.direction),cse(e.frameClass),wc(e.sequence),hc.encode(e.binding.runtimeId),wc(e.binding.connectionEpoch),Cc(e.ciphertextLength)].map(sse))}async function mse(e=Oc){let t=new Uint8Array(await e.randomBytes(pc));if(t.byteLength!==pc)throw new bc(`endpoint_key_invalid`,`The endpoint random source must return ${pc} bytes.`);try{return await yc.kem.deriveKeyPair(t)}catch(e){throw new bc(`endpoint_key_invalid`,e instanceof Error?e.message:`Endpoint key generation failed.`)}finally{t.fill(0)}}async function Nc(e){try{return Ec(xc(await yc.kem.serializePublicKey(e)))}catch(e){throw new bc(`endpoint_key_invalid`,e instanceof Error?e.message:`Endpoint public-key serialization failed.`)}}function hse(e,t){if(!/^[A-Za-z0-9_-]{43}$/u.test(t))throw new bc(`endpoint_key_invalid`,`The endpoint key ID requires a canonical X25519 public key.`);return`${e}:${t}`}async function gse(e){try{let t=Dc(e);if(t.byteLength!==pc)throw Error(`Invalid endpoint key length.`);if(lse(t))throw new bc(`endpoint_key_invalid`,`Low-order X25519 endpoint public keys are not allowed.`);return await yc.kem.deserializePublicKey(t)}catch(e){throw e instanceof bc?e:new bc(`endpoint_key_invalid`,e instanceof Error?e.message:`Endpoint public-key deserialization failed.`)}}var Pc=class{tail=Promise.resolve();run(e){let t=this.tail.then(e,e);return this.tail=t.then(()=>void 0,()=>void 0),t}},Fc=class{startedAt=Date.now();records=0;bytes=0;assertAvailable(e){if(this.records>=tse||this.bytes+e>1073741824||Date.now()-this.startedAt>=18e5)throw new bc(`channel_limit_reached`,`The encrypted relay channel must be renewed before another record is sent.`)}commit(e){this.records+=1,this.bytes+=e}};function _se(e,t){if(e.type!==`relay.encrypted-frame`||e.protocolVersion!==4||e.channelId!==t.channelId||e.direction!==t.direction||![`handshake`,`application`,`close`].includes(e.frameClass))throw new bc(`channel_ticket_binding_invalid`,`Encrypted relay frame does not match the CMMD-ticket-bound channel.`)}var vse=class{binding;context;encapsulatedKey;queue=new Pc;budget=new Fc;sequence=0;constructor(e,t){this.binding=e,this.context=t,this.encapsulatedKey=Ec(xc(t.enc))}seal(e){return this.queue.run(async()=>{if(e.plaintext.byteLength>16777216)throw new bc(`channel_limit_reached`,`Encrypted relay plaintext exceeds the per-record byte limit.`);let t=e.plaintext.byteLength+rse;this.budget.assertAvailable(t);let n=this.sequence,r=Mc({binding:this.binding,frameClass:e.frameClass,sequence:n,ciphertextLength:t}),i;try{i=xc(await this.context.seal(e.plaintext,r))}catch(e){throw new bc(`channel_authentication_failed`,e instanceof Error?e.message:`Relay payload encryption failed.`)}if(i.byteLength!==t)throw new bc(`channel_authentication_failed`,`Relay payload encryption returned an invalid ciphertext length.`);return this.sequence+=1,this.budget.commit(i.byteLength),{type:`relay.encrypted-frame`,protocolVersion:4,channelId:this.binding.channelId,direction:this.binding.direction,frameClass:e.frameClass,sequence:n,ciphertext:Ec(i)}})}},yse=class{binding;context;queue=new Pc;budget=new Fc;sequence=0;constructor(e,t){this.binding=e,this.context=t}open(e){return this.queue.run(async()=>{if(_se(e,this.binding),!Number.isSafeInteger(e.sequence)||e.sequence!==this.sequence)throw new bc(`channel_sequence_invalid`,`Expected encrypted relay sequence ${this.sequence}, received ${String(e.sequence)}.`);let t=Dc(e.ciphertext);this.budget.assertAvailable(t.byteLength);let n=Mc({binding:this.binding,frameClass:e.frameClass,sequence:e.sequence,ciphertextLength:t.byteLength}),r;try{r=xc(await this.context.open(t,n))}catch(e){throw new bc(`channel_authentication_failed`,e instanceof Error?e.message:`Relay payload authentication failed.`)}if(r.byteLength>16777216)throw new bc(`channel_limit_reached`,`Decrypted relay plaintext exceeds the per-record byte limit.`);return this.sequence+=1,this.budget.commit(t.byteLength),r})}};async function bse(e){let t=null;try{if(t=new Uint8Array(await(e.randomSource??Oc).randomBytes(pc)),t.byteLength!==pc)throw Error(`The endpoint random source must return ${pc} bytes.`);let n=await yc.createSenderContext({recipientPublicKey:e.recipientPublicKey,senderKey:e.senderKey,info:jc(e.binding),ekm:t});return new vse(e.binding,n)}catch(e){throw new bc(`channel_authentication_failed`,e instanceof Error?e.message:`Relay payload sender setup failed.`)}finally{t?.fill(0)}}async function xse(e){try{let t=await yc.createRecipientContext({recipientKey:e.recipientKey,senderPublicKey:e.senderPublicKey,enc:Dc(e.encapsulatedKey),info:jc(e.binding)});return new yse(e.binding,t)}catch(e){throw e instanceof bc?e:new bc(`channel_authentication_failed`,e instanceof Error?e.message:`Relay payload recipient setup failed.`)}}var Sse=128,Cse=2097152,wse=864e5,Ic=class extends Error{constructor(e){super(e),this.name=`RelayControlJournalError`}};function Lc(e){return typeof e==`string`&&e.length>0}function Rc(e){return Lc(e)&&Number.isFinite(Date.parse(e))}function Tse(e){return e===`pending`||e===`retrying`||e===`outcome-unknown`||e===`failed`}function Ese(e){return Lc(e.transportRequestId)&&Lc(e.runtimeId)&&Lc(e.actorSessionId)&&Lc(e.durableRequestId)&&Lc(e.method)}function Dse(e){return Number.isSafeInteger(e.sequence)&&Number(e.sequence)>0&&Number.isSafeInteger(e.attemptCount)&&Number(e.attemptCount)>=0}function Ose(e){return e.persistence!==`frame`&&e.persistence!==`metadata-only`||e.frame!==null&&!Lc(e.frame)?!1:e.persistence!==`metadata-only`||e.frame===null}function kse(e){return!Tse(e.status)||e.errorCode!==null&&!Lc(e.errorCode)?!1:e.status===`outcome-unknown`||e.status===`failed`?e.frame===null&&Lc(e.errorCode):e.errorCode===null}function Ase(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return Ese(t)&&Dse(t)&&Ose(t)&&kse(t)&&Rc(t.createdAt)&&Rc(t.updatedAt)}function jse(e){try{return JSON.parse(e)}catch{throw new Ic(`Forge relay control journal is corrupt.`)}}function Mse(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return t.version===1&&Lc(t.controlSessionId)&&Number.isSafeInteger(t.nextSequence)&&Number(t.nextSequence)>=1&&Array.isArray(t.records)&&t.records.every(Ase)}function Nse(e){let t=new Set(e.map(zc)),n=new Set(e.map(e=>e.durableRequestId)),r=new Set(e.map(e=>e.sequence));return t.size===e.length&&n.size===e.length&&r.size===e.length}function Pse(e){let t=jse(e);if(!Mse(t))throw new Ic(`Forge relay control journal is corrupt.`);let n=t.records,r=n.reduce((e,t)=>Math.max(e,t.sequence),0);if(!Nse(n)||t.nextSequence<=r)throw new Ic(`Forge relay control journal is corrupt.`);return{version:1,controlSessionId:t.controlSessionId,nextSequence:t.nextSequence,records:n}}function Fse(){return crypto.randomUUID()}function zc(e){return`${e.runtimeId}\0${e.actorSessionId}\0${e.transportRequestId}`}var Bc={pending:1,retrying:2,"outcome-unknown":3,failed:4};function Ise(e,t){let n=e.filter(e=>e.runtimeId===t);if(n.length===0)return{state:`idle`,count:0};let r=n.reduce((e,t)=>Bc[t.status]>Bc[e]?t.status:e,`pending`);return{state:r,count:n.filter(e=>e.status===r).length}}function Vc(e){let t=e.randomUUID??Fse,n=e.now??(()=>new Date),r=e.maxRecords??Sse,i=e.maxBytes??Cse,a=e.maxReplayAgeMs??wse;if(r<1||i<1||a<1)throw new Ic(`Forge relay control journal limits must be positive.`);let o=e.storage.read(),s=n(),c=o?Pse(o):{version:1,controlSessionId:t(),nextSequence:1,records:[]},l=new Map,u=new Set;function d(){return{controlSessionId:c.controlSessionId,records:[...c.records]}}function f(t){if(t.records.length>r)throw new Ic(`Forge relay control journal reached its record limit.`);let n=JSON.stringify(t);if(new TextEncoder().encode(n).byteLength>i)throw new Ic(`Forge relay control journal reached its storage limit.`);e.storage.write(n),c=t;let a=d();for(let e of u)e(a)}function p(e,t){return e.status!==`pending`&&e.status!==`retrying`?e:e.persistence===`metadata-only`||e.frame===null?{...e,frame:null,status:`outcome-unknown`,errorCode:`RELAY_COMMAND_OUTCOME_UNKNOWN`,updatedAt:t.toISOString()}:t.getTime()-Date.parse(e.createdAt)>a?{...e,frame:null,status:`outcome-unknown`,errorCode:`RELAY_RECOVERY_EXPIRED`,updatedAt:t.toISOString()}:e}let m=c.records.map(e=>p(e,s)),h=m.some((e,t)=>e!==c.records[t]);(o===null||h)&&f({...c,records:m});function g(e){let t=zc(e);return{key:t,existing:c.records.find(e=>zc(e)===t)??null}}function _(e,t,n){if([e.method===t.method,e.persistence===t.persistence,n===void 0||n===t.frame,e.frame===null||e.frame===t.frame,t.durableRequestId===void 0||e.durableRequestId===t.durableRequestId].includes(!1))throw new Ic(`Relay transport request ${t.transportRequestId} was reused with different content.`);if(e.status===`failed`||e.status===`outcome-unknown`)throw new Ic(`Relay transport request ${t.transportRequestId} requires an explicit outcome acknowledgement.`)}function v(e){if(e.durableRequestId!==void 0&&c.records.some(t=>t.durableRequestId===e.durableRequestId))throw new Ic(`Relay durable request ${e.durableRequestId} was reused by another transport request.`)}function y(e){let r=n().toISOString();return{runtimeId:e.runtimeId,actorSessionId:e.actorSessionId,transportRequestId:e.transportRequestId,durableRequestId:e.durableRequestId??t(),sequence:c.nextSequence,method:e.method,persistence:e.persistence,frame:e.persistence===`frame`?e.frame:null,status:`pending`,attemptCount:0,errorCode:null,createdAt:r,updatedAt:r}}function b(e){let{key:t,existing:n}=g(e);if(n!==null)return _(n,e,l.get(t)),l.set(t,e.frame),n;v(e);let r=y(e);return l.set(t,e.frame),f({...c,nextSequence:c.nextSequence+1,records:[...c.records,r]}),r}function x(e,t,n){let r=c.records.find(r=>r.runtimeId===e&&r.actorSessionId===t&&r.transportRequestId===n);if(!r)throw new Ic(`Relay transport request ${n} is not journaled.`);return r}function S(e,t,r,i){x(e,t,r);let a=n().toISOString();l.delete(zc({runtimeId:e,actorSessionId:t,transportRequestId:r})),f({...c,records:c.records.map(n=>n.runtimeId===e&&n.actorSessionId===t&&n.transportRequestId===r?{...n,frame:null,status:`failed`,errorCode:i,updatedAt:a}:n)})}function C(e,t,r){let i=x(e,t,r);if(i.status===`failed`||i.status===`outcome-unknown`)throw new Ic(`Relay transport request ${r} has no replayable outcome.`);let a={...i,status:i.attemptCount>0?`retrying`:`pending`,attemptCount:i.attemptCount+1,errorCode:null,updatedAt:n().toISOString()};return f({...c,records:c.records.map(n=>n.runtimeId===e&&n.actorSessionId===t&&n.transportRequestId===r?a:n)}),a}function w(e,t,n){let r=c.records.filter(r=>r.runtimeId!==e||r.actorSessionId!==t||r.transportRequestId!==n);r.length!==c.records.length&&(l.delete(zc({runtimeId:e,actorSessionId:t,transportRequestId:n})),f({...c,records:r}))}function T(e,t,n){let r=x(e,t,n);if(r.status!==`failed`&&r.status!==`outcome-unknown`)throw new Ic(`Relay transport request ${n} does not have an acknowledgeable outcome.`);w(e,t,n)}function E(){let e=n(),t=c.records.map(t=>p(t,e));t.some((e,t)=>e!==c.records[t])&&f({...c,records:t})}function D(e,t){let r=n().toISOString(),i=c.records.map(n=>n.runtimeId!==e||n.actorSessionId===t||n.status!==`pending`&&n.status!==`retrying`?n:(l.delete(zc(n)),{...n,frame:null,status:`outcome-unknown`,errorCode:`RELAY_ACTOR_SESSION_CHANGED`,updatedAt:r}));i.some((e,t)=>e!==c.records[t])&&f({...c,records:i})}return{controlSessionId:c.controlSessionId,prepare:b,records:()=>[...c.records],pending:()=>[...c.records],replayable:(e,t)=>(E(),c.records.filter(n=>n.runtimeId===e&&n.actorSessionId===t&&n.persistence===`frame`&&n.frame!==null&&(n.status===`pending`||n.status===`retrying`))),fenceActor:D,beginAttempt:C,markFailed:S,complete:w,acknowledge:T,subscribe:e=>(u.add(e),e(d()),()=>u.delete(e))}}function Lse(e=null){let t=e;return{read:()=>t,write:e=>{t=e}}}var Rse=tn(rne),zse=ir(tne),Bse=ir(er),Vse=[`rpc.read`,`rpc.mutate`,`cursor.resume`,`terminal.stream`,`browser.stream`,`bulk.transfer`,`envelope.validation`,`payload.e2e`];function Hc(e,t){if(!Array.isArray(e))return null;for(let n of e)if(Array.isArray(n)&&n.length===2&&n[0]===t&&typeof n[1]==`string`)return n[1];return null}function Uc(e,t){let n=JSON.parse(e),r=sae(n);if(r!==null)return{messageType:`request`,...r};let i=Hse(n,t);if(i!==null)return i;let a=Use(n);if(a!==null)return a;throw Error(`Forge relay protocol v2 requires a recognized Effect RPC frame.`)}function Hse(e,t){if(e._tag!==`Request`||typeof e.id!=`string`||e.id.length===0||typeof e.tag!=`string`||e.tag.length===0)return null;let n=Xo({method:e.tag,payload:e.payload,grantedScopes:t});return{messageType:`request`,requestId:e.id,correlationId:Hc(e.headers,An.requestId)??e.id,method:e.tag,...n}}function Use(e){return e._tag!==`Ack`&&e._tag!==`Interrupt`||typeof e.requestId!=`string`||e.requestId.length===0?null:{messageType:`acknowledgement`,requestId:e.requestId,correlationId:e.requestId,method:`@effect/rpc/${e._tag}`,requiredScope:null,deliveryClass:`read`,journalPersistence:`none`}}function Wc(e,t){let n=new Event(`error`);return Object.defineProperties(n,{error:{value:Error(t),enumerable:!0},message:{value:`${e}: ${t}`,enumerable:!0}}),n}var Wse=new Set([`network`,`server`,`auth`,`permission`,`client`]),Gse=new Set([`network`,`server`]);function Kse(e){return e&&typeof e==`object`?e:{}}function qse(e){return typeof e.code==`string`&&e.code.length>0?e.code:typeof e.kind==`string`&&Wse.has(e.kind)?`RELAY_ACTION_GRANT_UNAVAILABLE`:`MALFORMED_FRAME`}function Jse(e){if(e.retryable===!0||typeof e.kind==`string`&&Gse.has(e.kind))return!0;let t=typeof e.status==`number`?e.status:null;return t===429||t!==null&&t>=500}function Gc(e){let t=Kse(e);return{code:qse(t),message:e instanceof Error?e.message:`Forge relay frame encoding failed.`,retryable:Jse(t)}}function Kc(e,t){let n=new Event(e.type),r=e;for(let e of t)r[e]!==void 0&&Object.defineProperty(n,e,{value:r[e],enumerable:!0});return n}function Yse(e){return!Array.isArray(e)||e.length!==2||typeof e[0]!=`string`?!1:Object.values(An).includes(e[0])}function qc(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Xse(e){if(!Array.isArray(e))return null;for(let t of e){let e=qc(t);if(e?._tag!==`Fail`)continue;let n=qc(e.error)?.code;if(typeof n==`string`&&n.length>0)return n}return null}function Zse(e){let t=qc(e.exit);return t===null?`RELAY_RPC_RESPONSE_INVALID`:t._tag===`Success`?null:t._tag!==`Failure`||!Array.isArray(t.cause)?`RELAY_RPC_RESPONSE_INVALID`:Xse(t.cause)??`RELAY_RPC_FAILED`}function Jc(e){if(typeof e!=`string`)return null;try{let t=Rse(JSON.parse(e));return t._tag===`Some`?t.value:null}catch{return null}}function Qse(e,t){if(e.role===`control`&&e.protocolVersion===t&&e.protocolVersion>=1){if(e.protocolVersion===1)return null;if(e.actor!==void 0&&e.scopes!==void 0)return{runtimeId:e.runtimeId,connectionEpoch:e.connectionEpoch,protocolVersion:e.protocolVersion,actor:e.actor,scopes:e.scopes}}}function Yc(e,t,n){if(typeof e==`string`)try{let r=qc(JSON.parse(e));if(r?._tag!==`Exit`||typeof r.requestId!=`string`)return;let i=Zse(r);if(i===null){n.complete(t.runtimeId,t.actor.sessionId,r.requestId);return}n.markFailed(t.runtimeId,t.actor.sessionId,r.requestId,i)}catch{}}function $se(e){let t=Hc(e,An.sequence);if(t===null)return;let n=Number(t);return Number.isSafeInteger(n)&&n>=0?n:void 0}function ece(e){return{issuedAt:Hc(e,An.issuedAt)??new Date().toISOString(),expiresAt:Hc(e,An.expiresAt)??new Date(Date.now()+12e4).toISOString()}}function tce(e){if(e!==2&&e!==3&&e!==4)throw new qo(`protocol_version_mismatch`,`Unsupported Forge relay envelope version: ${e}`,!1);return e}async function nce(e){let t=hae({method:e.identity.method,payload:e.payload});if(t===null)return;let n=rce(e.context);if(e.acquire===void 0)throw new qo(`action_grant_required`,`CMMD action-grant issuance is unavailable for this remote response.`,!1);return e.acquire({...n,method:`orchestration.dispatchCommand`,...t,durableRequestId:e.identity.correlationId,payloadHash:e.payloadHash,requiredScope:`approval.respond`})}function rce(e){if(e.protocolVersion===3)return{protocolVersion:3};if(e.protocolVersion!==4)throw new qo(`protocol_update_required`,`Update Forge on the target runtime before responding remotely.`,!1);return{protocolVersion:4,channelId:Xc(e.channelId),channelTicketDigest:Xc(e.channelTicketDigest),runtimeEndpointKeyId:Xc(e.runtimeEndpointKeyId),controlEndpointKeyId:Xc(e.controlEndpointKeyId)}}function Xc(e){if(typeof e==`string`&&e.length>0)return e;throw new qo(`channel_ticket_binding_invalid`,`The encrypted Forge relay channel is missing its CMMD ticket binding.`,!1)}function ice(e){return e===void 0?{}:{sequence:e}}function Zc(e){return e===void 0?{}:{actionGrant:e}}async function ace(e){let t=Uc(e.data,e.context.scopes),n=JSON.parse(e.data),r=ece(n.headers),i=$se(n.headers),a=await e.crypto.sha256Base64Url(e.data),o=await nce({context:e.context,identity:t,payload:n.payload,payloadHash:a,...e.acquireActionGrant===void 0?{}:{acquire:e.acquireActionGrant}}),s=tce(e.context.protocolVersion),c={messageType:t.messageType,requestId:t.requestId,correlationId:t.correlationId,method:t.method,requiredScope:t.requiredScope,deliveryClass:t.deliveryClass,runtimeId:e.context.runtimeId,connectionEpoch:e.context.connectionEpoch,actor:e.context.actor,...r,payloadHash:a,...ice(i)};return s===2?{protocolVersion:2,...c}:s===3?{protocolVersion:3,...c,...Zc(o)}:{protocolVersion:4,...c,...Zc(o)}}function Qc(e){return typeof e==`string`&&e.length>0}function oce(e){return[e.protocolVersion===4,Qc(e.runtimeId),Number.isSafeInteger(e.connectionEpoch),Number(e.connectionEpoch)>0,e.hpkeSuite===fc,Qc(e.channelId),Qc(e.runtimeEndpointKeyId),Qc(e.runtimeEndpointPublicKey),Qc(e.controlEndpointKeyId),Qc(e.controlEndpointPublicKey),Qc(e.controlChannelNonce),e.controlEndpointKeyPair!==void 0].every(Boolean)}function $c(e){if(!oce(e))throw new qo(`end_to_end_encryption_required`,`Forge relay protocol v4 requires complete endpoint encryption metadata.`,!1);return e}async function sce(e){if(await Nc(e.controlEndpointKeyPair.publicKey)!==e.controlEndpointPublicKey)throw new qo(`endpoint_key_invalid`,`The control endpoint private key does not match the CMMD route.`,!1);let t=await gse(e.runtimeEndpointPublicKey),[n,r]=await Promise.all([Ac({exactCompactTicket:e.token,channelId:e.channelId,direction:`control-to-runtime`,runtimeId:e.runtimeId,connectionEpoch:e.connectionEpoch},e.payloadDigestProvider),Ac({exactCompactTicket:e.token,channelId:e.channelId,direction:`runtime-to-control`,runtimeId:e.runtimeId,connectionEpoch:e.connectionEpoch},e.payloadDigestProvider)]);return{controlToRuntimeBinding:n,runtimeToControlBinding:r,sender:await bse({binding:n,senderKey:e.controlEndpointKeyPair,recipientPublicKey:t,...e.payloadRandomSource?{randomSource:e.payloadRandomSource}:{}}),runtimePublicKey:t,recipient:null,phase:`awaiting-runtime-hello`}}function el(e,t,n){return[e.direction===`runtime-to-control`,e.frameClass===n,e.channelId===t.channelId].every(Boolean)}function cce(e){return[e.confirmation.phase===e.expectedPhase,e.confirmation.channelId===e.route.channelId,e.confirmation.runtimeId===e.context.runtimeId,e.confirmation.connectionEpoch===e.context.connectionEpoch].every(Boolean)}function lce(e){let{envelope:t}=e.application;return[t.runtimeId===e.context.runtimeId,t.connectionEpoch===e.context.connectionEpoch,t.actor.userId===e.context.actor.userId,t.actor.deviceId===e.context.actor.deviceId,t.actor.sessionId===e.context.actor.sessionId,t.payloadHash===e.payloadHash].every(Boolean)}async function uce(e){if(e.channel.recipient!==null){if(e.message.encapsulatedKey!==void 0)throw new qo(`endpoint_key_invalid`,`The runtime attempted to replace its endpoint encapsulation.`,!1);return e.channel.recipient}if(e.message.sequence!==0||!e.message.encapsulatedKey)throw new qo(`channel_confirmation_failed`,`The runtime handshake omitted its endpoint encapsulation.`,!1);let t=await xse({binding:e.channel.runtimeToControlBinding,recipientKey:e.route.controlEndpointKeyPair,senderPublicKey:e.channel.runtimePublicKey,encapsulatedKey:e.message.encapsulatedKey});return e.channel.recipient=t,t}var dce=class extends EventTarget{socket;route;relayCrypto;journal;lifecycle;acquireActionGrant;CONNECTING=WebSocket.CONNECTING;OPEN=WebSocket.OPEN;CLOSING=WebSocket.CLOSING;CLOSED=WebSocket.CLOSED;binaryType=`blob`;onopen=null;onclose=null;onerror=null;onmessage=null;authenticated=!1;context=null;payloadChannel=null;sendChain=Promise.resolve();constructor(e,t,n,r,i={},a){super(),this.socket=e,this.route=t,this.relayCrypto=n,this.journal=r,this.lifecycle=i,this.acquireActionGrant=a,e.addEventListener(`open`,()=>void this.beginAuthentication()),e.addEventListener(`message`,e=>void this.handleMessageSafely(e)),e.addEventListener(`error`,e=>{let t=Kc(e,[`error`,`message`]),n=typeof t.message==`string`?String(t.message):`Forge relay connection failed.`;this.lifecycle.onError?.({code:`RELAY_SOCKET_ERROR`,message:n}),this.emit(`error`,t)}),e.addEventListener(`close`,e=>{this.authenticated=!1,this.context=null,this.payloadChannel=null,this.lifecycle.onDisconnected?.({code:e.code,reason:e.reason}),this.emit(`close`,Kc(e,[`code`,`reason`,`wasClean`]))})}get bufferedAmount(){return this.socket.bufferedAmount}get extensions(){return this.socket.extensions}get protocol(){return this.socket.protocol}get readyState(){return this.authenticated?this.socket.readyState:WebSocket.CONNECTING}get url(){return this.route.relayWebSocketUrl}send(e){if(!this.authenticated||typeof e!=`string`)throw new DOMException(`Forge relay RPC socket is not open for text frames.`,`InvalidStateError`);if(this.route.protocolVersion===1){this.socket.send(JSON.stringify({type:`relay.frame`,payload:e}));return}let t=this.context;if(t===null)throw new DOMException(`Forge relay v2 context is unavailable.`,`InvalidStateError`);let n=Uc(e,t.scopes),r=n.messageType===`request`&&n.journalPersistence!==`none`?this.journal.prepare({runtimeId:t.runtimeId,actorSessionId:t.actor.sessionId,transportRequestId:n.requestId,...n.correlationId===n.requestId?{}:{durableRequestId:n.correlationId},method:n.method,frame:e,persistence:n.journalPersistence}):null;this.enqueueFrame(e,r)}enqueueFrame(e,t){this.sendChain=this.sendChain.then(()=>this.transmitFrame(e,t)).catch(e=>{let n=Gc(e);t!==null&&!n.retryable&&this.journal.markFailed(t.runtimeId,t.actorSessionId,t.transportRequestId,n.code),this.lifecycle.onError?.({code:n.code,message:n.message}),this.emit(`error`,Wc(n.code,n.message)),this.socket.readyState<WebSocket.CLOSING&&this.socket.close(4400,`${n.code}: ${n.message}`)})}async transmitFrame(e,t){let n=this.requireReadyContext(),r=await this.outboundFrame(e,t),i=await ace({data:r,context:n,crypto:this.relayCrypto,...this.acquireActionGrant?{acquireActionGrant:this.acquireActionGrant}:{}});if(n.protocolVersion===4){let e=await this.requirePayloadChannel().sender.seal({frameClass:`application`,plaintext:new TextEncoder().encode(JSON.stringify({payload:r,envelope:i}))});this.socket.send(JSON.stringify(e));return}this.socket.send(JSON.stringify({type:`relay.frame`,payload:r,envelope:i}))}requireReadyContext(){if(!this.authenticated||this.socket.readyState!==WebSocket.OPEN)throw new DOMException(`Forge relay RPC socket closed before send.`,`InvalidStateError`);if(this.context===null)throw new DOMException(`Forge relay v2 context is unavailable.`,`InvalidStateError`);return this.context}requirePayloadChannel(){let e=this.payloadChannel;if(e===null||e.phase!==`ready`)throw new qo(`channel_confirmation_failed`,`The Forge relay endpoint channel is not confirmed.`,!1);return e}async outboundFrame(e,t){return t===null?e:this.withDurableHeaders(t,e)}async withDurableHeaders(e,t){let n=this.journal.beginAttempt(e.runtimeId,e.actorSessionId,e.transportRequestId),r=JSON.parse(t),i=await vce({payload:r.payload,sequence:n.sequence,requestId:n.durableRequestId,issuedAt:new Date(n.updatedAt),crypto:this.relayCrypto}),a=Array.isArray(r.headers)?r.headers.filter(e=>!Yse(e)):[];return JSON.stringify({...r,headers:[...a,...Object.entries(i)]})}close(e,t){this.socket.close(e,t)}asWebSocket(){return this}emit(e,t){this.dispatchEvent(t);let n=this[`on${e}`];n&&n.call(this.asWebSocket(),t)}async handleMessage(e){if(this.authenticated){if(this.context?.protocolVersion===4){await this.handleEncryptedApplicationMessage(e.data);return}this.context!==null&&Yc(e.data,this.context,this.journal),this.emit(`message`,new MessageEvent(`message`,{data:e.data}));return}await this.handleAuthenticationMessage(e.data)}async handleMessageSafely(e){try{await this.handleMessage(e)}catch(e){let t=Gc(e);this.lifecycle.onError?.({code:t.code,message:t.message}),this.emit(`error`,Wc(t.code,t.message)),this.socket.readyState<WebSocket.CLOSING&&this.socket.close(4400,`${t.code}: ${t.message}`)}}async beginAuthentication(){try{this.route.protocolVersion===4&&(this.payloadChannel=await sce($c(this.route))),this.socket.send(JSON.stringify({type:`relay.auth`,ticket:this.route.token,protocolMinVersion:this.route.protocolVersion,protocolMaxVersion:this.route.protocolVersion,capabilities:Vse,...this.payloadChannel?{controlToRuntimeEncapsulatedKey:this.payloadChannel.sender.encapsulatedKey}:{}}))}catch(e){let t=Gc(e);this.lifecycle.onError?.({code:t.code,message:t.message}),this.emit(`error`,Wc(t.code,t.message)),this.socket.close(4400,t.message)}}async handleAuthenticationMessage(e){let t=Jc(e);if(t!==null){if(t.type===`relay.encrypted-frame`&&this.context?.protocolVersion===4){await this.handleEncryptedHandshakeMessage(t);return}if(t.type===`relay.error`){this.lifecycle.onError?.({code:t.code,message:t.message}),this.emit(`error`,Wc(t.code,t.message)),this.socket.close(4403,t.message);return}t.type===`relay.authenticated`&&await this.handleAuthenticatedMessage(t)}}async handleAuthenticatedMessage(e){let t=Qse(e,this.route.protocolVersion);if(t===void 0){this.socket.close(4400,`Forge relay authenticated the wrong role.`);return}if(t!==null&&t.protocolVersion===4){let n=$c(this.route),r=this.payloadChannel;if(r===null||![e.runtimeId===n.runtimeId,e.connectionEpoch===n.connectionEpoch].every(Boolean)){this.socket.close(4400,`Forge relay authenticated stale endpoint metadata.`);return}t={...t,channelId:n.channelId,channelTicketDigest:fse(r.controlToRuntimeBinding),runtimeEndpointKeyId:n.runtimeEndpointKeyId,controlEndpointKeyId:n.controlEndpointKeyId},this.context=t;return}await this.activateAuthenticatedRelay(t)}async handleEncryptedHandshakeMessage(e){if(e.type!==`relay.encrypted-frame`)return;let t=this.payloadChannel,n=this.context,r=$c(this.route);if(t===null||n===null||!el(e,r,`handshake`))throw new qo(`channel_confirmation_failed`,`The runtime sent an invalid encrypted handshake frame.`,!1);let i=await(await uce({channel:t,route:r,message:e})).open(e),a=zse(JSON.parse(new TextDecoder().decode(i))),o=t.phase===`awaiting-runtime-hello`?`runtime-hello`:`runtime-confirm`;if(!cce({confirmation:a,expectedPhase:o,route:r,context:n}))throw new qo(`channel_confirmation_failed`,`The runtime endpoint confirmation does not match the CMMD route.`,!1);if(o===`runtime-hello`){let e=await t.sender.seal({frameClass:`handshake`,plaintext:new TextEncoder().encode(JSON.stringify({type:`relay.endpoint-confirmation`,protocolVersion:4,phase:`control-confirm`,channelId:r.channelId,runtimeId:n.runtimeId,connectionEpoch:n.connectionEpoch}))});t.phase=`awaiting-runtime-confirm`,this.socket.send(JSON.stringify(e));return}t.phase=`ready`,await this.activateAuthenticatedRelay(n)}async handleEncryptedApplicationMessage(e){let t=Jc(e);if(t?.type!==`relay.encrypted-frame`)throw new qo(`end_to_end_encryption_required`,`The runtime sent plaintext after the encrypted channel was confirmed.`,!1);let n=this.requirePayloadChannel();if(!el(t,$c(this.route),`application`)||t.encapsulatedKey!==void 0||n.recipient===null)throw new qo(`channel_authentication_failed`,`The runtime sent an invalid encrypted application frame.`,!1);let r=await n.recipient.open(t),i=Bse(JSON.parse(new TextDecoder().decode(r))),a=this.requireReadyContext();if(!lce({application:i,context:a,payloadHash:await this.relayCrypto.sha256Base64Url(i.payload)}))throw new qo(`channel_authentication_failed`,`The decrypted runtime envelope does not match the active route.`,!1);Yc(i.payload,a,this.journal),this.emit(`message`,new MessageEvent(`message`,{data:i.payload}))}async activateAuthenticatedRelay(e){this.context=e,this.authenticated=!0,this.lifecycle.onAuthenticated?.();let t=e===null?[]:this.replayForActor(e);for(let e of t)e.frame!==null&&this.enqueueFrame(e.frame,e);t.length>0&&await this.sendChain,this.emit(`open`,new Event(`open`))}replayForActor(e){return this.journal.fenceActor(e.runtimeId,e.actor.sessionId),this.journal.replayable(e.runtimeId,e.actor.sessionId)}};function fce(e,t,n=tl,r=Vc({storage:Lse(),randomUUID:n.randomUUID}),i={},a){return new dce(e,t,n,r,i,a).asWebSocket()}var pce=jo(one);async function mce(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest(`SHA-256`,t);return btoa(String.fromCharCode(...new Uint8Array(n))).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replaceAll(`=`,``)}var tl={randomUUID:()=>crypto.randomUUID(),sha256Base64Url:mce},nl=`forge-relay-binding=`,hce=3e4;function gce(e){let t=new URL(String(e)).hash.slice(1);if(!t.startsWith(nl))throw Error(`Forge relay socket URL is missing its route binding.`);let n=decodeURIComponent(t.slice(20));if(n.length===0)throw Error(`Forge relay socket URL has an invalid route binding.`);return n}function _ce(e){let t=e.crypto??tl,n=e.bindingTtlMs??hce,r=e.createSocket??((e,t)=>new globalThis.WebSocket(e,t)),i=new Map;return{acquireSocketUrl:async()=>{let r=await e.acquireRoute(),a=t.randomUUID();if(i.has(a))throw Error(`Forge relay route binding identifier was reused.`);let o=new URL(r.relayWebSocketUrl);o.hash=`${nl}${encodeURIComponent(a)}`;let s=setTimeout(()=>i.delete(a),n);return i.set(a,{route:r,expires:s}),o.toString()},constructSocket:(n,a)=>{let o=gce(n),s=i.get(o);if(s===void 0)throw Error(`Forge relay route binding is missing, expired, or already consumed.`);return i.delete(o),clearTimeout(s.expires),e.lifecycle?.onConnecting?.(),fce(r(s.route.relayWebSocketUrl,a),s.route,t,e.journal,e.lifecycle,e.acquireActionGrant)}}}async function vce(e){let t=e.issuedAt??new Date,n=e.crypto??tl;return{[An.requestId]:e.requestId??n.randomUUID(),[An.sequence]:String(e.sequence),[An.issuedAt]:t.toISOString(),[An.expiresAt]:new Date(t.getTime()+12e4).toISOString(),[An.payloadHash]:await n.sha256Base64Url(aae(e.payload))}}function yce(e,t){return $te(une,({rpc:t,request:n,next:r})=>nt(function*(){return Xo({method:t._tag,payload:n.payload,grantedScopes:e}),yield*r(n)}))}function bce(e,t=tl){return pce.pipe(be(yce(e,t)))}function xce(e){let t=e.crypto??tl,n=_ce({acquireRoute:e.acquireRoute,...e.acquireActionGrant?{acquireActionGrant:e.acquireActionGrant}:{},crypto:t,journal:e.journal,...e.lifecycle?{lifecycle:e.lifecycle}:{}}),r=ft(n.acquireSocketUrl).pipe(l),i=pe(ca,n.constructSocket),a=la(r).pipe(E(i)),o=e.delayForRetry??iae,s=It(y(e.maxRetries??10),e=>et(Ve(o(e)??0)));return dt(Po,Fo({retryPolicy:s,retryTransientErrors:!0})).pipe(E(Ee(a,Ao)))}var rl=class extends Error{name=`RelayControlRouteSecurityFailure`};async function Sce(e){let t=await mse(e),n=await Nc(t.publicKey);return{keyPair:t,publicKey:n,keyId:hse(`control`,n),channelNonce:await pse(e)}}function Cce(e){return{hpkeSuite:fc,controlEndpointKeyId:e.keyId,controlEndpointPublicKey:e.publicKey,controlChannelNonce:e.channelNonce}}function wce(e){let t=e.route;if(t.protocolVersion!==4||t.hpkeSuite!==`DHKEM_X25519_HKDF_SHA256/HKDF_SHA256/CHACHA20_POLY1305/AUTH`||!t.channelId||!t.runtimeEndpointKeyId||!t.runtimeEndpointPublicKey||t.controlEndpointKeyId!==e.endpoint.keyId||t.controlEndpointPublicKey!==e.endpoint.publicKey||t.controlChannelNonce!==e.endpoint.channelNonce)throw new rl(`Forge could not establish a verified end-to-end encrypted runtime route.`);return{...t,runtimeId:e.runtimeId,protocolVersion:4,channelId:t.channelId,hpkeSuite:fc,runtimeEndpointKeyId:t.runtimeEndpointKeyId,runtimeEndpointPublicKey:t.runtimeEndpointPublicKey,controlEndpointKeyId:e.endpoint.keyId,controlEndpointPublicKey:e.endpoint.publicKey,controlChannelNonce:e.endpoint.channelNonce,controlEndpointKeyPair:e.endpoint.keyPair,...e.digestProvider?{payloadDigestProvider:e.digestProvider}:{},...e.randomSource?{payloadRandomSource:e.randomSource}:{}}}var il=`~effect/ManagedRuntime`,al=(e,t)=>{let n=t?.memoMap??eee(),r=pee(`parallel`),i=k(r,`sequential`),a={onFiberStart:fe(r)},o=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,c,l=Nt(t=>(c||=m(Dee(s(e,n,i),e=>ct(()=>{u.cachedContext=e})),{...a,scheduler:t.currentScheduler}),zee(ge(c)))),u={[il]:il,memoMap:n,scope:r,contextEffect:l,cachedContext:void 0,context(){return u.cachedContext===void 0?ne(u.contextEffect):Promise.resolve(u.cachedContext)},dispose(){return ne(u.disposeEffect)},disposeEffect:Dt(()=>(u.contextEffect=gee(`ManagedRuntime disposed`),u.cachedContext=void 0,Be(u.scope,St))),runFork(e,t){return u.cachedContext===void 0?m(ol(u,e),o(t)):He(u.cachedContext)(e,o(t))},runCallback(e,t){return u.cachedContext===void 0?oee(ol(u,e),o(t)):Bt(u.cachedContext)(e,o(t))},runSyncExit(e){return u.cachedContext===void 0?Xee(ol(u,e)):se(u.cachedContext)(e)},runSync(e){return u.cachedContext===void 0?de(ol(u,e)):yee(u.cachedContext)(e)},runPromiseExit(e,t){return u.cachedContext===void 0?uee(ol(u,e),o(t)):hee(u.cachedContext)(e,o(t))},runPromise(e,t){return u.cachedContext===void 0?ne(ol(u,e),o(t)):te(u.cachedContext)(e,o(t))}};return u};function ol(e,t){return bt(e.contextEffect,e=>Ce(t,e))}function sl(e,t=nr){return`${e}\0${t}`}function Tce(e){let t=new Map,n=!1;return{register(e){if(n)throw Error(`Terminal control sequencer is disposed.`);let r=sl(e.threadId,e.terminalId);t.get(r)?.sessionEpoch!==e.sessionEpoch&&t.set(r,{sessionEpoch:e.sessionEpoch,nextControlSequence:1,tail:Promise.resolve(),pendingWriteBytes:0})},enqueue(r){if(n)return Promise.reject(Error(`Terminal control sequencer is disposed.`));let i=r.terminalId??`default`,a=t.get(sl(r.threadId,i));if(!a)return Promise.reject(Error(`Terminal must be opened before sending controls.`));let o=r.writeBytes??0;if(a.pendingWriteBytes+o>e.maxPendingWriteBytes)return Promise.reject(Error(`Terminal input queue is full while reconnecting.`));a.pendingWriteBytes+=o;let s=a.tail.then(async()=>{let t=a.nextControlSequence;await r.execute({sessionEpoch:a.sessionEpoch,controllerId:e.controllerId,controlSequence:t}),a.nextControlSequence=t+1});return a.tail=s.finally(()=>{a.pendingWriteBytes-=o}).catch(()=>void 0),s},remove(e,n){if(n){t.delete(sl(e,n));return}let r=`${e}\0`;for(let e of t.keys())e.startsWith(r)&&t.delete(e)},terminalIds(e){let n=`${e}\0`;return[...t.keys()].filter(e=>e.startsWith(n)).map(e=>e.slice(n.length))},dispose(){n=!0,t.clear()}}}var cl={accept:!1,observe:!1,missingFrameCount:0,startsNewStream:!1};function ll(e){let t=e===!0;return{accept:t,observe:t,missingFrameCount:0,startsNewStream:t}}function Ece(e,t){let n=e.streamGeneration===void 0&&e.streamId===void 0,r=t.streamGeneration!==void 0||t.streamId!==void 0;return n&&r?ll(t.keyframe):null}function Dce(e,t){return e.streamGeneration===void 0||t.streamGeneration===void 0?null:t.streamGeneration<e.streamGeneration?cl:t.streamGeneration>e.streamGeneration?ll(t.keyframe):null}function Oce(e,t){if(!e.streamId||!t.streamId)return null;if(e.streamId!==t.streamId)return ll(t.keyframe);if(t.sequence<=e.observedSequence)return cl;let n=Math.max(0,t.sequence-e.observedSequence-1);return{accept:n===0||t.keyframe===!0,observe:!0,missingFrameCount:n,startsNewStream:!1}}function kce(e,t){if(t.sequence>e.acceptedSequence)return{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1};if(!e.acceptedCapturedAt)return cl;let n=Date.parse(e.acceptedCapturedAt),r=Date.parse(t.capturedAt);return Number.isNaN(n)||Number.isNaN(r)||r<=n?cl:{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1}}function Ace(e,t){return Ece(e,t)??Dce(e,t)??Oce(e,t)??kce(e,t)}function jce(e,t){let n=Ace(e,t);if(!n.observe)return{accept:n.accept,observe:n.observe,missingFrameCount:n.missingFrameCount,state:e};let r=n.startsNewStream?t.sequence:Math.max(e.observedSequence,t.sequence),i={...e,observedSequence:r,gapCount:e.gapCount+n.missingFrameCount},a=n.accept?{...i,acceptedSequence:t.sequence,acceptedCapturedAt:t.capturedAt,...t.streamId?{streamId:t.streamId}:{},...t.streamGeneration===void 0?{}:{streamGeneration:t.streamGeneration}}:i;return{accept:n.accept,observe:n.observe,missingFrameCount:n.missingFrameCount,state:a}}ir(fne);var ul=mte(),dl=`Forge`,fl=`Alpha`,pl=dl,ml=`0.9.10`;function hl(e){return{_tag:`Value`,value:e}}function gl(e,t){return{_tag:`Record`,keys:e,value:t}}function _l(e,t){return{_tag:`Array`,length:e,value:t}}qn(`SourceError`);var vl=xt(`effect/ConfigProvider`,{defaultValue:()=>xl()}),yl={...le,toJSON(){return{_id:`ConfigProvider`}}};function bl(e,t,n){let r=Object.create(yl);return r.get=e,r.mapInput=t,r.prefix=n,r.load=r=>(t&&(r=t(r)),n&&(r=[...n,...r]),e(r)),r}function xl(e){let t=e?.env??{APP_VERSION:`0.9.10`,BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`,VITE_COMMIT_SHA:``,VITE_HTTP_URL:``,VITE_SENTRY_COMMIT_SHA:``,VITE_SENTRY_DEBUG:``,VITE_SENTRY_DSN:``,VITE_SENTRY_ENABLED:``,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_PROFILES_SAMPLE_RATE:``,VITE_SENTRY_RELEASE:`forge-web@0.9.10`,VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE:``,VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE:``,VITE_SENTRY_TRACES_SAMPLE_RATE:``,VITE_WS_URL:``},n=Sl(t);return bl(e=>et(wl(n,t,e)))}function Sl(e){let t={};for(let[n,r]of Object.entries(e)){if(r===void 0)continue;let e=n.split(`_`),i=t;for(let t of e)i.children??={},i=i.children[t]??={};i.value=r}return t}var Cl=/^(0|[1-9][0-9]*)$/;function wl(e,t,n){let r=t[n.map(String).join(`_`)],i=Tl(e,n),a=i?.children?Object.keys(i.children):[];return a.length===0?r===void 0?void 0:hl(r):a.every(e=>Cl.test(e))?_l(Math.max(...a.map(e=>parseInt(e,10)))+1,r):gl(new Set(a),r)}function Tl(e,t){if(t.length===0)return e;let n=e;for(let e of t)if(n=n?.children?.[String(e)],!n)return;return n}var El=`~effect/Config`,Dl=class{_tag=`ConfigError`;name=`ConfigError`;cause;constructor(e){this.cause=e}get message(){return this.cause.toString()}toString(){return`ConfigError(${this.message})`}},Ol={...le,...ae,[El]:El,asEffect(){return bt(vl.asEffect(),e=>this.parse(e))},toJSON(){return{_id:`Config`}}};function kl(e){let t=Object.create(Ol);return t.parse=e,t}var Al=Xe(function*(e,t){let n=yield*e.load(t);if(n!==void 0)switch(n._tag){case`Value`:return n.value;case`Record`:{if(n.value!==void 0)return n.value;let r={};for(let i of n.keys){let n=yield*Al(e,[...t,i]);n!==void 0&&(r[i]=n)}return r}case`Array`:{if(n.value!==void 0)return n.value;let r=[];for(let i=0;i<n.length;i++)r.push(yield*Al(e,[...t,i]));return r}}}),jl=Xe(function*(e,t,n){switch(e._tag){case`Objects`:{let r={};for(let i of e.propertySignatures){let e=i.name;if(typeof e==`string`){let a=yield*jl(i.type,t,[...n,e]);a!==void 0&&(r[e]=a)}}if(e.indexSignatures.length>0){let i=yield*t.load(n);if(i&&i._tag===`Record`)for(let a of e.indexSignatures){let e=Lte(a.parameter);for(let o of i.keys)if(!Object.hasOwn(r,o)&&e(o)){let e=yield*jl(a.type,t,[...n,o]);e!==void 0&&(r[o]=e)}}}return r}case`Arrays`:{let r=yield*t.load(n);if(r&&r._tag===`Value`)return r.value;let i=[];for(let r=0;r<e.elements.length;r++)i.push(yield*jl(e.elements[r],t,[...n,r]));return i}case`Union`:return yield*Al(t,n);case`Suspend`:return yield*jl(e.thunk(),t,n);default:{let e=yield*t.load(n);return e===void 0?void 0:e._tag===`Value`||e._tag===`Record`&&e.value!==void 0||e._tag===`Array`&&e.value!==void 0?e.value:void 0}}});function Ml(e,t){let n=Vte(e),r=Gte(n),i=Ote(n.ast),a=typeof t==`string`?[t]:t??[];return kl(e=>{let t=e.prefix?[...e.prefix,...a]:a;return jl(i,e,a).pipe(ete(e=>r(e).pipe(Ft(e=>new Nte(t.length>0?new Yte(t,e):e)))),Ft(e=>new Dl(e)))})}var Nl=(e,t,n)=>{let r=Pn(e,t),i=Gn.pipe(ar(Pn(Gn,Gn),Jte(n)),ar(r));return Dn([r,i])},Pl=_te(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Fl=!1,Il=!1,Ll=null,Rl=null,zl=null,Bl=!1,Vl=new Set;function Mce(e){if(Fl||Il)return;if(!e.publicKey||!e.host){Il=!0;return}if(Ll)return;if(typeof window>`u`||typeof location>`u`){Il=!0;return}let t=e.publicKey,n=e.host;Ll=N(async()=>{let{default:e}=await import(`./module-44GyzBiP.js`);return{default:e}},[]).then(({default:e})=>{Rl=e,e.init(t,{api_host:n,person_profiles:`identified_only`,capture_pageview:!1,capture_pageleave:!1,autocapture:!1,disable_session_recording:!0,loaded:()=>{Fl=!0,zl&&Hl(zl),Ul(),Vl.forEach(e=>e())}})}).catch(()=>{Il=!0,Rl=null})}function Hl(e){if(zl=e,!Fl||!Rl)return;let t={};e.email!==void 0&&(t.email=e.email),e.displayName!==void 0&&(t.name=e.displayName),Rl.identify(e.cmmdUserId,t)}function Nce(e){return!Fl||!Rl?!1:Rl.isFeatureEnabled(e)===!0}function Ul(){!Rl||Bl||(Bl=!0,Rl.onFeatureFlags(()=>{Vl.forEach(e=>e())}))}function Pce(e){return Vl.add(e),Fl&&Rl&&(Ul(),e()),()=>{Vl.delete(e)}}var Wl=`token`;function Gl(e){return new URLSearchParams(e.hash.startsWith(`#`)?e.hash.slice(1):e.hash)}function Kl(e){let t=Gl(e).get(Wl)?.trim()??``;if(t.length>0)return t;let n=e.searchParams.get(Wl)?.trim()??``;return n.length>0?n:null}function Fce(e){let t=new URL(e.toString()),n=Gl(t);return n.has(Wl)&&(n.delete(Wl),t.hash=n.toString()),t.searchParams.delete(Wl),t}function ql(e,t){let n=new URL(e.toString());return n.searchParams.delete(Wl),n.hash=new URLSearchParams([[Wl,t]]).toString(),n}function Ice(e,t){let n=new URL(e);return n.pathname=`/login`,ql(n,t).toString()}function Lce(e){return ql(new URL(`/login`,window.location.href),e).toString()}function Rce(e){let t=new URL(e),n=Kl(t),r=new URL(`forge:///pair`);return r.searchParams.set(`serverUrl`,t.origin),n&&r.searchParams.set(Wl,n),r.toString()}var B=typeof __SENTRY_DEBUG__>`u`||__SENTRY_DEBUG__,V=globalThis,Jl=`10.70.0`;function Yl(){return Xl(V),V}function Xl(e){let t=e.__SENTRY__=e.__SENTRY__||{};return t.version=t.version||`10.70.0`,t[Jl]=t[`10.70.0`]||{}}function Zl(e,t,n=V){let r=n.__SENTRY__=n.__SENTRY__||{},i=r[Jl]=r[`10.70.0`]||{};return i[e]||(i[e]=t())}var Ql=[`debug`,`info`,`warn`,`error`,`log`,`assert`,`trace`],zce=`Sentry Logger `,$l={};function eu(e){if(!(`console`in V))return e();let t=V.console,n={},r=Object.keys($l);r.forEach(e=>{let r=$l[e];n[e]=t[e],t[e]=r});try{return e()}finally{r.forEach(e=>{t[e]=n[e]})}}function Bce(){ru().enabled=!0}function Vce(){ru().enabled=!1}function tu(){return ru().enabled}function Hce(...e){nu(`log`,...e)}function Uce(...e){nu(`warn`,...e)}function Wce(...e){nu(`error`,...e)}function nu(e,...t){B&&tu()&&eu(()=>{V.console[e](`${zce}[${e}]:`,...t)})}function ru(){return B?Zl(`loggerSettings`,()=>({enabled:!1})):{enabled:!1}}var H={enable:Bce,disable:Vce,isEnabled:tu,log:Hce,warn:Uce,error:Wce},iu=50,au=/\(error: (.*)\)/,ou=/captureMessage|captureException/;function su(...e){let t=e.sort((e,t)=>e[0]-t[0]).map(e=>e[1]);return(e,n=0,r=0)=>{let i=[],a=e.split(`
|
|
2
|
+
(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`forge-web@0.9.10`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`d798db5f-add5-4d07-a7bc-3016e5adaf01`,e._sentryDebugIdIdentifier=`sentry-dbid-d798db5f-add5-4d07-a7bc-3016e5adaf01`)}catch{}})();import{n as e,r as t,t as n}from"./rolldown-runtime-BaTzPAyU.js";import{$ as r,$i as i,$t as a,Ai as o,An as s,Ar as c,At as l,B as u,Ba as d,Bn as f,Br as p,Bt as m,C as h,Ci as g,Cn as _,Da as v,Dn as y,Dt as b,Ei as x,En as S,Er as C,Et as w,F as T,Fn as E,Fr as D,Ft as O,Gn as ee,Gt as te,Hn as k,Hr as A,Ht as ne,Ir as j,It as re,J as ie,Ji as ae,Jn as oe,Jt as se,K as ce,Ki as le,Kn as ue,Kt as de,L as fe,Ln as pe,Lr as me,Lt as he,M as ge,Ma as _e,Mi as ve,Mr as ye,Mt as be,N as xe,Na as Se,Nn as eee,Nt as Ce,O as we,Oa as tee,On as nee,Ot as ree,P as iee,Pa as Te,Pn as Ee,Pt as De,Qn as Oe,Qt as aee,R as ke,Ra as Ae,Rn as je,Rr as Me,Rt as oee,Sa as Ne,Sn as see,T as Pe,Ta as cee,Tn as lee,Tr as Fe,Tt as Ie,U as Le,Un as Re,Ur as ze,Ut as uee,V as dee,Va as fee,Vn as Be,Vr as Ve,Vt as He,W as Ue,Wn as pee,Wr as mee,Wt as hee,X as gee,Xn as _ee,Y as vee,Yi as We,Yn as Ge,Yt as yee,Z as Ke,Zi as qe,Zn as Je,Zt as bee,_ as xee,_i as See,_n as Cee,_r as wee,_t as Tee,aa as Ye,ai as Eee,an as Dee,at as Xe,bi as Oee,bn as kee,br as Aee,bt as Ze,ci as jee,cn as Mee,ct as Qe,di as Nee,dn as Pee,dr as Fee,dt as $e,ei as Iee,en as et,er as Lee,et as tt,fr as Ree,ft as nt,gn as rt,gt as it,hn as at,hr as ot,ht as st,in as ct,it as zee,j as lt,ja as Bee,ji as ut,jn as dt,jr as Vee,jt as ft,ka as Hee,ki as Uee,kr as Wee,kt as pt,li as Gee,ln as Kee,m as qee,ma as mt,mi as ht,mn as gt,mr as _t,mt as vt,ni as Jee,nr as yt,nt as bt,oi as xt,on as Yee,or as St,pn as Ct,pt as wt,q as Tt,qn as Et,qt as Xee,r as Zee,ra as Qee,rn as Dt,rr as $ee,rt as ete,s as tte,si as Ot,sn as nte,st as kt,ti as rte,ui as At,un as jt,ut as Mt,vn as Nt,vr as ite,vt as ate,w as Pt,wi as ote,wn as ste,wr as cte,wt as Ft,x as lte,xi as ute,xn as It,y as dte,yi as fte,yn as Lt,yt as pte,z as Rt,za as mte,zn as zt,zt as Bt}from"./Stream-D8tJNlvy.js";import{i as hte,l as Vt,n as Ht,o as Ut,s as Wt}from"./atomRegistry-Bz2MHqst.js";import{An as Gt,Fn as gte,Mn as Kt,Nn as _te,Pn as vte,Sn as yte,Z as bte,_ as xte,_n as qt,b as Jt,g as Yt,gn as Xt,i as Ste,pn as Zt,v as Cte,xn as Qt,y as wte}from"./CompositeItem-Bsi2e5qV.js";import{$t as Tte,An as $t,At as Ete,B as Dte,Bn as Ote,Bt as en,Cn as tn,Ct as nn,D as kte,Dn as rn,Dt as an,E as on,En as Ate,Et as sn,F as jte,Ft as cn,Gt as Mte,H as ln,Ht as un,In as Nte,It as Pte,J as dn,Jt as Fte,Kt as fn,L as Ite,Ln as Lte,Lt as pn,Mn as mn,Mt as hn,Nn as gn,Nt as Rte,O as zte,On as Bte,Ot as _n,Pn as Vte,Pt as Hte,Q as Ute,Qt as Wte,Rn as Gte,Rt as vn,S as Kte,Sn as yn,T as bn,Tn as qte,Ut as xn,V as Sn,Vn as Jte,Vt as Cn,Wn as Yte,Wt as Xte,X as wn,Xt as Zte,Y as Tn,Yt as Qte,Zt as En,_n as Dn,a as M,an as On,bn as kn,bt as $te,c as An,cn as jn,ct as ene,d as tne,dn as Mn,en as nne,et as Nn,f as rne,fn as Pn,ft as Fn,g as In,gn as Ln,hn as ine,ht as ane,i as one,in as Rn,it as sne,jn as zn,jt as cne,k as Bn,kt as lne,l as une,ln as dne,m as fne,mn as Vn,mt as pne,n as mne,nn as Hn,nt as Un,o as Wn,pn as Gn,pt as Kn,qn,qt as hne,rn as Jn,s as Yn,st as Xn,t as Zn,tn as Qn,tt as $n,u as er,un as tr,ut as nr,v as rr,vt as gne,wn as ir,x as _ne,xn as ar,xt as or,y as vne,zn as yne,zt as sr}from"./src-BL6J64vk.js";import{A as cr,D as lr,E as ur,F as bne,I as dr,M as xne,O as fr,P as Sne,S as Cne,_ as wne,a as pr,b as Tne,c as Ene,j as mr,k as hr,l as Dne,n as gr,s as One,u as kne,v as Ane,w as _r,x as jne,y as Mne}from"./cmmdAuthRedirect-lmPzseq5.js";import{t as N}from"./preload-helper-DDBXDd-E.js";import{n as P,t as vr}from"./transport-1MbRJyXh.js";import{n as Nne,t as Pne}from"./workspaceReadinessAtom-DsJoTBtH.js";function Fne(e){return e[e.length-1]}function Ine(e,t){return typeof e==`function`?e(t):e}var yr=Object.prototype.hasOwnProperty,Lne=Object.prototype.propertyIsEnumerable;function Rne(e){for(let t in e)if(yr.call(e,t))return!0;return!1}var zne=()=>Object.create(null),Bne=(e,t)=>br(e,t,zne);function br(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=wr(e)&&wr(i);if(!a&&!(Sr(e)&&Sr(i)))return i;let o=a?e:xr(e);if(!o)return i;let s=a?i:xr(i);if(!s)return i;let c=o.length,l=s.length,u=a?Array(l):n(),d=0;for(let t=0;t<l;t++){let o=a?t:s[t],l=e[o],f=i[o];if(l===f){u[o]=l,(a?t<c:yr.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=br(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function xr(e){let t=Object.keys(e);if(t.length!==Object.getOwnPropertyNames(e).length)return!1;let n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;for(let r of n){if(!Lne.call(e,r))return!1;t.push(r)}return t}function Sr(e){if(!Cr(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Cr(n)||!n.hasOwnProperty(`isPrototypeOf`))}function Cr(e){return Object.prototype.toString.call(e)===`[object Object]`}function wr(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Tr(e,t,n){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!Tr(e[r],t[r],n))return!1;return!0}if(Sr(e)&&Sr(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!Tr(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!Tr(e[o],t[o],n)))return!1;return i===a}return!1}var Vne=/[\x00-\x1f\x7f"<>`{}]/g;function Hne(e){return e.replace(Vne,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function Er(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return Hne(t)}var Une=[`http:`,`https:`,`mailto:`,`tel:`];function Wne(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}function Gne(e){if(!e||!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith(`//`))return{path:e,handledProtocolRelativeURL:!1};let t=/%25|%5C/gi,n=0,r=``,i;for(;(i=t.exec(e))!==null;)r+=Er(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=Er(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function Kne(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function qne(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Dr(){throw Error(`Invariant failed`)}var F=t(fee(),1),Or=F.createContext(null);function kr(e){return F.useContext(Or)}var Ar=F.createContext(void 0),Jne=F.createContext(void 0),Yne=gte();function Xne(e,t){return e===t}function jr(e,t,n=Xne){let r=(0,F.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,F.useCallback)(()=>e?.get(),[e]);return(0,Yne.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var Mr={};function Nr(e,t){let n=F.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=br(n.current,i):i}}function Pr(e){let t=kr(),n=F.useContext(e.from?Jne:Ar),r=e.from??n,i=t.stores.getMatchStore(r),a=Nr(e,t),o=jr(i,e=>e?a(e):Mr);if(o!==Mr)return o;(e.shouldThrow??!0)&&Dr()}function Zne(e){return Pr({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}var Fr=d(),Ir=typeof window<`u`&&(window.desktopBridge!==void 0||window.nativeApi!==void 0),Lr=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(){}},Rr=new class extends Lr{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},Qne={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},zr=new class{#e=Qne;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function $ne(e){setTimeout(e,0)}var ere=typeof window>`u`||`Deno`in globalThis;function Br(){}function tre(e,t){return typeof e==`function`?e(t):e}function Vr(e){return typeof e==`number`&&e>=0&&e!==1/0}function Hr(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Ur(e,t){return typeof e==`function`?e(t):e}function Wr(e,t){return typeof e==`function`?e(t):e}function nre(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Gr(o,t.options))return!1}else if(!qr(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function rre(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Kr(t.options.mutationKey)!==Kr(a))return!1}else if(!qr(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Gr(e,t){return(t?.queryKeyHashFn||Kr)(e)}function Kr(e){return JSON.stringify(e,(e,t)=>Zr(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function qr(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!qr(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!qr(e[r],t[r]))return!1;return!0}return!1}var ire=Object.prototype.hasOwnProperty;function Jr(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Xr(e)&&Xr(t);if(!r&&!(Zr(e)&&Zr(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:ire.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Jr(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Yr(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Xr(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Zr(e){if(!Qr(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Qr(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Qr(e){return Object.prototype.toString.call(e)===`[object Object]`}function are(e){return new Promise(t=>{zr.setTimeout(t,e)})}function $r(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Jr(e,t)}function ore(e){return e}function sre(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function cre(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var ei=Symbol();function ti(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ei?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ni(e,t){return typeof e==`function`?e(...t):!!e}function lre(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var ri=(()=>{let e=()=>ere;return{isServer(){return e()},setIsServer(t){e=t}}})();function ii(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var ure=$ne;function dre(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=ure,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var ai=dre(),oi=new class extends Lr{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let 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.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function fre(e){return Math.min(1e3*2**e,3e4)}function si(e){return(e??`online`)!==`online`||oi.isOnline()}var ci=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function li(e){let t=!1,n=0,r,i=ii(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new ci(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>Rr.isFocused()&&(e.networkMode===`always`||oi.isOnline())&&e.canRun(),u=()=>si(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(ri.isServer()?0:3),o=e.retryDelay??fre,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),are(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var ui=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Vr(this.gcTime)&&(this.#e=zr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ri.isServer()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(zr.clearTimeout(this.#e),this.#e=void 0)}};function pre(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{lre(e,()=>t.signal,()=>n=!0)},u=ti(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?cre:sre;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?fi:di,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:di(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function di(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function fi(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function mre(e,t){return t?di(e,t)!=null:!1}function hre(e,t){return!t||!e.getPreviousPageParam?!1:fi(e,t)!=null}var gre=class extends ui{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=hi(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=hi(this.options);e.data!==void 0&&(this.setState(mi(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=$r(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(Br).catch(Br):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Wr(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ei||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Ur(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Hr(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.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.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#s=!0,n.signal)})},i=()=>{let e=ti(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?pre(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=li({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof ci&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof ci){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...pi(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...mi(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),ai.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function pi(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:si(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function mi(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function hi(e){let 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 gi=class extends Lr{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=ii(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),_i(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return vi(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return vi(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof Wr(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Yr(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&yi(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||Wr(this.options.enabled,this.#t)!==Wr(t.enabled,this.#t)||Ur(this.options.staleTime,this.#t)!==Ur(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Wr(this.options.enabled,this.#t)!==Wr(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return vre(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Br)),t}#g(){this.#b();let e=Ur(this.options.staleTime,this.#t);if(ri.isServer()||this.#r.isStale||!Vr(e))return;let t=Hr(this.#r.dataUpdatedAt,e)+1;this.#d=zr.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(ri.isServer()||Wr(this.options.enabled,this.#t)===!1||!Vr(this.#p)||this.#p===0)&&(this.#f=zr.setInterval(()=>{(this.options.refetchIntervalInBackground||Rr.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(zr.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(zr.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&_i(e,t),o=i&&yi(e,n,t,r);(a||o)&&(l={...l,...pi(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=$r(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=$r(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:bi(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Wr(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{let e=this.#o=x.promise=ii();i(e)},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a()}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!Yr(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){ai.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function _re(e,t){return Wr(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||Wr(t.retryOnMount,e)!==!1)}function _i(e,t){return _re(e,t)||e.state.data!==void 0&&vi(e,t,t.refetchOnMount)}function vi(e,t,n){if(Wr(t.enabled,e)!==!1&&Ur(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&bi(e,t)}return!1}function yi(e,t,n,r){return(e!==t||Wr(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&bi(e,n)}function bi(e,t){return Wr(t.enabled,e)!==!1&&e.isStaleByTime(Ur(t.staleTime,e))}function vre(e,t){return!Yr(e.getCurrentResult(),t)}var xi=F.createContext(void 0),Si=e=>{let t=F.useContext(xi);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},yre=({client:e,children:t})=>(F.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,Fr.jsx)(xi.Provider,{value:e,children:t})),Ci=F.createContext(!1),wi=()=>F.useContext(Ci);Ci.Provider;function bre(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var xre=F.createContext(bre()),Ti=()=>F.useContext(xre),Ei=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?ni(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Di=e=>{F.useEffect(()=>{e.clearReset()},[e])},Oi=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||ni(n,[e.error,r])),ki=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Sre=(e,t)=>e.isLoading&&e.isFetching&&!t,Ai=(e,t)=>e?.suspense&&t.isPending,ji=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Mi(e,t,n){let r=wi(),i=Ti(),a=Si(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,ki(o),Ei(o,i,s),Di(i);let l=!a.getQueryCache().get(o.queryHash),[u]=F.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(F.useSyncExternalStore(F.useCallback(e=>{let t=f?u.subscribe(ai.batchCalls(e)):Br;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),F.useEffect(()=>{u.setOptions(o)},[o,u]),Ai(o,d))throw ji(o,u,i);if(Oi({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,d),o.experimental_prefetchInRender&&!ri.isServer()&&Sre(d,r)&&(l?ji(o,u,i):s?.promise)?.catch(Br).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?d:u.trackResult(d)}function Ni(e,t){return Mi(e,gi,t)}function Cre(e){return e}var wre={[Symbol.iterator](){return Tre}},Tre={next(){return{done:!0,value:void 0}}},Ere=()=>wre,Dre=C,Pi=globalThis.Number,Ore=e=>{if(e===`NaN`)return ve(NaN);if(e===`Infinity`)return ve(1/0);if(e===`-Infinity`)return ve(-1/0);if(e.trim()===``)return ut();let t=Pi(e);return Pi.isNaN(t)?ut():ve(t)},kre=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`]],Fi=`~effect/http/HttpClientRequest`,Are={[Fi]:Fi,...We,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Qee(this.headers),body:this.body.toJSON()}},pipe(){return Ae(this,arguments)}};function Ii(e,t,n,r,i,a){let o=Object.create(Are);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var jre=Ii(`GET`,``,hne,ut(),pn,Mte),Li=e=>(t,n)=>Nre(jre,{method:e,url:t,...n??void 0}),Mre=Li(`POST`),Nre=_e(2,(e,t)=>{let n=e;return t.method&&(n=Pre(n,t.method)),t.url&&(n=Lre(n,t.url)),t.headers&&(n=Ri(n,t.headers)),t.urlParams&&(n=Rre(n,t.urlParams)),t.hash&&(n=zre(n,t.hash)),t.body&&(n=Bi(n,t.body)),t.accept&&(n=zi(n,t.accept)),t.acceptJson&&(n=Ire(n)),n}),Pre=_e(2,(e,t)=>Ii(t,e.url,e.urlParams,e.hash,e.headers,e.body)),Fre=_e(3,(e,t,n)=>Ii(e.method,e.url,e.urlParams,e.hash,xn(e.headers,t,n),e.body)),Ri=_e(2,(e,t)=>Ii(e.method,e.url,e.urlParams,e.hash,Xte(e.headers,t),e.body)),zi=_e(2,(e,t)=>Fre(e,`Accept`,t)),Ire=zi(`application/json`),Lre=_e(2,(e,t)=>{if(typeof t==`string`)return Ii(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=Fte(n.searchParams),i=fte(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,Ii(e.method,n.toString(),r,i,e.headers,e.body)}),Rre=_e(2,(e,t)=>Ii(e.method,e.url,Zte(e.urlParams,t),e.hash,e.headers,e.body)),zre=_e(2,(e,t)=>Ii(e.method,e.url,e.urlParams,ve(t),e.headers,e.body)),Bi=_e(2,(e,t)=>{let n=e.headers;return t._tag===`Empty`||t._tag===`FormData`?n=un(un(n,`Content-Type`),`Content-length`):(t.contentType&&(n=xn(n,`content-type`,t.contentType)),t.contentLength!==void 0&&(n=xn(n,`content-length`,t.contentLength.toString()))),Ii(e.method,e.url,e.urlParams,e.hash,n,t)}),Bre=e=>sr({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${o(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),Vi=`~effect/http/HttpClient`,Hi=Ot(`effect/HttpClient`),Ui=_e(2,(e,t)=>Wi(n=>t(e.postprocess(n)),e.preprocess)),Vre=Ui(bt(Rte)),Wi=(e,t)=>{let n=Object.create(Hre);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},Hre={[Vi]:Vi,pipe(){return Ae(this,arguments)},...We,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(kre.map(([e,t])=>[t,function(t,n){return this.execute(Li(e)(t,n))}]))},Ure=e=>Wi(t=>bt(t,t=>Nt(n=>{let i=qre.get(t),a=i??new AbortController,o=Qte(t.url,t.urlParams,g(t.hash));if(rte(o))return r(new En({reason:new Tte({request:t,cause:o.failure})}));let s=o.success;if(n.getRef(Wee)||n.getRef(Gi)(t)){let r=e(t,s,a.signal,n);return i?r:Ct(e=>Ie(e(r),{onSuccess(e){return qi.register(e,a),et(new Ji(e,a))},onFailure(e){return _t(e)&&a.abort(),tt(e)}}))}return at(n.getRef(Gre)(t),{kind:`client`},r=>{r.attribute(`http.request.method`,t.method),r.attribute(`server.address`,s.origin),s.port!==``&&r.attribute(`server.port`,+s.port),r.attribute(`url.full`,s.toString()),r.attribute(`url.path`,s.pathname),r.attribute(`url.scheme`,s.protocol.slice(0,-1));let o=s.search.slice(1);o!==``&&r.attribute(`url.query`,o);let c=n.getRef(Pte),l=Cn(t.headers,c);for(let e in l)r.attribute(`http.request.header.${e}`,String(l[e]));return t=n.getRef(Ki)?Ri(t,Bre(r)):t,Ct(o=>o(e(t,s,a.signal,n)).pipe(Lt(r,{captureStackTrace:!1}),Ie({onSuccess:e=>{r.attribute(`http.response.status_code`,e.status);let t=Cn(e.headers,c);for(let e in t)r.attribute(`http.response.header.${e}`,String(t[e]));return i?et(e):(qi.register(e,a),et(new Ji(e,a)))},onFailure(e){return!i&&_t(e)&&a.abort(),tt(e)}})))})})),et),Wre=_e(2,(e,t)=>{let n=lee(t),r=n?`errors-and-responses`:t.retryOn??`errors-and-responses`,i=n?t:t.schedule,a=i&&S(i),o=n?void 0:t.times;return Ui(e,Se(r===`errors-only`?Te:re({schedule:a,times:o,while:Xi}),r===`response-only`?Te:he({while:n||t.while===void 0?Yi:v(Yi,t.while),schedule:i,times:o})))}),Gi=xt(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>tee}),Ki=xt(`effect/HttpClient/TracerPropagationEnabled`,{defaultValue:Hee}),Gre=xt(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),Kre=e=>dt(Hi)(ie(t=>Ze(e,e=>Ui(e,gt(e=>ht(t,e)))))),qi=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{e.abort()});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),qre=new WeakMap,Ji=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[hn]=hn;[cn]=cn;applyInterrupt(e){return Dt(()=>(qi.unregister(this.original),pt(e,()=>ct(()=>{this.controller.abort()}))))}get request(){return this.original.request}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return xee(()=>(qi.unregister(this.original),Zee(this.original.stream,ct(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[qe](){return this.original[qe]()}pipe(){return Ae(this,arguments)}},Yi=e=>Aee(e)||Jre(e),Jre=e=>Qn(e)&&(e.reason._tag===`TransportError`||e.reason._tag===`StatusCodeError`&&Xi(e.reason.response)),Xi=e=>e.status===408||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504,Zi=`~effect/FiberSet`,Yre=e=>mt(e,Zi),Xre={[Zi]:Zi,[Symbol.iterator](){return this.state._tag===`Closed`?Ere():this.state.backing[Symbol.iterator]()},...le,toJSON(){return{_id:`FiberMap`,state:this.state}}},Zre=(e,t)=>{let n=Object.create(Xre);return n.state={_tag:`Open`,backing:e},n.deferred=t,n},Qre=()=>ke(ct(()=>Zre(new Set,Ge())),e=>Dt(()=>{let t=e.state;if(t._tag===`Closed`)return rt;e.state={_tag:`Closed`};let n=t.backing;return T(n).pipe(oe(e.deferred))})),Qi=-1,$re=me(D(Fee,j(Qi))),eie=_e(e=>Yre(e[0]),(e,t,n)=>{if(e.state._tag===`Closed`){t.interruptUnsafe(Qi);return}e.state.backing.has(t)||(e.state.backing.add(t),t.addObserver(r=>{e.state._tag!==`Closed`&&(e.state.backing.delete(t),yt(r)&&(n?.propagateInterruption===!0?!$re(r.cause):!ot(r.cause))&&Et(e.deferred,r))}))}),tie=function(){let e;return()=>(e===void 0&&(e=m(vt)),e)}(),nie=e=>()=>Ze(Tt(),t=>{let n=He(t);return(t,r)=>{if(e.state._tag===`Closed`)return tie();let i=n(t,r);return eie(e,i),i}}),$i=e=>ue(e.deferred),ea=`~effect/socket/Socket`,ta=Ot(`effect/socket/Socket`),rie=`~effect/socket/Socket/CloseEvent`,iie=e=>mt(e,rie),na=`~effect/socket/Socket/SocketError`,aie=e=>mt(e,na),ra=class extends On(`effect/socket/Socket/SocketReadError`)({_tag:mn(`SocketReadError`),cause:Rn}){message=`An error occurred during Read`},oie=class extends On(`effect/socket/Socket/SocketWriteError`)({_tag:mn(`SocketWriteError`),cause:Rn}){message=`An error occurred during Write`},ia=class extends On(`effect/socket/Socket/SocketOpenError`)({_tag:mn(`SocketOpenError`),kind:jn([`Unknown`,`Timeout`]),cause:Rn}){get message(){return this.kind===`Timeout`?`timeout waiting for "open"`:`An error occurred during Open`}},aa=class extends On(`effect/socket/Socket/SocketCloseError`)({_tag:mn(`SocketCloseError`),code:Mn,closeReason:$t(Gn)}){static filterClean(e){return function(t){return sa.is(t)&&t.reason._tag===`SocketCloseError`&&e(t.reason.code)?Eee(t.reason):Iee(t)}}get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},oa=Dn([ra,oie,ia,aa]),sa=class extends ine(na)(`SocketError`,{_tag:mn(`SocketError`),reason:oa}){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[na]=na;static is(e){return aie(e)}message=this.reason.message},sie=e=>!0,cie=class extends Ot()(`~effect/socket/Socket/WebSocket`){},ca=class extends Ot()(`@effect/platform/Socket/WebSocketConstructor`){},lie=(e,t)=>ca.use(n=>uie(ke((typeof e==`string`?et(e):e).pipe(Ze(e=>n(e,t?.protocols))),e=>ct(()=>e.close(1e3))),t)),uie=(e,t)=>Nt(n=>{let i,a=lt(!1),o=n.context,s=t?.closeCodeIsError??sie,c=(n,c)=>bee(Xe(function*(o){let l=yield*Qre().pipe(ee(o)),u=yield*ee(e,o),d=yield*De(nie(l)(),cie,u),f=!1;function p(e){if(e.data instanceof Blob){let t=bt(ft(()=>e.data.arrayBuffer()),e=>{let t=n(new Uint8Array(e));return it(t)?t:rt});return d(t)}let t=n(e.data);it(t)&&d(t)}function m(e){u.removeEventListener(`message`,p),u.removeEventListener(`close`,h),Et(l.deferred,r(new sa({reason:f?new ra({cause:e}):new ia({kind:`Unknown`,cause:e})})))}function h(e){let t=typeof e.code==`number`?e.code:1001;u.removeEventListener(`message`,p),u.removeEventListener(`error`,m),Et(l.deferred,r(new sa({reason:new aa({code:t,closeReason:e.reason})})))}if(u.addEventListener(`close`,h,{once:!0}),u.addEventListener(`error`,m,{once:!0}),u.addEventListener(`message`,p),u.readyState!==1){let e=Ge();u.addEventListener(`open`,()=>{f=!0,Et(e,rt)},{once:!0}),yield*ue(e).pipe(jt({duration:t?.openTimeout??1e4,orElse:()=>r(new sa({reason:new ia({kind:`Timeout`,cause:Error(`timeout waiting for "open"`)})}))}),O($i(l)))}return f=!0,i=u,a.openUnsafe(),c?.onOpen&&(yield*c.onOpen),yield*ce($i(l),aa.filterClean(e=>!s(e)),()=>rt)})).pipe(gt(e=>ht(o,e)),Ke(ct(()=>{a.closeUnsafe(),i=void 0}))),l=new TextEncoder,u=(e,t)=>c(t=>typeof t==`string`?e(l.encode(t)):t instanceof Uint8Array?e(t):e(new Uint8Array(t)),t),d=et(e=>a.whenOpen(ct(()=>{let t=i;iie(e)?t.close(e.code,e.reason):t.send(e)})));return et(ta.of({[ea]:ea,run:u,runRaw:c,writer:d}))}),la=Se(lie,dt(ta)),ua=class extends Ot()(`effect/workers/Transferable/Collector`){},die=()=>{let e=[],t=t=>{e.push(...t)},n=()=>e,r=()=>{let t=e;return e=[],t};return ua.of({addAllUnsafe:t,addAll:e=>ct(()=>t(e)),readUnsafe:n,read:ct(n),clearUnsafe:r,clear:ct(r)})},fie=`~effect/workers/WorkerError`,pie=class extends On(`effect/workers/WorkerError/WorkerSpawnError`)({_tag:mn(`WorkerSpawnError`),message:Gn,cause:$t(Rn)}){},mie=class extends On(`effect/workers/WorkerError/WorkerSendError`)({_tag:mn(`WorkerSendError`),message:Gn,cause:$t(Rn)}){},hie=class extends On(`effect/workers/WorkerError/WorkerReceiveError`)({_tag:mn(`WorkerReceiveError`),message:Gn,cause:$t(Rn)}){},gie=class extends On(`effect/workers/WorkerError/WorkerUnknownError`)({_tag:mn(`WorkerUnknownError`),message:Gn,cause:$t(Rn)}){},da=Dn([pie,mie,hie,gie]);On(fie)({_tag:mn(`WorkerError`),reason:da});var fa=`~effect/rpc/RpcClientError`,pa=class extends On(`effect/rpc/RpcClientError/RpcClientDefect`)({_tag:mn(`RpcClientDefect`),message:Gn,cause:Rn}){},ma=class extends On(fa)({_tag:mn(`RpcClientError`),reason:Dn([da,oa,Wte,pa])}){[fa]=fa;get message(){return`${this.reason._tag}: ${this.reason.message}`}},ha=e=>typeof e==`bigint`?e:BigInt(e),_ie={_tag:`Ping`},ga;try{ga=new TextDecoder}catch{}var I,_a,L=0,va=[],ya=va,ba=0,xa={},Sa,Ca,wa=0,Ta=0,Ea,Da,Oa=[],ka,Aa={useRecords:!1,mapsAsObjects:!0},ja=class{},Ma=new ja;Ma.name=`MessagePack 0xC1`;var Na=!1,Pa=2,Fa,Ia,La;try{Function(``)}catch{Pa=1/0}var Ra=class e{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=0&&(e.structures=[],e.maxSharedStructures||=0)),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType=`number`)),Object.assign(this,e)}unpack(t,n){if(I)return so(()=>(co(),this?this.unpack(t,n):e.prototype.unpack.call(Aa,t,n)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<`u`?Buffer.from(t):new Uint8Array(t)),typeof n==`object`?(_a=n.end||t.length,L=n.start||0):(L=0,_a=n>-1?n:t.length),ba=0,Ta=0,Ca=null,ya=va,Ea=null,I=t;try{ka=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(e){throw I=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(xa=this,this.structures)return Sa=this.structures,za(n);(!Sa||Sa.length>0)&&(Sa=[])}else xa=Aa,(!Sa||Sa.length>0)&&(Sa=[]);return za(n)}unpackMultiple(e,t){let n,r=0;try{Na=!0;let i=e.length,a=this?this.unpack(e,i):uo.unpack(e,i);if(t){if(t(a,r,L)===!1)return;for(;L<i;)if(r=L,t(za(),r,L)===!1)return}else{for(n=[a];L<i;)r=L,n.push(za());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{Na=!1,co()}}_mergeStructures(e,t){Ia&&(e=Ia.call(this,e)),e||=[],Object.isFrozen(e)&&(e=e.map(e=>e.slice(0)));for(let t=0,n=e.length;t<n;t++){let n=e[t];n&&(n.isShared=!0,t>=32&&(n.highByte=t-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let r=e[n],i=t[n];i&&(r&&((e.restoreStructures||(e.restoreStructures=[]))[n]=r),e[n]=i)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function za(e){try{if(!xa.trusted&&!Na){let e=Sa.sharedLength||0;e<Sa.length&&(Sa.length=e)}let t;if(xa.randomAccessStructure&&I[L]<64&&I[L]>=32&&Fa?(t=Fa(I,L,_a,xa),I=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),L=_a):t=Va(),Ea&&=(L=Ea.postBundlePosition,null),Na&&(Sa.restoreStructures=null),L==_a)Sa&&Sa.restoreStructures&&Ba(),Sa=null,I=null,Da&&=null;else if(L>_a)throw Error(`Unexpected end of MessagePack data`);else if(!Na){let e;try{e=JSON.stringify(t,(e,t)=>typeof t==`bigint`?`${t}n`:t).slice(0,100)}catch(t){e=`(JSON view not available `+t+`)`}throw Error(`Data read, but end of buffer not reached `+e)}return t}catch(e){throw Sa&&Sa.restoreStructures&&Ba(),co(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`)||L>_a)&&(e.incomplete=!0),e}}function Ba(){for(let e in Sa.restoreStructures)Sa[e]=Sa.restoreStructures[e];Sa.restoreStructures=null}function Va(){let e=I[L++];if(e<160)if(e<128){if(e<64)return e;{let t=Sa[e&63]||xa.getStructures&&Wa()[e&63];return t?(t.read||=Ha(t,e&63),t.read()):e}}else if(e<144){if(e-=128,xa.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=no();e===`__proto__`&&(e=`__proto_`),t[e]=Va()}return t}{let t=new Map;for(let n=0;n<e;n++)t.set(Va(),Va());return t}}else{e-=144;let t=Array(e);for(let n=0;n<e;n++)t[n]=Va();return xa.freezeData?Object.freeze(t):t}if(e<192){let t=e-160;if(Ta>=L)return Ca.slice(L-wa,(L+=t)-wa);if(Ta==0&&_a<140){let e=t<16?Za(t):Xa(t);if(e!=null)return e}return Ga(t)}{let t;switch(e){case 192:return null;case 193:return Ea?(t=Va(),t>0?Ea[1].slice(Ea.position1,Ea.position1+=t):Ea[0].slice(Ea.position0,Ea.position0-=t)):Ma;case 194:return!1;case 195:return!0;case 196:if(t=I[L++],t===void 0)throw Error(`Unexpected end of buffer`);return $a(t);case 197:return t=ka.getUint16(L),L+=2,$a(t);case 198:return t=ka.getUint32(L),L+=4,$a(t);case 199:return eo(I[L++]);case 200:return t=ka.getUint16(L),L+=2,eo(t);case 201:return t=ka.getUint32(L),L+=4,eo(t);case 202:if(t=ka.getFloat32(L),xa.useFloat32>2){let e=lo[(I[L]&127)<<1|I[L+1]>>7];return L+=4,(e*t+(t>0?.5:-.5)>>0)/e}return L+=4,t;case 203:return t=ka.getFloat64(L),L+=8,t;case 204:return I[L++];case 205:return t=ka.getUint16(L),L+=2,t;case 206:return t=ka.getUint32(L),L+=4,t;case 207:return xa.int64AsType===`number`?(t=ka.getUint32(L)*4294967296,t+=ka.getUint32(L+4)):xa.int64AsType===`string`?t=ka.getBigUint64(L).toString():xa.int64AsType===`auto`?(t=ka.getBigUint64(L),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=ka.getBigUint64(L),L+=8,t;case 208:return ka.getInt8(L++);case 209:return t=ka.getInt16(L),L+=2,t;case 210:return t=ka.getInt32(L),L+=4,t;case 211:return xa.int64AsType===`number`?(t=ka.getInt32(L)*4294967296,t+=ka.getUint32(L+4)):xa.int64AsType===`string`?t=ka.getBigInt64(L).toString():xa.int64AsType===`auto`?(t=ka.getBigInt64(L),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=ka.getBigInt64(L),L+=8,t;case 212:if(t=I[L++],t==114)return io(I[L++]&63);{let e=Oa[t];if(e)return e.read?(L++,e.read(Va())):e.noBuffer?(L++,e()):e(I.subarray(L,++L));throw Error(`Unknown extension `+t)}case 213:return t=I[L],t==114?(L++,io(I[L++]&63,I[L++])):eo(2);case 214:return eo(4);case 215:return eo(8);case 216:return eo(16);case 217:return t=I[L++],Ta>=L?Ca.slice(L-wa,(L+=t)-wa):yie(t);case 218:return t=ka.getUint16(L),L+=2,Ta>=L?Ca.slice(L-wa,(L+=t)-wa):bie(t);case 219:return t=ka.getUint32(L),L+=4,Ta>=L?Ca.slice(L-wa,(L+=t)-wa):xie(t);case 220:return t=ka.getUint16(L),L+=2,qa(t);case 221:return t=ka.getUint32(L),L+=4,qa(t);case 222:return t=ka.getUint16(L),L+=2,Ja(t);case 223:return t=ka.getUint32(L),L+=4,Ja(t);default:if(e>=224)return e-256;if(e===void 0){let e=Error(`Unexpected end of MessagePack data`);throw e.incomplete=!0,e}throw Error(`Unknown MessagePack token `+e)}}}var vie=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Ha(e,t){function n(){if(n.count++>Pa){let n=e.read=Function(`r`,`return function(){return `+(xa.freezeData?`Object.freeze`:``)+`({`+e.map(e=>e===`__proto__`?`__proto_:r()`:vie.test(e)?e+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`})}`)(Va);return e.highByte===0&&(e.read=Ua(t,e.read)),n()}let r={};for(let t=0,n=e.length;t<n;t++){let n=e[t];n===`__proto__`&&(n=`__proto_`),r[n]=Va()}return xa.freezeData?Object.freeze(r):r}return n.count=0,e.highByte===0?Ua(t,n):n}var Ua=(e,t)=>function(){let n=I[L++];if(n===0)return t();let r=e<32?-(e+(n<<5)):e+(n<<5),i=Sa[r]||Wa()[r];if(!i)throw Error(`Record id is not defined for `+r);return i.read||=Ha(i,e),i.read()};function Wa(){let e=so(()=>(I=null,xa.getStructures()));return Sa=xa._mergeStructures(e,Sa)}var Ga=Ka,yie=Ka,bie=Ka,xie=Ka;function Ka(e){let t;if(e<16&&(t=Za(e)))return t;if(e>64&&ga)return ga.decode(I.subarray(L,L+=e));let n=L+e,r=[];for(t=``;L<n;){let e=I[L++];if(!(e&128))r.push(e);else if((e&224)==192){let t=I[L++]&63,n=(e&31)<<6|t;n<128?r.push(65533):r.push(n)}else if((e&240)==224){let t=I[L++]&63,n=I[L++]&63,i=(e&31)<<12|t<<6|n;i<2048||i>=55296&&i<=57343?r.push(65533):r.push(i)}else if((e&248)==240){let t=I[L++]&63,n=I[L++]&63,i=I[L++]&63,a=(e&7)<<18|t<<12|n<<6|i;a<65536||a>1114111?r.push(65533):a>65535?(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023,r.push(a)):r.push(a)}else r.push(65533);r.length>=4096&&(t+=Ya.apply(String,r),r.length=0)}return r.length>0&&(t+=Ya.apply(String,r)),t}function qa(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=Va();return xa.freezeData?Object.freeze(t):t}function Ja(e){if(xa.mapsAsObjects){let t={};for(let n=0;n<e;n++){let e=no();e===`__proto__`&&(e=`__proto_`),t[e]=Va()}return t}{let t=new Map;for(let n=0;n<e;n++)t.set(Va(),Va());return t}}var Ya=String.fromCharCode;function Xa(e){let t=L,n=Array(e);for(let r=0;r<e;r++){let e=I[L++];if((e&128)>0){L=t;return}n[r]=e}return Ya.apply(String,n)}function Za(e){if(e<4)if(e<2){if(e===0)return``;{let e=I[L++];if((e&128)>1){--L;return}return Ya(e)}}else{let t=I[L++],n=I[L++];if((t&128)>0||(n&128)>0){L-=2;return}if(e<3)return Ya(t,n);let r=I[L++];if((r&128)>0){L-=3;return}return Ya(t,n,r)}{let t=I[L++],n=I[L++],r=I[L++],i=I[L++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){L-=4;return}if(e<6){if(e===4)return Ya(t,n,r,i);{let e=I[L++];if((e&128)>0){L-=5;return}return Ya(t,n,r,i,e)}}if(e<8){let a=I[L++],o=I[L++];if((a&128)>0||(o&128)>0){L-=6;return}if(e<7)return Ya(t,n,r,i,a,o);let s=I[L++];if((s&128)>0){L-=7;return}return Ya(t,n,r,i,a,o,s)}{let a=I[L++],o=I[L++],s=I[L++],c=I[L++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){L-=8;return}if(e<10){if(e===8)return Ya(t,n,r,i,a,o,s,c);{let e=I[L++];if((e&128)>0){L-=9;return}return Ya(t,n,r,i,a,o,s,c,e)}}if(e<12){let l=I[L++],u=I[L++];if((l&128)>0||(u&128)>0){L-=10;return}if(e<11)return Ya(t,n,r,i,a,o,s,c,l,u);let d=I[L++];if((d&128)>0){L-=11;return}return Ya(t,n,r,i,a,o,s,c,l,u,d)}{let l=I[L++],u=I[L++],d=I[L++],f=I[L++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){L-=12;return}if(e<14){if(e===12)return Ya(t,n,r,i,a,o,s,c,l,u,d,f);{let e=I[L++];if((e&128)>0){L-=13;return}return Ya(t,n,r,i,a,o,s,c,l,u,d,f,e)}}{let p=I[L++],m=I[L++];if((p&128)>0||(m&128)>0){L-=14;return}if(e<15)return Ya(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let h=I[L++];if((h&128)>0){L-=15;return}return Ya(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}}}}}function Qa(){let e=I[L++],t;if(e<192)t=e-160;else switch(e){case 217:t=I[L++];break;case 218:t=ka.getUint16(L),L+=2;break;case 219:t=ka.getUint32(L),L+=4;break;default:throw Error(`Expected string`)}return Ka(t)}function $a(e){return xa.copyBuffers?Uint8Array.prototype.slice.call(I,L,L+=e):I.subarray(L,L+=e)}function eo(e){let t=I[L++];if(Oa[t]){let n;return Oa[t](I.subarray(L,n=L+=e),e=>{L=e;try{return Va()}finally{L=n}})}throw Error(`Unknown extension type `+t)}var to=Array(4096);function no(){let e=I[L++];if(e>=160&&e<192){if(e-=160,Ta>=L)return Ca.slice(L-wa,(L+=e)-wa);if(!(Ta==0&&_a<180))return Ga(e)}else return L--,ro(Va());let t=(e<<5^(e>1?ka.getUint16(L):e>0?I[L]:0))&4095,n=to[t],r=L,i=L+e-3,a,o=0;if(n&&n.bytes==e){for(;r<i;){if(a=ka.getUint32(r),a!=n[o++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(a=I[r++],a!=n[o++]){r=1879048192;break}if(r===i)return L=r,n.string;i-=3,r=L}for(n=[],to[t]=n,n.bytes=e;r<i;)a=ka.getUint32(r),n.push(a),r+=4;for(i+=3;r<i;)a=I[r++],n.push(a);let s=e<16?Za(e):Xa(e);return s==null?n.string=Ga(e):n.string=s}function ro(e){if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;if(xa.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(e=>[`string`,`number`,`boolean`,`bigint`].includes(typeof e)))return e.flat().toString();throw Error(`Invalid property type for record: ${typeof e}`)}var io=(e,t)=>{let n=Va().map(ro),r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,n.highByte=t);let i=Sa[e];return i&&(i.isShared||Na)&&((Sa.restoreStructures||(Sa.restoreStructures=[]))[e]=i),Sa[e]=n,n.read=Ha(n,r),n.read()};Oa[0]=()=>{},Oa[0].noBuffer=!0,Oa[66]=e=>{let t=e.byteLength%8||8,n=BigInt(e[0]&128?e[0]-256:e[0]);for(let r=1;r<t;r++)n<<=BigInt(8),n+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=(e,t)=>{let n=t-e;if(n<=40){let n=r.getBigUint64(e);for(let i=e+8;i<t;i+=8)n<<=64n,n|=r.getBigUint64(i);return n}let a=e+(n>>4<<3),o=i(e,a),s=i(a,t);return o<<BigInt((t-a)*8)|s};n=n<<BigInt((r.byteLength-t)*8)|i(t,r.byteLength)}return n};var ao={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError==`function`?AggregateError:null};Oa[101]=()=>{let e=Va();if(!ao[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return ao[e[0]](e[1],{cause:e[2]})},Oa[105]=e=>{if(xa.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=ka.getUint32(L-4);Da||=new Map;let n=I[L],r;r=n>=144&&n<160||n==220||n==221?[]:n>=128&&n<144||n==222||n==223?new Map:(n>=199&&n<=201||n>=212&&n<=216)&&I[L+1]===115?new Set:{};let i={target:r};Da.set(t,i);let a=Va();if(i.used)Object.assign(r,a);else return i.target=a;if(r instanceof Map)for(let[e,t]of a.entries())r.set(e,t);if(r instanceof Set)for(let e of Array.from(a))r.add(e);return r},Oa[112]=e=>{if(xa.structuredClone===!1)throw Error(`Structured clone extension is disabled`);let t=ka.getUint32(L-4),n=Da.get(t);return n.used=!0,n.target},Oa[115]=()=>new Set(Va());var oo=[`Int8`,`Uint8`,`Uint8Clamped`,`Int16`,`Uint16`,`Int32`,`Uint32`,`Float32`,`Float64`,`BigInt64`,`BigUint64`].map(e=>e+`Array`),Sie=typeof globalThis==`object`?globalThis:window;Oa[116]=e=>{let t=e[0],n=Uint8Array.prototype.slice.call(e,1).buffer,r=oo[t];if(!r){if(t===16)return n;if(t===17)return new DataView(n);throw Error(`Could not find typed array for code `+t)}return new Sie[r](n)},Oa[120]=()=>{let e=Va();return new RegExp(e[0],e[1])};var Cie=[];Oa[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],n=L;return L+=t-e.length,Ea=Cie,Ea=[Qa(),Qa()],Ea.position0=0,Ea.position1=0,Ea.postBundlePosition=L,L=n,Va()},Oa[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date(`invalid`);function so(e){La&&La();let t=_a,n=L,r=ba,i=wa,a=Ta,o=Ca,s=ya,c=Da,l=Ea,u=new Uint8Array(I.slice(0,_a)),d=Sa,f=Sa.slice(0,Sa.length),p=xa,m=Na,h=e();return _a=t,L=n,ba=r,wa=i,Ta=a,Ca=o,ya=s,Da=c,Ea=l,I=u,Na=m,Sa=d,Sa.splice(0,Sa.length,...f),xa=p,ka=new DataView(I.buffer,I.byteOffset,I.byteLength),h}function co(){I=null,Da=null,Sa=null}var lo=Array(147);for(let e=0;e<256;e++)lo[e]=+(`1e`+Math.floor(45.15-e*.30103));var uo=new Ra({useRecords:!1});uo.unpack,uo.unpackMultiple,uo.unpack;var wie={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4};new Uint8Array(new Float32Array(1).buffer,0,4);var fo;try{fo=new TextEncoder}catch{}var po,mo,ho=typeof Buffer<`u`,go=ho?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array,_o=ho?Buffer:Uint8Array,vo=ho?4294967296:2144337920,R,yo,bo,z=0,xo,So=null,Tie,Eie=21760,Die=/[\u0080-\uFFFF]/,Co=Symbol(`record-id`),Oie=class extends Ra{constructor(e){super(e),this.offset=0;let t,n,r,i,a=_o.prototype.utf8Write?function(e,t){return R.utf8Write(e,t,R.byteLength-t)}:fo&&fo.encodeInto?function(e,t){return fo.encodeInto(e,R.subarray(t)).written}:!1,o=this;e||={};let s=e&&e.sequential,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?32:0,l>8160)throw Error(`Maximum maxSharedStructure is 8160`);e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let u=e.maxOwnStructures;u??=c?32:64,!this.structures&&e.useRecords!=0&&(this.structures=[]);let d=l>32||u+l>64,f=l+64,p=l+u+64;if(p>8256)throw Error(`Maximum maxSharedStructure + maxOwnStructure is 8192`);let m=[],h=0,g=0;this.pack=this.encode=function(e,a){if(R||(R=new go(8192),bo=R.dataView||(R.dataView=new DataView(R.buffer,0,8192)),z=0),xo=R.length-10,xo-z<2048?(R=new go(R.length),bo=R.dataView||(R.dataView=new DataView(R.buffer,0,R.length)),xo=R.length-10,z=0):z=z+7&2147483640,t=z,a&2048&&(z+=a&255),i=o.structuredClone?new Map:null,o.bundleStrings&&typeof e!=`string`?(So=[],So.size=1/0):So=null,r=o.structures,r){r.uninitialized&&(r=o._mergeStructures(o.getStructures()));let e=r.sharedLength||0;if(e>l)throw Error(`Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to `+r.sharedLength);if(!r.transitions){r.transitions=Object.create(null);for(let t=0;t<e;t++){let e=r[t];if(!e)continue;let n,i=r.transitions;for(let t=0,r=e.length;t<r;t++){let r=e[t];n=i[r],n||=i[r]=Object.create(null),i=n}i[Co]=t+64}this.lastNamedStructuresLength=e}s||(r.nextId=e+64)}n&&=!1;let c;try{o.randomAccessStructure&&e&&typeof e==`object`?e.constructor===Object?D(e):e.constructor!==Map&&!Array.isArray(e)&&!mo.some(t=>e instanceof t)?D(e.toJSON?e.toJSON():e):y(e):y(e);let n=So;if(So&&Do(t,y,0),i&&i.idsToInsert){let e=i.idsToInsert.sort((e,t)=>e.offset>t.offset?1:-1),r=e.length,a=-1;for(;n&&r>0;){let i=e[--r].offset+t;i<n.stringsPosition+t&&a===-1&&(a=0),i>n.position+t?a>=0&&(a+=6):(a>=0&&(bo.setUint32(n.position+t,bo.getUint32(n.position+t)+a),a=-1),n=n.previous,r++)}a>=0&&n&&bo.setUint32(n.position+t,bo.getUint32(n.position+t)+a),z+=e.length*6,z>xo&&w(z),o.offset=z;let s=kie(R.subarray(t,z),e);return i=null,s}return o.offset=z,a&512?(R.start=t,R.end=z,R):R.subarray(t,z)}catch(e){throw c=e,e}finally{if(r&&(_(),n&&o.saveStructures)){let n=r.sharedLength||0,i=R.subarray(t,z),s=Aie(r,o);if(!c)return o.saveStructures(s,s.isCompatible)===!1?o.pack(e,a):(o.lastNamedStructuresLength=n,R.length>1073741824&&(R=null),i)}R.length>1073741824&&(R=null),a&1024&&(z=t)}};let _=()=>{g<10&&g++;let e=r.sharedLength||0;if(r.length>e&&!s&&(r.length=e),h>1e4)r.transitions=null,g=0,h=0,m.length>0&&(m=[]);else if(m.length>0&&!s){for(let e=0,t=m.length;e<t;e++)m[e][Co]=0;m=[]}},v=e=>{var t=e.length;t<16?R[z++]=144|t:t<65536?(R[z++]=220,R[z++]=t>>8,R[z++]=t&255):(R[z++]=221,bo.setUint32(z,t),z+=4);for(let n=0;n<t;n++)y(e[n])},y=e=>{z>xo&&(R=w(z));var n=typeof e,r;if(n===`string`){let n=e.length;if(So&&n>=4&&n<4096){if((So.size+=n)>Eie){let e,n=(So[0]?So[0].length*3+So[1].length:0)+10;z+n>xo&&(R=w(z+n));let r;So.position?(r=So,R[z]=200,z+=3,R[z++]=98,e=z-t,z+=4,Do(t,y,0),bo.setUint16(e+t-3,z-t-e)):(R[z++]=214,R[z++]=98,e=z-t,z+=4),So=[``,``],So.previous=r,So.size=0,So.position=e}let r=Die.test(e);So[+!r]+=e,R[z++]=193,y(r?-n:n);return}let i;i=n<32?1:n<256?2:n<65536?3:5;let o=n*3;if(z+o>xo&&(R=w(z+o)),n<64||!a){let t,a,o,s=z+i;for(t=0;t<n;t++)a=e.charCodeAt(t),a<128?R[s++]=a:a<2048?(R[s++]=a>>6|192,R[s++]=a&63|128):(a&64512)==55296&&((o=e.charCodeAt(t+1))&64512)==56320?(a=65536+((a&1023)<<10)+(o&1023),t++,R[s++]=a>>18|240,R[s++]=a>>12&63|128,R[s++]=a>>6&63|128,R[s++]=a&63|128):(R[s++]=a>>12|224,R[s++]=a>>6&63|128,R[s++]=a&63|128);r=s-z-i}else r=a(e,z+i);r<32?R[z++]=160|r:r<256?(i<2&&R.copyWithin(z+2,z+1,z+1+r),R[z++]=217,R[z++]=r):r<65536?(i<3&&R.copyWithin(z+3,z+2,z+2+r),R[z++]=218,R[z++]=r>>8,R[z++]=r&255):(i<5&&R.copyWithin(z+5,z+3,z+3+r),R[z++]=219,bo.setUint32(z,r),z+=4),z+=r}else if(n===`number`)if(e>>>0===e)e<32||e<128&&this.useRecords===!1||e<64&&!this.randomAccessStructure?R[z++]=e:e<256?(R[z++]=204,R[z++]=e):e<65536?(R[z++]=205,R[z++]=e>>8,R[z++]=e&255):(R[z++]=206,bo.setUint32(z,e),z+=4);else if(e>>0===e)e>=-32?R[z++]=256+e:e>=-128?(R[z++]=208,R[z++]=e+256):e>=-32768?(R[z++]=209,bo.setInt16(z,e),z+=2):(R[z++]=210,bo.setInt32(z,e),z+=4);else{let t;if((t=this.useFloat32)>0&&e<4294967296&&e>=-2147483648){R[z++]=202,bo.setFloat32(z,e);let n;if(t<4||(n=e*lo[(R[z]&127)<<1|R[z+1]>>7])>>0===n){z+=4;return}z--}R[z++]=203,bo.setFloat64(z,e),z+=8}else if(n===`object`||n===`function`)if(!e)R[z++]=192;else{if(i){let n=i.get(e);if(n){n.id||=(i.idsToInsert||(i.idsToInsert=[])).push(n),R[z++]=214,R[z++]=112,bo.setUint32(z,n.id),z+=4;return}i.set(e,{offset:z-t})}let a=e.constructor;if(a===Object)C(e);else if(a===Array)v(e);else if(a===Map)if(this.mapAsEmptyObject)R[z++]=128;else{r=e.size,r<16?R[z++]=128|r:r<65536?(R[z++]=222,R[z++]=r>>8,R[z++]=r&255):(R[z++]=223,bo.setUint32(z,r),z+=4);for(let[t,n]of e)y(t),y(n)}else{for(let t=0,n=po.length;t<n;t++){let n=mo[t];if(e instanceof n){let n=po[t];if(n.write){n.type&&(R[z++]=212,R[z++]=n.type,R[z++]=0);let t=n.write.call(this,e);t===e?Array.isArray(e)?v(e):C(e):y(t);return}let r=R,i=bo,a=z;R=null;let o;try{o=n.pack.call(this,e,e=>(R=r,r=null,z+=e,z>xo&&w(z),{target:R,targetView:bo,position:z-e}),y)}finally{r&&(R=r,bo=i,z=a,xo=R.length-10)}o&&(o.length+z>xo&&w(o.length+z),z=Eo(o,R,z,n.type));return}}if(Array.isArray(e))v(e);else{if(e.toJSON){let t=e.toJSON();if(t!==e)return y(t)}if(n===`function`)return y(this.writeFunction&&this.writeFunction(e));C(e)}}}else if(n===`boolean`)R[z++]=e?195:194;else if(n===`bigint`){if(e<0x8000000000000000&&e>=-0x8000000000000000)R[z++]=211,bo.setBigInt64(z,e);else if(e<0x10000000000000000&&e>0)R[z++]=207,bo.setBigUint64(z,e);else if(this.largeBigIntToFloat)R[z++]=203,bo.setFloat64(z,Number(e));else if(this.largeBigIntToString)return y(e.toString());else if(this.useBigIntExtension||this.moreTypes){let t=BigInt(e<0?-1:0),n;if(e>>BigInt(65536)===t){let r=BigInt(0x10000000000000000)-BigInt(1),i=[];for(;i.push(e&r),e>>BigInt(63)!==t;)e>>=BigInt(64);n=new Uint8Array(new BigUint64Array(i).buffer),n.reverse()}else{let t=e<0,r=(t?~e:e).toString(16);if(r.length%2?r=`0`+r:parseInt(r.charAt(0),16)>=8&&(r=`00`+r),ho)n=Buffer.from(r,`hex`);else{n=new Uint8Array(r.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(r.slice(e*2,e*2+2),16)}if(t)for(let e=0;e<n.length;e++)n[e]=~n[e]}n.length+z>xo&&w(n.length+z),z=Eo(n,R,z,66);return}else throw RangeError(e+` was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string`);z+=8}else if(n===`undefined`)this.encodeUndefinedAsNil?R[z++]=192:(R[z++]=212,R[z++]=0,R[z++]=0);else throw Error(`Unknown type: `+n)},b=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?e=>{let t;if(this.skipValues){t=[];for(let n in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(n))&&!this.skipValues.includes(e[n])&&t.push(n)}else t=Object.keys(e);let n=t.length;n<16?R[z++]=128|n:n<65536?(R[z++]=222,R[z++]=n>>8,R[z++]=n&255):(R[z++]=223,bo.setUint32(z,n),z+=4);let r;if(this.coercibleKeyAsNumber)for(let i=0;i<n;i++){r=t[i];let n=Number(r);y(isNaN(n)?r:n),y(e[r])}else for(let i=0;i<n;i++)y(r=t[i]),y(e[r])}:e=>{R[z++]=222;let n=z-t;z+=2;let r=0;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(y(t),y(e[t]),r++);if(r>65535)throw Error(`Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object`);R[n+++t]=r>>8,R[n+t]=r&255},x=this.useRecords===!1?b:e.progressiveRecords&&!d?e=>{let n,i=r.transitions||(r.transitions=Object.create(null)),a=z++-t,o;for(let s in e)if(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(s)){if(n=i[s],n)i=n;else{let c=Object.keys(e),l=i;i=r.transitions;let u=0;for(let e=0,t=c.length;e<t;e++){let t=c[e];n=i[t],n||(n=i[t]=Object.create(null),u++),i=n}a+t+1==z?(z--,T(i,c,u)):E(i,c,a,u),o=!0,i=l[s]}y(e[s])}if(!o){let n=i[Co];n?R[a+t]=n:E(i,Object.keys(e),a,0)}}:e=>{let t,n=r.transitions||(r.transitions=Object.create(null)),i=0;for(let r in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(r))&&(t=n[r],t||(t=n[r]=Object.create(null),i++),n=t);let a=n[Co];a?a>=96&&d?(R[z++]=((a-=96)&31)+96,R[z++]=a>>5):R[z++]=a:T(n,n.__keys__||Object.keys(e),i);for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&y(e[t])},S=typeof this.useRecords==`function`&&this.useRecords,C=S?e=>{S(e)?x(e):b(e)}:x,w=e=>{let n;if(e>16777216){if(e-t>vo)throw Error(`Packed buffer would be larger than maximum buffer size`);n=Math.min(vo,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,R.length-1)>>12)+1<<12;let r=new go(n);return bo=r.dataView||=new DataView(r.buffer,0,n),e=Math.min(e,R.length),R.copy?R.copy(r,0,t,e):r.set(R.slice(t,e)),z-=t,t=0,xo=r.length-10,R=r},T=(e,t,i)=>{let a=r.nextId;a||=64,a<f&&this.shouldShareStructure&&!this.shouldShareStructure(t)?(a=r.nextOwnId,a<p||(a=f),r.nextOwnId=a+1):(a>=p&&(a=f),r.nextId=a+1);let o=t.highByte=a>=96&&d?a-96>>5:-1;e[Co]=a,e.__keys__=t,r[a-64]=t,a<f?(t.isShared=!0,r.sharedLength=a-63,n=!0,o>=0?(R[z++]=(a&31)+96,R[z++]=o):R[z++]=a):(o>=0?(R[z++]=213,R[z++]=114,R[z++]=(a&31)+96,R[z++]=o):(R[z++]=212,R[z++]=114,R[z++]=a),i&&(h+=g*i),m.length>=u&&(m.shift()[Co]=0),m.push(e),y(t))},E=(e,n,r,i)=>{let a=R,o=z,s=xo,c=t;R=yo,z=0,t=0,R||(yo=R=new go(8192)),xo=R.length-10,T(e,n,i),yo=R;let l=z;if(R=a,z=o,xo=s,t=c,l>1){let e=z+l-1;e>xo&&w(e);let n=r+t;R.copyWithin(n+l,n+1,z),R.set(yo.slice(0,l),n),z=e}else R[r+t]=yo[0]},D=e=>{let i=Tie(e,R,t,z,r,w,(e,t,r)=>{if(r)return n=!0;z=t;let i=R;return y(e),_(),i===R?z:{position:z,targetView:bo,target:R}},this);if(i===0)return C(e);z=i}}useBuffer(e){R=e,R.dataView||(R.dataView=new DataView(R.buffer,R.byteOffset,R.byteLength)),bo=R.dataView,z=0}set position(e){z=e}get position(){return z}clearSharedData(){this.structures&&=[],this.typedStructs&&=[]}};mo=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,ja],po=[{pack(e,t,n){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:e,targetView:n,position:i}=t(6);e[i++]=214,e[i++]=255,n.setUint32(i,r)}else if(r>0&&r<4294967296){let{target:n,targetView:i,position:a}=t(10);n[a++]=215,n[a++]=255,i.setUint32(a,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),i.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),n(this.onInvalidDate());let{target:e,targetView:r,position:i}=t(3);e[i++]=212,e[i++]=255,e[i++]=255}else{let{target:n,targetView:i,position:a}=t(15);n[a++]=199,n[a++]=12,n[a++]=255,i.setUint32(a,e.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(e,t,n){if(this.setAsEmptyObject)return t(0),n({});let r=Array.from(e),{target:i,position:a}=t(this.moreTypes?3:0);this.moreTypes&&(i[a++]=212,i[a++]=115,i[a++]=0),n(r)}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=101,r[i++]=0),n([e.name,e.message,e.cause])}},{pack(e,t,n){let{target:r,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(r[i++]=212,r[i++]=120,r[i++]=0),n([e.source,e.flags])}},{pack(e,t){this.moreTypes?wo(e,16,t):To(ho?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let n=e.constructor;n!==_o&&this.moreTypes?wo(e,oo.indexOf(n.name),t):To(e,t)}},{pack(e,t){this.moreTypes?wo(e,17,t):To(ho?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let{target:n,position:r}=t(1);n[r]=193}}];function wo(e,t,n,r){let i=e.byteLength;if(i+1<256){var{target:a,position:o}=n(4+i);a[o++]=199,a[o++]=i+1}else if(i+1<65536){var{target:a,position:o}=n(5+i);a[o++]=200,a[o++]=i+1>>8,a[o++]=i+1&255}else{var{target:a,position:o,targetView:s}=n(7+i);a[o++]=201,s.setUint32(o,i+1),o+=4}a[o++]=116,a[o++]=t,e.buffer||(e=new Uint8Array(e)),a.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),o)}function To(e,t){let n=e.byteLength;var r,i;if(n<256){var{target:r,position:i}=t(n+2);r[i++]=196,r[i++]=n}else if(n<65536){var{target:r,position:i}=t(n+3);r[i++]=197,r[i++]=n>>8,r[i++]=n&255}else{var{target:r,position:i,targetView:a}=t(n+5);r[i++]=198,a.setUint32(i,n),i+=4}r.set(e,i)}function Eo(e,t,n,r){let i=e.length;switch(i){case 1:t[n++]=212;break;case 2:t[n++]=213;break;case 4:t[n++]=214;break;case 8:t[n++]=215;break;case 16:t[n++]=216;break;default:i<256?(t[n++]=199,t[n++]=i):i<65536?(t[n++]=200,t[n++]=i>>8,t[n++]=i&255):(t[n++]=201,t[n++]=i>>24,t[n++]=i>>16&255,t[n++]=i>>8&255,t[n++]=i&255)}return t[n++]=r,t.set(e,n),n+=i,n}function kie(e,t){let n,r=t.length*6,i=e.length-r;for(;n=t.pop();){let t=n.offset,a=n.id;e.copyWithin(t+r,t,i),r-=6;let o=t+r;e[o++]=214,e[o++]=105,e[o++]=a>>24,e[o++]=a>>16&255,e[o++]=a>>8&255,e[o++]=a&255,i=t}return e}function Do(e,t,n){if(So.length>0){bo.setUint32(So.position+e,z+n-So.position-e),So.stringsPosition=z-e;let r=So;So=null,t(r[0]),t(r[1])}}function Aie(e,t){return e.isCompatible=e=>{let n=!e||(t.lastNamedStructuresLength||0)===e.length;return n||t._mergeStructures(e),n},e}var Oo=new Oie({useRecords:!1});Oo.pack,Oo.pack;var{NEVER:jie,ALWAYS:Mie,DECIMAL_ROUND:Nie,DECIMAL_FIT:Pie}=wie,ko=class extends Ot()(`effect/rpc/RpcSerialization`){},Fie=ko.of({contentType:`application/json`,includesFraming:!1,makeUnsafe:()=>{let e=new TextDecoder;return{decode:t=>{let n=JSON.parse(typeof t==`string`?t:e.decode(t));return Array.isArray(n)?n:[n]},encode:e=>JSON.stringify(e)}}}),Ao=pe(ko)(Fie),Iie=e=>Dt(()=>{let t=new Set,n=new Map,r=new Map,i=(e,t)=>ie(r=>{let i=n.get(e);return i||(i=[],n.set(e,i)),i.push([t,r]),rt});return Ze(e((e,t)=>{let n=r.get(e);return n?n(t):i(e,t)},t),e=>({...e,run(e,i){return nt(function*(){t.add(e),r.set(e,i);let a=n.get(e);if(a){n.delete(e);for(let[e,t]of a)yield*Ce(Dt(()=>i(e)),t)}return yield*ree(w,()=>(t.delete(e),r.delete(e),rt))})}}))}),Lie=BigInt(0),Rie=Xe(function*(e,t){let n=t?.spanPrefix??`RpcClient`,r=t?.supportsAck??!0,i=t?.disableTracing??!1,a=t?.generateRequestId??(()=>Lie++),o=yield*Tt(),s=At(o,je),c=new Map,l=!1;yield*zt(s,Nt(e=>(l=!0,u(Lee(e.id)))));let u=Xe(function*(e){for(let[t,n]of c)c.delete(t),n._tag===`Queue`?yield*e._tag===`Success`?Pt(n.queue):Pe(n.queue,e.cause):n.resume(e)}),d=e=>{let r=cne(e.successSchema),a=g(e);return(o,s)=>{let c=s?.headers?vn(s.headers):pn,l=s?.context??Gee();if(!r){let r=t=>p(e,a,t,e.payloadSchema.make(o),c,l,s?.discard??!1);return i?r(void 0):at(`${n}.${e._tag}`,{attributes:t.spanAttributes},r)}let u=m(e,a,e.payloadSchema.make(o),c,s?.streamBufferSize??16,l);return s?.asQueue?u:lte(Ze(u,tte))}},p=(e,n,r,i,o,s,u)=>Nt(d=>{if(l)return vt;let f=a(),p=n(e=>t.onFromClient({message:e,context:s,discard:u}),{_tag:`Request`,id:f,tag:e._tag,payload:i,...r?{traceId:r.traceId,spanId:r.spanId,sampled:r.sampled}:{},headers:en(d.getRef(No),o)});if(u)return p;let m;return pt(Le(t=>{let n={_tag:`Effect`,rpc:e,context:s,resume(e){t(e),m&&!m.pollUnsafe()&&d.currentDispatcher.scheduleTask(()=>{m.interruptUnsafe(d.id)},0)}};c.set(f,n),m=p.pipe(r?Lt(r,{captureStackTrace:!1}):Te,He(d.context)),m.addObserver(e=>{if(e._tag===`Failure`)return t(e)})}),e=>(c.delete(f),Rt(iee(m),_(f,Array.from(e),s))))}),m=Xe(function*(e,r,o,s,u,d){if(l)return yield*vt;let p=i?void 0:yield*pte(`${n}.${e._tag}`,{attributes:t.spanAttributes}),m=xe(),g=a(),v=Nee(m.context,je);yield*f(v,e=>c.has(g)?(c.delete(g),_(g,yt(e)?Array.from(wee(e.cause)):[],d)):rt);let y=yield*h(u);return c.set(g,{_tag:`Queue`,rpc:e,queue:y,scope:v,context:d}),yield*r(e=>t.onFromClient({message:e,context:d,discard:!1}),{_tag:`Request`,id:g,tag:e._tag,payload:o,...p?{traceId:p.traceId,spanId:p.spanId,sampled:p.sampled}:{},headers:en(m.getRef(No),s)}).pipe(p?Lt(p,{captureStackTrace:!1}):Te,Ue(e=>Pe(y,e)),st,Mt(v,{startImmediately:!0})),y}),g=e=>{let t=[];for(let n of e.middlewares.values()){let e=o.mapUnsafe.get(`${n.key}/Client`);e&&t.push(e)}return t.length===0?(e,t)=>e(t):function n(r,i,a=t.length-1){return a===-1?r(i):t[a]({rpc:e,request:i,next(e){return n(r,e,a-1)}})}},_=(e,n,r)=>Le(i=>{let a=xe();t.onFromClient({message:{_tag:`Interrupt`,requestId:e,interruptors:n},context:r,discard:!1}).pipe(Mee(1e3),He(a.context)).addObserver(()=>{i(rt)})}),v=e=>{switch(e._tag){case`Chunk`:{let n=e.requestId,i=c.get(n);return!i||i._tag!==`Queue`?rt:we(i.queue,e.values).pipe(r?bt(()=>t.onFromClient({message:{_tag:`Ack`,requestId:e.requestId},context:i.context,discard:!1})):Te,Ue(e=>Pe(i.queue,e)))}case`Exit`:{let t=e.requestId,n=c.get(t);return n?(c.delete(t),n._tag===`Effect`?(n.resume(e.exit),rt):e.exit._tag===`Success`?Pt(n.queue):Pe(n.queue,e.exit.cause)):rt}case`Defect`:return u(_ee(e.defect));case`ClientEnd`:return rt}},y;if(t.flatten){let t=new Map;y=function(n,r,i){let a=t.get(n);return a||(a=d(e.requests.get(n)),t.set(n,a)),a(r,i)}}else y={},e.requests.forEach(e=>{y[e._tag]=d(e)});return{client:y,write:v}}),zie=0,jo=Xe(function*(e,t){let n=zie++,{run:r,send:i,supportsAck:a,supportsTransferables:o}=yield*Po,s=new Map,{client:c,write:u}=yield*Rie(e,{...t,supportsAck:a,onFromClient({message:t}){switch(t._tag){case`Request`:{let r=e.requests.get(t.tag),a=o?die():void 0,c=xe(),u={rpc:r,context:a?jee(c.context,ua,a):c.context,schemas:Bie(r)};return s.set(t.id,u),u.schemas.encodePayload(t.payload).pipe(Ce(u.context),l,bt(e=>i(n,{...t,id:String(t.id),payload:e,headers:Object.entries(t.headers)},a&&a.readUnsafe())))}case`Ack`:return s.get(t.requestId)?i(n,{_tag:`Ack`,requestId:String(t.requestId)}):rt;case`Interrupt`:return s.get(t.requestId)?(s.delete(t.requestId),i(n,{_tag:`Interrupt`,requestId:String(t.requestId)})):rt;case`Eof`:return rt}}});return yield*r(n,e=>{switch(e._tag){case`Chunk`:{let t=ha(e.requestId),n=s.get(t);return!n||ote(n.schemas.decodeChunk)?rt:n.schemas.decodeChunk.value(e.values).pipe(Ce(n.context),l,bt(t=>u({_tag:`Chunk`,clientId:0,requestId:ha(e.requestId),values:t})),b(t=>u({_tag:`Exit`,clientId:0,requestId:ha(e.requestId),exit:Oe(t)})))}case`Exit`:{let t=ha(e.requestId),n=s.get(t);return n?(s.delete(t),n.schemas.decodeExit(e.exit).pipe(Ce(n.context),l,Ie({onSuccess:e=>u({_tag:`Exit`,clientId:0,requestId:t,exit:e}),onFailure:e=>u({_tag:`Exit`,clientId:0,requestId:t,exit:Oe(e)})}))):rt}case`Defect`:return u({_tag:`Defect`,clientId:0,defect:Wie(e.defect)});case`ClientProtocolError`:{let t=Je(e.error);return kt(s.keys(),e=>u({_tag:`Exit`,clientId:0,requestId:e,exit:t}))}default:return rt}}).pipe(Ue(ate),st,$e),c}),Mo=new WeakMap,Bie=e=>{let t=Mo.get(e);if(t!==void 0)return t;let n=Ete(e.successSchema);return t={decodeChunk:Uee(n,e=>yn(gn(dne(e.success)))),encodePayload:qte(gn(e.payloadSchema)),decodeExit:yn(gn(lne(e)))},Mo.set(e,t),t},No=xt(`effect/rpc/RpcClient/CurrentHeaders`,{defaultValue:()=>pn}),Po=class extends Ot()(`effect/rpc/RpcClient/Protocol`){static make=Iie},Fo=e=>Po.make(Xe(function*(t,n){let i=yield*ta,a=yield*ko,o=yield*aee(Uie),s=new Map,c=yield*i.writer,d=a.makeUnsafe(),f=yield*Hie(c(d.encode(_ie))),p,m=Dt(()=>(p=void 0,x(o)?o.value.onConnect:rt)),h=e=>kt(n,n=>t(n,e));return yield*Dt(()=>(d=a.makeUnsafe(),f.reset(),i.runRaw(e=>{try{let n=d.decode(e);if(n.length===0)return;let r=0;return Cee({while:()=>r<n.length,body:()=>{let e=n[r++];if(e._tag===`Pong`)return f.onPong(),rt;if(`requestId`in e){let n=s.get(e.requestId);if(n!==void 0)return e._tag===`Exit`&&s.delete(e.requestId),t(n,e)}return h(e)},step:Bee})}catch(e){return h({_tag:`ClientProtocolError`,error:new ma({reason:new pa({message:`Error decoding message`,cause:e})})})}},{onOpen:m}).pipe(O(bt(f.timeout,()=>r(new sa({reason:new ia({kind:`Timeout`,cause:Error(`ping timeout`)})}))))))).pipe(bt(()=>r(new sa({reason:new aa({code:1e3})}))),x(o)?Ke(o.value.onDisconnect):Te,Yee(t=>{let n=Ree(t),r=Jee(n);return e?.retryTransientErrors&&r&&n.success.reason._tag===`SocketOpenError`?rt:(p=new ma({reason:r?n.success.reason:new pa({message:`Unknown socket error`,cause:Fe(t)})}),h({_tag:`ClientProtocolError`,error:p}))}),he(e?.retryPolicy??Vie),u({module:`RpcClient`,method:`makeProtocolSocket`}),$e),{send(e,t){if(p)return r(p);t._tag===`Request`&&s.set(t.id,e);let n=d.encode(t);return n===void 0?rt:l(c(n))},supportsAck:!0,supportsTransferables:!1}})),Vie=_(500,1.5).pipe(see(nee(5e3))),Hie=Xe(function*(e){let t=!0,n=0,r=lt();return yield*Dt(()=>t?(t=!1,n=0,e):(n+=1,n>=3?r.open:e)).pipe(vee(`5 seconds`),wt,Qe,st,$e),{timeout:r.await,reset:()=>{t=!0,n=0,r.closeUnsafe()},onPong:()=>{t=!0,n=0}}}),Uie=class extends Ot()(`effect/rpc/RpcClient/ConnectionHooks`){},Wie=kn(Rn);function Io(e){return{id:e.id??`ws:${e.label}`,label:e.label,source:e.source??`manual`,target:e.target}}function Gie(e){return e?.target.wsBaseUrl??null}function Kie(e){return e?.target.httpBaseUrl??null}function qie(e,t){return{...e,environmentId:t.environmentId,label:t.label}}function Jie(e){return e.cloudMode?`cmmd-cloud-runtime`:`local-web`}function Yie(e){let t=Jie(e);return{topology:t,controlPlane:t!==`cmmd-cloud-runtime`,executionPlane:!0,workspaceProxy:!1}}function Xie(e){let t=e.topology===`cmmd-cloud-runtime`;return{cmmd:!0,ownerBootstrapPromotion:e.topology!==`cloud-shell`&&!t,bearerBootstrap:!0,desktopBootstrap:e.topology===`desktop-local`,providerCredentialBroker:e.topology===`cmmd-control-plane`}}function Zie(e){let t=e.executionPlane;return{agents:t,browser:t,github:t,terminal:t,providerEgress:e.topology===`cmmd-control-plane`}}function Qie(e,t){return{localProjects:t.executionPlane,cloudProjects:e.cloudMode}}function Lo(e){let t=e.capabilities,n=t.runtime??Yie(t);return{repositoryIdentity:t.repositoryIdentity,pullRequests:t.pullRequests??!1,cloudMode:t.cloudMode,posthogPublicKey:t.posthogPublicKey,posthogHost:t.posthogHost,runtime:n,auth:t.auth??Xie(n),tools:t.tools??Zie(n),projects:t.projects??Qie(t,n)}}function $ie(e){return e?Lo(e).projects.cloudProjects:!1}function eae(e){return e?Lo(e).runtime.workspaceProxy??!1:!1}function Ro(e,t){return{environmentId:e,projectId:t}}function zo(e,t){return{environmentId:e,threadId:t}}var Bo=`scoped:v1:`;function Vo(e){let t=`projectId`in e?e.projectId:e.threadId;return t.includes(`:`)||e.environmentId.startsWith(Bo)?`${Bo}${encodeURIComponent(e.environmentId)}:${encodeURIComponent(t)}`:`${e.environmentId}:${t}`}function Ho(e){return Vo(e)}function Uo(e){return Vo(e)}function tae(e){let t=e.slice(10),n=t.indexOf(`:`);if(n<=0||n>=t.length-1||t.indexOf(`:`,n+1)!==-1)return null;try{let e=decodeURIComponent(t.slice(0,n)),r=decodeURIComponent(t.slice(n+1));return e.length>0&&r.length>0?{environmentId:e,localId:r}:null}catch{return null}}function Wo(e){if(e.startsWith(Bo))return tae(e);let t=e.lastIndexOf(`:`);return t<=0||t>=e.length-1?null:{environmentId:e.slice(0,t),localId:e.slice(t+1)}}function Go(e){let t=Wo(e);return t?{environmentId:t.environmentId,projectId:t.localId}:null}function Ko(e){let t=Wo(e);return t?{environmentId:t.environmentId,threadId:t.localId}:null}var nae=1e3,rae=64e3;jo(Wn);function iae(e){return!Number.isInteger(e)||e<0||e>=10?null:Math.min(Math.round(nae*2**e),rae)}var qo=class extends Error{code;retryable;name=`RelayProtocolFailure`;constructor(e,t,n){super(t),this.code=e,this.retryable=n}};function Jo(e){return Array.isArray(e)?e.map(Jo):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,Jo(t)])):e}function aae(e){let t=JSON.stringify(Jo(e));if(t===void 0)throw Error(`Relay payload is not JSON serializable.`);return t}var oae={requestId:`@effect/rpc/Ping`,correlationId:`@effect/rpc/Ping`,method:`@effect/rpc/Ping`,requiredScope:null,deliveryClass:`read`,journalPersistence:`none`};function sae(e){return e._tag===`Ping`?oae:null}function cae(e){if(e.policy===null||e.policy.method!==e.method)throw new qo(`method_not_remotable`,`Relay method has no exact dispatch policy: ${e.method}`,!1);if(e.policy.requiredScope!==null&&!e.grantedScopes.includes(e.policy.requiredScope))throw new qo(`scope_denied`,`Relay method ${e.method} requires scope ${e.policy.requiredScope}`,!1);return{requiredScope:e.policy.requiredScope,deliveryClass:e.policy.deliveryClass,journalPersistence:e.policy.journalPersistence}}function lae(e){let t=new Set(e.registeredMethods),n=new Map;for(let r of e.policies){if(n.has(r.method))throw new qo(`method_not_remotable`,`Relay method has duplicate dispatch policies: ${r.method}`,!1);if(!t.has(r.method))throw new qo(`method_not_remotable`,`Relay dispatch policy targets an unregistered method: ${r.method}`,!1);if((r.deliveryClass===`idempotent-command`||r.deliveryClass===`create-command`)==(r.journalPersistence===`none`))throw new qo(`method_not_remotable`,`Relay dispatch policy has incompatible journal persistence: ${r.method}`,!1);n.set(r.method,r)}for(let t of e.registeredMethods)if(!n.has(t))throw new qo(`method_not_remotable`,`Remotely registered method has no dispatch policy: ${t}`,!1);return n}var uae=[{method:M.projectsSearchEntries,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.projectsListEntries,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.serverDiscoverSourceControl,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.serverReportClientActivity,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.codeGraphSummary,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.codeGraphNeighborhood,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.codeGraphSearch,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.projectsWriteFile,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.projectCheckoutDeletionPreview,requiredScope:`workspace.write`,deliveryClass:`read`},{method:M.projectCheckoutDeletionExecute,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.workspaceReadFile,requiredScope:`workspace.read`,deliveryClass:`bulk-transfer`},{method:M.workspaceBeginWriteFile,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.workspaceWriteFileChunk,requiredScope:`workspace.write`,deliveryClass:`bulk-transfer`},{method:M.workspaceCommitWriteFile,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.workspaceCancelWriteFile,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.shellOpenInEditor,requiredScope:`shell.open`,deliveryClass:`idempotent-command`},{method:M.gitPull,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitRefreshStatus,requiredScope:`git.read`,deliveryClass:`read`},{method:M.gitRunStackedAction,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitListBranches,requiredScope:`git.read`,deliveryClass:`read`},{method:M.vcsListRefs,requiredScope:`git.read`,deliveryClass:`read`},{method:M.vcsRefreshStatus,requiredScope:`git.read`,deliveryClass:`read`},{method:M.vcsPull,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.vcsCreateWorktree,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.vcsRemoveWorktree,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.vcsCreateRef,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.vcsSwitchRef,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.vcsInit,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitCreateWorktree,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.gitRemoveWorktree,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitCreateBranch,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.gitCheckout,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitInit,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.gitResolvePullRequest,requiredScope:`git.read`,deliveryClass:`read`},{method:M.gitPreparePullRequestThread,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.terminalOpen,requiredScope:`terminal.write`,deliveryClass:`create-command`},{method:M.terminalAttach,requiredScope:`terminal.write`,deliveryClass:`terminal-output`},{method:M.terminalWrite,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalResize,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalSignal,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalClear,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalRestart,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.terminalClose,requiredScope:`terminal.write`,deliveryClass:`idempotent-command`},{method:M.browserOpenSession,requiredScope:`browser.control`,deliveryClass:`create-command`},{method:M.browserListSessions,requiredScope:`browser.read`,deliveryClass:`read`},{method:M.browserCloseSession,requiredScope:`browser.control`,deliveryClass:`browser-control`},{method:M.browserGetSession,requiredScope:`browser.read`,deliveryClass:`read`},{method:M.browserCommand,requiredScope:`browser.control`,deliveryClass:`browser-control`},{method:M.browserClearBrowsingData,requiredScope:`browser.control`,deliveryClass:`browser-control`},{method:M.browserAttachDisplay,requiredScope:`browser.read`,deliveryClass:`subscription`},{method:M.computerInput,requiredScope:`browser.control`,deliveryClass:`browser-control`},{method:M.browserAddDisplayIceCandidate,requiredScope:`browser.read`,deliveryClass:`browser-control`},{method:M.devTunnelRegister,requiredScope:`browser.control`,deliveryClass:`idempotent-command`},{method:M.devTunnelUnregister,requiredScope:`browser.control`,deliveryClass:`idempotent-command`},{method:M.devTunnelList,requiredScope:`browser.read`,deliveryClass:`read`},{method:M.threadDevRuntimeGet,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.threadDevRuntimeAllocatePort,requiredScope:`runtime.manage`,deliveryClass:`idempotent-command`},{method:M.threadDevRuntimeRelease,requiredScope:`runtime.manage`,deliveryClass:`idempotent-command`},{method:M.workspaceEnvironmentPreflight,requiredScope:`workspace.read`,deliveryClass:`read`},{method:M.workspaceEnsureScratch,requiredScope:`workspace.write`,deliveryClass:`idempotent-command`},{method:M.serverGetConfig,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.serverRefreshProviders,requiredScope:`provider.read`,deliveryClass:`read`},{method:M.serverStartProviderAuth,requiredScope:`provider.manage`,deliveryClass:`create-command`},{method:M.serverRepairProviderAuthRuntime,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverDisconnectProviderAuth,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverGetProviderAuthSession,requiredScope:`provider.read`,deliveryClass:`read`},{method:M.serverCancelProviderAuth,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverSubmitProviderAuthCode,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverSyncPersonalCodexToCloud,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverSyncPersonalClaudeToCloud,requiredScope:`provider.manage`,deliveryClass:`idempotent-command`},{method:M.serverUpsertKeybinding,requiredScope:`settings.write`,deliveryClass:`idempotent-command`},{method:M.serverRemoveKeybinding,requiredScope:`settings.write`,deliveryClass:`idempotent-command`},{method:M.serverGetSettings,requiredScope:`settings.read`,deliveryClass:`read`},{method:M.serverUpdateSettings,requiredScope:`settings.write`,deliveryClass:`idempotent-command`},{method:M.serverUpdateEnvironmentDisplayName,requiredScope:`settings.write`,deliveryClass:`idempotent-command`},{method:M.serverGetTraceDiagnostics,requiredScope:`settings.read`,deliveryClass:`read`},{method:M.serverHeartbeat,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.usageGetSummary,requiredScope:`runtime.read`,deliveryClass:`read`},{method:M.pullRequestsList,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsListStats,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsDetail,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsActivity,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsThreadComments,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsDiffFileContents,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsRunAction,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsUpdate,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsComment,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.pullRequestsUpdateComment,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsSubmitReview,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.pullRequestsReplyToThread,requiredScope:`git.write`,deliveryClass:`create-command`},{method:M.pullRequestsSetThreadResolution,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsSetReaction,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.pullRequestsInvalidate,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsReviewerCandidates,requiredScope:`git.read`,deliveryClass:`read`},{method:M.pullRequestsRequestReviewers,requiredScope:`git.write`,deliveryClass:`idempotent-command`},{method:M.subscribeGitStatus,requiredScope:`git.read`,deliveryClass:`subscription`},{method:M.subscribeVcsStatus,requiredScope:`git.read`,deliveryClass:`subscription`},{method:M.subscribeTerminalEvents,requiredScope:`terminal.read`,deliveryClass:`terminal-output`},{method:M.subscribeTerminalMetadata,requiredScope:`terminal.read`,deliveryClass:`read`},{method:M.subscribeBrowserEvents,requiredScope:`browser.read`,deliveryClass:`browser-frame`},{method:M.subscribeServerConfig,requiredScope:`runtime.read`,deliveryClass:`subscription`},{method:M.subscribeServerLifecycle,requiredScope:`runtime.read`,deliveryClass:`subscription`},{method:M.subscribeAuthAccess,requiredScope:`provider.read`,deliveryClass:`subscription`},{method:M.subscribeWorkspaceReadiness,requiredScope:`runtime.read`,deliveryClass:`subscription`},{method:ln.dispatchCommand,requiredScope:null,deliveryClass:`idempotent-command`},{method:ln.getTurnDiff,requiredScope:`diff.read`,deliveryClass:`read`},{method:ln.getFullThreadDiff,requiredScope:`diff.read`,deliveryClass:`read`},{method:ln.streamTurnDiff,requiredScope:`diff.read`,deliveryClass:`bulk-transfer`},{method:ln.streamFullThreadDiff,requiredScope:`diff.read`,deliveryClass:`bulk-transfer`},{method:ln.replayEvents,requiredScope:`thread.read`,deliveryClass:`subscription`},{method:ln.subscribeShell,requiredScope:`thread.read`,deliveryClass:`subscription`},{method:ln.subscribeThread,requiredScope:`thread.read`,deliveryClass:`subscription`}],dae=new Set([M.gitPull,M.gitRunStackedAction,M.gitCreateWorktree,M.gitRemoveWorktree,M.gitCreateBranch,M.gitCheckout,M.gitInit,M.gitPreparePullRequestThread,M.threadDevRuntimeAllocatePort,M.threadDevRuntimeRelease,M.serverUpsertKeybinding,M.serverRemoveKeybinding,M.serverUpdateEnvironmentDisplayName,ln.dispatchCommand]),fae=uae.map(e=>{let t=e.deliveryClass===`idempotent-command`||e.deliveryClass===`create-command`;return{method:e.method,requiredScope:e.requiredScope,deliveryClass:e.deliveryClass,journalPersistence:t?dae.has(e.method)?`frame`:`metadata-only`:`none`}}),pae=lae({registeredMethods:[...Wn.requests.keys()],policies:fae}),Yo={"project.create":{requiredScope:`project.write`,deliveryClass:`create-command`},"project.meta.update":{requiredScope:`project.write`,deliveryClass:`idempotent-command`},"project.delete":{requiredScope:`project.write`,deliveryClass:`idempotent-command`},"thread.create":{requiredScope:`thread.create`,deliveryClass:`create-command`},"thread.delete":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.archive":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.settle":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.unsettle":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.unarchive":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.meta.update":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.runtime-mode.set":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.interaction-mode.set":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.turn.start":{requiredScope:`turn.dispatch`,deliveryClass:`create-command`},"thread.turn.interrupt":{requiredScope:`turn.stop`,deliveryClass:`idempotent-command`},"thread.approval.respond":{requiredScope:`approval.respond`,deliveryClass:`idempotent-command`},"thread.user-input.respond":{requiredScope:`approval.respond`,deliveryClass:`idempotent-command`},"thread.checkpoint.revert":{requiredScope:`thread.mutate`,deliveryClass:`idempotent-command`},"thread.session.stop":{requiredScope:`turn.stop`,deliveryClass:`idempotent-command`},"thread.plan-approval.respond":{requiredScope:`approval.respond`,deliveryClass:`idempotent-command`}},mae=new Set([`thread.approval.respond`,`thread.user-input.respond`,`thread.plan-approval.respond`]);function hae(e){if(e.method!==ln.dispatchCommand||!e.payload||typeof e.payload!=`object`||Array.isArray(e.payload))return null;let t=e.payload;if(typeof t.type!=`string`||!mae.has(t.type))return null;let n=t.type===`thread.plan-approval.respond`?t.promptId:t.requestId;if(typeof t.commandId!=`string`||t.commandId.length===0||typeof n!=`string`||n.length===0)throw new qo(`action_grant_invalid`,`Relay sensitive action metadata is incomplete`,!1);return{commandType:t.type,commandId:t.commandId,targetId:n}}function Xo(e){let t=pae.get(e.method)??null,n=cae({method:e.method,grantedScopes:e.grantedScopes,policy:t});if(e.method!==ln.dispatchCommand)return n;if(!e.payload||typeof e.payload!=`object`||!(`type`in e.payload))throw new qo(`method_not_remotable`,`Relay orchestration dispatch payload has no command policy`,!1);let r=e.payload.type;if(typeof r!=`string`||!(r in Yo))throw new qo(`method_not_remotable`,`Relay orchestration command has no dispatch policy: ${String(r)}`,!1);let i=Yo[r];if(!e.grantedScopes.includes(i.requiredScope))throw new qo(`scope_denied`,`Relay orchestration command ${r} requires scope ${i.requiredScope}`,!1);return{requiredScope:i.requiredScope,deliveryClass:i.deliveryClass,journalPersistence:n.journalPersistence}}var Zo=class extends Error{constructor(e){let t;t=e instanceof Error?e.message:typeof e==`string`?e:``,super(t),this.name=this.constructor.name}},Qo=class extends Zo{},$o=class extends Zo{},es=class extends Zo{},gae=class extends Zo{},_ae=class extends Zo{},vae=class extends Zo{},yae=class extends Zo{},bae=class extends Zo{},xae=class extends Zo{},Sae=class extends Zo{},ts=class extends Zo{},ns=Cae(globalThis,{});function Cae(e,t){return new Proxy(e,{get(n,r,i){return r in t?t[r]:e[r]},set(n,r,i){return r in t&&delete t[r],e[r]=i,!0},deleteProperty(n,r){let i=!1;return r in t&&(delete t[r],i=!0),r in e&&(delete e[r],i=!0),i},ownKeys(n){let r=Reflect.ownKeys(e),i=Reflect.ownKeys(t),a=new Set(i);return[...r.filter(e=>!a.has(e)),...i]},defineProperty(n,r,i){return r in t&&delete t[r],Reflect.defineProperty(e,r,i),!0},getOwnPropertyDescriptor(n,r){return r in t?Reflect.getOwnPropertyDescriptor(t,r):Reflect.getOwnPropertyDescriptor(e,r)},has(n,r){return r in t||r in e}})}async function wae(){if(ns!==void 0&&globalThis.crypto!==void 0)return globalThis.crypto.subtle;try{let{webcrypto:e}=await N(async()=>{let{webcrypto:e}=await import(`./__vite-browser-external-y4e5bF-h.js`).then(e=>t(e.default));return{webcrypto:e}},__vite__mapDeps([0,1]));return e.subtle}catch(e){throw new ts(e)}}var rs=class{constructor(){Object.defineProperty(this,"_api",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}async _setup(){this._api===void 0&&(this._api=await wae())}},is={Base:0,Psk:1,Auth:2,AuthPsk:3},Tae={NotAssigned:0,DhkemP256HkdfSha256:16,DhkemP384HkdfSha384:17,DhkemP521HkdfSha512:18,DhkemSecp256k1HkdfSha256:19,DhkemX25519HkdfSha256:32,DhkemX448HkdfSha512:33,HybridkemX25519Kyber768:48,MlKem512:64,MlKem768:65,MlKem1024:66,XWing:25722},as={HkdfSha256:1,HkdfSha384:2,HkdfSha512:3,Sha3256:4,Sha3384:5,Sha3512:6,Shake128:16,Shake256:17,TurboShake128:18,TurboShake256:19},os={Aes128Gcm:1,Aes256Gcm:2,Chacha20Poly1305:3,ExportOnly:65535},ss=new Uint8Array,cs=0n,ls=1n,us=2n,Eae=new Uint8Array([75,69,77,0,0]),ds=new Uint8Array([72,80,75,69,45,118,49]);function fs(e){return new Uint8Array(ps(e))}function ps(e){return e instanceof ArrayBuffer?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength).slice().buffer:new Uint8Array(e).slice().buffer}var Dae=class extends rs{constructor(){super(),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:as.HkdfSha256}),Object.defineProperty(this,"hashSize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_suiteId",{enumerable:!0,configurable:!0,writable:!0,value:ss}),Object.defineProperty(this,"algHash",{enumerable:!0,configurable:!0,writable:!0,value:{name:`HMAC`,hash:`SHA-256`,length:256}})}init(e){this._suiteId=e}buildLabeledIkm(e,t){this._checkInit();let n=new Uint8Array(7+this._suiteId.byteLength+e.byteLength+t.byteLength);return n.set(ds,0),n.set(this._suiteId,7),n.set(e,7+this._suiteId.byteLength),n.set(t,7+this._suiteId.byteLength+e.byteLength),n}buildLabeledInfo(e,t,n){this._checkInit();let r=new Uint8Array(9+this._suiteId.byteLength+e.byteLength+t.byteLength);return r.set(new Uint8Array([0,n]),0),r.set(ds,2),r.set(this._suiteId,9),r.set(e,9+this._suiteId.byteLength),r.set(t,9+this._suiteId.byteLength+e.byteLength),r}async extract(e,t){await this._setup();let n=e.byteLength===0?new ArrayBuffer(this.hashSize):ps(e);if(n.byteLength!==this.hashSize)throw new Qo(`The salt length must be the same as the hashSize`);let r=ps(t),i=await this._api.importKey(`raw`,n,this.algHash,!1,[`sign`]);return await this._api.sign(`HMAC`,i,r)}async expand(e,t,n){await this._setup();let r=ps(e),i=await this._api.importKey(`raw`,r,this.algHash,!1,[`sign`]),a=new ArrayBuffer(n),o=new Uint8Array(a),s=ss,c=fs(t),l=new Uint8Array(1);if(n>255*this.hashSize)throw Error(`Entropy limit reached`);let u=new Uint8Array(this.hashSize+c.length+1);for(let e=1,t=0;t<o.length;e++)l[0]=e,u.set(s,0),u.set(c,s.length),u.set(l,s.length+c.length),s=new Uint8Array(await this._api.sign(`HMAC`,i,u.slice(0,s.length+c.length+1))),o.length-t>=s.length?(o.set(s,t),t+=s.length):(o.set(s.slice(0,o.length-t),t),t+=o.length-t);return a}async extractAndExpand(e,t,n,r){await this._setup();let i=ps(t),a=await this._api.importKey(`raw`,i,`HKDF`,!1,[`deriveBits`]);return await this._api.deriveBits({name:`HKDF`,hash:this.algHash.hash,salt:ps(e),info:ps(n)},a,r*8)}async labeledExtract(e,t,n){return await this.extract(e,this.buildLabeledIkm(t,n))}async labeledExpand(e,t,n,r){return await this.expand(e,this.buildLabeledInfo(t,n,r),r)}_checkInit(){if(this._suiteId===ss)throw Error(`Not initialized. Call init()`)}},Oae=class extends Dae{constructor(){super(...arguments),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:as.HkdfSha256}),Object.defineProperty(this,"hashSize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"algHash",{enumerable:!0,configurable:!0,writable:!0,value:{name:`HMAC`,hash:`SHA-256`,length:256}})}},ms=e=>typeof e==`object`&&!!e&&typeof e.privateKey==`object`&&typeof e.publicKey==`object`;function hs(e,t){if(t<=0)throw Error(`i2Osp: too small size`);if(e>=256**t)throw Error(`i2Osp: too large integer`);let n=new Uint8Array(t);for(let r=0;r<t&&e;r++)n[t-(r+1)]=e%256,e=Math.floor(e/256);return n}function gs(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}function _s(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}async function kae(){if(ns!==void 0&&globalThis.crypto!==void 0)return globalThis.crypto;try{let{webcrypto:e}=await N(async()=>{let{webcrypto:e}=await import(`./__vite-browser-external-y4e5bF-h.js`).then(e=>t(e.default));return{webcrypto:e}},__vite__mapDeps([0,1]));return e}catch{throw Error(`failed to load Crypto`)}}function Aae(e,t){if(e.byteLength!==t.byteLength)throw Error(`xor: different length inputs`);let n=new Uint8Array(e.byteLength);for(let r=0;r<e.byteLength;r++)n[r]=e[r]^t[r];return n}var jae=new Uint8Array([101,97,101,95,112,114,107]),Mae=new Uint8Array([115,104,97,114,101,100,95,115,101,99,114,101,116]);function Nae(e,t,n){let r=new Uint8Array(e.length+t.length+n.length);return r.set(e,0),r.set(t,e.length),r.set(n,e.length+t.length),r}var Pae=class{constructor(e,t,n){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"secretSize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"encSize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"publicKeySize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"privateKeySize",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_prim",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_kdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.id=e,this._prim=t,this._kdf=n;let r=new Uint8Array(Eae);r.set(hs(this.id,2),3),this._kdf.init(r)}async serializePublicKey(e){return await this._prim.serializePublicKey(e)}async deserializePublicKey(e){return await this._prim.deserializePublicKey(ps(e))}async serializePrivateKey(e){return await this._prim.serializePrivateKey(e)}async deserializePrivateKey(e){return await this._prim.deserializePrivateKey(ps(e))}async importKey(e,t,n=!0){return await this._prim.importKey(e,t,n)}async generateKeyPair(){return await this._prim.generateKeyPair()}async deriveKeyPair(e){let t=ps(e);if(t.byteLength>8192)throw new Qo(`Too long ikm`);return await this._prim.deriveKeyPair(t)}async encap(e){let t;t=e.ekm===void 0?await this.generateKeyPair():ms(e.ekm)?e.ekm:await this.deriveKeyPair(e.ekm);let n=await this._prim.serializePublicKey(t.publicKey),r=await this._prim.serializePublicKey(e.recipientPublicKey);try{let i;if(e.senderKey===void 0)i=new Uint8Array(await this._prim.dh(t.privateKey,e.recipientPublicKey));else{let n=ms(e.senderKey)?e.senderKey.privateKey:e.senderKey;i=gs(new Uint8Array(await this._prim.dh(t.privateKey,e.recipientPublicKey)),new Uint8Array(await this._prim.dh(n,e.recipientPublicKey)))}let a;if(e.senderKey===void 0)a=gs(new Uint8Array(n),new Uint8Array(r));else{let t=ms(e.senderKey)?e.senderKey.publicKey:await this._prim.derivePublicKey(e.senderKey),i=await this._prim.serializePublicKey(t);a=Nae(new Uint8Array(n),new Uint8Array(r),new Uint8Array(i))}return{enc:n,sharedSecret:await this._generateSharedSecret(i,a)}}catch(e){throw new gae(e)}}async decap(e){let t=ps(e.enc),n=await this._prim.deserializePublicKey(t),r=ms(e.recipientKey)?e.recipientKey.privateKey:e.recipientKey,i=ms(e.recipientKey)?e.recipientKey.publicKey:await this._prim.derivePublicKey(e.recipientKey),a=await this._prim.serializePublicKey(i);try{let i;i=e.senderPublicKey===void 0?new Uint8Array(await this._prim.dh(r,n)):gs(new Uint8Array(await this._prim.dh(r,n)),new Uint8Array(await this._prim.dh(r,e.senderPublicKey)));let o;if(e.senderPublicKey===void 0)o=gs(new Uint8Array(t),new Uint8Array(a));else{let n=await this._prim.serializePublicKey(e.senderPublicKey);o=new Uint8Array(t.byteLength+a.byteLength+n.byteLength),o.set(new Uint8Array(t),0),o.set(new Uint8Array(a),t.byteLength),o.set(new Uint8Array(n),t.byteLength+a.byteLength)}return await this._generateSharedSecret(i,o)}catch(e){throw new _ae(e)}}async _generateSharedSecret(e,t){let n=this._kdf.buildLabeledIkm(jae,e),r=this._kdf.buildLabeledInfo(Mae,t,this.secretSize);return await this._kdf.extractAndExpand(ss,n,r,this.secretSize)}},vs=[`deriveBits`],Fae=new Uint8Array([100,107,112,95,112,114,107]),Iae=new Uint8Array([115,107]),ys=class{constructor(e,t,n,r=[]){Object.defineProperty(this,"key",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"extractable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"algorithm",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"usages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.key=t,this.type=n,this.algorithm={name:e},this.usages=r,n===`public`&&(this.usages=[])}},Lae=class{constructor(e,t,n,r){Object.defineProperty(this,"_algName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_curve",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_hkdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nPk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nSk",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._algName=e,this._nPk=t,this._nSk=t,this._curve=n,this._hkdf=r}serializePublicKey(e){try{return Promise.resolve(e.key.buffer)}catch(e){return Promise.reject(new $o(e))}}async deserializePublicKey(e){try{return await this._importRawKey(ps(e),!0)}catch(e){throw new es(e)}}serializePrivateKey(e){try{return Promise.resolve(e.key.buffer)}catch(e){return Promise.reject(new $o(e))}}async deserializePrivateKey(e){try{return await this._importRawKey(ps(e),!1)}catch(e){throw new es(e)}}async importKey(e,t,n){try{if(e===`raw`)return await this._importRawKey(t,n);if(t instanceof ArrayBuffer)throw Error(`Invalid jwk key format`);return await this._importJWK(t,n)}catch(e){throw new es(e)}}async generateKeyPair(){try{let e=await this._curve.utils.randomSecretKey(),t=new ys(this._algName,e,`private`,vs);return{publicKey:await this.derivePublicKey(t),privateKey:t}}catch(e){throw new ts(e)}}async deriveKeyPair(e){try{let t=ps(e),n=await this._hkdf.labeledExtract(ss.buffer,Fae,new Uint8Array(t)),r=await this._hkdf.labeledExpand(n,Iae,ss,this._nSk),i=new ys(this._algName,new Uint8Array(r),`private`,vs);return{privateKey:i,publicKey:await this.derivePublicKey(i)}}catch(e){throw new Sae(e)}}derivePublicKey(e){try{let t=this._curve.getPublicKey(e.key);return Promise.resolve(new ys(this._algName,t,`public`))}catch(e){return Promise.reject(new es(e))}}dh(e,t){try{return Promise.resolve(this._curve.getSharedSecret(e.key,t.key).buffer)}catch(e){return Promise.reject(new $o(e))}}_importRawKey(e,t){return new Promise((n,r)=>{t&&e.byteLength!==this._nPk&&r(Error(`Invalid length of the key`)),!t&&e.byteLength!==this._nSk&&r(Error(`Invalid length of the key`)),n(new ys(this._algName,new Uint8Array(e),t?`public`:`private`,t?[]:vs))})}_importJWK(e,t){return new Promise((n,r)=>{e.kty!==`OKP`&&r(Error(`Invalid kty: ${e.kty}`)),e.crv!==this._algName&&r(Error(`Invalid crv: ${e.crv}`)),t?(e.d!==void 0&&r(Error("Invalid key: `d` should not be set")),typeof e.x!=`string`&&r(Error("Invalid key: `x` not found")),n(new ys(this._algName,_s(e.x),`public`))):(typeof e.d!=`string`&&r(Error("Invalid key: `d` not found")),n(new ys(this._algName,_s(e.d),`private`,vs)))})}};function Rae(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function bs(e,t=``){if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw Error(`${n}expected integer >0, got ${e}`)}}function xs(e,t,n=``){let r=Rae(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`;throw Error(o+`expected Uint8Array`+s+`, got `+c)}return e}function Ss(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function Cs(e,t){xs(e,void 0,`digestInto() output`);let n=t.outputLen;if(e.length<n)throw Error(`"digestInto() output" expected to be of length >=`+n)}function zae(e){if(typeof e==`bigint`){if(!Ps(e))throw Error(`positive bigint expected, got `+e)}else bs(e);return e}function ws(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ts(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}var Bae=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Es(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ds(e,t){return e<<32-t|e>>>t}var Os=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,Vae=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`)),Hae=[0n,1n,2n,3n,4n,5n,6n,7n,8n,9n,10n,11n,12n,13n,14n,15n];function Uae(e){if(xs(e),Os)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=Vae[e[n]];return t}var ks={_0:48,_9:57,A:65,F:70,a:97,f:102};function As(e){if(e>=ks._0&&e<=ks._9)return e-ks._0;if(e>=ks.A&&e<=ks.F)return e-(ks.A-10);if(e>=ks.a&&e<=ks.f)return e-(ks.a-10)}function Wae(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(Os)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=As(e.charCodeAt(i)),a=As(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function Gae(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);let t=cs;for(let n=0;n<e.length;n++){let r=As(e.charCodeAt(n));if(r===void 0)throw Error(`hex string expected, got non-hex character "`+e[n]+`" at index `+n);t=t<<4n|Hae[r]}return t}function js(e){bs(e,`numberToBigint`);let t=e,n=cs,r=1n;for(;t>0;)t%2==1&&(n+=r),t=Math.floor(t/2),r<<=1n;return n}function Ms(e){return Gae(Uae(Ns(xs(e)).reverse()))}function Kae(e,t){bs(t),e=zae(e);let n=Wae(e.toString(16).padStart(t*2,`0`));if(n.length!==t)throw Error(`number too large`);return n}function qae(e,t){return Kae(e,t).reverse()}function Ns(e){return Uint8Array.from(e)}function Ps(e){return typeof e==`bigint`&&0n<=e}function Jae(e,t,n){return Ps(e)&&Ps(t)&&Ps(n)&&t<=e&&e<n}function Fs(e,t,n,r){if(!Jae(t,n,r))throw Error(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function Yae(e,t={},n={}){if(!e||typeof e!=`object`)throw Error(`expected valid options object`);function r(t,n,r){let i=e[t];if(r&&i===void 0)return;let a=typeof i;if(a!==n||i===null)throw Error(`param "${t}" is invalid: expected ${n}, got ${a}`)}let i=(e,t)=>Object.entries(e).forEach(([e,n])=>r(e,n,t));i(t,!1),i(n,!0)}async function Xae(e=32){let t=await kae(),n=new Uint8Array(e);return t.getRandomValues(n),n}function Zae(e){return{oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])}}function Qae(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash must wrapped by utils.createHasher`);bs(e.outputLen),bs(e.blockLen)}function $ae(e,t={}){let n=(t,n)=>e(n).update(t).digest(),r=e(void 0),i=Object.assign(n,{outputLen:r.outputLen,blockLen:r.blockLen,create:t=>e(t),...t});return Object.freeze(i)}var Is=class{constructor(e,t){if(Object.defineProperty(this,"oHash",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"iHash",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"blockLen",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputLen",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"finished",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Qae(e),xs(t,void 0,`key`),this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,r=new Uint8Array(n);r.set(t.length>n?e.create().update(t).digest():t);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),Ts(r)}update(e){return Ss(this),this.iHash.update(e),this}digestInto(e){Ss(this),xs(e,this.outputLen,`output`),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ls=(e,t,n)=>new Is(e,t).update(n).digest();Ls.create=(e,t)=>new Is(e,t);function eoe(e,t,n){return e&t^~e&n}function toe(e,t,n){return e&t^e&n^t&n}var noe=class{constructor(e,t,n,r){Object.defineProperty(this,"blockLen",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputLen",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"padOffset",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLE",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"buffer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"view",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"finished",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"length",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"pos",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Es(this.buffer)}update(e){Ss(this),xs(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=Es(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ss(this),Cs(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,Ts(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;n.setBigUint64(r-8,js(this.length*8),i),this.process(n,0);let o=Es(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen must be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},Rs=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),roe=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),zs=new Uint32Array(64),ioe=class extends noe{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)zs[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=zs[e-15],n=zs[e-2],r=Ds(t,7)^Ds(t,18)^t>>>3,i=Ds(n,17)^Ds(n,19)^n>>>10;zs[e]=i+zs[e-7]+r+zs[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=Ds(o,6)^Ds(o,11)^Ds(o,25),u=l+t+eoe(o,s,c)+roe[e]+zs[e]|0,d=(Ds(n,2)^Ds(n,13)^Ds(n,22))+toe(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){Ts(zs)}destroy(){this.set(0,0,0,0,0,0,0,0),Ts(this.buffer)}},aoe=class extends ioe{constructor(){super(32),Object.defineProperty(this,"A",{enumerable:!0,configurable:!0,writable:!0,value:Rs[0]|0}),Object.defineProperty(this,"B",{enumerable:!0,configurable:!0,writable:!0,value:Rs[1]|0}),Object.defineProperty(this,"C",{enumerable:!0,configurable:!0,writable:!0,value:Rs[2]|0}),Object.defineProperty(this,"D",{enumerable:!0,configurable:!0,writable:!0,value:Rs[3]|0}),Object.defineProperty(this,"E",{enumerable:!0,configurable:!0,writable:!0,value:Rs[4]|0}),Object.defineProperty(this,"F",{enumerable:!0,configurable:!0,writable:!0,value:Rs[5]|0}),Object.defineProperty(this,"G",{enumerable:!0,configurable:!0,writable:!0,value:Rs[6]|0}),Object.defineProperty(this,"H",{enumerable:!0,configurable:!0,writable:!0,value:Rs[7]|0})}},Bs=$ae(()=>new aoe,Zae(1));function Vs(e,t){let n=e%t;return n>=0n?n:t+n}function Hs(e,t,n){let r=e;for(;t-->cs;)r*=r,r%=n;return r}function ooe(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}function soe(e){return Yae(e,{adjustScalarBytes:`function`,powPminus2:`function`}),Object.freeze({...e})}function coe(e){let{P:t,type:n,adjustScalarBytes:r,powPminus2:i,randomBytes:a}=soe(e),o=n===`x25519`;if(!o&&n!==`x448`)throw Error(`invalid type`);let s=a||Xae,c=o?255n:448n,l=o?32:56,u=o?9n:5n,d=o?121665n:39081n,f=o?us**254n:us**447n,p=f+(o?8n*us**251n-ls:4n*us**445n-ls)+ls,m=e=>Vs(e,t),h=g(u);function g(e){return qae(m(e),l)}function _(e){let t=Ns(xs(e,l,`uCoordinate`));return o&&(t[31]&=127),m(Ms(t))}function v(e){return Ms(r(Ns(xs(e,l,`scalar`))))}function y(e,t){let n=w(_(t),v(e));if(n===0n)throw Error(`invalid private or public key received`);return g(n)}function b(e){return y(e,h)}let x=b,S=y;function C(e,t,n){let r=m(e*(t-n));return t=m(t-r),n=m(n+r),{x_2:t,x_3:n}}function w(e,n){Fs(`u`,e,cs,t),Fs(`scalar`,n,f,p);let r=n,a=e,o=ls,s=cs,l=e,u=ls,h=cs;for(let e=c-1n;e>=cs;e--){let t=r>>e&ls;h^=t,{x_2:o,x_3:l}=C(h,o,l),{x_2:s,x_3:u}=C(h,s,u),h=t;let n=o+s,i=m(n*n),c=o-s,f=m(c*c),p=i-f,g=l+u,_=l-u,v=m(_*n),y=m(g*c),b=v+y,x=v-y;l=m(b*b),u=m(a*m(x*x)),o=m(i*f),s=m(p*(i+m(d*p)))}({x_2:o,x_3:l}=C(h,o,l)),{x_2:s,x_3:u}=C(h,s,u);let g=i(s);return m(o*g)}let T={secretKey:l,publicKey:l,seed:l},E=async e=>(e===void 0&&(e=await s(l)),xs(e,T.seed,`seed`),e),D={randomSecretKey:E};return Object.freeze({keygen:ooe(E,x),getSharedSecret:S,getPublicKey:x,scalarMult:y,scalarMultBase:b,utils:D,GuBytes:h.slice(),lengths:T})}function Us(e){if(typeof e!=`boolean`)throw Error(`boolean expected, not ${e}`)}var loe=(e,t)=>{function n(n,...r){if(xs(n,void 0,`key`),!Bae)throw Error(`Non little-endian hardware is not yet supported`);if(e.nonceLength!==void 0){let t=r[0];xs(t,e.varSizeNonce?void 0:e.nonceLength,`nonce`)}let i=e.tagLength;i&&r[1]!==void 0&&xs(r[1],void 0,`AAD`);let a=t(n,...r),o=(e,t)=>{if(t!==void 0){if(e!==2)throw Error(`cipher output not supported`);xs(t,void 0,`output`)}},s=!1;return{encrypt(e,t){if(s)throw Error(`cannot encrypt() twice with same key + nonce`);return s=!0,xs(e),o(a.encrypt.length,t),a.encrypt(e,t)},decrypt(e,t){if(xs(e),i&&e.length<i)throw Error(`"ciphertext" expected length bigger than tagLength=`+i);return o(a.decrypt.length,t),a.decrypt(e,t)}}}return Object.assign(n,e),n};function uoe(e,t){if(typeof t!=`object`||!t)throw Error(`options must be defined`);return Object.assign(e,t)}function doe(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function Ws(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(t.length!==e)throw Error(`"output" expected Uint8Array of length `+e+`, got: `+t.length);if(n&&!poe(t))throw Error(`invalid output, must be aligned`);return t}function foe(e,t,n){Us(n);let r=new Uint8Array(16),i=Es(r);return i.setBigUint64(0,js(t),n),i.setBigUint64(8,js(e),n),r}function poe(e){return e.byteOffset%4==0}var Gs=e=>Uint8Array.from(e.split(``).map(e=>e.charCodeAt(0))),moe=Gs(`expand 16-byte k`),hoe=Gs(`expand 32-byte k`),goe=ws(moe),_oe=ws(hoe);function Ks(e,t){return e<<t|e>>>32-t}function qs(e){return e.byteOffset%4==0}var Js=64,voe=16,Ys=2**32-1,Xs=Uint32Array.of();function yoe(e,t,n,r,i,a,o,s){let c=i.length,l=new Uint8Array(Js),u=ws(l),d=qs(i)&&qs(a),f=d?ws(i):Xs,p=d?ws(a):Xs;for(let m=0;m<c;o++){if(e(t,n,r,u,o,s),o>=Ys)throw Error(`arx: counter overflow`);let h=Math.min(Js,c-m);if(d&&h===Js){let e=m/4;if(m%4!=0)throw Error(`arx: invalid block position`);for(let t=0,n;t<voe;t++)n=e+t,p[n]=f[n]^u[t];m+=Js;continue}for(let e=0,t;e<h;e++)t=m+e,a[t]=i[t]^l[e];m+=h}}function boe(e,t){let{allowShortKeys:n,extendNonceFn:r,counterLength:i,counterRight:a,rounds:o}=uoe({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!=`function`)throw Error(`core must be a function`);return bs(i),bs(o),Us(a),Us(n),(t,s,c,l,u=0)=>{xs(t,void 0,`key`),xs(s,void 0,`nonce`),xs(c,void 0,`data`);let d=c.length;if(l===void 0&&(l=new Uint8Array(d)),xs(l,void 0,`output`),bs(u),u<0||u>=Ys)throw Error(`arx: counter overflow`);if(l.length<d)throw Error(`arx: output (${l.length}) is shorter than data (${d})`);let f=[],p=t.length,m,h;if(p===32)f.push(m=Ns(t)),h=_oe;else if(p===16&&n)m=new Uint8Array(32),m.set(t),m.set(t,16),h=goe,f.push(m);else throw xs(t,32,`arx key`),Error(`invalid key size`);qs(s)||f.push(s=Ns(s));let g=ws(m);if(r){if(s.length!==24)throw Error(`arx: extended nonce must be 24 bytes`);r(h,g,ws(s.subarray(0,16)),g),s=s.subarray(16)}let _=16-i;if(_!==s.length)throw Error(`arx: nonce must be ${_} or 16 bytes`);if(_!==12){let e=new Uint8Array(12);e.set(s,a?0:12-s.length),s=e,f.push(s)}let v=ws(s);return yoe(e,h,g,v,c,l,u,o),Ts(...f),l}}function Zs(e,t){return e[t++]&255|(e[t++]&255)<<8}var xoe=class{constructor(e){Object.defineProperty(this,"blockLen",{enumerable:!0,configurable:!0,writable:!0,value:16}),Object.defineProperty(this,"outputLen",{enumerable:!0,configurable:!0,writable:!0,value:16}),Object.defineProperty(this,"buffer",{enumerable:!0,configurable:!0,writable:!0,value:new Uint8Array(16)}),Object.defineProperty(this,"r",{enumerable:!0,configurable:!0,writable:!0,value:new Uint16Array(10)}),Object.defineProperty(this,"h",{enumerable:!0,configurable:!0,writable:!0,value:new Uint16Array(10)}),Object.defineProperty(this,"pad",{enumerable:!0,configurable:!0,writable:!0,value:new Uint16Array(8)}),Object.defineProperty(this,"pos",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"finished",{enumerable:!0,configurable:!0,writable:!0,value:!1}),e=Ns(xs(e,32,`key`));let t=Zs(e,0),n=Zs(e,2),r=Zs(e,4),i=Zs(e,6),a=Zs(e,8),o=Zs(e,10),s=Zs(e,12),c=Zs(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|n<<3)&8191,this.r[2]=(n>>>10|r<<6)&7939,this.r[3]=(r>>>7|i<<9)&8191,this.r[4]=(i>>>4|a<<12)&255,this.r[5]=a>>>1&8190,this.r[6]=(a>>>14|o<<2)&8191,this.r[7]=(o>>>11|s<<5)&8065,this.r[8]=(s>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=Zs(e,16+2*t)}process(e,t,n=!1){let r=n?0:2048,{h:i,r:a}=this,o=a[0],s=a[1],c=a[2],l=a[3],u=a[4],d=a[5],f=a[6],p=a[7],m=a[8],h=a[9],g=Zs(e,t+0),_=Zs(e,t+2),v=Zs(e,t+4),y=Zs(e,t+6),b=Zs(e,t+8),x=Zs(e,t+10),S=Zs(e,t+12),C=Zs(e,t+14),w=i[0]+(g&8191),T=i[1]+((g>>>13|_<<3)&8191),E=i[2]+((_>>>10|v<<6)&8191),D=i[3]+((v>>>7|y<<9)&8191),O=i[4]+((y>>>4|b<<12)&8191),ee=i[5]+(b>>>1&8191),te=i[6]+((b>>>14|x<<2)&8191),k=i[7]+((x>>>11|S<<5)&8191),A=i[8]+((S>>>8|C<<8)&8191),ne=i[9]+(C>>>5|r),j=0,re=j+w*o+5*h*T+5*m*E+5*p*D+5*f*O;j=re>>>13,re&=8191,re+=5*d*ee+5*u*te+5*l*k+5*c*A+5*s*ne,j+=re>>>13,re&=8191;let ie=j+w*s+T*o+5*h*E+5*m*D+5*p*O;j=ie>>>13,ie&=8191,ie+=5*f*ee+5*d*te+5*u*k+5*l*A+5*c*ne,j+=ie>>>13,ie&=8191;let ae=j+w*c+T*s+E*o+5*h*D+5*m*O;j=ae>>>13,ae&=8191,ae+=5*p*ee+5*f*te+5*d*k+5*u*A+5*l*ne,j+=ae>>>13,ae&=8191;let oe=j+w*l+T*c+E*s+D*o+5*h*O;j=oe>>>13,oe&=8191,oe+=5*m*ee+5*p*te+5*f*k+5*d*A+5*u*ne,j+=oe>>>13,oe&=8191;let se=j+w*u+T*l+E*c+D*s+O*o;j=se>>>13,se&=8191,se+=5*h*ee+5*m*te+5*p*k+5*f*A+5*d*ne,j+=se>>>13,se&=8191;let ce=j+w*d+T*u+E*l+D*c+O*s;j=ce>>>13,ce&=8191,ce+=ee*o+5*h*te+5*m*k+5*p*A+5*f*ne,j+=ce>>>13,ce&=8191;let le=j+w*f+T*d+E*u+D*l+O*c;j=le>>>13,le&=8191,le+=ee*s+te*o+5*h*k+5*m*A+5*p*ne,j+=le>>>13,le&=8191;let ue=j+w*p+T*f+E*d+D*u+O*l;j=ue>>>13,ue&=8191,ue+=ee*c+te*s+k*o+5*h*A+5*m*ne,j+=ue>>>13,ue&=8191;let de=j+w*m+T*p+E*f+D*d+O*u;j=de>>>13,de&=8191,de+=ee*l+te*c+k*s+A*o+5*h*ne,j+=de>>>13,de&=8191;let fe=j+w*h+T*m+E*p+D*f+O*d;j=fe>>>13,fe&=8191,fe+=ee*u+te*l+k*c+A*s+ne*o,j+=fe>>>13,fe&=8191,j=(j<<2)+j|0,j=j+re|0,re=j&8191,j>>>=13,ie+=j,i[0]=re,i[1]=ie,i[2]=ae,i[3]=oe,i[4]=se,i[5]=ce,i[6]=le,i[7]=ue,i[8]=de,i[9]=fe}finalize(){let{h:e,pad:t}=this,n=new Uint16Array(10),r=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=r,r=e[t]>>>13,e[t]&=8191;e[0]+=r*5,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,n[0]=e[0]+5,r=n[0]>>>13,n[0]&=8191;for(let t=1;t<10;t++)n[t]=e[t]+r,r=n[t]>>>13,n[t]&=8191;n[9]-=8192;let i=(r^1)-1;for(let e=0;e<10;e++)n[e]&=i;i=~i;for(let t=0;t<10;t++)e[t]=e[t]&i|n[t];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let a=e[0]+t[0];e[0]=a&65535;for(let n=1;n<8;n++)a=(e[n]+t[n]|0)+(a>>>16)|0,e[n]=a&65535;Ts(n)}update(e){Ss(this),xs(e),e=Ns(e);let{buffer:t,blockLen:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(n-this.pos,r-i);if(a===n){for(;n<=r-i;i+=n)this.process(e,i);continue}t.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===n&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){Ts(this.h,this.r,this.buffer,this.pad)}digestInto(e){Ss(this),Cs(e,this),this.finished=!0;let{buffer:t,h:n}=this,{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let i=0;for(let t=0;t<8;t++)e[i++]=n[t]>>>0,e[i++]=n[t]>>>8;return e}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}};function Soe(e){let t=(t,n)=>e(n).update(t).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}var Coe=Soe(e=>new xoe(e));function woe(e,t,n,r,i,a=20){let o=e[0],s=e[1],c=e[2],l=e[3],u=t[0],d=t[1],f=t[2],p=t[3],m=t[4],h=t[5],g=t[6],_=t[7],v=i,y=n[0],b=n[1],x=n[2],S=o,C=s,w=c,T=l,E=u,D=d,O=f,ee=p,te=m,k=h,A=g,ne=_,j=v,re=y,ie=b,ae=x;for(let e=0;e<a;e+=2)S=S+E|0,j=Ks(j^S,16),te=te+j|0,E=Ks(E^te,12),S=S+E|0,j=Ks(j^S,8),te=te+j|0,E=Ks(E^te,7),C=C+D|0,re=Ks(re^C,16),k=k+re|0,D=Ks(D^k,12),C=C+D|0,re=Ks(re^C,8),k=k+re|0,D=Ks(D^k,7),w=w+O|0,ie=Ks(ie^w,16),A=A+ie|0,O=Ks(O^A,12),w=w+O|0,ie=Ks(ie^w,8),A=A+ie|0,O=Ks(O^A,7),T=T+ee|0,ae=Ks(ae^T,16),ne=ne+ae|0,ee=Ks(ee^ne,12),T=T+ee|0,ae=Ks(ae^T,8),ne=ne+ae|0,ee=Ks(ee^ne,7),S=S+D|0,ae=Ks(ae^S,16),A=A+ae|0,D=Ks(D^A,12),S=S+D|0,ae=Ks(ae^S,8),A=A+ae|0,D=Ks(D^A,7),C=C+O|0,j=Ks(j^C,16),ne=ne+j|0,O=Ks(O^ne,12),C=C+O|0,j=Ks(j^C,8),ne=ne+j|0,O=Ks(O^ne,7),w=w+ee|0,re=Ks(re^w,16),te=te+re|0,ee=Ks(ee^te,12),w=w+ee|0,re=Ks(re^w,8),te=te+re|0,ee=Ks(ee^te,7),T=T+E|0,ie=Ks(ie^T,16),k=k+ie|0,E=Ks(E^k,12),T=T+E|0,ie=Ks(ie^T,8),k=k+ie|0,E=Ks(E^k,7);let oe=0;r[oe++]=o+S|0,r[oe++]=s+C|0,r[oe++]=c+w|0,r[oe++]=l+T|0,r[oe++]=u+E|0,r[oe++]=d+D|0,r[oe++]=f+O|0,r[oe++]=p+ee|0,r[oe++]=m+te|0,r[oe++]=h+k|0,r[oe++]=g+A|0,r[oe++]=_+ne|0,r[oe++]=v+j|0,r[oe++]=y+re|0,r[oe++]=b+ie|0,r[oe++]=x+ae|0}var Toe=boe(woe,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Eoe=new Uint8Array(16),Qs=(e,t)=>{e.update(t);let n=t.length%16;n&&e.update(Eoe.subarray(n))},Doe=new Uint8Array(32);function $s(e,t,n,r,i){i!==void 0&&xs(i,void 0,`AAD`);let a=e(t,n,Doe),o=foe(r.length,i?i.length:0,!0),s=Coe.create(a);i&&Qs(s,i),Qs(s,r),s.update(o);let c=s.digest();return Ts(a,o),c}var ec=loe({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,n,r)=>({encrypt(i,a){let o=i.length;a=Ws(o+16,a,!1),a.set(i);let s=a.subarray(0,-16);e(t,n,s,s,1);let c=$s(e,t,n,s,r);return a.set(c,o),Ts(c),a},decrypt(i,a){a=Ws(i.length-16,a,!1);let o=i.subarray(0,-16),s=i.subarray(-16),c=$s(e,t,n,o,r);if(!doe(s,c))throw Error(`invalid tag`);return a.set(i.subarray(0,-16)),e(t,n,a,a,1),Ts(c),a}}))(Toe)),Ooe=class{constructor(e){Object.defineProperty(this,"_key",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._key=new Uint8Array(ps(e))}async seal(e,t,n){return await this._seal(ps(e),ps(t),ps(n))}async open(e,t,n){return await this._open(ps(e),ps(t),ps(n))}_seal(e,t,n){return new Promise(r=>{r(ec(this._key,new Uint8Array(e),new Uint8Array(n)).encrypt(new Uint8Array(t)).buffer)})}_open(e,t,n){return new Promise(r=>{r(ec(this._key,new Uint8Array(e),new Uint8Array(n)).decrypt(new Uint8Array(t)).buffer)})}},koe=class{constructor(){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:os.Chacha20Poly1305}),Object.defineProperty(this,"keySize",{enumerable:!0,configurable:!0,writable:!0,value:32}),Object.defineProperty(this,"nonceSize",{enumerable:!0,configurable:!0,writable:!0,value:12}),Object.defineProperty(this,"tagSize",{enumerable:!0,configurable:!0,writable:!0,value:16})}createEncryptionContext(e){return new Ooe(e)}};function tc(){return new Promise((e,t)=>{t(new ts(`Not supported`))})}var Aoe=new Uint8Array([115,101,99]),nc=class{constructor(e,t,n){Object.defineProperty(this,"_api",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"exporterSecret",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_kdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._api=e,this._kdf=t,this.exporterSecret=n}async seal(e,t){return await tc()}async open(e,t){return await tc()}async export(e,t){let n=ps(e);if(n.byteLength>8192)throw new Qo(`Too long exporter context`);try{return await this._kdf.labeledExpand(this.exporterSecret,Aoe,new Uint8Array(n),t)}catch(e){throw new vae(e)}}},joe=class extends nc{},Moe=class extends nc{constructor(e,t,n,r){super(e,t,n),Object.defineProperty(this,"enc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.enc=r}},rc=class extends nc{constructor(e,t,n){if(super(e,t,n.exporterSecret),Object.defineProperty(this,"_aead",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nK",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nN",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_nT",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_ctx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n.key===void 0||n.baseNonce===void 0||n.seq===void 0)throw Error(`Required parameters are missing`);this._aead=n.aead,this._nK=this._aead.keySize,this._nN=this._aead.nonceSize,this._nT=this._aead.tagSize;let r=this._aead.createEncryptionContext(n.key);this._ctx={key:r,baseNonce:n.baseNonce,seq:n.seq}}computeNonce(e){let t=hs(e.seq,e.baseNonce.byteLength);return Aae(e.baseNonce,t).buffer}incrementSeq(e){if(e.seq>2**53-1)throw new xae(`Message limit reached`);e.seq+=1}},Noe=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Poe=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},ic,ac=class{constructor(){ic.set(this,Promise.resolve())}async lock(){let e,t=new Promise(t=>{e=t}),n=Noe(this,ic,`f`);return Poe(this,ic,t,`f`),await n,e}};ic=new WeakMap;var oc=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Foe=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},sc,Ioe=class extends rc{constructor(){super(...arguments),sc.set(this,void 0)}async open(e,t=ss.buffer){Foe(this,sc,oc(this,sc,`f`)??new ac,`f`);let n=await oc(this,sc,`f`).lock(),r;try{r=await this._ctx.key.open(this.computeNonce(this._ctx),ps(e),ps(t))}catch(e){throw new bae(e)}finally{n()}return this.incrementSeq(this._ctx),r}};sc=new WeakMap;var cc=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},Loe=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},lc,Roe=class extends rc{constructor(e,t,n,r){super(e,t,n),Object.defineProperty(this,"enc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),lc.set(this,void 0),this.enc=r}async seal(e,t=ss.buffer){Loe(this,lc,cc(this,lc,`f`)??new ac,`f`);let n=await cc(this,lc,`f`).lock(),r;try{r=await this._ctx.key.seal(this.computeNonce(this._ctx),ps(e),ps(t))}catch(e){throw new yae(e)}finally{n()}return this.incrementSeq(this._ctx),r}};lc=new WeakMap;var zoe=new Uint8Array([98,97,115,101,95,110,111,110,99,101]),Boe=new Uint8Array([101,120,112]),Voe=new Uint8Array([105,110,102,111,95,104,97,115,104]),Hoe=new Uint8Array([107,101,121]),Uoe=new Uint8Array([112,115,107,95,105,100,95,104,97,115,104]),Woe=new Uint8Array([115,101,99,114,101,116]),Goe=new Uint8Array([72,80,75,69,0,0,0,0,0,0]),Koe=class extends rs{constructor(e){if(super(),Object.defineProperty(this,"_kem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_kdf",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_aead",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_suiteId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),typeof e.kem==`number`)throw new Qo(`KemId cannot be used`);if(this._kem=e.kem,typeof e.kdf==`number`)throw new Qo(`KdfId cannot be used`);if(this._kdf=e.kdf,typeof e.aead==`number`)throw new Qo(`AeadId cannot be used`);this._aead=e.aead,this._suiteId=new Uint8Array(Goe),this._suiteId.set(hs(this._kem.id,2),4),this._suiteId.set(hs(this._kdf.id,2),6),this._suiteId.set(hs(this._aead.id,2),8),this._kdf.init(this._suiteId)}get kem(){return this._kem}get kdf(){return this._kdf}get aead(){return this._aead}async createSenderContext(e){this._validateInputLength(e),await this._setup();let t=await this._kem.encap(e),n;return n=e.psk===void 0?e.senderKey===void 0?is.Base:is.Auth:e.senderKey===void 0?is.Psk:is.AuthPsk,await this._keyScheduleS(n,t.sharedSecret,t.enc,e)}async createRecipientContext(e){this._validateInputLength(e),await this._setup();let t=await this._kem.decap(e),n;return n=e.psk===void 0?e.senderPublicKey===void 0?is.Base:is.Auth:e.senderPublicKey===void 0?is.Psk:is.AuthPsk,await this._keyScheduleR(n,t,e)}async seal(e,t,n=ss.buffer){let r=await this.createSenderContext(e);return{ct:await r.seal(t,n),enc:r.enc}}async open(e,t,n=ss.buffer){return await(await this.createRecipientContext(e)).open(t,n)}async _keySchedule(e,t,n){let r=n.psk===void 0?ss:fs(n.psk.id),i=await this._kdf.labeledExtract(ss,Uoe,r),a=n.info===void 0?ss:fs(n.info),o=await this._kdf.labeledExtract(ss,Voe,a),s=new Uint8Array(1+i.byteLength+o.byteLength);s.set(new Uint8Array([e]),0),s.set(new Uint8Array(i),1),s.set(new Uint8Array(o),1+i.byteLength);let c=n.psk===void 0?ss:fs(n.psk.key),l=this._kdf.buildLabeledIkm(Woe,c),u=this._kdf.buildLabeledInfo(Boe,s,this._kdf.hashSize),d=await this._kdf.extractAndExpand(t,l,u,this._kdf.hashSize);if(this._aead.id===os.ExportOnly)return{aead:this._aead,exporterSecret:d};let f=this._kdf.buildLabeledInfo(Hoe,s,this._aead.keySize),p=await this._kdf.extractAndExpand(t,l,f,this._aead.keySize),m=this._kdf.buildLabeledInfo(zoe,s,this._aead.nonceSize),h=await this._kdf.extractAndExpand(t,l,m,this._aead.nonceSize);return{aead:this._aead,exporterSecret:d,key:p,baseNonce:new Uint8Array(h),seq:0}}async _keyScheduleS(e,t,n,r){let i=await this._keySchedule(e,t,r);return i.key===void 0?new Moe(this._api,this._kdf,i.exporterSecret,n):new Roe(this._api,this._kdf,i,n)}async _keyScheduleR(e,t,n){let r=await this._keySchedule(e,t,n);return r.key===void 0?new joe(this._api,this._kdf,r.exporterSecret):new Ioe(this._api,this._kdf,r)}_validateInputLength(e){if(e.info!==void 0&&e.info.byteLength>268435456)throw new Qo(`Too long info`);if(e.psk!==void 0){if(e.psk.key.byteLength<32)throw new Qo(`PSK must have at least 32 bytes`);if(e.psk.key.byteLength>8192)throw new Qo(`Too long psk.key`);if(e.psk.id.byteLength>8192)throw new Qo(`Too long psk.id`)}}},qoe=class extends Koe{},Joe=1n,uc=2n,Yoe=3n,Xoe=5n,dc=57896044618658097711785492504343953926634992332820282019728792003956564819949n;function Zoe(e){let t=10n,n=80n,r=dc,i=e*e%r*e%r,a=Hs(Hs(i,uc,r)*i%r,Joe,r)*e%r,o=Hs(a,Xoe,r)*a%r,s=Hs(o,t,r)*o%r,c=Hs(s,20n,r)*s%r,l=Hs(c,40n,r)*c%r;return{pow_p_5_8:Hs(Hs(Hs(Hs(l,n,r)*l%r,n,r)*l%r,t,r)*o%r,uc,r)*e%r,b2:i}}function Qoe(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var $oe=(()=>{let e=dc;return coe({P:e,type:`x25519`,powPminus2:t=>{let{pow_p_5_8:n,b2:r}=Zoe(t);return Vs(Hs(n,Yoe,e)*r,e)},adjustScalarBytes:Qoe})})(),ese=class extends Lae{constructor(e){super(`X25519`,32,$oe,e)}derive(e,t){try{return Promise.resolve(this._curve.getSharedSecret(e,t))}catch(e){return Promise.reject(new $o(e))}}},fc=`DHKEM_X25519_HKDF_SHA256/HKDF_SHA256/CHACHA20_POLY1305/AUTH`,tse=2**31,nse=65536,rse=16,pc=32,mc=(1n<<255n)-19n,hc=new TextEncoder,gc=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`;function _c(e){let t=0n;for(let n=0;n<e.length;n+=2)t|=BigInt(Number.parseInt(e.slice(n,n+2),16))<<BigInt(n/2*8);return t}var ise=new Set([0n,1n,_c(`e0eb7a7c3b41b8ae1656e3faf19fc46ada098deb9c32b1fd866205165f49b800`),_c(`5f9c95bca3508c24b1d0b1559c83ef5b04445cc4581c8e86d8224eddd09f1157`),mc-1n]),ase=new Uint8Array,vc=class extends Oae{async extract(e,t){return ps(Ls(Bs,e.byteLength===0?new Uint8Array(this.hashSize):fs(e),fs(t)))}async expand(e,t,n){if(!Number.isSafeInteger(n)||n<0||n>255*this.hashSize)throw Error(`HKDF output length exceeds the RFC 5869 limit.`);let r=fs(e),i=fs(t),a=new Uint8Array(n),o=ase;for(let e=1,t=0;t<a.byteLength;e+=1){let n=Sc([o,i,Uint8Array.of(e)]);o=new Uint8Array(Ls(Bs,r,n));let s=a.byteLength-t;a.set(o.subarray(0,Math.min(o.byteLength,s)),t),t+=Math.min(o.byteLength,s)}return ps(a)}async extractAndExpand(e,t,n,r){return this.expand(await this.extract(e,t),n,r)}},yc=new qoe({kem:new class extends Pae{secretSize=32;encSize=32;publicKeySize=32;privateKeySize=32;constructor(e){super(Tae.DhkemX25519HkdfSha256,new ese(e),e)}}(new vc),kdf:new vc,aead:new koe}),bc=class extends Error{code;name=`RelayPayloadChannelFailure`;constructor(e,t){super(t),this.code=e}};function xc(e){return new Uint8Array(e.slice(0))}function ose(e){let t=new Uint8Array(e.byteLength);return t.set(e),t.buffer}function Sc(e){let t=e.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}function Cc(e){if(!Number.isSafeInteger(e)||e<0||e>4294967295)throw new bc(`channel_ticket_binding_invalid`,`Invalid uint32 value.`);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!1),t}function wc(e){if(!Number.isSafeInteger(e)||e<0)throw new bc(`channel_ticket_binding_invalid`,`Invalid uint64 value.`);let t=new Uint8Array(8);return new DataView(t.buffer).setBigUint64(0,BigInt(e),!1),t}function sse(e){return Sc([Cc(e.byteLength),e])}function Tc(e){return Uint8Array.of(e===`control-to-runtime`?0:1)}function cse(e){return e===`handshake`?Uint8Array.of(0):e===`application`?Uint8Array.of(1):Uint8Array.of(2)}function Ec(e){let t=``;for(let n=0;n<e.byteLength;n+=3){let r=e[n]??0,i=e[n+1]??0,a=e[n+2]??0,o=r<<16|i<<8|a;t+=gc[o>>>18&63],t+=gc[o>>>12&63],n+1<e.byteLength&&(t+=gc[o>>>6&63]),n+2<e.byteLength&&(t+=gc[o&63])}return t}function Dc(e){if(!/^[A-Za-z0-9_-]*$/.test(e)||e.length%4==1)throw new bc(`channel_authentication_failed`,`Encrypted relay frame is not canonical base64url.`);let t=new Uint8Array(Math.floor(e.length*6/8)),n=0,r=0,i=0;for(let a of e){let e=gc.indexOf(a);n=n<<6|e,r+=6,r>=8&&(r-=8,t[i]=n>>>r&255,i+=1)}if(Ec(t)!==e)throw new bc(`channel_authentication_failed`,`Encrypted relay frame has a non-canonical base64url encoding.`);return t}function lse(e){let t=new Uint8Array(e);t[31]=(t[31]??0)&127;let n=0n;for(let e=0;e<t.byteLength;e+=1)n|=BigInt(t[e]??0)<<BigInt(e*8);return ise.has(n%mc)}var use={async sha256(e){if(globalThis.crypto?.subtle===void 0)throw new bc(`channel_authentication_failed`,`SHA-256 is unavailable in this runtime.`);return xc(await globalThis.crypto.subtle.digest(`SHA-256`,ose(e)))}},Oc={randomBytes(e){if(globalThis.crypto?.getRandomValues===void 0)throw new bc(`endpoint_key_invalid`,`A cryptographically secure random source is unavailable.`);return globalThis.crypto.getRandomValues(new Uint8Array(e))}};function kc(e,t){let n=hc.encode(e).byteLength;if(n===0||n>256)throw new bc(`channel_ticket_binding_invalid`,`${t} must contain between 1 and 256 UTF-8 bytes.`)}function dse(e){let t=hc.encode(e).byteLength;if(t===0||t>65536)throw new bc(`channel_ticket_binding_invalid`,`Control ticket must contain between 1 and ${nse} UTF-8 bytes.`)}async function Ac(e,t=use){dse(e.exactCompactTicket),kc(e.channelId,`Channel ID`),kc(e.runtimeId,`Runtime ID`),wc(e.connectionEpoch);let n=await t.sha256(hc.encode(e.exactCompactTicket));if(n.byteLength!==32)throw new bc(`channel_ticket_binding_invalid`,`The control ticket digest must be 32 bytes.`);return{...e,ticketDigest:new Uint8Array(n)}}function fse(e){return Ec(e.ticketDigest)}async function pse(e=Oc){let t=new Uint8Array(await e.randomBytes(pc));if(t.byteLength!==pc)throw new bc(`endpoint_key_invalid`,`The endpoint random source must return ${pc} bytes.`);try{return Ec(t)}finally{t.fill(0)}}function jc(e){return Sc([hc.encode(`forge-relay-v4`),Uint8Array.of(0),e.ticketDigest,Tc(e.direction)])}function Mc(e){return Sc([hc.encode(`forge-relay`),Cc(4),e.binding.ticketDigest,hc.encode(e.binding.channelId),Tc(e.binding.direction),cse(e.frameClass),wc(e.sequence),hc.encode(e.binding.runtimeId),wc(e.binding.connectionEpoch),Cc(e.ciphertextLength)].map(sse))}async function mse(e=Oc){let t=new Uint8Array(await e.randomBytes(pc));if(t.byteLength!==pc)throw new bc(`endpoint_key_invalid`,`The endpoint random source must return ${pc} bytes.`);try{return await yc.kem.deriveKeyPair(t)}catch(e){throw new bc(`endpoint_key_invalid`,e instanceof Error?e.message:`Endpoint key generation failed.`)}finally{t.fill(0)}}async function Nc(e){try{return Ec(xc(await yc.kem.serializePublicKey(e)))}catch(e){throw new bc(`endpoint_key_invalid`,e instanceof Error?e.message:`Endpoint public-key serialization failed.`)}}function hse(e,t){if(!/^[A-Za-z0-9_-]{43}$/u.test(t))throw new bc(`endpoint_key_invalid`,`The endpoint key ID requires a canonical X25519 public key.`);return`${e}:${t}`}async function gse(e){try{let t=Dc(e);if(t.byteLength!==pc)throw Error(`Invalid endpoint key length.`);if(lse(t))throw new bc(`endpoint_key_invalid`,`Low-order X25519 endpoint public keys are not allowed.`);return await yc.kem.deserializePublicKey(t)}catch(e){throw e instanceof bc?e:new bc(`endpoint_key_invalid`,e instanceof Error?e.message:`Endpoint public-key deserialization failed.`)}}var Pc=class{tail=Promise.resolve();run(e){let t=this.tail.then(e,e);return this.tail=t.then(()=>void 0,()=>void 0),t}},Fc=class{startedAt=Date.now();records=0;bytes=0;assertAvailable(e){if(this.records>=tse||this.bytes+e>1073741824||Date.now()-this.startedAt>=18e5)throw new bc(`channel_limit_reached`,`The encrypted relay channel must be renewed before another record is sent.`)}commit(e){this.records+=1,this.bytes+=e}};function _se(e,t){if(e.type!==`relay.encrypted-frame`||e.protocolVersion!==4||e.channelId!==t.channelId||e.direction!==t.direction||![`handshake`,`application`,`close`].includes(e.frameClass))throw new bc(`channel_ticket_binding_invalid`,`Encrypted relay frame does not match the CMMD-ticket-bound channel.`)}var vse=class{binding;context;encapsulatedKey;queue=new Pc;budget=new Fc;sequence=0;constructor(e,t){this.binding=e,this.context=t,this.encapsulatedKey=Ec(xc(t.enc))}seal(e){return this.queue.run(async()=>{if(e.plaintext.byteLength>16777216)throw new bc(`channel_limit_reached`,`Encrypted relay plaintext exceeds the per-record byte limit.`);let t=e.plaintext.byteLength+rse;this.budget.assertAvailable(t);let n=this.sequence,r=Mc({binding:this.binding,frameClass:e.frameClass,sequence:n,ciphertextLength:t}),i;try{i=xc(await this.context.seal(e.plaintext,r))}catch(e){throw new bc(`channel_authentication_failed`,e instanceof Error?e.message:`Relay payload encryption failed.`)}if(i.byteLength!==t)throw new bc(`channel_authentication_failed`,`Relay payload encryption returned an invalid ciphertext length.`);return this.sequence+=1,this.budget.commit(i.byteLength),{type:`relay.encrypted-frame`,protocolVersion:4,channelId:this.binding.channelId,direction:this.binding.direction,frameClass:e.frameClass,sequence:n,ciphertext:Ec(i)}})}},yse=class{binding;context;queue=new Pc;budget=new Fc;sequence=0;constructor(e,t){this.binding=e,this.context=t}open(e){return this.queue.run(async()=>{if(_se(e,this.binding),!Number.isSafeInteger(e.sequence)||e.sequence!==this.sequence)throw new bc(`channel_sequence_invalid`,`Expected encrypted relay sequence ${this.sequence}, received ${String(e.sequence)}.`);let t=Dc(e.ciphertext);this.budget.assertAvailable(t.byteLength);let n=Mc({binding:this.binding,frameClass:e.frameClass,sequence:e.sequence,ciphertextLength:t.byteLength}),r;try{r=xc(await this.context.open(t,n))}catch(e){throw new bc(`channel_authentication_failed`,e instanceof Error?e.message:`Relay payload authentication failed.`)}if(r.byteLength>16777216)throw new bc(`channel_limit_reached`,`Decrypted relay plaintext exceeds the per-record byte limit.`);return this.sequence+=1,this.budget.commit(t.byteLength),r})}};async function bse(e){let t=null;try{if(t=new Uint8Array(await(e.randomSource??Oc).randomBytes(pc)),t.byteLength!==pc)throw Error(`The endpoint random source must return ${pc} bytes.`);let n=await yc.createSenderContext({recipientPublicKey:e.recipientPublicKey,senderKey:e.senderKey,info:jc(e.binding),ekm:t});return new vse(e.binding,n)}catch(e){throw new bc(`channel_authentication_failed`,e instanceof Error?e.message:`Relay payload sender setup failed.`)}finally{t?.fill(0)}}async function xse(e){try{let t=await yc.createRecipientContext({recipientKey:e.recipientKey,senderPublicKey:e.senderPublicKey,enc:Dc(e.encapsulatedKey),info:jc(e.binding)});return new yse(e.binding,t)}catch(e){throw e instanceof bc?e:new bc(`channel_authentication_failed`,e instanceof Error?e.message:`Relay payload recipient setup failed.`)}}var Sse=128,Cse=2097152,wse=864e5,Ic=class extends Error{constructor(e){super(e),this.name=`RelayControlJournalError`}};function Lc(e){return typeof e==`string`&&e.length>0}function Rc(e){return Lc(e)&&Number.isFinite(Date.parse(e))}function Tse(e){return e===`pending`||e===`retrying`||e===`outcome-unknown`||e===`failed`}function Ese(e){return Lc(e.transportRequestId)&&Lc(e.runtimeId)&&Lc(e.actorSessionId)&&Lc(e.durableRequestId)&&Lc(e.method)}function Dse(e){return Number.isSafeInteger(e.sequence)&&Number(e.sequence)>0&&Number.isSafeInteger(e.attemptCount)&&Number(e.attemptCount)>=0}function Ose(e){return e.persistence!==`frame`&&e.persistence!==`metadata-only`||e.frame!==null&&!Lc(e.frame)?!1:e.persistence!==`metadata-only`||e.frame===null}function kse(e){return!Tse(e.status)||e.errorCode!==null&&!Lc(e.errorCode)?!1:e.status===`outcome-unknown`||e.status===`failed`?e.frame===null&&Lc(e.errorCode):e.errorCode===null}function Ase(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return Ese(t)&&Dse(t)&&Ose(t)&&kse(t)&&Rc(t.createdAt)&&Rc(t.updatedAt)}function jse(e){try{return JSON.parse(e)}catch{throw new Ic(`Forge relay control journal is corrupt.`)}}function Mse(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return t.version===1&&Lc(t.controlSessionId)&&Number.isSafeInteger(t.nextSequence)&&Number(t.nextSequence)>=1&&Array.isArray(t.records)&&t.records.every(Ase)}function Nse(e){let t=new Set(e.map(zc)),n=new Set(e.map(e=>e.durableRequestId)),r=new Set(e.map(e=>e.sequence));return t.size===e.length&&n.size===e.length&&r.size===e.length}function Pse(e){let t=jse(e);if(!Mse(t))throw new Ic(`Forge relay control journal is corrupt.`);let n=t.records,r=n.reduce((e,t)=>Math.max(e,t.sequence),0);if(!Nse(n)||t.nextSequence<=r)throw new Ic(`Forge relay control journal is corrupt.`);return{version:1,controlSessionId:t.controlSessionId,nextSequence:t.nextSequence,records:n}}function Fse(){return crypto.randomUUID()}function zc(e){return`${e.runtimeId}\0${e.actorSessionId}\0${e.transportRequestId}`}var Bc={pending:1,retrying:2,"outcome-unknown":3,failed:4};function Ise(e,t){let n=e.filter(e=>e.runtimeId===t);if(n.length===0)return{state:`idle`,count:0};let r=n.reduce((e,t)=>Bc[t.status]>Bc[e]?t.status:e,`pending`);return{state:r,count:n.filter(e=>e.status===r).length}}function Vc(e){let t=e.randomUUID??Fse,n=e.now??(()=>new Date),r=e.maxRecords??Sse,i=e.maxBytes??Cse,a=e.maxReplayAgeMs??wse;if(r<1||i<1||a<1)throw new Ic(`Forge relay control journal limits must be positive.`);let o=e.storage.read(),s=n(),c=o?Pse(o):{version:1,controlSessionId:t(),nextSequence:1,records:[]},l=new Map,u=new Set;function d(){return{controlSessionId:c.controlSessionId,records:[...c.records]}}function f(t){if(t.records.length>r)throw new Ic(`Forge relay control journal reached its record limit.`);let n=JSON.stringify(t);if(new TextEncoder().encode(n).byteLength>i)throw new Ic(`Forge relay control journal reached its storage limit.`);e.storage.write(n),c=t;let a=d();for(let e of u)e(a)}function p(e,t){return e.status!==`pending`&&e.status!==`retrying`?e:e.persistence===`metadata-only`||e.frame===null?{...e,frame:null,status:`outcome-unknown`,errorCode:`RELAY_COMMAND_OUTCOME_UNKNOWN`,updatedAt:t.toISOString()}:t.getTime()-Date.parse(e.createdAt)>a?{...e,frame:null,status:`outcome-unknown`,errorCode:`RELAY_RECOVERY_EXPIRED`,updatedAt:t.toISOString()}:e}let m=c.records.map(e=>p(e,s)),h=m.some((e,t)=>e!==c.records[t]);(o===null||h)&&f({...c,records:m});function g(e){let t=zc(e);return{key:t,existing:c.records.find(e=>zc(e)===t)??null}}function _(e,t,n){if([e.method===t.method,e.persistence===t.persistence,n===void 0||n===t.frame,e.frame===null||e.frame===t.frame,t.durableRequestId===void 0||e.durableRequestId===t.durableRequestId].includes(!1))throw new Ic(`Relay transport request ${t.transportRequestId} was reused with different content.`);if(e.status===`failed`||e.status===`outcome-unknown`)throw new Ic(`Relay transport request ${t.transportRequestId} requires an explicit outcome acknowledgement.`)}function v(e){if(e.durableRequestId!==void 0&&c.records.some(t=>t.durableRequestId===e.durableRequestId))throw new Ic(`Relay durable request ${e.durableRequestId} was reused by another transport request.`)}function y(e){let r=n().toISOString();return{runtimeId:e.runtimeId,actorSessionId:e.actorSessionId,transportRequestId:e.transportRequestId,durableRequestId:e.durableRequestId??t(),sequence:c.nextSequence,method:e.method,persistence:e.persistence,frame:e.persistence===`frame`?e.frame:null,status:`pending`,attemptCount:0,errorCode:null,createdAt:r,updatedAt:r}}function b(e){let{key:t,existing:n}=g(e);if(n!==null)return _(n,e,l.get(t)),l.set(t,e.frame),n;v(e);let r=y(e);return l.set(t,e.frame),f({...c,nextSequence:c.nextSequence+1,records:[...c.records,r]}),r}function x(e,t,n){let r=c.records.find(r=>r.runtimeId===e&&r.actorSessionId===t&&r.transportRequestId===n);if(!r)throw new Ic(`Relay transport request ${n} is not journaled.`);return r}function S(e,t,r,i){x(e,t,r);let a=n().toISOString();l.delete(zc({runtimeId:e,actorSessionId:t,transportRequestId:r})),f({...c,records:c.records.map(n=>n.runtimeId===e&&n.actorSessionId===t&&n.transportRequestId===r?{...n,frame:null,status:`failed`,errorCode:i,updatedAt:a}:n)})}function C(e,t,r){let i=x(e,t,r);if(i.status===`failed`||i.status===`outcome-unknown`)throw new Ic(`Relay transport request ${r} has no replayable outcome.`);let a={...i,status:i.attemptCount>0?`retrying`:`pending`,attemptCount:i.attemptCount+1,errorCode:null,updatedAt:n().toISOString()};return f({...c,records:c.records.map(n=>n.runtimeId===e&&n.actorSessionId===t&&n.transportRequestId===r?a:n)}),a}function w(e,t,n){let r=c.records.filter(r=>r.runtimeId!==e||r.actorSessionId!==t||r.transportRequestId!==n);r.length!==c.records.length&&(l.delete(zc({runtimeId:e,actorSessionId:t,transportRequestId:n})),f({...c,records:r}))}function T(e,t,n){let r=x(e,t,n);if(r.status!==`failed`&&r.status!==`outcome-unknown`)throw new Ic(`Relay transport request ${n} does not have an acknowledgeable outcome.`);w(e,t,n)}function E(){let e=n(),t=c.records.map(t=>p(t,e));t.some((e,t)=>e!==c.records[t])&&f({...c,records:t})}function D(e,t){let r=n().toISOString(),i=c.records.map(n=>n.runtimeId!==e||n.actorSessionId===t||n.status!==`pending`&&n.status!==`retrying`?n:(l.delete(zc(n)),{...n,frame:null,status:`outcome-unknown`,errorCode:`RELAY_ACTOR_SESSION_CHANGED`,updatedAt:r}));i.some((e,t)=>e!==c.records[t])&&f({...c,records:i})}return{controlSessionId:c.controlSessionId,prepare:b,records:()=>[...c.records],pending:()=>[...c.records],replayable:(e,t)=>(E(),c.records.filter(n=>n.runtimeId===e&&n.actorSessionId===t&&n.persistence===`frame`&&n.frame!==null&&(n.status===`pending`||n.status===`retrying`))),fenceActor:D,beginAttempt:C,markFailed:S,complete:w,acknowledge:T,subscribe:e=>(u.add(e),e(d()),()=>u.delete(e))}}function Lse(e=null){let t=e;return{read:()=>t,write:e=>{t=e}}}var Rse=tn(rne),zse=ir(tne),Bse=ir(er),Vse=[`rpc.read`,`rpc.mutate`,`cursor.resume`,`terminal.stream`,`browser.stream`,`bulk.transfer`,`envelope.validation`,`payload.e2e`];function Hc(e,t){if(!Array.isArray(e))return null;for(let n of e)if(Array.isArray(n)&&n.length===2&&n[0]===t&&typeof n[1]==`string`)return n[1];return null}function Uc(e,t){let n=JSON.parse(e),r=sae(n);if(r!==null)return{messageType:`request`,...r};let i=Hse(n,t);if(i!==null)return i;let a=Use(n);if(a!==null)return a;throw Error(`Forge relay protocol v2 requires a recognized Effect RPC frame.`)}function Hse(e,t){if(e._tag!==`Request`||typeof e.id!=`string`||e.id.length===0||typeof e.tag!=`string`||e.tag.length===0)return null;let n=Xo({method:e.tag,payload:e.payload,grantedScopes:t});return{messageType:`request`,requestId:e.id,correlationId:Hc(e.headers,An.requestId)??e.id,method:e.tag,...n}}function Use(e){return e._tag!==`Ack`&&e._tag!==`Interrupt`||typeof e.requestId!=`string`||e.requestId.length===0?null:{messageType:`acknowledgement`,requestId:e.requestId,correlationId:e.requestId,method:`@effect/rpc/${e._tag}`,requiredScope:null,deliveryClass:`read`,journalPersistence:`none`}}function Wc(e,t){let n=new Event(`error`);return Object.defineProperties(n,{error:{value:Error(t),enumerable:!0},message:{value:`${e}: ${t}`,enumerable:!0}}),n}var Wse=new Set([`network`,`server`,`auth`,`permission`,`client`]),Gse=new Set([`network`,`server`]);function Kse(e){return e&&typeof e==`object`?e:{}}function qse(e){return typeof e.code==`string`&&e.code.length>0?e.code:typeof e.kind==`string`&&Wse.has(e.kind)?`RELAY_ACTION_GRANT_UNAVAILABLE`:`MALFORMED_FRAME`}function Jse(e){if(e.retryable===!0||typeof e.kind==`string`&&Gse.has(e.kind))return!0;let t=typeof e.status==`number`?e.status:null;return t===429||t!==null&&t>=500}function Gc(e){let t=Kse(e);return{code:qse(t),message:e instanceof Error?e.message:`Forge relay frame encoding failed.`,retryable:Jse(t)}}function Kc(e,t){let n=new Event(e.type),r=e;for(let e of t)r[e]!==void 0&&Object.defineProperty(n,e,{value:r[e],enumerable:!0});return n}function Yse(e){return!Array.isArray(e)||e.length!==2||typeof e[0]!=`string`?!1:Object.values(An).includes(e[0])}function qc(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function Xse(e){if(!Array.isArray(e))return null;for(let t of e){let e=qc(t);if(e?._tag!==`Fail`)continue;let n=qc(e.error)?.code;if(typeof n==`string`&&n.length>0)return n}return null}function Zse(e){let t=qc(e.exit);return t===null?`RELAY_RPC_RESPONSE_INVALID`:t._tag===`Success`?null:t._tag!==`Failure`||!Array.isArray(t.cause)?`RELAY_RPC_RESPONSE_INVALID`:Xse(t.cause)??`RELAY_RPC_FAILED`}function Jc(e){if(typeof e!=`string`)return null;try{let t=Rse(JSON.parse(e));return t._tag===`Some`?t.value:null}catch{return null}}function Qse(e,t){if(e.role===`control`&&e.protocolVersion===t&&e.protocolVersion>=1){if(e.protocolVersion===1)return null;if(e.actor!==void 0&&e.scopes!==void 0)return{runtimeId:e.runtimeId,connectionEpoch:e.connectionEpoch,protocolVersion:e.protocolVersion,actor:e.actor,scopes:e.scopes}}}function Yc(e,t,n){if(typeof e==`string`)try{let r=qc(JSON.parse(e));if(r?._tag!==`Exit`||typeof r.requestId!=`string`)return;let i=Zse(r);if(i===null){n.complete(t.runtimeId,t.actor.sessionId,r.requestId);return}n.markFailed(t.runtimeId,t.actor.sessionId,r.requestId,i)}catch{}}function $se(e){let t=Hc(e,An.sequence);if(t===null)return;let n=Number(t);return Number.isSafeInteger(n)&&n>=0?n:void 0}function ece(e){return{issuedAt:Hc(e,An.issuedAt)??new Date().toISOString(),expiresAt:Hc(e,An.expiresAt)??new Date(Date.now()+12e4).toISOString()}}function tce(e){if(e!==2&&e!==3&&e!==4)throw new qo(`protocol_version_mismatch`,`Unsupported Forge relay envelope version: ${e}`,!1);return e}async function nce(e){let t=hae({method:e.identity.method,payload:e.payload});if(t===null)return;let n=rce(e.context);if(e.acquire===void 0)throw new qo(`action_grant_required`,`CMMD action-grant issuance is unavailable for this remote response.`,!1);return e.acquire({...n,method:`orchestration.dispatchCommand`,...t,durableRequestId:e.identity.correlationId,payloadHash:e.payloadHash,requiredScope:`approval.respond`})}function rce(e){if(e.protocolVersion===3)return{protocolVersion:3};if(e.protocolVersion!==4)throw new qo(`protocol_update_required`,`Update Forge on the target runtime before responding remotely.`,!1);return{protocolVersion:4,channelId:Xc(e.channelId),channelTicketDigest:Xc(e.channelTicketDigest),runtimeEndpointKeyId:Xc(e.runtimeEndpointKeyId),controlEndpointKeyId:Xc(e.controlEndpointKeyId)}}function Xc(e){if(typeof e==`string`&&e.length>0)return e;throw new qo(`channel_ticket_binding_invalid`,`The encrypted Forge relay channel is missing its CMMD ticket binding.`,!1)}function ice(e){return e===void 0?{}:{sequence:e}}function Zc(e){return e===void 0?{}:{actionGrant:e}}async function ace(e){let t=Uc(e.data,e.context.scopes),n=JSON.parse(e.data),r=ece(n.headers),i=$se(n.headers),a=await e.crypto.sha256Base64Url(e.data),o=await nce({context:e.context,identity:t,payload:n.payload,payloadHash:a,...e.acquireActionGrant===void 0?{}:{acquire:e.acquireActionGrant}}),s=tce(e.context.protocolVersion),c={messageType:t.messageType,requestId:t.requestId,correlationId:t.correlationId,method:t.method,requiredScope:t.requiredScope,deliveryClass:t.deliveryClass,runtimeId:e.context.runtimeId,connectionEpoch:e.context.connectionEpoch,actor:e.context.actor,...r,payloadHash:a,...ice(i)};return s===2?{protocolVersion:2,...c}:s===3?{protocolVersion:3,...c,...Zc(o)}:{protocolVersion:4,...c,...Zc(o)}}function Qc(e){return typeof e==`string`&&e.length>0}function oce(e){return[e.protocolVersion===4,Qc(e.runtimeId),Number.isSafeInteger(e.connectionEpoch),Number(e.connectionEpoch)>0,e.hpkeSuite===fc,Qc(e.channelId),Qc(e.runtimeEndpointKeyId),Qc(e.runtimeEndpointPublicKey),Qc(e.controlEndpointKeyId),Qc(e.controlEndpointPublicKey),Qc(e.controlChannelNonce),e.controlEndpointKeyPair!==void 0].every(Boolean)}function $c(e){if(!oce(e))throw new qo(`end_to_end_encryption_required`,`Forge relay protocol v4 requires complete endpoint encryption metadata.`,!1);return e}async function sce(e){if(await Nc(e.controlEndpointKeyPair.publicKey)!==e.controlEndpointPublicKey)throw new qo(`endpoint_key_invalid`,`The control endpoint private key does not match the CMMD route.`,!1);let t=await gse(e.runtimeEndpointPublicKey),[n,r]=await Promise.all([Ac({exactCompactTicket:e.token,channelId:e.channelId,direction:`control-to-runtime`,runtimeId:e.runtimeId,connectionEpoch:e.connectionEpoch},e.payloadDigestProvider),Ac({exactCompactTicket:e.token,channelId:e.channelId,direction:`runtime-to-control`,runtimeId:e.runtimeId,connectionEpoch:e.connectionEpoch},e.payloadDigestProvider)]);return{controlToRuntimeBinding:n,runtimeToControlBinding:r,sender:await bse({binding:n,senderKey:e.controlEndpointKeyPair,recipientPublicKey:t,...e.payloadRandomSource?{randomSource:e.payloadRandomSource}:{}}),runtimePublicKey:t,recipient:null,phase:`awaiting-runtime-hello`}}function el(e,t,n){return[e.direction===`runtime-to-control`,e.frameClass===n,e.channelId===t.channelId].every(Boolean)}function cce(e){return[e.confirmation.phase===e.expectedPhase,e.confirmation.channelId===e.route.channelId,e.confirmation.runtimeId===e.context.runtimeId,e.confirmation.connectionEpoch===e.context.connectionEpoch].every(Boolean)}function lce(e){let{envelope:t}=e.application;return[t.runtimeId===e.context.runtimeId,t.connectionEpoch===e.context.connectionEpoch,t.actor.userId===e.context.actor.userId,t.actor.deviceId===e.context.actor.deviceId,t.actor.sessionId===e.context.actor.sessionId,t.payloadHash===e.payloadHash].every(Boolean)}async function uce(e){if(e.channel.recipient!==null){if(e.message.encapsulatedKey!==void 0)throw new qo(`endpoint_key_invalid`,`The runtime attempted to replace its endpoint encapsulation.`,!1);return e.channel.recipient}if(e.message.sequence!==0||!e.message.encapsulatedKey)throw new qo(`channel_confirmation_failed`,`The runtime handshake omitted its endpoint encapsulation.`,!1);let t=await xse({binding:e.channel.runtimeToControlBinding,recipientKey:e.route.controlEndpointKeyPair,senderPublicKey:e.channel.runtimePublicKey,encapsulatedKey:e.message.encapsulatedKey});return e.channel.recipient=t,t}var dce=class extends EventTarget{socket;route;relayCrypto;journal;lifecycle;acquireActionGrant;CONNECTING=WebSocket.CONNECTING;OPEN=WebSocket.OPEN;CLOSING=WebSocket.CLOSING;CLOSED=WebSocket.CLOSED;binaryType=`blob`;onopen=null;onclose=null;onerror=null;onmessage=null;authenticated=!1;context=null;payloadChannel=null;sendChain=Promise.resolve();constructor(e,t,n,r,i={},a){super(),this.socket=e,this.route=t,this.relayCrypto=n,this.journal=r,this.lifecycle=i,this.acquireActionGrant=a,e.addEventListener(`open`,()=>void this.beginAuthentication()),e.addEventListener(`message`,e=>void this.handleMessageSafely(e)),e.addEventListener(`error`,e=>{let t=Kc(e,[`error`,`message`]),n=typeof t.message==`string`?String(t.message):`Forge relay connection failed.`;this.lifecycle.onError?.({code:`RELAY_SOCKET_ERROR`,message:n}),this.emit(`error`,t)}),e.addEventListener(`close`,e=>{this.authenticated=!1,this.context=null,this.payloadChannel=null,this.lifecycle.onDisconnected?.({code:e.code,reason:e.reason}),this.emit(`close`,Kc(e,[`code`,`reason`,`wasClean`]))})}get bufferedAmount(){return this.socket.bufferedAmount}get extensions(){return this.socket.extensions}get protocol(){return this.socket.protocol}get readyState(){return this.authenticated?this.socket.readyState:WebSocket.CONNECTING}get url(){return this.route.relayWebSocketUrl}send(e){if(!this.authenticated||typeof e!=`string`)throw new DOMException(`Forge relay RPC socket is not open for text frames.`,`InvalidStateError`);if(this.route.protocolVersion===1){this.socket.send(JSON.stringify({type:`relay.frame`,payload:e}));return}let t=this.context;if(t===null)throw new DOMException(`Forge relay v2 context is unavailable.`,`InvalidStateError`);let n=Uc(e,t.scopes),r=n.messageType===`request`&&n.journalPersistence!==`none`?this.journal.prepare({runtimeId:t.runtimeId,actorSessionId:t.actor.sessionId,transportRequestId:n.requestId,...n.correlationId===n.requestId?{}:{durableRequestId:n.correlationId},method:n.method,frame:e,persistence:n.journalPersistence}):null;this.enqueueFrame(e,r)}enqueueFrame(e,t){this.sendChain=this.sendChain.then(()=>this.transmitFrame(e,t)).catch(e=>{let n=Gc(e);t!==null&&!n.retryable&&this.journal.markFailed(t.runtimeId,t.actorSessionId,t.transportRequestId,n.code),this.lifecycle.onError?.({code:n.code,message:n.message}),this.emit(`error`,Wc(n.code,n.message)),this.socket.readyState<WebSocket.CLOSING&&this.socket.close(4400,`${n.code}: ${n.message}`)})}async transmitFrame(e,t){let n=this.requireReadyContext(),r=await this.outboundFrame(e,t),i=await ace({data:r,context:n,crypto:this.relayCrypto,...this.acquireActionGrant?{acquireActionGrant:this.acquireActionGrant}:{}});if(n.protocolVersion===4){let e=await this.requirePayloadChannel().sender.seal({frameClass:`application`,plaintext:new TextEncoder().encode(JSON.stringify({payload:r,envelope:i}))});this.socket.send(JSON.stringify(e));return}this.socket.send(JSON.stringify({type:`relay.frame`,payload:r,envelope:i}))}requireReadyContext(){if(!this.authenticated||this.socket.readyState!==WebSocket.OPEN)throw new DOMException(`Forge relay RPC socket closed before send.`,`InvalidStateError`);if(this.context===null)throw new DOMException(`Forge relay v2 context is unavailable.`,`InvalidStateError`);return this.context}requirePayloadChannel(){let e=this.payloadChannel;if(e===null||e.phase!==`ready`)throw new qo(`channel_confirmation_failed`,`The Forge relay endpoint channel is not confirmed.`,!1);return e}async outboundFrame(e,t){return t===null?e:this.withDurableHeaders(t,e)}async withDurableHeaders(e,t){let n=this.journal.beginAttempt(e.runtimeId,e.actorSessionId,e.transportRequestId),r=JSON.parse(t),i=await vce({payload:r.payload,sequence:n.sequence,requestId:n.durableRequestId,issuedAt:new Date(n.updatedAt),crypto:this.relayCrypto}),a=Array.isArray(r.headers)?r.headers.filter(e=>!Yse(e)):[];return JSON.stringify({...r,headers:[...a,...Object.entries(i)]})}close(e,t){this.socket.close(e,t)}asWebSocket(){return this}emit(e,t){this.dispatchEvent(t);let n=this[`on${e}`];n&&n.call(this.asWebSocket(),t)}async handleMessage(e){if(this.authenticated){if(this.context?.protocolVersion===4){await this.handleEncryptedApplicationMessage(e.data);return}this.context!==null&&Yc(e.data,this.context,this.journal),this.emit(`message`,new MessageEvent(`message`,{data:e.data}));return}await this.handleAuthenticationMessage(e.data)}async handleMessageSafely(e){try{await this.handleMessage(e)}catch(e){let t=Gc(e);this.lifecycle.onError?.({code:t.code,message:t.message}),this.emit(`error`,Wc(t.code,t.message)),this.socket.readyState<WebSocket.CLOSING&&this.socket.close(4400,`${t.code}: ${t.message}`)}}async beginAuthentication(){try{this.route.protocolVersion===4&&(this.payloadChannel=await sce($c(this.route))),this.socket.send(JSON.stringify({type:`relay.auth`,ticket:this.route.token,protocolMinVersion:this.route.protocolVersion,protocolMaxVersion:this.route.protocolVersion,capabilities:Vse,...this.payloadChannel?{controlToRuntimeEncapsulatedKey:this.payloadChannel.sender.encapsulatedKey}:{}}))}catch(e){let t=Gc(e);this.lifecycle.onError?.({code:t.code,message:t.message}),this.emit(`error`,Wc(t.code,t.message)),this.socket.close(4400,t.message)}}async handleAuthenticationMessage(e){let t=Jc(e);if(t!==null){if(t.type===`relay.encrypted-frame`&&this.context?.protocolVersion===4){await this.handleEncryptedHandshakeMessage(t);return}if(t.type===`relay.error`){this.lifecycle.onError?.({code:t.code,message:t.message}),this.emit(`error`,Wc(t.code,t.message)),this.socket.close(4403,t.message);return}t.type===`relay.authenticated`&&await this.handleAuthenticatedMessage(t)}}async handleAuthenticatedMessage(e){let t=Qse(e,this.route.protocolVersion);if(t===void 0){this.socket.close(4400,`Forge relay authenticated the wrong role.`);return}if(t!==null&&t.protocolVersion===4){let n=$c(this.route),r=this.payloadChannel;if(r===null||![e.runtimeId===n.runtimeId,e.connectionEpoch===n.connectionEpoch].every(Boolean)){this.socket.close(4400,`Forge relay authenticated stale endpoint metadata.`);return}t={...t,channelId:n.channelId,channelTicketDigest:fse(r.controlToRuntimeBinding),runtimeEndpointKeyId:n.runtimeEndpointKeyId,controlEndpointKeyId:n.controlEndpointKeyId},this.context=t;return}await this.activateAuthenticatedRelay(t)}async handleEncryptedHandshakeMessage(e){if(e.type!==`relay.encrypted-frame`)return;let t=this.payloadChannel,n=this.context,r=$c(this.route);if(t===null||n===null||!el(e,r,`handshake`))throw new qo(`channel_confirmation_failed`,`The runtime sent an invalid encrypted handshake frame.`,!1);let i=await(await uce({channel:t,route:r,message:e})).open(e),a=zse(JSON.parse(new TextDecoder().decode(i))),o=t.phase===`awaiting-runtime-hello`?`runtime-hello`:`runtime-confirm`;if(!cce({confirmation:a,expectedPhase:o,route:r,context:n}))throw new qo(`channel_confirmation_failed`,`The runtime endpoint confirmation does not match the CMMD route.`,!1);if(o===`runtime-hello`){let e=await t.sender.seal({frameClass:`handshake`,plaintext:new TextEncoder().encode(JSON.stringify({type:`relay.endpoint-confirmation`,protocolVersion:4,phase:`control-confirm`,channelId:r.channelId,runtimeId:n.runtimeId,connectionEpoch:n.connectionEpoch}))});t.phase=`awaiting-runtime-confirm`,this.socket.send(JSON.stringify(e));return}t.phase=`ready`,await this.activateAuthenticatedRelay(n)}async handleEncryptedApplicationMessage(e){let t=Jc(e);if(t?.type!==`relay.encrypted-frame`)throw new qo(`end_to_end_encryption_required`,`The runtime sent plaintext after the encrypted channel was confirmed.`,!1);let n=this.requirePayloadChannel();if(!el(t,$c(this.route),`application`)||t.encapsulatedKey!==void 0||n.recipient===null)throw new qo(`channel_authentication_failed`,`The runtime sent an invalid encrypted application frame.`,!1);let r=await n.recipient.open(t),i=Bse(JSON.parse(new TextDecoder().decode(r))),a=this.requireReadyContext();if(!lce({application:i,context:a,payloadHash:await this.relayCrypto.sha256Base64Url(i.payload)}))throw new qo(`channel_authentication_failed`,`The decrypted runtime envelope does not match the active route.`,!1);Yc(i.payload,a,this.journal),this.emit(`message`,new MessageEvent(`message`,{data:i.payload}))}async activateAuthenticatedRelay(e){this.context=e,this.authenticated=!0,this.lifecycle.onAuthenticated?.();let t=e===null?[]:this.replayForActor(e);for(let e of t)e.frame!==null&&this.enqueueFrame(e.frame,e);t.length>0&&await this.sendChain,this.emit(`open`,new Event(`open`))}replayForActor(e){return this.journal.fenceActor(e.runtimeId,e.actor.sessionId),this.journal.replayable(e.runtimeId,e.actor.sessionId)}};function fce(e,t,n=tl,r=Vc({storage:Lse(),randomUUID:n.randomUUID}),i={},a){return new dce(e,t,n,r,i,a).asWebSocket()}var pce=jo(one);async function mce(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest(`SHA-256`,t);return btoa(String.fromCharCode(...new Uint8Array(n))).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replaceAll(`=`,``)}var tl={randomUUID:()=>crypto.randomUUID(),sha256Base64Url:mce},nl=`forge-relay-binding=`,hce=3e4;function gce(e){let t=new URL(String(e)).hash.slice(1);if(!t.startsWith(nl))throw Error(`Forge relay socket URL is missing its route binding.`);let n=decodeURIComponent(t.slice(20));if(n.length===0)throw Error(`Forge relay socket URL has an invalid route binding.`);return n}function _ce(e){let t=e.crypto??tl,n=e.bindingTtlMs??hce,r=e.createSocket??((e,t)=>new globalThis.WebSocket(e,t)),i=new Map;return{acquireSocketUrl:async()=>{let r=await e.acquireRoute(),a=t.randomUUID();if(i.has(a))throw Error(`Forge relay route binding identifier was reused.`);let o=new URL(r.relayWebSocketUrl);o.hash=`${nl}${encodeURIComponent(a)}`;let s=setTimeout(()=>i.delete(a),n);return i.set(a,{route:r,expires:s}),o.toString()},constructSocket:(n,a)=>{let o=gce(n),s=i.get(o);if(s===void 0)throw Error(`Forge relay route binding is missing, expired, or already consumed.`);return i.delete(o),clearTimeout(s.expires),e.lifecycle?.onConnecting?.(),fce(r(s.route.relayWebSocketUrl,a),s.route,t,e.journal,e.lifecycle,e.acquireActionGrant)}}}async function vce(e){let t=e.issuedAt??new Date,n=e.crypto??tl;return{[An.requestId]:e.requestId??n.randomUUID(),[An.sequence]:String(e.sequence),[An.issuedAt]:t.toISOString(),[An.expiresAt]:new Date(t.getTime()+12e4).toISOString(),[An.payloadHash]:await n.sha256Base64Url(aae(e.payload))}}function yce(e,t){return $te(une,({rpc:t,request:n,next:r})=>nt(function*(){return Xo({method:t._tag,payload:n.payload,grantedScopes:e}),yield*r(n)}))}function bce(e,t=tl){return pce.pipe(be(yce(e,t)))}function xce(e){let t=e.crypto??tl,n=_ce({acquireRoute:e.acquireRoute,...e.acquireActionGrant?{acquireActionGrant:e.acquireActionGrant}:{},crypto:t,journal:e.journal,...e.lifecycle?{lifecycle:e.lifecycle}:{}}),r=ft(n.acquireSocketUrl).pipe(l),i=pe(ca,n.constructSocket),a=la(r).pipe(E(i)),o=e.delayForRetry??iae,s=It(y(e.maxRetries??10),e=>et(Ve(o(e)??0)));return dt(Po,Fo({retryPolicy:s,retryTransientErrors:!0})).pipe(E(Ee(a,Ao)))}var rl=class extends Error{name=`RelayControlRouteSecurityFailure`};async function Sce(e){let t=await mse(e),n=await Nc(t.publicKey);return{keyPair:t,publicKey:n,keyId:hse(`control`,n),channelNonce:await pse(e)}}function Cce(e){return{hpkeSuite:fc,controlEndpointKeyId:e.keyId,controlEndpointPublicKey:e.publicKey,controlChannelNonce:e.channelNonce}}function wce(e){let t=e.route;if(t.protocolVersion!==4||t.hpkeSuite!==`DHKEM_X25519_HKDF_SHA256/HKDF_SHA256/CHACHA20_POLY1305/AUTH`||!t.channelId||!t.runtimeEndpointKeyId||!t.runtimeEndpointPublicKey||t.controlEndpointKeyId!==e.endpoint.keyId||t.controlEndpointPublicKey!==e.endpoint.publicKey||t.controlChannelNonce!==e.endpoint.channelNonce)throw new rl(`Forge could not establish a verified end-to-end encrypted runtime route.`);return{...t,runtimeId:e.runtimeId,protocolVersion:4,channelId:t.channelId,hpkeSuite:fc,runtimeEndpointKeyId:t.runtimeEndpointKeyId,runtimeEndpointPublicKey:t.runtimeEndpointPublicKey,controlEndpointKeyId:e.endpoint.keyId,controlEndpointPublicKey:e.endpoint.publicKey,controlChannelNonce:e.endpoint.channelNonce,controlEndpointKeyPair:e.endpoint.keyPair,...e.digestProvider?{payloadDigestProvider:e.digestProvider}:{},...e.randomSource?{payloadRandomSource:e.randomSource}:{}}}var il=`~effect/ManagedRuntime`,al=(e,t)=>{let n=t?.memoMap??eee(),r=pee(`parallel`),i=k(r,`sequential`),a={onFiberStart:fe(r)},o=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,c,l=Nt(t=>(c||=m(Dee(s(e,n,i),e=>ct(()=>{u.cachedContext=e})),{...a,scheduler:t.currentScheduler}),zee(ge(c)))),u={[il]:il,memoMap:n,scope:r,contextEffect:l,cachedContext:void 0,context(){return u.cachedContext===void 0?ne(u.contextEffect):Promise.resolve(u.cachedContext)},dispose(){return ne(u.disposeEffect)},disposeEffect:Dt(()=>(u.contextEffect=gee(`ManagedRuntime disposed`),u.cachedContext=void 0,Be(u.scope,St))),runFork(e,t){return u.cachedContext===void 0?m(ol(u,e),o(t)):He(u.cachedContext)(e,o(t))},runCallback(e,t){return u.cachedContext===void 0?oee(ol(u,e),o(t)):Bt(u.cachedContext)(e,o(t))},runSyncExit(e){return u.cachedContext===void 0?Xee(ol(u,e)):se(u.cachedContext)(e)},runSync(e){return u.cachedContext===void 0?de(ol(u,e)):yee(u.cachedContext)(e)},runPromiseExit(e,t){return u.cachedContext===void 0?uee(ol(u,e),o(t)):hee(u.cachedContext)(e,o(t))},runPromise(e,t){return u.cachedContext===void 0?ne(ol(u,e),o(t)):te(u.cachedContext)(e,o(t))}};return u};function ol(e,t){return bt(e.contextEffect,e=>Ce(t,e))}function sl(e,t=nr){return`${e}\0${t}`}function Tce(e){let t=new Map,n=!1;return{register(e){if(n)throw Error(`Terminal control sequencer is disposed.`);let r=sl(e.threadId,e.terminalId);t.get(r)?.sessionEpoch!==e.sessionEpoch&&t.set(r,{sessionEpoch:e.sessionEpoch,nextControlSequence:1,tail:Promise.resolve(),pendingWriteBytes:0})},enqueue(r){if(n)return Promise.reject(Error(`Terminal control sequencer is disposed.`));let i=r.terminalId??`default`,a=t.get(sl(r.threadId,i));if(!a)return Promise.reject(Error(`Terminal must be opened before sending controls.`));let o=r.writeBytes??0;if(a.pendingWriteBytes+o>e.maxPendingWriteBytes)return Promise.reject(Error(`Terminal input queue is full while reconnecting.`));a.pendingWriteBytes+=o;let s=a.tail.then(async()=>{let t=a.nextControlSequence;await r.execute({sessionEpoch:a.sessionEpoch,controllerId:e.controllerId,controlSequence:t}),a.nextControlSequence=t+1});return a.tail=s.finally(()=>{a.pendingWriteBytes-=o}).catch(()=>void 0),s},remove(e,n){if(n){t.delete(sl(e,n));return}let r=`${e}\0`;for(let e of t.keys())e.startsWith(r)&&t.delete(e)},terminalIds(e){let n=`${e}\0`;return[...t.keys()].filter(e=>e.startsWith(n)).map(e=>e.slice(n.length))},dispose(){n=!0,t.clear()}}}var cl={accept:!1,observe:!1,missingFrameCount:0,startsNewStream:!1};function ll(e){let t=e===!0;return{accept:t,observe:t,missingFrameCount:0,startsNewStream:t}}function Ece(e,t){let n=e.streamGeneration===void 0&&e.streamId===void 0,r=t.streamGeneration!==void 0||t.streamId!==void 0;return n&&r?ll(t.keyframe):null}function Dce(e,t){return e.streamGeneration===void 0||t.streamGeneration===void 0?null:t.streamGeneration<e.streamGeneration?cl:t.streamGeneration>e.streamGeneration?ll(t.keyframe):null}function Oce(e,t){if(!e.streamId||!t.streamId)return null;if(e.streamId!==t.streamId)return ll(t.keyframe);if(t.sequence<=e.observedSequence)return cl;let n=Math.max(0,t.sequence-e.observedSequence-1);return{accept:n===0||t.keyframe===!0,observe:!0,missingFrameCount:n,startsNewStream:!1}}function kce(e,t){if(t.sequence>e.acceptedSequence)return{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1};if(!e.acceptedCapturedAt)return cl;let n=Date.parse(e.acceptedCapturedAt),r=Date.parse(t.capturedAt);return Number.isNaN(n)||Number.isNaN(r)||r<=n?cl:{accept:!0,observe:!0,missingFrameCount:0,startsNewStream:!1}}function Ace(e,t){return Ece(e,t)??Dce(e,t)??Oce(e,t)??kce(e,t)}function jce(e,t){let n=Ace(e,t);if(!n.observe)return{accept:n.accept,observe:n.observe,missingFrameCount:n.missingFrameCount,state:e};let r=n.startsNewStream?t.sequence:Math.max(e.observedSequence,t.sequence),i={...e,observedSequence:r,gapCount:e.gapCount+n.missingFrameCount},a=n.accept?{...i,acceptedSequence:t.sequence,acceptedCapturedAt:t.capturedAt,...t.streamId?{streamId:t.streamId}:{},...t.streamGeneration===void 0?{}:{streamGeneration:t.streamGeneration}}:i;return{accept:n.accept,observe:n.observe,missingFrameCount:n.missingFrameCount,state:a}}ir(fne);var ul=mte(),dl=`Forge`,fl=`Alpha`,pl=dl,ml=`0.9.10`;function hl(e){return{_tag:`Value`,value:e}}function gl(e,t){return{_tag:`Record`,keys:e,value:t}}function _l(e,t){return{_tag:`Array`,length:e,value:t}}qn(`SourceError`);var vl=xt(`effect/ConfigProvider`,{defaultValue:()=>xl()}),yl={...le,toJSON(){return{_id:`ConfigProvider`}}};function bl(e,t,n){let r=Object.create(yl);return r.get=e,r.mapInput=t,r.prefix=n,r.load=r=>(t&&(r=t(r)),n&&(r=[...n,...r]),e(r)),r}function xl(e){let t=e?.env??{APP_VERSION:`0.9.10`,BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,TSS_INLINE_CSS_ENABLED:`false`,VITE_COMMIT_SHA:``,VITE_HTTP_URL:``,VITE_SENTRY_COMMIT_SHA:``,VITE_SENTRY_DEBUG:``,VITE_SENTRY_DSN:``,VITE_SENTRY_ENABLED:``,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_PROFILES_SAMPLE_RATE:``,VITE_SENTRY_RELEASE:`forge-web@0.9.10`,VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE:``,VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE:``,VITE_SENTRY_TRACES_SAMPLE_RATE:``,VITE_WS_URL:``},n=Sl(t);return bl(e=>et(wl(n,t,e)))}function Sl(e){let t={};for(let[n,r]of Object.entries(e)){if(r===void 0)continue;let e=n.split(`_`),i=t;for(let t of e)i.children??={},i=i.children[t]??={};i.value=r}return t}var Cl=/^(0|[1-9][0-9]*)$/;function wl(e,t,n){let r=t[n.map(String).join(`_`)],i=Tl(e,n),a=i?.children?Object.keys(i.children):[];return a.length===0?r===void 0?void 0:hl(r):a.every(e=>Cl.test(e))?_l(Math.max(...a.map(e=>parseInt(e,10)))+1,r):gl(new Set(a),r)}function Tl(e,t){if(t.length===0)return e;let n=e;for(let e of t)if(n=n?.children?.[String(e)],!n)return;return n}var El=`~effect/Config`,Dl=class{_tag=`ConfigError`;name=`ConfigError`;cause;constructor(e){this.cause=e}get message(){return this.cause.toString()}toString(){return`ConfigError(${this.message})`}},Ol={...le,...ae,[El]:El,asEffect(){return bt(vl.asEffect(),e=>this.parse(e))},toJSON(){return{_id:`Config`}}};function kl(e){let t=Object.create(Ol);return t.parse=e,t}var Al=Xe(function*(e,t){let n=yield*e.load(t);if(n!==void 0)switch(n._tag){case`Value`:return n.value;case`Record`:{if(n.value!==void 0)return n.value;let r={};for(let i of n.keys){let n=yield*Al(e,[...t,i]);n!==void 0&&(r[i]=n)}return r}case`Array`:{if(n.value!==void 0)return n.value;let r=[];for(let i=0;i<n.length;i++)r.push(yield*Al(e,[...t,i]));return r}}}),jl=Xe(function*(e,t,n){switch(e._tag){case`Objects`:{let r={};for(let i of e.propertySignatures){let e=i.name;if(typeof e==`string`){let a=yield*jl(i.type,t,[...n,e]);a!==void 0&&(r[e]=a)}}if(e.indexSignatures.length>0){let i=yield*t.load(n);if(i&&i._tag===`Record`)for(let a of e.indexSignatures){let e=Lte(a.parameter);for(let o of i.keys)if(!Object.hasOwn(r,o)&&e(o)){let e=yield*jl(a.type,t,[...n,o]);e!==void 0&&(r[o]=e)}}}return r}case`Arrays`:{let r=yield*t.load(n);if(r&&r._tag===`Value`)return r.value;let i=[];for(let r=0;r<e.elements.length;r++)i.push(yield*jl(e.elements[r],t,[...n,r]));return i}case`Union`:return yield*Al(t,n);case`Suspend`:return yield*jl(e.thunk(),t,n);default:{let e=yield*t.load(n);return e===void 0?void 0:e._tag===`Value`||e._tag===`Record`&&e.value!==void 0||e._tag===`Array`&&e.value!==void 0?e.value:void 0}}});function Ml(e,t){let n=Vte(e),r=Gte(n),i=Ote(n.ast),a=typeof t==`string`?[t]:t??[];return kl(e=>{let t=e.prefix?[...e.prefix,...a]:a;return jl(i,e,a).pipe(ete(e=>r(e).pipe(Ft(e=>new Nte(t.length>0?new Yte(t,e):e)))),Ft(e=>new Dl(e)))})}var Nl=(e,t,n)=>{let r=Pn(e,t),i=Gn.pipe(ar(Pn(Gn,Gn),Jte(n)),ar(r));return Dn([r,i])},Pl=_te(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),Fl=!1,Il=!1,Ll=null,Rl=null,zl=null,Bl=!1,Vl=new Set;function Mce(e){if(Fl||Il)return;if(!e.publicKey||!e.host){Il=!0;return}if(Ll)return;if(typeof window>`u`||typeof location>`u`){Il=!0;return}let t=e.publicKey,n=e.host;Ll=N(async()=>{let{default:e}=await import(`./module-44GyzBiP.js`);return{default:e}},[]).then(({default:e})=>{Rl=e,e.init(t,{api_host:n,person_profiles:`identified_only`,capture_pageview:!1,capture_pageleave:!1,autocapture:!1,disable_session_recording:!0,loaded:()=>{Fl=!0,zl&&Hl(zl),Ul(),Vl.forEach(e=>e())}})}).catch(()=>{Il=!0,Rl=null})}function Hl(e){if(zl=e,!Fl||!Rl)return;let t={};e.email!==void 0&&(t.email=e.email),e.displayName!==void 0&&(t.name=e.displayName),Rl.identify(e.cmmdUserId,t)}function Nce(e){return!Fl||!Rl?!1:Rl.isFeatureEnabled(e)===!0}function Ul(){!Rl||Bl||(Bl=!0,Rl.onFeatureFlags(()=>{Vl.forEach(e=>e())}))}function Pce(e){return Vl.add(e),Fl&&Rl&&(Ul(),e()),()=>{Vl.delete(e)}}var Wl=`token`;function Gl(e){return new URLSearchParams(e.hash.startsWith(`#`)?e.hash.slice(1):e.hash)}function Kl(e){let t=Gl(e).get(Wl)?.trim()??``;if(t.length>0)return t;let n=e.searchParams.get(Wl)?.trim()??``;return n.length>0?n:null}function Fce(e){let t=new URL(e.toString()),n=Gl(t);return n.has(Wl)&&(n.delete(Wl),t.hash=n.toString()),t.searchParams.delete(Wl),t}function ql(e,t){let n=new URL(e.toString());return n.searchParams.delete(Wl),n.hash=new URLSearchParams([[Wl,t]]).toString(),n}function Ice(e,t){let n=new URL(e);return n.pathname=`/login`,ql(n,t).toString()}function Lce(e){return ql(new URL(`/login`,window.location.href),e).toString()}function Rce(e){let t=new URL(e),n=Kl(t),r=new URL(`forge:///pair`);return r.searchParams.set(`serverUrl`,t.origin),n&&r.searchParams.set(Wl,n),r.toString()}var B=typeof __SENTRY_DEBUG__>`u`||__SENTRY_DEBUG__,V=globalThis,Jl=`10.70.0`;function Yl(){return Xl(V),V}function Xl(e){let t=e.__SENTRY__=e.__SENTRY__||{};return t.version=t.version||`10.70.0`,t[Jl]=t[`10.70.0`]||{}}function Zl(e,t,n=V){let r=n.__SENTRY__=n.__SENTRY__||{},i=r[Jl]=r[`10.70.0`]||{};return i[e]||(i[e]=t())}var Ql=[`debug`,`info`,`warn`,`error`,`log`,`assert`,`trace`],zce=`Sentry Logger `,$l={};function eu(e){if(!(`console`in V))return e();let t=V.console,n={},r=Object.keys($l);r.forEach(e=>{let r=$l[e];n[e]=t[e],t[e]=r});try{return e()}finally{r.forEach(e=>{t[e]=n[e]})}}function Bce(){ru().enabled=!0}function Vce(){ru().enabled=!1}function tu(){return ru().enabled}function Hce(...e){nu(`log`,...e)}function Uce(...e){nu(`warn`,...e)}function Wce(...e){nu(`error`,...e)}function nu(e,...t){B&&tu()&&eu(()=>{V.console[e](`${zce}[${e}]:`,...t)})}function ru(){return B?Zl(`loggerSettings`,()=>({enabled:!1})):{enabled:!1}}var H={enable:Bce,disable:Vce,isEnabled:tu,log:Hce,warn:Uce,error:Wce},iu=50,au=/\(error: (.*)\)/,ou=/captureMessage|captureException/;function su(...e){let t=e.sort((e,t)=>e[0]-t[0]).map(e=>e[1]);return(e,n=0,r=0)=>{let i=[],a=e.split(`
|
|
3
3
|
`);for(let e=n;e<a.length;e++){let n=a[e];n.length>1024&&(n=n.slice(0,1024));let o=au.test(n)?n.replace(au,`$1`):n;if(!o.includes(`Error: `)){for(let e of t){let t=e(o);if(t){i.push(t);break}}if(i.length>=iu+r)break}}return Kce(i.slice(r))}}function Gce(e){return Array.isArray(e)?su(...e):e}function Kce(e){if(!e.length)return[];let t=Array.from(e);return/sentryWrapped/.test(cu(t).function||``)&&t.pop(),t.reverse(),ou.test(cu(t).function||``)&&(t.pop(),ou.test(cu(t).function||``)&&t.pop()),t.slice(0,iu).map(e=>({...e,filename:e.filename||cu(t).filename,function:e.function||`?`}))}function cu(e){return e[e.length-1]||{}}var lu=`<anonymous>`;function uu(e){try{return!e||typeof e!=`function`?lu:e.name||lu}catch{return lu}}function du(e){let t=e.exception;if(t){let e=[];try{return t.values.forEach(t=>{t.stacktrace.frames&&e.push(...t.stacktrace.frames)}),e}catch{return}}}function qce(e){let t=e?.startsWith(`file://`)?e.slice(7):e;return t?.match(/\/[A-Z]:/)&&(t=t.slice(1)),t}var fu={},pu={};function mu(e,t){return fu[e]=fu[e]||[],fu[e].push(t),()=>{let n=fu[e];if(n){let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}function hu(e,t){if(!pu[e]){pu[e]=!0;try{t()}catch(t){B&&H.error(`Error while instrumenting ${e}`,t)}}}function gu(e,t){let n=e&&fu[e];if(n)for(let r of n)try{r(t)}catch(t){B&&H.error(`Error while triggering instrumentation handler.
|
|
4
4
|
Type: ${e}
|
|
5
5
|
Name: ${uu(r)}
|
|
@@ -2528,4 +2528,4 @@ XID_Start XIDS`.split(/\s/).map(e=>[i5(e),e])),o9e=new Map([[`s`,D5(383)],[D5(38
|
|
|
2528
2528
|
${e}
|
|
2529
2529
|
}
|
|
2530
2530
|
}`}function stt(e,t){let n=t9(t);return e.replace(itt,n)}function ctt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ltt({code:e,pre:t,columnType:n,rowSpan:r,containerSize:i=!1}={}){return e??(e=document.createElement(`code`),e.setAttribute(`data-code`,``),n!=null&&e.setAttribute(`data-${n}`,``),t?.appendChild(e)),r==null?e.style.removeProperty(`grid-row`):e.style.setProperty(`grid-row`,`span ${r}`),i?e.setAttribute(`data-container-size`,``):e.removeAttribute(`data-container-size`),e}function utt(e,t){if(t==null)return;let n=e.shadowRoot??e.attachShadow({mode:`open`});n.innerHTML===``&&(n.innerHTML=t)}function dtt(e,{type:t,diffIndicators:n,disableBackground:r,disableLineNumbers:i,overflow:a,split:o,totalLines:s,customProperties:c}){if(c!=null)for(let t in c){let n=c[t];n!=null&&e.setAttribute(t,`${n}`)}switch(t===`diff`?(e.setAttribute(`data-diff`,``),e.removeAttribute(`data-file`)):(e.setAttribute(`data-file`,``),e.removeAttribute(`data-diff`)),n){case`bars`:case`classic`:e.setAttribute(`data-indicators`,n);break;case`none`:e.removeAttribute(`data-indicators`)}return i?e.setAttribute(`data-disable-line-numbers`,``):e.removeAttribute(`data-disable-line-numbers`),r?e.removeAttribute(`data-background`):e.setAttribute(`data-background`,``),t===`diff`?e.setAttribute(`data-diff-type`,o?`split`:`single`):e.removeAttribute(`data-diff-type`),e.setAttribute(`data-overflow`,a),e.style.setProperty(`--diffs-min-number-column-width-default`,`${`${s}`.length}ch`),e}function ftt(e){if(typeof HTMLStyleElement<`u`&&e instanceof HTMLStyleElement)return!0;let t=e.tagName??e.nodeName;return typeof t==`string`&&t.toLowerCase()===`style`}function ptt(e){return e?.useTokenTransformer===!0||e?.onTokenClick!=null||e?.onTokenEnter!=null||e?.onTokenLeave!=null}function mtt(e,t){let n=e?.offsetHeight??0;if(e==null||n===0){t();return}e.style.minHeight=`${n}px`;try{t(),e.offsetHeight}finally{e.style.minHeight=``}}function htt({shadowRoot:e,currentNode:t,themeCSS:n}){if(n.trim()===``){t?.remove();return}return t??=gtt(),t.textContent=n,t.parentNode!==e&&e.appendChild(t),t}function gtt(){let e=document.createElement(`style`);return e.setAttribute(V4e,``),e}var _tt=void 0;function vtt(){return _tt??=`safari`in window&&`pushNotification`in window.safari||/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}if(typeof HTMLElement<`u`&&customElements.get(`diffs-container`)==null){let e;class t extends HTMLElement{constructor(){if(super(),this.shadowRoot!=null)return;let t=this.attachShadow({mode:`open`});e??(e=new CSSStyleSheet,e.replaceSync(rtt)),t.adoptedStyleSheets=[e]}connectedCallback(){e9(this.shadowRoot??this.attachShadow({mode:`open`}))}}customElements.define(y2,t)}function ytt(e){return{...E2,...e}}function btt(e,t){let n=xtt(e,t);return t?n:e.diffHeaderHeight+n}function xtt(e,t){return e.paddingTop??(t?e.spacing:0)}function Stt(e){return e.paddingBottom??e.spacing}function Ctt(e){switch(e){case`simple`:return 4;case`metadata`:case`line-info`:case`line-info-basic`:case`custom`:return 32}}function r9(e,t){return e===t||e?.cacheKey!=null&&e.cacheKey===t?.cacheKey}function i9(e,t){return N2(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength&&e.lineDiffType===t.lineDiffType&&e.maxLineDiffLength===t.maxLineDiffLength}function a9({line:e,spanStart:t,spanLength:n}){return{start:{line:e,character:t},end:{line:e,character:t+n},properties:{"data-diff-span":``},alwaysWrap:!0}}function o9({item:e,arr:t,enableJoin:n,isNeutral:r=!1,isLastItem:i=!1}){let a=t[t.length-1];if(a==null||i||!n){t.push([+!r,e.value]);return}let o=a[0]===0;if(r===o||r&&e.value.length===1&&!o){a[1]+=e.value;return}t.push([+!r,e.value])}function s9(e){return[L2(e.additionStart,e.additionCount)+1,R2(e.additionStart,e.additionCount)+1]}function c9({isPartial:e,rangeSize:t,expandedHunks:n,hunkIndex:r,collapsedContextThreshold:i}){let a=Math.max(t,0);if(a===0||e)return{fromStart:0,fromEnd:0,rangeSize:a,collapsedLines:a,renderAll:!1};if(n===!0||a<=i)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(r),s=Math.min(Math.max(o?.fromStart??0,0),a),c=Math.min(Math.max(o?.fromEnd??0,0),a),l=s+c,u=l>=a;return{fromStart:u?a:s,fromEnd:u?0:c,rangeSize:a,collapsedLines:Math.max(a-l,0),renderAll:u}}function wtt(e){let t=e.hunks[e.hunks.length-1];if(t==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return!1;let n=e.additionLines.length-R2(t.additionStart,t.additionCount),r=e.deletionLines.length-R2(t.deletionStart,t.deletionCount);return n<=0&&r<=0?!1:n!==r}function l9({fileDiff:e,errorPrefix:t}){let n=e.hunks[e.hunks.length-1];if(n==null||e.isPartial||e.additionLines.length===0||e.deletionLines.length===0)return 0;let r=e.additionLines.length-R2(n.additionStart,n.additionCount),i=e.deletionLines.length-R2(n.deletionStart,n.deletionCount);if(r<=0&&i<=0)return 0;if(r!==i)throw Error(`${t}: trailing context mismatch (additions=${r}, deletions=${i}) for ${e.name}`);return Math.min(r,i)}function u9({fileDiff:e,hunkIndex:t,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:i}){if(t!==e.hunks.length-1)return;let a=l9({fileDiff:e,errorPrefix:i});if(a<=0)return;if(n===!0||a<=r)return{fromStart:a,fromEnd:0,rangeSize:a,collapsedLines:0,renderAll:!0};let o=n?.get(e.hunks.length),s=Math.min(Math.max(o?.fromStart??0,0),a);return{fromStart:s,fromEnd:0,rangeSize:a,collapsedLines:a-s,renderAll:s>=a}}function Ttt({fileDiff:e,lineNumber:t,expandedHunks:n,collapsedContextThreshold:r}){if(n===!0||e.isPartial)return!0;for(let[i,a]of e.hunks.entries()){let[o,s]=s9(a);if(t<o){let s=c9({isPartial:e.isPartial,rangeSize:a.collapsedBefore,expandedHunks:n,hunkIndex:i,collapsedContextThreshold:r}),c=o-s.rangeSize;return s.renderAll||t<c+s.fromStart||t>=o-s.fromEnd}if(t<s)return!0}let i=u9({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:n,collapsedContextThreshold:r,errorPrefix:`isAdditionLineRenderable`});if(i==null||i.renderAll)return!0;let a=e.hunks[e.hunks.length-1],[,o]=s9(a);return t<o+i.fromStart||t>=o+i.rangeSize}function Ett({fileDiff:e,lineNumber:t,direction:n,expandedHunks:r,collapsedContextThreshold:i}){if(r===!0||e.isPartial)return t;let a=[],o=1;for(let[t,n]of e.hunks.entries()){let[s,c]=s9(n),l=c9({isPartial:e.isPartial,rangeSize:n.collapsedBefore,expandedHunks:r,hunkIndex:t,collapsedContextThreshold:i}),u=s-l.rangeSize;l.renderAll?a.push([u,s]):(l.fromStart>0&&a.push([u,u+l.fromStart]),l.fromEnd>0&&a.push([s-l.fromEnd,s])),a.push([s,c]),o=c}let s=u9({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:r,collapsedContextThreshold:i,errorPrefix:`getNearestRenderableAdditionLine`});if(s!=null){let e=o;o=e+s.rangeSize,s.renderAll?a.push([e,o]):s.fromStart>0&&a.push([e,e+s.fromStart])}if(t>=o)return t;if(n===`down`){for(let[e,n]of a)if(n>t)return Math.max(e,t);return}for(let e=a.length-1;e>=0;e--){let[n,r]=a[e];if(n<=t)return Math.min(r-1,t)}}function d9({type:e,metrics:t}){return t.hunkSeparatorHeight??Ctt(e)}function f9({type:e,metrics:t}){return e===`simple`||e===`metadata`||e===`line-info-basic`?0:t.spacing}function Dtt({type:e,hunkIndex:t,hunkSpecs:n}){switch(e){case`simple`:return t>0;case`metadata`:return n!=null;case`line-info`:case`line-info-basic`:case`custom`:return!0}}function Ott(e){return e!==`simple`&&e!==`metadata`}function ktt({type:e,metrics:t,hunkIndex:n,hunkSpecs:r}){if(!Dtt({type:e,hunkIndex:n,hunkSpecs:r}))return;let i=d9({type:e,metrics:t}),a=f9({type:e,metrics:t}),o=n>0?a:0,s=a;return{height:i,gapBefore:o,gapAfter:s,totalHeight:o+i+s}}function Att({type:e,metrics:t}){if(!Ott(e))return;let n=d9({type:e,metrics:t}),r=f9({type:e,metrics:t});return{height:n,gapBefore:r,gapAfter:0,totalHeight:r+n}}function p9({diff:e,diffStyle:t,startingLine:n=0,totalLines:r=1/0,expandedHunks:i,collapsedContextThreshold:a=1,callback:o}){let s=jtt({diff:e,diffStyle:t,startingLine:n,expandedHunks:i,collapsedContextThreshold:a}),c={viewportStart:n,viewportEnd:n+r,isWindowedHighlight:n>0||r<1/0,splitCount:s.splitCount,unifiedCount:s.unifiedCount,finalHunkIndex:e.hunks.length-1,shouldBreak(){if(!c.isWindowedHighlight)return!1;let e=c.unifiedCount>=n+r,i=c.splitCount>=n+r;return t===`unified`?e:(t===`split`||e)&&i},shouldSkip(e,r){if(!c.isWindowedHighlight)return!1;let i=e>0&&c.unifiedCount+e<=n,a=r>0&&c.splitCount+r<=n;return t===`unified`?i:(t===`split`||i)&&a},incrementCounts(e,n){(t===`unified`||t===`both`)&&(c.unifiedCount+=e),(t===`split`||t===`both`)&&(c.splitCount+=n)},isInWindow(e,n){if(!c.isWindowedHighlight)return!0;let r=c.isInUnifiedWindow(e),i=c.isInSplitWindow(n);return t===`unified`?r:t===`split`?i:r||i},isInUnifiedWindow(e){return!c.isWindowedHighlight||c.unifiedCount>=n-e&&c.unifiedCount<n+r},isInSplitWindow(e){return!c.isWindowedHighlight||c.splitCount>=n-e&&c.splitCount<n+r},emit(e,n=!1){return n||(t===`unified`?c.incrementCounts(1,0):t===`split`?c.incrementCounts(0,1):c.incrementCounts(1,1)),o(e)??!1}};hunkIterator:for(let n=s.hunkIndex;n<e.hunks.length;n++){let r=e.hunks[n];if(r==null)throw Error(`iterateOverDiff: invalid hunk index`);if(c.shouldBreak())break;let o=L2(r.deletionStart,r.deletionCount),s=L2(r.additionStart,r.additionCount),l=!e.isPartial&&r.deletionCount===0?o:r.deletionLineIndex,u=!e.isPartial&&r.additionCount===0?s:r.additionLineIndex,d=c9({isPartial:e.isPartial,rangeSize:r.collapsedBefore,expandedHunks:i,hunkIndex:n,collapsedContextThreshold:a}),f=n===c.finalHunkIndex?u9({fileDiff:e,hunkIndex:n,expandedHunks:i,collapsedContextThreshold:a,errorPrefix:`iterateOverDiff`}):void 0,p=d.fromStart+d.fromEnd;function m(e,n){return f==null||f.collapsedLines<=0||f.fromStart+f.fromEnd>0?0:t===`unified`?e===r.unifiedLineStart+r.unifiedLineCount-1?f.collapsedLines:0:n===r.splitLineStart+r.splitLineCount-1?f.collapsedLines:0}let h=d.collapsedLines===0;function g(){return h?0:(h=!0,d.collapsedLines)}if(c.shouldSkip(p,p))c.incrementCounts(p,p),g();else{let e=r.unifiedLineStart-d.rangeSize,i=r.splitLineStart-d.rangeSize,a=l-d.rangeSize,f=u-d.rangeSize,p=o+1-d.rangeSize,m=s+1-d.rangeSize;if(m9(c,d.fromStart,t,t=>c.emit({hunkIndex:n,hunk:r,collapsedBefore:0,collapsedAfter:0,type:`context-expanded`,deletionLine:{lineNumber:p+t,lineIndex:a+t,noEOFCR:!1,unifiedLineIndex:e+t,splitLineIndex:i+t},additionLine:{unifiedLineIndex:e+t,splitLineIndex:i+t,lineIndex:f+t,lineNumber:m+t,noEOFCR:!1}}))||(e=r.unifiedLineStart-d.fromEnd,i=r.splitLineStart-d.fromEnd,a=l-d.fromEnd,f=u-d.fromEnd,p=o+1-d.fromEnd,m=s+1-d.fromEnd,m9(c,d.fromEnd,t,t=>c.emit({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:0,type:`context-expanded`,deletionLine:{lineNumber:p+t,lineIndex:a+t,noEOFCR:!1,unifiedLineIndex:e+t,splitLineIndex:i+t},additionLine:{unifiedLineIndex:e+t,splitLineIndex:i+t,lineIndex:f+t,lineNumber:m+t,noEOFCR:!1}}),()=>{g()})))break hunkIterator}let _=r.unifiedLineStart,v=r.splitLineStart,y=l,b=u,x=o+1,S=s+1,C=r.hunkContent.at(-1);for(let e of r.hunkContent){if(c.shouldBreak())break hunkIterator;let i=e===C;if(e.type===`context`){if(c.shouldSkip(e.lines,e.lines))c.incrementCounts(e.lines,e.lines),g();else if(m9(c,e.lines,t,t=>{let a=i&&t===e.lines-1,o=_+t,s=v+t;return c.emit({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:m(o,s),type:`context`,deletionLine:{lineNumber:x+t,lineIndex:y+t,noEOFCR:a&&r.noEOFCRDeletions,unifiedLineIndex:o,splitLineIndex:s},additionLine:{unifiedLineIndex:o,splitLineIndex:s,lineIndex:b+t,lineNumber:S+t,noEOFCR:a&&r.noEOFCRAdditions}})},()=>{g()}))break hunkIterator;_+=e.lines,v+=e.lines,y+=e.lines,b+=e.lines,x+=e.lines,S+=e.lines}else{let a=Math.max(e.deletions,e.additions),o=e.deletions+e.additions;if(!c.shouldSkip(o,a)){let s=Ptt(c,e,t);(s[0]?.[0]??0)>0&&g();for(let[l,u]of s)for(let s=l;s<u;s++){let l=m(_+s,t===`unified`?v+(s<e.deletions?s:s-e.deletions):v+s);if(c.emit(Ftt({hunkIndex:n,hunk:r,collapsedBefore:g(),collapsedAfter:l,diffStyle:t,index:s,unifiedLineIndex:_,splitLineIndex:v,additionLineIndex:b,deletionLineIndex:y,additionLineNumber:S,deletionLineNumber:x,content:e,isLastContent:i,unifiedCount:o,splitCount:a}),!0))break hunkIterator}}g(),c.incrementCounts(o,a),_+=o,v+=a,y+=e.deletions,b+=e.additions,x+=e.deletions,S+=e.additions}}if(f!=null){let{collapsedLines:n,fromStart:r,fromEnd:i}=f,a=r+i;if(m9(c,a,t,t=>{let r=t===a-1;return c.emit({hunkIndex:e.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:r?n:0,type:`context-expanded`,deletionLine:{lineNumber:x+t,lineIndex:y+t,noEOFCR:!1,unifiedLineIndex:_+t,splitLineIndex:v+t},additionLine:{unifiedLineIndex:_+t,splitLineIndex:v+t,lineIndex:b+t,lineNumber:S+t,noEOFCR:!1}})},void 0,()=>c.shouldBreak()))break hunkIterator}}}function jtt({diff:e,diffStyle:t,startingLine:n,expandedHunks:r,collapsedContextThreshold:i}){if(n<=0||t===`both`)return{hunkIndex:0,splitCount:0,unifiedCount:0};let a=Mtt({diff:e,expandedHunks:r,collapsedContextThreshold:i}),o=0,s=e.hunks.length-1,c=e.hunks.length;for(;o<=s;){let e=o+s>>1,r=a[e+1];if(r==null)throw Error(`iterateOverDiff: invalid hunk prefix index`);(t===`unified`?r.unifiedCount:r.splitCount)>n?(c=e,s=e-1):o=e+1}if(c>=e.hunks.length){let t=a[e.hunks.length];if(t==null)throw Error(`iterateOverDiff: invalid terminal hunk prefix index`);return{hunkIndex:e.hunks.length,splitCount:t.splitCount,unifiedCount:t.unifiedCount}}let l=a[c];if(l==null)throw Error(`iterateOverDiff: invalid selected hunk prefix index`);return{hunkIndex:c,splitCount:l.splitCount,unifiedCount:l.unifiedCount}}function Mtt({diff:e,expandedHunks:t,collapsedContextThreshold:n}){let r=0,i=0,a=e.hunks.length-1,o=[{splitCount:0,unifiedCount:0}];for(let s=0;s<e.hunks.length;s++){let c=e.hunks[s];if(c==null)throw Error(`iterateOverDiff: invalid hunk summary index`);let l=c9({isPartial:e.isPartial,rangeSize:c.collapsedBefore,expandedHunks:t,hunkIndex:s,collapsedContextThreshold:n}),u=l.fromStart+l.fromEnd;r+=u+c.splitLineCount,i+=u+c.unifiedLineCount;let d=s===a?u9({fileDiff:e,hunkIndex:s,expandedHunks:t,collapsedContextThreshold:n,errorPrefix:`iterateOverDiff`}):void 0;if(d!=null){let e=d.fromStart+d.fromEnd;r+=e,i+=e}o.push({splitCount:r,unifiedCount:i})}return o}function Ntt(e,t,n){if(!e.isWindowedHighlight||t<=0)return[0,t];let r=[];function i(n){let i=Math.max(0,e.viewportStart-n),a=Math.min(t,e.viewportEnd-n);a>i&&r.push([i,a])}if(n!==`split`&&i(e.unifiedCount),n!==`unified`&&i(e.splitCount),r.length===0)return[0,0];let a=r[0][0],o=r[0][1];for(let e=1;e<r.length;e++){let t=r[e];a=Math.min(a,t[0]),o=Math.max(o,t[1])}return[a,o]}function m9(e,t,n,r,i,a){let[o,s]=Ntt(e,t,n);o>0&&(e.incrementCounts(o,o),i?.());let c=o;for(;c<t;){if(a?.()===!0)return!0;if(c>=s){e.incrementCounts(t-c,t-c);break}if(e.isInWindow(0,0)){if(r(c)===!0)return!0}else e.incrementCounts(1,1);c++}return!1}function Ptt(e,t,n){if(!e.isWindowedHighlight)return[[0,n===`unified`?t.deletions+t.additions:Math.max(t.deletions,t.additions)]];let r=n!==`split`,i=n!==`unified`,a=n===`unified`?`unified`:`split`,o=[];function s(t,n){if(t+n<=e.viewportStart||t>=e.viewportEnd)return;let r=Math.max(0,e.viewportStart-t),i=Math.min(n,e.viewportEnd-t);return i>r?[r,i]:void 0}function c(e,n){return a===`split`?e:n===`additions`?[e[0]+t.deletions,e[1]+t.deletions]:e}function l(e,t){if(e==null)return;let[n,r]=c(e,t);r>n&&o.push([n,r])}if(r&&(l(s(e.unifiedCount,t.deletions),`deletions`),l(s(e.unifiedCount+t.deletions,t.additions),`additions`)),i&&(l(s(e.splitCount,t.deletions),`deletions`),l(s(e.splitCount,t.additions),`additions`)),o.length===0)return o;o.sort((e,t)=>e[0]-t[0]);let u=[o[0]];for(let[e,t]of o.slice(1)){let n=u[u.length-1];e<=n[1]?n[1]=Math.max(n[1],t):u.push([e,t])}return u}function Ftt({hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,diffStyle:i,index:a,unifiedLineIndex:o,splitLineIndex:s,additionLineIndex:c,deletionLineIndex:l,additionLineNumber:u,deletionLineNumber:d,content:f,isLastContent:p,unifiedCount:m,splitCount:h}){let g=a<f.deletions?o+a:void 0,_=i===`unified`?a>=f.deletions?o+a:void 0:a<f.additions?o+f.deletions+a:void 0,v=i===`unified`?s+(a<f.deletions?a:a-f.deletions):s+a,y=a<f.deletions?l+a:void 0,b=a<f.deletions?d+a:void 0,x=i===`unified`?a>=f.deletions?c+(a-f.deletions):void 0:a<f.additions?c+a:void 0,S=i===`unified`?a>=f.deletions?u+(a-f.deletions):void 0:a<f.additions?u+a:void 0,C=i===`unified`?p&&a===f.deletions-1&&t.noEOFCRDeletions:p&&a===h-1&&t.noEOFCRDeletions,w=i===`unified`?p&&a===m-1&&t.noEOFCRAdditions:p&&a===h-1&&t.noEOFCRAdditions,T=y!=null&&b!=null&&g!=null?{lineNumber:b,lineIndex:y,noEOFCR:C,unifiedLineIndex:g,splitLineIndex:v}:void 0,E=x!=null&&S!=null&&_!=null?{unifiedLineIndex:_,splitLineIndex:v,lineIndex:x,lineNumber:S,noEOFCR:w}:void 0;if(T==null&&E!=null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:void 0,additionLine:E};if(T!=null&&E==null)return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:T,additionLine:void 0};if(T==null||E==null)throw Error(`iterateOverDiff: missing change line data`);return{type:`change`,hunkIndex:e,hunk:t,collapsedAfter:n,collapsedBefore:r,deletionLine:T,additionLine:E}}var Itt={forcePlainText:!1};function h9(e,t,n,{forcePlainText:r,startingLine:i,totalLines:a,expandedHunks:o,collapsedContextThreshold:s=1}=Itt){r?(i??=0,a??=1/0):(i=0,a=1/0);let c=i>0||a<1/0,l=typeof n.theme==`string`?t.getTheme(n.theme).type:void 0,u=W7({theme:n.theme,highlighter:t}),d=r&&!c&&(e.unifiedLineCount>1e3||e.splitLineCount>1e3)?`none`:n.lineDiffType,f={deletionLines:[],additionLines:[]},{maxLineDiffLength:p}=n,m=!r&&!e.isPartial,h=r?o:void 0,g=new Map;function _(e){let t=m?0:e,n=g.get(t)??Rtt();return g.set(t,n),n}function v(e,t,n,r){if(c){let e=n.at(-1);(e==null||e.targetIndex+e.count!==t)&&(e={targetIndex:t,originalOffset:r.length,count:0},n.push(e)),e.count++}r.push(e)}p9({diff:e,diffStyle:`both`,startingLine:i,totalLines:a,expandedHunks:!c||h,collapsedContextThreshold:s,callback:({hunkIndex:t,additionLine:n,deletionLine:r,type:i})=>{let a=_(t),o=n==null?r.splitLineIndex:n.splitLineIndex;i===`change`&&n!=null&&r!=null&&Ltt({additionLine:e.additionLines[n.lineIndex],deletionLine:e.deletionLines[r.lineIndex],deletionLineIndex:a.deletionContent.length,additionLineIndex:a.additionContent.length,deletionDecorations:a.deletionDecorations,additionDecorations:a.additionDecorations,lineDiffType:d,maxLineDiffLength:p}),r!=null&&(v(e.deletionLines[r.lineIndex],r.lineIndex,a.deletionSegments,a.deletionContent),a.deletionInfo.push({type:i===`change`?`change-deletion`:i,lineNumber:r.lineNumber,altLineNumber:i===`change`?void 0:n.lineNumber??void 0,lineIndex:`${r.unifiedLineIndex},${o}`})),n!=null&&(v(e.additionLines[n.lineIndex],n.lineIndex,a.additionSegments,a.additionContent),a.additionInfo.push({type:i===`change`?`change-addition`:i,lineNumber:n.lineNumber,altLineNumber:i===`change`?void 0:r.lineNumber??void 0,lineIndex:`${n.unifiedLineIndex},${o}`}))}});for(let i of g.values()){if(i.deletionContent.length===0&&i.additionContent.length===0)continue;let a={name:e.prevName??e.name,contents:i.deletionContent.value},o={name:e.name,contents:i.additionContent.value},{deletionLines:s,additionLines:c}=ztt({deletionFile:a,deletionInfo:i.deletionInfo,deletionDecorations:i.deletionDecorations,additionFile:o,additionInfo:i.additionInfo,additionDecorations:i.additionDecorations,highlighter:t,options:n,languageOverride:r?`text`:e.lang});if(m){f.deletionLines=s,f.additionLines=c;continue}if(i.deletionSegments.length>0)for(let e of i.deletionSegments)for(let t=0;t<e.count;t++)f.deletionLines[e.targetIndex+t]=s[e.originalOffset+t];else f.deletionLines.push(...s);if(i.additionSegments.length>0)for(let e of i.additionSegments)for(let t=0;t<e.count;t++)f.additionLines[e.targetIndex+t]=c[e.originalOffset+t];else f.additionLines.push(...c)}return{code:f,themeStyles:u,baseThemeType:l}}function Ltt({deletionLine:e,additionLine:t,deletionLineIndex:n,additionLineIndex:r,deletionDecorations:i,additionDecorations:a,lineDiffType:o,maxLineDiffLength:s}){if(e==null||t==null||o===`none`||(e=I2(e),t=I2(t),e.length>s||t.length>s))return;let c=o===`char`?n3e(e,t):o3e(e,t),l=[],u=[],d=o===`word-alt`,f=c.at(-1);for(let e of c){let t=e===f;!e.added&&!e.removed?(o9({item:e,arr:l,enableJoin:d,isNeutral:!0,isLastItem:t}),o9({item:e,arr:u,enableJoin:d,isNeutral:!0,isLastItem:t})):e.removed?o9({item:e,arr:l,enableJoin:d,isLastItem:t}):o9({item:e,arr:u,enableJoin:d,isLastItem:t})}let p=0;for(let e of l)e[0]===1&&i.push(a9({line:n,spanStart:p,spanLength:e[1].length})),p+=e[1].length;p=0;for(let e of u)e[0]===1&&a.push(a9({line:r,spanStart:p,spanLength:e[1].length})),p+=e[1].length}function Rtt(){return{deletionContent:{push(e){this.value+=e,this.length++},value:``,length:0},additionContent:{push(e){this.value+=e,this.length++},value:``,length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function ztt({deletionFile:e,additionFile:t,deletionInfo:n,additionInfo:r,highlighter:i,deletionDecorations:a,additionDecorations:o,languageOverride:s,options:{theme:c=w2,...l}}){let u=s??O7(e.name),d=s??O7(t.name),{state:f,transformers:p}=F7(l.useTokenTransformer),m=typeof c==`string`?{...l,lang:`text`,theme:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:L7(`token`),tokenizeTimeLimit:0}:{...l,lang:`text`,themes:c,transformers:p,decorations:void 0,defaultColor:!1,cssVariablePrefix:L7(`token`),tokenizeTimeLimit:0};return{deletionLines:e.contents===``?[]:(m.lang=u,f.lineInfo=n,m.decorations=a,K7(i.codeToHast(I2(e.contents),m))),additionLines:t.contents===``?[]:(m.lang=d,m.decorations=o,f.lineInfo=r,K7(i.codeToHast(I2(t.contents),m)))}}function g9(e){let t=e.lang??O7(e.name),n=e.lang??(e.prevName==null?`text`:O7(e.prevName));return t===`text`&&n===`text`}function _9(e){let t=[];for(let n of e){let e=b3.get(n);if(e==null)throw Error(`getResolvedLanguages: ${n} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(e)}return t}function v9(e){for(let t of Array.isArray(e)?e:[e])if(!b3.has(t))return!1;return!0}async function y9(e){let t=[],n=[];for(let r of e){if(r===`text`||r===`ansi`)continue;let e=c7(r)??s7(r);`then`in e?n.push(e):t.push(e)}return n.length>0&&await Promise.all(n).then(e=>{for(let n of e){if(n==null)throw Error(`resolvedLanguages: unable to resolve language`);t.push(n)}}),t}function b9(e){return p7.getResolvedThemes(e)}async function x9(e){for(let t of e)y7(t);let t=await p7.resolveThemes(e);for(let n=0;n<e.length;n++)b7(e[n],t[n]);return t}var S9={light:`pierre-light`,dark:`pierre-dark`};function Btt(e){return e===`dark`?S9.dark:S9.light}var C9=2166136261,w9=16777619,Vtt=2654435769,Htt=2246822507;function T9(e,t=C9,n=w9){let r=t>>>0;for(let t=0;t<e.length;t+=1)r^=e.charCodeAt(t),r=Math.imul(r,n)>>>0;return r>>>0}function Utt(e,t=`diff-panel`){let n=e.trim(),r=T9(n,C9,w9).toString(36),i=T9(n,Vtt,Htt).toString(36);return`${t}:${n.length}:${r}:${i}`}var Wtt=`-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif`,Gtt=`ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace`;function Ktt(e){let t=e.trim();return t.length===0?``:/^(['"]).*\1$/u.test(t)||/^[a-zA-Z][a-zA-Z0-9-]*$/u.test(t)?t:`"${t.replaceAll(`"`,``)}"`}function qtt(e){let t=e.split(`,`).map(Ktt).filter(e=>e.length>0);return t.length>0?t.join(`, `):null}var E9={fontSans:`--font-sans`,fontMono:`--font-mono`,fontComposer:`--font-composer`,fontTerminal:`--font-terminal`,promptFontSize:`--forge-prompt-font-size`,terminalFontSize:`--forge-terminal-font-size`,glassOpacity:`--glass-opacity`};function Jtt(e,t){let n=[[E9.fontSans,t.fontFamilySans,Wtt],[E9.fontMono,t.fontFamilyCode,Gtt],[E9.fontComposer,t.fontFamilyComposer,`var(--font-sans)`],[E9.fontTerminal,t.fontFamilyTerminal,`var(--font-mono)`]];for(let[t,r,i]of n){let n=qtt(r);if(n===null){e.style.removeProperty(t);continue}e.style.setProperty(t,`${n}, ${i}`)}e.style.setProperty(E9.promptFontSize,`${String(t.promptFontSize)}px`),e.style.setProperty(E9.terminalFontSize,`${String(t.terminalFontSize)}px`),e.style.setProperty(E9.glassOpacity,`${String(t.glassOpacity)}%`),t.fontSmoothing?e.style.setProperty(`-webkit-font-smoothing`,`antialiased`):e.style.removeProperty(`-webkit-font-smoothing`)}var D9=`themeId`,O9=`forge:theme-boot:v1`;function Ytt(e,t){try{window.localStorage.setItem(O9,JSON.stringify({appearance:t,background:e}))}catch{}}function Xtt(){try{window.localStorage.removeItem(O9)}catch{}}function k9(){return typeof document>`u`?null:document.documentElement}function A9(){let e=k9();if(e!==null){for(let t of bn)e.style.removeProperty(on[t]);delete e.dataset[D9],Xtt()}}function Ztt(e,t){let n=k9();if(n===null)return;let r=t===`dark`?e.dark:e.light;for(let e of bn){let t=r[e];if(t===void 0){n.style.removeProperty(on[e]);continue}n.style.setProperty(on[e],t)}n.dataset[D9]=e.id,r.background!==void 0&&Ytt(r.background,t)}function Qtt(e,t){if(e===`forge`){A9();return}let n=kte(e);if(n===void 0){A9();return}Ztt(n,t)}var $tt=`forge:theme`,j9=`theme-color`,ent=`meta[name="${j9}"][data-dynamic-theme-color="true"]`,M9=`(prefers-color-scheme: dark)`,tnt={dark:`#0a0a0a`,light:`#ffffff`};function nnt(){return typeof window<`u`&&typeof localStorage<`u`}function N9(e){return e===`system`||e===`light`||e===`dark`}function P9(e,t){return typeof e!=`number`||!Number.isFinite(e)?t:Math.min(20,Math.max(11,Math.round(e)))}function rnt(){if(!nnt())return{theme:`system`,uiFontSize:16,codeFontSize:13};try{let e=window.localStorage.getItem(GY);if(e){let t=JY(JSON.parse(e));return{theme:N9(t.theme)?t.theme:`system`,uiFontSize:P9(t.uiFontSize,16),codeFontSize:P9(t.codeFontSize,13)}}let t=window.localStorage.getItem($tt);return{theme:N9(t)?t:`system`,uiFontSize:16,codeFontSize:13}}catch{return{theme:`system`,uiFontSize:16,codeFontSize:13}}}function int(){return typeof window>`u`||typeof window.matchMedia!=`function`||window.matchMedia(M9).matches?`dark`:`light`}function F9(e){return e===`system`?int():e}function ant(){let e=document.querySelector(ent);return e||(e=document.createElement(`meta`),e.name=j9,e.setAttribute(`data-dynamic-theme-color`,`true`),document.head.append(e),e)}function I9(e){let t=e?.trim().toLowerCase();return!t||t===`transparent`||t===`rgba(0, 0, 0, 0)`||t===`rgba(0 0 0 / 0)`?null:e?.trim()??null}function ont(){return document.querySelector(`main[data-slot='sidebar-inset']`)??document.querySelector(`[data-slot='sidebar-inner']`)??document.body}function snt(){return document.documentElement.classList.contains(`dark`)?`dark`:`light`}function L9(e=snt()){if(typeof document>`u`||typeof getComputedStyle>`u`)return;document.documentElement.style.backgroundColor=``,document.body.style.backgroundColor=``;let t=I9(getComputedStyle(ont()).backgroundColor),n=I9(getComputedStyle(document.body).backgroundColor),r=t??n??tnt[e];document.documentElement.style.backgroundColor=r,document.body.style.backgroundColor=r,ant().setAttribute(`content`,r)}function cnt(e){if(typeof window>`u`)return;let t=window.desktopBridge;t&&t.setTheme(e).catch(()=>{})}function R9(e,t=!1){let n=F9(e);return typeof document>`u`||typeof window>`u`?n:(t&&document.documentElement.classList.add(`no-transitions`),document.documentElement.classList.toggle(`dark`,n===`dark`),document.documentElement.dataset.theme=e,document.documentElement.style.colorScheme=n,L9(n),cnt(e),t&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove(`no-transitions`)})),n)}function z9(e){typeof document>`u`||document.documentElement.style.setProperty(`--forge-ui-font-size`,`${P9(e,16)}px`)}function B9(e){typeof document>`u`||document.documentElement.style.setProperty(`--forge-code-font-size`,`${P9(e,13)}px`)}function V9(e){z9(e.uiFontSize),B9(e.codeFontSize)}if(typeof document<`u`){let e=rnt();R9(e.theme),V9(e)}function lnt(){let e=(0,ul.c)(34),t=C0(pnt),n=C0(fnt),r=C0(dnt),i=C0(unt),{updateSettings:a}=w0(),o;e[0]===t?o=e[1]:(o=()=>F9(t),e[0]=t,e[1]=o);let[s,c]=(0,F.useState)(o),l;e[2]===a?l=e[3]:(l=e=>{a({theme:e}),c(R9(e,!0))},e[2]=a,e[3]=l);let u=l,d;e[4]===a?d=e[5]:(d=e=>{a({themeId:e})},e[4]=a,e[5]=d);let f=d,p;e[6]===a?p=e[7]:(p=e=>{let t=P9(e,16);a({uiFontSize:t}),z9(t)},e[6]=a,e[7]=p);let m=p,h;e[8]===a?h=e[9]:(h=e=>{let t=P9(e,13);a({codeFontSize:t}),B9(t)},e[8]=a,e[9]=h);let g=h,_,v;e[10]===t?(_=e[11],v=e[12]):(_=()=>{c(R9(t))},v=[t],e[10]=t,e[11]=_,e[12]=v),(0,F.useEffect)(_,v);let y,b;e[13]!==i||e[14]!==r?(y=()=>{V9({uiFontSize:r,codeFontSize:i})},b=[r,i],e[13]=i,e[14]=r,e[15]=y,e[16]=b):(y=e[15],b=e[16]),(0,F.useEffect)(y,b);let x,S;e[17]!==s||e[18]!==n?(S=()=>{Qtt(n,s===`dark`?`dark`:`light`)},x=[n,s],e[17]=s,e[18]=n,e[19]=x,e[20]=S):(x=e[19],S=e[20]),(0,F.useEffect)(S,x);let C,w;e[21]===t?(C=e[22],w=e[23]):(C=()=>{if(t!==`system`||typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(M9),n=()=>{c(R9(`system`,!0))};return e.addEventListener(`change`,n),()=>{e.removeEventListener(`change`,n)}},w=[t],e[21]=t,e[22]=C,e[23]=w),(0,F.useEffect)(C,w);let T;return e[24]!==i||e[25]!==s||e[26]!==g||e[27]!==u||e[28]!==f||e[29]!==m||e[30]!==t||e[31]!==n||e[32]!==r?(T={theme:t,setTheme:u,themeId:n,setThemeId:f,resolvedTheme:s,uiFontSize:r,codeFontSize:i,setUiFontSize:m,setCodeFontSize:g},e[24]=i,e[25]=s,e[26]=g,e[27]=u,e[28]=f,e[29]=m,e[30]=t,e[31]=n,e[32]=r,e[33]=T):T=e[33],T}function unt(e){return e.codeFontSize}function dnt(e){return e.uiFontSize}function fnt(e){return e.themeId}function pnt(e){return e.theme}function mnt(){let e=(0,ul.c)(10),t=C0(Snt),n=C0(xnt),r=C0(bnt),i=C0(ynt),a=C0(vnt),o=C0(_nt),s=C0(gnt),c=C0(hnt),l,u;e[0]!==n||e[1]!==r||e[2]!==t||e[3]!==i||e[4]!==s||e[5]!==c||e[6]!==a||e[7]!==o?(l=()=>{typeof document>`u`||Jtt(document.documentElement,{fontFamilyCode:n,fontFamilyComposer:r,fontFamilySans:t,fontFamilyTerminal:i,fontSmoothing:s,glassOpacity:c,promptFontSize:a,terminalFontSize:o})},u=[n,r,t,i,s,c,a,o],e[0]=n,e[1]=r,e[2]=t,e[3]=i,e[4]=s,e[5]=c,e[6]=a,e[7]=o,e[8]=l,e[9]=u):(l=e[8],u=e[9]),(0,F.useEffect)(l,u)}function hnt(e){return e.glassOpacity}function gnt(e){return e.fontSmoothing}function _nt(e){return e.terminalFontSize}function vnt(e){return e.promptFontSize}function ynt(e){return e.fontFamilyTerminal}function bnt(e){return e.fontFamilyComposer}function xnt(e){return e.fontFamilyCode}function Snt(e){return e.fontFamilySans}function Cnt(e){let t=(0,F.useRef)(e);return(0,F.useInsertionEffect)(()=>void(t.current=e)),(0,F.useCallback)((...e)=>t.current(...e),[])}var wnt=(0,F.createContext)(void 0);function Tnt(){return(0,F.useContext)(wnt)}var Ent={position:`absolute`,top:0,bottom:0,textAlign:`center`,whiteSpace:`normal`,touchAction:`none`},Dnt={display:`contents`};function Ont(){return null}var H9=t(n(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):r((n||=self).lru_map=n.lru_map||{})})(e,function(e){let t=Symbol(`newer`),n=Symbol(`older`);class r{constructor(e,t){typeof e!=`number`&&(t=e,e=0),this.size=0,this.limit=e,this.oldest=this.newest=void 0,this._keymap=new Map,t&&(this.assign(t),e<1&&(this.limit=this.size))}_markEntryAsUsed(e){e!==this.newest&&(e[t]&&(e===this.oldest&&(this.oldest=e[t]),e[t][n]=e[n]),e[n]&&(e[n][t]=e[t]),e[t]=void 0,e[n]=this.newest,this.newest&&(this.newest[t]=e),this.newest=e)}assign(e){let r,a=this.limit||Number.MAX_VALUE;this._keymap.clear();let o=e[Symbol.iterator]();for(let e=o.next();!e.done;e=o.next()){let o=new i(e.value[0],e.value[1]);if(this._keymap.set(o.key,o),r?(r[t]=o,o[n]=r):this.oldest=o,r=o,a--==0)throw Error(`overflow`)}this.newest=r,this.size=this._keymap.size}get(e){var t=this._keymap.get(e);return t?(this._markEntryAsUsed(t),t.value):void 0}set(e,r){var a=this._keymap.get(e);return a?(a.value=r,this._markEntryAsUsed(a),this):(this._keymap.set(e,a=new i(e,r)),this.newest?(this.newest[t]=a,a[n]=this.newest):this.oldest=a,this.newest=a,++this.size,this.size>this.limit&&this.shift(),this)}shift(){var e=this.oldest;if(e)return this.oldest[t]?(this.oldest=this.oldest[t],this.oldest[n]=void 0):(this.oldest=void 0,this.newest=void 0),e[t]=e[n]=void 0,this._keymap.delete(e.key),--this.size,[e.key,e.value]}find(e){let t=this._keymap.get(e);return t?t.value:void 0}has(e){return this._keymap.has(e)}delete(e){var r=this._keymap.get(e);return r?(this._keymap.delete(r.key),r[t]&&r[n]?(r[n][t]=r[t],r[t][n]=r[n]):r[t]?(r[t][n]=void 0,this.oldest=r[t]):r[n]?(r[n][t]=void 0,this.newest=r[n]):this.oldest=this.newest=void 0,this.size--,r.value):void 0}clear(){this.oldest=this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new o(this.oldest)}values(){return new s(this.oldest)}entries(){return this}[Symbol.iterator](){return new a(this.oldest)}forEach(e,n){typeof n!=`object`&&(n=this);let r=this.oldest;for(;r;)e.call(n,r.value,r.key,this),r=r[t]}toJSON(){for(var e=Array(this.size),n=0,r=this.oldest;r;)e[n++]={key:r.key,value:r.value},r=r[t];return e}toString(){for(var e=``,n=this.oldest;n;)e+=String(n.key)+`:`+n.value,n=n[t],n&&(e+=` < `);return e}}e.LRUMap=r;function i(e,r){this.key=e,this.value=r,this[t]=void 0,this[n]=void 0}function a(e){this.entry=e}a.prototype[Symbol.iterator]=function(){return this},a.prototype.next=function(){let e=this.entry;return e?(this.entry=e[t],{done:!1,value:[e.key,e.value]}):{done:!0,value:void 0}};function o(e){this.entry=e}o.prototype[Symbol.iterator]=function(){return this},o.prototype.next=function(){let e=this.entry;return e?(this.entry=e[t],{done:!1,value:e.key}):{done:!0,value:void 0}};function s(e){this.entry=e}s.prototype[Symbol.iterator]=function(){return this},s.prototype.next=function(){let e=this.entry;return e?(this.entry=e[t],{done:!1,value:e.value}):{done:!0,value:void 0}}})}))(),1),U9=Symbol(`IGNORE_RESPONSE`),W9=class extends Error{constructor(){super(`WorkerPoolManager: operation canceled because the pool terminated`)}},G9=class extends Error{constructor(){super(`WorkerPoolManager: operation canceled before the task completed`)}},knt=class{options;highlighter;preferredHighlighter;renderOptions;renderOptionsRequestVersion=0;renderOptionsVersion=0;initialized=!1;workers=[];queuedTasks=[];queuedTaskByInstance=new Map;taskByHighlightKey=new Map;activeTaskById=new Map;activeRequestByInstance=new Map;nextRequestId=0;themeSubscribers=new Set;workersFailed=!1;statSubscribers=new Set;fileCache;diffCache;_queuedBroadcast;lifecycleGeneration=0;constructor(e,{langs:t,theme:n=w2,useTokenTransformer:r=!1,lineDiffType:i=`word-alt`,maxLineDiffLength:a=1e3,tokenizeMaxLineLength:o=1e3,preferredHighlighter:s=`shiki-js`}){this.options=e,this.preferredHighlighter=s,this.renderOptions={theme:n,useTokenTransformer:r,lineDiffType:i,maxLineDiffLength:a,tokenizeMaxLineLength:o},this.fileCache=new H9.default.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new H9.default.LRUMap(e.totalASTLRUCacheSize??100),this.queueInitialization(t)}isWorkingPool(){return!this.workersFailed}getFileResultCache(e){return e.cacheKey==null?void 0:this.fileCache.get(e.cacheKey)}getDiffResultCache(e){return e.cacheKey==null?void 0:this.diffCache.get(e.cacheKey)}inspectCaches(){let{fileCache:e,diffCache:t}=this;return{fileCache:e,diffCache:t}}evictFileFromCache(e){try{return this.fileCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}evictDiffFromCache(e){try{return this.diffCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}async setRenderOptions({theme:e=this.renderOptions.theme??w2,useTokenTransformer:t=this.renderOptions.useTokenTransformer??!1,lineDiffType:n=this.renderOptions.lineDiffType??`word-alt`,maxLineDiffLength:r=this.renderOptions.maxLineDiffLength??1e3,tokenizeMaxLineLength:i=this.renderOptions.tokenizeMaxLineLength??1e3}){let{lifecycleGeneration:a}=this,o=++this.renderOptionsRequestVersion,s=()=>this.isCurrentLifecycle(a)&&this.renderOptionsRequestVersion===o;try{let a={theme:e,useTokenTransformer:t,lineDiffType:n,maxLineDiffLength:r,tokenizeMaxLineLength:i};if(this.isInitialized()||await this.initialize(),!s()||i9(a,this.renderOptions))return;let o=C7(e),c=[];if(N2(a.theme,this.renderOptions.theme)||(c=w7(o)?b9(o):await x9(o)),!s())return;if(this.highlighter!=null)m7(c,this.highlighter);else{let e=await S7({themes:o,langs:[`text`],preferredHighlighter:this.preferredHighlighter});if(!s())return;this.highlighter=e}let l=this.setRenderOptionsOnWorkers(a,c);this.renderOptions=a,this.renderOptionsVersion++,this.diffCache.clear(),this.fileCache.clear(),this.invalidateRenderTasks();for(let e of this.themeSubscribers)e.onThemeChange();await l}catch(e){if(e instanceof W9||!s())return;throw e}}getPreferredHighlighter(){return this.preferredHighlighter}getFileRenderOptions(){let{tokenizeMaxLineLength:e,theme:t,useTokenTransformer:n}=this.renderOptions;return{theme:t,useTokenTransformer:n,tokenizeMaxLineLength:e}}getDiffRenderOptions(){return{...this.renderOptions}}async setRenderOptionsOnWorkers(e,t){if(this.workersFailed)return;this.isInitialized()||await this.initialize();let n=[];for(let r of this.workers){if(!r.initialized)throw console.log({managedWorker:r}),Error(`setRenderOptionsOnWorkers: Somehow we have an uninitialized worker`);n.push(new Promise((n,i)=>{let a=this.generateRequestId(),o={type:`set-render-options`,id:a,request:{type:`set-render-options`,id:a,renderOptions:e,resolvedThemes:t},resolve:n,reject:i,requestStart:Date.now()};this.activeTaskById.set(a,o),r.pendingSetupRequestId=a,r.worker.postMessage(o.request)}))}await Promise.all(n)}subscribeToThemeChanges(e){return this.themeSubscribers.add(e),this.queueBroadcastStateChanges(),()=>{this.unsubscribeToThemeChanges(e),this.queueBroadcastStateChanges()}}unsubscribeToThemeChanges(e){this.themeSubscribers.delete(e),this.queueBroadcastStateChanges()}subscribeToStatChanges(e){return this.statSubscribers.add(e),e(this.getStats()),()=>{this.statSubscribers.delete(e)}}queueBroadcastStateChanges(){this._queuedBroadcast??=requestAnimationFrame(this._broadcastStateChanges)}_broadcastStateChanges=()=>{this._queuedBroadcast!=null&&(cancelAnimationFrame(this._queuedBroadcast),this._queuedBroadcast=void 0);let e=this.getStats();for(let t of this.statSubscribers)t(e)};cleanUpTasks(e){this.detachInstanceFromQueuedTasks(e);let t=this.activeRequestByInstance.get(e);if(t!=null){let n=this.activeTaskById.get(t);q9(n)?(this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0&&this.removeActiveTask(n)):this.activeTaskById.delete(t)}this.activeRequestByInstance.delete(e),this.queueBroadcastStateChanges()}isInitialized(){return this.initialized===!0}async initialize(e=[]){if(this.initialized!==!0)if(this.initialized===!1){let{lifecycleGeneration:t}=this;this.initialized=new Promise((n,r)=>{(async()=>{try{let r=C7(this.renderOptions.theme),i=[];if(i=w7(r)?b9(r):await x9(r),!this.isCurrentLifecycle(t)){n();return}let a=[];if(a=v9(e)?_9(e):await y9(e),!this.isCurrentLifecycle(t)){n();return}let[o]=await Promise.all([S7({themes:r,langs:[`text`,...e],preferredHighlighter:this.preferredHighlighter}),this.initializeWorkers(i,a)]);if(!this.isCurrentLifecycle(t)){this.terminateWorkers(),n();return}this.highlighter=o,this.initialized=!0,this.diffCache.clear(),this.fileCache.clear(),this.drainQueue(),this.queueBroadcastStateChanges(),n()}catch(e){if(e instanceof W9||!this.isCurrentLifecycle(t)){n();return}this.initialized=!1,this.workersFailed=!0;for(let t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,Y9(e));this.queueBroadcastStateChanges(),r(e)}})()}),this.queueBroadcastStateChanges()}else return this.initialized}async initializeWorkers(e,t){this.workersFailed=!1;let n=[],r=k7(),i=r>0?A7():void 0;this.workers.length>0&&this.terminateWorkers();for(let a=0;a<(this.options.poolSize??8);a++){let a=this.options.workerFactory(),o={worker:a,requestId:void 0,pendingSetupRequestId:void 0,initialized:!1,langs:new Set([`text`,...t.map(({name:e})=>e)]),customExtensionsVersion:0};a.addEventListener(`message`,e=>{this.handleWorkerMessage(o,e.data)}),a.addEventListener(`error`,e=>console.error(`Worker error:`,e,o)),this.workers.push(o),n.push(new Promise((n,a)=>{let s=this.generateRequestId(),c={type:`initialize`,id:s,request:{type:`initialize`,id:s,renderOptions:this.renderOptions,preferredHighlighter:this.preferredHighlighter,resolvedThemes:e,resolvedLanguages:t,customExtensionsVersion:i==null?void 0:r,customExtensionMap:i},resolve(){o.initialized=!0,n()},reject:a,requestStart:Date.now()};this.activeTaskById.set(s,c),this.executeTask(o,c)}))}await Promise.all(n)}drainQueue=()=>{if(this._queuedDrain=void 0,this.initialized===!0&&this.queuedTasks.length!==0){for(let e=0;e<this.queuedTasks.length;){let t=this.queuedTasks[e];if(this.hasActiveRequest(t)){e++;continue}let n=K9(t),r=this.getAvailableWorker(n);if(r==null)break;this.queuedTasks.splice(e,1),this.assignWorkerToTask(t,r),this.resolveLanguagesAndExecuteTask(r,t,n)}this.queueBroadcastStateChanges()}};highlightFileAST(e,t){let n=this.getFileResultCache(t);Z7(t)||n!=null&&T7(n.options,this.getFileRenderOptions())||this.hasMatchingFileInstanceTask(e,t)||this.submitTask(e,{type:`file`,file:t})}primeFileHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error(`WorkerPoolManager.primeFileHighlightCache: worker pool is not working`));let t=this.getOrCreateFileHighlightCacheTask(e);return t==null?Promise.resolve():this.createRenderTaskCallbacks(t)}getOrCreateFileHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeFileHighlightCache: priming highlight cache requires file.cacheKey; skipping "${e.name}".`);return}let t=this.getFileResultCache(e),n=this.getFileHighlightKey(e);if(n==null||Z7(e)||t!=null&&T7(t.options,this.getFileRenderOptions()))return;let r=this.getTaskByHighlightKey(n);if(r!=null)return r.primeCache=!0,r.type===`file`?r:void 0;{let t=this.submitCacheTask({type:`file`,file:e},n);return t.type===`file`?t:void 0}}getPlainFileAST(e,t,n,r){if(this.highlighter==null){this.queueInitialization();return}return X7(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,lines:r})}highlightDiffAST(e,t){let n=this.getDiffResultCache(t);g9(t)||n!=null&&i9(n.options,this.getDiffRenderOptions())||this.hasMatchingDiffInstanceTask(e,t)||this.submitTask(e,{type:`diff`,diff:t})}primeDiffHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error(`WorkerPoolManager.primeDiffHighlightCache: worker pool is not working`));let t=this.getOrCreateDiffHighlightCacheTask(e);return t==null?Promise.resolve():this.createRenderTaskCallbacks(t)}getOrCreateDiffHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeDiffHighlightCache: priming highlight cache requires diff.cacheKey; skipping "${e.prevName??e.name}" -> "${e.name}".`);return}let t=this.getDiffResultCache(e),n=this.getDiffHighlightKey(e);if(n==null||g9(e)||t!=null&&i9(t.options,this.getDiffRenderOptions()))return;let r=this.getTaskByHighlightKey(n);if(r!=null)return r.primeCache=!0,r.type===`diff`?r:void 0;{let t=this.submitCacheTask({type:`diff`,diff:e},n);return t.type===`diff`?t:void 0}}getPlainDiffAST(e,t,n,r,i){return this.highlighter==null?void 0:h9(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,expandedHunks:r,collapsedContextThreshold:i})}terminate(){this.lifecycleGeneration++,this.cancelActiveWorkerTasks(),this.terminateWorkers();let e=new W9;for(let t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,e);this.fileCache.clear(),this.diffCache.clear(),this.activeRequestByInstance.clear(),this.queuedTasks.length=0,this.queuedTaskByInstance.clear(),this.taskByHighlightKey.clear(),this.activeTaskById.clear(),this.highlighter=void 0,this.initialized=!1,this.workersFailed=!1,this.queueBroadcastStateChanges()}isCurrentLifecycle(e){return this.lifecycleGeneration===e}queueInitialization(e){this.initialize(e).catch(e=>{console.error(e)})}cancelActiveWorkerTasks(){let e=new W9;for(let t of this.activeTaskById.values())`reject`in t?t.reject(e):q9(t)&&this.rejectRenderTaskCallbacks(t,e)}terminateWorkers(){for(let e of this.workers)e.worker.terminate();this.workers.length=0}getStats(){return{managerState:this.initialized===!1?`waiting`:this.initialized===!0?`initialized`:`initializing`,totalWorkers:this.workers.length,workersFailed:this.workersFailed,busyWorkers:this.workers.filter(e=>e.requestId!=null||e.pendingSetupRequestId!=null).length,queuedTasks:this.queuedTasks.length,activeTasks:this.activeTaskById.size,themeSubscribers:this.themeSubscribers.size,fileCacheSize:this.fileCache.size,diffCacheSize:this.diffCache.size}}submitTask(e,t){this.initialized===!1&&this.queueInitialization();let n=this.getHighlightKeyForRequest(t),r=n==null?void 0:this.getTaskByHighlightKey(n);if(r!=null){this.detachInstanceFromQueuedTasks(e,r),this.addInstanceToTask(r,e),this.queueBroadcastStateChanges();return}this.detachInstanceFromQueuedTasks(e);let i=this.generateRequestId(),a=Date.now(),{renderOptionsVersion:o}=this,s=(()=>{switch(t.type){case`file`:return{type:`file`,id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:o,requestStart:a};case`diff`:return{type:`diff`,id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:o,requestStart:a}}})();this.enqueueRenderTask(s,e)}submitCacheTask(e,t){this.initialized===!1&&this.queueInitialization();let n=this.generateRequestId(),r=Date.now(),{renderOptionsVersion:i}=this,a=(()=>{switch(e.type){case`file`:return{type:`file`,id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r};case`diff`:return{type:`diff`,id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r}}})();return this.enqueueRenderTask(a),a}enqueueRenderTask(e,t){this.queuedTasks.push(e),t!=null&&this.queuedTaskByInstance.set(t,e),e.highlightKey!=null&&this.taskByHighlightKey.set(e.highlightKey,e),this.queueDrain()}async resolveLanguagesAndExecuteTask(e,t,n){try{let r=n.filter(t=>!e.langs.has(t));if(r.length>0&&(v9(r)?t.request.resolvedLanguages=_9(r):t.request.resolvedLanguages=await y9(r)),!this.activeTaskById.has(t.id)){e.requestId===t.id&&(this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain());return}this.executeTask(e,t)}catch(n){this.rejectRenderTaskCallbacks(t,Y9(n)),this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}}handleWorkerMessage(e,t){let n=this.activeTaskById.get(t.id);try{if(n==null)throw U9;if(t.type===`error`){let e=Error(t.error);if(t.stack&&(e.stack=t.stack),`reject`in n)n.reject(e);else if(q9(n))this.notifyHighlightError(n,e),this.rejectRenderTaskCallbacks(n,e);else throw Error(`handleWorkerMessage: unknown task type`);throw e}switch(t.requestType){case`initialize`:if(n.type!==`initialize`)throw Error(`handleWorkerMessage: task/response dont match`);this.syncCustomExtensionVersion(e,n.request),n.resolve();break;case`set-render-options`:if(n.type!==`set-render-options`)throw Error(`handleWorkerMessage: task/response dont match`);n.resolve();break;case`file`:{if(n.type!==`file`)throw Error(`handleWorkerMessage: task/response dont match`);let{result:r,options:i}=t;if(!this.isCurrentRenderTask(n)||!T7(i,this.getFileRenderOptions()))throw U9;let{request:a}=n;this.syncCustomExtensionVersion(e,a),n.cacheKeyAtDispatch!=null&&this.fileCache.set(n.cacheKeyAtDispatch,{result:r,options:i}),this.resolveRenderTaskCallbacks(n),this.notifyFileInstances(n,r,i);break}case`diff`:{if(n.type!==`diff`)throw Error(`handleWorkerMessage: task/response dont match`);let{result:r,options:i}=t;if(!this.isCurrentRenderTask(n)||!i9(i,this.getDiffRenderOptions()))throw U9;let{request:a}=n;this.syncCustomExtensionVersion(e,a),n.cacheKeyAtDispatch!=null&&this.diffCache.set(n.cacheKeyAtDispatch,{result:r,options:i}),this.resolveRenderTaskCallbacks(n),this.notifyDiffInstances(n,r,i);break}}}catch(e){e!==U9&&console.error(e,n,t)}this.cleanWorkerAndTask(e,n,t.id),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}_queuedDrain;queueDrain(){this._queuedDrain??(this._queuedDrain=Promise.resolve().then(this.drainQueue),this.queueBroadcastStateChanges())}assignWorkerToTask(e,t){t.requestId=e.id,q9(e)&&(this.clearQueuedInstanceRequests(e),this.trackInstanceRequests(e)),this.activeTaskById.set(e.id,e)}cleanWorkerAndTask(e,t,n=t?.id){e.requestId===n&&(e.requestId=void 0),e.pendingSetupRequestId===n&&(e.pendingSetupRequestId=void 0),t!=null&&(q9(t)&&(this.rejectRenderTaskCallbacks(t,new G9),this.clearInstanceRequests(t),this.clearHighlightKey(t)),this.activeTaskById.delete(t.id))}executeTask(e,t){Ant(t.request)&&this.maybeAttachCustomExtensions(e,t.request),this.activeTaskById.has(t.id)||this.assignWorkerToTask(t,e);for(let n of K9(t))e.langs.add(n);try{t.type===`file`?t.cacheKeyAtDispatch=t.request.file.cacheKey:t.type===`diff`&&(t.cacheKeyAtDispatch=t.request.diff.cacheKey),e.worker.postMessage(t.request)}catch(n){console.error(`Failed to post message to worker:`,n),q9(t)?(this.notifyHighlightError(t,n),this.rejectRenderTaskCallbacks(t,Y9(n))):`reject`in t&&t.reject(n),this.cleanWorkerAndTask(e,t),this.queuedTasks.length>0&&this.queueDrain()}this.queueBroadcastStateChanges()}maybeAttachCustomExtensions(e,t){if(t.customExtensionsVersion!=null)return;let n=k7();e.customExtensionsVersion>=n||(t.customExtensionsVersion=n,t.customExtensionMap=A7())}syncCustomExtensionVersion(e,t){t.customExtensionsVersion!=null&&(e.customExtensionsVersion=t.customExtensionsVersion)}getAvailableWorker(e){let t;for(let n of this.workers){if(n.requestId!=null||n.pendingSetupRequestId!=null||!n.initialized)continue;if(t=n,e.length===0)break;let r=!0;for(let t of e)if(!n.langs.has(t)){r=!1;break}if(r)break}return t}getFileHighlightKey(e){if(e.cacheKey!=null)return`file:${e.cacheKey}:${this.renderOptionsVersion}`}getDiffHighlightKey(e){if(e.cacheKey!=null)return`diff:${e.cacheKey}:${this.renderOptionsVersion}`}getHighlightKeyForRequest(e){switch(e.type){case`file`:return this.getFileHighlightKey(e.file);case`diff`:return this.getDiffHighlightKey(e.diff)}}hasActiveRequest(e){for(let t of J9(e))if(this.activeRequestByInstance.has(t))return!0;return!1}addInstanceToTask(e,t){e.type,e.instances.add(t),this.activeTaskById.has(e.id)?this.activeRequestByInstance.set(t,e.id):this.queuedTaskByInstance.set(t,e)}detachInstanceFromQueuedTasks(e,t){let n=this.queuedTaskByInstance.get(e);n!=null&&n!==t&&(this.queuedTaskByInstance.delete(e),this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0&&this.removeQueuedTask(n))}detachInstanceFromRenderTask(e,t){e.type,e.instances.delete(t)}removeQueuedTask(e){let t=this.queuedTasks.indexOf(e);t!==-1&&this.queuedTasks.splice(t,1),this.rejectRenderTaskCallbacks(e,new G9),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.rejectRenderTaskCallbacks(e,new G9),this.clearInstanceRequests(e),this.clearHighlightKey(e),this.activeTaskById.delete(e.id)}createRenderTaskCallbacks(e){return new Promise((t,n)=>{e.callbacks.add({resolve:t,reject:n})})}resolveRenderTaskCallbacks(e){for(let t of e.callbacks)t.resolve();e.callbacks.clear()}rejectRenderTaskCallbacks(e,t){for(let n of e.callbacks)n.reject(t);e.callbacks.clear()}invalidateRenderTasks(){for(let e=this.queuedTasks.length-1;e>=0;e--){let t=this.queuedTasks[e];t.renderOptionsVersion!==this.renderOptionsVersion&&this.removeQueuedTask(t)}for(let e of Array.from(this.activeTaskById.values()))q9(e)&&e.renderOptionsVersion!==this.renderOptionsVersion&&this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(let t of J9(e))this.queuedTaskByInstance.get(t)===e&&this.queuedTaskByInstance.delete(t)}clearHighlightKey(e){e.highlightKey!=null&&this.taskByHighlightKey.get(e.highlightKey)===e&&this.taskByHighlightKey.delete(e.highlightKey)}trackInstanceRequests(e){for(let t of J9(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(let t of J9(e))this.activeRequestByInstance.get(t)===e.id&&this.activeRequestByInstance.delete(t)}notifyFileInstances(e,t,n){for(let r of e.instances)this.activeRequestByInstance.get(r)===e.id&&r.onHighlightSuccess(e.request.file,t,n)}notifyDiffInstances(e,t,n){for(let r of e.instances)this.activeRequestByInstance.get(r)===e.id&&r.onHighlightSuccess(e.request.diff,t,n)}notifyHighlightError(e,t){for(let n of J9(e))this.activeRequestByInstance.get(n)===e.id&&n.onHighlightError(t)}hasMatchingFileInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type===`file`&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&o4(t,n.request.file))return!0;return!1}hasMatchingDiffInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type===`diff`&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&r9(n.request.diff,t))return!0;return!1}getTaskByHighlightKey(e){let t=this.taskByHighlightKey.get(e);return t!=null&&this.isCurrentRenderTask(t)?t:void 0}isCurrentRenderTask(e){return e.renderOptionsVersion===this.renderOptionsVersion}*iterateRenderTasks(){for(let e of this.queuedTasks)yield e;for(let e of this.activeTaskById.values())q9(e)&&(yield e)}generateRequestId(){return`req_${++this.nextRequestId}`}};function Ant(e){return e.type===`initialize`||e.type===`file`||e.type===`diff`}function K9(e){let t=new Set;if(e.type===`initialize`||e.type===`set-render-options`)return[];switch(e.type){case`file`:t.add(e.request.file.lang??O7(e.request.file.name));break;case`diff`:t.add(e.request.diff.lang??O7(e.request.diff.name)),t.add(e.request.diff.lang??O7(e.request.diff.prevName??`-`))}return t.delete(`text`),Array.from(t)}function q9(e){return e?.type===`file`||e?.type===`diff`}function J9(e){return e.instances}function Y9(e){return e instanceof Error?e:Error(String(e))}var X9;function jnt({poolOptions:e,highlighterOptions:t}){return X9??=new knt(e,t),X9}function Mnt(){X9!=null&&(X9.terminate(),X9=void 0)}var Z9=(0,F.createContext)(void 0),Q9=0;function Nnt({children:e,poolOptions:t,highlighterOptions:n}){let[r]=(0,F.useState)(()=>{if(!(typeof window>`u`))return jnt({poolOptions:t,highlighterOptions:n})});return(0,F.useInsertionEffect)(()=>{if(r!=null)return Q9++,()=>{Q9--}},[r]),(0,F.useEffect)(()=>()=>{Q9===0&&Mnt()},[]),(0,Fr.jsx)(Z9.Provider,{value:r,children:e})}function Pnt(){return(0,F.useContext)(Z9)}function $9(e){return Qt(`flex items-center justify-between gap-2 px-4 wco:pr-[calc(100vw-env(titlebar-area-width)-env(titlebar-area-x)+1em)]`,Ir&&e!==`sheet`?`h-[52px] border-b border-border wco:h-[env(titlebar-area-height)]`:`h-12 wco:max-h-[env(titlebar-area-height)]`)}function Fnt(e){let t=(0,ul.c)(10),n=Ir&&e.mode!==`sheet`,r=e.mode===`inline`?`w-[42vw] min-w-[360px] max-w-[560px] shrink-0 border-l border-border`:`w-full`,i;t[0]===r?i=t[1]:(i=Qt(`flex h-full min-w-0 flex-col bg-background`,r),t[0]=r,t[1]=i);let a;t[2]!==e.header||t[3]!==e.mode||t[4]!==n?(a=n?(0,Fr.jsx)(`div`,{className:$9(e.mode),children:e.header}):(0,Fr.jsx)(`div`,{className:`border-b border-border`,children:(0,Fr.jsx)(`div`,{className:$9(e.mode),children:e.header})}),t[2]=e.header,t[3]=e.mode,t[4]=n,t[5]=a):a=t[5];let o;return t[6]!==e.children||t[7]!==i||t[8]!==a?(o=(0,Fr.jsxs)(`div`,{className:i,children:[a,e.children]}),t[6]=e.children,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function Int(){let e=(0,ul.c)(4),t,n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Fr.jsx)(VY,{className:`absolute left-0 top-1/2 size-6 -translate-y-1/2 rounded-md border border-border/50`}),n=(0,Fr.jsx)(VY,{className:`absolute right-0 top-1/2 size-6 -translate-y-1/2 rounded-md border border-border/50`}),e[0]=t,e[1]=n):(t=e[0],n=e[1]);let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Fr.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[t,n,(0,Fr.jsxs)(`div`,{className:`flex gap-1 overflow-hidden px-8 py-0.5`,children:[(0,Fr.jsx)(VY,{className:`h-6 w-16 shrink-0 rounded-md`}),(0,Fr.jsx)(VY,{className:`h-6 w-24 shrink-0 rounded-md`}),(0,Fr.jsx)(VY,{className:`h-6 w-24 shrink-0 rounded-md max-sm:hidden`})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Fr.jsxs)(Fr.Fragment,{children:[r,(0,Fr.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,Fr.jsx)(VY,{className:`size-7 rounded-md`}),(0,Fr.jsx)(VY,{className:`size-7 rounded-md`})]})]}),e[3]=i):i=e[3],i}function Lnt(e){let t=(0,ul.c)(7),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Fr.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,Fr.jsx)(VY,{className:`h-4 w-32 rounded-full`}),(0,Fr.jsx)(VY,{className:`ml-auto h-4 w-20 rounded-full`})]}),t[0]=n):n=t[0];let r;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Fr.jsxs)(`div`,{className:`space-y-2`,children:[(0,Fr.jsx)(VY,{className:`h-3 w-full rounded-full`}),(0,Fr.jsx)(VY,{className:`h-3 w-full rounded-full`}),(0,Fr.jsx)(VY,{className:`h-3 w-10/12 rounded-full`}),(0,Fr.jsx)(VY,{className:`h-3 w-11/12 rounded-full`}),(0,Fr.jsx)(VY,{className:`h-3 w-9/12 rounded-full`})]}),t[1]=r):r=t[1];let i;t[2]===e.label?i=t[3]:(i=(0,Fr.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4 px-3 py-4`,children:[r,(0,Fr.jsx)(`span`,{className:`sr-only`,children:e.label})]}),t[2]=e.label,t[3]=i);let a;return t[4]!==e.label||t[5]!==i?(a=(0,Fr.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col p-2`,children:(0,Fr.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border border-border/60 bg-card/25`,role:`status`,"aria-live":`polite`,"aria-label":e.label,children:[n,i]})}),t[4]=e.label,t[5]=i,t[6]=a):a=t[6],a}export{Xet as $,mJ as $a,WYe as $i,L2e as $n,lq as $o,j1e as $r,rre as $s,A2 as $t,i9 as A,WJ as Aa,br as Ac,JXe as Ai,_2 as An,Gq as Ao,n0 as Ar,Mi as As,K4 as At,dtt as B,gqe as Ba,DZ as Bi,p4e as Bn,PGe as Bo,d0 as Br,Si as Bs,c4 as Bt,ktt as C,mJe as Ca,Kne as Cc,vZe as Ci,B4e as Cn,Wq as Co,w0 as Cr,Ro as Cs,A6e as Ct,Att as D,Pqe as Da,Wne as Dc,mQ as Di,j4e as Dn,Vq as Do,m0 as Dr,Lo as Ds,J4 as Dt,u9 as E,JJ as Ea,yr as Ec,ZXe as Ei,D4e as En,zq as Eo,C0e as Er,Uo as Es,q3e as Et,vtt as F,HJ as Fa,xXe as Fi,v4e as Fn,HGe as Fo,v0e as Fr,Oi as Fs,m4 as Ft,att as G,PKe as Ga,fZ as Gi,V2e as Gn,jGe as Go,R1e as Gr,ui as Gs,R2 as Gt,ltt as H,jJ as Ha,CZ as Hi,$0 as Hn,CGe as Ho,K1e as Hr,gre as Hs,s4 as Ht,htt as I,PJ as Ia,jZ as Ii,h4e as In,BGe as Io,p0e as Ir,Di as Is,d4 as It,ttt as J,zKe as Ja,yZ as Ji,R2e as Jn,MGe as Jo,B1e as Jr,ai as Js,e3e as Jt,e9 as K,IKe as Ka,UYe as Ki,B2e as Kn,tGe as Ko,M1e as Kr,li as Ks,L2 as Kt,mtt as L,Aqe as La,TXe as Li,g4e as Ln,RGe as Lo,h0e as Lr,Ti as Ls,h3e as Lt,ytt as M,zJ as Ma,dQ as Mi,y4e as Mn,tKe as Mo,l0e as Mr,ji as Ms,I4 as Mt,btt as N,Mqe as Na,pQ as Ni,f2 as Nn,Pq as No,m0e as Nr,Ai as Ns,L4 as Nt,wtt as O,KJ as Oa,Fne as Oc,GXe as Oi,M4e as On,Hq as Oo,i0 as Or,Cre as Os,K3e as Ot,Stt as P,UJ as Pa,PZ as Pi,m4e as Pn,qGe as Po,d0e as Pr,Ei as Ps,F4 as Pt,Z7 as Q,xJ as Qa,vZ as Qi,G0e as Qn,kGe as Qo,L1e as Qr,ore as Qs,M2 as Qt,ptt as R,cqe as Ra,NZ as Ri,_4e as Rn,WGe as Ro,g0e as Rr,wi as Rs,m3e as Rt,s9 as S,zY as Sa,Tr as Sc,gZe as Si,b2 as Sn,nKe as So,C0 as Sr,Ko as Ss,k6e as St,l9 as T,Nqe as Ta,Rne as Tc,bQ as Ti,O4e as Tn,Lq as To,E0e as Tr,Ho as Ts,Y4 as Tt,stt as U,kJ as Ua,SZ as Ui,t2 as Un,wGe as Uo,q1e as Ur,mre as Us,o4 as Ut,utt as V,QKe as Va,wZ as Vi,e2 as Vn,Tq as Vo,_0e as Vr,gi as Vs,l4 as Vt,ott as W,WKe as Wa,HYe as Wi,r2 as Wn,OGe as Wo,I1e as Wr,hre as Ws,u3e as Wt,Qet as X,EJ as Xa,_Z as Xi,r2e as Xn,bGe as Xo,N1 as Xr,Kr as Xs,$4e as Xt,ett as Y,DJ as Ya,BYe as Yi,R0e as Yn,vq as Yo,P1e as Yr,tre as Ys,F2 as Yt,Zet as Z,CJ as Za,VYe as Zi,i2e as Zn,kq as Zo,M1 as Zr,Gr as Zs,N2 as Zt,Btt as _,bJe as _a,Or as _c,gQe as _i,L4e as _n,$q as _o,n2e as _r,Nce as _s,C7 as _t,Nnt as a,CX as aa,Yr as ac,I$e as ai,C2 as an,cJ as ao,I2e as ar,AK as as,X7 as at,p9 as b,SJe as ba,qne as bc,WZe as bi,x2 as bn,Jq as bo,I0e as br,pl as bs,K6e as bt,Dnt as c,gX as ca,Rr as cc,w$e as ci,X4e as cn,dKe as co,j0 as cr,EK as cs,Eet as ct,Cnt as d,HY as da,Zne as dc,h$ as di,w2 as dn,CKe as do,I0 as dr,TK as ds,yet as dt,zYe as ea,nre as ec,l1e as ei,k2 as en,yJ as eo,K0e as er,oq as es,Yet as et,L9 as f,wJe as fa,Pr as fc,VQe as fi,K4e as fn,uKe as fo,J0e as fr,bWe as fs,_et as ft,T9 as g,CJe as ga,kr as gc,s$ as gi,Q4e as gn,Zq as go,R0 as gr,Mce as gs,het as gt,Utt as h,VY as ha,Ar as hc,WQe as hi,y2 as hn,Qq as ho,O0 as hr,Rce as hs,w7 as ht,Z9 as i,XJe as ia,Ur as ic,z$e as ii,P4e as in,oJ as io,W0e as ir,RK as is,Jet as it,r9 as j,BJ as ja,qXe as ji,A4e as jn,Uq as jo,o0e as jr,ki as js,z4 as jt,Ttt as k,GJ as ka,Bne as kc,KXe as ki,k4e as kn,Rq as ko,a0 as kr,Ni as ks,q4 as kt,Ont as l,dX as la,Lr as lc,_$ as li,Z4e as ln,rJ as lo,q0e as lr,wK as ls,O7 as lt,lnt as m,UY as ma,jr as mc,HQe as mi,N4e as mn,wKe as mo,F2e as mr,Ice as ms,T7 as mt,Lnt as n,bZ as na,qr as nc,j1 as ni,G4e as nn,bJ as no,P2e as nr,UWe as ns,qet as nt,Pnt as o,hX as oa,ni as oc,S$ as oi,q4e as on,_Ke as oo,O2e as or,OK as os,Y7 as ot,mnt as p,WY as pa,Nr as pc,XQe as pi,E2 as pn,TKe as po,D2e as pr,Lce as ps,get as pt,ntt as q,RKe as qa,pZ as qi,Z0 as qn,NGe as qo,z1e as qr,oi as qs,I2 as qt,Fnt as r,YJe as ra,Jr as rc,F$ as ri,W4e as rn,fJ as ro,H0e as rr,BK as rs,Ket as rt,Ent as s,vX as sa,ei as sc,T$ as si,J4e as sn,bKe as so,Y0e as sr,DK as ss,Det as st,Int as t,RYe as ta,Br as tc,V1e as ti,z4e as tn,jKe as to,V0e as tr,aq as ts,Get as tt,Tnt as u,xX as ua,Ir as uc,g$ as ui,Y4e as un,nJ as uo,B0e as ur,yWe as us,Cet as ut,g9 as v,yJe as va,Dr as vc,yQe as vi,R4e as vn,qq as vo,D0 as vr,Pce as vs,pet as vt,Ett as w,gJe as wa,Ine as wc,mZe as wi,I4e as wn,Bq as wo,p0 as wr,zo as ws,s3 as wt,c9 as x,vJe as xa,Gne as xc,FQ as xi,S2 as xn,sKe as xo,F0e as xr,ml as xs,z6e as xt,h9 as y,xJe as ya,Une as yc,uQe as yi,F4e as yn,Yq as yo,L0e as yr,Pl as ys,S7 as yt,ftt as z,aqe as za,AZ as zi,u4e as zn,Fq as zo,f0e as zr,yre as zs,p3e as zt};
|
|
2531
|
-
//# sourceMappingURL=DiffPanelShell-
|
|
2531
|
+
//# sourceMappingURL=DiffPanelShell-R1Q66jTc.js.map
|