seroval 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/cjs/development/index.cjs +339 -226
  2. package/dist/cjs/development/index.cjs.map +3 -3
  3. package/dist/cjs/production/index.cjs +17 -3
  4. package/dist/esm/development/index.mjs +339 -226
  5. package/dist/esm/development/index.mjs.map +3 -3
  6. package/dist/esm/production/index.mjs +17 -3
  7. package/dist/types/core/base-primitives.d.ts.map +1 -1
  8. package/dist/types/core/context/deserializer.d.ts.map +1 -1
  9. package/dist/types/core/context/parser/async.d.ts.map +1 -1
  10. package/dist/types/core/context/parser/sync.d.ts.map +1 -1
  11. package/dist/types/core/context/parser.d.ts.map +1 -1
  12. package/dist/types/core/context/serializer.d.ts.map +1 -1
  13. package/dist/types/core/errors.d.ts +38 -0
  14. package/dist/types/core/errors.d.ts.map +1 -0
  15. package/dist/types/core/reference.d.ts.map +1 -1
  16. package/dist/types/core/tree/serializer.d.ts.map +1 -1
  17. package/dist/types/core/utils/typed-array.d.ts.map +1 -1
  18. package/dist/types/index.d.ts +1 -0
  19. package/dist/types/index.d.ts.map +1 -1
  20. package/package.json +2 -2
  21. package/src/core/base-primitives.ts +0 -5
  22. package/src/core/context/deserializer.ts +86 -76
  23. package/src/core/context/parser/async.ts +30 -26
  24. package/src/core/context/parser/sync.ts +30 -26
  25. package/src/core/context/parser.ts +3 -10
  26. package/src/core/context/serializer.ts +113 -80
  27. package/src/core/errors.ts +99 -0
  28. package/src/core/reference.ts +6 -2
  29. package/src/core/tree/serializer.ts +4 -3
  30. package/src/core/utils/typed-array.ts +3 -1
  31. package/src/index.ts +1 -0
  32. package/dist/types/core/UnsupportedTypeError.d.ts +0 -5
  33. package/dist/types/core/UnsupportedTypeError.d.ts.map +0 -1
  34. package/src/core/UnsupportedTypeError.ts +0 -7
@@ -1,3 +1,17 @@
1
- "use strict";var Ie=Object.defineProperty;var ir=Object.getOwnPropertyDescriptor;var ar=Object.getOwnPropertyNames;var lr=Object.prototype.hasOwnProperty;var dr=(n,e)=>{for(var r in e)Ie(n,r,{get:e[r],enumerable:!0})},ur=(n,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ar(e))!lr.call(n,s)&&s!==r&&Ie(n,s,{get:()=>e[s],enumerable:!(t=ir(e,s))||t.enumerable});return n};var cr=n=>ur(Ie({},"__esModule",{value:!0}),n);var _r={};dr(_r,{Feature:()=>b,Serializer:()=>q,compileJSON:()=>Tr,createPlugin:()=>gr,createReference:()=>Te,createStream:()=>E,crossSerialize:()=>Fr,crossSerializeAsync:()=>Dr,crossSerializeStream:()=>Oe,deserialize:()=>Cr,fromCrossJSON:()=>Mr,fromJSON:()=>kr,getCrossReferenceHeader:()=>ze,resolvePlugins:()=>c,serialize:()=>wr,serializeAsync:()=>Pr,toCrossJSON:()=>Vr,toCrossJSONAsync:()=>Br,toCrossJSONStream:()=>jr,toJSON:()=>Or,toJSONAsync:()=>zr});module.exports=cr(_r);var b=(o=>(o[o.AggregateError=1]="AggregateError",o[o.ArrowFunction=2]="ArrowFunction",o[o.ErrorPrototypeStack=4]="ErrorPrototypeStack",o[o.ObjectAssign=8]="ObjectAssign",o[o.BigIntTypedArray=16]="BigIntTypedArray",o))(b||{});function f(n,e){if(!n)throw e}function fr(n){switch(n){case'"':return'\\"';case"\\":return"\\\\";case`
2
- `:return"\\n";case"\r":return"\\r";case"\b":return"\\b";case" ":return"\\t";case"\f":return"\\f";case"<":return"\\x3C";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:return}}function u(n){let e="",r=0,t;for(let s=0,o=n.length;s<o;s++)t=fr(n[s]),t&&(e+=n.slice(r,s)+t,r=s+1);return r===0?e=n:e+=n.slice(r),e}function pr(n){switch(n){case"\\\\":return"\\";case'\\"':return'"';case"\\n":return`
3
- `;case"\\r":return"\r";case"\\b":return"\b";case"\\t":return" ";case"\\f":return"\f";case"\\x3C":return"<";case"\\u2028":return"\u2028";case"\\u2029":return"\u2029";default:return n}}function S(n){return n.replace(/(\\\\|\\"|\\n|\\r|\\b|\\t|\\f|\\u2028|\\u2029|\\x3C)/g,pr)}var x="__SEROVAL_REFS__",K="$R",Z=`self.${K}`;function ze(n){return n==null?`${Z}=${Z}||[]`:`(${Z}=${Z}||{})["${u(n)}"]=[]`}var Ee=new Map,A=new Map;function Te(n,e){return Ee.set(e,n),A.set(n,e),e}function X(n){return Ee.has(n)}function mr(n){return A.has(n)}function ke(n){return f(X(n),new Error("Missing reference id")),Ee.get(n)}function Fe(n){return f(mr(n),new Error("Missing reference for id:"+n)),A.get(n)}typeof globalThis!="undefined"?Object.defineProperty(globalThis,x,{value:A,configurable:!0,writable:!1,enumerable:!1}):typeof window!="undefined"?Object.defineProperty(window,x,{value:A,configurable:!0,writable:!1,enumerable:!1}):typeof self!="undefined"?Object.defineProperty(self,x,{value:A,configurable:!0,writable:!1,enumerable:!1}):typeof global!="undefined"&&Object.defineProperty(global,x,{value:A,configurable:!0,writable:!1,enumerable:!1});function gr(n){return n}function De(n,e){for(let r=0,t=e.length;r<t;r++){let s=e[r];n.has(s)||(n.add(s),s.extends&&De(n,s.extends))}}function c(n){if(n){let e=new Set;return De(e,n),[...e]}}var{toString:Sr}=Object.prototype,p=class extends Error{constructor(r){super('Unsupported type "'+Sr.call(r)+'"');this.value=r}};var Ve={0:"Symbol.asyncIterator",1:"Symbol.hasInstance",2:"Symbol.isConcatSpreadable",3:"Symbol.iterator",4:"Symbol.match",5:"Symbol.matchAll",6:"Symbol.replace",7:"Symbol.search",8:"Symbol.species",9:"Symbol.split",10:"Symbol.toPrimitive",11:"Symbol.toStringTag",12:"Symbol.unscopables"},L={[Symbol.asyncIterator]:0,[Symbol.hasInstance]:1,[Symbol.isConcatSpreadable]:2,[Symbol.iterator]:3,[Symbol.match]:4,[Symbol.matchAll]:5,[Symbol.replace]:6,[Symbol.search]:7,[Symbol.species]:8,[Symbol.split]:9,[Symbol.toPrimitive]:10,[Symbol.toStringTag]:11,[Symbol.unscopables]:12},Be={0:Symbol.asyncIterator,1:Symbol.hasInstance,2:Symbol.isConcatSpreadable,3:Symbol.iterator,4:Symbol.match,5:Symbol.matchAll,6:Symbol.replace,7:Symbol.search,8:Symbol.species,9:Symbol.split,10:Symbol.toPrimitive,11:Symbol.toStringTag,12:Symbol.unscopables},je={2:"!0",3:"!1",1:"void 0",0:"null",4:"-0",5:"1/0",6:"-1/0",7:"0/0"},Me={2:!0,3:!1,1:void 0,0:null,4:-0,5:1/0,6:-1/0,7:NaN};var Q={0:"Error",1:"EvalError",2:"RangeError",3:"ReferenceError",4:"SyntaxError",5:"TypeError",6:"URIError"},_e={0:Error,1:EvalError,2:RangeError,3:ReferenceError,4:SyntaxError,5:TypeError,6:URIError};function h(n){return{t:2,i:void 0,s:n,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}var y=h(2),v=h(3),ee=h(1),re=h(0),Ue=h(4),We=h(5),Ke=h(6),Le=h(7);function te(n){return n instanceof EvalError?1:n instanceof RangeError?2:n instanceof ReferenceError?3:n instanceof SyntaxError?4:n instanceof TypeError?5:n instanceof URIError?6:0}function hr(n){let e=Q[te(n)];return n.name!==e?{name:n.name}:n.constructor.name!==e?{name:n.constructor.name}:{}}function z(n,e){let r=hr(n),t=Object.getOwnPropertyNames(n);for(let s=0,o=t.length,i;s<o;s++)i=t[s],i!=="name"&&i!=="message"&&(i==="stack"?e&4&&(r=r||{},r[i]=n[i]):(r=r||{},r[i]=n[i]));return r}function ne(n){return Object.isFrozen(n)?3:Object.isSealed(n)?2:Object.isExtensible(n)?0:1}function se(n){switch(n){case 1/0:return We;case-1/0:return Ke}return n!==n?Le:Object.is(n,-0)?Ue:{t:0,i:void 0,s:n,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function N(n){return{t:1,i:void 0,s:u(n),l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function oe(n){return{t:3,i:void 0,s:""+n,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function Ye(n){return{t:4,i:n,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function ie(n,e){return{t:5,i:n,s:e.toISOString(),l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,f:void 0,a:void 0,b:void 0,o:void 0}}function ae(n,e){return{t:6,i:n,s:void 0,l:void 0,c:u(e.source),m:e.flags,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function le(n,e){let r=new Uint8Array(e),t=r.length,s=new Array(t);for(let o=0;o<t;o++)s[o]=r[o];return{t:19,i:n,s,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function Ge(n,e){return f(e in L,new Error("Only well-known symbols are supported.")),{t:17,i:n,s:L[e],l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function Re(n,e){return{t:18,i:n,s:u(ke(e)),l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function T(n,e,r){return{t:25,i:n,s:r,l:void 0,c:u(e),m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function de(n,e,r){return{t:9,i:n,s:void 0,l:e.length,c:void 0,m:void 0,p:void 0,e:void 0,a:r,f:void 0,b:void 0,o:ne(e)}}function ue(n,e){return{t:21,i:n,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:e,b:void 0,o:void 0}}function ce(n,e,r){return{t:15,i:n,s:void 0,l:e.length,c:e.constructor.name,m:void 0,p:void 0,e:void 0,a:void 0,f:r,b:e.byteOffset,o:void 0}}function fe(n,e,r){return{t:16,i:n,s:void 0,l:e.length,c:e.constructor.name,m:void 0,p:void 0,e:void 0,a:void 0,f:r,b:e.byteOffset,o:void 0}}function pe(n,e,r){return{t:20,i:n,s:void 0,l:e.byteLength,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:r,b:e.byteOffset,o:void 0}}function me(n,e,r){return{t:13,i:n,s:te(e),l:void 0,c:void 0,m:u(e.message),p:r,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function ge(n,e,r){return{t:14,i:n,s:te(e),l:void 0,c:void 0,m:u(e.message),p:r,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function Se(n,e,r){return{t:7,i:n,s:void 0,l:e,c:void 0,m:void 0,p:void 0,e:void 0,a:r,f:void 0,b:void 0,o:void 0}}function k(n,e){return{t:28,i:void 0,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:[n,e],f:void 0,b:void 0,o:void 0}}function F(n,e){return{t:30,i:void 0,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:[n,e],f:void 0,b:void 0,o:void 0}}function D(n,e,r){return{t:31,i:n,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:r,f:e,b:void 0,o:void 0}}function he(n,e){return{t:32,i:n,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:e,b:void 0,o:void 0}}function ye(n,e){return{t:33,i:n,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:e,b:void 0,o:void 0}}function ve(n,e){return{t:34,i:n,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:e,b:void 0,o:void 0}}function V(n){let e=[],r=-1,t=-1,s=n[Symbol.iterator]();for(;;)try{let o=s.next();if(e.push(o.value),o.done){t=e.length-1;break}}catch(o){r=e.length,e.push(o)}return{v:e,t:r,d:t}}function He(n){return()=>{let e=0;return{[Symbol.iterator](){return this},next(){if(e>n.d)return{done:!0,value:void 0};let r=e++,t=n.v[r];if(r===n.t)throw t;return{done:r===n.d,value:t}}}}}var $e={},qe={};var Ze={0:{},1:{},2:{},3:{},4:{}};var B=class{constructor(e){this.marked=new Set;this.plugins=e.plugins,this.features=31^(e.disabledFeatures||0),this.refs=e.refs||new Map}markRef(e){this.marked.add(e)}isMarked(e){return this.marked.has(e)}getIndexedValue(e){let r=this.refs.get(e);if(r!=null)return this.markRef(r),{type:1,value:Ye(r)};let t=this.refs.size;return this.refs.set(e,t),{type:0,value:t}}getReference(e){let r=this.getIndexedValue(e);return r.type===1?r:X(e)?{type:2,value:Re(r.value,e)}:r}getStrictReference(e){f(X(e),new Error("Cannot serialize "+typeof e+" without reference ID."));let r=this.getIndexedValue(e);return r.type===1?r.value:Re(r.value,e)}parseFunction(e){return this.getStrictReference(e)}parseWellKnownSymbol(e){let r=this.getReference(e);return r.type!==0?r.value:(f(e in L,new Error("Cannot serialized unsupported symbol.")),Ge(r.value,e))}parseSpecialReference(e){let r=this.getIndexedValue(Ze[e]);return r.type===1?r.value:{t:26,i:r.value,s:e,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}parseIteratorFactory(){let e=this.getIndexedValue($e);return e.type===1?e.value:{t:27,i:e.value,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:this.parseWellKnownSymbol(Symbol.iterator),b:void 0,o:void 0}}parseAsyncIteratorFactory(){let e=this.getIndexedValue(qe);return e.type===1?e.value:{t:29,i:e.value,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:[this.parseSpecialReference(1),this.parseWellKnownSymbol(Symbol.asyncIterator)],f:void 0,b:void 0,o:void 0}}createObjectNode(e,r,t,s){return{t:t?11:10,i:e,s:void 0,l:void 0,c:void 0,m:void 0,p:s,e:void 0,a:void 0,f:void 0,b:void 0,o:ne(r)}}createMapNode(e,r,t,s){return{t:8,i:e,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:{k:r,v:t,s},a:void 0,f:this.parseSpecialReference(0),b:void 0,o:void 0}}createPromiseConstructorNode(e){return{t:22,i:e,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:this.parseSpecialReference(1),b:void 0,o:void 0}}};async function we(n){try{return[1,await n]}catch(e){return[0,e]}}function J(){let n,e;return{promise:new Promise((r,t)=>{n=r,e=t}),resolve(r){n(r)},reject(r){e(r)}}}function be(n){return"__SEROVAL_STREAM__"in n}function E(){let n=new Set,e=[],r=!0,t=!1;function s(a){for(let l of n.keys())l.next(a)}function o(a){for(let l of n.keys())l.throw(a)}function i(a){for(let l of n.keys())l.return(a)}return{__SEROVAL_STREAM__:!0,on(a){r&&n.add(a);for(let l=0,d=e.length;l<d;l++){let g=e[l];l===d-1?t?a.return(g):a.throw(g):a.next(g)}return()=>{r&&n.delete(a)}},next(a){r&&(e.push(a),s(a))},throw(a){r&&(e.push(a),o(a),r=!1,t=!1,n.clear())},return(a){r&&(e.push(a),i(a),r=!1,t=!0,n.clear())}}}function xe(n){let e=E(),r=n[Symbol.asyncIterator]();async function t(){try{let s=await r.next();s.done?e.return(s.value):(e.next(s.value),await t())}catch(s){e.throw(s)}}return t().catch(()=>{}),e}function Xe(n){return()=>{let e=[],r=[],t=0,s=-1,o=!1;function i(){for(let l=0,d=r.length;l<d;l++)r[l].resolve({done:!0,value:void 0})}n.on({next(l){let d=r.shift();d&&d.resolve({done:!1,value:l}),e.push(l)},throw(l){let d=r.shift();d&&d.reject(l),i(),s=e.length,e.push(l),o=!0},return(l){let d=r.shift();d&&d.resolve({done:!0,value:l}),i(),s=e.length,e.push(l)}});function a(){let l=t++,d=e[l];if(l!==s)return{done:!1,value:d};if(o)throw d;return{done:!0,value:d}}return{[Symbol.asyncIterator](){return this},async next(){if(s===-1){let l=t++;if(l>=e.length){let d=J();return r.push(d),await d.promise}return{done:!1,value:e[l]}}return t>s?{done:!0,value:void 0}:a()}}}}var R=class extends B{async parseItems(e){let r=[];for(let t=0,s=e.length;t<s;t++)t in e&&(r[t]=await this.parse(e[t]));return r}async parseArray(e,r){return de(e,r,await this.parseItems(r))}async parseProperties(e){let r=Object.entries(e),t=[],s=[];for(let i=0,a=r.length;i<a;i++)t.push(u(r[i][0])),s.push(await this.parse(r[i][1]));let o=Symbol.iterator;return o in e&&(t.push(this.parseWellKnownSymbol(o)),s.push(k(this.parseIteratorFactory(),await this.parse(V(e))))),o=Symbol.asyncIterator,o in e&&(t.push(this.parseWellKnownSymbol(o)),s.push(F(this.parseAsyncIteratorFactory(),await this.parse(xe(e))))),o=Symbol.toStringTag,o in e&&(t.push(this.parseWellKnownSymbol(o)),s.push(N(e[o]))),o=Symbol.isConcatSpreadable,o in e&&(t.push(this.parseWellKnownSymbol(o)),s.push(e[o]?y:v)),{k:t,v:s,s:t.length}}async parsePlainObject(e,r,t){return this.createObjectNode(e,r,t,await this.parseProperties(r))}async parseBoxed(e,r){return ue(e,await this.parse(r.valueOf()))}async parseTypedArray(e,r){return ce(e,r,await this.parse(r.buffer))}async parseBigIntTypedArray(e,r){return fe(e,r,await this.parse(r.buffer))}async parseDataView(e,r){return pe(e,r,await this.parse(r.buffer))}async parseError(e,r){let t=z(r,this.features);return me(e,r,t?await this.parseProperties(t):void 0)}async parseAggregateError(e,r){let t=z(r,this.features);return ge(e,r,t?await this.parseProperties(t):void 0)}async parseMap(e,r){let t=[],s=[];for(let[o,i]of r.entries())t.push(await this.parse(o)),s.push(await this.parse(i));return this.createMapNode(e,t,s,r.size)}async parseSet(e,r){let t=[];for(let s of r.keys())t.push(await this.parse(s));return Se(e,r.size,t)}async parsePromise(e,r){let[t,s]=await we(r);return{t:12,i:e,s:t,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:await this.parse(s),b:void 0,o:void 0}}async parsePlugin(e,r){let t=this.plugins;if(t)for(let s=0,o=t.length;s<o;s++){let i=t[s];if(i.parse.async&&i.test(r))return T(e,i.tag,await i.parse.async(r,this,{id:e}))}}async parseStream(e,r){return D(e,this.parseSpecialReference(4),await new Promise((t,s)=>{let o=[],i=r.on({next:a=>{this.markRef(e),this.parse(a).then(l=>{o.push(he(e,l))},l=>{s(l),i()})},throw:a=>{this.markRef(e),this.parse(a).then(l=>{o.push(ye(e,l)),t(o),i()},l=>{s(l),i()})},return:a=>{this.markRef(e),this.parse(a).then(l=>{o.push(ve(e,l)),t(o),i()},l=>{s(l),i()})}})}))}async parseObject(e,r){if(Array.isArray(r))return this.parseArray(e,r);if(be(r))return this.parseStream(e,r);let t=await this.parsePlugin(e,r);if(t)return t;let s=r.constructor;switch(s){case Object:return this.parsePlainObject(e,r,!1);case void 0:return this.parsePlainObject(e,r,!0);case Date:return ie(e,r);case RegExp:return ae(e,r);case Error:case EvalError:case RangeError:case ReferenceError:case SyntaxError:case TypeError:case URIError:return this.parseError(e,r);case Number:case Boolean:case String:case BigInt:return this.parseBoxed(e,r);case ArrayBuffer:return le(e,r);case Int8Array:case Int16Array:case Int32Array:case Uint8Array:case Uint16Array:case Uint32Array:case Uint8ClampedArray:case Float32Array:case Float64Array:return this.parseTypedArray(e,r);case DataView:return this.parseDataView(e,r);case Map:return this.parseMap(e,r);case Set:return this.parseSet(e,r);default:break}if(s===Promise||r instanceof Promise)return this.parsePromise(e,r);let o=this.features;if(o&16)switch(s){case BigInt64Array:case BigUint64Array:return this.parseBigIntTypedArray(e,r);default:break}if(o&1&&typeof AggregateError!="undefined"&&(s===AggregateError||r instanceof AggregateError))return this.parseAggregateError(e,r);if(r instanceof Error)return this.parseError(e,r);if(Symbol.iterator in r||Symbol.asyncIterator in r)return this.parsePlainObject(e,r,!!s);throw new p(r)}async parse(e){switch(typeof e){case"boolean":return e?y:v;case"undefined":return ee;case"string":return N(e);case"number":return se(e);case"bigint":return oe(e);case"object":{if(e){let r=this.getReference(e);return r.type===0?await this.parseObject(r.value,e):r.value}return re}case"symbol":return this.parseWellKnownSymbol(e);case"function":return this.parseFunction(e);default:throw new p(e)}}};var j=class extends R{constructor(){super(...arguments);this.mode="vanilla"}};function Qe(n){switch(n){case"Int8Array":return Int8Array;case"Int16Array":return Int16Array;case"Int32Array":return Int32Array;case"Uint8Array":return Uint8Array;case"Uint16Array":return Uint16Array;case"Uint32Array":return Uint32Array;case"Uint8ClampedArray":return Uint8ClampedArray;case"Float32Array":return Float32Array;case"Float64Array":return Float64Array;case"BigInt64Array":return BigInt64Array;case"BigUint64Array":return BigUint64Array;default:throw new Error(`Unknown TypedArray "${n}"`)}}function er(n,e){switch(e){case 3:return Object.freeze(n);case 1:return Object.preventExtensions(n);case 2:return Object.seal(n);default:return n}}var w=class{constructor(e){this.plugins=e.plugins,this.refs=e.refs||new Map}deserializeReference(e){return this.assignIndexedValue(e.i,Fe(S(e.s)))}deserializeArray(e){let r=e.l,t=this.assignIndexedValue(e.i,new Array(r)),s;for(let o=0;o<r;o++)s=e.a[o],s&&(t[o]=this.deserialize(s));return er(t,e.o),t}deserializeProperties(e,r){let t=e.s;if(t){let s=e.k,o=e.v;for(let i=0,a;i<t;i++)a=s[i],typeof a=="string"?r[S(a)]=this.deserialize(o[i]):r[this.deserialize(a)]=this.deserialize(o[i])}return r}deserializeObject(e){let r=this.assignIndexedValue(e.i,e.t===10?{}:Object.create(null));return this.deserializeProperties(e.p,r),er(r,e.o),r}deserializeDate(e){return this.assignIndexedValue(e.i,new Date(e.s))}deserializeRegExp(e){return this.assignIndexedValue(e.i,new RegExp(S(e.c),e.m))}deserializeSet(e){let r=this.assignIndexedValue(e.i,new Set),t=e.a;for(let s=0,o=e.l;s<o;s++)r.add(this.deserialize(t[s]));return r}deserializeMap(e){let r=this.assignIndexedValue(e.i,new Map),t=e.e.k,s=e.e.v;for(let o=0,i=e.e.s;o<i;o++)r.set(this.deserialize(t[o]),this.deserialize(s[o]));return r}deserializeArrayBuffer(e){let r=new Uint8Array(e.s);return this.assignIndexedValue(e.i,r.buffer)}deserializeTypedArray(e){let r=Qe(e.c),t=this.deserialize(e.f);return this.assignIndexedValue(e.i,new r(t,e.b,e.l))}deserializeDataView(e){let r=this.deserialize(e.f);return this.assignIndexedValue(e.i,new DataView(r,e.b,e.l))}deserializeDictionary(e,r){if(e.p){let t=this.deserializeProperties(e.p,{});Object.assign(r,t)}return r}deserializeAggregateError(e){let r=this.assignIndexedValue(e.i,new AggregateError([],S(e.m)));return this.deserializeDictionary(e,r)}deserializeError(e){let r=_e[e.s],t=this.assignIndexedValue(e.i,new r(S(e.m)));return this.deserializeDictionary(e,t)}deserializePromise(e){let r=J(),t=this.assignIndexedValue(e.i,r),s=this.deserialize(e.f);return e.s?r.resolve(s):r.reject(s),t.promise}deserializeBoxed(e){return this.assignIndexedValue(e.i,Object(this.deserialize(e.f)))}deserializePlugin(e){let r=this.plugins;if(r){let t=S(e.c);for(let s=0,o=r.length;s<o;s++){let i=r[s];if(i.tag===t)return this.assignIndexedValue(e.i,i.deserialize(e.s,this,{id:e.i}))}}throw new Error('Missing plugin for tag "'+e.c+'".')}deserializePromiseConstructor(e){return this.assignIndexedValue(e.i,J()).promise}deserializePromiseResolve(e){let r=this.refs.get(e.i);f(r,new Error("Missing Promise instance.")),r.resolve(this.deserialize(e.a[1]))}deserializePromiseReject(e){let r=this.refs.get(e.i);f(r,new Error("Missing Promise instance.")),r.reject(this.deserialize(e.a[1]))}deserializeIteratorFactoryInstance(e){this.deserialize(e.a[0]);let r=this.deserialize(e.a[1]);return He(r)}deserializeAsyncIteratorFactoryInstance(e){this.deserialize(e.a[0]);let r=this.deserialize(e.a[1]);return Xe(r)}deserializeStreamConstructor(e){let r=this.assignIndexedValue(e.i,E()),t=e.a.length;if(t)for(let s=0;s<t;s++)this.deserialize(e.a[s]);return r}deserializeStreamNext(e){let r=this.refs.get(e.i);f(r,new Error("Missing Stream instance.")),r.next(this.deserialize(e.f))}deserializeStreamThrow(e){let r=this.refs.get(e.i);f(r,new Error("Missing Stream instance.")),r.throw(this.deserialize(e.f))}deserializeStreamReturn(e){let r=this.refs.get(e.i);f(r,new Error("Missing Stream instance.")),r.return(this.deserialize(e.f))}deserializeIteratorFactory(e){this.deserialize(e.f)}deserializeAsyncIteratorFactory(e){this.deserialize(e.a[1])}deserialize(e){switch(e.t){case 2:return Me[e.s];case 0:return e.s;case 1:return S(e.s);case 3:return BigInt(e.s);case 4:return this.refs.get(e.i);case 18:return this.deserializeReference(e);case 9:return this.deserializeArray(e);case 10:case 11:return this.deserializeObject(e);case 5:return this.deserializeDate(e);case 6:return this.deserializeRegExp(e);case 7:return this.deserializeSet(e);case 8:return this.deserializeMap(e);case 19:return this.deserializeArrayBuffer(e);case 16:case 15:return this.deserializeTypedArray(e);case 20:return this.deserializeDataView(e);case 14:return this.deserializeAggregateError(e);case 13:return this.deserializeError(e);case 12:return this.deserializePromise(e);case 17:return Be[e.s];case 21:return this.deserializeBoxed(e);case 25:return this.deserializePlugin(e);case 22:return this.deserializePromiseConstructor(e);case 23:return this.deserializePromiseResolve(e);case 24:return this.deserializePromiseReject(e);case 28:return this.deserializeIteratorFactoryInstance(e);case 30:return this.deserializeAsyncIteratorFactoryInstance(e);case 31:return this.deserializeStreamConstructor(e);case 32:return this.deserializeStreamNext(e);case 33:return this.deserializeStreamThrow(e);case 34:return this.deserializeStreamReturn(e);case 27:return this.deserializeIteratorFactory(e);case 29:return this.deserializeAsyncIteratorFactory(e);default:throw new Error("invariant")}}};var Y=class extends w{constructor(r){super(r);this.mode="vanilla";this.marked=new Set(r.markedRefs)}assignIndexedValue(r,t){return this.marked.has(r)&&this.refs.set(r,t),t}};var vr=/^[$A-Z_][0-9A-Z_$]*$/i;function Pe(n){let e=n[0];return(e==="$"||e==="_"||e>="A"&&e<="Z"||e>="a"&&e<="z")&&vr.test(n)}function G(n){switch(n.t){case 0:return n.s+"="+n.v;case 2:return n.s+".set("+n.k+","+n.v+")";case 1:return n.s+".add("+n.v+")";case 3:return n.s+".delete("+n.k+")"}}function Nr(n){let e=[],r=n[0];for(let t=1,s=n.length,o,i=r;t<s;t++)o=n[t],o.t===0&&o.v===i.v?r={t:0,s:o.s,k:void 0,v:G(r)}:o.t===2&&o.s===i.s?r={t:2,s:G(r),k:o.k,v:o.v}:o.t===1&&o.s===i.s?r={t:1,s:G(r),k:void 0,v:o.v}:o.t===3&&o.s===i.s?r={t:3,s:G(r),k:o.k,v:void 0}:(e.push(r),r=o),i=o;return e.push(r),e}function rr(n){if(n.length){let e="",r=Nr(n);for(let t=0,s=r.length;t<s;t++)e+=G(r[t])+",";return e}}var br="Object.create(null)",xr="new Set",Ar="new Map",Ir="Promise.resolve",Er="Promise.reject",Rr={3:"Object.freeze",2:"Object.seal",1:"Object.preventExtensions",0:void 0},P=class{constructor(e){this.stack=[];this.flags=[];this.assignments=[];this.plugins=e.plugins,this.features=e.features,this.marked=new Set(e.markedRefs)}createFunction(e,r){return this.features&2?(e.length===1?e[0]:"("+e.join(",")+")")+"=>"+r:"function("+e.join(",")+"){return "+r+"}"}createEffectfulFunction(e,r){return this.features&2?(e.length===1?e[0]:"("+e.join(",")+")")+"=>{"+r+"}":"function("+e.join(",")+"){"+r+"}"}markRef(e){this.marked.add(e)}isMarked(e){return this.marked.has(e)}pushObjectFlag(e,r){e!==0&&(this.markRef(r),this.flags.push({type:e,value:this.getRefParam(r)}))}resolveFlags(){let e="";for(let r=0,t=this.flags,s=t.length;r<s;r++){let o=t[r];e+=Rr[o.type]+"("+o.value+"),"}return e}resolvePatches(){let e=rr(this.assignments),r=this.resolveFlags();return e?r?e+r:e:r}createAssignment(e,r){this.assignments.push({t:0,s:e,k:void 0,v:r})}createAddAssignment(e,r){this.assignments.push({t:1,s:this.getRefParam(e),k:void 0,v:r})}createSetAssignment(e,r,t){this.assignments.push({t:2,s:this.getRefParam(e),k:r,v:t})}createDeleteAssignment(e,r){this.assignments.push({t:3,s:this.getRefParam(e),k:r,v:void 0})}createArrayAssign(e,r,t){this.createAssignment(this.getRefParam(e)+"["+r+"]",t)}createObjectAssign(e,r,t){this.createAssignment(this.getRefParam(e)+"."+r,t)}isIndexedValueInStack(e){return e.t===4&&this.stack.includes(e.i)}serializeReference(e){return this.assignIndexedValue(e.i,x+'.get("'+e.s+'")')}serializeArrayItem(e,r,t){return r?this.isIndexedValueInStack(r)?(this.markRef(e),this.createArrayAssign(e,t,this.getRefParam(r.i)),""):this.serialize(r):""}serializeArray(e){let r=e.i;if(e.l){this.stack.push(r);let t=e.a,s=this.serializeArrayItem(r,t[0],0),o=s==="";for(let i=1,a=e.l,l;i<a;i++)l=this.serializeArrayItem(r,t[i],i),s+=","+l,o=l==="";return this.stack.pop(),this.pushObjectFlag(e.o,e.i),this.assignIndexedValue(r,"["+s+(o?",]":"]"))}return this.assignIndexedValue(r,"[]")}serializeProperty(e,r,t){if(typeof r=="string"){let s=Number(r),o=s>=0||Pe(r);if(this.isIndexedValueInStack(t)){let i=this.getRefParam(t.i);return this.markRef(e.i),o&&s!==s?this.createObjectAssign(e.i,r,i):this.createArrayAssign(e.i,o?r:'"'+r+'"',i),""}return(o?r:'"'+r+'"')+":"+this.serialize(t)}return"["+this.serialize(r)+"]:"+this.serialize(t)}serializeProperties(e,r){let t=r.s;if(t){let s=r.k,o=r.v;this.stack.push(e.i);let i=this.serializeProperty(e,s[0],o[0]);for(let a=1,l=i;a<t;a++)l=this.serializeProperty(e,s[a],o[a]),i+=(l&&i&&",")+l;return this.stack.pop(),"{"+i+"}"}return"{}"}serializeObject(e){return this.pushObjectFlag(e.o,e.i),this.assignIndexedValue(e.i,this.serializeProperties(e,e.p))}serializeWithObjectAssign(e,r,t){let s=this.serializeProperties(e,r);return s!=="{}"?"Object.assign("+t+","+s+")":t}serializeStringKeyAssignment(e,r,t,s){let o=this.serialize(s),i=Number(t),a=i>=0||Pe(t);if(this.isIndexedValueInStack(s))a&&i!==i?this.createObjectAssign(e.i,t,o):this.createArrayAssign(e.i,a?t:'"'+t+'"',o);else{let l=this.assignments;this.assignments=r,a?this.createObjectAssign(e.i,t,o):this.createArrayAssign(e.i,a?t:'"'+t+'"',o),this.assignments=l}}serializeAssignment(e,r,t,s){if(typeof t=="string")this.serializeStringKeyAssignment(e,r,t,s);else{let o=this.stack;this.stack=[];let i=this.serialize(s);this.stack=o;let a=this.assignments;this.assignments=r,this.createArrayAssign(e.i,this.serialize(t),i),this.assignments=a}}serializeAssignments(e,r){let t=r.s;if(t){let s=[],o=r.k,i=r.v;this.stack.push(e.i);for(let a=0;a<t;a++)this.serializeAssignment(e,s,o[a],i[a]);return this.stack.pop(),rr(s)}}serializeDictionary(e,r){if(e.p)if(this.features&8)r=this.serializeWithObjectAssign(e,e.p,r);else{this.markRef(e.i);let t=this.serializeAssignments(e,e.p);if(t)return"("+this.assignIndexedValue(e.i,r)+","+t+this.getRefParam(e.i)+")"}return this.assignIndexedValue(e.i,r)}serializeNullConstructor(e){return this.pushObjectFlag(e.o,e.i),this.serializeDictionary(e,br)}serializeDate(e){return this.assignIndexedValue(e.i,'new Date("'+e.s+'")')}serializeRegExp(e){return this.assignIndexedValue(e.i,"/"+e.c+"/"+e.m)}serializeSetItem(e,r){return this.isIndexedValueInStack(r)?(this.markRef(e),this.createAddAssignment(e,this.getRefParam(r.i)),""):this.serialize(r)}serializeSet(e){let r=xr,t=e.l,s=e.i;if(t){let o=e.a;this.stack.push(s);let i=this.serializeSetItem(s,o[0]);for(let a=1,l=i;a<t;a++)l=this.serializeSetItem(s,o[a]),i+=(l&&i&&",")+l;this.stack.pop(),i&&(r+="(["+i+"])")}return this.assignIndexedValue(s,r)}serializeMapEntry(e,r,t,s){if(this.isIndexedValueInStack(r)){let o=this.getRefParam(r.i);if(this.markRef(e),this.isIndexedValueInStack(t)){let a=this.getRefParam(t.i);return this.createSetAssignment(e,o,a),""}if(t.t!==4&&t.i!=null&&this.isMarked(t.i)){let a="("+this.serialize(t)+",["+s+","+s+"])";return this.createSetAssignment(e,o,this.getRefParam(t.i)),this.createDeleteAssignment(e,s),a}let i=this.stack;return this.stack=[],this.createSetAssignment(e,o,this.serialize(t)),this.stack=i,""}if(this.isIndexedValueInStack(t)){let o=this.getRefParam(t.i);if(this.markRef(e),r.t!==4&&r.i!=null&&this.isMarked(r.i)){let a="("+this.serialize(r)+",["+s+","+s+"])";return this.createSetAssignment(e,this.getRefParam(r.i),o),this.createDeleteAssignment(e,s),a}let i=this.stack;return this.stack=[],this.createSetAssignment(e,this.serialize(r),o),this.stack=i,""}return"["+this.serialize(r)+","+this.serialize(t)+"]"}serializeMap(e){let r=Ar,t=e.e.s,s=e.i,o=e.f,i=this.getRefParam(o.i);if(t){let a=e.e.k,l=e.e.v;this.stack.push(s);let d=this.serializeMapEntry(s,a[0],l[0],i);for(let g=1,Ae=d;g<t;g++)Ae=this.serializeMapEntry(s,a[g],l[g],i),d+=(Ae&&d&&",")+Ae;this.stack.pop(),d&&(r+="(["+d+"])")}return o.t===26&&(this.markRef(o.i),r="("+this.serialize(o)+","+r+")"),this.assignIndexedValue(s,r)}serializeArrayBuffer(e){let r="new Uint8Array(",t=e.s,s=t.length;if(s){r+="["+t[0];for(let o=1;o<s;o++)r+=","+t[o];r+="]"}return this.assignIndexedValue(e.i,r+").buffer")}serializeTypedArray(e){return this.assignIndexedValue(e.i,"new "+e.c+"("+this.serialize(e.f)+","+e.b+","+e.l+")")}serializeDataView(e){return this.assignIndexedValue(e.i,"new DataView("+this.serialize(e.f)+","+e.b+","+e.l+")")}serializeAggregateError(e){let r=e.i;this.stack.push(r);let t=this.serializeDictionary(e,'new AggregateError([],"'+e.m+'")');return this.stack.pop(),t}serializeError(e){return this.serializeDictionary(e,"new "+Q[e.s]+'("'+e.m+'")')}serializePromise(e){let r,t=e.f,s=e.i,o=e.s?Ir:Er;if(this.isIndexedValueInStack(t)){let i=this.getRefParam(t.i);r=o+(e.s?"().then("+this.createFunction([],i)+")":"().catch("+this.createEffectfulFunction([],"throw "+i)+")")}else{this.stack.push(s);let i=this.serialize(t);this.stack.pop(),r=o+"("+i+")"}return this.assignIndexedValue(s,r)}serializeWellKnownSymbol(e){return this.assignIndexedValue(e.i,Ve[e.s])}serializeBoxed(e){return this.assignIndexedValue(e.i,"Object("+this.serialize(e.f)+")")}serializePlugin(e){let r=this.plugins;if(r)for(let t=0,s=r.length;t<s;t++){let o=r[t];if(o.tag===e.c)return this.assignIndexedValue(e.i,o.serialize(e.s,this,{id:e.i}))}throw new Error('Missing plugin for tag "'+e.c+'".')}getConstructor(e){let r=this.serialize(e);return r===this.getRefParam(e.i)?r:"("+r+")"}serializePromiseConstructor(e){return this.assignIndexedValue(e.i,this.getConstructor(e.f)+"()")}serializePromiseResolve(e){return this.getConstructor(e.a[0])+"("+this.getRefParam(e.i)+","+this.serialize(e.a[1])+")"}serializePromiseReject(e){return this.getConstructor(e.a[0])+"("+this.getRefParam(e.i)+","+this.serialize(e.a[1])+")"}serializeSpecialReferenceValue(e){switch(e){case 0:return"[]";case 1:return this.createFunction(["s","f","p"],"((p=new Promise("+this.createEffectfulFunction(["a","b"],"s=a,f=b")+")).s=s,p.f=f,p)");case 2:return this.createEffectfulFunction(["p","d"],'p.s(d),p.status="success",p.value=d;delete p.s;delete p.f');case 3:return this.createEffectfulFunction(["p","d"],'p.f(d),p.status="failure",p.value=d;delete p.s;delete p.f');case 4:return this.createFunction(["b","a","s","l","p","f","e","n"],"(b=[],a=!0,s=!1,l=[],p=0,f="+this.createEffectfulFunction(["v","m","x"],"for(x=0;x<p;x++)l[x]&&l[x][m](v)")+",n="+this.createEffectfulFunction(["o","x","z","c"],'for(x=0,z=b.length;x<z;x++)(c=b[x],x===z-1?o[s?"return":"throw"](c):o.next(c))')+",e="+this.createFunction(["o","t"],"(a&&(l[t=p++]=o),n(o),"+this.createEffectfulFunction([],"a&&(l[t]=void 0)")+")")+",{__SEROVAL_STREAM__:!0,on:"+this.createFunction(["o"],"e(o)")+",next:"+this.createEffectfulFunction(["v"],'a&&(b.push(v),f(v,"next"))')+",throw:"+this.createEffectfulFunction(["v"],'a&&(b.push(v),f(v,"throw"),a=s=!1,l.length=0)')+",return:"+this.createEffectfulFunction(["v"],'a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)')+"})");default:return""}}serializeSpecialReference(e){return this.assignIndexedValue(e.i,this.serializeSpecialReferenceValue(e.s))}serializeIteratorFactory(e){let r="",t=!1;return e.f.t!==4&&(this.markRef(e.f.i),r="("+this.serialize(e.f)+",",t=!0),r+=this.assignIndexedValue(e.i,this.createFunction(["s"],this.createFunction(["i","c","d","t"],"(i=0,t={["+this.getRefParam(e.f.i)+"]:"+this.createFunction([],"t")+",next:"+this.createEffectfulFunction([],"if(i>s.d)return{done:!0,value:void 0};if(d=s.v[c=i++],c===s.t)throw d;return{done:c===s.d,value:d}")+"})"))),t&&(r+=")"),r}serializeIteratorFactoryInstance(e){return this.getConstructor(e.a[0])+"("+this.serialize(e.a[1])+")"}serializeAsyncIteratorFactory(e){let r=e.a[0],t=e.a[1],s="";r.t!==4&&(this.markRef(r.i),s+="("+this.serialize(r)),t.t!==4&&(this.markRef(t.i),s+=(s?",":"(")+this.serialize(t)),s&&(s+=",");let o=this.assignIndexedValue(e.i,this.createFunction(["s"],this.createFunction(["b","c","p","d","e","t","f"],"(b=[],c=0,p=[],d=-1,e=!1,f="+this.createEffectfulFunction(["i","l"],"for(i=0,l=p.length;i<l;i++)p[i].s({done:!0,value:void 0})")+",s.on({next:"+this.createEffectfulFunction(["v","t"],"if(t=p.shift())t.s({done:!1,value:v});b.push(v)")+",throw:"+this.createEffectfulFunction(["v","t"],"if(t=p.shift())t.f(v);f(),d=b.length,e=!0,b.push(v)")+",return:"+this.createEffectfulFunction(["v","t"],"if(t=p.shift())t.s({done:!0,value:v});f(),d=b.length,b.push(v)")+"}),t={["+this.getRefParam(t.i)+"]:"+this.createFunction([],"t")+",next:"+this.createEffectfulFunction(["i","t","v"],"if(d===-1){return((i=c++)>=b.length)?(p.push(t="+this.getRefParam(r.i)+"()),t):{done:!0,value:b[i]}}if(c>d)return{done:!0,value:void 0};if(v=b[i=c++],i!==d)return{done:!1,value:v};if(e)throw v;return{done:!0,value:v}")+"})")));return s?s+o+")":o}serializeAsyncIteratorFactoryInstance(e){return this.getConstructor(e.a[0])+"("+this.serialize(e.a[1])+")"}serializeStreamConstructor(e){let r=this.assignIndexedValue(e.i,this.getConstructor(e.f)+"()"),t=e.a.length;if(t){let s=this.serialize(e.a[0]);for(let o=1;o<t;o++)s+=","+this.serialize(e.a[o]);return"("+r+","+s+","+this.getRefParam(e.i)+")"}return r}serializeStreamNext(e){return this.getRefParam(e.i)+".next("+this.serialize(e.f)+")"}serializeStreamThrow(e){return this.getRefParam(e.i)+".throw("+this.serialize(e.f)+")"}serializeStreamReturn(e){return this.getRefParam(e.i)+".return("+this.serialize(e.f)+")"}serialize(e){switch(e.t){case 2:return je[e.s];case 0:return""+e.s;case 1:return'"'+e.s+'"';case 3:return e.s+"n";case 4:return this.getRefParam(e.i);case 18:return this.serializeReference(e);case 9:return this.serializeArray(e);case 10:return this.serializeObject(e);case 11:return this.serializeNullConstructor(e);case 5:return this.serializeDate(e);case 6:return this.serializeRegExp(e);case 7:return this.serializeSet(e);case 8:return this.serializeMap(e);case 19:return this.serializeArrayBuffer(e);case 16:case 15:return this.serializeTypedArray(e);case 20:return this.serializeDataView(e);case 14:return this.serializeAggregateError(e);case 13:return this.serializeError(e);case 12:return this.serializePromise(e);case 17:return this.serializeWellKnownSymbol(e);case 21:return this.serializeBoxed(e);case 22:return this.serializePromiseConstructor(e);case 23:return this.serializePromiseResolve(e);case 24:return this.serializePromiseReject(e);case 25:return this.serializePlugin(e);case 26:return this.serializeSpecialReference(e);case 27:return this.serializeIteratorFactory(e);case 28:return this.serializeIteratorFactoryInstance(e);case 29:return this.serializeAsyncIteratorFactory(e);case 30:return this.serializeAsyncIteratorFactoryInstance(e);case 31:return this.serializeStreamConstructor(e);case 32:return this.serializeStreamNext(e);case 33:return this.serializeStreamThrow(e);case 34:return this.serializeStreamReturn(e);default:throw new Error("invariant")}}};var sr="hjkmoquxzABCDEFGHIJKLNPQRTUVWXYZ$_",tr=sr.length,or="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_",nr=or.length;function Ce(n){let e=n%tr,r=sr[e];for(n=(n-e)/tr;n>0;)e=n%nr,r+=or[e],n=(n-e)/nr;return r}var C=class extends P{constructor(){super(...arguments);this.mode="vanilla";this.valid=new Map;this.vars=[]}getRefParam(r){let t=this.valid.get(r);t==null&&(t=this.valid.size,this.valid.set(r,t));let s=this.vars[t];return s==null&&(s=Ce(t),this.vars[t]=s),s}assignIndexedValue(r,t){return this.isMarked(r)?this.getRefParam(r)+"="+t:t}serializePromiseConstructor(r){throw new Error('Unsupported node type "'+r.t+'".')}serializePromiseResolve(r){throw new Error('Unsupported node type "'+r.t+'".')}serializePromiseReject(r){throw new Error('Unsupported node type "'+r.t+'".')}serializeTop(r){let t=this.serialize(r);if(r.i!=null&&this.vars.length){let s=this.resolvePatches(),o=t;if(s){let i=this.getRefParam(r.i);o=t+","+s+i,t.startsWith(i+"=")||(o=i+"="+o)}return"("+this.createFunction(this.vars,"("+o+")")+")()"}return r.t===10?"("+t+")":t}};var m=class extends B{parseItems(e){let r=[];for(let t=0,s=e.length;t<s;t++)t in e&&(r[t]=this.parse(e[t]));return r}parseArray(e,r){return de(e,r,this.parseItems(r))}parseProperties(e){let r=Object.entries(e),t=[],s=[];for(let i=0,a=r.length;i<a;i++)t.push(u(r[i][0])),s.push(this.parse(r[i][1]));let o=Symbol.iterator;return o in e&&(t.push(this.parseWellKnownSymbol(o)),s.push(k(this.parseIteratorFactory(),this.parse(V(e))))),o=Symbol.asyncIterator,o in e&&(t.push(this.parseWellKnownSymbol(o)),s.push(F(this.parseAsyncIteratorFactory(),this.parse(E())))),o=Symbol.toStringTag,o in e&&(t.push(this.parseWellKnownSymbol(o)),s.push(N(e[o]))),o=Symbol.isConcatSpreadable,o in e&&(t.push(this.parseWellKnownSymbol(o)),s.push(e[o]?y:v)),{k:t,v:s,s:t.length}}parsePlainObject(e,r,t){return this.createObjectNode(e,r,t,this.parseProperties(r))}parseBoxed(e,r){return ue(e,this.parse(r.valueOf()))}parseTypedArray(e,r){return ce(e,r,this.parse(r.buffer))}parseBigIntTypedArray(e,r){return fe(e,r,this.parse(r.buffer))}parseDataView(e,r){return pe(e,r,this.parse(r.buffer))}parseError(e,r){let t=z(r,this.features);return me(e,r,t?this.parseProperties(t):void 0)}parseAggregateError(e,r){let t=z(r,this.features);return ge(e,r,t?this.parseProperties(t):void 0)}parseMap(e,r){let t=[],s=[];for(let[o,i]of r.entries())t.push(this.parse(o)),s.push(this.parse(i));return this.createMapNode(e,t,s,r.size)}parseSet(e,r){let t=[];for(let s of r.keys())t.push(this.parse(s));return Se(e,r.size,t)}parsePlugin(e,r){let t=this.plugins;if(t)for(let s=0,o=t.length;s<o;s++){let i=t[s];if(i.parse.sync&&i.test(r))return T(e,i.tag,i.parse.sync(r,this,{id:e}))}}parseStream(e,r){return D(e,this.parseSpecialReference(4),[])}parsePromise(e,r){return this.createPromiseConstructorNode(e)}parseObject(e,r){if(Array.isArray(r))return this.parseArray(e,r);if(be(r))return this.parseStream(e,r);let t=this.parsePlugin(e,r);if(t)return t;let s=r.constructor;switch(s){case Object:return this.parsePlainObject(e,r,!1);case void 0:return this.parsePlainObject(e,r,!0);case Date:return ie(e,r);case RegExp:return ae(e,r);case Error:case EvalError:case RangeError:case ReferenceError:case SyntaxError:case TypeError:case URIError:return this.parseError(e,r);case Number:case Boolean:case String:case BigInt:return this.parseBoxed(e,r);case ArrayBuffer:return le(e,r);case Int8Array:case Int16Array:case Int32Array:case Uint8Array:case Uint16Array:case Uint32Array:case Uint8ClampedArray:case Float32Array:case Float64Array:return this.parseTypedArray(e,r);case DataView:return this.parseDataView(e,r);case Map:return this.parseMap(e,r);case Set:return this.parseSet(e,r);default:break}if(s===Promise||r instanceof Promise)return this.parsePromise(e,r);let o=this.features;if(o&16)switch(s){case BigInt64Array:case BigUint64Array:return this.parseBigIntTypedArray(e,r);default:break}if(o&1&&typeof AggregateError!="undefined"&&(s===AggregateError||r instanceof AggregateError))return this.parseAggregateError(e,r);if(r instanceof Error)return this.parseError(e,r);if(Symbol.iterator in r||Symbol.asyncIterator in r)return this.parsePlainObject(e,r,!!s);throw new p(r)}parse(e){switch(typeof e){case"boolean":return e?y:v;case"undefined":return ee;case"string":return N(e);case"number":return se(e);case"bigint":return oe(e);case"object":{if(e){let r=this.getReference(e);return r.type===0?this.parseObject(r.value,e):r.value}return re}case"symbol":return this.parseWellKnownSymbol(e);case"function":return this.parseFunction(e);default:throw new p(e)}}};var M=class extends m{constructor(){super(...arguments);this.mode="vanilla"}};function wr(n,e={}){let r=c(e.plugins),t=new M({plugins:r,disabledFeatures:e.disabledFeatures}),s=t.parse(n);return new C({plugins:r,features:t.features,markedRefs:t.marked}).serializeTop(s)}async function Pr(n,e={}){let r=c(e.plugins),t=new j({plugins:r,disabledFeatures:e.disabledFeatures}),s=await t.parse(n);return new C({plugins:r,features:t.features,markedRefs:t.marked}).serializeTop(s)}function Cr(n){return(0,eval)(n)}function Or(n,e={}){let r=c(e.plugins),t=new M({plugins:r,disabledFeatures:e.disabledFeatures});return{t:t.parse(n),f:t.features,m:Array.from(t.marked)}}async function zr(n,e={}){let r=c(e.plugins),t=new j({plugins:r,disabledFeatures:e.disabledFeatures});return{t:await t.parse(n),f:t.features,m:Array.from(t.marked)}}function Tr(n,e={}){let r=c(e.plugins);return new C({plugins:r,features:n.f,markedRefs:n.m}).serializeTop(n.t)}function kr(n,e={}){let r=c(e.plugins);return new Y({plugins:r,markedRefs:n.m}).deserialize(n.t)}var _=class extends R{constructor(){super(...arguments);this.mode="cross"}};var H=class extends w{constructor(){super(...arguments);this.mode="cross"}assignIndexedValue(r,t){return this.refs.has(r)||this.refs.set(r,t),t}};var O=class extends P{constructor(r){super(r);this.mode="cross";this.scopeId=r.scopeId}getRefParam(r){return K+"["+r+"]"}assignIndexedValue(r,t){return this.getRefParam(r)+"="+t}serializeTop(r){let t=this.serialize(r),s=r.i;if(s==null)return t;let o=this.resolvePatches(),i=this.getRefParam(s),a=this.scopeId==null?"":K,l=o?t+","+o+i:t;if(a==="")return o?"("+l+")":l;let d=this.scopeId==null?"()":"("+K+'["'+u(this.scopeId)+'"])';return"("+this.createFunction([a],l)+")"+d}};var $=class extends m{constructor(r){super(r);this.alive=!0;this.pending=0;this.initial=!0;this.buffer=[];this.onParseCallback=r.onParse,this.onErrorCallback=r.onError,this.onDoneCallback=r.onDone}onParseInternal(r,t){try{this.onParseCallback(r,t)}catch(s){this.onError(s)}}flush(){for(let r=0,t=this.buffer.length;r<t;r++)this.onParseInternal(this.buffer[r],!1)}onParse(r){this.initial?this.buffer.push(r):this.onParseInternal(r,!1)}onError(r){if(this.onErrorCallback)this.onErrorCallback(r);else throw r}onDone(){this.onDoneCallback&&this.onDoneCallback()}pushPendingState(){this.pending++}popPendingState(){--this.pending<=0&&this.onDone()}parseProperties(r){let t=Object.entries(r),s=[],o=[];for(let a=0,l=t.length;a<l;a++)s.push(u(t[a][0])),o.push(this.parse(t[a][1]));let i=Symbol.iterator;return i in r&&(s.push(this.parseWellKnownSymbol(i)),o.push(k(this.parseIteratorFactory(),this.parse(V(r))))),i=Symbol.asyncIterator,i in r&&(s.push(this.parseWellKnownSymbol(i)),o.push(F(this.parseAsyncIteratorFactory(),this.parse(xe(r))))),i=Symbol.toStringTag,i in r&&(s.push(this.parseWellKnownSymbol(i)),o.push(N(r[i]))),i=Symbol.isConcatSpreadable,i in r&&(s.push(this.parseWellKnownSymbol(i)),o.push(r[i]?y:v)),{k:s,v:o,s:s.length}}parsePromise(r,t){return t.then(s=>{let o=this.parseWithError(s);o&&this.onParse({t:23,i:r,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:[this.parseSpecialReference(2),o],f:void 0,b:void 0,o:void 0}),this.popPendingState()},s=>{if(this.alive){let o=this.parseWithError(s);o&&this.onParse({t:24,i:r,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:[this.parseSpecialReference(3),o],f:void 0,b:void 0,o:void 0})}this.popPendingState()}),this.pushPendingState(),this.createPromiseConstructorNode(r)}parsePlugin(r,t){let s=this.plugins;if(s)for(let o=0,i=s.length;o<i;o++){let a=s[o];if(a.parse.stream&&a.test(t))return T(r,a.tag,a.parse.stream(t,this,{id:r}))}}parseStream(r,t){let s=D(r,this.parseSpecialReference(4),[]);return this.pushPendingState(),t.on({next:o=>{if(this.alive){let i=this.parseWithError(o);i&&this.onParse(he(r,i))}},throw:o=>{if(this.alive){let i=this.parseWithError(o);i&&this.onParse(ye(r,i))}this.popPendingState()},return:o=>{if(this.alive){let i=this.parseWithError(o);i&&this.onParse(ve(r,i))}this.popPendingState()}}),s}parseWithError(r){try{return this.parse(r)}catch(t){this.onError(t);return}}start(r){let t=this.parseWithError(r);t&&(this.onParseInternal(t,!0),this.initial=!1,this.flush(),this.pending<=0&&this.destroy())}destroy(){this.alive&&(this.onDone(),this.alive=!1)}isAlive(){return this.alive}};var U=class extends ${constructor(){super(...arguments);this.mode="cross"}};var W=class extends m{constructor(){super(...arguments);this.mode="cross"}};function Fr(n,e={}){let r=c(e.plugins),t=new W({plugins:r,disabledFeatures:e.disabledFeatures,refs:e.refs}),s=t.parse(n);return new O({plugins:r,features:t.features,scopeId:e.scopeId,markedRefs:t.marked}).serializeTop(s)}async function Dr(n,e={}){let r=c(e.plugins),t=new _({plugins:r,disabledFeatures:e.disabledFeatures,refs:e.refs}),s=await t.parse(n);return new O({plugins:r,features:t.features,scopeId:e.scopeId,markedRefs:t.marked}).serializeTop(s)}function Vr(n,e={}){let r=c(e.plugins);return new W({plugins:r,disabledFeatures:e.disabledFeatures,refs:e.refs}).parse(n)}async function Br(n,e={}){let r=c(e.plugins);return await new _({plugins:r,disabledFeatures:e.disabledFeatures,refs:e.refs}).parse(n)}function Oe(n,e){let r=c(e.plugins),t=new U({plugins:r,refs:e.refs,disabledFeatures:e.disabledFeatures,onParse(s,o){let i=new O({plugins:r,features:t.features,scopeId:e.scopeId,markedRefs:t.marked}),a;try{a=i.serializeTop(s)}catch(l){e.onError&&e.onError(l);return}e.onSerialize(a,o)},onError:e.onError,onDone:e.onDone});return t.start(n),()=>{t.destroy()}}function jr(n,e){let r=c(e.plugins),t=new U({plugins:r,refs:e.refs,disabledFeatures:e.disabledFeatures,onParse:e.onParse,onError:e.onError,onDone:e.onDone});return t.start(n),()=>{t.destroy()}}function Mr(n,e){let r=c(e.plugins);return new H({plugins:r,refs:e.refs}).deserialize(n)}var q=class{constructor(e){this.options=e;this.alive=!0;this.flushed=!1;this.done=!1;this.pending=0;this.cleanups=[];this.refs=new Map;this.keys=new Set;this.ids=0;this.plugins=c(e.plugins)}write(e,r){this.alive&&!this.flushed&&(this.pending++,this.keys.add(e),this.cleanups.push(Oe(r,{plugins:this.plugins,scopeId:this.options.scopeId,refs:this.refs,disabledFeatures:this.options.disabledFeatures,onError:this.options.onError,onSerialize:(t,s)=>{this.alive&&this.options.onData(s?this.options.globalIdentifier+'["'+u(e)+'"]='+t:t)},onDone:()=>{this.alive&&(this.pending--,this.pending<=0&&this.flushed&&!this.done&&this.options.onDone&&(this.options.onDone(),this.done=!0))}})))}getNextID(){for(;this.keys.has(""+this.ids);)this.ids++;return""+this.ids}push(e){let r=this.getNextID();return this.write(r,e),r}flush(){this.alive&&(this.flushed=!0,this.pending<=0&&!this.done&&this.options.onDone&&(this.options.onDone(),this.done=!0))}close(){if(this.alive){for(let e=0,r=this.cleanups.length;e<r;e++)this.cleanups[e]();!this.done&&this.options.onDone&&(this.options.onDone(),this.done=!0),this.alive=!1}}};
1
+ "use strict";var Fe=Object.defineProperty;var hr=Object.getOwnPropertyDescriptor;var yr=Object.getOwnPropertyNames;var vr=Object.prototype.hasOwnProperty;var Nr=(n,e)=>{for(var r in e)Fe(n,r,{get:e[r],enumerable:!0})},br=(n,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of yr(e))!vr.call(n,s)&&s!==r&&Fe(n,s,{get:()=>e[s],enumerable:!(t=hr(e,s))||t.enumerable});return n};var xr=n=>br(Fe({},"__esModule",{value:!0}),n);var Zr={};Nr(Zr,{Feature:()=>A,Serializer:()=>oe,SerovalDeserializationError:()=>X,SerovalError:()=>U,SerovalMissingInstanceError:()=>g,SerovalMissingPluginError:()=>P,SerovalMissingReferenceError:()=>H,SerovalMissingReferenceForIdError:()=>q,SerovalParserError:()=>E,SerovalSerializationError:()=>Z,SerovalUnknownTypedArrayError:()=>Q,SerovalUnsupportedNodeError:()=>m,SerovalUnsupportedTypeError:()=>p,compileJSON:()=>Kr,createPlugin:()=>Rr,createReference:()=>Ke,createStream:()=>C,crossSerialize:()=>Jr,crossSerializeAsync:()=>$r,crossSerializeStream:()=>Ue,deserialize:()=>Mr,fromCrossJSON:()=>qr,fromJSON:()=>Lr,getCrossReferenceHeader:()=>We,resolvePlugins:()=>c,serialize:()=>jr,serializeAsync:()=>_r,toCrossJSON:()=>Yr,toCrossJSONAsync:()=>Gr,toCrossJSONStream:()=>Hr,toJSON:()=>Ur,toJSONAsync:()=>Wr});module.exports=xr(Zr);var A=(o=>(o[o.AggregateError=1]="AggregateError",o[o.ArrowFunction=2]="ArrowFunction",o[o.ErrorPrototypeStack=4]="ErrorPrototypeStack",o[o.ObjectAssign=8]="ObjectAssign",o[o.BigIntTypedArray=16]="BigIntTypedArray",o))(A||{});function f(n,e){if(!n)throw e}function Ar(n){switch(n){case'"':return'\\"';case"\\":return"\\\\";case`
2
+ `:return"\\n";case"\r":return"\\r";case"\b":return"\\b";case" ":return"\\t";case"\f":return"\\f";case"<":return"\\x3C";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:return}}function d(n){let e="",r=0,t;for(let s=0,o=n.length;s<o;s++)t=Ar(n[s]),t&&(e+=n.slice(r,s)+t,r=s+1);return r===0?e=n:e+=n.slice(r),e}function Ir(n){switch(n){case"\\\\":return"\\";case'\\"':return'"';case"\\n":return`
3
+ `;case"\\r":return"\r";case"\\b":return"\b";case"\\t":return" ";case"\\f":return"\f";case"\\x3C":return"<";case"\\u2028":return"\u2028";case"\\u2029":return"\u2029";default:return n}}function y(n){return n.replace(/(\\\\|\\"|\\n|\\r|\\b|\\t|\\f|\\u2028|\\u2029|\\x3C)/g,Ir)}var I="__SEROVAL_REFS__",G="$R",ie=`self.${G}`;function We(n){return n==null?`${ie}=${ie}||[]`:`(${ie}=${ie}||{})["${d(n)}"]=[]`}var De=new Map,w=new Map;function Ke(n,e){return De.set(e,n),w.set(n,e),e}function ae(n){return De.has(n)}function wr(n){return w.has(n)}function Le(n){return f(ae(n),new H(n)),De.get(n)}function Je(n){return f(wr(n),new q(n)),w.get(n)}typeof globalThis!="undefined"?Object.defineProperty(globalThis,I,{value:w,configurable:!0,writable:!1,enumerable:!1}):typeof window!="undefined"?Object.defineProperty(window,I,{value:w,configurable:!0,writable:!1,enumerable:!1}):typeof self!="undefined"?Object.defineProperty(self,I,{value:w,configurable:!0,writable:!1,enumerable:!1}):typeof global!="undefined"&&Object.defineProperty(global,I,{value:w,configurable:!0,writable:!1,enumerable:!1});function Rr(n){return n}function $e(n,e){for(let r=0,t=e.length;r<t;r++){let s=e[r];n.has(s)||(n.add(s),s.extends&&$e(n,s.extends))}}function c(n){if(n){let e=new Set;return $e(e,n),[...e]}}var Ye={0:"Symbol.asyncIterator",1:"Symbol.hasInstance",2:"Symbol.isConcatSpreadable",3:"Symbol.iterator",4:"Symbol.match",5:"Symbol.matchAll",6:"Symbol.replace",7:"Symbol.search",8:"Symbol.species",9:"Symbol.split",10:"Symbol.toPrimitive",11:"Symbol.toStringTag",12:"Symbol.unscopables"},le={[Symbol.asyncIterator]:0,[Symbol.hasInstance]:1,[Symbol.isConcatSpreadable]:2,[Symbol.iterator]:3,[Symbol.match]:4,[Symbol.matchAll]:5,[Symbol.replace]:6,[Symbol.search]:7,[Symbol.species]:8,[Symbol.split]:9,[Symbol.toPrimitive]:10,[Symbol.toStringTag]:11,[Symbol.unscopables]:12},Ge={0:Symbol.asyncIterator,1:Symbol.hasInstance,2:Symbol.isConcatSpreadable,3:Symbol.iterator,4:Symbol.match,5:Symbol.matchAll,6:Symbol.replace,7:Symbol.search,8:Symbol.species,9:Symbol.split,10:Symbol.toPrimitive,11:Symbol.toStringTag,12:Symbol.unscopables},He={2:"!0",3:"!1",1:"void 0",0:"null",4:"-0",5:"1/0",6:"-1/0",7:"0/0"},qe={2:!0,3:!1,1:void 0,0:null,4:-0,5:1/0,6:-1/0,7:NaN};var ue={0:"Error",1:"EvalError",2:"RangeError",3:"ReferenceError",4:"SyntaxError",5:"TypeError",6:"URIError"},Ze={0:Error,1:EvalError,2:RangeError,3:ReferenceError,4:SyntaxError,5:TypeError,6:URIError};function v(n){return{t:2,i:void 0,s:n,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}var N=v(2),b=v(3),de=v(1),ce=v(0),Xe=v(4),Qe=v(5),er=v(6),rr=v(7);function fe(n){return n instanceof EvalError?1:n instanceof RangeError?2:n instanceof ReferenceError?3:n instanceof SyntaxError?4:n instanceof TypeError?5:n instanceof URIError?6:0}function Er(n){let e=ue[fe(n)];return n.name!==e?{name:n.name}:n.constructor.name!==e?{name:n.constructor.name}:{}}function D(n,e){let r=Er(n),t=Object.getOwnPropertyNames(n);for(let s=0,o=t.length,i;s<o;s++)i=t[s],i!=="name"&&i!=="message"&&(i==="stack"?e&4&&(r=r||{},r[i]=n[i]):(r=r||{},r[i]=n[i]));return r}function pe(n){return Object.isFrozen(n)?3:Object.isSealed(n)?2:Object.isExtensible(n)?0:1}function me(n){switch(n){case 1/0:return Qe;case-1/0:return er}return n!==n?rr:Object.is(n,-0)?Xe:{t:0,i:void 0,s:n,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function x(n){return{t:1,i:void 0,s:d(n),l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function ge(n){return{t:3,i:void 0,s:""+n,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function nr(n){return{t:4,i:n,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function Se(n,e){return{t:5,i:n,s:e.toISOString(),l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,f:void 0,a:void 0,b:void 0,o:void 0}}function he(n,e){return{t:6,i:n,s:void 0,l:void 0,c:d(e.source),m:e.flags,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function ye(n,e){let r=new Uint8Array(e),t=r.length,s=new Array(t);for(let o=0;o<t;o++)s[o]=r[o];return{t:19,i:n,s,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function sr(n,e){return{t:17,i:n,s:le[e],l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function Ve(n,e){return{t:18,i:n,s:d(Le(e)),l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function V(n,e,r){return{t:25,i:n,s:r,l:void 0,c:d(e),m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function ve(n,e,r){return{t:9,i:n,s:void 0,l:e.length,c:void 0,m:void 0,p:void 0,e:void 0,a:r,f:void 0,b:void 0,o:pe(e)}}function Ne(n,e){return{t:21,i:n,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:e,b:void 0,o:void 0}}function be(n,e,r){return{t:15,i:n,s:void 0,l:e.length,c:e.constructor.name,m:void 0,p:void 0,e:void 0,a:void 0,f:r,b:e.byteOffset,o:void 0}}function xe(n,e,r){return{t:16,i:n,s:void 0,l:e.length,c:e.constructor.name,m:void 0,p:void 0,e:void 0,a:void 0,f:r,b:e.byteOffset,o:void 0}}function Ae(n,e,r){return{t:20,i:n,s:void 0,l:e.byteLength,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:r,b:e.byteOffset,o:void 0}}function Ie(n,e,r){return{t:13,i:n,s:fe(e),l:void 0,c:void 0,m:d(e.message),p:r,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function we(n,e,r){return{t:14,i:n,s:fe(e),l:void 0,c:void 0,m:d(e.message),p:r,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}function Re(n,e,r){return{t:7,i:n,s:void 0,l:e,c:void 0,m:void 0,p:void 0,e:void 0,a:r,f:void 0,b:void 0,o:void 0}}function B(n,e){return{t:28,i:void 0,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:[n,e],f:void 0,b:void 0,o:void 0}}function j(n,e){return{t:30,i:void 0,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:[n,e],f:void 0,b:void 0,o:void 0}}function _(n,e,r){return{t:31,i:n,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:r,f:e,b:void 0,o:void 0}}function Ee(n,e){return{t:32,i:n,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:e,b:void 0,o:void 0}}function Pe(n,e){return{t:33,i:n,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:e,b:void 0,o:void 0}}function Ce(n,e){return{t:34,i:n,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:e,b:void 0,o:void 0}}function M(n){let e=[],r=-1,t=-1,s=n[Symbol.iterator]();for(;;)try{let o=s.next();if(e.push(o.value),o.done){t=e.length-1;break}}catch(o){r=e.length,e.push(o)}return{v:e,t:r,d:t}}function or(n){return()=>{let e=0;return{[Symbol.iterator](){return this},next(){if(e>n.d)return{done:!0,value:void 0};let r=e++,t=n.v[r];if(r===n.t)throw t;return{done:r===n.d,value:t}}}}}var ir={},ar={};var lr={0:{},1:{},2:{},3:{},4:{}};var{toString:Be}=Object.prototype;function Pr(n,e){return e instanceof Error?`Seroval caught an error during the ${n} process.
4
+
5
+ ${e.name}
6
+ ${e.message}
7
+
8
+ - For more information, please check the "cause" property of this error.
9
+ - If you believe this is an error in Seroval, please submit an issue at https://github.com/lxsmnsyc/seroval/issues/new`:`Seroval caught an error during the ${n} process.
10
+
11
+ "${Be.call(e)}"
12
+
13
+ For more information, please check the "cause" property of this error.`}var U=class extends Error{constructor(r,t){super(Pr(r,t));this.cause=t}},E=class extends U{constructor(e){super("parsing",e)}},Z=class extends U{constructor(e){super("serialization",e)}},X=class extends U{constructor(e){super("deserialization",e)}},p=class extends Error{constructor(r){super(`The value ${Be.call(r)} of type "${typeof r}" cannot be parsed/serialized.
14
+
15
+ There are few workarounds for this problem:
16
+ - Transform the value in a way that it can be serialized.
17
+ - If the reference is present on multiple runtimes (isomorphic), you can use the Reference API to map the references.`);this.value=r}},m=class extends Error{constructor(e){super('Unsupported node type "'+e.t+'".')}},P=class extends Error{constructor(e){super('Missing plugin for tag "'+e+'".')}},g=class extends Error{constructor(e){super('Missing "'+e+'" instance.')}},H=class extends Error{constructor(r){super('Missing reference for the value "'+Be.call(r)+'" of type "'+typeof r+'"');this.value=r}},q=class extends Error{constructor(e){super('Missing reference for id "'+d(e)+'"')}},Q=class extends Error{constructor(e){super('Unknown TypedArray "'+e+'"')}};var W=class{constructor(e){this.marked=new Set;this.plugins=e.plugins,this.features=31^(e.disabledFeatures||0),this.refs=e.refs||new Map}markRef(e){this.marked.add(e)}isMarked(e){return this.marked.has(e)}getIndexedValue(e){let r=this.refs.get(e);if(r!=null)return this.markRef(r),{type:1,value:nr(r)};let t=this.refs.size;return this.refs.set(e,t),{type:0,value:t}}getReference(e){let r=this.getIndexedValue(e);return r.type===1?r:ae(e)?{type:2,value:Ve(r.value,e)}:r}getStrictReference(e){f(ae(e),new p(e));let r=this.getIndexedValue(e);return r.type===1?r.value:Ve(r.value,e)}parseFunction(e){return this.getStrictReference(e)}parseWellKnownSymbol(e){let r=this.getReference(e);return r.type!==0?r.value:(f(e in le,new p(e)),sr(r.value,e))}parseSpecialReference(e){let r=this.getIndexedValue(lr[e]);return r.type===1?r.value:{t:26,i:r.value,s:e,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:void 0,b:void 0,o:void 0}}parseIteratorFactory(){let e=this.getIndexedValue(ir);return e.type===1?e.value:{t:27,i:e.value,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:this.parseWellKnownSymbol(Symbol.iterator),b:void 0,o:void 0}}parseAsyncIteratorFactory(){let e=this.getIndexedValue(ar);return e.type===1?e.value:{t:29,i:e.value,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:[this.parseSpecialReference(1),this.parseWellKnownSymbol(Symbol.asyncIterator)],f:void 0,b:void 0,o:void 0}}createObjectNode(e,r,t,s){return{t:t?11:10,i:e,s:void 0,l:void 0,c:void 0,m:void 0,p:s,e:void 0,a:void 0,f:void 0,b:void 0,o:pe(r)}}createMapNode(e,r,t,s){return{t:8,i:e,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:{k:r,v:t,s},a:void 0,f:this.parseSpecialReference(0),b:void 0,o:void 0}}createPromiseConstructorNode(e){return{t:22,i:e,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:this.parseSpecialReference(1),b:void 0,o:void 0}}};async function je(n){try{return[1,await n]}catch(e){return[0,e]}}function ee(){let n,e;return{promise:new Promise((r,t)=>{n=r,e=t}),resolve(r){n(r)},reject(r){e(r)}}}function ze(n){return"__SEROVAL_STREAM__"in n}function C(){let n=new Set,e=[],r=!0,t=!1;function s(a){for(let l of n.keys())l.next(a)}function o(a){for(let l of n.keys())l.throw(a)}function i(a){for(let l of n.keys())l.return(a)}return{__SEROVAL_STREAM__:!0,on(a){r&&n.add(a);for(let l=0,u=e.length;l<u;l++){let h=e[l];l===u-1?t?a.return(h):a.throw(h):a.next(h)}return()=>{r&&n.delete(a)}},next(a){r&&(e.push(a),s(a))},throw(a){r&&(e.push(a),o(a),r=!1,t=!1,n.clear())},return(a){r&&(e.push(a),i(a),r=!1,t=!0,n.clear())}}}function Te(n){let e=C(),r=n[Symbol.asyncIterator]();async function t(){try{let s=await r.next();s.done?e.return(s.value):(e.next(s.value),await t())}catch(s){e.throw(s)}}return t().catch(()=>{}),e}function ur(n){return()=>{let e=[],r=[],t=0,s=-1,o=!1;function i(){for(let l=0,u=r.length;l<u;l++)r[l].resolve({done:!0,value:void 0})}n.on({next(l){let u=r.shift();u&&u.resolve({done:!1,value:l}),e.push(l)},throw(l){let u=r.shift();u&&u.reject(l),i(),s=e.length,e.push(l),o=!0},return(l){let u=r.shift();u&&u.resolve({done:!0,value:l}),i(),s=e.length,e.push(l)}});function a(){let l=t++,u=e[l];if(l!==s)return{done:!1,value:u};if(o)throw u;return{done:!0,value:u}}return{[Symbol.asyncIterator](){return this},async next(){if(s===-1){let l=t++;if(l>=e.length){let u=ee();return r.push(u),await u.promise}return{done:!1,value:e[l]}}return t>s?{done:!0,value:void 0}:a()}}}}var O=class extends W{async parseItems(e){let r=[];for(let t=0,s=e.length;t<s;t++)t in e&&(r[t]=await this.parse(e[t]));return r}async parseArray(e,r){return ve(e,r,await this.parseItems(r))}async parseProperties(e){let r=Object.entries(e),t=[],s=[];for(let i=0,a=r.length;i<a;i++)t.push(d(r[i][0])),s.push(await this.parse(r[i][1]));let o=Symbol.iterator;return o in e&&(t.push(this.parseWellKnownSymbol(o)),s.push(B(this.parseIteratorFactory(),await this.parse(M(e))))),o=Symbol.asyncIterator,o in e&&(t.push(this.parseWellKnownSymbol(o)),s.push(j(this.parseAsyncIteratorFactory(),await this.parse(Te(e))))),o=Symbol.toStringTag,o in e&&(t.push(this.parseWellKnownSymbol(o)),s.push(x(e[o]))),o=Symbol.isConcatSpreadable,o in e&&(t.push(this.parseWellKnownSymbol(o)),s.push(e[o]?N:b)),{k:t,v:s,s:t.length}}async parsePlainObject(e,r,t){return this.createObjectNode(e,r,t,await this.parseProperties(r))}async parseBoxed(e,r){return Ne(e,await this.parse(r.valueOf()))}async parseTypedArray(e,r){return be(e,r,await this.parse(r.buffer))}async parseBigIntTypedArray(e,r){return xe(e,r,await this.parse(r.buffer))}async parseDataView(e,r){return Ae(e,r,await this.parse(r.buffer))}async parseError(e,r){let t=D(r,this.features);return Ie(e,r,t?await this.parseProperties(t):void 0)}async parseAggregateError(e,r){let t=D(r,this.features);return we(e,r,t?await this.parseProperties(t):void 0)}async parseMap(e,r){let t=[],s=[];for(let[o,i]of r.entries())t.push(await this.parse(o)),s.push(await this.parse(i));return this.createMapNode(e,t,s,r.size)}async parseSet(e,r){let t=[];for(let s of r.keys())t.push(await this.parse(s));return Re(e,r.size,t)}async parsePromise(e,r){let[t,s]=await je(r);return{t:12,i:e,s:t,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:void 0,f:await this.parse(s),b:void 0,o:void 0}}async parsePlugin(e,r){let t=this.plugins;if(t)for(let s=0,o=t.length;s<o;s++){let i=t[s];if(i.parse.async&&i.test(r))return V(e,i.tag,await i.parse.async(r,this,{id:e}))}}async parseStream(e,r){return _(e,this.parseSpecialReference(4),await new Promise((t,s)=>{let o=[],i=r.on({next:a=>{this.markRef(e),this.parse(a).then(l=>{o.push(Ee(e,l))},l=>{s(l),i()})},throw:a=>{this.markRef(e),this.parse(a).then(l=>{o.push(Pe(e,l)),t(o),i()},l=>{s(l),i()})},return:a=>{this.markRef(e),this.parse(a).then(l=>{o.push(Ce(e,l)),t(o),i()},l=>{s(l),i()})}})}))}async parseObject(e,r){if(Array.isArray(r))return this.parseArray(e,r);if(ze(r))return this.parseStream(e,r);let t=await this.parsePlugin(e,r);if(t)return t;let s=r.constructor;switch(s){case Object:return this.parsePlainObject(e,r,!1);case void 0:return this.parsePlainObject(e,r,!0);case Date:return Se(e,r);case RegExp:return he(e,r);case Error:case EvalError:case RangeError:case ReferenceError:case SyntaxError:case TypeError:case URIError:return this.parseError(e,r);case Number:case Boolean:case String:case BigInt:return this.parseBoxed(e,r);case ArrayBuffer:return ye(e,r);case Int8Array:case Int16Array:case Int32Array:case Uint8Array:case Uint16Array:case Uint32Array:case Uint8ClampedArray:case Float32Array:case Float64Array:return this.parseTypedArray(e,r);case DataView:return this.parseDataView(e,r);case Map:return this.parseMap(e,r);case Set:return this.parseSet(e,r);default:break}if(s===Promise||r instanceof Promise)return this.parsePromise(e,r);let o=this.features;if(o&16)switch(s){case BigInt64Array:case BigUint64Array:return this.parseBigIntTypedArray(e,r);default:break}if(o&1&&typeof AggregateError!="undefined"&&(s===AggregateError||r instanceof AggregateError))return this.parseAggregateError(e,r);if(r instanceof Error)return this.parseError(e,r);if(Symbol.iterator in r||Symbol.asyncIterator in r)return this.parsePlainObject(e,r,!!s);throw new p(r)}async parse(e){try{switch(typeof e){case"boolean":return e?N:b;case"undefined":return de;case"string":return x(e);case"number":return me(e);case"bigint":return ge(e);case"object":{if(e){let r=this.getReference(e);return r.type===0?await this.parseObject(r.value,e):r.value}return ce}case"symbol":return this.parseWellKnownSymbol(e);case"function":return this.parseFunction(e);default:throw new p(e)}}catch(r){throw new E(r)}}};var K=class extends O{constructor(){super(...arguments);this.mode="vanilla"}};function dr(n){switch(n){case"Int8Array":return Int8Array;case"Int16Array":return Int16Array;case"Int32Array":return Int32Array;case"Uint8Array":return Uint8Array;case"Uint16Array":return Uint16Array;case"Uint32Array":return Uint32Array;case"Uint8ClampedArray":return Uint8ClampedArray;case"Float32Array":return Float32Array;case"Float64Array":return Float64Array;case"BigInt64Array":return BigInt64Array;case"BigUint64Array":return BigUint64Array;default:throw new Q(n)}}function cr(n,e){switch(e){case 3:return Object.freeze(n);case 1:return Object.preventExtensions(n);case 2:return Object.seal(n);default:return n}}var z=class{constructor(e){this.plugins=e.plugins,this.refs=e.refs||new Map}deserializeReference(e){return this.assignIndexedValue(e.i,Je(y(e.s)))}deserializeArray(e){let r=e.l,t=this.assignIndexedValue(e.i,new Array(r)),s;for(let o=0;o<r;o++)s=e.a[o],s&&(t[o]=this.deserialize(s));return cr(t,e.o),t}deserializeProperties(e,r){let t=e.s;if(t){let s=e.k,o=e.v;for(let i=0,a;i<t;i++)a=s[i],typeof a=="string"?r[y(a)]=this.deserialize(o[i]):r[this.deserialize(a)]=this.deserialize(o[i])}return r}deserializeObject(e){let r=this.assignIndexedValue(e.i,e.t===10?{}:Object.create(null));return this.deserializeProperties(e.p,r),cr(r,e.o),r}deserializeDate(e){return this.assignIndexedValue(e.i,new Date(e.s))}deserializeRegExp(e){return this.assignIndexedValue(e.i,new RegExp(y(e.c),e.m))}deserializeSet(e){let r=this.assignIndexedValue(e.i,new Set),t=e.a;for(let s=0,o=e.l;s<o;s++)r.add(this.deserialize(t[s]));return r}deserializeMap(e){let r=this.assignIndexedValue(e.i,new Map),t=e.e.k,s=e.e.v;for(let o=0,i=e.e.s;o<i;o++)r.set(this.deserialize(t[o]),this.deserialize(s[o]));return r}deserializeArrayBuffer(e){let r=new Uint8Array(e.s);return this.assignIndexedValue(e.i,r.buffer)}deserializeTypedArray(e){let r=dr(e.c),t=this.deserialize(e.f);return this.assignIndexedValue(e.i,new r(t,e.b,e.l))}deserializeDataView(e){let r=this.deserialize(e.f);return this.assignIndexedValue(e.i,new DataView(r,e.b,e.l))}deserializeDictionary(e,r){if(e.p){let t=this.deserializeProperties(e.p,{});Object.assign(r,t)}return r}deserializeAggregateError(e){let r=this.assignIndexedValue(e.i,new AggregateError([],y(e.m)));return this.deserializeDictionary(e,r)}deserializeError(e){let r=Ze[e.s],t=this.assignIndexedValue(e.i,new r(y(e.m)));return this.deserializeDictionary(e,t)}deserializePromise(e){let r=ee(),t=this.assignIndexedValue(e.i,r),s=this.deserialize(e.f);return e.s?r.resolve(s):r.reject(s),t.promise}deserializeBoxed(e){return this.assignIndexedValue(e.i,Object(this.deserialize(e.f)))}deserializePlugin(e){let r=this.plugins;if(r){let t=y(e.c);for(let s=0,o=r.length;s<o;s++){let i=r[s];if(i.tag===t)return this.assignIndexedValue(e.i,i.deserialize(e.s,this,{id:e.i}))}}throw new P(e.c)}deserializePromiseConstructor(e){return this.assignIndexedValue(e.i,ee()).promise}deserializePromiseResolve(e){let r=this.refs.get(e.i);f(r,new g("Promise")),r.resolve(this.deserialize(e.a[1]))}deserializePromiseReject(e){let r=this.refs.get(e.i);f(r,new g("Promise")),r.reject(this.deserialize(e.a[1]))}deserializeIteratorFactoryInstance(e){this.deserialize(e.a[0]);let r=this.deserialize(e.a[1]);return or(r)}deserializeAsyncIteratorFactoryInstance(e){this.deserialize(e.a[0]);let r=this.deserialize(e.a[1]);return ur(r)}deserializeStreamConstructor(e){let r=this.assignIndexedValue(e.i,C()),t=e.a.length;if(t)for(let s=0;s<t;s++)this.deserialize(e.a[s]);return r}deserializeStreamNext(e){let r=this.refs.get(e.i);f(r,new g("Stream")),r.next(this.deserialize(e.f))}deserializeStreamThrow(e){let r=this.refs.get(e.i);f(r,new g("Stream")),r.throw(this.deserialize(e.f))}deserializeStreamReturn(e){let r=this.refs.get(e.i);f(r,new g("Stream")),r.return(this.deserialize(e.f))}deserializeIteratorFactory(e){this.deserialize(e.f)}deserializeAsyncIteratorFactory(e){this.deserialize(e.a[1])}deserialize(e){try{switch(e.t){case 2:return qe[e.s];case 0:return e.s;case 1:return y(e.s);case 3:return BigInt(e.s);case 4:return this.refs.get(e.i);case 18:return this.deserializeReference(e);case 9:return this.deserializeArray(e);case 10:case 11:return this.deserializeObject(e);case 5:return this.deserializeDate(e);case 6:return this.deserializeRegExp(e);case 7:return this.deserializeSet(e);case 8:return this.deserializeMap(e);case 19:return this.deserializeArrayBuffer(e);case 16:case 15:return this.deserializeTypedArray(e);case 20:return this.deserializeDataView(e);case 14:return this.deserializeAggregateError(e);case 13:return this.deserializeError(e);case 12:return this.deserializePromise(e);case 17:return Ge[e.s];case 21:return this.deserializeBoxed(e);case 25:return this.deserializePlugin(e);case 22:return this.deserializePromiseConstructor(e);case 23:return this.deserializePromiseResolve(e);case 24:return this.deserializePromiseReject(e);case 28:return this.deserializeIteratorFactoryInstance(e);case 30:return this.deserializeAsyncIteratorFactoryInstance(e);case 31:return this.deserializeStreamConstructor(e);case 32:return this.deserializeStreamNext(e);case 33:return this.deserializeStreamThrow(e);case 34:return this.deserializeStreamReturn(e);case 27:return this.deserializeIteratorFactory(e);case 29:return this.deserializeAsyncIteratorFactory(e);default:throw new m(e)}}catch(r){throw new X(r)}}};var re=class extends z{constructor(r){super(r);this.mode="vanilla";this.marked=new Set(r.markedRefs)}assignIndexedValue(r,t){return this.marked.has(r)&&this.refs.set(r,t),t}};var Or=/^[$A-Z_][0-9A-Z_$]*$/i;function _e(n){let e=n[0];return(e==="$"||e==="_"||e>="A"&&e<="Z"||e>="a"&&e<="z")&&Or.test(n)}function te(n){switch(n.t){case 0:return n.s+"="+n.v;case 2:return n.s+".set("+n.k+","+n.v+")";case 1:return n.s+".add("+n.v+")";case 3:return n.s+".delete("+n.k+")"}}function zr(n){let e=[],r=n[0];for(let t=1,s=n.length,o,i=r;t<s;t++)o=n[t],o.t===0&&o.v===i.v?r={t:0,s:o.s,k:void 0,v:te(r)}:o.t===2&&o.s===i.s?r={t:2,s:te(r),k:o.k,v:o.v}:o.t===1&&o.s===i.s?r={t:1,s:te(r),k:void 0,v:o.v}:o.t===3&&o.s===i.s?r={t:3,s:te(r),k:o.k,v:void 0}:(e.push(r),r=o),i=o;return e.push(r),e}function fr(n){if(n.length){let e="",r=zr(n);for(let t=0,s=r.length;t<s;t++)e+=te(r[t])+",";return e}}var Tr="Object.create(null)",kr="new Set",Fr="new Map",Dr="Promise.resolve",Vr="Promise.reject",Br={3:"Object.freeze",2:"Object.seal",1:"Object.preventExtensions",0:void 0},T=class{constructor(e){this.stack=[];this.flags=[];this.assignments=[];this.plugins=e.plugins,this.features=e.features,this.marked=new Set(e.markedRefs)}createFunction(e,r){return this.features&2?(e.length===1?e[0]:"("+e.join(",")+")")+"=>"+r:"function("+e.join(",")+"){return "+r+"}"}createEffectfulFunction(e,r){return this.features&2?(e.length===1?e[0]:"("+e.join(",")+")")+"=>{"+r+"}":"function("+e.join(",")+"){"+r+"}"}markRef(e){this.marked.add(e)}isMarked(e){return this.marked.has(e)}pushObjectFlag(e,r){e!==0&&(this.markRef(r),this.flags.push({type:e,value:this.getRefParam(r)}))}resolveFlags(){let e="";for(let r=0,t=this.flags,s=t.length;r<s;r++){let o=t[r];e+=Br[o.type]+"("+o.value+"),"}return e}resolvePatches(){let e=fr(this.assignments),r=this.resolveFlags();return e?r?e+r:e:r}createAssignment(e,r){this.assignments.push({t:0,s:e,k:void 0,v:r})}createAddAssignment(e,r){this.assignments.push({t:1,s:this.getRefParam(e),k:void 0,v:r})}createSetAssignment(e,r,t){this.assignments.push({t:2,s:this.getRefParam(e),k:r,v:t})}createDeleteAssignment(e,r){this.assignments.push({t:3,s:this.getRefParam(e),k:r,v:void 0})}createArrayAssign(e,r,t){this.createAssignment(this.getRefParam(e)+"["+r+"]",t)}createObjectAssign(e,r,t){this.createAssignment(this.getRefParam(e)+"."+r,t)}isIndexedValueInStack(e){return e.t===4&&this.stack.includes(e.i)}serializeReference(e){return this.assignIndexedValue(e.i,I+'.get("'+e.s+'")')}serializeArrayItem(e,r,t){return r?this.isIndexedValueInStack(r)?(this.markRef(e),this.createArrayAssign(e,t,this.getRefParam(r.i)),""):this.serialize(r):""}serializeArray(e){let r=e.i;if(e.l){this.stack.push(r);let t=e.a,s=this.serializeArrayItem(r,t[0],0),o=s==="";for(let i=1,a=e.l,l;i<a;i++)l=this.serializeArrayItem(r,t[i],i),s+=","+l,o=l==="";return this.stack.pop(),this.pushObjectFlag(e.o,e.i),this.assignIndexedValue(r,"["+s+(o?",]":"]"))}return this.assignIndexedValue(r,"[]")}serializeProperty(e,r,t){if(typeof r=="string"){let s=Number(r),o=s>=0&&s.toString()===r||_e(r);if(this.isIndexedValueInStack(t)){let i=this.getRefParam(t.i);return this.markRef(e.i),o&&s!==s?this.createObjectAssign(e.i,r,i):this.createArrayAssign(e.i,o?r:'"'+r+'"',i),""}return(o?r:'"'+r+'"')+":"+this.serialize(t)}return"["+this.serialize(r)+"]:"+this.serialize(t)}serializeProperties(e,r){let t=r.s;if(t){let s=r.k,o=r.v;this.stack.push(e.i);let i=this.serializeProperty(e,s[0],o[0]);for(let a=1,l=i;a<t;a++)l=this.serializeProperty(e,s[a],o[a]),i+=(l&&i&&",")+l;return this.stack.pop(),"{"+i+"}"}return"{}"}serializeObject(e){return this.pushObjectFlag(e.o,e.i),this.assignIndexedValue(e.i,this.serializeProperties(e,e.p))}serializeWithObjectAssign(e,r,t){let s=this.serializeProperties(e,r);return s!=="{}"?"Object.assign("+t+","+s+")":t}serializeStringKeyAssignment(e,r,t,s){let o=this.serialize(s),i=Number(t),a=i>=0&&i.toString()===t||_e(t);if(this.isIndexedValueInStack(s))a&&i!==i?this.createObjectAssign(e.i,t,o):this.createArrayAssign(e.i,a?t:'"'+t+'"',o);else{let l=this.assignments;this.assignments=r,a&&i!==i?this.createObjectAssign(e.i,t,o):this.createArrayAssign(e.i,a?t:'"'+t+'"',o),this.assignments=l}}serializeAssignment(e,r,t,s){if(typeof t=="string")this.serializeStringKeyAssignment(e,r,t,s);else{let o=this.stack;this.stack=[];let i=this.serialize(s);this.stack=o;let a=this.assignments;this.assignments=r,this.createArrayAssign(e.i,this.serialize(t),i),this.assignments=a}}serializeAssignments(e,r){let t=r.s;if(t){let s=[],o=r.k,i=r.v;this.stack.push(e.i);for(let a=0;a<t;a++)this.serializeAssignment(e,s,o[a],i[a]);return this.stack.pop(),fr(s)}}serializeDictionary(e,r){if(e.p)if(this.features&8)r=this.serializeWithObjectAssign(e,e.p,r);else{this.markRef(e.i);let t=this.serializeAssignments(e,e.p);if(t)return"("+this.assignIndexedValue(e.i,r)+","+t+this.getRefParam(e.i)+")"}return this.assignIndexedValue(e.i,r)}serializeNullConstructor(e){return this.pushObjectFlag(e.o,e.i),this.serializeDictionary(e,Tr)}serializeDate(e){return this.assignIndexedValue(e.i,'new Date("'+e.s+'")')}serializeRegExp(e){return this.assignIndexedValue(e.i,"/"+e.c+"/"+e.m)}serializeSetItem(e,r){return this.isIndexedValueInStack(r)?(this.markRef(e),this.createAddAssignment(e,this.getRefParam(r.i)),""):this.serialize(r)}serializeSet(e){let r=kr,t=e.l,s=e.i;if(t){let o=e.a;this.stack.push(s);let i=this.serializeSetItem(s,o[0]);for(let a=1,l=i;a<t;a++)l=this.serializeSetItem(s,o[a]),i+=(l&&i&&",")+l;this.stack.pop(),i&&(r+="(["+i+"])")}return this.assignIndexedValue(s,r)}serializeMapEntry(e,r,t,s){if(this.isIndexedValueInStack(r)){let o=this.getRefParam(r.i);if(this.markRef(e),this.isIndexedValueInStack(t)){let a=this.getRefParam(t.i);return this.createSetAssignment(e,o,a),""}if(t.t!==4&&t.i!=null&&this.isMarked(t.i)){let a="("+this.serialize(t)+",["+s+","+s+"])";return this.createSetAssignment(e,o,this.getRefParam(t.i)),this.createDeleteAssignment(e,s),a}let i=this.stack;return this.stack=[],this.createSetAssignment(e,o,this.serialize(t)),this.stack=i,""}if(this.isIndexedValueInStack(t)){let o=this.getRefParam(t.i);if(this.markRef(e),r.t!==4&&r.i!=null&&this.isMarked(r.i)){let a="("+this.serialize(r)+",["+s+","+s+"])";return this.createSetAssignment(e,this.getRefParam(r.i),o),this.createDeleteAssignment(e,s),a}let i=this.stack;return this.stack=[],this.createSetAssignment(e,this.serialize(r),o),this.stack=i,""}return"["+this.serialize(r)+","+this.serialize(t)+"]"}serializeMap(e){let r=Fr,t=e.e.s,s=e.i,o=e.f,i=this.getRefParam(o.i);if(t){let a=e.e.k,l=e.e.v;this.stack.push(s);let u=this.serializeMapEntry(s,a[0],l[0],i);for(let h=1,ke=u;h<t;h++)ke=this.serializeMapEntry(s,a[h],l[h],i),u+=(ke&&u&&",")+ke;this.stack.pop(),u&&(r+="(["+u+"])")}return o.t===26&&(this.markRef(o.i),r="("+this.serialize(o)+","+r+")"),this.assignIndexedValue(s,r)}serializeArrayBuffer(e){let r="new Uint8Array(",t=e.s,s=t.length;if(s){r+="["+t[0];for(let o=1;o<s;o++)r+=","+t[o];r+="]"}return this.assignIndexedValue(e.i,r+").buffer")}serializeTypedArray(e){return this.assignIndexedValue(e.i,"new "+e.c+"("+this.serialize(e.f)+","+e.b+","+e.l+")")}serializeDataView(e){return this.assignIndexedValue(e.i,"new DataView("+this.serialize(e.f)+","+e.b+","+e.l+")")}serializeAggregateError(e){let r=e.i;this.stack.push(r);let t=this.serializeDictionary(e,'new AggregateError([],"'+e.m+'")');return this.stack.pop(),t}serializeError(e){return this.serializeDictionary(e,"new "+ue[e.s]+'("'+e.m+'")')}serializePromise(e){let r,t=e.f,s=e.i,o=e.s?Dr:Vr;if(this.isIndexedValueInStack(t)){let i=this.getRefParam(t.i);r=o+(e.s?"().then("+this.createFunction([],i)+")":"().catch("+this.createEffectfulFunction([],"throw "+i)+")")}else{this.stack.push(s);let i=this.serialize(t);this.stack.pop(),r=o+"("+i+")"}return this.assignIndexedValue(s,r)}serializeWellKnownSymbol(e){return this.assignIndexedValue(e.i,Ye[e.s])}serializeBoxed(e){return this.assignIndexedValue(e.i,"Object("+this.serialize(e.f)+")")}serializePlugin(e){let r=this.plugins;if(r)for(let t=0,s=r.length;t<s;t++){let o=r[t];if(o.tag===e.c)return this.assignIndexedValue(e.i,o.serialize(e.s,this,{id:e.i}))}throw new P(e.c)}getConstructor(e){let r=this.serialize(e);return r===this.getRefParam(e.i)?r:"("+r+")"}serializePromiseConstructor(e){return this.assignIndexedValue(e.i,this.getConstructor(e.f)+"()")}serializePromiseResolve(e){return this.getConstructor(e.a[0])+"("+this.getRefParam(e.i)+","+this.serialize(e.a[1])+")"}serializePromiseReject(e){return this.getConstructor(e.a[0])+"("+this.getRefParam(e.i)+","+this.serialize(e.a[1])+")"}serializeSpecialReferenceValue(e){switch(e){case 0:return"[]";case 1:return this.createFunction(["s","f","p"],"((p=new Promise("+this.createEffectfulFunction(["a","b"],"s=a,f=b")+")).s=s,p.f=f,p)");case 2:return this.createEffectfulFunction(["p","d"],'p.s(d),p.status="success",p.value=d;delete p.s;delete p.f');case 3:return this.createEffectfulFunction(["p","d"],'p.f(d),p.status="failure",p.value=d;delete p.s;delete p.f');case 4:return this.createFunction(["b","a","s","l","p","f","e","n"],"(b=[],a=!0,s=!1,l=[],p=0,f="+this.createEffectfulFunction(["v","m","x"],"for(x=0;x<p;x++)l[x]&&l[x][m](v)")+",n="+this.createEffectfulFunction(["o","x","z","c"],'for(x=0,z=b.length;x<z;x++)(c=b[x],x===z-1?o[s?"return":"throw"](c):o.next(c))')+",e="+this.createFunction(["o","t"],"(a&&(l[t=p++]=o),n(o),"+this.createEffectfulFunction([],"a&&(l[t]=void 0)")+")")+",{__SEROVAL_STREAM__:!0,on:"+this.createFunction(["o"],"e(o)")+",next:"+this.createEffectfulFunction(["v"],'a&&(b.push(v),f(v,"next"))')+",throw:"+this.createEffectfulFunction(["v"],'a&&(b.push(v),f(v,"throw"),a=s=!1,l.length=0)')+",return:"+this.createEffectfulFunction(["v"],'a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)')+"})");default:return""}}serializeSpecialReference(e){return this.assignIndexedValue(e.i,this.serializeSpecialReferenceValue(e.s))}serializeIteratorFactory(e){let r="",t=!1;return e.f.t!==4&&(this.markRef(e.f.i),r="("+this.serialize(e.f)+",",t=!0),r+=this.assignIndexedValue(e.i,this.createFunction(["s"],this.createFunction(["i","c","d","t"],"(i=0,t={["+this.getRefParam(e.f.i)+"]:"+this.createFunction([],"t")+",next:"+this.createEffectfulFunction([],"if(i>s.d)return{done:!0,value:void 0};if(d=s.v[c=i++],c===s.t)throw d;return{done:c===s.d,value:d}")+"})"))),t&&(r+=")"),r}serializeIteratorFactoryInstance(e){return this.getConstructor(e.a[0])+"("+this.serialize(e.a[1])+")"}serializeAsyncIteratorFactory(e){let r=e.a[0],t=e.a[1],s="";r.t!==4&&(this.markRef(r.i),s+="("+this.serialize(r)),t.t!==4&&(this.markRef(t.i),s+=(s?",":"(")+this.serialize(t)),s&&(s+=",");let o=this.assignIndexedValue(e.i,this.createFunction(["s"],this.createFunction(["b","c","p","d","e","t","f"],"(b=[],c=0,p=[],d=-1,e=!1,f="+this.createEffectfulFunction(["i","l"],"for(i=0,l=p.length;i<l;i++)p[i].s({done:!0,value:void 0})")+",s.on({next:"+this.createEffectfulFunction(["v","t"],"if(t=p.shift())t.s({done:!1,value:v});b.push(v)")+",throw:"+this.createEffectfulFunction(["v","t"],"if(t=p.shift())t.f(v);f(),d=b.length,e=!0,b.push(v)")+",return:"+this.createEffectfulFunction(["v","t"],"if(t=p.shift())t.s({done:!0,value:v});f(),d=b.length,b.push(v)")+"}),t={["+this.getRefParam(t.i)+"]:"+this.createFunction([],"t")+",next:"+this.createEffectfulFunction(["i","t","v"],"if(d===-1){return((i=c++)>=b.length)?(p.push(t="+this.getRefParam(r.i)+"()),t):{done:!0,value:b[i]}}if(c>d)return{done:!0,value:void 0};if(v=b[i=c++],i!==d)return{done:!1,value:v};if(e)throw v;return{done:!0,value:v}")+"})")));return s?s+o+")":o}serializeAsyncIteratorFactoryInstance(e){return this.getConstructor(e.a[0])+"("+this.serialize(e.a[1])+")"}serializeStreamConstructor(e){let r=this.assignIndexedValue(e.i,this.getConstructor(e.f)+"()"),t=e.a.length;if(t){let s=this.serialize(e.a[0]);for(let o=1;o<t;o++)s+=","+this.serialize(e.a[o]);return"("+r+","+s+","+this.getRefParam(e.i)+")"}return r}serializeStreamNext(e){return this.getRefParam(e.i)+".next("+this.serialize(e.f)+")"}serializeStreamThrow(e){return this.getRefParam(e.i)+".throw("+this.serialize(e.f)+")"}serializeStreamReturn(e){return this.getRefParam(e.i)+".return("+this.serialize(e.f)+")"}serialize(e){try{switch(e.t){case 2:return He[e.s];case 0:return""+e.s;case 1:return'"'+e.s+'"';case 3:return e.s+"n";case 4:return this.getRefParam(e.i);case 18:return this.serializeReference(e);case 9:return this.serializeArray(e);case 10:return this.serializeObject(e);case 11:return this.serializeNullConstructor(e);case 5:return this.serializeDate(e);case 6:return this.serializeRegExp(e);case 7:return this.serializeSet(e);case 8:return this.serializeMap(e);case 19:return this.serializeArrayBuffer(e);case 16:case 15:return this.serializeTypedArray(e);case 20:return this.serializeDataView(e);case 14:return this.serializeAggregateError(e);case 13:return this.serializeError(e);case 12:return this.serializePromise(e);case 17:return this.serializeWellKnownSymbol(e);case 21:return this.serializeBoxed(e);case 22:return this.serializePromiseConstructor(e);case 23:return this.serializePromiseResolve(e);case 24:return this.serializePromiseReject(e);case 25:return this.serializePlugin(e);case 26:return this.serializeSpecialReference(e);case 27:return this.serializeIteratorFactory(e);case 28:return this.serializeIteratorFactoryInstance(e);case 29:return this.serializeAsyncIteratorFactory(e);case 30:return this.serializeAsyncIteratorFactoryInstance(e);case 31:return this.serializeStreamConstructor(e);case 32:return this.serializeStreamNext(e);case 33:return this.serializeStreamThrow(e);case 34:return this.serializeStreamReturn(e);default:throw new m(e)}}catch(r){throw new Z(r)}}};var gr="hjkmoquxzABCDEFGHIJKLNPQRTUVWXYZ$_",pr=gr.length,Sr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_",mr=Sr.length;function Me(n){let e=n%pr,r=gr[e];for(n=(n-e)/pr;n>0;)e=n%mr,r+=Sr[e],n=(n-e)/mr;return r}var k=class extends T{constructor(){super(...arguments);this.mode="vanilla";this.valid=new Map;this.vars=[]}getRefParam(r){let t=this.valid.get(r);t==null&&(t=this.valid.size,this.valid.set(r,t));let s=this.vars[t];return s==null&&(s=Me(t),this.vars[t]=s),s}assignIndexedValue(r,t){return this.isMarked(r)?this.getRefParam(r)+"="+t:t}serializePromiseConstructor(r){throw new m(r)}serializePromiseResolve(r){throw new m(r)}serializePromiseReject(r){throw new m(r)}serializeTop(r){let t=this.serialize(r);if(r.i!=null&&this.vars.length){let s=this.resolvePatches(),o=t;if(s){let i=this.getRefParam(r.i);o=t+","+s+i,t.startsWith(i+"=")||(o=i+"="+o)}return"("+this.createFunction(this.vars,"("+o+")")+")()"}return r.t===10?"("+t+")":t}};var S=class extends W{parseItems(e){let r=[];for(let t=0,s=e.length;t<s;t++)t in e&&(r[t]=this.parse(e[t]));return r}parseArray(e,r){return ve(e,r,this.parseItems(r))}parseProperties(e){let r=Object.entries(e),t=[],s=[];for(let i=0,a=r.length;i<a;i++)t.push(d(r[i][0])),s.push(this.parse(r[i][1]));let o=Symbol.iterator;return o in e&&(t.push(this.parseWellKnownSymbol(o)),s.push(B(this.parseIteratorFactory(),this.parse(M(e))))),o=Symbol.asyncIterator,o in e&&(t.push(this.parseWellKnownSymbol(o)),s.push(j(this.parseAsyncIteratorFactory(),this.parse(C())))),o=Symbol.toStringTag,o in e&&(t.push(this.parseWellKnownSymbol(o)),s.push(x(e[o]))),o=Symbol.isConcatSpreadable,o in e&&(t.push(this.parseWellKnownSymbol(o)),s.push(e[o]?N:b)),{k:t,v:s,s:t.length}}parsePlainObject(e,r,t){return this.createObjectNode(e,r,t,this.parseProperties(r))}parseBoxed(e,r){return Ne(e,this.parse(r.valueOf()))}parseTypedArray(e,r){return be(e,r,this.parse(r.buffer))}parseBigIntTypedArray(e,r){return xe(e,r,this.parse(r.buffer))}parseDataView(e,r){return Ae(e,r,this.parse(r.buffer))}parseError(e,r){let t=D(r,this.features);return Ie(e,r,t?this.parseProperties(t):void 0)}parseAggregateError(e,r){let t=D(r,this.features);return we(e,r,t?this.parseProperties(t):void 0)}parseMap(e,r){let t=[],s=[];for(let[o,i]of r.entries())t.push(this.parse(o)),s.push(this.parse(i));return this.createMapNode(e,t,s,r.size)}parseSet(e,r){let t=[];for(let s of r.keys())t.push(this.parse(s));return Re(e,r.size,t)}parsePlugin(e,r){let t=this.plugins;if(t)for(let s=0,o=t.length;s<o;s++){let i=t[s];if(i.parse.sync&&i.test(r))return V(e,i.tag,i.parse.sync(r,this,{id:e}))}}parseStream(e,r){return _(e,this.parseSpecialReference(4),[])}parsePromise(e,r){return this.createPromiseConstructorNode(e)}parseObject(e,r){if(Array.isArray(r))return this.parseArray(e,r);if(ze(r))return this.parseStream(e,r);let t=this.parsePlugin(e,r);if(t)return t;let s=r.constructor;switch(s){case Object:return this.parsePlainObject(e,r,!1);case void 0:return this.parsePlainObject(e,r,!0);case Date:return Se(e,r);case RegExp:return he(e,r);case Error:case EvalError:case RangeError:case ReferenceError:case SyntaxError:case TypeError:case URIError:return this.parseError(e,r);case Number:case Boolean:case String:case BigInt:return this.parseBoxed(e,r);case ArrayBuffer:return ye(e,r);case Int8Array:case Int16Array:case Int32Array:case Uint8Array:case Uint16Array:case Uint32Array:case Uint8ClampedArray:case Float32Array:case Float64Array:return this.parseTypedArray(e,r);case DataView:return this.parseDataView(e,r);case Map:return this.parseMap(e,r);case Set:return this.parseSet(e,r);default:break}if(s===Promise||r instanceof Promise)return this.parsePromise(e,r);let o=this.features;if(o&16)switch(s){case BigInt64Array:case BigUint64Array:return this.parseBigIntTypedArray(e,r);default:break}if(o&1&&typeof AggregateError!="undefined"&&(s===AggregateError||r instanceof AggregateError))return this.parseAggregateError(e,r);if(r instanceof Error)return this.parseError(e,r);if(Symbol.iterator in r||Symbol.asyncIterator in r)return this.parsePlainObject(e,r,!!s);throw new p(r)}parse(e){try{switch(typeof e){case"boolean":return e?N:b;case"undefined":return de;case"string":return x(e);case"number":return me(e);case"bigint":return ge(e);case"object":{if(e){let r=this.getReference(e);return r.type===0?this.parseObject(r.value,e):r.value}return ce}case"symbol":return this.parseWellKnownSymbol(e);case"function":return this.parseFunction(e);default:throw new p(e)}}catch(r){throw new E(r)}}};var L=class extends S{constructor(){super(...arguments);this.mode="vanilla"}};function jr(n,e={}){let r=c(e.plugins),t=new L({plugins:r,disabledFeatures:e.disabledFeatures}),s=t.parse(n);return new k({plugins:r,features:t.features,markedRefs:t.marked}).serializeTop(s)}async function _r(n,e={}){let r=c(e.plugins),t=new K({plugins:r,disabledFeatures:e.disabledFeatures}),s=await t.parse(n);return new k({plugins:r,features:t.features,markedRefs:t.marked}).serializeTop(s)}function Mr(n){return(0,eval)(n)}function Ur(n,e={}){let r=c(e.plugins),t=new L({plugins:r,disabledFeatures:e.disabledFeatures});return{t:t.parse(n),f:t.features,m:Array.from(t.marked)}}async function Wr(n,e={}){let r=c(e.plugins),t=new K({plugins:r,disabledFeatures:e.disabledFeatures});return{t:await t.parse(n),f:t.features,m:Array.from(t.marked)}}function Kr(n,e={}){let r=c(e.plugins);return new k({plugins:r,features:n.f,markedRefs:n.m}).serializeTop(n.t)}function Lr(n,e={}){let r=c(e.plugins);return new re({plugins:r,markedRefs:n.m}).deserialize(n.t)}var J=class extends O{constructor(){super(...arguments);this.mode="cross"}};var ne=class extends z{constructor(){super(...arguments);this.mode="cross"}assignIndexedValue(r,t){return this.refs.has(r)||this.refs.set(r,t),t}};var F=class extends T{constructor(r){super(r);this.mode="cross";this.scopeId=r.scopeId}getRefParam(r){return G+"["+r+"]"}assignIndexedValue(r,t){return this.getRefParam(r)+"="+t}serializeTop(r){let t=this.serialize(r),s=r.i;if(s==null)return t;let o=this.resolvePatches(),i=this.getRefParam(s),a=this.scopeId==null?"":G,l=o?t+","+o+i:t;if(a==="")return o?"("+l+")":l;let u=this.scopeId==null?"()":"("+G+'["'+d(this.scopeId)+'"])';return"("+this.createFunction([a],l)+")"+u}};var se=class extends S{constructor(r){super(r);this.alive=!0;this.pending=0;this.initial=!0;this.buffer=[];this.onParseCallback=r.onParse,this.onErrorCallback=r.onError,this.onDoneCallback=r.onDone}onParseInternal(r,t){try{this.onParseCallback(r,t)}catch(s){this.onError(s)}}flush(){for(let r=0,t=this.buffer.length;r<t;r++)this.onParseInternal(this.buffer[r],!1)}onParse(r){this.initial?this.buffer.push(r):this.onParseInternal(r,!1)}onError(r){if(this.onErrorCallback)this.onErrorCallback(r);else throw r}onDone(){this.onDoneCallback&&this.onDoneCallback()}pushPendingState(){this.pending++}popPendingState(){--this.pending<=0&&this.onDone()}parseProperties(r){let t=Object.entries(r),s=[],o=[];for(let a=0,l=t.length;a<l;a++)s.push(d(t[a][0])),o.push(this.parse(t[a][1]));let i=Symbol.iterator;return i in r&&(s.push(this.parseWellKnownSymbol(i)),o.push(B(this.parseIteratorFactory(),this.parse(M(r))))),i=Symbol.asyncIterator,i in r&&(s.push(this.parseWellKnownSymbol(i)),o.push(j(this.parseAsyncIteratorFactory(),this.parse(Te(r))))),i=Symbol.toStringTag,i in r&&(s.push(this.parseWellKnownSymbol(i)),o.push(x(r[i]))),i=Symbol.isConcatSpreadable,i in r&&(s.push(this.parseWellKnownSymbol(i)),o.push(r[i]?N:b)),{k:s,v:o,s:s.length}}parsePromise(r,t){return t.then(s=>{let o=this.parseWithError(s);o&&this.onParse({t:23,i:r,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:[this.parseSpecialReference(2),o],f:void 0,b:void 0,o:void 0}),this.popPendingState()},s=>{if(this.alive){let o=this.parseWithError(s);o&&this.onParse({t:24,i:r,s:void 0,l:void 0,c:void 0,m:void 0,p:void 0,e:void 0,a:[this.parseSpecialReference(3),o],f:void 0,b:void 0,o:void 0})}this.popPendingState()}),this.pushPendingState(),this.createPromiseConstructorNode(r)}parsePlugin(r,t){let s=this.plugins;if(s)for(let o=0,i=s.length;o<i;o++){let a=s[o];if(a.parse.stream&&a.test(t))return V(r,a.tag,a.parse.stream(t,this,{id:r}))}}parseStream(r,t){let s=_(r,this.parseSpecialReference(4),[]);return this.pushPendingState(),t.on({next:o=>{if(this.alive){let i=this.parseWithError(o);i&&this.onParse(Ee(r,i))}},throw:o=>{if(this.alive){let i=this.parseWithError(o);i&&this.onParse(Pe(r,i))}this.popPendingState()},return:o=>{if(this.alive){let i=this.parseWithError(o);i&&this.onParse(Ce(r,i))}this.popPendingState()}}),s}parseWithError(r){try{return this.parse(r)}catch(t){this.onError(t);return}}start(r){let t=this.parseWithError(r);t&&(this.onParseInternal(t,!0),this.initial=!1,this.flush(),this.pending<=0&&this.destroy())}destroy(){this.alive&&(this.onDone(),this.alive=!1)}isAlive(){return this.alive}};var $=class extends se{constructor(){super(...arguments);this.mode="cross"}};var Y=class extends S{constructor(){super(...arguments);this.mode="cross"}};function Jr(n,e={}){let r=c(e.plugins),t=new Y({plugins:r,disabledFeatures:e.disabledFeatures,refs:e.refs}),s=t.parse(n);return new F({plugins:r,features:t.features,scopeId:e.scopeId,markedRefs:t.marked}).serializeTop(s)}async function $r(n,e={}){let r=c(e.plugins),t=new J({plugins:r,disabledFeatures:e.disabledFeatures,refs:e.refs}),s=await t.parse(n);return new F({plugins:r,features:t.features,scopeId:e.scopeId,markedRefs:t.marked}).serializeTop(s)}function Yr(n,e={}){let r=c(e.plugins);return new Y({plugins:r,disabledFeatures:e.disabledFeatures,refs:e.refs}).parse(n)}async function Gr(n,e={}){let r=c(e.plugins);return await new J({plugins:r,disabledFeatures:e.disabledFeatures,refs:e.refs}).parse(n)}function Ue(n,e){let r=c(e.plugins),t=new $({plugins:r,refs:e.refs,disabledFeatures:e.disabledFeatures,onParse(s,o){let i=new F({plugins:r,features:t.features,scopeId:e.scopeId,markedRefs:t.marked}),a;try{a=i.serializeTop(s)}catch(l){e.onError&&e.onError(l);return}e.onSerialize(a,o)},onError:e.onError,onDone:e.onDone});return t.start(n),()=>{t.destroy()}}function Hr(n,e){let r=c(e.plugins),t=new $({plugins:r,refs:e.refs,disabledFeatures:e.disabledFeatures,onParse:e.onParse,onError:e.onError,onDone:e.onDone});return t.start(n),()=>{t.destroy()}}function qr(n,e){let r=c(e.plugins);return new ne({plugins:r,refs:e.refs}).deserialize(n)}var oe=class{constructor(e){this.options=e;this.alive=!0;this.flushed=!1;this.done=!1;this.pending=0;this.cleanups=[];this.refs=new Map;this.keys=new Set;this.ids=0;this.plugins=c(e.plugins)}write(e,r){this.alive&&!this.flushed&&(this.pending++,this.keys.add(e),this.cleanups.push(Ue(r,{plugins:this.plugins,scopeId:this.options.scopeId,refs:this.refs,disabledFeatures:this.options.disabledFeatures,onError:this.options.onError,onSerialize:(t,s)=>{this.alive&&this.options.onData(s?this.options.globalIdentifier+'["'+d(e)+'"]='+t:t)},onDone:()=>{this.alive&&(this.pending--,this.pending<=0&&this.flushed&&!this.done&&this.options.onDone&&(this.options.onDone(),this.done=!0))}})))}getNextID(){for(;this.keys.has(""+this.ids);)this.ids++;return""+this.ids}push(e){let r=this.getNextID();return this.write(r,e),r}flush(){this.alive&&(this.flushed=!0,this.pending<=0&&!this.done&&this.options.onDone&&(this.options.onDone(),this.done=!0))}close(){if(this.alive){for(let e=0,r=this.cleanups.length;e<r;e++)this.cleanups[e]();!this.done&&this.options.onDone&&(this.options.onDone(),this.done=!0),this.alive=!1}}};