var mi=ArrayBuffer,N=Uint8Array,De=Uint16Array,_i=Int16Array;var Ge=Int32Array,ur=function(n,i,s){if(N.prototype.slice)return N.prototype.slice.call(n,i,s);(i==null||i<0)&&(i=0),(s==null||s>n.length)&&(s=n.length);var c=new N(s-i);return c.set(n.subarray(i,s)),c},Re=function(n,i,s,c){if(N.prototype.fill)return N.prototype.fill.call(n,i,s,c);for((s==null||s<0)&&(s=0),(c==null||c>n.length)&&(c=n.length);sn.length)&&(c=n.length);s2046MB)","invalid block type","FSE accuracy too high","match distance too far back","unexpected EOF"],k=function(n,i,s){var c=new Error(i||bi[n]);if(c.code=n,Error.captureStackTrace&&Error.captureStackTrace(c,k),!s)throw c;return c},Lr=function(n,i,s){for(var c=0,l=0;c>>0},Mi=function(n,i){var s=n[0]|n[1]<<8|n[2]<<16;if(s==3126568&&n[3]==253){var c=n[4],l=c>>5&1,p=c>>2&1,h=c&3,d=c>>6;c&8&&k(0);var U=6-l,C=h==3?4:h,M=Lr(n,U,C);U+=C;var Q=d?1<>3);R=Z+(Z>>3)*(n[5]&7)}R>2145386496&&k(1);var b=new N((i==1?x||R:i?0:R)+12);return b[0]=1,b[4]=4,b[8]=8,{b:U+Q,y:0,l:0,d:M,w:i&&i!=1?i:b.subarray(12),e:R,o:new Ge(b.buffer,0,3),u:x,c:p,m:Math.min(131072,R)}}else if((s>>4|n[3]<<20)==25481893)return Ci(n,4)+8;k(0)},me=function(n){for(var i=0;1<s&&k(3);for(var p=1<0;){var V=me(h+1),K=c>>3,ie=(1<>(c&7)&ie,y=(1<y&&($-=L)),x[++d]=--$,$==-1?(h+=$,q[--M]=d):h-=$,!$)do{var W=c>>3;U=(n[W]|n[W+1]<<8)>>(c&7)&3,c+=2,d+=U}while(U==3)}(d>255||h)&&k(0);for(var Y=0,A=(p>>1)+(p>>3)+3,ee=p-1,D=0;D<=d;++D){var P=x[D];if(P<1){R[D]=-P;continue}for(C=0;C=M)}}for(Y&&k(0),C=0;C>3,{b:l,s:q,n:te,t:Z}]},Pi=function(n,i){var s=0,c=-1,l=new N(292),p=n[i],h=l.subarray(0,256),d=l.subarray(256,268),U=new De(l.buffer,268);if(p<128){var C=$e(n,i+1,6),M=C[0],Q=C[1];i+=p;var x=M<<3,R=n[i];R||k(0);for(var Z=0,b=0,q=Q.b,te=q,V=(++i<<3)-8+me(R);V-=q,!(V>3;if(Z+=(n[K]|n[K+1]<<8)>>(V&7)&(1<>3,b+=(n[K]|n[K+1]<<8)>>(V&7)&(1<255&&k(0)}else{for(c=p-127;s>4,h[s+1]=ie&15}++i}var $=0;for(s=0;s11&&k(0),$+=y&&1<0;--s){var D=U[s];Re(ee,s,D,U[s-1]=D+d[s]*(1<d&&Q>3,R=(n[x]|n[x+1]<<8|n[x+2]<<16)>>(M&7);U=(U<>2,h=p<<1,d=p+h;qe(n.subarray(c,c+=n[0]|n[1]<<8),i.subarray(0,p),s),qe(n.subarray(c,c+=n[2]|n[3]<<8),i.subarray(p,h),s),qe(n.subarray(c,c+=n[4]|n[5]<<8),i.subarray(h,d),s),qe(n.subarray(c),i.subarray(d),s)},qi=function(n,i,s){var c,l=i.b,p=n[l],h=p>>1&3;i.l=p&1;var d=p>>3|n[l+1]<<5|n[l+2]<<13,U=(l+=3)+d;if(h==1)return l>=n.length?void 0:(i.b=l+1,s?(Re(s,n[l],i.y,i.y+=d),s):Re(new N(d),n[l]));if(!(U>n.length)){if(h==0)return i.b=U,s?(s.set(n.subarray(l,U),i.y),i.y+=d,s):ur(n,l,U);if(h==2){var C=n[l],M=C&3,Q=C>>2&3,x=C>>4,R=0,Z=0;M<2?Q&1?x|=n[++l]<<4|(Q&2&&n[++l]<<12):x=C>>3:(Z=Q,Q<2?(x|=(n[++l]&63)<<4,R=n[l]>>6|n[++l]<<2):Q==2?(x|=n[++l]<<4|(n[++l]&3)<<12,R=n[l]>>2|n[++l]<<6):(x|=n[++l]<<4|(n[++l]&63)<<12,R=n[l]>>6|n[++l]<<2|n[++l]<<10)),++l;var b=s?s.subarray(i.y,i.y+i.m):new N(i.m),q=b.length-x;if(M==0)b.set(n.subarray(l,l+=x),q);else if(M==1)Re(b,n[l++],q);else{var te=i.h;if(M==2){var V=Pi(n,l);R+=l-(l=V[0]),i.h=te=V[1]}else te||k(0);(Z?Ei:qe)(n.subarray(l,l+=R),b.subarray(q),te)}var K=n[l++];if(K){K==255?K=(n[l++]|n[l++]<<8)+32512:K>127&&(K=K-128<<8|n[l++]);var ie=n[l++];ie&3&&k(0);for(var $=[Fi,Hi,Qi],y=2;y>-1;--y){var L=ie>>(y<<1)+2&3;if(L==1){var O=new N([0,0,n[l++]]);$[y]={s:O.subarray(2,3),n:O.subarray(0,1),t:new De(O.buffer,0,1),b:0}}else L==2?(c=$e(n,l,9-(y&1)),l=c[0],$[y]=c[1]):L==3&&(i.t||k(0),$[y]=i.t[y])}var W=i.t=$,Y=W[0],A=W[1],ee=W[2],D=n[U-1];D||k(0);var P=(U<<3)-8+me(D)-ee.b,m=P>>3,S=0,_e=(n[m]|n[m+1]<<8)>>(P&7)&(1<>3;var Ue=(n[m]|n[m+1]<<8)>>(P&7)&(1<>3;var ge=(n[m]|n[m+1]<<8)>>(P&7)&(1<>3;var ke=1<>>(P&7)&ke-1);m=(P-=lr[Ce])>>3;var we=Ti[Ce]+((n[m]|n[m+1]<<8|n[m+2]<<16)>>(P&7)&(1<>3;var Me=xi[be]+((n[m]|n[m+1]<<8|n[m+2]<<16)>>(P&7)&(1<>3,_e=ee.t[_e]+((n[m]|n[m+1]<<8)>>(P&7)&(1<>3,ge=Y.t[ge]+((n[m]|n[m+1]<<8)>>(P&7)&(1<>3,Ue=A.t[Ue]+((n[m]|n[m+1]<<8)>>(P&7)&(1<3)i.o[2]=i.o[1],i.o[1]=i.o[0],i.o[0]=ue-=3;else{var ce=ue-(Me!=0);ce?(ue=ce==3?i.o[0]-1:i.o[ce],ce>1&&(i.o[2]=i.o[1]),i.o[1]=i.o[0],i.o[0]=ue):ue=i.o[0]}for(var y=0;ywe&&(ne=we);for(var y=0;y{throw e},c='',l="";function p(r){return l+r}var h,d,U=console.log.bind(console),C=console.error.bind(console),M,Q=!1,x,R=r=>r.startsWith("file://"),Z=!1;function b(){return Be.buffer}function q(){if(!P?.buffer?.resizable){var r=b();P=new Int8Array(r),Ve=new Int16Array(r),i.HEAPU8=G=new Uint8Array(r),He=new Uint16Array(r),Xe=new Int32Array(r),z=new Uint32Array(r),Pr=new Float32Array(r),Qr=new Float64Array(r),pr=new BigInt64Array(r),hr=new BigUint64Array(r)}}function te(){}function V(){Z=!0,Ee.A()}function K(){}function ie(r){r=`Aborted(${r})`,C(r),Q=!0,r+=". Build with -sASSERTIONS for more info.",Z&&Nr();var e=new WebAssembly.RuntimeError(r);throw e}var $;let y=()=>"";function L(r){if(r==$&&M)return new Uint8Array(M);if(d)return d(r);throw"both async and sync fetching of the wasm failed"}async function O(r){if(!M)try{var e=await h(r);return new Uint8Array(e)}catch{}return L(r)}async function W(r,e){try{var t=await O(r),a=await WebAssembly.instantiate(t,e);return a}catch(o){C(`failed to asynchronously prepare wasm: ${o}`),ie(o)}}async function Y(r,e,t){if(!r&&!R(e))try{var a=fetch(e,{credentials:"same-origin"}),o=await WebAssembly.instantiateStreaming(a,t);return o}catch(u){C(`wasm streaming compile failed: ${u}`),C("falling back to ArrayBuffer instantiation")}return W(e,t)}function A(){var r={a:wi};return r}async function ee(){function r(u){return Ee=u.exports,di(Ee),q(),Ee}function e(u){return r(u.instance)}var t=A();$??=y();var a=await Y(M,$,t),o=e(a);return o}class D{name="ExitStatus";constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var P,m=()=>Xr,S=r=>{var e=r.getArg(m(),0);return zr(e)},_e=()=>Kr(),Ue=r=>Jr(r),ge=r=>kr(r),be=globalThis.TextDecoder&&new TextDecoder,Qe=(r,e,t,a)=>{var o=e+t;if(a)return o;for(;r[e]&&!(e>=o);)++e;return e},Ce=(r,e=0,t,a)=>{var o=Qe(r,e,t,a);if(o-e>16&&r.buffer&&be)return be.decode(r.subarray(e,o));for(var u="";e>10,56320|w&1023)}}return u},G,de=(r,e,t)=>r?Ce(G,r,e,t):"",z,ke=r=>{var e=_e(),t=ge(4),a=ge(4);Vr(r,t,a);var o=z[t>>2],u=z[a>>2],v=de(o);se(o);var f;return u&&(f=de(u),se(u)),Ue(e),[v,f]},ue=r=>{var e=S(r);return ke(e)},we=r=>{var e=new WebAssembly.Exception(m(),[r],{traceStack:!0});throw e.message=ue(e),e},Me=()=>ie(""),ce={},fe=r=>{for(;r.length;){var e=r.pop(),t=r.pop();t(e)}};function ne(r){return this.fromWireType(z[r>>2])}var ve={},Pe={},Ke={};class Wr extends Error{constructor(e){super(e),this.name="InternalError"}}var ze=r=>{throw new Wr(r)},pe=(r,e,t)=>{r.forEach(f=>Ke[f]=e);function a(f){var g=t(f);g.length!==r.length&&ze("Mismatched type converter count");for(var w=0;w{o[f]=Pe[g],++v,v===u.length&&a(o)}));u.length===0&&a(o)},Ar=r=>{var e=ce[r];delete ce[r];var t=e.rawConstructor,a=e.rawDestructor,o=e.fields,u=o.map(v=>v.getterReturnType).concat(o.map(v=>v.setterArgumentType));pe([r],u,v=>{var f={};for(var[g,w]of o.entries()){let _=v[g],T=w.getter,H=w.getterContext,E=v[g+o.length],X=w.setter,j=w.setterContext;f[w.fieldName]={read:I=>_.fromWireType(T(H,I)),write:(I,J)=>{var he=[];X(j,I,E.toWireType(he,J)),fe(he)},optional:_.optional}}return[{name:e.name,fromWireType:_=>{var T={};for(var H in f)T[H]=f[H].read(_);return a(_),T},toWireType:(_,T)=>{for(var H in f)if(!(H in T)&&!f[H].optional)throw new TypeError(`Missing field: "${H}"`);var E=t();for(H in f)f[H].write(E,T[H]);return _!==null&&_.push(a,E),E},readValueFromPointer:ne,destructorFunction:a}]})},B=r=>{for(var e="";;){var t=G[r++];if(!t)return e;e+=String.fromCharCode(t)}};class Fe extends Error{constructor(e){super(e),this.name="BindingError"}}var F=r=>{throw new Fe(r)};function et(r,e,t={}){var a=e.name;if(r||F(`type "${a}" must have a positive integer typeid pointer`),Pe.hasOwnProperty(r)){if(t.ignoreDuplicateRegistrations)return;F(`Cannot register type '${a}' twice`)}if(Pe[r]=e,delete Ke[r],ve.hasOwnProperty(r)){var o=ve[r];delete ve[r],o.forEach(u=>u())}}function oe(r,e,t={}){return et(r,e,t)}var Ve,He,Xe,pr,hr,gr=(r,e,t)=>{switch(e){case 1:return t?a=>P[a]:a=>G[a];case 2:return t?a=>Ve[a>>1]:a=>He[a>>1];case 4:return t?a=>Xe[a>>2]:a=>z[a>>2];case 8:return t?a=>pr[a>>3]:a=>hr[a>>3];default:throw new TypeError(`invalid integer width (${e}): ${r}`)}},rt=(r,e,t,a,o)=>{e=B(e);let u=a===0n,v=f=>f;if(u){let f=t*8;v=g=>BigInt.asUintN(f,g),o=v(o)}oe(r,{name:e,fromWireType:v,toWireType:(f,g)=>(typeof g=="number"&&(g=BigInt(g)),g),readValueFromPointer:gr(e,t,!u),destructorFunction:null})},tt=(r,e,t,a)=>{e=B(e),oe(r,{name:e,fromWireType:function(o){return!!o},toWireType:function(o,u){return u?t:a},readValueFromPointer:function(o){return this.fromWireType(G[o])},destructorFunction:null})},it=r=>({count:r.count,deleteScheduled:r.deleteScheduled,preservePointerOnDelete:r.preservePointerOnDelete,ptr:r.ptr,ptrType:r.ptrType,smartPtr:r.smartPtr,smartPtrType:r.smartPtrType}),je=r=>{function e(t){return t.$$.ptrType.registeredClass.name}F(e(r)+" instance already deleted")},We=!1,dr=r=>{},nt=r=>{r.smartPtr?r.smartPtrType.rawDestructor(r.smartPtr):r.ptrType.registeredClass.rawDestructor(r.ptr)},wr=r=>{r.count.value-=1;var e=r.count.value===0;e&&nt(r)},xe=r=>globalThis.FinalizationRegistry?(We=new FinalizationRegistry(e=>{wr(e.$$)}),xe=e=>{var t=e.$$,a=!!t.smartPtr;if(a){var o={$$:t};We.register(e,o,e)}return e},dr=e=>We.unregister(e),xe(r)):(xe=e=>e,r),Ie=[],at=()=>{for(;Ie.length;){var r=Ie.pop();r.$$.deleteScheduled=!1,r.delete()}},yr,st=()=>{let r=Ze.prototype;Object.assign(r,{isAliasOf(t){if(!(this instanceof Ze)||!(t instanceof Ze))return!1;var a=this.$$.ptrType.registeredClass,o=this.$$.ptr;t.$$=t.$$;for(var u=t.$$.ptrType.registeredClass,v=t.$$.ptr;a.baseClass;)o=a.upcast(o),a=a.baseClass;for(;u.baseClass;)v=u.upcast(v),u=u.baseClass;return a===u&&o===v},clone(){if(this.$$.ptr||je(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var t=xe(Object.create(Object.getPrototypeOf(this),{$$:{value:it(this.$$)}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t},delete(){this.$$.ptr||je(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&F("Object already scheduled for deletion"),dr(this),wr(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||je(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&F("Object already scheduled for deletion"),Ie.push(this),Ie.length===1&&yr&&yr(at),this.$$.deleteScheduled=!0,this}});let e=Symbol.dispose;e&&(r[e]=r.delete)};function Ze(){}var mr=(r,e)=>Object.defineProperty(e,"name",{value:r}),_r={},Ae=(r,e,t)=>{if(r[e].overloadTable===void 0){var a=r[e];r[e]=function(...o){return r[e].overloadTable.hasOwnProperty(o.length)||F(`Function '${t}' called with an invalid number of arguments (${o.length}) - expects one of (${r[e].overloadTable})!`),r[e].overloadTable[o.length].apply(this,o)},r[e].overloadTable=[],r[e].overloadTable[a.argCount]=a}},ot=(r,e,t)=>{i.hasOwnProperty(r)?((t===void 0||i[r].overloadTable!==void 0&&i[r].overloadTable[t]!==void 0)&&F(`Cannot register public name '${r}' twice`),Ae(i,r,r),i[r].overloadTable.hasOwnProperty(t)&&F(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),i[r].overloadTable[t]=e):(i[r]=e,i[r].argCount=t)},ut=48,ct=57,lt=r=>{r=r.replace(/[^a-zA-Z0-9_]/g,"$");var e=r.charCodeAt(0);return e>=ut&&e<=ct?`_${r}`:r};function ft(r,e,t,a,o,u,v,f){this.name=r,this.constructor=e,this.instancePrototype=t,this.rawDestructor=a,this.baseClass=o,this.getActualType=u,this.upcast=v,this.downcast=f,this.pureVirtualFunctions=[]}var er=(r,e,t)=>{for(;e!==t;)e.upcast||F(`Expected null or instance of ${t.name}, got an instance of ${e.name}`),r=e.upcast(r),e=e.baseClass;return r},rr=r=>{if(r===null)return"null";var e=typeof r;return e==="object"||e==="array"||e==="function"?r.toString():""+r};function vt(r,e){if(e===null)return this.isReference&&F(`null is not a valid ${this.name}`),0;e.$$||F(`Cannot pass "${rr(e)}" as a ${this.name}`),e.$$.ptr||F(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=e.$$.ptrType.registeredClass,a=er(e.$$.ptr,t,this.registeredClass);return a}function pt(r,e){var t;if(e===null)return this.isReference&&F(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),r!==null&&r.push(this.rawDestructor,t),t):0;(!e||!e.$$)&&F(`Cannot pass "${rr(e)}" as a ${this.name}`),e.$$.ptr||F(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&e.$$.ptrType.isConst&&F(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);var a=e.$$.ptrType.registeredClass;if(t=er(e.$$.ptr,a,this.registeredClass),this.isSmartPointer)switch(e.$$.smartPtr===void 0&&F("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:e.$$.smartPtrType===this?t=e.$$.smartPtr:F(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:t=e.$$.smartPtr;break;case 2:if(e.$$.smartPtrType===this)t=e.$$.smartPtr;else{var o=e.clone();t=this.rawShare(t,nr.toHandle(()=>o.delete())),r!==null&&r.push(this.rawDestructor,t)}break;default:F("Unsupported sharing policy")}return t}function ht(r,e){if(e===null)return this.isReference&&F(`null is not a valid ${this.name}`),0;e.$$||F(`Cannot pass "${rr(e)}" as a ${this.name}`),e.$$.ptr||F(`Cannot pass deleted object as a pointer of type ${this.name}`),e.$$.ptrType.isConst&&F(`Cannot convert argument of type ${e.$$.ptrType.name} to parameter type ${this.name}`);var t=e.$$.ptrType.registeredClass,a=er(e.$$.ptr,t,this.registeredClass);return a}var Ur=(r,e,t)=>{if(e===t)return r;if(t.baseClass===void 0)return null;var a=Ur(r,e,t.baseClass);return a===null?null:t.downcast(a)},gt={},dt=(r,e)=>{for(e===void 0&&F("ptr should not be undefined");r.baseClass;)e=r.upcast(e),r=r.baseClass;return e},wt=(r,e)=>(e=dt(r,e),gt[e]),Le=(r,e)=>{(!e.ptrType||!e.ptr)&&ze("makeClassHandle requires ptr and ptrType");var t=!!e.smartPtrType,a=!!e.smartPtr;return t!==a&&ze("Both smartPtrType and smartPtr must be specified"),e.count={value:1},xe(Object.create(r,{$$:{value:e,writable:!0}}))};function yt(r){var e=this.getPointee(r);if(!e)return this.destructor(r),null;var t=wt(this.registeredClass,e);if(t!==void 0){if(t.$$.count.value===0)return t.$$.ptr=e,t.$$.smartPtr=r,t.clone();var a=t.clone();return this.destructor(r),a}function o(){return this.isSmartPointer?Le(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:e,smartPtrType:this,smartPtr:r}):Le(this.registeredClass.instancePrototype,{ptrType:this,ptr:r})}var u=this.registeredClass.getActualType(e),v=_r[u];if(!v)return o.call(this);var f;this.isConst?f=v.constPointerType:f=v.pointerType;var g=Ur(e,this.registeredClass,f.registeredClass);return g===null?o.call(this):this.isSmartPointer?Le(f.registeredClass.instancePrototype,{ptrType:f,ptr:g,smartPtrType:this,smartPtr:r}):Le(f.registeredClass.instancePrototype,{ptrType:f,ptr:g})}var mt=()=>{Object.assign(Ye.prototype,{getPointee(r){return this.rawGetPointee&&(r=this.rawGetPointee(r)),r},destructor(r){this.rawDestructor?.(r)},readValueFromPointer:ne,fromWireType:yt})};function Ye(r,e,t,a,o,u,v,f,g,w,_){this.name=r,this.registeredClass=e,this.isReference=t,this.isConst=a,this.isSmartPointer=o,this.pointeeType=u,this.sharingPolicy=v,this.rawGetPointee=f,this.rawConstructor=g,this.rawShare=w,this.rawDestructor=_,!o&&e.baseClass===void 0?a?(this.toWireType=vt,this.destructorFunction=null):(this.toWireType=ht,this.destructorFunction=null):this.toWireType=pt}var _t=(r,e,t)=>{i.hasOwnProperty(r)||ze("Replacing nonexistent public symbol"),i[r].overloadTable!==void 0&&t!==void 0?i[r].overloadTable[t]=e:(i[r]=e,i[r].argCount=t)},Ut=r=>Ir.get(r),ae=(r,e,t=!1)=>{r=B(r);function a(){var u=Ut(e);return u}var o=a();return typeof o!="function"&&F(`unknown function pointer with signature ${r}: ${e}`),o};class bt extends Error{}var Ct=r=>{var e=Rr(r),t=B(e);return se(e),t},Se=(r,e)=>{var t=[],a={};function o(u){if(!a[u]&&!Pe[u]){if(Ke[u]){Ke[u].forEach(o);return}t.push(u),a[u]=!0}}throw e.forEach(o),new bt(`${r}: `+t.map(Ct).join([", "]))},Mt=(r,e,t,a,o,u,v,f,g,w,_,T,H)=>{_=B(_),u=ae(o,u),f&&=ae(v,f),w&&=ae(g,w),H=ae(T,H);var E=lt(_);ot(E,function(){Se(`Cannot construct ${_} due to unbound types`,[a])}),pe([r,e,t],a?[a]:[],X=>{X=X[0];var j,I;a?(j=X.registeredClass,I=j.instancePrototype):I=Ze.prototype;var J=mr(_,function(...or){if(Object.getPrototypeOf(this)!==he)throw new Fe(`Use 'new' to construct ${_}`);if(re.constructor_body===void 0)throw new Fe(`${_} has no accessible constructor`);var Zr=re.constructor_body[or.length];if(Zr===void 0)throw new Fe(`Tried to invoke ctor of ${_} with invalid number of parameters (${or.length}) - expected (${Object.keys(re.constructor_body).toString()}) parameters instead!`);return Zr.apply(this,or)}),he=Object.create(I,{constructor:{value:J}});J.prototype=he;var re=new ft(_,J,he,H,j,u,f,w);re.baseClass&&(re.baseClass.__derivedClasses??=[],re.baseClass.__derivedClasses.push(re));var sr=new Ye(_,re,!0,!1,!1),le=new Ye(_+"*",re,!1,!1,!1),Oe=new Ye(_+" const*",re,!1,!0,!1);return _r[r]={pointerType:le,constPointerType:Oe},_t(E,J),[sr,le,Oe]})};function Pt(r){for(var e=1;e{for(var t=[],a=0;a>2]);return t},br=r=>{r=r.trim();let e=r.indexOf("(");return e===-1?r:r.slice(0,e)},Qt=(r,e,t,a,o,u,v,f,g)=>{var w=ir(t,a);e=B(e),e=br(e),u=ae(o,u,f),pe([],[r],_=>{_=_[0];var T=`${_.name}.${e}`;function H(){Se(`Cannot call ${T} due to unbound types`,w)}e.startsWith("@@")&&(e=Symbol[e.substring(2)]);var E=_.registeredClass.constructor;return E[e]===void 0?(H.argCount=t-1,E[e]=H):(Ae(E,e,T),E[e].overloadTable[t-1]=H),pe([],w,X=>{var j=[X[0],null].concat(X.slice(1)),I=tr(T,j,null,u,v,f);if(E[e].overloadTable===void 0?(I.argCount=t-1,E[e]=I):E[e].overloadTable[t-1]=I,_.registeredClass.__derivedClasses)for(let J of _.registeredClass.__derivedClasses)J.constructor.hasOwnProperty(e)||(J.constructor[e]=I);return[]}),[]})},Ft=(r,e,t,a,o,u)=>{var v=ir(e,t);o=ae(a,o),pe([],[r],f=>{f=f[0];var g=`constructor ${f.name}`;if(f.registeredClass.constructor_body===void 0&&(f.registeredClass.constructor_body=[]),f.registeredClass.constructor_body[e-1]!==void 0)throw new Fe(`Cannot register multiple constructors with identical number of parameters (${e-1}) for class '${f.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return f.registeredClass.constructor_body[e-1]=()=>{Se(`Cannot construct ${f.name} due to unbound types`,v)},pe([],v,w=>(w.splice(1,0,null),f.registeredClass.constructor_body[e-1]=tr(g,w,null,o,u),[])),[]})},Ht=(r,e,t,a,o,u,v,f,g,w)=>{var _=ir(t,a);e=B(e),e=br(e),u=ae(o,u,g),pe([],[r],T=>{T=T[0];var H=`${T.name}.${e}`;e.startsWith("@@")&&(e=Symbol[e.substring(2)]),f&&T.registeredClass.pureVirtualFunctions.push(e);function E(){Se(`Cannot call ${H} due to unbound types`,_)}var X=T.registeredClass.instancePrototype,j=X[e];return j===void 0||j.overloadTable===void 0&&j.className!==T.name&&j.argCount===t-2?(E.argCount=t-2,E.className=T.name,X[e]=E):(Ae(X,e,H),X[e].overloadTable[t-2]=E),pe([],_,I=>{var J=tr(H,I,T,u,v,g);return X[e].overloadTable===void 0?(J.argCount=t-2,X[e]=J):X[e].overloadTable[t-2]=J,[]}),[]})},Cr=[],ye=[0,1,,1,null,1,!0,1,!1,1],Mr=[],xt=r=>{if(r>9&&--ye[r+1]===0){var e=ye[r];ye[r]=void 0;var t=Mr[r];t&&(Mr[r]=void 0,t(e)),Cr.push(r)}},nr={toValue:r=>(r||F(`Cannot use deleted val. handle = ${r}`),ye[r]),toHandle:r=>{switch(r){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let e=Cr.pop()||ye.length;return ye[e]=r,ye[e+1]=1,e}}}},Tt={name:"emscripten::val",fromWireType:r=>{var e=nr.toValue(r);return xt(r),e},toWireType:(r,e)=>nr.toHandle(e),readValueFromPointer:ne,destructorFunction:null},Et=r=>oe(r,Tt),Pr,Qr,qt=(r,e)=>{switch(e){case 4:return function(t){return this.fromWireType(Pr[t>>2])};case 8:return function(t){return this.fromWireType(Qr[t>>3])};default:throw new TypeError(`invalid float width (${e}): ${r}`)}},Rt=(r,e,t)=>{e=B(e),oe(r,{name:e,fromWireType:a=>a,toWireType:(a,o)=>o,readValueFromPointer:qt(e,t),destructorFunction:null})},$t=(r,e,t,a,o)=>{e=B(e);let u=a===0,v=g=>g;if(u){var f=32-8*t;v=g=>g<>>f,o=v(o)}oe(r,{name:e,fromWireType:v,toWireType:(g,w)=>w,readValueFromPointer:gr(e,t,a!==0),destructorFunction:null})},Nt=(r,e,t)=>{var a=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array],o=a[e];function u(v){var f=z[v>>2],g=z[v+4>>2];return new o(P.buffer,g,f)}t=B(t),oe(r,{name:t,fromWireType:u,readValueFromPointer:u},{ignoreDuplicateRegistrations:!0})},Jt=(r,e,t,a)=>{if(!(a>0))return 0;for(var o=t,u=t+a-1,v=0;v=u)break;e[t++]=f}else if(f<=2047){if(t+1>=u)break;e[t++]=192|f>>6,e[t++]=128|f&63}else if(f<=65535){if(t+2>=u)break;e[t++]=224|f>>12,e[t++]=128|f>>6&63,e[t++]=128|f&63}else{if(t+3>=u)break;e[t++]=240|f>>18,e[t++]=128|f>>12&63,e[t++]=128|f>>6&63,e[t++]=128|f&63,v++}}return e[t]=0,t-o},Fr=(r,e,t)=>Jt(r,G,e,t),Hr=r=>{for(var e=0,t=0;t=55296&&a<=57343?(e+=4,++t):e+=3}return e},kt=(r,e)=>{e=B(e);var t=!0;oe(r,{name:e,fromWireType(a){var o=z[a>>2],u=a+4,v;if(t)v=de(u,o,!0);else{v="";for(var f=0;f>2]=u,v)if(t)Fr(o,g,u+1);else for(var w=0;w255&&(se(f),F("String has UTF-16 code units that do not fit in 8 bits")),G[g+w]=_}else G.set(o,g);return a!==null&&a.push(se,f),f},readValueFromPointer:ne,destructorFunction(a){se(a)}})},xr=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,Kt=(r,e,t)=>{var a=r>>1,o=Qe(He,a,e/2,t);if(o-a>16&&xr)return xr.decode(He.subarray(a,o));for(var u="",v=a;v{if(t<2)return 0;t-=2;for(var a=e,o=t>1]=v,e+=2}return Ve[e>>1]=0,e-a},Vt=r=>r.length*2,Xt=(r,e,t)=>{for(var a="",o=r>>2,u=0;!(u>=e/4);u++){var v=z[o+u];if(!v&&!t)break;a+=String.fromCodePoint(v)}return a},It=(r,e,t=2147483647)=>{if(t<4)return 0;for(var a=e,o=a+t-4,u=0;u65535&&u++,Xe[e>>2]=v,e+=4,e+4>o)break}return Xe[e>>2]=0,e-a},Zt=r=>{for(var e=0,t=0;t65535&&t++,e+=4}return e},Lt=(r,e,t)=>{t=B(t);var a,o,u;e===2?(a=Kt,o=zt,u=Vt):(a=Xt,o=It,u=Zt),oe(r,{name:t,fromWireType:v=>{var f=z[v>>2],g=a(v+4,f*e,!0);return se(v),g},toWireType:(v,f)=>{typeof f!="string"&&F(`Cannot pass non-string to C++ string type ${t}`);var g=u(f),w=ar(4+g+e);return z[w>>2]=g/e,o(f,w+4,g+e),v!==null&&v.push(se,w),w},readValueFromPointer:ne,destructorFunction(v){se(v)}})},Yt=(r,e,t,a,o,u)=>{ce[r]={name:B(e),rawConstructor:ae(t,a),rawDestructor:ae(o,u),fields:[]}},St=(r,e,t,a,o,u,v,f,g,w)=>{ce[r].fields.push({fieldName:B(e),getterReturnType:t,getter:ae(a,o),getterContext:u,setterArgumentType:v,setter:ae(f,g),setterContext:w})},Bt=(r,e)=>{e=B(e),oe(r,{isVoid:!0,name:e,fromWireType:()=>{},toWireType:(t,a)=>{}})},Ot=0,Dt=()=>{Ot=0},Te={},Tr=r=>{if(r instanceof D||r=="unwind")return x;s(1,r)},Er=()=>!0,qr=r=>{x=r,Er()||(Q=!0),s(r,new D(r))},Gt=(r,e)=>{x=r,qr(r)},jt=Gt,Wt=()=>{if(!Er())try{jt(x)}catch(r){Tr(r)}},At=r=>{if(!Q)try{return r()}catch(e){Tr(e)}finally{Wt()}},ei=()=>performance.now(),ri=(r,e)=>{if(Te[r]&&(clearTimeout(Te[r].id),delete Te[r]),!e)return 0;var t=setTimeout(()=>{delete Te[r],At(()=>$r(r,ei()))},e);return Te[r]={id:t,timeout_ms:e},0},ti=()=>2147483648,ii=(r,e)=>Math.ceil(r/e)*e,ni=r=>{var e=Be.buffer.byteLength,t=(r-e+65535)/65536|0;try{return Be.grow(t),q(),1}catch{}},ai=r=>{var e=G.length;r>>>=0;var t=ti();if(r>t)return!1;for(var a=1;a<=4;a*=2){var o=e*(1+.2/a);o=Math.min(o,r+100663296);var u=Math.min(t,ii(Math.max(r,o),65536)),v=ni(u);if(v)return!0}return!1},si=r=>52,oi=9007199254740992,ui=-9007199254740992,ci=r=>roi?NaN:Number(r);function li(r,e,t,a){return e=ci(e),70}var fi=[null,[],[]],vi=(r,e)=>{var t=fi[r];!e||e===10?((r===1?U:C)(Ce(t)),t.length=0):t.push(e)},pi=(r,e,t,a)=>{for(var o=0,u=0;u>2],f=z[e+4>>2];e+=8;for(var g=0;g>2]=o,0};st(),mt(),i.wasmBinary&&(M=i.wasmBinary),i.UTF8ToString=de,i.stringToUTF8=Fr,i.lengthBytesUTF8=Hr;var Rr,ar,se,$r,Nr,Jr,kr,Kr,zr,Vr,hi,gi,Xr,Be,Ir;function di(r){Rr=r.B,ar=i._malloc=r.C,se=i._free=r.D,$r=r.F,Nr=r.G,Jr=r.H,kr=r.I,Kr=r.J,zr=r.K,Vr=r.L,hi=Be=r.z,gi=Ir=r.E,Xr=r.M}var wi={t:we,x:Me,f:Ar,i:rt,l:tt,o:Mt,b:Qt,n:Ft,d:Ht,y:Et,h:Rt,c:$t,a:Nt,k:kt,g:Lt,j:Yt,e:St,m:Bt,w:Dt,p:ri,u:ai,s:si,q:li,r:pi,v:qr};async function yi(){!Q&&(V(),void 0)}var Ee;return Ee=await ee(),await yi(),i}var Br=$i;var Ni=new Int8Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,90,63,64,65,66,-1,67,68,69,70,71,-1,72,73,52,53,54,55,56,57,58,59,60,61,74,75,76,77,78,79,80,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,81,-1,82,83,84,85,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,86,87,88,89,-1]);function Ji(n){let i=new Uint8Array(170930),s=0,c=0,l=0,p=-1;for(let h=0,d=n.length;h127)continue;let C=Ni[U];if(!(C<0))if(p<0)p=C;else{p+=C*91,c|=p<88?13:14;do i[s++]=c,c>>>=8,l-=8;while(l>7);p=-1}}return p>=0&&(i[s++]=(c|p<""})}function Dr(){fr=void 0}var Gr=class{_module;constructor(n){this._module=n}malloc(n){let i=this._module._malloc(n);return{ptr:i,size:n,dispose:()=>this.free({ptr:i,size:n,dispose:()=>{}})}}free(n){this._module._free(n.ptr)}dataToHeap(n){let i=this.malloc(n.byteLength);return this._module.HEAPU8.set(n,i.ptr),i}heapView(n){return this._module.HEAPU8.subarray(n.ptr,n.ptr+n.size)}heapToUint8Array(n){return new Uint8Array([...this.heapView(n)])}lengthBytes(n){return this._module.lengthBytesUTF8(n)}stringToHeap(n){let i=this.lengthBytes(n)+1,s=this._module._malloc(i);return this._module.stringToUTF8(n,s,i),{ptr:s,size:i,dispose:()=>this.free({ptr:s,size:i,dispose:()=>{}})}}heapToString(n){return this._module.UTF8ToString(n.ptr,n.size)}hasFilesystem(){let n=this._module;return n.FS_createPath!==void 0&&n.FS_createDataFile!==void 0&&n.FS_preloadFile!==void 0&&n.FS_unlink!==void 0}createPath(n,i=!0,s=!0){return this._module.FS_createPath("/",n,i,s)}createDataFile(n,i,s=!0,c=!0,l=!0){return this._module.FS_createDataFile("/",n,i,s,c,l)}preloadFile(n,i,s=!0,c=!0,l=!1,p=!0,h=!1){return this._module.FS_preloadFile("/",n,i,s,c,l,p,h)}unlink(n){return this._module.FS_unlink(n)}};var Ne,Ki=4294967295;function Je(n,i){if(!Number.isInteger(n)||n<0||n>Ki)throw new Error(`${i} length ${n} is outside the WASM32-safe range`)}function vr(n){if(n.length===0)return new Uint8Array(0);if(n.length===1)return n[0];let i=0;for(let l of n)i+=l.length;let s=new Uint8Array(i),c=0;for(let l of n)s.set(l,c),c+=l.length;return s}var jr=class n{_mainModule;_zstdClass;_zstd;_compressionLevel;_decompressFrameCompleted=!1;_decompressRemaining=0;_decompressSawInput=!1;constructor(i){this._mainModule=new Gr(i),this._zstdClass=i.zstd,this._zstd=new this._zstdClass,this._compressionLevel=this._zstdClass.defaultCLevel()}static load(){return Ne||(Ne=Or().then(i=>new n(i))),Ne}static unload(){Dr(),Ne?.then(i=>{i?._zstd?.delete()}),Ne=void 0}copyHeap(i){return this._mainModule.heapView(i).slice()}mallocChecked(i,s){Je(i,s);let c=this._mainModule.malloc(i);if(!c.ptr)throw this._mainModule.free(c),new Error(`Failed to allocate ${i} bytes for ${s}`);return c}throwStreamError(i,s){throw new Error(`${i} failed: ${s.errorName||"unknown error"}`)}ensureStreamOk(i,s){s.error&&this.throwStreamError(i,s)}version(){return this._zstdClass.version()}reset(){let i=this._zstd.reset();this.ensureStreamOk("reset",i),this._decompressFrameCompleted=!1,this._decompressRemaining=0,this._decompressSawInput=!1}resetCompression(i){i!==void 0&&(this._compressionLevel=i);let s=this._zstd.resetCompression(this._compressionLevel);this.ensureStreamOk("resetCompression",s)}resetDecompression(){let i=this._zstd.resetDecompression();this.ensureStreamOk("resetDecompression",i),this._decompressFrameCompleted=!1,this._decompressRemaining=0,this._decompressSawInput=!1}setCompressionLevel(i){let s=this._zstd.setCompressionLevel(i);this.ensureStreamOk("setCompressionLevel",s),this._compressionLevel=i}compress(i,s=this.defaultCLevel()){Je(i.length,"compress input");let c=this._mainModule.dataToHeap(i);try{if(!c.ptr&&i.length>0)throw new Error("Failed to allocate compress input buffer");let l=this._zstdClass.compressBound(i.length),p=this.mallocChecked(l,"compress output");try{if(p.size=this._zstdClass.compress(p.ptr,l,c.ptr,c.size,s),this._zstdClass.isError(p.size))throw new Error(`compress failed: ${this._zstdClass.getErrorName(p.size)}`);return this.copyHeap(p)}finally{this._mainModule.free(p)}}finally{this._mainModule.free(c)}}compressChunk(i){if(Je(i.length,"compressChunk input"),i.length===0)return new Uint8Array(0);let s=this._mainModule.dataToHeap(i);try{if(!s.ptr)throw new Error("Failed to allocate compressChunk input buffer");let c=this._zstdClass.CStreamOutSize(),l=[],p=0;for(;p0&&(h.size=d.produced,l.push(this.copyHeap(h)))}finally{this._mainModule.free(h)}}return vr(l)}finally{this._mainModule.free(s)}}compressEnd(){let i=this._zstdClass.CStreamOutSize(),s=[],c=1;for(;c!==0;){let l=this.mallocChecked(i,"compressEnd output");try{let p=this._zstd.compressEnd(l.ptr,i);if(this.ensureStreamOk("compressEnd",p),p.produced===0&&p.remaining!==0)throw new Error("compressEnd failed: no progress while finishing stream");c=p.remaining,p.produced>0&&(l.size=p.produced,s.push(this.copyHeap(l)))}finally{this._mainModule.free(l)}}return vr(s)}frameContentSize(i){return this._zstdClass.getFrameContentSize(i.ptr,i.size)}decompress(i){Je(i.length,"decompress input");let s=this._mainModule.dataToHeap(i);try{if(!s.ptr&&i.length>0)throw new Error("Failed to allocate decompress input buffer");let c=this.frameContentSize(s);if(c.error)throw new Error(`Failed to get frame content size: ${c.errorName}`);let l=c.known;if(l){let p=this._zstdClass.findFrameCompressedSize(s.ptr,s.size);if(this._zstdClass.isError(p))throw new Error(`Failed to find frame compressed size: ${this._zstdClass.getErrorName(p)}`);p0?s.ptr+p:0,M=this._zstd.decompressChunk(d.ptr,c,C,U);if(this.ensureStreamOk("decompressChunk",M),M.consumed===0&&M.produced===0){if(U===0){M.remaining>0&&(this._decompressRemaining=M.remaining);break}throw new Error("decompressChunk failed: no progress while consuming input")}p+=M.consumed,h=M.produced===c&&M.remaining!==0,M.produced>0&&(d.size=M.produced,l.push(this.copyHeap(d))),M.remaining===0?(this._decompressFrameCompleted=!0,this._decompressRemaining=0):this._decompressRemaining=M.remaining}finally{this._mainModule.free(d)}}return vr(l)}finally{this._mainModule.free(s)}}decompressEnd(){if(!this._decompressSawInput)throw new Error("decompressEnd failed: empty compressed input is not a completed frame");if(!this._decompressFrameCompleted||this._decompressRemaining!==0)throw new Error("decompressEnd failed: truncated Zstandard input")}defaultCLevel(){return this._zstdClass.defaultCLevel()}minCLevel(){return this._zstdClass.minCLevel()}maxCLevel(){return this._zstdClass.maxCLevel()}};export{jr as Zstd}; //# sourceMappingURL=index.js.map