UNPKG

webr

Version:

The statistical programming language R compiled into WASM for use in a web browser and node.

2 lines 133 kB
"use strict";var _o=Object.create;var qs=Object.defineProperty;var go=Object.getOwnPropertyDescriptor;var yo=Object.getOwnPropertyNames;var wo=Object.getPrototypeOf,bo=Object.prototype.hasOwnProperty;var Hs=e=>{throw TypeError(e)};var Z=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var Ro=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of yo(r))!bo.call(e,s)&&s!==t&&qs(e,s,{get:()=>r[s],enumerable:!(n=go(r,s))||n.enumerable});return e};var ut=(e,r,t)=>(t=e!=null?_o(wo(e)):{},Ro(r||!e||!e.__esModule?qs(t,"default",{value:e,enumerable:!0}):t,e));var Pn=(e,r,t)=>r.has(e)||Hs("Cannot "+t);var E=(e,r,t)=>(Pn(e,r,"read from private field"),t?t.call(e):r.get(e)),I=(e,r,t)=>r.has(e)?Hs("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(e):r.set(e,t),F=(e,r,t,n)=>(Pn(e,r,"write to private field"),n?n.call(e,t):r.set(e,t),t),ke=(e,r,t)=>(Pn(e,r,"access private method"),t);var $s=(e,r,t,n)=>({set _(s){F(e,r,s,t)},get _(){return E(e,r,n)}});var Zt=Z(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});ae.getUint64=ae.getInt64=ae.setInt64=ae.setUint64=ae.UINT32_MAX=void 0;ae.UINT32_MAX=4294967295;function So(e,r,t){let n=t/4294967296,s=t;e.setUint32(r,n),e.setUint32(r+4,s)}ae.setUint64=So;function ko(e,r,t){let n=Math.floor(t/4294967296),s=t;e.setUint32(r,n),e.setUint32(r+4,s)}ae.setInt64=ko;function Ao(e,r){let t=e.getInt32(r),n=e.getUint32(r+4);return t*4294967296+n}ae.getInt64=Ao;function Do(e,r){let t=e.getUint32(r),n=e.getUint32(r+4);return t*4294967296+n}ae.getUint64=Do});var Zr=Z(X=>{"use strict";var Cn,Fn,Wn;Object.defineProperty(X,"__esModule",{value:!0});X.utf8DecodeTD=X.TEXT_DECODER_THRESHOLD=X.utf8DecodeJs=X.utf8EncodeTE=X.TEXT_ENCODER_THRESHOLD=X.utf8EncodeJs=X.utf8Count=void 0;var ta=Zt(),$r=(typeof process>"u"||((Cn=process==null?void 0:process.env)===null||Cn===void 0?void 0:Cn.TEXT_ENCODING)!=="never")&&typeof TextEncoder<"u"&&typeof TextDecoder<"u";function Po(e){let r=e.length,t=0,n=0;for(;n<r;){let s=e.charCodeAt(n++);if((s&4294967168)===0){t++;continue}else if((s&4294965248)===0)t+=2;else{if(s>=55296&&s<=56319&&n<r){let a=e.charCodeAt(n);(a&64512)===56320&&(++n,s=((s&1023)<<10)+(a&1023)+65536)}(s&4294901760)===0?t+=3:t+=4}}return t}X.utf8Count=Po;function Oo(e,r,t){let n=e.length,s=t,a=0;for(;a<n;){let i=e.charCodeAt(a++);if((i&4294967168)===0){r[s++]=i;continue}else if((i&4294965248)===0)r[s++]=i>>6&31|192;else{if(i>=55296&&i<=56319&&a<n){let o=e.charCodeAt(a);(o&64512)===56320&&(++a,i=((i&1023)<<10)+(o&1023)+65536)}(i&4294901760)===0?(r[s++]=i>>12&15|224,r[s++]=i>>6&63|128):(r[s++]=i>>18&7|240,r[s++]=i>>12&63|128,r[s++]=i>>6&63|128)}r[s++]=i&63|128}}X.utf8EncodeJs=Oo;var Vt=$r?new TextEncoder:void 0;X.TEXT_ENCODER_THRESHOLD=$r?typeof process<"u"&&((Fn=process==null?void 0:process.env)===null||Fn===void 0?void 0:Fn.TEXT_ENCODING)!=="force"?200:0:ta.UINT32_MAX;function Mo(e,r,t){r.set(Vt.encode(e),t)}function Io(e,r,t){Vt.encodeInto(e,r.subarray(t))}X.utf8EncodeTE=Vt!=null&&Vt.encodeInto?Io:Mo;var Uo=4096;function No(e,r,t){let n=r,s=n+t,a=[],i="";for(;n<s;){let o=e[n++];if((o&128)===0)a.push(o);else if((o&224)===192){let d=e[n++]&63;a.push((o&31)<<6|d)}else if((o&240)===224){let d=e[n++]&63,l=e[n++]&63;a.push((o&31)<<12|d<<6|l)}else if((o&248)===240){let d=e[n++]&63,l=e[n++]&63,u=e[n++]&63,w=(o&7)<<18|d<<12|l<<6|u;w>65535&&(w-=65536,a.push(w>>>10&1023|55296),w=56320|w&1023),a.push(w)}else a.push(o);a.length>=Uo&&(i+=String.fromCharCode(...a),a.length=0)}return a.length>0&&(i+=String.fromCharCode(...a)),i}X.utf8DecodeJs=No;var Co=$r?new TextDecoder:null;X.TEXT_DECODER_THRESHOLD=$r?typeof process<"u"&&((Wn=process==null?void 0:process.env)===null||Wn===void 0?void 0:Wn.TEXT_DECODER)!=="force"?200:0:ta.UINT32_MAX;function Fo(e,r,t){let n=e.subarray(r,r+t);return Co.decode(n)}X.utf8DecodeTD=Fo});var Bn=Z(Vr=>{"use strict";Object.defineProperty(Vr,"__esModule",{value:!0});Vr.ExtData=void 0;var Ln=class{constructor(r,t){this.type=r,this.data=t}};Vr.ExtData=Ln});var Xr=Z(Jr=>{"use strict";Object.defineProperty(Jr,"__esModule",{value:!0});Jr.DecodeError=void 0;var zn=class e extends Error{constructor(r){super(r);let t=Object.create(e.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:e.name})}};Jr.DecodeError=zn});var jn=Z(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.timestampExtension=V.decodeTimestampExtension=V.decodeTimestampToTimeSpec=V.encodeTimestampExtension=V.encodeDateToTimeSpec=V.encodeTimeSpecToTimestamp=V.EXT_TIMESTAMP=void 0;var Wo=Xr(),ra=Zt();V.EXT_TIMESTAMP=-1;var Lo=4294967296-1,Bo=17179869184-1;function na({sec:e,nsec:r}){if(e>=0&&r>=0&&e<=Bo)if(r===0&&e<=Lo){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),t}else{let t=e/4294967296,n=e&4294967295,s=new Uint8Array(8),a=new DataView(s.buffer);return a.setUint32(0,r<<2|t&3),a.setUint32(4,n),s}else{let t=new Uint8Array(12),n=new DataView(t.buffer);return n.setUint32(0,r),(0,ra.setInt64)(n,4,e),t}}V.encodeTimeSpecToTimestamp=na;function sa(e){let r=e.getTime(),t=Math.floor(r/1e3),n=(r-t*1e3)*1e6,s=Math.floor(n/1e9);return{sec:t+s,nsec:n-s*1e9}}V.encodeDateToTimeSpec=sa;function aa(e){if(e instanceof Date){let r=sa(e);return na(r)}else return null}V.encodeTimestampExtension=aa;function ia(e){let r=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:r.getUint32(0),nsec:0};case 8:{let t=r.getUint32(0),n=r.getUint32(4),s=(t&3)*4294967296+n,a=t>>>2;return{sec:s,nsec:a}}case 12:{let t=(0,ra.getInt64)(r,4),n=r.getUint32(0);return{sec:t,nsec:n}}default:throw new Wo.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}V.decodeTimestampToTimeSpec=ia;function oa(e){let r=ia(e);return new Date(r.sec*1e3+r.nsec/1e6)}V.decodeTimestampExtension=oa;V.timestampExtension={type:V.EXT_TIMESTAMP,encode:aa,decode:oa}});var Yr=Z(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0});Kr.ExtensionCodec=void 0;var Gr=Bn(),zo=jn(),Jt=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(zo.timestampExtension)}register({type:r,encode:t,decode:n}){if(r>=0)this.encoders[r]=t,this.decoders[r]=n;else{let s=1+r;this.builtInEncoders[s]=t,this.builtInDecoders[s]=n}}tryToEncode(r,t){for(let n=0;n<this.builtInEncoders.length;n++){let s=this.builtInEncoders[n];if(s!=null){let a=s(r,t);if(a!=null){let i=-1-n;return new Gr.ExtData(i,a)}}}for(let n=0;n<this.encoders.length;n++){let s=this.encoders[n];if(s!=null){let a=s(r,t);if(a!=null){let i=n;return new Gr.ExtData(i,a)}}}return r instanceof Gr.ExtData?r:null}decode(r,t,n){let s=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return s?s(r,t,n):new Gr.ExtData(t,r)}};Kr.ExtensionCodec=Jt;Jt.defaultCodec=new Jt});var qn=Z(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.createDataView=yt.ensureUint8Array=void 0;function la(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer?new Uint8Array(e):Uint8Array.from(e)}yt.ensureUint8Array=la;function jo(e){if(e instanceof ArrayBuffer)return new DataView(e);let r=la(e);return new DataView(r.buffer,r.byteOffset,r.byteLength)}yt.createDataView=jo});var $n=Z(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.Encoder=he.DEFAULT_INITIAL_BUFFER_SIZE=he.DEFAULT_MAX_DEPTH=void 0;var Xt=Zr(),qo=Yr(),ca=Zt(),Ho=qn();he.DEFAULT_MAX_DEPTH=100;he.DEFAULT_INITIAL_BUFFER_SIZE=2048;var Hn=class{constructor(r=qo.ExtensionCodec.defaultCodec,t=void 0,n=he.DEFAULT_MAX_DEPTH,s=he.DEFAULT_INITIAL_BUFFER_SIZE,a=!1,i=!1,o=!1,d=!1){this.extensionCodec=r,this.context=t,this.maxDepth=n,this.initialBufferSize=s,this.sortKeys=a,this.forceFloat32=i,this.ignoreUndefined=o,this.forceIntegerToFloat=d,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}reinitializeState(){this.pos=0}encodeSharedRef(r){return this.reinitializeState(),this.doEncode(r,1),this.bytes.subarray(0,this.pos)}encode(r){return this.reinitializeState(),this.doEncode(r,1),this.bytes.slice(0,this.pos)}doEncode(r,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);r==null?this.encodeNil():typeof r=="boolean"?this.encodeBoolean(r):typeof r=="number"?this.encodeNumber(r):typeof r=="string"?this.encodeString(r):this.encodeObject(r,t)}ensureBufferSizeToWrite(r){let t=this.pos+r;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(r){let t=new ArrayBuffer(r),n=new Uint8Array(t),s=new DataView(t);n.set(this.bytes),this.view=s,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(r){r===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(r){Number.isSafeInteger(r)&&!this.forceIntegerToFloat?r>=0?r<128?this.writeU8(r):r<256?(this.writeU8(204),this.writeU8(r)):r<65536?(this.writeU8(205),this.writeU16(r)):r<4294967296?(this.writeU8(206),this.writeU32(r)):(this.writeU8(207),this.writeU64(r)):r>=-32?this.writeU8(224|r+32):r>=-128?(this.writeU8(208),this.writeI8(r)):r>=-32768?(this.writeU8(209),this.writeI16(r)):r>=-2147483648?(this.writeU8(210),this.writeI32(r)):(this.writeU8(211),this.writeI64(r)):this.forceFloat32?(this.writeU8(202),this.writeF32(r)):(this.writeU8(203),this.writeF64(r))}writeStringHeader(r){if(r<32)this.writeU8(160+r);else if(r<256)this.writeU8(217),this.writeU8(r);else if(r<65536)this.writeU8(218),this.writeU16(r);else if(r<4294967296)this.writeU8(219),this.writeU32(r);else throw new Error(`Too long string: ${r} bytes in UTF-8`)}encodeString(r){if(r.length>Xt.TEXT_ENCODER_THRESHOLD){let s=(0,Xt.utf8Count)(r);this.ensureBufferSizeToWrite(5+s),this.writeStringHeader(s),(0,Xt.utf8EncodeTE)(r,this.bytes,this.pos),this.pos+=s}else{let s=(0,Xt.utf8Count)(r);this.ensureBufferSizeToWrite(5+s),this.writeStringHeader(s),(0,Xt.utf8EncodeJs)(r,this.bytes,this.pos),this.pos+=s}}encodeObject(r,t){let n=this.extensionCodec.tryToEncode(r,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(r))this.encodeArray(r,t);else if(ArrayBuffer.isView(r))this.encodeBinary(r);else if(typeof r=="object")this.encodeMap(r,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(r)}`)}encodeBinary(r){let t=r.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);let n=(0,Ho.ensureUint8Array)(r);this.writeU8a(n)}encodeArray(r,t){let n=r.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(let s of r)this.doEncode(s,t+1)}countWithoutUndefined(r,t){let n=0;for(let s of t)r[s]!==void 0&&n++;return n}encodeMap(r,t){let n=Object.keys(r);this.sortKeys&&n.sort();let s=this.ignoreUndefined?this.countWithoutUndefined(r,n):n.length;if(s<16)this.writeU8(128+s);else if(s<65536)this.writeU8(222),this.writeU16(s);else if(s<4294967296)this.writeU8(223),this.writeU32(s);else throw new Error(`Too large map object: ${s}`);for(let a of n){let i=r[a];this.ignoreUndefined&&i===void 0||(this.encodeString(a),this.doEncode(i,t+1))}}encodeExtension(r){let t=r.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(r.type),this.writeU8a(r.data)}writeU8(r){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,r),this.pos++}writeU8a(r){let t=r.length;this.ensureBufferSizeToWrite(t),this.bytes.set(r,this.pos),this.pos+=t}writeI8(r){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,r),this.pos++}writeU16(r){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,r),this.pos+=2}writeI16(r){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,r),this.pos+=2}writeU32(r){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,r),this.pos+=4}writeI32(r){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,r),this.pos+=4}writeF32(r){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,r),this.pos+=4}writeF64(r){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,r),this.pos+=8}writeU64(r){this.ensureBufferSizeToWrite(8),(0,ca.setUint64)(this.view,this.pos,r),this.pos+=8}writeI64(r){this.ensureBufferSizeToWrite(8),(0,ca.setInt64)(this.view,this.pos,r),this.pos+=8}};he.Encoder=Hn});var ua=Z(Qr=>{"use strict";Object.defineProperty(Qr,"__esModule",{value:!0});Qr.encode=void 0;var $o=$n(),Zo={};function Vo(e,r=Zo){return new $o.Encoder(r.extensionCodec,r.context,r.maxDepth,r.initialBufferSize,r.sortKeys,r.forceFloat32,r.ignoreUndefined,r.forceIntegerToFloat).encodeSharedRef(e)}Qr.encode=Vo});var da=Z(en=>{"use strict";Object.defineProperty(en,"__esModule",{value:!0});en.prettyByte=void 0;function Jo(e){return`${e<0?"-":""}0x${Math.abs(e).toString(16).padStart(2,"0")}`}en.prettyByte=Jo});var fa=Z(tn=>{"use strict";Object.defineProperty(tn,"__esModule",{value:!0});tn.CachedKeyDecoder=void 0;var Xo=Zr(),Go=16,Ko=16,Zn=class{constructor(r=Go,t=Ko){this.maxKeyLength=r,this.maxLengthPerKey=t,this.hit=0,this.miss=0,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(r){return r>0&&r<=this.maxKeyLength}find(r,t,n){let s=this.caches[n-1];e:for(let a of s){let i=a.bytes;for(let o=0;o<n;o++)if(i[o]!==r[t+o])continue e;return a.str}return null}store(r,t){let n=this.caches[r.length-1],s={bytes:r,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=s:n.push(s)}decode(r,t,n){let s=this.find(r,t,n);if(s!=null)return this.hit++,s;this.miss++;let a=(0,Xo.utf8DecodeJs)(r,t,n),i=Uint8Array.prototype.slice.call(r,t,t+n);return this.store(i,a),a}};tn.CachedKeyDecoder=Zn});var rn=Z(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.Decoder=xe.DataViewIndexOutOfBoundsError=void 0;var Vn=da(),Yo=Yr(),Qe=Zt(),Jn=Zr(),Xn=qn(),Qo=fa(),Re=Xr(),el=e=>{let r=typeof e;return r==="string"||r==="number"},Gt=-1,Kn=new DataView(new ArrayBuffer(0)),tl=new Uint8Array(Kn.buffer);xe.DataViewIndexOutOfBoundsError=(()=>{try{Kn.getInt8(0)}catch(e){return e.constructor}throw new Error("never reached")})();var ha=new xe.DataViewIndexOutOfBoundsError("Insufficient data"),rl=new Qo.CachedKeyDecoder,Gn=class{constructor(r=Yo.ExtensionCodec.defaultCodec,t=void 0,n=Qe.UINT32_MAX,s=Qe.UINT32_MAX,a=Qe.UINT32_MAX,i=Qe.UINT32_MAX,o=Qe.UINT32_MAX,d=rl){this.extensionCodec=r,this.context=t,this.maxStrLength=n,this.maxBinLength=s,this.maxArrayLength=a,this.maxMapLength=i,this.maxExtLength=o,this.keyDecoder=d,this.totalPos=0,this.pos=0,this.view=Kn,this.bytes=tl,this.headByte=Gt,this.stack=[]}reinitializeState(){this.totalPos=0,this.headByte=Gt,this.stack.length=0}setBuffer(r){this.bytes=(0,Xn.ensureUint8Array)(r),this.view=(0,Xn.createDataView)(this.bytes),this.pos=0}appendBuffer(r){if(this.headByte===Gt&&!this.hasRemaining(1))this.setBuffer(r);else{let t=this.bytes.subarray(this.pos),n=(0,Xn.ensureUint8Array)(r),s=new Uint8Array(t.length+n.length);s.set(t),s.set(n,t.length),this.setBuffer(s)}}hasRemaining(r){return this.view.byteLength-this.pos>=r}createExtraByteError(r){let{view:t,pos:n}=this;return new RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${r}]`)}decode(r){this.reinitializeState(),this.setBuffer(r);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}*decodeMulti(r){for(this.reinitializeState(),this.setBuffer(r);this.hasRemaining(1);)yield this.doDecodeSync()}async decodeAsync(r){let t=!1,n;for await(let o of r){if(t)throw this.createExtraByteError(this.totalPos);this.appendBuffer(o);try{n=this.doDecodeSync(),t=!0}catch(d){if(!(d instanceof xe.DataViewIndexOutOfBoundsError))throw d}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:s,pos:a,totalPos:i}=this;throw new RangeError(`Insufficient data in parsing ${(0,Vn.prettyByte)(s)} at ${i} (${a} in the current buffer)`)}decodeArrayStream(r){return this.decodeMultiAsync(r,!0)}decodeStream(r){return this.decodeMultiAsync(r,!1)}async*decodeMultiAsync(r,t){let n=t,s=-1;for await(let a of r){if(t&&s===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(a),n&&(s=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--s!==0;);}catch(i){if(!(i instanceof xe.DataViewIndexOutOfBoundsError))throw i}this.totalPos+=this.pos}}doDecodeSync(){e:for(;;){let r=this.readHeadByte(),t;if(r>=224)t=r-256;else if(r<192)if(r<128)t=r;else if(r<144){let s=r-128;if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(r<160){let s=r-144;if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else{let s=r-160;t=this.decodeUtf8String(s,0)}else if(r===192)t=null;else if(r===194)t=!1;else if(r===195)t=!0;else if(r===202)t=this.readF32();else if(r===203)t=this.readF64();else if(r===204)t=this.readU8();else if(r===205)t=this.readU16();else if(r===206)t=this.readU32();else if(r===207)t=this.readU64();else if(r===208)t=this.readI8();else if(r===209)t=this.readI16();else if(r===210)t=this.readI32();else if(r===211)t=this.readI64();else if(r===217){let s=this.lookU8();t=this.decodeUtf8String(s,1)}else if(r===218){let s=this.lookU16();t=this.decodeUtf8String(s,2)}else if(r===219){let s=this.lookU32();t=this.decodeUtf8String(s,4)}else if(r===220){let s=this.readU16();if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else if(r===221){let s=this.readU32();if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else if(r===222){let s=this.readU16();if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(r===223){let s=this.readU32();if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(r===196){let s=this.lookU8();t=this.decodeBinary(s,1)}else if(r===197){let s=this.lookU16();t=this.decodeBinary(s,2)}else if(r===198){let s=this.lookU32();t=this.decodeBinary(s,4)}else if(r===212)t=this.decodeExtension(1,0);else if(r===213)t=this.decodeExtension(2,0);else if(r===214)t=this.decodeExtension(4,0);else if(r===215)t=this.decodeExtension(8,0);else if(r===216)t=this.decodeExtension(16,0);else if(r===199){let s=this.lookU8();t=this.decodeExtension(s,1)}else if(r===200){let s=this.lookU16();t=this.decodeExtension(s,2)}else if(r===201){let s=this.lookU32();t=this.decodeExtension(s,4)}else throw new Re.DecodeError(`Unrecognized type byte: ${(0,Vn.prettyByte)(r)}`);this.complete();let n=this.stack;for(;n.length>0;){let s=n[n.length-1];if(s.type===0)if(s.array[s.position]=t,s.position++,s.position===s.size)n.pop(),t=s.array;else continue e;else if(s.type===1){if(!el(t))throw new Re.DecodeError("The type of key must be string or number but "+typeof t);if(t==="__proto__")throw new Re.DecodeError("The key __proto__ is not allowed");s.key=t,s.type=2;continue e}else if(s.map[s.key]=t,s.readCount++,s.readCount===s.size)n.pop(),t=s.map;else{s.key=null,s.type=1;continue e}}return t}}readHeadByte(){return this.headByte===Gt&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Gt}readArraySize(){let r=this.readHeadByte();switch(r){case 220:return this.readU16();case 221:return this.readU32();default:{if(r<160)return r-144;throw new Re.DecodeError(`Unrecognized array type byte: ${(0,Vn.prettyByte)(r)}`)}}}pushMapState(r){if(r>this.maxMapLength)throw new Re.DecodeError(`Max length exceeded: map length (${r}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.push({type:1,size:r,key:null,readCount:0,map:{}})}pushArrayState(r){if(r>this.maxArrayLength)throw new Re.DecodeError(`Max length exceeded: array length (${r}) > maxArrayLength (${this.maxArrayLength})`);this.stack.push({type:0,size:r,array:new Array(r),position:0})}decodeUtf8String(r,t){var n;if(r>this.maxStrLength)throw new Re.DecodeError(`Max length exceeded: UTF-8 byte length (${r}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+r)throw ha;let s=this.pos+t,a;return this.stateIsMapKey()&&(!((n=this.keyDecoder)===null||n===void 0)&&n.canBeCached(r))?a=this.keyDecoder.decode(this.bytes,s,r):r>Jn.TEXT_DECODER_THRESHOLD?a=(0,Jn.utf8DecodeTD)(this.bytes,s,r):a=(0,Jn.utf8DecodeJs)(this.bytes,s,r),this.pos+=t+r,a}stateIsMapKey(){return this.stack.length>0?this.stack[this.stack.length-1].type===1:!1}decodeBinary(r,t){if(r>this.maxBinLength)throw new Re.DecodeError(`Max length exceeded: bin length (${r}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(r+t))throw ha;let n=this.pos+t,s=this.bytes.subarray(n,n+r);return this.pos+=t+r,s}decodeExtension(r,t){if(r>this.maxExtLength)throw new Re.DecodeError(`Max length exceeded: ext length (${r}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+t),s=this.decodeBinary(r,t+1);return this.extensionCodec.decode(s,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let r=this.view.getUint8(this.pos);return this.pos++,r}readI8(){let r=this.view.getInt8(this.pos);return this.pos++,r}readU16(){let r=this.view.getUint16(this.pos);return this.pos+=2,r}readI16(){let r=this.view.getInt16(this.pos);return this.pos+=2,r}readU32(){let r=this.view.getUint32(this.pos);return this.pos+=4,r}readI32(){let r=this.view.getInt32(this.pos);return this.pos+=4,r}readU64(){let r=(0,Qe.getUint64)(this.view,this.pos);return this.pos+=8,r}readI64(){let r=(0,Qe.getInt64)(this.view,this.pos);return this.pos+=8,r}readF32(){let r=this.view.getFloat32(this.pos);return this.pos+=4,r}readF64(){let r=this.view.getFloat64(this.pos);return this.pos+=8,r}};xe.Decoder=Gn});var Yn=Z(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});pe.decodeMulti=pe.decode=pe.defaultDecodeOptions=void 0;var pa=rn();pe.defaultDecodeOptions={};function nl(e,r=pe.defaultDecodeOptions){return new pa.Decoder(r.extensionCodec,r.context,r.maxStrLength,r.maxBinLength,r.maxArrayLength,r.maxMapLength,r.maxExtLength).decode(e)}pe.decode=nl;function sl(e,r=pe.defaultDecodeOptions){return new pa.Decoder(r.extensionCodec,r.context,r.maxStrLength,r.maxBinLength,r.maxArrayLength,r.maxMapLength,r.maxExtLength).decodeMulti(e)}pe.decodeMulti=sl});var ga=Z(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.ensureAsyncIterable=Pe.asyncIterableFromStream=Pe.isAsyncIterable=void 0;function ma(e){return e[Symbol.asyncIterator]!=null}Pe.isAsyncIterable=ma;function al(e){if(e==null)throw new Error("Assertion Failure: value must not be null nor undefined")}async function*_a(e){let r=e.getReader();try{for(;;){let{done:t,value:n}=await r.read();if(t)return;al(n),yield n}}finally{r.releaseLock()}}Pe.asyncIterableFromStream=_a;function il(e){return ma(e)?e:_a(e)}Pe.ensureAsyncIterable=il});var wa=Z(me=>{"use strict";Object.defineProperty(me,"__esModule",{value:!0});me.decodeStream=me.decodeMultiStream=me.decodeArrayStream=me.decodeAsync=void 0;var Qn=rn(),es=ga(),nn=Yn();async function ol(e,r=nn.defaultDecodeOptions){let t=(0,es.ensureAsyncIterable)(e);return new Qn.Decoder(r.extensionCodec,r.context,r.maxStrLength,r.maxBinLength,r.maxArrayLength,r.maxMapLength,r.maxExtLength).decodeAsync(t)}me.decodeAsync=ol;function ll(e,r=nn.defaultDecodeOptions){let t=(0,es.ensureAsyncIterable)(e);return new Qn.Decoder(r.extensionCodec,r.context,r.maxStrLength,r.maxBinLength,r.maxArrayLength,r.maxMapLength,r.maxExtLength).decodeArrayStream(t)}me.decodeArrayStream=ll;function ya(e,r=nn.defaultDecodeOptions){let t=(0,es.ensureAsyncIterable)(e);return new Qn.Decoder(r.extensionCodec,r.context,r.maxStrLength,r.maxBinLength,r.maxArrayLength,r.maxMapLength,r.maxExtLength).decodeStream(t)}me.decodeMultiStream=ya;function cl(e,r=nn.defaultDecodeOptions){return ya(e,r)}me.decodeStream=cl});var ts=Z(A=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0});A.decodeTimestampExtension=A.encodeTimestampExtension=A.decodeTimestampToTimeSpec=A.encodeTimeSpecToTimestamp=A.encodeDateToTimeSpec=A.EXT_TIMESTAMP=A.ExtData=A.ExtensionCodec=A.Encoder=A.DataViewIndexOutOfBoundsError=A.DecodeError=A.Decoder=A.decodeStream=A.decodeMultiStream=A.decodeArrayStream=A.decodeAsync=A.decodeMulti=A.decode=A.encode=void 0;var ul=ua();Object.defineProperty(A,"encode",{enumerable:!0,get:function(){return ul.encode}});var ba=Yn();Object.defineProperty(A,"decode",{enumerable:!0,get:function(){return ba.decode}});Object.defineProperty(A,"decodeMulti",{enumerable:!0,get:function(){return ba.decodeMulti}});var sn=wa();Object.defineProperty(A,"decodeAsync",{enumerable:!0,get:function(){return sn.decodeAsync}});Object.defineProperty(A,"decodeArrayStream",{enumerable:!0,get:function(){return sn.decodeArrayStream}});Object.defineProperty(A,"decodeMultiStream",{enumerable:!0,get:function(){return sn.decodeMultiStream}});Object.defineProperty(A,"decodeStream",{enumerable:!0,get:function(){return sn.decodeStream}});var Ra=rn();Object.defineProperty(A,"Decoder",{enumerable:!0,get:function(){return Ra.Decoder}});Object.defineProperty(A,"DataViewIndexOutOfBoundsError",{enumerable:!0,get:function(){return Ra.DataViewIndexOutOfBoundsError}});var dl=Xr();Object.defineProperty(A,"DecodeError",{enumerable:!0,get:function(){return dl.DecodeError}});var fl=$n();Object.defineProperty(A,"Encoder",{enumerable:!0,get:function(){return fl.Encoder}});var hl=Yr();Object.defineProperty(A,"ExtensionCodec",{enumerable:!0,get:function(){return hl.ExtensionCodec}});var pl=Bn();Object.defineProperty(A,"ExtData",{enumerable:!0,get:function(){return pl.ExtData}});var wt=jn();Object.defineProperty(A,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return wt.EXT_TIMESTAMP}});Object.defineProperty(A,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return wt.encodeDateToTimeSpec}});Object.defineProperty(A,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return wt.encodeTimeSpecToTimestamp}});Object.defineProperty(A,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return wt.decodeTimestampToTimeSpec}});Object.defineProperty(A,"encodeTimestampExtension",{enumerable:!0,get:function(){return wt.encodeTimestampExtension}});Object.defineProperty(A,"decodeTimestampExtension",{enumerable:!0,get:function(){return wt.decodeTimestampExtension}})});var oo=Z((dp,io)=>{var Nt=require("fs"),ao=require("url"),id=require("child_process").spawn;io.exports=zs;zs.XMLHttpRequest=zs;function zs(e){"use strict";e=e||{};var r=this,t=require("http"),n=require("https"),s,a,i={},o=!1,d={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},l=Object.assign({},d),u=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","content-transfer-encoding","cookie","cookie2","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"],w=["TRACE","TRACK","CONNECT"],m=!1,f=!1,_=!1,T={};this.UNSENT=0,this.OPENED=1,this.HEADERS_RECEIVED=2,this.LOADING=3,this.DONE=4,this.readyState=this.UNSENT,this.onreadystatechange=null,this.responseText="",this.responseXML="",this.response=Buffer.alloc(0),this.status=null,this.statusText=null;var R=function(p){return o||p&&u.indexOf(p.toLowerCase())===-1},b=function(p){return p&&w.indexOf(p)===-1};this.open=function(p,h,k,C,y){if(this.abort(),f=!1,_=!1,!b(p))throw new Error("SecurityError: Request method not allowed");i={method:p,url:h.toString(),async:typeof k!="boolean"?!0:k,user:C||null,password:y||null},S(this.OPENED)},this.setDisableHeaderCheck=function(p){o=p},this.setRequestHeader=function(p,h){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!R(p))return console.warn('Refused to set unsafe header "'+p+'"'),!1;if(m)throw new Error("INVALID_STATE_ERR: send flag is true");return l[p]=h,!0},this.getResponseHeader=function(p){return typeof p=="string"&&this.readyState>this.OPENED&&a.headers[p.toLowerCase()]&&!f?a.headers[p.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||f)return"";var p="";for(var h in a.headers)h!=="set-cookie"&&h!=="set-cookie2"&&(p+=h+": "+a.headers[h]+`\r `);return p.substr(0,p.length-2)},this.getRequestHeader=function(p){return typeof p=="string"&&l[p]?l[p]:""},this.send=function(p){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(m)throw new Error("INVALID_STATE_ERR: send has already been called");var h=!1,k=!1,C=ao.parse(i.url),y;switch(C.protocol){case"https:":h=!0;case"http:":y=C.hostname;break;case"file:":k=!0;break;case void 0:case"":y="localhost";break;default:throw new Error("Protocol not supported.")}if(k){if(i.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(i.async)Nt.readFile(unescape(C.pathname),function(te,Le){te?r.handleError(te,te.errno||-1):(r.status=200,r.responseText=Le.toString("utf8"),r.response=Le,S(r.DONE))});else try{this.response=Nt.readFileSync(unescape(C.pathname)),this.responseText=this.response.toString("utf8"),this.status=200,S(r.DONE)}catch(te){this.handleError(te,te.errno||-1)}return}var U=C.port||(h?443:80),P=C.pathname+(C.search?C.search:"");if(l.Host=y,h&&U===443||U===80||(l.Host+=":"+C.port),i.user){typeof i.password>"u"&&(i.password="");var v=new Buffer(i.user+":"+i.password);l.Authorization="Basic "+v.toString("base64")}i.method==="GET"||i.method==="HEAD"?p=null:p?(l["Content-Length"]=Buffer.isBuffer(p)?p.length:Buffer.byteLength(p),l["Content-Type"]||(l["Content-Type"]="text/plain;charset=UTF-8")):i.method==="POST"&&(l["Content-Length"]=0);var D=e.agent||!1,$={host:y,port:U,path:P,method:i.method,headers:l,agent:D};if(h&&($.pfx=e.pfx,$.key=e.key,$.passphrase=e.passphrase,$.cert=e.cert,$.ca=e.ca,$.ciphers=e.ciphers,$.rejectUnauthorized=e.rejectUnauthorized!==!1),f=!1,i.async){var Ct=h?n.request:t.request;m=!0,r.dispatchEvent("readystatechange");var Fe=function(te){if(a=te,a.statusCode===302||a.statusCode===303||a.statusCode===307){i.url=a.headers.location;var Le=ao.parse(i.url);y=Le.hostname;var Se={hostname:Le.hostname,port:Le.port,path:Le.path,method:a.statusCode===303?"GET":i.method,headers:l};h&&(Se.pfx=e.pfx,Se.key=e.key,Se.passphrase=e.passphrase,Se.cert=e.cert,Se.ca=e.ca,Se.ciphers=e.ciphers,Se.rejectUnauthorized=e.rejectUnauthorized!==!1),s=Ct(Se,Fe).on("error",We),s.end();return}S(r.HEADERS_RECEIVED),r.status=a.statusCode,a.on("data",function(Dr){if(Dr){var mo=Buffer.from(Dr);r.response=Buffer.concat([r.response,mo])}m&&S(r.LOADING)}),a.on("end",function(){m&&(m=!1,S(r.DONE),r.responseText=r.response.toString("utf8"))}),a.on("error",function(Dr){r.handleError(Dr)})},We=function(te){r.handleError(te)};s=Ct($,Fe).on("error",We),e.autoUnref&&s.on("socket",te=>{te.unref()}),p&&s.write(p),s.end(),r.dispatchEvent("loadstart")}else{var Ft=".node-xmlhttprequest-content-"+process.pid,Wt=".node-xmlhttprequest-sync-"+process.pid;Nt.writeFileSync(Wt,"","utf8");for(var fo="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(h?"s":"")+".request;var options = "+JSON.stringify($)+";var responseText = '';var responseData = Buffer.alloc(0);var req = doRequest(options, function(response) {response.on('data', function(chunk) { var data = Buffer.from(chunk); responseText += data.toString('utf8'); responseData = Buffer.concat([responseData, data]);});response.on('end', function() {fs.writeFileSync('"+Ft+"', JSON.stringify({err: null, data: {statusCode: response.statusCode, headers: response.headers, text: responseText, data: responseData.toString('base64')}}), 'utf8');fs.unlinkSync('"+Wt+"');});response.on('error', function(error) {fs.writeFileSync('"+Ft+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+Wt+"');});}).on('error', function(error) {fs.writeFileSync('"+Ft+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+Wt+"');});"+(p?"req.write('"+JSON.stringify(p).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",ho=id(process.argv[0],["-e",fo]),fd;Nt.existsSync(Wt););if(r.responseText=Nt.readFileSync(Ft,"utf8"),ho.stdin.end(),Nt.unlinkSync(Ft),r.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var po=JSON.parse(r.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,""));r.handleError(po,503)}else{r.status=r.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1");var Dn=JSON.parse(r.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"));a={statusCode:r.status,headers:Dn.data.headers},r.responseText=Dn.data.text,r.response=Buffer.from(Dn.data.data,"base64"),S(r.DONE,!0)}}},this.handleError=function(p,h){this.status=h||0,this.statusText=p,this.responseText=p.stack,f=!0,S(this.DONE)},this.abort=function(){s&&(s.abort(),s=null),l=Object.assign({},d),this.responseText="",this.responseXML="",this.response=Buffer.alloc(0),f=_=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||m)&&this.readyState!==this.DONE&&(m=!1,S(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(p,h){p in T||(T[p]=[]),T[p].push(h)},this.removeEventListener=function(p,h){p in T&&(T[p]=T[p].filter(function(k){return k!==h}))},this.dispatchEvent=function(p){if(typeof r["on"+p]=="function"&&(this.readyState===this.DONE&&i.async?setTimeout(function(){r["on"+p]()},0):r["on"+p]()),p in T)for(let h=0,k=T[p].length;h<k;h++)this.readyState===this.DONE?setTimeout(function(){T[p][h].call(r)},0):T[p][h].call(r)};var S=function(p){if(!(r.readyState===p||r.readyState===r.UNSENT&&_)&&(r.readyState=p,(i.async||r.readyState<r.OPENED||r.readyState===r.DONE)&&r.dispatchEvent("readystatechange"),r.readyState===r.DONE)){let h;_?h="abort":f?h="error":h="load",r.dispatchEvent(h),r.dispatchEvent("loadend")}}}});var Be=class extends Error{constructor(r){super(r),this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}};var ue=class extends Be{};var j=typeof process<"u"&&process.release&&process.release.name==="node",Lt;if(globalThis.document)Lt=e=>new Promise((r,t)=>{let n=document.createElement("script");n.src=e,n.onload=()=>r(),n.onerror=t,document.head.appendChild(n)});else if(globalThis.importScripts)Lt=async e=>{try{globalThis.importScripts(e)}catch(r){if(r instanceof TypeError)await Promise.resolve().then(()=>ut(require(e)));else throw r}};else if(j)Lt=async e=>{let r=(await Promise.resolve().then(()=>ut(require("path")))).default;await Promise.resolve().then(()=>ut(require(r.resolve(e))))};else throw new Be("Cannot determine runtime environment");var le={null:0,symbol:1,pairlist:2,closure:3,environment:4,promise:5,call:6,special:7,builtin:8,string:9,logical:10,integer:13,double:14,complex:15,character:16,dots:17,any:18,list:19,expression:20,bytecode:21,pointer:22,weakref:23,raw:24,s4:25,new:30,free:31,function:99};function Bt(e){return!!e&&typeof e=="object"&&Object.keys(le).includes(e.type)}function ze(e){return!!e&&typeof e=="object"&&"re"in e&&"im"in e}var c={};function Zs(e){Object.keys(e).forEach(r=>c._free(e[r]))}function je(e){return c._Rf_protect(re(e)),e}function O(e,r){return c._Rf_protect(re(e)),++r.n,e}function Vs(e){let r=c._malloc(4);return c._R_ProtectWithIndex(re(e),r),{loc:c.getValue(r,"i32"),ptr:r}}function Js(e){c._Rf_unprotect(1),c._free(e.ptr)}function Xs(e,r){return c._R_Reprotect(re(e),r.loc),e}function W(e){c._Rf_unprotect(e)}function On(e,r,t){c._Rf_defineVar(re(r),re(t),re(e))}function be(e,r){let t={},n={n:0};try{let s=new ne(r);O(s,n),t.code=c.allocateUTF8(e);let a=c._R_ParseEvalString(t.code,s.ptr);return x.wrap(a)}finally{Zs(t),W(n.n)}}var dt=class extends Error{constructor(r,t){super(r),this.name="UnwindProtectException",this.cont=t}};function qe(e,r){return c.getWasmTableEntry(c.GOT.ffi_safe_eval.value)(re(e),re(r))}var xo=new WeakMap;function Gs(e,r){return xo.set(e,r),e}function Mn(e){return typeof e=="string"&&e.length===zt}var zt=63;function jt(){let e=Array.from({length:4},Eo).join("-");if(e.length!==zt)throw new Error("comlink internal error: UUID has the wrong length");return e}function Eo(){let e=Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16),r=15-e.length;return r>0&&(e=Array.from({length:r},()=>0).join("")+e),e}function re(e){return Xe(e)?e.ptr:e}function Ge(e,r){if(c._TYPEOF(e.ptr)!==le[r])throw new Error(`Unexpected object type "${e.type()}" when expecting type "${r}"`)}var Ae=new Map;function Ke(e,r){let t=re(r);if(c._R_PreserveObject(t),e!==void 0){if(Mn(e)){Ae.get(e).push(t);return}throw new Error("Unexpected shelter type "+typeof e)}}function In(e,r){let t=re(r);c._R_ReleaseObject(t);let n=Ae.get(e),s=n.indexOf(t);if(s<0)throw new Error("Can't find object in shelter.");n.splice(s,1)}function Un(e){let r=Ae.get(e);for(let t of r)try{c._R_ReleaseObject(t)}catch(n){console.error(n)}Ae.set(e,[])}function Ks(e){if(Bt(e))return new(Ht(e.type))(e);if(typeof e>"u")return new pt;if(e&&typeof e=="object"&&"type"in e&&e.type==="null")return new pt;if(e===null)return new se({type:"logical",names:null,values:[null]});if(typeof e=="boolean")return new se(e);if(typeof e=="number")return new Je(e);if(typeof e=="string")return new ce(e);if(ze(e))return new mt(e);if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)return new _t(e);if(Array.isArray(e))return vo(e);if(typeof e=="object")return Ze.fromObject(e);throw new Error("R object construction for this JS object is not yet supported.")}function vo(e){let r={n:0};if(e.every(n=>n&&typeof n=="object"&&!Xe(n)&&!ze(n))){let n=e,s=n.every(i=>Object.keys(i).filter(o=>!Object.keys(n[0]).includes(o)).length===0&&Object.keys(n[0]).filter(o=>!Object.keys(i).includes(o)).length===0),a=n.every(i=>Object.values(i).every(o=>Qs(o)||Ys(o)));if(s&&a)return Ze.fromD3(n)}if(e.every(n=>typeof n=="boolean"||n===null))return new se(e);if(e.every(n=>typeof n=="number"||n===null))return new Je(e);if(e.every(n=>typeof n=="string"||n===null))return new ce(e);try{let n=new de([new q("c"),...e]);return O(n,r),n.eval()}finally{W(r.n)}}var z=class{constructor(r){this.ptr=r}type(){let r=c._TYPEOF(this.ptr);return Object.keys(le).find(n=>le[n]===r)}},ht,Pr,He=class He extends z{constructor(t){if(!(t instanceof z))return Ks(t);super(t.ptr);I(this,ht)}static wrap(t){let n=c._TYPEOF(t),s=Object.keys(le)[Object.values(le).indexOf(n)];return new(Ht(s))(new z(t))}get[Symbol.toStringTag](){return`RObject:${this.type()}`}static getPersistentObject(t){return L[t]}getPropertyValue(t){return this[t]}inspect(){be(".Internal(inspect(x))",{x:this})}isNull(){return c._TYPEOF(this.ptr)===le.null}isNa(){try{let t=be("is.na(x)",{x:this});return je(t),t.toBoolean()}finally{W(1)}}isUnbound(){return this.ptr===L.unboundValue.ptr}attrs(){return $e.wrap(c._ATTRIB(this.ptr))}class(){let t={n:0},n=new de([new q("class"),this]);O(n,t);try{return n.eval()}finally{W(t.n)}}setNames(t){let n;if(t===null)n=L.null;else if(Array.isArray(t)&&t.every(s=>typeof s=="string"||s===null))n=new ce(t);else throw new Error("Argument to setNames must be null or an Array of strings or null");return c._Rf_setAttrib(this.ptr,L.namesSymbol.ptr,n.ptr),this}names(){let t=ce.wrap(c._Rf_getAttrib(this.ptr,L.namesSymbol.ptr));return t.isNull()?null:t.toArray()}includes(t){let n=this.names();return n&&n.includes(t)}toJs(t={depth:0},n=1){throw new Error("This R object cannot be converted to JS")}subset(t){return ke(this,ht,Pr).call(this,t,L.bracketSymbol.ptr)}get(t){return ke(this,ht,Pr).call(this,t,L.bracket2Symbol.ptr)}getDollar(t){return ke(this,ht,Pr).call(this,t,L.dollarSymbol.ptr)}pluck(...t){let n=Vs(L.null);try{let s=(i,o)=>{let d=i.get(o);return Xs(d,n)},a=t.reduce(s,this);return a.isNull()?void 0:a}finally{Js(n)}}set(t,n){let s={n:0};try{let a=new He(t);O(a,s);let i=new He(n);O(i,s);let o=new q("[[<-"),d=c._Rf_lang4(o.ptr,this.ptr,a.ptr,i.ptr);return O(d,s),He.wrap(qe(d,L.baseEnv))}finally{W(s.n)}}static getMethods(t){let n=new Set,s=t;do Object.getOwnPropertyNames(s).map(a=>n.add(a));while(s=Object.getPrototypeOf(s));return[...n.keys()].filter(a=>typeof t[a]=="function")}};ht=new WeakSet,Pr=function(t,n){let s={n:0};try{let a=new He(t);O(a,s);let i=c._Rf_lang3(n,this.ptr,a.ptr);return O(i,s),He.wrap(qe(i,L.baseEnv))}finally{W(s.n)}};var x=He,pt=class extends x{constructor(){return super(new z(c.getValue(c._R_NilValue,"*"))),this}toJs(){return{type:"null"}}},q=class extends x{constructor(r){if(r instanceof z){Ge(r,"symbol"),super(r);return}let t=c.allocateUTF8(r);try{super(new z(c._Rf_install(t)))}finally{c._free(t)}}toJs(){let r=this.toObject();return{type:"symbol",printname:r.printname,symvalue:r.symvalue,internal:r.internal}}toObject(){return{printname:this.printname().isUnbound()?null:this.printname().toString(),symvalue:this.symvalue().isUnbound()?null:this.symvalue().ptr,internal:this.internal().isNull()?null:this.internal().ptr}}toString(){return this.printname().toString()}printname(){return Ve.wrap(c._PRINTNAME(this.ptr))}symvalue(){return x.wrap(c._SYMVALUE(this.ptr))}internal(){return x.wrap(c._INTERNAL(this.ptr))}},$e=class e extends x{constructor(r){if(r instanceof z)return Ge(r,"pairlist"),super(r),this;let t={n:0};try{let{names:n,values:s}=gt(r),a=e.wrap(c._Rf_allocList(s.length));O(a,t);for(let[i,o]=[0,a];!o.isNull();[i,o]=[i+1,o.cdr()])o.setcar(new x(s[i]));a.setNames(n),super(a)}finally{W(t.n)}}get length(){return this.toArray().length}toArray(r={depth:1}){return this.toJs(r).values}toObject({allowDuplicateKey:r=!0,allowEmptyKey:t=!1,depth:n=-1}={}){let s=this.entries({depth:n}),a=s.map(([i])=>i);if(!r&&new Set(a).size!==a.length)throw new Error("Duplicate key when converting pairlist without allowDuplicateKey enabled");if(!t&&a.some(i=>!i))throw new Error("Empty or null key when converting pairlist without allowEmptyKey enabled");return Object.fromEntries(s.filter((i,o)=>s.findIndex(d=>d[0]===i[0])===o))}entries(r={depth:1}){let t=this.toJs(r);return t.values.map((n,s)=>[t.names?t.names[s]:null,n])}toJs(r={depth:0},t=1){let n=[],s=!1,a=[];for(let o=this;!o.isNull();o=o.cdr()){let d=o.tag();d.isNull()?n.push(""):(s=!0,n.push(d.toString())),r.depth&&t>=r.depth?a.push(o.car()):a.push(o.car().toJs(r,t+1))}return{type:"pairlist",names:s?n:null,values:a}}includes(r){return r in this.toObject()}setcar(r){c._SETCAR(this.ptr,r.ptr)}car(){return x.wrap(c._CAR(this.ptr))}cdr(){return x.wrap(c._CDR(this.ptr))}tag(){return x.wrap(c._TAG(this.ptr))}},de=class e extends x{constructor(r){if(r instanceof z)return Ge(r,"call"),super(r),this;let t={n:0};try{let{values:n}=gt(r),s=n.map(i=>O(new x(i),t)),a=e.wrap(c._Rf_allocVector(le.call,n.length));O(a,t);for(let[i,o]=[0,a];!o.isNull();[i,o]=[i+1,o.cdr()])o.setcar(s[i]);super(a)}finally{W(t.n)}}setcar(r){c._SETCAR(this.ptr,r.ptr)}car(){return x.wrap(c._CAR(this.ptr))}cdr(){return x.wrap(c._CDR(this.ptr))}eval(){return c.webr.evalR(this,{env:L.baseEnv})}capture(r={}){return c.webr.captureR(this,r)}deparse(){let r={n:0};try{let t=c._Rf_lang2(new q("deparse1").ptr,c._Rf_lang2(new q("quote").ptr,this.ptr));O(t,r);let n=ce.wrap(qe(t,L.baseEnv));return O(n,r),n.toString()}finally{W(r.n)}}},fe=class e extends x{constructor(r,t=null){if(r instanceof z){if(Ge(r,"list"),super(r),t){if(t.length!==this.length)throw new Error("Can't construct named `RList`. Supplied `names` must be the same length as the list.");this.setNames(t)}return this}let n={n:0};try{let s=gt(r),a=c._Rf_allocVector(le.list,s.values.length);O(a,n),s.values.forEach((o,d)=>{ea(o)?c._SET_VECTOR_ELT(a,d,new e(o).ptr):c._SET_VECTOR_ELT(a,d,new x(o).ptr)});let i=t||s.names;if(i&&i.length!==s.values.length)throw new Error("Can't construct named `RList`. Supplied `names` must be the same length as the list.");x.wrap(a).setNames(i),super(new z(a))}finally{W(n.n)}}get length(){return c._LENGTH(this.ptr)}isDataFrame(){let r=$e.wrap(c._ATTRIB(this.ptr)).get("class");return!r.isNull()&&r.toArray().includes("data.frame")}toArray(r={depth:1}){return this.toJs(r).values}toObject({allowDuplicateKey:r=!0,allowEmptyKey:t=!1,depth:n=-1}={}){let s=this.entries({depth:n}),a=s.map(([i])=>i);if(!r&&new Set(a).size!==a.length)throw new Error("Duplicate key when converting list without allowDuplicateKey enabled");if(!t&&a.some(i=>!i))throw new Error("Empty or null key when converting list without allowEmptyKey enabled");return Object.fromEntries(s.filter((i,o)=>s.findIndex(d=>d[0]===i[0])===o))}toD3(){if(!this.isDataFrame())throw new Error("Can't convert R list object to D3 format. Object must be of class 'data.frame'.");return this.entries().reduce((t,n)=>(n[1].forEach((s,a)=>t[a]=Object.assign(t[a]||{},{[n[0]]:s})),t),[])}entries(r={depth:-1}){let t=this.toJs(r);return this.isDataFrame()&&r.depth<0&&(t.values=t.values.map(n=>n.toArray())),t.values.map((n,s)=>[t.names?t.names[s]:null,n])}toJs(r={depth:0},t=1){return{type:"list",names:this.names(),values:[...Array(this.length).keys()].map(n=>r.depth&&t>=r.depth?this.get(n+1):this.get(n+1).toJs(r,t+1))}}},Ze=class e extends fe{constructor(r){if(r instanceof z){if(super(r),!this.isDataFrame())throw new Error("Can't construct `RDataFrame`. Supplied R object is not a `data.frame`.");return this}return e.fromObject(r)}static fromObject(r){let{names:t,values:n}=gt(r),s={n:0};try{let a=!!t&&t.length>0&&t.every(o=>o),i=n.length>0&&n.every(o=>Array.isArray(o)||ArrayBuffer.isView(o)||o instanceof ArrayBuffer);if(a&&i){let o=n,d=o.every(u=>u.length===o[0].length),l=o.every(u=>Qs(u[0])||Ys(u[0]));if(d&&l){let u=new fe({type:"list",names:t,values:o.map(m=>Ks(m))});O(u,s);let w=new de([new q("as.data.frame"),u]);return O(w,s),new e(w.eval())}}}finally{W(s.n)}throw new Error("Can't construct `data.frame`. Source object is not eligible.")}static fromD3(r){return this.fromObject(Object.fromEntries(Object.keys(r[0]).map(t=>[t,r.map(n=>n[t])])))}},ft=class extends x{exec(...r){let t={n:0};try{let n=new de([this,...r]);return O(n,t),n.eval()}finally{W(t.n)}}capture(r={},...t){let n={n:0};try{let s=new de([this,...t]);return O(s,n),s.capture(r)}finally{W(n.n)}}},Or=class Or extends x{constructor(r){if(r instanceof z){Ge(r,"string"),super(r);return}let t=c.allocateUTF8(r);try{super(new z(c._Rf_mkCharCE(t,Or.CEType.CE_UTF8)))}finally{c._free(t)}}toString(){let r=c._vmaxget();try{return c.UTF8ToString(c._Rf_translateCharUTF8(this.ptr))}finally{c._vmaxset(r)}}toJs(){return{type:"string",value:this.toString()}}};Or.CEType={CE_NATIVE:0,CE_UTF8:1,CE_LATIN1:2,CE_BYTES:3,CE_SYMBOL:5,CE_ANY:99};var Ve=Or,ne=class extends x{constructor(r={}){if(r instanceof z)return Ge(r,"environment"),super(r),this;let t=0;try{let{names:n,values:s}=gt(r),a=je(c._R_NewEnv(L.globalEnv.ptr,0,0));++t,s.forEach((i,o)=>{let d=n?n[o]:null;if(!d)throw new Error("Can't create object in new environment with empty symbol name");let l=new q(d),u=je(new x(i));try{On(a,l,u)}finally{W(1)}}),super(new z(a))}finally{W(t)}}ls(r=!1,t=!0){return ce.wrap(c._R_lsInternal3(this.ptr,Number(r),Number(t))).toArray()}bind(r,t){let n=new q(r),s=je(new x(t));try{On(this,n,s)}finally{W(1)}}names(){return this.ls(!0,!0)}frame(){return x.wrap(c._FRAME(this.ptr))}subset(r){if(typeof r=="number")throw new Error("Object of type environment is not subsettable");return this.getDollar(r)}toObject({depth:r=-1}={}){let t=this.names();return Object.fromEntries([...Array(t.length).keys()].map(n=>{let s=this.getDollar(t[n]);return[t[n],r<0?s:s.toJs({depth:r})]}))}toJs(r={depth:0},t=1){let n=this.names(),s=[...Array(n.length).keys()].map(a=>r.depth&&t>=r.depth?this.getDollar(n[a]):this.getDollar(n[a]).toJs(r,t+1));return{type:"environment",names:n,values:s}}},De=class extends x{constructor(r,t,n){if(r instanceof z)return Ge(r,t),super(r),this;let s={n:0};try{let{names:a,values:i}=gt(r),o=c._Rf_allocVector(le[t],i.length);O(o,s),i.forEach(n(o)),x.wrap(o).setNames(a),super(new z(o))}finally{W(s.n)}}get length(){return c._LENGTH(this.ptr)}get(r){return super.get(r)}subset(r){return super.subset(r)}getDollar(){throw new Error("$ operator is invalid for atomic vectors")}detectMissing(){let r={n:0};try{let t=c._Rf_lang2(new q("is.na").ptr,this.ptr);O(t,r);let n=se.wrap(qe(t,L.baseEnv));O(n,r);let s=n.toTypedArray();return Array.from(s).map(a=>!!a)}finally{W(r.n)}}toArray(){let r=this.toTypedArray();return this.detectMissing().map((t,n)=>t?null:r[n])}toObject({allowDuplicateKey:r=!0,allowEmptyKey:t=!1}={}){let n=this.entries(),s=n.map(([a])=>a);if(!r&&new Set(s).size!==s.length)throw new Error("Duplicate key when converting atomic vector without allowDuplicateKey enabled");if(!t&&s.some(a=>!a))throw new Error("Empty or null key when converting atomic vector without allowEmptyKey enabled");return Object.fromEntries(n.filter((a,i)=>n.findIndex(o=>o[0]===a[0])===i))}entries(){let r=this.toArray(),t=this.names();return r.map((n,s)=>[t?t[s]:null,n])}toJs(){return{type:this.type(),names:this.names(),values:this.toArray()}}},Mr,Ir=class Ir extends De{constructor(r){super(r,"logical",E(Ir,Mr))}getBoolean(r){return this.get(r).toArray()[0]}toBoolean(){if(this.length!==1)throw new Error("Can't convert atomic vector of length > 1 to a scalar JS value");let r=this.getBoolean(1);if(r===null)throw new Error("Can't convert missing value `NA` to a JS boolean");return r}toTypedArray(){return new Int32Array(c.HEAP32.subarray(c._LOGICAL(this.ptr)/4,c._LOGICAL(this.ptr)/4+this.length))}toArray(){let r=this.toTypedArray();return this.detectMissing().map((t,n)=>t?null:!!r[n])}};Mr=new WeakMap,I(Ir,Mr,r=>{let t=c._LOGICAL(r),n=c.getValue(c._R_NaInt,"i32");return(s,a)=>{c.setValue(t+4*a,s===null?n:!!s,"i32")}});var se=Ir,Ur,Nr=class Nr extends De{constructor(r){super(r,"integer",E(Nr,Ur))}getNumber(r){return this.get(r).toArray()[0]}toNumber(){if(thi