"use strict";var De=Object.defineProperty;var Nr=Object.getOwnPropertyDescriptor;var Ar=Object.getOwnPropertyNames;var xr=Object.prototype.hasOwnProperty;var Ir=(o,e)=>{for(var r in e)De(o,r,{get:e[r],enumerable:!0})},wr=(o,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ar(e))!xr.call(o,n)&&n!==r&&De(o,n,{get:()=>e[n],enumerable:!(t=Nr(e,n))||t.enumerable});return o};var Er=o=>wr(De({},"__esModule",{value:!0}),o);var ot={};Ir(ot,{Feature:()=>R,OpaqueReference:()=>E,Serializer:()=>ce,SerovalDeserializationError:()=>te,SerovalError:()=>W,SerovalMissingInstanceError:()=>y,SerovalMissingPluginError:()=>O,SerovalMissingReferenceError:()=>Q,SerovalMissingReferenceForIdError:()=>ee,SerovalParserError:()=>z,SerovalSerializationError:()=>re,SerovalUnknownTypedArrayError:()=>se,SerovalUnsupportedNodeError:()=>g,SerovalUnsupportedTypeError:()=>S,compileJSON:()=>tt,createPlugin:()=>zr,createReference:()=>Je,createStream:()=>T,crossSerialize:()=>Jr,crossSerializeAsync:()=>Yr,crossSerializeStream:()=>Le,deserialize:()=>Qr,fromCrossJSON:()=>Hr,fromJSON:()=>st,getCrossReferenceHeader:()=>Ke,resolvePlugins:()=>f,serialize:()=>Zr,serializeAsync:()=>Xr,toCrossJSON:()=>$r,toCrossJSONAsync:()=>Gr,toCrossJSONStream:()=>qr,toJSON:()=>et,toJSONAsync:()=>rt});module.exports=Er(ot);var R=(i=>(i[i.AggregateError=1]="AggregateError",i[i.ArrowFunction=2]="ArrowFunction",i[i.ErrorPrototypeStack=4]="ErrorPrototypeStack",i[i.ObjectAssign=8]="ObjectAssign",i[i.BigIntTypedArray=16]="BigIntTypedArray",i[i.AbortSignal=32]="AbortSignal",i))(R||{});function Rr(o){switch(o){case'"':return'\\"';case"\\":return"\\\\";case` `: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 p(o){let e="",r=0,t;for(let n=0,a=o.length;n{o=r,e=t}),resolve(r){o(r)},reject(r){e(r)}}}function ke(o){return"__SEROVAL_STREAM__"in o}function T(){let o=new Set,e=[],r=!0,t=!0;function n(l){for(let c of o.keys())c.next(l)}function a(l){for(let c of o.keys())c.throw(l)}function i(l){for(let c of o.keys())c.return(l)}return{__SEROVAL_STREAM__:!0,on(l){r&&o.add(l);for(let c=0,d=e.length;c{r&&o.delete(l)}},next(l){r&&(e.push(l),n(l))},throw(l){r&&(e.push(l),a(l),r=!1,t=!1,o.clear())},return(l){r&&(e.push(l),i(l),r=!1,t=!0,o.clear())}}}function Fe(o){let e=T(),r=o[Symbol.asyncIterator]();async function t(){try{let n=await r.next();n.done?e.return(n.value):(e.next(n.value),await t())}catch(n){e.throw(n)}}return t().catch(()=>{}),e}function pr(o){return()=>{let e=[],r=[],t=0,n=-1,a=!1;function i(){for(let c=0,d=r.length;c=e.length){let d=oe();return r.push(d),await d.promise}return{done:!1,value:e[c]}}return t>n?{done:!0,value:void 0}:l()}}}}function K(o){let e=[],r=-1,t=-1,n=o[Symbol.iterator]();for(;;)try{let a=n.next();if(e.push(a.value),a.done){t=e.length-1;break}}catch(a){r=e.length,e.push(a)}return{v:e,t:r,d:t}}function fr(o){return()=>{let e=0;return{[Symbol.iterator](){return this},next(){if(e>o.d)return{done:!0,value:s};let r=e++,t=o.v[r];if(r===o.t)throw t;return{done:r===o.d,value:t}}}}}async function Me(o){try{return[1,await o]}catch(e){return[0,e]}}var J=class{constructor(e){this.marked=new Set;this.plugins=e.plugins,this.features=47^(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:ar(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:je(e)?{type:2,value:lr(r.value,e)}:r}parseWellKnownSymbol(e){let r=this.getReference(e);return r.type!==0?r.value:(m(e in de,new S(e)),ir(r.value,e))}parseSpecialReference(e){let r=this.getIndexedValue(dr[e]);return r.type===1?r.value:u(26,r.value,e,s,s,s,s,s,s,s,s,s)}parseIteratorFactory(){let e=this.getIndexedValue(cr);return e.type===1?e.value:u(27,e.value,s,s,s,s,s,s,s,this.parseWellKnownSymbol(Symbol.iterator),s,s)}parseAsyncIteratorFactory(){let e=this.getIndexedValue(ur);return e.type===1?e.value:u(29,e.value,s,s,s,s,s,s,[this.parseSpecialReference(1),this.parseWellKnownSymbol(Symbol.asyncIterator)],s,s,s)}createObjectNode(e,r,t,n){return u(t?11:10,e,s,s,s,s,n,s,s,s,s,ge(r))}createMapNode(e,r,t,n){return u(8,e,s,s,s,s,s,{k:r,v:t,s:n},s,this.parseSpecialReference(0),s,s)}createPromiseConstructorNode(e){return u(22,e,s,s,s,s,s,s,s,this.parseSpecialReference(1),s,s)}createAbortSignalConstructorNode(e){return u(35,e,s,s,s,s,s,s,s,this.parseSpecialReference(5),s,s)}};var k=class extends J{async parseItems(e){let r=[];for(let t=0,n=e.length;t{let a=[],i=r.on({next:l=>{this.markRef(e),this.parse(l).then(c=>{a.push(ze(e,c))},c=>{n(c),i()})},throw:l=>{this.markRef(e),this.parse(l).then(c=>{a.push(Oe(e,c)),t(a),i()},c=>{n(c),i()})},return:l=>{this.markRef(e),this.parse(l).then(c=>{a.push(Te(e,c)),t(a),i()},c=>{n(c),i()})}})}))}async parseAbortSignalSync(e,r){return u(37,e,s,s,s,s,s,s,s,await this.parse(r.reason),s,s)}async parseAbortSignal(e,r){return r.aborted||await qe(r),this.parseAbortSignalSync(e,r)}async parseObject(e,r){if(Array.isArray(r))return this.parseArray(e,r);if(ke(r))return this.parseStream(e,r);let t=r.constructor;if(t===E)return this.parse(r.replacement);let n=await this.parsePlugin(e,r);if(n)return n;switch(t){case Object:return this.parsePlainObject(e,r,!1);case s:return this.parsePlainObject(e,r,!0);case Date:return ve(e,r);case RegExp:return be(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 Ne(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(t===Promise||r instanceof Promise)return this.parsePromise(e,r);let a=this.features;if(a&32&&typeof AbortSignal!="undefined"&&t===AbortSignal)return this.parseAbortSignal(e,r);if(a&16)switch(t){case BigInt64Array:case BigUint64Array:return this.parseBigIntTypedArray(e,r);default:break}if(a&1&&typeof AggregateError!="undefined"&&(t===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,!!t);throw new S(r)}async parseFunction(e){let r=this.getReference(e);if(r.type!==0)return r.value;let t=await this.parsePlugin(r.value,e);if(t)return t;throw new S(e)}async parse(e){try{switch(typeof e){case"boolean":return e?x:I;case"undefined":return fe;case"string":return w(e);case"number":return he(e);case"bigint":return ye(e);case"object":{if(e){let r=this.getReference(e);return r.type===0?await this.parseObject(r.value,e):r.value}return me}case"symbol":return this.parseWellKnownSymbol(e);case"function":return this.parseFunction(e);default:throw new S(e)}}catch(r){throw new z(r)}}};var Y=class extends k{constructor(){super(...arguments);this.mode="cross"}};function mr(o){switch(o){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 se(o)}}function Sr(o,e){switch(e){case 3:return Object.freeze(o);case 1:return Object.preventExtensions(o);case 2:return Object.seal(o);default:return o}}var F=class{constructor(e){this.plugins=e.plugins,this.refs=e.refs||new Map}deserializeReference(e){return this.assignIndexedValue(e.i,$e(N(e.s)))}deserializeArray(e){let r=e.l,t=this.assignIndexedValue(e.i,new Array(r)),n;for(let a=0;a="A"&&e<="Z"||e>="a"&&e<="z")&&Br.test(o)}function ae(o){switch(o.t){case 0:return o.s+"="+o.v;case 2:return o.s+".set("+o.k+","+o.v+")";case 1:return o.s+".add("+o.v+")";case 3:return o.s+".delete("+o.k+")"}}function jr(o){let e=[],r=o[0];for(let t=1,n=o.length,a,i=r;t"+(r.startsWith("{")?"("+r+")":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,n=t.length;r=0&&n.toString()===r||Ue(r);if(this.isIndexedValueInStack(t)){let i=this.getRefParam(t.i);return this.markRef(e.i),a&&n!==n?this.createObjectAssign(e.i,r,i):this.createArrayAssign(e.i,a?r:'"'+r+'"',i),""}return(a?r:'"'+r+'"')+":"+this.serialize(t)}return"["+this.serialize(r)+"]:"+this.serialize(t)}serializeProperties(e,r){let t=r.s;if(t){let n=r.k,a=r.v;this.stack.push(e.i);let i=this.serializeProperty(e,n[0],a[0]);for(let l=1,c=i;l=0&&i.toString()===t||Ue(t);if(this.isIndexedValueInStack(n))l&&i!==i?this.createObjectAssign(e.i,t,a):this.createArrayAssign(e.i,l?t:'"'+t+'"',a);else{let c=this.assignments;this.assignments=r,l&&i!==i?this.createObjectAssign(e.i,t,a):this.createArrayAssign(e.i,l?t:'"'+t+'"',a),this.assignments=c}}serializeAssignment(e,r,t,n){if(typeof t=="string")this.serializeStringKeyAssignment(e,r,t,n);else{let a=this.stack;this.stack=[];let i=this.serialize(n);this.stack=a;let l=this.assignments;this.assignments=r,this.createArrayAssign(e.i,this.serialize(t),i),this.assignments=l}}serializeAssignments(e,r){let t=r.s;if(t){let n=[],a=r.k,i=r.v;this.stack.push(e.i);for(let l=0;ls.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],n="";r.t!==4&&(this.markRef(r.i),n+="("+this.serialize(r)),t.t!==4&&(this.markRef(t.i),n+=(n?",":"(")+this.serialize(t)),n&&(n+=",");let a=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=b.length)?(p.push(t="+this.getRefParam(r.i)+"()),t):{done:!1,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 n?n+a+")":a}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 n=this.serialize(e.a[0]);for(let a=1;a{let a=this.parseWithError(n);a&&this.onParse(u(23,r,s,s,s,s,s,s,[this.parseSpecialReference(2),a],s,s,s)),this.popPendingState()},n=>{if(this.alive){let a=this.parseWithError(n);a&&this.onParse(u(24,r,s,s,s,s,s,s,[this.parseSpecialReference(3),a],s,s,s))}this.popPendingState()}),this.pushPendingState(),this.createPromiseConstructorNode(r)}parsePlugin(r,t){let n=this.plugins;if(n)for(let a=0,i=n.length;a{if(this.alive){let i=this.parseWithError(a);i&&this.onParse(ze(r,i))}},throw:a=>{if(this.alive){let i=this.parseWithError(a);i&&this.onParse(Oe(r,i))}this.popPendingState()},return:a=>{if(this.alive){let i=this.parseWithError(a);i&&this.onParse(Te(r,i))}this.popPendingState()}}),n}handleAbortSignal(r,t){if(this.alive){let n=this.parseWithError(t.reason);n&&this.onParse(u(36,r,s,s,s,s,s,s,[this.parseSpecialReference(6),n],s,s,s))}this.popPendingState()}parseAbortSignal(r,t){return t.aborted?this.parseAbortSignalSync(r,t):(this.pushPendingState(),t.addEventListener("abort",this.handleAbortSignal.bind(this,r,t),{once:!0}),this.createAbortSignalConstructorNode(r))}parseWithError(r){try{return this.parse(r)}catch(t){return this.onError(t),s}}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 ie{constructor(){super(...arguments);this.mode="cross"}};var G=class extends b{constructor(){super(...arguments);this.mode="cross"}};function Jr(o,e={}){let r=f(e.plugins),t=new G({plugins:r,disabledFeatures:e.disabledFeatures,refs:e.refs}),n=t.parse(o);return new D({plugins:r,features:t.features,scopeId:e.scopeId,markedRefs:t.marked}).serializeTop(n)}async function Yr(o,e={}){let r=f(e.plugins),t=new Y({plugins:r,disabledFeatures:e.disabledFeatures,refs:e.refs}),n=await t.parse(o);return new D({plugins:r,features:t.features,scopeId:e.scopeId,markedRefs:t.marked}).serializeTop(n)}function $r(o,e={}){let r=f(e.plugins);return new G({plugins:r,disabledFeatures:e.disabledFeatures,refs:e.refs}).parse(o)}async function Gr(o,e={}){let r=f(e.plugins);return await new Y({plugins:r,disabledFeatures:e.disabledFeatures,refs:e.refs}).parse(o)}function Le(o,e){let r=f(e.plugins),t=new $({plugins:r,refs:e.refs,disabledFeatures:e.disabledFeatures,onParse(n,a){let i=new D({plugins:r,features:t.features,scopeId:e.scopeId,markedRefs:t.marked}),l;try{l=i.serializeTop(n)}catch(c){e.onError&&e.onError(c);return}e.onSerialize(l,a)},onError:e.onError,onDone:e.onDone});return t.start(o),t.destroy.bind(t)}function qr(o,e){let r=f(e.plugins),t=new $({plugins:r,refs:e.refs,disabledFeatures:e.disabledFeatures,onParse:e.onParse,onError:e.onError,onDone:e.onDone});return t.start(o),t.destroy.bind(t)}function Hr(o,e){let r=f(e.plugins);return new ne({plugins:r,refs:e.refs}).deserialize(o)}var q=class extends k{constructor(){super(...arguments);this.mode="vanilla"}};var le=class extends F{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="hjkmoquxzABCDEFGHIJKLNPQRTUVWXYZ$_",hr=vr.length,br="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_",yr=br.length;function We(o){let e=o%hr,r=vr[e];for(o=(o-e)/hr;o>0;)e=o%yr,r+=br[e],o=(o-e)/yr;return r}var B=class extends V{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 n=this.vars[t];return n==null&&(n=We(t),this.vars[t]=n),n}assignIndexedValue(r,t){return this.isMarked(r)?this.getRefParam(r)+"="+t:t}serializePromiseConstructor(r){throw new g(r)}serializePromiseResolve(r){throw new g(r)}serializePromiseReject(r){throw new g(r)}serializeAbortSignalAbort(r){throw new g(r)}serializeTop(r){let t=this.serialize(r);if(r.i!=null&&this.vars.length){let n=this.resolvePatches(),a=t;if(n){let i=this.getRefParam(r.i);a=t+","+n+i,t.startsWith(i+"=")||(a=i+"="+a),a="("+a+")"}return"("+this.createFunction(this.vars,a)+")()"}return r.t===10?"("+t+")":t}};var H=class extends b{constructor(){super(...arguments);this.mode="vanilla"}};function Zr(o,e={}){let r=f(e.plugins),t=new H({plugins:r,disabledFeatures:e.disabledFeatures}),n=t.parse(o);return new B({plugins:r,features:t.features,markedRefs:t.marked}).serializeTop(n)}async function Xr(o,e={}){let r=f(e.plugins),t=new q({plugins:r,disabledFeatures:e.disabledFeatures}),n=await t.parse(o);return new B({plugins:r,features:t.features,markedRefs:t.marked}).serializeTop(n)}function Qr(o){return(0,eval)(o)}function et(o,e={}){let r=f(e.plugins),t=new H({plugins:r,disabledFeatures:e.disabledFeatures});return{t:t.parse(o),f:t.features,m:Array.from(t.marked)}}async function rt(o,e={}){let r=f(e.plugins),t=new q({plugins:r,disabledFeatures:e.disabledFeatures});return{t:await t.parse(o),f:t.features,m:Array.from(t.marked)}}function tt(o,e={}){let r=f(e.plugins);return new B({plugins:r,features:o.f,markedRefs:o.m}).serializeTop(o.t)}function st(o,e={}){let r=f(e.plugins);return new le({plugins:r,markedRefs:o.m}).deserialize(o.t)}var ce=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=f(e.plugins)}write(e,r){this.alive&&!this.flushed&&(this.pending++,this.keys.add(e),this.cleanups.push(Le(r,{plugins:this.plugins,scopeId:this.options.scopeId,refs:this.refs,disabledFeatures:this.options.disabledFeatures,onError:this.options.onError,onSerialize:(t,n)=>{this.alive&&this.options.onData(n?this.options.globalIdentifier+'["'+p(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